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.
- package/lib/commonjs/iap.js +143 -110
- package/lib/commonjs/iap.js.map +1 -1
- package/lib/commonjs/internal/fillProductsWithAdditionalData.js +2 -1
- package/lib/commonjs/internal/fillProductsWithAdditionalData.js.map +1 -1
- package/lib/commonjs/internal/platform.js +28 -1
- package/lib/commonjs/internal/platform.js.map +1 -1
- package/lib/commonjs/modules/android.js +14 -1
- package/lib/commonjs/modules/android.js.map +1 -1
- package/lib/commonjs/modules/ios.js +24 -12
- package/lib/commonjs/modules/ios.js.map +1 -1
- package/lib/commonjs/types/appleSk2.js +3 -0
- package/lib/commonjs/types/appleSk2.js.map +1 -1
- package/lib/commonjs/types/index.js +15 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/iap.js +143 -111
- package/lib/module/iap.js.map +1 -1
- package/lib/module/internal/fillProductsWithAdditionalData.js +2 -1
- package/lib/module/internal/fillProductsWithAdditionalData.js.map +1 -1
- package/lib/module/internal/platform.js +24 -0
- package/lib/module/internal/platform.js.map +1 -1
- package/lib/module/modules/android.js +15 -2
- package/lib/module/modules/android.js.map +1 -1
- package/lib/module/modules/ios.js +25 -13
- package/lib/module/modules/ios.js.map +1 -1
- package/lib/module/types/appleSk2.js +2 -0
- package/lib/module/types/appleSk2.js.map +1 -1
- package/lib/module/types/index.js +12 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/iap.d.ts +4 -4
- package/lib/typescript/internal/fillProductsWithAdditionalData.d.ts +2 -1
- package/lib/typescript/internal/platform.d.ts +9 -0
- package/lib/typescript/modules/android.d.ts +1 -1
- package/lib/typescript/modules/ios.d.ts +4 -4
- package/lib/typescript/types/index.d.ts +54 -28
- package/package.json +1 -1
- package/src/iap.ts +130 -74
- package/src/internal/fillProductsWithAdditionalData.ts +3 -2
- package/src/internal/platform.ts +20 -0
- package/src/modules/android.ts +16 -7
- package/src/modules/ios.ts +35 -20
- package/src/types/appleSk2.ts +2 -0
- package/src/types/index.ts +70 -30
package/lib/module/iap.js
CHANGED
|
@@ -5,9 +5,8 @@ import * as IapIos from './modules/ios';
|
|
|
5
5
|
import * as IapIosSk2 from './modules/iosSk2';
|
|
6
6
|
import { offerToRecord } from './types/apple';
|
|
7
7
|
import { offerSk2Map, productSk2Map, subscriptionSk2Map, transactionSk2Map } from './types/appleSk2';
|
|
8
|
-
import { fillProductsWithAdditionalData, getAndroidModule, getIosModule, getNativeModule, isAmazon, isIosStorekit2, storekit1Mode, storekit2Mode, storekitHybridMode } from './internal';
|
|
9
|
-
import { ProductType } from './types';
|
|
10
|
-
import { PurchaseStateAndroid } from './types';
|
|
8
|
+
import { fillProductsWithAdditionalData, getAndroidModule, getAndroidModuleType, getIosModule, getNativeModule, isAmazon, isIosStorekit2, storekit1Mode, storekit2Mode, storekitHybridMode } from './internal';
|
|
9
|
+
import { ProductType, PurchaseStateAndroid, SubscriptionPlatform } from './types';
|
|
11
10
|
export { IapAndroid, IapAmazon, IapIos, IapIosSk2, isIosStorekit2 };
|
|
12
11
|
const {
|
|
13
12
|
RNIapIos,
|
|
@@ -200,14 +199,42 @@ export const getSubscriptions = _ref2 => {
|
|
|
200
199
|
items = await RNIapIos.getItems(skus);
|
|
201
200
|
}
|
|
202
201
|
|
|
203
|
-
|
|
202
|
+
items = items.filter(item => skus.includes(item.productId) && item.type === 'subs');
|
|
203
|
+
return addSubscriptionPlatform(items, SubscriptionPlatform.ios);
|
|
204
204
|
},
|
|
205
205
|
android: async () => {
|
|
206
|
-
const
|
|
207
|
-
|
|
206
|
+
const androidPlatform = getAndroidModuleType();
|
|
207
|
+
let subscriptions = await getAndroidModule().getItemsByType(ANDROID_ITEM_TYPE_SUBSCRIPTION, skus);
|
|
208
|
+
|
|
209
|
+
switch (androidPlatform) {
|
|
210
|
+
case 'android':
|
|
211
|
+
{
|
|
212
|
+
const castSubscriptions = subscriptions;
|
|
213
|
+
return addSubscriptionPlatform(castSubscriptions, SubscriptionPlatform.android);
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
case 'amazon':
|
|
217
|
+
let castSubscriptions = subscriptions;
|
|
218
|
+
castSubscriptions = await fillProductsWithAdditionalData(castSubscriptions);
|
|
219
|
+
return addSubscriptionPlatform(castSubscriptions, SubscriptionPlatform.amazon);
|
|
220
|
+
|
|
221
|
+
case null:
|
|
222
|
+
default:
|
|
223
|
+
throw new Error(`getSubscriptions received unknown platform ${androidPlatform}. Verify the logic in getAndroidModuleType`);
|
|
224
|
+
}
|
|
208
225
|
}
|
|
209
226
|
}) || (() => Promise.reject(new Error('Unsupported Platform'))))();
|
|
210
227
|
};
|
|
228
|
+
/**
|
|
229
|
+
* Adds an extra property to subscriptions so we can distinguish the platform
|
|
230
|
+
* we retrieved them on.
|
|
231
|
+
*/
|
|
232
|
+
|
|
233
|
+
const addSubscriptionPlatform = (subscriptions, platform) => {
|
|
234
|
+
return subscriptions.map(subscription => ({ ...subscription,
|
|
235
|
+
platform
|
|
236
|
+
}));
|
|
237
|
+
};
|
|
211
238
|
/**
|
|
212
239
|
* Gets an inventory of purchases made by the user regardless of consumption status
|
|
213
240
|
* ## Usage
|
|
@@ -232,11 +259,12 @@ const App = () => {
|
|
|
232
259
|
```
|
|
233
260
|
@param {alsoPublishToEventListener}:boolean. (IOS Sk2 only) When `true`, every element will also be pushed to the purchaseUpdated listener.
|
|
234
261
|
Note that this is only for backaward compatiblity. It won't publish to transactionUpdated (Storekit2) Defaults to `false`
|
|
235
|
-
@param {automaticallyFinishRestoredTransactions}:boolean. (IOS Sk1 only) When `true`, all the transactions that are returned are automatically
|
|
236
|
-
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
|
|
262
|
+
@param {automaticallyFinishRestoredTransactions}:boolean. (IOS Sk1 only) When `true`, all the transactions that are returned are automatically
|
|
263
|
+
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
|
|
237
264
|
have to manually finish the returned transaction once you have delivered the content to your user.
|
|
238
265
|
*/
|
|
239
266
|
|
|
267
|
+
|
|
240
268
|
export const getPurchaseHistory = function () {
|
|
241
269
|
let {
|
|
242
270
|
alsoPublishToEventListener = false,
|
|
@@ -339,7 +367,7 @@ const App = () => {
|
|
|
339
367
|
```
|
|
340
368
|
@param {alsoPublishToEventListener}:boolean When `true`, every element will also be pushed to the purchaseUpdated listener.
|
|
341
369
|
Note that this is only for backaward compatiblity. It won't publish to transactionUpdated (Storekit2) Defaults to `false`
|
|
342
|
-
*
|
|
370
|
+
*
|
|
343
371
|
*/
|
|
344
372
|
|
|
345
373
|
export const getAvailablePurchases = function () {
|
|
@@ -381,22 +409,22 @@ always keeping at false, and verifying the transaction receipts on the server-si
|
|
|
381
409
|
|
|
382
410
|
```ts
|
|
383
411
|
requestPurchase(
|
|
384
|
-
The product's sku/ID
|
|
412
|
+
The product's sku/ID
|
|
385
413
|
sku,
|
|
386
414
|
|
|
387
|
-
|
|
415
|
+
|
|
388
416
|
* You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.
|
|
389
417
|
* @default false
|
|
390
|
-
|
|
418
|
+
|
|
391
419
|
andDangerouslyFinishTransactionAutomaticallyIOS = false,
|
|
392
420
|
|
|
393
|
-
/** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
|
|
421
|
+
/** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
|
|
394
422
|
obfuscatedAccountIdAndroid,
|
|
395
423
|
|
|
396
|
-
Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
|
|
424
|
+
Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
|
|
397
425
|
obfuscatedProfileIdAndroid,
|
|
398
426
|
|
|
399
|
-
The purchaser's user ID
|
|
427
|
+
The purchaser's user ID
|
|
400
428
|
applicationUsername,
|
|
401
429
|
): Promise<ProductPurchase>;
|
|
402
430
|
```
|
|
@@ -434,54 +462,56 @@ const App = () => {
|
|
|
434
462
|
|
|
435
463
|
*/
|
|
436
464
|
|
|
437
|
-
export const requestPurchase =
|
|
438
|
-
|
|
439
|
-
sku
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
obfuscatedProfileIdAndroid,
|
|
443
|
-
appAccountToken,
|
|
444
|
-
skus,
|
|
445
|
-
// Android Billing V5
|
|
446
|
-
isOfferPersonalized = undefined,
|
|
447
|
-
// Android Billing V5
|
|
448
|
-
quantity,
|
|
449
|
-
withOffer
|
|
450
|
-
} = _ref3;
|
|
451
|
-
return (Platform.select({
|
|
452
|
-
ios: async () => {
|
|
453
|
-
if (!sku) {
|
|
454
|
-
return Promise.reject(new Error('sku is required for iOS purchase'));
|
|
455
|
-
}
|
|
465
|
+
export const requestPurchase = request => (Platform.select({
|
|
466
|
+
ios: async () => {
|
|
467
|
+
if (!('sku' in request)) {
|
|
468
|
+
throw new Error('sku is required for iOS purchase');
|
|
469
|
+
}
|
|
456
470
|
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
471
|
+
const {
|
|
472
|
+
sku,
|
|
473
|
+
andDangerouslyFinishTransactionAutomaticallyIOS = false,
|
|
474
|
+
appAccountToken,
|
|
475
|
+
quantity,
|
|
476
|
+
withOffer
|
|
477
|
+
} = request;
|
|
460
478
|
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
} else {
|
|
465
|
-
return RNIapIos.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, offerToRecord(withOffer));
|
|
466
|
-
}
|
|
467
|
-
},
|
|
468
|
-
android: async () => {
|
|
469
|
-
if (isAmazon) {
|
|
470
|
-
if (!sku) {
|
|
471
|
-
return Promise.reject(new Error('sku is required for Amazon purchase'));
|
|
472
|
-
}
|
|
479
|
+
if (andDangerouslyFinishTransactionAutomaticallyIOS) {
|
|
480
|
+
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.');
|
|
481
|
+
}
|
|
473
482
|
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
483
|
+
if (isIosStorekit2()) {
|
|
484
|
+
const offer = offerSk2Map(withOffer);
|
|
485
|
+
return RNIapIosSk2.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, offer);
|
|
486
|
+
} else {
|
|
487
|
+
return RNIapIos.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, offerToRecord(withOffer));
|
|
488
|
+
}
|
|
489
|
+
},
|
|
490
|
+
android: async () => {
|
|
491
|
+
if (isAmazon) {
|
|
492
|
+
if (!('sku' in request)) {
|
|
493
|
+
throw new Error('sku is required for Amazon purchase');
|
|
494
|
+
}
|
|
479
495
|
|
|
480
|
-
|
|
496
|
+
const {
|
|
497
|
+
sku
|
|
498
|
+
} = request;
|
|
499
|
+
return RNIapAmazonModule.buyItemByType(sku);
|
|
500
|
+
} else {
|
|
501
|
+
if (!('skus' in request) || !request.skus.length) {
|
|
502
|
+
throw new Error('skus is required for Android purchase');
|
|
481
503
|
}
|
|
504
|
+
|
|
505
|
+
const {
|
|
506
|
+
skus,
|
|
507
|
+
obfuscatedAccountIdAndroid,
|
|
508
|
+
obfuscatedProfileIdAndroid,
|
|
509
|
+
isOfferPersonalized
|
|
510
|
+
} = request;
|
|
511
|
+
return getAndroidModule().buyItemByType(ANDROID_ITEM_TYPE_IAP, skus, undefined, -1, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, [], isOfferPersonalized ?? false);
|
|
482
512
|
}
|
|
483
|
-
}
|
|
484
|
-
};
|
|
513
|
+
}
|
|
514
|
+
}) || Promise.resolve)();
|
|
485
515
|
/**
|
|
486
516
|
* Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
|
|
487
517
|
* Request a purchase for a subscription.
|
|
@@ -497,7 +527,7 @@ always keeping at false, and verifying the transaction receipts on the server-si
|
|
|
497
527
|
|
|
498
528
|
```ts
|
|
499
529
|
requestSubscription(
|
|
500
|
-
The product's sku/ID
|
|
530
|
+
The product's sku/ID
|
|
501
531
|
sku,
|
|
502
532
|
|
|
503
533
|
|
|
@@ -506,19 +536,19 @@ requestSubscription(
|
|
|
506
536
|
|
|
507
537
|
andDangerouslyFinishTransactionAutomaticallyIOS = false,
|
|
508
538
|
|
|
509
|
-
purchaseToken that the user is upgrading or downgrading from (Android).
|
|
539
|
+
purchaseToken that the user is upgrading or downgrading from (Android).
|
|
510
540
|
purchaseTokenAndroid,
|
|
511
541
|
|
|
512
|
-
UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED
|
|
542
|
+
UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED
|
|
513
543
|
prorationModeAndroid = -1,
|
|
514
544
|
|
|
515
|
-
/** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
|
|
545
|
+
/** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.
|
|
516
546
|
obfuscatedAccountIdAndroid,
|
|
517
547
|
|
|
518
|
-
Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
|
|
548
|
+
Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.
|
|
519
549
|
obfuscatedProfileIdAndroid,
|
|
520
550
|
|
|
521
|
-
The purchaser's user ID
|
|
551
|
+
The purchaser's user ID
|
|
522
552
|
applicationUsername,
|
|
523
553
|
): Promise<SubscriptionPurchase>
|
|
524
554
|
```
|
|
@@ -560,56 +590,58 @@ const App = () => {
|
|
|
560
590
|
```
|
|
561
591
|
*/
|
|
562
592
|
|
|
563
|
-
export const requestSubscription =
|
|
564
|
-
|
|
565
|
-
sku
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
prorationModeAndroid = -1,
|
|
569
|
-
obfuscatedAccountIdAndroid,
|
|
570
|
-
obfuscatedProfileIdAndroid,
|
|
571
|
-
subscriptionOffers = undefined,
|
|
572
|
-
// Android Billing V5
|
|
573
|
-
isOfferPersonalized = undefined,
|
|
574
|
-
// Android Billing V5
|
|
575
|
-
appAccountToken,
|
|
576
|
-
quantity,
|
|
577
|
-
withOffer
|
|
578
|
-
} = _ref4;
|
|
579
|
-
return (Platform.select({
|
|
580
|
-
ios: async () => {
|
|
581
|
-
if (!sku) {
|
|
582
|
-
return Promise.reject(new Error('sku is required for iOS subscription'));
|
|
583
|
-
}
|
|
593
|
+
export const requestSubscription = request => (Platform.select({
|
|
594
|
+
ios: async () => {
|
|
595
|
+
if (!('sku' in request)) {
|
|
596
|
+
throw new Error('sku is required for iOS subscriptions');
|
|
597
|
+
}
|
|
584
598
|
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
599
|
+
const {
|
|
600
|
+
sku,
|
|
601
|
+
andDangerouslyFinishTransactionAutomaticallyIOS = false,
|
|
602
|
+
appAccountToken,
|
|
603
|
+
quantity,
|
|
604
|
+
withOffer
|
|
605
|
+
} = request;
|
|
588
606
|
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
} else {
|
|
593
|
-
return RNIapIos.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, offerToRecord(withOffer));
|
|
594
|
-
}
|
|
595
|
-
},
|
|
596
|
-
android: async () => {
|
|
597
|
-
if (isAmazon) {
|
|
598
|
-
if (!sku) {
|
|
599
|
-
return Promise.reject(new Error('sku is required for Amazon purchase'));
|
|
600
|
-
}
|
|
607
|
+
if (andDangerouslyFinishTransactionAutomaticallyIOS) {
|
|
608
|
+
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.');
|
|
609
|
+
}
|
|
601
610
|
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
611
|
+
if (isIosStorekit2()) {
|
|
612
|
+
const offer = offerSk2Map(withOffer);
|
|
613
|
+
return RNIapIosSk2.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, offer);
|
|
614
|
+
} else {
|
|
615
|
+
return RNIapIos.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, offerToRecord(withOffer));
|
|
616
|
+
}
|
|
617
|
+
},
|
|
618
|
+
android: async () => {
|
|
619
|
+
if (isAmazon) {
|
|
620
|
+
if (!('sku' in request)) {
|
|
621
|
+
throw new Error('sku is required for Amazon subscriptions');
|
|
622
|
+
}
|
|
607
623
|
|
|
608
|
-
|
|
624
|
+
const {
|
|
625
|
+
sku
|
|
626
|
+
} = request;
|
|
627
|
+
return RNIapAmazonModule.buyItemByType(sku);
|
|
628
|
+
} else {
|
|
629
|
+
if (!('subscriptionOffers' in request) || request.subscriptionOffers.length === 0) {
|
|
630
|
+
throw new Error('subscriptionOffers are required for Google Play subscriptions');
|
|
609
631
|
}
|
|
632
|
+
|
|
633
|
+
const {
|
|
634
|
+
subscriptionOffers,
|
|
635
|
+
purchaseTokenAndroid,
|
|
636
|
+
prorationModeAndroid,
|
|
637
|
+
obfuscatedAccountIdAndroid,
|
|
638
|
+
obfuscatedProfileIdAndroid,
|
|
639
|
+
isOfferPersonalized
|
|
640
|
+
} = request;
|
|
641
|
+
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);
|
|
610
642
|
}
|
|
611
|
-
}
|
|
612
|
-
};
|
|
643
|
+
}
|
|
644
|
+
}) || (() => Promise.resolve(null)))();
|
|
613
645
|
/**
|
|
614
646
|
* Finish Transaction (both platforms)
|
|
615
647
|
* Abstracts Finish Transaction
|
|
@@ -617,7 +649,7 @@ export const requestSubscription = _ref4 => {
|
|
|
617
649
|
* Call this after you have persisted the purchased state to your server or local data in your app.
|
|
618
650
|
* `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.**
|
|
619
651
|
* Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.
|
|
620
|
-
*
|
|
652
|
+
*
|
|
621
653
|
```tsx
|
|
622
654
|
import React from 'react';
|
|
623
655
|
import {Button} from 'react-native';
|
|
@@ -632,15 +664,15 @@ const App = () => {
|
|
|
632
664
|
|
|
633
665
|
return <Button title="Buy product" onPress={handlePurchase} />;
|
|
634
666
|
};
|
|
635
|
-
```
|
|
667
|
+
```
|
|
636
668
|
*/
|
|
637
669
|
|
|
638
|
-
export const finishTransaction =
|
|
670
|
+
export const finishTransaction = _ref3 => {
|
|
639
671
|
let {
|
|
640
672
|
purchase,
|
|
641
673
|
isConsumable,
|
|
642
674
|
developerPayloadAndroid
|
|
643
|
-
} =
|
|
675
|
+
} = _ref3;
|
|
644
676
|
return (Platform.select({
|
|
645
677
|
ios: async () => {
|
|
646
678
|
const transactionId = purchase.transactionId;
|
package/lib/module/iap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","Platform","IapAmazon","IapAndroid","IapIos","IapIosSk2","offerToRecord","offerSk2Map","productSk2Map","subscriptionSk2Map","transactionSk2Map","fillProductsWithAdditionalData","getAndroidModule","getIosModule","getNativeModule","isAmazon","isIosStorekit2","storekit1Mode","storekit2Mode","storekitHybridMode","ProductType","PurchaseStateAndroid","RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","ANDROID_ITEM_TYPE_SUBSCRIPTION","subs","ANDROID_ITEM_TYPE_IAP","inapp","setup","storekitMode","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","select","ios","items","getItems","map","filter","item","includes","productId","type","android","products","getItemsByType","Promise","reject","Error","getSubscriptions","subscriptions","getPurchaseHistory","alsoPublishToEventListener","automaticallyFinishRestoredTransactions","resolve","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","appAccountToken","isOfferPersonalized","undefined","quantity","withOffer","console","warn","offer","buyProduct","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","so","offerToken","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","purchaseToken","consumeProduct","userIdAmazon","isAcknowledgedAndroid","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,SAAQA,aAAR,EAAuBC,QAAvB,QAAsC,cAAtC;AAEA,OAAO,KAAKC,SAAZ,MAA2B,kBAA3B;AACA,OAAO,KAAKC,UAAZ,MAA4B,mBAA5B;AACA,OAAO,KAAKC,MAAZ,MAAwB,eAAxB;AACA,OAAO,KAAKC,SAAZ,MAA2B,kBAA3B;AACA,SAAQC,aAAR,QAA4B,eAA5B;AACA,SACEC,WADF,EAGEC,aAHF,EAIEC,kBAJF,EAKEC,iBALF,QAMO,kBANP;AAOA,SACEC,8BADF,EAEEC,gBAFF,EAGEC,YAHF,EAIEC,eAJF,EAKEC,QALF,EAMEC,cANF,EAOEC,aAPF,EAQEC,aARF,EASEC,kBATF,QAUO,YAVP;AAWA,SAGEC,WAHF,QASO,SATP;AAUA,SAAQC,oBAAR,QAAmC,SAAnC;AAEA,SAAQlB,UAAR,EAAoBD,SAApB,EAA+BE,MAA/B,EAAuCC,SAAvC,EAAkDW,cAAlD;AAEA,MAAM;EAACM,QAAD;EAAWC,WAAX;EAAwBC,WAAxB;EAAqCC;AAArC,IAA0DzB,aAAhE;AACA,MAAM0B,8BAA8B,GAAGN,WAAW,CAACO,IAAnD;AACA,MAAMC,qBAAqB,GAAGR,WAAW,CAACS,KAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAO,MAAMC,KAAK,GAAG,YAIV;EAAA,IAJW;IACpBC,YAAY,GAAG;EADK,CAIX,uEAAP,EAAO;;EACT,QAAQA,YAAR;IACE,KAAK,gBAAL;MACEd,aAAa;MACb;;IACF,KAAK,gBAAL;MACEC,aAAa;MACb;;IACF,KAAK,sBAAL;MACEC,kBAAkB;MAClB;;IACF;MACE;EAXJ;AAaD,CAlBM;AAoBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMa,cAAc,GAAG,MAC5BlB,eAAe,GAAGkB,cAAlB,EADK;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG,MAC3BnB,eAAe,GAAGmB,aAAlB,EADK;AAGP;AACA;AACA;AACA;;AACA,OAAO,MAAMC,0CAA0C,GACrD,MACEtB,gBAAgB,GAAGuB,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;;AACA,OAAO,MAAMC,WAAW,GAAG;EAAA,IAAC;IAC1BC;EAD0B,CAAD;EAAA,OAKzB,CACEpC,QAAQ,CAACqC,MAAT,CAAgB;IACdC,GAAG,EAAE,YAAY;MACf,IAAIC,KAAJ;;MACA,IAAIxB,cAAc,EAAlB,EAAsB;QACpBwB,KAAK,GAAG,CAAE,MAAMjB,WAAW,CAACkB,QAAZ,CAAqBJ,IAArB,CAAR,EAAqDK,GAArD,CACNlC,aADM,CAAR;MAGD,CAJD,MAIO;QACLgC,KAAK,GAAI,MAAMlB,QAAQ,CAACmB,QAAT,CAAkBJ,IAAlB,CAAf;MACD;;MACD,OAAOG,KAAK,CAACG,MAAN,CACJC,IAAD,IACEP,IAAI,CAACQ,QAAL,CAAcD,IAAI,CAACE,SAAnB,KAAiCF,IAAI,CAACG,IAAL,KAAc,KAF5C,CAAP;IAID,CAda;IAedC,OAAO,EAAE,YAAY;MACnB,MAAMC,QAAQ,GAAG,MAAMrC,gBAAgB,GAAGsC,cAAnB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AAR,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":["NativeModules","Platform","IapAmazon","IapAndroid","IapIos","IapIosSk2","offerToRecord","offerSk2Map","productSk2Map","subscriptionSk2Map","transactionSk2Map","fillProductsWithAdditionalData","getAndroidModule","getAndroidModuleType","getIosModule","getNativeModule","isAmazon","isIosStorekit2","storekit1Mode","storekit2Mode","storekitHybridMode","ProductType","PurchaseStateAndroid","SubscriptionPlatform","RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","ANDROID_ITEM_TYPE_SUBSCRIPTION","subs","ANDROID_ITEM_TYPE_IAP","inapp","setup","storekitMode","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","select","ios","items","getItems","map","filter","item","includes","productId","type","android","products","getItemsByType","Promise","reject","Error","getSubscriptions","addSubscriptionPlatform","androidPlatform","subscriptions","castSubscriptions","amazon","platform","subscription","getPurchaseHistory","alsoPublishToEventListener","automaticallyFinishRestoredTransactions","resolve","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","request","sku","andDangerouslyFinishTransactionAutomaticallyIOS","appAccountToken","quantity","withOffer","console","warn","offer","buyProduct","buyItemByType","length","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","isOfferPersonalized","undefined","requestSubscription","subscriptionOffers","purchaseTokenAndroid","prorationModeAndroid","so","offerToken","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","purchaseToken","consumeProduct","userIdAmazon","isAcknowledgedAndroid","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"],"mapp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OAAOtF,gBAAgB,GAAG0F,cAAnB,CACLL,QAAQ,CAACI,aADJ,EAELF,uBAFK,CAAP;QAID,CALD,MAKO,IACLF,QAAQ,CAACM,YAAT,IACC,CAACN,QAAQ,CAACO,qBAAV,IACCP,QAAQ,CAACQ,oBAAT,KAAkCnF,oBAAoB,CAACoF,SAHpD,EAIL;UACA,OAAO9F,gBAAgB,GAAG+F,mBAAnB,CACLV,QAAQ,CAACI,aADJ,EAELF,uBAFK,CAAP;QAID,CATM,MASA;UACL,OAAO9C,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"}
|
|
@@ -3,7 +3,8 @@ const {
|
|
|
3
3
|
RNIapAmazonModule
|
|
4
4
|
} = NativeModules;
|
|
5
5
|
/**
|
|
6
|
-
*
|
|
6
|
+
* For Amazon products, we add the currency code from the user's information
|
|
7
|
+
* since it isn't included in the product information.
|
|
7
8
|
*/
|
|
8
9
|
|
|
9
10
|
export const fillProductsWithAdditionalData = async items => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","RNIapAmazonModule","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 *
|
|
1
|
+
{"version":3,"names":["NativeModules","RNIapAmazonModule","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,SAAQA,aAAR,QAA4B,cAA5B;AAIA,MAAM;EAACC;AAAD,IAAsBD,aAA5B;AAEA;AACA;AACA;AACA;;AACA,OAAO,MAAME,8BAA8B,GAAG,MAC5CC,KAD4C,IAE3B;EACjB,IAAIF,iBAAJ,EAAuB;IACrB;IACA,MAAMG,IAAI,GAAG,MAAMH,iBAAiB,CAACI,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"}
|
|
@@ -20,10 +20,34 @@ export const checkNativeAndroidAvailable = () => {
|
|
|
20
20
|
throw new Error(ErrorCode.E_IAP_NOT_AVAILABLE);
|
|
21
21
|
}
|
|
22
22
|
};
|
|
23
|
+
/**
|
|
24
|
+
* If changing the typings of `getAndroidModule` to accommodate extra modules,
|
|
25
|
+
* make sure to update `getAndroidModuleType`.
|
|
26
|
+
*/
|
|
27
|
+
|
|
23
28
|
export const getAndroidModule = () => {
|
|
24
29
|
checkNativeAndroidAvailable();
|
|
25
30
|
return androidNativeModule ? androidNativeModule : RNIapModule ? RNIapModule : RNIapAmazonModule;
|
|
26
31
|
};
|
|
32
|
+
/**
|
|
33
|
+
* Returns whether the Android in-app-purchase code is using the Android,
|
|
34
|
+
* Amazon, or another store.
|
|
35
|
+
*/
|
|
36
|
+
|
|
37
|
+
export const getAndroidModuleType = () => {
|
|
38
|
+
const module = getAndroidModule();
|
|
39
|
+
|
|
40
|
+
switch (module) {
|
|
41
|
+
case RNIapModule:
|
|
42
|
+
return 'android';
|
|
43
|
+
|
|
44
|
+
case RNIapAmazonModule:
|
|
45
|
+
return 'amazon';
|
|
46
|
+
|
|
47
|
+
default:
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
27
51
|
export const getNativeModule = () => {
|
|
28
52
|
return isAndroid ? getAndroidModule() : getIosModule();
|
|
29
53
|
}; // iOS
|