Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how to cancel an in-app test purchase on android?

Until june 20th 2016 i was able to cancel test purchases done in my app. Doing multiple in-app purchases (not consumable) from the same test account made it easy to develop and test the code without too much hazzle.

After 20th june 2016, the purchases did not show in my merchant account and i was unable to do more than 1 purchase from my test account. All i got was the: "you already own this item" message.

I logged a request to the google developer support group and the answer was:

Beginning June 20, 2016, we changed test purchases for one-time in-app purchases (IAPs). Previously, test purchases for one-time IAPs generated order IDs. Starting June 20, 2016, one-time IAPs do not generate official order IDs (if at all) and will not appear in the Merchant Center. This behavior already applies to subscription IAPs. You can learn more about testing in-app billing in the Android Developers Help Center: https://developer.android.com/google/play/billing/billing_testing.html#testing-purchases

allright.. so i go to the mentioned link and theres a section there: Canceling completed test purchases which states:

Google Play accumulates completed test purchases for each user but does not pass them on to financial processing. In some cases, you might want to manually cancel a test purchase to continue testing. To do so, open the app page in the Play Store. If the test purchase that you want to cancel is a subscription, you can also use the cancel() method of the Purchases.subscriptions API. Important: The refund() and revoke() methods of the Purchases.subscriptions API don't support test purchases.

So I go to the app page in play store...and do what exactly? the webpage does not state what i am supposed to do there. anyone know?

it does say: you can also use the cancel() method of the Purchases.subscriptions API.

which indicates that using the cancel() method is not the only method.

How to solve this without adding additional code in my app?

like image 848
KennethJohansen Avatar asked Aug 08 '16 17:08

KennethJohansen


3 Answers

I went into the main Google Play Console page and clicked on Order Management. Under that I was able to select all test purchases and Refund them. I'm the primary developer of the app so I have access. If you are a tester you'd probably have to contact the support team and request that they refund your order.

like image 157
cminus Avatar answered Oct 15 '22 13:10

cminus


All managed in-app products are consumable.

as stated in the docs.

That means that you can consume an owned item instead of cancelling the purchase and buy it all over again. I suggest querying the inventory at the app launch time:

mIabHelper.queryInventoryAsync(this);

You can then consume the owned item in the callback:

@Override
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
    Purchase purchase = inventory.getPurchase(MY_SKU);
    boolean isBought = (purchase != null && verifyDeveloperPayload(purchase));
    if (isBought) {
        mIabHelper.consumeAsync(purchase, new OnConsumeFinishedListener() {
            @Override
            public void onConsumeFinished(Purchase purchase, IabResult result) {
                //Clear the purchase info from persistent storage
            }
        });
    }
}

This is OK for testing the IAB flow but make sure to remove this code from the release version.

like image 20
dev.bmax Avatar answered Oct 15 '22 12:10

dev.bmax


  • On Play Console, go to Developer Account -> Account Details, set the license testers (you are one by default)

  • Purchase items

  • Go to Order Management, choose those test orders, select: refund, but DON'T FORGET to check REVOKE when you are refunding. (I forgot to revoke, and now can't find a way to take them back)

Anyway, another test account will do.

like image 11
user2167374 Avatar answered Oct 15 '22 13:10

user2167374