cordova-plugin-inapppurchase
cordova-plugin-inapppurchase copied to clipboard
Unable to access "productId" field
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,
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
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 Thank you. I used JSON.stringify(products) to access the object!! It finally works.