react-native-iap 8.5.1 → 8.6.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 (85) hide show
  1. package/README.md +4 -20
  2. package/RNIap.podspec +33 -18
  3. package/android/build.gradle +137 -38
  4. package/android/gradle.properties +8 -0
  5. package/ios/RNIapIos-Bridging-Header.h +2 -0
  6. package/ios/RNIapIos.m +14 -2
  7. package/ios/RNIapIos.swift +903 -881
  8. package/ios/{RNIap.xcodeproj → RNIapIos.xcodeproj}/project.pbxproj +29 -116
  9. package/lib/commonjs/__test__/iap.test.js +21 -0
  10. package/lib/commonjs/__test__/iap.test.js.map +1 -0
  11. package/lib/commonjs/hooks/useIAP.js +78 -0
  12. package/lib/commonjs/hooks/useIAP.js.map +1 -0
  13. package/lib/commonjs/hooks/withIAPContext.js +92 -0
  14. package/lib/commonjs/hooks/withIAPContext.js.map +1 -0
  15. package/lib/commonjs/iap.js +577 -0
  16. package/lib/commonjs/iap.js.map +1 -0
  17. package/lib/commonjs/index.js +59 -0
  18. package/lib/commonjs/index.js.map +1 -0
  19. package/lib/commonjs/types/amazon.js +2 -0
  20. package/lib/commonjs/types/amazon.js.map +1 -0
  21. package/lib/commonjs/types/android.js +55 -0
  22. package/lib/commonjs/types/android.js.map +1 -0
  23. package/lib/commonjs/types/apple.js +165 -0
  24. package/lib/commonjs/types/apple.js.map +1 -0
  25. package/lib/commonjs/types/index.js +59 -0
  26. package/lib/commonjs/types/index.js.map +1 -0
  27. package/lib/module/__test__/iap.test.js +17 -0
  28. package/lib/module/__test__/iap.test.js.map +1 -0
  29. package/lib/module/hooks/useIAP.js +68 -0
  30. package/lib/module/hooks/useIAP.js.map +1 -0
  31. package/lib/module/hooks/withIAPContext.js +76 -0
  32. package/lib/module/hooks/withIAPContext.js.map +1 -0
  33. package/lib/module/iap.js +488 -0
  34. package/lib/module/iap.js.map +1 -0
  35. package/lib/module/index.js +6 -0
  36. package/lib/module/index.js.map +1 -0
  37. package/lib/module/types/amazon.js +2 -0
  38. package/lib/module/types/amazon.js.map +1 -0
  39. package/lib/module/types/android.js +44 -0
  40. package/lib/module/types/android.js.map +1 -0
  41. package/lib/module/types/apple.js +153 -0
  42. package/lib/module/types/apple.js.map +1 -0
  43. package/lib/module/types/index.js +48 -0
  44. package/lib/module/types/index.js.map +1 -0
  45. package/{src → lib/typescript}/__test__/iap.test.d.ts +0 -0
  46. package/{src → lib/typescript}/hooks/useIAP.d.ts +1 -1
  47. package/{src → lib/typescript}/hooks/withIAPContext.d.ts +1 -1
  48. package/{src → lib/typescript}/iap.d.ts +13 -11
  49. package/{src → lib/typescript}/index.d.ts +2 -1
  50. package/{src → lib/typescript}/types/amazon.d.ts +0 -0
  51. package/{src → lib/typescript}/types/android.d.ts +0 -0
  52. package/{src → lib/typescript}/types/apple.d.ts +0 -0
  53. package/{src → lib/typescript}/types/index.d.ts +25 -4
  54. package/package.json +87 -56
  55. package/src/__test__/iap.test.ts +20 -0
  56. package/src/hooks/useIAP.ts +130 -0
  57. package/src/hooks/withIAPContext.tsx +160 -0
  58. package/src/iap.ts +686 -0
  59. package/src/{index.js → index.ts} +4 -1
  60. package/src/types/amazon.ts +23 -0
  61. package/src/types/android.ts +51 -0
  62. package/src/types/apple.ts +467 -0
  63. package/src/types/index.ts +185 -0
  64. package/.editorconfig +0 -10
  65. package/.flowconfig +0 -11
  66. package/.monolinterrc +0 -3
  67. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  68. package/android/gradle/wrapper/gradle-wrapper.properties +0 -6
  69. package/android/gradlew +0 -160
  70. package/android/gradlew.bat +0 -90
  71. package/babel.config.js +0 -10
  72. package/index.d.ts +0 -3
  73. package/index.js +0 -3
  74. package/index.js.flow +0 -9
  75. package/ios/RNIap.xcodeproj/xcshareddata/xcschemes/RNIap.xcscheme +0 -80
  76. package/jest.config.js +0 -194
  77. package/src/__test__/iap.test.js +0 -59
  78. package/src/hooks/useIAP.js +0 -141
  79. package/src/hooks/withIAPContext.js +0 -150
  80. package/src/iap.js +0 -631
  81. package/src/types/amazon.js +0 -1
  82. package/src/types/android.js +0 -22
  83. package/src/types/apple.js +0 -165
  84. package/src/types/index.js +0 -40
  85. package/test/mocks/react-native-modules.js +0 -14
@@ -0,0 +1,577 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.validateReceiptIos = exports.validateReceiptAndroid = exports.validateReceiptAmazon = exports.requestSubscription = exports.requestPurchaseWithQuantityIOS = exports.requestPurchaseWithOfferIOS = exports.requestPurchase = exports.purchaseUpdatedListener = exports.purchaseErrorListener = exports.promotedProductListener = exports.presentCodeRedemptionSheetIOS = exports.initConnection = exports.getSubscriptions = exports.getPurchaseHistory = exports.getPromotedProductIOS = exports.getProducts = exports.getPendingPurchasesIOS = exports.getInstallSourceAndroid = exports.getAvailablePurchases = exports.flushFailedPurchasesCachedAsPendingAndroid = exports.finishTransaction = exports.endConnection = exports.deepLinkToSubscriptionsAndroid = exports.clearTransactionIOS = exports.clearProductsIOS = exports.buyPromotedProductIOS = exports.acknowledgePurchaseAndroid = void 0;
7
+
8
+ var _reactNative = require("react-native");
9
+
10
+ var _apple = require("./types/apple");
11
+
12
+ var _types = require("./types");
13
+
14
+ const {
15
+ RNIapIos,
16
+ RNIapModule,
17
+ RNIapAmazonModule
18
+ } = _reactNative.NativeModules;
19
+ const isAndroid = _reactNative.Platform.OS === 'android';
20
+ const ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';
21
+ const ANDROID_ITEM_TYPE_IAP = 'inapp';
22
+
23
+ const getInstallSourceAndroid = () => {
24
+ return RNIapModule ? _types.InstallSourceAndroid.GOOGLE_PLAY : _types.InstallSourceAndroid.AMAZON;
25
+ };
26
+
27
+ exports.getInstallSourceAndroid = getInstallSourceAndroid;
28
+
29
+ const checkNativeAndroidAvailable = () => {
30
+ if (!RNIapModule && !RNIapAmazonModule) {
31
+ throw new Error(_types.IAPErrorCode.E_IAP_NOT_AVAILABLE);
32
+ }
33
+ };
34
+
35
+ const getAndroidModule = () => {
36
+ checkNativeAndroidAvailable();
37
+ return RNIapModule ? RNIapModule : RNIapAmazonModule;
38
+ };
39
+
40
+ const checkNativeIOSAvailable = () => {
41
+ if (!RNIapIos) {
42
+ throw new Error(_types.IAPErrorCode.E_IAP_NOT_AVAILABLE);
43
+ }
44
+ };
45
+
46
+ const getIosModule = () => {
47
+ checkNativeIOSAvailable();
48
+ return RNIapIos;
49
+ };
50
+
51
+ const getNativeModule = () => {
52
+ if (isAndroid) {
53
+ return getAndroidModule();
54
+ }
55
+
56
+ return getIosModule();
57
+ };
58
+ /**
59
+ * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.
60
+ * @returns {Promise<boolean>}
61
+ */
62
+
63
+
64
+ const initConnection = () => getNativeModule().initConnection();
65
+ /**
66
+ * End module for purchase flow.
67
+ * @returns {Promise<void>}
68
+ */
69
+
70
+
71
+ exports.initConnection = initConnection;
72
+
73
+ const endConnection = () => getNativeModule().endConnection();
74
+ /**
75
+ * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.
76
+ * @returns {Promise<boolean>}
77
+ */
78
+
79
+
80
+ exports.endConnection = endConnection;
81
+
82
+ const flushFailedPurchasesCachedAsPendingAndroid = () => getAndroidModule().flushFailedPurchasesCachedAsPending();
83
+ /**
84
+ * Fill products with additional data
85
+ * @param {Array<ProductCommon>} products Products
86
+ */
87
+
88
+
89
+ exports.flushFailedPurchasesCachedAsPendingAndroid = flushFailedPurchasesCachedAsPendingAndroid;
90
+
91
+ const fillProductsAdditionalData = async products => {
92
+ // Amazon
93
+ if (RNIapAmazonModule) {
94
+ // On amazon we must get the user marketplace to detect the currency
95
+ const user = await RNIapAmazonModule.getUser();
96
+ const currencies = {
97
+ CA: 'CAD',
98
+ ES: 'EUR',
99
+ AU: 'AUD',
100
+ DE: 'EUR',
101
+ IN: 'INR',
102
+ US: 'USD',
103
+ JP: 'JPY',
104
+ GB: 'GBP',
105
+ IT: 'EUR',
106
+ BR: 'BRL',
107
+ FR: 'EUR'
108
+ };
109
+ const currency = currencies[user.userMarketplaceAmazon]; // Add currency to products
110
+
111
+ products.forEach(product => {
112
+ if (currency) {
113
+ product.currency = currency;
114
+ }
115
+ });
116
+ }
117
+
118
+ return products;
119
+ };
120
+ /**
121
+ * Get a list of products (consumable and non-consumable items, but not subscriptions)
122
+ * @param {string[]} skus The item skus
123
+ * @returns {Promise<Product[]>}
124
+ */
125
+
126
+
127
+ const getProducts = skus => (_reactNative.Platform.select({
128
+ ios: async () => {
129
+ const items = await getIosModule().getItems(skus);
130
+ return items.filter(item => skus.includes(item.productId) && item.type === 'iap');
131
+ },
132
+ android: async () => {
133
+ const products = await getAndroidModule().getItemsByType(ANDROID_ITEM_TYPE_IAP, skus);
134
+ return fillProductsAdditionalData(products);
135
+ }
136
+ }) || Promise.resolve)();
137
+ /**
138
+ * Get a list of subscriptions
139
+ * @param {string[]} skus The item skus
140
+ * @returns {Promise<Subscription[]>}
141
+ */
142
+
143
+
144
+ exports.getProducts = getProducts;
145
+
146
+ const getSubscriptions = skus => (_reactNative.Platform.select({
147
+ ios: async () => {
148
+ const items = await getIosModule().getItems(skus);
149
+ return items.filter(item => skus.includes(item.productId) && item.type === 'subs');
150
+ },
151
+ android: async () => {
152
+ const subscriptions = await getAndroidModule().getItemsByType(ANDROID_ITEM_TYPE_SUBSCRIPTION, skus);
153
+ return fillProductsAdditionalData(subscriptions);
154
+ }
155
+ }) || Promise.resolve)();
156
+ /**
157
+ * Gets an inventory of purchases made by the user regardless of consumption status
158
+ * @returns {Promise<(InAppPurchase | SubscriptionPurchase)[]>}
159
+ */
160
+
161
+
162
+ exports.getSubscriptions = getSubscriptions;
163
+
164
+ const getPurchaseHistory = () => (_reactNative.Platform.select({
165
+ ios: async () => {
166
+ return getIosModule().getAvailableItems();
167
+ },
168
+ android: async () => {
169
+ if (RNIapAmazonModule) {
170
+ return await RNIapAmazonModule.getAvailableItems();
171
+ }
172
+
173
+ const products = await getAndroidModule().getPurchaseHistoryByType(ANDROID_ITEM_TYPE_IAP);
174
+ const subscriptions = await getAndroidModule().getPurchaseHistoryByType(ANDROID_ITEM_TYPE_SUBSCRIPTION);
175
+ return products.concat(subscriptions);
176
+ }
177
+ }) || Promise.resolve)();
178
+ /**
179
+ * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)
180
+ * @returns {Promise<(InAppPurchase | SubscriptionPurchase)[]>}
181
+ */
182
+
183
+
184
+ exports.getPurchaseHistory = getPurchaseHistory;
185
+
186
+ const getAvailablePurchases = () => (_reactNative.Platform.select({
187
+ ios: async () => {
188
+ return getIosModule().getAvailableItems();
189
+ },
190
+ android: async () => {
191
+ if (RNIapAmazonModule) {
192
+ return await RNIapAmazonModule.getAvailableItems();
193
+ }
194
+
195
+ const products = await getAndroidModule().getAvailableItemsByType(ANDROID_ITEM_TYPE_IAP);
196
+ const subscriptions = await getAndroidModule().getAvailableItemsByType(ANDROID_ITEM_TYPE_SUBSCRIPTION);
197
+ return products.concat(subscriptions);
198
+ }
199
+ }) || Promise.resolve)();
200
+ /**
201
+ * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
202
+ * @param {string} sku The product's sku/ID
203
+ * @param {string} [applicationUsername] The purchaser's user ID
204
+ * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.
205
+ * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
206
+ * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
207
+ * @returns {Promise<InAppPurchase>}
208
+ */
209
+
210
+
211
+ exports.getAvailablePurchases = getAvailablePurchases;
212
+
213
+ const requestPurchase = _ref => {
214
+ let {
215
+ sku,
216
+ andDangerouslyFinishTransactionAutomaticallyIOS = false,
217
+ obfuscatedAccountIdAndroid,
218
+ obfuscatedProfileIdAndroid,
219
+ applicationUsername
220
+ } = _ref;
221
+ return (_reactNative.Platform.select({
222
+ ios: async () => {
223
+ if (andDangerouslyFinishTransactionAutomaticallyIOS) {
224
+ console.warn('You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.');
225
+ }
226
+
227
+ return getIosModule().buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, applicationUsername);
228
+ },
229
+ android: async () => {
230
+ return getAndroidModule().buyItemByType(ANDROID_ITEM_TYPE_IAP, sku, null, 0, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid);
231
+ }
232
+ }) || Promise.resolve)();
233
+ };
234
+ /**
235
+ * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
236
+ * @param {string} [sku] The product's sku/ID
237
+ * @param {string} [applicationUsername] The purchaser's user ID
238
+ * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.
239
+ * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).
240
+ * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED
241
+ * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
242
+ * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
243
+ * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise
244
+ */
245
+
246
+
247
+ exports.requestPurchase = requestPurchase;
248
+
249
+ const requestSubscription = _ref2 => {
250
+ let {
251
+ sku,
252
+ andDangerouslyFinishTransactionAutomaticallyIOS = false,
253
+ purchaseTokenAndroid,
254
+ prorationModeAndroid = -1,
255
+ obfuscatedAccountIdAndroid,
256
+ obfuscatedProfileIdAndroid,
257
+ applicationUsername
258
+ } = _ref2;
259
+ return (_reactNative.Platform.select({
260
+ ios: async () => {
261
+ if (andDangerouslyFinishTransactionAutomaticallyIOS) {
262
+ console.warn('You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.');
263
+ }
264
+
265
+ return getIosModule().buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, applicationUsername);
266
+ },
267
+ android: async () => {
268
+ return getAndroidModule().buyItemByType(ANDROID_ITEM_TYPE_SUBSCRIPTION, sku, purchaseTokenAndroid, prorationModeAndroid, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid);
269
+ }
270
+ }) || Promise.resolve)();
271
+ };
272
+ /**
273
+ * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
274
+ * @param {string} sku The product's sku/ID
275
+ * @returns {Promise<void>}
276
+ */
277
+
278
+
279
+ exports.requestSubscription = requestSubscription;
280
+
281
+ const requestPurchaseWithQuantityIOS = (sku, quantity) => getIosModule().buyProductWithQuantityIOS(sku, quantity);
282
+ /**
283
+ * Finish Transaction (both platforms)
284
+ * Abstracts Finish Transaction
285
+ * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.
286
+ * Call this after you have persisted the purchased state to your server or local data in your app.
287
+ * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**
288
+ * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.
289
+ * @param {object} purchase The purchase that you would like to finish.
290
+ * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.
291
+ * @param {string} developerPayloadAndroid Android developerPayload.
292
+ * @returns {Promise<string | void> }
293
+ */
294
+
295
+
296
+ exports.requestPurchaseWithQuantityIOS = requestPurchaseWithQuantityIOS;
297
+
298
+ const finishTransaction = (purchase, isConsumable, developerPayloadAndroid) => {
299
+ return (_reactNative.Platform.select({
300
+ ios: async () => {
301
+ return getIosModule().finishTransaction(purchase.transactionId);
302
+ },
303
+ android: async () => {
304
+ if (purchase) {
305
+ if (isConsumable) {
306
+ return getAndroidModule().consumeProduct(purchase.purchaseToken, developerPayloadAndroid);
307
+ } else if (purchase.userIdAmazon || !purchase.isAcknowledgedAndroid && purchase.purchaseStateAndroid === _types.PurchaseStateAndroid.PURCHASED) {
308
+ return getAndroidModule().acknowledgePurchase(purchase.purchaseToken, developerPayloadAndroid);
309
+ } else {
310
+ throw new Error('purchase is not suitable to be purchased');
311
+ }
312
+ } else {
313
+ throw new Error('purchase is not assigned');
314
+ }
315
+ }
316
+ }) || Promise.resolve)();
317
+ };
318
+ /**
319
+ * Clear Transaction (iOS only)
320
+ * Finish remaining transactions. Related to issue #257 and #801
321
+ * link : https://github.com/dooboolab/react-native-iap/issues/257
322
+ * https://github.com/dooboolab/react-native-iap/issues/801
323
+ * @returns {Promise<void>}
324
+ */
325
+
326
+
327
+ exports.finishTransaction = finishTransaction;
328
+
329
+ const clearTransactionIOS = () => getIosModule().clearTransaction();
330
+ /**
331
+ * Clear valid Products (iOS only)
332
+ * Remove all products which are validated by Apple server.
333
+ * @returns {void}
334
+ */
335
+
336
+
337
+ exports.clearTransactionIOS = clearTransactionIOS;
338
+
339
+ const clearProductsIOS = () => getIosModule().clearProducts();
340
+ /**
341
+ * Acknowledge a product (on Android.) No-op on iOS.
342
+ * @param {string} token The product's token (on Android)
343
+ * @returns {Promise<PurchaseResult | void>}
344
+ */
345
+
346
+
347
+ exports.clearProductsIOS = clearProductsIOS;
348
+
349
+ const acknowledgePurchaseAndroid = (token, developerPayload) => {
350
+ return getAndroidModule().acknowledgePurchase(token, developerPayload);
351
+ };
352
+ /**
353
+ * Deep link to subscriptions screen on Android. No-op on iOS.
354
+ * @param {string} sku The product's SKU (on Android)
355
+ * @returns {Promise<void>}
356
+ */
357
+
358
+
359
+ exports.acknowledgePurchaseAndroid = acknowledgePurchaseAndroid;
360
+
361
+ const deepLinkToSubscriptionsAndroid = async sku => {
362
+ checkNativeAndroidAvailable();
363
+ return _reactNative.Linking.openURL(`https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`);
364
+ };
365
+ /**
366
+ * Should Add Store Payment (iOS only)
367
+ * Indicates the the App Store purchase should continue from the app instead of the App Store.
368
+ * @returns {Promise<Product | null>} promoted product
369
+ */
370
+
371
+
372
+ exports.deepLinkToSubscriptionsAndroid = deepLinkToSubscriptionsAndroid;
373
+
374
+ const getPromotedProductIOS = () => getIosModule().promotedProduct();
375
+ /**
376
+ * Buy the currently selected promoted product (iOS only)
377
+ * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.
378
+ * @returns {Promise<void>}
379
+ */
380
+
381
+
382
+ exports.getPromotedProductIOS = getPromotedProductIOS;
383
+
384
+ const buyPromotedProductIOS = () => getIosModule().buyPromotedProduct();
385
+
386
+ exports.buyPromotedProductIOS = buyPromotedProductIOS;
387
+
388
+ const fetchJsonOrThrow = async (url, receiptBody) => {
389
+ const response = await fetch(url, {
390
+ method: 'POST',
391
+ headers: {
392
+ Accept: 'application/json',
393
+ 'Content-Type': 'application/json'
394
+ },
395
+ body: JSON.stringify(receiptBody)
396
+ });
397
+
398
+ if (!response.ok) {
399
+ throw Object.assign(new Error(response.statusText), {
400
+ statusCode: response.status
401
+ });
402
+ }
403
+
404
+ return response.json();
405
+ };
406
+
407
+ const requestAgnosticReceiptValidationIos = async receiptBody => {
408
+ const response = await fetchJsonOrThrow('https://buy.itunes.apple.com/verifyReceipt', receiptBody); // Best practice is to check for test receipt and check sandbox instead
409
+ // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt
410
+
411
+ if (response && response.status === _apple.ReceiptValidationStatus.TEST_RECEIPT) {
412
+ const testResponse = await fetchJsonOrThrow('https://sandbox.itunes.apple.com/verifyReceipt', receiptBody);
413
+ return testResponse;
414
+ }
415
+
416
+ return response;
417
+ };
418
+ /**
419
+ * Buy products or subscriptions with offers (iOS only)
420
+ *
421
+ * Runs the payment process with some info you must fetch
422
+ * from your server.
423
+ * @param {string} sku The product identifier
424
+ * @param {string} forUser An user identifier on you system
425
+ * @param {Apple.PaymentDiscount} withOffer The offer information
426
+ * @param {string} withOffer.identifier The offer identifier
427
+ * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature
428
+ * @param {string} withOffer.nonce An UUID returned from the server
429
+ * @param {string} withOffer.signature The actual signature returned from the server
430
+ * @param {number} withOffer.timestamp The timestamp of the signature
431
+ * @returns {Promise<void>}
432
+ */
433
+
434
+
435
+ const requestPurchaseWithOfferIOS = (sku, forUser, withOffer) => getIosModule().buyProductWithOffer(sku, forUser, withOffer);
436
+ /**
437
+ * Validate receipt for iOS.
438
+ * @param {object} receiptBody the receipt body to send to apple server.
439
+ * @param {boolean} isTest whether this is in test environment which is sandbox.
440
+ * @returns {Promise<Apple.ReceiptValidationResponse | false>}
441
+ */
442
+
443
+
444
+ exports.requestPurchaseWithOfferIOS = requestPurchaseWithOfferIOS;
445
+
446
+ const validateReceiptIos = async (receiptBody, isTest) => {
447
+ if (isTest == null) {
448
+ return await requestAgnosticReceiptValidationIos(receiptBody);
449
+ }
450
+
451
+ const url = isTest ? 'https://sandbox.itunes.apple.com/verifyReceipt' : 'https://buy.itunes.apple.com/verifyReceipt';
452
+ const response = await fetchJsonOrThrow(url, receiptBody);
453
+ return response;
454
+ };
455
+ /**
456
+ * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including
457
+ * your access token in the binary you ship to users is potentially dangerous.
458
+ * Use server side validation instead for your production builds
459
+ * @param {string} packageName package name of your app.
460
+ * @param {string} productId product id for your in app product.
461
+ * @param {string} productToken token for your purchase.
462
+ * @param {string} accessToken accessToken from googleApis.
463
+ * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.
464
+ * @returns {Promise<object>}
465
+ */
466
+
467
+
468
+ exports.validateReceiptIos = validateReceiptIos;
469
+
470
+ const validateReceiptAndroid = async (packageName, productId, productToken, accessToken, isSub) => {
471
+ const type = isSub ? 'subscriptions' : 'products';
472
+ const url = 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' + `/${packageName}/purchases/${type}/${productId}` + `/tokens/${productToken}?access_token=${accessToken}`;
473
+ const response = await fetch(url, {
474
+ method: 'GET',
475
+ headers: {
476
+ 'Content-Type': 'application/json'
477
+ }
478
+ });
479
+
480
+ if (!response.ok) {
481
+ throw Object.assign(new Error(response.statusText), {
482
+ statusCode: response.status
483
+ });
484
+ }
485
+
486
+ return response.json();
487
+ };
488
+ /**
489
+ * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including
490
+ * your developer secret in the binary you ship to users is potentially dangerous.
491
+ * Use server side validation instead for your production builds
492
+ * @param {string} developerSecret: from the Amazon developer console.
493
+ * @param {string} userId who purchased the item.
494
+ * @param {string} receiptId long obfuscated string returned when purchasing the item
495
+ * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.
496
+ * @returns {Promise<object>}
497
+ */
498
+
499
+
500
+ exports.validateReceiptAndroid = validateReceiptAndroid;
501
+
502
+ const validateReceiptAmazon = async function (developerSecret, userId, receiptId) {
503
+ let useSandbox = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : true;
504
+ const sandBoxUrl = useSandbox ? 'sandbox/' : '';
505
+ const url = `https://appstore-sdk.amazon.com/${sandBoxUrl}version/1.0/verifyReceiptId/developer/${developerSecret}/user/${userId}/receiptId/${receiptId}`;
506
+ const response = await fetch(url, {
507
+ method: 'GET',
508
+ headers: {
509
+ 'Content-Type': 'application/json'
510
+ }
511
+ });
512
+
513
+ if (!response.ok) {
514
+ throw Object.assign(new Error(response.statusText), {
515
+ statusCode: response.status
516
+ });
517
+ }
518
+
519
+ return response.json();
520
+ };
521
+ /**
522
+ * Add IAP purchase event
523
+ * @returns {callback(e: InAppPurchase | ProductPurchase)}
524
+ */
525
+
526
+
527
+ exports.validateReceiptAmazon = validateReceiptAmazon;
528
+
529
+ const purchaseUpdatedListener = listener => {
530
+ const emitterSubscription = new _reactNative.NativeEventEmitter(getNativeModule()).addListener('purchase-updated', listener);
531
+
532
+ if (isAndroid) {
533
+ getAndroidModule().startListening();
534
+ }
535
+
536
+ return emitterSubscription;
537
+ };
538
+ /**
539
+ * Add IAP purchase error event
540
+ * @returns {callback(e: PurchaseError)}
541
+ */
542
+
543
+
544
+ exports.purchaseUpdatedListener = purchaseUpdatedListener;
545
+
546
+ const purchaseErrorListener = listener => new _reactNative.NativeEventEmitter(getNativeModule()).addListener('purchase-error', listener);
547
+ /**
548
+ * Add IAP promoted subscription event
549
+ * Only available on iOS
550
+ */
551
+
552
+
553
+ exports.purchaseErrorListener = purchaseErrorListener;
554
+
555
+ const promotedProductListener = listener => new _reactNative.NativeEventEmitter(getIosModule()).addListener('iap-promoted-product', listener);
556
+ /**
557
+ * Get the current receipt base64 encoded in IOS.
558
+ * @param {forceRefresh?:boolean}
559
+ * @returns {Promise<ProductPurchase[]>}
560
+ */
561
+
562
+
563
+ exports.promotedProductListener = promotedProductListener;
564
+
565
+ const getPendingPurchasesIOS = async () => getIosModule().getPendingTransactions();
566
+ /**
567
+ * Launches a modal to register the redeem offer code in IOS.
568
+ * @returns {Promise<null>}
569
+ */
570
+
571
+
572
+ exports.getPendingPurchasesIOS = getPendingPurchasesIOS;
573
+
574
+ const presentCodeRedemptionSheetIOS = async () => getIosModule().presentCodeRedemptionSheet();
575
+
576
+ exports.presentCodeRedemptionSheetIOS = presentCodeRedemptionSheetIOS;
577
+ //# sourceMappingURL=iap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"names":["RNIapIos","RNIapModule","RNIapAmazonModule","NativeModules","isAndroid","Platform","OS","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","getInstallSourceAndroid","InstallSourceAndroid","GOOGLE_PLAY","AMAZON","checkNativeAndroidAvailable","Error","IAPErrorCode","E_IAP_NOT_AVAILABLE","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","fillProductsAdditionalData","products","user","getUser","currencies","CA","ES","AU","DE","IN","US","JP","GB","IT","BR","FR","currency","userMarketplaceAmazon","forEach","product","getProducts","skus","select","ios","items","getItems","filter","item","includes","productId","type","android","getItemsByType","Promise","resolve","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","applicationUsername","console","warn","buyProduct","buyItemByType","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","consumeProduct","purchaseToken","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PurchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","Linking","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","fetchJsonOrThrow","url","receiptBody","response","fetch","method","headers","Accept","body","JSON","stringify","ok","Object","assign","statusText","statusCode","status","json","requestAgnosticReceiptValidationIos","ReceiptValidationStatus","TEST_RECEIPT","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","purchaseUpdatedListener","listener","emitterSubscription","NativeEventEmitter","addListener","startListening","purchaseErrorListener","promotedProductListener","getPendingPurchasesIOS","getPendingTransactions","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {\n EmitterSubscription,\n Linking,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} from 'react-native';\n\nimport type * as Amazon from './types/amazon';\nimport type * as Android from './types/android';\nimport type * as Apple from './types/apple';\nimport {ReceiptValidationStatus} from './types/apple';\nimport type {\n InAppPurchase,\n Product,\n ProductCommon,\n ProductPurchase,\n PurchaseError,\n PurchaseResult,\n RequestPurchase,\n RequestSubscription,\n Subscription,\n SubscriptionPurchase,\n} from './types';\nimport {\n IAPErrorCode,\n InstallSourceAndroid,\n PurchaseStateAndroid,\n} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst isAndroid = Platform.OS === 'android';\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getAndroidModule = (): typeof RNIapModule | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return RNIapModule ? RNIapModule : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nconst getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n if (isAndroid) {\n return getAndroidModule();\n }\n\n return getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<void> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid = (): Promise<\n string[]\n> => getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Fill products with additional data\n * @param {Array<ProductCommon>} products Products\n */\nconst fillProductsAdditionalData = async (\n products: Array<ProductCommon>,\n): Promise<Array<ProductCommon>> => {\n // Amazon\n if (RNIapAmazonModule) {\n // On amazon we must get the user marketplace to detect the currency\n const user = await RNIapAmazonModule.getUser();\n\n const currencies = {\n CA: 'CAD',\n ES: 'EUR',\n AU: 'AUD',\n DE: 'EUR',\n IN: 'INR',\n US: 'USD',\n JP: 'JPY',\n GB: 'GBP',\n IT: 'EUR',\n BR: 'BRL',\n FR: 'EUR',\n };\n\n const currency =\n currencies[user.userMarketplaceAmazon as keyof typeof currencies];\n\n // Add currency to products\n products.forEach((product) => {\n if (currency) {\n product.currency = currency;\n }\n });\n }\n\n return products;\n};\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n * @param {string[]} skus The item skus\n * @returns {Promise<Product[]>}\n */\nexport const getProducts = (skus: string[]): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Product) =>\n skus.includes(item.productId) && item.type === 'iap',\n );\n },\n android: async () => {\n const products = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n skus,\n );\n\n return fillProductsAdditionalData(products);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get a list of subscriptions\n * @param {string[]} skus The item skus\n * @returns {Promise<Subscription[]>}\n */\nexport const getSubscriptions = (skus: string[]): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Subscription) =>\n skus.includes(item.productId) && item.type === 'subs',\n );\n },\n android: async () => {\n const subscriptions = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n );\n\n return fillProductsAdditionalData(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * @returns {Promise<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (InAppPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)\n * @returns {Promise<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (InAppPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @returns {Promise<InAppPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestPurchase): Promise<InAppPurchase> =>\n (\n Platform.select({\n ios: async () => {\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n sku,\n null,\n 0,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n );\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestSubscription): Promise<SubscriptionPurchase | null> =>\n (\n Platform.select({\n ios: async () => {\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n sku,\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n );\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = (\n sku: string,\n quantity: number,\n): Promise<InAppPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\n\n/**\n * Finish Transaction (both platforms)\n * Abstracts Finish Transaction\n * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.\n * Call this after you have persisted the purchased state to your server or local data in your app.\n * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**\n * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.\n * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = (\n purchase: InAppPurchase | ProductPurchase,\n isConsumable?: boolean,\n developerPayloadAndroid?: string,\n): Promise<string | void> => {\n return (\n Platform.select({\n ios: async () => {\n return getIosModule().finishTransaction(purchase.transactionId);\n },\n android: async () => {\n if (purchase) {\n if (isConsumable) {\n return getAndroidModule().consumeProduct(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else if (\n purchase.userIdAmazon ||\n (!purchase.isAcknowledgedAndroid &&\n purchase.purchaseStateAndroid === PurchaseStateAndroid.PURCHASED)\n ) {\n return getAndroidModule().acknowledgePurchase(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else {\n throw new Error('purchase is not suitable to be purchased');\n }\n } else {\n throw new Error('purchase is not assigned');\n }\n },\n }) || Promise.resolve\n )();\n};\n\n/**\n * Clear Transaction (iOS only)\n * Finish remaining transactions. Related to issue #257 and #801\n * link : https://github.com/dooboolab/react-native-iap/issues/257\n * https://github.com/dooboolab/react-native-iap/issues/801\n * @returns {Promise<void>}\n */\nexport const clearTransactionIOS = (): Promise<void> =>\n getIosModule().clearTransaction();\n\n/**\n * Clear valid Products (iOS only)\n * Remove all products which are validated by Apple server.\n * @returns {void}\n */\nexport const clearProductsIOS = (): Promise<void> =>\n getIosModule().clearProducts();\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = (\n token: string,\n developerPayload?: string,\n): Promise<PurchaseResult | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async (\n sku: string,\n): Promise<void> => {\n checkNativeAndroidAvailable();\n\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\n\n/**\n * Buy the currently selected promoted product (iOS only)\n * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.\n * @returns {Promise<void>}\n */\nexport const buyPromotedProductIOS = (): Promise<void> =>\n getIosModule().buyPromotedProduct();\n\nconst fetchJsonOrThrow = async (\n url: string,\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(receiptBody),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetchJsonOrThrow(\n 'https://buy.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === ReceiptValidationStatus.TEST_RECEIPT) {\n const testResponse = await fetchJsonOrThrow(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = (\n sku: string,\n forUser: string,\n withOffer: Apple.PaymentDiscount,\n): Promise<void> => getIosModule().buyProductWithOffer(sku, forUser, withOffer);\n\n/**\n * Validate receipt for iOS.\n * @param {object} receiptBody the receipt body to send to apple server.\n * @param {boolean} isTest whether this is in test environment which is sandbox.\n * @returns {Promise<Apple.ReceiptValidationResponse | false>}\n */\nexport const validateReceiptIos = async (\n receiptBody: Record<string, unknown>,\n isTest?: boolean,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n const response = await fetchJsonOrThrow(url, receiptBody);\n\n return response;\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} packageName package name of your app.\n * @param {string} productId product id for your in app product.\n * @param {string} productToken token for your purchase.\n * @param {string} accessToken accessToken from googleApis.\n * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAndroid = async (\n packageName: string,\n productId: string,\n productToken: string,\n accessToken: string,\n isSub?: boolean,\n): Promise<Android.ReceiptType> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}?access_token=${accessToken}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including\n * your developer secret in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} developerSecret: from the Amazon developer console.\n * @param {string} userId who purchased the item.\n * @param {string} receiptId long obfuscated string returned when purchasing the item\n * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAmazon = async (\n developerSecret: string,\n userId: string,\n receiptId: string,\n useSandbox: boolean = true,\n): Promise<Amazon.ReceiptType> => {\n const sandBoxUrl = useSandbox ? 'sandbox/' : '';\n const url = `https://appstore-sdk.amazon.com/${sandBoxUrl}version/1.0/verifyReceiptId/developer/${developerSecret}/user/${userId}/receiptId/${receiptId}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Add IAP purchase event\n * @returns {callback(e: InAppPurchase | ProductPurchase)}\n */\nexport const purchaseUpdatedListener = (\n listener: (event: InAppPurchase | SubscriptionPurchase) => void,\n): EmitterSubscription => {\n const emitterSubscription = new NativeEventEmitter(\n getNativeModule(),\n ).addListener('purchase-updated', listener);\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n * @returns {callback(e: PurchaseError)}\n */\nexport const purchaseErrorListener = (\n listener: (errorEvent: PurchaseError) => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getNativeModule()).addListener(\n 'purchase-error',\n listener,\n );\n\n/**\n * Add IAP promoted subscription event\n * Only available on iOS\n */\nexport const promotedProductListener = (\n listener: () => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getIosModule()).addListener(\n 'iap-promoted-product',\n listener,\n );\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":";;;;;;;AAAA;;AAWA;;AAaA;;AAMA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CC,0BAAnD;AACA,MAAMC,SAAS,GAAGC,qBAAA,CAASC,EAAT,KAAgB,SAAlC;AACA,MAAMC,8BAA8B,GAAG,MAAvC;AACA,MAAMC,qBAAqB,GAAG,OAA9B;;AAEO,MAAMC,uBAAuB,GAAG,MAA4B;EACjE,OAAOR,WAAW,GACdS,2BAAA,CAAqBC,WADP,GAEdD,2BAAA,CAAqBE,MAFzB;AAGD,CAJM;;;;AAMP,MAAMC,2BAA2B,GAAG,MAAY;EAC9C,IAAI,CAACZ,WAAD,IAAgB,CAACC,iBAArB,EAAwC;IACtC,MAAM,IAAIY,KAAJ,CAAUC,mBAAA,CAAaC,mBAAvB,CAAN;EACD;AACF,CAJD;;AAMA,MAAMC,gBAAgB,GAAG,MAAqD;EAC5EJ,2BAA2B;EAE3B,OAAOZ,WAAW,GAAGA,WAAH,GAAiBC,iBAAnC;AACD,CAJD;;AAMA,MAAMgB,uBAAuB,GAAG,MAAY;EAC1C,IAAI,CAAClB,QAAL,EAAe;IACb,MAAM,IAA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