How do I revoke an Android in-app non-consumable purchase entitlement after refunding?
Asked Answered
T

1

13

I'm currently testing my Android app (license testing in-app payments), requiring many iterations of buying and refunding an item to test it. This last time, while issuing a refund, I accidentally forgot to check the "revoke entitlement" box in the Play Developer Console (which is unchecked by default for some reason). Now, my version of the app always has the entitlement and I can't test buying it anymore.

I know that there is no way to revoke the entitlement via the website. There seems to be a way to do it through an API call, but I don't have a back-end setup for the app, and haven't been able to figure out how to call the function successfully through my browser/curl (always authentication errors). My app doesn't seem to be able to tell the difference between a purchased entitlement or one that was refunded but not revoked (my Purchase object's getPurchaseState() call always returns Purchase.PurchaseState.PURCHASED), so I don't know if I can revoke it via the app's code-base.

Is there any way that I can revoke the entitlement? The procedure to authorize myself to make API calls is completely opaque to me, but that seems like a viable route if I could understand it.

Tineid answered 1/12, 2020 at 1:33 Comment(2)
For anyone interested, here is the documentation of the API call: developers.google.com/android-publisher/api-ref/rest/v3/…Jumbuck
Or maybe this: developers.google.com/android-publisher/api-ref/rest/v3/orders/…Jumbuck
T
10

It turns out I had to go the route of consuming the purchase via the app. I did this by adding a developer-only Preference in the Settings pane (by programmatically adding a new Preference depending on the value of BuildConfig.Debug) specifically for revoking the given product. Once clicked, the app will:

  1. Get a list of all Purchases (through the BillingClient object's queryPurchases method)
  2. Find the Purchase with the SKU of the product I want to consume (if it exists).
  3. Call the consumeAsync method of my BillingClient object, which accepts the purchase token (held by the Purchase object from step 2).

Once this is done and has been verified, the product is consumed immediately and the entitlement that was granted is revoked (significantly faster than refunding through the Google Play Developer Console).

Be careful to not let this option sneak into your release build, because I think it will revoke entitlements without refunding (not a problem for license testers who aren't using real money, but will lead to angry customers).

Tineid answered 1/12, 2020 at 17:52 Comment(3)
Excellent thanks. Another benefit is that there is a limit of 10 refunds per day via the developer console (includes test purchases for some reason). If you exceed this, your ability to refund is blocked for 24 hours.Jumbuck
Thank you for answering your own question, You don't have to, but you still did, It is really helpful for me and others, Thank you so much for your help!Fireplace
Thank you for this idea, I implemented it as well and it's working fine. In my case, I added a "debug" section in my app settings, loading it from a resource file located within the debug/res/xml folder to ensure that it will never be displayed in release neither. You can as well add an extra if(BuildConfig.Debug) to guard the logic behind.Speroni

© 2022 - 2024 — McMap. All rights reserved.