How to use the react-native-iap.consumePurchase function in react-native-iap

To help you get started, we’ve selected a few react-native-iap examples, based on popular ways it is used in public projects.

github HenryQuan / WoWs-Info-Re / WoWsInfo / src / component / common / Donation.js View on Github external
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();
      });
    }
  }
}
github Musicoin / app / components / product / ProductModal.js View on Github external
purchases.forEach(async purchase => {
        console.log(purchase);
        await RNIap.consumePurchase(purchase.purchaseToken);
      });