react-native-iap 9.0.1 → 9.0.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.
@@ -13,6 +13,7 @@ import java.util.HashSet
13
13
 
14
14
  class RNIapAmazonModule(reactContext: ReactApplicationContext) :
15
15
  ReactContextBaseJavaModule(reactContext) {
16
+ var hasListener = false
16
17
  override fun getName(): String {
17
18
  return TAG
18
19
  }
@@ -21,6 +22,7 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
21
22
  fun initConnection(promise: Promise) {
22
23
  val context = reactApplicationContext
23
24
  PurchasingService.registerListener(context, RNIapAmazonListener(context))
25
+ hasListener = true
24
26
  // Prefetch user and purchases as per Amazon SDK documentation:
25
27
  PurchasingService.getUserData()
26
28
  PurchasingService.getPurchaseUpdates(false)
@@ -132,8 +134,10 @@ class RNIapAmazonModule(reactContext: ReactApplicationContext) :
132
134
  * We should fetch updates on resume
133
135
  */
134
136
  override fun onHostResume() {
135
- PurchasingService.getUserData()
136
- PurchasingService.getPurchaseUpdates(false)
137
+ if (hasListener) {
138
+ PurchasingService.getUserData()
139
+ PurchasingService.getPurchaseUpdates(false)
140
+ }
137
141
  }
138
142
  override fun onHostPause() {}
139
143
  override fun onHostDestroy() {
@@ -250,7 +250,11 @@ const requestPurchase = _ref => {
250
250
  return getIosModule().buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, applicationUsername);
251
251
  },
252
252
  android: async () => {
253
- return getAndroidModule().buyItemByType(ANDROID_ITEM_TYPE_IAP, skus !== null && skus !== void 0 && skus.length ? skus : [sku], null, -1, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, [], isOfferPersonalized ?? false);
253
+ if (isAmazon) {
254
+ return RNIapAmazonModule.buyItemByType(sku);
255
+ } else {
256
+ return getAndroidModule().buyItemByType(ANDROID_ITEM_TYPE_IAP, skus !== null && skus !== void 0 && skus.length ? skus : [sku], null, -1, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, [], isOfferPersonalized ?? false);
257
+ }
254
258
  }
255
259
  }) || Promise.resolve)();
256
260
  };
@@ -1 +1 @@
1
- {"version":3,"names":["RNIapIos","RNIapModule","RNIapAmazonModule","NativeModules","isAndroid","Platform","OS","isAmazon","isIos","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","IapError","constructor","code","message","getInstallSourceAndroid","InstallSourceAndroid","GOOGLE_PLAY","AMAZON","androidNativeModule","setAndroidNativeModule","nativeModule","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","isOfferPersonalized","undefined","console","warn","buyProduct","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","reject","map","so","offerToken","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","consumeProduct","purchaseToken","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PurchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","Linking","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","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 isAmazon = isAndroid && !!RNIapAmazonModule;\nconst isIos = Platform.OS === 'ios';\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport class IapError implements PurchaseError {\n constructor(public code?: string, public message?: string) {\n this.code = code;\n this.message = message;\n }\n}\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getAndroidModule = (): typeof RNIapModule | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return androidNativeModule\n ? androidNativeModule\n : RNIapModule\n ? RNIapModule\n : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error(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 return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<void> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid = (): Promise<\n string[]\n> => getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * 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 * @param {string[]} [skus] Product Ids to purchase. Note that this is only for Android. iOS only uses a single SKU. If not provided, it'll default to using [sku] for backward-compatibility\n * @param {boolean} [isOfferPersonalized] Defaults to false, Only for Android V5\n * @returns {Promise<InAppPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n skus, // Android Billing V5\n isOfferPersonalized = undefined, // Android Billing V5\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 skus?.length ? skus : [sku],\n null,\n -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n [],\n isOfferPersonalized ?? false,\n );\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {SubscriptionOffers[]} [subscriptionOffers] Array of SubscriptionOffers. Every sku must be paired with a corresponding offerToken\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers = undefined, // Android Billing V5\n isOfferPersonalized = undefined, // Android Billing V5\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 if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!subscriptionOffers?.length) {\n Promise.reject(\n 'subscriptionOffers are required for Google Play Subscriptions',\n );\n return;\n }\n return RNIapModule.buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n subscriptionOffers?.map((so) => so.sku),\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers?.map((so) => so.offerToken),\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = (\n sku: string,\n quantity: number,\n): Promise<InAppPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\n\n/**\n * Finish Transaction (both platforms)\n * Abstracts Finish Transaction\n * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.\n * Call this after you have persisted the purchased state to your server or local data in your app.\n * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**\n * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.\n * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = (\n purchase: InAppPurchase | ProductPurchase,\n isConsumable?: boolean,\n developerPayloadAndroid?: string,\n): Promise<string | void> => {\n return (\n Platform.select({\n ios: async () => {\n return getIosModule().finishTransaction(purchase.transactionId);\n },\n android: async () => {\n if (purchase) {\n if (isConsumable) {\n return getAndroidModule().consumeProduct(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else if (\n purchase.userIdAmazon ||\n (!purchase.isAcknowledgedAndroid &&\n purchase.purchaseStateAndroid === PurchaseStateAndroid.PURCHASED)\n ) {\n return getAndroidModule().acknowledgePurchase(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else {\n throw new Error('purchase is not suitable to be purchased');\n }\n } else {\n throw new Error('purchase is not assigned');\n }\n },\n }) || Promise.resolve\n )();\n};\n\n/**\n * Clear Transaction (iOS only)\n * Finish remaining transactions. Related to issue #257 and #801\n * link : https://github.com/dooboolab/react-native-iap/issues/257\n * https://github.com/dooboolab/react-native-iap/issues/801\n * @returns {Promise<void>}\n */\nexport const clearTransactionIOS = (): Promise<void> =>\n getIosModule().clearTransaction();\n\n/**\n * Clear valid Products (iOS only)\n * Remove all products which are validated by Apple server.\n * @returns {void}\n */\nexport const clearProductsIOS = (): Promise<void> =>\n getIosModule().clearProducts();\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = (\n token: string,\n developerPayload?: string,\n): Promise<PurchaseResult | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async (\n sku: string,\n): Promise<void> => {\n checkNativeAndroidAvailable();\n\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\n\n/**\n * Buy the currently selected promoted product (iOS only)\n * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.\n * @returns {Promise<void>}\n */\nexport const buyPromotedProductIOS = (): Promise<void> =>\n getIosModule().buyPromotedProduct();\n\nconst fetchJsonOrThrow = async (\n url: string,\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(receiptBody),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetchJsonOrThrow(\n 'https://buy.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === ReceiptValidationStatus.TEST_RECEIPT) {\n const testResponse = await fetchJsonOrThrow(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = (\n sku: string,\n forUser: string,\n withOffer: Apple.PaymentDiscount,\n): Promise<void> => getIosModule().buyProductWithOffer(sku, forUser, withOffer);\n\n/**\n * Validate receipt for iOS.\n * @param {object} receiptBody the receipt body to send to apple server.\n * @param {boolean} isTest whether this is in test environment which is sandbox.\n * @returns {Promise<Apple.ReceiptValidationResponse | false>}\n */\nexport const validateReceiptIos = async (\n receiptBody: Record<string, unknown>,\n isTest?: boolean,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n const response = await fetchJsonOrThrow(url, receiptBody);\n\n return response;\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} packageName package name of your app.\n * @param {string} productId product id for your in app product.\n * @param {string} productToken token for your purchase.\n * @param {string} accessToken accessToken from googleApis.\n * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAndroid = async (\n packageName: string,\n productId: string,\n productToken: string,\n accessToken: string,\n isSub?: boolean,\n): Promise<Android.ReceiptType> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}?access_token=${accessToken}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including\n * your developer secret in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} developerSecret: from the Amazon developer console.\n * @param {string} userId who purchased the item.\n * @param {string} receiptId long obfuscated string returned when purchasing the item\n * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAmazon = async (\n developerSecret: string,\n userId: string,\n receiptId: string,\n useSandbox: boolean = true,\n): Promise<Amazon.ReceiptType> => {\n const sandBoxUrl = useSandbox ? 'sandbox/' : '';\n const url = `https://appstore-sdk.amazon.com/${sandBoxUrl}version/1.0/verifyReceiptId/developer/${developerSecret}/user/${userId}/receiptId/${receiptId}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Add IAP purchase event\n * @returns {callback(e: InAppPurchase | ProductPurchase)}\n */\nexport const purchaseUpdatedListener = (\n listener: (event: InAppPurchase | SubscriptionPurchase) => void,\n): EmitterSubscription => {\n const emitterSubscription = new NativeEventEmitter(\n getNativeModule(),\n ).addListener('purchase-updated', listener);\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n * @returns {callback(e: PurchaseError)}\n */\nexport const purchaseErrorListener = (\n listener: (errorEvent: PurchaseError) => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getNativeModule()).addListener(\n 'purchase-error',\n listener,\n );\n\n/**\n * Add IAP promoted subscription event\n * Only available on iOS\n */\nexport const promotedProductListener = (\n listener: (productId?: string) => void,\n): EmitterSubscription | null => {\n if (isIos) {\n return new NativeEventEmitter(getIosModule()).addListener(\n 'iap-promoted-product',\n listener,\n );\n }\n return null;\n};\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async (forceRefresh?: boolean): Promise<string> =>\n getIosModule().requestReceipt(forceRefresh ?? false);\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":";;;;;;;AAAA;;AAWA;;AAaA;;AAMA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CC,0BAAnD;AACA,MAAMC,SAAS,GAAGC,qBAAA,CAASC,EAAT,KAAgB,SAAlC;AACA,MAAMC,QAAQ,GAAGH,SAAS,IAAI,CAAC,CAACF,iBAAhC;AACA,MAAMM,KAAK,GAAGH,qBAAA,CAASC,EAAT,KAAgB,KAA9B;AACA,MAAMG,8BAA8B,GAAG,MAAvC;AACA,MAAMC,qBAAqB,GAAG,OAA9B;;AAEO,MAAMC,QAAN,CAAwC;EAC7CC,WAAW,CAAQC,IAAR,EAA8BC,OAA9B,EAAgD;IAAA,KAAxCD,IAAwC,GAAxCA,IAAwC;IAAA,KAAlBC,OAAkB,GAAlBA,OAAkB;IACzD,KAAKD,IAAL,GAAYA,IAAZ;IACA,KAAKC,OAAL,GAAeA,OAAf;EACD;;AAJ4C;;;;AAOxC,MAAMC,uBAAuB,GAAG,MAA4B;EACjE,OAAOd,WAAW,GACde,2BAAA,CAAqBC,WADP,GAEdD,2BAAA,CAAqBE,MAFzB;AAGD,CAJM;;;AAMP,IAAIC,mBAAmB,GAAGlB,WAA1B;;AAEO,MA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SAAJ,EAAe;IACbsB,gBAAgB,GAAGmJ,cAAnB;EACD;;EAED,OAAOH,mBAAP;AACD,CAZM;AAcP;AACA;AACA;AACA;;;;;AACO,MAAMI,qBAAqB,GAChCL,QADmC,IAGnC,IAAIE,+BAAJ,CAAuB9I,eAAe,EAAtC,EAA0C+I,WAA1C,CACE,gBADF,EAEEH,QAFF,CAHK;AAQP;AACA;AACA;AACA;;;;;AACO,MAAMM,uBAAuB,GAClCN,QADqC,IAEN;EAC/B,IAAIjK,KAAJ,EAAW;IACT,OAAO,IAAImK,+BAAJ,CAAuB/I,YAAY,EAAnC,EAAuCgJ,WAAvC,CACL,sBADK,EAELH,QAFK,CAAP;EAID;;EACD,OAAO,IAAP;AACD,CAVM;AAYP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMO,sBAAsB,GAAG,YACpCpJ,YAAY,GAAGqJ,sBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,aAAa,GAAG,MAAOC,YAAP,IAC3BvJ,YAAY,GAAGwJ,cAAf,CAA8BD,YAAY,IAAI,KAA9C,CADK;AAGP;AACA;AACA;AACA;;;;;AACO,MAAME,6BAA6B,GAAG,YAC3CzJ,YAAY,GAAG0J,0BAAf,EADK"}
1
+ {"version":3,"names":["RNIapIos","RNIapModule","RNIapAmazonModule","NativeModules","isAndroid","Platform","OS","isAmazon","isIos","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","IapError","constructor","code","message","getInstallSourceAndroid","InstallSourceAndroid","GOOGLE_PLAY","AMAZON","androidNativeModule","setAndroidNativeModule","nativeModule","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","isOfferPersonalized","undefined","console","warn","buyProduct","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","reject","map","so","offerToken","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","consumeProduct","purchaseToken","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PurchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","Linking","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","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 isAmazon = isAndroid && !!RNIapAmazonModule;\nconst isIos = Platform.OS === 'ios';\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport class IapError implements PurchaseError {\n constructor(public code?: string, public message?: string) {\n this.code = code;\n this.message = message;\n }\n}\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getAndroidModule = (): typeof RNIapModule | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return androidNativeModule\n ? androidNativeModule\n : RNIapModule\n ? RNIapModule\n : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error(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 return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<void> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid = (): Promise<\n string[]\n> => getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * 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 * @param {string[]} [skus] Product Ids to purchase. Note that this is only for Android. iOS only uses a single SKU. If not provided, it'll default to using [sku] for backward-compatibility\n * @param {boolean} [isOfferPersonalized] Defaults to false, Only for Android V5\n * @returns {Promise<InAppPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n skus, // Android Billing V5\n isOfferPersonalized = undefined, // Android Billing V5\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 if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n skus?.length ? skus : [sku],\n null,\n -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n [],\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {SubscriptionOffers[]} [subscriptionOffers] Array of SubscriptionOffers. Every sku must be paired with a corresponding offerToken\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers = undefined, // Android Billing V5\n isOfferPersonalized = undefined, // Android Billing V5\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 if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!subscriptionOffers?.length) {\n Promise.reject(\n 'subscriptionOffers are required for Google Play Subscriptions',\n );\n return;\n }\n return RNIapModule.buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n subscriptionOffers?.map((so) => so.sku),\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers?.map((so) => so.offerToken),\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = (\n sku: string,\n quantity: number,\n): Promise<InAppPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\n\n/**\n * Finish Transaction (both platforms)\n * Abstracts Finish Transaction\n * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.\n * Call this after you have persisted the purchased state to your server or local data in your app.\n * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**\n * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.\n * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = (\n purchase: InAppPurchase | ProductPurchase,\n isConsumable?: boolean,\n developerPayloadAndroid?: string,\n): Promise<string | void> => {\n return (\n Platform.select({\n ios: async () => {\n return getIosModule().finishTransaction(purchase.transactionId);\n },\n android: async () => {\n if (purchase) {\n if (isConsumable) {\n return getAndroidModule().consumeProduct(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else if (\n purchase.userIdAmazon ||\n (!purchase.isAcknowledgedAndroid &&\n purchase.purchaseStateAndroid === PurchaseStateAndroid.PURCHASED)\n ) {\n return getAndroidModule().acknowledgePurchase(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else {\n throw new Error('purchase is not suitable to be purchased');\n }\n } else {\n throw new Error('purchase is not assigned');\n }\n },\n }) || Promise.resolve\n )();\n};\n\n/**\n * Clear Transaction (iOS only)\n * Finish remaining transactions. Related to issue #257 and #801\n * link : https://github.com/dooboolab/react-native-iap/issues/257\n * https://github.com/dooboolab/react-native-iap/issues/801\n * @returns {Promise<void>}\n */\nexport const clearTransactionIOS = (): Promise<void> =>\n getIosModule().clearTransaction();\n\n/**\n * Clear valid Products (iOS only)\n * Remove all products which are validated by Apple server.\n * @returns {void}\n */\nexport const clearProductsIOS = (): Promise<void> =>\n getIosModule().clearProducts();\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = (\n token: string,\n developerPayload?: string,\n): Promise<PurchaseResult | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async (\n sku: string,\n): Promise<void> => {\n checkNativeAndroidAvailable();\n\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\n\n/**\n * Buy the currently selected promoted product (iOS only)\n * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.\n * @returns {Promise<void>}\n */\nexport const buyPromotedProductIOS = (): Promise<void> =>\n getIosModule().buyPromotedProduct();\n\nconst fetchJsonOrThrow = async (\n url: string,\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(receiptBody),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetchJsonOrThrow(\n 'https://buy.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === ReceiptValidationStatus.TEST_RECEIPT) {\n const testResponse = await fetchJsonOrThrow(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = (\n sku: string,\n forUser: string,\n withOffer: Apple.PaymentDiscount,\n): Promise<void> => getIosModule().buyProductWithOffer(sku, forUser, withOffer);\n\n/**\n * Validate receipt for iOS.\n * @param {object} receiptBody the receipt body to send to apple server.\n * @param {boolean} isTest whether this is in test environment which is sandbox.\n * @returns {Promise<Apple.ReceiptValidationResponse | false>}\n */\nexport const validateReceiptIos = async (\n receiptBody: Record<string, unknown>,\n isTest?: boolean,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n const response = await fetchJsonOrThrow(url, receiptBody);\n\n return response;\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} packageName package name of your app.\n * @param {string} productId product id for your in app product.\n * @param {string} productToken token for your purchase.\n * @param {string} accessToken accessToken from googleApis.\n * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAndroid = async (\n packageName: string,\n productId: string,\n productToken: string,\n accessToken: string,\n isSub?: boolean,\n): Promise<Android.ReceiptType> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}?access_token=${accessToken}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including\n * your developer secret in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} developerSecret: from the Amazon developer console.\n * @param {string} userId who purchased the item.\n * @param {string} receiptId long obfuscated string returned when purchasing the item\n * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAmazon = async (\n developerSecret: string,\n userId: string,\n receiptId: string,\n useSandbox: boolean = true,\n): Promise<Amazon.ReceiptType> => {\n const sandBoxUrl = useSandbox ? 'sandbox/' : '';\n const url = `https://appstore-sdk.amazon.com/${sandBoxUrl}version/1.0/verifyReceiptId/developer/${developerSecret}/user/${userId}/receiptId/${receiptId}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Add IAP purchase event\n * @returns {callback(e: InAppPurchase | ProductPurchase)}\n */\nexport const purchaseUpdatedListener = (\n listener: (event: InAppPurchase | SubscriptionPurchase) => void,\n): EmitterSubscription => {\n const emitterSubscription = new NativeEventEmitter(\n getNativeModule(),\n ).addListener('purchase-updated', listener);\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n * @returns {callback(e: PurchaseError)}\n */\nexport const purchaseErrorListener = (\n listener: (errorEvent: PurchaseError) => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getNativeModule()).addListener(\n 'purchase-error',\n listener,\n );\n\n/**\n * Add IAP promoted subscription event\n * Only available on iOS\n */\nexport const promotedProductListener = (\n listener: (productId?: string) => void,\n): EmitterSubscription | null => {\n if (isIos) {\n return new NativeEventEmitter(getIosModule()).addListener(\n 'iap-promoted-product',\n listener,\n );\n }\n return null;\n};\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async (forceRefresh?: boolean): Promise<string> =>\n getIosModule().requestReceipt(forceRefresh ?? false);\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":";;;;;;;AAAA;;A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AvC,CACL,sBADK,EAELH,QAFK,CAAP;EAID;;EACD,OAAO,IAAP;AACD,CAVM;AAYP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMO,sBAAsB,GAAG,YACpCpJ,YAAY,GAAGqJ,sBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,aAAa,GAAG,MAAOC,YAAP,IAC3BvJ,YAAY,GAAGwJ,cAAf,CAA8BD,YAAY,IAAI,KAA9C,CADK;AAGP;AACA;AACA;AACA;;;;;AACO,MAAME,6BAA6B,GAAG,YAC3CzJ,YAAY,GAAG0J,0BAAf,EADK"}
@@ -34,6 +34,7 @@ exports.ProrationModesAndroid = ProrationModesAndroid;
34
34
  ProrationModesAndroid[ProrationModesAndroid["IMMEDIATE_AND_CHARGE_PRORATED_PRICE"] = 2] = "IMMEDIATE_AND_CHARGE_PRORATED_PRICE";
35
35
  ProrationModesAndroid[ProrationModesAndroid["IMMEDIATE_WITHOUT_PRORATION"] = 3] = "IMMEDIATE_WITHOUT_PRORATION";
36
36
  ProrationModesAndroid[ProrationModesAndroid["DEFERRED"] = 4] = "DEFERRED";
37
+ ProrationModesAndroid[ProrationModesAndroid["IMMEDIATE_AND_CHARGE_FULL_PRICE"] = 5] = "IMMEDIATE_AND_CHARGE_FULL_PRICE";
37
38
  ProrationModesAndroid[ProrationModesAndroid["UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY"] = 0] = "UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY";
38
39
  })(ProrationModesAndroid || (exports.ProrationModesAndroid = ProrationModesAndroid = {}));
39
40
 
@@ -1 +1 @@
1
- {"version":3,"names":["IAPErrorCode","ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid"],"sources":["index.ts"],"sourcesContent":["export type Sku = string;\n\nexport enum IAPErrorCode {\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n}\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string;\n productIds?: 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 productIds?: string[];\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 // Android V5\n oneTimePurchaseOfferDetails?: {\n priceCurrencyCode: string;\n formattedPrice: string;\n priceAmountMicros: string;\n };\n}\n\n// Android V5\nexport interface SubscriptionAndroid extends ProductCommon {\n type: 'subs';\n\n productType?: string;\n name?: string;\n subscriptionOfferDetails?: {\n offerToken: string;\n pricingPhases: {\n pricingPhaseList: {\n formattedPrice: string;\n priceCurrencyCode: string;\n /**\n * P1W, P1M, P1Y\n */\n billingPeriod: string;\n billingCycleCount: number;\n priceAmountMicros: string;\n recurrenceMode: number;\n }[];\n };\n }[];\n}\n\nexport interface SubscriptionIOS extends ProductCommon {\n type: 'subs';\n\n discounts?: Discount[];\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\nexport type Subscription = SubscriptionAndroid & SubscriptionIOS;\n\nexport interface RequestPurchaseBaseAndroid {\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n isOfferPersonalized?: boolean; // For AndroidBilling V5 https://developer.android.com/google/play/billing/integrate#personalized-price\n}\n\nexport interface RequestPurchaseAndroid extends RequestPurchaseBaseAndroid {\n skus?: Sku[];\n}\n\nexport interface RequestPurchaseIOS {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n}\n\nexport type RequestPurchase = RequestPurchaseAndroid & RequestPurchaseIOS;\n\n/**\n * In order to purchase a new subscription, every sku must have a selected offerToken\n * @see SubscriptionAndroid.subscriptionOfferDetails.offerToken\n */\nexport interface SubscriptionOffer {\n sku: Sku;\n offerToken: string;\n}\n\nexport interface RequestSubscriptionAndroid extends RequestPurchaseBaseAndroid {\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n subscriptionOffers?: SubscriptionOffer[]; // For AndroidBilling V5\n}\n\nexport type RequestSubscriptionIOS = RequestPurchaseIOS;\n\nexport type RequestSubscription = RequestSubscriptionAndroid &\n RequestSubscriptionIOS;\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"}
1
+ {"version":3,"names":["IAPErrorCode","ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid"],"sources":["index.ts"],"sourcesContent":["export type Sku = string;\n\nexport enum IAPErrorCode {\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n}\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n IMMEDIATE_AND_CHARGE_FULL_PRICE = 5,\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 productIds?: 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 productIds?: string[];\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 // Android V5\n oneTimePurchaseOfferDetails?: {\n priceCurrencyCode: string;\n formattedPrice: string;\n priceAmountMicros: string;\n };\n}\n\n// Android V5\nexport interface SubscriptionAndroid extends ProductCommon {\n type: 'subs';\n\n productType?: string;\n name?: string;\n subscriptionOfferDetails?: {\n offerToken: string;\n pricingPhases: {\n pricingPhaseList: {\n formattedPrice: string;\n priceCurrencyCode: string;\n /**\n * P1W, P1M, P1Y\n */\n billingPeriod: string;\n billingCycleCount: number;\n priceAmountMicros: string;\n recurrenceMode: number;\n }[];\n };\n }[];\n}\n\nexport interface SubscriptionIOS extends ProductCommon {\n type: 'subs';\n\n discounts?: Discount[];\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\nexport type Subscription = SubscriptionAndroid & SubscriptionIOS;\n\nexport interface RequestPurchaseBaseAndroid {\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n isOfferPersonalized?: boolean; // For AndroidBilling V5 https://developer.android.com/google/play/billing/integrate#personalized-price\n}\n\nexport interface RequestPurchaseAndroid extends RequestPurchaseBaseAndroid {\n skus?: Sku[];\n}\n\nexport interface RequestPurchaseIOS {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n}\n\nexport type RequestPurchase = RequestPurchaseAndroid & RequestPurchaseIOS;\n\n/**\n * In order to purchase a new subscription, every sku must have a selected offerToken\n * @see SubscriptionAndroid.subscriptionOfferDetails.offerToken\n */\nexport interface SubscriptionOffer {\n sku: Sku;\n offerToken: string;\n}\n\nexport interface RequestSubscriptionAndroid extends RequestPurchaseBaseAndroid {\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n subscriptionOffers?: SubscriptionOffer[]; // For AndroidBilling V5\n}\n\nexport type RequestSubscriptionIOS = RequestPurchaseIOS;\n\nexport type RequestSubscription = RequestSubscriptionAndroid &\n RequestSubscriptionIOS;\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;EAAAA,qB,CAAAA,qB;GAAAA,qB,qCAAAA,qB;;IASAC,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
@@ -210,7 +210,11 @@ export const requestPurchase = _ref => {
210
210
  return getIosModule().buyProduct(sku, andDangerouslyFinishTransactionAutomaticallyIOS, applicationUsername);
211
211
  },
212
212
  android: async () => {
213
- return getAndroidModule().buyItemByType(ANDROID_ITEM_TYPE_IAP, skus !== null && skus !== void 0 && skus.length ? skus : [sku], null, -1, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, [], isOfferPersonalized ?? false);
213
+ if (isAmazon) {
214
+ return RNIapAmazonModule.buyItemByType(sku);
215
+ } else {
216
+ return getAndroidModule().buyItemByType(ANDROID_ITEM_TYPE_IAP, skus !== null && skus !== void 0 && skus.length ? skus : [sku], null, -1, obfuscatedAccountIdAndroid, obfuscatedProfileIdAndroid, [], isOfferPersonalized ?? false);
217
+ }
214
218
  }
215
219
  }) || Promise.resolve)();
216
220
  };
@@ -1 +1 @@
1
- {"version":3,"names":["Linking","NativeEventEmitter","NativeModules","Platform","ReceiptValidationStatus","IAPErrorCode","InstallSourceAndroid","PurchaseStateAndroid","RNIapIos","RNIapModule","RNIapAmazonModule","isAndroid","OS","isAmazon","isIos","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","IapError","constructor","code","message","getInstallSourceAndroid","GOOGLE_PLAY","AMAZON","androidNativeModule","setAndroidNativeModule","nativeModule","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","isOfferPersonalized","undefined","console","warn","buyProduct","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","reject","map","so","offerToken","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 isAmazon = isAndroid && !!RNIapAmazonModule;\nconst isIos = Platform.OS === 'ios';\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport class IapError implements PurchaseError {\n constructor(public code?: string, public message?: string) {\n this.code = code;\n this.message = message;\n }\n}\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getAndroidModule = (): typeof RNIapModule | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return androidNativeModule\n ? androidNativeModule\n : RNIapModule\n ? RNIapModule\n : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error(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 return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<void> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid = (): Promise<\n string[]\n> => getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * 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 * @param {string[]} [skus] Product Ids to purchase. Note that this is only for Android. iOS only uses a single SKU. If not provided, it'll default to using [sku] for backward-compatibility\n * @param {boolean} [isOfferPersonalized] Defaults to false, Only for Android V5\n * @returns {Promise<InAppPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n skus, // Android Billing V5\n isOfferPersonalized = undefined, // Android Billing V5\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 skus?.length ? skus : [sku],\n null,\n -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n [],\n isOfferPersonalized ?? false,\n );\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {SubscriptionOffers[]} [subscriptionOffers] Array of SubscriptionOffers. Every sku must be paired with a corresponding offerToken\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers = undefined, // Android Billing V5\n isOfferPersonalized = undefined, // Android Billing V5\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 if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!subscriptionOffers?.length) {\n Promise.reject(\n 'subscriptionOffers are required for Google Play Subscriptions',\n );\n return;\n }\n return RNIapModule.buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n subscriptionOffers?.map((so) => so.sku),\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers?.map((so) => so.offerToken),\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = (\n sku: string,\n quantity: number,\n): Promise<InAppPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\n\n/**\n * Finish Transaction (both platforms)\n * Abstracts Finish Transaction\n * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.\n * Call this after you have persisted the purchased state to your server or local data in your app.\n * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**\n * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.\n * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = (\n purchase: InAppPurchase | ProductPurchase,\n isConsumable?: boolean,\n developerPayloadAndroid?: string,\n): Promise<string | void> => {\n return (\n Platform.select({\n ios: async () => {\n return getIosModule().finishTransaction(purchase.transactionId);\n },\n android: async () => {\n if (purchase) {\n if (isConsumable) {\n return getAndroidModule().consumeProduct(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else if (\n purchase.userIdAmazon ||\n (!purchase.isAcknowledgedAndroid &&\n purchase.purchaseStateAndroid === PurchaseStateAndroid.PURCHASED)\n ) {\n return getAndroidModule().acknowledgePurchase(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else {\n throw new Error('purchase is not suitable to be purchased');\n }\n } else {\n throw new Error('purchase is not assigned');\n }\n },\n }) || Promise.resolve\n )();\n};\n\n/**\n * Clear Transaction (iOS only)\n * Finish remaining transactions. Related to issue #257 and #801\n * link : https://github.com/dooboolab/react-native-iap/issues/257\n * https://github.com/dooboolab/react-native-iap/issues/801\n * @returns {Promise<void>}\n */\nexport const clearTransactionIOS = (): Promise<void> =>\n getIosModule().clearTransaction();\n\n/**\n * Clear valid Products (iOS only)\n * Remove all products which are validated by Apple server.\n * @returns {void}\n */\nexport const clearProductsIOS = (): Promise<void> =>\n getIosModule().clearProducts();\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = (\n token: string,\n developerPayload?: string,\n): Promise<PurchaseResult | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async (\n sku: string,\n): Promise<void> => {\n checkNativeAndroidAvailable();\n\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\n\n/**\n * Buy the currently selected promoted product (iOS only)\n * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.\n * @returns {Promise<void>}\n */\nexport const buyPromotedProductIOS = (): Promise<void> =>\n getIosModule().buyPromotedProduct();\n\nconst fetchJsonOrThrow = async (\n url: string,\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(receiptBody),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetchJsonOrThrow(\n 'https://buy.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === ReceiptValidationStatus.TEST_RECEIPT) {\n const testResponse = await fetchJsonOrThrow(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = (\n sku: string,\n forUser: string,\n withOffer: Apple.PaymentDiscount,\n): Promise<void> => getIosModule().buyProductWithOffer(sku, forUser, withOffer);\n\n/**\n * Validate receipt for iOS.\n * @param {object} receiptBody the receipt body to send to apple server.\n * @param {boolean} isTest whether this is in test environment which is sandbox.\n * @returns {Promise<Apple.ReceiptValidationResponse | false>}\n */\nexport const validateReceiptIos = async (\n receiptBody: Record<string, unknown>,\n isTest?: boolean,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n const response = await fetchJsonOrThrow(url, receiptBody);\n\n return response;\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} packageName package name of your app.\n * @param {string} productId product id for your in app product.\n * @param {string} productToken token for your purchase.\n * @param {string} accessToken accessToken from googleApis.\n * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAndroid = async (\n packageName: string,\n productId: string,\n productToken: string,\n accessToken: string,\n isSub?: boolean,\n): Promise<Android.ReceiptType> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}?access_token=${accessToken}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including\n * your developer secret in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} developerSecret: from the Amazon developer console.\n * @param {string} userId who purchased the item.\n * @param {string} receiptId long obfuscated string returned when purchasing the item\n * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAmazon = async (\n developerSecret: string,\n userId: string,\n receiptId: string,\n useSandbox: boolean = true,\n): Promise<Amazon.ReceiptType> => {\n const sandBoxUrl = useSandbox ? 'sandbox/' : '';\n const url = `https://appstore-sdk.amazon.com/${sandBoxUrl}version/1.0/verifyReceiptId/developer/${developerSecret}/user/${userId}/receiptId/${receiptId}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Add IAP purchase event\n * @returns {callback(e: InAppPurchase | ProductPurchase)}\n */\nexport const purchaseUpdatedListener = (\n listener: (event: InAppPurchase | SubscriptionPurchase) => void,\n): EmitterSubscription => {\n const emitterSubscription = new NativeEventEmitter(\n getNativeModule(),\n ).addListener('purchase-updated', listener);\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n * @returns {callback(e: PurchaseError)}\n */\nexport const purchaseErrorListener = (\n listener: (errorEvent: PurchaseError) => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getNativeModule()).addListener(\n 'purchase-error',\n listener,\n );\n\n/**\n * Add IAP promoted subscription event\n * Only available on iOS\n */\nexport const promotedProductListener = (\n listener: (productId?: string) => void,\n): EmitterSubscription | null => {\n if (isIos) {\n return new NativeEventEmitter(getIosModule()).addListener(\n 'iap-promoted-product',\n listener,\n );\n }\n return null;\n};\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async (forceRefresh?: boolean): Promise<string> =>\n getIosModule().requestReceipt(forceRefresh ?? false);\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":"AAAA,SAEEA,OAFF,EAGEC,kBAHF,EAIEC,aAJF,EAKEC,QALF,QAMO,cANP;AAWA,SAAQC,uBAAR,QAAsC,eAAtC;AAaA,SACEC,YADF,EAEEC,oBAFF,EAGEC,oBAHF,QAIO,SAJP;AAMA,MAAM;EAACC,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CR,aAAnD;AACA,MAAMS,SAAS,GAAGR,QAAQ,CAACS,EA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ADK;AAGP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG,MAAOC,YAAP,IAC3BnJ,YAAY,GAAGoJ,cAAf,CAA8BD,YAAY,IAAI,KAA9C,CADK;AAGP;AACA;AACA;AACA;;AACA,OAAO,MAAME,6BAA6B,GAAG,YAC3CrJ,YAAY,GAAGsJ,0BAAf,EADK"}
1
+ {"version":3,"names":["Linking","NativeEventEmitter","NativeModules","Platform","ReceiptValidationStatus","IAPErrorCode","InstallSourceAndroid","PurchaseStateAndroid","RNIapIos","RNIapModule","RNIapAmazonModule","isAndroid","OS","isAmazon","isIos","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","IapError","constructor","code","message","getInstallSourceAndroid","GOOGLE_PLAY","AMAZON","androidNativeModule","setAndroidNativeModule","nativeModule","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","isOfferPersonalized","undefined","console","warn","buyProduct","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","reject","map","so","offerToken","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 isAmazon = isAndroid && !!RNIapAmazonModule;\nconst isIos = Platform.OS === 'ios';\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport class IapError implements PurchaseError {\n constructor(public code?: string, public message?: string) {\n this.code = code;\n this.message = message;\n }\n}\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getAndroidModule = (): typeof RNIapModule | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return androidNativeModule\n ? androidNativeModule\n : RNIapModule\n ? RNIapModule\n : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error(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 return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<void> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid = (): Promise<\n string[]\n> => getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * 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 * @param {string[]} [skus] Product Ids to purchase. Note that this is only for Android. iOS only uses a single SKU. If not provided, it'll default to using [sku] for backward-compatibility\n * @param {boolean} [isOfferPersonalized] Defaults to false, Only for Android V5\n * @returns {Promise<InAppPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n skus, // Android Billing V5\n isOfferPersonalized = undefined, // Android Billing V5\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 if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n skus?.length ? skus : [sku],\n null,\n -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n [],\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @param {SubscriptionOffers[]} [subscriptionOffers] Array of SubscriptionOffers. Every sku must be paired with a corresponding offerToken\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers = undefined, // Android Billing V5\n isOfferPersonalized = undefined, // Android Billing V5\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 if (isAmazon) {\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!subscriptionOffers?.length) {\n Promise.reject(\n 'subscriptionOffers are required for Google Play Subscriptions',\n );\n return;\n }\n return RNIapModule.buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n subscriptionOffers?.map((so) => so.sku),\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers?.map((so) => so.offerToken),\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = (\n sku: string,\n quantity: number,\n): Promise<InAppPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\n\n/**\n * Finish Transaction (both platforms)\n * Abstracts Finish Transaction\n * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.\n * Call this after you have persisted the purchased state to your server or local data in your app.\n * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**\n * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.\n * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = (\n purchase: InAppPurchase | ProductPurchase,\n isConsumable?: boolean,\n developerPayloadAndroid?: string,\n): Promise<string | void> => {\n return (\n Platform.select({\n ios: async () => {\n return getIosModule().finishTransaction(purchase.transactionId);\n },\n android: async () => {\n if (purchase) {\n if (isConsumable) {\n return getAndroidModule().consumeProduct(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else if (\n purchase.userIdAmazon ||\n (!purchase.isAcknowledgedAndroid &&\n purchase.purchaseStateAndroid === PurchaseStateAndroid.PURCHASED)\n ) {\n return getAndroidModule().acknowledgePurchase(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else {\n throw new Error('purchase is not suitable to be purchased');\n }\n } else {\n throw new Error('purchase is not assigned');\n }\n },\n }) || Promise.resolve\n )();\n};\n\n/**\n * Clear Transaction (iOS only)\n * Finish remaining transactions. Related to issue #257 and #801\n * link : https://github.com/dooboolab/react-native-iap/issues/257\n * https://github.com/dooboolab/react-native-iap/issues/801\n * @returns {Promise<void>}\n */\nexport const clearTransactionIOS = (): Promise<void> =>\n getIosModule().clearTransaction();\n\n/**\n * Clear valid Products (iOS only)\n * Remove all products which are validated by Apple server.\n * @returns {void}\n */\nexport const clearProductsIOS = (): Promise<void> =>\n getIosModule().clearProducts();\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = (\n token: string,\n developerPayload?: string,\n): Promise<PurchaseResult | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async (\n sku: string,\n): Promise<void> => {\n checkNativeAndroidAvailable();\n\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\n\n/**\n * Buy the currently selected promoted product (iOS only)\n * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.\n * @returns {Promise<void>}\n */\nexport const buyPromotedProductIOS = (): Promise<void> =>\n getIosModule().buyPromotedProduct();\n\nconst fetchJsonOrThrow = async (\n url: string,\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(receiptBody),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetchJsonOrThrow(\n 'https://buy.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === ReceiptValidationStatus.TEST_RECEIPT) {\n const testResponse = await fetchJsonOrThrow(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = (\n sku: string,\n forUser: string,\n withOffer: Apple.PaymentDiscount,\n): Promise<void> => getIosModule().buyProductWithOffer(sku, forUser, withOffer);\n\n/**\n * Validate receipt for iOS.\n * @param {object} receiptBody the receipt body to send to apple server.\n * @param {boolean} isTest whether this is in test environment which is sandbox.\n * @returns {Promise<Apple.ReceiptValidationResponse | false>}\n */\nexport const validateReceiptIos = async (\n receiptBody: Record<string, unknown>,\n isTest?: boolean,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n const response = await fetchJsonOrThrow(url, receiptBody);\n\n return response;\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} packageName package name of your app.\n * @param {string} productId product id for your in app product.\n * @param {string} productToken token for your purchase.\n * @param {string} accessToken accessToken from googleApis.\n * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAndroid = async (\n packageName: string,\n productId: string,\n productToken: string,\n accessToken: string,\n isSub?: boolean,\n): Promise<Android.ReceiptType> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}?access_token=${accessToken}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including\n * your developer secret in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} developerSecret: from the Amazon developer console.\n * @param {string} userId who purchased the item.\n * @param {string} receiptId long obfuscated string returned when purchasing the item\n * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAmazon = async (\n developerSecret: string,\n userId: string,\n receiptId: string,\n useSandbox: boolean = true,\n): Promise<Amazon.ReceiptType> => {\n const sandBoxUrl = useSandbox ? 'sandbox/' : '';\n const url = `https://appstore-sdk.amazon.com/${sandBoxUrl}version/1.0/verifyReceiptId/developer/${developerSecret}/user/${userId}/receiptId/${receiptId}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Add IAP purchase event\n * @returns {callback(e: InAppPurchase | ProductPurchase)}\n */\nexport const purchaseUpdatedListener = (\n listener: (event: InAppPurchase | SubscriptionPurchase) => void,\n): EmitterSubscription => {\n const emitterSubscription = new NativeEventEmitter(\n getNativeModule(),\n ).addListener('purchase-updated', listener);\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n * @returns {callback(e: PurchaseError)}\n */\nexport const purchaseErrorListener = (\n listener: (errorEvent: PurchaseError) => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getNativeModule()).addListener(\n 'purchase-error',\n listener,\n );\n\n/**\n * Add IAP promoted subscription event\n * Only available on iOS\n */\nexport const promotedProductListener = (\n listener: (productId?: string) => void,\n): EmitterSubscription | null => {\n if (isIos) {\n return new NativeEventEmitter(getIosModule()).addListener(\n 'iap-promoted-product',\n listener,\n );\n }\n return null;\n};\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async (forceRefresh?: boolean): Promise<string> =>\n getIosModule().requestReceipt(forceRefresh ?? false);\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":"AAAA,SAEEA,OAFF,EAGEC,kBAHF,EAIEC,aAJF,EAKEC,QALF,QAMO,cANP;AAWA,SAAQC,uBAAR,QAAsC,eAAtC;AAaA,SACEC,YADF,EAEEC,oBAFF,EAGEC,oBAHF,QAIO,SAJP;AAMA,MAAM;EAACC,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CR,aAAnD;AACA,MAAMS,SAAS,GAAGR,QAAQ,CAACS,EAAT,KAAgB,SAAlC;AACA,MAAMC,QAAQ,GAAGF,SAAS,IAAI,CAAC,CAACD,iBAAhC;AACA,MAAMI,KAAK,GAAGX,QAAQ,CAACS,EAAT,KAAgB,KAA9B;AACA,MAAMG,8BAA8B,GAAG,MAAvC;AACA,MAAMC,qBAAqB,GAAG,OAA9B;AAEA,OAAO,MAAMC,QAAN,CAAwC;EAC7CC,WAAW,CAAQC,IAAR,EAA8BC,OAA9B,EAAgD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BAA6B,GAAG,YAC3CrJ,YAAY,GAAGsJ,0BAAf,EADK"}
@@ -26,6 +26,7 @@ export let ProrationModesAndroid;
26
26
  ProrationModesAndroid[ProrationModesAndroid["IMMEDIATE_AND_CHARGE_PRORATED_PRICE"] = 2] = "IMMEDIATE_AND_CHARGE_PRORATED_PRICE";
27
27
  ProrationModesAndroid[ProrationModesAndroid["IMMEDIATE_WITHOUT_PRORATION"] = 3] = "IMMEDIATE_WITHOUT_PRORATION";
28
28
  ProrationModesAndroid[ProrationModesAndroid["DEFERRED"] = 4] = "DEFERRED";
29
+ ProrationModesAndroid[ProrationModesAndroid["IMMEDIATE_AND_CHARGE_FULL_PRICE"] = 5] = "IMMEDIATE_AND_CHARGE_FULL_PRICE";
29
30
  ProrationModesAndroid[ProrationModesAndroid["UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY"] = 0] = "UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY";
30
31
  })(ProrationModesAndroid || (ProrationModesAndroid = {}));
31
32
 
@@ -1 +1 @@
1
- {"version":3,"names":["IAPErrorCode","ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid"],"sources":["index.ts"],"sourcesContent":["export type Sku = string;\n\nexport enum IAPErrorCode {\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n}\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string;\n productIds?: 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 productIds?: string[];\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 // Android V5\n oneTimePurchaseOfferDetails?: {\n priceCurrencyCode: string;\n formattedPrice: string;\n priceAmountMicros: string;\n };\n}\n\n// Android V5\nexport interface SubscriptionAndroid extends ProductCommon {\n type: 'subs';\n\n productType?: string;\n name?: string;\n subscriptionOfferDetails?: {\n offerToken: string;\n pricingPhases: {\n pricingPhaseList: {\n formattedPrice: string;\n priceCurrencyCode: string;\n /**\n * P1W, P1M, P1Y\n */\n billingPeriod: string;\n billingCycleCount: number;\n priceAmountMicros: string;\n recurrenceMode: number;\n }[];\n };\n }[];\n}\n\nexport interface SubscriptionIOS extends ProductCommon {\n type: 'subs';\n\n discounts?: Discount[];\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\nexport type Subscription = SubscriptionAndroid & SubscriptionIOS;\n\nexport interface RequestPurchaseBaseAndroid {\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n isOfferPersonalized?: boolean; // For AndroidBilling V5 https://developer.android.com/google/play/billing/integrate#personalized-price\n}\n\nexport interface RequestPurchaseAndroid extends RequestPurchaseBaseAndroid {\n skus?: Sku[];\n}\n\nexport interface RequestPurchaseIOS {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n}\n\nexport type RequestPurchase = RequestPurchaseAndroid & RequestPurchaseIOS;\n\n/**\n * In order to purchase a new subscription, every sku must have a selected offerToken\n * @see SubscriptionAndroid.subscriptionOfferDetails.offerToken\n */\nexport interface SubscriptionOffer {\n sku: Sku;\n offerToken: string;\n}\n\nexport interface RequestSubscriptionAndroid extends RequestPurchaseBaseAndroid {\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n subscriptionOffers?: SubscriptionOffer[]; // For AndroidBilling V5\n}\n\nexport type RequestSubscriptionIOS = RequestPurchaseIOS;\n\nexport type RequestSubscription = RequestSubscriptionAndroid &\n RequestSubscriptionIOS;\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"}
1
+ {"version":3,"names":["IAPErrorCode","ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid"],"sources":["index.ts"],"sourcesContent":["export type Sku = string;\n\nexport enum IAPErrorCode {\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n}\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n IMMEDIATE_AND_CHARGE_FULL_PRICE = 5,\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 productIds?: 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 productIds?: string[];\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 // Android V5\n oneTimePurchaseOfferDetails?: {\n priceCurrencyCode: string;\n formattedPrice: string;\n priceAmountMicros: string;\n };\n}\n\n// Android V5\nexport interface SubscriptionAndroid extends ProductCommon {\n type: 'subs';\n\n productType?: string;\n name?: string;\n subscriptionOfferDetails?: {\n offerToken: string;\n pricingPhases: {\n pricingPhaseList: {\n formattedPrice: string;\n priceCurrencyCode: string;\n /**\n * P1W, P1M, P1Y\n */\n billingPeriod: string;\n billingCycleCount: number;\n priceAmountMicros: string;\n recurrenceMode: number;\n }[];\n };\n }[];\n}\n\nexport interface SubscriptionIOS extends ProductCommon {\n type: 'subs';\n\n discounts?: Discount[];\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\nexport type Subscription = SubscriptionAndroid & SubscriptionIOS;\n\nexport interface RequestPurchaseBaseAndroid {\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n isOfferPersonalized?: boolean; // For AndroidBilling V5 https://developer.android.com/google/play/billing/integrate#personalized-price\n}\n\nexport interface RequestPurchaseAndroid extends RequestPurchaseBaseAndroid {\n skus?: Sku[];\n}\n\nexport interface RequestPurchaseIOS {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n applicationUsername?: string;\n}\n\nexport type RequestPurchase = RequestPurchaseAndroid & RequestPurchaseIOS;\n\n/**\n * In order to purchase a new subscription, every sku must have a selected offerToken\n * @see SubscriptionAndroid.subscriptionOfferDetails.offerToken\n */\nexport interface SubscriptionOffer {\n sku: Sku;\n offerToken: string;\n}\n\nexport interface RequestSubscriptionAndroid extends RequestPurchaseBaseAndroid {\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n subscriptionOffers?: SubscriptionOffer[]; // For AndroidBilling V5\n}\n\nexport type RequestSubscriptionIOS = RequestPurchaseIOS;\n\nexport type RequestSubscription = RequestSubscriptionAndroid &\n RequestSubscriptionIOS;\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;EAAAA,qB,CAAAA,qB;GAAAA,qB,KAAAA,qB;;AASZ,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"}
@@ -22,6 +22,7 @@ export declare enum ProrationModesAndroid {
22
22
  IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,
23
23
  IMMEDIATE_WITHOUT_PRORATION = 3,
24
24
  DEFERRED = 4,
25
+ IMMEDIATE_AND_CHARGE_FULL_PRICE = 5,
25
26
  UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0
26
27
  }
27
28
  export declare enum PurchaseStateAndroid {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-iap",
3
- "version": "9.0.1",
3
+ "version": "9.0.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
@@ -304,16 +304,20 @@ export const requestPurchase = ({
304
304
  );
305
305
  },
306
306
  android: async () => {
307
- return getAndroidModule().buyItemByType(
308
- ANDROID_ITEM_TYPE_IAP,
309
- skus?.length ? skus : [sku],
310
- null,
311
- -1,
312
- obfuscatedAccountIdAndroid,
313
- obfuscatedProfileIdAndroid,
314
- [],
315
- isOfferPersonalized ?? false,
316
- );
307
+ if (isAmazon) {
308
+ return RNIapAmazonModule.buyItemByType(sku);
309
+ } else {
310
+ return getAndroidModule().buyItemByType(
311
+ ANDROID_ITEM_TYPE_IAP,
312
+ skus?.length ? skus : [sku],
313
+ null,
314
+ -1,
315
+ obfuscatedAccountIdAndroid,
316
+ obfuscatedProfileIdAndroid,
317
+ [],
318
+ isOfferPersonalized ?? false,
319
+ );
320
+ }
317
321
  },
318
322
  }) || Promise.resolve
319
323
  )();
@@ -24,6 +24,7 @@ export enum ProrationModesAndroid {
24
24
  IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,
25
25
  IMMEDIATE_WITHOUT_PRORATION = 3,
26
26
  DEFERRED = 4,
27
+ IMMEDIATE_AND_CHARGE_FULL_PRICE = 5,
27
28
  UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,
28
29
  }
29
30