Cancelling orders on Google Play IAB test purchases after June 20, 2016
Asked Answered
F

5

33

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.

Flung answered 30/6, 2016 at 17:45 Comment(3)
Do you keep the above code in your production release? or do you have to add/remove it for the alpha/beta test version?Carnet
I do not run this code in production/release, it will cancel a real purchase. I use only in beta, and in a hidden button normal users would not be able to find.Flung
Ahh, "in a hidden button normal users would not be able to find". I hope Chuck Norris is not one of your testers. He will find that button.Kravits
O
14

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.

Oldtime answered 15/7, 2016 at 23:10 Comment(4)
Nice, perfect it this way I can cancel a test purchase. It does work, thank you very much.Flung
@Antonio. You should mark the answer as accepted if it has answered your question. meta.stackexchange.com/questions/5234/…Besprinkle
@powder366 Code was provided in the question that does exactly what I described. Check out the "UPDATE 2" section of the question.Oldtime
how to consume all in-app products?Repellent
Z
1

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.

Zosima answered 30/6, 2016 at 17:53 Comment(5)
Yes, I have several testing accounts that can make in app purchases that I have added in the Developer Console. Right now I’m testing several procedures that occur at purchase time. In order to test correctly I need to cancel the purchase, to make the purchase again and debug all the process. The 14 day wait does not solve the problem for me. Few days ago, I just hit the “cancel order” button on the Payments Merchant Center, but now I can’t find a way to “cancel” or “refund” the test purchase.Flung
According to google all test purchases made with the licence and all of that will never be processed in the form of the payment part. To test the cancelling it isn't enough with test purchases as far as I know. But if you do a real purchase and cancel it it will have the same effect as it doesn't cost anythingZosima
True. Making a real purchase, and refunding the purchase will allow me to test all purchase procedure. But there should be a solution without involving real money banking transactions, after all that is the purpose of “test purchase”, where you should be able to test all the purchase flow. You should be able to cancel a test purchase in Google Play. I haven’t found a way yet.Flung
Yea, but if google suddenly stops supporting that you have to do it other waysZosima
If I understand you correctly, The problem is you want to test cancellation of a purchase order. Since you are a developer you want to cancel the purchase, to make the purchase again and debug all the process as you done previously. Since the Test Order is not available at merchant page now, you can not cancel a test order anymore.Laborer
B
1

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

Bartolome answered 20/9, 2017 at 12:13 Comment(2)
I get this message in the developer console: "The selected orders can not be refunded due to their age, status, or because you are missing the necessary permissions" (or similar do to translation) I am admin for the account so I don't know what the problem.Cobbett
i got above message too, any solution ?Aronow
T
0

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
            }
        }
    }
}
Thing answered 24/12, 2019 at 11:36 Comment(0)
A
0

If you use a similar way than TrivialDriveKotlin, I post an functional answer in this post https://mcmap.net/q/336434/-how-to-cancel-an-in-app-test-purchase-on-android

Attestation answered 10/4, 2020 at 16:32 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.