我正在测试应用内结算,但效果都很好。现在,当我发送购买请求时,我有“购买窗口”,当我点击“立即购买”时,GET_PURCHASE_INFORMATION会向我发送一个RESULT_ERROR响应代码:/当我尝试恢复交易时,它会失败。< / p>
有没有办法知道问题是我的还是谷歌?什么是^^ (我拿了谷歌的代码,然后实现了下面的课程)
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
我尝试使用手机的其他Google帐户(将其重置为出厂设置后),但现在当我检查是否支持时,它会给我一个RESULT_BILLING_UNAVAILABLE ...
答案 0 :(得分:0)
我也有这个,它解决的方式是在我开启Android市场应用程序并接受新帐户的条款和条件之后。
答案 1 :(得分:0)
我发现在长时间测试时它会给我这个错误。我认为市场检测到过度使用,并在一段时间内关闭自己的请求。请在24小时后重试或尝试使用其他Google帐户进行测试。