cordova-plugin-inapppurchase icon indicating copy to clipboard operation
cordova-plugin-inapppurchase copied to clipboard

Unable to access "productId" field

Open FiveHundredMiles opened this issue 8 years ago • 3 comments

I spent a lot of time to figure this out. I am not sure what I missed. Anyway, I found a way to fix this issue.

inAppPurchase
                    .restorePurchases()
                    .then((purchases) => {
                        purchases.forEach(purchase => alert(purchase.productId + ' should be restored') );
                    })

Console output

purchase.productId returns nothing

Here is how I fix this error:

inAppPurchase
                    .restorePurchases()
                    .then((purchases) => {
                         purchases.forEach(purchase => alert(purchase["productId"] + ' should be restored') ); 
                    })

It works and I can see the productId.

FiveHundredMiles avatar Sep 28 '16 23:09 FiveHundredMiles

@ FiveHundredMiles,

Thanks for above information, This was helpful to me to get required information.

Can you please guide me on how to do a restore purchase using this plugin, I am getting empty result "[]" in console.log.

Waiting for your reply.

Regards, Venkat

Venkat-TTapp avatar Dec 19 '16 17:12 Venkat-TTapp

Everything goes well if you do something like this

inAppPurchase .getProducts([prodID]) .then(function (products) { alert(JSON.stringify(products)); //Products are loaded //Try making the purchase in here to test if it works inAppPurchase.restorePurchases().then(function (data) { alert("AFTER RESTORE"); alert(JSON.stringify(data)); }) inAppPurchase.buy(prodID).then(function (data) { }) }) .catch(function (err) { alert(err); }

ysharoiko avatar Aug 20 '18 08:08 ysharoiko

@ysharoiko Thank you. I used JSON.stringify(products) to access the object!! It finally works.

puneethshetty12 avatar Oct 24 '18 13:10 puneethshetty12