react-native-iap 10.1.0 → 10.1.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -19,7 +19,6 @@ Read the [documentation](https://react-native-iap.dooboolab.com). See the [troub
19
19
  Please [fund the project](https://opencollective.com/react-native-iap) if you are willing the maintainers to make the repository sustainable.
20
20
 
21
21
  - [andresesfm](https://github.com/andresesfm)
22
- - [jeremybarbet](https://github.com/jeremybarbet)
23
22
 
24
23
  > The fund goes to maintainers.
25
24
 
@@ -63,7 +63,21 @@ const getNativeModule = () => {
63
63
  };
64
64
  /**
65
65
  * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.
66
- * @returns {Promise<boolean>}
66
+ * ## Usage
67
+
68
+ ```tsx
69
+ import React, {useEffect} from 'react';
70
+ import {View} from 'react-native';
71
+ import {initConnection} from 'react-native-iap';
72
+
73
+ const App = () => {
74
+ useEffect(() => {
75
+ void initConnection();
76
+ }, []);
77
+
78
+ return <View />;
79
+ };
80
+ ```
67
81
  */
68
82
 
69
83
 
@@ -71,7 +85,23 @@ exports.getNativeModule = getNativeModule;
71
85
 
72
86
  const initConnection = () => getNativeModule().initConnection();
73
87
  /**
74
- * End module for purchase flow.
88
+ * Disconnects from native SDK
89
+ * Usage
90
+ * ```tsx
91
+ import React, {useEffect} from 'react';
92
+ import {View} from 'react-native';
93
+ import {endConnection} from 'react-native-iap';
94
+
95
+ const App = () => {
96
+ useEffect(() => {
97
+ return () => {
98
+ void endConnection();
99
+ };
100
+ }, []);
101
+
102
+ return <View />;
103
+ };
104
+ ```
75
105
  * @returns {Promise<void>}
76
106
  */
77
107
 
@@ -90,8 +120,47 @@ exports.endConnection = endConnection;
90
120
  const flushFailedPurchasesCachedAsPendingAndroid = () => getAndroidModule().flushFailedPurchasesCachedAsPending();
91
121
  /**
92
122
  * Get a list of products (consumable and non-consumable items, but not subscriptions)
93
- * @param {string[]} skus The item skus
94
- * @returns {Promise<Product[]>}
123
+ ## Usage
124
+
125
+ ```ts
126
+ import React, {useState} from 'react';
127
+ import {Platform} from 'react-native';
128
+ import {getProducts, Product} from 'react-native-iap';
129
+
130
+ const skus = Platform.select({
131
+ ios: ['com.example.consumableIos'],
132
+ android: ['com.example.consumableAndroid'],
133
+ });
134
+
135
+ const App = () => {
136
+ const [products, setProducts] = useState<Product[]>([]);
137
+
138
+ const handleProducts = async () => {
139
+ const items = await getProducts({skus});
140
+
141
+ setProducts(items);
142
+ };
143
+
144
+ useEffect(() => {
145
+ void handleProducts();
146
+ }, []);
147
+
148
+ return (
149
+ <>
150
+ {products.map((product) => (
151
+ <Text key={product.productId}>{product.productId}</Text>
152
+ ))}
153
+ </>
154
+ );
155
+ };
156
+ ```
157
+
158
+ Just a few things to keep in mind:
159
+
160
+ - You can get your products in `componentDidMount`, `useEffect` or another appropriate area of your app.
161
+ - Since a user may start your app with a bad or no internet connection, preparing/getting the items more than once may be a good idea.
162
+ - If the user has no IAPs available when the app starts first, you may want to check again when the user enters your IAP store.
163
+
95
164
  */
96
165
 
97
166
 
@@ -114,8 +183,24 @@ const getProducts = _ref => {
114
183
  };
115
184
  /**
116
185
  * Get a list of subscriptions
117
- * @param {string[]} skus The item skus
118
- * @returns {Promise<Subscription[]>}
186
+ * ## Usage
187
+
188
+ ```tsx
189
+ import React, {useCallback} from 'react';
190
+ import {View} from 'react-native';
191
+ import {getSubscriptions} from 'react-native-iap';
192
+
193
+ const App = () => {
194
+ const subscriptions = useCallback(
195
+ async () =>
196
+ await getSubscriptions(['com.example.product1', 'com.example.product2']),
197
+ [],
198
+ );
199
+
200
+ return <View />;
201
+ };
202
+ ```
203
+
119
204
  */
120
205
 
121
206
 
@@ -138,7 +223,26 @@ const getSubscriptions = _ref2 => {
138
223
  };
139
224
  /**
140
225
  * Gets an inventory of purchases made by the user regardless of consumption status
141
- * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}
226
+ * ## Usage
227
+
228
+ ```tsx
229
+ import React, {useCallback} from 'react';
230
+ import {View} from 'react-native';
231
+ import {getPurchaseHistory} from 'react-native-iap';
232
+
233
+ const App = () => {
234
+ const history = useCallback(
235
+ async () =>
236
+ await getPurchaseHistory([
237
+ 'com.example.product1',
238
+ 'com.example.product2',
239
+ ]),
240
+ [],
241
+ );
242
+
243
+ return <View />;
244
+ };
245
+ ```
142
246
  */
143
247
 
144
248
 
@@ -160,7 +264,81 @@ const getPurchaseHistory = () => (_reactNative.Platform.select({
160
264
  }) || (() => Promise.resolve([])))();
161
265
  /**
162
266
  * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)
163
- * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}
267
+ * ## Usage
268
+
269
+ ```tsx
270
+ import React, {useCallback} from 'react';
271
+ import {View} from 'react-native';
272
+ import {getAvailablePurchases} from 'react-native-iap';
273
+
274
+ const App = () => {
275
+ const availablePurchases = useCallback(
276
+ async () => await getAvailablePurchases(),
277
+ [],
278
+ );
279
+
280
+ return <View />;
281
+ };
282
+ ```
283
+
284
+ ## Restoring purchases
285
+
286
+ You can use `getAvailablePurchases()` to do what's commonly understood as "restoring" purchases.
287
+
288
+ :::note
289
+ For debugging you may want to consume all items, you have then to iterate over the purchases returned by `getAvailablePurchases()`.
290
+ :::
291
+
292
+ :::warning
293
+ Beware that if you consume an item without having recorded the purchase in your database the user may have paid for something without getting it delivered and you will have no way to recover the receipt to validate and restore their purchase.
294
+ :::
295
+
296
+ ```tsx
297
+ import React from 'react';
298
+ import {Button} from 'react-native';
299
+ import {getAvailablePurchases,finishTransaction} from 'react-native-iap';
300
+
301
+ const App = () => {
302
+ handleRestore = async () => {
303
+ try {
304
+ const purchases = await getAvailablePurchases();
305
+ const newState = {premium: false, ads: true};
306
+ let titles = [];
307
+
308
+ await Promise.all(purchases.map(async purchase => {
309
+ switch (purchase.productId) {
310
+ case 'com.example.premium':
311
+ newState.premium = true;
312
+ titles.push('Premium Version');
313
+ break;
314
+
315
+ case 'com.example.no_ads':
316
+ newState.ads = false;
317
+ titles.push('No Ads');
318
+ break;
319
+
320
+ case 'com.example.coins100':
321
+ await finishTransaction(purchase.purchaseToken);
322
+ CoinStore.addCoins(100);
323
+ }
324
+ })
325
+
326
+ Alert.alert(
327
+ 'Restore Successful',
328
+ `You successfully restored the following purchases: ${titles.join(', ')}`,
329
+ );
330
+ } catch (error) {
331
+ console.warn(error);
332
+ Alert.alert(error.message);
333
+ }
334
+ };
335
+
336
+ return (
337
+ <Button title="Restore purchases" onPress={handleRestore} />
338
+ )
339
+ };
340
+ ```
341
+ *
164
342
  */
165
343
 
166
344
 
@@ -182,14 +360,70 @@ const getAvailablePurchases = () => (_reactNative.Platform.select({
182
360
  }) || (() => Promise.resolve([])))();
183
361
  /**
184
362
  * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
185
- * @param {string} sku The product's sku/ID
186
- * @param {string} [applicationUsername] The purchaser's user ID
187
- * @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.
188
- * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
189
- * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
190
- * @param {string[]} [skus] Product Ids to purchase. Note that this is only for Android. iOS only uses a single SKU. If not provided, it'll default to using [sku] for backward-compatibility
191
- * @param {boolean} [isOfferPersonalized] Defaults to false, Only for Android V5
192
- * @returns {Promise<ProductPurchase>}
363
+ * Request a purchase for a product (consumables or non-consumables).
364
+
365
+ The response will be received through the `PurchaseUpdatedListener`.
366
+
367
+ :::note
368
+ `andDangerouslyFinishTransactionAutomatically` defaults to false. We recommend
369
+ always keeping at false, and verifying the transaction receipts on the server-side.
370
+ :::
371
+
372
+ ## Signature
373
+
374
+ ```ts
375
+ requestPurchase(
376
+ The product's sku/ID
377
+ sku,
378
+
379
+
380
+ * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.
381
+ * @default false
382
+
383
+ andDangerouslyFinishTransactionAutomaticallyIOS = false,
384
+
385
+ /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
386
+ obfuscatedAccountIdAndroid,
387
+
388
+ Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
389
+ obfuscatedProfileIdAndroid,
390
+
391
+ The purchaser's user ID
392
+ applicationUsername,
393
+ ): Promise<ProductPurchase>;
394
+ ```
395
+
396
+ ## Usage
397
+
398
+ ```tsx
399
+ import React, {useCallback} from 'react';
400
+ import {Button} from 'react-native';
401
+ import {requestPurchase, Product, Sku, getProducts} from 'react-native-iap';
402
+
403
+ const App = () => {
404
+ const products = useCallback(
405
+ async () => getProducts(['com.example.product']),
406
+ [],
407
+ );
408
+
409
+ const handlePurchase = async (sku: Sku) => {
410
+ await requestPurchase({sku});
411
+ };
412
+
413
+ return (
414
+ <>
415
+ {products.map((product) => (
416
+ <Button
417
+ key={product.productId}
418
+ title="Buy product"
419
+ onPress={() => handlePurchase(product.productId)}
420
+ />
421
+ ))}
422
+ </>
423
+ );
424
+ };
425
+ ```
426
+
193
427
  */
194
428
 
195
429
 
@@ -236,15 +470,80 @@ const requestPurchase = _ref3 => {
236
470
  };
237
471
  /**
238
472
  * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
239
- * @param {string} [sku] The product's sku/ID
240
- * @param {string} [applicationUsername] The purchaser's user ID
241
- * @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.
242
- * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).
243
- * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED
244
- * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
245
- * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
246
- * @param {SubscriptionOffers[]} [subscriptionOffers] Array of SubscriptionOffers. Every sku must be paired with a corresponding offerToken
247
- * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise
473
+ * Request a purchase for a subscription.
474
+
475
+ The response will be received through the `PurchaseUpdatedListener`.
476
+
477
+ :::note
478
+ `andDangerouslyFinishTransactionAutomatically` defaults to false. We recommend
479
+ always keeping at false, and verifying the transaction receipts on the server-side.
480
+ :::
481
+
482
+ ## Signature
483
+
484
+ ```ts
485
+ requestSubscription(
486
+ The product's sku/ID
487
+ sku,
488
+
489
+
490
+ * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.
491
+ * @default false
492
+
493
+ andDangerouslyFinishTransactionAutomaticallyIOS = false,
494
+
495
+ purchaseToken that the user is upgrading or downgrading from (Android).
496
+ purchaseTokenAndroid,
497
+
498
+ UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED
499
+ prorationModeAndroid = -1,
500
+
501
+ /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
502
+ obfuscatedAccountIdAndroid,
503
+
504
+ Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
505
+ obfuscatedProfileIdAndroid,
506
+
507
+ The purchaser's user ID
508
+ applicationUsername,
509
+ ): Promise<SubscriptionPurchase>
510
+ ```
511
+
512
+ ## Usage
513
+
514
+ ```tsx
515
+ import React, {useCallback} from 'react';
516
+ import {Button} from 'react-native';
517
+ import {
518
+ requestSubscription,
519
+ Product,
520
+ Sku,
521
+ getSubscriptions,
522
+ } from 'react-native-iap';
523
+
524
+ const App = () => {
525
+ const subscriptions = useCallback(
526
+ async () => getSubscriptions(['com.example.subscription']),
527
+ [],
528
+ );
529
+
530
+ const handlePurchase = async (sku: Sku) => {
531
+ await requestSubscription({sku});
532
+ };
533
+
534
+ return (
535
+ <>
536
+ {subscriptions.map((subscription) => (
537
+ <Button
538
+ key={subscription.productId}
539
+ title="Buy subscription"
540
+ onPress={() => handlePurchase(subscription.productId)}
541
+ />
542
+ ))}
543
+ </>
544
+ );
545
+ };
546
+ ```
248
547
  */
249
548
 
250
549
 
@@ -314,10 +613,22 @@ const requestPurchaseWithQuantityIOS = _ref5 => {
314
613
  * Call this after you have persisted the purchased state to your server or local data in your app.
315
614
  * `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.**
316
615
  * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.
317
- * @param {object} purchase The purchase that you would like to finish.
318
- * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.
319
- * @param {string} developerPayloadAndroid Android developerPayload.
320
- * @returns {Promise<string | void> }
616
+ *
617
+ ```tsx
618
+ import React from 'react';
619
+ import {Button} from 'react-native';
620
+ import {finishTransaction} from 'react-native-iap';
621
+
622
+ const App = () => {
623
+ const handlePurchase = async () => {
624
+ // ... handle the purchase request
625
+
626
+ const result = finishTransaction(purchase);
627
+ };
628
+
629
+ return <Button title="Buy product" onPress={handlePurchase} />;
630
+ };
631
+ ```
321
632
  */
322
633
 
323
634
 
@@ -495,7 +806,10 @@ const validateReceiptIos = async _ref10 => {
495
806
  }
496
807
 
497
808
  const url = isTest ? 'https://sandbox.itunes.apple.com/verifyReceipt' : 'https://buy.itunes.apple.com/verifyReceipt';
498
- return await (0, _internal.enhancedFetch)(url);
809
+ return await (0, _internal.enhancedFetch)(url, {
810
+ method: 'POST',
811
+ body: receiptBody
812
+ });
499
813
  };
500
814
  /**
501
815
  * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including
@@ -1 +1 @@
1
- {"version":3,"names":["RNIapIos","RNIapModule","RNIapAmazonModule","NativeModules","ANDROID_ITEM_TYPE_SUBSCRIPTION","ProductType","subs","ANDROID_ITEM_TYPE_IAP","inapp","getInstallSourceAndroid","InstallSourceAndroid","GOOGLE_PLAY","AMAZON","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","isAndroid","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","Platform","select","ios","items","getItems","filter","item","includes","productId","type","android","products","getItemsByType","fillProductsWithAdditionalData","Promise","reject","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","resolve","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","applicationUsername","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","isOfferPersonalized","console","warn","buyProduct","isAmazon","buyItemByType","length","undefined","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","map","so","offerToken","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","purchaseToken","consumeProduct","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PurchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","Linking","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","TEST_RECEIPT","requestAgnosticReceiptValidationIos","receiptBody","response","enhancedFetch","method","body","status","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","url","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {Linking, NativeModules, Platform} from 'react-native';\nimport type {ResponseBody as ReceiptValidationResponse} from '@jeremybarbet/apple-api-types';\n\nimport type * as Amazon from './types/amazon';\nimport type * as Android from './types/android';\nimport type * as Apple from './types/apple';\nimport {\n enhancedFetch,\n fillProductsWithAdditionalData,\n isAmazon,\n isAndroid,\n} from './internal';\nimport {\n Product,\n ProductPurchase,\n ProductType,\n ProrationModesAndroid,\n Purchase,\n PurchaseResult,\n Sku,\n Subscription,\n SubscriptionOffer,\n SubscriptionPurchase,\n} from './types';\nimport {InstallSourceAndroid, PurchaseStateAndroid} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = ProductType.subs;\nconst ANDROID_ITEM_TYPE_IAP = ProductType.inapp;\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getAndroidModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return androidNativeModule\n ? androidNativeModule\n : RNIapModule\n ? RNIapModule\n : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nexport const getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n return isAndroid ? getAndroidModule() : 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<boolean> =>\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 =\n (): Promise<boolean> =>\n getAndroidModule().flushFailedPurchasesCachedAsPending();\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 = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n const items = (await getIosModule().getItems(skus)) as Product[];\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 fillProductsWithAdditionalData(products);\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n\n/**\n * Get a list of subscriptions\n * @param {string[]} skus The item skus\n * @returns {Promise<Subscription[]>}\n */\nexport const getSubscriptions = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n const items = (await getIosModule().getItems(skus)) as Subscription[];\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 )) as Subscription[];\n\n return fillProductsWithAdditionalData(subscriptions);\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (ProductPurchase | 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 RNIapModule.getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.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<(ProductPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (ProductPurchase | 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 RNIapModule.getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.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 * @param {string[]} [skus] Product Ids to purchase. Note that this is only for Android. iOS only uses a single SKU. If not provided, it'll default to using [sku] for backward-compatibility\n * @param {boolean} [isOfferPersonalized] Defaults to false, Only for Android V5\n * @returns {Promise<ProductPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n skus,\n isOfferPersonalized,\n}: {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n /** For Google Play Billing Library 5 https://developer.android.com/google/play/billing/integrate#personalized-price */\n skus?: Sku[];\n isOfferPersonalized?: boolean;\n}): Promise<ProductPurchase | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!sku) {\n return Promise.reject(new Error('sku is required for iOS purchase'));\n }\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 if (isAmazon) {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for Amazon purchase'),\n );\n }\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!sku?.length && !sku) {\n return Promise.reject(\n new Error('skus is required for Android purchase'),\n );\n }\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n skus?.length ? skus : [sku],\n undefined,\n -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n [],\n isOfferPersonalized ?? false,\n );\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 * @param {SubscriptionOffers[]} [subscriptionOffers] Array of SubscriptionOffers. Every sku must be paired with a corresponding offerToken\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 applicationUsername,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n subscriptionOffers,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized = undefined,\n}: {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n /** For Google Play Billing Library 5 */\n subscriptionOffers?: SubscriptionOffer[];\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n /** For Google Play Billing Library 5 https://developer.android.com/google/play/billing/integrate#personalized-price */\n isOfferPersonalized?: boolean;\n}): Promise<SubscriptionPurchase | null | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for iOS subscription'),\n );\n }\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 if (isAmazon) {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for Amazon purchase'),\n );\n }\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!subscriptionOffers?.length) {\n return Promise.reject(\n 'subscriptionOffers are required for Google Play Subscriptions',\n );\n }\n return RNIapModule.buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n subscriptionOffers?.map((so) => so.sku),\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers?.map((so) => so.offerToken),\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || (() => Promise.resolve(null))\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,\n quantity,\n}: {\n sku: Sku;\n quantity: number;\n}): Promise<ProductPurchase> =>\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,\n isConsumable,\n developerPayloadAndroid,\n}: {\n purchase: ProductPurchase | ProductPurchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n}): Promise<PurchaseResult | boolean> => {\n return (\n Platform.select({\n ios: async () => {\n const transactionId = purchase.transactionId;\n\n if (!transactionId) {\n return Promise.reject(\n new Error('transactionId required to finish iOS transaction'),\n );\n }\n return getIosModule().finishTransaction(transactionId);\n },\n android: async () => {\n if (purchase?.purchaseToken) {\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 return Promise.reject(\n new Error('purchase is not suitable to be purchased'),\n );\n }\n }\n return Promise.reject(\n new Error('purchase is not suitable to be purchased'),\n );\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\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,\n developerPayload,\n}: {\n token: string;\n developerPayload?: string;\n}): Promise<PurchaseResult | boolean | 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,\n}: {\n sku: Sku;\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 TEST_RECEIPT = 21007;\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<ReceiptValidationResponse | false> => {\n const response = await enhancedFetch<ReceiptValidationResponse>(\n 'https://buy.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\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 === TEST_RECEIPT) {\n const testResponse = await enhancedFetch<ReceiptValidationResponse>(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\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,\n forUser,\n withOffer,\n}: {\n sku: Sku;\n forUser: string;\n withOffer: Apple.PaymentDiscount;\n}): Promise<Purchase> =>\n 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,\n isTest,\n}: {\n receiptBody: Record<string, unknown>;\n isTest?: boolean;\n}): Promise<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 return await enhancedFetch<ReceiptValidationResponse>(url);\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,\n productId,\n productToken,\n accessToken,\n isSub,\n}: {\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 return await enhancedFetch<Android.ReceiptType>(url);\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,\n userId,\n receiptId,\n useSandbox = true,\n}: {\n developerSecret: string;\n userId: string;\n receiptId: string;\n useSandbox: boolean;\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 return await enhancedFetch<Amazon.ReceiptType>(url);\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 * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async ({\n forceRefresh,\n}: {\n forceRefresh?: boolean;\n}): Promise<string> => getIosModule().requestReceipt(forceRefresh ?? false);\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;;AAMA;;AAMA;;AAcA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6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NIapIos","RNIapModule","RNIapAmazonModule","NativeModules","ANDROID_ITEM_TYPE_SUBSCRIPTION","ProductType","subs","ANDROID_ITEM_TYPE_IAP","inapp","getInstallSourceAndroid","InstallSourceAndroid","GOOGLE_PLAY","AMAZON","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","isAndroid","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","Platform","select","ios","items","getItems","filter","item","includes","productId","type","android","products","getItemsByType","fillProductsWithAdditionalData","Promise","reject","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","resolve","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","applicationUsername","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","isOfferPersonalized","console","warn","buyProduct","isAmazon","buyItemByType","length","undefined","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","map","so","offerToken","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","purchaseToken","consumeProduct","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PurchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","Linking","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","TEST_RECEIPT","requestAgnosticReceiptValidationIos","receiptBody","response","enhancedFetch","method","body","status","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","url","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {Linking, NativeModules, Platform} from 'react-native';\nimport type {ResponseBody as ReceiptValidationResponse} from '@jeremybarbet/apple-api-types';\n\nimport type * as Amazon from './types/amazon';\nimport type * as Android from './types/android';\nimport type * as Apple from './types/apple';\nimport {\n enhancedFetch,\n fillProductsWithAdditionalData,\n isAmazon,\n isAndroid,\n} from './internal';\nimport {\n Product,\n ProductPurchase,\n ProductType,\n Purchase,\n PurchaseResult,\n RequestPurchase,\n RequestSubscription,\n Sku,\n Subscription,\n SubscriptionPurchase,\n} from './types';\nimport {InstallSourceAndroid, PurchaseStateAndroid} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = ProductType.subs;\nconst ANDROID_ITEM_TYPE_IAP = ProductType.inapp;\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getAndroidModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return androidNativeModule\n ? androidNativeModule\n : RNIapModule\n ? RNIapModule\n : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nexport const getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * ## Usage\n\n```tsx\nimport React, {useEffect} from 'react';\nimport {View} from 'react-native';\nimport {initConnection} from 'react-native-iap';\n\nconst App = () => {\n useEffect(() => {\n void initConnection();\n }, []);\n\n return <View />;\n};\n```\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * Disconnects from native SDK\n * Usage\n * ```tsx\nimport React, {useEffect} from 'react';\nimport {View} from 'react-native';\nimport {endConnection} from 'react-native-iap';\n\nconst App = () => {\n useEffect(() => {\n return () => {\n void endConnection();\n };\n }, []);\n\n return <View />;\n};\n```\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<boolean> =>\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 =\n (): Promise<boolean> =>\n getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n ## Usage\n\n```ts\nimport React, {useState} from 'react';\nimport {Platform} from 'react-native';\nimport {getProducts, Product} from 'react-native-iap';\n\nconst skus = Platform.select({\n ios: ['com.example.consumableIos'],\n android: ['com.example.consumableAndroid'],\n});\n\nconst App = () => {\n const [products, setProducts] = useState<Product[]>([]);\n\n const handleProducts = async () => {\n const items = await getProducts({skus});\n\n setProducts(items);\n };\n\n useEffect(() => {\n void handleProducts();\n }, []);\n\n return (\n <>\n {products.map((product) => (\n <Text key={product.productId}>{product.productId}</Text>\n ))}\n </>\n );\n};\n```\n\nJust a few things to keep in mind:\n\n- You can get your products in `componentDidMount`, `useEffect` or another appropriate area of your app.\n- Since a user may start your app with a bad or no internet connection, preparing/getting the items more than once may be a good idea.\n- If the user has no IAPs available when the app starts first, you may want to check again when the user enters your IAP store.\n\n */\nexport const getProducts = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n const items = (await getIosModule().getItems(skus)) as Product[];\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 fillProductsWithAdditionalData(products);\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n\n/**\n * Get a list of subscriptions\n * ## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {View} from 'react-native';\nimport {getSubscriptions} from 'react-native-iap';\n\nconst App = () => {\n const subscriptions = useCallback(\n async () =>\n await getSubscriptions(['com.example.product1', 'com.example.product2']),\n [],\n );\n\n return <View />;\n};\n```\n\n */\nexport const getSubscriptions = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n const items = (await getIosModule().getItems(skus)) as Subscription[];\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 )) as Subscription[];\n\n return fillProductsWithAdditionalData(subscriptions);\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * ## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {View} from 'react-native';\nimport {getPurchaseHistory} from 'react-native-iap';\n\nconst App = () => {\n const history = useCallback(\n async () =>\n await getPurchaseHistory([\n 'com.example.product1',\n 'com.example.product2',\n ]),\n [],\n );\n\n return <View />;\n};\n```\n */\nexport const getPurchaseHistory = (): Promise<\n (ProductPurchase | 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 RNIapModule.getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.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 * ## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {View} from 'react-native';\nimport {getAvailablePurchases} from 'react-native-iap';\n\nconst App = () => {\n const availablePurchases = useCallback(\n async () => await getAvailablePurchases(),\n [],\n );\n\n return <View />;\n};\n```\n\n## Restoring purchases\n\nYou can use `getAvailablePurchases()` to do what's commonly understood as \"restoring\" purchases.\n\n:::note\nFor debugging you may want to consume all items, you have then to iterate over the purchases returned by `getAvailablePurchases()`.\n:::\n\n:::warning\nBeware that if you consume an item without having recorded the purchase in your database the user may have paid for something without getting it delivered and you will have no way to recover the receipt to validate and restore their purchase.\n:::\n\n```tsx\nimport React from 'react';\nimport {Button} from 'react-native';\nimport {getAvailablePurchases,finishTransaction} from 'react-native-iap';\n\nconst App = () => {\n handleRestore = async () => {\n try {\n const purchases = await getAvailablePurchases();\n const newState = {premium: false, ads: true};\n let titles = [];\n\n await Promise.all(purchases.map(async purchase => {\n switch (purchase.productId) {\n case 'com.example.premium':\n newState.premium = true;\n titles.push('Premium Version');\n break;\n\n case 'com.example.no_ads':\n newState.ads = false;\n titles.push('No Ads');\n break;\n\n case 'com.example.coins100':\n await finishTransaction(purchase.purchaseToken);\n CoinStore.addCoins(100);\n }\n })\n\n Alert.alert(\n 'Restore Successful',\n `You successfully restored the following purchases: ${titles.join(', ')}`,\n );\n } catch (error) {\n console.warn(error);\n Alert.alert(error.message);\n }\n };\n\n return (\n <Button title=\"Restore purchases\" onPress={handleRestore} />\n )\n};\n```\n * \n */\nexport const getAvailablePurchases = (): Promise<\n (ProductPurchase | 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 RNIapModule.getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.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 * Request a purchase for a product (consumables or non-consumables).\n\nThe response will be received through the `PurchaseUpdatedListener`.\n\n:::note\n`andDangerouslyFinishTransactionAutomatically` defaults to false. We recommend\nalways keeping at false, and verifying the transaction receipts on the server-side.\n:::\n\n## Signature\n\n```ts\nrequestPurchase(\n The product's sku/ID \n sku,\n\n \n * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.\n * @default false\n \n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n\n /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app. \n obfuscatedAccountIdAndroid,\n\n Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app. \n obfuscatedProfileIdAndroid,\n\n The purchaser's user ID \n applicationUsername,\n): Promise<ProductPurchase>;\n```\n\n## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {Button} from 'react-native';\nimport {requestPurchase, Product, Sku, getProducts} from 'react-native-iap';\n\nconst App = () => {\n const products = useCallback(\n async () => getProducts(['com.example.product']),\n [],\n );\n\n const handlePurchase = async (sku: Sku) => {\n await requestPurchase({sku});\n };\n\n return (\n <>\n {products.map((product) => (\n <Button\n key={product.productId}\n title=\"Buy product\"\n onPress={() => handlePurchase(product.productId)}\n />\n ))}\n </>\n );\n};\n```\n\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n skus,\n isOfferPersonalized,\n}: RequestPurchase): Promise<ProductPurchase | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!sku) {\n return Promise.reject(new Error('sku is required for iOS purchase'));\n }\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 if (isAmazon) {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for Amazon purchase'),\n );\n }\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!sku?.length && !sku) {\n return Promise.reject(\n new Error('skus is required for Android purchase'),\n );\n }\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n skus?.length ? skus : [sku],\n undefined,\n -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n [],\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * Request a purchase for a subscription.\n\nThe response will be received through the `PurchaseUpdatedListener`.\n\n:::note\n`andDangerouslyFinishTransactionAutomatically` defaults to false. We recommend\nalways keeping at false, and verifying the transaction receipts on the server-side.\n:::\n\n## Signature\n\n```ts\nrequestSubscription(\n The product's sku/ID \n sku,\n\n\n * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.\n * @default false\n\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n\n purchaseToken that the user is upgrading or downgrading from (Android). \n purchaseTokenAndroid,\n\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED \n prorationModeAndroid = -1,\n\n /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app. \n obfuscatedAccountIdAndroid,\n\n Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app. \n obfuscatedProfileIdAndroid,\n\n The purchaser's user ID \n applicationUsername,\n): Promise<SubscriptionPurchase>\n```\n\n## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {Button} from 'react-native';\nimport {\n requestSubscription,\n Product,\n Sku,\n getSubscriptions,\n} from 'react-native-iap';\n\nconst App = () => {\n const subscriptions = useCallback(\n async () => getSubscriptions(['com.example.subscription']),\n [],\n );\n\n const handlePurchase = async (sku: Sku) => {\n await requestSubscription({sku});\n };\n\n return (\n <>\n {subscriptions.map((subscription) => (\n <Button\n key={subscription.productId}\n title=\"Buy subscription\"\n onPress={() => handlePurchase(subscription.productId)}\n />\n ))}\n </>\n );\n};\n```\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n subscriptionOffers,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized = undefined,\n}: RequestSubscription): Promise<SubscriptionPurchase | null | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for iOS subscription'),\n );\n }\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 if (isAmazon) {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for Amazon purchase'),\n );\n }\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!subscriptionOffers?.length) {\n return Promise.reject(\n 'subscriptionOffers are required for Google Play Subscriptions',\n );\n }\n return RNIapModule.buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n subscriptionOffers?.map((so) => so.sku),\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers?.map((so) => so.offerToken),\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || (() => Promise.resolve(null))\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,\n quantity,\n}: {\n sku: Sku;\n quantity: number;\n}): Promise<ProductPurchase> =>\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 * \n```tsx\nimport React from 'react';\nimport {Button} from 'react-native';\nimport {finishTransaction} from 'react-native-iap';\n\nconst App = () => {\n const handlePurchase = async () => {\n // ... handle the purchase request\n\n const result = finishTransaction(purchase);\n };\n\n return <Button title=\"Buy product\" onPress={handlePurchase} />;\n};\n``` \n */\nexport const finishTransaction = ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n}: {\n purchase: ProductPurchase | ProductPurchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n}): Promise<PurchaseResult | boolean> => {\n return (\n Platform.select({\n ios: async () => {\n const transactionId = purchase.transactionId;\n\n if (!transactionId) {\n return Promise.reject(\n new Error('transactionId required to finish iOS transaction'),\n );\n }\n return getIosModule().finishTransaction(transactionId);\n },\n android: async () => {\n if (purchase?.purchaseToken) {\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 return Promise.reject(\n new Error('purchase is not suitable to be purchased'),\n );\n }\n }\n return Promise.reject(\n new Error('purchase is not suitable to be purchased'),\n );\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\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,\n developerPayload,\n}: {\n token: string;\n developerPayload?: string;\n}): Promise<PurchaseResult | boolean | 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,\n}: {\n sku: Sku;\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 TEST_RECEIPT = 21007;\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<ReceiptValidationResponse | false> => {\n const response = await enhancedFetch<ReceiptValidationResponse>(\n 'https://buy.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\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 === TEST_RECEIPT) {\n const testResponse = await enhancedFetch<ReceiptValidationResponse>(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\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,\n forUser,\n withOffer,\n}: {\n sku: Sku;\n forUser: string;\n withOffer: Apple.PaymentDiscount;\n}): Promise<Purchase> =>\n 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,\n isTest,\n}: {\n receiptBody: Record<string, unknown>;\n isTest?: boolean;\n}): Promise<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 return await enhancedFetch<ReceiptValidationResponse>(url, {\n method: 'POST',\n body: receiptBody,\n });\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,\n productId,\n productToken,\n accessToken,\n isSub,\n}: {\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 return await enhancedFetch<Android.ReceiptType>(url);\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,\n userId,\n receiptId,\n useSandbox = true,\n}: {\n developerSecret: string;\n userId: string;\n receiptId: string;\n useSandbox: boolean;\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 return await enhancedFetch<Amazon.ReceiptType>(url);\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 * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async ({\n forceRefresh,\n}: {\n forceRefresh?: boolean;\n}): Promise<string> => getIosModule().requestReceipt(forceRefresh ?? false);\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;;AAMA;;AAMA;;AAcA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CC,0BAAnD;AACA,MAAMC,8BAA8B,GAAGC,kBAAA,CAAYC,IAAnD;AACA,MAAMC,qBAAqB,GAAGF,kBAAA,CAAYG,KAA1C;;AAEO,MAAMC,uBAAuB,GAAG,MAA4B;EACjE,OAAOR,WAAW,GACdS,2BAAA,CAAqBC,WADP,GAEdD,2BAAA,CAAqBE,MAFzB;AAGD,CAJM;;;AAMP,IAAIC,mBAAmB,GAAGZ,WAA1B;;AAEO,MAAMa,sBAAsB,GACjCC,YADoC,IAE3B;EACTF,mBAAmB,GAAGE,YAAtB;AACD,CAJM;;;;AAMP,MAAMC,2BAA2B,GAAG,MAAY;EAC9C,IAAI,CAACf,WAAD,IAAgB,CAACC,iBAArB,EAAwC;IACtC,MAAM,IAAIe,KAAJ,CAAU,mBAAV,CAAN;EACD;AACF,CAJD;;AAMO,MAAMC,gBAAgB,GAAG,MAEA;EAC9BF,2BAA2B;EAE3B,OAAOH,mBAAmB,GACtBA,mBADsB,GAEtBZ,WAAW,GACXA,WADW,GAEXC,iBAJJ;AAKD,CAVM;;;;AAYP,MAAMiB,uBAAuB,GAAG,MAAY;EAC1C,IAAI,CAACnB,QAAL,EAAe;IACb,MAAM,IAAIiB,KAAJ,CAAU,mBAAV,CAAN;EACD;AACF,CAJD;;AAMO,MAAMG,YAAY,GAAG,MAAuB;EACjDD,uBAAuB;EAEvB,OAAOnB,QAAP;AACD,CAJM;;;;AAMA,MAAMqB,eAAe,GAAG,MAGR;EACrB,OAAOC,mBAAA,GAAYJ,gBAAgB,EAA5B,GAAiCE,YAAY,EAApD;AACD,CALM;AAOP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMG,cAAc,GAAG,MAC5BF,eAAe,GAAGE,cAAlB,EADK;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,aAAa,GAAG,MAC3BH,eAAe,GAAGG,aAAlB,EADK;AAGP;AACA;AACA;AACA;;;;;AACO,MAAMC,0CAA0C,GACrD,MACEP,gBAAgB,GAAGQ,mCAAnB,EAFG;AAIP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAM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O,IAAAc,wCAAA,EAA+BI,aAA/B,CAAP;IACD;EAhBa,CAAhB,MAiBO,MAAMH,OAAO,CAACC,MAAR,CAAe,IAAI3B,KAAJ,CAAU,sBAAV,CAAf,CAjBb,CADF,GAL8B;AAAA,CAAzB;AA0BP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAM8B,kBAAkB,GAAG,MAGhC,CACElB,qBAAA,CAASC,MAAT,CAAgB;EACdC,GAAG,EAAE,YAAY;IACf,OAAOX,YAAY,GAAG4B,iBAAf,EAAP;EACD,CAHa;EAIdT,OAAO,EAAE,YAAY;IACnB,IAAIrC,iBAAJ,EAAuB;MACrB,OAAO,MAAMA,iBAAiB,CAAC8C,iBAAlB,EAAb;IACD;;IAED,MAAMR,QAAQ,GAAG,MAAMvC,WAAW,CAACgD,wBAAZ,CACrB1C,qBADqB,CAAvB;IAIA,MAAMuC,aAAa,GAAG,MAAM7C,WAAW,CAACgD,wBAAZ,CAC1B7C,8BAD0B,CAA5B;IAIA,OAAOoC,QAAQ,CAACU,MAAT,CAAgBJ,aAAhB,CAAP;EACD;AAlBa,CAAhB,MAmBO,MAAMH,OAAO,CAACQ,OAAR,CAAgB,EAAhB,CAnBb,CADF,GAHK;AA0BP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,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