小编syn*_*ded的帖子

Google结算库取消了所有订阅

我正在使用 Google 的计费库在我的应用程序内进行订阅。

~~ 3天后,google play已经退还了我用户的所有订阅,为什么呢?

一些带有活动的代码,用于进行订阅:

    private var billingClient: BillingClient? = null
    private val purchasesUpdateListener = PurchasesUpdatedListener { billingResult, purchases ->
        val isSuccessResult = billingResult.responseCode == BillingClient.BillingResponseCode.OK
        val hasPurchases = !purchases.isNullOrEmpty()
        if (isSuccessResult && hasPurchases) {
            purchases?.forEach(::confirmPurchase)
            viewModel.hasSubscription.value = true
        }
    }

    private fun confirmPurchase(purchase: Purchase) {
        val consumeParams = ConsumeParams.newBuilder()
            .setPurchaseToken(purchase.purchaseToken)
            .build()
        billingClient?.consumeAsync(consumeParams) { billingResult, _ ->
            if (billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
                //all done
            }
        }
    }
 override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
   
        billingClient = BillingClient.newBuilder(this)
            .setListener(purchasesUpdateListener)
            .enablePendingPurchases() …
Run Code Online (Sandbox Code Playgroud)

android google-play in-app-subscription play-billing-library

0
推荐指数
1
解决办法
396
查看次数