0

I've followed a tutorial about implementing subscriptions with Google Billing, but I've left out some methods but it seems to work just fine.

This is one of the methods I left out:

private fun handelPurchase(purchase: Purchase){
    val consumeParams =
        ConsumeParams.newBuilder()
            .setPurchaseToken(purchase.purchaseToken)
            .build()

    val listener = ConsumeResponseListener { billingResult, s ->

        if(purchase.purchaseState == BillingClient.BillingResponseCode.OK){

        }
    }
    billingClient.consumeAsync(consumeParams, listener)
    if(purchase.purchaseState == Purchase.PurchaseState.PURCHASED){

    }
}

What is the purpose of it? Should I still implement it?

This is the last step that I'm using so far:

private fun ackPurchase(purchase: Purchase) {
    if (!purchase.isAcknowledged) {
        val params = AcknowledgePurchaseParams.newBuilder().setPurchaseToken(purchase.purchaseToken).build()
        billingClient.acknowledgePurchase(params) { billingResult ->
            if(billingResult.responseCode == BillingClient.BillingResponseCode.OK){
                premiumActivate()
            }
        }
    }else{
        premiumActivate()
    }
}

so do I need both or only one of those? Google docs are as always incomplete

The only other question that I've found that is similar is:

Android In-app billing, How to determine whether to call consumeAsync or acknowledgePurchase?

but it's not answered

Eduard Unruh
  • 985
  • 1
  • 14
  • 35

0 Answers0