The Google Play Billing library documentation on acknowledging purchases states that:
you must acknowledge all purchases that have a SUCCESS state received through the Google Play Billing Library as soon as possible after granting entitlement to the user.
So your app should first give the user what he bought, and then acknowledge the purchase. This is also what their example code implies:
fun handlePurchase() {
if (purchase.purchaseState === PurchaseState.PURCHASED) {
// Grant entitlement to the user.
...
// Acknowledge the purchase if it hasn't already been acknowledged.
if (!purchase.isAcknowledged) {
val acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder()
.setPurchaseToken(purchase.purchaseToken)
.build()
client.acknowledgePurchase(acknowledgePurchaseParams, acknowledgePurchaseResponseListener)
}
}
}
I am currently developing an Android app where I give users access to their bought content after the acknoweldgement returned with an OK status (so the other way around):
private fun acknowledgePurchase(purchase: Purchase) {
val params = AcknowledgePurchaseParams.newBuilder()
.setPurchaseToken(purchase.purchaseToken)
.build()
billingClient.acknowledgePurchase(params) { billingResult ->
when (billingResult.responseCode) {
BillingResponseCode.OK -> loadPurchase(purchase.sku)
else -> { ... }
}
}
}
because the documentation states that:
... you must acknowledge all purchases within three days. Failure to properly acknowledge purchases results in those purchases being refunded.
If this happens, and a user gets refunded, the user's entitlment to the product should also be withdrawn. But in my case, making a purchase means loading data, storing stuff in the database, and so on, and I do not have, nor do I want to have, code in place to revert this. Therefore I provide the user with the product only after a successful acknowledge.
Hence my question: is it okay to wait with granting entitlement to an in-app purchase until after the purchase has been acknowledged? Or is there some catch I am missing here? I assume that the documentation specifies this order for a reason, but they do not elaborate on it.