I am working on migrating my project from Google Billing Library 4 to use Google Billing Library 6. In my querySkuDetails()
method, I can't access the sku (string) from queryProductDetailsAsync
Here's my progress. I am not able to access skuDetails.sku
, along with skuDetails.price
private fun querySkuDetails() {
val productList =
listOf(
QueryProductDetailsParams.Product.newBuilder()
.setProductId(PRODUCT_ID)
.setProductType(BillingClient.ProductType.INAPP)
.build()
)
val params = QueryProductDetailsParams.newBuilder().setProductList(productList).build()
billingClient?.queryProductDetailsAsync(params) { billingResult, productDetailsList ->
if (billingResult.responseCode == BillingClient.BillingResponseCode.OK) {
for (skuDetails in productDetailsList) {
val sku = skuDetails.sku
if (PRODUCT_ID == sku) {
val price = skuDetails.price
priceFromBillingManager = price
}
}
}
}
}
You can replace skuDetails.sku
with skuDetails.productId
As for skuDetails.price
, now it depends on the product type. Since you've requested INAPP
, you can find the price details inside skuDetails.oneTimePurchaseOfferDetails
. The corresponding property is called formattedPrice
.