In-app Billing - Google Play gives me the "You already own this item" message when queryPurchases() returns an empty list

17,603

I had the exact same issue, where I got the error message that I already own this item, but the getPurchases call returned an empty list. What ended up working for me was getting the purchase history if this list is empty, and taking the purchase token for the last purchase of this specific product id and using that for the consume:

mService.getPurchaseHistory(version, packageName, "inapp", null, new Bundle());

Keep in mind the history contains the information of the last purchase of each of the product types from this user, so make sure to compare the product id's to the relevant one.

Share:
17,603
Gensoukyou1337
Author by

Gensoukyou1337

Updated on June 11, 2022

Comments

  • Gensoukyou1337
    Gensoukyou1337 about 2 years

    I just made one test purchase for an item, and it failed because my Wi-fi died, but for some reason Google Play then gave me a message that the order was pending or something and that I should check it on some link (I forgot to write it down).

    When I tried to make that same test purchase again, Google Play gave me that "You already own this item" error. Said purchase is NOT in my order history in the Google Play dashboard.

    What's going on, and how do I resolve this?

    EDIT: Clearing the Google Play Store cache, clearing the Google Services Framework cache, and reinstalling the app does not work.


    EDIT 2:

    I managed to resolve this issue by Force Stopping the Google Play Store app, clearing its data, then restarting it. Right now, I can only conclude that the purchases made when the Wi-fi is disconnected is in the Play Store app's Data, not Cache.

    My question thus becomes: Is it the developer's responsibility to handle this particular case (when the solution is not within the app itself), and how does one handle it?

  • Shahood ul Hassan
    Shahood ul Hassan over 4 years
    What is mService and what is this method getPurchaseHistory()?
  • temnoi
    temnoi over 3 years
    @ShahoodulHassan I assume it is a wrapper around BillingClient#queryPurchaseHistoryAsync()