处理跨 sessions/devices 的应用内购买/消耗品?
Handling in-app purchases / consumable products across sessions/devices?
我的问题主要围绕使用 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.
我的问题是如何跟踪消耗品的用户库存?文档和各种视频似乎很快就掩盖了这一点,基本上是说应用程序必须在获得成功购买确认后应用消耗品的效果。但这并不是真正的全貌。如果用户注销并使用其他帐户重新登录怎么办?或者他们切换到新的 phone,他们应该在那个 phone.
上有产品
您无法真正将购买记录保存在 SharedPreferences 或持久缓存中,因为它与 phone 相关联。如果用户登录其他 phone,那么他们应该享受所有购买的好处。
举个例子:
一场比赛以1000金币开始玩家。玩家通过应用内购买再购买 500 金币,然后花费 200 金币。如果玩家购买新的 phone 并在 phone 上安装该应用程序,他们应该有 1300 金币。
这通常是如何完成的?
您是否需要 运行 一个私人服务器来跟踪 purchases/consumption 与 Google 分开的此类事情?
谢谢!!
我正在实施 in-app 自己购买。
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
绑定到帐户或设备。
在第一种情况下,您可以在用户切换设备时轻松管理购买(获得私人服务器的另一个原因)。
而在第二种情况下,您可以允许在同一台设备上切换帐户。
所以由你决定要 select.
您需要将本地消费同步到服务器。
这是验证购买的流程:
- User clicks “BUY” button.
- Makes payment with google.
- App receives “receipt” from google and store it locally
- Send this “RECEIPT” to the Server.
- The Server sends the “purchaseToken” to Google Play Developer API for validation
- The 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)
我使用了以下文章:
我的问题主要围绕使用 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.
我的问题是如何跟踪消耗品的用户库存?文档和各种视频似乎很快就掩盖了这一点,基本上是说应用程序必须在获得成功购买确认后应用消耗品的效果。但这并不是真正的全貌。如果用户注销并使用其他帐户重新登录怎么办?或者他们切换到新的 phone,他们应该在那个 phone.
上有产品您无法真正将购买记录保存在 SharedPreferences 或持久缓存中,因为它与 phone 相关联。如果用户登录其他 phone,那么他们应该享受所有购买的好处。
举个例子:
一场比赛以1000金币开始玩家。玩家通过应用内购买再购买 500 金币,然后花费 200 金币。如果玩家购买新的 phone 并在 phone 上安装该应用程序,他们应该有 1300 金币。
这通常是如何完成的?
您是否需要 运行 一个私人服务器来跟踪 purchases/consumption 与 Google 分开的此类事情?
谢谢!!
我正在实施 in-app 自己购买。
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
绑定到帐户或设备。
在第一种情况下,您可以在用户切换设备时轻松管理购买(获得私人服务器的另一个原因)。
而在第二种情况下,您可以允许在同一台设备上切换帐户。
所以由你决定要 select.
您需要将本地消费同步到服务器。
这是验证购买的流程:
- User clicks “BUY” button.
- Makes payment with google.
- App receives “receipt” from google and store it locally
- Send this “RECEIPT” to the Server.
- The Server sends the “purchaseToken” to Google Play Developer API for validation
- The 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)
我使用了以下文章: