cordova-plugin-inapppurchase
cordova-plugin-inapppurchase copied to clipboard
getPurchases() state not foud
Hi there!
I have an issue with the function getPurchases(): on Android.
inAppPurchase .restorePurchases() .then(function (data) { for (let i = 0; i < data.length; i++) { let x = JSON.parse(data[i].receipt); if (x.purchaseState == 0) { return true; } else { return false; } ...
How can I get the state of the subscription?
In the docs, there is a variable 'state' shown.
But my data-Json looks like the one in the function buy():
[{productId: "", transactionId: "", type:"",productType:"", signature;"", receipt: {purchaseState;0, ....} }]
So there is no state but a purchaseState but this variable is always 0.
Can anyone help me?
is this plugin support this function getPurchases on Android ? did you try it ?
The function call works, but there is no state attribute.
So basically my question is how do i get to know whether a product is subscribed or not.
@attex I have a similar issue. The state
attribute is undefined
when I use restorePurchase()
. However, this might be intentional? If there is no active subscription, it returns an empty array for me.
https://stackoverflow.com/questions/48041120/how-to-check-purchase-state-of-subscription-in-all-new-play-billing-library
Also, I noticed you are using this let x = JSON.parse(data[i].receipt)
. The state
attribute of the object returned by restorePurchase()
is not in the receipt. It is a property of the returned object itself. It should be undefined
though.
I have a similar problem ! Nothing state and transactionId is empty.