【问题标题】:Android in app billing v3, how to restore purchases safely?Android in app billing v3,如何安全恢复购买?
【发布时间】:2013-06-10 08:00:07
【问题描述】:
当用户购买产品时,我使用网络服务来验证购买,为了防止重放攻击,我在购买中添加了一个(随机数)开发人员有效负载。
它按预期工作。
但是恢复交易呢?
我可以从本地库存中获取签名数据和签名以及所有其他信息(通过在 IabHelper 中调用 queryPurchases()),但我无法在任何地方设置新的开发人员有效负载,因此我无法在我的网络服务上验证它。
如何安全地恢复交易?
非常感谢您的帮助...
编辑:我应该坚持使用 iab v2 来恢复交易吗?
【问题讨论】:
标签:
android
in-app-purchase
in-app-billing
restore
【解决方案1】:
所以,据我所知,这是一个未解决的安全问题,它会损害应用内计费 api v3 的安全性。
在应用计费 api v3 中无法安全地(通过网络服务验证)恢复购买。
【解决方案2】:
在撰写本文时,Google Play 结算库示例应用会在查询购买的商品时检索开发人员有效负载以进行验证。代码如下所示:
// Listener that's called when we finish querying the items and subscriptions we own
IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, "Query inventory finished.");
.
.
.
// Do we have the premium upgrade?
Purchase premiumPurchase = inventory.getPurchase(SKU_PREMIUM);
mIsPremium = (premiumPurchase != null && verifyDeveloperPayload(premiumPurchase));
Log.d(TAG, "User is " + (mIsPremium ? "PREMIUM" : "NOT PREMIUM"));
.
.
.
}