react-native-iap 8.6.4 → 8.6.5
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 +14 -1
- package/ios/RNIapIos.swift +30 -17
- package/lib/commonjs/iap.js +13 -1
- package/lib/commonjs/iap.js.map +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/iap.js +9 -0
- package/lib/module/iap.js.map +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/iap.d.ts +6 -1
- package/lib/typescript/types/index.d.ts +1 -3
- package/package.json +1 -1
- package/src/iap.ts +8 -1
- package/src/types/index.ts +1 -2
package/README.md
CHANGED
|
@@ -19,9 +19,22 @@
|
|
|
19
19
|
|
|
20
20
|
Published in [website](https://react-native-iap.dooboolab.com).
|
|
21
21
|
|
|
22
|
+
## Our maintainers
|
|
23
|
+
|
|
24
|
+
Please [fund the project](https://opencollective.com/react-native-iap) if you are willing the maintainers to make the repository sustainable.
|
|
25
|
+
|
|
26
|
+
- [andresesfm](https://github.com/andresesfm)
|
|
27
|
+
- [jeremybarbet](https://github.com/jeremybarbet)
|
|
28
|
+
|
|
29
|
+
> The fund goes to maintainers.
|
|
30
|
+
|
|
31
|
+
### Supporter
|
|
32
|
+
|
|
33
|
+
- [hyochan](https://github.com/hyochan)
|
|
34
|
+
|
|
22
35
|
## Announcement
|
|
23
36
|
|
|
24
|
-
- Version `9.0.0` is currently in release candidate. The module migrates android sdk to [play billing library v5](https://qonversion.io/blog/google-play-billing-library-5-0) and iOS sdk to [storekit2](https://developer.apple.com/videos/play/wwdc2021/10114). Our core
|
|
37
|
+
- Version `9.0.0` is currently in release candidate. The module migrates android sdk to [play billing library v5](https://qonversion.io/blog/google-play-billing-library-5-0) and iOS sdk to [storekit2](https://developer.apple.com/videos/play/wwdc2021/10114). Our core maintainers [andresesfm](https://github.com/andresesfm) and [jeremybarbet](https://github.com/jeremybarbet) are working hard on this.
|
|
25
38
|
|
|
26
39
|
```
|
|
27
40
|
yarn add react-native-iap@next
|
package/ios/RNIapIos.swift
CHANGED
|
@@ -43,7 +43,8 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
|
|
|
43
43
|
private var promotedPayment: SKPayment?
|
|
44
44
|
private var promotedProduct: SKProduct?
|
|
45
45
|
private var productsRequest: SKProductsRequest?
|
|
46
|
-
private var countPendingTransaction: Int
|
|
46
|
+
private var countPendingTransaction: Int = 0
|
|
47
|
+
private var hasTransactionObserver = false
|
|
47
48
|
|
|
48
49
|
override init() {
|
|
49
50
|
promisesByKey = [String: [RNIapIosPromise]]()
|
|
@@ -51,17 +52,31 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
|
|
|
51
52
|
myQueue = DispatchQueue(label: "reject")
|
|
52
53
|
validProducts = [SKProduct]()
|
|
53
54
|
super.init()
|
|
54
|
-
|
|
55
|
+
addTransactionObserver()
|
|
55
56
|
}
|
|
56
57
|
|
|
57
58
|
deinit {
|
|
58
|
-
|
|
59
|
+
removeTransactionObserver()
|
|
59
60
|
}
|
|
60
61
|
|
|
61
62
|
override class func requiresMainQueueSetup() -> Bool {
|
|
62
63
|
return true
|
|
63
64
|
}
|
|
64
65
|
|
|
66
|
+
func addTransactionObserver() {
|
|
67
|
+
if !hasTransactionObserver {
|
|
68
|
+
hasTransactionObserver = true
|
|
69
|
+
SKPaymentQueue.default().add(self)
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
func removeTransactionObserver() {
|
|
74
|
+
if hasTransactionObserver {
|
|
75
|
+
hasTransactionObserver = false
|
|
76
|
+
SKPaymentQueue.default().remove(self)
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
65
80
|
func flushUnheardEvents() {
|
|
66
81
|
paymentQueue(SKPaymentQueue.default(), updatedTransactions: SKPaymentQueue.default().transactions)
|
|
67
82
|
}
|
|
@@ -136,6 +151,7 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
|
|
|
136
151
|
_ resolve: @escaping RCTPromiseResolveBlock = { _ in },
|
|
137
152
|
reject: @escaping RCTPromiseRejectBlock = { _, _, _ in }
|
|
138
153
|
) {
|
|
154
|
+
addTransactionObserver()
|
|
139
155
|
let canMakePayments = SKPaymentQueue.canMakePayments()
|
|
140
156
|
resolve(NSNumber(value: canMakePayments))
|
|
141
157
|
}
|
|
@@ -143,7 +159,7 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
|
|
|
143
159
|
_ resolve: @escaping RCTPromiseResolveBlock = { _ in },
|
|
144
160
|
reject: @escaping RCTPromiseRejectBlock = { _, _, _ in }
|
|
145
161
|
) {
|
|
146
|
-
|
|
162
|
+
removeTransactionObserver()
|
|
147
163
|
resolve(nil)
|
|
148
164
|
}
|
|
149
165
|
@objc public func getItems(
|
|
@@ -300,18 +316,19 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
|
|
|
300
316
|
_ resolve: @escaping RCTPromiseResolveBlock = { _ in },
|
|
301
317
|
reject: @escaping RCTPromiseRejectBlock = { _, _, _ in }
|
|
302
318
|
) {
|
|
303
|
-
debugMessage("clear remaining Transactions. Call this before make a new transaction")
|
|
304
|
-
|
|
305
319
|
let pendingTrans = SKPaymentQueue.default().transactions
|
|
306
|
-
|
|
320
|
+
countPendingTransaction = pendingTrans.count
|
|
321
|
+
|
|
322
|
+
debugMessage("clear remaining Transactions (\(countPendingTransaction)). Call this before make a new transaction")
|
|
307
323
|
|
|
308
324
|
if countPendingTransaction > 0 {
|
|
309
325
|
addPromise(forKey: "cleaningTransactions", resolve: resolve, reject: reject)
|
|
310
326
|
for transaction in pendingTrans {
|
|
311
327
|
SKPaymentQueue.default().finishTransaction(transaction)
|
|
312
328
|
}
|
|
329
|
+
} else {
|
|
330
|
+
resolve(nil)
|
|
313
331
|
}
|
|
314
|
-
resolve(nil)
|
|
315
332
|
}
|
|
316
333
|
|
|
317
334
|
@objc public func clearProducts(
|
|
@@ -936,18 +953,14 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
|
|
|
936
953
|
}
|
|
937
954
|
|
|
938
955
|
func paymentQueue(_ queue: SKPaymentQueue, removedTransactions transactions: [SKPaymentTransaction]) {
|
|
939
|
-
debugMessage("removedTransactions")
|
|
956
|
+
debugMessage("removedTransactions - countPendingTransactions \(countPendingTransaction)")
|
|
940
957
|
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
}
|
|
944
|
-
|
|
945
|
-
if unwrappedCount > 0 {
|
|
946
|
-
unwrappedCount -= transactions.count
|
|
958
|
+
if countPendingTransaction > 0 {
|
|
959
|
+
countPendingTransaction -= transactions.count
|
|
947
960
|
|
|
948
|
-
if
|
|
961
|
+
if countPendingTransaction <= 0 {
|
|
949
962
|
resolvePromises(forKey: "cleaningTransactions", value: nil)
|
|
950
|
-
countPendingTransaction =
|
|
963
|
+
countPendingTransaction = 0
|
|
951
964
|
}
|
|
952
965
|
}
|
|
953
966
|
}
|
package/lib/commonjs/iap.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.validateReceiptIos = exports.validateReceiptAndroid = exports.validateReceiptAmazon = exports.requestSubscription = exports.requestPurchaseWithQuantityIOS = exports.requestPurchaseWithOfferIOS = exports.requestPurchase = exports.purchaseUpdatedListener = exports.purchaseErrorListener = exports.promotedProductListener = exports.presentCodeRedemptionSheetIOS = exports.initConnection = exports.getSubscriptions = exports.getReceiptIOS = exports.getPurchaseHistory = exports.getPromotedProductIOS = exports.getProducts = exports.getPendingPurchasesIOS = exports.getInstallSourceAndroid = exports.getAvailablePurchases = exports.flushFailedPurchasesCachedAsPendingAndroid = exports.finishTransaction = exports.endConnection = exports.deepLinkToSubscriptionsAndroid = exports.clearTransactionIOS = exports.clearProductsIOS = exports.buyPromotedProductIOS = exports.acknowledgePurchaseAndroid = void 0;
|
|
6
|
+
exports.validateReceiptIos = exports.validateReceiptAndroid = exports.validateReceiptAmazon = exports.requestSubscription = exports.requestPurchaseWithQuantityIOS = exports.requestPurchaseWithOfferIOS = exports.requestPurchase = exports.purchaseUpdatedListener = exports.purchaseErrorListener = exports.promotedProductListener = exports.presentCodeRedemptionSheetIOS = exports.initConnection = exports.getSubscriptions = exports.getReceiptIOS = exports.getPurchaseHistory = exports.getPromotedProductIOS = exports.getProducts = exports.getPendingPurchasesIOS = exports.getInstallSourceAndroid = exports.getAvailablePurchases = exports.flushFailedPurchasesCachedAsPendingAndroid = exports.finishTransaction = exports.endConnection = exports.deepLinkToSubscriptionsAndroid = exports.clearTransactionIOS = exports.clearProductsIOS = exports.buyPromotedProductIOS = exports.acknowledgePurchaseAndroid = exports.IapError = void 0;
|
|
7
7
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
|
|
@@ -21,6 +21,18 @@ const isIos = _reactNative.Platform.OS === 'ios';
|
|
|
21
21
|
const ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';
|
|
22
22
|
const ANDROID_ITEM_TYPE_IAP = 'inapp';
|
|
23
23
|
|
|
24
|
+
class IapError {
|
|
25
|
+
constructor(code, message) {
|
|
26
|
+
this.code = code;
|
|
27
|
+
this.message = message;
|
|
28
|
+
this.code = code;
|
|
29
|
+
this.message = message;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
exports.IapError = IapError;
|
|
35
|
+
|
|
24
36
|
const getInstallSourceAndroid = () => {
|
|
25
37
|
return RNIapModule ? _types.InstallSourceAndroid.GOOGLE_PLAY : _types.InstallSourceAndroid.AMAZON;
|
|
26
38
|
};
|
package/lib/commonjs/iap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RNIapIos","RNIapModule","RNIapAmazonModule","NativeModules","isAndroid","Platform","OS","isIos","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","getInstallSourceAndroid","InstallSourceAndroid","GOOGLE_PLAY","AMAZON","checkNativeAndroidAvailable","Error","IAPErrorCode","E_IAP_NOT_AVAILABLE","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","fillProductsAdditionalData","products","user","getUser","currencies","CA","ES","AU","DE","IN","US","JP","GB","IT","BR","FR","currency","userMarketplaceAmazon","forEach","product","getProducts","skus","select","ios","items","getItems","filter","item","includes","productId","type","android","getItemsByType","Promise","resolve","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","applicationUsername","console","warn","buyProduct","buyItemByType","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","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","fetchJsonOrThrow","url","receiptBody","response","fetch","method","headers","Accept","body","JSON","stringify","ok","Object","assign","statusText","statusCode","status","json","requestAgnosticReceiptValidationIos","ReceiptValidationStatus","TEST_RECEIPT","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","purchaseUpdatedListener","listener","emitterSubscription","NativeEventEmitter","addListener","startListening","purchaseErrorListener","promotedProductListener","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {\n EmitterSubscription,\n Linking,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} 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 type {\n InAppPurchase,\n Product,\n ProductCommon,\n ProductPurchase,\n PurchaseError,\n PurchaseResult,\n RequestPurchase,\n RequestSubscription,\n Subscription,\n SubscriptionPurchase,\n} from './types';\nimport {\n IAPErrorCode,\n InstallSourceAndroid,\n PurchaseStateAndroid,\n} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst isAndroid = Platform.OS === 'android';\nconst isIos = Platform.OS === 'ios';\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\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getAndroidModule = (): typeof RNIapModule | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return RNIapModule ? RNIapModule : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nconst getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n if (isAndroid) {\n return getAndroidModule();\n }\n\n return 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 * Fill products with additional data\n * @param {Array<ProductCommon>} products Products\n */\nconst fillProductsAdditionalData = async (\n products: Array<ProductCommon>,\n): Promise<Array<ProductCommon>> => {\n // Amazon\n if (RNIapAmazonModule) {\n // On amazon we must get the user marketplace to detect the currency\n const user = await RNIapAmazonModule.getUser();\n\n const currencies = {\n CA: 'CAD',\n ES: 'EUR',\n AU: 'AUD',\n DE: 'EUR',\n IN: 'INR',\n US: 'USD',\n JP: 'JPY',\n GB: 'GBP',\n IT: 'EUR',\n BR: 'BRL',\n FR: 'EUR',\n };\n\n const currency =\n currencies[user.userMarketplaceAmazon as keyof typeof currencies];\n\n // Add currency to products\n products.forEach((product) => {\n if (currency) {\n product.currency = currency;\n }\n });\n }\n\n return products;\n};\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 = (skus: string[]): 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 fillProductsAdditionalData(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 = (skus: string[]): 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 fillProductsAdditionalData(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<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (InAppPurchase | 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<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (InAppPurchase | 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 * @returns {Promise<InAppPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestPurchase): Promise<InAppPurchase> =>\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 return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n sku,\n null,\n 0,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\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 * @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 purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestSubscription): 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 return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n sku,\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\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: string,\n quantity: number,\n): Promise<InAppPurchase> =>\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: InAppPurchase | 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: 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: string,\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 fetchJsonOrThrow = async (\n url: string,\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(receiptBody),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetchJsonOrThrow(\n 'https://buy.itunes.apple.com/verifyReceipt',\n receiptBody,\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 fetchJsonOrThrow(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n receiptBody,\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: string,\n forUser: string,\n withOffer: Apple.PaymentDiscount,\n): Promise<void> => 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: 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 const response = await fetchJsonOrThrow(url, receiptBody);\n\n return response;\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: 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 const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\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: string,\n userId: string,\n receiptId: string,\n useSandbox: boolean = true,\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 const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Add IAP purchase event\n * @returns {callback(e: InAppPurchase | ProductPurchase)}\n */\nexport const purchaseUpdatedListener = (\n listener: (event: InAppPurchase | SubscriptionPurchase) => void,\n): EmitterSubscription => {\n const emitterSubscription = new NativeEventEmitter(\n getNativeModule(),\n ).addListener('purchase-updated', listener);\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n * @returns {callback(e: PurchaseError)}\n */\nexport const purchaseErrorListener = (\n listener: (errorEvent: PurchaseError) => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getNativeModule()).addListener(\n 'purchase-error',\n listener,\n );\n\n/**\n * Add IAP promoted subscription event\n * Only available on iOS\n */\nexport const promotedProductListener = (\n listener: () => void,\n): EmitterSubscription | null => {\n if (isIos) {\n return new NativeEventEmitter(getIosModule()).addListener(\n 'iap-promoted-product',\n listener,\n );\n }\n return null;\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 (forceRefresh?: boolean): Promise<string> =>\n 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;;AAWA;;AAaA;;AAMA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CC,0BAAnD;AACA,MAAMC,SAAS,GAAGC,qBAAA,CAASC,EAAT,KAAgB,SAAlC;AACA,MAAMC,KAAK,GAAGF,qBAAA,CAASC,EAAT,KAAgB,KAA9B;AACA,MAAME,8BAA8B,GAAG,MAAvC;AACA,MAAMC,qBAAqB,GAAG,OAA9B;;AAEO,MAAMC,uBAAuB,GAAG,MAA4B;EACjE,OAAOT,WAAW,GACdU,2BAAA,CAAqBC,WADP,GAEdD,2BAAA,CAAqBE,MAFzB;AAGD,CAJM;;;;AAMP,MAAMC,2BAA2B,GAAG,MAAY;EAC9C,IAAI,CAACb,WAAD,IAAgB,CAACC,iBAArB,EAAwC;IACtC,MAAM,IAAIa,KAAJ,CAAUC,mBAA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B,CAA9C,CAAN;EAGD;;EAED,OAAOb,QAAQ,CAACc,IAAT,EAAP;AACD,CAvBM;AAyBP;AACA;AACA;AACA;;;;;AACO,MAAMsB,uBAAuB,GAClCC,QADqC,IAEb;EACxB,MAAMC,mBAAmB,GAAG,IAAIC,+BAAJ,CAC1BtI,eAAe,EADW,EAE1BuI,WAF0B,CAEd,kBAFc,EAEMH,QAFN,CAA5B;;EAIA,IAAIrJ,SAAJ,EAAe;IACbc,gBAAgB,GAAG2I,cAAnB;EACD;;EAED,OAAOH,mBAAP;AACD,CAZM;AAcP;AACA;AACA;AACA;;;;;AACO,MAAMI,qBAAqB,GAChCL,QADmC,IAGnC,IAAIE,+BAAJ,CAAuBtI,eAAe,EAAtC,EAA0CuI,WAA1C,CACE,gBADF,EAEEH,QAFF,CAHK;AAQP;AACA;AACA;AACA;;;;;AACO,MAAMM,uBAAuB,GAClCN,QADqC,IAEN;EAC/B,IAAIlJ,KAAJ,EAAW;IACT,OAAO,IAAIoJ,+BAAJ,CAAuBvI,YAAY,EAAnC,EAAuCwI,WAAvC,CACL,sBADK,EAELH,QAFK,CAAP;EAID;;EACD,OAAO,IAAP;AACD,CAVM;AAYP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMO,sBAAsB,GAAG,YACpC5I,YAAY,GAAG6I,sBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,aAAa,GAAG,MAAOC,YAAP,IAC3B/I,YAAY,GAAGgJ,cAAf,CAA8BD,YAAY,IAAI,KAA9C,CADK;AAGP;AACA;AACA;AACA;;;;;AACO,MAAME,6BAA6B,GAAG,YAC3CjJ,YAAY,GAAGkJ,0BAAf,EADK"}
|
|
1
|
+
{"version":3,"names":["RNIapIos","RNIapModule","RNIapAmazonModule","NativeModules","isAndroid","Platform","OS","isIos","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","IapError","constructor","code","message","getInstallSourceAndroid","InstallSourceAndroid","GOOGLE_PLAY","AMAZON","checkNativeAndroidAvailable","Error","IAPErrorCode","E_IAP_NOT_AVAILABLE","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","fillProductsAdditionalData","products","user","getUser","currencies","CA","ES","AU","DE","IN","US","JP","GB","IT","BR","FR","currency","userMarketplaceAmazon","forEach","product","getProducts","skus","select","ios","items","getItems","filter","item","includes","productId","type","android","getItemsByType","Promise","resolve","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","applicationUsername","console","warn","buyProduct","buyItemByType","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","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","fetchJsonOrThrow","url","receiptBody","response","fetch","method","headers","Accept","body","JSON","stringify","ok","Object","assign","statusText","statusCode","status","json","requestAgnosticReceiptValidationIos","ReceiptValidationStatus","TEST_RECEIPT","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","purchaseUpdatedListener","listener","emitterSubscription","NativeEventEmitter","addListener","startListening","purchaseErrorListener","promotedProductListener","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {\n EmitterSubscription,\n Linking,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} 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 type {\n InAppPurchase,\n Product,\n ProductCommon,\n ProductPurchase,\n PurchaseError,\n PurchaseResult,\n RequestPurchase,\n RequestSubscription,\n Subscription,\n SubscriptionPurchase,\n} from './types';\nimport {\n IAPErrorCode,\n InstallSourceAndroid,\n PurchaseStateAndroid,\n} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst isAndroid = Platform.OS === 'android';\nconst isIos = Platform.OS === 'ios';\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport class IapError implements PurchaseError {\n constructor(public code?: string, public message?: string) {\n this.code = code;\n this.message = message;\n }\n}\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getAndroidModule = (): typeof RNIapModule | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return RNIapModule ? RNIapModule : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nconst getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n if (isAndroid) {\n return getAndroidModule();\n }\n\n return 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 * Fill products with additional data\n * @param {Array<ProductCommon>} products Products\n */\nconst fillProductsAdditionalData = async (\n products: Array<ProductCommon>,\n): Promise<Array<ProductCommon>> => {\n // Amazon\n if (RNIapAmazonModule) {\n // On amazon we must get the user marketplace to detect the currency\n const user = await RNIapAmazonModule.getUser();\n\n const currencies = {\n CA: 'CAD',\n ES: 'EUR',\n AU: 'AUD',\n DE: 'EUR',\n IN: 'INR',\n US: 'USD',\n JP: 'JPY',\n GB: 'GBP',\n IT: 'EUR',\n BR: 'BRL',\n FR: 'EUR',\n };\n\n const currency =\n currencies[user.userMarketplaceAmazon as keyof typeof currencies];\n\n // Add currency to products\n products.forEach((product) => {\n if (currency) {\n product.currency = currency;\n }\n });\n }\n\n return products;\n};\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 = (skus: string[]): 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 fillProductsAdditionalData(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 = (skus: string[]): 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 fillProductsAdditionalData(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<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (InAppPurchase | 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<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (InAppPurchase | 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 * @returns {Promise<InAppPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestPurchase): Promise<InAppPurchase> =>\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 return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n sku,\n null,\n 0,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\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 * @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 purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestSubscription): 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 return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n sku,\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\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: string,\n quantity: number,\n): Promise<InAppPurchase> =>\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: InAppPurchase | 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: 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: string,\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 fetchJsonOrThrow = async (\n url: string,\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(receiptBody),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetchJsonOrThrow(\n 'https://buy.itunes.apple.com/verifyReceipt',\n receiptBody,\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 fetchJsonOrThrow(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n receiptBody,\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: string,\n forUser: string,\n withOffer: Apple.PaymentDiscount,\n): Promise<void> => 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: 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 const response = await fetchJsonOrThrow(url, receiptBody);\n\n return response;\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: 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 const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\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: string,\n userId: string,\n receiptId: string,\n useSandbox: boolean = true,\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 const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Add IAP purchase event\n * @returns {callback(e: InAppPurchase | ProductPurchase)}\n */\nexport const purchaseUpdatedListener = (\n listener: (event: InAppPurchase | SubscriptionPurchase) => void,\n): EmitterSubscription => {\n const emitterSubscription = new NativeEventEmitter(\n getNativeModule(),\n ).addListener('purchase-updated', listener);\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n * @returns {callback(e: PurchaseError)}\n */\nexport const purchaseErrorListener = (\n listener: (errorEvent: PurchaseError) => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getNativeModule()).addListener(\n 'purchase-error',\n listener,\n );\n\n/**\n * Add IAP promoted subscription event\n * Only available on iOS\n */\nexport const promotedProductListener = (\n listener: (productId?: string) => void,\n): EmitterSubscription | null => {\n if (isIos) {\n return new NativeEventEmitter(getIosModule()).addListener(\n 'iap-promoted-product',\n listener,\n );\n }\n return null;\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 (forceRefresh?: boolean): Promise<string> =>\n 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;;AAWA;;AAaA;;AAMA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CC,0BAAnD;AACA,MAAMC,SAAS,GAAGC,qBAAA,CAASC,EAAT,KAAgB,SAAlC;AACA,MAAMC,KAAK,GAAGF,qBAAA,CAASC,EAAT,KAAgB,KAA9B;AACA,MAAME,8BAA8B,GAAG,MAAvC;AACA,MAAMC,qBAAqB,GAAG,OAA9B;;AAEO,MAAMC,QAAN,CAAwC;EAC7CC,WAAW,CAAQC,IAAR,EAA8BC,OAA9B,EAAgD;IAAA,KAAxCD,IAAwC,GAAxCA,IAAwC;IAAA,KAAlBC,OAAkB,GAAlBA,OAAkB;IACzD,KAAKD,IAAL,GAAYA,IAAZ;IACA,KAAKC,OAAL,GAAeA,OAAf;EACD;;AAJ4C;;;;AAOxC,MAAMC,uBAAuB,GAAG,MAA4B;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AY,GAAGkJ,0BAAf,EADK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["IAPErrorCode","ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid"],"sources":["index.ts"],"sourcesContent":["type Sku = string;\n\nexport enum IAPErrorCode {\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n}\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string;\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n //Android\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n //Amazon\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n isCanceledAmazon?: boolean;\n}\n\nexport interface PurchaseResult {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n}\n\nexport interface PurchaseError {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n productId?: string;\n}\n\nexport type InAppPurchase = ProductPurchase;\n\nexport interface SubscriptionPurchase extends ProductPurchase {\n autoRenewingAndroid?: boolean;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n}\n\nexport type Purchase = InAppPurchase | SubscriptionPurchase;\n\nexport interface Discount {\n identifier: string;\n type: string;\n numberOfPeriods: string;\n price: string;\n localizedPrice: string;\n paymentMode: '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';\n subscriptionPeriod: string;\n}\n\nexport interface Product extends ProductCommon {\n type: 'inapp' | 'iap';\n}\n\nexport interface Subscription extends ProductCommon {\n type: 'subs' | 'sub';\n\n discounts?: Discount[];\n\n introductoryPrice?: string;\n introductoryPriceAsAmountIOS?: string;\n introductoryPricePaymentModeIOS?:\n | ''\n | 'FREETRIAL'\n | 'PAYASYOUGO'\n | 'PAYUPFRONT';\n introductoryPriceNumberOfPeriodsIOS?: string;\n introductoryPriceSubscriptionPeriodIOS?:\n | 'DAY'\n | 'WEEK'\n | 'MONTH'\n | 'YEAR'\n | '';\n\n subscriptionPeriodNumberIOS?: string;\n subscriptionPeriodUnitIOS?: '' | 'YEAR' | 'MONTH' | 'WEEK' | 'DAY';\n\n introductoryPriceAsAmountAndroid: string;\n introductoryPriceCyclesAndroid?: string;\n introductoryPricePeriodAndroid?: string;\n subscriptionPeriodAndroid?: string;\n freeTrialPeriodAndroid?: string;\n}\n\nexport interface RequestPurchase {\n sku: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n
|
|
1
|
+
{"version":3,"names":["IAPErrorCode","ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid"],"sources":["index.ts"],"sourcesContent":["export type Sku = string;\n\nexport enum IAPErrorCode {\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n}\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string;\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n //Android\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n //Amazon\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n isCanceledAmazon?: boolean;\n}\n\nexport interface PurchaseResult {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n}\n\nexport interface PurchaseError {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n productId?: string;\n}\n\nexport type InAppPurchase = ProductPurchase;\n\nexport interface SubscriptionPurchase extends ProductPurchase {\n autoRenewingAndroid?: boolean;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n}\n\nexport type Purchase = InAppPurchase | SubscriptionPurchase;\n\nexport interface Discount {\n identifier: string;\n type: string;\n numberOfPeriods: string;\n price: string;\n localizedPrice: string;\n paymentMode: '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';\n subscriptionPeriod: string;\n}\n\nexport interface Product extends ProductCommon {\n type: 'inapp' | 'iap';\n}\n\nexport interface Subscription extends ProductCommon {\n type: 'subs' | 'sub';\n\n discounts?: Discount[];\n\n introductoryPrice?: string;\n introductoryPriceAsAmountIOS?: string;\n introductoryPricePaymentModeIOS?:\n | ''\n | 'FREETRIAL'\n | 'PAYASYOUGO'\n | 'PAYUPFRONT';\n introductoryPriceNumberOfPeriodsIOS?: string;\n introductoryPriceSubscriptionPeriodIOS?:\n | 'DAY'\n | 'WEEK'\n | 'MONTH'\n | 'YEAR'\n | '';\n\n subscriptionPeriodNumberIOS?: string;\n subscriptionPeriodUnitIOS?: '' | 'YEAR' | 'MONTH' | 'WEEK' | 'DAY';\n\n introductoryPriceAsAmountAndroid: string;\n introductoryPriceCyclesAndroid?: string;\n introductoryPricePeriodAndroid?: string;\n subscriptionPeriodAndroid?: string;\n freeTrialPeriodAndroid?: string;\n}\n\nexport interface RequestPurchase {\n sku: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n}\n\nexport interface RequestSubscription extends RequestPurchase {\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n}\n"],"mappings":";;;;;;IAEYA,Y;;;WAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;GAAAA,Y,4BAAAA,Y;;IAmBAC,qB;;;WAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,qCAAAA,qB;;IAQAC,oB;;;WAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,oCAAAA,oB;;AAML,MAAMC,gBAAgB,GAAG,sBAAzB;;IAEKC,oB;;;WAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,oCAAAA,oB"}
|
package/lib/module/iap.js
CHANGED
|
@@ -10,6 +10,15 @@ const isAndroid = Platform.OS === 'android';
|
|
|
10
10
|
const isIos = Platform.OS === 'ios';
|
|
11
11
|
const ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';
|
|
12
12
|
const ANDROID_ITEM_TYPE_IAP = 'inapp';
|
|
13
|
+
export class IapError {
|
|
14
|
+
constructor(code, message) {
|
|
15
|
+
this.code = code;
|
|
16
|
+
this.message = message;
|
|
17
|
+
this.code = code;
|
|
18
|
+
this.message = message;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
}
|
|
13
22
|
export const getInstallSourceAndroid = () => {
|
|
14
23
|
return RNIapModule ? InstallSourceAndroid.GOOGLE_PLAY : InstallSourceAndroid.AMAZON;
|
|
15
24
|
};
|
package/lib/module/iap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["Linking","NativeEventEmitter","NativeModules","Platform","ReceiptValidationStatus","IAPErrorCode","InstallSourceAndroid","PurchaseStateAndroid","RNIapIos","RNIapModule","RNIapAmazonModule","isAndroid","OS","isIos","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","getInstallSourceAndroid","GOOGLE_PLAY","AMAZON","checkNativeAndroidAvailable","Error","E_IAP_NOT_AVAILABLE","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","fillProductsAdditionalData","products","user","getUser","currencies","CA","ES","AU","DE","IN","US","JP","GB","IT","BR","FR","currency","userMarketplaceAmazon","forEach","product","getProducts","skus","select","ios","items","getItems","filter","item","includes","productId","type","android","getItemsByType","Promise","resolve","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","applicationUsername","console","warn","buyProduct","buyItemByType","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","consumeProduct","purchaseToken","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","fetchJsonOrThrow","url","receiptBody","response","fetch","method","headers","Accept","body","JSON","stringify","ok","Object","assign","statusText","statusCode","status","json","requestAgnosticReceiptValidationIos","TEST_RECEIPT","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","purchaseUpdatedListener","listener","emitterSubscription","addListener","startListening","purchaseErrorListener","promotedProductListener","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {\n EmitterSubscription,\n Linking,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} 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 type {\n InAppPurchase,\n Product,\n ProductCommon,\n ProductPurchase,\n PurchaseError,\n PurchaseResult,\n RequestPurchase,\n RequestSubscription,\n Subscription,\n SubscriptionPurchase,\n} from './types';\nimport {\n IAPErrorCode,\n InstallSourceAndroid,\n PurchaseStateAndroid,\n} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst isAndroid = Platform.OS === 'android';\nconst isIos = Platform.OS === 'ios';\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\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getAndroidModule = (): typeof RNIapModule | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return RNIapModule ? RNIapModule : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nconst getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n if (isAndroid) {\n return getAndroidModule();\n }\n\n return 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 * Fill products with additional data\n * @param {Array<ProductCommon>} products Products\n */\nconst fillProductsAdditionalData = async (\n products: Array<ProductCommon>,\n): Promise<Array<ProductCommon>> => {\n // Amazon\n if (RNIapAmazonModule) {\n // On amazon we must get the user marketplace to detect the currency\n const user = await RNIapAmazonModule.getUser();\n\n const currencies = {\n CA: 'CAD',\n ES: 'EUR',\n AU: 'AUD',\n DE: 'EUR',\n IN: 'INR',\n US: 'USD',\n JP: 'JPY',\n GB: 'GBP',\n IT: 'EUR',\n BR: 'BRL',\n FR: 'EUR',\n };\n\n const currency =\n currencies[user.userMarketplaceAmazon as keyof typeof currencies];\n\n // Add currency to products\n products.forEach((product) => {\n if (currency) {\n product.currency = currency;\n }\n });\n }\n\n return products;\n};\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 = (skus: string[]): 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 fillProductsAdditionalData(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 = (skus: string[]): 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 fillProductsAdditionalData(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<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (InAppPurchase | 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<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (InAppPurchase | 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 * @returns {Promise<InAppPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestPurchase): Promise<InAppPurchase> =>\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 return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n sku,\n null,\n 0,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\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 * @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 purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestSubscription): 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 return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n sku,\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\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: string,\n quantity: number,\n): Promise<InAppPurchase> =>\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: InAppPurchase | 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: 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: string,\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 fetchJsonOrThrow = async (\n url: string,\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(receiptBody),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetchJsonOrThrow(\n 'https://buy.itunes.apple.com/verifyReceipt',\n receiptBody,\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 fetchJsonOrThrow(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n receiptBody,\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: string,\n forUser: string,\n withOffer: Apple.PaymentDiscount,\n): Promise<void> => 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: 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 const response = await fetchJsonOrThrow(url, receiptBody);\n\n return response;\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: 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 const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\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: string,\n userId: string,\n receiptId: string,\n useSandbox: boolean = true,\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 const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Add IAP purchase event\n * @returns {callback(e: InAppPurchase | ProductPurchase)}\n */\nexport const purchaseUpdatedListener = (\n listener: (event: InAppPurchase | SubscriptionPurchase) => void,\n): EmitterSubscription => {\n const emitterSubscription = new NativeEventEmitter(\n getNativeModule(),\n ).addListener('purchase-updated', listener);\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n * @returns {callback(e: PurchaseError)}\n */\nexport const purchaseErrorListener = (\n listener: (errorEvent: PurchaseError) => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getNativeModule()).addListener(\n 'purchase-error',\n listener,\n );\n\n/**\n * Add IAP promoted subscription event\n * Only available on iOS\n */\nexport const promotedProductListener = (\n listener: () => void,\n): EmitterSubscription | null => {\n if (isIos) {\n return new NativeEventEmitter(getIosModule()).addListener(\n 'iap-promoted-product',\n listener,\n );\n }\n return null;\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 (forceRefresh?: boolean): Promise<string> =>\n 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,SAEEA,OAFF,EAGEC,kBAHF,EAIEC,aAJF,EAKEC,QALF,QAMO,cANP;AAWA,SAAQC,uBAAR,QAAsC,eAAtC;AAaA,SACEC,YADF,EAEEC,oBAFF,EAGEC,oBAHF,QAIO,SAJP;AAMA,MAAM;EAACC,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CR,aAAnD;AACA,MAAMS,SAAS,GAAGR,QAAQ,CAACS,EAAT,KAAgB,SAAlC;AACA,MAAMC,KAAK,GAAGV,QAAQ,CAACS,EAAT,KAAgB,KAA9B;AACA,MAAME,8BAA8B,GAAG,MAAvC;AACA,MAAMC,qBAAqB,GAAG,OAA9B;AAEA,OAAO,MAAMC,uBAAuB,GAAG,MAA4B;EACjE,OAAOP,WAAW,GACdH,oBAAoB,CAACW,WADP,GAEdX,oBAAoB,CAACY,MAFzB;AAGD,CAJM;;AAMP,MAAMC,2BAA2B,GAAG,MAAY;EAC9C,IAAI,CAACV,WAAD,IAAgB,CAACC,iBAArB,EAAwC;IACtC,MAAM,IAAIU,KAAJ,CAAUf,YAAY,CAACgB,mBAAvB,CAAN;EACD;AACF,CAJD;;AAMA,MAAMC,gBAAgB,GAAG,MAAqD;EAC5EH,2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,IAAT,EAAP;AACD,CAvBM;AAyBP;AACA;AACA;AACA;;AACA,OAAO,MAAMqB,uBAAuB,GAClCC,QADqC,IAEb;EACxB,MAAMC,mBAAmB,GAAG,IAAI1J,kBAAJ,CAC1BwB,eAAe,EADW,EAE1BmI,WAF0B,CAEd,kBAFc,EAEMF,QAFN,CAA5B;;EAIA,IAAI/I,SAAJ,EAAe;IACbW,gBAAgB,GAAGuI,cAAnB;EACD;;EAED,OAAOF,mBAAP;AACD,CAZM;AAcP;AACA;AACA;AACA;;AACA,OAAO,MAAMG,qBAAqB,GAChCJ,QADmC,IAGnC,IAAIzJ,kBAAJ,CAAuBwB,eAAe,EAAtC,EAA0CmI,WAA1C,CACE,gBADF,EAEEF,QAFF,CAHK;AAQP;AACA;AACA;AACA;;AACA,OAAO,MAAMK,uBAAuB,GAClCL,QADqC,IAEN;EAC/B,IAAI7I,KAAJ,EAAW;IACT,OAAO,IAAIZ,kBAAJ,CAAuBuB,YAAY,EAAnC,EAAuCoI,WAAvC,CACL,sBADK,EAELF,QAFK,CAAP;EAID;;EACD,OAAO,IAAP;AACD,CAVM;AAYP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMM,sBAAsB,GAAG,YACpCxI,YAAY,GAAGyI,sBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG,MAAOC,YAAP,IAC3B3I,YAAY,GAAG4I,cAAf,CAA8BD,YAAY,IAAI,KAA9C,CADK;AAGP;AACA;AACA;AACA;;AACA,OAAO,MAAME,6BAA6B,GAAG,YAC3C7I,YAAY,GAAG8I,0BAAf,EADK"}
|
|
1
|
+
{"version":3,"names":["Linking","NativeEventEmitter","NativeModules","Platform","ReceiptValidationStatus","IAPErrorCode","InstallSourceAndroid","PurchaseStateAndroid","RNIapIos","RNIapModule","RNIapAmazonModule","isAndroid","OS","isIos","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","IapError","constructor","code","message","getInstallSourceAndroid","GOOGLE_PLAY","AMAZON","checkNativeAndroidAvailable","Error","E_IAP_NOT_AVAILABLE","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","fillProductsAdditionalData","products","user","getUser","currencies","CA","ES","AU","DE","IN","US","JP","GB","IT","BR","FR","currency","userMarketplaceAmazon","forEach","product","getProducts","skus","select","ios","items","getItems","filter","item","includes","productId","type","android","getItemsByType","Promise","resolve","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","applicationUsername","console","warn","buyProduct","buyItemByType","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","consumeProduct","purchaseToken","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","fetchJsonOrThrow","url","receiptBody","response","fetch","method","headers","Accept","body","JSON","stringify","ok","Object","assign","statusText","statusCode","status","json","requestAgnosticReceiptValidationIos","TEST_RECEIPT","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","purchaseUpdatedListener","listener","emitterSubscription","addListener","startListening","purchaseErrorListener","promotedProductListener","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {\n EmitterSubscription,\n Linking,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} 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 type {\n InAppPurchase,\n Product,\n ProductCommon,\n ProductPurchase,\n PurchaseError,\n PurchaseResult,\n RequestPurchase,\n RequestSubscription,\n Subscription,\n SubscriptionPurchase,\n} from './types';\nimport {\n IAPErrorCode,\n InstallSourceAndroid,\n PurchaseStateAndroid,\n} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst isAndroid = Platform.OS === 'android';\nconst isIos = Platform.OS === 'ios';\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport class IapError implements PurchaseError {\n constructor(public code?: string, public message?: string) {\n this.code = code;\n this.message = message;\n }\n}\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getAndroidModule = (): typeof RNIapModule | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return RNIapModule ? RNIapModule : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nconst getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n if (isAndroid) {\n return getAndroidModule();\n }\n\n return 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 * Fill products with additional data\n * @param {Array<ProductCommon>} products Products\n */\nconst fillProductsAdditionalData = async (\n products: Array<ProductCommon>,\n): Promise<Array<ProductCommon>> => {\n // Amazon\n if (RNIapAmazonModule) {\n // On amazon we must get the user marketplace to detect the currency\n const user = await RNIapAmazonModule.getUser();\n\n const currencies = {\n CA: 'CAD',\n ES: 'EUR',\n AU: 'AUD',\n DE: 'EUR',\n IN: 'INR',\n US: 'USD',\n JP: 'JPY',\n GB: 'GBP',\n IT: 'EUR',\n BR: 'BRL',\n FR: 'EUR',\n };\n\n const currency =\n currencies[user.userMarketplaceAmazon as keyof typeof currencies];\n\n // Add currency to products\n products.forEach((product) => {\n if (currency) {\n product.currency = currency;\n }\n });\n }\n\n return products;\n};\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 = (skus: string[]): 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 fillProductsAdditionalData(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 = (skus: string[]): 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 fillProductsAdditionalData(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<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (InAppPurchase | 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<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (InAppPurchase | 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 * @returns {Promise<InAppPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestPurchase): Promise<InAppPurchase> =>\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 return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n sku,\n null,\n 0,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\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 * @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 purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestSubscription): 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 return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n sku,\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\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: string,\n quantity: number,\n): Promise<InAppPurchase> =>\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: InAppPurchase | 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: 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: string,\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 fetchJsonOrThrow = async (\n url: string,\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(receiptBody),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetchJsonOrThrow(\n 'https://buy.itunes.apple.com/verifyReceipt',\n receiptBody,\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 fetchJsonOrThrow(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n receiptBody,\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: string,\n forUser: string,\n withOffer: Apple.PaymentDiscount,\n): Promise<void> => 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: 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 const response = await fetchJsonOrThrow(url, receiptBody);\n\n return response;\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: 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 const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\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: string,\n userId: string,\n receiptId: string,\n useSandbox: boolean = true,\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 const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Add IAP purchase event\n * @returns {callback(e: InAppPurchase | ProductPurchase)}\n */\nexport const purchaseUpdatedListener = (\n listener: (event: InAppPurchase | SubscriptionPurchase) => void,\n): EmitterSubscription => {\n const emitterSubscription = new NativeEventEmitter(\n getNativeModule(),\n ).addListener('purchase-updated', listener);\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n * @returns {callback(e: PurchaseError)}\n */\nexport const purchaseErrorListener = (\n listener: (errorEvent: PurchaseError) => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getNativeModule()).addListener(\n 'purchase-error',\n listener,\n );\n\n/**\n * Add IAP promoted subscription event\n * Only available on iOS\n */\nexport const promotedProductListener = (\n listener: (productId?: string) => void,\n): EmitterSubscription | null => {\n if (isIos) {\n return new NativeEventEmitter(getIosModule()).addListener(\n 'iap-promoted-product',\n listener,\n );\n }\n return null;\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 (forceRefresh?: boolean): Promise<string> =>\n 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,SAEEA,OAFF,EAGEC,kBAHF,EAIEC,aAJF,EAKEC,QALF,QAMO,cANP;AAWA,SAAQC,uBAAR,QAAsC,eAAtC;AAaA,SACEC,YADF,EAEEC,oBAFF,EAGEC,oBAHF,QAIO,SAJP;AAMA,MAAM;EAACC,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CR,aAAnD;AACA,MAAMS,SAAS,GAAGR,QAAQ,CAACS,EAAT,KAAgB,SAAlC;AACA,MAAMC,KAAK,GAAGV,QAAQ,CAACS,EAAT,KAAgB,KAA9B;AACA,MAAME,8BAA8B,GAAG,MAAvC;AACA,MAAMC,qBAAqB,GAAG,OAA9B;AAEA,OAAO,MAAMC,QAAN,CAAwC;EAC7CC,WAAW,CAAQC,IAAR,EAA8BC,OAA9B,EAAgD;IAAA,KAAxCD,IAAwC,GAAxCA,IAAwC;IAAA,KAAlBC,OAAkB,GAAlBA,OAAkB;IACzD,KAAKD,IAA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AAMC,aAAa,GAAG,MAAOC,YAAP,IAC3B3I,YAAY,GAAG4I,cAAf,CAA8BD,YAAY,IAAI,KAA9C,CADK;AAGP;AACA;AACA;AACA;;AACA,OAAO,MAAME,6BAA6B,GAAG,YAC3C7I,YAAY,GAAG8I,0BAAf,EADK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["IAPErrorCode","ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid"],"sources":["index.ts"],"sourcesContent":["type Sku = string;\n\nexport enum IAPErrorCode {\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n}\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string;\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n //Android\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n //Amazon\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n isCanceledAmazon?: boolean;\n}\n\nexport interface PurchaseResult {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n}\n\nexport interface PurchaseError {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n productId?: string;\n}\n\nexport type InAppPurchase = ProductPurchase;\n\nexport interface SubscriptionPurchase extends ProductPurchase {\n autoRenewingAndroid?: boolean;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n}\n\nexport type Purchase = InAppPurchase | SubscriptionPurchase;\n\nexport interface Discount {\n identifier: string;\n type: string;\n numberOfPeriods: string;\n price: string;\n localizedPrice: string;\n paymentMode: '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';\n subscriptionPeriod: string;\n}\n\nexport interface Product extends ProductCommon {\n type: 'inapp' | 'iap';\n}\n\nexport interface Subscription extends ProductCommon {\n type: 'subs' | 'sub';\n\n discounts?: Discount[];\n\n introductoryPrice?: string;\n introductoryPriceAsAmountIOS?: string;\n introductoryPricePaymentModeIOS?:\n | ''\n | 'FREETRIAL'\n | 'PAYASYOUGO'\n | 'PAYUPFRONT';\n introductoryPriceNumberOfPeriodsIOS?: string;\n introductoryPriceSubscriptionPeriodIOS?:\n | 'DAY'\n | 'WEEK'\n | 'MONTH'\n | 'YEAR'\n | '';\n\n subscriptionPeriodNumberIOS?: string;\n subscriptionPeriodUnitIOS?: '' | 'YEAR' | 'MONTH' | 'WEEK' | 'DAY';\n\n introductoryPriceAsAmountAndroid: string;\n introductoryPriceCyclesAndroid?: string;\n introductoryPricePeriodAndroid?: string;\n subscriptionPeriodAndroid?: string;\n freeTrialPeriodAndroid?: string;\n}\n\nexport interface RequestPurchase {\n sku: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n
|
|
1
|
+
{"version":3,"names":["IAPErrorCode","ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid"],"sources":["index.ts"],"sourcesContent":["export type Sku = string;\n\nexport enum IAPErrorCode {\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n}\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string;\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n //Android\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n //Amazon\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n isCanceledAmazon?: boolean;\n}\n\nexport interface PurchaseResult {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n}\n\nexport interface PurchaseError {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n productId?: string;\n}\n\nexport type InAppPurchase = ProductPurchase;\n\nexport interface SubscriptionPurchase extends ProductPurchase {\n autoRenewingAndroid?: boolean;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n}\n\nexport type Purchase = InAppPurchase | SubscriptionPurchase;\n\nexport interface Discount {\n identifier: string;\n type: string;\n numberOfPeriods: string;\n price: string;\n localizedPrice: string;\n paymentMode: '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';\n subscriptionPeriod: string;\n}\n\nexport interface Product extends ProductCommon {\n type: 'inapp' | 'iap';\n}\n\nexport interface Subscription extends ProductCommon {\n type: 'subs' | 'sub';\n\n discounts?: Discount[];\n\n introductoryPrice?: string;\n introductoryPriceAsAmountIOS?: string;\n introductoryPricePaymentModeIOS?:\n | ''\n | 'FREETRIAL'\n | 'PAYASYOUGO'\n | 'PAYUPFRONT';\n introductoryPriceNumberOfPeriodsIOS?: string;\n introductoryPriceSubscriptionPeriodIOS?:\n | 'DAY'\n | 'WEEK'\n | 'MONTH'\n | 'YEAR'\n | '';\n\n subscriptionPeriodNumberIOS?: string;\n subscriptionPeriodUnitIOS?: '' | 'YEAR' | 'MONTH' | 'WEEK' | 'DAY';\n\n introductoryPriceAsAmountAndroid: string;\n introductoryPriceCyclesAndroid?: string;\n introductoryPricePeriodAndroid?: string;\n subscriptionPeriodAndroid?: string;\n freeTrialPeriodAndroid?: string;\n}\n\nexport interface RequestPurchase {\n sku: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n}\n\nexport interface RequestSubscription extends RequestPurchase {\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n}\n"],"mappings":"AAEA,WAAYA,YAAZ;;WAAYA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;GAAAA,Y,KAAAA,Y;;AAmBZ,WAAYC,qBAAZ;;WAAYA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,KAAAA,qB;;AAQZ,WAAYC,oBAAZ;;WAAYA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,KAAAA,oB;;AAMZ,OAAO,MAAMC,gBAAgB,GAAG,sBAAzB;AAEP,WAAYC,oBAAZ;;WAAYA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,KAAAA,oB"}
|
package/lib/typescript/iap.d.ts
CHANGED
|
@@ -4,6 +4,11 @@ import type * as Android from './types/android';
|
|
|
4
4
|
import type * as Apple from './types/apple';
|
|
5
5
|
import type { InAppPurchase, Product, ProductPurchase, PurchaseError, PurchaseResult, RequestPurchase, RequestSubscription, Subscription, SubscriptionPurchase } from './types';
|
|
6
6
|
import { InstallSourceAndroid } from './types';
|
|
7
|
+
export declare class IapError implements PurchaseError {
|
|
8
|
+
code?: string | undefined;
|
|
9
|
+
message?: string | undefined;
|
|
10
|
+
constructor(code?: string | undefined, message?: string | undefined);
|
|
11
|
+
}
|
|
7
12
|
export declare const getInstallSourceAndroid: () => InstallSourceAndroid;
|
|
8
13
|
/**
|
|
9
14
|
* Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.
|
|
@@ -181,7 +186,7 @@ export declare const purchaseErrorListener: (listener: (errorEvent: PurchaseErro
|
|
|
181
186
|
* Add IAP promoted subscription event
|
|
182
187
|
* Only available on iOS
|
|
183
188
|
*/
|
|
184
|
-
export declare const promotedProductListener: (listener: () => void) => EmitterSubscription | null;
|
|
189
|
+
export declare const promotedProductListener: (listener: (productId?: string) => void) => EmitterSubscription | null;
|
|
185
190
|
/**
|
|
186
191
|
* Get the current receipt base64 encoded in IOS.
|
|
187
192
|
* @param {forceRefresh?:boolean}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
declare type Sku = string;
|
|
1
|
+
export declare type Sku = string;
|
|
2
2
|
export declare enum IAPErrorCode {
|
|
3
3
|
E_IAP_NOT_AVAILABLE = "E_IAP_NOT_AVAILABLE",
|
|
4
4
|
E_UNKNOWN = "E_UNKNOWN",
|
|
@@ -122,10 +122,8 @@ export interface RequestPurchase {
|
|
|
122
122
|
applicationUsername?: string;
|
|
123
123
|
obfuscatedAccountIdAndroid?: string;
|
|
124
124
|
obfuscatedProfileIdAndroid?: string;
|
|
125
|
-
selectedOfferIndex?: number;
|
|
126
125
|
}
|
|
127
126
|
export interface RequestSubscription extends RequestPurchase {
|
|
128
127
|
purchaseTokenAndroid?: string;
|
|
129
128
|
prorationModeAndroid?: ProrationModesAndroid;
|
|
130
129
|
}
|
|
131
|
-
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-iap",
|
|
3
|
-
"version": "8.6.
|
|
3
|
+
"version": "8.6.5",
|
|
4
4
|
"description": "React Native In App Purchase Module.",
|
|
5
5
|
"repository": "https://github.com/dooboolab/react-native-iap",
|
|
6
6
|
"author": "dooboolab <support@dooboolab.com> (https://github.com/dooboolab)",
|
package/src/iap.ts
CHANGED
|
@@ -34,6 +34,13 @@ const isIos = Platform.OS === 'ios';
|
|
|
34
34
|
const ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';
|
|
35
35
|
const ANDROID_ITEM_TYPE_IAP = 'inapp';
|
|
36
36
|
|
|
37
|
+
export class IapError implements PurchaseError {
|
|
38
|
+
constructor(public code?: string, public message?: string) {
|
|
39
|
+
this.code = code;
|
|
40
|
+
this.message = message;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
37
44
|
export const getInstallSourceAndroid = (): InstallSourceAndroid => {
|
|
38
45
|
return RNIapModule
|
|
39
46
|
? InstallSourceAndroid.GOOGLE_PLAY
|
|
@@ -664,7 +671,7 @@ export const purchaseErrorListener = (
|
|
|
664
671
|
* Only available on iOS
|
|
665
672
|
*/
|
|
666
673
|
export const promotedProductListener = (
|
|
667
|
-
listener: () => void,
|
|
674
|
+
listener: (productId?: string) => void,
|
|
668
675
|
): EmitterSubscription | null => {
|
|
669
676
|
if (isIos) {
|
|
670
677
|
return new NativeEventEmitter(getIosModule()).addListener(
|
package/src/types/index.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
type Sku = string;
|
|
1
|
+
export type Sku = string;
|
|
2
2
|
|
|
3
3
|
export enum IAPErrorCode {
|
|
4
4
|
E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',
|
|
@@ -154,7 +154,6 @@ export interface RequestPurchase {
|
|
|
154
154
|
applicationUsername?: string;
|
|
155
155
|
obfuscatedAccountIdAndroid?: string;
|
|
156
156
|
obfuscatedProfileIdAndroid?: string;
|
|
157
|
-
selectedOfferIndex?: number;
|
|
158
157
|
}
|
|
159
158
|
|
|
160
159
|
export interface RequestSubscription extends RequestPurchase {
|