Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async supportWoWsInfo(item) {
try {
// Will return a purchase object with a receipt which can be used to validate on your server.
const purchase = await RNIap.buyProduct(item.productId);
// Consume it right away to buy multiple times
await RNIap.consumePurchase(purchase.purchaseToken);
this.setState({
receipt: purchase.transactionReceipt, // save the receipt if you need it, whether locally, or to your server.
});
} catch(err) {
// standardized err.code and err.message available
console.error(err.code, err.message);
const subscription = RNIap.addAdditionalSuccessPurchaseListenerIOS(async (purchase) => {
this.setState({ receipt: purchase.transactionReceipt }, () => this.goToNext());
subscription.remove();
});
}
}
}
purchases.forEach(async purchase => {
console.log(purchase);
await RNIap.consumePurchase(purchase.purchaseToken);
});