1

I require in-app purchases for certain functionality in my Android App. For users in countries where in-app purchases are not supported I want to make this functionality available for free.

How can one check if in-app purchases are supported in the user's Google Play country?

Problems with things I tried:

  1. It seems not possible to determine the Play Store Country.

  2. Checking BillingClient.BillingResponseCode for BILLING_UNAVAILABLE does not help as this response may also be returned if "The Play Store app on the user's device is out of date" or "Google Play is unable to charge the user’s payment method".

  3. The debugMessage in the BillingResult returned by the onBillingSetupFinished callback of BillingClient.startConnection seems also not helpful as it incorrectly says "Google Play In-app Billing API version is less than 3" for unsupported countries. (I tried for China using VPN.)

  4. Checking the user's IP address would give wrong results if the user is in a country other than his Play country or uses a VPN.

  5. Using location APIs would require location permissions and also give wrong results if the user is in a foreign country.

jake n
  • 342
  • 3
  • 15

1 Answers1

-1

In latest version of Billing library (5.1). BILLING_UNAVAILABLE represents:

The Play Store app on the user's device is out of date.

The user is in an unsupported country.

The user is an enterprise user and their enterprise admin has disabled users from making purchases.

Google Play is unable to charge the user’s payment method.

implementation "com.android.billingclient:billing-ktx:5.1.0"

So, I hope this will be helpful for you.

After initializing billingClient object, query for starting connection.

billingClient.startConnection(object : BillingClientStateListener {
    override fun onBillingServiceDisconnected() {}

    override fun onBillingSetupFinished(billingResult: BillingResult) {
        val isBillingReady = billingResult.responseCode == BillingClient.BillingResponseCode.OK
        if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
            // Available
        } else if (billingResult.responseCode == BillingClient.BillingResponseCode.BILLING_UNAVAILABLE){

            // Make free purchases

        } else {
            // some error needs to be handled
        }
    }
})

I have recently developed a template of Google Play Billing V5, you can have a look into that too.

Sohaib Ahmed
  • 1,990
  • 1
  • 5
  • 23