react-native-iap 11.0.0-rc.2 → 11.0.0-rc.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/IapSerializationUtils.swift +50 -11
- package/ios/IapTypes.swift +1 -6
- package/ios/RNIapIos.m +3 -0
- package/ios/RNIapIos.swift +12 -3
- package/ios/RNIapIosSk2.m +6 -1
- package/ios/RNIapIosSk2.swift +37 -16
- package/lib/commonjs/eventEmitter.js +145 -2
- package/lib/commonjs/eventEmitter.js.map +1 -1
- package/lib/commonjs/hooks/withIAPContext.js +8 -1
- package/lib/commonjs/hooks/withIAPContext.js.map +1 -1
- package/lib/commonjs/iap.js +81 -37
- package/lib/commonjs/iap.js.map +1 -1
- package/lib/commonjs/internal/platform.js +33 -4
- package/lib/commonjs/internal/platform.js.map +1 -1
- package/lib/commonjs/modules/ios.js +5 -2
- package/lib/commonjs/modules/ios.js.map +1 -1
- package/lib/commonjs/modules/iosSk2.js.map +1 -1
- package/lib/commonjs/types/apple.js +24 -0
- package/lib/commonjs/types/apple.js.map +1 -1
- package/lib/commonjs/types/appleSk2.js +3 -3
- package/lib/commonjs/types/appleSk2.js.map +1 -1
- package/lib/commonjs/types/index.js.map +1 -1
- package/lib/module/eventEmitter.js +141 -1
- package/lib/module/eventEmitter.js.map +1 -1
- package/lib/module/hooks/withIAPContext.js +9 -2
- package/lib/module/hooks/withIAPContext.js.map +1 -1
- package/lib/module/iap.js +77 -30
- package/lib/module/iap.js.map +1 -1
- package/lib/module/internal/platform.js +25 -2
- package/lib/module/internal/platform.js.map +1 -1
- package/lib/module/modules/ios.js +5 -2
- package/lib/module/modules/ios.js.map +1 -1
- package/lib/module/modules/iosSk2.js.map +1 -1
- package/lib/module/types/apple.js +15 -0
- package/lib/module/types/apple.js.map +1 -1
- package/lib/module/types/appleSk2.js +3 -3
- package/lib/module/types/appleSk2.js.map +1 -1
- package/lib/module/types/index.js.map +1 -1
- package/lib/typescript/eventEmitter.d.ts +133 -0
- package/lib/typescript/hooks/withIAPContext.d.ts +2 -0
- package/lib/typescript/iap.d.ts +25 -4
- package/lib/typescript/internal/platform.d.ts +3 -1
- package/lib/typescript/modules/ios.d.ts +2 -1
- package/lib/typescript/modules/iosSk2.d.ts +3 -2
- package/lib/typescript/types/apple.d.ts +1 -0
- package/lib/typescript/types/appleSk2.d.ts +31 -2
- package/lib/typescript/types/index.d.ts +1 -0
- package/package.json +1 -1
- package/src/eventEmitter.ts +144 -2
- package/src/hooks/withIAPContext.tsx +15 -0
- package/src/iap.ts +55 -17
- package/src/internal/platform.ts +24 -2
- package/src/modules/ios.ts +7 -3
- package/src/modules/iosSk2.ts +5 -2
- package/src/types/apple.ts +15 -0
- package/src/types/appleSk2.ts +42 -5
- package/src/types/index.ts +1 -0
package/lib/module/iap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","Platform","IapAmazon","IapAndroid","IapIos","IapIosSk2","offerSk2Map","productSk2Map","subscriptionSk2Map","enableStorekit2","fillProductsWithAdditionalData","getAndroidModule","getIosModule","getNativeModule","isAmazon","isIosStorekit2","ProductType","PurchaseStateAndroid","RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","ANDROID_ITEM_TYPE_SUBSCRIPTION","subs","ANDROID_ITEM_TYPE_IAP","inapp","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","select","ios","items","getItems","map","filter","item","includes","productId","type","android","products","getItemsByType","Promise","reject","Error","getSubscriptions","subscriptions","getPurchaseHistory","getAvailableItems","getPurchaseHistoryByType","concat","resolve","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","appAccountToken","isOfferPersonalized","undefined","quantity","withOffer","console","warn","offer","buyProduct","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","so","offerToken","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","purchaseToken","consumeProduct","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PURCHASED","acknowledgePurchase"],"sources":["iap.ts"],"sourcesContent":["import {NativeModules, Platform} from 'react-native';\n\nimport * as IapAmazon from './modules/amazon';\nimport * as IapAndroid from './modules/android';\nimport * as IapIos from './modules/ios';\nimport * as IapIosSk2 from './modules/iosSk2';\nimport {\n offerSk2Map,\n ProductSk2,\n productSk2Map,\n subscriptionSk2Map,\n} from './types/appleSk2';\nimport {\n enableStorekit2,\n fillProductsWithAdditionalData,\n getAndroidModule,\n getIosModule,\n getNativeModule,\n isAmazon,\n isIosStorekit2,\n} from './internal';\nimport {\n Product,\n ProductPurchase,\n ProductType,\n PurchaseResult,\n RequestPurchase,\n RequestSubscription,\n Subscription,\n SubscriptionPurchase,\n} from './types';\nimport {PurchaseStateAndroid} from './types';\n\nexport {\n IapAndroid,\n IapAmazon,\n IapIos,\n IapIosSk2,\n isIosStorekit2,\n enableStorekit2,\n};\n\nconst {RNIapIos, RNIapIosSk2, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = ProductType.subs;\nconst ANDROID_ITEM_TYPE_IAP = ProductType.inapp;\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * ## Usage\n\n```tsx\nimport React, {useEffect} from 'react';\nimport {View} from 'react-native';\nimport {initConnection} from 'react-native-iap';\n\nconst App = () => {\n useEffect(() => {\n void initConnection();\n }, []);\n\n return <View />;\n};\n```\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * Disconnects from native SDK\n * Usage\n * ```tsx\nimport React, {useEffect} from 'react';\nimport {View} from 'react-native';\nimport {endConnection} from 'react-native-iap';\n\nconst App = () => {\n useEffect(() => {\n return () => {\n void endConnection();\n };\n }, []);\n\n return <View />;\n};\n```\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<boolean> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid =\n (): Promise<boolean> =>\n getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n ## Usage\n\n```ts\nimport React, {useState} from 'react';\nimport {Platform} from 'react-native';\nimport {getProducts, Product} from 'react-native-iap';\n\nconst skus = Platform.select({\n ios: ['com.example.consumableIos'],\n android: ['com.example.consumableAndroid'],\n});\n\nconst App = () => {\n const [products, setProducts] = useState<Product[]>([]);\n\n const handleProducts = async () => {\n const items = await getProducts({skus});\n\n setProducts(items);\n };\n\n useEffect(() => {\n void handleProducts();\n }, []);\n\n return (\n <>\n {products.map((product) => (\n <Text key={product.productId}>{product.productId}</Text>\n ))}\n </>\n );\n};\n```\n\nJust a few things to keep in mind:\n\n- You can get your products in `componentDidMount`, `useEffect` or another appropriate area of your app.\n- Since a user may start your app with a bad or no internet connection, preparing/getting the items more than once may be a good idea.\n- If the user has no IAPs available when the app starts first, you may want to check again when the user enters your IAP store.\n\n */\nexport const getProducts = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n let items: Product[];\n if (isIosStorekit2()) {\n items = ((await RNIapIosSk2.getItems(skus)) as ProductSk2[]).map(\n productSk2Map,\n );\n } else {\n items = (await RNIapIos.getItems(skus)) as Product[];\n }\n return items.filter(\n (item: Product) =>\n skus.includes(item.productId) && item.type === 'iap',\n );\n },\n android: async () => {\n const products = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n skus,\n );\n\n return fillProductsWithAdditionalData(products);\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n\n/**\n * Get a list of subscriptions\n * ## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {View} from 'react-native';\nimport {getSubscriptions} from 'react-native-iap';\n\nconst App = () => {\n const subscriptions = useCallback(\n async () =>\n await getSubscriptions(['com.example.product1', 'com.example.product2']),\n [],\n );\n\n return <View />;\n};\n```\n\n */\nexport const getSubscriptions = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n let items: Subscription[];\n if (isIosStorekit2()) {\n items = ((await RNIapIosSk2.getItems(skus)) as ProductSk2[]).map(\n subscriptionSk2Map,\n );\n } else {\n items = (await RNIapIos.getItems(skus)) as Subscription[];\n }\n\n return items.filter(\n (item: Subscription) =>\n skus.includes(item.productId) && item.type === 'subs',\n );\n },\n android: async () => {\n const subscriptions = (await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n )) as Subscription[];\n\n return fillProductsWithAdditionalData(subscriptions);\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * ## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {View} from 'react-native';\nimport {getPurchaseHistory} from 'react-native-iap';\n\nconst App = () => {\n const history = useCallback(\n async () =>\n await getPurchaseHistory([\n 'com.example.product1',\n 'com.example.product2',\n ]),\n [],\n );\n\n return <View />;\n};\n```\n */\nexport const getPurchaseHistory = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await RNIapModule.getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\n/**\n * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)\n * ## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {View} from 'react-native';\nimport {getAvailablePurchases} from 'react-native-iap';\n\nconst App = () => {\n const availablePurchases = useCallback(\n async () => await getAvailablePurchases(),\n [],\n );\n\n return <View />;\n};\n```\n\n## Restoring purchases\n\nYou can use `getAvailablePurchases()` to do what's commonly understood as \"restoring\" purchases.\n\n:::note\nFor debugging you may want to consume all items, you have then to iterate over the purchases returned by `getAvailablePurchases()`.\n:::\n\n:::warning\nBeware that if you consume an item without having recorded the purchase in your database the user may have paid for something without getting it delivered and you will have no way to recover the receipt to validate and restore their purchase.\n:::\n\n```tsx\nimport React from 'react';\nimport {Button} from 'react-native';\nimport {getAvailablePurchases,finishTransaction} from 'react-native-iap';\n\nconst App = () => {\n handleRestore = async () => {\n try {\n const purchases = await getAvailablePurchases();\n const newState = {premium: false, ads: true};\n let titles = [];\n\n await Promise.all(purchases.map(async purchase => {\n switch (purchase.productId) {\n case 'com.example.premium':\n newState.premium = true;\n titles.push('Premium Version');\n break;\n\n case 'com.example.no_ads':\n newState.ads = false;\n titles.push('No Ads');\n break;\n\n case 'com.example.coins100':\n await finishTransaction(purchase.purchaseToken);\n CoinStore.addCoins(100);\n }\n })\n\n Alert.alert(\n 'Restore Successful',\n `You successfully restored the following purchases: ${titles.join(', ')}`,\n );\n } catch (error) {\n console.warn(error);\n Alert.alert(error.message);\n }\n };\n\n return (\n <Button title=\"Restore purchases\" onPress={handleRestore} />\n )\n};\n```\n * \n */\nexport const getAvailablePurchases = (): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems();\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await RNIapModule.getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.getAvailableItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * Request a purchase for a product (consumables or non-consumables).\n\nThe response will be received through the `PurchaseUpdatedListener`.\n\n:::note\n`andDangerouslyFinishTransactionAutomatically` defaults to false. We recommend\nalways keeping at false, and verifying the transaction receipts on the server-side.\n:::\n\n## Signature\n\n```ts\nrequestPurchase(\n The product's sku/ID \n sku,\n\n \n * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.\n * @default false\n \n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n\n /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app. \n obfuscatedAccountIdAndroid,\n\n Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app. \n obfuscatedProfileIdAndroid,\n\n The purchaser's user ID \n applicationUsername,\n): Promise<ProductPurchase>;\n```\n\n## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {Button} from 'react-native';\nimport {requestPurchase, Product, Sku, getProducts} from 'react-native-iap';\n\nconst App = () => {\n const products = useCallback(\n async () => getProducts(['com.example.product']),\n [],\n );\n\n const handlePurchase = async (sku: Sku) => {\n await requestPurchase({sku});\n };\n\n return (\n <>\n {products.map((product) => (\n <Button\n key={product.productId}\n title=\"Buy product\"\n onPress={() => handlePurchase(product.productId)}\n />\n ))}\n </>\n );\n};\n```\n\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n appAccountToken,\n skus, // Android Billing V5\n isOfferPersonalized = undefined, // Android Billing V5\n quantity,\n withOffer,\n}: RequestPurchase): Promise<ProductPurchase | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!sku) {\n return Promise.reject(new Error('sku is required for iOS purchase'));\n }\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n if (isIosStorekit2()) {\n const offer = offerSk2Map(withOffer);\n\n return RNIapIosSk2.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n );\n } else {\n return RNIapIos.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n withOffer,\n );\n }\n },\n android: async () => {\n if (isAmazon) {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for Amazon purchase'),\n );\n }\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!sku?.length && !sku) {\n return Promise.reject(\n new Error('skus is required for Android purchase'),\n );\n }\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n skus?.length ? skus : [sku],\n undefined,\n -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n [],\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * Request a purchase for a subscription.\n\nThe response will be received through the `PurchaseUpdatedListener`.\n\n:::note\n`andDangerouslyFinishTransactionAutomatically` defaults to false. We recommend\nalways keeping at false, and verifying the transaction receipts on the server-side.\n:::\n\n## Signature\n\n```ts\nrequestSubscription(\n The product's sku/ID \n sku,\n\n\n * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.\n * @default false\n\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n\n purchaseToken that the user is upgrading or downgrading from (Android). \n purchaseTokenAndroid,\n\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED \n prorationModeAndroid = -1,\n\n /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app. \n obfuscatedAccountIdAndroid,\n\n Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app. \n obfuscatedProfileIdAndroid,\n\n The purchaser's user ID \n applicationUsername,\n): Promise<SubscriptionPurchase>\n```\n\n## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {Button} from 'react-native';\nimport {\n requestSubscription,\n Product,\n Sku,\n getSubscriptions,\n} from 'react-native-iap';\n\nconst App = () => {\n const subscriptions = useCallback(\n async () => getSubscriptions(['com.example.subscription']),\n [],\n );\n\n const handlePurchase = async (sku: Sku) => {\n await requestSubscription({sku});\n };\n\n return (\n <>\n {subscriptions.map((subscription) => (\n <Button\n key={subscription.productId}\n title=\"Buy subscription\"\n onPress={() => handlePurchase(subscription.productId)}\n />\n ))}\n </>\n );\n};\n```\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers = undefined, // Android Billing V5\n isOfferPersonalized = undefined, // Android Billing V5\n appAccountToken,\n quantity,\n withOffer,\n}: RequestSubscription): Promise<SubscriptionPurchase | null | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for iOS subscription'),\n );\n }\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n if (isIosStorekit2()) {\n const offer = offerSk2Map(withOffer);\n\n return RNIapIosSk2.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n );\n } else {\n return RNIapIos.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n withOffer,\n );\n }\n },\n android: async () => {\n if (isAmazon) {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for Amazon purchase'),\n );\n }\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!subscriptionOffers?.length) {\n return Promise.reject(\n 'subscriptionOffers are required for Google Play Subscriptions',\n );\n }\n return RNIapModule.buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n subscriptionOffers?.map((so) => so.sku),\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers?.map((so) => so.offerToken),\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || (() => Promise.resolve(null))\n )();\n\n/**\n * 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 * \n```tsx\nimport React from 'react';\nimport {Button} from 'react-native';\nimport {finishTransaction} from 'react-native-iap';\n\nconst App = () => {\n const handlePurchase = async () => {\n // ... handle the purchase request\n\n const result = finishTransaction(purchase);\n };\n\n return <Button title=\"Buy product\" onPress={handlePurchase} />;\n};\n``` \n */\nexport const finishTransaction = ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n}: {\n purchase: ProductPurchase | SubscriptionPurchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n}): Promise<PurchaseResult | boolean> => {\n return (\n Platform.select({\n ios: async () => {\n const transactionId = purchase.transactionId;\n\n if (!transactionId) {\n return Promise.reject(\n new Error('transactionId required to finish iOS transaction'),\n );\n }\n return getIosModule().finishTransaction(transactionId);\n },\n android: async () => {\n if (purchase?.purchaseToken) {\n if (isConsumable) {\n return getAndroidModule().consumeProduct(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else if (\n purchase.userIdAmazon ||\n (!purchase.isAcknowledgedAndroid &&\n purchase.purchaseStateAndroid === PurchaseStateAndroid.PURCHASED)\n ) {\n return getAndroidModule().acknowledgePurchase(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else {\n return Promise.reject(\n new Error('purchase is not suitable to be purchased'),\n );\n }\n }\n return Promise.reject(\n new Error('purchase is not suitable to be purchased'),\n );\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n};\n"],"mappings":"AAAA,SAAQA,aAAR,EAAuBC,QAAvB,QAAsC,cAAtC;AAEA,OAAO,KAAKC,SAAZ,MAA2B,kBAA3B;AACA,OAAO,KAAKC,UAAZ,MAA4B,mBAA5B;AACA,OAAO,KAAKC,MAAZ,MAAwB,eAAxB;AACA,OAAO,KAAKC,SAAZ,MAA2B,kBAA3B;AACA,SACEC,WADF,EAGEC,aAHF,EAIEC,kBAJF,QAKO,kBALP;AAMA,SACEC,eADF,EAEEC,8BAFF,EAGEC,gBAHF,EAIEC,YAJF,EAKEC,eALF,EAMEC,QANF,EAOEC,cAPF,QAQO,YARP;AASA,SAGEC,WAHF,QASO,SATP;AAUA,SAAQC,oBAAR,QAAmC,SAAnC;AAEA,SACEd,UADF,EAEED,SAFF,EAGEE,MAHF,EAIEC,SAJF,EAKEU,cALF,EAMEN,eANF;AASA,MAAM;EAACS,QAAD;EAAWC,WAAX;EAAwBC,WAAxB;EAAqCC;AAArC,IAA0DrB,aAAhE;AACA,MAAMsB,8BAA8B,GAAGN,WAAW,CAACO,IAAnD;AACA,MAAMC,qBAAqB,GAAGR,WAAW,CAACS,KAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,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,EAAkB;UAChB,OAAOtE,gBAAgB,GAAG0E,cAAnB,CACLL,QAAQ,CAACI,aADJ,EAELF,uBAFK,CAAP;QAID,CALD,MAKO,IACLF,QAAQ,CAACM,YAAT,IACC,CAACN,QAAQ,CAACO,qBAAV,IACCP,QAAQ,CAACQ,oBAAT,KAAkCvE,oBAAoB,CAACwE,SAHpD,EAIL;UACA,OAAO9E,gBAAgB,GAAG+E,mBAAnB,CACLV,QAAQ,CAACI,aADJ,EAELF,uBAFK,CAAP;QAID,CATM,MASA;UACL,OAAOrC,OAAO,CAACC,MAAR,CACL,IAAIC,KAAJ,CAAU,0CAAV,CADK,CAAP;QAGD;MACF;;MACD,OAAOF,OAAO,CAACC,MAAR,CACL,IAAIC,KAAJ,CAAU,0CAAV,CADK,CAAP;IAGD;EApCa,CAAhB,MAqCO,MAAMF,OAAO,CAACC,MAAR,CAAe,IAAIC,KAAJ,CAAU,sBAAV,CAAf,CArCb,CADK,GAAP;AAwCD,CAjDM"}
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","IapAmazon","IapAndroid","IapIos","IapIosSk2","offerToRecord","offerSk2Map","productSk2Map","subscriptionSk2Map","fillProductsWithAdditionalData","getAndroidModule","getIosModule","getNativeModule","isAmazon","isIosStorekit2","storekit1Mode","storekit2Mode","storekitHybridMode","ProductType","PurchaseStateAndroid","RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","ANDROID_ITEM_TYPE_SUBSCRIPTION","subs","ANDROID_ITEM_TYPE_IAP","inapp","setup","storekitMode","initConnection","endConnection","flushFailedPurchasesCachedAsPendingAndroid","flushFailedPurchasesCachedAsPending","getProducts","skus","select","ios","items","getItems","map","filter","item","includes","productId","type","android","products","getItemsByType","Promise","reject","Error","getSubscriptions","subscriptions","getPurchaseHistory","alsoPublishToEventListener","getAvailableItems","getPurchaseHistoryByType","concat","resolve","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","appAccountToken","isOfferPersonalized","undefined","quantity","withOffer","console","warn","offer","buyProduct","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","so","offerToken","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","purchaseToken","consumeProduct","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","PURCHASED","acknowledgePurchase"],"sources":["iap.ts"],"sourcesContent":["import {NativeModules, Platform} from 'react-native';\n\nimport * as IapAmazon from './modules/amazon';\nimport * as IapAndroid from './modules/android';\nimport * as IapIos from './modules/ios';\nimport * as IapIosSk2 from './modules/iosSk2';\nimport {offerToRecord} from './types/apple';\nimport {\n offerSk2Map,\n ProductSk2,\n productSk2Map,\n subscriptionSk2Map,\n} from './types/appleSk2';\nimport {\n fillProductsWithAdditionalData,\n getAndroidModule,\n getIosModule,\n getNativeModule,\n isAmazon,\n isIosStorekit2,\n storekit1Mode,\n storekit2Mode,\n storekitHybridMode,\n} from './internal';\nimport {\n Product,\n ProductPurchase,\n ProductType,\n PurchaseResult,\n RequestPurchase,\n RequestSubscription,\n Subscription,\n SubscriptionPurchase,\n} from './types';\nimport {PurchaseStateAndroid} from './types';\n\nexport {IapAndroid, IapAmazon, IapIos, IapIosSk2, isIosStorekit2};\n\nconst {RNIapIos, RNIapIosSk2, RNIapModule, RNIapAmazonModule} = NativeModules;\nconst ANDROID_ITEM_TYPE_SUBSCRIPTION = ProductType.subs;\nconst ANDROID_ITEM_TYPE_IAP = ProductType.inapp;\n\n/**\n * STOREKIT1_MODE: Will not enable Storekit 2 even if the device supports it. Thigs will work as before,\n * minimum changes required in the migration guide (default)\n * HYBRID_MODE: Will enable Storekit 2 for iOS devices > 15.0 but will fallback to Sk1 on older devices\n * There are some edge cases that you need to handle in this case (described in migration guide). This mode\n * is for developers that are migrating to Storekit 2 but want to keep supporting older versions.\n * STOREKIT2_MODE: Will *only* enable Storekit 2. This disables Storekit 1. This is for apps that\n * have already targeted a min version of 15 for their app.\n */\nexport type STOREKIT_OPTIONS =\n | 'STOREKIT1_MODE'\n | 'STOREKIT_HYBRID_MODE'\n | 'STOREKIT2_MODE';\n\nexport const setup = ({\n storekitMode = 'STOREKIT1_MODE',\n}: {\n storekitMode?: STOREKIT_OPTIONS;\n} = {}) => {\n switch (storekitMode) {\n case 'STOREKIT1_MODE':\n storekit1Mode();\n break;\n case 'STOREKIT2_MODE':\n storekit2Mode();\n break;\n case 'STOREKIT_HYBRID_MODE':\n storekitHybridMode();\n break;\n default:\n break;\n }\n};\n\n/**\n * Init module for purchase flow. Required on Android. In ios it will check whether user canMakePayment.\n * ## Usage\n\n```tsx\nimport React, {useEffect} from 'react';\nimport {View} from 'react-native';\nimport {initConnection} from 'react-native-iap';\n\nconst App = () => {\n useEffect(() => {\n void initConnection();\n }, []);\n\n return <View />;\n};\n```\n */\nexport const initConnection = (): Promise<boolean> =>\n getNativeModule().initConnection();\n\n/**\n * Disconnects from native SDK\n * Usage\n * ```tsx\nimport React, {useEffect} from 'react';\nimport {View} from 'react-native';\nimport {endConnection} from 'react-native-iap';\n\nconst App = () => {\n useEffect(() => {\n return () => {\n void endConnection();\n };\n }, []);\n\n return <View />;\n};\n```\n * @returns {Promise<void>}\n */\nexport const endConnection = (): Promise<boolean> =>\n getNativeModule().endConnection();\n\n/**\n * Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache). Android only.\n * @returns {Promise<boolean>}\n */\nexport const flushFailedPurchasesCachedAsPendingAndroid =\n (): Promise<boolean> =>\n getAndroidModule().flushFailedPurchasesCachedAsPending();\n\n/**\n * Get a list of products (consumable and non-consumable items, but not subscriptions)\n ## Usage\n\n```ts\nimport React, {useState} from 'react';\nimport {Platform} from 'react-native';\nimport {getProducts, Product} from 'react-native-iap';\n\nconst skus = Platform.select({\n ios: ['com.example.consumableIos'],\n android: ['com.example.consumableAndroid'],\n});\n\nconst App = () => {\n const [products, setProducts] = useState<Product[]>([]);\n\n const handleProducts = async () => {\n const items = await getProducts({skus});\n\n setProducts(items);\n };\n\n useEffect(() => {\n void handleProducts();\n }, []);\n\n return (\n <>\n {products.map((product) => (\n <Text key={product.productId}>{product.productId}</Text>\n ))}\n </>\n );\n};\n```\n\nJust a few things to keep in mind:\n\n- You can get your products in `componentDidMount`, `useEffect` or another appropriate area of your app.\n- Since a user may start your app with a bad or no internet connection, preparing/getting the items more than once may be a good idea.\n- If the user has no IAPs available when the app starts first, you may want to check again when the user enters your IAP store.\n\n */\nexport const getProducts = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Array<Product>> =>\n (\n Platform.select({\n ios: async () => {\n let items: Product[];\n if (isIosStorekit2()) {\n items = ((await RNIapIosSk2.getItems(skus)) as ProductSk2[]).map(\n productSk2Map,\n );\n } else {\n items = (await RNIapIos.getItems(skus)) as Product[];\n }\n return items.filter(\n (item: Product) =>\n skus.includes(item.productId) && item.type === 'iap',\n );\n },\n android: async () => {\n const products = await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n skus,\n );\n\n return fillProductsWithAdditionalData(products);\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n\n/**\n * Get a list of subscriptions\n * ## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {View} from 'react-native';\nimport {getSubscriptions} from 'react-native-iap';\n\nconst App = () => {\n const subscriptions = useCallback(\n async () =>\n await getSubscriptions(['com.example.product1', 'com.example.product2']),\n [],\n );\n\n return <View />;\n};\n```\n\n */\nexport const getSubscriptions = ({\n skus,\n}: {\n skus: string[];\n}): Promise<Subscription[]> =>\n (\n Platform.select({\n ios: async () => {\n let items: Subscription[];\n if (isIosStorekit2()) {\n items = ((await RNIapIosSk2.getItems(skus)) as ProductSk2[]).map(\n subscriptionSk2Map,\n );\n } else {\n items = (await RNIapIos.getItems(skus)) as Subscription[];\n }\n\n return items.filter(\n (item: Subscription) =>\n skus.includes(item.productId) && item.type === 'subs',\n );\n },\n android: async () => {\n const subscriptions = (await getAndroidModule().getItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n skus,\n )) as Subscription[];\n\n return fillProductsWithAdditionalData(subscriptions);\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n\n/**\n * Gets an inventory of purchases made by the user regardless of consumption status\n * ## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {View} from 'react-native';\nimport {getPurchaseHistory} from 'react-native-iap';\n\nconst App = () => {\n const history = useCallback(\n async () =>\n await getPurchaseHistory([\n 'com.example.product1',\n 'com.example.product2',\n ]),\n [],\n );\n\n return <View />;\n};\n```\n@param {alsoPublishToEventListener}:boolean When `true`, every element will also be pushed to the purchaseUpdated listener.\nNote that this is only for backaward compatiblity. It won't publish to transactionUpdated (Storekit2) Defaults to `false`\n */\nexport const getPurchaseHistory = ({\n alsoPublishToEventListener = false,\n}: {\n alsoPublishToEventListener?: boolean;\n} = {}): Promise<(ProductPurchase | SubscriptionPurchase)[]> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems(alsoPublishToEventListener);\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await RNIapModule.getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.getPurchaseHistoryByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\n/**\n * Get all purchases made by the user (either non-consumable, or haven't been consumed yet)\n * ## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {View} from 'react-native';\nimport {getAvailablePurchases} from 'react-native-iap';\n\nconst App = () => {\n const availablePurchases = useCallback(\n async () => await getAvailablePurchases(),\n [],\n );\n\n return <View />;\n};\n```\n\n## Restoring purchases\n\nYou can use `getAvailablePurchases()` to do what's commonly understood as \"restoring\" purchases.\n\n:::note\nFor debugging you may want to consume all items, you have then to iterate over the purchases returned by `getAvailablePurchases()`.\n:::\n\n:::warning\nBeware that if you consume an item without having recorded the purchase in your database the user may have paid for something without getting it delivered and you will have no way to recover the receipt to validate and restore their purchase.\n:::\n\n```tsx\nimport React from 'react';\nimport {Button} from 'react-native';\nimport {getAvailablePurchases,finishTransaction} from 'react-native-iap';\n\nconst App = () => {\n handleRestore = async () => {\n try {\n const purchases = await getAvailablePurchases();\n const newState = {premium: false, ads: true};\n let titles = [];\n\n await Promise.all(purchases.map(async purchase => {\n switch (purchase.productId) {\n case 'com.example.premium':\n newState.premium = true;\n titles.push('Premium Version');\n break;\n\n case 'com.example.no_ads':\n newState.ads = false;\n titles.push('No Ads');\n break;\n\n case 'com.example.coins100':\n await finishTransaction(purchase.purchaseToken);\n CoinStore.addCoins(100);\n }\n })\n\n Alert.alert(\n 'Restore Successful',\n `You successfully restored the following purchases: ${titles.join(', ')}`,\n );\n } catch (error) {\n console.warn(error);\n Alert.alert(error.message);\n }\n };\n\n return (\n <Button title=\"Restore purchases\" onPress={handleRestore} />\n )\n};\n```\n@param {alsoPublishToEventListener}:boolean When `true`, every element will also be pushed to the purchaseUpdated listener.\nNote that this is only for backaward compatiblity. It won't publish to transactionUpdated (Storekit2) Defaults to `false`\n * \n */\nexport const getAvailablePurchases = ({\n alsoPublishToEventListener = false,\n}: {alsoPublishToEventListener?: boolean} = {}): Promise<\n (ProductPurchase | SubscriptionPurchase)[]\n> =>\n (\n Platform.select({\n ios: async () => {\n return getIosModule().getAvailableItems(alsoPublishToEventListener);\n },\n android: async () => {\n if (RNIapAmazonModule) {\n return await RNIapAmazonModule.getAvailableItems();\n }\n\n const products = await RNIapModule.getAvailableItemsByType(\n ANDROID_ITEM_TYPE_IAP,\n );\n\n const subscriptions = await RNIapModule.getAvailableItemsByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n );\n\n return products.concat(subscriptions);\n },\n }) || (() => Promise.resolve([]))\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * Request a purchase for a product (consumables or non-consumables).\n\nThe response will be received through the `PurchaseUpdatedListener`.\n\n:::note\n`andDangerouslyFinishTransactionAutomatically` defaults to false. We recommend\nalways keeping at false, and verifying the transaction receipts on the server-side.\n:::\n\n## Signature\n\n```ts\nrequestPurchase(\n The product's sku/ID \n sku,\n\n \n * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.\n * @default false\n \n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n\n /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app. \n obfuscatedAccountIdAndroid,\n\n Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app. \n obfuscatedProfileIdAndroid,\n\n The purchaser's user ID \n applicationUsername,\n): Promise<ProductPurchase>;\n```\n\n## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {Button} from 'react-native';\nimport {requestPurchase, Product, Sku, getProducts} from 'react-native-iap';\n\nconst App = () => {\n const products = useCallback(\n async () => getProducts(['com.example.product']),\n [],\n );\n\n const handlePurchase = async (sku: Sku) => {\n await requestPurchase({sku});\n };\n\n return (\n <>\n {products.map((product) => (\n <Button\n key={product.productId}\n title=\"Buy product\"\n onPress={() => handlePurchase(product.productId)}\n />\n ))}\n </>\n );\n};\n```\n\n */\n\nexport const requestPurchase = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n appAccountToken,\n skus, // Android Billing V5\n isOfferPersonalized = undefined, // Android Billing V5\n quantity,\n withOffer,\n}: RequestPurchase): Promise<ProductPurchase | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!sku) {\n return Promise.reject(new Error('sku is required for iOS purchase'));\n }\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n if (isIosStorekit2()) {\n const offer = offerSk2Map(withOffer);\n\n return RNIapIosSk2.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n );\n } else {\n return RNIapIos.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offerToRecord(withOffer),\n );\n }\n },\n android: async () => {\n if (isAmazon) {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for Amazon purchase'),\n );\n }\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!sku?.length && !sku) {\n return Promise.reject(\n new Error('skus is required for Android purchase'),\n );\n }\n return getAndroidModule().buyItemByType(\n ANDROID_ITEM_TYPE_IAP,\n skus?.length ? skus : [sku],\n undefined,\n -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n [],\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || Promise.resolve\n )();\n\n/**\n * Request a purchase for product. This will be received in `PurchaseUpdatedListener`.\n * Request a purchase for a subscription.\n\nThe response will be received through the `PurchaseUpdatedListener`.\n\n:::note\n`andDangerouslyFinishTransactionAutomatically` defaults to false. We recommend\nalways keeping at false, and verifying the transaction receipts on the server-side.\n:::\n\n## Signature\n\n```ts\nrequestSubscription(\n The product's sku/ID \n sku,\n\n\n * You should set this to false and call finishTransaction manually when you have delivered the purchased goods to the user.\n * @default false\n\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n\n purchaseToken that the user is upgrading or downgrading from (Android). \n purchaseTokenAndroid,\n\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY, IMMEDIATE_WITH_TIME_PRORATION, IMMEDIATE_AND_CHARGE_PRORATED_PRICE, IMMEDIATE_WITHOUT_PRORATION, DEFERRED \n prorationModeAndroid = -1,\n\n /** Specifies an optional obfuscated string that is uniquely associated with the user's account in your app. \n obfuscatedAccountIdAndroid,\n\n Specifies an optional obfuscated string that is uniquely associated with the user's profile in your app. \n obfuscatedProfileIdAndroid,\n\n The purchaser's user ID \n applicationUsername,\n): Promise<SubscriptionPurchase>\n```\n\n## Usage\n\n```tsx\nimport React, {useCallback} from 'react';\nimport {Button} from 'react-native';\nimport {\n requestSubscription,\n Product,\n Sku,\n getSubscriptions,\n} from 'react-native-iap';\n\nconst App = () => {\n const subscriptions = useCallback(\n async () => getSubscriptions(['com.example.subscription']),\n [],\n );\n\n const handlePurchase = async (sku: Sku) => {\n await requestSubscription({sku});\n };\n\n return (\n <>\n {subscriptions.map((subscription) => (\n <Button\n key={subscription.productId}\n title=\"Buy subscription\"\n onPress={() => handlePurchase(subscription.productId)}\n />\n ))}\n </>\n );\n};\n```\n */\nexport const requestSubscription = ({\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS = false,\n purchaseTokenAndroid,\n prorationModeAndroid = -1,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers = undefined, // Android Billing V5\n isOfferPersonalized = undefined, // Android Billing V5\n appAccountToken,\n quantity,\n withOffer,\n}: RequestSubscription): Promise<SubscriptionPurchase | null | void> =>\n (\n Platform.select({\n ios: async () => {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for iOS subscription'),\n );\n }\n if (andDangerouslyFinishTransactionAutomaticallyIOS) {\n console.warn(\n 'You are dangerously allowing react-native-iap to finish your transaction automatically. You should set andDangerouslyFinishTransactionAutomatically to false when calling requestPurchase and call finishTransaction manually when you have delivered the purchased goods to the user. It defaults to true to provide backwards compatibility. Will default to false in version 4.0.0.',\n );\n }\n\n if (isIosStorekit2()) {\n const offer = offerSk2Map(withOffer);\n\n return RNIapIosSk2.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offer,\n );\n } else {\n return RNIapIos.buyProduct(\n sku,\n andDangerouslyFinishTransactionAutomaticallyIOS,\n appAccountToken,\n quantity ?? -1,\n offerToRecord(withOffer),\n );\n }\n },\n android: async () => {\n if (isAmazon) {\n if (!sku) {\n return Promise.reject(\n new Error('sku is required for Amazon purchase'),\n );\n }\n return RNIapAmazonModule.buyItemByType(sku);\n } else {\n if (!subscriptionOffers?.length) {\n return Promise.reject(\n 'subscriptionOffers are required for Google Play Subscriptions',\n );\n }\n return RNIapModule.buyItemByType(\n ANDROID_ITEM_TYPE_SUBSCRIPTION,\n subscriptionOffers?.map((so) => so.sku),\n purchaseTokenAndroid,\n prorationModeAndroid,\n obfuscatedAccountIdAndroid,\n obfuscatedProfileIdAndroid,\n subscriptionOffers?.map((so) => so.offerToken),\n isOfferPersonalized ?? false,\n );\n }\n },\n }) || (() => Promise.resolve(null))\n )();\n\n/**\n * 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 * \n```tsx\nimport React from 'react';\nimport {Button} from 'react-native';\nimport {finishTransaction} from 'react-native-iap';\n\nconst App = () => {\n const handlePurchase = async () => {\n // ... handle the purchase request\n\n const result = finishTransaction(purchase);\n };\n\n return <Button title=\"Buy product\" onPress={handlePurchase} />;\n};\n``` \n */\nexport const finishTransaction = ({\n purchase,\n isConsumable,\n developerPayloadAndroid,\n}: {\n purchase: ProductPurchase | SubscriptionPurchase;\n isConsumable?: boolean;\n developerPayloadAndroid?: string;\n}): Promise<PurchaseResult | boolean> => {\n return (\n Platform.select({\n ios: async () => {\n const transactionId = purchase.transactionId;\n\n if (!transactionId) {\n return Promise.reject(\n new Error('transactionId required to finish iOS transaction'),\n );\n }\n return getIosModule().finishTransaction(transactionId);\n },\n android: async () => {\n if (purchase?.purchaseToken) {\n if (isConsumable) {\n return getAndroidModule().consumeProduct(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else if (\n purchase.userIdAmazon ||\n (!purchase.isAcknowledgedAndroid &&\n purchase.purchaseStateAndroid === PurchaseStateAndroid.PURCHASED)\n ) {\n return getAndroidModule().acknowledgePurchase(\n purchase.purchaseToken,\n developerPayloadAndroid,\n );\n } else {\n return Promise.reject(\n new Error('purchase is not suitable to be purchased'),\n );\n }\n }\n return Promise.reject(\n new Error('purchase is not suitable to be purchased'),\n );\n },\n }) || (() => Promise.reject(new Error('Unsupported Platform')))\n )();\n};\n"],"mappings":"AAAA,SAAQA,aAAR,EAAuBC,QAAvB,QAAsC,cAAtC;AAEA,OAAO,KAAKC,SAAZ,MAA2B,kBAA3B;AACA,OAAO,KAAKC,UAAZ,MAA4B,mBAA5B;AACA,OAAO,KAAKC,MAAZ,MAAwB,eAAxB;AACA,OAAO,KAAKC,SAAZ,MAA2B,kBAA3B;AACA,SAAQC,aAAR,QAA4B,eAA5B;AACA,SACEC,WADF,EAGEC,aAHF,EAIEC,kBAJF,QAKO,kBALP;AAMA,SACEC,8BADF,EAEEC,gBAFF,EAGEC,YAHF,EAIEC,eAJF,EAKEC,QALF,EAMEC,cANF,EAOEC,aAPF,EAQEC,aARF,EASEC,kBATF,QAUO,YAVP;AAWA,SAGEC,WAHF,QASO,SATP;AAUA,SAAQC,oBAAR,QAAmC,SAAnC;AAEA,SAAQjB,UAAR,EAAoBD,SAApB,EAA+BE,MAA/B,EAAuCC,SAAvC,EAAkDU,cAAlD;AAEA,MAAM;EAACM,QAAD;EAAWC,WAAX;EAAwBC,WAAxB;EAAqCC;AAArC,IAA0DxB,aAAhE;AACA,MAAMyB,8BAA8B,GAAGN,WAAW,CAACO,IAAnD;AACA,MAAMC,qBAAqB,GAAGR,WAAW,CAACS,KAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA,OAAO,MAAMC,KAAK,GAAG,YAIV;EAAA,IAJW;IACpBC,YAAY,GAAG;EADK,CAIX,uEAAP,EAAO;;EACT,QAAQA,YAAR;IACE,KAAK,gBAAL;MACEd,aAAa;MACb;;IACF,KAAK,gBAAL;MACEC,aAAa;MACb;;IACF,KAAK,sBAAL;MACEC,kBAAkB;MAClB;;IACF;MACE;EAXJ;AAaD,CAlBM;AAoBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMa,cAAc,GAAG,MAC5BlB,eAAe,GAAGkB,cAAlB,EADK;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG,MAC3BnB,eAAe,GAAGmB,aAAlB,EADK;AAGP;AACA;AACA;AACA;;AACA,OAAO,MAAMC,0CAA0C,GACrD,MACEtB,gBAAgB,GAAGuB,mCAAnB,EAFG;AAIP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,WAAW,GAAG;EAAA,IAAC;IAC1BC;EAD0B,CAAD;EAAA,OAKzB,CACEnC,QAAQ,CAACoC,MAAT,CAAgB;IACdC,GAAG,EAAE,YAAY;MACf,IAAIC,KAAJ;;MACA,IAAIxB,cAAc,EAAlB,EAAsB;QACpBwB,KAAK,GAAG,CAAE,MAAMjB,WAAW,CAACkB,QAAZ,CAAqBJ,IAArB,CAAR,EAAqDK,GAArD,CACNjC,aADM,CAAR;MAGD,CAJD,MAIO;QACL+B,KAAK,GAAI,MAAMlB,QAAQ,CAACmB,QAAT,CAAkBJ,IAAlB,CAAf;MACD;;MACD,OAAOG,KAAK,CAACG,MAAN,CACJC,IAA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B,MAwBO,MAAMJ,OAAO,CAACC,MAAR,CAAe,IAAIC,KAAJ,CAAU,sBAAV,CAAf,CAxBb,CADF,GAL8B;AAAA,CAAzB;AAiCP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMG,kBAAkB,GAAG;EAAA,IAAC;IACjCC,0BAA0B,GAAG;EADI,CAAD,uEAI9B,EAJ8B;EAAA,OAKhC,CACEvD,QAAQ,CAACoC,MAAT,CAAgB;IACdC,GAAG,EAAE,YAAY;MACf,OAAO1B,YAAY,GAAG6C,iBAAf,CAAiCD,0BAAjC,CAAP;IACD,CAHa;IAIdT,OAAO,EAAE,YAAY;MACnB,IAAIvB,iBAAJ,EAAuB;QACrB,OAAO,MAAMA,iBAAiB,CAACiC,iBAAlB,EAAb;MACD;;MAED,MAAMT,QAAQ,GAAG,MAAMzB,WAAW,CAACmC,wBAAZ,CACrB/B,qBADqB,CAAvB;MAIA,MAAM2B,aAAa,GAAG,MAAM/B,WAAW,CAACmC,wBAAZ,CAC1BjC,8BAD0B,CAA5B;MAIA,OAAOuB,QAAQ,CAACW,MAAT,CAAgBL,aAAhB,CAAP;IACD;EAlBa,CAAhB,MAmBO,MAAMJ,OAAO,CAACU,OAAR,CAAgB,EAAhB,CAnBb,CADF,GALgC;AAAA,CAA3B;AA4BP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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Module => {
|
|
33
33
|
iosNativeModule = nativeModule;
|
|
34
34
|
};
|
|
35
|
-
export const
|
|
35
|
+
export const storekit2Mode = () => {
|
|
36
|
+
iosNativeModule = RNIapIosSk2;
|
|
37
|
+
|
|
36
38
|
if (RNIapIosSk2) {
|
|
37
|
-
|
|
39
|
+
RNIapIos.disable();
|
|
38
40
|
return true;
|
|
39
41
|
}
|
|
40
42
|
|
|
41
43
|
console.warn('Storekit 2 is not available on this device');
|
|
42
44
|
return false;
|
|
43
45
|
};
|
|
46
|
+
export const storekit1Mode = () => {
|
|
47
|
+
iosNativeModule = RNIapIos;
|
|
48
|
+
|
|
49
|
+
if (RNIapIosSk2) {
|
|
50
|
+
RNIapIosSk2.disable();
|
|
51
|
+
return true;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
return false;
|
|
55
|
+
};
|
|
56
|
+
export const storekitHybridMode = () => {
|
|
57
|
+
if (RNIapIosSk2) {
|
|
58
|
+
iosNativeModule = RNIapIosSk2;
|
|
59
|
+
console.info('Using Storekit 2');
|
|
60
|
+
return true;
|
|
61
|
+
} else {
|
|
62
|
+
iosNativeModule = RNIapIos;
|
|
63
|
+
console.info('Using Storekit 1');
|
|
64
|
+
return true;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
44
67
|
|
|
45
68
|
const checkNativeIOSAvailable = () => {
|
|
46
69
|
if (!RNIapIos && !RNIapIosSk2) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","Platform","RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","isIos","OS","isAndroid","isAmazon","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","getAndroidModule","getNativeModule","getIosModule","iosNativeModule","isIosStorekit2","isStorekit2Avaiable","setIosNativeModule","
|
|
1
|
+
{"version":3,"names":["NativeModules","Platform","RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","isIos","OS","isAndroid","isAmazon","androidNativeModule","setAndroidNativeModule","nativeModule","checkNativeAndroidAvailable","Error","getAndroidModule","getNativeModule","getIosModule","iosNativeModule","isIosStorekit2","isStorekit2Avaiable","setIosNativeModule","storekit2Mode","disable","console","warn","storekit1Mode","storekitHybridMode","info","checkNativeIOSAvailable"],"sources":["platform.ts"],"sourcesContent":["import {NativeModules, Platform} from 'react-native';\n\nconst {RNIapIos, RNIapIosSk2, RNIapModule, RNIapAmazonModule} = NativeModules;\n\nexport const isIos = Platform.OS === 'ios';\nexport const isAndroid = Platform.OS === 'android';\nexport const isAmazon = isAndroid && !!RNIapAmazonModule;\n\n// Android\n\nlet androidNativeModule = RNIapModule;\n\nexport const setAndroidNativeModule = (\n nativeModule: typeof RNIapModule,\n): void => {\n androidNativeModule = nativeModule;\n};\n\nexport const checkNativeAndroidAvailable = (): void => {\n if (!RNIapModule && !RNIapAmazonModule) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getAndroidModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule => {\n checkNativeAndroidAvailable();\n\n return androidNativeModule\n ? androidNativeModule\n : RNIapModule\n ? RNIapModule\n : RNIapAmazonModule;\n};\n\nexport const getNativeModule = ():\n | typeof RNIapModule\n | typeof RNIapAmazonModule\n | typeof RNIapIos\n | typeof RNIapIosSk2 => {\n return isAndroid ? getAndroidModule() : getIosModule();\n};\n\n// iOS\n\nlet iosNativeModule: typeof RNIapIos | typeof RNIapIosSk2 = RNIapIos;\n\nexport const isIosStorekit2 = () =>\n !!iosNativeModule && iosNativeModule === RNIapIosSk2;\n\nexport const isStorekit2Avaiable = (): boolean => !!RNIapIosSk2;\n\nexport const setIosNativeModule = (\n nativeModule: typeof RNIapIos | typeof RNIapIosSk2,\n): void => {\n iosNativeModule = nativeModule;\n};\n\nexport const storekit2Mode = () => {\n iosNativeModule = RNIapIosSk2;\n if (RNIapIosSk2) {\n RNIapIos.disable();\n return true;\n }\n console.warn('Storekit 2 is not available on this device');\n\n return false;\n};\n\nexport const storekit1Mode = () => {\n iosNativeModule = RNIapIos;\n if (RNIapIosSk2) {\n RNIapIosSk2.disable();\n return true;\n }\n return false;\n};\n\nexport const storekitHybridMode = () => {\n if (RNIapIosSk2) {\n iosNativeModule = RNIapIosSk2;\n console.info('Using Storekit 2');\n return true;\n } else {\n iosNativeModule = RNIapIos;\n console.info('Using Storekit 1');\n return true;\n }\n};\n\nconst checkNativeIOSAvailable = (): void => {\n if (!RNIapIos && !RNIapIosSk2) {\n throw new Error('IAP_NOT_AVAILABLE');\n }\n};\n\nexport const getIosModule = (): typeof RNIapIos | typeof RNIapIosSk2 => {\n checkNativeIOSAvailable();\n\n return iosNativeModule\n ? iosNativeModule\n : RNIapIosSk2\n ? RNIapIosSk2\n : RNIapIos;\n};\n"],"mappings":"AAAA,SAAQA,aAAR,EAAuBC,QAAvB,QAAsC,cAAtC;AAEA,MAAM;EAACC,QAAD;EAAWC,WAAX;EAAwBC,WAAxB;EAAqCC;AAArC,IAA0DL,aAAhE;AAEA,OAAO,MAAMM,KAAK,GAAGL,QAAQ,CAACM,EAAT,KAAgB,KAA9B;AACP,OAAO,MAAMC,SAAS,GAAGP,QAAQ,CAACM,EAAT,KAAgB,SAAlC;AACP,OAAO,MAAME,QAAQ,GAAGD,SAAS,IAAI,CAAC,CAACH,iBAAhC,C,CAEP;;AAEA,IAAIK,mBAAmB,GAAGN,WAA1B;AAEA,OAAO,MAAMO,sBAAsB,GACjCC,YADoC,IAE3B;EACTF,mBAAmB,GAAGE,YAAtB;AACD,CAJM;AAMP,OAAO,MAAMC,2BAA2B,GAAG,MAAY;EACrD,IAAI,CAACT,WAAD,IAAgB,CAACC,iBAArB,EAAwC;IACtC,MAAM,IAAIS,KAAJ,CAAU,mBAAV,CAAN;EACD;AACF,CAJM;AAMP,OAAO,MAAMC,gBAAgB,GAAG,MAEA;EAC9BF,2BAA2B;EAE3B,OAAOH,mBAAmB,GACtBA,mBADsB,GAEtBN,WAAW,GACXA,WADW,GAEXC,iBAJJ;AAKD,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ACtEY,uBAAuB;EAEvB,OAAOX,eAAe,GAClBA,eADkB,GAElBf,WAAW,GACXA,WADW,GAEXD,QAJJ;AAKD,CARM"}
|
|
@@ -34,7 +34,7 @@ export const getPromotedProductIOS = () => {
|
|
|
34
34
|
if (!isIosStorekit2()) {
|
|
35
35
|
return getIosModule().promotedProduct();
|
|
36
36
|
} else {
|
|
37
|
-
return Promise.reject('Only available on
|
|
37
|
+
return Promise.reject('Only available on Sk1');
|
|
38
38
|
}
|
|
39
39
|
};
|
|
40
40
|
/**
|
|
@@ -82,7 +82,10 @@ export const validateReceiptIos = async _ref2 => {
|
|
|
82
82
|
}
|
|
83
83
|
|
|
84
84
|
const url = isTest ? 'https://sandbox.itunes.apple.com/verifyReceipt' : 'https://buy.itunes.apple.com/verifyReceipt';
|
|
85
|
-
return await enhancedFetch(url
|
|
85
|
+
return await enhancedFetch(url, {
|
|
86
|
+
method: 'POST',
|
|
87
|
+
body: receiptBody
|
|
88
|
+
});
|
|
86
89
|
};
|
|
87
90
|
/**
|
|
88
91
|
* Clear Transaction (iOS only)
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["enhancedFetch","getIosModule","isIosStorekit2","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet","getPromotedProductIOS","promotedProduct","Promise","reject","buyPromotedProductIOS","buyPromotedProduct","TEST_RECEIPT","requestAgnosticReceiptValidationIos","receiptBody","response","method","body","status","testResponse","validateReceiptIos","isTest","url","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts"],"sources":["ios.ts"],"sourcesContent":["import type {ResponseBody as ReceiptValidationResponse} from '@jeremybarbet/apple-api-types';\n\nimport {enhancedFetch, getIosModule, isIosStorekit2} from '../internal';\nimport type {\n Product,\n ProductPurchase,\n Purchase,\n Sku,\n Subscription,\n} from '../types';\nimport type {PaymentDiscount} from '../types/apple';\n\nimport type {NativeModuleProps} from './common';\n\ntype getItems = (skus: Sku[]) => Promise<Product[] | Subscription[]>;\n\ntype getAvailableItems = () => Promise<Purchase[]>;\n\nexport type BuyProduct = (\n sku: Sku,\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean,\n applicationUsername: string | undefined,\n quantity: number,\n withOffer: PaymentDiscount | undefined,\n) => Promise<Purchase>;\n\ntype clearTransaction = () => Promise<void>;\ntype clearProducts = () => Promise<void>;\ntype promotedProduct = () => Promise<Product | null>;\ntype buyPromotedProduct = () => Promise<void>;\ntype requestReceipt = (refresh: boolean) => Promise<string>;\n\ntype finishTransaction = (transactionIdentifier: string) => Promise<boolean>;\n\ntype getPendingTransactions = () => Promise<ProductPurchase[]>;\ntype presentCodeRedemptionSheet = () => Promise<null>;\n\nexport interface IosModuleProps extends NativeModuleProps {\n getItems: getItems;\n getAvailableItems: getAvailableItems;\n buyProduct: BuyProduct;\n clearTransaction: clearTransaction;\n clearProducts: clearProducts;\n promotedProduct: promotedProduct;\n buyPromotedProduct: buyPromotedProduct;\n requestReceipt: requestReceipt;\n finishTransaction: finishTransaction;\n getPendingTransactions: getPendingTransactions;\n presentCodeRedemptionSheet: presentCodeRedemptionSheet;\n}\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async ({\n forceRefresh,\n}: {\n forceRefresh?: boolean;\n}): Promise<string> => getIosModule().requestReceipt(forceRefresh ?? false);\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n\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 if (!isIosStorekit2()) {\n return getIosModule().promotedProduct();\n } else {\n return Promise.reject('Only available on
|
|
1
|
+
{"version":3,"names":["enhancedFetch","getIosModule","isIosStorekit2","getPendingPurchasesIOS","getPendingTransactions","getReceiptIOS","forceRefresh","requestReceipt","presentCodeRedemptionSheetIOS","presentCodeRedemptionSheet","getPromotedProductIOS","promotedProduct","Promise","reject","buyPromotedProductIOS","buyPromotedProduct","TEST_RECEIPT","requestAgnosticReceiptValidationIos","receiptBody","response","method","body","status","testResponse","validateReceiptIos","isTest","url","clearTransactionIOS","clearTransaction","clearProductsIOS","clearProducts"],"sources":["ios.ts"],"sourcesContent":["import type {ResponseBody as ReceiptValidationResponse} from '@jeremybarbet/apple-api-types';\n\nimport {enhancedFetch, getIosModule, isIosStorekit2} from '../internal';\nimport type {\n Product,\n ProductPurchase,\n Purchase,\n Sku,\n Subscription,\n} from '../types';\nimport type {PaymentDiscount} from '../types/apple';\n\nimport type {NativeModuleProps} from './common';\n\ntype getItems = (skus: Sku[]) => Promise<Product[] | Subscription[]>;\n\ntype getAvailableItems = () => Promise<Purchase[]>;\n\nexport type BuyProduct = (\n sku: Sku,\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean,\n applicationUsername: string | undefined,\n quantity: number,\n withOffer: Record<keyof PaymentDiscount, string> | undefined,\n) => Promise<Purchase>;\n\ntype clearTransaction = () => Promise<void>;\ntype clearProducts = () => Promise<void>;\ntype promotedProduct = () => Promise<Product | null>;\ntype buyPromotedProduct = () => Promise<void>;\ntype requestReceipt = (refresh: boolean) => Promise<string>;\n\ntype finishTransaction = (transactionIdentifier: string) => Promise<boolean>;\n\ntype getPendingTransactions = () => Promise<ProductPurchase[]>;\ntype presentCodeRedemptionSheet = () => Promise<null>;\n\nexport interface IosModuleProps extends NativeModuleProps {\n getItems: getItems;\n getAvailableItems: getAvailableItems;\n buyProduct: BuyProduct;\n clearTransaction: clearTransaction;\n clearProducts: clearProducts;\n promotedProduct: promotedProduct;\n buyPromotedProduct: buyPromotedProduct;\n requestReceipt: requestReceipt;\n finishTransaction: finishTransaction;\n getPendingTransactions: getPendingTransactions;\n presentCodeRedemptionSheet: presentCodeRedemptionSheet;\n disable: () => Promise<null>;\n}\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<ProductPurchase[]>}\n */\nexport const getPendingPurchasesIOS = async (): Promise<ProductPurchase[]> =>\n getIosModule().getPendingTransactions();\n\n/**\n * Get the current receipt base64 encoded in IOS.\n * @param {forceRefresh?:boolean}\n * @returns {Promise<string>}\n */\nexport const getReceiptIOS = async ({\n forceRefresh,\n}: {\n forceRefresh?: boolean;\n}): Promise<string> => getIosModule().requestReceipt(forceRefresh ?? false);\n\n/**\n * Launches a modal to register the redeem offer code in IOS.\n * @returns {Promise<null>}\n */\nexport const presentCodeRedemptionSheetIOS = async (): Promise<null> =>\n getIosModule().presentCodeRedemptionSheet();\n\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 if (!isIosStorekit2()) {\n return getIosModule().promotedProduct();\n } else {\n return Promise.reject('Only available on Sk1');\n }\n};\n\n/**\n * Buy the currently selected promoted product (iOS only)\n * Initiates the payment process for a promoted product. Should only be called in response to the `iap-promoted-product` event.\n * @returns {Promise<void>}\n */\nexport const buyPromotedProductIOS = (): Promise<void> =>\n getIosModule().buyPromotedProduct();\n\nconst TEST_RECEIPT = 21007;\nconst requestAgnosticReceiptValidationIos = async (\n receiptBody: Record<string, unknown>,\n): Promise<ReceiptValidationResponse | false> => {\n const response = await enhancedFetch<ReceiptValidationResponse>(\n 'https://buy.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n // Best practice is to check for test receipt and check sandbox instead\n // https://developer.apple.com/documentation/appstorereceipts/verifyreceipt\n if (response && response.status === TEST_RECEIPT) {\n const testResponse = await enhancedFetch<ReceiptValidationResponse>(\n 'https://sandbox.itunes.apple.com/verifyReceipt',\n {\n method: 'POST',\n body: receiptBody,\n },\n );\n\n return testResponse;\n }\n\n return response;\n};\n\n/**\n * Validate receipt for iOS.\n * @param {object} receiptBody the receipt body to send to apple server.\n * @param {boolean} isTest whether this is in test environment which is sandbox.\n * @returns {Promise<Apple.ReceiptValidationResponse | false>}\n */\nexport const validateReceiptIos = async ({\n receiptBody,\n isTest,\n}: {\n receiptBody: Record<string, unknown>;\n isTest?: boolean;\n}): Promise<ReceiptValidationResponse | false> => {\n if (isTest == null) {\n return await requestAgnosticReceiptValidationIos(receiptBody);\n }\n\n const url = isTest\n ? 'https://sandbox.itunes.apple.com/verifyReceipt'\n : 'https://buy.itunes.apple.com/verifyReceipt';\n\n return await enhancedFetch<ReceiptValidationResponse>(url, {\n method: 'POST',\n body: receiptBody,\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"],"mappings":"AAEA,SAAQA,aAAR,EAAuBC,YAAvB,EAAqCC,cAArC,QAA0D,aAA1D;;AAkDA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,sBAAsB,GAAG,YACpCF,YAAY,GAAGG,sBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,aAAa,GAAG;EAAA,IAAO;IAClCC;EADkC,CAAP;EAAA,OAINL,YAAY,GAAGM,cAAf,CAA8BD,YAAY,IAAI,KAA9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,EAAE,MADiD;IAEzDC,IAAI,EAAEH;EAFmD,CAAjC,CAA1B;AAID,CAnBM;AAqBP;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMS,mBAAmB,GAAG,MACjC1B,YAAY,GAAG2B,gBAAf,EADK;AAGP;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMC,gBAAgB,GAAG,MAC9B5B,YAAY,GAAG6B,aAAf,EADK"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["NativeModules","RNIapIosSk2","sync","isEligibleForIntroOffer","groupID","subscriptionStatus","sku","currentEntitlement","latestTransaction"],"sources":["iosSk2.ts"],"sourcesContent":["import {NativeModules} from 'react-native';\n\nimport type {Product, ProductPurchase, Purchase, Sku} from '../types';\nimport type {\n PaymentDiscountSk2,\n ProductSk2,\n ProductStatus,\n TransactionSk2,\n} from '../types/appleSk2';\n\nimport type {NativeModuleProps} from './common';\nconst {RNIapIosSk2} = NativeModules;\n\ntype getItems = (skus: Sku[]) => Promise<ProductSk2[]>;\n\ntype getAvailableItems = () => Promise<Purchase[]>;\n\nexport type BuyProduct = (\n sku: Sku,\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean,\n applicationUsername: string | undefined,\n quantity: number,\n withOffer: PaymentDiscountSk2 | undefined,\n) => Promise<Purchase>;\n\ntype clearTransaction = () => Promise<void>;\ntype clearProducts = () => Promise<void>;\ntype promotedProduct = () => Promise<Product | null>;\ntype buyPromotedProduct = () => Promise<void>;\ntype requestReceipt = (refresh: boolean) => Promise<string>;\n\ntype finishTransaction = (transactionIdentifier: string) => Promise<boolean>;\n\ntype getPendingTransactions = () => Promise<ProductPurchase[]>;\ntype presentCodeRedemptionSheet = () => Promise<null>;\n\nexport interface IosModulePropsSk2 extends NativeModuleProps {\n latestTransaction(sku: string): Promise<TransactionSk2>;\n currentEntitlement(sku: string): Promise<TransactionSk2>;\n subscriptionStatus(sku: string): Promise<ProductStatus[]>;\n isEligibleForIntroOffer(groupID: string): Promise<Boolean>;\n sync(): Promise<null>;\n getItems: getItems;\n getAvailableItems: getAvailableItems;\n buyProduct: BuyProduct;\n clearTransaction: clearTransaction;\n clearProducts: clearProducts;\n promotedProduct: promotedProduct;\n buyPromotedProduct: buyPromotedProduct;\n requestReceipt: requestReceipt;\n finishTransaction: finishTransaction;\n getPendingTransactions: getPendingTransactions;\n presentCodeRedemptionSheet: presentCodeRedemptionSheet;\n}\n\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n */\nexport const sync = (): Promise<null> => RNIapIosSk2.sync();\n\n/**\n *\n */\nexport const isEligibleForIntroOffer = (groupID: string): Promise<Boolean> =>\n RNIapIosSk2.isEligibleForIntroOffer(groupID);\n\n/**\n *\n */\n\nexport const subscriptionStatus = (sku: string): Promise<ProductStatus[]> =>\n RNIapIosSk2.subscriptionStatus(sku);\n\n/**\n *\n */\nexport const currentEntitlement = (sku: string): Promise<TransactionSk2> =>\n RNIapIosSk2.currentEntitlement(sku);\n\n/**\n *\n */\nexport const latestTransaction = (sku: string): Promise<TransactionSk2> =>\n RNIapIosSk2.latestTransaction(sku);\n"],"mappings":"AAAA,SAAQA,aAAR,QAA4B,cAA5B;AAWA,MAAM;EAACC;AAAD,IAAgBD,aAAtB;;
|
|
1
|
+
{"version":3,"names":["NativeModules","RNIapIosSk2","sync","isEligibleForIntroOffer","groupID","subscriptionStatus","sku","currentEntitlement","latestTransaction"],"sources":["iosSk2.ts"],"sourcesContent":["import {NativeModules} from 'react-native';\n\nimport type {Product, ProductPurchase, Purchase, Sku} from '../types';\nimport type {\n PaymentDiscountSk2,\n ProductSk2,\n ProductStatus,\n TransactionSk2,\n} from '../types/appleSk2';\n\nimport type {NativeModuleProps} from './common';\nconst {RNIapIosSk2} = NativeModules;\n\ntype getItems = (skus: Sku[]) => Promise<ProductSk2[]>;\n\ntype getAvailableItems = (\n alsoPublishToEventListener?: boolean,\n) => Promise<Purchase[]>;\n\nexport type BuyProduct = (\n sku: Sku,\n andDangerouslyFinishTransactionAutomaticallyIOS: boolean,\n applicationUsername: string | undefined,\n quantity: number,\n withOffer: Record<keyof PaymentDiscountSk2, string> | undefined,\n) => Promise<Purchase>;\n\ntype clearTransaction = () => Promise<void>;\ntype clearProducts = () => Promise<void>;\ntype promotedProduct = () => Promise<Product | null>;\ntype buyPromotedProduct = () => Promise<void>;\ntype requestReceipt = (refresh: boolean) => Promise<string>;\n\ntype finishTransaction = (transactionIdentifier: string) => Promise<boolean>;\n\ntype getPendingTransactions = () => Promise<ProductPurchase[]>;\ntype presentCodeRedemptionSheet = () => Promise<null>;\n\nexport interface IosModulePropsSk2 extends NativeModuleProps {\n latestTransaction(sku: string): Promise<TransactionSk2>;\n currentEntitlement(sku: string): Promise<TransactionSk2>;\n subscriptionStatus(sku: string): Promise<ProductStatus[]>;\n isEligibleForIntroOffer(groupID: string): Promise<Boolean>;\n sync(): Promise<null>;\n getItems: getItems;\n getAvailableItems: getAvailableItems;\n buyProduct: BuyProduct;\n clearTransaction: clearTransaction;\n clearProducts: clearProducts;\n promotedProduct: promotedProduct;\n buyPromotedProduct: buyPromotedProduct;\n requestReceipt: requestReceipt;\n finishTransaction: finishTransaction;\n getPendingTransactions: getPendingTransactions;\n presentCodeRedemptionSheet: presentCodeRedemptionSheet;\n disable: () => Promise<null>;\n}\n\n/**\n * Sync state with Appstore (iOS only)\n * https://developer.apple.com/documentation/storekit/appstore/3791906-sync\n */\nexport const sync = (): Promise<null> => RNIapIosSk2.sync();\n\n/**\n *\n */\nexport const isEligibleForIntroOffer = (groupID: string): Promise<Boolean> =>\n RNIapIosSk2.isEligibleForIntroOffer(groupID);\n\n/**\n *\n */\n\nexport const subscriptionStatus = (sku: string): Promise<ProductStatus[]> =>\n RNIapIosSk2.subscriptionStatus(sku);\n\n/**\n *\n */\nexport const currentEntitlement = (sku: string): Promise<TransactionSk2> =>\n RNIapIosSk2.currentEntitlement(sku);\n\n/**\n *\n */\nexport const latestTransaction = (sku: string): Promise<TransactionSk2> =>\n RNIapIosSk2.latestTransaction(sku);\n"],"mappings":"AAAA,SAAQA,aAAR,QAA4B,cAA5B;AAWA,MAAM;EAACC;AAAD,IAAgBD,aAAtB;;AA+CA;AACA;AACA;AACA;AACA,OAAO,MAAME,IAAI,GAAG,MAAqBD,WAAW,CAACC,IAAZ,EAAlC;AAEP;AACA;AACA;;AACA,OAAO,MAAMC,uBAAuB,GAAIC,OAAD,IACrCH,WAAW,CAACE,uBAAZ,CAAoCC,OAApC,CADK;AAGP;AACA;AACA;;AAEA,OAAO,MAAMC,kBAAkB,GAAIC,GAAD,IAChCL,WAAW,CAACI,kBAAZ,CAA+BC,GAA/B,CADK;AAGP;AACA;AACA;;AACA,OAAO,MAAMC,kBAAkB,GAAID,GAAD,IAChCL,WAAW,CAACM,kBAAZ,CAA+BD,GAA/B,CADK;AAGP;AACA;AACA;;AACA,OAAO,MAAME,iBAAiB,GAAIF,GAAD,IAC/BL,WAAW,CAACO,iBAAZ,CAA8BF,GAA9B,CADK"}
|
|
@@ -1,2 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Payment discount interface @see https://developer.apple.com/documentation/storekit/skpaymentdiscount?language=objc
|
|
3
|
+
*/
|
|
4
|
+
export const offerToRecord = offer => {
|
|
5
|
+
if (!offer) {
|
|
6
|
+
return undefined;
|
|
7
|
+
}
|
|
1
8
|
|
|
9
|
+
return {
|
|
10
|
+
identifier: offer.identifier,
|
|
11
|
+
keyIdentifier: offer.keyIdentifier,
|
|
12
|
+
nonce: offer.nonce,
|
|
13
|
+
signature: offer.signature,
|
|
14
|
+
timestamp: offer.timestamp.toString()
|
|
15
|
+
};
|
|
16
|
+
};
|
|
2
17
|
//# sourceMappingURL=apple.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":[],"sources":["apple.ts"],"sourcesContent":["/**\n * Payment discount interface @see https://developer.apple.com/documentation/storekit/skpaymentdiscount?language=objc\n */\nexport interface PaymentDiscount {\n /**\n * A string used to uniquely identify a discount offer for a product.\n */\n identifier: string;\n\n /**\n * A string that identifies the key used to generate the signature.\n */\n keyIdentifier: string;\n\n /**\n * A universally unique ID (UUID) value that you define.\n */\n nonce: string;\n\n /**\n * A UTF-8 string representing the properties of a specific discount offer, cryptographically signed.\n */\n signature: string;\n\n /**\n * The date and time of the signature's creation in milliseconds, formatted in Unix epoch time.\n */\n timestamp: number;\n}\n"],"mappings":""}
|
|
1
|
+
{"version":3,"names":["offerToRecord","offer","undefined","identifier","keyIdentifier","nonce","signature","timestamp","toString"],"sources":["apple.ts"],"sourcesContent":["/**\n * Payment discount interface @see https://developer.apple.com/documentation/storekit/skpaymentdiscount?language=objc\n */\nexport interface PaymentDiscount {\n /**\n * A string used to uniquely identify a discount offer for a product.\n */\n identifier: string;\n\n /**\n * A string that identifies the key used to generate the signature.\n */\n keyIdentifier: string;\n\n /**\n * A universally unique ID (UUID) value that you define.\n */\n nonce: string;\n\n /**\n * A UTF-8 string representing the properties of a specific discount offer, cryptographically signed.\n */\n signature: string;\n\n /**\n * The date and time of the signature's creation in milliseconds, formatted in Unix epoch time.\n */\n timestamp: number;\n}\n\nexport const offerToRecord = (\n offer: PaymentDiscount | undefined,\n): Record<keyof PaymentDiscount, string> | undefined => {\n if (!offer) {\n return undefined;\n }\n return {\n identifier: offer.identifier,\n keyIdentifier: offer.keyIdentifier,\n nonce: offer.nonce,\n signature: offer.signature,\n timestamp: offer.timestamp.toString(),\n };\n};\n"],"mappings":"AAAA;AACA;AACA;AA4BA,OAAO,MAAMA,aAAa,GACxBC,KAD2B,IAE2B;EACtD,IAAI,CAACA,KAAL,EAAY;IACV,OAAOC,SAAP;EACD;;EACD,OAAO;IACLC,UAAU,EAAEF,KAAK,CAACE,UADb;IAELC,aAAa,EAAEH,KAAK,CAACG,aAFhB;IAGLC,KAAK,EAAEJ,KAAK,CAACI,KAHR;IAILC,SAAS,EAAEL,KAAK,CAACK,SAJZ;IAKLC,SAAS,EAAEN,KAAK,CAACM,SAAN,CAAgBC,QAAhB;EALN,CAAP;AAOD,CAbM"}
|
|
@@ -13,7 +13,7 @@ export const productSk2Map = _ref => {
|
|
|
13
13
|
type: 'iap',
|
|
14
14
|
price: String(price),
|
|
15
15
|
localizedPrice: displayPrice,
|
|
16
|
-
currency: '' //
|
|
16
|
+
currency: '' // Not avaiable on new API, use localizedPrice instead
|
|
17
17
|
|
|
18
18
|
};
|
|
19
19
|
return prod;
|
|
@@ -33,7 +33,7 @@ export const subscriptionSk2Map = _ref2 => {
|
|
|
33
33
|
type: 'subs',
|
|
34
34
|
price: String(price),
|
|
35
35
|
localizedPrice: displayPrice,
|
|
36
|
-
currency: '' //
|
|
36
|
+
currency: '' // Not avaiable on new API, use localizedPrice instead
|
|
37
37
|
|
|
38
38
|
};
|
|
39
39
|
return prod;
|
|
@@ -76,7 +76,7 @@ export const offerSk2Map = offer => {
|
|
|
76
76
|
keyID: offer.keyIdentifier,
|
|
77
77
|
nonce: offer.nonce,
|
|
78
78
|
signature: offer.signature,
|
|
79
|
-
timestamp: offer.timestamp
|
|
79
|
+
timestamp: offer.timestamp.toString()
|
|
80
80
|
};
|
|
81
81
|
};
|
|
82
82
|
//# sourceMappingURL=appleSk2.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["productSk2Map","id","description","displayName","price","displayPrice","prod","title","productId","String","type","localizedPrice","currency","subscriptionSk2Map","transactionSk2Map","originalPurchaseDate","productID","purchaseDate","purchasedQuantity","purchase","transactionId","transactionDate","transactionReceipt","purchaseToken","quantityIOS","originalTransactionDateIOS","originalTransactionIdentifierIOS","offerSk2Map","offer","undefined","offerID","identifier","keyID","keyIdentifier","nonce","signature","timestamp"],"sources":["appleSk2.ts"],"sourcesContent":["import type {ProductIOS, Purchase, SubscriptionIOS} from '.';\nimport type * as Apple from './apple';\nexport type ProductSk2 = {\n description: string;\n displayName: string;\n displayPrice: string;\n id: number;\n isFamilyShareable: boolean;\n jsonRepresentation: string;\n price: number;\n subscription:
|
|
1
|
+
{"version":3,"names":["productSk2Map","id","description","displayName","price","displayPrice","prod","title","productId","String","type","localizedPrice","currency","subscriptionSk2Map","transactionSk2Map","originalPurchaseDate","productID","purchaseDate","purchasedQuantity","purchase","transactionId","transactionDate","transactionReceipt","purchaseToken","quantityIOS","originalTransactionDateIOS","originalTransactionIdentifierIOS","offerSk2Map","offer","undefined","offerID","identifier","keyID","keyIdentifier","nonce","signature","timestamp","toString"],"sources":["appleSk2.ts"],"sourcesContent":["import type {PurchaseError} from '../purchaseError';\n\nimport type {ProductIOS, Purchase, SubscriptionIOS} from '.';\nimport type * as Apple from './apple';\n\nexport type SubscriptionPeriod = {\n unit: 'day' | 'week' | 'month' | 'year';\n value: number;\n};\n\nexport type PaymentMode = 'freeTrial' | 'payAsYouGo' | 'payUpFront';\n\nexport type SubscriptionOffer = {\n displayPrice: string;\n id: string;\n paymentMode: PaymentMode;\n period: SubscriptionPeriod;\n periodCount: number;\n price: number;\n type: 'introductory' | 'promotional';\n};\n\nexport type SubscriptionInfo = {\n introductoryOffer?: SubscriptionOffer;\n promotionalOffers?: SubscriptionOffer[];\n subscriptionGroupID: string;\n subscriptionPeriod: SubscriptionPeriod;\n};\n\nexport type ProductSk2 = {\n description: string;\n displayName: string;\n displayPrice: string;\n id: number;\n isFamilyShareable: boolean;\n jsonRepresentation: string;\n price: number;\n subscription: SubscriptionInfo;\n type: 'autoRenewable' | 'consumable' | 'nonConsumable' | 'nonRenewable';\n};\nexport const productSk2Map = ({\n id,\n description,\n displayName,\n price,\n displayPrice,\n}: ProductSk2): ProductIOS => {\n const prod: ProductIOS = {\n title: displayName,\n productId: String(id),\n description,\n type: 'iap',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', // Not avaiable on new API, use localizedPrice instead\n };\n return prod;\n};\n\nexport const subscriptionSk2Map = ({\n id,\n description,\n displayName,\n price,\n displayPrice,\n}: ProductSk2): SubscriptionIOS => {\n const prod: SubscriptionIOS = {\n title: displayName,\n productId: String(id),\n description,\n type: 'subs',\n price: String(price),\n localizedPrice: displayPrice,\n currency: '', // Not avaiable on new API, use localizedPrice instead\n };\n return prod;\n};\n\nexport type TransactionSk2 = {\n appAccountToken: string;\n appBundleID: string;\n debugDescription: string;\n deviceVerification: string;\n deviceVerificationNonce: string;\n expirationDate: number;\n id: number;\n isUpgraded: boolean;\n jsonRepresentation: string;\n offerID: string;\n offerType: string;\n originalID: string;\n originalPurchaseDate: number;\n ownershipType: string;\n productID: string;\n productType: string;\n purchaseDate: number;\n purchasedQuantity: number;\n revocationDate: number;\n revocationReason: string;\n signedDate: number;\n subscriptionGroupID: number;\n webOrderLineItemID: number;\n};\n\nexport type TransactionError = PurchaseError;\n\n/**\n * Only one of `transaction` and `error` is not undefined at the time\n */\nexport type TransactionEvent = {\n transaction?: TransactionSk2;\n error?: TransactionError;\n};\n\nexport type SubscriptionStatus =\n | 'expired'\n | 'inBillingRetryPeriod'\n | 'inGracePeriod'\n | 'revoked'\n | 'subscribed';\n\nexport type ProductStatus = {\n state: SubscriptionStatus;\n};\n\nexport const transactionSk2Map = ({\n id,\n originalPurchaseDate,\n productID,\n purchaseDate,\n purchasedQuantity,\n}: TransactionSk2): Purchase => {\n const purchase: Purchase = {\n productId: productID,\n transactionId: String(id),\n transactionDate: purchaseDate, //??\n transactionReceipt: '', // Not available\n purchaseToken: '', //Not avaiable\n quantityIOS: purchasedQuantity,\n originalTransactionDateIOS: String(originalPurchaseDate),\n originalTransactionIdentifierIOS: String(id), // ??\n };\n return purchase;\n};\n\n/**\n * Payment discount interface @see https://developer.apple.com/documentation/storekit/skpaymentdiscount?language=objc\n */\nexport interface PaymentDiscountSk2 {\n /**\n * A string used to uniquely identify a discount offer for a product.\n */\n offerID: string;\n\n /**\n * A string that identifies the key used to generate the signature.\n */\n keyID: string;\n\n /**\n * A universally unique ID (UUID) value that you define.\n */\n nonce: string;\n\n /**\n * A UTF-8 string representing the properties of a specific discount offer, cryptographically signed.\n */\n signature: string;\n\n /**\n * The date and time of the signature's creation in milliseconds, formatted in Unix epoch time.\n */\n timestamp: number;\n}\n\nexport const offerSk2Map = (\n offer: Apple.PaymentDiscount | undefined,\n): Record<keyof PaymentDiscountSk2, string> | undefined => {\n if (!offer) {\n return undefined;\n }\n return {\n offerID: offer.identifier,\n keyID: offer.keyIdentifier,\n nonce: offer.nonce,\n signature: offer.signature,\n timestamp: offer.timestamp.toString(),\n };\n};\n"],"mappings":"AAwCA,OAAO,MAAMA,aAAa,GAAG,QAMC;EAAA,IANA;IAC5BC,EAD4B;IAE5BC,WAF4B;IAG5BC,WAH4B;IAI5BC,KAJ4B;IAK5BC;EAL4B,CAMA;EAC5B,MAAMC,IAAgB,GAAG;IACvBC,KAAK,EAAEJ,WADgB;IAEvBK,SAAS,EAAEC,MAAM,CAACR,EAAD,CAFM;IAGvBC,WAHuB;IAIvBQ,IAAI,EAAE,KAJiB;IAKvBN,KAAK,EAAEK,MAAM,CAACL,KAAD,CALU;IAMvBO,cAAc,EAAEN,YANO;IAOvBO,QAAQ,EAAE,EAPa,CAOT;;EAPS,CAAzB;EASA,OAAON,IAAP;AACD,CAjBM;AAmBP,OAAO,MAAMO,kBAAkB,GAAG,SAMC;EAAA,IANA;IACjCZ,EADiC;IAEjCC,WAFiC;IAGjCC,WAHiC;IAIjCC,KAJiC;IAKjCC;EALiC,CAMA;EACjC,MAAMC,IAAqB,GAAG;IAC5BC,KAAK,EAAEJ,WADqB;IAE5BK,SAAS,EAAEC,MAAM,CAACR,EAAD,CAFW;IAG5BC,WAH4B;IAI5BQ,IAAI,EAAE,MAJsB;IAK5BN,KAAK,EAAEK,MAAM,CAACL,KAAD,CALe;IAM5BO,cAAc,EAAEN,YANY;IAO5BO,QAAQ,EAAE,EAPkB,CAOd;;EAPc,CAA9B;EASA,OAAON,IAAP;AACD,CAjBM;AAkEP,OAAO,MAAMQ,iBAAiB,GAAG,SAMD;EAAA,IANE;IAChCb,EADgC;IAEhCc,oBAFgC;IAGhCC,SAHgC;IAIhCC,YAJgC;IAKhCC;EALgC,CAMF;EAC9B,MAAMC,QAAkB,GAAG;IACzBX,SAAS,EAAEQ,SADc;IAEzBI,aAAa,EAAEX,MAAM,CAACR,EAAD,CAFI;IAGzBoB,eAAe,EAAEJ,YAHQ;IAGM;IAC/BK,kBAAkB,EAAE,EAJK;IAID;IACxBC,aAAa,EAAE,EALU;IAKN;IACnBC,WAAW,EAAEN,iBANY;IAOzBO,0BAA0B,EAAEhB,MAAM,CAACM,oBAAD,CAPT;IAQzBW,gCAAgC,EAAEjB,MAAM,CAACR,EAAD,CARf,CAQqB;;EARrB,CAA3B;EAUA,OAAOkB,QAAP;AACD,CAlBM;AAoBP;AACA;AACA;;AA4BA,OAAO,MAAMQ,WAAW,GACtBC,KADyB,IAEgC;EACzD,IAAI,CAACA,KAAL,EAAY;IACV,OAAOC,SAAP;EACD;;EACD,OAAO;IACLC,OAAO,EAAEF,KAAK,CAACG,UADV;IAELC,KAAK,EAAEJ,KAAK,CAACK,aAFR;IAGLC,KAAK,EAAEN,KAAK,CAACM,KAHR;IAILC,SAAS,EAAEP,KAAK,CAACO,SAJZ;IAKLC,SAAS,EAAER,KAAK,CAACQ,SAAN,CAAgBC,QAAhB;EALN,CAAP;AAOD,CAbM"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid","ProductType"],"sources":["index.ts"],"sourcesContent":["import type {\n AmazonModuleProps,\n AndroidModuleProps,\n IosModuleProps,\n} from '../modules';\nimport type {IosModulePropsSk2} from '../modules/iosSk2';\n\nimport type * as Apple from './apple';\n\nexport type Sku = string;\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n IMMEDIATE_AND_CHARGE_FULL_PRICE = 5,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport enum ProductType {\n /** Subscription */\n subs = 'subs',\n\n /** Subscription */\n sub = 'sub',\n\n /** Consumable */\n inapp = 'inapp',\n\n /** Consumable */\n iap = 'iap',\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string; //iOS\n productIds?: string[];\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n //Android\n productIds?: string[];\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n //Amazon\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n isCanceledAmazon?: boolean;\n}\n\nexport interface PurchaseResult {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n purchaseToken?: string;\n}\n\nexport interface SubscriptionPurchase extends ProductPurchase {\n autoRenewingAndroid?: boolean;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n}\n\nexport type Purchase = ProductPurchase | 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 ProductAndroid extends ProductCommon {\n type: 'inapp' | 'iap';\n oneTimePurchaseOfferDetails?: {\n priceCurrencyCode: string;\n formattedPrice: string;\n priceAmountMicros: string;\n };\n}\nexport interface ProductIOS extends ProductCommon {\n type: 'inapp' | 'iap';\n}\n\nexport type Product = ProductAndroid & ProductIOS;\n\n// Android V5\nexport interface SubscriptionAndroid extends ProductCommon {\n type: 'subs';\n\n productType?: string;\n name?: string;\n subscriptionOfferDetails?: {\n offerToken: string;\n pricingPhases: {\n pricingPhaseList: {\n formattedPrice: string;\n priceCurrencyCode: string;\n /**\n * P1W, P1M, P1Y\n */\n billingPeriod: string;\n billingCycleCount: number;\n priceAmountMicros: string;\n recurrenceMode: number;\n }[];\n };\n }[];\n}\n\nexport interface SubscriptionIOS extends ProductCommon {\n type: 'subs';\n discounts?: Discount[];\n introductoryPrice?: string;\n introductoryPriceAsAmountIOS?: string;\n introductoryPricePaymentModeIOS?:\n | ''\n | 'FREETRIAL'\n | 'PAYASYOUGO'\n | 'PAYUPFRONT';\n introductoryPriceNumberOfPeriodsIOS?: string;\n introductoryPriceSubscriptionPeriodIOS?:\n | 'DAY'\n | 'WEEK'\n | 'MONTH'\n | 'YEAR'\n | '';\n\n subscriptionPeriodNumberIOS?: string;\n subscriptionPeriodUnitIOS?: '' | 'YEAR' | 'MONTH' | 'WEEK' | 'DAY';\n}\n\nexport type Subscription = SubscriptionAndroid & SubscriptionIOS;\nexport interface RequestPurchaseBaseAndroid {\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n isOfferPersonalized?: boolean; // For AndroidBilling V5 https://developer.android.com/google/play/billing/integrate#personalized-price\n}\n\nexport interface RequestPurchaseAndroid extends RequestPurchaseBaseAndroid {\n skus?: Sku[];\n}\n\nexport interface RequestPurchaseIOS {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n /**\n * UUID representing user account\n */\n appAccountToken?: string;\n quantity?: number;\n withOffer?: Apple.PaymentDiscount;\n}\n\nexport type RequestPurchase = RequestPurchaseAndroid & RequestPurchaseIOS;\n\n/**\n * In order to purchase a new subscription, every sku must have a selected offerToken\n * @see SubscriptionAndroid.subscriptionOfferDetails.offerToken\n */\nexport interface SubscriptionOffer {\n sku: Sku;\n offerToken: string;\n}\n\nexport interface RequestSubscriptionAndroid extends RequestPurchaseBaseAndroid {\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n subscriptionOffers?: SubscriptionOffer[]; // For AndroidBilling V5\n}\n\nexport type RequestSubscriptionIOS = RequestPurchaseIOS;\n\nexport type RequestSubscription = RequestSubscriptionAndroid &\n RequestSubscriptionIOS;\n\ndeclare module 'react-native' {\n interface NativeModulesStatic {\n RNIapIos: IosModuleProps;\n RNIapIosSk2: IosModulePropsSk2;\n RNIapModule: AndroidModuleProps;\n RNIapAmazonModule: AmazonModuleProps;\n }\n}\n"],"mappings":"AAWA,WAAYA,qBAAZ;;WAAYA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,KAAAA,qB;;AASZ,WAAYC,oBAAZ;;WAAYA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,KAAAA,oB;;AAMZ,OAAO,MAAMC,gBAAgB,GAAG,sBAAzB;AAEP,WAAYC,oBAAZ;;WAAYA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,KAAAA,oB;;AAMZ,WAAYC,WAAZ;;WAAYA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,KAAAA,W"}
|
|
1
|
+
{"version":3,"names":["ProrationModesAndroid","PurchaseStateAndroid","PROMOTED_PRODUCT","InstallSourceAndroid","ProductType"],"sources":["index.ts"],"sourcesContent":["import type {\n AmazonModuleProps,\n AndroidModuleProps,\n IosModuleProps,\n} from '../modules';\nimport type {IosModulePropsSk2} from '../modules/iosSk2';\n\nimport type * as Apple from './apple';\n\nexport type Sku = string;\n\nexport enum ProrationModesAndroid {\n IMMEDIATE_WITH_TIME_PRORATION = 1,\n IMMEDIATE_AND_CHARGE_PRORATED_PRICE = 2,\n IMMEDIATE_WITHOUT_PRORATION = 3,\n DEFERRED = 4,\n IMMEDIATE_AND_CHARGE_FULL_PRICE = 5,\n UNKNOWN_SUBSCRIPTION_UPGRADE_DOWNGRADE_POLICY = 0,\n}\n\nexport enum PurchaseStateAndroid {\n UNSPECIFIED_STATE = 0,\n PURCHASED = 1,\n PENDING = 2,\n}\n\nexport const PROMOTED_PRODUCT = 'iap-promoted-product';\n\nexport enum InstallSourceAndroid {\n NOT_SET = 0,\n GOOGLE_PLAY = 1,\n AMAZON = 2,\n}\n\nexport enum ProductType {\n /** Subscription */\n subs = 'subs',\n\n /** Subscription */\n sub = 'sub',\n\n /** Consumable */\n inapp = 'inapp',\n\n /** Consumable */\n iap = 'iap',\n}\n\nexport interface ProductCommon {\n type: 'subs' | 'sub' | 'inapp' | 'iap';\n productId: string; //iOS\n productIds?: string[];\n title: string;\n description: string;\n price: string;\n currency: string;\n localizedPrice: string;\n countryCode?: string;\n}\n\nexport interface ProductPurchase {\n productId: string;\n transactionId?: string;\n transactionDate: number;\n transactionReceipt: string;\n purchaseToken?: string;\n //iOS\n quantityIOS?: number;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n //Android\n productIds?: string[];\n dataAndroid?: string;\n signatureAndroid?: string;\n autoRenewingAndroid?: boolean;\n purchaseStateAndroid?: PurchaseStateAndroid;\n isAcknowledgedAndroid?: boolean;\n packageNameAndroid?: string;\n developerPayloadAndroid?: string;\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n //Amazon\n userIdAmazon?: string;\n userMarketplaceAmazon?: string;\n userJsonAmazon?: string;\n isCanceledAmazon?: boolean;\n}\n\nexport interface PurchaseResult {\n responseCode?: number;\n debugMessage?: string;\n code?: string;\n message?: string;\n purchaseToken?: string;\n}\n\nexport interface SubscriptionPurchase extends ProductPurchase {\n autoRenewingAndroid?: boolean;\n originalTransactionDateIOS?: string;\n originalTransactionIdentifierIOS?: string;\n}\n\nexport type Purchase = ProductPurchase | 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 ProductAndroid extends ProductCommon {\n type: 'inapp' | 'iap';\n oneTimePurchaseOfferDetails?: {\n priceCurrencyCode: string;\n formattedPrice: string;\n priceAmountMicros: string;\n };\n}\nexport interface ProductIOS extends ProductCommon {\n type: 'inapp' | 'iap';\n}\n\nexport type Product = ProductAndroid & ProductIOS;\n\n// Android V5\nexport interface SubscriptionAndroid extends ProductCommon {\n type: 'subs';\n\n productType?: string;\n name?: string;\n subscriptionOfferDetails?: {\n offerToken: string;\n pricingPhases: {\n pricingPhaseList: {\n formattedPrice: string;\n priceCurrencyCode: string;\n /**\n * P1W, P1M, P1Y\n */\n billingPeriod: string;\n billingCycleCount: number;\n priceAmountMicros: string;\n recurrenceMode: number;\n }[];\n };\n offerTags: string[];\n }[];\n}\n\nexport interface SubscriptionIOS extends ProductCommon {\n type: 'subs';\n discounts?: Discount[];\n introductoryPrice?: string;\n introductoryPriceAsAmountIOS?: string;\n introductoryPricePaymentModeIOS?:\n | ''\n | 'FREETRIAL'\n | 'PAYASYOUGO'\n | 'PAYUPFRONT';\n introductoryPriceNumberOfPeriodsIOS?: string;\n introductoryPriceSubscriptionPeriodIOS?:\n | 'DAY'\n | 'WEEK'\n | 'MONTH'\n | 'YEAR'\n | '';\n\n subscriptionPeriodNumberIOS?: string;\n subscriptionPeriodUnitIOS?: '' | 'YEAR' | 'MONTH' | 'WEEK' | 'DAY';\n}\n\nexport type Subscription = SubscriptionAndroid & SubscriptionIOS;\nexport interface RequestPurchaseBaseAndroid {\n obfuscatedAccountIdAndroid?: string;\n obfuscatedProfileIdAndroid?: string;\n isOfferPersonalized?: boolean; // For AndroidBilling V5 https://developer.android.com/google/play/billing/integrate#personalized-price\n}\n\nexport interface RequestPurchaseAndroid extends RequestPurchaseBaseAndroid {\n skus?: Sku[];\n}\n\nexport interface RequestPurchaseIOS {\n sku?: Sku;\n andDangerouslyFinishTransactionAutomaticallyIOS?: boolean;\n /**\n * UUID representing user account\n */\n appAccountToken?: string;\n quantity?: number;\n withOffer?: Apple.PaymentDiscount;\n}\n\nexport type RequestPurchase = RequestPurchaseAndroid & RequestPurchaseIOS;\n\n/**\n * In order to purchase a new subscription, every sku must have a selected offerToken\n * @see SubscriptionAndroid.subscriptionOfferDetails.offerToken\n */\nexport interface SubscriptionOffer {\n sku: Sku;\n offerToken: string;\n}\n\nexport interface RequestSubscriptionAndroid extends RequestPurchaseBaseAndroid {\n purchaseTokenAndroid?: string;\n prorationModeAndroid?: ProrationModesAndroid;\n subscriptionOffers?: SubscriptionOffer[]; // For AndroidBilling V5\n}\n\nexport type RequestSubscriptionIOS = RequestPurchaseIOS;\n\nexport type RequestSubscription = RequestSubscriptionAndroid &\n RequestSubscriptionIOS;\n\ndeclare module 'react-native' {\n interface NativeModulesStatic {\n RNIapIos: IosModuleProps;\n RNIapIosSk2: IosModulePropsSk2;\n RNIapModule: AndroidModuleProps;\n RNIapAmazonModule: AmazonModuleProps;\n }\n}\n"],"mappings":"AAWA,WAAYA,qBAAZ;;WAAYA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;EAAAA,qB,CAAAA,qB;GAAAA,qB,KAAAA,qB;;AASZ,WAAYC,oBAAZ;;WAAYA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,KAAAA,oB;;AAMZ,OAAO,MAAMC,gBAAgB,GAAG,sBAAzB;AAEP,WAAYC,oBAAZ;;WAAYA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;EAAAA,oB,CAAAA,oB;GAAAA,oB,KAAAA,oB;;AAMZ,WAAYC,WAAZ;;WAAYA,W;EAAAA,W;EAAAA,W;EAAAA,W;EAAAA,W;GAAAA,W,KAAAA,W"}
|
|
@@ -1,17 +1,150 @@
|
|
|
1
1
|
import { EmitterSubscription } from 'react-native';
|
|
2
|
+
import { TransactionEvent } from './types/appleSk2';
|
|
2
3
|
import type { PurchaseError } from './purchaseError';
|
|
3
4
|
import type { Purchase } from './types';
|
|
4
5
|
/**
|
|
5
6
|
* Add IAP purchase event
|
|
7
|
+
* Register a callback that gets called when the store has any updates to purchases that have not yet been finished, consumed or acknowledged. Returns a React Native `EmitterSubscription` on which you can call `.remove()` to stop receiving updates. Register you listener as soon as possible and react to updates at all times.
|
|
8
|
+
|
|
9
|
+
## Signature
|
|
10
|
+
|
|
11
|
+
```ts
|
|
12
|
+
purchaseUpdatedListener((purchase: Purchase) => {});
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Usage
|
|
16
|
+
|
|
17
|
+
```tsx
|
|
18
|
+
import React, {useEffect} from 'react';
|
|
19
|
+
import {View} from 'react-native';
|
|
20
|
+
import {purchaseUpdatedListener} from 'react-native-iap';
|
|
21
|
+
|
|
22
|
+
const App = () => {
|
|
23
|
+
useEffect(() => {
|
|
24
|
+
const subscription = purchaseUpdatedListener((purchase: Purchase) => {
|
|
25
|
+
console.log(purchase);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return () => {
|
|
29
|
+
subscription.remove();
|
|
30
|
+
};
|
|
31
|
+
}, []);
|
|
32
|
+
|
|
33
|
+
return <View />;
|
|
34
|
+
};
|
|
35
|
+
```
|
|
6
36
|
*/
|
|
7
37
|
export declare const purchaseUpdatedListener: (listener: (event: Purchase) => void) => EmitterSubscription;
|
|
8
38
|
/**
|
|
9
39
|
* Add IAP purchase error event
|
|
40
|
+
* Register a callback that gets called when there has been an error with a purchase. Returns a React Native `EmitterSubscription` on which you can call `.remove()` to stop receiving updates.
|
|
41
|
+
|
|
42
|
+
## Signature
|
|
43
|
+
|
|
44
|
+
```ts
|
|
45
|
+
purchaseErrorListener((error: PurchaseError) => {});
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
```tsx
|
|
51
|
+
import React, {useEffect} from 'react';
|
|
52
|
+
import {View} from 'react-native';
|
|
53
|
+
import {purchaseErrorListener} from 'react-native-iap';
|
|
54
|
+
|
|
55
|
+
const App = () => {
|
|
56
|
+
useEffect(() => {
|
|
57
|
+
const subscription = purchaseErrorListener((error: PurchaseError) => {
|
|
58
|
+
console.log(error);
|
|
59
|
+
});
|
|
60
|
+
|
|
61
|
+
return () => {
|
|
62
|
+
subscription.remove();
|
|
63
|
+
};
|
|
64
|
+
}, []);
|
|
65
|
+
|
|
66
|
+
return <View />;
|
|
67
|
+
};
|
|
68
|
+
```
|
|
69
|
+
|
|
10
70
|
*/
|
|
11
71
|
export declare const purchaseErrorListener: (listener: (error: PurchaseError) => void) => EmitterSubscription;
|
|
12
72
|
/**
|
|
13
73
|
* Add IAP promoted subscription event
|
|
74
|
+
* Add IAP promoted subscription event.
|
|
75
|
+
|
|
76
|
+
## Signature
|
|
77
|
+
|
|
78
|
+
```ts
|
|
79
|
+
promotedProductListener((productId?: string) => {});
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
## Usage
|
|
83
|
+
|
|
84
|
+
```tsx
|
|
85
|
+
import React, {useEffect} from 'react';
|
|
86
|
+
import {View} from 'react-native';
|
|
87
|
+
import {promotedProductListener} from 'react-native-iap';
|
|
88
|
+
|
|
89
|
+
const App = () => {
|
|
90
|
+
useEffect(() => {
|
|
91
|
+
const subscription = promotedProductListener((productId) => {
|
|
92
|
+
console.log(productId);
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
return () => {
|
|
96
|
+
subscription.remove();
|
|
97
|
+
};
|
|
98
|
+
}, []);
|
|
99
|
+
|
|
100
|
+
return <View />;
|
|
101
|
+
};
|
|
102
|
+
```
|
|
103
|
+
|
|
14
104
|
*
|
|
15
105
|
* @platform iOS
|
|
16
106
|
*/
|
|
17
107
|
export declare const promotedProductListener: (listener: () => void) => EmitterSubscription | null;
|
|
108
|
+
/**
|
|
109
|
+
* Updated transactions for iOS Sk2
|
|
110
|
+
* Register a callback that gets called when the store has any updates to transactions related to purchases that have not yet been finished, consumed or acknowledged.
|
|
111
|
+
* Returns a React Native `EmitterSubscription` on which you can call `.remove()` to stop receiving updates. Register you listener as soon as possible and react to updates at all times.
|
|
112
|
+
|
|
113
|
+
**Warning**
|
|
114
|
+
This is only available for iOS 15 and higher and Storekit 2 is activated
|
|
115
|
+
|
|
116
|
+
## Signature
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
purchaseUpdatedListener((transactionOrError: TransactionOrError) => {});
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
## Usage
|
|
123
|
+
|
|
124
|
+
```tsx
|
|
125
|
+
import React, {useEffect} from 'react';
|
|
126
|
+
import {View} from 'react-native';
|
|
127
|
+
import {purchaseUpdatedListener} from 'react-native-iap';
|
|
128
|
+
|
|
129
|
+
const App = () => {
|
|
130
|
+
useEffect(() => {
|
|
131
|
+
const subscription = purchaseUpdatedListener((transactionOrError: TransactionOrError) => {
|
|
132
|
+
if(transactionOrError.transaction){
|
|
133
|
+
console.log("There's an update to a transaction", transactionOrError.transaction);
|
|
134
|
+
}else{
|
|
135
|
+
console.log("There's been an error with a received transaction")
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
|
|
139
|
+
return () => {
|
|
140
|
+
subscription.remove();
|
|
141
|
+
};
|
|
142
|
+
}, []);
|
|
143
|
+
|
|
144
|
+
return <View />;
|
|
145
|
+
};
|
|
146
|
+
```
|
|
147
|
+
*
|
|
148
|
+
* @platform iOS (Sk2)
|
|
149
|
+
*/
|
|
150
|
+
export declare const transactionListener: (listener: (event: TransactionEvent) => void) => EmitterSubscription | null;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { PurchaseError } from '../purchaseError';
|
|
3
3
|
import type { Product, Purchase, Subscription } from '../types';
|
|
4
|
+
import type { TransactionSk2 } from '../types/appleSk2';
|
|
4
5
|
declare type IAPContextType = {
|
|
5
6
|
connected: boolean;
|
|
6
7
|
products: Product[];
|
|
@@ -9,6 +10,7 @@ declare type IAPContextType = {
|
|
|
9
10
|
purchaseHistory: Purchase[];
|
|
10
11
|
availablePurchases: Purchase[];
|
|
11
12
|
currentPurchase?: Purchase;
|
|
13
|
+
currentTransaction?: TransactionSk2;
|
|
12
14
|
currentPurchaseError?: PurchaseError;
|
|
13
15
|
initConnectionError?: Error;
|
|
14
16
|
setProducts: (products: Product[]) => void;
|