在我的应用程序中,我进行了购买。问题是购买工作正常。但是,我想在购买退款时禁用购买的功能。我在谷歌上搜索他们是否是一种检测退款的方法,但没有成功。接下来我尝试实现自己的功能。这列出了购买的物品:
...
billingClient.apply {
queryPurchasesAsync(BillingClient.SkuType.INAPP) { _, skuDetailsList ->
var isPro = false
skuDetailsList.forEach { item ->
Log.wtf("TST_", item.toString())
item.skus.forEach { sku ->
if (skuIds[0] == sku)
isPro = true
}
}
purchased(isPro) // BTW mIsPro does not keep the new value outside of queryPurchasesAsync hence, I need to call a method for it.
// Any ideas why? May be because of queryPurchasesAsync?
}
}
...
private fun purchased(isPro: Boolean) {
mIsPro = isPro
}
从逻辑上讲,当购买退款时,该商品不应在queryPurchasesAsync
. 但是,它被列出,这里是日志输出:
Purchase. Json: {"orderId":"GPA.3368-7206-8304-37493","packageName":"com.myapp.mycarapp","productId":"test_pro","purchaseTime":1631452097318,"purchaseState":0,"purchaseToken":"fmfalggabkkdnojbpijmmeaj.AO-J1Oyr5MrPeRpY8Mu2UCvTrEhpv6WhQc8X4SBwlGusdae5NwTcWsJe5gpKAUsQSHGi82Ob0QyVat_rTwmB9eGqbJ8LRK5a0nF8KZqUKw0jZ3JjzwF3AA0","quantity":1,"acknowledged":false}
根据输出,它说购买状态为 0,这意味着UNSPECIFIED_STATE
它不是acknowledged
。我可以使用这些信息来构建一个功能来禁用这些功能。但不确定如何。
不幸的是,当购买退款时,我不知道如何完成它。
很高兴得到任何建议!