无法查询购买的商品库存(错误-1003) - Appcelerator Titanium inAppBilling

时间:2016-11-08 17:10:40

标签: android titanium appcelerator

我正在使用Appcelerator Titanium制作Android应用程序。我添加了ti.inappbilling模块(v.3.0.2),一切正常(我可以购买,应用程序在Google Play中),直到我想查询库存(总是返回错误)。

我想查询已购买的商品,我这样做了:

var runSetup = function() {
     myApp.inAppBilling.startSetup({
        publicKey: myApp.PUBLIC_KEY //this is defined in code
    });
}

var setupComplete = function(e) {
    if (e.success) {
        setTimeout(function() {
            //i did timeout to be sure sure delay is not an issue
            myApp.inAppBilling.queryInventory();
        }, 5000);
    } else {
        alert('Payment Setup FAILED.');
    }
};


myApp.inAppBilling = require('ti.inappbilling');

myApp.inAppBilling.addEventListener('queryinventorycomplete', function(e) {
    Ti.API.info(JSON.stringify(e));
});

myApp.inAppBilling.addEventListener('setupcomplete', setupComplete);

runSetup();

作为resposne我总是得到错误-1003(IAB结果验证失败)。

整个回复如下:

{
    "type": "queryinventorycomplete",
    "source": {
        "bubleParent": true,
        "invocationAPIs": [],
        "apiName": "Ti.Module",
        "__propertiesDefined__": true,
        "_events": {
            "purchasecomplete": {},
            "queryinventorycomplete": {},
            "setupcomplete": {},
        }
    },
    "responseCode": -1003,
    "success": false,
    "bubbles": false,
    "cancelBubble" :false
}

1 个答案:

答案 0 :(得分:0)

我遇到了同样的问题

检查myApp.PUBLIC_KEY是否包含正确的密钥

runSetup = function() {
    Ti.API.info('myApp.PUBLIC_KEY  ' + myApp.PUBLIC_KEY);
    myApp.inAppBilling.startSetup({
        publicKey : myApp.PUBLIC_KEY //this is defined in code
    });
};