Google refunds your purchase if you skip this one call
Stop treating launchBillingFlow as a synchronous checkout. Learn why PENDING states require no action, how to verify and acknowledge within three days, and why querying purchases on every start is mandatory to avoid automatic refunds.

The purchase isn't done when launchBillingFlow returns. That is the trap. Most developers treat the return value of that function as a confirmation that the user has paid. It is not. The result arrives later in a listener, sometimes after the app was closed, sometimes as PENDING, and sometimes from a different device. If you grant entitlements immediately or skip the final confirmation step, Google's integration guide states that the purchase is automatically refunded and the entitlement revoked.
The book Get Paid for Your Android App opens its billing chapter with exactly this warning under the heading "The trap". This post covers the lifecycle of a purchase, the specific handling required for PENDING states, and the mandatory refresh call that keeps your app compliant.
One caveat, straight from the book: this guidance applies to Play Billing Library 9.1.0 (June 18, 2026) and later. Versions have strict deadlines; starting a new integration today means using version 9.1.0, which buys you until August 31, 2028. The author's TextPilot app serves as a real example of these deadlines arriving, where policy status required target API 36 and Billing 8.0.0.
The trap: assuming launchBillingFlow returns "paid"
The most common mistake is treating launchBillingFlow() like a checkout that returns a synchronous "paid" status. It does not. The result arrives asynchronously in a listener. This delay introduces several risks. The payment might come back as PENDING if the user selects a delayed method like cash or certain wallets. If you grant access immediately, you risk giving away features for free if the payment fails later. Furthermore, the purchase event might arrive after the app has been closed, or it might originate from a different device where the user logged in with their Google account.
Google gives every major version of the library a two-year life. If you are upgrading old code, note that version 8.0.0 removed several methods including queryPurchaseHistory() and querySkuDetailsAsync(). Version 9.0.0 changed the response for a blocked Play Store from ERROR to BILLING_UNAVAILABLE, and the library's targetSdkVersion became 35. You must ensure your client is connected properly before attempting any billing operations.
// BillingRepository.kt
import com.android.billingclient.api.BillingClient.BillingResponseCode
class BillingRepository(context: Context, private val scope: CoroutineScope) :
PurchasesUpdatedListener {
private val _purchases = MutableStateFlow<List<Purchase>>(emptyList())
val purchases: StateFlow<List<Purchase>> = _purchases
private val client = BillingClient.newBuilder(context)
.setListener(this)
.enablePendingPurchases(
PendingPurchasesParams.newBuilder()
.enableOneTimeProducts()
.build()
)
.enableAutoServiceReconnection()
.build()
fun connect() {
if (client.isReady) { refreshPurchases(); return }
client.startConnection(object : BillingClientStateListener {
override fun onBillingSetupFinished(result: BillingResult) {
if (result.responseCode == BillingResponseCode.OK) {
refreshPurchases()
}
}
override fun onBillingServiceDisconnected() {
// Auto reconnection handles retries; nothing to do here.
}
})
}
override fun onPurchasesUpdated(
result: BillingResult,
purchases: List<Purchase>?,
) {
when (result.responseCode) {
BillingResponseCode.OK -> purchases?.forEach(::process)
BillingResponseCode.USER_CANCELED -> Unit
else -> Log.w(TAG, "Update error ${result.responseCode}")
}
}
// refreshPurchases(), process() and acknowledge() follow below.
private companion object { const val TAG = "Billing" }
}
The trap: granting access for PENDING purchases
When the listener returns a purchase with state PENDING, you must not grant any entitlements. A PENDING state means the user has started paying by a delayed method, but the transaction is not yet complete. Google's integration guide explicitly states that if your app does not acknowledge a purchase within three days, it is automatically refunded and the entitlement revoked.
The lifecycle of a purchase requires you to verify the signature on your server (if you have one), grant the entitlement for PURCHASED states, and then acknowledge the purchase. For consumables like coins or credits, you consume them instead, which both acknowledges the purchase and allows the user to buy it again. A remove-ads unlock is never consumed.
private fun process(purchase: Purchase) {
when (purchase.purchaseState) {
Purchase.PurchaseState.PENDING -> {
// Tell the user payment is pending. Grant nothing.
}
Purchase.PurchaseState.PURCHASED -> {
// 1. Verify (on your server if you have one, Chapter 7).
// 2. Grant the entitlement (Chapter 6).
// 3. Acknowledge, unless it is a consumable you consume instead.
if (!purchase.isAcknowledged) acknowledge(purchase)
}
else -> Unit
}
_purchases.update { current ->
val token = purchase.purchaseToken
current.filterNot { it.purchaseToken == token } + purchase
}
}
private fun acknowledge(purchase: Purchase) {
val params = AcknowledgePurchaseParams.newBuilder()
.setPurchaseToken(purchase.purchaseToken)
.build()
client.acknowledgePurchase(params) { result ->
if (result.responseCode != BillingResponseCode.OK) {
Log.w(TAG, "Ack failed ${result.responseCode}; retry on refresh")
}
}
}
The trap: trusting only the listener
Google lists several cases where the listener will miss a purchase. The network might drop after payment, the user might have bought something on another device, or a promotion might have been redeemed outside the app. A pending payment might also complete while the app was closed. Relying solely on onPurchasesUpdated is insufficient because it does not cover these offline or cross-device scenarios.
The fix is to call queryPurchasesAsync on every start and whenever the app returns to the foreground. This one refresh also retries failed acknowledgements, keeping them well inside the three-day window. Because process() acknowledges anything not yet acknowledged, this periodic check ensures that no purchase remains in a limbo state that triggers an automatic refund.
fun refreshPurchases() {
val types = listOf(ProductType.INAPP, ProductType.SUBS)
types.forEach { type ->
client.queryPurchasesAsync(
QueryPurchasesParams.newBuilder().setProductType(type).build()
) { result, list ->
if (result.responseCode == BillingResponseCode.OK) {
list.forEach(::process)
}
}
}
}
Checklist
- Never treat
launchBillingFlow()as a synchronous payment confirmation; the result arrives later in a listener. - Check
purchase.purchaseStateforPENDING; grant nothing and inform the user that payment is processing. - For
PURCHASEDstates, verify the signature, grant the entitlement, and acknowledge the purchase immediately. - Call
queryPurchasesAsyncfor bothINAPPandSUBStypes every time the app starts or resumes to catch missed events. - Ensure your
BillingClientusesenableAutoServiceReconnection()to handle network drops automatically. - Use
setObfuscatedAccountId()when launching flows to help Google detect fraud and attribute purchases correctly; never pass readable data like email addresses. - Test using license testers in Play Console with test payment methods that simulate delays, declines, or chargebacks.
- Verify your library version against Google's deprecation deadlines; as of October 2026, new apps require version 8 or later, with 9.1.0 being the current stable release.