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

前端 未结 5 1622
感情败类
感情败类 2020-12-13 18:28

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

5条回答
  •  死守一世寂寞
    2020-12-13 19:05

    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) {
        purchases.value?.forEach {
            val consumeParams = ConsumeParams.newBuilder().setPurchaseToken(it.purchaseToken).build()
            billingClient.consumeAsync(consumeParams) { billingResult, _ ->
                if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
                    var purchaseConsumed = true
                }
            }
        }
    }
    

提交回复
热议问题