我可以通过 Google Play in Android App 一次购买多件商品吗?

Can I purchase multiple items at one time through Google Play in Android App?

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

代码A来自项目play-billing-samples,你可以看到here

purchases: MutableList<Purchase>可能存在多个物品,看来我可以通过GooglePlay同时购买这些物品,对吧?

代码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)
        }
    }
}

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

其他解决方案是将该项目视为消耗品:

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

是的,没有办法一次性全部买完。因为您必须在再次使用或使用另一个之前消耗它。但是您可以做的是创建一个组合的应用程序产品,它是您所有软件包的总和。

假设您有 A 件 2 美元,B 件 3 美元,C 件 5 美元。 然后,您可以用 (A+B+C) 的总和(即 10 美元)创建一个项目,并向用户提供项目 A、B 和 C 的所有好处。