Home » Android » android – Cancelling orders on Google Play IAB test purchases after June 20, 2016

android – Cancelling orders on Google Play IAB test purchases after June 20, 2016

Posted by: admin April 23, 2020 Leave a comment

Questions:

I have been using Google Play in-app purchases (IAPs) for a long time, but recently (June 20, 2016). They updated the Payments Merchant Center so that test purchases are not shown anymore. I quote a recent email to developers:

“Previously, test purchases for one-time IAPs generated order IDs. Starting June 20, 2016, one-time IAPs will not generate order IDs and will not appear in the Merchant Center.”

I have found no information regarding purchases (not subscriptions) in the link:
https://developer.android.com/google/play/billing/billing_testing.html
The page has a “Canceling completed test purchases” that only comments on subscriptions.

My question is, where do I cancel a test purchase if they do not appear in the Payments Merchant Center?

UPDATE- Official answer from Google Support:

Thanks for contacting Google Play Developer Support.
I checked into it, and the Play Developer Console doesn’t currently support the cancelation of test IAP. The only ways are to either consume the IAP or wait the 14 days consumption time.

UPDATE 2- Thanks to the answer below from Mike, I inserted the code below:

Purchase premiumPurchase = inventory.getPurchase(Constants.SKU_PRO);
if (premiumPurchase != null) {
    App.mHelper.consumeAsync(premiumPurchase, new IabHelper.OnConsumeFinishedListener() {
        @Override
        public void onConsumeFinished(Purchase purchase, IabResult result) {
            Log.d(TAG, "Test purchase is consumed.");
        }
    });
}

I only run this code to cancel the test purchase and debug the complete purchase flow again.

How to&Answers:

The easiest way to cancel an in-app purchase is to consume it. If you use the Google provided IabHelper you can just call consumeAsync and pass in the Purchase. I maintain a function to consume all the app’s in-app products; this is essentially a billing reset function for testing.

Answer:

What I get from the Android developer site is that they prevent the purchase flow from at all getting to the point where you have to pay for it if it is a test purchase. It makes it easier because Google makes sure you do not pay for test purchases. It stops them within 14 days. The accounts that are to do that needs testing licences that you can activate from the Developer console.

So you do not have to cancel them because technically you never purchased anything while at the same time you get to test what happens when something is bought. But the merchant center never recieves the request.

EDIT:

If you are to try to directly cancel and see what happens, do a real purchase and cancel it.

Answer:

I am late to the question, but this is the most recent way to refund/cancel in-app purchases from Google. On you Google Play Console in the left hand menu there is a menu item called Order management. This brings up an order summary with a blue REFUND button at the bottom. Click this, select a reason for the refund and submit.

Explanation on official docs

Answer:

This is an up-to-date Kotlin code that will consume all your purchases so you can buy them again. BE CAREFUL not to use this in production code, since doing this will surely have undesired behaviours.

Clearly, you’ll have to obtain your purchases previously.

fun consumeAllTestPurchases(purchases: ArrayList<Purchase>) {
    purchases.value?.forEach {
        val consumeParams = ConsumeParams.newBuilder().setPurchaseToken(it.purchaseToken).build()
        billingClient.consumeAsync(consumeParams) { billingResult, _ ->
            if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
                var purchaseConsumed = true
            }
        }
    }
}

Answer:

If you use a similar way than TrivialDriveKotlin, I post an functional answer in this post https://stackoverflow.com/a/61141740/1568148