Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 334
sgbrown Avatar asked Dec 01 '20 01:12

sgbrown


People also ask

Can you undo a Google Play purchase?

On any Android device linked to the account you made the purchase from, go to the Play Store page of the item you purchased and hit the Refund button. In the pop-up that appears, click Request refund to confirm.

How many times can you refund on Google Play?

1 Answer. Save this answer. Show activity on this post. Note: You can only return an app or game for a refund once.


1 Answers

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

like image 65
sgbrown Avatar answered Oct 10 '22 00:10

sgbrown