react-native-iap 14.4.46 → 14.5.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.
Files changed (105) hide show
  1. package/NitroIap.podspec +2 -2
  2. package/android/src/main/java/com/margelo/nitro/iap/HybridRnIap.kt +134 -4
  3. package/ios/HybridRnIap.swift +73 -2
  4. package/ios/RnIapHelper.swift +8 -0
  5. package/lib/module/hooks/useIAP.js +9 -1
  6. package/lib/module/hooks/useIAP.js.map +1 -1
  7. package/lib/module/index.js +69 -1
  8. package/lib/module/index.js.map +1 -1
  9. package/lib/module/types.js +5 -0
  10. package/lib/module/types.js.map +1 -1
  11. package/lib/module/utils/errorMapping.js +32 -6
  12. package/lib/module/utils/errorMapping.js.map +1 -1
  13. package/lib/module/utils/type-bridge.js +19 -0
  14. package/lib/module/utils/type-bridge.js.map +1 -1
  15. package/lib/typescript/src/hooks/useIAP.d.ts +5 -1
  16. package/lib/typescript/src/hooks/useIAP.d.ts.map +1 -1
  17. package/lib/typescript/src/index.d.ts +34 -1
  18. package/lib/typescript/src/index.d.ts.map +1 -1
  19. package/lib/typescript/src/specs/RnIap.nitro.d.ts +86 -26
  20. package/lib/typescript/src/specs/RnIap.nitro.d.ts.map +1 -1
  21. package/lib/typescript/src/types.d.ts +145 -55
  22. package/lib/typescript/src/types.d.ts.map +1 -1
  23. package/lib/typescript/src/utils/errorMapping.d.ts.map +1 -1
  24. package/lib/typescript/src/utils/type-bridge.d.ts.map +1 -1
  25. package/nitrogen/generated/android/c++/JFunc_void_NitroPurchase.hpp +2 -0
  26. package/nitrogen/generated/android/c++/JHybridRnIapSpec.cpp +80 -0
  27. package/nitrogen/generated/android/c++/JHybridRnIapSpec.hpp +2 -0
  28. package/nitrogen/generated/android/c++/JIapStore.hpp +65 -0
  29. package/nitrogen/generated/android/c++/JIapkitPurchaseState.hpp +80 -0
  30. package/nitrogen/generated/android/c++/JNitroPurchase.hpp +7 -1
  31. package/nitrogen/generated/android/c++/JNitroPurchaseRequest.hpp +11 -3
  32. package/nitrogen/generated/android/c++/JNitroReceiptValidationResultIOS.hpp +2 -0
  33. package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitAppleProps.hpp +57 -0
  34. package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitGoogleProps.hpp +57 -0
  35. package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitProps.hpp +70 -0
  36. package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithIapkitResult.hpp +68 -0
  37. package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithProviderError.hpp +62 -0
  38. package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithProviderProps.hpp +70 -0
  39. package/nitrogen/generated/android/c++/JNitroVerifyPurchaseWithProviderResult.hpp +94 -0
  40. package/nitrogen/generated/android/c++/JPurchase.hpp +2 -0
  41. package/nitrogen/generated/android/c++/JPurchaseAndroid.hpp +7 -1
  42. package/nitrogen/generated/android/c++/JPurchaseIOS.hpp +7 -1
  43. package/nitrogen/generated/android/c++/JPurchaseVerificationProvider.hpp +59 -0
  44. package/nitrogen/generated/android/c++/JRequestPurchaseResult.hpp +2 -0
  45. package/nitrogen/generated/android/c++/JVariant_NitroReceiptValidationResultIOS_NitroReceiptValidationResultAndroid.hpp +2 -0
  46. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/HybridRnIapSpec.kt +8 -0
  47. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/IapStore.kt +23 -0
  48. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/IapkitPurchaseState.kt +28 -0
  49. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchase.kt +5 -2
  50. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroPurchaseRequest.kt +9 -3
  51. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitAppleProps.kt +36 -0
  52. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitGoogleProps.kt +36 -0
  53. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitProps.kt +42 -0
  54. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithIapkitResult.kt +42 -0
  55. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithProviderError.kt +39 -0
  56. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithProviderProps.kt +39 -0
  57. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/NitroVerifyPurchaseWithProviderResult.kt +42 -0
  58. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseAndroid.kt +5 -2
  59. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseIOS.kt +5 -2
  60. package/nitrogen/generated/android/kotlin/com/margelo/nitro/iap/PurchaseVerificationProvider.kt +21 -0
  61. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.cpp +8 -0
  62. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Bridge.hpp +156 -0
  63. package/nitrogen/generated/ios/NitroIap-Swift-Cxx-Umbrella.hpp +30 -0
  64. package/nitrogen/generated/ios/c++/HybridRnIapSpecSwift.hpp +46 -0
  65. package/nitrogen/generated/ios/swift/Func_void_NitroVerifyPurchaseWithProviderResult.swift +47 -0
  66. package/nitrogen/generated/ios/swift/HybridRnIapSpec.swift +2 -0
  67. package/nitrogen/generated/ios/swift/HybridRnIapSpec_cxx.swift +45 -0
  68. package/nitrogen/generated/ios/swift/IapStore.swift +48 -0
  69. package/nitrogen/generated/ios/swift/IapkitPurchaseState.swift +68 -0
  70. package/nitrogen/generated/ios/swift/NitroPurchase.swift +13 -2
  71. package/nitrogen/generated/ios/swift/NitroPurchaseRequest.swift +47 -1
  72. package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitAppleProps.swift +35 -0
  73. package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitGoogleProps.swift +35 -0
  74. package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitProps.swift +100 -0
  75. package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithIapkitResult.swift +57 -0
  76. package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithProviderError.swift +65 -0
  77. package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithProviderProps.swift +58 -0
  78. package/nitrogen/generated/ios/swift/NitroVerifyPurchaseWithProviderResult.swift +100 -0
  79. package/nitrogen/generated/ios/swift/PurchaseAndroid.swift +13 -2
  80. package/nitrogen/generated/ios/swift/PurchaseIOS.swift +13 -2
  81. package/nitrogen/generated/ios/swift/PurchaseVerificationProvider.swift +40 -0
  82. package/nitrogen/generated/shared/c++/HybridRnIapSpec.cpp +2 -0
  83. package/nitrogen/generated/shared/c++/HybridRnIapSpec.hpp +8 -0
  84. package/nitrogen/generated/shared/c++/IapStore.hpp +84 -0
  85. package/nitrogen/generated/shared/c++/IapkitPurchaseState.hpp +104 -0
  86. package/nitrogen/generated/shared/c++/NitroPurchase.hpp +8 -1
  87. package/nitrogen/generated/shared/c++/NitroPurchaseRequest.hpp +10 -2
  88. package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitAppleProps.hpp +75 -0
  89. package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitGoogleProps.hpp +75 -0
  90. package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitProps.hpp +89 -0
  91. package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithIapkitResult.hpp +87 -0
  92. package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithProviderError.hpp +80 -0
  93. package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithProviderProps.hpp +84 -0
  94. package/nitrogen/generated/shared/c++/NitroVerifyPurchaseWithProviderResult.hpp +92 -0
  95. package/nitrogen/generated/shared/c++/PurchaseAndroid.hpp +8 -1
  96. package/nitrogen/generated/shared/c++/PurchaseIOS.hpp +8 -1
  97. package/nitrogen/generated/shared/c++/PurchaseVerificationProvider.hpp +76 -0
  98. package/openiap-versions.json +3 -3
  99. package/package.json +1 -1
  100. package/src/hooks/useIAP.ts +32 -0
  101. package/src/index.ts +77 -5
  102. package/src/specs/RnIap.nitro.ts +117 -28
  103. package/src/types.ts +163 -61
  104. package/src/utils/errorMapping.ts +32 -4
  105. package/src/utils/type-bridge.ts +22 -0
@@ -14,9 +14,9 @@ import type {
14
14
  ProductCommon,
15
15
  PurchaseCommon,
16
16
  PurchaseOptions,
17
- ReceiptValidationAndroidOptions,
18
- ReceiptValidationProps,
19
- ReceiptValidationResultAndroid,
17
+ VerifyPurchaseAndroidOptions,
18
+ VerifyPurchaseProps,
19
+ VerifyPurchaseResultAndroid,
20
20
  RequestPurchaseIosProps,
21
21
  RequestPurchaseResult,
22
22
  RequestSubscriptionAndroidProps,
@@ -24,6 +24,26 @@ import type {
24
24
  PaymentModeIOS,
25
25
  } from '../types';
26
26
 
27
+ // Nitro-compatible enum types (Nitro doesn't support inline string unions from types.ts)
28
+ export type IapPlatform = 'ios' | 'android';
29
+
30
+ export type IapkitPurchaseState =
31
+ | 'entitled'
32
+ | 'pending-acknowledgment'
33
+ | 'pending'
34
+ | 'canceled'
35
+ | 'expired'
36
+ | 'ready-to-consume'
37
+ | 'consumed'
38
+ | 'unknown'
39
+ | 'inauthentic';
40
+
41
+ // IapStore enum for purchase store identification
42
+ export type IapStore = 'unknown' | 'apple' | 'google' | 'horizon';
43
+
44
+ // Note: Nitro requires at least 2 values for union types
45
+ export type PurchaseVerificationProvider = 'iapkit' | 'none';
46
+
27
47
  // ╔══════════════════════════════════════════════════════════════════════════╗
28
48
  // ║ PARAMS ║
29
49
  // ╚══════════════════════════════════════════════════════════════════════════╝
@@ -31,14 +51,14 @@ import type {
31
51
  // Receipt validation parameters
32
52
 
33
53
  export interface NitroReceiptValidationAndroidOptions {
34
- accessToken: ReceiptValidationAndroidOptions['accessToken'];
35
- isSub?: ReceiptValidationAndroidOptions['isSub'];
36
- packageName: ReceiptValidationAndroidOptions['packageName'];
37
- productToken: ReceiptValidationAndroidOptions['productToken'];
54
+ accessToken: VerifyPurchaseAndroidOptions['accessToken'];
55
+ isSub?: VerifyPurchaseAndroidOptions['isSub'];
56
+ packageName: VerifyPurchaseAndroidOptions['packageName'];
57
+ productToken: VerifyPurchaseAndroidOptions['productToken'];
38
58
  }
39
59
 
40
60
  export interface NitroReceiptValidationParams {
41
- sku: ReceiptValidationProps['sku'];
61
+ sku: VerifyPurchaseProps['sku'];
42
62
  androidOptions?: NitroReceiptValidationAndroidOptions | null;
43
63
  }
44
64
 
@@ -66,8 +86,14 @@ export interface NitroRequestPurchaseAndroid {
66
86
  }
67
87
 
68
88
  export interface NitroPurchaseRequest {
89
+ /** @deprecated Use apple instead */
69
90
  ios?: NitroRequestPurchaseIos | null;
91
+ /** @deprecated Use google instead */
70
92
  android?: NitroRequestPurchaseAndroid | null;
93
+ /** Apple-specific purchase parameters */
94
+ apple?: NitroRequestPurchaseIos | null;
95
+ /** Google-specific purchase parameters */
96
+ google?: NitroRequestPurchaseAndroid | null;
71
97
  }
72
98
 
73
99
  // Available purchases parameters
@@ -165,24 +191,64 @@ export interface NitroReceiptValidationResultIOS {
165
191
  }
166
192
 
167
193
  export interface NitroReceiptValidationResultAndroid {
168
- autoRenewing: ReceiptValidationResultAndroid['autoRenewing'];
169
- betaProduct: ReceiptValidationResultAndroid['betaProduct'];
170
- cancelDate: ReceiptValidationResultAndroid['cancelDate'];
171
- cancelReason: ReceiptValidationResultAndroid['cancelReason'];
172
- deferredDate: ReceiptValidationResultAndroid['deferredDate'];
173
- deferredSku: ReceiptValidationResultAndroid['deferredSku'];
174
- freeTrialEndDate: ReceiptValidationResultAndroid['freeTrialEndDate'];
175
- gracePeriodEndDate: ReceiptValidationResultAndroid['gracePeriodEndDate'];
176
- parentProductId: ReceiptValidationResultAndroid['parentProductId'];
177
- productId: ReceiptValidationResultAndroid['productId'];
178
- productType: ReceiptValidationResultAndroid['productType'];
179
- purchaseDate: ReceiptValidationResultAndroid['purchaseDate'];
180
- quantity: ReceiptValidationResultAndroid['quantity'];
181
- receiptId: ReceiptValidationResultAndroid['receiptId'];
182
- renewalDate: ReceiptValidationResultAndroid['renewalDate'];
183
- term: ReceiptValidationResultAndroid['term'];
184
- termSku: ReceiptValidationResultAndroid['termSku'];
185
- testTransaction: ReceiptValidationResultAndroid['testTransaction'];
194
+ autoRenewing: VerifyPurchaseResultAndroid['autoRenewing'];
195
+ betaProduct: VerifyPurchaseResultAndroid['betaProduct'];
196
+ cancelDate: VerifyPurchaseResultAndroid['cancelDate'];
197
+ cancelReason: VerifyPurchaseResultAndroid['cancelReason'];
198
+ deferredDate: VerifyPurchaseResultAndroid['deferredDate'];
199
+ deferredSku: VerifyPurchaseResultAndroid['deferredSku'];
200
+ freeTrialEndDate: VerifyPurchaseResultAndroid['freeTrialEndDate'];
201
+ gracePeriodEndDate: VerifyPurchaseResultAndroid['gracePeriodEndDate'];
202
+ parentProductId: VerifyPurchaseResultAndroid['parentProductId'];
203
+ productId: VerifyPurchaseResultAndroid['productId'];
204
+ productType: VerifyPurchaseResultAndroid['productType'];
205
+ purchaseDate: VerifyPurchaseResultAndroid['purchaseDate'];
206
+ quantity: VerifyPurchaseResultAndroid['quantity'];
207
+ receiptId: VerifyPurchaseResultAndroid['receiptId'];
208
+ renewalDate: VerifyPurchaseResultAndroid['renewalDate'];
209
+ term: VerifyPurchaseResultAndroid['term'];
210
+ termSku: VerifyPurchaseResultAndroid['termSku'];
211
+ testTransaction: VerifyPurchaseResultAndroid['testTransaction'];
212
+ }
213
+
214
+ // VerifyPurchaseWithProvider types
215
+
216
+ export interface NitroVerifyPurchaseWithIapkitAppleProps {
217
+ /** The JWS token returned with the purchase response. */
218
+ jws: string;
219
+ }
220
+
221
+ export interface NitroVerifyPurchaseWithIapkitGoogleProps {
222
+ /** The token provided to the user's device when the product or subscription was purchased. */
223
+ purchaseToken: string;
224
+ }
225
+
226
+ export interface NitroVerifyPurchaseWithIapkitProps {
227
+ apiKey?: string | null;
228
+ apple?: NitroVerifyPurchaseWithIapkitAppleProps | null;
229
+ google?: NitroVerifyPurchaseWithIapkitGoogleProps | null;
230
+ }
231
+
232
+ export interface NitroVerifyPurchaseWithProviderProps {
233
+ iapkit?: NitroVerifyPurchaseWithIapkitProps | null;
234
+ provider: PurchaseVerificationProvider;
235
+ }
236
+
237
+ export interface NitroVerifyPurchaseWithIapkitResult {
238
+ isValid: boolean;
239
+ state: IapkitPurchaseState;
240
+ store: IapStore;
241
+ }
242
+
243
+ export interface NitroVerifyPurchaseWithProviderError {
244
+ code?: string | null;
245
+ message: string;
246
+ }
247
+
248
+ export interface NitroVerifyPurchaseWithProviderResult {
249
+ iapkit?: NitroVerifyPurchaseWithIapkitResult | null;
250
+ errors?: NitroVerifyPurchaseWithProviderError[] | null;
251
+ provider: PurchaseVerificationProvider;
186
252
  }
187
253
 
188
254
  /**
@@ -199,7 +265,10 @@ export interface NitroPurchase {
199
265
  productId: PurchaseCommon['productId'];
200
266
  transactionDate: PurchaseCommon['transactionDate'];
201
267
  purchaseToken?: PurchaseCommon['purchaseToken'];
202
- platform: PurchaseCommon['platform'];
268
+ /** @deprecated Use store instead */
269
+ platform: IapPlatform;
270
+ /** Store where purchase was made */
271
+ store: IapStore;
203
272
  quantity: PurchaseCommon['quantity'];
204
273
  purchaseState: PurchaseCommon['purchaseState'];
205
274
  isAutoRenewing: PurchaseCommon['isAutoRenewing'];
@@ -288,7 +357,7 @@ export interface NitroProduct {
288
357
  displayPrice?: ProductCommon['displayPrice'];
289
358
  currency?: ProductCommon['currency'];
290
359
  price?: ProductCommon['price'];
291
- platform: ProductCommon['platform'];
360
+ platform: IapPlatform;
292
361
  // iOS specific fields
293
362
  typeIOS?: string | null;
294
363
  isFamilyShareableIOS?: boolean | null;
@@ -378,6 +447,13 @@ export interface RnIap extends HybridObject<{ios: 'swift'; android: 'kotlin'}> {
378
447
  subscriptionIds?: string[],
379
448
  ): Promise<NitroActiveSubscription[]>;
380
449
 
450
+ /**
451
+ * Check if there are any active subscriptions
452
+ * @param subscriptionIds - Optional array of subscription IDs to filter
453
+ * @returns Promise<boolean> - True if there are active subscriptions
454
+ */
455
+ hasActiveSubscriptions(subscriptionIds?: string[]): Promise<boolean>;
456
+
381
457
  /**
382
458
  * Finish a transaction (unified method for both platforms)
383
459
  * @param params - Platform-specific transaction finish parameters
@@ -646,6 +722,19 @@ export interface RnIap extends HybridObject<{ios: 'swift'; android: 'kotlin'}> {
646
722
  NitroReceiptValidationResultIOS | NitroReceiptValidationResultAndroid
647
723
  >;
648
724
 
725
+ /**
726
+ * Verify purchase with a specific provider (e.g., IAPKit)
727
+ *
728
+ * This function allows you to verify purchases using external verification
729
+ * services like IAPKit, which provide additional validation and security.
730
+ *
731
+ * @param params - Verification options including provider and credentials
732
+ * @returns Promise<NitroVerifyPurchaseWithProviderResult> - Provider-specific verification result
733
+ */
734
+ verifyPurchaseWithProvider(
735
+ params: NitroVerifyPurchaseWithProviderProps,
736
+ ): Promise<NitroVerifyPurchaseWithProviderResult>;
737
+
649
738
  /**
650
739
  * Get the storefront country/region code for the current user.
651
740
  * @returns Promise<string> - The storefront country code (e.g., "USA")
package/src/types.ts CHANGED
@@ -28,6 +28,11 @@ export interface ActiveSubscription {
28
28
  renewalInfoIOS?: (RenewalInfoIOS | null);
29
29
  transactionDate: number;
30
30
  transactionId: string;
31
+ /**
32
+ * @deprecated iOS only - use daysUntilExpirationIOS instead.
33
+ * Whether the subscription will expire soon (within 7 days).
34
+ * Consider using daysUntilExpirationIOS for more precise control.
35
+ */
31
36
  willExpireSoon?: (boolean | null);
32
37
  }
33
38
 
@@ -131,6 +136,9 @@ export enum ErrorCode {
131
136
  NotPrepared = 'not-prepared',
132
137
  Pending = 'pending',
133
138
  PurchaseError = 'purchase-error',
139
+ PurchaseVerificationFailed = 'purchase-verification-failed',
140
+ PurchaseVerificationFinishFailed = 'purchase-verification-finish-failed',
141
+ PurchaseVerificationFinished = 'purchase-verification-finished',
134
142
  QueryProduct = 'query-product',
135
143
  ReceiptFailed = 'receipt-failed',
136
144
  ReceiptFinished = 'receipt-finished',
@@ -172,6 +180,11 @@ export type IapEvent = 'purchase-updated' | 'purchase-error' | 'promoted-product
172
180
 
173
181
  export type IapPlatform = 'ios' | 'android';
174
182
 
183
+ export type IapStore = 'unknown' | 'apple' | 'google' | 'horizon';
184
+
185
+ /** Unified purchase states from IAPKit verification response. */
186
+ export type IapkitPurchaseState = 'entitled' | 'pending-acknowledgment' | 'pending' | 'canceled' | 'expired' | 'ready-to-consume' | 'consumed' | 'unknown' | 'inauthentic';
187
+
175
188
  /** Connection initialization configuration */
176
189
  export interface InitConnectionConfig {
177
190
  /**
@@ -241,8 +254,15 @@ export interface Mutation {
241
254
  showManageSubscriptionsIOS: Promise<PurchaseIOS[]>;
242
255
  /** Force a StoreKit sync for transactions (iOS 15+) */
243
256
  syncIOS: Promise<boolean>;
244
- /** Validate purchase receipts with the configured providers */
245
- validateReceipt: Promise<ReceiptValidationResult>;
257
+ /**
258
+ * Validate purchase receipts with the configured providers
259
+ * @deprecated Use verifyPurchase
260
+ */
261
+ validateReceipt: Promise<VerifyPurchaseResult>;
262
+ /** Verify purchases with the configured providers */
263
+ verifyPurchase: Promise<VerifyPurchaseResult>;
264
+ /** Verify purchases with a specific provider (e.g., IAPKit) */
265
+ verifyPurchaseWithProvider: Promise<VerifyPurchaseWithProviderResult>;
246
266
  }
247
267
 
248
268
 
@@ -282,7 +302,11 @@ export type MutationRequestPurchaseArgs =
282
302
  };
283
303
 
284
304
 
285
- export type MutationValidateReceiptArgs = ReceiptValidationProps;
305
+ export type MutationValidateReceiptArgs = VerifyPurchaseProps;
306
+
307
+ export type MutationVerifyPurchaseArgs = VerifyPurchaseProps;
308
+
309
+ export type MutationVerifyPurchaseWithProviderArgs = VerifyPurchaseWithProviderProps;
286
310
 
287
311
  export type PaymentModeIOS = 'empty' | 'free-trial' | 'pay-as-you-go' | 'pay-up-front';
288
312
 
@@ -330,11 +354,11 @@ export interface ProductCommon {
330
354
  displayName?: (string | null);
331
355
  displayPrice: string;
332
356
  id: string;
333
- platform: IapPlatform;
357
+ platform: 'android' | 'ios';
334
358
  price?: (number | null);
335
359
  title: string;
336
- type: ProductType;
337
- }
360
+ type: 'in-app' | 'subs';
361
+ }
338
362
 
339
363
  export interface ProductIOS extends ProductCommon {
340
364
  currency: string;
@@ -433,12 +457,18 @@ export interface PurchaseAndroid extends PurchaseCommon {
433
457
  obfuscatedAccountIdAndroid?: (string | null);
434
458
  obfuscatedProfileIdAndroid?: (string | null);
435
459
  packageNameAndroid?: (string | null);
460
+ /**
461
+ * @deprecated Use store instead
462
+ * @deprecated Use store instead
463
+ */
436
464
  platform: IapPlatform;
437
465
  productId: string;
438
466
  purchaseState: PurchaseState;
439
467
  purchaseToken?: (string | null);
440
468
  quantity: number;
441
469
  signatureAndroid?: (string | null);
470
+ /** Store where purchase was made */
471
+ store: IapStore;
442
472
  transactionDate: number;
443
473
  transactionId?: (string | null);
444
474
  }
@@ -454,12 +484,18 @@ export interface PurchaseCommon {
454
484
  id: string;
455
485
  ids?: (string[] | null);
456
486
  isAutoRenewing: boolean;
487
+ /**
488
+ * @deprecated Use store instead
489
+ * @deprecated Use store instead
490
+ */
457
491
  platform: IapPlatform;
458
492
  productId: string;
459
493
  purchaseState: PurchaseState;
460
494
  /** Unified purchase token (iOS JWS, Android purchaseToken) */
461
495
  purchaseToken?: (string | null);
462
496
  quantity: number;
497
+ /** Store where purchase was made */
498
+ store: IapStore;
463
499
  transactionDate: number;
464
500
  }
465
501
 
@@ -486,6 +522,10 @@ export interface PurchaseIOS extends PurchaseCommon {
486
522
  originalTransactionDateIOS?: (number | null);
487
523
  originalTransactionIdentifierIOS?: (string | null);
488
524
  ownershipTypeIOS?: (string | null);
525
+ /**
526
+ * @deprecated Use store instead
527
+ * @deprecated Use store instead
528
+ */
489
529
  platform: IapPlatform;
490
530
  productId: string;
491
531
  purchaseState: PurchaseState;
@@ -497,6 +537,8 @@ export interface PurchaseIOS extends PurchaseCommon {
497
537
  renewalInfoIOS?: (RenewalInfoIOS | null);
498
538
  revocationDateIOS?: (number | null);
499
539
  revocationReasonIOS?: (string | null);
540
+ /** Store where purchase was made */
541
+ store: IapStore;
500
542
  storefrontCountryCodeIOS?: (string | null);
501
543
  subscriptionGroupIdIOS?: (string | null);
502
544
  transactionDate: number;
@@ -522,6 +564,8 @@ export interface PurchaseOptions {
522
564
 
523
565
  export type PurchaseState = 'pending' | 'purchased' | 'failed' | 'restored' | 'deferred' | 'unknown';
524
566
 
567
+ export type PurchaseVerificationProvider = 'iapkit';
568
+
525
569
  export interface Query {
526
570
  /** Check if external purchase notice sheet can be presented (iOS 18.2+) */
527
571
  canPresentExternalPurchaseNoticeIOS: Promise<boolean>;
@@ -560,8 +604,11 @@ export interface Query {
560
604
  latestTransactionIOS?: Promise<(PurchaseIOS | null)>;
561
605
  /** Get StoreKit 2 subscription status details (iOS 15+) */
562
606
  subscriptionStatusIOS: Promise<SubscriptionStatusIOS[]>;
563
- /** Validate a receipt for a specific product */
564
- validateReceiptIOS: Promise<ReceiptValidationResultIOS>;
607
+ /**
608
+ * Validate a receipt for a specific product
609
+ * @deprecated Use verifyPurchase
610
+ */
611
+ validateReceiptIOS: Promise<VerifyPurchaseResultIOS>;
565
612
  }
566
613
 
567
614
 
@@ -586,55 +633,7 @@ export type QueryLatestTransactionIosArgs = string;
586
633
 
587
634
  export type QuerySubscriptionStatusIosArgs = string;
588
635
 
589
- export type QueryValidateReceiptIosArgs = ReceiptValidationProps;
590
-
591
- export interface ReceiptValidationAndroidOptions {
592
- accessToken: string;
593
- isSub?: (boolean | null);
594
- packageName: string;
595
- productToken: string;
596
- }
597
-
598
- export interface ReceiptValidationProps {
599
- /** Android-specific validation options */
600
- androidOptions?: (ReceiptValidationAndroidOptions | null);
601
- /** Product SKU to validate */
602
- sku: string;
603
- }
604
-
605
- export type ReceiptValidationResult = ReceiptValidationResultAndroid | ReceiptValidationResultIOS;
606
-
607
- export interface ReceiptValidationResultAndroid {
608
- autoRenewing: boolean;
609
- betaProduct: boolean;
610
- cancelDate?: (number | null);
611
- cancelReason?: (string | null);
612
- deferredDate?: (number | null);
613
- deferredSku?: (string | null);
614
- freeTrialEndDate: number;
615
- gracePeriodEndDate: number;
616
- parentProductId: string;
617
- productId: string;
618
- productType: string;
619
- purchaseDate: number;
620
- quantity: number;
621
- receiptId: string;
622
- renewalDate: number;
623
- term: string;
624
- termSku: string;
625
- testTransaction: boolean;
626
- }
627
-
628
- export interface ReceiptValidationResultIOS {
629
- /** Whether the receipt is valid */
630
- isValid: boolean;
631
- /** JWS representation */
632
- jwsRepresentation: string;
633
- /** Latest transaction if available */
634
- latestTransaction?: (Purchase | null);
635
- /** Receipt data string */
636
- receiptData: string;
637
- }
636
+ export type QueryValidateReceiptIosArgs = VerifyPurchaseProps;
638
637
 
639
638
  export interface RefundResultIOS {
640
639
  message?: (string | null);
@@ -729,9 +728,13 @@ export type RequestPurchaseProps =
729
728
  };
730
729
 
731
730
  export interface RequestPurchasePropsByPlatforms {
732
- /** Android-specific purchase parameters */
731
+ /** @deprecated Use google instead */
733
732
  android?: (RequestPurchaseAndroidProps | null);
734
- /** iOS-specific purchase parameters */
733
+ /** Apple-specific purchase parameters */
734
+ apple?: (RequestPurchaseIosProps | null);
735
+ /** Google-specific purchase parameters */
736
+ google?: (RequestPurchaseAndroidProps | null);
737
+ /** @deprecated Use apple instead */
735
738
  ios?: (RequestPurchaseIosProps | null);
736
739
  }
737
740
 
@@ -763,12 +766,43 @@ export interface RequestSubscriptionIosProps {
763
766
  }
764
767
 
765
768
  export interface RequestSubscriptionPropsByPlatforms {
766
- /** Android-specific subscription parameters */
769
+ /** @deprecated Use google instead */
767
770
  android?: (RequestSubscriptionAndroidProps | null);
768
- /** iOS-specific subscription parameters */
771
+ /** Apple-specific subscription parameters */
772
+ apple?: (RequestSubscriptionIosProps | null);
773
+ /** Google-specific subscription parameters */
774
+ google?: (RequestSubscriptionAndroidProps | null);
775
+ /** @deprecated Use apple instead */
769
776
  ios?: (RequestSubscriptionIosProps | null);
770
777
  }
771
778
 
779
+ export interface RequestVerifyPurchaseWithIapkitAppleProps {
780
+ /** The JWS token returned with the purchase response. */
781
+ jws: string;
782
+ }
783
+
784
+ export interface RequestVerifyPurchaseWithIapkitGoogleProps {
785
+ /** The token provided to the user's device when the product or subscription was purchased. */
786
+ purchaseToken: string;
787
+ }
788
+
789
+ export interface RequestVerifyPurchaseWithIapkitProps {
790
+ /** API key used for the Authorization header (Bearer {apiKey}). */
791
+ apiKey?: (string | null);
792
+ /** Apple verification parameters. */
793
+ apple?: (RequestVerifyPurchaseWithIapkitAppleProps | null);
794
+ /** Google verification parameters. */
795
+ google?: (RequestVerifyPurchaseWithIapkitGoogleProps | null);
796
+ }
797
+
798
+ export interface RequestVerifyPurchaseWithIapkitResult {
799
+ /** Whether the purchase is valid (not falsified). */
800
+ isValid: boolean;
801
+ /** The current state of the purchase. */
802
+ state: IapkitPurchaseState;
803
+ store: IapStore;
804
+ }
805
+
772
806
  export interface Subscription {
773
807
  /** Fires when the App Store surfaces a promoted product (iOS only) */
774
808
  promotedProductIOS: string;
@@ -826,6 +860,72 @@ export interface UserChoiceBillingDetails {
826
860
  products: string[];
827
861
  }
828
862
 
863
+ export interface VerifyPurchaseAndroidOptions {
864
+ accessToken: string;
865
+ isSub?: (boolean | null);
866
+ packageName: string;
867
+ productToken: string;
868
+ }
869
+
870
+ export interface VerifyPurchaseProps {
871
+ /** Android-specific validation options */
872
+ androidOptions?: (VerifyPurchaseAndroidOptions | null);
873
+ /** Product SKU to validate */
874
+ sku: string;
875
+ }
876
+
877
+ export type VerifyPurchaseResult = VerifyPurchaseResultAndroid | VerifyPurchaseResultIOS;
878
+
879
+ export interface VerifyPurchaseResultAndroid {
880
+ autoRenewing: boolean;
881
+ betaProduct: boolean;
882
+ cancelDate?: (number | null);
883
+ cancelReason?: (string | null);
884
+ deferredDate?: (number | null);
885
+ deferredSku?: (string | null);
886
+ freeTrialEndDate: number;
887
+ gracePeriodEndDate: number;
888
+ parentProductId: string;
889
+ productId: string;
890
+ productType: string;
891
+ purchaseDate: number;
892
+ quantity: number;
893
+ receiptId: string;
894
+ renewalDate: number;
895
+ term: string;
896
+ termSku: string;
897
+ testTransaction: boolean;
898
+ }
899
+
900
+ export interface VerifyPurchaseResultIOS {
901
+ /** Whether the receipt is valid */
902
+ isValid: boolean;
903
+ /** JWS representation */
904
+ jwsRepresentation: string;
905
+ /** Latest transaction if available */
906
+ latestTransaction?: (Purchase | null);
907
+ /** Receipt data string */
908
+ receiptData: string;
909
+ }
910
+
911
+ export interface VerifyPurchaseWithProviderError {
912
+ code?: (string | null);
913
+ message: string;
914
+ }
915
+
916
+ export interface VerifyPurchaseWithProviderProps {
917
+ iapkit?: (RequestVerifyPurchaseWithIapkitProps | null);
918
+ provider: PurchaseVerificationProvider;
919
+ }
920
+
921
+ export interface VerifyPurchaseWithProviderResult {
922
+ /** Error details if verification failed */
923
+ errors?: (VerifyPurchaseWithProviderError[] | null);
924
+ /** IAPKit verification result */
925
+ iapkit?: (RequestVerifyPurchaseWithIapkitResult | null);
926
+ provider: PurchaseVerificationProvider;
927
+ }
928
+
829
929
  export type VoidResult = void;
830
930
 
831
931
  // -- Query helper types (auto-generated)
@@ -884,6 +984,8 @@ export type MutationArgsMap = {
884
984
  showManageSubscriptionsIOS: never;
885
985
  syncIOS: never;
886
986
  validateReceipt: MutationValidateReceiptArgs;
987
+ verifyPurchase: MutationVerifyPurchaseArgs;
988
+ verifyPurchaseWithProvider: MutationVerifyPurchaseWithProviderArgs;
887
989
  };
888
990
 
889
991
  export type MutationField<K extends keyof Mutation> =
@@ -11,6 +11,18 @@ const ERROR_CODE_ALIASES: Record<string, ErrorCode> = {
11
11
  USER_CANCELED: ErrorCode.UserCancelled,
12
12
  E_USER_CANCELLED: ErrorCode.UserCancelled,
13
13
  USER_CANCELLED: ErrorCode.UserCancelled,
14
+ // Deprecated error code mappings (map old Receipt* codes to new PurchaseVerification* codes)
15
+ // These ensure backwards compatibility while preferring new codes
16
+ RECEIPT_FAILED: ErrorCode.PurchaseVerificationFailed,
17
+ E_RECEIPT_FAILED: ErrorCode.PurchaseVerificationFailed,
18
+ RECEIPT_FINISHED: ErrorCode.PurchaseVerificationFinished,
19
+ E_RECEIPT_FINISHED: ErrorCode.PurchaseVerificationFinished,
20
+ RECEIPT_FINISHED_FAILED: ErrorCode.PurchaseVerificationFinishFailed,
21
+ E_RECEIPT_FINISHED_FAILED: ErrorCode.PurchaseVerificationFinishFailed,
22
+ // Also handle kebab-case versions
23
+ 'receipt-failed': ErrorCode.PurchaseVerificationFailed,
24
+ 'receipt-finished': ErrorCode.PurchaseVerificationFinished,
25
+ 'receipt-finished-failed': ErrorCode.PurchaseVerificationFinishFailed,
14
26
  };
15
27
 
16
28
  const toKebabCase = (str: string): string => {
@@ -86,6 +98,11 @@ const COMMON_ERROR_CODE_MAP: Record<ErrorCode, string> = {
86
98
  [ErrorCode.BillingUnavailable]: ErrorCode.BillingUnavailable,
87
99
  [ErrorCode.FeatureNotSupported]: ErrorCode.FeatureNotSupported,
88
100
  [ErrorCode.EmptySkuList]: ErrorCode.EmptySkuList,
101
+ [ErrorCode.PurchaseVerificationFailed]: ErrorCode.PurchaseVerificationFailed,
102
+ [ErrorCode.PurchaseVerificationFinishFailed]:
103
+ ErrorCode.PurchaseVerificationFinishFailed,
104
+ [ErrorCode.PurchaseVerificationFinished]:
105
+ ErrorCode.PurchaseVerificationFinished,
89
106
  };
90
107
 
91
108
  export const ErrorCodeMapping = {
@@ -293,8 +310,6 @@ export function getUserFriendlyErrorMessage(error: ErrorLike): string {
293
310
  return 'Purchase cancelled';
294
311
  case ErrorCode.NetworkError:
295
312
  return 'Network connection error. Please check your internet connection and try again.';
296
- case ErrorCode.ReceiptFinished:
297
- return 'Receipt already finished';
298
313
  case ErrorCode.ServiceDisconnected:
299
314
  return 'Billing service disconnected. Please try again.';
300
315
  case ErrorCode.BillingUnavailable:
@@ -320,7 +335,14 @@ export function getUserFriendlyErrorMessage(error: ErrorLike): string {
320
335
  case ErrorCode.TransactionValidationFailed:
321
336
  return 'Transaction could not be verified';
322
337
  case ErrorCode.ReceiptFailed:
323
- return 'Receipt processing failed';
338
+ case ErrorCode.PurchaseVerificationFailed:
339
+ return 'Purchase verification failed';
340
+ case ErrorCode.ReceiptFinished:
341
+ case ErrorCode.PurchaseVerificationFinished:
342
+ return 'Purchase verification completed';
343
+ case ErrorCode.ReceiptFinishedFailed:
344
+ case ErrorCode.PurchaseVerificationFinishFailed:
345
+ return 'Failed to complete purchase verification';
324
346
  case ErrorCode.EmptySkuList:
325
347
  return 'No product IDs provided';
326
348
  case ErrorCode.InitConnection:
@@ -345,12 +367,18 @@ export const normalizeErrorCodeFromNative = (code: unknown): ErrorCode => {
345
367
  if (typeof code === 'string') {
346
368
  const upper = code.toUpperCase();
347
369
 
348
- // Check aliases first
370
+ // Check aliases first (includes deprecated Receipt* -> PurchaseVerification* mappings)
349
371
  const alias = ERROR_CODE_ALIASES[upper];
350
372
  if (alias) {
351
373
  return alias;
352
374
  }
353
375
 
376
+ // Also check lowercase alias for kebab-case codes
377
+ const lowerAlias = ERROR_CODE_ALIASES[code];
378
+ if (lowerAlias) {
379
+ return lowerAlias;
380
+ }
381
+
354
382
  // Handle various user cancelled formats
355
383
  if (
356
384
  upper === 'USER_CANCELLED' ||