0

When you apply in-app purchases described in the developer.android website this is the explanation link

Use the Google Play Billing Library

Everything is perfect I can get the price, description and address of the product The problem is the purchase dialog does not appear I use a real phone

This is the in-app purchase code

class AppBilling : AppCompatActivity(), PurchasesUpdatedListener {
private lateinit var billingClient: BillingClient
private val skuList = ArrayList<String>()

override fun onPurchasesUpdated(billingResult: BillingResult?, purchases: List<Purchase>?) {

    Log.i("TAG", "$billingResult :::: $purchases")

    if (billingResult != null) {
        if (billingResult.responseCode == BillingClient.BillingResponseCode.OK && purchases != null) {
            for (purchase in purchases) {
                Log.i("TAG", "$purchase if")
                handlePurchase(purchase)
            }
        } else if (billingResult.responseCode == BillingClient.BillingResponseCode.USER_CANCELED) {
            Log.i("TAG", "else if")
        } else {
            Log.i("TAG", "else")
        }
    }
}
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    setContentView(R.layout.activity_app_billing)
    billingClient = BillingClient.newBuilder(this@AppBilling).setListener(this).enablePendingPurchases().build()

    val params = SkuDetailsParams.newBuilder()
    skuList.add("rm_admob")
    params.setSkusList(skuList).setType(BillingClient.SkuType.INAPP)

    billingClient.startConnection(object : BillingClientStateListener {
        override fun onBillingSetupFinished(billingResult: BillingResult?) {
            billingClient.querySkuDetailsAsync(params.build()) { billingResult, skuDetailsList ->
                if (billingResult.responseCode == BillingClient.BillingResponseCode.OK && skuDetailsList != null) {
                    for (skuDetails in skuDetailsList) {
                        val sku = skuDetails.sku
                        val price = skuDetails.originalPrice
                        val title = skuDetails.title
                        val desc = skuDetails.description
                        val flowParams = BillingFlowParams.newBuilder().setSkuDetails(skuDetails).build()
                        if ("rm_admob" == sku) {
                            id_price.text = price
                            id_title.text = title
                            id_desc.text = desc

                            id_rm_admob.setOnClickListener {
                                val responseCode = billingClient.launchBillingFlow(this@AppBilling, flowParams)
                            }

                        }
                    }
                }
            }
        }

        override fun onBillingServiceDisconnected() {

        }

    })
}

private fun handlePurchase(purchase: Purchase) {
    if (purchase.sku == "rm_admob") {
        Log.i("TAG", "handlePurchase()")
    }
}
}

thank you

Mustafa Max
  • 59
  • 2
  • 9

1 Answers1

0

Please use your email id as a tester in google app console.

Avinash
  • 867
  • 4
  • 11
  • Please confirm the tester email same as phone email?. can i see where you put email in play console. – Avinash Oct 23 '19 at 04:15
  • Thank you This is a picture of the account https://2.top4top.net/p_139135bj21.png – Mustafa Max Oct 23 '19 at 08:37
  • yeah good,but please add email on manage tester option which are available on play console and keep in mind , please use release apk , after 1 hours the pop up will show. – Avinash Oct 24 '19 at 10:32