jamesmontemagno / InAppBillingPlugin

Cross-platform In App Billing Plugin for .NET
MIT License
651 stars 152 forks source link

Android refunded purchases do not have a state of refunded. #201

Closed sudo007 closed 5 years ago

sudo007 commented 5 years ago

Hello, I am having troubles with the GetPurchasesAsync() method not returning what I believe should be the correct PurchaseState for an Android in-app purchase. The non-consumable purchase has been refunded in the Google Play Console. I expect that the PurchaseState should be Refunded, but instead it returns Purchased.

This app is currently just in the Alpha track (it has never been to Beta or production). The user has been whitelisted in the Google Play Console: Settings -> Developer Account -> Account Details -> License Testing section with license test response set to RESPOND_NORMALLY. Troubleshooting steps included clearing the Play store cache on the device, and stepping through the InAppBillingImplementation class with no luck.

My goal with all of this is to retest the purchasing process for this user. The idea was to hide the 'purchase' button if the user had already purchased the item (identified by calling the aforementioned GetPurchasesAsync() method). Because this is not working as I expect, the button stays hidden despite the fact that the purchase has been refunded. Is this just my own misunderstanding of how this flow should work on Android?

Thanks for any guidance you can provide!

jamesmontemagno commented 5 years ago

From looking at https://github.com/jamesmontemagno/InAppBillingPlugin/blob/master/src/Plugin.InAppBilling.Android/InAppBillingImplementation.cs#L790-L822 we take in the json and parse the purchaseState string on it, and it should be returning correct.

sudo007 commented 5 years ago

Hmm, okay. So, if this is behaving 'as designed', I suspect what I need to do is Consume the purchased item. I can keep track of this purchase info as part of my app, and manually clear it when testing, but how can I know if the user has had their purchases refunded so they no longer get the added functionality? Any advice from your experience?

jamesmontemagno commented 5 years ago

You may want to think about storing it on your server somehow based on the logged in user. That is how I do it in my apps where I have more than a non-consumable, which is easily restored.

nexxuno commented 5 years ago

Hello @jamesmontemagno , maybe I'm missing the point here but I can't understand how having the State set to "Purchased" when on the store it's "Refunded" could be behaving as designed. Moreover how is a private server helping at all here?

Let me explain: -user buys the "Premium User" one time non-consumable purchase in the app -the user closes the app, goes into the play store within 48hrs from the purchase and refunds it -how do we fetch the information about the fact that the user got his money back if the GetPurchases tells us it's "Purchased" instead of "Refunded"?

nexxuno commented 5 years ago

I think we have the answer: https://stackoverflow.com/questions/14303850/android-in-app-billing-purchase-state-stays-purchased-after-order-cancelation https://stackoverflow.com/questions/13861625/in-app-billing-v3-dont-detect-refund https://code.google.com/archive/p/marketbilling/issues/88#makechanges

Let's see if it's really "just" a caching problem.... I'll be back with the answer!

nexxuno commented 5 years ago

Ok it was a caching problem.

You can test it by removing google play from memory, clearing google play cache, reload google play.

The point is that if it really takes up to 72 hours to google play to refresh the cache we could have some users playing smart, anyway I don't think this is a bug.