我正在测试应用内计费,一切都很好。现在,当我发送购买请求时,我有“购买窗口”,当我单击“立即购买”时,GET_PURCHASE_INFORMATION 会向我发送一个 RESULT_ERROR 响应代码:/ 当我尝试恢复交易时,同样的事情,它失败了。
有没有办法知道问题是我的还是谷歌的?它是什么^^(我拿了谷歌的代码,只是实现了下面的类)
private class ThemePurchaseObserver extends PurchaseObserver {
public ThemePurchaseObserver(Handler handler) {
super(PageAccueilActivity.this, handler);
}
@Override
public void onBillingSupported(boolean supported) {
Log.d("ThemePurchaseObserver", "onBillingSupported: "+supported);
if (supported){
SharedPreferences prefs = getSharedPreferences(Utils.getPrefFile(), MODE_PRIVATE);
boolean restorationDone = prefs.getBoolean(KEY_PREF_RESTORATION_DONE, false);
if (!restorationDone){
mBillingService.restoreTransactions();
}
}
}
@Override
public void onPurchaseStateChange(PurchaseState purchaseState,String itemId, int quantity, long purchaseTime,String developerPayload) {
Log.d("ThemePurchaseObserver", "onPurchaseStateChange()");
if (purchaseState == PurchaseState.PURCHASED){
Log.d("ThemePurchaseObserver", itemId+ "PURCHASED");
} else if (purchaseState == PurchaseState.REFUNDED){
Log.d("ThemePurchaseObserver", itemId+ "REFUNDED");
} else if (purchaseState == PurchaseState.CANCELED){
Log.d("ThemePurchaseObserver", itemId+ "CANCELED");
} else {
Log.d("ThemePurchaseObserver", itemId+ " unknow state");
}
}
@Override
public void onRequestPurchaseResponse(RequestPurchase request, ResponseCode responseCode) {
Log.d("ThemePurchaseObserver", "onRequestPurchaseResponse: "+responseCode);
}
@Override
public void onRestoreTransactionsResponse(RestoreTransactions request, ResponseCode responseCode) {
Log.d("ThemePurchaseObserver", "onRestoreTransactionsResponse: "+responseCode);
if (responseCode == ResponseCode.RESULT_OK){
SharedPreferences prefs = getSharedPreferences(Utils.getPrefFile(), MODE_PRIVATE);
Editor editeur = prefs.edit();
editeur.putBoolean(KEY_PREF_RESTORATION_DONE, true);
editeur.commit();
} else {
}
}
}
还有用于恢复的 logcat:
DEBUG/BillingService(3363): Billing service connected
DEBUG/BillingService(3363): CheckBillingSupported
INFO/BillingService(3363): CheckBillingSupported response code: RESULT_OK
DEBUG/ThemePurchaseObserver(3363): onBillingSupported: true
DEBUG/BillingService(3363): RestoreTransactions
ERROR/BillingService(3363): restoreTransactions received RESULT_OK
DEBUG/BillingService(3363): request id: 8836359618243990524
DEBUG/BillingService(3363): request id: -1
INFO/BillingService(3363): handleCommand() action:com.android.vending.billing.RESPONSE_CODE
DEBUG/BillingService(3363): RestoreTransactions: RESULT_ERROR
DEBUG/ThemePurchaseObserver(3363): onRestoreTransactionsResponse: RESULT_ERROR
用于静态购买的 logcat(“android.test.purchase”):
DEBUG/BillingService(3363): RequestPurchase
DEBUG/BillingService(3363): request id: 8990314669027459189
INFO/BillingReceiver(3363): notifyId: android.test.purchased
INFO/BillingService(3363): handleCommand() action: com.example.dungeons.GET_PURCHASE_INFORMATION
DEBUG/BillingService(3363): GetPurchaseInformation
DEBUG/BillingService(3363): request id: 7301564145243038858
DEBUG/BillingService(3363): RequestPurchase: RESULT_OK
DEBUG/ThemePurchaseObserver(3363): onRequestPurchaseResponse: RESULT_OK
INFO/BillingService(3363): handleCommand() action: com.android.vending.billing.RESPONSE_CODE
DEBUG/BillingService(3363): GetPurchaseInformation: RESULT_ERROR
我尝试使用我手机的另一个谷歌帐户(将其重置为出厂设置后),但现在当我检查它是否受支持时,它会给我一个 RESULT_BILLING_UNAVAILABLE ......