chirag04 / react-native-in-app-utils

A react-native wrapper for handling in-app payments
MIT License
890 stars 185 forks source link

Restore purchases method returns no purchase #144

Closed camel113 closed 6 years ago

camel113 commented 6 years ago

When I try to retrieve the purchased items, the response contains no items. However I have already purchased item (non-renewing subscription) right before with successful status. I am testing it with my sandbox account. What surprise me is if I try to purchase the subscription again, an alert tell me "You've already purchased this subscription".

My in app purchase has currently the status waiting for review. I tested it with my developper account and sandbox account. I tested it on my physical device.

The way I try to restore the purchases.

restorePurchaseItem(){
    InAppUtils.restorePurchases((error, response) => {
       if(error) {
          console.log('itunes Error', 'Could not connect to itunes store.');
       } else {
          console.log('Restore Successful', 'Successfully restores all your purchases.');
          this.setState({purchasedItemsLength:response.length})
          if (response.length === 0) {
            console.log('No Purchases', "We didn't find any purchases to restore.");
            return;
          }

          response.forEach((purchase) => {
            if (purchase.productIdentifier === 'top_scorers_ranking') {
              console.log(purchase)
            }
          });
       }
    });
  }
camel113 commented 6 years ago

I thought it was an issue related to iTunes Connect... And after multiple hours researching doc, I found this link https://stackoverflow.com/questions/45079214/ios-restore-purchases-in-testflight. Non-renewing subscriptions should not be returned by restorePurchases method.