chirag04 / react-native-in-app-utils

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

Auto-renewing restore #168

Open tombaki opened 6 years ago

tombaki commented 6 years ago

@chirag04 when I try to restore I received array of purchase but non of them have the true transactionReceipt I subscribed

chirag04 commented 6 years ago

I'm not sure what's going on there. I haven't used it that way. I suggest checking out what's wrong.

Worst case: Once you have the productIds, you can fetch receiptData separately. I suggest debugging first.

tombaki commented 6 years ago

@chirag04 in the begging I'v 2 product month and year in one group mean I can upgrade from product to anther .. then i purchased product for example com.example.month it's purchased correct and I got the transactionReceipt and send it to my server to store it .. and I upgrade to year product and back to monthly product .. all that keep send new transactionReceipt to my server so when I try to restore purchase I got arrays with purchase but non of them have the new product transactionReceipt

tombaki commented 6 years ago

@chirag04 `restore = async()=>{ try{ await InAppUtils.restorePurchases((error, response) => { if(error) { Alert.alert('خطأ آيتونز', 'توجد مشكلة حاول مرة أخري'); } else { Alert.alert('إستعادة المشتريات', 'تم الإستعادة بنجاح'); //alert(JSON.stringify(response)) if (response.length === 0) { Alert.alert('إستعادة المشتريات', "عفواً لا توجد مشتريات سابقة"); return; }

  response.forEach((purchase) => {

    if (purchase.productIdentifier === "com.example.monthly") {
  console.log(JSON.stringify(purchase. transactionReceipt))

} })`

will print in console arrays but non of them have a valid transactionReceipt

superandrew213 commented 6 years ago

The transaction receipt is the base64 encoded string that you need to send to Apple to validate. You should not compare it to a previous receipt because it will always be different.

ts-ign0re commented 6 years ago

I'm using https://github.com/sibelius/iap-receipt-validator for that, this is a best way.

sandeepsipl commented 6 years ago

@superandrew213: Did you get any solution for this issue? And how the server validates the receipt which we are storing during the transaction?