initConnection() | Promise<boolean> | Init IAP module. On Android this can be called to preload the connection to Play Services. On iOS, it will simply call canMakePayments method and return value which is required for the listeners to work properly. | |
purchaseUpdatedListener((purchase: ProductPurchase) => {}) | EmitterSubscription | Register a callback that gets called when the store has any updates to purchases that have not yet been finished, consumed or acknowledged. Returns a React Native EmitterSubscription on which you can call .remove() to stop receiving updates. Register you listener as soon as possible and react to updates at all times. | |
purchaseErrorListener((error: PurchaseError) => {}) | EmitterSubscription | Register a callback that gets called when there has been an error with a purchase. Returns a React Native EmitterSubscription on which you can call .remove() to stop receiving updates. | |
getProducts(skus: string[])- skus: array of Product ID/sku
| Promise<Product[]> | Get a list of products (consumable and non-consumable items, but not subscriptions). Note: With before iOS 11.2, this method will also return subscriptions if they are included in your list of SKUs. This is because we cannot differentiate between IAP products and subscriptions prior to iOS 11.2. | |
getSubscriptions(skus: string[])- skus: array of Subscription ID/sku
| Promise<Subscription[]> | Get a list of subscriptions. Note: With before iOS 11.2, this method will also return products if they are included in your list of SKUs. This is because we cannot differentiate between IAP products and subscriptions prior to iOS 11.2. | |
getPurchaseHistory() | Promise<Purchase> | Gets an inventory of purchases made by the user regardless of consumption status (where possible). | |
getAvailablePurchases() | Promise<Purchase[]> | Get all purchases made by the user (either non-consumable, or haven't been consumed yet). On Android, it can be called at app launch, but on iOS, only at restoring purchase is recommended (See: #747). | |
requestPurchase(sku: string, andDangerouslyFinishTransactionAutomatically: boolean, obfuscatedAccountIdAndroid: string, obfuscatedProfileIdAndroid: string) | Promise<ProductPurchase> | Request a purchase. purchaseUpdatedListener will receive the result. andDangerouslyFinishTransactionAutomatically defaults to true for backwards compatibility but this is deprecated and you should set it to false once you're manually finishing your transactions. | |
requestPurchaseWithQuantityIOS(sku: string, quantity: number)- sku: product ID/sku
- quantity: Quantity
| void | iOS only Buy a product with a specified quantity. purchaseUpdatedListener will receive the result | |
*deprecated buySubscription(sku: string) | void | Create (buy) a subscription to a sku. | |
requestSubscription(sku: string, andDangerouslyFinishTransactionAutomaticallyIOS: boolean, oldSkuAndroid: string, purchaseTokenAndroid: string, prorationModeAndroid: string, obfuscatedAccountIdAndroid: string, obfuscatedProfileIdAndroid: string) | void | Create (buy) a subscription to a sku. | |
clearTransactionIOS() | void | iOS only Clear up unfinished transanctions which sometimes cause problems. Read more in #257, #801. | |
clearProductsIOS() | void | iOS only Clear all products and subscriptions. Read more in below README. | |
getReceiptIOS() | Promise<string> | iOS only Get the current receipt. | |
getPendingPurchasesIOS() | Promise<ProductPurchase[]> | IOS only Gets all the transactions which are pending to be finished. | |
validateReceiptIos(body: Record<string, unknown>, devMode: boolean)- body: receiptBody
- devMode: isTest
| Object\|boolean | iOS only Validate receipt. | |
presentCodeRedemptionSheetIOS() | Promise<null> | iOS only Availability: iOS 14.0+ Displays a sheet that enables users to redeem subscription offer codes that you generated in App Store Connect. | |
endConnection() | Promise<void> | End billing connection. | |
consumeAllItemsAndroid() | Promise<void> | Android only Consume all items so they are able to buy again. โ ๏ธ Use in dev only (as you should deliver the purchased feature BEFORE consuming it) | |
flushFailedPurchasesCachedAsPendingAndroid() | Promise<void> | Android only Consume all 'ghost' purchases (that is, pending payment that already failed but is still marked as pending in Play Store cache) | |
consumePurchaseAndroid(token: string, payload?: string)- token: purchase token
- payload: developerPayload
| void | Android only Finish a purchase. All purchases should be finished once you have delivered the purchased items. E.g. by recording the purchase in your database or on your server. | |
acknowledgePurchaseAndroid(token: string, payload?: string)- token: purchase token
- payload: developerPayload
| Promise<PurchaseResult> | Android only Acknowledge a product. Like above for non-consumables. Use finishTransaction instead for both platforms since version 4.1.0 or later. | |
consumePurchaseAndroid(token: string, payload?: string)- token: purchase token
- payload: developerPayload
| Promise<PurchaseResult> | Android only Consume a product. Like above for consumables. Use finishTransaction instead for both platforms since version 4.1.0 or later. | |
finishTransactionIOS(transactionId: string)- transactionId: the transactionId that you would like to finish.
| Promise<void> | iOS only Finish a transaction. Use finishTransaction instead for both platforms since version 4.1.0 or later. | |
finishTransaction(purchase: InAppPurchase/ProductPurchase, isConsumable?: boolean, developerPayloadAndroid?: string)- purchase: purchase object
- isConsumable?: specify whether the product is a consumable
- developerPayloadAndroid: developerPayload
| Promise<void> | This method works for both platforms and is recommended since version 4.1.0 or later. Equal to finishTransactionIOS + consumePurchaseAndroid and acknowledgePurchaseAndroid. | |
*deprecated buySubscription(sku: string, prevSku?: string, mode?: number)- sku: subscription ID/sku
- prevSku: old subscription ID/sku (optional)
- mode: proration mode (optional)
| Promise<Purchase> | Android only Create (buy) a subscription to a sku. For upgrading/downgrading subscription on Android pass the second parameter with current subscription ID, on iOS this is handled automatically by store. You can also optionally pass in a proration mode integer for upgrading/downgrading subscriptions on Android | |
validateReceiptAndroid(bundleId: string, productId: string, productToken: string, accessToken: string) - bundleId: the packageName
- productId: productId
- productToken: productToken
- accessToken: accessToken
- isSubscription: isSubscription
| Object\|boolean | Android only Validate receipt. | |