20

I'm stuck with Google In App v3 - I tested a purchase without consumption (e.g. when app crashes between buying and consuming) - now I don't find a way out.

If I try to buy again, it says 'you already own that item'. But when I test for ownership, it says I don't own it:

Inventory inv = mHelper.queryInventory(false, null);
inv.getPurchase(sku); // null
inv.hasPurchase(sku); // false

I can't consume something either, as I don't have a purchase to consume. How to proceed here?

EDIT Reproduce it like the following: purchase in-app consumable, then disable internet connection. After that, you're not able to purchase the product again for some hours. Just tested with a popular app from the play store (Diamond Digger Saga), I had the exact same behaviour. Is there really no possibility to avoid/solve this?

swalkner
  • 16,679
  • 31
  • 123
  • 210
  • Have you logged in to your Android device with your google Account in which you are testinfg the app? – Balvinder Singh Sep 23 '14 at 08:52
  • yes - I need to be logged in to that account to load the app from the beta tester in play store – swalkner Sep 23 '14 at 09:52
  • Try with Inventory inv = mHelper.queryInventory(true, list_of_skus);? – ElDuderino Sep 23 '14 at 15:59
  • exact same problem... – swalkner Sep 23 '14 at 16:09
  • Please post the section of code in which you purchase and then consume the product. – Juan Andrés Diana Sep 28 '14 at 00:47
  • @swalkner what state is your app in, is it only in testing right now or does it have a live version that contains the in problem inapp purchase? I ask because it can matter to the possible solutions – Jared Reeves Sep 28 '14 at 19:58
  • One also last question, you state that when testing the Diamond Digger Saga app, you are able to reproduce the issue, and for some amount of time are not able to purchase the products again. However, you can at some point purchase that item, Is this correct? If so does your app behave in the same way? – Jared Reeves Sep 28 '14 at 20:04
  • 1
    exactly. I'm able to purchase again after dome time (or after deleting the cache of play store!), same behavior for e.g. Diamond Digger Saga and my app. – swalkner Sep 29 '14 at 04:43
  • possible duplicate of ["You already own this item" but getPurchases is empty](http://stackoverflow.com/questions/25694829/you-already-own-this-item-but-getpurchases-is-empty) – Peter O. Oct 01 '14 at 12:44

2 Answers2

1

I ran into this exact problem. I had two Google accounts on the phone, one which was the developer account (which I foolishly used my personal account for) and another which was the test account I registered in the developer console. I had removed and re-added the developer account from my accounts on the phone, which allowed me to make test-purchases from my app, thinking if the developer account was the second on this list it would use the first for purchases.

Alas, after a couple of runs of the app I ran into your issue. I gave up trying to have both and removed the developer account from my phone. While incredibly inconvenient, this got rid of this problem and allowed me to test purchase, consume, query, etc.

Bob Liberatore
  • 860
  • 10
  • 24
1

If you are doing everything correctly and your code is ok - most likely the problem is in cached Google Play Services data.

For example when you make a test purchase on your device A - on your device B (with the same Google account logged in) you will keep receiving inventory without your purchase for some time. And your inventory.getPurchase(sku) will return null and inventory.hasPurchase(sku) will return false;

To fix this try to open Google Play and close it using Recent Apps button (click it and then swipe the app away) this will terminate the app faster than usual "back" button. Then turn your device off for couple of minutes.

Our goal here is to make Google Play to update it's cache.

Be sure that you're on wifi because it may update rarely if you're on mobile data. Eventually data will be updated and you will get your purchase. In my case it happened after 5 minutes or smth.

Kirill Karmazin
  • 6,256
  • 2
  • 54
  • 42