我现在遇到一个重大问题,我们的服务器正在取消订阅我们的应用程序(不是Google Play)的用户,并删除我们在成功购买后从Google Play收到的购买代币。我们已经注意到它们不再被删除,但我需要处理我们已经丢失的那些。
所以我的问题是,有没有办法恢复购买令牌? (主要在V2 API中)
答案 0 :(得分:4)
您可以从'getPurchases'
获取解析响应的令牌和订单IDhttps://developer.android.com/google/play/billing/billing_reference.html#getPurchases
但如果你使用TrialDrive Sample的IabHelper,那就更容易了。 https://github.com/googlesamples/android-play-billing/tree/master/TrivialDrive
在那里,您可以从购买对象中检索令牌,该对象是您从queryInventory:
开始获得的IabHelper.QueryInventoryFinishedListener mGotInventoryListener = new IabHelper.QueryInventoryFinishedListener() {
public void onQueryInventoryFinished(IabResult result, Inventory inventory) {
Log.d(TAG, "Query inventory finished.");
// Have we been disposed of in the meantime? If so, quit.
if (mHelper == null) return;
// Is it a failure?
if (result.isFailure()) {
Log.d(TAG, "Failed to query inventory: " + result);
return;
}
Purchase premiumMonthly = inventory.getPurchase(SKU_SUSCRIPTION);
if (premiumMonthly != null && premiumMonthly.isAutoRenewing()) {
String token = premiumMonthly.getToken();
String orderid = premiumMonthly.getOrderId();
Log.d(TAG, token);
Log.d(TAG, orderid);
}
}
....
mHelper.queryInventoryAsync(mGotInventoryListener);