react-native-iap 11.0.0-beta.1 → 11.0.0-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -1
- package/ios/IapSerializationUtils.swift +30 -0
- package/ios/RNIapIosSk2.m +5 -0
- package/ios/RNIapIosSk2.swift +63 -49
- package/lib/commonjs/eventEmitter.js +4 -4
- package/lib/commonjs/eventEmitter.js.map +1 -1
- package/lib/commonjs/hooks/withIAPContext.js +1 -1
- package/lib/commonjs/hooks/withIAPContext.js.map +1 -1
- package/lib/commonjs/iap.js +50 -297
- package/lib/commonjs/iap.js.map +1 -1
- package/lib/commonjs/internal/platform.js +75 -2
- package/lib/commonjs/internal/platform.js.map +1 -1
- package/lib/commonjs/modules/amazon.js +28 -1
- package/lib/commonjs/modules/amazon.js.map +1 -1
- package/lib/commonjs/modules/android.js +73 -1
- package/lib/commonjs/modules/android.js.map +1 -1
- package/lib/commonjs/modules/ios.js +126 -0
- package/lib/commonjs/modules/ios.js.map +1 -1
- package/lib/commonjs/modules/iosSk2.js +47 -0
- package/lib/commonjs/modules/iosSk2.js.map +1 -1
- package/lib/commonjs/types/appleSk2.js.map +1 -1
- package/lib/module/eventEmitter.js +2 -2
- package/lib/module/eventEmitter.js.map +1 -1
- package/lib/module/hooks/withIAPContext.js +2 -2
- package/lib/module/hooks/withIAPContext.js.map +1 -1
- package/lib/module/iap.js +8 -223
- package/lib/module/iap.js.map +1 -1
- package/lib/module/internal/platform.js +48 -1
- package/lib/module/internal/platform.js.map +1 -1
- package/lib/module/modules/amazon.js +23 -0
- package/lib/module/modules/amazon.js.map +1 -1
- package/lib/module/modules/android.js +59 -1
- package/lib/module/modules/android.js.map +1 -1
- package/lib/module/modules/ios.js +102 -1
- package/lib/module/modules/ios.js.map +1 -1
- package/lib/module/modules/iosSk2.js +30 -1
- package/lib/module/modules/iosSk2.js.map +1 -1
- package/lib/module/types/appleSk2.js.map +1 -1
- package/lib/typescript/iap.d.ts +7 -120
- package/lib/typescript/internal/platform.d.ts +9 -0
- package/lib/typescript/modules/amazon.d.ts +17 -0
- package/lib/typescript/modules/android.d.ts +38 -1
- package/lib/typescript/modules/ios.d.ts +56 -0
- package/lib/typescript/modules/iosSk2.d.ts +27 -1
- package/lib/typescript/types/appleSk2.d.ts +4 -0
- package/package.json +1 -1
- package/src/eventEmitter.ts +4 -3
- package/src/hooks/withIAPContext.tsx +2 -2
- package/src/iap.ts +20 -297
- package/src/internal/platform.ts +78 -1
- package/src/modules/amazon.ts +29 -1
- package/src/modules/android.ts +83 -2
- package/src/modules/ios.ts +121 -0
- package/src/modules/iosSk2.ts +45 -1
- package/src/types/appleSk2.ts +12 -0
package/lib/commonjs/iap.js
CHANGED
|
@@ -3,16 +3,50 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.IapIosSk2 = exports.IapIos = exports.IapAndroid = exports.IapAmazon = void 0;
|
|
7
|
+
Object.defineProperty(exports, "enableStorekit2", {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: function () {
|
|
10
|
+
return _internal.enableStorekit2;
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
exports.initConnection = exports.getSubscriptions = exports.getPurchaseHistory = exports.getProducts = exports.getAvailablePurchases = exports.flushFailedPurchasesCachedAsPendingAndroid = exports.finishTransaction = exports.endConnection = void 0;
|
|
14
|
+
Object.defineProperty(exports, "isIosStorekit2", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () {
|
|
17
|
+
return _internal.isIosStorekit2;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
exports.requestSubscription = exports.requestPurchase = void 0;
|
|
7
21
|
|
|
8
22
|
var _reactNative = require("react-native");
|
|
9
23
|
|
|
24
|
+
var IapAmazon = _interopRequireWildcard(require("./modules/amazon"));
|
|
25
|
+
|
|
26
|
+
exports.IapAmazon = IapAmazon;
|
|
27
|
+
|
|
28
|
+
var IapAndroid = _interopRequireWildcard(require("./modules/android"));
|
|
29
|
+
|
|
30
|
+
exports.IapAndroid = IapAndroid;
|
|
31
|
+
|
|
32
|
+
var IapIos = _interopRequireWildcard(require("./modules/ios"));
|
|
33
|
+
|
|
34
|
+
exports.IapIos = IapIos;
|
|
35
|
+
|
|
36
|
+
var IapIosSk2 = _interopRequireWildcard(require("./modules/iosSk2"));
|
|
37
|
+
|
|
38
|
+
exports.IapIosSk2 = IapIosSk2;
|
|
39
|
+
|
|
10
40
|
var _appleSk = require("./types/appleSk2");
|
|
11
41
|
|
|
12
42
|
var _internal = require("./internal");
|
|
13
43
|
|
|
14
44
|
var _types = require("./types");
|
|
15
45
|
|
|
46
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
47
|
+
|
|
48
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
49
|
+
|
|
16
50
|
const {
|
|
17
51
|
RNIapIos,
|
|
18
52
|
RNIapIosSk2,
|
|
@@ -21,76 +55,6 @@ const {
|
|
|
21
55
|
} = _reactNative.NativeModules;
|
|
22
56
|
const ANDROID_ITEM_TYPE_SUBSCRIPTION = _types.ProductType.subs;
|
|
23
57
|
const ANDROID_ITEM_TYPE_IAP = _types.ProductType.inapp;
|
|
24
|
-
|
|
25
|
-
const getInstallSourceAndroid = () => {
|
|
26
|
-
return RNIapModule ? _types.InstallSourceAndroid.GOOGLE_PLAY : _types.InstallSourceAndroid.AMAZON;
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
exports.getInstallSourceAndroid = getInstallSourceAndroid;
|
|
30
|
-
let androidNativeModule = RNIapModule;
|
|
31
|
-
let iosNativeModule = RNIapIos;
|
|
32
|
-
|
|
33
|
-
const isIosStorekit2 = () => iosNativeModule === RNIapIosSk2;
|
|
34
|
-
|
|
35
|
-
exports.isIosStorekit2 = isIosStorekit2;
|
|
36
|
-
|
|
37
|
-
const isStorekit2Avaiable = () => !!RNIapIosSk2;
|
|
38
|
-
|
|
39
|
-
exports.isStorekit2Avaiable = isStorekit2Avaiable;
|
|
40
|
-
|
|
41
|
-
const enableStorekit2 = () => {
|
|
42
|
-
if (RNIapIosSk2) {
|
|
43
|
-
iosNativeModule = RNIapIosSk2;
|
|
44
|
-
return true;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
console.warn('Storekit 2 is not available on this device');
|
|
48
|
-
return false;
|
|
49
|
-
};
|
|
50
|
-
|
|
51
|
-
exports.enableStorekit2 = enableStorekit2;
|
|
52
|
-
|
|
53
|
-
const setAndroidNativeModule = nativeModule => {
|
|
54
|
-
androidNativeModule = nativeModule;
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
exports.setAndroidNativeModule = setAndroidNativeModule;
|
|
58
|
-
|
|
59
|
-
const setIosNativeModule = nativeModule => {
|
|
60
|
-
iosNativeModule = nativeModule;
|
|
61
|
-
};
|
|
62
|
-
|
|
63
|
-
exports.setIosNativeModule = setIosNativeModule;
|
|
64
|
-
|
|
65
|
-
const checkNativeAndroidAvailable = () => {
|
|
66
|
-
if (!RNIapModule && !RNIapAmazonModule) {
|
|
67
|
-
throw new Error('IAP_NOT_AVAILABLE');
|
|
68
|
-
}
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
const getAndroidModule = () => {
|
|
72
|
-
checkNativeAndroidAvailable();
|
|
73
|
-
return androidNativeModule ? androidNativeModule : RNIapModule ? RNIapModule : RNIapAmazonModule;
|
|
74
|
-
};
|
|
75
|
-
|
|
76
|
-
exports.getAndroidModule = getAndroidModule;
|
|
77
|
-
|
|
78
|
-
const checkNativeIOSAvailable = () => {
|
|
79
|
-
if (!RNIapIos && !RNIapIosSk2) {
|
|
80
|
-
throw new Error('IAP_NOT_AVAILABLE');
|
|
81
|
-
}
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
const getIosModule = () => {
|
|
85
|
-
checkNativeIOSAvailable();
|
|
86
|
-
return iosNativeModule ? iosNativeModule : RNIapIosSk2 ? RNIapIosSk2 : RNIapIos;
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
exports.getIosModule = getIosModule;
|
|
90
|
-
|
|
91
|
-
const getNativeModule = () => {
|
|
92
|
-
return _internal.isAndroid ? getAndroidModule() : getIosModule();
|
|
93
|
-
};
|
|
94
58
|
/**
|
|
95
59
|
* Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.
|
|
96
60
|
* ## Usage
|
|
@@ -110,10 +74,7 @@ const App = () => {
|
|
|
110
74
|
```
|
|
111
75
|
*/
|
|
112
76
|
|
|
113
|
-
|
|
114
|
-
exports.getNativeModule = getNativeModule;
|
|
115
|
-
|
|
116
|
-
const initConnection = () => getNativeModule().initConnection();
|
|
77
|
+
const initConnection = () => (0, _internal.getNativeModule)().initConnection();
|
|
117
78
|
/**
|
|
118
79
|
* Disconnects from native SDK
|
|
119
80
|
* Usage
|
|
@@ -138,7 +99,7 @@ const App = () => {
|
|
|
138
99
|
|
|
139
100
|
exports.initConnection = initConnection;
|
|
140
101
|
|
|
141
|
-
const endConnection = () => getNativeModule().endConnection();
|
|
102
|
+
const endConnection = () => (0, _internal.getNativeModule)().endConnection();
|
|
142
103
|
/**
|
|
143
104
|
* Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.
|
|
144
105
|
* @returns {Promise<boolean>}
|
|
@@ -147,7 +108,7 @@ const endConnection = () => getNativeModule().endConnection();
|
|
|
147
108
|
|
|
148
109
|
exports.endConnection = endConnection;
|
|
149
110
|
|
|
150
|
-
const flushFailedPurchasesCachedAsPendingAndroid = () => getAndroidModule().flushFailedPurchasesCachedAsPending();
|
|
111
|
+
const flushFailedPurchasesCachedAsPendingAndroid = () => (0, _internal.getAndroidModule)().flushFailedPurchasesCachedAsPending();
|
|
151
112
|
/**
|
|
152
113
|
* Get a list of products (consumable and non-consumable items, but not subscriptions)
|
|
153
114
|
## Usage
|
|
@@ -204,7 +165,7 @@ const getProducts = _ref => {
|
|
|
204
165
|
ios: async () => {
|
|
205
166
|
let items;
|
|
206
167
|
|
|
207
|
-
if (isIosStorekit2()) {
|
|
168
|
+
if ((0, _internal.isIosStorekit2)()) {
|
|
208
169
|
items = (await RNIapIosSk2.getItems(skus)).map(_appleSk.productSk2Map);
|
|
209
170
|
} else {
|
|
210
171
|
items = await RNIapIos.getItems(skus);
|
|
@@ -213,7 +174,7 @@ const getProducts = _ref => {
|
|
|
213
174
|
return items.filter(item => skus.includes(item.productId) && item.type === 'iap');
|
|
214
175
|
},
|
|
215
176
|
android: async () => {
|
|
216
|
-
const products = await getAndroidModule().getItemsByType(ANDROID_ITEM_TYPE_IAP, skus);
|
|
177
|
+
const products = await (0, _internal.getAndroidModule)().getItemsByType(ANDROID_ITEM_TYPE_IAP, skus);
|
|
217
178
|
return (0, _internal.fillProductsWithAdditionalData)(products);
|
|
218
179
|
}
|
|
219
180
|
}) || (() => Promise.reject(new Error('Unsupported Platform'))))();
|
|
@@ -251,7 +212,7 @@ const getSubscriptions = _ref2 => {
|
|
|
251
212
|
ios: async () => {
|
|
252
213
|
let items;
|
|
253
214
|
|
|
254
|
-
if (isIosStorekit2()) {
|
|
215
|
+
if ((0, _internal.isIosStorekit2)()) {
|
|
255
216
|
items = (await RNIapIosSk2.getItems(skus)).map(_appleSk.subscriptionSk2Map);
|
|
256
217
|
} else {
|
|
257
218
|
items = await RNIapIos.getItems(skus);
|
|
@@ -260,7 +221,7 @@ const getSubscriptions = _ref2 => {
|
|
|
260
221
|
return items.filter(item => skus.includes(item.productId) && item.type === 'subs');
|
|
261
222
|
},
|
|
262
223
|
android: async () => {
|
|
263
|
-
const subscriptions = await getAndroidModule().getItemsByType(ANDROID_ITEM_TYPE_SUBSCRIPTION, skus);
|
|
224
|
+
const subscriptions = await (0, _internal.getAndroidModule)().getItemsByType(ANDROID_ITEM_TYPE_SUBSCRIPTION, skus);
|
|
264
225
|
return (0, _internal.fillProductsWithAdditionalData)(subscriptions);
|
|
265
226
|
}
|
|
266
227
|
}) || (() => Promise.reject(new Error('Unsupported Platform'))))();
|
|
@@ -294,7 +255,7 @@ exports.getSubscriptions = getSubscriptions;
|
|
|
294
255
|
|
|
295
256
|
const getPurchaseHistory = () => (_reactNative.Platform.select({
|
|
296
257
|
ios: async () => {
|
|
297
|
-
return getIosModule().getAvailableItems();
|
|
258
|
+
return (0, _internal.getIosModule)().getAvailableItems();
|
|
298
259
|
},
|
|
299
260
|
android: async () => {
|
|
300
261
|
if (RNIapAmazonModule) {
|
|
@@ -390,7 +351,7 @@ exports.getPurchaseHistory = getPurchaseHistory;
|
|
|
390
351
|
|
|
391
352
|
const getAvailablePurchases = () => (_reactNative.Platform.select({
|
|
392
353
|
ios: async () => {
|
|
393
|
-
return getIosModule().getAvailableItems();
|
|
354
|
+
return (0, _internal.getIosModule)().getAvailableItems();
|
|
394
355
|
},
|
|
395
356
|
android: async () => {
|
|
396
357
|
if (RNIapAmazonModule) {
|
|
@@ -497,7 +458,7 @@ const requestPurchase = _ref3 => {
|
|
|
497
458
|
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.');
|
|
498
459
|
}
|
|
499
460
|
|
|
500
|
-
if (isIosStorekit2()) {
|
|
461
|
+
if ((0, _internal.isIosStorekit2)()) {
|
|
501
462
|
const offer = (0, _appleSk.offerSk2Map)(withOffer);
|
|
502
463
|
return RNIapIosSk2.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, offer);
|
|
503
464
|
} else {
|
|
@@ -516,7 +477,7 @@ const requestPurchase = _ref3 => {
|
|
|
516
477
|
return Promise.reject(new Error('skus is required for Android purchase'));
|
|
517
478
|
}
|
|
518
479
|
|
|
519
|
-
return getAndroidModule().buyItemByType(ANDROID_ITEM_TYPE_IAP, skus !== null && skus !== void 0 && skus.length ? skus : [sku], undefined, -1, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, [], isOfferPersonalized ?? false);
|
|
480
|
+
return (0, _internal.getAndroidModule)().buyItemByType(ANDROID_ITEM_TYPE_IAP, skus !== null && skus !== void 0 && skus.length ? skus : [sku], undefined, -1, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, [], isOfferPersonalized ?? false);
|
|
520
481
|
}
|
|
521
482
|
}
|
|
522
483
|
}) || Promise.resolve)();
|
|
@@ -628,7 +589,7 @@ const requestSubscription = _ref4 => {
|
|
|
628
589
|
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.');
|
|
629
590
|
}
|
|
630
591
|
|
|
631
|
-
if (isIosStorekit2()) {
|
|
592
|
+
if ((0, _internal.isIosStorekit2)()) {
|
|
632
593
|
const offer = (0, _appleSk.offerSk2Map)(withOffer);
|
|
633
594
|
return RNIapIosSk2.buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, appAccountToken, quantity ?? -1, offer);
|
|
634
595
|
} else {
|
|
@@ -694,14 +655,14 @@ const finishTransaction = _ref5 => {
|
|
|
694
655
|
return Promise.reject(new Error('transactionId required to finish iOS transaction'));
|
|
695
656
|
}
|
|
696
657
|
|
|
697
|
-
return getIosModule().finishTransaction(transactionId);
|
|
658
|
+
return (0, _internal.getIosModule)().finishTransaction(transactionId);
|
|
698
659
|
},
|
|
699
660
|
android: async () => {
|
|
700
661
|
if (purchase !== null && purchase !== void 0 && purchase.purchaseToken) {
|
|
701
662
|
if (isConsumable) {
|
|
702
|
-
return getAndroidModule().consumeProduct(purchase.purchaseToken, developerPayloadAndroid);
|
|
663
|
+
return (0, _internal.getAndroidModule)().consumeProduct(purchase.purchaseToken, developerPayloadAndroid);
|
|
703
664
|
} else if (purchase.userIdAmazon || !purchase.isAcknowledgedAndroid && purchase.purchaseStateAndroid === _types.PurchaseStateAndroid.PURCHASED) {
|
|
704
|
-
return getAndroidModule().acknowledgePurchase(purchase.purchaseToken, developerPayloadAndroid);
|
|
665
|
+
return (0, _internal.getAndroidModule)().acknowledgePurchase(purchase.purchaseToken, developerPayloadAndroid);
|
|
705
666
|
} else {
|
|
706
667
|
return Promise.reject(new Error('purchase is not suitable to be purchased'));
|
|
707
668
|
}
|
|
@@ -711,214 +672,6 @@ const finishTransaction = _ref5 => {
|
|
|
711
672
|
}
|
|
712
673
|
}) || (() => Promise.reject(new Error('Unsupported Platform'))))();
|
|
713
674
|
};
|
|
714
|
-
/**
|
|
715
|
-
* Clear Transaction (iOS only)
|
|
716
|
-
* Finish remaining transactions. Related to issue #257 and #801
|
|
717
|
-
* link : https://github.com/dooboolab/react-native-iap/issues/257
|
|
718
|
-
* https://github.com/dooboolab/react-native-iap/issues/801
|
|
719
|
-
* @returns {Promise<void>}
|
|
720
|
-
*/
|
|
721
|
-
|
|
722
675
|
|
|
723
676
|
exports.finishTransaction = finishTransaction;
|
|
724
|
-
|
|
725
|
-
const clearTransactionIOS = () => getIosModule().clearTransaction();
|
|
726
|
-
/**
|
|
727
|
-
* Clear valid Products (iOS only)
|
|
728
|
-
* Remove all products which are validated by Apple server.
|
|
729
|
-
* @returns {void}
|
|
730
|
-
*/
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
exports.clearTransactionIOS = clearTransactionIOS;
|
|
734
|
-
|
|
735
|
-
const clearProductsIOS = () => getIosModule().clearProducts();
|
|
736
|
-
/**
|
|
737
|
-
* Acknowledge a product (on Android.) No-op on iOS.
|
|
738
|
-
* @param {string} token The product's token (on Android)
|
|
739
|
-
* @returns {Promise<PurchaseResult | void>}
|
|
740
|
-
*/
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
exports.clearProductsIOS = clearProductsIOS;
|
|
744
|
-
|
|
745
|
-
const acknowledgePurchaseAndroid = _ref6 => {
|
|
746
|
-
let {
|
|
747
|
-
token,
|
|
748
|
-
developerPayload
|
|
749
|
-
} = _ref6;
|
|
750
|
-
return getAndroidModule().acknowledgePurchase(token, developerPayload);
|
|
751
|
-
};
|
|
752
|
-
/**
|
|
753
|
-
* Deep link to subscriptions screen on Android. No-op on iOS.
|
|
754
|
-
* @param {string} sku The product's SKU (on Android)
|
|
755
|
-
* @returns {Promise<void>}
|
|
756
|
-
*/
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
exports.acknowledgePurchaseAndroid = acknowledgePurchaseAndroid;
|
|
760
|
-
|
|
761
|
-
const deepLinkToSubscriptionsAndroid = async _ref7 => {
|
|
762
|
-
let {
|
|
763
|
-
sku
|
|
764
|
-
} = _ref7;
|
|
765
|
-
checkNativeAndroidAvailable();
|
|
766
|
-
return _reactNative.Linking.openURL(`https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`);
|
|
767
|
-
};
|
|
768
|
-
/**
|
|
769
|
-
* Should Add Store Payment (iOS only)
|
|
770
|
-
* Indicates the the App Store purchase should continue from the app instead of the App Store.
|
|
771
|
-
* @returns {Promise<Product | null>} promoted product
|
|
772
|
-
*/
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
exports.deepLinkToSubscriptionsAndroid = deepLinkToSubscriptionsAndroid;
|
|
776
|
-
|
|
777
|
-
const getPromotedProductIOS = () => {
|
|
778
|
-
if (!isIosStorekit2) {
|
|
779
|
-
return getIosModule().promotedProduct();
|
|
780
|
-
} else {
|
|
781
|
-
return Promise.reject('Only available on SK1');
|
|
782
|
-
}
|
|
783
|
-
};
|
|
784
|
-
/**
|
|
785
|
-
* Buy the currently selected promoted product (iOS only)
|
|
786
|
-
* Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.
|
|
787
|
-
* @returns {Promise<void>}
|
|
788
|
-
*/
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
exports.getPromotedProductIOS = getPromotedProductIOS;
|
|
792
|
-
|
|
793
|
-
const buyPromotedProductIOS = () => getIosModule().buyPromotedProduct();
|
|
794
|
-
|
|
795
|
-
exports.buyPromotedProductIOS = buyPromotedProductIOS;
|
|
796
|
-
const TEST_RECEIPT = 21007;
|
|
797
|
-
|
|
798
|
-
const requestAgnosticReceiptValidationIos = async receiptBody => {
|
|
799
|
-
const response = await (0, _internal.enhancedFetch)('https://buy.itunes.apple.com/verifyReceipt', {
|
|
800
|
-
method: 'POST',
|
|
801
|
-
body: receiptBody
|
|
802
|
-
}); // Best practice is to check for test receipt and check sandbox instead
|
|
803
|
-
// https://developer.apple.com/documentation/appstorereceipts/verifyreceipt
|
|
804
|
-
|
|
805
|
-
if (response && response.status === TEST_RECEIPT) {
|
|
806
|
-
const testResponse = await (0, _internal.enhancedFetch)('https://sandbox.itunes.apple.com/verifyReceipt', {
|
|
807
|
-
method: 'POST',
|
|
808
|
-
body: receiptBody
|
|
809
|
-
});
|
|
810
|
-
return testResponse;
|
|
811
|
-
}
|
|
812
|
-
|
|
813
|
-
return response;
|
|
814
|
-
};
|
|
815
|
-
/**
|
|
816
|
-
* Validate receipt for iOS.
|
|
817
|
-
* @param {object} receiptBody the receipt body to send to apple server.
|
|
818
|
-
* @param {boolean} isTest whether this is in test environment which is sandbox.
|
|
819
|
-
* @returns {Promise<Apple.ReceiptValidationResponse | false>}
|
|
820
|
-
*/
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
const validateReceiptIos = async _ref8 => {
|
|
824
|
-
let {
|
|
825
|
-
receiptBody,
|
|
826
|
-
isTest
|
|
827
|
-
} = _ref8;
|
|
828
|
-
|
|
829
|
-
if (isTest == null) {
|
|
830
|
-
return await requestAgnosticReceiptValidationIos(receiptBody);
|
|
831
|
-
}
|
|
832
|
-
|
|
833
|
-
const url = isTest ? 'https://sandbox.itunes.apple.com/verifyReceipt' : 'https://buy.itunes.apple.com/verifyReceipt';
|
|
834
|
-
return await (0, _internal.enhancedFetch)(url);
|
|
835
|
-
};
|
|
836
|
-
/**
|
|
837
|
-
* Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including
|
|
838
|
-
* your access token in the binary you ship to users is potentially dangerous.
|
|
839
|
-
* Use server side validation instead for your production builds
|
|
840
|
-
* @param {string} packageName package name of your app.
|
|
841
|
-
* @param {string} productId product id for your in app product.
|
|
842
|
-
* @param {string} productToken token for your purchase.
|
|
843
|
-
* @param {string} accessToken accessToken from googleApis.
|
|
844
|
-
* @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.
|
|
845
|
-
* @returns {Promise<object>}
|
|
846
|
-
*/
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
exports.validateReceiptIos = validateReceiptIos;
|
|
850
|
-
|
|
851
|
-
const validateReceiptAndroid = async _ref9 => {
|
|
852
|
-
let {
|
|
853
|
-
packageName,
|
|
854
|
-
productId,
|
|
855
|
-
productToken,
|
|
856
|
-
accessToken,
|
|
857
|
-
isSub
|
|
858
|
-
} = _ref9;
|
|
859
|
-
const type = isSub ? 'subscriptions' : 'products';
|
|
860
|
-
const url = 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' + `/${packageName}/purchases/${type}/${productId}` + `/tokens/${productToken}?access_token=${accessToken}`;
|
|
861
|
-
return await (0, _internal.enhancedFetch)(url);
|
|
862
|
-
};
|
|
863
|
-
/**
|
|
864
|
-
* Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including
|
|
865
|
-
* your developer secret in the binary you ship to users is potentially dangerous.
|
|
866
|
-
* Use server side validation instead for your production builds
|
|
867
|
-
* @param {string} developerSecret: from the Amazon developer console.
|
|
868
|
-
* @param {string} userId who purchased the item.
|
|
869
|
-
* @param {string} receiptId long obfuscated string returned when purchasing the item
|
|
870
|
-
* @param {boolean} useSandbox Defaults to true, use sandbox environment or production.
|
|
871
|
-
* @returns {Promise<object>}
|
|
872
|
-
*/
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
exports.validateReceiptAndroid = validateReceiptAndroid;
|
|
876
|
-
|
|
877
|
-
const validateReceiptAmazon = async _ref10 => {
|
|
878
|
-
let {
|
|
879
|
-
developerSecret,
|
|
880
|
-
userId,
|
|
881
|
-
receiptId,
|
|
882
|
-
useSandbox = true
|
|
883
|
-
} = _ref10;
|
|
884
|
-
const sandBoxUrl = useSandbox ? 'sandbox/' : '';
|
|
885
|
-
const url = `https://appstore-sdk.amazon.com/${sandBoxUrl}version/1.0/verifyReceiptId/developer/${developerSecret}/user/${userId}/receiptId/${receiptId}`;
|
|
886
|
-
return await (0, _internal.enhancedFetch)(url);
|
|
887
|
-
};
|
|
888
|
-
/**
|
|
889
|
-
* Get the current receipt base64 encoded in IOS.
|
|
890
|
-
* @param {forceRefresh?:boolean}
|
|
891
|
-
* @returns {Promise<ProductPurchase[]>}
|
|
892
|
-
*/
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
exports.validateReceiptAmazon = validateReceiptAmazon;
|
|
896
|
-
|
|
897
|
-
const getPendingPurchasesIOS = async () => getIosModule().getPendingTransactions();
|
|
898
|
-
/**
|
|
899
|
-
* Get the current receipt base64 encoded in IOS.
|
|
900
|
-
* @param {forceRefresh?:boolean}
|
|
901
|
-
* @returns {Promise<string>}
|
|
902
|
-
*/
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
exports.getPendingPurchasesIOS = getPendingPurchasesIOS;
|
|
906
|
-
|
|
907
|
-
const getReceiptIOS = async _ref11 => {
|
|
908
|
-
let {
|
|
909
|
-
forceRefresh
|
|
910
|
-
} = _ref11;
|
|
911
|
-
return getIosModule().requestReceipt(forceRefresh ?? false);
|
|
912
|
-
};
|
|
913
|
-
/**
|
|
914
|
-
* Launches a modal to register the redeem offer code in IOS.
|
|
915
|
-
* @returns {Promise<null>}
|
|
916
|
-
*/
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
exports.getReceiptIOS = getReceiptIOS;
|
|
920
|
-
|
|
921
|
-
const presentCodeRedemptionSheetIOS = async () => getIosModule().presentCodeRedemptionSheet();
|
|
922
|
-
|
|
923
|
-
exports.presentCodeRedemptionSheetIOS = presentCodeRedemptionSheetIOS;
|
|
924
677
|
//# sourceMappingURL=iap.js.map
|
package/lib/commonjs/iap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","NativeModules","ANDROID_ITEM_TYPE_SUBSCRIPTION","ProductType","subs","ANDROID_ITEM_TYPE_IAP","inapp","getInstallSourceAndroid","InstallSourceAndroid","GOOGLE_PLAY","AMAZON","androidNativeModule","iosNativeModule","isIosStorekit2","isStorekit2Avaiable","enableStorekit2","console","warn","setAndroidNativeModule","nativeModule","setIosNativeModule","checkNativeAndroidAvailable","Error","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","isAndroid","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","Platform","select","ios","items","getItems","map","productSk2Map","filter","item","includes","productId","type","android","products","getItemsByType","fillProductsWithAdditionalData","Promise","reject","getSubscriptions","subscriptionSk2Map","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","resolve","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","appAccountToken","isOfferPersonalized","undefined","quantity","withOffer","offer","offerSk2Map","buyProduct","isAmazon","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","so","offerToken","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","purchaseToken","consumeProduct","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PurchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","Linking","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","TEST_RECEIPT","requestAgnosticReceiptValidationIos","receiptBody","response","enhancedFetch","method","body","status","testResponse","validateReceiptIos","isTest","url","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {Linking, NativeModules, Platform} from 'react-native';\nimport type {ResponseBody as ReceiptValidationResponse} from '@jeremybarbet/apple-api-types';\n\nimport type * as Amazon from './types/amazon';\nimport type * as Android from './types/android';\nimport {\n offerSk2Map,\n ProductSk2,\n productSk2Map,\n subscriptionSk2Map,\n} from './types/appleSk2';\nimport {\n enhancedFetch,\n fillProductsWithAdditionalData,\n isAmazon,\n isAndroid,\n} from './internal';\nimport {\n Product,\n ProductPurchase,\n ProductType,\n PurchaseResult,\n RequestPurchase,\n RequestSubscription,\n Sku,\n Subscription,\n SubscriptionPurchase,\n} from './types';\nimport {InstallSourceAndroid, PurchaseStateAndroid} from './types';\n\nconst {RNIapIos, RNIapIosSk2, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = ProductType.subs;\nconst ANDROID_ITEM_TYPE_IAP = ProductType.inapp;\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nlet androidNativeModule = RNIapModule;\n\nlet iosNativeModule: typeof RNIapIos | typeof RNIapIosSk2 = RNIapIos;\n\nexport const isIosStorekit2 = () => iosNativeModule === RNIapIosSk2;\n\nexport const isStorekit2Avaiable = (): boolean => !!RNIapIosSk2;\n\nexport const enableStorekit2 = () => {\n if (RNIapIosSk2) {\n iosNativeModule = RNIapIosSk2;\n return true;\n }\n console.warn('Storekit 2 is not available on this device');\n\n return false;\n};\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nexport const setIosNativeModule = (\n nativeModule: typeof RNIapIos | typeof RNIapIosSk2,\n): void => {\n iosNativeModule = nativeModule;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getAndroidModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return androidNativeModule\n ? androidNativeModule\n : RNIapModule\n ? RNIapModule\n : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos && !RNIapIosSk2) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getIosModule = (): typeof RNIapIos | typeof RNIapIosSk2 => {\n checkNativeIOSAvailable();\n\n return iosNativeModule\n ? iosNativeModule\n : RNIapIosSk2\n ? RNIapIosSk2\n : RNIapIos;\n};\n\nexport const getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos\n | typeof RNIapIosSk2 => {\n return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * ## Usage\n\n```tsx\nimport React, {useEffect} from 'react';\nimport {View} from 'react-native';\nimport {initConnection} from 'react-native-iap';\n\nconst App = () => {\n useEffect(() => {\n void initConnection();\n }, []);\n\n return <View />;\n};\n```\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * Disconnects from native SDK\n * Usage\n * ```tsx\nimport React, {useEffect} from 'react';\nimport {View} from 'react-native';\nimport {endConnection} from 'react-native-iap';\n\nconst App = () => {\n useEffect(() => {\n return () => {\n void endConnection();\n };\n }, []);\n\n return <View />;\n};\n```\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<boolean> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid =\n (): Promise<boolean> =>\n getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n ## Usage\n\n```ts\nimport React, {useState} from 'react';\nimport {Platform} from 'react-native';\nimport {getProducts, Product} from 'react-native-iap';\n\nconst skus = Platform.select({\n ios: ['com.example.consumableIos'],\n android: ['com.example.consumableAndroid'],\n});\n\nconst App = () => {\n const [products, setProducts] = useState<Product[]>([]);\n\n const handleProducts = async () => {\n const items = await getProducts({skus});\n\n setProducts(items);\n };\n\n useEffect(() => {\n void handleProducts();\n }, []);\n\n return (\n <>\n {products.map((product) => (\n <Text key={product.productId}>{product.productId}</Text>\n ))}\n </>\n );\n};\n```\n\nJust a few things to keep in mind:\n\n- You can get your products in `componentDidMount`, `useEffect` or another appropriate area of your app.\n- Since a user may start your app with a bad or no internet connection, preparing/getting the items more than once may be a good idea.\n- If the user has no IAPs available when the app starts first, you may want to check again when the user enters your IAP store.\n\n */\nexport const getProducts = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n 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 */\nexport const getPurchaseHistory = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await RNIapModule.getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\n/**\n * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)\n * ## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {View} from 'react-native';\nimport {getAvailablePurchases} from 'react-native-iap';\n\nconst App = () => {\n const availablePurchases = useCallback(\n async () => await getAvailablePurchases(),\n [],\n );\n\n return <View />;\n};\n```\n\n## Restoring purchases\n\nYou can use `getAvailablePurchases()` to do what's commonly understood as \"restoring\" purchases.\n\n:::note\nFor debugging you may want to consume all items, you have then to iterate over the purchases returned by `getAvailablePurchases()`.\n:::\n\n:::warning\nBeware that if you consume an item without having recorded the purchase in your database the user may have paid for something without getting it delivered and you will have no way to recover the receipt to validate and restore their purchase.\n:::\n\n```tsx\nimport React from 'react';\nimport {Button} from 'react-native';\nimport {getAvailablePurchases,finishTransaction} from 'react-native-iap';\n\nconst App = () => {\n handleRestore = async () => {\n try {\n const purchases = await getAvailablePurchases();\n const newState = {premium: false, ads: true};\n let titles = [];\n\n await Promise.all(purchases.map(async purchase => {\n switch (purchase.productId) {\n case 'com.example.premium':\n newState.premium = true;\n titles.push('Premium Version');\n break;\n\n case 'com.example.no_ads':\n newState.ads = false;\n titles.push('No Ads');\n break;\n\n case 'com.example.coins100':\n await finishTransaction(purchase.purchaseToken);\n CoinStore.addCoins(100);\n }\n })\n\n Alert.alert(\n 'Restore Successful',\n `You successfully restored the following purchases: ${titles.join(', ')}`,\n );\n } catch (error) {\n console.warn(error);\n Alert.alert(error.message);\n }\n };\n\n return (\n <Button title=\"Restore purchases\" onPress={handleRestore} />\n )\n};\n```\n * \n */\nexport const getAvailablePurchases = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await RNIapModule.getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.getAvailableItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * Request a purchase for a product (consumables or non-consumables).\n\nThe response will be received through the `PurchaseUpdatedListener`.\n\n:::note\n`andDangerouslyFinishTransactionAutomatically` defaults to false. We recommend\nalways keeping at false, and verifying the transaction receipts on the server-side.\n:::\n\n## Signature\n\n```ts\nrequestPurchase(\n The product's sku/ID \n sku,\n\n \n * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.\n * @default false\n \n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n\n /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app. \n obfuscatedAccountIdAndroid,\n\n Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app. \n obfuscatedProfileIdAndroid,\n\n The purchaser's user ID \n applicationUsername,\n): Promise<ProductPurchase>;\n```\n\n## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {Button} from 'react-native';\nimport {requestPurchase, Product, Sku, getProducts} from 'react-native-iap';\n\nconst App = () => {\n const products = useCallback(\n async () => getProducts(['com.example.product']),\n [],\n );\n\n const handlePurchase = async (sku: Sku) => {\n await requestPurchase({sku});\n };\n\n return (\n <>\n {products.map((product) => (\n <Button\n key={product.productId}\n title=\"Buy product\"\n onPress={() => handlePurchase(product.productId)}\n />\n ))}\n </>\n );\n};\n```\n\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n 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 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 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\n/**\n * Clear Transaction (iOS only)\n * Finish remaining transactions. Related to issue #257 and #801\n * link : https://github.com/dooboolab/react-native-iap/issues/257\n * https://github.com/dooboolab/react-native-iap/issues/801\n * @returns {Promise<void>}\n */\nexport const clearTransactionIOS = (): Promise<void> =>\n getIosModule().clearTransaction();\n\n/**\n * Clear valid Products (iOS only)\n * Remove all products which are validated by Apple server.\n * @returns {void}\n */\nexport const clearProductsIOS = (): Promise<void> =>\n getIosModule().clearProducts();\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = ({\n token,\n developerPayload,\n}: {\n token: string;\n developerPayload?: string;\n}): Promise<PurchaseResult | boolean | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async ({\n sku,\n}: {\n sku: Sku;\n}): Promise<void> => {\n checkNativeAndroidAvailable();\n\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> => {\n if (!isIosStorekit2) {\n return getIosModule().promotedProduct();\n } else {\n return Promise.reject('Only available on SK1');\n }\n};\n\n/**\n * Buy the currently selected promoted product (iOS only)\n * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.\n * @returns {Promise<void>}\n */\nexport const buyPromotedProductIOS = (): Promise<void> =>\n getIosModule().buyPromotedProduct();\n\nconst TEST_RECEIPT = 21007;\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<ReceiptValidationResponse | false> => {\n const response = await enhancedFetch<ReceiptValidationResponse>(\n 'https://buy.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === TEST_RECEIPT) {\n const testResponse = await enhancedFetch<ReceiptValidationResponse>(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Validate receipt for iOS.\n * @param {object} receiptBody the receipt body to send to apple server.\n * @param {boolean} isTest whether this is in test environment which is sandbox.\n * @returns {Promise<Apple.ReceiptValidationResponse | false>}\n */\nexport const validateReceiptIos = async ({\n receiptBody,\n isTest,\n}: {\n receiptBody: Record<string, unknown>;\n isTest?: boolean;\n}): Promise<ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n return await enhancedFetch<ReceiptValidationResponse>(url);\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} packageName package name of your app.\n * @param {string} productId product id for your in app product.\n * @param {string} productToken token for your purchase.\n * @param {string} accessToken accessToken from googleApis.\n * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAndroid = async ({\n packageName,\n productId,\n productToken,\n accessToken,\n isSub,\n}: {\n packageName: string;\n productId: string;\n productToken: string;\n accessToken: string;\n isSub?: boolean;\n}): Promise<Android.ReceiptType> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}?access_token=${accessToken}`;\n\n return await enhancedFetch<Android.ReceiptType>(url);\n};\n\n/**\n * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including\n * your developer secret in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} developerSecret: from the Amazon developer console.\n * @param {string} userId who purchased the item.\n * @param {string} receiptId long obfuscated string returned when purchasing the item\n * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAmazon = async ({\n developerSecret,\n userId,\n receiptId,\n useSandbox = true,\n}: {\n developerSecret: string;\n userId: string;\n receiptId: string;\n useSandbox: boolean;\n}): Promise<Amazon.ReceiptType> => {\n const sandBoxUrl = useSandbox ? 'sandbox/' : '';\n const url = `https://appstore-sdk.amazon.com/${sandBoxUrl}version/1.0/verifyReceiptId/developer/${developerSecret}/user/${userId}/receiptId/${receiptId}`;\n\n return await enhancedFetch<Amazon.ReceiptType>(url);\n};\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async ({\n forceRefresh,\n}: {\n forceRefresh?: boolean;\n}): Promise<string> => getIosModule().requestReceipt(forceRefresh ?? false);\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":";;;;;;;AAAA;;AAKA;;AAMA;;AAMA;;AAaA,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;;AAEO,MAAMC,uBAAuB,GAAG,MAA4B;EACjE,OAAOR,WAAW,GACdS,2BAAA,CAAqBC,WADP,GAEdD,2BAAA,CAAqBE,MAFzB;AAGD,CAJM;;;AAMP,IAAIC,mBAAmB,GAAGZ,WAA1B;AAEA,IAAIa,eAAqD,GAAGf,QAA5D;;AAEO,MAAMgB,cAAc,GAAG,MAAMD,eAAe,KAAKd,WAAjD;;;;AAEA,MAAMgB,mBAAmB,GAAG,MAAe,CAAC,CAAChB,WAA7C;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C,WAJ2C;IAK3CC;EAL2C,CAYT;EAClC,MAAMnF,IAAI,GAAGmF,KAAK,GAAG,eAAH,GAAqB,UAAvC;EAEA,MAAML,GAAG,GACP,6EACC,IAAGE,WAAY,cAAahF,IAAK,IAAGD,SAAU,EAD/C,GAEC,WAAUkF,YAAa,iBAAgBC,WAAY,EAHtD;EAKA,OAAO,MAAM,IAAAX,uBAAA,EAAmCO,GAAnC,CAAb;AACD,CArBM;AAuBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMM,qBAAqB,GAAG,gBAUF;EAAA,IAVS;IAC1CC,eAD0C;IAE1CC,MAF0C;IAG1CC,SAH0C;IAI1CC,UAAU,GAAG;EAJ6B,CAUT;EACjC,MAAMC,UAAU,GAAGD,UAAU,GAAG,UAAH,GAAgB,EAA7C;EACA,MAAMV,GAAG,GAAI,mCAAkCW,UAAW,yCAAwCJ,eAAgB,SAAQC,MAAO,cAAaC,SAAU,EAAxJ;EAEA,OAAO,MAAM,IAAAhB,uBAAA,EAAkCO,GAAlC,CAAb;AACD,CAfM;AAiBP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMY,sBAAsB,GAAG,YACpC9G,YAAY,GAAG+G,sBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,aAAa,GAAG;EAAA,IAAO;IAClCC;EADkC,CAAP;EAAA,OAINjH,YAAY,GAAGkH,cAAf,CAA8BD,YAAY,IAAI,KAA9C,CAJM;AAAA,CAAtB;AAMP;AACA;AACA;AACA;;;;;AACO,MAAME,6BAA6B,GAAG,YAC3CnH,YAAY,GAAGoH,0BAAf,EADK"}
|
|
1
|
+
{"version":3,"names":["RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","NativeModules","ANDROID_ITEM_TYPE_SUBSCRIPTION","ProductType","subs","ANDROID_ITEM_TYPE_IAP","inapp","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","getIosModule","getAvailableItems","getPurchaseHistoryByType","concat","resolve","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","appAccountToken","isOfferPersonalized","undefined","quantity","withOffer","console","warn","offer","offerSk2Map","buyProduct","isAmazon","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","so","offerToken","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","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 {\n offerSk2Map,\n ProductSk2,\n productSk2Map,\n subscriptionSk2Map,\n} from './types/appleSk2';\nimport {\n enableStorekit2,\n fillProductsWithAdditionalData,\n getAndroidModule,\n getIosModule,\n getNativeModule,\n isAmazon,\n isIosStorekit2,\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 {\n IapAndroid,\n IapAmazon,\n IapIos,\n IapIosSk2,\n isIosStorekit2,\n enableStorekit2,\n};\n\nconst {RNIapIos, RNIapIosSk2, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = ProductType.subs;\nconst ANDROID_ITEM_TYPE_IAP = ProductType.inapp;\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 */\nexport const getPurchaseHistory = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await RNIapModule.getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\n/**\n * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)\n * ## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {View} from 'react-native';\nimport {getAvailablePurchases} from 'react-native-iap';\n\nconst App = () => {\n const availablePurchases = useCallback(\n async () => await getAvailablePurchases(),\n [],\n );\n\n return <View />;\n};\n```\n\n## Restoring purchases\n\nYou can use `getAvailablePurchases()` to do what's commonly understood as \"restoring\" purchases.\n\n:::note\nFor debugging you may want to consume all items, you have then to iterate over the purchases returned by `getAvailablePurchases()`.\n:::\n\n:::warning\nBeware that if you consume an item without having recorded the purchase in your database the user may have paid for something without getting it delivered and you will have no way to recover the receipt to validate and restore their purchase.\n:::\n\n```tsx\nimport React from 'react';\nimport {Button} from 'react-native';\nimport {getAvailablePurchases,finishTransaction} from 'react-native-iap';\n\nconst App = () => {\n handleRestore = async () => {\n try {\n const purchases = await getAvailablePurchases();\n const newState = {premium: false, ads: true};\n let titles = [];\n\n await Promise.all(purchases.map(async purchase => {\n switch (purchase.productId) {\n case 'com.example.premium':\n newState.premium = true;\n titles.push('Premium Version');\n break;\n\n case 'com.example.no_ads':\n newState.ads = false;\n titles.push('No Ads');\n break;\n\n case 'com.example.coins100':\n await finishTransaction(purchase.purchaseToken);\n CoinStore.addCoins(100);\n }\n })\n\n Alert.alert(\n 'Restore Successful',\n `You successfully restored the following purchases: ${titles.join(', ')}`,\n );\n } catch (error) {\n console.warn(error);\n Alert.alert(error.message);\n }\n };\n\n return (\n <Button title=\"Restore purchases\" onPress={handleRestore} />\n )\n};\n```\n * \n */\nexport const getAvailablePurchases = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await RNIapModule.getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.getAvailableItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * Request a purchase for a product (consumables or non-consumables).\n\nThe response will be received through the `PurchaseUpdatedListener`.\n\n:::note\n`andDangerouslyFinishTransactionAutomatically` defaults to false. We recommend\nalways keeping at false, and verifying the transaction receipts on the server-side.\n:::\n\n## Signature\n\n```ts\nrequestPurchase(\n The product's sku/ID \n sku,\n\n \n * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.\n * @default false\n \n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n\n /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app. \n obfuscatedAccountIdAndroid,\n\n Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app. \n obfuscatedProfileIdAndroid,\n\n The purchaser's user ID \n applicationUsername,\n): Promise<ProductPurchase>;\n```\n\n## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {Button} from 'react-native';\nimport {requestPurchase, Product, Sku, getProducts} from 'react-native-iap';\n\nconst App = () => {\n const products = useCallback(\n async () => getProducts(['com.example.product']),\n [],\n );\n\n const handlePurchase = async (sku: Sku) => {\n await requestPurchase({sku});\n };\n\n return (\n <>\n {products.map((product) => (\n <Button\n key={product.productId}\n title=\"Buy product\"\n onPress={() => handlePurchase(product.productId)}\n />\n ))}\n </>\n );\n};\n```\n\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n 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 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 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;;AAMA;;AASA;;;;;;AAqBA,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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AAC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