IabResult:错误刷新库存(查询拥有项目) [英] IabResult: Error refreshing inventory (querying owned items)
问题描述
我设立从谷歌酒店应用内结算在我的基础LibGDX Play下载Android应用。
场景:我已经买了试验品 android.test.purchased 成功,我还没有消耗它。我还没有消耗它,因为它只能一次买了,我已经停用该测试产品的购买按钮。直到这一切都很好。
问题:现在,当我重新打开了再次第二次。我得到一个警告说无法查询库存:IabResult:错误刷新库存(查询拥有项目)(回应:-1003:购买签名验证失败。
问:
我希望我的产品可以只买一次,所以我也没有消耗它。这会不会是一个问题,在查询中的onCreate)库存(
mHelper.queryInventoryAsync(mGotInventoryListener);
code
私人无效iabSetup(){//加载游戏数据
loadData();字符串base64En codedPublicKey =键;Log.d(TAG创建IAB帮手。);
mHelper =新IabHelper(这一点,base64En codedPublicKey);mHelper.enableDebugLogging(真);Log.d(TAG启动安装程序。);
mHelper.startSetup(新IabHelper.OnIabSetupFinishedListener(){
公共无效onIabSetupFinished(IabResult结果){
Log.d(TAG,设置完成。);
如果(!result.isSuccess()){
抱怨(问题设置应用内结算:+结果);
返回;
}
如果(mHelper == NULL)回报;
Log.d(TAG,设置成功查询库存。);
mHelper.queryInventoryAsync(mGotInventoryListener); }
});
}IabHelper.QueryInventoryFinishedListener mGotInventoryListener =新IabHelper.QueryInventoryFinishedListener(){
公共无效onQueryInventoryFinished(IabResult结果,库存盘点){ Log.d(TAG,查询库存结束了。);
//我们有在此期间被处置的?如果是这样,退出。
如果(mHelper == NULL)回报; //它是一个失败吗?
如果(result.isFailure()){
抱怨(无法查询盘点:+结果);
返回;
}
Log.d(TAG,查询库存是成功的。); //我们是否有额外1点生命?
购买life1Purchase = inventory.getPurchase(SKU_1_Life);
life1Purchased =(life1Purchase!= NULL);
Log.d(TAG,用户life1Purchased:+ life1Purchased);};
公共无效onAdd1lifeButtonClicked(){
如果(!mHelper.subscriptionsSupported()){
抱怨(订阅不支持您的设备上没有对不起!);
返回;
}
Log.d(TAG启动无限气体订阅购买流程。); 如果(忙){
Log.d(TAG,不能买项目这么忙呢。);
返回;
}
尝试{
新主题(新的Runnable接口(){
@覆盖
公共无效的run(){
繁忙= TRUE;
mHelper.launchPurchaseFlow(AndroidLauncher.this,SKU_1_Life,RC_REQUEST,mPurchaseFinishedListener,payloadString);
}
})。开始();
}赶上(例外五){
Log.d(TAG,buyItem例外:+ E);
}
}//回调确认购买后,完成了
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener =新IabHelper.OnIabPurchaseFinishedListener(){
公共无效onIabPurchaseFinished(IabResult结果,购购){
Log.d(TAG,购买完成:+结果+,购买+购买); //如果我们在这期间处置,退出。
如果(mHelper == NULL)回报; 如果(result.isFailure()){
抱怨(错误的采购:+结果);
返回;
}
如果(!verifyDeveloperPayload(购买)){
抱怨(错误采购真实性验证失败。);
返回;
} Log.d(TAG,购买成功); 如果(purchase.getSku()。等于(SKU_1_Life)){
Log.d(TAG,购买是SKU_1_Life。);
繁忙= FALSE;
}
}
};
您只想添加此其为我工作。
mHelper.consumeAsync(购买,mConsumeFinishedListener);
在OnIabPurchaseFinishedListener;
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener =新OnIabPurchaseFinishedListener(){
@覆盖
公共无效onIabPurchaseFinished(IabResult结果,购购){ Log.d(TAG,购买完成:+结果+,购买
+购买);
如果(购买== NULL || result.isFailure()){ 返回;
}
如果(mHelper == NULL){
Log.i(TAGMhelper为空);
返回;
} 如果(result.isFailure()){
Log.i(TAG,
ERROR采购项目结果是: -
+ result.toString());
返回;
}
如果(purchase.getSku()。等于(android.test.purchased)){ purchasefinish = purchase.getOriginalJson();
Log.i(TAG,SUCCESS+ purchasefinish);
如果(mHelper!= NULL){
mHelper.consumeAsync(购买,mConsumeFinishedListener);
} } } };
I am setting up the Inn-App billing from Google play in my LibGDX based Android app.
Scenario : I have bought the test product "android.test.purchased" successfully and I have not Consumed it. I have not consumed it because it can be bought only once and I have disabled the buy button for that test product. Till this everything is fine.
Issue : Now when I re open the again for 2nd time. I got an alert saying that "Failed to query inventory: IabResult: Error refreshing inventory (querying owned items). (response: -1003:Purchase signature verification failed".
Question : I expect my product can be bought only once and hence I have not consumed it. Will that be a problem while querying for the inventory in onCreate().
mHelper.queryInventoryAsync(mGotInventoryListener);
Code
private void iabSetup() {
// load game data
loadData();
String base64EncodedPublicKey = "Key";
Log.d(TAG, "Creating IAB helper.");
mHelper = new IabHelper(this, base64EncodedPublicKey);
mHelper.enableDebugLogging(true);
Log.d(TAG, "Starting setup.");
mHelper.startSetup(new IabHelper.OnIabSetupFinishedListener() {
public void onIabSetupFinished(IabResult result) {
Log.d(TAG, "Setup finished.");
if (!result.isSuccess()) {
complain("Problem setting up in-app billing: " + result);
return;
}
if (mHelper == null) return;
Log.d(TAG, "Setup successful. Querying inventory.");
mHelper.queryInventoryAsync(mGotInventoryListener);
}
});
}
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()) {
complain("Failed to query inventory: " + result);
return;
}
Log.d(TAG, "Query inventory was successful.");
// Do we have the additional 1 life?
Purchase life1Purchase = inventory.getPurchase(SKU_1_Life);
life1Purchased = (life1Purchase != null);
Log.d(TAG, "User life1Purchased : " + life1Purchased);
};
public void onAdd1lifeButtonClicked() {
if (!mHelper.subscriptionsSupported()) {
complain("Subscriptions not supported on your device yet. Sorry!");
return;
}
Log.d(TAG, "Launching purchase flow for infinite gas subscription.");
if (busy) {
Log.d(TAG, "Can't buy item. So busy yet");
return;
}
try {
new Thread(new Runnable() {
@Override
public void run() {
busy = true;
mHelper.launchPurchaseFlow(AndroidLauncher.this, SKU_1_Life, RC_REQUEST, mPurchaseFinishedListener, payloadString);
}
}).start();
} catch (Exception e) {
Log.d(TAG, "buyItem Exception: " + e);
}
}
// Callback for when a purchase is finished
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new IabHelper.OnIabPurchaseFinishedListener() {
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
Log.d(TAG, "Purchase finished: " + result + ", purchase: " + purchase);
// if we were disposed of in the meantime, quit.
if (mHelper == null) return;
if (result.isFailure()) {
complain("Error purchasing: " + result);
return;
}
if (!verifyDeveloperPayload(purchase)) {
complain("Error purchasing. Authenticity verification failed.");
return;
}
Log.d(TAG, "Purchase successful.");
if (purchase.getSku().equals(SKU_1_Life)) {
Log.d(TAG, "Purchase is SKU_1_Life.");
busy = false;
}
}
};
you want to add just this its works for me .
mHelper.consumeAsync(purchase, mConsumeFinishedListener);
in OnIabPurchaseFinishedListener;
IabHelper.OnIabPurchaseFinishedListener mPurchaseFinishedListener = new OnIabPurchaseFinishedListener() {
@Override
public void onIabPurchaseFinished(IabResult result, Purchase purchase) {
Log.d(TAG, "Purchase finished: " + result + ", purchase: "
+ purchase);
if (purchase == null || result.isFailure()) {
return;
}
if (mHelper == null) {
Log.i(TAG, "Mhelper is null");
return;
}
if (result.isFailure()) {
Log.i(TAG,
"ERROR in Purchasing Item Result is :- "
+ result.toString());
return;
}
if (purchase.getSku().equals("android.test.purchased")) {
purchasefinish = purchase.getOriginalJson();
Log.i(TAG, "SUCCESS" + purchasefinish);
if (mHelper != null) {
mHelper.consumeAsync(purchase, mConsumeFinishedListener);
}
}
}
};
这篇关于IabResult:错误刷新库存(查询拥有项目)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!