Android 应用内多次购买

发布于 2024-12-23 08:32:10 字数 52 浏览 1 评论 0原文

有没有办法使用应用内购买购买超过 1 件商品? 例如 - 我可以购买 2 件相同的商品吗?

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

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

末が日狂欢 2024-12-30 08:32:10

创建多个产品不是正确的答案。因为如果你计划出售游戏内的金钱或“健康药水”。这些东西可以无限次购买。
请参阅有关托管/非托管产品的答案进行更正处理这种情况。

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.

谁与争疯 2024-12-30 08:32:10

不,现在不行。您可以购买多个非托管项目,但它们需要单独购买。

作为一种解决方法,我看到人们为不同的商品数量创建单独的 SKU。例如:

  • potion_1 = 1 瓶药水 ($1)
  • potion_2 = 2 瓶药水 ($2)
  • potion_3 = 3 瓶药水 ($3)
  • 等等...

或者,您可以允许用户购买特定于您的应用程序的应用程序内积分(同样,您需要创建代表不同信用值的不同 SKU),然后编写自己的店面以将这些信用值兑换成商品。这需要更多的工作,但这让您对结帐流程有更多的控制和灵活性。

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.

三生一梦 2024-12-30 08:32:10

可以

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

基本上你必须使用该项目来通知 Google 有关此可能性的信息。

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;
                }
            }

请参阅有关消费购买的文档

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

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文