本文介绍了播放应用内结算v3的 - 我应该保存购买代币?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在写一个特殊的应用程序内货币的Andr​​oid应用程序。您可以在1,5,10等的数据包通过应用内计费买这个货币。这里是我是如何实现的:

so I'm writing an android app with a special in-app currency. You can buy this currency in packets of 1, 5, 10 etc through in-app billing. Here is how I implemented it:


  1. 使用管理产品(当应用程序启动时,我使用IabHelper来查询购买的产品)

  1. Use managed products (When the app starts, I use IabHelper to query for purchased products)

一旦购买完成后,消费购买

As soon as the purchase completes, consume the purchase

我的问题是,如果第3步失败是什么?如果连接被切断或什么的,购买令牌将永远不会得到我的服务器。在这种情况下,用户支付了货币,但他们的帐户不会得到它。当我的应用程序再次启动,和1A运行时,它会找不到的购买,它也不会重新使用它。

My question is, what if step 3 fails? If the connection gets cut off or something, the purchase token will never get to my server. In that case, users will have paid for currency but their account won't get it. When my app starts again, and 1a runs, it won't find the purchase and it won't re-consume it either.

这是推理是否正确?如果是这样,我需要购买代币存储在Android的一面呢?然后,如果事情失败了,我不断重试,直到它的工作原理?这似乎有点凌乱......我也在想制作我的购买页面在这里你可以看到所有的购买,然后点击它们赎回,如果第3步中由于某种原因失败的。

Is this reasoning correct? If so, do I need to store purchase tokens on the android side? Then, if something fails, I keep retrying until it works? It seems kind of messy... I was also thinking of making a "My purchases page" where you could see all your purchases, and then click them to redeem it if step 3 failed for some reason.

推荐答案

您应该保持 purchaseToken 的后端。有两个原因这样做的:

You should keep purchaseToken on your backend. There are two reasons to do so:


  • 块重复购买

  • 保持消费购买的曲目

消费购买的情况应该是这样的:

The scenario to consume a purchase should look like this:


  1. 发送到购买后端

  2. 保存 purchaseToken

  3. 增加用户余额(虚拟货币)

  4. 发送回信息来源关于成功操作

一旦你收到你的后端成功的响应,你应该消耗在Android上侧的条目。如果您已经添加上你的后端虚拟货币(不消耗的项目),您也应该返回成功的响应所以该项目将在不增加用户的平衡被消耗掉。

Once you've received successful response from your backend, you should consume the item on Android side. If you've already added the virtual currency on your backend (without consuming the item) you should also return successful response so the item will be consumed without increasing user balance.

记住,它很容易重复的相同,即使它已经被消耗掉如此 purchaseToken 购买必须验证您的后端每次。如果已经在你的数据库的存在只是不增加虚拟货币。

Keep in mind that it's very easy to repeat the same purchase even if it's already been consumed so purchaseToken must be validated every time on your backend. If it already exists in your DB just do not increase the virtual currency.

这篇关于播放应用内结算v3的 - 我应该保存购买代币?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 18:35