@capgo/native-purchases 7.13.5 → 7.14.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 +95 -26
- package/android/src/main/java/ee/forgr/nativepurchases/NativePurchasesPlugin.java +59 -3
- package/dist/docs.json +246 -4
- package/dist/esm/definitions.d.ts +156 -2
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/web.d.ts +3 -0
- package/dist/esm/web.js +3 -0
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +3 -0
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +3 -0
- package/dist/plugin.js.map +1 -1
- package/ios/Sources/NativePurchasesPlugin/NativePurchasesPlugin.swift +72 -57
- package/ios/Sources/NativePurchasesPlugin/TransactionHelpers.swift +84 -6
- package/package.json +1 -1
package/dist/docs.json
CHANGED
|
@@ -17,12 +17,12 @@
|
|
|
17
17
|
},
|
|
18
18
|
{
|
|
19
19
|
"name": "purchaseProduct",
|
|
20
|
-
"signature": "(options: { productIdentifier: string; planIdentifier?: string; productType?: PURCHASE_TYPE; quantity?: number; appAccountToken?: string; isConsumable?: boolean; }) => Promise<Transaction>",
|
|
20
|
+
"signature": "(options: { productIdentifier: string; planIdentifier?: string; productType?: PURCHASE_TYPE; quantity?: number; appAccountToken?: string; isConsumable?: boolean; autoAcknowledgePurchases?: boolean; }) => Promise<Transaction>",
|
|
21
21
|
"parameters": [
|
|
22
22
|
{
|
|
23
23
|
"name": "options",
|
|
24
24
|
"docs": "- The product to purchase",
|
|
25
|
-
"type": "{ productIdentifier: string; planIdentifier?: string | undefined; productType?: PURCHASE_TYPE | undefined; quantity?: number | undefined; appAccountToken?: string | undefined; isConsumable?: boolean | undefined; }"
|
|
25
|
+
"type": "{ productIdentifier: string; planIdentifier?: string | undefined; productType?: PURCHASE_TYPE | undefined; quantity?: number | undefined; appAccountToken?: string | undefined; isConsumable?: boolean | undefined; autoAcknowledgePurchases?: boolean | undefined; }"
|
|
26
26
|
}
|
|
27
27
|
],
|
|
28
28
|
"returns": "Promise<Transaction>",
|
|
@@ -54,6 +54,10 @@
|
|
|
54
54
|
{
|
|
55
55
|
"name": "param",
|
|
56
56
|
"text": "options.isConsumable - Only Android, when true the purchase token is consumed after granting entitlement (for consumable in-app items). Defaults to false."
|
|
57
|
+
},
|
|
58
|
+
{
|
|
59
|
+
"name": "param",
|
|
60
|
+
"text": "options.autoAcknowledgePurchases - Only Android, when false the purchase will NOT be automatically acknowledged. You must manually call acknowledgePurchase() within 3 days or the purchase will be refunded. Defaults to true."
|
|
57
61
|
}
|
|
58
62
|
],
|
|
59
63
|
"docs": "Started purchase process for the given product.",
|
|
@@ -231,6 +235,51 @@
|
|
|
231
235
|
"complexTypes": [],
|
|
232
236
|
"slug": "managesubscriptions"
|
|
233
237
|
},
|
|
238
|
+
{
|
|
239
|
+
"name": "acknowledgePurchase",
|
|
240
|
+
"signature": "(options: { purchaseToken: string; }) => Promise<void>",
|
|
241
|
+
"parameters": [
|
|
242
|
+
{
|
|
243
|
+
"name": "options",
|
|
244
|
+
"docs": "- The purchase to acknowledge",
|
|
245
|
+
"type": "{ purchaseToken: string; }"
|
|
246
|
+
}
|
|
247
|
+
],
|
|
248
|
+
"returns": "Promise<void>",
|
|
249
|
+
"tags": [
|
|
250
|
+
{
|
|
251
|
+
"name": "param",
|
|
252
|
+
"text": "options - The purchase to acknowledge"
|
|
253
|
+
},
|
|
254
|
+
{
|
|
255
|
+
"name": "param",
|
|
256
|
+
"text": "options.purchaseToken - The purchase token from the Transaction object (Android)"
|
|
257
|
+
},
|
|
258
|
+
{
|
|
259
|
+
"name": "returns",
|
|
260
|
+
"text": "Promise that resolves when the purchase is acknowledged"
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
"name": "throws",
|
|
264
|
+
"text": "An error if acknowledgment fails"
|
|
265
|
+
},
|
|
266
|
+
{
|
|
267
|
+
"name": "platform",
|
|
268
|
+
"text": "android Only available on Android (iOS automatically finishes transactions)"
|
|
269
|
+
},
|
|
270
|
+
{
|
|
271
|
+
"name": "since",
|
|
272
|
+
"text": "7.14.0"
|
|
273
|
+
},
|
|
274
|
+
{
|
|
275
|
+
"name": "example",
|
|
276
|
+
"text": "```typescript\n// Client-side acknowledgment\nconst transaction = await NativePurchases.purchaseProduct({\n productIdentifier: 'premium_feature',\n autoAcknowledgePurchases: false\n});\n\n// Validate with your backend\nconst isValid = await fetch('/api/validate-purchase', {\n method: 'POST',\n body: JSON.stringify({ purchaseToken: transaction.purchaseToken })\n});\n\nif (isValid) {\n // Option 1: Acknowledge from client\n await NativePurchases.acknowledgePurchase({\n purchaseToken: transaction.purchaseToken\n });\n\n // Option 2: Or let your backend acknowledge via Google Play API\n // Your backend calls Google Play Developer API\n}\n```"
|
|
277
|
+
}
|
|
278
|
+
],
|
|
279
|
+
"docs": "Manually acknowledge a purchase on Android.\n\nThis method is only needed when you set `autoAcknowledgePurchases: false` in purchaseProduct().\nPurchases MUST be acknowledged within 3 days or they will be automatically refunded by Google Play.\n\n**Acknowledgment Options:**\n1. **Client-side (this method)**: Call from your app after validation\n2. **Server-side (recommended for security)**: Use Google Play Developer API v3\n - Endpoint: POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/products/{productId}/tokens/{token}:acknowledge\n - Requires OAuth 2.0 authentication with appropriate scopes\n - See: https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.products/acknowledge\n\nWhen to use manual acknowledgment:\n- Server-side validation: Verify the purchase with your backend before acknowledging\n- Entitlement delivery: Ensure user receives content/features before acknowledging\n- Multi-step workflows: Complete all steps before final acknowledgment\n- Security: Prevent client-side manipulation by handling acknowledgment server-side",
|
|
280
|
+
"complexTypes": [],
|
|
281
|
+
"slug": "acknowledgepurchase"
|
|
282
|
+
},
|
|
234
283
|
{
|
|
235
284
|
"name": "addListener",
|
|
236
285
|
"signature": "(eventName: 'transactionUpdated', listenerFunc: (transaction: Transaction) => void) => Promise<PluginListenerHandle>",
|
|
@@ -255,6 +304,30 @@
|
|
|
255
304
|
],
|
|
256
305
|
"slug": "addlistenertransactionupdated-"
|
|
257
306
|
},
|
|
307
|
+
{
|
|
308
|
+
"name": "addListener",
|
|
309
|
+
"signature": "(eventName: 'transactionVerificationFailed', listenerFunc: (payload: TransactionVerificationFailedEvent) => void) => Promise<PluginListenerHandle>",
|
|
310
|
+
"parameters": [
|
|
311
|
+
{
|
|
312
|
+
"name": "eventName",
|
|
313
|
+
"docs": "",
|
|
314
|
+
"type": "'transactionVerificationFailed'"
|
|
315
|
+
},
|
|
316
|
+
{
|
|
317
|
+
"name": "listenerFunc",
|
|
318
|
+
"docs": "",
|
|
319
|
+
"type": "(payload: TransactionVerificationFailedEvent) => void"
|
|
320
|
+
}
|
|
321
|
+
],
|
|
322
|
+
"returns": "Promise<PluginListenerHandle>",
|
|
323
|
+
"tags": [],
|
|
324
|
+
"docs": "Listen for StoreKit transaction verification failures delivered by Apple's Transaction.updates.\nFires when the verification result is unverified.\niOS only.",
|
|
325
|
+
"complexTypes": [
|
|
326
|
+
"PluginListenerHandle",
|
|
327
|
+
"TransactionVerificationFailedEvent"
|
|
328
|
+
],
|
|
329
|
+
"slug": "addlistenertransactionverificationfailed-"
|
|
330
|
+
},
|
|
258
331
|
{
|
|
259
332
|
"name": "removeAllListeners",
|
|
260
333
|
"signature": "() => Promise<void>",
|
|
@@ -316,6 +389,26 @@
|
|
|
316
389
|
"complexTypes": [],
|
|
317
390
|
"type": "string | undefined"
|
|
318
391
|
},
|
|
392
|
+
{
|
|
393
|
+
"name": "jwsRepresentation",
|
|
394
|
+
"tags": [
|
|
395
|
+
{
|
|
396
|
+
"text": "7.13.2",
|
|
397
|
+
"name": "since"
|
|
398
|
+
},
|
|
399
|
+
{
|
|
400
|
+
"text": "ios Present for StoreKit 2 transactions (iOS 15+)",
|
|
401
|
+
"name": "platform"
|
|
402
|
+
},
|
|
403
|
+
{
|
|
404
|
+
"text": "android Not available",
|
|
405
|
+
"name": "platform"
|
|
406
|
+
}
|
|
407
|
+
],
|
|
408
|
+
"docs": "StoreKit 2 JSON Web Signature (JWS) payload describing the verified transaction.\n\nSend this to your backend when using Apple's App Store Server API v2 instead of raw receipts.\nOnly available when the transaction originated from StoreKit 2 APIs (e.g. Transaction.updates).",
|
|
409
|
+
"complexTypes": [],
|
|
410
|
+
"type": "string | undefined"
|
|
411
|
+
},
|
|
319
412
|
{
|
|
320
413
|
"name": "appAccountToken",
|
|
321
414
|
"tags": [],
|
|
@@ -367,6 +460,26 @@
|
|
|
367
460
|
"complexTypes": [],
|
|
368
461
|
"type": "string"
|
|
369
462
|
},
|
|
463
|
+
{
|
|
464
|
+
"name": "isUpgraded",
|
|
465
|
+
"tags": [
|
|
466
|
+
{
|
|
467
|
+
"text": "7.13.2",
|
|
468
|
+
"name": "since"
|
|
469
|
+
},
|
|
470
|
+
{
|
|
471
|
+
"text": "ios Present for auto-renewable subscriptions (iOS 15+)",
|
|
472
|
+
"name": "platform"
|
|
473
|
+
},
|
|
474
|
+
{
|
|
475
|
+
"text": "android Not available",
|
|
476
|
+
"name": "platform"
|
|
477
|
+
}
|
|
478
|
+
],
|
|
479
|
+
"docs": "Indicates whether this transaction is the result of a subscription upgrade.\n\nUseful for understanding when StoreKit generated the transaction because\nthe customer moved from a lower tier to a higher tier plan.",
|
|
480
|
+
"complexTypes": [],
|
|
481
|
+
"type": "boolean | undefined"
|
|
482
|
+
},
|
|
370
483
|
{
|
|
371
484
|
"name": "originalPurchaseDate",
|
|
372
485
|
"tags": [
|
|
@@ -427,6 +540,46 @@
|
|
|
427
540
|
"complexTypes": [],
|
|
428
541
|
"type": "boolean | undefined"
|
|
429
542
|
},
|
|
543
|
+
{
|
|
544
|
+
"name": "revocationDate",
|
|
545
|
+
"tags": [
|
|
546
|
+
{
|
|
547
|
+
"text": "7.13.2",
|
|
548
|
+
"name": "since"
|
|
549
|
+
},
|
|
550
|
+
{
|
|
551
|
+
"text": "ios Present for revoked transactions (iOS 15+)",
|
|
552
|
+
"name": "platform"
|
|
553
|
+
},
|
|
554
|
+
{
|
|
555
|
+
"text": "android Not available",
|
|
556
|
+
"name": "platform"
|
|
557
|
+
}
|
|
558
|
+
],
|
|
559
|
+
"docs": "Date the transaction was revoked/refunded, in ISO 8601 format.\n\nPresent when Apple revokes access due to an issue (e.g., refund or developer issue).",
|
|
560
|
+
"complexTypes": [],
|
|
561
|
+
"type": "string | undefined"
|
|
562
|
+
},
|
|
563
|
+
{
|
|
564
|
+
"name": "revocationReason",
|
|
565
|
+
"tags": [
|
|
566
|
+
{
|
|
567
|
+
"text": "7.13.2",
|
|
568
|
+
"name": "since"
|
|
569
|
+
},
|
|
570
|
+
{
|
|
571
|
+
"text": "ios Present for revoked transactions (iOS 15+)",
|
|
572
|
+
"name": "platform"
|
|
573
|
+
},
|
|
574
|
+
{
|
|
575
|
+
"text": "android Not available",
|
|
576
|
+
"name": "platform"
|
|
577
|
+
}
|
|
578
|
+
],
|
|
579
|
+
"docs": "Reason why Apple revoked the transaction.\n\nPossible values:\n- `\"developerIssue\"`: Developer-initiated refund or issue\n- `\"other\"`: Apple-initiated (customer refund, billing problem, etc.)\n- `\"unknown\"`: StoreKit didn't report a specific reason",
|
|
580
|
+
"complexTypes": [],
|
|
581
|
+
"type": "'developerIssue' | 'other' | 'unknown' | undefined"
|
|
582
|
+
},
|
|
430
583
|
{
|
|
431
584
|
"name": "willCancel",
|
|
432
585
|
"tags": [
|
|
@@ -451,6 +604,26 @@
|
|
|
451
604
|
"complexTypes": [],
|
|
452
605
|
"type": "boolean | null"
|
|
453
606
|
},
|
|
607
|
+
{
|
|
608
|
+
"name": "subscriptionState",
|
|
609
|
+
"tags": [
|
|
610
|
+
{
|
|
611
|
+
"text": "7.13.2",
|
|
612
|
+
"name": "since"
|
|
613
|
+
},
|
|
614
|
+
{
|
|
615
|
+
"text": "ios Present for auto-renewable subscriptions (iOS 15+)",
|
|
616
|
+
"name": "platform"
|
|
617
|
+
},
|
|
618
|
+
{
|
|
619
|
+
"text": "android Not available",
|
|
620
|
+
"name": "platform"
|
|
621
|
+
}
|
|
622
|
+
],
|
|
623
|
+
"docs": "Current subscription state reported by StoreKit.\n\nPossible values:\n- `\"subscribed\"`: Auto-renewing and in good standing\n- `\"expired\"`: Lapsed with no access\n- `\"revoked\"`: Access removed due to refund or issue\n- `\"inGracePeriod\"`: Payment issue but still in grace access window\n- `\"inBillingRetryPeriod\"`: StoreKit retrying failed billing\n- `\"unknown\"`: StoreKit did not report a state",
|
|
624
|
+
"complexTypes": [],
|
|
625
|
+
"type": "'unknown' | 'subscribed' | 'expired' | 'revoked' | 'inGracePeriod' | 'inBillingRetryPeriod' | undefined"
|
|
626
|
+
},
|
|
454
627
|
{
|
|
455
628
|
"name": "purchaseState",
|
|
456
629
|
"tags": [
|
|
@@ -527,11 +700,11 @@
|
|
|
527
700
|
"name": "platform"
|
|
528
701
|
},
|
|
529
702
|
{
|
|
530
|
-
"text": "android Always present (should be true after successful purchase)",
|
|
703
|
+
"text": "android Always present (should be true after successful purchase or manual acknowledgment)",
|
|
531
704
|
"name": "platform"
|
|
532
705
|
}
|
|
533
706
|
],
|
|
534
|
-
"docs": "Whether the purchase has been acknowledged.\n\nPurchases must be acknowledged within 3 days or they will be refunded.\
|
|
707
|
+
"docs": "Whether the purchase has been acknowledged.\n\nPurchases must be acknowledged within 3 days or they will be refunded.\nBy default, this plugin automatically acknowledges purchases unless you set\n`autoAcknowledgePurchases: false` in purchaseProduct().",
|
|
535
708
|
"complexTypes": [],
|
|
536
709
|
"type": "boolean | undefined"
|
|
537
710
|
},
|
|
@@ -619,6 +792,26 @@
|
|
|
619
792
|
"complexTypes": [],
|
|
620
793
|
"type": "'Sandbox' | 'Production' | 'Xcode' | undefined"
|
|
621
794
|
},
|
|
795
|
+
{
|
|
796
|
+
"name": "transactionReason",
|
|
797
|
+
"tags": [
|
|
798
|
+
{
|
|
799
|
+
"text": "7.13.2",
|
|
800
|
+
"name": "since"
|
|
801
|
+
},
|
|
802
|
+
{
|
|
803
|
+
"text": "ios Present on iOS 17.0+ (StoreKit 2 transactions)",
|
|
804
|
+
"name": "platform"
|
|
805
|
+
},
|
|
806
|
+
{
|
|
807
|
+
"text": "android Not available",
|
|
808
|
+
"name": "platform"
|
|
809
|
+
}
|
|
810
|
+
],
|
|
811
|
+
"docs": "Reason StoreKit generated the transaction.\n\n- `\"purchase\"`: Initial purchase that user made manually\n- `\"renewal\"`: Automatically generated renewal for an auto-renewable subscription\n- `\"unknown\"`: StoreKit did not return a reason",
|
|
812
|
+
"complexTypes": [],
|
|
813
|
+
"type": "'unknown' | 'purchase' | 'renewal' | undefined"
|
|
814
|
+
},
|
|
622
815
|
{
|
|
623
816
|
"name": "isTrialPeriod",
|
|
624
817
|
"tags": [
|
|
@@ -892,6 +1085,55 @@
|
|
|
892
1085
|
"type": "() => Promise<void>"
|
|
893
1086
|
}
|
|
894
1087
|
]
|
|
1088
|
+
},
|
|
1089
|
+
{
|
|
1090
|
+
"name": "TransactionVerificationFailedEvent",
|
|
1091
|
+
"slug": "transactionverificationfailedevent",
|
|
1092
|
+
"docs": "",
|
|
1093
|
+
"tags": [],
|
|
1094
|
+
"methods": [],
|
|
1095
|
+
"properties": [
|
|
1096
|
+
{
|
|
1097
|
+
"name": "transactionId",
|
|
1098
|
+
"tags": [
|
|
1099
|
+
{
|
|
1100
|
+
"text": "7.13.2",
|
|
1101
|
+
"name": "since"
|
|
1102
|
+
},
|
|
1103
|
+
{
|
|
1104
|
+
"text": "ios Present when StoreKit reports an unverified transaction",
|
|
1105
|
+
"name": "platform"
|
|
1106
|
+
},
|
|
1107
|
+
{
|
|
1108
|
+
"text": "android Not available",
|
|
1109
|
+
"name": "platform"
|
|
1110
|
+
}
|
|
1111
|
+
],
|
|
1112
|
+
"docs": "Identifier of the transaction that failed verification.",
|
|
1113
|
+
"complexTypes": [],
|
|
1114
|
+
"type": "string"
|
|
1115
|
+
},
|
|
1116
|
+
{
|
|
1117
|
+
"name": "error",
|
|
1118
|
+
"tags": [
|
|
1119
|
+
{
|
|
1120
|
+
"text": "7.13.2",
|
|
1121
|
+
"name": "since"
|
|
1122
|
+
},
|
|
1123
|
+
{
|
|
1124
|
+
"text": "ios Always present",
|
|
1125
|
+
"name": "platform"
|
|
1126
|
+
},
|
|
1127
|
+
{
|
|
1128
|
+
"text": "android Not available",
|
|
1129
|
+
"name": "platform"
|
|
1130
|
+
}
|
|
1131
|
+
],
|
|
1132
|
+
"docs": "Localized error message describing why verification failed.",
|
|
1133
|
+
"complexTypes": [],
|
|
1134
|
+
"type": "string"
|
|
1135
|
+
}
|
|
1136
|
+
]
|
|
895
1137
|
}
|
|
896
1138
|
],
|
|
897
1139
|
"enums": [
|
|
@@ -140,6 +140,17 @@ export interface Transaction {
|
|
|
140
140
|
* @platform android Not available (use purchaseToken instead)
|
|
141
141
|
*/
|
|
142
142
|
readonly receipt?: string;
|
|
143
|
+
/**
|
|
144
|
+
* StoreKit 2 JSON Web Signature (JWS) payload describing the verified transaction.
|
|
145
|
+
*
|
|
146
|
+
* Send this to your backend when using Apple's App Store Server API v2 instead of raw receipts.
|
|
147
|
+
* Only available when the transaction originated from StoreKit 2 APIs (e.g. Transaction.updates).
|
|
148
|
+
*
|
|
149
|
+
* @since 7.13.2
|
|
150
|
+
* @platform ios Present for StoreKit 2 transactions (iOS 15+)
|
|
151
|
+
* @platform android Not available
|
|
152
|
+
*/
|
|
153
|
+
readonly jwsRepresentation?: string;
|
|
143
154
|
/**
|
|
144
155
|
* An optional obfuscated identifier that uniquely associates the transaction with a user account in your app.
|
|
145
156
|
*
|
|
@@ -188,6 +199,17 @@ export interface Transaction {
|
|
|
188
199
|
* @platform android Always present
|
|
189
200
|
*/
|
|
190
201
|
readonly purchaseDate: string;
|
|
202
|
+
/**
|
|
203
|
+
* Indicates whether this transaction is the result of a subscription upgrade.
|
|
204
|
+
*
|
|
205
|
+
* Useful for understanding when StoreKit generated the transaction because
|
|
206
|
+
* the customer moved from a lower tier to a higher tier plan.
|
|
207
|
+
*
|
|
208
|
+
* @since 7.13.2
|
|
209
|
+
* @platform ios Present for auto-renewable subscriptions (iOS 15+)
|
|
210
|
+
* @platform android Not available
|
|
211
|
+
*/
|
|
212
|
+
readonly isUpgraded?: boolean;
|
|
191
213
|
/**
|
|
192
214
|
* Original purchase date of the transaction in ISO 8601 format.
|
|
193
215
|
*
|
|
@@ -221,6 +243,29 @@ export interface Transaction {
|
|
|
221
243
|
* @platform android Not available (check purchaseState === "1" instead)
|
|
222
244
|
*/
|
|
223
245
|
readonly isActive?: boolean;
|
|
246
|
+
/**
|
|
247
|
+
* Date the transaction was revoked/refunded, in ISO 8601 format.
|
|
248
|
+
*
|
|
249
|
+
* Present when Apple revokes access due to an issue (e.g., refund or developer issue).
|
|
250
|
+
*
|
|
251
|
+
* @since 7.13.2
|
|
252
|
+
* @platform ios Present for revoked transactions (iOS 15+)
|
|
253
|
+
* @platform android Not available
|
|
254
|
+
*/
|
|
255
|
+
readonly revocationDate?: string;
|
|
256
|
+
/**
|
|
257
|
+
* Reason why Apple revoked the transaction.
|
|
258
|
+
*
|
|
259
|
+
* Possible values:
|
|
260
|
+
* - `"developerIssue"`: Developer-initiated refund or issue
|
|
261
|
+
* - `"other"`: Apple-initiated (customer refund, billing problem, etc.)
|
|
262
|
+
* - `"unknown"`: StoreKit didn't report a specific reason
|
|
263
|
+
*
|
|
264
|
+
* @since 7.13.2
|
|
265
|
+
* @platform ios Present for revoked transactions (iOS 15+)
|
|
266
|
+
* @platform android Not available
|
|
267
|
+
*/
|
|
268
|
+
readonly revocationReason?: 'developerIssue' | 'other' | 'unknown';
|
|
224
269
|
/**
|
|
225
270
|
* Whether the subscription will be cancelled at the end of the billing cycle.
|
|
226
271
|
*
|
|
@@ -234,6 +279,22 @@ export interface Transaction {
|
|
|
234
279
|
* @platform android Always null (use Google Play Developer API for cancellation status)
|
|
235
280
|
*/
|
|
236
281
|
readonly willCancel: boolean | null;
|
|
282
|
+
/**
|
|
283
|
+
* Current subscription state reported by StoreKit.
|
|
284
|
+
*
|
|
285
|
+
* Possible values:
|
|
286
|
+
* - `"subscribed"`: Auto-renewing and in good standing
|
|
287
|
+
* - `"expired"`: Lapsed with no access
|
|
288
|
+
* - `"revoked"`: Access removed due to refund or issue
|
|
289
|
+
* - `"inGracePeriod"`: Payment issue but still in grace access window
|
|
290
|
+
* - `"inBillingRetryPeriod"`: StoreKit retrying failed billing
|
|
291
|
+
* - `"unknown"`: StoreKit did not report a state
|
|
292
|
+
*
|
|
293
|
+
* @since 7.13.2
|
|
294
|
+
* @platform ios Present for auto-renewable subscriptions (iOS 15+)
|
|
295
|
+
* @platform android Not available
|
|
296
|
+
*/
|
|
297
|
+
readonly subscriptionState?: 'subscribed' | 'expired' | 'revoked' | 'inGracePeriod' | 'inBillingRetryPeriod' | 'unknown';
|
|
237
298
|
/**
|
|
238
299
|
* Purchase state of the transaction (numeric string value).
|
|
239
300
|
*
|
|
@@ -276,11 +337,12 @@ export interface Transaction {
|
|
|
276
337
|
* Whether the purchase has been acknowledged.
|
|
277
338
|
*
|
|
278
339
|
* Purchases must be acknowledged within 3 days or they will be refunded.
|
|
279
|
-
*
|
|
340
|
+
* By default, this plugin automatically acknowledges purchases unless you set
|
|
341
|
+
* `autoAcknowledgePurchases: false` in purchaseProduct().
|
|
280
342
|
*
|
|
281
343
|
* @since 1.0.0
|
|
282
344
|
* @platform ios Not available
|
|
283
|
-
* @platform android Always present (should be true after successful purchase)
|
|
345
|
+
* @platform android Always present (should be true after successful purchase or manual acknowledgment)
|
|
284
346
|
*/
|
|
285
347
|
readonly isAcknowledged?: boolean;
|
|
286
348
|
/**
|
|
@@ -337,6 +399,18 @@ export interface Transaction {
|
|
|
337
399
|
* @platform android Not available
|
|
338
400
|
*/
|
|
339
401
|
readonly environment?: 'Sandbox' | 'Production' | 'Xcode';
|
|
402
|
+
/**
|
|
403
|
+
* Reason StoreKit generated the transaction.
|
|
404
|
+
*
|
|
405
|
+
* - `"purchase"`: Initial purchase that user made manually
|
|
406
|
+
* - `"renewal"`: Automatically generated renewal for an auto-renewable subscription
|
|
407
|
+
* - `"unknown"`: StoreKit did not return a reason
|
|
408
|
+
*
|
|
409
|
+
* @since 7.13.2
|
|
410
|
+
* @platform ios Present on iOS 17.0+ (StoreKit 2 transactions)
|
|
411
|
+
* @platform android Not available
|
|
412
|
+
*/
|
|
413
|
+
readonly transactionReason?: 'purchase' | 'renewal' | 'unknown';
|
|
340
414
|
/**
|
|
341
415
|
* Whether the transaction is in a trial period.
|
|
342
416
|
*
|
|
@@ -376,6 +450,24 @@ export interface Transaction {
|
|
|
376
450
|
*/
|
|
377
451
|
readonly isInGracePeriod?: boolean;
|
|
378
452
|
}
|
|
453
|
+
export interface TransactionVerificationFailedEvent {
|
|
454
|
+
/**
|
|
455
|
+
* Identifier of the transaction that failed verification.
|
|
456
|
+
*
|
|
457
|
+
* @since 7.13.2
|
|
458
|
+
* @platform ios Present when StoreKit reports an unverified transaction
|
|
459
|
+
* @platform android Not available
|
|
460
|
+
*/
|
|
461
|
+
readonly transactionId: string;
|
|
462
|
+
/**
|
|
463
|
+
* Localized error message describing why verification failed.
|
|
464
|
+
*
|
|
465
|
+
* @since 7.13.2
|
|
466
|
+
* @platform ios Always present
|
|
467
|
+
* @platform android Not available
|
|
468
|
+
*/
|
|
469
|
+
readonly error: string;
|
|
470
|
+
}
|
|
379
471
|
export interface SubscriptionPeriod {
|
|
380
472
|
/**
|
|
381
473
|
* The Subscription Period number of unit.
|
|
@@ -494,6 +586,7 @@ export interface NativePurchasesPlugin {
|
|
|
494
586
|
* SECURITY: DO NOT use PII like emails in cleartext - use UUID or hashed value.
|
|
495
587
|
* RECOMMENDED: Use UUID v5 with deterministic generation for cross-platform compatibility.
|
|
496
588
|
* @param options.isConsumable - Only Android, when true the purchase token is consumed after granting entitlement (for consumable in-app items). Defaults to false.
|
|
589
|
+
* @param options.autoAcknowledgePurchases - Only Android, when false the purchase will NOT be automatically acknowledged. You must manually call acknowledgePurchase() within 3 days or the purchase will be refunded. Defaults to true.
|
|
497
590
|
*/
|
|
498
591
|
purchaseProduct(options: {
|
|
499
592
|
productIdentifier: string;
|
|
@@ -502,6 +595,7 @@ export interface NativePurchasesPlugin {
|
|
|
502
595
|
quantity?: number;
|
|
503
596
|
appAccountToken?: string;
|
|
504
597
|
isConsumable?: boolean;
|
|
598
|
+
autoAcknowledgePurchases?: boolean;
|
|
505
599
|
}): Promise<Transaction>;
|
|
506
600
|
/**
|
|
507
601
|
* Gets the product info associated with a list of product identifiers.
|
|
@@ -579,12 +673,72 @@ export interface NativePurchasesPlugin {
|
|
|
579
673
|
* @since 7.10.0
|
|
580
674
|
*/
|
|
581
675
|
manageSubscriptions(): Promise<void>;
|
|
676
|
+
/**
|
|
677
|
+
* Manually acknowledge a purchase on Android.
|
|
678
|
+
*
|
|
679
|
+
* This method is only needed when you set `autoAcknowledgePurchases: false` in purchaseProduct().
|
|
680
|
+
* Purchases MUST be acknowledged within 3 days or they will be automatically refunded by Google Play.
|
|
681
|
+
*
|
|
682
|
+
* **Acknowledgment Options:**
|
|
683
|
+
* 1. **Client-side (this method)**: Call from your app after validation
|
|
684
|
+
* 2. **Server-side (recommended for security)**: Use Google Play Developer API v3
|
|
685
|
+
* - Endpoint: POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/products/{productId}/tokens/{token}:acknowledge
|
|
686
|
+
* - Requires OAuth 2.0 authentication with appropriate scopes
|
|
687
|
+
* - See: https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.products/acknowledge
|
|
688
|
+
*
|
|
689
|
+
* When to use manual acknowledgment:
|
|
690
|
+
* - Server-side validation: Verify the purchase with your backend before acknowledging
|
|
691
|
+
* - Entitlement delivery: Ensure user receives content/features before acknowledging
|
|
692
|
+
* - Multi-step workflows: Complete all steps before final acknowledgment
|
|
693
|
+
* - Security: Prevent client-side manipulation by handling acknowledgment server-side
|
|
694
|
+
*
|
|
695
|
+
* @param options - The purchase to acknowledge
|
|
696
|
+
* @param options.purchaseToken - The purchase token from the Transaction object (Android)
|
|
697
|
+
* @returns {Promise<void>} Promise that resolves when the purchase is acknowledged
|
|
698
|
+
* @throws An error if acknowledgment fails
|
|
699
|
+
* @platform android Only available on Android (iOS automatically finishes transactions)
|
|
700
|
+
* @since 7.14.0
|
|
701
|
+
*
|
|
702
|
+
* @example
|
|
703
|
+
* ```typescript
|
|
704
|
+
* // Client-side acknowledgment
|
|
705
|
+
* const transaction = await NativePurchases.purchaseProduct({
|
|
706
|
+
* productIdentifier: 'premium_feature',
|
|
707
|
+
* autoAcknowledgePurchases: false
|
|
708
|
+
* });
|
|
709
|
+
*
|
|
710
|
+
* // Validate with your backend
|
|
711
|
+
* const isValid = await fetch('/api/validate-purchase', {
|
|
712
|
+
* method: 'POST',
|
|
713
|
+
* body: JSON.stringify({ purchaseToken: transaction.purchaseToken })
|
|
714
|
+
* });
|
|
715
|
+
*
|
|
716
|
+
* if (isValid) {
|
|
717
|
+
* // Option 1: Acknowledge from client
|
|
718
|
+
* await NativePurchases.acknowledgePurchase({
|
|
719
|
+
* purchaseToken: transaction.purchaseToken
|
|
720
|
+
* });
|
|
721
|
+
*
|
|
722
|
+
* // Option 2: Or let your backend acknowledge via Google Play API
|
|
723
|
+
* // Your backend calls Google Play Developer API
|
|
724
|
+
* }
|
|
725
|
+
* ```
|
|
726
|
+
*/
|
|
727
|
+
acknowledgePurchase(options: {
|
|
728
|
+
purchaseToken: string;
|
|
729
|
+
}): Promise<void>;
|
|
582
730
|
/**
|
|
583
731
|
* Listen for StoreKit transaction updates delivered by Apple's Transaction.updates.
|
|
584
732
|
* Fires on app launch if there are unfinished transactions, and for any updates afterward.
|
|
585
733
|
* iOS only.
|
|
586
734
|
*/
|
|
587
735
|
addListener(eventName: 'transactionUpdated', listenerFunc: (transaction: Transaction) => void): Promise<PluginListenerHandle>;
|
|
736
|
+
/**
|
|
737
|
+
* Listen for StoreKit transaction verification failures delivered by Apple's Transaction.updates.
|
|
738
|
+
* Fires when the verification result is unverified.
|
|
739
|
+
* iOS only.
|
|
740
|
+
*/
|
|
741
|
+
addListener(eventName: 'transactionVerificationFailed', listenerFunc: (payload: TransactionVerificationFailedEvent) => void): Promise<PluginListenerHandle>;
|
|
588
742
|
/** Remove all registered listeners */
|
|
589
743
|
removeAllListeners(): Promise<void>;
|
|
590
744
|
}
|