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
If you use a similar way than TrivialDriveKotlin, I post an functional answer in this post https://stackoverflow.com/a/61141740/1568148
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.
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
}
}
}
}
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
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.