Search code examples
androidgoogle-playin-app-billing

Internal purchases in the android application


The application already includes purchases of internal currency through google pay, but I can buy a certain amount of currency only 1 time, the next time the payment dialog does not start. Why is this happening ? maybe I need to configure something in the play console


Solution

  • It's because you have to consume your purchase, as such:

    override fun onPurchasesUpdated(result: BillingResult, purchases: List<Purchase>?) {
        purchases?.forEach { consumePurchase(it) }
    }
    
    private fun consumePurchase(purchase: Purchase) {
        val consumeParams = ConsumeParams
            .newBuilder()
            .setPurchaseToken(purchase.purchaseToken)
            .build()
    
        billingClient.consumeAsync(consumeParams) { result, _ ->
            if (result.responseCode == OK) {
    
            }
        }
    }
    

    This signals to the Play Store that your app has received the update and processed it in it's backend, so it's ready for a second purchase. You can still do this by calling billingClient.queryPurchaseHistory(INAPP).