react-native-iap 12.0.2 → 12.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (42) hide show
  1. package/lib/commonjs/iap.js +143 -110
  2. package/lib/commonjs/iap.js.map +1 -1
  3. package/lib/commonjs/internal/fillProductsWithAdditionalData.js +2 -1
  4. package/lib/commonjs/internal/fillProductsWithAdditionalData.js.map +1 -1
  5. package/lib/commonjs/internal/platform.js +28 -1
  6. package/lib/commonjs/internal/platform.js.map +1 -1
  7. package/lib/commonjs/modules/android.js +14 -1
  8. package/lib/commonjs/modules/android.js.map +1 -1
  9. package/lib/commonjs/modules/ios.js +24 -12
  10. package/lib/commonjs/modules/ios.js.map +1 -1
  11. package/lib/commonjs/types/appleSk2.js +3 -0
  12. package/lib/commonjs/types/appleSk2.js.map +1 -1
  13. package/lib/commonjs/types/index.js +15 -1
  14. package/lib/commonjs/types/index.js.map +1 -1
  15. package/lib/module/iap.js +143 -111
  16. package/lib/module/iap.js.map +1 -1
  17. package/lib/module/internal/fillProductsWithAdditionalData.js +2 -1
  18. package/lib/module/internal/fillProductsWithAdditionalData.js.map +1 -1
  19. package/lib/module/internal/platform.js +24 -0
  20. package/lib/module/internal/platform.js.map +1 -1
  21. package/lib/module/modules/android.js +15 -2
  22. package/lib/module/modules/android.js.map +1 -1
  23. package/lib/module/modules/ios.js +25 -13
  24. package/lib/module/modules/ios.js.map +1 -1
  25. package/lib/module/types/appleSk2.js +2 -0
  26. package/lib/module/types/appleSk2.js.map +1 -1
  27. package/lib/module/types/index.js +12 -0
  28. package/lib/module/types/index.js.map +1 -1
  29. package/lib/typescript/iap.d.ts +4 -4
  30. package/lib/typescript/internal/fillProductsWithAdditionalData.d.ts +2 -1
  31. package/lib/typescript/internal/platform.d.ts +9 -0
  32. package/lib/typescript/modules/android.d.ts +1 -1
  33. package/lib/typescript/modules/ios.d.ts +4 -4
  34. package/lib/typescript/types/index.d.ts +54 -28
  35. package/package.json +1 -1
  36. package/src/iap.ts +130 -74
  37. package/src/internal/fillProductsWithAdditionalData.ts +3 -2
  38. package/src/internal/platform.ts +20 -0
  39. package/src/modules/android.ts +16 -7
  40. package/src/modules/ios.ts +35 -20
  41. package/src/types/appleSk2.ts +2 -0
  42. package/src/types/index.ts +70 -30
@@ -248,14 +248,45 @@ const getSubscriptions = _ref2 => {
248
248
  items = await RNIapIos.getItems(skus);
249
249
  }
250
250
 
251
- return items.filter(item => skus.includes(item.productId) && item.type === 'subs');
251
+ items = items.filter(item => skus.includes(item.productId) && item.type === 'subs');
252
+ return addSubscriptionPlatform(items, _types.SubscriptionPlatform.ios);
252
253
  },
253
254
  android: async () => {
254
- const subscriptions = await (0, _internal.getAndroidModule)().getItemsByType(ANDROID_ITEM_TYPE_SUBSCRIPTION, skus);
255
- return (0, _internal.fillProductsWithAdditionalData)(subscriptions);
255
+ const androidPlatform = (0, _internal.getAndroidModuleType)();
256
+ let subscriptions = await (0, _internal.getAndroidModule)().getItemsByType(ANDROID_ITEM_TYPE_SUBSCRIPTION, skus);
257
+
258
+ switch (androidPlatform) {
259
+ case 'android':
260
+ {
261
+ const castSubscriptions = subscriptions;
262
+ return addSubscriptionPlatform(castSubscriptions, _types.SubscriptionPlatform.android);
263
+ }
264
+
265
+ case 'amazon':
266
+ let castSubscriptions = subscriptions;
267
+ castSubscriptions = await (0, _internal.fillProductsWithAdditionalData)(castSubscriptions);
268
+ return addSubscriptionPlatform(castSubscriptions, _types.SubscriptionPlatform.amazon);
269
+
270
+ case null:
271
+ default:
272
+ throw new Error(`getSubscriptions received unknown platform ${androidPlatform}. Verify the logic in getAndroidModuleType`);
273
+ }
256
274
  }
257
275
  }) || (() => Promise.reject(new Error('Unsupported Platform'))))();
258
276
  };
277
+ /**
278
+ * Adds an extra property to subscriptions so we can distinguish the platform
279
+ * we retrieved them on.
280
+ */
281
+
282
+
283
+ exports.getSubscriptions = getSubscriptions;
284
+
285
+ const addSubscriptionPlatform = (subscriptions, platform) => {
286
+ return subscriptions.map(subscription => ({ ...subscription,
287
+ platform
288
+ }));
289
+ };
259
290
  /**
260
291
  * Gets an inventory of purchases made by the user regardless of consumption status
261
292
  * ## Usage
@@ -280,14 +311,12 @@ const App = () => {
280
311
  ```
281
312
  @param {alsoPublishToEventListener}:boolean. (IOS Sk2 only) When `true`, every element will also be pushed to the purchaseUpdated listener.
282
313
  Note that this is only for backaward compatiblity. It won't publish to transactionUpdated (Storekit2) Defaults to `false`
283
- @param {automaticallyFinishRestoredTransactions}:boolean. (IOS Sk1 only) When `true`, all the transactions that are returned are automatically
284
- finished. This means that if you call this method again you won't get the same result on the same device. On the other hand, if `false` you'd
314
+ @param {automaticallyFinishRestoredTransactions}:boolean. (IOS Sk1 only) When `true`, all the transactions that are returned are automatically
315
+ finished. This means that if you call this method again you won't get the same result on the same device. On the other hand, if `false` you'd
285
316
  have to manually finish the returned transaction once you have delivered the content to your user.
286
317
  */
287
318
 
288
319
 
289
- exports.getSubscriptions = getSubscriptions;
290
-
291
320
  const getPurchaseHistory = function () {
292
321
  let {
293
322
  alsoPublishToEventListener = false,
@@ -390,7 +419,7 @@ const App = () => {
390
419
  ```
391
420
  @param {alsoPublishToEventListener}:boolean When `true`, every element will also be pushed to the purchaseUpdated listener.
392
421
  Note that this is only for backaward compatiblity. It won't publish to transactionUpdated (Storekit2) Defaults to `false`
393
- *
422
+ *
394
423
  */
395
424
 
396
425
 
@@ -435,22 +464,22 @@ always keeping at false, and verifying the transaction receipts on the server-si
435
464
 
436
465
  ```ts
437
466
  requestPurchase(
438
- The product's sku/ID
467
+ The product's sku/ID
439
468
  sku,
440
469
 
441
-
470
+
442
471
  * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.
443
472
  * @default false
444
-
473
+
445
474
  andDangerouslyFinishTransactionAutomaticallyIOS = false,
446
475
 
447
- /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
476
+ /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
448
477
  obfuscatedAccountIdAndroid,
449
478
 
450
- Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
479
+ Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
451
480
  obfuscatedProfileIdAndroid,
452
481
 
453
- The purchaser's user ID
482
+ The purchaser's user ID
454
483
  applicationUsername,
455
484
  ): Promise<ProductPurchase>;
456
485
  ```
@@ -491,54 +520,56 @@ const App = () => {
491
520
 
492
521
  exports.getAvailablePurchases = getAvailablePurchases;
493
522
 
494
- const requestPurchase = _ref3 => {
495
- let {
496
- sku,
497
- andDangerouslyFinishTransactionAutomaticallyIOS = false,
498
- obfuscatedAccountIdAndroid,
499
- obfuscatedProfileIdAndroid,
500
- appAccountToken,
501
- skus,
502
- // Android Billing V5
503
- isOfferPersonalized = undefined,
504
- // Android Billing V5
505
- quantity,
506
- withOffer
507
- } = _ref3;
508
- return (_reactNative.Platform.select({
509
- ios: async () => {
510
- if (!sku) {
511
- return Promise.reject(new Error('sku is required for iOS purchase'));
512
- }
523
+ const requestPurchase = request => (_reactNative.Platform.select({
524
+ ios: async () => {
525
+ if (!('sku' in request)) {
526
+ throw new Error('sku is required for iOS purchase');
527
+ }
513
528
 
514
- if (andDangerouslyFinishTransactionAutomaticallyIOS) {
515
- 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.');
516
- }
529
+ const {
530
+ sku,
531
+ andDangerouslyFinishTransactionAutomaticallyIOS = false,
532
+ appAccountToken,
533
+ quantity,
534
+ withOffer
535
+ } = request;
517
536
 
518
- if ((0, _internal.isIosStorekit2)()) {
519
- const offer = (0, _appleSk.offerSk2Map)(withOffer);
520
- return RNIapIosSk2.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, offer);
521
- } else {
522
- return RNIapIos.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, (0, _apple.offerToRecord)(withOffer));
523
- }
524
- },
525
- android: async () => {
526
- if (_internal.isAmazon) {
527
- if (!sku) {
528
- return Promise.reject(new Error('sku is required for Amazon purchase'));
529
- }
537
+ if (andDangerouslyFinishTransactionAutomaticallyIOS) {
538
+ 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.');
539
+ }
530
540
 
531
- return RNIapAmazonModule.buyItemByType(sku);
532
- } else {
533
- if (!(sku !== null && sku !== void 0 && sku.length) && !sku) {
534
- return Promise.reject(new Error('skus is required for Android purchase'));
535
- }
541
+ if ((0, _internal.isIosStorekit2)()) {
542
+ const offer = (0, _appleSk.offerSk2Map)(withOffer);
543
+ return RNIapIosSk2.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, offer);
544
+ } else {
545
+ return RNIapIos.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, (0, _apple.offerToRecord)(withOffer));
546
+ }
547
+ },
548
+ android: async () => {
549
+ if (_internal.isAmazon) {
550
+ if (!('sku' in request)) {
551
+ throw new Error('sku is required for Amazon purchase');
552
+ }
536
553
 
537
- return (0, _internal.getAndroidModule)().buyItemByType(ANDROID_ITEM_TYPE_IAP, skus !== null && skus !== void 0 && skus.length ? skus : [sku], undefined, -1, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, [], isOfferPersonalized ?? false);
554
+ const {
555
+ sku
556
+ } = request;
557
+ return RNIapAmazonModule.buyItemByType(sku);
558
+ } else {
559
+ if (!('skus' in request) || !request.skus.length) {
560
+ throw new Error('skus is required for Android purchase');
538
561
  }
562
+
563
+ const {
564
+ skus,
565
+ obfuscatedAccountIdAndroid,
566
+ obfuscatedProfileIdAndroid,
567
+ isOfferPersonalized
568
+ } = request;
569
+ return (0, _internal.getAndroidModule)().buyItemByType(ANDROID_ITEM_TYPE_IAP, skus, undefined, -1, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, [], isOfferPersonalized ?? false);
539
570
  }
540
- }) || Promise.resolve)();
541
- };
571
+ }
572
+ }) || Promise.resolve)();
542
573
  /**
543
574
  * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
544
575
  * Request a purchase for a subscription.
@@ -554,7 +585,7 @@ always keeping at false, and verifying the transaction receipts on the server-si
554
585
 
555
586
  ```ts
556
587
  requestSubscription(
557
- The product's sku/ID
588
+ The product's sku/ID
558
589
  sku,
559
590
 
560
591
 
@@ -563,19 +594,19 @@ requestSubscription(
563
594
 
564
595
  andDangerouslyFinishTransactionAutomaticallyIOS = false,
565
596
 
566
- purchaseToken that the user is upgrading or downgrading from (Android).
597
+ purchaseToken that the user is upgrading or downgrading from (Android).
567
598
  purchaseTokenAndroid,
568
599
 
569
- UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED
600
+ UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED
570
601
  prorationModeAndroid = -1,
571
602
 
572
- /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
603
+ /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
573
604
  obfuscatedAccountIdAndroid,
574
605
 
575
- Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
606
+ Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
576
607
  obfuscatedProfileIdAndroid,
577
608
 
578
- The purchaser's user ID
609
+ The purchaser's user ID
579
610
  applicationUsername,
580
611
  ): Promise<SubscriptionPurchase>
581
612
  ```
@@ -620,56 +651,58 @@ const App = () => {
620
651
 
621
652
  exports.requestPurchase = requestPurchase;
622
653
 
623
- const requestSubscription = _ref4 => {
624
- let {
625
- sku,
626
- andDangerouslyFinishTransactionAutomaticallyIOS = false,
627
- purchaseTokenAndroid,
628
- prorationModeAndroid = -1,
629
- obfuscatedAccountIdAndroid,
630
- obfuscatedProfileIdAndroid,
631
- subscriptionOffers = undefined,
632
- // Android Billing V5
633
- isOfferPersonalized = undefined,
634
- // Android Billing V5
635
- appAccountToken,
636
- quantity,
637
- withOffer
638
- } = _ref4;
639
- return (_reactNative.Platform.select({
640
- ios: async () => {
641
- if (!sku) {
642
- return Promise.reject(new Error('sku is required for iOS subscription'));
643
- }
654
+ const requestSubscription = request => (_reactNative.Platform.select({
655
+ ios: async () => {
656
+ if (!('sku' in request)) {
657
+ throw new Error('sku is required for iOS subscriptions');
658
+ }
644
659
 
645
- if (andDangerouslyFinishTransactionAutomaticallyIOS) {
646
- 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.');
647
- }
660
+ const {
661
+ sku,
662
+ andDangerouslyFinishTransactionAutomaticallyIOS = false,
663
+ appAccountToken,
664
+ quantity,
665
+ withOffer
666
+ } = request;
648
667
 
649
- if ((0, _internal.isIosStorekit2)()) {
650
- const offer = (0, _appleSk.offerSk2Map)(withOffer);
651
- return RNIapIosSk2.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, offer);
652
- } else {
653
- return RNIapIos.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, (0, _apple.offerToRecord)(withOffer));
654
- }
655
- },
656
- android: async () => {
657
- if (_internal.isAmazon) {
658
- if (!sku) {
659
- return Promise.reject(new Error('sku is required for Amazon purchase'));
660
- }
668
+ if (andDangerouslyFinishTransactionAutomaticallyIOS) {
669
+ 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.');
670
+ }
661
671
 
662
- return RNIapAmazonModule.buyItemByType(sku);
663
- } else {
664
- if (!(subscriptionOffers !== null && subscriptionOffers !== void 0 && subscriptionOffers.length)) {
665
- return Promise.reject('subscriptionOffers are required for Google Play Subscriptions');
666
- }
672
+ if ((0, _internal.isIosStorekit2)()) {
673
+ const offer = (0, _appleSk.offerSk2Map)(withOffer);
674
+ return RNIapIosSk2.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, offer);
675
+ } else {
676
+ return RNIapIos.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, (0, _apple.offerToRecord)(withOffer));
677
+ }
678
+ },
679
+ android: async () => {
680
+ if (_internal.isAmazon) {
681
+ if (!('sku' in request)) {
682
+ throw new Error('sku is required for Amazon subscriptions');
683
+ }
667
684
 
668
- return RNIapModule.buyItemByType(ANDROID_ITEM_TYPE_SUBSCRIPTION, subscriptionOffers === null || subscriptionOffers === void 0 ? void 0 : subscriptionOffers.map(so => so.sku), purchaseTokenAndroid, prorationModeAndroid, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, subscriptionOffers === null || subscriptionOffers === void 0 ? void 0 : subscriptionOffers.map(so => so.offerToken), isOfferPersonalized ?? false);
685
+ const {
686
+ sku
687
+ } = request;
688
+ return RNIapAmazonModule.buyItemByType(sku);
689
+ } else {
690
+ if (!('subscriptionOffers' in request) || request.subscriptionOffers.length === 0) {
691
+ throw new Error('subscriptionOffers are required for Google Play subscriptions');
669
692
  }
693
+
694
+ const {
695
+ subscriptionOffers,
696
+ purchaseTokenAndroid,
697
+ prorationModeAndroid,
698
+ obfuscatedAccountIdAndroid,
699
+ obfuscatedProfileIdAndroid,
700
+ isOfferPersonalized
701
+ } = request;
702
+ return RNIapModule.buyItemByType(ANDROID_ITEM_TYPE_SUBSCRIPTION, subscriptionOffers === null || subscriptionOffers === void 0 ? void 0 : subscriptionOffers.map(so => so.sku), purchaseTokenAndroid, prorationModeAndroid, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, subscriptionOffers === null || subscriptionOffers === void 0 ? void 0 : subscriptionOffers.map(so => so.offerToken), isOfferPersonalized ?? false);
670
703
  }
671
- }) || (() => Promise.resolve(null)))();
672
- };
704
+ }
705
+ }) || (() => Promise.resolve(null)))();
673
706
  /**
674
707
  * Finish Transaction (both platforms)
675
708
  * Abstracts Finish Transaction
@@ -677,7 +710,7 @@ const requestSubscription = _ref4 => {
677
710
  * Call this after you have persisted the purchased state to your server or local data in your app.
678
711
  * `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.**
679
712
  * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.
680
- *
713
+ *
681
714
  ```tsx
682
715
  import React from 'react';
683
716
  import {Button} from 'react-native';
@@ -692,18 +725,18 @@ const App = () => {
692
725
 
693
726
  return <Button title="Buy product" onPress={handlePurchase} />;
694
727
  };
695
- ```
728
+ ```
696
729
  */
697
730
 
698
731
 
699
732
  exports.requestSubscription = requestSubscription;
700
733
 
701
- const finishTransaction = _ref5 => {
734
+ const finishTransaction = _ref3 => {
702
735
  let {
703
736
  purchase,
704
737
  isConsumable,
705
738
  developerPayloadAndroid
706
- } = _ref5;
739
+ } = _ref3;
707
740
  return (_reactNative.Platform.select({
708
741
  ios: async () => {
709
742
  const transactionId = purchase.transactionId;
@@ -1 +1 @@
1
- {"version":3,"names":["RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","NativeModules","ANDROID_ITEM_TYPE_SUBSCRIPTION","ProductType","subs","ANDROID_ITEM_TYPE_IAP","inapp","setup","storekitMode","storekit1Mode","storekit2Mode","storekitHybridMode","initConnection","getNativeModule","endConnection","flushFailedPurchasesCachedAsPendingAndroid","getAndroidModule","flushFailedPurchasesCachedAsPending","getProducts","skus","Platform","select","ios","items","isIosStorekit2","getItems","map","productSk2Map","filter","item","includes","productId","type","android","products","getItemsByType","fillProductsWithAdditionalData","Promise","reject","Error","getSubscriptions","subscriptionSk2Map","subscriptions","getPurchaseHistory","alsoPublishToEventListener","automaticallyFinishRestoredTransactions","resolve","getAvailableItems","transactionSk2Map","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","appAccountToken","isOfferPersonalized","undefined","quantity","withOffer","console","warn","offer","offerSk2Map","buyProduct","offerToRecord","isAmazon","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","so","offerToken","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","getIosModule","purchaseToken","consumeProduct","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PurchaseStateAndroid","PURCHASED","acknowledgePurchase"],"sources":["iap.ts"],"sourcesContent":["import {NativeModules, Platform} from 'react-native';\n\nimport * as IapAmazon from './modules/amazon';\nimport * as IapAndroid from './modules/android';\nimport * as IapIos from './modules/ios';\nimport * as IapIosSk2 from './modules/iosSk2';\nimport {offerToRecord} from './types/apple';\nimport {\n offerSk2Map,\n ProductSk2,\n productSk2Map,\n subscriptionSk2Map,\n transactionSk2Map,\n} from './types/appleSk2';\nimport {\n fillProductsWithAdditionalData,\n getAndroidModule,\n getIosModule,\n getNativeModule,\n isAmazon,\n isIosStorekit2,\n storekit1Mode,\n storekit2Mode,\n storekitHybridMode,\n} from './internal';\nimport {\n Product,\n ProductPurchase,\n ProductType,\n PurchaseResult,\n RequestPurchase,\n RequestSubscription,\n Subscription,\n SubscriptionPurchase,\n} from './types';\nimport {PurchaseStateAndroid} from './types';\n\nexport {IapAndroid, IapAmazon, IapIos, IapIosSk2, isIosStorekit2};\n\nconst {RNIapIos, RNIapIosSk2, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = ProductType.subs;\nconst ANDROID_ITEM_TYPE_IAP = ProductType.inapp;\n\n/**\n * STOREKIT1_MODE: Will not enable Storekit 2 even if the device supports it. Thigs will work as before,\n * minimum changes required in the migration guide (default)\n * HYBRID_MODE: Will enable Storekit 2 for iOS devices > 15.0 but will fallback to Sk1 on older devices\n * There are some edge cases that you need to handle in this case (described in migration guide). This mode\n * is for developers that are migrating to Storekit 2 but want to keep supporting older versions.\n * STOREKIT2_MODE: Will *only* enable Storekit 2. This disables Storekit 1. This is for apps that\n * have already targeted a min version of 15 for their app.\n */\nexport type STOREKIT_OPTIONS =\n | 'STOREKIT1_MODE'\n | 'STOREKIT_HYBRID_MODE'\n | 'STOREKIT2_MODE';\n\nexport const setup = ({\n storekitMode = 'STOREKIT1_MODE',\n}: {\n storekitMode?: STOREKIT_OPTIONS;\n} = {}) => {\n switch (storekitMode) {\n case 'STOREKIT1_MODE':\n storekit1Mode();\n break;\n case 'STOREKIT2_MODE':\n storekit2Mode();\n break;\n case 'STOREKIT_HYBRID_MODE':\n storekitHybridMode();\n break;\n default:\n break;\n }\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 let items: Product[];\n if (isIosStorekit2()) {\n items = ((await RNIapIosSk2.getItems(skus)) as ProductSk2[]).map(\n productSk2Map,\n );\n } else {\n items = (await RNIapIos.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 let items: Subscription[];\n if (isIosStorekit2()) {\n items = ((await RNIapIosSk2.getItems(skus)) as ProductSk2[]).map(\n subscriptionSk2Map,\n );\n } else {\n items = (await RNIapIos.getItems(skus)) as Subscription[];\n }\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@param {alsoPublishToEventListener}:boolean. (IOS Sk2 only) When `true`, every element will also be pushed to the purchaseUpdated listener.\nNote that this is only for backaward compatiblity. It won't publish to transactionUpdated (Storekit2) Defaults to `false`\n@param {automaticallyFinishRestoredTransactions}:boolean. (IOS Sk1 only) When `true`, all the transactions that are returned are automatically \nfinished. This means that if you call this method again you won't get the same result on the same device. On the other hand, if `false` you'd \nhave to manually finish the returned transaction once you have delivered the content to your user.\n */\nexport const getPurchaseHistory = ({\n alsoPublishToEventListener = false,\n automaticallyFinishRestoredTransactions = true,\n}: {\n alsoPublishToEventListener?: boolean;\n automaticallyFinishRestoredTransactions?: boolean;\n} = {}): Promise<(ProductPurchase | SubscriptionPurchase)[]> =>\n (\n Platform.select({\n ios: async () => {\n if (isIosStorekit2()) {\n return Promise.resolve(\n (\n await RNIapIosSk2.getAvailableItems(alsoPublishToEventListener)\n ).map(transactionSk2Map),\n );\n } else {\n return RNIapIos.getAvailableItems(\n automaticallyFinishRestoredTransactions,\n );\n }\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@param {alsoPublishToEventListener}:boolean When `true`, every element will also be pushed to the purchaseUpdated listener.\nNote that this is only for backaward compatiblity. It won't publish to transactionUpdated (Storekit2) Defaults to `false`\n * \n */\nexport const getAvailablePurchases = ({\n alsoPublishToEventListener = false,\n automaticallyFinishRestoredTransactions = false,\n}: {\n alsoPublishToEventListener?: boolean;\n automaticallyFinishRestoredTransactions?: boolean;\n} = {}): Promise<(ProductPurchase | SubscriptionPurchase)[]> =>\n (\n Platform.select({\n ios: async () => {\n if (isIosStorekit2()) {\n return Promise.resolve(\n (\n await RNIapIosSk2.getAvailableItems(alsoPublishToEventListener)\n ).map(transactionSk2Map),\n );\n } else {\n return RNIapIos.getAvailableItems(\n automaticallyFinishRestoredTransactions,\n );\n }\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 obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n appAccountToken,\n skus, // Android Billing V5\n isOfferPersonalized = undefined, // Android Billing V5\n quantity,\n withOffer,\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 if (isIosStorekit2()) {\n const offer = offerSk2Map(withOffer);\n\n return RNIapIosSk2.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n );\n } else {\n return RNIapIos.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offerToRecord(withOffer),\n );\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 purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers = undefined, // Android Billing V5\n isOfferPersonalized = undefined, // Android Billing V5\n appAccountToken,\n quantity,\n withOffer,\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 if (isIosStorekit2()) {\n const offer = offerSk2Map(withOffer);\n\n return RNIapIosSk2.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n );\n } else {\n return RNIapIos.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offerToRecord(withOffer),\n );\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 * 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 | SubscriptionPurchase;\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"],"mappings":";;;;;;;;;;;;;;AAAA;;AAEA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;AACA;;AAOA;;AAWA;;;;;;AAcA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC,WAAxB;EAAqCC;AAArC,IAA0DC,0BAAhE;AACA,MAAMC,8BAA8B,GAAGC,kBAAA,CAAYC,IAAnD;AACA,MAAMC,qBAAqB,GAAGF,kBAAA,CAAYG,KAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMO,MAAMC,KAAK,GAAG,YAIV;EAAA,IAJW;IACpBC,YAAY,GAAG;EADK,CAIX,uEAAP,EAAO;;EACT,QAAQA,YAAR;IACE,KAAK,gBAAL;MACE,IAAAC,uBAAA;MACA;;IACF,KAAK,gBAAL;MACE,IAAAC,uBAAA;MACA;;IACF,KAAK,sBAAL;MACE,IAAAC,4BAAA;MACA;;IACF;MACE;EAXJ;AAaD,CAlBM;AAoBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,cAAc,GAAG,MAC5B,IAAAC,yBAAA,IAAkBD,cAAlB,EADK;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAME,aAAa,GAAG,MAC3B,IAAAD,yBAAA,IAAkBC,aAAlB,EADK;AAGP;AACA;AACA;AACA;;;;;AACO,MAAMC,0CAA0C,GACrD,MACE,IAAAC,0BAAA,IAAmBC,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;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ACA;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,MAAM0B,mBAAmB,GAAG;EAAA,IAAC;IAClClB,GADkC;IAElCC,+CAA+C,GAAG,KAFhB;IAGlCkB,oBAHkC;IAIlCC,oBAAoB,GAAG,CAAC,CAJU;IAKlClB,0BALkC;IAMlCC,0BANkC;IAOlCkB,kBAAkB,GAAGf,SAPa;IAOF;IAChCD,mBAAmB,GAAGC,SARY;IAQD;IACjCF,eATkC;IAUlCG,QAVkC;IAWlCC;EAXkC,CAAD;EAAA,OAajC,CACE1C,qBAAA,CAASC,MAAT,CAAgB;IACdC,GAAG,EAAE,YAAY;MACf,IAAI,CAACgC,GAAL,EAAU;QACR,OAAOjB,OAAO,CAACC,MAAR,CACL,IAAIC,KAAJ,CAAU,sCAAV,CADK,CAAP;MAGD;;MACD,IAAIgB,+CAAJ,EAAqD;QACnDQ,OAAO,CAACC,IAAR,CACE,wXADF;MAGD;;MAED,IAAI,IAAAxC,wBAAA,GAAJ,EAAsB;QACpB,MAAMyC,KAAK,GAAG,IAAAC,oBAAA,EAAYJ,SAAZ,CAAd;QAEA,OAAOhE,WAAW,CAACqE,UAAZ,CACLb,GADK,EAELC,+CAFK,EAGLG,eAHK,EAILG,QAAQ,IAAI,CAAC,CAJR,EAKLI,KALK,CAAP;MAOD,CAVD,MAUO;QACL,OAAOpE,QAAQ,CAACsE,UAAT,CACLb,GADK,EAELC,+CAFK,EAGLG,eAHK,EAILG,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,aAAa,GAAGH,QAAQ,CAACG,aAA/B;;MAEA,IAAI,CAACA,aAAL,EAAoB;QAClB,OAAO7C,OAAO,CAACC,MAAR,CACL,IAAIC,KAAJ,CAAU,kDAAV,CADK,CAAP;MAGD;;MACD,OAAO,IAAA4C,sBAAA,IAAeL,iBAAf,CAAiCI,aAAjC,CAAP;IACD,CAVa;IAWdjD,OAAO,EAAE,YAAY;MACnB,IAAI8C,QAAJ,aAAIA,QAAJ,eAAIA,QAAQ,CAAEK,aAAd,EAA6B;QAC3B,IAAIJ,YAAJ,EAAkB;UAChB,OAAO,IAAAhE,0BAAA,IAAmBqE,cAAnB,CACLN,QAAQ,CAACK,aADJ,EAELH,uBAFK,CAAP;QAID,CALD,MAKO,IACLF,QAAQ,CAACO,YAAT,IACC,CAACP,QAAQ,CAACQ,qBAAV,IACCR,QAAQ,CAACS,oBAAT,KAAkCC,2BAAA,CAAqBC,SAHpD,EAIL;UACA,OAAO,IAAA1E,0BAAA,IAAmB2E,mBAAnB,CACLZ,QAAQ,CAACK,aADJ,EAELH,uBAFK,CAAP;QAID,CATM,MASA;UACL,OAAO5C,OAAO,CAACC,MAAR,CACL,IAAIC,KAAJ,CAAU,0CAAV,CADK,CAAP;QAGD;MACF;;MACD,OAAOF,OAAO,CAACC,MAAR,CACL,IAAIC,KAAJ,CAAU,0CAAV,CADK,CAAP;IAGD;EApCa,CAAhB,MAqCO,MAAMF,OAAO,CAACC,MAAR,CAAe,IAAIC,KAAJ,CAAU,sBAAV,CAAf,CArCb,CADK,GAAP;AAwCD,CAjDM"}
1
+ {"version":3,"names":["RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","NativeModules","ANDROID_ITEM_TYPE_SUBSCRIPTION","ProductType","subs","ANDROID_ITEM_TYPE_IAP","inapp","setup","storekitMode","storekit1Mode","storekit2Mode","storekitHybridMode","initConnection","getNativeModule","endConnection","flushFailedPurchasesCachedAsPendingAndroid","getAndroidModule","flushFailedPurchasesCachedAsPending","getProducts","skus","Platform","select","ios","items","isIosStorekit2","getItems","map","productSk2Map","filter","item","includes","productId","type","android","products","getItemsByType","fillProductsWithAdditionalData","Promise","reject","Error","getSubscriptions","subscriptionSk2Map","addSubscriptionPlatform","SubscriptionPlatform","androidPlatform","getAndroidModuleType","subscriptions","castSubscriptions","amazon","platform","subscription","getPurchaseHistory","alsoPublishToEventListener","automaticallyFinishRestoredTransactions","resolve","getAvailableItems","transactionSk2Map","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","request","sku","andDangerouslyFinishTransactionAutomaticallyIOS","appAccountToken","quantity","withOffer","console","warn","offer","offerSk2Map","buyProduct","offerToRecord","isAmazon","buyItemByType","length","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","isOfferPersonalized","undefined","requestSubscription","subscriptionOffers","purchaseTokenAndroid","prorationModeAndroid","so","offerToken","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","getIosModule","purchaseToken","consumeProduct","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PurchaseStateAndroid","PURCHASED","acknowledgePurchase"],"sources":["iap.ts"],"sourcesContent":["import {NativeModules, Platform} from 'react-native';\n\nimport * as IapAmazon from './modules/amazon';\nimport * as IapAndroid from './modules/android';\nimport * as IapIos from './modules/ios';\nimport * as IapIosSk2 from './modules/iosSk2';\nimport {offerToRecord} from './types/apple';\nimport {\n offerSk2Map,\n ProductSk2,\n productSk2Map,\n subscriptionSk2Map,\n transactionSk2Map,\n} from './types/appleSk2';\nimport {\n fillProductsWithAdditionalData,\n getAndroidModule,\n getAndroidModuleType,\n getIosModule,\n getNativeModule,\n isAmazon,\n isIosStorekit2,\n storekit1Mode,\n storekit2Mode,\n storekitHybridMode,\n} from './internal';\nimport {\n Product,\n ProductPurchase,\n ProductType,\n PurchaseResult,\n PurchaseStateAndroid,\n RequestPurchase,\n RequestSubscription,\n Subscription,\n SubscriptionAmazon,\n SubscriptionAndroid,\n SubscriptionIOS,\n SubscriptionPlatform,\n SubscriptionPurchase,\n} from './types';\n\nexport {IapAndroid, IapAmazon, IapIos, IapIosSk2, isIosStorekit2};\n\nconst {RNIapIos, RNIapIosSk2, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = ProductType.subs;\nconst ANDROID_ITEM_TYPE_IAP = ProductType.inapp;\n\n/**\n * STOREKIT1_MODE: Will not enable Storekit 2 even if the device supports it. Thigs will work as before,\n * minimum changes required in the migration guide (default)\n * HYBRID_MODE: Will enable Storekit 2 for iOS devices > 15.0 but will fallback to Sk1 on older devices\n * There are some edge cases that you need to handle in this case (described in migration guide). This mode\n * is for developers that are migrating to Storekit 2 but want to keep supporting older versions.\n * STOREKIT2_MODE: Will *only* enable Storekit 2. This disables Storekit 1. This is for apps that\n * have already targeted a min version of 15 for their app.\n */\nexport type STOREKIT_OPTIONS =\n | 'STOREKIT1_MODE'\n | 'STOREKIT_HYBRID_MODE'\n | 'STOREKIT2_MODE';\n\nexport const setup = ({\n storekitMode = 'STOREKIT1_MODE',\n}: {\n storekitMode?: STOREKIT_OPTIONS;\n} = {}) => {\n switch (storekitMode) {\n case 'STOREKIT1_MODE':\n storekit1Mode();\n break;\n case 'STOREKIT2_MODE':\n storekit2Mode();\n break;\n case 'STOREKIT_HYBRID_MODE':\n storekitHybridMode();\n break;\n default:\n break;\n }\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 let items: Product[];\n if (isIosStorekit2()) {\n items = ((await RNIapIosSk2.getItems(skus)) as ProductSk2[]).map(\n productSk2Map,\n );\n } else {\n items = (await RNIapIos.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 (): Promise<SubscriptionIOS[]> => {\n let items: SubscriptionIOS[];\n if (isIosStorekit2()) {\n items = ((await RNIapIosSk2.getItems(skus)) as ProductSk2[]).map(\n subscriptionSk2Map,\n );\n } else {\n items = (await RNIapIos.getItems(skus)) as SubscriptionIOS[];\n }\n\n items = items.filter(\n (item: SubscriptionIOS) =>\n skus.includes(item.productId) && item.type === 'subs',\n );\n\n return addSubscriptionPlatform(items, SubscriptionPlatform.ios);\n },\n android: async (): Promise<Subscription[]> => {\n const androidPlatform = getAndroidModuleType();\n\n let subscriptions = (await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n )) as SubscriptionAndroid[] | SubscriptionAmazon[];\n\n switch (androidPlatform) {\n case 'android': {\n const castSubscriptions = subscriptions as SubscriptionAndroid[];\n return addSubscriptionPlatform(\n castSubscriptions,\n SubscriptionPlatform.android,\n );\n }\n case 'amazon':\n let castSubscriptions = subscriptions as SubscriptionAmazon[];\n castSubscriptions = await fillProductsWithAdditionalData(\n castSubscriptions,\n );\n return addSubscriptionPlatform(\n castSubscriptions,\n SubscriptionPlatform.amazon,\n );\n case null:\n default:\n throw new Error(\n `getSubscriptions received unknown platform ${androidPlatform}. Verify the logic in getAndroidModuleType`,\n );\n }\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n\n/**\n * Adds an extra property to subscriptions so we can distinguish the platform\n * we retrieved them on.\n */\nconst addSubscriptionPlatform = <T>(\n subscriptions: T[],\n platform: SubscriptionPlatform,\n): T[] => {\n return subscriptions.map((subscription) => ({...subscription, 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@param {alsoPublishToEventListener}:boolean. (IOS Sk2 only) When `true`, every element will also be pushed to the purchaseUpdated listener.\nNote that this is only for backaward compatiblity. It won't publish to transactionUpdated (Storekit2) Defaults to `false`\n@param {automaticallyFinishRestoredTransactions}:boolean. (IOS Sk1 only) When `true`, all the transactions that are returned are automatically\nfinished. This means that if you call this method again you won't get the same result on the same device. On the other hand, if `false` you'd\nhave to manually finish the returned transaction once you have delivered the content to your user.\n */\nexport const getPurchaseHistory = ({\n alsoPublishToEventListener = false,\n automaticallyFinishRestoredTransactions = true,\n}: {\n alsoPublishToEventListener?: boolean;\n automaticallyFinishRestoredTransactions?: boolean;\n} = {}): Promise<(ProductPurchase | SubscriptionPurchase)[]> =>\n (\n Platform.select({\n ios: async () => {\n if (isIosStorekit2()) {\n return Promise.resolve(\n (\n await RNIapIosSk2.getAvailableItems(alsoPublishToEventListener)\n ).map(transactionSk2Map),\n );\n } else {\n return RNIapIos.getAvailableItems(\n automaticallyFinishRestoredTransactions,\n );\n }\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@param {alsoPublishToEventListener}:boolean When `true`, every element will also be pushed to the purchaseUpdated listener.\nNote that this is only for backaward compatiblity. It won't publish to transactionUpdated (Storekit2) Defaults to `false`\n *\n */\nexport const getAvailablePurchases = ({\n alsoPublishToEventListener = false,\n automaticallyFinishRestoredTransactions = false,\n}: {\n alsoPublishToEventListener?: boolean;\n automaticallyFinishRestoredTransactions?: boolean;\n} = {}): Promise<(ProductPurchase | SubscriptionPurchase)[]> =>\n (\n Platform.select({\n ios: async () => {\n if (isIosStorekit2()) {\n return Promise.resolve(\n (\n await RNIapIosSk2.getAvailableItems(alsoPublishToEventListener)\n ).map(transactionSk2Map),\n );\n } else {\n return RNIapIos.getAvailableItems(\n automaticallyFinishRestoredTransactions,\n );\n }\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 request: RequestPurchase,\n): Promise<ProductPurchase | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!('sku' in request)) {\n throw new Error('sku is required for iOS purchase');\n }\n\n const {\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n appAccountToken,\n quantity,\n withOffer,\n } = request;\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 if (isIosStorekit2()) {\n const offer = offerSk2Map(withOffer);\n\n return RNIapIosSk2.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n );\n } else {\n return RNIapIos.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offerToRecord(withOffer),\n );\n }\n },\n android: async () => {\n if (isAmazon) {\n if (!('sku' in request)) {\n throw new Error('sku is required for Amazon purchase');\n }\n const {sku} = request;\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!('skus' in request) || !request.skus.length) {\n throw new Error('skus is required for Android purchase');\n }\n\n const {\n skus,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized,\n } = request;\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n skus,\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 request: RequestSubscription,\n): Promise<SubscriptionPurchase | null | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!('sku' in request)) {\n throw new Error('sku is required for iOS subscriptions');\n }\n\n const {\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n appAccountToken,\n quantity,\n withOffer,\n } = request;\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 if (isIosStorekit2()) {\n const offer = offerSk2Map(withOffer);\n\n return RNIapIosSk2.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n );\n } else {\n return RNIapIos.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offerToRecord(withOffer),\n );\n }\n },\n android: async () => {\n if (isAmazon) {\n if (!('sku' in request)) {\n throw new Error('sku is required for Amazon subscriptions');\n }\n const {sku} = request;\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (\n !('subscriptionOffers' in request) ||\n request.subscriptionOffers.length === 0\n ) {\n throw new Error(\n 'subscriptionOffers are required for Google Play subscriptions',\n );\n }\n\n const {\n subscriptionOffers,\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized,\n } = request;\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 * 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 | SubscriptionPurchase;\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"],"mappings":";;;;;;;;;;;;;;AAAA;;AAEA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;AACA;;AAOA;;AAYA;;;;;;AAkBA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC,WAAxB;EAAqCC;AAArC,IAA0DC,0BAAhE;AACA,MAAMC,8BAA8B,GAAGC,kBAAA,CAAYC,IAAnD;AACA,MAAMC,qBAAqB,GAAGF,kBAAA,CAAYG,KAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMO,MAAMC,KAAK,GAAG,YAIV;EAAA,IAJW;IACpBC,YAAY,GAAG;EADK,CAIX,uEAAP,EAAO;;EACT,QAAQA,YAAR;IACE,KAAK,gBAAL;MACE,IAAAC,uBAAA;MACA;;IACF,KAAK,gBAAL;MACE,IAAAC,uBAAA;MACA;;IACF,KAAK,sBAAL;MACE,IAAAC,4BAAA;MACA;;IACF;MACE;EAXJ;AAaD,CAlBM;AAoBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,cAAc,GAAG,MAC5B,IAAAC,yBAAA,IAAkBD,cAAlB,EADK;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAME,aAAa,GAAG,MAC3B,IAAAD,yBAAA,IAAkBC,aAAlB,EADK;AAGP;AACA;AACA;AACA;;;;;AACO,MAAMC,0CAA0C,GACrD,MACE,IAAAC,0BAAA,IAAmBC,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,MAAMC,WAAW,GAAG;EAAA,IAAC;IAC1BC;EAD0B,CAAD;EAAA,OAKzB,CACEC,qBAAA,CAASC,MAAT,CAAgB;IACdC,GAAG,EAAE,YAAY;MACf,IAAIC,KAAJ;;MACA,IAAI,IAAAC,wBAAA,GAAJ,EAAsB;QACpBD,KAAK,GAAG,CAAE,MAAMzB,WAAW,CAAC2B,QAAZ,CAAqBN,IAArB,CAAR,EAAqDO,GAArD,CACNC,sBADM,CAAR;MAGD,CAJD,MAIO;QACLJ,KAAK,GAAI,MAAM1B,QAAQ,CAAC4B,QAAT,CAAkBN,IAAlB,CAAf;MACD;;MACD,OAAOI,KAAK,CAACK,MAAN,CACJC,IAAD,IACEV,IAAI,CAACW,QAAL,CAAcD,IAAI,CAACE,SAAnB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AMqE,aAAa,GAAGH,QAAQ,CAACG,aAA/B;;MAEA,IAAI,CAACA,aAAL,EAAoB;QAClB,OAAOtD,OAAO,CAACC,MAAR,CACL,IAAIC,KAAJ,CAAU,kDAAV,CADK,CAAP;MAGD;;MACD,OAAO,IAAAqD,sBAAA,IAAeL,iBAAf,CAAiCI,aAAjC,CAAP;IACD,CAVa;IAWd1D,OAAO,EAAE,YAAY;MACnB,IAAIuD,QAAJ,aAAIA,QAAJ,eAAIA,QAAQ,CAAEK,aAAd,EAA6B;QAC3B,IAAIJ,YAAJ,EAAkB;UAChB,OAAO,IAAAzE,0BAAA,IAAmB8E,cAAnB,CACLN,QAAQ,CAACK,aADJ,EAELH,uBAFK,CAAP;QAID,CALD,MAKO,IACLF,QAAQ,CAACO,YAAT,IACC,CAACP,QAAQ,CAACQ,qBAAV,IACCR,QAAQ,CAACS,oBAAT,KAAkCC,2BAAA,CAAqBC,SAHpD,EAIL;UACA,OAAO,IAAAnF,0BAAA,IAAmBoF,mBAAnB,CACLZ,QAAQ,CAACK,aADJ,EAELH,uBAFK,CAAP;QAID,CATM,MASA;UACL,OAAOrD,OAAO,CAACC,MAAR,CACL,IAAIC,KAAJ,CAAU,0CAAV,CADK,CAAP;QAGD;MACF;;MACD,OAAOF,OAAO,CAACC,MAAR,CACL,IAAIC,KAAJ,CAAU,0CAAV,CADK,CAAP;IAGD;EApCa,CAAhB,MAqCO,MAAMF,OAAO,CAACC,MAAR,CAAe,IAAIC,KAAJ,CAAU,sBAAV,CAAf,CArCb,CADK,GAAP;AAwCD,CAjDM"}
@@ -11,7 +11,8 @@ const {
11
11
  RNIapAmazonModule
12
12
  } = _reactNative.NativeModules;
13
13
  /**
14
- * Fill products with additional data
14
+ * For Amazon products, we add the currency code from the user's information
15
+ * since it isn't included in the product information.
15
16
  */
16
17
 
17
18
  const fillProductsWithAdditionalData = async items => {
@@ -1 +1 @@
1
- {"version":3,"names":["RNIapAmazonModule","NativeModules","fillProductsWithAdditionalData","items","user","getUser","currencies","CA","ES","AU","DE","IN","US","JP","GB","IT","BR","FR","currency","userMarketplaceAmazon","forEach","item"],"sources":["fillProductsWithAdditionalData.ts"],"sourcesContent":["import {NativeModules} from 'react-native';\n\nimport type {ProductCommon} from '../types';\n\nconst {RNIapAmazonModule} = NativeModules;\n\n/**\n * Fill products with additional data\n */\nexport const fillProductsWithAdditionalData = async <T extends ProductCommon>(\n items: T[],\n) => {\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 items\n items.forEach((item) => {\n if (currency) {\n item.currency = currency;\n }\n });\n }\n\n return items;\n};\n"],"mappings":";;;;;;;AAAA;;AAIA,MAAM;EAACA;AAAD,IAAsBC,0BAA5B;AAEA;AACA;AACA;;AACO,MAAMC,8BAA8B,GAAG,MAC5CC,KAD4C,IAEzC;EACH,IAAIH,iBAAJ,EAAuB;IACrB;IACA,MAAMI,IAAI,GAAG,MAAMJ,iBAAiB,CAACK,OAAlB,EAAnB;IAEA,MAAMC,UAAU,GAAG;MACjBC,EAAE,EAAE,KADa;MAEjBC,EAAE,EAAE,KAFa;MAGjBC,EAAE,EAAE,KAHa;MAIjBC,EAAE,EAAE,KAJa;MAKjBC,EAAE,EAAE,KALa;MAMjBC,EAAE,EAAE,KANa;MAOjBC,EAAE,EAAE,KAPa;MAQjBC,EAAE,EAAE,KARa;MASjBC,EAAE,EAAE,KATa;MAUjBC,EAAE,EAAE,KAVa;MAWjBC,EAAE,EAAE;IAXa,CAAnB;IAcA,MAAMC,QAAQ,GACZZ,UAAU,CAACF,IAAI,CAACe,qBAAN,CADZ,CAlBqB,CAqBrB;;IACAhB,KAAK,CAACiB,OAAN,CAAeC,IAAD,IAAU;MACtB,IAAIH,QAAJ,EAAc;QACZG,IAAI,CAACH,QAAL,GAAgBA,QAAhB;MACD;IACF,CAJD;EAKD;;EAED,OAAOf,KAAP;AACD,CAjCM"}
1
+ {"version":3,"names":["RNIapAmazonModule","NativeModules","fillProductsWithAdditionalData","items","user","getUser","currencies","CA","ES","AU","DE","IN","US","JP","GB","IT","BR","FR","currency","userMarketplaceAmazon","forEach","item"],"sources":["fillProductsWithAdditionalData.ts"],"sourcesContent":["import {NativeModules} from 'react-native';\n\nimport type {ProductCommon} from '../types';\n\nconst {RNIapAmazonModule} = NativeModules;\n\n/**\n * For Amazon products, we add the currency code from the user's information\n * since it isn't included in the product information.\n */\nexport const fillProductsWithAdditionalData = async <T extends ProductCommon>(\n items: T[],\n): Promise<T[]> => {\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 items\n items.forEach((item) => {\n if (currency) {\n item.currency = currency;\n }\n });\n }\n\n return items;\n};\n"],"mappings":";;;;;;;AAAA;;AAIA,MAAM;EAACA;AAAD,IAAsBC,0BAA5B;AAEA;AACA;AACA;AACA;;AACO,MAAMC,8BAA8B,GAAG,MAC5CC,KAD4C,IAE3B;EACjB,IAAIH,iBAAJ,EAAuB;IACrB;IACA,MAAMI,IAAI,GAAG,MAAMJ,iBAAiB,CAACK,OAAlB,EAAnB;IAEA,MAAMC,UAAU,GAAG;MACjBC,EAAE,EAAE,KADa;MAEjBC,EAAE,EAAE,KAFa;MAGjBC,EAAE,EAAE,KAHa;MAIjBC,EAAE,EAAE,KAJa;MAKjBC,EAAE,EAAE,KALa;MAMjBC,EAAE,EAAE,KANa;MAOjBC,EAAE,EAAE,KAPa;MAQjBC,EAAE,EAAE,KARa;MASjBC,EAAE,EAAE,KATa;MAUjBC,EAAE,EAAE,KAVa;MAWjBC,EAAE,EAAE;IAXa,CAAnB;IAcA,MAAMC,QAAQ,GACZZ,UAAU,CAACF,IAAI,CAACe,qBAAN,CADZ,CAlBqB,CAqBrB;;IACAhB,KAAK,CAACiB,OAAN,CAAeC,IAAD,IAAU;MACtB,IAAIH,QAAJ,EAAc;QACZG,IAAI,CAACH,QAAL,GAAgBA,QAAhB;MACD;IACF,CAJD;EAKD;;EAED,OAAOf,KAAP;AACD,CAjCM"}
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.storekitHybridMode = exports.storekit2Mode = exports.storekit1Mode = exports.setIosNativeModule = exports.setAndroidNativeModule = exports.isStorekit2Avaiable = exports.isPlay = exports.isIosStorekit2 = exports.isIos = exports.isAndroid = exports.isAmazon = exports.getNativeModule = exports.getIosModule = exports.getAndroidModule = exports.checkNativeAndroidAvailable = void 0;
6
+ exports.storekitHybridMode = exports.storekit2Mode = exports.storekit1Mode = exports.setIosNativeModule = exports.setAndroidNativeModule = exports.isStorekit2Avaiable = exports.isPlay = exports.isIosStorekit2 = exports.isIos = exports.isAndroid = exports.isAmazon = exports.getNativeModule = exports.getIosModule = exports.getAndroidModuleType = exports.getAndroidModule = exports.checkNativeAndroidAvailable = void 0;
7
7
 
8
8
  var _reactNative = require("react-native");
9
9
 
@@ -37,6 +37,11 @@ const checkNativeAndroidAvailable = () => {
37
37
  throw new Error(_purchaseError.ErrorCode.E_IAP_NOT_AVAILABLE);
38
38
  }
39
39
  };
40
+ /**
41
+ * If changing the typings of `getAndroidModule` to accommodate extra modules,
42
+ * make sure to update `getAndroidModuleType`.
43
+ */
44
+
40
45
 
41
46
  exports.checkNativeAndroidAvailable = checkNativeAndroidAvailable;
42
47
 
@@ -44,9 +49,31 @@ const getAndroidModule = () => {
44
49
  checkNativeAndroidAvailable();
45
50
  return androidNativeModule ? androidNativeModule : RNIapModule ? RNIapModule : RNIapAmazonModule;
46
51
  };
52
+ /**
53
+ * Returns whether the Android in-app-purchase code is using the Android,
54
+ * Amazon, or another store.
55
+ */
56
+
47
57
 
48
58
  exports.getAndroidModule = getAndroidModule;
49
59
 
60
+ const getAndroidModuleType = () => {
61
+ const module = getAndroidModule();
62
+
63
+ switch (module) {
64
+ case RNIapModule:
65
+ return 'android';
66
+
67
+ case RNIapAmazonModule:
68
+ return 'amazon';
69
+
70
+ default:
71
+ return null;
72
+ }
73
+ };
74
+
75
+ exports.getAndroidModuleType = getAndroidModuleType;
76
+
50
77
  const getNativeModule = () => {
51
78
  return isAndroid ? getAndroidModule() : getIosModule();
52
79
  }; // iOS