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

坚强是说给别人听的谎言 提交于 2020-06-27 08:59:11

问题


In my mind, I can only puchase one item at one time in Google App.

The Code A is from the project play-billing-samples, you can see here.

purchases: MutableList<Purchase> maybe exist multiple items, it seems that I can purchase these items simultaneously through Google Play, right?

Code 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)
        }
    }
}

回答1:


An user can own the same in-app item only once, but he can own different items at the same time.

Other solution is to consider the item as consumable:

if billingClient.consumeAsync() is called at the end of the purchase process then he can buy the same item again, but you have to keep track of how many times he bought it by your own means, probably through a backend server.




回答2:


Yes, there is no method to buy all them at once. As you have to consume it before using again or using another one. But what you can do is create a single combined in app product which is a sum of all of your packages.

Suppose you have item A with $2,B with $3, C with $5. Then you can crate a item with sum of (A+B+C) i.e., $10 and provide all the benefits of Item A,B and C to the user.



来源:https://stackoverflow.com/questions/61907342/can-i-purchase-multiple-items-at-one-time-through-google-play-in-android-app

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!