react-native-iap 8.6.3 → 8.6.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/commonjs/iap.js +12 -2
- package/lib/commonjs/iap.js.map +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/iap.js +7 -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 -0
- package/lib/typescript/types/index.d.ts +3 -3
- package/package.json +1 -1
- package/src/iap.ts +8 -0
- package/src/types/index.ts +3 -3
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.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 = void 0;
|
|
7
7
|
|
|
8
8
|
var _reactNative = require("react-native");
|
|
9
9
|
|
|
@@ -570,13 +570,23 @@ const promotedProductListener = listener => {
|
|
|
570
570
|
exports.promotedProductListener = promotedProductListener;
|
|
571
571
|
|
|
572
572
|
const getPendingPurchasesIOS = async () => getIosModule().getPendingTransactions();
|
|
573
|
+
/**
|
|
574
|
+
* Get the current receipt base64 encoded in IOS.
|
|
575
|
+
* @param {forceRefresh?:boolean}
|
|
576
|
+
* @returns {Promise<string>}
|
|
577
|
+
*/
|
|
578
|
+
|
|
579
|
+
|
|
580
|
+
exports.getPendingPurchasesIOS = getPendingPurchasesIOS;
|
|
581
|
+
|
|
582
|
+
const getReceiptIOS = async forceRefresh => getIosModule().requestReceipt(forceRefresh ?? false);
|
|
573
583
|
/**
|
|
574
584
|
* Launches a modal to register the redeem offer code in IOS.
|
|
575
585
|
* @returns {Promise<null>}
|
|
576
586
|
*/
|
|
577
587
|
|
|
578
588
|
|
|
579
|
-
exports.
|
|
589
|
+
exports.getReceiptIOS = getReceiptIOS;
|
|
580
590
|
|
|
581
591
|
const presentCodeRedemptionSheetIOS = async () => getIosModule().presentCodeRedemptionSheet();
|
|
582
592
|
|
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","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 * 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,mBAAA,CAAaC,mBAAvB,CAAN;EACD;AACF,CAJD;;AAMA,MAAMC,gBAAgB,GAAG,MAAqD;EAC5EJ,2BAA2B;EAE3B,OAAOb,WAAW,GAAGA,WAAH,GAAiBC,iBAAnC;AACD,CAJD;;AAMA,MAAMiB,uBAAuB,GAAG,MAAY;EAC1C,IAAI,CAACnB,QAAL,EAAe;IACb,MAAM,IAAIe,KAAJ,CAAUC,mBAAA,CAAaC,mBAAvB,CAAN;EACD;AACF,CAJD;;AAMA,MAAMG,YAAY,GAAG,M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OH,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;;;;;AACO,MAAMC,6BAA6B,GAAG,YAC3C9I,YAAY,GAAG+I,0BAAf,EADK"}
|
|
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,mBAAA,CAAaC,mBAAvB,CAAN;EACD;AACF,CAJD;;AAMA,MAAMC,gBAAgB,GAAG,MAAqD;EAC5EJ,2BAA2B;EAE3B,OAAOb,WAAW,GAAGA,WAAH,GAAiBC,iBAAnC;AACD,CAJD;;AAMA,MAAMiB,uBAAuB,GAAG,MAAY;EAC1C,IAAI,CAACnB,QAAL,EAAe;IACb,MAAM,IAAIe,KAAJ,CAAUC,mBAAA,CAAaC,mBAAvB,CAAN;EACD;AACF,CAJD;;AAMA,MAAMG,YAAY,GAAG,MAAuB;EAC1CD,uBAAuB;EAEvB,OAAOnB,QAAP;AACD,CAJD;;AAMA,MAAMqB,eAAe,GAAG,MAGD;EACrB,IAAIjB,SAAJ,EAAe;IACb,OAAOc,gBAAgB,EAAvB;EACD;;EAED,OAAOE,YAAY,EAAnB;AACD,CATD;AAWA;AACA;AACA;AACA;;;AACO,MAAME,cAAc,GAAG,MAC5BD,eAAe,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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 +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
|
|
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 selectedOfferIndex?: number;\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
|
@@ -486,6 +486,13 @@ export const promotedProductListener = listener => {
|
|
|
486
486
|
*/
|
|
487
487
|
|
|
488
488
|
export const getPendingPurchasesIOS = async () => getIosModule().getPendingTransactions();
|
|
489
|
+
/**
|
|
490
|
+
* Get the current receipt base64 encoded in IOS.
|
|
491
|
+
* @param {forceRefresh?:boolean}
|
|
492
|
+
* @returns {Promise<string>}
|
|
493
|
+
*/
|
|
494
|
+
|
|
495
|
+
export const getReceiptIOS = async forceRefresh => getIosModule().requestReceipt(forceRefresh ?? false);
|
|
489
496
|
/**
|
|
490
497
|
* Launches a modal to register the redeem offer code in IOS.
|
|
491
498
|
* @returns {Promise<null>}
|
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","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 * 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,IA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Ac,IAAI5G,KAAJ,CAAUkG,QAAQ,CAACW,UAAnB,CAAd,EAA8C;MAClDC,UAAU,EAAEZ,QAAQ,CAACa;IAD6B,CAA9C,CAAN;EAGD;;EAED,OAAOb,QAAQ,CAACc,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,OAAO,MAAMC,6BAA6B,GAAG,YAC3C1I,YAAY,GAAG2I,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","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,YAA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AClDC,UAAU,EAAEZ,QAAQ,CAACa;IAD6B,CAA9C,CAAN;EAGD;;EAED,OAAOb,QAAQ,CAACc,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 +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
|
|
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 selectedOfferIndex?: number;\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
|
@@ -188,6 +188,12 @@ export declare const promotedProductListener: (listener: () => void) => EmitterS
|
|
|
188
188
|
* @returns {Promise<ProductPurchase[]>}
|
|
189
189
|
*/
|
|
190
190
|
export declare const getPendingPurchasesIOS: () => Promise<ProductPurchase[]>;
|
|
191
|
+
/**
|
|
192
|
+
* Get the current receipt base64 encoded in IOS.
|
|
193
|
+
* @param {forceRefresh?:boolean}
|
|
194
|
+
* @returns {Promise<string>}
|
|
195
|
+
*/
|
|
196
|
+
export declare const getReceiptIOS: (forceRefresh?: boolean) => Promise<string>;
|
|
191
197
|
/**
|
|
192
198
|
* Launches a modal to register the redeem offer code in IOS.
|
|
193
199
|
* @returns {Promise<null>}
|
|
@@ -118,14 +118,14 @@ export interface Subscription extends ProductCommon {
|
|
|
118
118
|
}
|
|
119
119
|
export interface RequestPurchase {
|
|
120
120
|
sku: Sku;
|
|
121
|
-
andDangerouslyFinishTransactionAutomaticallyIOS
|
|
121
|
+
andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;
|
|
122
122
|
applicationUsername?: string;
|
|
123
123
|
obfuscatedAccountIdAndroid?: string;
|
|
124
124
|
obfuscatedProfileIdAndroid?: string;
|
|
125
|
-
selectedOfferIndex
|
|
125
|
+
selectedOfferIndex?: number;
|
|
126
126
|
}
|
|
127
127
|
export interface RequestSubscription extends RequestPurchase {
|
|
128
128
|
purchaseTokenAndroid?: string;
|
|
129
|
-
prorationModeAndroid
|
|
129
|
+
prorationModeAndroid?: ProrationModesAndroid;
|
|
130
130
|
}
|
|
131
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.4",
|
|
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
|
@@ -683,6 +683,14 @@ export const promotedProductListener = (
|
|
|
683
683
|
export const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>
|
|
684
684
|
getIosModule().getPendingTransactions();
|
|
685
685
|
|
|
686
|
+
/**
|
|
687
|
+
* Get the current receipt base64 encoded in IOS.
|
|
688
|
+
* @param {forceRefresh?:boolean}
|
|
689
|
+
* @returns {Promise<string>}
|
|
690
|
+
*/
|
|
691
|
+
export const getReceiptIOS = async (forceRefresh?: boolean): Promise<string> =>
|
|
692
|
+
getIosModule().requestReceipt(forceRefresh ?? false);
|
|
693
|
+
|
|
686
694
|
/**
|
|
687
695
|
* Launches a modal to register the redeem offer code in IOS.
|
|
688
696
|
* @returns {Promise<null>}
|
package/src/types/index.ts
CHANGED
|
@@ -150,14 +150,14 @@ export interface Subscription extends ProductCommon {
|
|
|
150
150
|
|
|
151
151
|
export interface RequestPurchase {
|
|
152
152
|
sku: Sku;
|
|
153
|
-
andDangerouslyFinishTransactionAutomaticallyIOS
|
|
153
|
+
andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;
|
|
154
154
|
applicationUsername?: string;
|
|
155
155
|
obfuscatedAccountIdAndroid?: string;
|
|
156
156
|
obfuscatedProfileIdAndroid?: string;
|
|
157
|
-
selectedOfferIndex
|
|
157
|
+
selectedOfferIndex?: number;
|
|
158
158
|
}
|
|
159
159
|
|
|
160
160
|
export interface RequestSubscription extends RequestPurchase {
|
|
161
161
|
purchaseTokenAndroid?: string;
|
|
162
|
-
prorationModeAndroid
|
|
162
|
+
prorationModeAndroid?: ProrationModesAndroid;
|
|
163
163
|
}
|