In-App Billing test: android.test.purchased already owned

后端 未结 16 1341
情深已故
情深已故 2020-12-07 08:09

I am currently testing In-App Billing for a future app, and after I successfully \"bought\" the test item \"android.test.purchased\" the first time, I now receive the respon

相关标签:
16条回答
  • 2020-12-07 08:43

    The main issue is you have to consume the android.test.purchased item. But this item won't be available in your query inventory, so you can't consume using the normal flow.

    So, if you are using IabHelper, in IabHelper class, you can temporarily change the IInAppBillingService mService to public so that it is accessible from your IabHelper.

    Then in your class, you can consume like this,

    int response = mHelper.mService.consumePurchase(3, getPackageName(), "inapp:"+getPackageName()+":android.test.purchased");
    

    If success, the response is going to be 0.

    Hope this helps.

    0 讨论(0)
  • 2020-12-07 08:45

    i used adb shell:

    adb shell pm clear com.android.vending
    
    0 讨论(0)
  • 2020-12-07 08:46

    In my case, it appears that Google does not record a purchase for the item. Rather, the local copy of Google Play Services caches the purchase. That way, when a second request is made on the same device, android.test.purchased already owned appears. However, using another device or resetting the device clears the cache, and allows the purchase to be repeated.

    0 讨论(0)
  • 2020-12-07 08:48

    In-app version 3:

    IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
    
        public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
    
            .....................
    
            if (inventory.hasPurchase(SKU_CONTENT)) {
    
                mHelper.consumeAsync(inventory.getPurchase(SKU_CONTENT), null);
            }
        }
    };
    
    0 讨论(0)
  • 2020-12-07 08:51

    Version 3 - Fastest way to solve : Clearing the cache of Google Play Store will let "android.test.purchased" available again.

    0 讨论(0)
  • 2020-12-07 08:52

    It turns out that the android.test.purchased item behaves like a regular ID. It means that if you want be able to buy it again, you have to consume it somewhere in your code. I think that the Google documentation is misleading on this matter, and that they should add another static ID that you can buy endlessly for test purposes.

    0 讨论(0)
提交回复
热议问题