Android in-app multiple purchases

前端 未结 3 851
深忆病人
深忆病人 2021-01-18 02:12

Is there a way to do more than 1 item using in-app purchase? For example - can I buy 2 of the same item?

相关标签:
3条回答
  • 2021-01-18 02:23

    No, not at this time. You can buy multiple unmanaged items, but they'll need to be separate purchases.

    As a workaround, I've seen people create separate SKUs for different item quantities. For example:

    • potion_1 = 1 potion ($1)
    • potion_2 = 2 potions ($2)
    • potion_3 = 3 potions ($3)
    • and so on...

    Alternatively, you can allow users to buy in-app credits specific to your app (again, you'll need to create different SKUs representing different credit values), then write your own storefront for exchanging these credits for goods. It's a bit more work, but this gives you a lot more control and flexibility over the checkout flow.

    0 讨论(0)
  • 2021-01-18 02:25

    It's possible

    Reference: https://github.com/googlesamples/android-play-billing/blob/master/TrivialDrive/app/src/main/java/com/example/android/trivialdrivesample/MainActivity.java

    Basically you must cunsume the item to notify Google about this possibility.

    if (purchase.getSku().equals(SKU_GAS)) {
                    // bought 1/4 tank of gas. So consume it.
                    Log.d(TAG, "Purchase is gas. Starting gas consumption.");
                    try {
                        mHelper.consumeAsync(purchase, mConsumeFinishedListener);
                    } catch (IabAsyncInProgressException e) {
                        complain("Error consuming gas. Another async operation in progress.");
                        setWaitScreen(false);
                        return;
                    }
                }
    

    See the documentation about Consume a purchase

    https://developer.android.com/training/in-app-billing/purchase-iab-products.html#Consume

    0 讨论(0)
  • 2021-01-18 02:33

    Creation multiple Products is not correct answer. Because if you planing sell in-game money or "health potions". These things can be purchased an infinite number of times. See the answer about managed/unmanaged products to correct processing this situation.

    0 讨论(0)
提交回复
热议问题