2017-04-25 72 views
1

我已将所有产品添加为被管理产品。当我查询getPurchases时,它只返回1项,但当我查询getHistory时比返回3项我感到困惑为什么它发生?Android:应用帐单仅返回1次购买

GET采购编号:

Bundle ownedItems = mService.getPurchases(6, getPackageName(), "inapp", null); 

获得的交易记录代码:

Bundle purchaseHistoryBundle = mService.getPurchaseHistory(6, getPackageName(), "inapp", null, new Bundle()); 

我已经购买了很多产品我怎么能解决这个问题?

回答

1

getPurchases需要一个表示InApp Billing API的整数。所以你的电话

Bundle ownedItems = mService.getPurchases(6, getPackageName(), "inapp", null); 

必须处理的api版本。如果您在开发应用程式内结算第3版,它必须是:

Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null); 

像API描述:

通过了应用内结算API版本(“3”),您的调用应用的应用包名称,以及该方法中的购买类型(“inapp”或“subs”)。这里是一个例子:

Bundle ownedItems = mService.getPurchases(3, getPackageName(), "inapp", null);

我想知道它为什么会起作用,无论如何,我不认为这是造成问题。

接下来就是,getPurchases()只返回没有消耗的物品。如果你的物品被消耗,它将不会返回这些物品。这就是历史回归的原因。像在API描述:

getPurchases() 

此方法返回由用户,包括兑换优惠代码获取既购买的物品和物品所拥有的当前未消耗的产品。

getPurchaseHistory() 

此方法返回用户对每个SKU所作的最近购买,即使购买已过期,取消,或消耗。

我对inApp账单的经验是,这是一个巨大的痛苦,因为无法通过测试账户来测试每个货币。这似乎是一个未完成的部分的Android。但我们没有其他选择可以遵循api,所以我建议完全按照所描述的那样来完成。

API和源代码:

https://developer.android.com/google/play/billing/billing_integrate.html

https://developer.android.com/google/play/billing/billing_reference.html

https://github.com/googlesamples/android-play-billing/blob/master/TrivialDrive/app/src/main/aidl/com/android/vending/billing/IInAppBillingService.aidl