首页 > 解决方案 > 我可以通过 Android App 中的 Google Play 一次购买多件商品吗?

问题描述

在我看来,我一次只能在 Google App 中购买一件商品。

代码 A 来自项目 play-billing-samples,您可以在此处查看

purchases: MutableList<Purchase>可能存在多个项目,我似乎可以通过Google Play同时购买这些项目,对吧?

代码 A

override fun onPurchasesUpdated(
        billingResult: BillingResult,
        purchases: MutableList<Purchase>?
) {
    when (billingResult.responseCode) {
        BillingClient.BillingResponseCode.OK -> {
            // will handle server verification, consumables, and updating the local cache
            purchases?.apply { processPurchases(this.toSet()) }
        }
        BillingClient.BillingResponseCode.ITEM_ALREADY_OWNED -> {
            // item already owned? call queryPurchasesAsync to verify and process all such items
            Log.d(LOG_TAG, billingResult.debugMessage)
            queryPurchasesAsync()
        }
        BillingClient.BillingResponseCode.SERVICE_DISCONNECTED -> {
            connectToPlayBillingService()
        }
        else -> {
            Log.i(LOG_TAG, billingResult.debugMessage)
        }
    }
}

标签: androidkotlingoogle-play

解决方案


用户只能拥有相同的应用内商品一次,但他可以同时拥有不同的商品。

其他解决方案是将物品视为消耗品:

如果billingClient.consumeAsync()在购买过程结束时被调用,那么他可以再次购买相同的物品,但是您必须通过自己的方式(可能通过后端服务器)跟踪他购买了多少次。


推荐阅读