I am trying to use IN-APP purchasing but I can't deal with querySkuDetailsAsync method. All code works well but inside SkuDetailsResponseListener only the first 2 line of codes are executing, namely itemInfo and textProduct.text are executing.
fun getProductDetails() {
val productIds = mutableListOf<String>()
productIds.add("product1")
val getProductDetailQuery: SkuDetailsParams = SkuDetailsParams
.newBuilder()
.setSkusList(productIds)
.setType(BillingClient.SkuType.INAPP)
.build()
billingClient.querySkuDetailsAsync(
getProductDetailQuery
) { billingResult, list ->
if (billingResult.responseCode == BillingClient.BillingResponseCode.OK && list != null) {
val itemInfo: SkuDetails = list[0]
textProduct.text = itemInfo.title
// BELOW ARE NOT EXECUTING ???
textDesc.text = itemInfo.description
btnPrice.text = itemInfo.price
btnPrice.setOnClickListener {
billingClient.launchBillingFlow(
this@BillingMainActivity,
BillingFlowParams.newBuilder()
.setSkuDetails(list[0])
.build()
)
}
} else {
val error = BillingUtils.getBillingResponses(billingResult.responseCode)
logBilling("getProductDetails error:$error")
}
}
}