I am making Android application with Appcelerator Titanium. I've added ti.inappbilling module (v. 3.0.2) and everything was working fine (I can make purchases, application is in Google Play) until I want to query inventory (what always returns an error).
I wanted to query already bought items and I did it this way:
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();
As a resposne I always get error -1003 (IAB RESULT VERIFICATION FAILED).
Whole response looks like this:
{
"type": "queryinventorycomplete",
"source": {
"bubleParent": true,
"invocationAPIs": [],
"apiName": "Ti.Module",
"__propertiesDefined__": true,
"_events": {
"purchasecomplete": {},
"queryinventorycomplete": {},
"setupcomplete": {},
}
},
"responseCode": -1003,
"success": false,
"bubbles": false,
"cancelBubble" :false
}
I had the same problem
check if myApp.PUBLIC_KEY contain your correct key
runSetup = function() {
Ti.API.info('myApp.PUBLIC_KEY ' + myApp.PUBLIC_KEY);
myApp.inAppBilling.startSetup({
publicKey : myApp.PUBLIC_KEY //this is defined in code
});
};