@capawesome/capacitor-square-mobile-payments 0.1.5 → 0.1.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/Package.swift
CHANGED
|
@@ -22,10 +22,6 @@ let package = Package(
|
|
|
22
22
|
.product(name: "SquareMobilePaymentsSDK", package: "mobile-payments-sdk-ios"),
|
|
23
23
|
.product(name: "MockReaderUI", package: "mobile-payments-sdk-ios")
|
|
24
24
|
],
|
|
25
|
-
path: "ios/Plugin")
|
|
26
|
-
.testTarget(
|
|
27
|
-
name: "SquareMobilePaymentsPluginTests",
|
|
28
|
-
dependencies: ["SquareMobilePaymentsPlugin"],
|
|
29
|
-
path: "ios/PluginTests")
|
|
25
|
+
path: "ios/Plugin")
|
|
30
26
|
]
|
|
31
27
|
)
|
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Capacitor Square Mobile Payments Plugin
|
|
2
2
|
|
|
3
3
|
Unofficial Capacitor plugin for [Square Mobile Payments SDK](https://developer.squareup.com/docs/mobile-payments-sdk).[^1]
|
|
4
4
|
|
|
@@ -25,6 +25,16 @@ This plugin provides a comprehensive integration with Square's Mobile Payments S
|
|
|
25
25
|
|
|
26
26
|
Missing a feature? Just [open an issue](https://github.com/capawesome-team/capacitor-plugins/issues) and we'll take a look!
|
|
27
27
|
|
|
28
|
+
## Use Cases
|
|
29
|
+
|
|
30
|
+
The Square Mobile Payments plugin is typically used to accept in-person payments in a Capacitor app, for example:
|
|
31
|
+
|
|
32
|
+
- **Point of sale**: Turn your app into a POS system that accepts tap, dip, swipe, and manually entered card payments with Square card readers.
|
|
33
|
+
- **Tap to Pay on iPhone**: Accept contactless payments directly on an iPhone without additional hardware by linking a Square seller account with an Apple ID.
|
|
34
|
+
- **Mobile and pop-up sales**: Pair, monitor, and manage Square readers for markets, food trucks, or events, and process payments offline with automatic sync when connectivity is limited.
|
|
35
|
+
- **Compliant receipts**: Access card details, authorization codes, and EMV data of completed payments to generate compliant receipts.
|
|
36
|
+
- **Testing without hardware**: Use the mock reader in debug builds to test the whole payment flow without a physical reader.
|
|
37
|
+
|
|
28
38
|
## Compatibility
|
|
29
39
|
|
|
30
40
|
| Plugin Version | Capacitor Version | Status |
|
|
@@ -33,6 +43,21 @@ Missing a feature? Just [open an issue](https://github.com/capawesome-team/capac
|
|
|
33
43
|
|
|
34
44
|
## Installation
|
|
35
45
|
|
|
46
|
+
You can use our **AI-Assisted Setup** to install the plugin.
|
|
47
|
+
Add the [Capawesome Skills](https://github.com/capawesome-team/skills) to your AI tool using the following command:
|
|
48
|
+
|
|
49
|
+
```bash
|
|
50
|
+
npx skills add capawesome-team/skills --skill capacitor-plugins
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
Then use the following prompt:
|
|
54
|
+
|
|
55
|
+
```
|
|
56
|
+
Use the `capacitor-plugins` skill from `capawesome-team/skills` to install the `@capawesome/capacitor-square-mobile-payments` plugin in my project.
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
If you prefer **Manual Setup**, install the plugin by running the following commands and follow the platform-specific instructions below:
|
|
60
|
+
|
|
36
61
|
```bash
|
|
37
62
|
npm install @capawesome/capacitor-square-mobile-payments
|
|
38
63
|
npx cap sync
|
|
@@ -154,8 +179,14 @@ No configuration required for this plugin.
|
|
|
154
179
|
|
|
155
180
|
## Usage
|
|
156
181
|
|
|
182
|
+
The following examples show how to initialize and authorize the SDK, pair and list readers, start a payment, read the available card input methods, and listen for payment and reader events.
|
|
183
|
+
|
|
184
|
+
### Initialize and authorize the SDK
|
|
185
|
+
|
|
186
|
+
Initialize the SDK with your Square location ID and authorize it with a Square access token. The `initialize(...)` method must be called before any other method:
|
|
187
|
+
|
|
157
188
|
```typescript
|
|
158
|
-
import { SquareMobilePayments
|
|
189
|
+
import { SquareMobilePayments } from '@capawesome/capacitor-square-mobile-payments';
|
|
159
190
|
|
|
160
191
|
const initializeSDK = async () => {
|
|
161
192
|
await SquareMobilePayments.initialize({
|
|
@@ -166,15 +197,39 @@ const initializeSDK = async () => {
|
|
|
166
197
|
accessToken: 'YOUR_ACCESS_TOKEN',
|
|
167
198
|
});
|
|
168
199
|
};
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
### Check the authorization state
|
|
203
|
+
|
|
204
|
+
Check whether the SDK is currently authorized, for example on app start:
|
|
205
|
+
|
|
206
|
+
```typescript
|
|
207
|
+
import { SquareMobilePayments } from '@capawesome/capacitor-square-mobile-payments';
|
|
169
208
|
|
|
170
209
|
const checkAuthorization = async () => {
|
|
171
210
|
const { authorized } = await SquareMobilePayments.isAuthorized();
|
|
172
211
|
console.log('Authorized:', authorized);
|
|
173
212
|
};
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
### Pair a Square reader
|
|
216
|
+
|
|
217
|
+
Start the pairing process. The SDK searches for nearby readers and pairs with the first one found:
|
|
218
|
+
|
|
219
|
+
```typescript
|
|
220
|
+
import { SquareMobilePayments } from '@capawesome/capacitor-square-mobile-payments';
|
|
174
221
|
|
|
175
222
|
const pairReader = async () => {
|
|
176
223
|
await SquareMobilePayments.startPairing();
|
|
177
224
|
};
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### List the paired readers
|
|
228
|
+
|
|
229
|
+
Get all paired readers with their serial number, model, and status:
|
|
230
|
+
|
|
231
|
+
```typescript
|
|
232
|
+
import { SquareMobilePayments } from '@capawesome/capacitor-square-mobile-payments';
|
|
178
233
|
|
|
179
234
|
const getReaders = async () => {
|
|
180
235
|
const { readers } = await SquareMobilePayments.getReaders();
|
|
@@ -182,6 +237,14 @@ const getReaders = async () => {
|
|
|
182
237
|
console.log('Reader:', reader.serialNumber, reader.model, reader.status);
|
|
183
238
|
}
|
|
184
239
|
};
|
|
240
|
+
```
|
|
241
|
+
|
|
242
|
+
### Start a payment
|
|
243
|
+
|
|
244
|
+
Present the payment UI and process a payment with the specified parameters. Only one payment can be active at a time:
|
|
245
|
+
|
|
246
|
+
```typescript
|
|
247
|
+
import { SquareMobilePayments } from '@capawesome/capacitor-square-mobile-payments';
|
|
185
248
|
|
|
186
249
|
const processPayment = async () => {
|
|
187
250
|
await SquareMobilePayments.startPayment({
|
|
@@ -198,6 +261,14 @@ const processPayment = async () => {
|
|
|
198
261
|
},
|
|
199
262
|
});
|
|
200
263
|
};
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### Listen for payment events
|
|
267
|
+
|
|
268
|
+
Listen for successful, failed, and cancelled payments to react to the result of a payment flow:
|
|
269
|
+
|
|
270
|
+
```typescript
|
|
271
|
+
import { SquareMobilePayments } from '@capawesome/capacitor-square-mobile-payments';
|
|
201
272
|
|
|
202
273
|
const listenToPaymentEvents = () => {
|
|
203
274
|
SquareMobilePayments.addListener('paymentDidFinish', (event) => {
|
|
@@ -214,6 +285,14 @@ const listenToPaymentEvents = () => {
|
|
|
214
285
|
console.log('Payment cancelled');
|
|
215
286
|
});
|
|
216
287
|
};
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
### Listen for reader events
|
|
291
|
+
|
|
292
|
+
Listen for reader status changes and changes to the available card input methods:
|
|
293
|
+
|
|
294
|
+
```typescript
|
|
295
|
+
import { SquareMobilePayments } from '@capawesome/capacitor-square-mobile-payments';
|
|
217
296
|
|
|
218
297
|
const listenToReaderEvents = () => {
|
|
219
298
|
SquareMobilePayments.addListener('readerWasAdded', (event) => {
|
|
@@ -228,6 +307,14 @@ const listenToReaderEvents = () => {
|
|
|
228
307
|
console.log('Available methods:', event.cardInputMethods);
|
|
229
308
|
});
|
|
230
309
|
};
|
|
310
|
+
```
|
|
311
|
+
|
|
312
|
+
### Get the available card input methods
|
|
313
|
+
|
|
314
|
+
Read the card entry methods that are currently available based on the connected readers (e.g. tap, dip, swipe, or keyed entry):
|
|
315
|
+
|
|
316
|
+
```typescript
|
|
317
|
+
import { SquareMobilePayments } from '@capawesome/capacitor-square-mobile-payments';
|
|
231
318
|
|
|
232
319
|
const getAvailableMethods = async () => {
|
|
233
320
|
const { cardInputMethods } = await SquareMobilePayments.getAvailableCardInputMethods();
|
|
@@ -1408,6 +1495,46 @@ Callback to receive payment cancellation notifications.
|
|
|
1408
1495
|
|
|
1409
1496
|
</docgen-api>
|
|
1410
1497
|
|
|
1498
|
+
## FAQ
|
|
1499
|
+
|
|
1500
|
+
### Which platforms are supported by this plugin?
|
|
1501
|
+
|
|
1502
|
+
The plugin supports Android and iOS. There is no Web implementation, since the Square Mobile Payments SDK requires native hardware access to card readers.
|
|
1503
|
+
|
|
1504
|
+
### How can I test payments without a physical card reader?
|
|
1505
|
+
|
|
1506
|
+
Use the `showMockReader()` method to display a mock reader interface for testing payment flows without physical hardware. It is only intended for development and testing purposes and is therefore only available in debug builds. You can hide it again with `hideMockReader()`.
|
|
1507
|
+
|
|
1508
|
+
### What permissions does the plugin require?
|
|
1509
|
+
|
|
1510
|
+
The plugin requires location access to confirm that payments are occurring in a supported Square location, Bluetooth access to connect to Square card readers, and, on iOS, microphone access to receive data from magstripe readers. You can check and request the required permissions with `checkPermissions()` and `requestPermissions()`, and the corresponding privacy descriptions must be added to your `Info.plist` on iOS (see [Installation](#installation)).
|
|
1511
|
+
|
|
1512
|
+
### Does the plugin support Tap to Pay on iPhone?
|
|
1513
|
+
|
|
1514
|
+
Yes, on iOS you can link a Square seller account with an Apple ID using `linkAppleAccount()`, which presents an Apple sheet with the Tap to Pay on iPhone terms and conditions. Use `isDeviceCapable()` to check whether the device supports Tap to Pay on iPhone, and `relinkAppleAccount()` to switch to a different Apple ID.
|
|
1515
|
+
|
|
1516
|
+
### Why do the plugin methods fail before I call any of them?
|
|
1517
|
+
|
|
1518
|
+
The Square Mobile Payments SDK must be initialized natively with your Square Application ID before the plugin can be used: in a custom `Application` class on Android and in the `AppDelegate` on iOS (see [Installation](#installation)). Additionally, `initialize(...)` must be called before any other plugin method, followed by `authorize(...)` with a Square access token.
|
|
1519
|
+
|
|
1520
|
+
### Can I process payments without an internet connection?
|
|
1521
|
+
|
|
1522
|
+
Yes, the plugin supports processing payments online or offline with automatic sync. Note that for offline payments, the payment `id` may be `null` until the payment has been synced.
|
|
1523
|
+
|
|
1524
|
+
### Can I use this plugin with Ionic, React, Vue or Angular?
|
|
1525
|
+
|
|
1526
|
+
Yes, the plugin is framework-agnostic. It works in any Capacitor app regardless of the web framework, including Ionic with Angular, React, or Vue, as well as plain JavaScript projects.
|
|
1527
|
+
|
|
1528
|
+
## Related Plugins
|
|
1529
|
+
|
|
1530
|
+
- [Purchases](https://capawesome.io/docs/sdks/capacitor/purchases/): Support in-app purchases in your Capacitor app.
|
|
1531
|
+
- [Superwall](https://capawesome.io/docs/sdks/capacitor/superwall/): Present remotely-configured paywalls to drive subscriptions.
|
|
1532
|
+
- [Wallet](https://capawesome.io/docs/sdks/capacitor/wallet/): Add passes to Apple Wallet and Google Wallet.
|
|
1533
|
+
|
|
1534
|
+
## Newsletter
|
|
1535
|
+
|
|
1536
|
+
Stay up to date with the latest news and updates about the Capawesome, Capacitor, and Ionic ecosystem by subscribing to our [Capawesome Newsletter](https://cloud.capawesome.io/newsletter/).
|
|
1537
|
+
|
|
1411
1538
|
## Changelog
|
|
1412
1539
|
|
|
1413
1540
|
See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-plugins/blob/main/packages/square-mobile-payments/CHANGELOG.md).
|
|
@@ -737,13 +737,15 @@ public class SquareMobilePayments {
|
|
|
737
737
|
sdkPayment.getTotalMoney().getCurrencyCode().toString()
|
|
738
738
|
);
|
|
739
739
|
|
|
740
|
-
MoneyResult tipMoney =
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
740
|
+
MoneyResult tipMoney =
|
|
741
|
+
sdkPayment.getTipMoney() != null
|
|
742
|
+
? new MoneyResult((int) sdkPayment.getTipMoney().getAmount(), sdkPayment.getTipMoney().getCurrencyCode().toString())
|
|
743
|
+
: null;
|
|
744
|
+
|
|
745
|
+
MoneyResult applicationFee =
|
|
746
|
+
sdkPayment.getAppFeeMoney() != null
|
|
747
|
+
? new MoneyResult((int) sdkPayment.getAppFeeMoney().getAmount(), sdkPayment.getAppFeeMoney().getCurrencyCode().toString())
|
|
748
|
+
: null;
|
|
747
749
|
|
|
748
750
|
return new io.capawesome.capacitorjs.plugins.squaremobilepayments.classes.results.Payment(
|
|
749
751
|
id,
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@capawesome/capacitor-square-mobile-payments",
|
|
3
|
-
"version": "0.1.
|
|
4
|
-
"description": "Unofficial Capacitor plugin for Square Mobile Payments SDK.",
|
|
3
|
+
"version": "0.1.6",
|
|
4
|
+
"description": "Unofficial Capacitor plugin for Square Mobile Payments SDK to accept in-person payments on Android and iOS.",
|
|
5
5
|
"main": "dist/plugin.cjs.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
7
7
|
"types": "dist/esm/index.d.ts",
|
|
@@ -36,7 +36,16 @@
|
|
|
36
36
|
"keywords": [
|
|
37
37
|
"capacitor",
|
|
38
38
|
"plugin",
|
|
39
|
-
"native"
|
|
39
|
+
"native",
|
|
40
|
+
"capacitor-plugin",
|
|
41
|
+
"square",
|
|
42
|
+
"mobile payments",
|
|
43
|
+
"in-person payments",
|
|
44
|
+
"card reader",
|
|
45
|
+
"point of sale",
|
|
46
|
+
"pos",
|
|
47
|
+
"tap to pay",
|
|
48
|
+
"payment processing"
|
|
40
49
|
],
|
|
41
50
|
"scripts": {
|
|
42
51
|
"verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
|
|
@@ -58,16 +67,15 @@
|
|
|
58
67
|
},
|
|
59
68
|
"devDependencies": {
|
|
60
69
|
"@capacitor/android": "8.0.0",
|
|
61
|
-
"@capacitor/cli": "8.
|
|
70
|
+
"@capacitor/cli": "8.4.2",
|
|
62
71
|
"@capacitor/core": "8.0.0",
|
|
63
72
|
"@capacitor/docgen": "0.3.1",
|
|
64
73
|
"@capacitor/ios": "8.0.0",
|
|
65
74
|
"@ionic/eslint-config": "0.4.0",
|
|
66
75
|
"eslint": "8.57.0",
|
|
67
|
-
"prettier": "
|
|
68
|
-
"prettier-plugin-java": "2.6.7",
|
|
76
|
+
"prettier-plugin-java": "2.9.7",
|
|
69
77
|
"rimraf": "6.1.2",
|
|
70
|
-
"rollup": "4.
|
|
78
|
+
"rollup": "4.62.3",
|
|
71
79
|
"swiftlint": "2.0.0",
|
|
72
80
|
"typescript": "5.9.3"
|
|
73
81
|
},
|