Android Billing Library v3 - Account in License Testing, Item stuck at Purchased

Viewed 206

After searching StackOverflow here, I seem to be having something that none of the suggested fixes work (except for one, mentioned below).

I am NOT using the test SKUs (android.test.*), but made my own test SKU in he App's play-store console. I added my phone/tablet's primary Google account to the License Testing in the Play Console. This account is NOT my developer's account. This product is a one-time purchase, non-consumable.

My first test, I started purchase, and got the expected pop up with two Credit Cards ("Test Card, Always Approves", and "Test Card, Always Declines"). Selected the Approve card, and everything worked as expected -

  • Order appeared in my developer's Play Console.
  • App recognized purchase, and my code handled it properly. (yay)

Now, to this date, when I try purchasing it again, I get the code ITEM_ALREADY_OWNED.

Everything I've done to try and clear this -

  1. According to this documentation, it said to cancel/refund the purchase. So, I did.
  2. Some reports, such as here on StackOverflow, suggested clearing Play Store cache (adb shell pm clear com.android.vending).

Neither of these allowed me to repurchase the item again.

The one thing I did NOT do was add all the code to 'consume' the product, as frankly, that seems counter-productive to testing. (Adding code which may have issues, then after successful testing, removing that same code, which could introduce other issues..)

My MAIN point of worry is that if I refunded a purchase, it really should NOT be telling my app that an item is still purchased - because frankly, it isn't any more: I refunded it.

My second worry point is properly testing this, without having to temporarily or permanency add code for consumable SKUs.

Is there another way of removing this 'already purchased' item that I'm missing? Or did I not set up a testing account or testing license entry properly?

1 Answers

A product can only be bought once, if you want the user to be able to buy it again, you have to call billingClient.consumeAsync() before, then billingClient.queryPurchases() will return that the user does not own the item and then he can buy it again

You can use consumeAsync() only for testing and then disable that part in the final version, that's what I usually do.

It is your code that decides whether a product is consumable or not.

Related