react-native-iap 8.6.0 → 8.6.3

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.
@@ -81,7 +81,7 @@ function withIAPContext(Component) {
81
81
  return () => {
82
82
  purchaseUpdateSubscription.remove();
83
83
  purchaseErrorSubscription.remove();
84
- promotedProductSubscription.remove();
84
+ promotedProductSubscription === null || promotedProductSubscription === void 0 ? void 0 : promotedProductSubscription.remove();
85
85
  };
86
86
  }, [connected]);
87
87
  return /*#__PURE__*/_react.default.createElement(IAPContext.Provider, {
@@ -1 +1 @@
1
- {"version":3,"names":["IAPContext","React","createContext","useIAPContext","ctx","useContext","Error","withIAPContext","Component","WrapperComponent","props","connected","setConnected","useState","products","setProducts","promotedProductsIOS","setPromotedProductsIOS","subscriptions","setSubscriptions","purchaseHistories","setPurchaseHistories","availablePurchases","setAvailablePurchases","currentPurchase","setCurrentPurchase","currentPurchaseError","setCurrentPurchaseError","initConnectionError","setInitConnectionError","context","useMemo","useEffect","initConnection","then","value","undefined","catch","purchaseUpdateSubscription","purchaseUpdatedListener","purchase","purchaseErrorSubscription","purchaseErrorListener","error","promotedProductSubscription","promotedProductListener","product","getPromotedProductIOS","prevProducts","remove"],"sources":["withIAPContext.tsx"],"sourcesContent":["import React, {useContext, useEffect, useMemo, useState} from 'react';\n\nimport {\n getPromotedProductIOS,\n initConnection,\n promotedProductListener,\n purchaseErrorListener,\n purchaseUpdatedListener,\n} from '../iap';\nimport type {\n InAppPurchase,\n Product,\n Purchase,\n PurchaseError,\n Subscription,\n SubscriptionPurchase,\n} from '../types';\n\ntype IAPContextType = {\n connected: boolean;\n products: Product[];\n promotedProductsIOS: Product[];\n subscriptions: Subscription[];\n purchaseHistories: Purchase[];\n availablePurchases: Purchase[];\n currentPurchase?: Purchase;\n currentPurchaseError?: PurchaseError;\n initConnectionError?: Error;\n setProducts: (products: Product[]) => void;\n setSubscriptions: (subscriptions: Subscription[]) => void;\n setPurchaseHistories: (purchaseHistories: Purchase[]) => void;\n setAvailablePurchases: (availablePurchases: Purchase[]) => void;\n setCurrentPurchase: (currentPurchase: Purchase | undefined) => void;\n setCurrentPurchaseError: (\n currentPurchaseError: PurchaseError | undefined,\n ) => void;\n};\n\n// @ts-ignore\nconst IAPContext = React.createContext<IAPContextType>(null);\n\nexport function useIAPContext(): IAPContextType {\n const ctx = useContext(IAPContext);\n\n if (!ctx) {\n throw new Error('You need wrap your app with withIAPContext HOC');\n }\n\n return ctx;\n}\n\nexport function withIAPContext<T>(Component: React.ComponentType<T>) {\n return function WrapperComponent(props: T) {\n const [connected, setConnected] = useState(false);\n const [products, setProducts] = useState<Product[]>([]);\n\n const [promotedProductsIOS, setPromotedProductsIOS] = useState<Product[]>(\n [],\n );\n const [subscriptions, setSubscriptions] = useState<Subscription[]>([]);\n const [purchaseHistories, setPurchaseHistories] = useState<Purchase[]>([]);\n\n const [availablePurchases, setAvailablePurchases] = useState<Purchase[]>(\n [],\n );\n const [currentPurchase, setCurrentPurchase] = useState<Purchase>();\n\n const [currentPurchaseError, setCurrentPurchaseError] =\n useState<PurchaseError>();\n\n const [initConnectionError, setInitConnectionError] = useState<Error>();\n\n const context = useMemo(\n () => ({\n connected,\n products,\n subscriptions,\n promotedProductsIOS,\n purchaseHistories,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n setProducts,\n setSubscriptions,\n setPurchaseHistories,\n setAvailablePurchases,\n setCurrentPurchase,\n setCurrentPurchaseError,\n }),\n [\n connected,\n products,\n subscriptions,\n promotedProductsIOS,\n purchaseHistories,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n setProducts,\n setSubscriptions,\n setPurchaseHistories,\n setAvailablePurchases,\n setCurrentPurchase,\n setCurrentPurchaseError,\n ],\n );\n\n useEffect(() => {\n initConnection()\n .then((value) => {\n setInitConnectionError(undefined);\n setConnected(value);\n })\n .catch(setInitConnectionError);\n }, []);\n\n useEffect(() => {\n if (!connected) {\n return;\n }\n\n const purchaseUpdateSubscription = purchaseUpdatedListener(\n async (purchase: InAppPurchase | SubscriptionPurchase) => {\n setCurrentPurchaseError(undefined);\n setCurrentPurchase(purchase);\n },\n );\n\n const purchaseErrorSubscription = purchaseErrorListener(\n (error: PurchaseError) => {\n setCurrentPurchase(undefined);\n setCurrentPurchaseError(error);\n },\n );\n\n const promotedProductSubscription = promotedProductListener(async () => {\n const product = await getPromotedProductIOS();\n\n setPromotedProductsIOS((prevProducts) => [\n ...prevProducts,\n ...(product ? [product] : []),\n ]);\n });\n\n return () => {\n purchaseUpdateSubscription.remove();\n purchaseErrorSubscription.remove();\n promotedProductSubscription.remove();\n };\n }, [connected]);\n\n return (\n <IAPContext.Provider value={context}>\n <Component {...props} />\n </IAPContext.Provider>\n );\n };\n}\n"],"mappings":";;;;;;;;AAAA;;AAEA;;;;;;AAoCA;AACA,MAAMA,UAAU,gBAAGC,cAAA,CAAMC,aAAN,CAAoC,IAApC,CAAnB;;AAEO,SAASC,aAAT,GAAyC;EAC9C,MAAMC,GAAG,GAAG,IAAAC,iBAAA,EAAWL,UAAX,CAAZ;;EAEA,IAAI,CAACI,GAAL,EAAU;IACR,MAAM,IAAIE,KAAJ,CAAU,gDAAV,CAAN;EACD;;EAED,OAAOF,GAAP;AACD;;AAEM,SAASG,cAAT,CAA2BC,SAA3B,EAA8D;EACnE,OAAO,SAASC,gBAAT,CAA0BC,KAA1B,EAAoC;IACzC,MAAM,CAACC,SAAD,EAAYC,YAAZ,IAA4B,IAAAC,eAAA,EAAS,KAAT,CAAlC;IACA,MAAM,CAACC,QAAD,EAAWC,WAAX,IAA0B,IAAAF,eAAA,EAAoB,EAApB,CAAhC;IAEA,MAAM,CAACG,mBAAD,EAAsBC,sBAAtB,IAAgD,IAAAJ,eAAA,EACpD,EADoD,CAAtD;IAGA,MAAM,CAACK,aAAD,EAAgBC,gBAAhB,IAAoC,IAAAN,eAAA,EAAyB,EAAzB,CAA1C;IACA,MAAM,CAACO,iBAAD,EA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QAAD,CAAlB;MACD,CAJgC,CAAnC;MAOA,MAAMC,yBAAyB,GAAG,IAAAC,0BAAA,EAC/BC,KAAD,IAA0B;QACxBlB,kBAAkB,CAACW,SAAD,CAAlB;QACAT,uBAAuB,CAACgB,KAAD,CAAvB;MACD,CAJ+B,CAAlC;MAOA,MAAMC,2BAA2B,GAAG,IAAAC,4BAAA,EAAwB,YAAY;QACtE,MAAMC,OAAO,GAAG,MAAM,IAAAC,0BAAA,GAAtB;QAEA9B,sBAAsB,CAAE+B,YAAD,IAAkB,CACvC,GAAGA,YADoC,EAEvC,IAAIF,OAAO,GAAG,CAACA,OAAD,CAAH,GAAe,EAA1B,CAFuC,CAAnB,CAAtB;MAID,CAPmC,CAApC;MASA,OAAO,MAAM;QACXR,0BAA0B,CAACW,MAA3B;QACAR,yBAAyB,CAACQ,MAA1B;QACAL,2BAA2B,CAACK,MAA5B;MACD,CAJD;IAKD,CAjCD,EAiCG,CAACtC,SAAD,CAjCH;IAmCA,oBACE,6BAAC,UAAD,CAAY,QAAZ;MAAqB,KAAK,EAAEmB;IAA5B,gBACE,6BAAC,SAAD,EAAepB,KAAf,CADF,CADF;EAKD,CA1GD;AA2GD"}
1
+ {"version":3,"names":["IAPContext","React","createContext","useIAPContext","ctx","useContext","Error","withIAPContext","Component","WrapperComponent","props","connected","setConnected","useState","products","setProducts","promotedProductsIOS","setPromotedProductsIOS","subscriptions","setSubscriptions","purchaseHistories","setPurchaseHistories","availablePurchases","setAvailablePurchases","currentPurchase","setCurrentPurchase","currentPurchaseError","setCurrentPurchaseError","initConnectionError","setInitConnectionError","context","useMemo","useEffect","initConnection","then","value","undefined","catch","purchaseUpdateSubscription","purchaseUpdatedListener","purchase","purchaseErrorSubscription","purchaseErrorListener","error","promotedProductSubscription","promotedProductListener","product","getPromotedProductIOS","prevProducts","remove"],"sources":["withIAPContext.tsx"],"sourcesContent":["import React, {useContext, useEffect, useMemo, useState} from 'react';\n\nimport {\n getPromotedProductIOS,\n initConnection,\n promotedProductListener,\n purchaseErrorListener,\n purchaseUpdatedListener,\n} from '../iap';\nimport type {\n InAppPurchase,\n Product,\n Purchase,\n PurchaseError,\n Subscription,\n SubscriptionPurchase,\n} from '../types';\n\ntype IAPContextType = {\n connected: boolean;\n products: Product[];\n promotedProductsIOS: Product[];\n subscriptions: Subscription[];\n purchaseHistories: Purchase[];\n availablePurchases: Purchase[];\n currentPurchase?: Purchase;\n currentPurchaseError?: PurchaseError;\n initConnectionError?: Error;\n setProducts: (products: Product[]) => void;\n setSubscriptions: (subscriptions: Subscription[]) => void;\n setPurchaseHistories: (purchaseHistories: Purchase[]) => void;\n setAvailablePurchases: (availablePurchases: Purchase[]) => void;\n setCurrentPurchase: (currentPurchase: Purchase | undefined) => void;\n setCurrentPurchaseError: (\n currentPurchaseError: PurchaseError | undefined,\n ) => void;\n};\n\n// @ts-ignore\nconst IAPContext = React.createContext<IAPContextType>(null);\n\nexport function useIAPContext(): IAPContextType {\n const ctx = useContext(IAPContext);\n\n if (!ctx) {\n throw new Error('You need wrap your app with withIAPContext HOC');\n }\n\n return ctx;\n}\n\nexport function withIAPContext<T>(Component: React.ComponentType<T>) {\n return function WrapperComponent(props: T) {\n const [connected, setConnected] = useState(false);\n const [products, setProducts] = useState<Product[]>([]);\n\n const [promotedProductsIOS, setPromotedProductsIOS] = useState<Product[]>(\n [],\n );\n const [subscriptions, setSubscriptions] = useState<Subscription[]>([]);\n const [purchaseHistories, setPurchaseHistories] = useState<Purchase[]>([]);\n\n const [availablePurchases, setAvailablePurchases] = useState<Purchase[]>(\n [],\n );\n const [currentPurchase, setCurrentPurchase] = useState<Purchase>();\n\n const [currentPurchaseError, setCurrentPurchaseError] =\n useState<PurchaseError>();\n\n const [initConnectionError, setInitConnectionError] = useState<Error>();\n\n const context = useMemo(\n () => ({\n connected,\n products,\n subscriptions,\n promotedProductsIOS,\n purchaseHistories,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n setProducts,\n setSubscriptions,\n setPurchaseHistories,\n setAvailablePurchases,\n setCurrentPurchase,\n setCurrentPurchaseError,\n }),\n [\n connected,\n products,\n subscriptions,\n promotedProductsIOS,\n purchaseHistories,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n setProducts,\n setSubscriptions,\n setPurchaseHistories,\n setAvailablePurchases,\n setCurrentPurchase,\n setCurrentPurchaseError,\n ],\n );\n\n useEffect(() => {\n initConnection()\n .then((value) => {\n setInitConnectionError(undefined);\n setConnected(value);\n })\n .catch(setInitConnectionError);\n }, []);\n\n useEffect(() => {\n if (!connected) {\n return;\n }\n\n const purchaseUpdateSubscription = purchaseUpdatedListener(\n async (purchase: InAppPurchase | SubscriptionPurchase) => {\n setCurrentPurchaseError(undefined);\n setCurrentPurchase(purchase);\n },\n );\n\n const purchaseErrorSubscription = purchaseErrorListener(\n (error: PurchaseError) => {\n setCurrentPurchase(undefined);\n setCurrentPurchaseError(error);\n },\n );\n\n const promotedProductSubscription = promotedProductListener(async () => {\n const product = await getPromotedProductIOS();\n\n setPromotedProductsIOS((prevProducts) => [\n ...prevProducts,\n ...(product ? [product] : []),\n ]);\n });\n\n return () => {\n purchaseUpdateSubscription.remove();\n purchaseErrorSubscription.remove();\n promotedProductSubscription?.remove();\n };\n }, [connected]);\n\n return (\n <IAPContext.Provider value={context}>\n <Component {...props} />\n </IAPContext.Provider>\n );\n };\n}\n"],"mappings":";;;;;;;;AAAA;;AAEA;;;;;;AAoCA;AACA,MAAMA,UAAU,gBAAGC,cAAA,CAAMC,aAAN,CAAoC,IAApC,CAAnB;;AAEO,SAASC,aAAT,GAAyC;EAC9C,MAAMC,GAAG,GAAG,IAAAC,iBAAA,EAAWL,UAAX,CAAZ;;EAEA,IAAI,CAACI,GAAL,EAAU;IACR,MAAM,IAAIE,KAAJ,CAAU,gDAAV,CAAN;EACD;;EAED,OAAOF,GAAP;AACD;;AAEM,SAASG,cAAT,CAA2BC,SAA3B,EAA8D;EACnE,OAAO,SAASC,gBAAT,CA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= _reactNative.Platform.OS === 'android';
20
+ const isIos = _reactNative.Platform.OS === 'ios';
20
21
  const ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';
21
22
  const ANDROID_ITEM_TYPE_IAP = 'inapp';
22
23
 
@@ -552,7 +553,13 @@ const purchaseErrorListener = listener => new _reactNative.NativeEventEmitter(ge
552
553
 
553
554
  exports.purchaseErrorListener = purchaseErrorListener;
554
555
 
555
- const promotedProductListener = listener => new _reactNative.NativeEventEmitter(getIosModule()).addListener('iap-promoted-product', listener);
556
+ const promotedProductListener = listener => {
557
+ if (isIos) {
558
+ return new _reactNative.NativeEventEmitter(getIosModule()).addListener('iap-promoted-product', listener);
559
+ }
560
+
561
+ return null;
562
+ };
556
563
  /**
557
564
  * Get the current receipt base64 encoded in IOS.
558
565
  * @param {forceRefresh?:boolean}
@@ -1 +1 @@
1
- {"version":3,"names":["RNIapIos","RNIapModule","RNIapAmazonModule","NativeModules","isAndroid","Platform","OS","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","getInstallSourceAndroid","InstallSourceAndroid","GOOGLE_PLAY","AMAZON","checkNativeAndroidAvailable","Error","IAPErrorCode","E_IAP_NOT_AVAILABLE","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","fillProductsAdditionalData","products","user","getUser","currencies","CA","ES","AU","DE","IN","US","JP","GB","IT","BR","FR","currency","userMarketplaceAmazon","forEach","product","getProducts","skus","select","ios","items","getItems","filter","item","includes","productId","type","android","getItemsByType","Promise","resolve","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","applicationUsername","console","warn","buyProduct","buyItemByType","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","consumeProduct","purchaseToken","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PurchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","Linking","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","fetchJsonOrThrow","url","receiptBody","response","fetch","method","headers","Accept","body","JSON","stringify","ok","Object","assign","statusText","statusCode","status","json","requestAgnosticReceiptValidationIos","ReceiptValidationStatus","TEST_RECEIPT","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","purchaseUpdatedListener","listener","emitterSubscription","NativeEventEmitter","addListener","startListening","purchaseErrorListener","promotedProductListener","getPendingPurchasesIOS","getPendingTransactions","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {\n EmitterSubscription,\n Linking,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} from 'react-native';\n\nimport type * as Amazon from './types/amazon';\nimport type * as Android from './types/android';\nimport type * as Apple from './types/apple';\nimport {ReceiptValidationStatus} from './types/apple';\nimport type {\n InAppPurchase,\n Product,\n ProductCommon,\n ProductPurchase,\n PurchaseError,\n PurchaseResult,\n RequestPurchase,\n RequestSubscription,\n Subscription,\n SubscriptionPurchase,\n} from './types';\nimport {\n IAPErrorCode,\n InstallSourceAndroid,\n PurchaseStateAndroid,\n} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst isAndroid = Platform.OS === 'android';\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getAndroidModule = (): typeof RNIapModule | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return RNIapModule ? RNIapModule : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nconst getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n if (isAndroid) {\n return getAndroidModule();\n }\n\n return getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<void> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid = (): Promise<\n string[]\n> => getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Fill products with additional data\n * @param {Array<ProductCommon>} products Products\n */\nconst fillProductsAdditionalData = async (\n products: Array<ProductCommon>,\n): Promise<Array<ProductCommon>> => {\n // Amazon\n if (RNIapAmazonModule) {\n // On amazon we must get the user marketplace to detect the currency\n const user = await RNIapAmazonModule.getUser();\n\n const currencies = {\n CA: 'CAD',\n ES: 'EUR',\n AU: 'AUD',\n DE: 'EUR',\n IN: 'INR',\n US: 'USD',\n JP: 'JPY',\n GB: 'GBP',\n IT: 'EUR',\n BR: 'BRL',\n FR: 'EUR',\n };\n\n const currency =\n currencies[user.userMarketplaceAmazon as keyof typeof currencies];\n\n // Add currency to products\n products.forEach((product) => {\n if (currency) {\n product.currency = currency;\n }\n });\n }\n\n return products;\n};\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n * @param {string[]} skus The item skus\n * @returns {Promise<Product[]>}\n */\nexport const getProducts = (skus: string[]): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Product) =>\n skus.includes(item.productId) && item.type === 'iap',\n );\n },\n android: async () => {\n const products = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n skus,\n );\n\n return fillProductsAdditionalData(products);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get a list of subscriptions\n * @param {string[]} skus The item skus\n * @returns {Promise<Subscription[]>}\n */\nexport const getSubscriptions = (skus: string[]): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Subscription) =>\n skus.includes(item.productId) && item.type === 'subs',\n );\n },\n android: async () => {\n const subscriptions = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n );\n\n return fillProductsAdditionalData(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * @returns {Promise<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (InAppPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)\n * @returns {Promise<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (InAppPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @returns {Promise<InAppPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestPurchase): Promise<InAppPurchase> =>\n (\n Platform.select({\n ios: async () => {\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n sku,\n null,\n 0,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n );\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestSubscription): Promise<SubscriptionPurchase | null> =>\n (\n Platform.select({\n ios: async () => {\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n sku,\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n );\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = (\n sku: string,\n quantity: number,\n): Promise<InAppPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\n\n/**\n * Finish Transaction (both platforms)\n * Abstracts Finish Transaction\n * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.\n * Call this after you have persisted the purchased state to your server or local data in your app.\n * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**\n * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.\n * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = (\n purchase: InAppPurchase | ProductPurchase,\n isConsumable?: boolean,\n developerPayloadAndroid?: string,\n): Promise<string | void> => {\n return (\n Platform.select({\n ios: async () => {\n return getIosModule().finishTransaction(purchase.transactionId);\n },\n android: async () => {\n if (purchase) {\n if (isConsumable) {\n return getAndroidModule().consumeProduct(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else if (\n purchase.userIdAmazon ||\n (!purchase.isAcknowledgedAndroid &&\n purchase.purchaseStateAndroid === PurchaseStateAndroid.PURCHASED)\n ) {\n return getAndroidModule().acknowledgePurchase(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else {\n throw new Error('purchase is not suitable to be purchased');\n }\n } else {\n throw new Error('purchase is not assigned');\n }\n },\n }) || Promise.resolve\n )();\n};\n\n/**\n * Clear Transaction (iOS only)\n * Finish remaining transactions. Related to issue #257 and #801\n * link : https://github.com/dooboolab/react-native-iap/issues/257\n * https://github.com/dooboolab/react-native-iap/issues/801\n * @returns {Promise<void>}\n */\nexport const clearTransactionIOS = (): Promise<void> =>\n getIosModule().clearTransaction();\n\n/**\n * Clear valid Products (iOS only)\n * Remove all products which are validated by Apple server.\n * @returns {void}\n */\nexport const clearProductsIOS = (): Promise<void> =>\n getIosModule().clearProducts();\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = (\n token: string,\n developerPayload?: string,\n): Promise<PurchaseResult | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async (\n sku: string,\n): Promise<void> => {\n checkNativeAndroidAvailable();\n\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\n\n/**\n * Buy the currently selected promoted product (iOS only)\n * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.\n * @returns {Promise<void>}\n */\nexport const buyPromotedProductIOS = (): Promise<void> =>\n getIosModule().buyPromotedProduct();\n\nconst fetchJsonOrThrow = async (\n url: string,\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(receiptBody),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetchJsonOrThrow(\n 'https://buy.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === ReceiptValidationStatus.TEST_RECEIPT) {\n const testResponse = await fetchJsonOrThrow(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = (\n sku: string,\n forUser: string,\n withOffer: Apple.PaymentDiscount,\n): Promise<void> => getIosModule().buyProductWithOffer(sku, forUser, withOffer);\n\n/**\n * Validate receipt for iOS.\n * @param {object} receiptBody the receipt body to send to apple server.\n * @param {boolean} isTest whether this is in test environment which is sandbox.\n * @returns {Promise<Apple.ReceiptValidationResponse | false>}\n */\nexport const validateReceiptIos = async (\n receiptBody: Record<string, unknown>,\n isTest?: boolean,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n const response = await fetchJsonOrThrow(url, receiptBody);\n\n return response;\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} packageName package name of your app.\n * @param {string} productId product id for your in app product.\n * @param {string} productToken token for your purchase.\n * @param {string} accessToken accessToken from googleApis.\n * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAndroid = async (\n packageName: string,\n productId: string,\n productToken: string,\n accessToken: string,\n isSub?: boolean,\n): Promise<Android.ReceiptType> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}?access_token=${accessToken}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including\n * your developer secret in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} developerSecret: from the Amazon developer console.\n * @param {string} userId who purchased the item.\n * @param {string} receiptId long obfuscated string returned when purchasing the item\n * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAmazon = async (\n developerSecret: string,\n userId: string,\n receiptId: string,\n useSandbox: boolean = true,\n): Promise<Amazon.ReceiptType> => {\n const sandBoxUrl = useSandbox ? 'sandbox/' : '';\n const url = `https://appstore-sdk.amazon.com/${sandBoxUrl}version/1.0/verifyReceiptId/developer/${developerSecret}/user/${userId}/receiptId/${receiptId}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Add IAP purchase event\n * @returns {callback(e: InAppPurchase | ProductPurchase)}\n */\nexport const purchaseUpdatedListener = (\n listener: (event: InAppPurchase | SubscriptionPurchase) => void,\n): EmitterSubscription => {\n const emitterSubscription = new NativeEventEmitter(\n getNativeModule(),\n ).addListener('purchase-updated', listener);\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n * @returns {callback(e: PurchaseError)}\n */\nexport const purchaseErrorListener = (\n listener: (errorEvent: PurchaseError) => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getNativeModule()).addListener(\n 'purchase-error',\n listener,\n );\n\n/**\n * Add IAP promoted subscription event\n * Only available on iOS\n */\nexport const promotedProductListener = (\n listener: () => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getIosModule()).addListener(\n 'iap-promoted-product',\n listener,\n );\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":";;;;;;;AAAA;;AAWA;;AAaA;;AAMA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CC,0BAAnD;AACA,MAAMC,SAAS,GAAGC,qBAAA,CAASC,EAAT,KAAgB,SAAlC;AACA,MAAMC,8B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AQ,GAAG,MAAMC,KAAK,CAACH,GAAD,EAAM;IAChCI,MAAM,EAAE,KADwB;IAEhCC,OAAO,EAAE;MACP,gBAAgB;IADT;EAFuB,CAAN,CAA5B;;EAOA,IAAI,CAACH,QAAQ,CAACQ,EAAd,EAAkB;IAChB,MAAMC,MAAM,CAACC,MAAP,CAAc,IAAI/G,KAAJ,CAAUqG,QAAQ,CAACW,UAAnB,CAAd,EAA8C;MAClDC,UAAU,EAAEZ,QAAQ,CAACa;IAD6B,CAA9C,CAAN;EAGD;;EAED,OAAOb,QAAQ,CAACc,IAAT,EAAP;AACD,CAvBM;AAyBP;AACA;AACA;AACA;;;;;AACO,MAAMsB,uBAAuB,GAClCC,QADqC,IAEb;EACxB,MAAMC,mBAAmB,GAAG,IAAIC,+BAAJ,CAC1BtI,eAAe,EADW,EAE1BuI,WAF0B,CAEd,kBAFc,EAEMH,QAFN,CAA5B;;EAIA,IAAIpJ,SAAJ,EAAe;IACba,gBAAgB,GAAG2I,cAAnB;EACD;;EAED,OAAOH,mBAAP;AACD,CAZM;AAcP;AACA;AACA;AACA;;;;;AACO,MAAMI,qBAAqB,GAChCL,QADmC,IAGnC,IAAIE,+BAAJ,CAAuBtI,eAAe,EAAtC,EAA0CuI,WAA1C,CACE,gBADF,EAEEH,QAFF,CAHK;AAQP;AACA;AACA;AACA;;;;;AACO,MAAMM,uBAAuB,GAClCN,QADqC,IAGrC,IAAIE,+BAAJ,CAAuBvI,YAAY,EAAnC,EAAuCwI,WAAvC,CACE,sBADF,EAEEH,QAFF,CAHK;AAQP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMO,sBAAsB,GAAG,YACpC5I,YAAY,GAAG6I,sBAAf,EADK;AAGP;AACA;AACA;AACA;;;;;AACO,MAAMC,6BAA6B,GAAG,YAC3C9I,YAAY,GAAG+I,0BAAf,EADK"}
1
+ {"version":3,"names":["RNIapIos","RNIapModule","RNIapAmazonModule","NativeModules","isAndroid","Platform","OS","isIos","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","getInstallSourceAndroid","InstallSourceAndroid","GOOGLE_PLAY","AMAZON","checkNativeAndroidAvailable","Error","IAPErrorCode","E_IAP_NOT_AVAILABLE","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","fillProductsAdditionalData","products","user","getUser","currencies","CA","ES","AU","DE","IN","US","JP","GB","IT","BR","FR","currency","userMarketplaceAmazon","forEach","product","getProducts","skus","select","ios","items","getItems","filter","item","includes","productId","type","android","getItemsByType","Promise","resolve","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","applicationUsername","console","warn","buyProduct","buyItemByType","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","consumeProduct","purchaseToken","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PurchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","Linking","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","fetchJsonOrThrow","url","receiptBody","response","fetch","method","headers","Accept","body","JSON","stringify","ok","Object","assign","statusText","statusCode","status","json","requestAgnosticReceiptValidationIos","ReceiptValidationStatus","TEST_RECEIPT","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","purchaseUpdatedListener","listener","emitterSubscription","NativeEventEmitter","addListener","startListening","purchaseErrorListener","promotedProductListener","getPendingPurchasesIOS","getPendingTransactions","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {\n EmitterSubscription,\n Linking,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} from 'react-native';\n\nimport type * as Amazon from './types/amazon';\nimport type * as Android from './types/android';\nimport type * as Apple from './types/apple';\nimport {ReceiptValidationStatus} from './types/apple';\nimport type {\n InAppPurchase,\n Product,\n ProductCommon,\n ProductPurchase,\n PurchaseError,\n PurchaseResult,\n RequestPurchase,\n RequestSubscription,\n Subscription,\n SubscriptionPurchase,\n} from './types';\nimport {\n IAPErrorCode,\n InstallSourceAndroid,\n PurchaseStateAndroid,\n} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst isAndroid = Platform.OS === 'android';\nconst isIos = Platform.OS === 'ios';\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getAndroidModule = (): typeof RNIapModule | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return RNIapModule ? RNIapModule : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nconst getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n if (isAndroid) {\n return getAndroidModule();\n }\n\n return getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<void> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid = (): Promise<\n string[]\n> => getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Fill products with additional data\n * @param {Array<ProductCommon>} products Products\n */\nconst fillProductsAdditionalData = async (\n products: Array<ProductCommon>,\n): Promise<Array<ProductCommon>> => {\n // Amazon\n if (RNIapAmazonModule) {\n // On amazon we must get the user marketplace to detect the currency\n const user = await RNIapAmazonModule.getUser();\n\n const currencies = {\n CA: 'CAD',\n ES: 'EUR',\n AU: 'AUD',\n DE: 'EUR',\n IN: 'INR',\n US: 'USD',\n JP: 'JPY',\n GB: 'GBP',\n IT: 'EUR',\n BR: 'BRL',\n FR: 'EUR',\n };\n\n const currency =\n currencies[user.userMarketplaceAmazon as keyof typeof currencies];\n\n // Add currency to products\n products.forEach((product) => {\n if (currency) {\n product.currency = currency;\n }\n });\n }\n\n return products;\n};\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n * @param {string[]} skus The item skus\n * @returns {Promise<Product[]>}\n */\nexport const getProducts = (skus: string[]): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Product) =>\n skus.includes(item.productId) && item.type === 'iap',\n );\n },\n android: async () => {\n const products = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n skus,\n );\n\n return fillProductsAdditionalData(products);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get a list of subscriptions\n * @param {string[]} skus The item skus\n * @returns {Promise<Subscription[]>}\n */\nexport const getSubscriptions = (skus: string[]): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Subscription) =>\n skus.includes(item.productId) && item.type === 'subs',\n );\n },\n android: async () => {\n const subscriptions = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n );\n\n return fillProductsAdditionalData(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * @returns {Promise<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (InAppPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)\n * @returns {Promise<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (InAppPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @returns {Promise<InAppPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestPurchase): Promise<InAppPurchase> =>\n (\n Platform.select({\n ios: async () => {\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n sku,\n null,\n 0,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n );\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestSubscription): Promise<SubscriptionPurchase | null> =>\n (\n Platform.select({\n ios: async () => {\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n sku,\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n );\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = (\n sku: string,\n quantity: number,\n): Promise<InAppPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\n\n/**\n * Finish Transaction (both platforms)\n * Abstracts Finish Transaction\n * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.\n * Call this after you have persisted the purchased state to your server or local data in your app.\n * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**\n * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.\n * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = (\n purchase: InAppPurchase | ProductPurchase,\n isConsumable?: boolean,\n developerPayloadAndroid?: string,\n): Promise<string | void> => {\n return (\n Platform.select({\n ios: async () => {\n return getIosModule().finishTransaction(purchase.transactionId);\n },\n android: async () => {\n if (purchase) {\n if (isConsumable) {\n return getAndroidModule().consumeProduct(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else if (\n purchase.userIdAmazon ||\n (!purchase.isAcknowledgedAndroid &&\n purchase.purchaseStateAndroid === PurchaseStateAndroid.PURCHASED)\n ) {\n return getAndroidModule().acknowledgePurchase(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else {\n throw new Error('purchase is not suitable to be purchased');\n }\n } else {\n throw new Error('purchase is not assigned');\n }\n },\n }) || Promise.resolve\n )();\n};\n\n/**\n * Clear Transaction (iOS only)\n * Finish remaining transactions. Related to issue #257 and #801\n * link : https://github.com/dooboolab/react-native-iap/issues/257\n * https://github.com/dooboolab/react-native-iap/issues/801\n * @returns {Promise<void>}\n */\nexport const clearTransactionIOS = (): Promise<void> =>\n getIosModule().clearTransaction();\n\n/**\n * Clear valid Products (iOS only)\n * Remove all products which are validated by Apple server.\n * @returns {void}\n */\nexport const clearProductsIOS = (): Promise<void> =>\n getIosModule().clearProducts();\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = (\n token: string,\n developerPayload?: string,\n): Promise<PurchaseResult | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async (\n sku: string,\n): Promise<void> => {\n checkNativeAndroidAvailable();\n\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\n\n/**\n * Buy the currently selected promoted product (iOS only)\n * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.\n * @returns {Promise<void>}\n */\nexport const buyPromotedProductIOS = (): Promise<void> =>\n getIosModule().buyPromotedProduct();\n\nconst fetchJsonOrThrow = async (\n url: string,\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(receiptBody),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetchJsonOrThrow(\n 'https://buy.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === ReceiptValidationStatus.TEST_RECEIPT) {\n const testResponse = await fetchJsonOrThrow(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = (\n sku: string,\n forUser: string,\n withOffer: Apple.PaymentDiscount,\n): Promise<void> => getIosModule().buyProductWithOffer(sku, forUser, withOffer);\n\n/**\n * Validate receipt for iOS.\n * @param {object} receiptBody the receipt body to send to apple server.\n * @param {boolean} isTest whether this is in test environment which is sandbox.\n * @returns {Promise<Apple.ReceiptValidationResponse | false>}\n */\nexport const validateReceiptIos = async (\n receiptBody: Record<string, unknown>,\n isTest?: boolean,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n const response = await fetchJsonOrThrow(url, receiptBody);\n\n return response;\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} packageName package name of your app.\n * @param {string} productId product id for your in app product.\n * @param {string} productToken token for your purchase.\n * @param {string} accessToken accessToken from googleApis.\n * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAndroid = async (\n packageName: string,\n productId: string,\n productToken: string,\n accessToken: string,\n isSub?: boolean,\n): Promise<Android.ReceiptType> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}?access_token=${accessToken}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including\n * your developer secret in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} developerSecret: from the Amazon developer console.\n * @param {string} userId who purchased the item.\n * @param {string} receiptId long obfuscated string returned when purchasing the item\n * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAmazon = async (\n developerSecret: string,\n userId: string,\n receiptId: string,\n useSandbox: boolean = true,\n): Promise<Amazon.ReceiptType> => {\n const sandBoxUrl = useSandbox ? 'sandbox/' : '';\n const url = `https://appstore-sdk.amazon.com/${sandBoxUrl}version/1.0/verifyReceiptId/developer/${developerSecret}/user/${userId}/receiptId/${receiptId}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Add IAP purchase event\n * @returns {callback(e: InAppPurchase | ProductPurchase)}\n */\nexport const purchaseUpdatedListener = (\n listener: (event: InAppPurchase | SubscriptionPurchase) => void,\n): EmitterSubscription => {\n const emitterSubscription = new NativeEventEmitter(\n getNativeModule(),\n ).addListener('purchase-updated', listener);\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n * @returns {callback(e: PurchaseError)}\n */\nexport const purchaseErrorListener = (\n listener: (errorEvent: PurchaseError) => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getNativeModule()).addListener(\n 'purchase-error',\n listener,\n );\n\n/**\n * Add IAP promoted subscription event\n * Only available on iOS\n */\nexport const promotedProductListener = (\n listener: () => void,\n): EmitterSubscription | null => {\n if (isIos) {\n return new NativeEventEmitter(getIosModule()).addListener(\n 'iap-promoted-product',\n listener,\n );\n }\n return null;\n};\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":";;;;;;;AAAA;;AAWA;;AAaA;;AAMA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CC,0BAAnD;AACA,MAAMC,SAAS,GAAGC,qBAAA,CAASC,EAAT,KAAgB,SAAlC;AACA,MAAMC,KAAK,GAAGF,qBAAA,CAASC,EAAT,KAAgB,KAA9B;AACA,MAAME,8BAA8B,GAAG,MAAvC;AACA,MAAMC,qBAAqB,GAAG,OAA9B;;AAEO,MAAMC,uBAAuB,GAAG,MAA4B;EACjE,OAAOT,WAAW,GACdU,2BAAA,CAAqBC,WADP,GAEdD,2BAAA,CAAqBE,MAFzB;AAGD,CAJM;;;;AAMP,MAAMC,2BAA2B,GAAG,MAAY;EAC9C,IAAI,CAACb,WAAD,IAAgB,CAACC,iBAArB,EAAwC;IACtC,MAAM,IAAIa,KAAJ,CAAUC,mBAAA,CAAaC,mBAAvB,CAAN;EACD;AACF,CAJD;;AAMA,MAAMC,gBAAgB,GAAG,MAAqD;EAC5EJ,2BAA2B;EAE3B,OAAOb,WAAW,GAAGA,WAAH,GAAiBC,iBAAnC;AACD,CAJD;;AAMA,MAAMiB,uBAAuB,GAAG,MAAY;EAC1C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,EADW,EAE1BuI,WAF0B,CAEd,kBAFc,EAEMH,QAFN,CAA5B;;EAIA,IAAIrJ,SAAJ,EAAe;IACbc,gBAAgB,GAAG2I,cAAnB;EACD;;EAED,OAAOH,mBAAP;AACD,CAZM;AAcP;AACA;AACA;AACA;;;;;AACO,MAAMI,qBAAqB,GAChCL,QADmC,IAGnC,IAAIE,+BAAJ,CAAuBtI,eAAe,EAAtC,EAA0CuI,WAA1C,CACE,gBADF,EAEEH,QAFF,CAHK;AAQP;AACA;AACA;AACA;;;;;AACO,MAAMM,uBAAuB,GAClCN,QADqC,IAEN;EAC/B,IAAIlJ,KAAJ,EAAW;IACT,OAAO,IAAIoJ,+BAAJ,CAAuBvI,YAAY,EAAnC,EAAuCwI,WAAvC,CACL,sBADK,EAELH,QAFK,CAAP;EAID;;EACD,OAAO,IAAP;AACD,CAVM;AAYP;AACA;AACA;AACA;AACA;;;;;AACO,MAAMO,sBAAsB,GAAG,YACpC5I,YAAY,GAAG6I,sBAAf,EADK;AAGP;AACA;AACA;AACA;;;;;AACO,MAAMC,6BAA6B,GAAG,YAC3C9I,YAAY,GAAG+I,0BAAf,EADK"}
@@ -1 +1 @@
1
- {"version":3,"names":["IAPErrorCode","ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid"],"sources":["index.ts"],"sourcesContent":["type Sku = string;\n\nexport enum IAPErrorCode {\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n}\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string;\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n //Android\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n //Amazon\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n isCanceledAmazon?: boolean;\n}\n\nexport interface PurchaseResult {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n}\n\nexport interface PurchaseError {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n productId?: string;\n}\n\nexport type InAppPurchase = ProductPurchase;\n\nexport interface SubscriptionPurchase extends ProductPurchase {\n autoRenewingAndroid?: boolean;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n}\n\nexport type Purchase = InAppPurchase | SubscriptionPurchase;\n\nexport interface Discount {\n identifier: string;\n type: string;\n numberOfPeriods: string;\n price: string;\n localizedPrice: string;\n paymentMode: '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';\n subscriptionPeriod: string;\n}\n\nexport interface Product extends ProductCommon {\n type: 'inapp' | 'iap';\n}\n\nexport interface Subscription extends ProductCommon {\n type: 'subs' | 'sub';\n\n discounts?: Discount[];\n\n introductoryPrice?: string;\n introductoryPriceAsAmountIOS?: string;\n introductoryPricePaymentModeIOS?:\n | ''\n | 'FREETRIAL'\n | 'PAYASYOUGO'\n | 'PAYUPFRONT';\n introductoryPriceNumberOfPeriodsIOS?: string;\n introductoryPriceSubscriptionPeriodIOS?:\n | 'DAY'\n | 'WEEK'\n | 'MONTH'\n | 'YEAR'\n | '';\n\n subscriptionPeriodNumberIOS?: string;\n subscriptionPeriodUnitIOS?: '' | 'YEAR' | 'MONTH' | 'WEEK' | 'DAY';\n\n introductoryPriceAsAmountAndroid: string;\n introductoryPriceCyclesAndroid?: string;\n introductoryPricePeriodAndroid?: string;\n subscriptionPeriodAndroid?: string;\n freeTrialPeriodAndroid?: string;\n}\n\ninterface RequestPurchaseCommon {\n sku: Sku;\n}\n\ninterface RequestPurchaseIOS extends RequestPurchaseCommon {\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: never;\n obfuscatedProfileIdAndroid?: never;\n selectedOfferIndex?: never;\n}\n\ninterface RequestPurchaseAndroid extends RequestPurchaseCommon {\n andDangerouslyFinishTransactionAutomaticallyIOS?: never;\n applicationUsername?: never;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n selectedOfferIndex: number;\n}\n\nexport type RequestPurchase = RequestPurchaseIOS | RequestPurchaseAndroid;\n\ninterface RequestSubscriptionIOS extends RequestPurchaseIOS {\n purchaseTokenAndroid?: never;\n prorationModeAndroid?: never;\n}\n\ninterface RequestSubscriptionAndroid extends RequestPurchaseAndroid {\n purchaseTokenAndroid?: string;\n prorationModeAndroid: ProrationModesAndroid;\n}\n\nexport type RequestSubscription =\n | RequestSubscriptionIOS\n | RequestSubscriptionAndroid;\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":["type Sku = string;\n\nexport enum IAPErrorCode {\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n}\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string;\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n //Android\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n //Amazon\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n isCanceledAmazon?: boolean;\n}\n\nexport interface PurchaseResult {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n}\n\nexport interface PurchaseError {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n productId?: string;\n}\n\nexport type InAppPurchase = ProductPurchase;\n\nexport interface SubscriptionPurchase extends ProductPurchase {\n autoRenewingAndroid?: boolean;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n}\n\nexport type Purchase = InAppPurchase | SubscriptionPurchase;\n\nexport interface Discount {\n identifier: string;\n type: string;\n numberOfPeriods: string;\n price: string;\n localizedPrice: string;\n paymentMode: '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';\n subscriptionPeriod: string;\n}\n\nexport interface Product extends ProductCommon {\n type: 'inapp' | 'iap';\n}\n\nexport interface Subscription extends ProductCommon {\n type: 'subs' | 'sub';\n\n discounts?: Discount[];\n\n introductoryPrice?: string;\n introductoryPriceAsAmountIOS?: string;\n introductoryPricePaymentModeIOS?:\n | ''\n | 'FREETRIAL'\n | 'PAYASYOUGO'\n | 'PAYUPFRONT';\n introductoryPriceNumberOfPeriodsIOS?: string;\n introductoryPriceSubscriptionPeriodIOS?:\n | 'DAY'\n | 'WEEK'\n | 'MONTH'\n | 'YEAR'\n | '';\n\n subscriptionPeriodNumberIOS?: string;\n subscriptionPeriodUnitIOS?: '' | 'YEAR' | 'MONTH' | 'WEEK' | 'DAY';\n\n introductoryPriceAsAmountAndroid: string;\n introductoryPriceCyclesAndroid?: string;\n introductoryPricePeriodAndroid?: string;\n subscriptionPeriodAndroid?: string;\n freeTrialPeriodAndroid?: string;\n}\n\nexport interface RequestPurchase {\n sku: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n selectedOfferIndex: number;\n}\n\nexport interface RequestSubscription extends RequestPurchase {\n purchaseTokenAndroid?: string;\n prorationModeAndroid: ProrationModesAndroid;\n}\n"],"mappings":";;;;;;IAEYA,Y;;;WAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;GAAAA,Y,4BAAAA,Y;;IAmBAC,qB;;;WAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,qCAAAA,qB;;IAQAC,oB;;;WAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,oCAAAA,oB;;AAML,MAAMC,gBAAgB,GAAG,sBAAzB;;IAEKC,oB;;;WAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,oCAAAA,oB"}
@@ -65,7 +65,7 @@ export function withIAPContext(Component) {
65
65
  return () => {
66
66
  purchaseUpdateSubscription.remove();
67
67
  purchaseErrorSubscription.remove();
68
- promotedProductSubscription.remove();
68
+ promotedProductSubscription === null || promotedProductSubscription === void 0 ? void 0 : promotedProductSubscription.remove();
69
69
  };
70
70
  }, [connected]);
71
71
  return /*#__PURE__*/React.createElement(IAPContext.Provider, {
@@ -1 +1 @@
1
- {"version":3,"names":["React","useContext","useEffect","useMemo","useState","getPromotedProductIOS","initConnection","promotedProductListener","purchaseErrorListener","purchaseUpdatedListener","IAPContext","createContext","useIAPContext","ctx","Error","withIAPContext","Component","WrapperComponent","props","connected","setConnected","products","setProducts","promotedProductsIOS","setPromotedProductsIOS","subscriptions","setSubscriptions","purchaseHistories","setPurchaseHistories","availablePurchases","setAvailablePurchases","currentPurchase","setCurrentPurchase","currentPurchaseError","setCurrentPurchaseError","initConnectionError","setInitConnectionError","context","then","value","undefined","catch","purchaseUpdateSubscription","purchase","purchaseErrorSubscription","error","promotedProductSubscription","product","prevProducts","remove"],"sources":["withIAPContext.tsx"],"sourcesContent":["import React, {useContext, useEffect, useMemo, useState} from 'react';\n\nimport {\n getPromotedProductIOS,\n initConnection,\n promotedProductListener,\n purchaseErrorListener,\n purchaseUpdatedListener,\n} from '../iap';\nimport type {\n InAppPurchase,\n Product,\n Purchase,\n PurchaseError,\n Subscription,\n SubscriptionPurchase,\n} from '../types';\n\ntype IAPContextType = {\n connected: boolean;\n products: Product[];\n promotedProductsIOS: Product[];\n subscriptions: Subscription[];\n purchaseHistories: Purchase[];\n availablePurchases: Purchase[];\n currentPurchase?: Purchase;\n currentPurchaseError?: PurchaseError;\n initConnectionError?: Error;\n setProducts: (products: Product[]) => void;\n setSubscriptions: (subscriptions: Subscription[]) => void;\n setPurchaseHistories: (purchaseHistories: Purchase[]) => void;\n setAvailablePurchases: (availablePurchases: Purchase[]) => void;\n setCurrentPurchase: (currentPurchase: Purchase | undefined) => void;\n setCurrentPurchaseError: (\n currentPurchaseError: PurchaseError | undefined,\n ) => void;\n};\n\n// @ts-ignore\nconst IAPContext = React.createContext<IAPContextType>(null);\n\nexport function useIAPContext(): IAPContextType {\n const ctx = useContext(IAPContext);\n\n if (!ctx) {\n throw new Error('You need wrap your app with withIAPContext HOC');\n }\n\n return ctx;\n}\n\nexport function withIAPContext<T>(Component: React.ComponentType<T>) {\n return function WrapperComponent(props: T) {\n const [connected, setConnected] = useState(false);\n const [products, setProducts] = useState<Product[]>([]);\n\n const [promotedProductsIOS, setPromotedProductsIOS] = useState<Product[]>(\n [],\n );\n const [subscriptions, setSubscriptions] = useState<Subscription[]>([]);\n const [purchaseHistories, setPurchaseHistories] = useState<Purchase[]>([]);\n\n const [availablePurchases, setAvailablePurchases] = useState<Purchase[]>(\n [],\n );\n const [currentPurchase, setCurrentPurchase] = useState<Purchase>();\n\n const [currentPurchaseError, setCurrentPurchaseError] =\n useState<PurchaseError>();\n\n const [initConnectionError, setInitConnectionError] = useState<Error>();\n\n const context = useMemo(\n () => ({\n connected,\n products,\n subscriptions,\n promotedProductsIOS,\n purchaseHistories,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n setProducts,\n setSubscriptions,\n setPurchaseHistories,\n setAvailablePurchases,\n setCurrentPurchase,\n setCurrentPurchaseError,\n }),\n [\n connected,\n products,\n subscriptions,\n promotedProductsIOS,\n purchaseHistories,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n setProducts,\n setSubscriptions,\n setPurchaseHistories,\n setAvailablePurchases,\n setCurrentPurchase,\n setCurrentPurchaseError,\n ],\n );\n\n useEffect(() => {\n initConnection()\n .then((value) => {\n setInitConnectionError(undefined);\n setConnected(value);\n })\n .catch(setInitConnectionError);\n }, []);\n\n useEffect(() => {\n if (!connected) {\n return;\n }\n\n const purchaseUpdateSubscription = purchaseUpdatedListener(\n async (purchase: InAppPurchase | SubscriptionPurchase) => {\n setCurrentPurchaseError(undefined);\n setCurrentPurchase(purchase);\n },\n );\n\n const purchaseErrorSubscription = purchaseErrorListener(\n (error: PurchaseError) => {\n setCurrentPurchase(undefined);\n setCurrentPurchaseError(error);\n },\n );\n\n const promotedProductSubscription = promotedProductListener(async () => {\n const product = await getPromotedProductIOS();\n\n setPromotedProductsIOS((prevProducts) => [\n ...prevProducts,\n ...(product ? [product] : []),\n ]);\n });\n\n return () => {\n purchaseUpdateSubscription.remove();\n purchaseErrorSubscription.remove();\n promotedProductSubscription.remove();\n };\n }, [connected]);\n\n return (\n <IAPContext.Provider value={context}>\n <Component {...props} />\n </IAPContext.Provider>\n );\n };\n}\n"],"mappings":"AAAA,OAAOA,KAAP,IAAeC,UAAf,EAA2BC,SAA3B,EAAsCC,OAAtC,EAA+CC,QAA/C,QAA8D,OAA9D;AAEA,SACEC,qBADF,EAEEC,cAFF,EAGEC,uBAHF,EAIEC,qBAJF,EAKEC,uBALF,QAMO,QANP;AAoCA;AACA,MAAMC,UAAU,gBAAGV,KAAK,CAACW,aAAN,CAAoC,IAApC,CAAnB;AAEA,OAAO,SAASC,aAAT,GAAyC;EAC9C,MAAMC,GAAG,GAAGZ,UAAU,CAACS,UAAD,CAAtB;;EAEA,IAAI,CAACG,GAAL,EAAU;IACR,MAAM,IAAIC,KAAJ,CAAU,gDAAV,CAAN;EACD;;EAED,OAAOD,GAAP;AACD;AAED,OAAO,SAASE,cAAT,CAA2BC,SAA3B,EAA8D;EACnE,OAAO,SAASC,gBAAT,CAA0BC,KAA1B,EAAoC;IACzC,MAAM,CAACC,SAAD,EAAYC,YAAZ,IAA4BhB,QAAQ,CAAC,KAAD,CAA1C;IACA,MAAM,CAACiB,QAAD,EAAWC,WAAX,IAA0BlB,QAAQ,CAAY,EAAZ,CAAxC;IAEA,MAAM,CAACmB,mBAAD,EAAsBC,sBAAtB,IAAgDpB,QAAQ,CAC5D,EAD4D,CAA9D;IAGA,MAAM,CAACqB,aAAD,EAAgBC,gBAAhB,IAAoCtB,QAAQ,CAAiB,EAAjB,CAAlD;IACA,MAAM,CAACuB,iBAAD,EAAoBC,oBAApB,IAA4CxB,QAAQ,CAAa,EAAb,CAA1D;IAEA,MAAM,CAACyB,kBAAD,EAAqBC,qBAArB,IAA8C1B,QAAQ,CAC1D,EAD0D,CAA5D;IAGA,MAAM,CAAC2B,eAAD,EAAkBC,kBAAlB,IAAwC5B,QAAQ,E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B,CAAC,YAAY;QACtE,MAAMwC,OAAO,GAAG,MAAM1C,qBAAqB,EAA3C;QAEAmB,sBAAsB,CAAEwB,YAAD,IAAkB,CACvC,GAAGA,YADoC,EAEvC,IAAID,OAAO,GAAG,CAACA,OAAD,CAAH,GAAe,EAA1B,CAFuC,CAAnB,CAAtB;MAID,CAP0D,CAA3D;MASA,OAAO,MAAM;QACXL,0BAA0B,CAACO,MAA3B;QACAL,yBAAyB,CAACK,MAA1B;QACAH,2BAA2B,CAACG,MAA5B;MACD,CAJD;IAKD,CAjCQ,EAiCN,CAAC9B,SAAD,CAjCM,CAAT;IAmCA,oBACE,oBAAC,UAAD,CAAY,QAAZ;MAAqB,KAAK,EAAEkB;IAA5B,gBACE,oBAAC,SAAD,EAAenB,KAAf,CADF,CADF;EAKD,CA1GD;AA2GD"}
1
+ {"version":3,"names":["React","useContext","useEffect","useMemo","useState","getPromotedProductIOS","initConnection","promotedProductListener","purchaseErrorListener","purchaseUpdatedListener","IAPContext","createContext","useIAPContext","ctx","Error","withIAPContext","Component","WrapperComponent","props","connected","setConnected","products","setProducts","promotedProductsIOS","setPromotedProductsIOS","subscriptions","setSubscriptions","purchaseHistories","setPurchaseHistories","availablePurchases","setAvailablePurchases","currentPurchase","setCurrentPurchase","currentPurchaseError","setCurrentPurchaseError","initConnectionError","setInitConnectionError","context","then","value","undefined","catch","purchaseUpdateSubscription","purchase","purchaseErrorSubscription","error","promotedProductSubscription","product","prevProducts","remove"],"sources":["withIAPContext.tsx"],"sourcesContent":["import React, {useContext, useEffect, useMemo, useState} from 'react';\n\nimport {\n getPromotedProductIOS,\n initConnection,\n promotedProductListener,\n purchaseErrorListener,\n purchaseUpdatedListener,\n} from '../iap';\nimport type {\n InAppPurchase,\n Product,\n Purchase,\n PurchaseError,\n Subscription,\n SubscriptionPurchase,\n} from '../types';\n\ntype IAPContextType = {\n connected: boolean;\n products: Product[];\n promotedProductsIOS: Product[];\n subscriptions: Subscription[];\n purchaseHistories: Purchase[];\n availablePurchases: Purchase[];\n currentPurchase?: Purchase;\n currentPurchaseError?: PurchaseError;\n initConnectionError?: Error;\n setProducts: (products: Product[]) => void;\n setSubscriptions: (subscriptions: Subscription[]) => void;\n setPurchaseHistories: (purchaseHistories: Purchase[]) => void;\n setAvailablePurchases: (availablePurchases: Purchase[]) => void;\n setCurrentPurchase: (currentPurchase: Purchase | undefined) => void;\n setCurrentPurchaseError: (\n currentPurchaseError: PurchaseError | undefined,\n ) => void;\n};\n\n// @ts-ignore\nconst IAPContext = React.createContext<IAPContextType>(null);\n\nexport function useIAPContext(): IAPContextType {\n const ctx = useContext(IAPContext);\n\n if (!ctx) {\n throw new Error('You need wrap your app with withIAPContext HOC');\n }\n\n return ctx;\n}\n\nexport function withIAPContext<T>(Component: React.ComponentType<T>) {\n return function WrapperComponent(props: T) {\n const [connected, setConnected] = useState(false);\n const [products, setProducts] = useState<Product[]>([]);\n\n const [promotedProductsIOS, setPromotedProductsIOS] = useState<Product[]>(\n [],\n );\n const [subscriptions, setSubscriptions] = useState<Subscription[]>([]);\n const [purchaseHistories, setPurchaseHistories] = useState<Purchase[]>([]);\n\n const [availablePurchases, setAvailablePurchases] = useState<Purchase[]>(\n [],\n );\n const [currentPurchase, setCurrentPurchase] = useState<Purchase>();\n\n const [currentPurchaseError, setCurrentPurchaseError] =\n useState<PurchaseError>();\n\n const [initConnectionError, setInitConnectionError] = useState<Error>();\n\n const context = useMemo(\n () => ({\n connected,\n products,\n subscriptions,\n promotedProductsIOS,\n purchaseHistories,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n setProducts,\n setSubscriptions,\n setPurchaseHistories,\n setAvailablePurchases,\n setCurrentPurchase,\n setCurrentPurchaseError,\n }),\n [\n connected,\n products,\n subscriptions,\n promotedProductsIOS,\n purchaseHistories,\n availablePurchases,\n currentPurchase,\n currentPurchaseError,\n initConnectionError,\n setProducts,\n setSubscriptions,\n setPurchaseHistories,\n setAvailablePurchases,\n setCurrentPurchase,\n setCurrentPurchaseError,\n ],\n );\n\n useEffect(() => {\n initConnection()\n .then((value) => {\n setInitConnectionError(undefined);\n setConnected(value);\n })\n .catch(setInitConnectionError);\n }, []);\n\n useEffect(() => {\n if (!connected) {\n return;\n }\n\n const purchaseUpdateSubscription = purchaseUpdatedListener(\n async (purchase: InAppPurchase | SubscriptionPurchase) => {\n setCurrentPurchaseError(undefined);\n setCurrentPurchase(purchase);\n },\n );\n\n const purchaseErrorSubscription = purchaseErrorListener(\n (error: PurchaseError) => {\n setCurrentPurchase(undefined);\n setCurrentPurchaseError(error);\n },\n );\n\n const promotedProductSubscription = promotedProductListener(async () => {\n const product = await getPromotedProductIOS();\n\n setPromotedProductsIOS((prevProducts) => [\n ...prevProducts,\n ...(product ? [product] : []),\n ]);\n });\n\n return () => {\n purchaseUpdateSubscription.remove();\n purchaseErrorSubscription.remove();\n promotedProductSubscription?.remove();\n };\n }, [connected]);\n\n return (\n <IAPContext.Provider value={context}>\n <Component {...props} />\n </IAPContext.Provider>\n );\n };\n}\n"],"mappings":"AAAA,OAAOA,KAAP,IAAeC,UAAf,EAA2BC,SAA3B,EAAsCC,OAAtC,EAA+CC,QAA/C,QAA8D,OAA9D;AAEA,SACEC,qBADF,EAEEC,cAFF,EAGEC,uBAHF,EAIEC,qBAJF,EAKEC,uBALF,QAMO,QANP;AAoCA;AACA,MAAMC,UAAU,gBAAGV,KAAK,CAACW,aAAN,CAAoC,IAApC,CAAnB;AAEA,OAAO,SAASC,aAAT,GAAyC;EAC9C,MAAMC,GAAG,GAAGZ,UAAU,CAACS,UAAD,CAAtB;;EAEA,IAAI,CAACG,GAAL,EAAU;IACR,MAAM,IAAIC,KAAJ,CAAU,gDAAV,CAAN;EACD;;EAED,OAAOD,GAAP;AACD;AAED,OAAO,SAASE,cAAT,CAA2BC,SAA3B,EAA8D;EACnE,OAAO,SAASC,gBAAT,CAA0BC,KAA1B,EAAoC;IACzC,MAAM,CAACC,SAAD,EAAYC,YAAZ,IAA4BhB,QAAQ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AZ;MACD,CAJH,EAKGE,KALH,CAKSL,sBALT;IAMD,CAPQ,EAON,EAPM,CAAT;IASAlC,SAAS,CAAC,MAAM;MACd,IAAI,CAACiB,SAAL,EAAgB;QACd;MACD;;MAED,MAAMuB,0BAA0B,GAAGjC,uBAAuB,CACxD,MAAOkC,QAAP,IAA0D;QACxDT,uBAAuB,CAACM,SAAD,CAAvB;QACAR,kBAAkB,CAACW,QAAD,CAAlB;MACD,CAJuD,CAA1D;MAOA,MAAMC,yBAAyB,GAAGpC,qBAAqB,CACpDqC,KAAD,IAA0B;QACxBb,kBAAkB,CAACQ,SAAD,CAAlB;QACAN,uBAAuB,CAACW,KAAD,CAAvB;MACD,CAJoD,CAAvD;MAOA,MAAMC,2BAA2B,GAAGvC,uBAAuB,CAAC,YAAY;QACtE,MAAMwC,OAAO,GAAG,MAAM1C,qBAAqB,EAA3C;QAEAmB,sBAAsB,CAAEwB,YAAD,IAAkB,CACvC,GAAGA,YADoC,EAEvC,IAAID,OAAO,GAAG,CAACA,OAAD,CAAH,GAAe,EAA1B,CAFuC,CAAnB,CAAtB;MAID,CAP0D,CAA3D;MASA,OAAO,MAAM;QACXL,0BAA0B,CAACO,MAA3B;QACAL,yBAAyB,CAACK,MAA1B;QACAH,2BAA2B,SAA3B,IAAAA,2BAA2B,WAA3B,YAAAA,2BAA2B,CAAEG,MAA7B;MACD,CAJD;IAKD,CAjCQ,EAiCN,CAAC9B,SAAD,CAjCM,CAAT;IAmCA,oBACE,oBAAC,UAAD,CAAY,QAAZ;MAAqB,KAAK,EAAEkB;IAA5B,gBACE,oBAAC,SAAD,EAAenB,KAAf,CADF,CADF;EAKD,CA1GD;AA2GD"}
package/lib/module/iap.js CHANGED
@@ -7,6 +7,7 @@ const {
7
7
  RNIapAmazonModule
8
8
  } = NativeModules;
9
9
  const isAndroid = Platform.OS === 'android';
10
+ const isIos = Platform.OS === 'ios';
10
11
  const ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';
11
12
  const ANDROID_ITEM_TYPE_IAP = 'inapp';
12
13
  export const getInstallSourceAndroid = () => {
@@ -471,7 +472,13 @@ export const purchaseErrorListener = listener => new NativeEventEmitter(getNativ
471
472
  * Only available on iOS
472
473
  */
473
474
 
474
- export const promotedProductListener = listener => new NativeEventEmitter(getIosModule()).addListener('iap-promoted-product', listener);
475
+ export const promotedProductListener = listener => {
476
+ if (isIos) {
477
+ return new NativeEventEmitter(getIosModule()).addListener('iap-promoted-product', listener);
478
+ }
479
+
480
+ return null;
481
+ };
475
482
  /**
476
483
  * Get the current receipt base64 encoded in IOS.
477
484
  * @param {forceRefresh?:boolean}
@@ -1 +1 @@
1
- {"version":3,"names":["Linking","NativeEventEmitter","NativeModules","Platform","ReceiptValidationStatus","IAPErrorCode","InstallSourceAndroid","PurchaseStateAndroid","RNIapIos","RNIapModule","RNIapAmazonModule","isAndroid","OS","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","getInstallSourceAndroid","GOOGLE_PLAY","AMAZON","checkNativeAndroidAvailable","Error","E_IAP_NOT_AVAILABLE","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","fillProductsAdditionalData","products","user","getUser","currencies","CA","ES","AU","DE","IN","US","JP","GB","IT","BR","FR","currency","userMarketplaceAmazon","forEach","product","getProducts","skus","select","ios","items","getItems","filter","item","includes","productId","type","android","getItemsByType","Promise","resolve","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","applicationUsername","console","warn","buyProduct","buyItemByType","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","consumeProduct","purchaseToken","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","fetchJsonOrThrow","url","receiptBody","response","fetch","method","headers","Accept","body","JSON","stringify","ok","Object","assign","statusText","statusCode","status","json","requestAgnosticReceiptValidationIos","TEST_RECEIPT","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","purchaseUpdatedListener","listener","emitterSubscription","addListener","startListening","purchaseErrorListener","promotedProductListener","getPendingPurchasesIOS","getPendingTransactions","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {\n EmitterSubscription,\n Linking,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} from 'react-native';\n\nimport type * as Amazon from './types/amazon';\nimport type * as Android from './types/android';\nimport type * as Apple from './types/apple';\nimport {ReceiptValidationStatus} from './types/apple';\nimport type {\n InAppPurchase,\n Product,\n ProductCommon,\n ProductPurchase,\n PurchaseError,\n PurchaseResult,\n RequestPurchase,\n RequestSubscription,\n Subscription,\n SubscriptionPurchase,\n} from './types';\nimport {\n IAPErrorCode,\n InstallSourceAndroid,\n PurchaseStateAndroid,\n} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst isAndroid = Platform.OS === 'android';\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getAndroidModule = (): typeof RNIapModule | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return RNIapModule ? RNIapModule : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nconst getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n if (isAndroid) {\n return getAndroidModule();\n }\n\n return getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<void> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid = (): Promise<\n string[]\n> => getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Fill products with additional data\n * @param {Array<ProductCommon>} products Products\n */\nconst fillProductsAdditionalData = async (\n products: Array<ProductCommon>,\n): Promise<Array<ProductCommon>> => {\n // Amazon\n if (RNIapAmazonModule) {\n // On amazon we must get the user marketplace to detect the currency\n const user = await RNIapAmazonModule.getUser();\n\n const currencies = {\n CA: 'CAD',\n ES: 'EUR',\n AU: 'AUD',\n DE: 'EUR',\n IN: 'INR',\n US: 'USD',\n JP: 'JPY',\n GB: 'GBP',\n IT: 'EUR',\n BR: 'BRL',\n FR: 'EUR',\n };\n\n const currency =\n currencies[user.userMarketplaceAmazon as keyof typeof currencies];\n\n // Add currency to products\n products.forEach((product) => {\n if (currency) {\n product.currency = currency;\n }\n });\n }\n\n return products;\n};\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n * @param {string[]} skus The item skus\n * @returns {Promise<Product[]>}\n */\nexport const getProducts = (skus: string[]): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Product) =>\n skus.includes(item.productId) && item.type === 'iap',\n );\n },\n android: async () => {\n const products = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n skus,\n );\n\n return fillProductsAdditionalData(products);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get a list of subscriptions\n * @param {string[]} skus The item skus\n * @returns {Promise<Subscription[]>}\n */\nexport const getSubscriptions = (skus: string[]): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Subscription) =>\n skus.includes(item.productId) && item.type === 'subs',\n );\n },\n android: async () => {\n const subscriptions = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n );\n\n return fillProductsAdditionalData(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * @returns {Promise<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (InAppPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)\n * @returns {Promise<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (InAppPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @returns {Promise<InAppPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestPurchase): Promise<InAppPurchase> =>\n (\n Platform.select({\n ios: async () => {\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n sku,\n null,\n 0,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n );\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestSubscription): Promise<SubscriptionPurchase | null> =>\n (\n Platform.select({\n ios: async () => {\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n sku,\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n );\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = (\n sku: string,\n quantity: number,\n): Promise<InAppPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\n\n/**\n * Finish Transaction (both platforms)\n * Abstracts Finish Transaction\n * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.\n * Call this after you have persisted the purchased state to your server or local data in your app.\n * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**\n * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.\n * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = (\n purchase: InAppPurchase | ProductPurchase,\n isConsumable?: boolean,\n developerPayloadAndroid?: string,\n): Promise<string | void> => {\n return (\n Platform.select({\n ios: async () => {\n return getIosModule().finishTransaction(purchase.transactionId);\n },\n android: async () => {\n if (purchase) {\n if (isConsumable) {\n return getAndroidModule().consumeProduct(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else if (\n purchase.userIdAmazon ||\n (!purchase.isAcknowledgedAndroid &&\n purchase.purchaseStateAndroid === PurchaseStateAndroid.PURCHASED)\n ) {\n return getAndroidModule().acknowledgePurchase(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else {\n throw new Error('purchase is not suitable to be purchased');\n }\n } else {\n throw new Error('purchase is not assigned');\n }\n },\n }) || Promise.resolve\n )();\n};\n\n/**\n * Clear Transaction (iOS only)\n * Finish remaining transactions. Related to issue #257 and #801\n * link : https://github.com/dooboolab/react-native-iap/issues/257\n * https://github.com/dooboolab/react-native-iap/issues/801\n * @returns {Promise<void>}\n */\nexport const clearTransactionIOS = (): Promise<void> =>\n getIosModule().clearTransaction();\n\n/**\n * Clear valid Products (iOS only)\n * Remove all products which are validated by Apple server.\n * @returns {void}\n */\nexport const clearProductsIOS = (): Promise<void> =>\n getIosModule().clearProducts();\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = (\n token: string,\n developerPayload?: string,\n): Promise<PurchaseResult | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async (\n sku: string,\n): Promise<void> => {\n checkNativeAndroidAvailable();\n\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\n\n/**\n * Buy the currently selected promoted product (iOS only)\n * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.\n * @returns {Promise<void>}\n */\nexport const buyPromotedProductIOS = (): Promise<void> =>\n getIosModule().buyPromotedProduct();\n\nconst fetchJsonOrThrow = async (\n url: string,\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(receiptBody),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetchJsonOrThrow(\n 'https://buy.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === ReceiptValidationStatus.TEST_RECEIPT) {\n const testResponse = await fetchJsonOrThrow(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = (\n sku: string,\n forUser: string,\n withOffer: Apple.PaymentDiscount,\n): Promise<void> => getIosModule().buyProductWithOffer(sku, forUser, withOffer);\n\n/**\n * Validate receipt for iOS.\n * @param {object} receiptBody the receipt body to send to apple server.\n * @param {boolean} isTest whether this is in test environment which is sandbox.\n * @returns {Promise<Apple.ReceiptValidationResponse | false>}\n */\nexport const validateReceiptIos = async (\n receiptBody: Record<string, unknown>,\n isTest?: boolean,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n const response = await fetchJsonOrThrow(url, receiptBody);\n\n return response;\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} packageName package name of your app.\n * @param {string} productId product id for your in app product.\n * @param {string} productToken token for your purchase.\n * @param {string} accessToken accessToken from googleApis.\n * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAndroid = async (\n packageName: string,\n productId: string,\n productToken: string,\n accessToken: string,\n isSub?: boolean,\n): Promise<Android.ReceiptType> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}?access_token=${accessToken}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including\n * your developer secret in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} developerSecret: from the Amazon developer console.\n * @param {string} userId who purchased the item.\n * @param {string} receiptId long obfuscated string returned when purchasing the item\n * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAmazon = async (\n developerSecret: string,\n userId: string,\n receiptId: string,\n useSandbox: boolean = true,\n): Promise<Amazon.ReceiptType> => {\n const sandBoxUrl = useSandbox ? 'sandbox/' : '';\n const url = `https://appstore-sdk.amazon.com/${sandBoxUrl}version/1.0/verifyReceiptId/developer/${developerSecret}/user/${userId}/receiptId/${receiptId}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Add IAP purchase event\n * @returns {callback(e: InAppPurchase | ProductPurchase)}\n */\nexport const purchaseUpdatedListener = (\n listener: (event: InAppPurchase | SubscriptionPurchase) => void,\n): EmitterSubscription => {\n const emitterSubscription = new NativeEventEmitter(\n getNativeModule(),\n ).addListener('purchase-updated', listener);\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n * @returns {callback(e: PurchaseError)}\n */\nexport const purchaseErrorListener = (\n listener: (errorEvent: PurchaseError) => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getNativeModule()).addListener(\n 'purchase-error',\n listener,\n );\n\n/**\n * Add IAP promoted subscription event\n * Only available on iOS\n */\nexport const promotedProductListener = (\n listener: () => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getIosModule()).addListener(\n 'iap-promoted-product',\n listener,\n );\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":"AAAA,SAEEA,OAFF,EAGEC,kBAHF,EAIEC,aAJF,EAKEC,QALF,QAMO,cANP;AAWA,SAAQC,uBAAR,QAAsC,eAAtC;AAaA,SACEC,YADF,EAEEC,oBAFF,EAGEC,oBAHF,QAIO,SAJP;AAMA,MAAM;EAACC,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CR,aAAnD;AACA,MAAMS,SAAS,GAAGR,QAAQ,CAACS,EAAT,KAAgB,SAAlC;AACA,MAAM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","NativeModules","Platform","ReceiptValidationStatus","IAPErrorCode","InstallSourceAndroid","PurchaseStateAndroid","RNIapIos","RNIapModule","RNIapAmazonModule","isAndroid","OS","isIos","ANDROID_ITEM_TYPE_SUBSCRIPTION","ANDROID_ITEM_TYPE_IAP","getInstallSourceAndroid","GOOGLE_PLAY","AMAZON","checkNativeAndroidAvailable","Error","E_IAP_NOT_AVAILABLE","getAndroidModule","checkNativeIOSAvailable","getIosModule","getNativeModule","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","fillProductsAdditionalData","products","user","getUser","currencies","CA","ES","AU","DE","IN","US","JP","GB","IT","BR","FR","currency","userMarketplaceAmazon","forEach","product","getProducts","skus","select","ios","items","getItems","filter","item","includes","productId","type","android","getItemsByType","Promise","resolve","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","applicationUsername","console","warn","buyProduct","buyItemByType","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","requestPurchaseWithQuantityIOS","quantity","buyProductWithQuantityIOS","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","consumeProduct","purchaseToken","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PURCHASED","acknowledgePurchase","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts","acknowledgePurchaseAndroid","token","developerPayload","deepLinkToSubscriptionsAndroid","openURL","getPackageName","getPromotedProductIOS","promotedProduct","buyPromotedProductIOS","buyPromotedProduct","fetchJsonOrThrow","url","receiptBody","response","fetch","method","headers","Accept","body","JSON","stringify","ok","Object","assign","statusText","statusCode","status","json","requestAgnosticReceiptValidationIos","TEST_RECEIPT","testResponse","requestPurchaseWithOfferIOS","forUser","withOffer","buyProductWithOffer","validateReceiptIos","isTest","validateReceiptAndroid","packageName","productToken","accessToken","isSub","validateReceiptAmazon","developerSecret","userId","receiptId","useSandbox","sandBoxUrl","purchaseUpdatedListener","listener","emitterSubscription","addListener","startListening","purchaseErrorListener","promotedProductListener","getPendingPurchasesIOS","getPendingTransactions","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet"],"sources":["iap.ts"],"sourcesContent":["import {\n EmitterSubscription,\n Linking,\n NativeEventEmitter,\n NativeModules,\n Platform,\n} from 'react-native';\n\nimport type * as Amazon from './types/amazon';\nimport type * as Android from './types/android';\nimport type * as Apple from './types/apple';\nimport {ReceiptValidationStatus} from './types/apple';\nimport type {\n InAppPurchase,\n Product,\n ProductCommon,\n ProductPurchase,\n PurchaseError,\n PurchaseResult,\n RequestPurchase,\n RequestSubscription,\n Subscription,\n SubscriptionPurchase,\n} from './types';\nimport {\n IAPErrorCode,\n InstallSourceAndroid,\n PurchaseStateAndroid,\n} from './types';\n\nconst {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst isAndroid = Platform.OS === 'android';\nconst isIos = Platform.OS === 'ios';\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';\nconst ANDROID_ITEM_TYPE_IAP = 'inapp';\n\nexport const getInstallSourceAndroid = (): InstallSourceAndroid => {\n return RNIapModule\n ? InstallSourceAndroid.GOOGLE_PLAY\n : InstallSourceAndroid.AMAZON;\n};\n\nconst checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getAndroidModule = (): typeof RNIapModule | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return RNIapModule ? RNIapModule : RNIapAmazonModule;\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos) {\n throw new Error(IAPErrorCode.E_IAP_NOT_AVAILABLE);\n }\n};\n\nconst getIosModule = (): typeof RNIapIos => {\n checkNativeIOSAvailable();\n\n return RNIapIos;\n};\n\nconst getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos => {\n if (isAndroid) {\n return getAndroidModule();\n }\n\n return getIosModule();\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * @returns {Promise<boolean>}\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * End module for purchase flow.\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<void> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid = (): Promise<\n string[]\n> => getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Fill products with additional data\n * @param {Array<ProductCommon>} products Products\n */\nconst fillProductsAdditionalData = async (\n products: Array<ProductCommon>,\n): Promise<Array<ProductCommon>> => {\n // Amazon\n if (RNIapAmazonModule) {\n // On amazon we must get the user marketplace to detect the currency\n const user = await RNIapAmazonModule.getUser();\n\n const currencies = {\n CA: 'CAD',\n ES: 'EUR',\n AU: 'AUD',\n DE: 'EUR',\n IN: 'INR',\n US: 'USD',\n JP: 'JPY',\n GB: 'GBP',\n IT: 'EUR',\n BR: 'BRL',\n FR: 'EUR',\n };\n\n const currency =\n currencies[user.userMarketplaceAmazon as keyof typeof currencies];\n\n // Add currency to products\n products.forEach((product) => {\n if (currency) {\n product.currency = currency;\n }\n });\n }\n\n return products;\n};\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n * @param {string[]} skus The item skus\n * @returns {Promise<Product[]>}\n */\nexport const getProducts = (skus: string[]): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Product) =>\n skus.includes(item.productId) && item.type === 'iap',\n );\n },\n android: async () => {\n const products = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n skus,\n );\n\n return fillProductsAdditionalData(products);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get a list of subscriptions\n * @param {string[]} skus The item skus\n * @returns {Promise<Subscription[]>}\n */\nexport const getSubscriptions = (skus: string[]): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n const items = await getIosModule().getItems(skus);\n\n return items.filter(\n (item: Subscription) =>\n skus.includes(item.productId) && item.type === 'subs',\n );\n },\n android: async () => {\n const subscriptions = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n );\n\n return fillProductsAdditionalData(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * @returns {Promise<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getPurchaseHistory = (): Promise<\n (InAppPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)\n * @returns {Promise<(InAppPurchase | SubscriptionPurchase)[]>}\n */\nexport const getAvailablePurchases = (): Promise<\n (InAppPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await getAndroidModule().getAvailableItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @returns {Promise<InAppPurchase>}\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestPurchase): Promise<InAppPurchase> =>\n (\n Platform.select({\n ios: async () => {\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n sku,\n null,\n 0,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n );\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} [sku] The product's sku/ID\n * @param {string} [applicationUsername] The purchaser's user ID\n * @param {boolean} [andDangerouslyFinishTransactionAutomaticallyIOS] You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.\n * @param {string} [purchaseTokenAndroid] purchaseToken that the user is upgrading or downgrading from (Android).\n * @param {ProrationModesAndroid} [prorationModeAndroid] UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED\n * @param {string} [obfuscatedAccountIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's account in your app.\n * @param {string} [obfuscatedProfileIdAndroid] Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app.\n * @returns {Promise<SubscriptionPurchase | null>} Promise resolves to null when using proratioModesAndroid=DEFERRED, and to a SubscriptionPurchase otherwise\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n applicationUsername,\n}: RequestSubscription): Promise<SubscriptionPurchase | null> =>\n (\n Platform.select({\n ios: async () => {\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n return getIosModule().buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n applicationUsername,\n );\n },\n android: async () => {\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n sku,\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n );\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * @param {string} sku The product's sku/ID\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithQuantityIOS = (\n sku: string,\n quantity: number,\n): Promise<InAppPurchase> =>\n getIosModule().buyProductWithQuantityIOS(sku, quantity);\n\n/**\n * Finish Transaction (both platforms)\n * Abstracts Finish Transaction\n * iOS: Tells StoreKit that you have delivered the purchase to the user and StoreKit can now let go of the transaction.\n * Call this after you have persisted the purchased state to your server or local data in your app.\n * `react-native-iap` will continue to deliver the purchase updated events with the successful purchase until you finish the transaction. **Even after the app has relaunched.**\n * Android: it will consume purchase for consumables and acknowledge purchase for non-consumables.\n * @param {object} purchase The purchase that you would like to finish.\n * @param {boolean} isConsumable Checks if purchase is consumable. Has effect on `android`.\n * @param {string} developerPayloadAndroid Android developerPayload.\n * @returns {Promise<string | void> }\n */\nexport const finishTransaction = (\n purchase: InAppPurchase | ProductPurchase,\n isConsumable?: boolean,\n developerPayloadAndroid?: string,\n): Promise<string | void> => {\n return (\n Platform.select({\n ios: async () => {\n return getIosModule().finishTransaction(purchase.transactionId);\n },\n android: async () => {\n if (purchase) {\n if (isConsumable) {\n return getAndroidModule().consumeProduct(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else if (\n purchase.userIdAmazon ||\n (!purchase.isAcknowledgedAndroid &&\n purchase.purchaseStateAndroid === PurchaseStateAndroid.PURCHASED)\n ) {\n return getAndroidModule().acknowledgePurchase(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else {\n throw new Error('purchase is not suitable to be purchased');\n }\n } else {\n throw new Error('purchase is not assigned');\n }\n },\n }) || Promise.resolve\n )();\n};\n\n/**\n * Clear Transaction (iOS only)\n * Finish remaining transactions. Related to issue #257 and #801\n * link : https://github.com/dooboolab/react-native-iap/issues/257\n * https://github.com/dooboolab/react-native-iap/issues/801\n * @returns {Promise<void>}\n */\nexport const clearTransactionIOS = (): Promise<void> =>\n getIosModule().clearTransaction();\n\n/**\n * Clear valid Products (iOS only)\n * Remove all products which are validated by Apple server.\n * @returns {void}\n */\nexport const clearProductsIOS = (): Promise<void> =>\n getIosModule().clearProducts();\n\n/**\n * Acknowledge a product (on Android.) No-op on iOS.\n * @param {string} token The product's token (on Android)\n * @returns {Promise<PurchaseResult | void>}\n */\nexport const acknowledgePurchaseAndroid = (\n token: string,\n developerPayload?: string,\n): Promise<PurchaseResult | void> => {\n return getAndroidModule().acknowledgePurchase(token, developerPayload);\n};\n\n/**\n * Deep link to subscriptions screen on Android. No-op on iOS.\n * @param {string} sku The product's SKU (on Android)\n * @returns {Promise<void>}\n */\nexport const deepLinkToSubscriptionsAndroid = async (\n sku: string,\n): Promise<void> => {\n checkNativeAndroidAvailable();\n\n return Linking.openURL(\n `https://play.google.com/store/account/subscriptions?package=${await RNIapModule.getPackageName()}&sku=${sku}`,\n );\n};\n\n/**\n * Should Add Store Payment (iOS only)\n * Indicates the the App Store purchase should continue from the app instead of the App Store.\n * @returns {Promise<Product | null>} promoted product\n */\nexport const getPromotedProductIOS = (): Promise<Product | null> =>\n getIosModule().promotedProduct();\n\n/**\n * Buy the currently selected promoted product (iOS only)\n * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.\n * @returns {Promise<void>}\n */\nexport const buyPromotedProductIOS = (): Promise<void> =>\n getIosModule().buyPromotedProduct();\n\nconst fetchJsonOrThrow = async (\n url: string,\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetch(url, {\n method: 'POST',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify(receiptBody),\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n const response = await fetchJsonOrThrow(\n 'https://buy.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === ReceiptValidationStatus.TEST_RECEIPT) {\n const testResponse = await fetchJsonOrThrow(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n receiptBody,\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Buy products or subscriptions with offers (iOS only)\n *\n * Runs the payment process with some info you must fetch\n * from your server.\n * @param {string} sku The product identifier\n * @param {string} forUser An user identifier on you system\n * @param {Apple.PaymentDiscount} withOffer The offer information\n * @param {string} withOffer.identifier The offer identifier\n * @param {string} withOffer.keyIdentifier Key identifier that it uses to generate the signature\n * @param {string} withOffer.nonce An UUID returned from the server\n * @param {string} withOffer.signature The actual signature returned from the server\n * @param {number} withOffer.timestamp The timestamp of the signature\n * @returns {Promise<void>}\n */\nexport const requestPurchaseWithOfferIOS = (\n sku: string,\n forUser: string,\n withOffer: Apple.PaymentDiscount,\n): Promise<void> => getIosModule().buyProductWithOffer(sku, forUser, withOffer);\n\n/**\n * Validate receipt for iOS.\n * @param {object} receiptBody the receipt body to send to apple server.\n * @param {boolean} isTest whether this is in test environment which is sandbox.\n * @returns {Promise<Apple.ReceiptValidationResponse | false>}\n */\nexport const validateReceiptIos = async (\n receiptBody: Record<string, unknown>,\n isTest?: boolean,\n): Promise<Apple.ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n const response = await fetchJsonOrThrow(url, receiptBody);\n\n return response;\n};\n\n/**\n * Validate receipt for Android. NOTE: This method is here for debugging purposes only. Including\n * your access token in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} packageName package name of your app.\n * @param {string} productId product id for your in app product.\n * @param {string} productToken token for your purchase.\n * @param {string} accessToken accessToken from googleApis.\n * @param {boolean} isSub whether this is subscription or inapp. `true` for subscription.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAndroid = async (\n packageName: string,\n productId: string,\n productToken: string,\n accessToken: string,\n isSub?: boolean,\n): Promise<Android.ReceiptType> => {\n const type = isSub ? 'subscriptions' : 'products';\n\n const url =\n 'https://androidpublisher.googleapis.com/androidpublisher/v3/applications' +\n `/${packageName}/purchases/${type}/${productId}` +\n `/tokens/${productToken}?access_token=${accessToken}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Validate receipt for Amazon. NOTE: This method is here for debugging purposes only. Including\n * your developer secret in the binary you ship to users is potentially dangerous.\n * Use server side validation instead for your production builds\n * @param {string} developerSecret: from the Amazon developer console.\n * @param {string} userId who purchased the item.\n * @param {string} receiptId long obfuscated string returned when purchasing the item\n * @param {boolean} useSandbox Defaults to true, use sandbox environment or production.\n * @returns {Promise<object>}\n */\nexport const validateReceiptAmazon = async (\n developerSecret: string,\n userId: string,\n receiptId: string,\n useSandbox: boolean = true,\n): Promise<Amazon.ReceiptType> => {\n const sandBoxUrl = useSandbox ? 'sandbox/' : '';\n const url = `https://appstore-sdk.amazon.com/${sandBoxUrl}version/1.0/verifyReceiptId/developer/${developerSecret}/user/${userId}/receiptId/${receiptId}`;\n\n const response = await fetch(url, {\n method: 'GET',\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n if (!response.ok) {\n throw Object.assign(new Error(response.statusText), {\n statusCode: response.status,\n });\n }\n\n return response.json();\n};\n\n/**\n * Add IAP purchase event\n * @returns {callback(e: InAppPurchase | ProductPurchase)}\n */\nexport const purchaseUpdatedListener = (\n listener: (event: InAppPurchase | SubscriptionPurchase) => void,\n): EmitterSubscription => {\n const emitterSubscription = new NativeEventEmitter(\n getNativeModule(),\n ).addListener('purchase-updated', listener);\n\n if (isAndroid) {\n getAndroidModule().startListening();\n }\n\n return emitterSubscription;\n};\n\n/**\n * Add IAP purchase error event\n * @returns {callback(e: PurchaseError)}\n */\nexport const purchaseErrorListener = (\n listener: (errorEvent: PurchaseError) => void,\n): EmitterSubscription =>\n new NativeEventEmitter(getNativeModule()).addListener(\n 'purchase-error',\n listener,\n );\n\n/**\n * Add IAP promoted subscription event\n * Only available on iOS\n */\nexport const promotedProductListener = (\n listener: () => void,\n): EmitterSubscription | null => {\n if (isIos) {\n return new NativeEventEmitter(getIosModule()).addListener(\n 'iap-promoted-product',\n listener,\n );\n }\n return null;\n};\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n"],"mappings":"AAAA,SAEEA,OAFF,EAGEC,kBAHF,EAIEC,aAJF,EAKEC,QALF,QAMO,cANP;AAWA,SAAQC,uBAAR,QAAsC,eAAtC;AAaA,SACEC,YADF,EAEEC,oBAFF,EAGEC,oBAHF,QAIO,SAJP;AAMA,MAAM;EAACC,QAAD;EAAWC,WAAX;EAAwBC;AAAxB,IAA6CR,aAAnD;AACA,MAAMS,SAAS,GAAGR,QAAQ,CAACS,EAAT,KAAgB,SAAlC;AACA,MAAMC,KAAK,GAAGV,QAAQ,CAACS,EAAT,KAAgB,KAA9B;AACA,MAAME,8BAA8B,GAAG,MAAvC;AACA,MAAMC,qBAAqB,GAAG,OAA9B;AAEA,OAAO,MAAMC,uBAAuB,GAAG,MAA4B;EACjE,OAAOP,WAAW,GACdH,oBAAoB,CAACW,WADP,GAEdX,oBAAoB,CAACY,MAFzB;AAGD,CAJM;;AAMP,MAAMC,2BAA2B,GAAG,MAAY;EAC9C,IAAI,CAACV,WAAD,IAAgB,CAACC,iBAArB,EAAwC;IACtC,MAAM,IAAIU,KAAJ,CAAUf,YAAY,CAACgB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AU,EAAEZ,QAAQ,CAACa;IAD6B,CAA9C,CAAN;EAGD;;EAED,OAAOb,QAAQ,CAACc,IAAT,EAAP;AACD,CAvBM;AAyBP;AACA;AACA;AACA;;AACA,OAAO,MAAMqB,uBAAuB,GAClCC,QADqC,IAEb;EACxB,MAAMC,mBAAmB,GAAG,IAAI1J,kBAAJ,CAC1BwB,eAAe,EADW,EAE1BmI,WAF0B,CAEd,kBAFc,EAEMF,QAFN,CAA5B;;EAIA,IAAI/I,SAAJ,EAAe;IACbW,gBAAgB,GAAGuI,cAAnB;EACD;;EAED,OAAOF,mBAAP;AACD,CAZM;AAcP;AACA;AACA;AACA;;AACA,OAAO,MAAMG,qBAAqB,GAChCJ,QADmC,IAGnC,IAAIzJ,kBAAJ,CAAuBwB,eAAe,EAAtC,EAA0CmI,WAA1C,CACE,gBADF,EAEEF,QAFF,CAHK;AAQP;AACA;AACA;AACA;;AACA,OAAO,MAAMK,uBAAuB,GAClCL,QADqC,IAEN;EAC/B,IAAI7I,KAAJ,EAAW;IACT,OAAO,IAAIZ,kBAAJ,CAAuBuB,YAAY,EAAnC,EAAuCoI,WAAvC,CACL,sBADK,EAELF,QAFK,CAAP;EAID;;EACD,OAAO,IAAP;AACD,CAVM;AAYP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMM,sBAAsB,GAAG,YACpCxI,YAAY,GAAGyI,sBAAf,EADK;AAGP;AACA;AACA;AACA;;AACA,OAAO,MAAMC,6BAA6B,GAAG,YAC3C1I,YAAY,GAAG2I,0BAAf,EADK"}
@@ -1 +1 @@
1
- {"version":3,"names":["IAPErrorCode","ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid"],"sources":["index.ts"],"sourcesContent":["type Sku = string;\n\nexport enum IAPErrorCode {\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n}\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string;\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n //Android\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n //Amazon\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n isCanceledAmazon?: boolean;\n}\n\nexport interface PurchaseResult {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n}\n\nexport interface PurchaseError {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n productId?: string;\n}\n\nexport type InAppPurchase = ProductPurchase;\n\nexport interface SubscriptionPurchase extends ProductPurchase {\n autoRenewingAndroid?: boolean;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n}\n\nexport type Purchase = InAppPurchase | SubscriptionPurchase;\n\nexport interface Discount {\n identifier: string;\n type: string;\n numberOfPeriods: string;\n price: string;\n localizedPrice: string;\n paymentMode: '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';\n subscriptionPeriod: string;\n}\n\nexport interface Product extends ProductCommon {\n type: 'inapp' | 'iap';\n}\n\nexport interface Subscription extends ProductCommon {\n type: 'subs' | 'sub';\n\n discounts?: Discount[];\n\n introductoryPrice?: string;\n introductoryPriceAsAmountIOS?: string;\n introductoryPricePaymentModeIOS?:\n | ''\n | 'FREETRIAL'\n | 'PAYASYOUGO'\n | 'PAYUPFRONT';\n introductoryPriceNumberOfPeriodsIOS?: string;\n introductoryPriceSubscriptionPeriodIOS?:\n | 'DAY'\n | 'WEEK'\n | 'MONTH'\n | 'YEAR'\n | '';\n\n subscriptionPeriodNumberIOS?: string;\n subscriptionPeriodUnitIOS?: '' | 'YEAR' | 'MONTH' | 'WEEK' | 'DAY';\n\n introductoryPriceAsAmountAndroid: string;\n introductoryPriceCyclesAndroid?: string;\n introductoryPricePeriodAndroid?: string;\n subscriptionPeriodAndroid?: string;\n freeTrialPeriodAndroid?: string;\n}\n\ninterface RequestPurchaseCommon {\n sku: Sku;\n}\n\ninterface RequestPurchaseIOS extends RequestPurchaseCommon {\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: never;\n obfuscatedProfileIdAndroid?: never;\n selectedOfferIndex?: never;\n}\n\ninterface RequestPurchaseAndroid extends RequestPurchaseCommon {\n andDangerouslyFinishTransactionAutomaticallyIOS?: never;\n applicationUsername?: never;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n selectedOfferIndex: number;\n}\n\nexport type RequestPurchase = RequestPurchaseIOS | RequestPurchaseAndroid;\n\ninterface RequestSubscriptionIOS extends RequestPurchaseIOS {\n purchaseTokenAndroid?: never;\n prorationModeAndroid?: never;\n}\n\ninterface RequestSubscriptionAndroid extends RequestPurchaseAndroid {\n purchaseTokenAndroid?: string;\n prorationModeAndroid: ProrationModesAndroid;\n}\n\nexport type RequestSubscription =\n | RequestSubscriptionIOS\n | RequestSubscriptionAndroid;\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":["type Sku = string;\n\nexport enum IAPErrorCode {\n E_IAP_NOT_AVAILABLE = 'E_IAP_NOT_AVAILABLE',\n E_UNKNOWN = 'E_UNKNOWN',\n E_USER_CANCELLED = 'E_USER_CANCELLED',\n E_USER_ERROR = 'E_USER_ERROR',\n E_ITEM_UNAVAILABLE = 'E_ITEM_UNAVAILABLE',\n E_REMOTE_ERROR = 'E_REMOTE_ERROR',\n E_NETWORK_ERROR = 'E_NETWORK_ERROR',\n E_SERVICE_ERROR = 'E_SERVICE_ERROR',\n E_RECEIPT_FAILED = 'E_RECEIPT_FAILED',\n E_RECEIPT_FINISHED_FAILED = 'E_RECEIPT_FINISHED_FAILED',\n E_NOT_PREPARED = 'E_NOT_PREPARED',\n E_NOT_ENDED = 'E_NOT_ENDED',\n E_ALREADY_OWNED = 'E_ALREADY_OWNED',\n E_DEVELOPER_ERROR = 'E_DEVELOPER_ERROR',\n E_BILLING_RESPONSE_JSON_PARSE_ERROR = 'E_BILLING_RESPONSE_JSON_PARSE_ERROR',\n E_DEFERRED_PAYMENT = 'E_DEFERRED_PAYMENT',\n}\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string;\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n //Android\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n //Amazon\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n isCanceledAmazon?: boolean;\n}\n\nexport interface PurchaseResult {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n}\n\nexport interface PurchaseError {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n productId?: string;\n}\n\nexport type InAppPurchase = ProductPurchase;\n\nexport interface SubscriptionPurchase extends ProductPurchase {\n autoRenewingAndroid?: boolean;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n}\n\nexport type Purchase = InAppPurchase | SubscriptionPurchase;\n\nexport interface Discount {\n identifier: string;\n type: string;\n numberOfPeriods: string;\n price: string;\n localizedPrice: string;\n paymentMode: '' | 'FREETRIAL' | 'PAYASYOUGO' | 'PAYUPFRONT';\n subscriptionPeriod: string;\n}\n\nexport interface Product extends ProductCommon {\n type: 'inapp' | 'iap';\n}\n\nexport interface Subscription extends ProductCommon {\n type: 'subs' | 'sub';\n\n discounts?: Discount[];\n\n introductoryPrice?: string;\n introductoryPriceAsAmountIOS?: string;\n introductoryPricePaymentModeIOS?:\n | ''\n | 'FREETRIAL'\n | 'PAYASYOUGO'\n | 'PAYUPFRONT';\n introductoryPriceNumberOfPeriodsIOS?: string;\n introductoryPriceSubscriptionPeriodIOS?:\n | 'DAY'\n | 'WEEK'\n | 'MONTH'\n | 'YEAR'\n | '';\n\n subscriptionPeriodNumberIOS?: string;\n subscriptionPeriodUnitIOS?: '' | 'YEAR' | 'MONTH' | 'WEEK' | 'DAY';\n\n introductoryPriceAsAmountAndroid: string;\n introductoryPriceCyclesAndroid?: string;\n introductoryPricePeriodAndroid?: string;\n subscriptionPeriodAndroid?: string;\n freeTrialPeriodAndroid?: string;\n}\n\nexport interface RequestPurchase {\n sku: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean;\n applicationUsername?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n selectedOfferIndex: number;\n}\n\nexport interface RequestSubscription extends RequestPurchase {\n purchaseTokenAndroid?: string;\n prorationModeAndroid: ProrationModesAndroid;\n}\n"],"mappings":"AAEA,WAAYA,YAAZ;;WAAYA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;EAAAA,Y;GAAAA,Y,KAAAA,Y;;AAmBZ,WAAYC,qBAAZ;;WAAYA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,KAAAA,qB;;AAQZ,WAAYC,oBAAZ;;WAAYA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,KAAAA,oB;;AAMZ,OAAO,MAAMC,gBAAgB,GAAG,sBAAzB;AAEP,WAAYC,oBAAZ;;WAAYA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,KAAAA,oB"}
@@ -181,7 +181,7 @@ export declare const purchaseErrorListener: (listener: (errorEvent: PurchaseErro
181
181
  * Add IAP promoted subscription event
182
182
  * Only available on iOS
183
183
  */
184
- export declare const promotedProductListener: (listener: () => void) => EmitterSubscription;
184
+ export declare const promotedProductListener: (listener: () => void) => EmitterSubscription | null;
185
185
  /**
186
186
  * Get the current receipt base64 encoded in IOS.
187
187
  * @param {forceRefresh?:boolean}
@@ -116,31 +116,16 @@ export interface Subscription extends ProductCommon {
116
116
  subscriptionPeriodAndroid?: string;
117
117
  freeTrialPeriodAndroid?: string;
118
118
  }
119
- interface RequestPurchaseCommon {
119
+ export interface RequestPurchase {
120
120
  sku: Sku;
121
- }
122
- interface RequestPurchaseIOS extends RequestPurchaseCommon {
123
121
  andDangerouslyFinishTransactionAutomaticallyIOS: boolean;
124
122
  applicationUsername?: string;
125
- obfuscatedAccountIdAndroid?: never;
126
- obfuscatedProfileIdAndroid?: never;
127
- selectedOfferIndex?: never;
128
- }
129
- interface RequestPurchaseAndroid extends RequestPurchaseCommon {
130
- andDangerouslyFinishTransactionAutomaticallyIOS?: never;
131
- applicationUsername?: never;
132
123
  obfuscatedAccountIdAndroid?: string;
133
124
  obfuscatedProfileIdAndroid?: string;
134
125
  selectedOfferIndex: number;
135
126
  }
136
- export declare type RequestPurchase = RequestPurchaseIOS | RequestPurchaseAndroid;
137
- interface RequestSubscriptionIOS extends RequestPurchaseIOS {
138
- purchaseTokenAndroid?: never;
139
- prorationModeAndroid?: never;
140
- }
141
- interface RequestSubscriptionAndroid extends RequestPurchaseAndroid {
127
+ export interface RequestSubscription extends RequestPurchase {
142
128
  purchaseTokenAndroid?: string;
143
129
  prorationModeAndroid: ProrationModesAndroid;
144
130
  }
145
- export declare type RequestSubscription = RequestSubscriptionIOS | RequestSubscriptionAndroid;
146
131
  export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-iap",
3
- "version": "8.6.0",
3
+ "version": "8.6.3",
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)",
@@ -147,7 +147,7 @@ export function withIAPContext<T>(Component: React.ComponentType<T>) {
147
147
  return () => {
148
148
  purchaseUpdateSubscription.remove();
149
149
  purchaseErrorSubscription.remove();
150
- promotedProductSubscription.remove();
150
+ promotedProductSubscription?.remove();
151
151
  };
152
152
  }, [connected]);
153
153
 
package/src/iap.ts CHANGED
@@ -30,6 +30,7 @@ import {
30
30
 
31
31
  const {RNIapIos, RNIapModule, RNIapAmazonModule} = NativeModules;
32
32
  const isAndroid = Platform.OS === 'android';
33
+ const isIos = Platform.OS === 'ios';
33
34
  const ANDROID_ITEM_TYPE_SUBSCRIPTION = 'subs';
34
35
  const ANDROID_ITEM_TYPE_IAP = 'inapp';
35
36
 
@@ -664,11 +665,15 @@ export const purchaseErrorListener = (
664
665
  */
665
666
  export const promotedProductListener = (
666
667
  listener: () => void,
667
- ): EmitterSubscription =>
668
- new NativeEventEmitter(getIosModule()).addListener(
669
- 'iap-promoted-product',
670
- listener,
671
- );
668
+ ): EmitterSubscription | null => {
669
+ if (isIos) {
670
+ return new NativeEventEmitter(getIosModule()).addListener(
671
+ 'iap-promoted-product',
672
+ listener,
673
+ );
674
+ }
675
+ return null;
676
+ };
672
677
 
673
678
  /**
674
679
  * Get the current receipt base64 encoded in IOS.
@@ -148,38 +148,16 @@ export interface Subscription extends ProductCommon {
148
148
  freeTrialPeriodAndroid?: string;
149
149
  }
150
150
 
151
- interface RequestPurchaseCommon {
151
+ export interface RequestPurchase {
152
152
  sku: Sku;
153
- }
154
-
155
- interface RequestPurchaseIOS extends RequestPurchaseCommon {
156
153
  andDangerouslyFinishTransactionAutomaticallyIOS: boolean;
157
154
  applicationUsername?: string;
158
- obfuscatedAccountIdAndroid?: never;
159
- obfuscatedProfileIdAndroid?: never;
160
- selectedOfferIndex?: never;
161
- }
162
-
163
- interface RequestPurchaseAndroid extends RequestPurchaseCommon {
164
- andDangerouslyFinishTransactionAutomaticallyIOS?: never;
165
- applicationUsername?: never;
166
155
  obfuscatedAccountIdAndroid?: string;
167
156
  obfuscatedProfileIdAndroid?: string;
168
157
  selectedOfferIndex: number;
169
158
  }
170
159
 
171
- export type RequestPurchase = RequestPurchaseIOS | RequestPurchaseAndroid;
172
-
173
- interface RequestSubscriptionIOS extends RequestPurchaseIOS {
174
- purchaseTokenAndroid?: never;
175
- prorationModeAndroid?: never;
176
- }
177
-
178
- interface RequestSubscriptionAndroid extends RequestPurchaseAndroid {
160
+ export interface RequestSubscription extends RequestPurchase {
179
161
  purchaseTokenAndroid?: string;
180
162
  prorationModeAndroid: ProrationModesAndroid;
181
163
  }
182
-
183
- export type RequestSubscription =
184
- | RequestSubscriptionIOS
185
- | RequestSubscriptionAndroid;