react-native-iap 11.0.0-rc.4 → 11.0.0-rc.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ios/RNIapIos.swift +0 -1
- package/ios/RNIapIosSk2.m +1 -1
- package/ios/RNIapIosSk2.swift +5 -5
- package/lib/commonjs/iap.js +10 -2
- package/lib/commonjs/iap.js.map +1 -1
- package/lib/commonjs/modules/iosSk2.js.map +1 -1
- package/lib/module/iap.js +11 -3
- package/lib/module/iap.js.map +1 -1
- package/lib/module/modules/iosSk2.js.map +1 -1
- package/lib/typescript/modules/iosSk2.d.ts +1 -1
- package/package.json +1 -1
- package/src/iap.ts +19 -2
- package/src/modules/iosSk2.ts +1 -1
package/ios/RNIapIos.swift
CHANGED
|
@@ -193,7 +193,6 @@ class RNIapIos: RCTEventEmitter, SKRequestDelegate, SKPaymentTransactionObserver
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
@objc public func getAvailableItems(
|
|
196
|
-
alsoPublishToEventListener: Bool,
|
|
197
196
|
_ resolve: @escaping RCTPromiseResolveBlock = { _ in },
|
|
198
197
|
reject: @escaping RCTPromiseRejectBlock = { _, _, _ in }
|
|
199
198
|
) {
|
package/ios/RNIapIosSk2.m
CHANGED
|
@@ -22,7 +22,7 @@ RCT_EXTERN_METHOD(getItems:
|
|
|
22
22
|
reject:(RCTPromiseRejectBlock)reject)
|
|
23
23
|
|
|
24
24
|
RCT_EXTERN_METHOD(getAvailableItems:
|
|
25
|
-
|
|
25
|
+
(BOOL)alsoPublishToEventListener
|
|
26
26
|
resolve:(RCTPromiseResolveBlock)resolve
|
|
27
27
|
reject:(RCTPromiseRejectBlock)reject)
|
|
28
28
|
|
package/ios/RNIapIosSk2.swift
CHANGED
|
@@ -131,9 +131,9 @@ class RNIapIosSk2: RCTEventEmitter {
|
|
|
131
131
|
Task {
|
|
132
132
|
do {
|
|
133
133
|
let products = try await Product.products(for: skus)
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
}
|
|
134
|
+
products.forEach({(prod) in
|
|
135
|
+
self.products[prod.id] = prod
|
|
136
|
+
})
|
|
137
137
|
resolve(products.map({ (prod: Product) -> [String: Any?]? in
|
|
138
138
|
return serialize(prod)
|
|
139
139
|
}).compactMap({$0}))
|
|
@@ -144,8 +144,8 @@ class RNIapIosSk2: RCTEventEmitter {
|
|
|
144
144
|
}
|
|
145
145
|
|
|
146
146
|
@objc public func getAvailableItems(
|
|
147
|
-
alsoPublishToEventListener: Bool,
|
|
148
|
-
|
|
147
|
+
_ alsoPublishToEventListener: Bool,
|
|
148
|
+
resolve: @escaping RCTPromiseResolveBlock = { _ in },
|
|
149
149
|
reject: @escaping RCTPromiseRejectBlock = { _, _, _ in }
|
|
150
150
|
) {
|
|
151
151
|
Task {
|
package/lib/commonjs/iap.js
CHANGED
|
@@ -291,7 +291,11 @@ const getPurchaseHistory = function () {
|
|
|
291
291
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
292
292
|
return (_reactNative.Platform.select({
|
|
293
293
|
ios: async () => {
|
|
294
|
-
|
|
294
|
+
if ((0, _internal.isIosStorekit2)()) {
|
|
295
|
+
return Promise.resolve((await RNIapIosSk2.getAvailableItems(alsoPublishToEventListener)).map(_appleSk.transactionSk2Map));
|
|
296
|
+
} else {
|
|
297
|
+
return RNIapIos.getAvailableItems();
|
|
298
|
+
}
|
|
295
299
|
},
|
|
296
300
|
android: async () => {
|
|
297
301
|
if (RNIapAmazonModule) {
|
|
@@ -394,7 +398,11 @@ const getAvailablePurchases = function () {
|
|
|
394
398
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
395
399
|
return (_reactNative.Platform.select({
|
|
396
400
|
ios: async () => {
|
|
397
|
-
|
|
401
|
+
if ((0, _internal.isIosStorekit2)()) {
|
|
402
|
+
return Promise.resolve((await RNIapIosSk2.getAvailableItems(alsoPublishToEventListener)).map(_appleSk.transactionSk2Map));
|
|
403
|
+
} else {
|
|
404
|
+
return RNIapIos.getAvailableItems();
|
|
405
|
+
}
|
|
398
406
|
},
|
|
399
407
|
android: async () => {
|
|
400
408
|
if (RNIapAmazonModule) {
|
package/lib/commonjs/iap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","NativeModules","ANDROID_ITEM_TYPE_SUBSCRIPTION","ProductType","subs","ANDROID_ITEM_TYPE_IAP","inapp","setup","storekitMode","storekit1Mode","storekit2Mode","storekitHybridMode","initConnection","getNativeModule","endConnection","flushFailedPurchasesCachedAsPendingAndroid","getAndroidModule","flushFailedPurchasesCachedAsPending","getProducts","skus","Platform","select","ios","items","isIosStorekit2","getItems","map","productSk2Map","filter","item","includes","productId","type","android","products","getItemsByType","fillProductsWithAdditionalData","Promise","reject","Error","getSubscriptions","subscriptionSk2Map","subscriptions","getPurchaseHistory","alsoPublishToEventListener","getIosModule","getAvailableItems","getPurchaseHistoryByType","concat","resolve","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","appAccountToken","isOfferPersonalized","undefined","quantity","withOffer","console","warn","offer","offerSk2Map","buyProduct","offerToRecord","isAmazon","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","so","offerToken","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","purchaseToken","consumeProduct","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","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;;AAEA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;AACA;;AAMA;;AAWA;;;;;;AAcA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC,WAAxB;EAAqCC;AAArC,IAA0DC,0BAAhE;AACA,MAAMC,8BAA8B,GAAGC,kBAAA,CAAYC,IAAnD;AACA,MAAMC,qBAAqB,GAAGF,kBAAA,CAAYG,KAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMO,MAAMC,KAAK,GAAG,YAIV;EAAA,IAJW;IACpBC,YAAY,GAAG;EADK,CAIX,uEAAP,EAAO;;EACT,QAAQA,YAAR;IACE,KAAK,gBAAL;MACE,IAAAC,uBAAA;MACA;;IACF,KAAK,gBAAL;MACE,IAAAC,uBAAA;MACA;;IACF,KAAK,sBAAL;MACE,IAAAC,4BAAA;MACA;;IACF;MACE;EAXJ;AAaD,CAlBM;AAoBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,cAAc,GAAG,MAC5B,IAAAC,yBAAA,IAAkBD,cAAlB,EADK;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAME,aAAa,GAAG,MAC3B,IAAAD,yBAAA,IAAkBC,aAAlB,EADK;AAGP;AACA;AACA;AACA;;;;;AACO,MAAMC,0CAA0C,GACrD,MACE,IAAAC,0BAAA,IAAmBC,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;;;;;AACO,MAAMC,WAAW,GAAG;EAAA,IAAC;IAC1BC;EAD0B,CAAD;EAAA,OAKzB,CACEC,qBAAA,CAASC,MAAT,CAAgB;IACdC,GAAG,EAAE,YAAY;MACf,IAAIC,K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ACA;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;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,qBAAqB,GAAG;EAAA,IAAC;IACpCN,0BAA0B,GAAG;EADO,CAAD,uEAEO,EAFP;EAAA,OAKnC,CACExB,qBAAA,CAASC,MAAT,CAAgB;IACdC,GAAG,EAAE,YAAY;MACf,OAAO,IAAAuB,sBAAA,IAAeC,iBAAf,CAAiCF,0BAAjC,CAAP;IACD,CAHa;IAIdX,OAAO,EAAE,YAAY;MACnB,IAAIjC,iBAAJ,EAAuB;QACrB,OAAO,MAAMA,iBAAiB,CAAC8C,iBAAlB,EAAb;MACD;;MAED,MAAMZ,QAAQ,GAAG,MAAMnC,WAAW,CAACoD,uBAAZ,CACrB9C,qBADqB,CAAvB;MAIA,MAAMqC,aAAa,GAAG,MAAM3C,WAAW,CAACoD,uBAAZ,CAC1BjD,8BAD0B,CAA5B;MAIA,OAAOgC,QAAQ,CAACc,MAAT,CAAgBN,aAAhB,CAAP;IACD;EAlBa,CAAhB,MAmBO,MAAML,OAAO,CAACY,OAAR,CAAgB,EAAhB,CAnBb,CADF,GALmC;AAAA,CAA9B;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;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CAAP;MACD,CAPD,MAOO;QACL,IAAI,EAACA,GAAD,aAACA,GAAD,eAACA,GAAG,CAAEiB,MAAN,KAAgB,CAACjB,GAArB,EAA0B;UACxB,OAAOhB,OAAO,CAACC,MAAR,CACL,IAAIC,KAAJ,CAAU,uCAAV,CADK,CAAP;QAGD;;QACD,OAAO,IAAAvB,0BAAA,IAAmBqD,aAAnB,CACLhE,qBADK,EAELc,IAAI,SAAJ,IAAAA,IAAI,WAAJ,IAAAA,IAAI,CAAEmD,MAAN,GAAenD,IAAf,GAAsB,CAACkC,GAAD,CAFjB,EAGLM,SAHK,EAIL,CAAC,CAJI,EAKLJ,0BALK,EAMLC,0BANK,EAOL,EAPK,EAQLE,mBAAmB,IAAI,KARlB,CAAP;MAUD;IACF;EAvDa,CAAhB,KAwDMrB,OAAO,CAACY,OAzDhB,GAX6B;AAAA,CAAxB;AAuEP;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMsB,mBAAmB,GAAG;EAAA,IAAC;IAClClB,GADkC;IAElCC,+CAA+C,GAAG,KAFhB;IAGlCkB,oBAHkC;IAIlCC,oBAAoB,GAAG,CAAC,CAJU;IAKlClB,0BALkC;IAMlCC,0BANkC;IAOlCkB,kBAAkB,GAAGf,SAPa;IAOF;IAChCD,mBAAmB,GAAGC,SARY;IAQD;IACjCF,eATkC;IAUlCG,QAVkC;IAWlCC;EAXkC,CAAD;EAAA,OAajC,CACEzC,qBAAA,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AO3C,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":["RNIapIos","RNIapIosSk2","RNIapModule","RNIapAmazonModule","NativeModules","ANDROID_ITEM_TYPE_SUBSCRIPTION","ProductType","subs","ANDROID_ITEM_TYPE_IAP","inapp","setup","storekitMode","storekit1Mode","storekit2Mode","storekitHybridMode","initConnection","getNativeModule","endConnection","flushFailedPurchasesCachedAsPendingAndroid","getAndroidModule","flushFailedPurchasesCachedAsPending","getProducts","skus","Platform","select","ios","items","isIosStorekit2","getItems","map","productSk2Map","filter","item","includes","productId","type","android","products","getItemsByType","fillProductsWithAdditionalData","Promise","reject","Error","getSubscriptions","subscriptionSk2Map","subscriptions","getPurchaseHistory","alsoPublishToEventListener","resolve","getAvailableItems","transactionSk2Map","getPurchaseHistoryByType","concat","getAvailablePurchases","getAvailableItemsByType","requestPurchase","sku","andDangerouslyFinishTransactionAutomaticallyIOS","obfuscatedAccountIdAndroid","obfuscatedProfileIdAndroid","appAccountToken","isOfferPersonalized","undefined","quantity","withOffer","console","warn","offer","offerSk2Map","buyProduct","offerToRecord","isAmazon","buyItemByType","length","requestSubscription","purchaseTokenAndroid","prorationModeAndroid","subscriptionOffers","so","offerToken","finishTransaction","purchase","isConsumable","developerPayloadAndroid","transactionId","getIosModule","purchaseToken","consumeProduct","userIdAmazon","isAcknowledgedAndroid","purchaseStateAndroid","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 transactionSk2Map,\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 if (isIosStorekit2()) {\n return Promise.resolve(\n (\n await RNIapIosSk2.getAvailableItems(alsoPublishToEventListener)\n ).map(transactionSk2Map),\n );\n } else {\n return RNIapIos.getAvailableItems();\n }\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 if (isIosStorekit2()) {\n return Promise.resolve(\n (\n await RNIapIosSk2.getAvailableItems(alsoPublishToEventListener)\n ).map(transactionSk2Map),\n );\n } else {\n return RNIapIos.getAvailableItems();\n }\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;;AAEA;;;;AACA;;;;AACA;;;;AACA;;;;AACA;;AACA;;AAOA;;AAWA;;;;;;AAcA,MAAM;EAACA,QAAD;EAAWC,WAAX;EAAwBC,WAAxB;EAAqCC;AAArC,IAA0DC,0BAAhE;AACA,MAAMC,8BAA8B,GAAGC,kBAAA,CAAYC,IAAnD;AACA,MAAMC,qBAAqB,GAAGF,kBAAA,CAAYG,KAA1C;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMO,MAAMC,KAAK,GAAG,YAIV;EAAA,IAJW;IACpBC,YAAY,GAAG;EADK,CAIX,uEAAP,EAAO;;EACT,QAAQA,YAAR;IACE,KAAK,gBAAL;MACE,IAAAC,uBAAA;MACA;;IACF,KAAK,gBAAL;MACE,IAAAC,uBAAA;MACA;;IACF,KAAK,sBAAL;MACE,IAAAC,4BAAA;MACA;;IACF;MACE;EAXJ;AAaD,CAlBM;AAoBP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAMC,cAAc,GAAG,MAC5B,IAAAC,yBAAA,IAAkBD,cAAlB,EADK;AAGP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;;;;AACO,MAAME,aAAa,GAAG,MAC3B,IAAAD,yBAAA,IAAkBC,aAAlB,EADK;AAGP;AACA;AACA;AACA;;;;;AACO,MAAMC,0CAA0C,GACrD,MACE,IAAAC,0BAAA,IAAmBC,mCAAnB,EAFG;AAIP;AACA;AACA;AACA;AACA;AACA;AACA;AACA;A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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;AACA;AACA;AACA;AACA;;;;;AACO,MAAM0B,mBAAmB,GAAG;EAAA,IAAC;IAClClB,GADkC;IAElCC,+CAA+C,GAAG,KAFhB;IAGlCkB,oBAHkC;IAIlCC,oBAAoB,GAAG,CAAC,CAJU;IAKlClB,0BALkC;IAMlCC,0BANkC;IAOlCkB,kBAAkB,GAAGf,SAPa;IAOF;IAChCD,mBAAmB,GAAGC,SARY;IAQD;IACjCF,eATkC;IAUlCG,QAVkC;IAWlCC;EAXkC,CAAD;EAAA,OAajC,CACEzC,qBAAA,CAASC,MAAT,CAAgB;IACdC,GAAG,EAAE,YAAY;MACf,IAAI,CAAC+B,GAAL,EAAU;QACR,OAAOhB,OAAO,CAACC,MAAR,CACL,IAAIC,KAAJ,CAAU,sCAAV,CADK,CAAP;MAGD;;MACD,IAAIe,+CAAJ,EAAqD;QACnDQ,OAAO,CAACC,IAAR,CACE,wXADF;MAGD;;MAED,IAAI,IAAAvC,wBAAA,GAAJ,EAAsB;QACpB,MAAMwC,KAAK,GAAG,IAAAC,oBAAA,EAAYJ,SAAZ,CAAd;QAEA,OAAO/D,WAAW,CAACoE,UAAZ,CACLb,GADK,EAELC,+CAFK,EAGLG,eAHK,EAILG,QAAQ,IAAI,CAAC,CAJR,EAKLI,KALK,CAAP;MAOD,CAVD,MAUO;QACL,OAAOnE,QAAQ,CAACqE,UAAT,CACLb,GADK,EAELC,+CAFK,EAGLG,eAHK,EAILG,QAAQ,IAAI,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,QAAQ,CAACG,aAA/B;;MAEA,IAAI,CAACA,aAAL,EAAoB;QAClB,OAAO5C,OAAO,CAACC,MAAR,CACL,IAAIC,KAAJ,CAAU,kDAAV,CADK,CAAP;MAGD;;MACD,OAAO,IAAA2C,sBAAA,IAAeL,iBAAf,CAAiCI,aAAjC,CAAP;IACD,CAVa;IAWdhD,OAAO,EAAE,YAAY;MACnB,IAAI6C,QAAJ,aAAIA,QAAJ,eAAIA,QAAQ,CAAEK,aAAd,EAA6B;QAC3B,IAAIJ,YAAJ,EAAkB;UAChB,OAAO,IAAA/D,0BAAA,IAAmBoE,cAAnB,CACLN,QAAQ,CAACK,aADJ,EAELH,uBAFK,CAAP;QAID,CALD,MAKO,IACLF,QAAQ,CAACO,YAAT,IACC,CAACP,QAAQ,CAACQ,qBAAV,IACCR,QAAQ,CAACS,oBAAT,KAAkCC,2BAAA,CAAqBC,SAHpD,EAIL;UACA,OAAO,IAAAzE,0BAAA,IAAmB0E,mBAAnB,CACLZ,QAAQ,CAACK,aADJ,EAELH,uBAFK,CAAP;QAID,CATM,MASA;UACL,OAAO3C,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 +1 @@
|
|
|
1
|
-
{"version":3,"names":["RNIapIosSk2","NativeModules","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<
|
|
1
|
+
{"version":3,"names":["RNIapIosSk2","NativeModules","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<TransactionSk2[]>;\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;;AAWA,MAAM;EAACA;AAAD,IAAgBC,0BAAtB;;AA+CA;AACA;AACA;AACA;AACO,MAAMC,IAAI,GAAG,MAAqBF,WAAW,CAACE,IAAZ,EAAlC;AAEP;AACA;AACA;;;;;AACO,MAAMC,uBAAuB,GAAIC,OAAD,IACrCJ,WAAW,CAACG,uBAAZ,CAAoCC,OAApC,CADK;AAGP;AACA;AACA;;;;;AAEO,MAAMC,kBAAkB,GAAIC,GAAD,IAChCN,WAAW,CAACK,kBAAZ,CAA+BC,GAA/B,CADK;AAGP;AACA;AACA;;;;;AACO,MAAMC,kBAAkB,GAAID,GAAD,IAChCN,WAAW,CAACO,kBAAZ,CAA+BD,GAA/B,CADK;AAGP;AACA;AACA;;;;;AACO,MAAME,iBAAiB,GAAIF,GAAD,IAC/BN,WAAW,CAACQ,iBAAZ,CAA8BF,GAA9B,CADK"}
|
package/lib/module/iap.js
CHANGED
|
@@ -4,7 +4,7 @@ import * as IapAndroid from './modules/android';
|
|
|
4
4
|
import * as IapIos from './modules/ios';
|
|
5
5
|
import * as IapIosSk2 from './modules/iosSk2';
|
|
6
6
|
import { offerToRecord } from './types/apple';
|
|
7
|
-
import { offerSk2Map, productSk2Map, subscriptionSk2Map } from './types/appleSk2';
|
|
7
|
+
import { offerSk2Map, productSk2Map, subscriptionSk2Map, transactionSk2Map } from './types/appleSk2';
|
|
8
8
|
import { fillProductsWithAdditionalData, getAndroidModule, getIosModule, getNativeModule, isAmazon, isIosStorekit2, storekit1Mode, storekit2Mode, storekitHybridMode } from './internal';
|
|
9
9
|
import { ProductType } from './types';
|
|
10
10
|
import { PurchaseStateAndroid } from './types';
|
|
@@ -240,7 +240,11 @@ export const getPurchaseHistory = function () {
|
|
|
240
240
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
241
241
|
return (Platform.select({
|
|
242
242
|
ios: async () => {
|
|
243
|
-
|
|
243
|
+
if (isIosStorekit2()) {
|
|
244
|
+
return Promise.resolve((await RNIapIosSk2.getAvailableItems(alsoPublishToEventListener)).map(transactionSk2Map));
|
|
245
|
+
} else {
|
|
246
|
+
return RNIapIos.getAvailableItems();
|
|
247
|
+
}
|
|
244
248
|
},
|
|
245
249
|
android: async () => {
|
|
246
250
|
if (RNIapAmazonModule) {
|
|
@@ -340,7 +344,11 @@ export const getAvailablePurchases = function () {
|
|
|
340
344
|
} = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
341
345
|
return (Platform.select({
|
|
342
346
|
ios: async () => {
|
|
343
|
-
|
|
347
|
+
if (isIosStorekit2()) {
|
|
348
|
+
return Promise.resolve((await RNIapIosSk2.getAvailableItems(alsoPublishToEventListener)).map(transactionSk2Map));
|
|
349
|
+
} else {
|
|
350
|
+
return RNIapIos.getAvailableItems();
|
|
351
|
+
}
|
|
344
352
|
},
|
|
345
353
|
android: async () => {
|
|
346
354
|
if (RNIapAmazonModule) {
|
package/lib/module/iap.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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,e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AQ,CAACI,aADJ,EAELF,uBAFK,CAAP;QAID,CALD,MAKO,IACLF,QAAQ,CAACM,YAAT,IACC,CAACN,QAAQ,CAACO,qBAAV,IACCP,QAAQ,CAACQ,oBAAT,KAAkC1E,oBAAoB,CAAC2E,SAHpD,EAIL;UACA,OAAOpF,gBAAgB,GAAGqF,mBAAnB,CACLV,QAAQ,CAACI,aADJ,EAELF,uBAFK,CAAP;QAID,CATM,MASA;UACL,OAAOtC,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","transactionSk2Map","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","resolve","getAvailableItems","getPurchaseHistoryByType","concat","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 transactionSk2Map,\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 if (isIosStorekit2()) {\n return Promise.resolve(\n (\n await RNIapIosSk2.getAvailableItems(alsoPublishToEventListener)\n ).map(transactionSk2Map),\n );\n } else {\n return RNIapIos.getAvailableItems();\n }\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 if (isIosStorekit2()) {\n return Promise.resolve(\n (\n await RNIapIosSk2.getAvailableItems(alsoPublishToEventListener)\n ).map(transactionSk2Map),\n );\n } else {\n return RNIapIos.getAvailableItems();\n }\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,EAKEC,iBALF,QAMO,kBANP;AAOA,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,SAAQlB,UAAR,EAAoBD,SAApB,EAA+BE,MAA/B,EAAuCC,SAAvC,EAAkDW,cAAlD;AAEA,MAAM;EAACM,QAAD;EAAWC,WAAX;EAAwBC,WAAxB;EAAqCC;AAArC,IAA0DzB,aAAhE;AACA,MAAM0B,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,CACEpC,QAAQ,CAACqC,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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AAoCP;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;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,OAAO,MAAMI,qBAAqB,GAAG;EAAA,IAAC;IACpCL,0BAA0B,GAAG;EADO,CAAD,uEAEO,EAFP;EAAA,OAKnC,CACExD,QAAQ,CAACqC,MAAT,CAAgB;IACdC,GAAG,EAAE,YAAY;MACf,IAAIvB,cAAc,EAAlB,EAAsB;QACpB,OAAOmC,OAAO,CAACO,OAAR,CACL,CACE,MAAMnC,WAAW,CAACoC,iBAAZ,CAA8BF,0BAA9B,CADR,EAEEf,GAFF,CAEMhC,iBAFN,CADK,CAAP;MAKD,CAND,MAMO;QACL,OAAOY,QAAQ,CAACqC,iBAAT,EAAP;MACD;IACF,CAXa;IAYdX,OAAO,EAAE,YAAY;MACnB,IAAIvB,iBAAJ,EAAuB;QACrB,OAAO,MAAMA,iBAAiB,CAACkC,iBAAlB,EAAb;MACD;;MAED,MAAMV,QAAQ,GAAG,MAAMzB,WAAW,CAACuC,uBAAZ,CACrBnC,qBADqB,CAAvB;MAIA,MAAM2B,aAAa,GAAG,MAAM/B,WAAW,CAACuC,uBAAZ,CAC1BrC,8BAD0B,CAA5B;MAIA,OAAOuB,QAAQ,CAACY,MAAT,CAAgBN,aAAhB,CAAP;IACD;EA1Ba,CAAhB,MA2BO,MAAMJ,OAAO,CAACO,OAAR,CAAgB,EAAhB,CA3Bb,CADF,GALmC;AAAA,CAA9B;AAoCP;AACA;AACA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AkC1E,oBAAoB,CAAC2E,SAHpD,EAIL;UACA,OAAOpF,gBAAgB,GAAGqF,mBAAnB,CACLV,QAAQ,CAACI,aADJ,EAELF,uBAFK,CAAP;QAID,CATM,MASA;UACL,OAAOtC,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 +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 = (\n alsoPublishToEventListener?: boolean,\n) => Promise<
|
|
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<TransactionSk2[]>;\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"}
|
|
@@ -2,7 +2,7 @@ import type { Product, ProductPurchase, Purchase, Sku } from '../types';
|
|
|
2
2
|
import type { PaymentDiscountSk2, ProductSk2, ProductStatus, TransactionSk2 } from '../types/appleSk2';
|
|
3
3
|
import type { NativeModuleProps } from './common';
|
|
4
4
|
declare type getItems = (skus: Sku[]) => Promise<ProductSk2[]>;
|
|
5
|
-
declare type getAvailableItems = (alsoPublishToEventListener?: boolean) => Promise<
|
|
5
|
+
declare type getAvailableItems = (alsoPublishToEventListener?: boolean) => Promise<TransactionSk2[]>;
|
|
6
6
|
export declare type BuyProduct = (sku: Sku, andDangerouslyFinishTransactionAutomaticallyIOS: boolean, applicationUsername: string | undefined, quantity: number, withOffer: Record<keyof PaymentDiscountSk2, string> | undefined) => Promise<Purchase>;
|
|
7
7
|
declare type clearTransaction = () => Promise<void>;
|
|
8
8
|
declare type clearProducts = () => Promise<void>;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "react-native-iap",
|
|
3
|
-
"version": "11.0.0-rc.
|
|
3
|
+
"version": "11.0.0-rc.5",
|
|
4
4
|
"description": "React Native In App Purchase Module.",
|
|
5
5
|
"repository": "https://github.com/dooboolab/react-native-iap",
|
|
6
6
|
"author": "dooboolab <support@dooboolab.com> (https://github.com/dooboolab)",
|
package/src/iap.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
ProductSk2,
|
|
11
11
|
productSk2Map,
|
|
12
12
|
subscriptionSk2Map,
|
|
13
|
+
transactionSk2Map,
|
|
13
14
|
} from './types/appleSk2';
|
|
14
15
|
import {
|
|
15
16
|
fillProductsWithAdditionalData,
|
|
@@ -289,7 +290,15 @@ export const getPurchaseHistory = ({
|
|
|
289
290
|
(
|
|
290
291
|
Platform.select({
|
|
291
292
|
ios: async () => {
|
|
292
|
-
|
|
293
|
+
if (isIosStorekit2()) {
|
|
294
|
+
return Promise.resolve(
|
|
295
|
+
(
|
|
296
|
+
await RNIapIosSk2.getAvailableItems(alsoPublishToEventListener)
|
|
297
|
+
).map(transactionSk2Map),
|
|
298
|
+
);
|
|
299
|
+
} else {
|
|
300
|
+
return RNIapIos.getAvailableItems();
|
|
301
|
+
}
|
|
293
302
|
},
|
|
294
303
|
android: async () => {
|
|
295
304
|
if (RNIapAmazonModule) {
|
|
@@ -397,7 +406,15 @@ export const getAvailablePurchases = ({
|
|
|
397
406
|
(
|
|
398
407
|
Platform.select({
|
|
399
408
|
ios: async () => {
|
|
400
|
-
|
|
409
|
+
if (isIosStorekit2()) {
|
|
410
|
+
return Promise.resolve(
|
|
411
|
+
(
|
|
412
|
+
await RNIapIosSk2.getAvailableItems(alsoPublishToEventListener)
|
|
413
|
+
).map(transactionSk2Map),
|
|
414
|
+
);
|
|
415
|
+
} else {
|
|
416
|
+
return RNIapIos.getAvailableItems();
|
|
417
|
+
}
|
|
401
418
|
},
|
|
402
419
|
android: async () => {
|
|
403
420
|
if (RNIapAmazonModule) {
|
package/src/modules/iosSk2.ts
CHANGED