Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Flutter and app store releases

In-app purchase fails in Google Play with a purchase error while testing

ErrorAn error message in the Google Play purchase cart

Short answer

A generic purchase error is the Play Store's way of saying the billing flow stopped. Log the BillingResult response code and debug message first. In test setups the cause is usually that the account is not a license tester, the product is not active or available in the tester's country, or the Play Store is out of date.

  • Applies to Google Play Billing Library 8, Android 14, Play Console
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Print the response code and debug message that launchBillingFlow or queryProductDetailsAsync returns. The code tells you which cause below applies, and the message often names the exact problem.

    Log.e("Billing", "code=${billingResult.responseCode} msg=${billingResult.debugMessage}")
  2. 2Match what you see, then jump to its fix

    1. 1No test notice across the middle of the purchase dialog, and no test payment methods offeredThe account on the device is not a license testerFix
    2. 2BillingResponseCode.ITEM_UNAVAILABLE, or an empty product list from queryProductDetailsAsyncThe product is not available to this user (ITEM_UNAVAILABLE)Fix
    3. 3BillingResponseCode.BILLING_UNAVAILABLEThe Play Store cannot sell to this user right now (BILLING_UNAVAILABLE)Fix
    4. 4BillingResponseCode.DEVELOPER_ERROR from launchBillingFlowThe billing call is wrong (DEVELOPER_ERROR)Fix
    5. 5An error message in the purchase cart on an app that is in draft or only on the internal trackSpend limits on an unpublished appFix

What does the error look like?

  • An error message in the Google Play purchase cart
  • BillingResponseCode.ITEM_UNAVAILABLE
  • BillingResponseCode.BILLING_UNAVAILABLE
  • BillingResponseCode.DEVELOPER_ERROR

Cause 1 of 5

The account on the device is not a license tester

1Check

Test purchases that avoid real charges only work for license testers. Confirm the Google Account that downloaded the app is on a license testing list, and that the account is on the device.

# On the device: Settings > Passwords & accounts, and the account shown in the Play Store profile menu

2Fix

In Play Console open Monetization settings, then License testing, add the tester's Gmail address to an email list or Google Group, and save. Use that account on the device.

# Play Console > Manage account > Play apps settings
#   > Monetization settings > License testing > add email list > Save changes

3Verify

Start the purchase again. A test purchase shows a notice across the middle of the purchase dialog and offers test payment methods such as the always-approves one.

# Look for the 'Test instrument, always approves' payment method in the dialog

Confirmed by developer.android.com

Did this fix it?

Cause 2 of 5

The product is not available to this user (ITEM_UNAVAILABLE)

1Check

A product can only be bought when it is active, its app is published, and the app is available in the user's country. Run the product query and see whether the product id comes back.

val params = QueryProductDetailsParams.newBuilder()
    .setProductList(listOf(
        QueryProductDetailsParams.Product.newBuilder()
            .setProductId("premium_upgrade")
            .setProductType(BillingClient.ProductType.INAPP)
            .build()))
    .build()
billingClient.queryProductDetailsAsync(params) { result, details ->
    Log.d("Billing", "code=${result.responseCode} found=${details.productDetailsList.size}")
}

2Fix

Activate the product in Play Console, publish the app to at least a testing track, and make sure the tester's country is included. If everything is correct and it still fails right after a change, wait: product details can take time to spread across Google's servers.

# Play Console > Monetize with Play > Products > In-app products
#   > open the product > Activate

3Verify

queryProductDetailsAsync returns the product with response code OK, and the purchase sheet opens.

# found=1 in the log line above

Confirmed by developer.android.com

Did this fix it?

Cause 3 of 5

The Play Store cannot sell to this user right now (BILLING_UNAVAILABLE)

1Check

Google lists these situations: the Play Store app is out of date, the user is in an unsupported country, an enterprise admin blocked purchases, the payment method cannot be charged, or the Play Store is blocked by the system (the debug message says Play Store is blocked).

# On the device: Play Store > profile icon > Settings > About > Play Store version

2Fix

Update the Play Store, use a device or profile that is allowed to buy, or fix the payment method. A manual retry works only after that condition is gone, so show a Try again button instead of retrying in a loop.

# On the device: Play Store > profile icon > Settings > About > Update Play Store

3Verify

Try the purchase again after the change and read the new response code.

# The Billing log line now shows a different code, or OK

Confirmed by developer.android.com

Did this fix it?

Cause 4 of 5

The billing call is wrong (DEVELOPER_ERROR)

1Check

DEVELOPER_ERROR means an API was used wrongly, for example wrong parameters passed to launchBillingFlow. Read the debug message, then compare the ProductDetails and offer token you pass with the ones queryProductDetailsAsync returned.

Log.e("Billing", billingResult.debugMessage)

2Fix

Build BillingFlowParams from a ProductDetails object you just queried, and for subscriptions pass the offer token of the chosen offer.

val productParams = BillingFlowParams.ProductDetailsParams.newBuilder()
    .setProductDetails(productDetails)
    .build()
val flowParams = BillingFlowParams.newBuilder()
    .setProductDetailsParamsList(listOf(productParams))
    .build()
billingClient.launchBillingFlow(activity, flowParams)

3Verify

launchBillingFlow returns OK and the purchase sheet appears.

# billingResult.responseCode == BillingClient.BillingResponseCode.OK

Confirmed by developer.android.com

Did this fix it?

Cause 5 of 5

Spend limits on an unpublished app

1Check

Apps in draft or on the internal test track have limits on daily transactions, per-order value and daily total spend. They reset every 24 hours.

# Compare the number and size of today's test purchases with the limits

2Fix

Wait for the limits to reset, or publish the app to a closed, open or production track if your testing needs higher limits.

# Play Console > Test and release > Testing > Closed testing > Create release

3Verify

The purchase goes through after the reset or after the release is live on the higher track.

# The order appears in Play Console > Orders

Confirmed by developer.android.com

Did this fix it?

How do I stop it coming back?

  • Keep one dedicated license-tester account per developer and sign in with it on every test device.
  • Log responseCode and debugMessage on every billing call, not only on failures you expect.
  • Query product details before every purchase and only offer products that come back.
  • Acknowledge each purchase: a license tester's purchase is refunded after 3 minutes when it is not acknowledged.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Mobile apps

Android Studio cannot pair the phone over Wi-Fi

The Pair devices over Wi-Fi dialog lists no device

Wireless pairing needs the phone on Android 11 or higher and on the same Wi-Fi network as the computer, with current Platform-Tools.

4 causes, each with a fix

Mobile apps

adb tcpip 5555 fails because no device is found

adb: more than one device/emulator

adb tcpip only works while the device is attached and listed by adb, because it tells the phone to start listening on port 5555.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.