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

getPurchases() state not foud

Open attex opened this issue 6 years ago • 4 comments

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?

attex avatar May 02 '18 19:05 attex

is this plugin support this function getPurchases on Android ? did you try it ?

SaidMarar avatar May 04 '18 13:05 SaidMarar

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 avatar May 04 '18 16:05 attex

@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.

netse-ai avatar May 14 '18 22:05 netse-ai

I have a similar problem ! Nothing state and transactionId is empty.

BlandineBurteaux avatar May 15 '18 14:05 BlandineBurteaux