java-处理跨会话设备的应用程序内购买消费品?

java-处理跨会话设备的应用程序内购买消费品?,第1张

概述我的问题集中在使用Google的应用内结算API处理应用内购买的消耗品.(https://developer.android.com/google/play/billing/api.html#consumetypes)他们的文档将耗材描述为:ConsumableproductsIncontrast,youcanimplementconsumptionforproductsthatcanbemadeavail

我的问题集中在使用Google的应用内结算API处理应用内购买的消耗品. (https://developer.android.com/google/play/billing/api.html#consumetypes)

他们的文档将耗材描述为:

Consumable products

In contrast, you can implement consumption for products that can be made available for purchase multiple times. Typically, these products provIDe certain temporary effects. For example, the user’s in-game character might gain life points or gain extra gold coins in their inventory. dispensing the benefits or effects of the purchased product in your application is called provisioning the managed product. You are responsible for controlling and tracking how managed products are provisioned to the users.

消耗品是可以多次购买的东西(例如游戏币,游戏中的物品或使用的升级等),而非消耗品只能购买一次(无广告,皮肤/角色)等)

在有关消费的文档(https://developer.android.com/training/play-billing-library/purchase-iab-products.html)中,还提到:

How you use the consumption mechanism in your app is up to you. Typically, you would implement consumption for products with temporary benefits that users may want to purchase multiple times, such as in-game currency or replenishable game tokens. You would typically not want to implement consumption for products that are purchased once and provIDe a permanent effect, such as a premium upgrade.

It’s your responsibility to control and track how the in-app product is provisioned to the user. For example, if the user purchased in-game currency, you should update the player’s inventory with the amount of currency purchased.

我的问题是如何跟踪消耗品的用户库存?文档和各种视频似乎很快就掩盖了这一点,基本上是说该应用程序在确认购买成功后必须应用耗材的影响.但这并不是全部.如果用户注销并使用其他帐户重新登录怎么办?或者他们切换到新手机,则应该在该手机上安装该产品.

您实际上无法将购买记录保存在SharedPreferences或持久性缓存中,因为它与电话绑定.如果用户在其他电话上登录,则他们应该从所进行的所有购买中受益.

请看以下示例:

游戏以1000金币开始玩家.玩家通过应用内购买再购买500黄金,然后花费200黄金.如果玩家购买了一部新手机并在该手机上安装了该应用,则他们应该拥有1300金币.

通常如何完成?

您是否需要运行私人服务器来跟踪此类商品的购买/消费与Google分开?

谢谢!!

解决方法:

我正在自己实施应用内购买.

Do you need to run a private server that keeps track of purchases/consumption of such things separate from Google?

当然是,正如Google在Security Best Practices年建议的那样

It’s highly recommended to valIDate purchase details on a server that you trust. If you cannot use a server, however, it’s still possible to valIDate these details within your app on a device.

你的第二个问题

What if a user signs out and signs back in with a different account?

将orderID绑定到帐户或设备.
在第一种情况下,您可以在用户切换设备时轻松管理购买(这是获得私有服务器的另一个原因).
在第二种情况下,您可以允许在同一设备上切换帐户.
因此,由您决定选择哪一个.

您需要将本地消耗同步到服务器.

这是验证购买的流程:

User clicks “BUY” button.Makes payment with Google.App receives “receipt” from Google and store it locallySend this “RECEIPT” to the Server.The Server sends the “purchasetoken” to Google Play Developer API for valIDationThe Google Play Developer API sends response with status code.Store the RECEIPT in the server database (If we you to keep history of purchases by users).

这是消费产品的流程:

The user opens the app.App assigns values to the Resources by reading from local storage. App trIEs to synchronize with the Server.(checks last updated timestamp)

Different scenarios:

Synchronization Successful: Assigns Resource values from the server. Set newly retrIEved values in the local storage.

Synchronization Failed: Keep Resource values and try again.

User consumes the Resource.App updates local values in Resource and sync with the server.(checks last updated timestamp)

我使用了以下文章:

>教程:如何在AndroID LINK中实现应用内结算
>有关实施InApp购买LINK的文章.
>如何在服务器端验证AndroID应用程序的购买(应用程序帐单v3中的Google Play)LINK.
>另一个答案LINK.
>另一个答案LINK.
>代码项目样本LINK.

总结

以上是内存溢出为你收集整理的java-处理跨会话/设备的应用程序内购买/消费品?全部内容,希望文章能够帮你解决java-处理跨会话/设备的应用程序内购买/消费品?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/web/1080717.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-27
下一篇 2022-05-27

发表评论

登录后才能评论

评论列表(0条)

保存