@capgo/capacitor-pay 8.0.12 → 8.1.0

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/README.md CHANGED
@@ -26,8 +26,17 @@ The most complete doc is available here: https://capgo.app/docs/plugins/pay/
26
26
  ## Install
27
27
 
28
28
  ```bash
29
+ # Install (choose one)
29
30
  npm install @capgo/capacitor-pay
31
+ pnpm add @capgo/capacitor-pay
32
+ yarn add @capgo/capacitor-pay
33
+ bun add @capgo/capacitor-pay
34
+
35
+ # Then sync Capacitor (choose one)
30
36
  npx cap sync
37
+ pnpm exec cap sync
38
+ yarn cap sync
39
+ bunx cap sync
31
40
  ```
32
41
 
33
42
  ## Platform setup
@@ -130,6 +139,87 @@ if (availability.platform === 'ios') {
130
139
  }
131
140
  ```
132
141
 
142
+ ## Recurring payments
143
+
144
+ Apple Pay has first-class support via `recurringPaymentRequest` (iOS 16+):
145
+
146
+ ```ts
147
+ import { Pay } from '@capgo/capacitor-pay';
148
+
149
+ await Pay.requestPayment({
150
+ apple: {
151
+ merchantIdentifier: 'merchant.com.example.app',
152
+ countryCode: 'US',
153
+ currencyCode: 'USD',
154
+ supportedNetworks: ['visa', 'masterCard'],
155
+ paymentSummaryItems: [
156
+ { label: 'Pro Plan', amount: '9.99' },
157
+ { label: 'Example Store', amount: '9.99' },
158
+ ],
159
+ recurringPaymentRequest: {
160
+ paymentDescription: 'Pro Plan Subscription',
161
+ managementURL: 'https://example.com/account/subscription',
162
+ regularBilling: {
163
+ label: 'Pro Plan',
164
+ amount: '9.99',
165
+ intervalUnit: 'month',
166
+ intervalCount: 1,
167
+ startDate: Date.now(),
168
+ },
169
+ },
170
+ },
171
+ });
172
+ ```
173
+
174
+ Google Pay does not have a dedicated "recurring request" object in `PaymentDataRequest`. For subscriptions you typically:
175
+
176
+ 1. Collect a token once with a normal `paymentDataRequest`.
177
+ 2. Store it server-side and create recurring charges with your PSP/gateway (Stripe/Adyen/Braintree/etc).
178
+
179
+ ```ts
180
+ import { Pay, type GooglePayPaymentDataRequest } from '@capgo/capacitor-pay';
181
+
182
+ const paymentDataRequest: GooglePayPaymentDataRequest = {
183
+ apiVersion: 2,
184
+ apiVersionMinor: 0,
185
+ allowedPaymentMethods: [
186
+ {
187
+ type: 'CARD',
188
+ parameters: {
189
+ allowedAuthMethods: ['PAN_ONLY', 'CRYPTOGRAM_3DS'],
190
+ allowedCardNetworks: ['AMEX', 'DISCOVER', 'MASTERCARD', 'VISA'],
191
+ },
192
+ tokenizationSpecification: {
193
+ type: 'PAYMENT_GATEWAY',
194
+ parameters: {
195
+ gateway: 'example',
196
+ gatewayMerchantId: 'exampleGatewayMerchantId',
197
+ },
198
+ },
199
+ },
200
+ ],
201
+ merchantInfo: {
202
+ merchantId: '01234567890123456789',
203
+ merchantName: 'Example Merchant',
204
+ },
205
+ transactionInfo: {
206
+ totalPriceStatus: 'FINAL',
207
+ totalPrice: '9.99',
208
+ currencyCode: 'USD',
209
+ countryCode: 'US',
210
+ },
211
+ };
212
+
213
+ const result = await Pay.requestPayment({
214
+ google: {
215
+ environment: 'test',
216
+ paymentDataRequest,
217
+ },
218
+ });
219
+
220
+ // Send `result.google?.paymentData` to your backend and use your PSP to start the subscription.
221
+ ```
222
+
133
223
  ## API
134
224
 
135
225
  <docgen-index>
@@ -239,10 +329,55 @@ Get the native Capacitor plugin version
239
329
 
240
330
  #### GooglePayAvailabilityOptions
241
331
 
242
- | Prop | Type | Description |
243
- | ------------------------- | --------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
244
- | **`environment`** | <code><a href="#googlepayenvironment">GooglePayEnvironment</a></code> | Environment used to construct the Google Payments client. Defaults to `'test'`. |
245
- | **`isReadyToPayRequest`** | <code><a href="#record">Record</a>&lt;string, unknown&gt;</code> | Raw `IsReadyToPayRequest` JSON as defined by the Google Pay API. Supply the card networks and auth methods you intend to support at runtime. |
332
+ | Prop | Type | Description |
333
+ | ------------------------- | ------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
334
+ | **`environment`** | <code><a href="#googlepayenvironment">GooglePayEnvironment</a></code> | Environment used to construct the Google Payments client. Defaults to `'test'`. |
335
+ | **`isReadyToPayRequest`** | <code><a href="#googlepayisreadytopayrequest">GooglePayIsReadyToPayRequest</a></code> | Raw `IsReadyToPayRequest` JSON as defined by the Google Pay API. Supply the card networks and auth methods you intend to support at runtime. |
336
+
337
+
338
+ #### GooglePayIsReadyToPayRequest
339
+
340
+ Typed helper for the Google Pay `IsReadyToPayRequest` JSON.
341
+ The native Android implementation still accepts arbitrary JSON (forward compatible).
342
+
343
+ | Prop | Type | Description |
344
+ | --------------------------- | -------------------------------------------- | ------------------------------------------------------------ |
345
+ | **`allowedPaymentMethods`** | <code>GooglePayAllowedPaymentMethod[]</code> | The list of payment methods you want to check for readiness. |
346
+
347
+
348
+ #### GooglePayAllowedPaymentMethod
349
+
350
+ | Prop | Type |
351
+ | ------------------------------- | ----------------------------------------------------------------------------------------------------- |
352
+ | **`type`** | <code>(string & <a href="#record">Record</a>&lt;never, never&gt;) \| 'CARD'</code> |
353
+ | **`parameters`** | <code><a href="#googlepaycardpaymentmethodparameters">GooglePayCardPaymentMethodParameters</a></code> |
354
+ | **`tokenizationSpecification`** | <code><a href="#googlepaytokenizationspecification">GooglePayTokenizationSpecification</a></code> |
355
+
356
+
357
+ #### GooglePayCardPaymentMethodParameters
358
+
359
+ | Prop | Type |
360
+ | ------------------------------ | ----------------------------------------------------------------------------------------------- |
361
+ | **`allowedAuthMethods`** | <code>GooglePayAuthMethod[]</code> |
362
+ | **`allowedCardNetworks`** | <code>GooglePayCardNetwork[]</code> |
363
+ | **`billingAddressRequired`** | <code>boolean</code> |
364
+ | **`billingAddressParameters`** | <code><a href="#googlepaybillingaddressparameters">GooglePayBillingAddressParameters</a></code> |
365
+
366
+
367
+ #### GooglePayBillingAddressParameters
368
+
369
+ | Prop | Type |
370
+ | ------------------------- | ------------------------------------------------------------------------------------------- |
371
+ | **`format`** | <code>'MIN' \| 'FULL' \| (string & <a href="#record">Record</a>&lt;never, never&gt;)</code> |
372
+ | **`phoneNumberRequired`** | <code>boolean</code> |
373
+
374
+
375
+ #### GooglePayTokenizationSpecification
376
+
377
+ | Prop | Type |
378
+ | ---------------- | --------------------------------------------------------------------------------------------------------- |
379
+ | **`type`** | <code>(string & <a href="#record">Record</a>&lt;never, never&gt;) \| 'PAYMENT_GATEWAY' \| 'DIRECT'</code> |
380
+ | **`parameters`** | <code><a href="#record">Record</a>&lt;string, string&gt;</code> |
246
381
 
247
382
 
248
383
  #### PayPaymentResult
@@ -293,19 +428,20 @@ Get the native Capacitor plugin version
293
428
 
294
429
  #### ApplePayPaymentOptions
295
430
 
296
- | Prop | Type | Description |
297
- | ----------------------------------- | --------------------------------------------------------------------- | ------------------------------------------------------------------ |
298
- | **`merchantIdentifier`** | <code>string</code> | Merchant identifier created in the Apple Developer portal. |
299
- | **`countryCode`** | <code>string</code> | Two-letter ISO 3166 country code. |
300
- | **`currencyCode`** | <code>string</code> | Three-letter ISO 4217 currency code. |
301
- | **`paymentSummaryItems`** | <code>ApplePaySummaryItem[]</code> | Payment summary items displayed in the Apple Pay sheet. |
302
- | **`supportedNetworks`** | <code>ApplePayNetwork[]</code> | Card networks to support. |
303
- | **`merchantCapabilities`** | <code>ApplePayMerchantCapability[]</code> | Merchant payment capabilities. Defaults to ['3DS'] when omitted. |
304
- | **`requiredShippingContactFields`** | <code>ApplePayContactField[]</code> | Contact fields that must be supplied for shipping. |
305
- | **`requiredBillingContactFields`** | <code>ApplePayContactField[]</code> | Contact fields that must be supplied for billing. |
306
- | **`shippingType`** | <code><a href="#applepayshippingtype">ApplePayShippingType</a></code> | Controls the shipping flow presented to the user. |
307
- | **`supportedCountries`** | <code>string[]</code> | Optional ISO 3166 country codes where the merchant is supported. |
308
- | **`applicationData`** | <code>string</code> | Optional opaque application data passed back in the payment token. |
431
+ | Prop | Type | Description |
432
+ | ----------------------------------- | ------------------------------------------------------------------------------------------- | ------------------------------------------------------------------ |
433
+ | **`merchantIdentifier`** | <code>string</code> | Merchant identifier created in the Apple Developer portal. |
434
+ | **`countryCode`** | <code>string</code> | Two-letter ISO 3166 country code. |
435
+ | **`currencyCode`** | <code>string</code> | Three-letter ISO 4217 currency code. |
436
+ | **`paymentSummaryItems`** | <code>ApplePaySummaryItem[]</code> | Payment summary items displayed in the Apple Pay sheet. |
437
+ | **`supportedNetworks`** | <code>ApplePayNetwork[]</code> | Card networks to support. |
438
+ | **`merchantCapabilities`** | <code>ApplePayMerchantCapability[]</code> | Merchant payment capabilities. Defaults to ['3DS'] when omitted. |
439
+ | **`requiredShippingContactFields`** | <code>ApplePayContactField[]</code> | Contact fields that must be supplied for shipping. |
440
+ | **`requiredBillingContactFields`** | <code>ApplePayContactField[]</code> | Contact fields that must be supplied for billing. |
441
+ | **`shippingType`** | <code><a href="#applepayshippingtype">ApplePayShippingType</a></code> | Controls the shipping flow presented to the user. |
442
+ | **`supportedCountries`** | <code>string[]</code> | Optional ISO 3166 country codes where the merchant is supported. |
443
+ | **`applicationData`** | <code>string</code> | Optional opaque application data passed back in the payment token. |
444
+ | **`recurringPaymentRequest`** | <code><a href="#applepayrecurringpaymentrequest">ApplePayRecurringPaymentRequest</a></code> | Recurring payment configuration (iOS 16+). |
309
445
 
310
446
 
311
447
  #### ApplePaySummaryItem
@@ -317,12 +453,66 @@ Get the native Capacitor plugin version
317
453
  | **`type`** | <code><a href="#applepaysummaryitemtype">ApplePaySummaryItemType</a></code> |
318
454
 
319
455
 
456
+ #### ApplePayRecurringPaymentRequest
457
+
458
+ | Prop | Type | Description |
459
+ | -------------------------- | --------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------- |
460
+ | **`paymentDescription`** | <code>string</code> | A description for the recurring payment shown in the Apple Pay sheet. |
461
+ | **`regularBilling`** | <code><a href="#applepayrecurringpaymentsummaryitem">ApplePayRecurringPaymentSummaryItem</a></code> | The recurring billing item (for example your subscription). |
462
+ | **`managementURL`** | <code>string</code> | URL where the user can manage the recurring payment (cancel, update, etc). |
463
+ | **`billingAgreement`** | <code>string</code> | Optional billing agreement text shown to the user. |
464
+ | **`tokenNotificationURL`** | <code>string</code> | Optional URL where Apple can send token update notifications. |
465
+ | **`trialBilling`** | <code><a href="#applepayrecurringpaymentsummaryitem">ApplePayRecurringPaymentSummaryItem</a></code> | Optional trial billing item (for example a free trial period). |
466
+
467
+
468
+ #### ApplePayRecurringPaymentSummaryItem
469
+
470
+ | Prop | Type | Description |
471
+ | ------------------- | ----------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
472
+ | **`intervalUnit`** | <code><a href="#applepayrecurringpaymentintervalunit">ApplePayRecurringPaymentIntervalUnit</a></code> | Unit of time between recurring payments. |
473
+ | **`intervalCount`** | <code>number</code> | Number of `intervalUnit` units between recurring payments (for example `1` month, `2` weeks). |
474
+ | **`startDate`** | <code>string \| number</code> | Start date of the recurring period. On supported platforms this may be either: - a `number` representing milliseconds since Unix epoch, or - a `string` in a date format accepted by the native implementation (for example an ISO 8601 date-time string or a `yyyy-MM-dd` date string). |
475
+ | **`endDate`** | <code>string \| number</code> | End date of the recurring period. On supported platforms this may be either: - a `number` representing milliseconds since Unix epoch, or - a `string` in a date format accepted by the native implementation (for example an ISO 8601 date-time string or a `yyyy-MM-dd` date string). |
476
+
477
+
320
478
  #### GooglePayPaymentOptions
321
479
 
322
- | Prop | Type | Description |
323
- | ------------------------ | --------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
324
- | **`environment`** | <code><a href="#googlepayenvironment">GooglePayEnvironment</a></code> | Environment used to construct the Google Payments client. Defaults to `'test'`. |
325
- | **`paymentDataRequest`** | <code><a href="#record">Record</a>&lt;string, unknown&gt;</code> | Raw `PaymentDataRequest` JSON as defined by the Google Pay API. Provide transaction details, merchant info, and tokenization parameters. |
480
+ | Prop | Type | Description |
481
+ | ------------------------ | ----------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------- |
482
+ | **`environment`** | <code><a href="#googlepayenvironment">GooglePayEnvironment</a></code> | Environment used to construct the Google Payments client. Defaults to `'test'`. |
483
+ | **`paymentDataRequest`** | <code><a href="#googlepaypaymentdatarequest">GooglePayPaymentDataRequest</a></code> | Raw `PaymentDataRequest` JSON as defined by the Google Pay API. Provide transaction details, merchant info, and tokenization parameters. |
484
+
485
+
486
+ #### GooglePayPaymentDataRequest
487
+
488
+ Typed helper for the Google Pay `PaymentDataRequest` JSON.
489
+ The native Android implementation still accepts arbitrary JSON (forward compatible).
490
+
491
+ | Prop | Type | Description |
492
+ | --------------------------- | ----------------------------------------------------------------------------- | ------------------------------------------------------- |
493
+ | **`apiVersion`** | <code>number</code> | Google Pay API version, typically `2`. |
494
+ | **`apiVersionMinor`** | <code>number</code> | Google Pay API minor version, typically `0`. |
495
+ | **`allowedPaymentMethods`** | <code>GooglePayAllowedPaymentMethod[]</code> | Allowed payment method configurations. |
496
+ | **`merchantInfo`** | <code><a href="#googlepaymerchantinfo">GooglePayMerchantInfo</a></code> | Merchant information displayed in the Google Pay sheet. |
497
+ | **`transactionInfo`** | <code><a href="#googlepaytransactioninfo">GooglePayTransactionInfo</a></code> | Transaction details (amount, currency, etc). |
498
+
499
+
500
+ #### GooglePayMerchantInfo
501
+
502
+ | Prop | Type |
503
+ | ------------------ | ------------------- |
504
+ | **`merchantId`** | <code>string</code> |
505
+ | **`merchantName`** | <code>string</code> |
506
+
507
+
508
+ #### GooglePayTransactionInfo
509
+
510
+ | Prop | Type |
511
+ | ---------------------- | ------------------------------------------------------------------------------- |
512
+ | **`totalPriceStatus`** | <code><a href="#googlepaytotalpricestatus">GooglePayTotalPriceStatus</a></code> |
513
+ | **`totalPrice`** | <code>string</code> |
514
+ | **`currencyCode`** | <code>string</code> |
515
+ | **`countryCode`** | <code>string</code> |
326
516
 
327
517
 
328
518
  ### Type Aliases
@@ -335,7 +525,7 @@ Get the native Capacitor plugin version
335
525
 
336
526
  #### ApplePayNetwork
337
527
 
338
- <code>'AmEx' | 'Bancomat' | 'Bancontact' | 'PagoBancomat' | 'CarteBancaire' | 'CarteBancaires' | 'CartesBancaires' | 'ChinaUnionPay' | 'Dankort' | 'Discover' | 'Eftpos' | 'Electron' | 'Elo' | 'girocard' | 'Himyan' | 'Interac' | 'iD' | 'Jaywan' | 'JCB' | 'mada' | 'Maestro' | 'MasterCard' | 'Meeza' | 'Mir' | 'MyDebit' | 'NAPAS' | 'BankAxept' | 'PostFinanceAG' | 'PrivateLabel' | 'QUICPay' | 'Suica' | 'Visa' | 'VPay'</code>
528
+ <code>'AmEx' | 'amex' | 'Bancomat' | 'Bancontact' | 'PagoBancomat' | 'CarteBancaire' | 'CarteBancaires' | 'CartesBancaires' | 'ChinaUnionPay' | 'Dankort' | 'Discover' | 'discover' | 'Eftpos' | 'Electron' | 'Elo' | 'girocard' | 'Himyan' | 'Interac' | 'iD' | 'Jaywan' | 'JCB' | 'jcb' | 'mada' | 'Maestro' | 'maestro' | 'MasterCard' | 'masterCard' | 'Meeza' | 'Mir' | 'MyDebit' | 'NAPAS' | 'BankAxept' | 'PostFinanceAG' | 'PrivateLabel' | 'QUICPay' | 'Suica' | 'Visa' | 'visa' | 'VPay' | 'vPay'</code>
339
529
 
340
530
 
341
531
  #### GooglePayEnvironment
@@ -350,6 +540,16 @@ Construct a type with a set of properties K of type T
350
540
  <code>{
351
541
  [P in K]: T;
352
542
  }</code>
353
543
 
354
544
 
545
+ #### GooglePayAuthMethod
546
+
547
+ <code>'PAN_ONLY' | 'CRYPTOGRAM_3DS' | (string & <a href="#record">Record</a>&lt;never, never&gt;)</code>
548
+
549
+
550
+ #### GooglePayCardNetwork
551
+
552
+ <code>'AMEX' | 'DISCOVER' | 'JCB' | 'MASTERCARD' | 'VISA' | (string & <a href="#record">Record</a>&lt;never, never&gt;)</code>
553
+
554
+
355
555
  #### Exclude
356
556
 
357
557
  <a href="#exclude">Exclude</a> from T those types that are assignable to U
@@ -376,4 +576,14 @@ Construct a type with a set of properties K of type T
376
576
 
377
577
  <code>'shipping' | 'delivery' | 'servicePickup' | 'storePickup'</code>
378
578
 
579
+
580
+ #### ApplePayRecurringPaymentIntervalUnit
581
+
582
+ <code>'day' | 'week' | 'month' | 'year'</code>
583
+
584
+
585
+ #### GooglePayTotalPriceStatus
586
+
587
+ <code>'NOT_CURRENTLY_KNOWN' | 'ESTIMATED' | 'FINAL' | (string & <a href="#record">Record</a>&lt;never, never&gt;)</code>
588
+
379
589
  </docgen-api>
@@ -26,7 +26,7 @@ import org.json.JSONObject;
26
26
  @CapacitorPlugin(name = "Pay")
27
27
  public class PayPlugin extends Plugin {
28
28
 
29
- private final String pluginVersion = "8.0.12";
29
+ private final String pluginVersion = "8.1.0";
30
30
 
31
31
  private static final int LOAD_PAYMENT_DATA_REQUEST_CODE = 8001;
32
32