Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Error refreshing inventory. In-app Billing

I am setting up and testing in-app billing. I managed to purchase the android.test.purchased, and it did what it should. But now I need to consume it to continue my testing. The problem is that I can't reach the inventory.

When this is called I get the result.isFaliure() is called and I can't get the inventory.

IabHelper.QueryInventoryFinishedListener _gotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {

        @Override
        public void onQueryInventoryFinished(IabResult result, Inventory inventory) {

            if (_iabHelper == null) return;

            if (result.isFailure()) {
                Log.d(TAG, "Failed to query inventory: " + result);
                return;
            }

            Log.d(TAG, "Query inventory was successful.");

            Purchase premiumPurchase = inventory.getPurchase(SKU_PREMIUM);
            _isPremium = (premiumPurchase != null && verifyDeveloperPayload(premiumPurchase));
            Log.d(TAG, "User is " + (_isPremium ? "PREMIUM" : "NOT PREMIUM"));

            update();
        }
    };

It logs the error message

Failed to query inventory: IabResult: Error refreshing inventory (querying owned items). (response: -1003:Purchase signature verification failed)

The android.test.purchased is still owned - it won't let me buy it again. My phone has network connection so it's not that.

I have NOT uploaded a signed APK to Google Play, does that matter even if I test with googles static ID's?

like image 540
Christoffer Avatar asked Oct 29 '14 21:10

Christoffer


1 Answers

Solved it... It seems there are problems with the static purchase ID's. Here's a sollution I found in THIS thread:

If you have used the android.test.purchased then one way to get rid of the error is to do the following:-

 1. Edit Security.java and change the "return false" line in the
    verifyPurchase to "return true" - this is temporary, we'll be
    putting it back in a minute.
 2. In your QueryInventoryFinishedListener, after the "if
    (result.isFailure()) {...}" lines add the following to consume and
    get rid of your never ending android.test.purchased item:-

    if (inventory.hasPurchase(SKU_ANDROID_TEST_PURCHASE_GOOD)) {
    mHelper.consumeAsync(inventory.getPurchase(SKU_ANDROID_TEST_PURCHASE_GOOD),null);
    }
 3. Run your app so the consunmeAsync happens, this gets rid of the
    "android.test.purchased" item on the server.
 4. Remove the consumeAsync code (or comment it out). Back in the
    Security.java, change the "return true" back to "return false".
like image 99
Christoffer Avatar answered Oct 13 '22 14:10

Christoffer