StoreKit 2 and Billing API for React Native
npm install react-native-purchase-kitIt's built on top of the latest StoreKit 2 and Android Billing Library 3.0.0+ (coming soon). At the moment, it only supports subscriptions and there is a single API for both platforms. Check out below.
Requires iOS 15+ and Android minSdkVersion = 24.
``sh`
yarn add react-native-purchase-kit
Configure app to use StoreKit 2 and Android Billing Library 3.0.0+.
`js
import PurchaseKit from 'react-native-purchase-kit';
const kit = new PurchaseKit();
// Get products
const products = await kit.getProducts(['monthly_subscription']);
// Buy a product
const transaction = await kit.purchase({
productID: 'monthly_subscription',
uuid: 'uuid',
});
// Get recent transactions
kit.getRecentTransactions();
// Get receipt
const receipt = await kit.readReceipt();
// Listen to events
kit.addListener('transactions', (event) => {
if (event.kind === 'transactions') {
console.log(event.transaction);
}
});
``
MIT