react-native-iap 10.0.7 → 10.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/android/src/amazon/java/com/dooboolab/RNIap/RNIapAmazonModule.kt +1 -2
- package/lib/commonjs/hooks/index.js +19 -0
- package/lib/commonjs/hooks/index.js.map +1 -0
- package/lib/commonjs/hooks/useIAP.js +8 -4
- package/lib/commonjs/hooks/useIAP.js.map +1 -1
- package/lib/commonjs/iap.js +46 -21
- package/lib/commonjs/iap.js.map +1 -1
- package/lib/commonjs/modules/amazon.js +12 -0
- package/lib/commonjs/modules/amazon.js.map +1 -0
- package/lib/commonjs/modules/android.js +12 -0
- package/lib/commonjs/modules/android.js.map +1 -0
- package/lib/commonjs/modules/common.js +2 -0
- package/lib/commonjs/modules/common.js.map +1 -0
- package/lib/commonjs/modules/index.js +58 -0
- package/lib/commonjs/modules/index.js.map +1 -0
- package/lib/commonjs/modules/ios.js +6 -0
- package/lib/commonjs/modules/ios.js.map +1 -0
- package/lib/commonjs/types/amazon.js.map +1 -1
- package/lib/commonjs/types/apple.js +0 -163
- package/lib/commonjs/types/apple.js.map +1 -1
- package/lib/commonjs/types/index.js +11 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/hooks/index.js +2 -0
- package/lib/module/hooks/index.js.map +1 -0
- package/lib/module/hooks/useIAP.js +6 -4
- package/lib/module/hooks/useIAP.js.map +1 -1
- package/lib/module/iap.js +47 -20
- package/lib/module/iap.js.map +1 -1
- package/lib/module/modules/amazon.js +3 -0
- package/lib/module/modules/amazon.js.map +1 -0
- package/lib/module/modules/android.js +3 -0
- package/lib/module/modules/android.js.map +1 -0
- package/lib/module/modules/common.js +2 -0
- package/lib/module/modules/common.js.map +1 -0
- package/lib/module/modules/index.js +5 -0
- package/lib/module/modules/index.js.map +1 -0
- package/lib/module/modules/ios.js +2 -0
- package/lib/module/modules/ios.js.map +1 -0
- package/lib/module/types/amazon.js.map +1 -1
- package/lib/module/types/apple.js +0 -151
- package/lib/module/types/apple.js.map +1 -1
- package/lib/module/types/index.js +9 -0
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/hooks/index.d.ts +1 -0
- package/lib/typescript/hooks/useIAP.d.ts +6 -3
- package/lib/typescript/iap.d.ts +14 -13
- package/lib/typescript/modules/amazon.d.ts +23 -0
- package/lib/typescript/modules/android.d.ts +24 -0
- package/lib/typescript/modules/common.d.ts +13 -0
- package/lib/typescript/modules/index.d.ts +4 -0
- package/lib/typescript/modules/ios.d.ts +32 -0
- package/lib/typescript/types/amazon.d.ts +8 -0
- package/lib/typescript/types/apple.d.ts +0 -399
- package/lib/typescript/types/index.d.ts +19 -0
- package/package.json +3 -1
- package/src/hooks/index.ts +1 -0
- package/src/hooks/useIAP.ts +11 -5
- package/src/iap.ts +75 -39
- package/src/modules/amazon.ts +40 -0
- package/src/modules/android.ts +65 -0
- package/src/modules/common.ts +16 -0
- package/src/modules/index.ts +4 -0
- package/src/modules/ios.ts +57 -0
- package/src/types/amazon.ts +9 -0
- package/src/types/apple.ts +0 -438
- package/src/types/index.ts +29 -0
|
@@ -50,8 +50,7 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
|
|
|
50
50
|
@ReactMethod
|
|
51
51
|
fun flushFailedPurchasesCachedAsPending(promise: Promise) {
|
|
52
52
|
// No-op
|
|
53
|
-
|
|
54
|
-
promise.resolve(items)
|
|
53
|
+
promise.resolve(true)
|
|
55
54
|
}
|
|
56
55
|
|
|
57
56
|
@ReactMethod
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _useIAP = require("./useIAP");
|
|
8
|
+
|
|
9
|
+
Object.keys(_useIAP).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _useIAP[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _useIAP[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './useIAP';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.useIAP =
|
|
6
|
+
exports.useIAP = void 0;
|
|
7
7
|
|
|
8
8
|
var _react = require("react");
|
|
9
9
|
|
|
@@ -11,7 +11,7 @@ var _iap = require("../iap");
|
|
|
11
11
|
|
|
12
12
|
var _withIAPContext = require("./withIAPContext");
|
|
13
13
|
|
|
14
|
-
|
|
14
|
+
const useIAP = () => {
|
|
15
15
|
const {
|
|
16
16
|
connected,
|
|
17
17
|
products,
|
|
@@ -90,7 +90,11 @@ function useIAP() {
|
|
|
90
90
|
getProducts,
|
|
91
91
|
getSubscriptions,
|
|
92
92
|
getAvailablePurchases,
|
|
93
|
-
getPurchaseHistory
|
|
93
|
+
getPurchaseHistory,
|
|
94
|
+
requestPurchase: _iap.requestPurchase,
|
|
95
|
+
requestSubscription: _iap.requestSubscription
|
|
94
96
|
};
|
|
95
|
-
}
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
exports.useIAP = useIAP;
|
|
96
100
|
//# sourceMappingURL=useIAP.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["useIAP","connected","products","promotedProductsIOS","subscriptions","purchaseHistory","availablePurchases","currentPurchase","currentPurchaseError","initConnectionError","setProducts","setSubscriptions","setAvailablePurchases","setPurchaseHistory","setCurrentPurchase","setCurrentPurchaseError","useIAPContext","getProducts","useCallback","skus","iapGetProducts","getSubscriptions","iapGetSubscriptions","getAvailablePurchases","iapGetAvailablePurchases","getPurchaseHistory","iapGetPurchaseHistory","finishTransaction","purchase","isConsumable","developerPayloadAndroid","iapFinishTransaction","err","productId","undefined"],"sources":["useIAP.ts"],"sourcesContent":["import {useCallback} from 'react';\n\nimport {\n finishTransaction as iapFinishTransaction,\n getAvailablePurchases as iapGetAvailablePurchases,\n getProducts as iapGetProducts,\n getPurchaseHistory as iapGetPurchaseHistory,\n getSubscriptions as iapGetSubscriptions,\n} from '../iap';\nimport type {PurchaseError} from '../purchaseError';\nimport type {Product, Purchase, Subscription} from '../types';\n\nimport {useIAPContext} from './withIAPContext';\n\ntype IAP_STATUS = {\n connected: boolean;\n products: Product[];\n promotedProductsIOS: Product[];\n subscriptions: Subscription[];\n purchaseHistory: Purchase[];\n availablePurchases: Purchase[];\n currentPurchase?: Purchase;\n currentPurchaseError?: PurchaseError;\n initConnectionError?: Error;\n finishTransaction: ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n }) => Promise<string | void>;\n getAvailablePurchases: () => Promise<void>;\n getPurchaseHistory: () => Promise<void>;\n getProducts: ({skus}: {skus: string[]}) => Promise<void>;\n getSubscriptions: ({skus}: {skus: string[]}) => Promise<void>;\n};\n\nexport
|
|
1
|
+
{"version":3,"names":["useIAP","connected","products","promotedProductsIOS","subscriptions","purchaseHistory","availablePurchases","currentPurchase","currentPurchaseError","initConnectionError","setProducts","setSubscriptions","setAvailablePurchases","setPurchaseHistory","setCurrentPurchase","setCurrentPurchaseError","useIAPContext","getProducts","useCallback","skus","iapGetProducts","getSubscriptions","iapGetSubscriptions","getAvailablePurchases","iapGetAvailablePurchases","getPurchaseHistory","iapGetPurchaseHistory","finishTransaction","purchase","isConsumable","developerPayloadAndroid","iapFinishTransaction","err","productId","undefined","requestPurchase","iapRequestPurchase","requestSubscription","iapRequestSubscription"],"sources":["useIAP.ts"],"sourcesContent":["import {useCallback} from 'react';\n\nimport {\n finishTransaction as iapFinishTransaction,\n getAvailablePurchases as iapGetAvailablePurchases,\n getProducts as iapGetProducts,\n getPurchaseHistory as iapGetPurchaseHistory,\n getSubscriptions as iapGetSubscriptions,\n requestPurchase as iapRequestPurchase,\n requestSubscription as iapRequestSubscription,\n} from '../iap';\nimport type {PurchaseError} from '../purchaseError';\nimport type {Product, Purchase, PurchaseResult, Subscription} from '../types';\n\nimport {useIAPContext} from './withIAPContext';\n\ntype IAP_STATUS = {\n connected: boolean;\n products: Product[];\n promotedProductsIOS: Product[];\n subscriptions: Subscription[];\n purchaseHistory: Purchase[];\n availablePurchases: Purchase[];\n currentPurchase?: Purchase;\n currentPurchaseError?: PurchaseError;\n initConnectionError?: Error;\n finishTransaction: ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n }) => Promise<string | boolean | PurchaseResult | void>;\n getAvailablePurchases: () => Promise<void>;\n getPurchaseHistory: () => Promise<void>;\n getProducts: ({skus}: {skus: string[]}) => Promise<void>;\n getSubscriptions: ({skus}: {skus: string[]}) => Promise<void>;\n requestPurchase: typeof iapRequestPurchase;\n requestSubscription: typeof iapRequestSubscription;\n};\n\nexport const useIAP = (): IAP_STATUS => {\n const {\n connected,\n products,\n promotedProductsIOS,\n subscriptions,\n purchaseHistory,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n setProducts,\n setSubscriptions,\n setAvailablePurchases,\n setPurchaseHistory,\n setCurrentPurchase,\n setCurrentPurchaseError,\n } = useIAPContext();\n\n const getProducts = useCallback(\n async ({skus}: {skus: string[]}): Promise<void> => {\n setProducts(await iapGetProducts({skus}));\n },\n [setProducts],\n );\n\n const getSubscriptions = useCallback(\n async ({skus}: {skus: string[]}): Promise<void> => {\n setSubscriptions(await iapGetSubscriptions({skus}));\n },\n [setSubscriptions],\n );\n\n const getAvailablePurchases = useCallback(async (): Promise<void> => {\n setAvailablePurchases(await iapGetAvailablePurchases());\n }, [setAvailablePurchases]);\n\n const getPurchaseHistory = useCallback(async (): Promise<void> => {\n setPurchaseHistory(await iapGetPurchaseHistory());\n }, [setPurchaseHistory]);\n\n const finishTransaction = useCallback(\n async ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n }: {\n purchase: Purchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n }): Promise<string | boolean | PurchaseResult | void> => {\n try {\n return await iapFinishTransaction({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n });\n } catch (err) {\n throw err;\n } finally {\n if (purchase.productId === currentPurchase?.productId) {\n setCurrentPurchase(undefined);\n }\n\n if (purchase.productId === currentPurchaseError?.productId) {\n setCurrentPurchaseError(undefined);\n }\n }\n },\n [\n currentPurchase?.productId,\n currentPurchaseError?.productId,\n setCurrentPurchase,\n setCurrentPurchaseError,\n ],\n );\n\n return {\n connected,\n products,\n promotedProductsIOS,\n subscriptions,\n purchaseHistory,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n finishTransaction,\n getProducts,\n getSubscriptions,\n getAvailablePurchases,\n getPurchaseHistory,\n requestPurchase: iapRequestPurchase,\n requestSubscription: iapRequestSubscription,\n };\n};\n"],"mappings":";;;;;;;AAAA;;AAEA;;AAYA;;AA6BO,MAAMA,MAAM,GAAG,MAAkB;EACtC,MAAM;IACJC,SADI;IAEJC,QAFI;IAGJC,mBAHI;IAIJC,aAJI;IAKJC,eALI;IAMJC,kBANI;IAOJC,eAPI;IAQJC,oBARI;IASJC,mBATI;IAUJC,WAVI;IAWJC,gBAXI;IAYJC,qBAZI;IAaJC,kBAbI;IAcJC,kBAdI;IAeJC;EAfI,IAgBF,IAAAC,6BAAA,GAhBJ;EAkBA,MAAMC,WAAW,GAAG,IAAAC,kBAAA,EAClB,cAAmD;IAAA,IAA5C;MAACC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BAAuB,CAACmB,SAAD,CAAvB;MACD;IACF;EACF,CA3BuB,EA4BxB,CACE3B,eADF,aACEA,eADF,uBACEA,eAAe,CAAE0B,SADnB,EAEEzB,oBAFF,aAEEA,oBAFF,uBAEEA,oBAAoB,CAAEyB,SAFxB,EAGEnB,kBAHF,EAIEC,uBAJF,CA5BwB,CAA1B;EAoCA,OAAO;IACLd,SADK;IAELC,QAFK;IAGLC,mBAHK;IAILC,aAJK;IAKLC,eALK;IAMLC,kBANK;IAOLC,eAPK;IAQLC,oBARK;IASLC,mBATK;IAULkB,iBAVK;IAWLV,WAXK;IAYLI,gBAZK;IAaLE,qBAbK;IAcLE,kBAdK;IAeLU,eAAe,EAAEC,oBAfZ;IAgBLC,mBAAmB,EAAEC;EAhBhB,CAAP;AAkBD,CA/FM"}
|
package/lib/commonjs/iap.js
CHANGED
|
@@ -7,8 +7,6 @@ exports.validateReceiptIos = exports.validateReceiptAndroid = exports.validateRe
|
|
|
7
7
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
|
|
10
|
-
var _apple = require("./types/apple");
|
|
11
|
-
|
|
12
10
|
var _internal = require("./internal");
|
|
13
11
|
|
|
14
12
|
var _types = require("./types");
|
|
@@ -18,8 +16,8 @@ const {
|
|
|
18
16
|
RNIapModule,
|
|
19
17
|
RNIapAmazonModule
|
|
20
18
|
} = _reactNative.NativeModules;
|
|
21
|
-
const ANDROID_ITEM_TYPE_SUBSCRIPTION =
|
|
22
|
-
const ANDROID_ITEM_TYPE_IAP =
|
|
19
|
+
const ANDROID_ITEM_TYPE_SUBSCRIPTION = _types.ProductType.subs;
|
|
20
|
+
const ANDROID_ITEM_TYPE_IAP = _types.ProductType.inapp;
|
|
23
21
|
|
|
24
22
|
const getInstallSourceAndroid = () => {
|
|
25
23
|
return RNIapModule ? _types.InstallSourceAndroid.GOOGLE_PLAY : _types.InstallSourceAndroid.AMAZON;
|
|
@@ -112,7 +110,7 @@ const getProducts = _ref => {
|
|
|
112
110
|
const products = await getAndroidModule().getItemsByType(ANDROID_ITEM_TYPE_IAP, skus);
|
|
113
111
|
return (0, _internal.fillProductsWithAdditionalData)(products);
|
|
114
112
|
}
|
|
115
|
-
}) || Promise.
|
|
113
|
+
}) || (() => Promise.reject(new Error('Unsupported Platform'))))();
|
|
116
114
|
};
|
|
117
115
|
/**
|
|
118
116
|
* Get a list of subscriptions
|
|
@@ -136,7 +134,7 @@ const getSubscriptions = _ref2 => {
|
|
|
136
134
|
const subscriptions = await getAndroidModule().getItemsByType(ANDROID_ITEM_TYPE_SUBSCRIPTION, skus);
|
|
137
135
|
return (0, _internal.fillProductsWithAdditionalData)(subscriptions);
|
|
138
136
|
}
|
|
139
|
-
}) || Promise.
|
|
137
|
+
}) || (() => Promise.reject(new Error('Unsupported Platform'))))();
|
|
140
138
|
};
|
|
141
139
|
/**
|
|
142
140
|
* Gets an inventory of purchases made by the user regardless of consumption status
|
|
@@ -155,11 +153,11 @@ const getPurchaseHistory = () => (_reactNative.Platform.select({
|
|
|
155
153
|
return await RNIapAmazonModule.getAvailableItems();
|
|
156
154
|
}
|
|
157
155
|
|
|
158
|
-
const products = await
|
|
159
|
-
const subscriptions = await
|
|
156
|
+
const products = await RNIapModule.getPurchaseHistoryByType(ANDROID_ITEM_TYPE_IAP);
|
|
157
|
+
const subscriptions = await RNIapModule.getPurchaseHistoryByType(ANDROID_ITEM_TYPE_SUBSCRIPTION);
|
|
160
158
|
return products.concat(subscriptions);
|
|
161
159
|
}
|
|
162
|
-
}) || Promise.resolve)();
|
|
160
|
+
}) || (() => Promise.resolve([])))();
|
|
163
161
|
/**
|
|
164
162
|
* Get all purchases made by the user (either non-consumable, or haven't been consumed yet)
|
|
165
163
|
* @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}
|
|
@@ -177,11 +175,11 @@ const getAvailablePurchases = () => (_reactNative.Platform.select({
|
|
|
177
175
|
return await RNIapAmazonModule.getAvailableItems();
|
|
178
176
|
}
|
|
179
177
|
|
|
180
|
-
const products = await
|
|
181
|
-
const subscriptions = await
|
|
178
|
+
const products = await RNIapModule.getAvailableItemsByType(ANDROID_ITEM_TYPE_IAP);
|
|
179
|
+
const subscriptions = await RNIapModule.getAvailableItemsByType(ANDROID_ITEM_TYPE_SUBSCRIPTION);
|
|
182
180
|
return products.concat(subscriptions);
|
|
183
181
|
}
|
|
184
|
-
}) || Promise.resolve)();
|
|
182
|
+
}) || (() => Promise.resolve([])))();
|
|
185
183
|
/**
|
|
186
184
|
* Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
|
|
187
185
|
* @param {string} sku The product's sku/ID
|
|
@@ -209,6 +207,10 @@ const requestPurchase = _ref3 => {
|
|
|
209
207
|
} = _ref3;
|
|
210
208
|
return (_reactNative.Platform.select({
|
|
211
209
|
ios: async () => {
|
|
210
|
+
if (!sku) {
|
|
211
|
+
return Promise.reject(new Error('sku is required for iOS purchase'));
|
|
212
|
+
}
|
|
213
|
+
|
|
212
214
|
if (andDangerouslyFinishTransactionAutomaticallyIOS) {
|
|
213
215
|
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.');
|
|
214
216
|
}
|
|
@@ -217,9 +219,17 @@ const requestPurchase = _ref3 => {
|
|
|
217
219
|
},
|
|
218
220
|
android: async () => {
|
|
219
221
|
if (_internal.isAmazon) {
|
|
222
|
+
if (!sku) {
|
|
223
|
+
return Promise.reject(new Error('sku is required for Amazon purchase'));
|
|
224
|
+
}
|
|
225
|
+
|
|
220
226
|
return RNIapAmazonModule.buyItemByType(sku);
|
|
221
227
|
} else {
|
|
222
|
-
|
|
228
|
+
if (!(sku !== null && sku !== void 0 && sku.length) && !sku) {
|
|
229
|
+
return Promise.reject(new Error('skus is required for Android purchase'));
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
return getAndroidModule().buyItemByType(ANDROID_ITEM_TYPE_IAP, skus !== null && skus !== void 0 && skus.length ? skus : [sku], undefined, -1, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, [], isOfferPersonalized ?? false);
|
|
223
233
|
}
|
|
224
234
|
}
|
|
225
235
|
}) || Promise.resolve)();
|
|
@@ -254,6 +264,10 @@ const requestSubscription = _ref4 => {
|
|
|
254
264
|
} = _ref4;
|
|
255
265
|
return (_reactNative.Platform.select({
|
|
256
266
|
ios: async () => {
|
|
267
|
+
if (!sku) {
|
|
268
|
+
return Promise.reject(new Error('sku is required for iOS subscription'));
|
|
269
|
+
}
|
|
270
|
+
|
|
257
271
|
if (andDangerouslyFinishTransactionAutomaticallyIOS) {
|
|
258
272
|
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.');
|
|
259
273
|
}
|
|
@@ -262,6 +276,10 @@ const requestSubscription = _ref4 => {
|
|
|
262
276
|
},
|
|
263
277
|
android: async () => {
|
|
264
278
|
if (_internal.isAmazon) {
|
|
279
|
+
if (!sku) {
|
|
280
|
+
return Promise.reject(new Error('sku is required for Amazon purchase'));
|
|
281
|
+
}
|
|
282
|
+
|
|
265
283
|
return RNIapAmazonModule.buyItemByType(sku);
|
|
266
284
|
} else {
|
|
267
285
|
if (!(subscriptionOffers !== null && subscriptionOffers !== void 0 && subscriptionOffers.length)) {
|
|
@@ -271,7 +289,7 @@ const requestSubscription = _ref4 => {
|
|
|
271
289
|
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);
|
|
272
290
|
}
|
|
273
291
|
}
|
|
274
|
-
}) || Promise.resolve)();
|
|
292
|
+
}) || (() => Promise.resolve(null)))();
|
|
275
293
|
};
|
|
276
294
|
/**
|
|
277
295
|
* Request a purchase for product. This will be received in `PurchaseUpdatedListener`.
|
|
@@ -313,22 +331,28 @@ const finishTransaction = _ref6 => {
|
|
|
313
331
|
} = _ref6;
|
|
314
332
|
return (_reactNative.Platform.select({
|
|
315
333
|
ios: async () => {
|
|
316
|
-
|
|
334
|
+
const transactionId = purchase.transactionId;
|
|
335
|
+
|
|
336
|
+
if (!transactionId) {
|
|
337
|
+
return Promise.reject(new Error('transactionId required to finish iOS transaction'));
|
|
338
|
+
}
|
|
339
|
+
|
|
340
|
+
return getIosModule().finishTransaction(transactionId);
|
|
317
341
|
},
|
|
318
342
|
android: async () => {
|
|
319
|
-
if (purchase) {
|
|
343
|
+
if (purchase !== null && purchase !== void 0 && purchase.purchaseToken) {
|
|
320
344
|
if (isConsumable) {
|
|
321
345
|
return getAndroidModule().consumeProduct(purchase.purchaseToken, developerPayloadAndroid);
|
|
322
346
|
} else if (purchase.userIdAmazon || !purchase.isAcknowledgedAndroid && purchase.purchaseStateAndroid === _types.PurchaseStateAndroid.PURCHASED) {
|
|
323
347
|
return getAndroidModule().acknowledgePurchase(purchase.purchaseToken, developerPayloadAndroid);
|
|
324
348
|
} else {
|
|
325
|
-
|
|
349
|
+
return Promise.reject(new Error('purchase is not suitable to be purchased'));
|
|
326
350
|
}
|
|
327
|
-
} else {
|
|
328
|
-
throw new Error('purchase is not assigned');
|
|
329
351
|
}
|
|
352
|
+
|
|
353
|
+
return Promise.reject(new Error('purchase is not suitable to be purchased'));
|
|
330
354
|
}
|
|
331
|
-
}) || Promise.
|
|
355
|
+
}) || (() => Promise.reject(new Error('Unsupported Platform'))))();
|
|
332
356
|
};
|
|
333
357
|
/**
|
|
334
358
|
* Clear Transaction (iOS only)
|
|
@@ -406,6 +430,7 @@ exports.getPromotedProductIOS = getPromotedProductIOS;
|
|
|
406
430
|
const buyPromotedProductIOS = () => getIosModule().buyPromotedProduct();
|
|
407
431
|
|
|
408
432
|
exports.buyPromotedProductIOS = buyPromotedProductIOS;
|
|
433
|
+
const TEST_RECEIPT = 21007;
|
|
409
434
|
|
|
410
435
|
const requestAgnosticReceiptValidationIos = async receiptBody => {
|
|
411
436
|
const response = await (0, _internal.enhancedFetch)('https://buy.itunes.apple.com/verifyReceipt', {
|
|
@@ -414,7 +439,7 @@ const requestAgnosticReceiptValidationIos = async receiptBody => {
|
|
|
414
439
|
}); // Best practice is to check for test receipt and check sandbox instead
|
|
415
440
|
// https://developer.apple.com/documentation/appstorereceipts/verifyreceipt
|
|
416
441
|
|
|
417
|
-
if (response && response.status ===
|
|
442
|
+
if (response && response.status === TEST_RECEIPT) {
|
|
418
443
|
const testResponse = await (0, _internal.enhancedFetch)('https://sandbox.itunes.apple.com/verifyReceipt', {
|
|
419
444
|
method: 'POST',
|
|
420
445
|
body: receiptBody
|
package/lib/commonjs/iap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RNIapIos","RNIapModule","RNIapAmazonModule","NativeModules","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","getInstallSourceAndroid","InstallSourceAndroid","GOOGLE_PLAY","AMAZON","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","isAndroid","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","Platform","select","ios","items","getItems","filter","item","includes","productId","type","android","products","getItemsByType","fillProductsWithAdditionalData","Promise","resolve","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","applicationUsername","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","isOfferPersonalized","console","warn","buyProduct","isAmazon","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","undefined","reject","map","so","offerToken","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","consumeProduct","purchaseToken","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PurchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","Linking","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","requestAgnosticReceiptValidationIos","receiptBody","response","enhancedFetch","method","body","status","ReceiptValidationStatus","TEST_RECEIPT","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","url","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {Linking, NativeModules, Platform} from 'react-native';\n\nimport type * as Amazon from './types/amazon';\nimport type * as Android from './types/android';\nimport type * as Apple from './types/apple';\nimport {ReceiptValidationStatus} from './types/apple';\nimport {\n enhancedFetch,\n fillProductsWithAdditionalData,\n isAmazon,\n isAndroid,\n} from './internal';\nimport type {\n Product,\n ProductPurchase,\n ProrationModesAndroid,\n PurchaseResult,\n Sku,\n Subscription,\n SubscriptionOffer,\n SubscriptionPurchase,\n} from './types';\nimport {InstallSourceAndroid, PurchaseStateAndroid} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getAndroidModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return androidNativeModule\n ? androidNativeModule\n : RNIapModule\n ? RNIapModule\n : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nexport const getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<void> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid = (): Promise<\n string[]\n> => getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n * @param {string[]} skus The item skus\n * @returns {Promise<Product[]>}\n */\nexport const getProducts = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\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.resolve\n )();\n\n/**\n * Get a list of subscriptions\n * @param {string[]} skus The item skus\n * @returns {Promise<Subscription[]>}\n */\nexport const getSubscriptions = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Subscription) =>\n skus.includes(item.productId) && item.type === 'subs',\n );\n },\n android: async () => {\n const subscriptions = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n );\n\n return fillProductsWithAdditionalData(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)\n * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {string[]} [skus] Product Ids to purchase. Note that this is only for Android. iOS only uses a single SKU. If not provided, it'll default to using [sku] for backward-compatibility\n * @param {boolean} [isOfferPersonalized] Defaults to false, Only for Android V5\n * @returns {Promise<ProductPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n skus,\n isOfferPersonalized,\n}: {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n /** For Google Play Billing Library 5 https://developer.android.com/google/play/billing/integrate#personalized-price */\n skus?: Sku[];\n isOfferPersonalized?: boolean;\n}): Promise<ProductPurchase> =>\n (\n Platform.select({\n ios: async () => {\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n skus?.length ? skus : [sku],\n null,\n -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n [],\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {SubscriptionOffers[]} [subscriptionOffers] Array of SubscriptionOffers. Every sku must be paired with a corresponding offerToken\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n subscriptionOffers,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized = undefined,\n}: {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n /** For Google Play Billing Library 5 */\n subscriptionOffers?: SubscriptionOffer[];\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n /** For Google Play Billing Library 5 https://developer.android.com/google/play/billing/integrate#personalized-price */\n isOfferPersonalized?: boolean;\n}): Promise<SubscriptionPurchase | null> =>\n (\n Platform.select({\n ios: async () => {\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n if (isAmazon) {\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\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = ({\n sku,\n quantity,\n}: {\n sku: Sku;\n quantity: number;\n}): Promise<ProductPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\n\n/**\n * Finish Transaction (both platforms)\n * Abstracts Finish Transaction\n * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.\n * Call this after you have persisted the purchased state to your server or local data in your app.\n * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**\n * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.\n * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n}: {\n purchase: ProductPurchase | ProductPurchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n}): Promise<string | void> => {\n return (\n Platform.select({\n ios: async () => {\n return getIosModule().finishTransaction(purchase.transactionId);\n },\n android: async () => {\n if (purchase) {\n if (isConsumable) {\n return getAndroidModule().consumeProduct(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else if (\n purchase.userIdAmazon ||\n (!purchase.isAcknowledgedAndroid &&\n purchase.purchaseStateAndroid === PurchaseStateAndroid.PURCHASED)\n ) {\n return getAndroidModule().acknowledgePurchase(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else {\n throw new Error('purchase is not suitable to be purchased');\n }\n } else {\n throw new Error('purchase is not assigned');\n }\n },\n }) || Promise.resolve\n )();\n};\n\n/**\n * Clear Transaction (iOS only)\n * Finish remaining transactions. Related to issue #257 and #801\n * link : https://github.com/dooboolab/react-native-iap/issues/257\n * https://github.com/dooboolab/react-native-iap/issues/801\n * @returns {Promise<void>}\n */\nexport const clearTransactionIOS = (): Promise<void> =>\n getIosModule().clearTransaction();\n\n/**\n * Clear valid Products (iOS only)\n * Remove all products which are validated by Apple server.\n * @returns {void}\n */\nexport const clearProductsIOS = (): Promise<void> =>\n getIosModule().clearProducts();\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = ({\n token,\n developerPayload,\n}: {\n token: string;\n developerPayload?: string;\n}): Promise<PurchaseResult | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async ({\n sku,\n}: {\n sku: Sku;\n}): Promise<void> => {\n checkNativeAndroidAvailable();\n\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\n\n/**\n * Buy the currently selected promoted product (iOS only)\n * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.\n * @returns {Promise<void>}\n */\nexport const buyPromotedProductIOS = (): Promise<void> =>\n getIosModule().buyPromotedProduct();\n\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await enhancedFetch<Apple.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 === ReceiptValidationStatus.TEST_RECEIPT) {\n const testResponse = await enhancedFetch<Apple.ReceiptValidationResponse>(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = ({\n sku,\n forUser,\n withOffer,\n}: {\n sku: Sku;\n forUser: string;\n withOffer: Apple.PaymentDiscount;\n}): Promise<void> =>\n getIosModule().buyProductWithOffer(sku, forUser, withOffer);\n\n/**\n * Validate receipt for iOS.\n * @param {object} receiptBody the receipt body to send to apple server.\n * @param {boolean} isTest whether this is in test environment which is sandbox.\n * @returns {Promise<Apple.ReceiptValidationResponse | false>}\n */\nexport const validateReceiptIos = async ({\n receiptBody,\n isTest,\n}: {\n receiptBody: Record<string, unknown>;\n isTest?: boolean;\n}): Promise<Apple.ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n return await enhancedFetch<Apple.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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IAAI,KAA9C,CAJM;AAAA,CAAtB;AAMP;AACA;AACA;AACA;;;;;AACO,MAAME,6BAA6B,GAAG,YAC3CvH,YAAY,GAAGwH,0BAAf,EADK"}
|
|
1
|
+
{"version":3,"names":["RNIapIos","RNIapModule","RNIapAmazonModule","NativeModules","ANDROID_ITEM_TYPE_SUBSCRIPTION","ProductType","subs","ANDROID_ITEM_TYPE_IAP","inapp","getInstallSourceAndroid","InstallSourceAndroid","GOOGLE_PLAY","AMAZON","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","isAndroid","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","Platform","select","ios","items","getItems","filter","item","includes","productId","type","android","products","getItemsByType","fillProductsWithAdditionalData","Promise","reject","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","resolve","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","applicationUsername","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","isOfferPersonalized","console","warn","buyProduct","isAmazon","buyItemByType","length","undefined","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","map","so","offerToken","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","purchaseToken","consumeProduct","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PurchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","Linking","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","TEST_RECEIPT","requestAgnosticReceiptValidationIos","receiptBody","response","enhancedFetch","method","body","status","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","url","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {Linking, NativeModules, Platform} from 'react-native';\nimport type {ResponseBody as ReceiptValidationResponse} from '@jeremybarbet/apple-api-types';\n\nimport type * as Amazon from './types/amazon';\nimport type * as Android from './types/android';\nimport type * as Apple from './types/apple';\nimport {\n enhancedFetch,\n fillProductsWithAdditionalData,\n isAmazon,\n isAndroid,\n} from './internal';\nimport {\n Product,\n ProductPurchase,\n ProductType,\n ProrationModesAndroid,\n Purchase,\n PurchaseResult,\n Sku,\n Subscription,\n SubscriptionOffer,\n SubscriptionPurchase,\n} from './types';\nimport {InstallSourceAndroid, PurchaseStateAndroid} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = ProductType.subs;\nconst ANDROID_ITEM_TYPE_IAP = ProductType.inapp;\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getAndroidModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return androidNativeModule\n ? androidNativeModule\n : RNIapModule\n ? RNIapModule\n : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nexport const getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<boolean> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid =\n (): Promise<boolean> =>\n getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n * @param {string[]} skus The item skus\n * @returns {Promise<Product[]>}\n */\nexport const getProducts = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n const items = (await getIosModule().getItems(skus)) as Product[];\n\n return items.filter(\n (item: Product) =>\n skus.includes(item.productId) && item.type === 'iap',\n );\n },\n android: async () => {\n const products = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n skus,\n );\n\n return fillProductsWithAdditionalData(products);\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n\n/**\n * Get a list of subscriptions\n * @param {string[]} skus The item skus\n * @returns {Promise<Subscription[]>}\n */\nexport const getSubscriptions = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n const items = (await getIosModule().getItems(skus)) as Subscription[];\n\n return items.filter(\n (item: Subscription) =>\n skus.includes(item.productId) && item.type === 'subs',\n );\n },\n android: async () => {\n const subscriptions = (await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n )) as Subscription[];\n\n return fillProductsWithAdditionalData(subscriptions);\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await RNIapModule.getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\n/**\n * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)\n * @returns {Promise<(ProductPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await RNIapModule.getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.getAvailableItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {string[]} [skus] Product Ids to purchase. Note that this is only for Android. iOS only uses a single SKU. If not provided, it'll default to using [sku] for backward-compatibility\n * @param {boolean} [isOfferPersonalized] Defaults to false, Only for Android V5\n * @returns {Promise<ProductPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n skus,\n isOfferPersonalized,\n}: {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n /** For Google Play Billing Library 5 https://developer.android.com/google/play/billing/integrate#personalized-price */\n skus?: Sku[];\n isOfferPersonalized?: boolean;\n}): Promise<ProductPurchase | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!sku) {\n return Promise.reject(new Error('sku is required for iOS purchase'));\n }\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n if (isAmazon) {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for Amazon purchase'),\n );\n }\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!sku?.length && !sku) {\n return Promise.reject(\n new Error('skus is required for Android purchase'),\n );\n }\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n skus?.length ? skus : [sku],\n undefined,\n -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n [],\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {SubscriptionOffers[]} [subscriptionOffers] Array of SubscriptionOffers. Every sku must be paired with a corresponding offerToken\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n applicationUsername,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n subscriptionOffers,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n isOfferPersonalized = undefined,\n}: {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n /** For Google Play Billing Library 5 */\n subscriptionOffers?: SubscriptionOffer[];\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n /** For Google Play Billing Library 5 https://developer.android.com/google/play/billing/integrate#personalized-price */\n isOfferPersonalized?: boolean;\n}): Promise<SubscriptionPurchase | null | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for iOS subscription'),\n );\n }\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n if (isAmazon) {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for Amazon purchase'),\n );\n }\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!subscriptionOffers?.length) {\n return Promise.reject(\n 'subscriptionOffers are required for Google Play Subscriptions',\n );\n }\n return RNIapModule.buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n subscriptionOffers?.map((so) => so.sku),\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers?.map((so) => so.offerToken),\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || (() => Promise.resolve(null))\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = ({\n sku,\n quantity,\n}: {\n sku: Sku;\n quantity: number;\n}): Promise<ProductPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\n\n/**\n * Finish Transaction (both platforms)\n * Abstracts Finish Transaction\n * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.\n * Call this after you have persisted the purchased state to your server or local data in your app.\n * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**\n * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.\n * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n}: {\n purchase: ProductPurchase | ProductPurchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n}): Promise<PurchaseResult | boolean> => {\n return (\n Platform.select({\n ios: async () => {\n const transactionId = purchase.transactionId;\n\n if (!transactionId) {\n return Promise.reject(\n new Error('transactionId required to finish iOS transaction'),\n );\n }\n return getIosModule().finishTransaction(transactionId);\n },\n android: async () => {\n if (purchase?.purchaseToken) {\n if (isConsumable) {\n return getAndroidModule().consumeProduct(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else if (\n purchase.userIdAmazon ||\n (!purchase.isAcknowledgedAndroid &&\n purchase.purchaseStateAndroid === PurchaseStateAndroid.PURCHASED)\n ) {\n return getAndroidModule().acknowledgePurchase(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else {\n return Promise.reject(\n new Error('purchase is not suitable to be purchased'),\n );\n }\n }\n return Promise.reject(\n new Error('purchase is not suitable to be purchased'),\n );\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n};\n\n/**\n * Clear Transaction (iOS only)\n * Finish remaining transactions. Related to issue #257 and #801\n * link : https://github.com/dooboolab/react-native-iap/issues/257\n * https://github.com/dooboolab/react-native-iap/issues/801\n * @returns {Promise<void>}\n */\nexport const clearTransactionIOS = (): Promise<void> =>\n getIosModule().clearTransaction();\n\n/**\n * Clear valid Products (iOS only)\n * Remove all products which are validated by Apple server.\n * @returns {void}\n */\nexport const clearProductsIOS = (): Promise<void> =>\n getIosModule().clearProducts();\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = ({\n token,\n developerPayload,\n}: {\n token: string;\n developerPayload?: string;\n}): Promise<PurchaseResult | boolean | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async ({\n sku,\n}: {\n sku: Sku;\n}): Promise<void> => {\n checkNativeAndroidAvailable();\n\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\n\n/**\n * Buy the currently selected promoted product (iOS only)\n * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.\n * @returns {Promise<void>}\n */\nexport const buyPromotedProductIOS = (): Promise<void> =>\n getIosModule().buyPromotedProduct();\n\nconst TEST_RECEIPT = 21007;\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<ReceiptValidationResponse | false> => {\n const response = await enhancedFetch<ReceiptValidationResponse>(\n 'https://buy.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === TEST_RECEIPT) {\n const testResponse = await enhancedFetch<ReceiptValidationResponse>(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = ({\n sku,\n forUser,\n withOffer,\n}: {\n sku: Sku;\n forUser: string;\n withOffer: Apple.PaymentDiscount;\n}): Promise<Purchase> =>\n getIosModule().buyProductWithOffer(sku, forUser, withOffer);\n\n/**\n * Validate receipt for iOS.\n * @param {object} receiptBody the receipt body to send to apple server.\n * @param {boolean} isTest whether this is in test environment which is sandbox.\n * @returns {Promise<Apple.ReceiptValidationResponse | false>}\n */\nexport const validateReceiptIos = async ({\n receiptBody,\n isTest,\n}: {\n receiptBody: Record<string, unknown>;\n isTest?: boolean;\n}): Promise<ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n return await enhancedFetch<ReceiptValidationResponse>(url);\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} packageName package name of your app.\n * @param {string} productId product id for your in app product.\n * @param {string} productToken token for your purchase.\n * @param {string} accessToken accessToken from googleApis.\n * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAndroid = async ({\n packageName,\n productId,\n productToken,\n accessToken,\n isSub,\n}: {\n packageName: string;\n productId: string;\n productToken: string;\n accessToken: string;\n isSub?: boolean;\n}): Promise<Android.ReceiptType> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}?access_token=${accessToken}`;\n\n return await enhancedFetch<Android.ReceiptType>(url);\n};\n\n/**\n * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including\n * your developer secret in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} developerSecret: from the Amazon developer console.\n * @param {string} userId who purchased the item.\n * @param {string} receiptId long obfuscated string returned when purchasing the item\n * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAmazon = async ({\n developerSecret,\n userId,\n receiptId,\n useSandbox = true,\n}: {\n developerSecret: string;\n userId: string;\n receiptId: string;\n useSandbox: boolean;\n}): Promise<Amazon.ReceiptType> => {\n const sandBoxUrl = useSandbox ? 'sandbox/' : '';\n const url = `https://appstore-sdk.amazon.com/${sandBoxUrl}version/1.0/verifyReceiptId/developer/${developerSecret}/user/${userId}/receiptId/${receiptId}`;\n\n return await enhancedFetch<Amazon.ReceiptType>(url);\n};\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async ({\n forceRefresh,\n}: {\n forceRefresh?: boolean;\n}): Promise<string> => getIosModule().requestReceipt(forceRefresh ?? false);\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":";;;;;;;AAAA;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ME,6BAA6B,GAAG,YAC3CtH,YAAY,GAAGuH,0BAAf,EADK"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AmazonModule = void 0;
|
|
7
|
+
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
10
|
+
const AmazonModule = _reactNative.NativeModules.RNIapAmazonModule;
|
|
11
|
+
exports.AmazonModule = AmazonModule;
|
|
12
|
+
//# sourceMappingURL=amazon.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AmazonModule","NativeModules","RNIapAmazonModule"],"sources":["amazon.ts"],"sourcesContent":["import {NativeModules} from 'react-native';\n\nimport type {Product, Purchase, Sku} from '../types';\nimport type {UserDataAmazon} from '../types/amazon';\n\nimport type {NativeModuleProps} from './common';\n\n// ----------\n\ntype GetUser = () => Promise<UserDataAmazon>;\ntype FlushFailedPurchasesCachedAsPending = () => Promise<boolean>;\ntype GetItemsByType = (type: string, skus: Sku[]) => Promise<Product[]>;\ntype GetAvailableItems = () => Promise<Purchase[]>;\ntype BuyItemByType = (sku: Sku) => Promise<Purchase>;\n\ntype AcknowledgePurchase = (\n purchaseToken: string,\n developerPayloadAndroid?: string,\n) => Promise<boolean>;\n\ntype ConsumeProduct = (\n purchaseToken: string,\n developerPayloadAndroid?: string,\n) => Promise<boolean>;\n\ntype StartListening = () => Promise<void>;\n\nexport interface AmazonModuleProps extends NativeModuleProps {\n getUser: GetUser;\n flushFailedPurchasesCachedAsPending: FlushFailedPurchasesCachedAsPending;\n getItemsByType: GetItemsByType;\n getAvailableItems: GetAvailableItems;\n buyItemByType: BuyItemByType;\n acknowledgePurchase: AcknowledgePurchase;\n consumeProduct: ConsumeProduct;\n startListening: StartListening;\n}\n\nexport const AmazonModule =\n NativeModules.RNIapAmazonModule as AmazonModuleProps;\n"],"mappings":";;;;;;;AAAA;;AAsCO,MAAMA,YAAY,GACvBC,0BAAA,CAAcC,iBADT"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.AndroidModule = void 0;
|
|
7
|
+
|
|
8
|
+
var _reactNative = require("react-native");
|
|
9
|
+
|
|
10
|
+
const AndroidModule = _reactNative.NativeModules.RNIapModule;
|
|
11
|
+
exports.AndroidModule = AndroidModule;
|
|
12
|
+
//# sourceMappingURL=android.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":["AndroidModule","NativeModules","RNIapModule"],"sources":["android.ts"],"sourcesContent":["import {NativeModules} from 'react-native';\n\nimport type {\n Product,\n ProductType,\n ProrationModesAndroid,\n Purchase,\n PurchaseResult,\n Sku,\n} from '../types';\n\nimport type {NativeModuleProps} from './common';\n\ntype FlushFailedPurchasesCachedAsPending = () => Promise<boolean>;\n\ntype GetItemsByType = <T = Product>(\n type: ProductType,\n skus: Sku[],\n) => Promise<T[]>;\n\ntype GetAvailableItemsByType = <T = Purchase>(\n type: ProductType,\n) => Promise<T[]>;\n\ntype GetPurchaseHistoryByType = <T = Purchase>(\n type: ProductType,\n) => Promise<T[]>;\n\nexport type BuyItemByType = (\n type: string,\n skus: Sku[],\n purchaseToken: string | undefined,\n prorationMode: ProrationModesAndroid,\n obfuscatedAccountId: string | undefined,\n obfuscatedProfileId: string | undefined,\n subscriptionOffers: string[],\n isOfferPersonalized: boolean,\n) => Promise<Purchase>;\n\ntype AcknowledgePurchase = (\n purchaseToken: string,\n developerPayloadAndroid?: string,\n) => Promise<PurchaseResult | boolean>;\n\ntype ConsumeProduct = (\n purchaseToken: string,\n developerPayloadAndroid?: string,\n) => Promise<PurchaseResult | boolean>;\n\ntype StartListening = () => Promise<void>;\ntype GetPackageName = () => Promise<string>;\n\nexport interface AndroidModuleProps extends NativeModuleProps {\n flushFailedPurchasesCachedAsPending: FlushFailedPurchasesCachedAsPending;\n getItemsByType: GetItemsByType;\n getAvailableItemsByType: GetAvailableItemsByType;\n getPurchaseHistoryByType: GetPurchaseHistoryByType;\n buyItemByType: BuyItemByType;\n acknowledgePurchase: AcknowledgePurchase;\n consumeProduct: ConsumeProduct;\n startListening: StartListening;\n getPackageName: GetPackageName;\n}\n\nexport const AndroidModule = NativeModules.RNIapModule as AndroidModuleProps;\n"],"mappings":";;;;;;;AAAA;;AAgEO,MAAMA,aAAa,GAAGC,0BAAA,CAAcC,WAApC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["common.ts"],"sourcesContent":["/**\n * Common interface for all native modules (iOS — AppStore, Android — PlayStore and Amazon).\n */\nexport interface NativeModuleProps {\n /** Required method to start a payment provider connection */\n initConnection(): Promise<boolean>;\n\n /** Required method to end the payment provider connection */\n endConnection(): Promise<boolean>;\n\n /** addListener for NativeEventEmitter */\n addListener(eventType: string): void;\n\n /** removeListeners for NativeEventEmitter */\n removeListeners(count: number): void;\n}\n"],"mappings":""}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
var _amazon = require("./amazon");
|
|
8
|
+
|
|
9
|
+
Object.keys(_amazon).forEach(function (key) {
|
|
10
|
+
if (key === "default" || key === "__esModule") return;
|
|
11
|
+
if (key in exports && exports[key] === _amazon[key]) return;
|
|
12
|
+
Object.defineProperty(exports, key, {
|
|
13
|
+
enumerable: true,
|
|
14
|
+
get: function () {
|
|
15
|
+
return _amazon[key];
|
|
16
|
+
}
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
var _android = require("./android");
|
|
21
|
+
|
|
22
|
+
Object.keys(_android).forEach(function (key) {
|
|
23
|
+
if (key === "default" || key === "__esModule") return;
|
|
24
|
+
if (key in exports && exports[key] === _android[key]) return;
|
|
25
|
+
Object.defineProperty(exports, key, {
|
|
26
|
+
enumerable: true,
|
|
27
|
+
get: function () {
|
|
28
|
+
return _android[key];
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var _ios = require("./ios");
|
|
34
|
+
|
|
35
|
+
Object.keys(_ios).forEach(function (key) {
|
|
36
|
+
if (key === "default" || key === "__esModule") return;
|
|
37
|
+
if (key in exports && exports[key] === _ios[key]) return;
|
|
38
|
+
Object.defineProperty(exports, key, {
|
|
39
|
+
enumerable: true,
|
|
40
|
+
get: function () {
|
|
41
|
+
return _ios[key];
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
var _common = require("./common");
|
|
47
|
+
|
|
48
|
+
Object.keys(_common).forEach(function (key) {
|
|
49
|
+
if (key === "default" || key === "__esModule") return;
|
|
50
|
+
if (key in exports && exports[key] === _common[key]) return;
|
|
51
|
+
Object.defineProperty(exports, key, {
|
|
52
|
+
enumerable: true,
|
|
53
|
+
get: function () {
|
|
54
|
+
return _common[key];
|
|
55
|
+
}
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["index.ts"],"sourcesContent":["export * from './amazon';\nexport * from './android';\nexport * from './ios';\nexport * from './common';\n"],"mappings":";;;;;;AAAA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA;;AACA;;AAAA;EAAA;EAAA;EAAA;IAAA;IAAA;MAAA;IAAA;EAAA;AAAA"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"names":[],"sources":["ios.ts"],"sourcesContent":["import type {\n Product,\n ProductPurchase,\n Purchase,\n Sku,\n Subscription,\n} from '../types';\nimport type {PaymentDiscount} from '../types/apple';\n\nimport type {NativeModuleProps} from './common';\n\ntype getItems = (skus: Sku[]) => Promise<Product[] | Subscription[]>;\n\ntype getAvailableItems = () => Promise<Purchase[]>;\n\nexport type BuyProduct = (\n sku: Sku,\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean,\n applicationUsername?: string,\n) => Promise<Purchase>;\n\ntype buyProductWithOffer = (\n sku: Sku,\n forUser: string,\n withOffer: PaymentDiscount,\n) => Promise<Purchase>;\n\ntype buyProductWithQuantity = (\n sku: Sku,\n quantity: number,\n) => Promise<ProductPurchase>;\ntype clearTransaction = () => Promise<void>;\ntype clearProducts = () => Promise<void>;\ntype promotedProduct = () => Promise<Product | null>;\ntype buyPromotedProduct = () => Promise<void>;\ntype requestReceipt = (refresh: boolean) => Promise<string>;\n\ntype finishTransaction = (transactionIdentifier: string) => Promise<boolean>;\n\ntype getPendingTransactions = () => Promise<ProductPurchase[]>;\ntype presentCodeRedemptionSheet = () => Promise<null>;\n\nexport interface IosModuleProps extends NativeModuleProps {\n getItems: getItems;\n getAvailableItems: getAvailableItems;\n buyProduct: BuyProduct;\n buyProductWithOffer: buyProductWithOffer;\n buyProductWithQuantityIOS: buyProductWithQuantity;\n clearTransaction: clearTransaction;\n clearProducts: clearProducts;\n promotedProduct: promotedProduct;\n buyPromotedProduct: buyPromotedProduct;\n requestReceipt: requestReceipt;\n finishTransaction: finishTransaction;\n getPendingTransactions: getPendingTransactions;\n presentCodeRedemptionSheet: presentCodeRedemptionSheet;\n}\n"],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["amazon.ts"],"sourcesContent":["/**\n * From: https://developer.amazon.com/es/docs/in-app-purchasing/iap-rvs-examples.html\n */\nexport type ReceiptType = {\n autoRenewing: boolean;\n betaProduct: boolean;\n cancelDate: number | null;\n cancelReason: string;\n deferredDate: number | null;\n deferredSku: number | null;\n freeTrialEndDate: number;\n gracePeriodEndDate: number;\n parentProductId: string;\n productId: string;\n productType: string;\n purchaseDate: number;\n quantity: number;\n receiptId: string;\n renewalDate: number;\n term: string;\n termSku: string;\n testTransaction: boolean;\n} & Record<string, unknown>;\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":[],"sources":["amazon.ts"],"sourcesContent":["export interface UserDataAmazon {\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n}\n\nexport interface ProductPurchaseAmazon extends UserDataAmazon {\n isCanceledAmazon?: boolean;\n}\n/**\n * From: https://developer.amazon.com/es/docs/in-app-purchasing/iap-rvs-examples.html\n */\nexport type ReceiptType = {\n autoRenewing: boolean;\n betaProduct: boolean;\n cancelDate: number | null;\n cancelReason: string;\n deferredDate: number | null;\n deferredSku: number | null;\n freeTrialEndDate: number;\n gracePeriodEndDate: number;\n parentProductId: string;\n productId: string;\n productType: string;\n purchaseDate: number;\n quantity: number;\n receiptId: string;\n renewalDate: number;\n term: string;\n termSku: string;\n testTransaction: boolean;\n} & Record<string, unknown>;\n"],"mappings":""}
|