Store kit module error in titanium - iphone

Hi I am using store kit module in titanium.The code is working fine until i add the line of purchasing the product
My code is as follows
var Storekit = require('ti.storekit');
Storekit.requestProducts([ 'com.example.qld.inapp' ], function (evt) {
if (!evt.success) {
alert('ERROR: We were not able to get the product!');
}
else if (evt.invalid) {
alert('ERROR: We requested an invalid product!');
}
else {
alert(evt.products[0]);
Storekit.purchase(evt);
}
});
and when i add the purchase line it gives the following error
[ERROR] Exception in event callback: {
line = 14;
message = "*** -[__NSArrayM objectAtIndex:]: index 1 beyond bounds [0 .. 0]";
sourceId = 173081376;
sourceURL = "file://localhost/Users/aadilf/Library/Application%20Support/iPhone%20Simulator/5.0/Applications/C7C55347-5965-4C58-9624-8A41837459D4/QLD%20Best%20Bets.app/home.js";
}
as i have not done objective c before i am unable to resolve this error

You're not specifying the object you want to purchase. You're purchasing the event itself (which contains a status, and zero, one, or multiple products).
Storekit.purchase(evt.products[0]);

Related

TypeError seneca indexof if not a function during respond

I have written a simple action which connects to mongo db using seneca-mongo store module, execute a list query and get the results. I can see that the query was successful and the correct results were fetched. When I try to send these results back to the client, the respond call errors out with following message and stack trace.
ERROR act root$ OUT cmd:getparams,role:diff 11 {cmd:getparams,role:diff,payload:{id:scalaScan}} ENTRY (dqk22) - seneca: Action cmd:getparams,role:diff callback threw: k.indexOf is not a function. act_callback {message:k.indexOf is not a function,pattern:cmd:getparams,role:diff,instance:Seneca/0.7.2/d0twcki9cmxg/1485517 TypeError: k.indexOf is not a function
at /scratch/DiffAnalyzer/node_modules/seneca/node_modules/seneca-web/web.js:851:13
at Function.forEach (/scratch/DiffAnalyzer/node_modules/lodash/dist/lodash.js:3298:15)
at Object.defaultmodify [as modify] (/scratch/DiffAnalyzer/node_modules/seneca/node_modules/seneca-web/web.js:850:7)
at respond (/scratch/DiffAnalyzer/node_modules/seneca/node_modules/seneca-web/web.js:654:22)
at Seneca.<anonymous> (/scratch/DiffAnalyzer/node_modules/seneca/node_modules/seneca-web/web.js:401:7)
at act_done (/scratch/DiffAnalyzer/node_modules/seneca/seneca.js:1554:16)
at /scratch/DiffAnalyzer/node_modules/gate-executor/gate-executor.js:127:20
at Seneca.<anonymous> (/scratch/DiffAnalyzer/analyze.js:613:5)
at act_done (/scratch/DiffAnalyzer/node_modules/seneca/seneca.js:1554:16)
at /scratch/DiffAnalyzer/node_modules/gate-executor/gate-executor.js:127:20
at /scratch/DiffAnalyzer/node_modules/seneca-mongo-store/mongo-store.js:329:21
at /scratch/DiffAnalyzer/node_modules/mongodb/lib/mongodb/cursor.js:271:33
at /scratch/DiffAnalyzer/node_modules/mongodb/lib/mongodb/cursor.js:778:35
at Cursor.close (/scratch/DiffAnalyzer/node_modules/mongodb/lib/mongodb/cursor.js:1009:5)
at Cursor.nextObject (/scratch/DiffAnalyzer/node_modules/mongodb/lib/mongodb/cursor.js:778:17)
at Cursor.each (/scratch/DiffAnalyzer/node_modules/mongodb/lib/mongodb/cursor.js:264:12)
The action that I have written is
seneca.add("role:diff,cmd:getparams", function(msg, respond) {
seneca.ready(function() {
var collection = seneca.make$("paramStore");
var f = msg.payload;
seneca.log.info("Filter", f);
collection.list$(f, function(err, ob) {
if (err) {
seneca.log.error(err);
respond(err);
} else {
seneca.log.info("Result", ob);
respond(null, ob);
}
});
});
});
The same piece of code was working and now I am getting this error. Not sure what changed. Any help/suggestions are greatly appreciated.
The issue I was facing was because of this bit of code in the module's js file
if( _.isObject( result.out ) ) {
_.each(result.out,function(v,k){
if(~k.indexOf('$') && 'http$' !== k) {
delete result.out[k]
}
})
The _.each function is meant to parse a JSON object, where in my case the out was actually a JSON array. Wrapping the array into an object resolved it.

Storekit requestProducts returns empty products array, nothing returned invalid

I am trying to get IAP working with Appcelerator Titanium 3.1. I have all the signing/certificates/provisioning profiles/contracts working. I was getting an invalid product ID, and fixed that issue. Now, the product array is simply returned empty when calling requestProducts().
When I requestProducts('valid_product')
Response: {"type":"callback","products":[{}],"source":{},"success":true}
When I requestProducts('invalid_product')
Response: {"products":[],"type":"callback","source":{},"invalid":["invalid_product"],"success":true}
Note that I do not get an invalid product returned when I request a valid product (setup in itunesconnect under IAP for this app), I simply get an empty string for the product array.
Why could this be happening? I have tried this for IAP products in the "Waiting for Review" status, as well as "Ready to Submit" status. I have not yet submitted the binary for review.
Any help would be immensely appreciated.
Regards,
Daniel
EDIT, code posted below
function requestProduct(identifier, success) {
showLoading();
Storekit.requestProducts([identifier], function (evt) {
hideLoading();
Ti.API.info('ReqProduct:' + JSON.stringify(evt));
if (!evt.success) {
alert('ERROR: We failed to talk to Apple!');
}
else if (evt.invalid) {
alert('ERROR: We requested an invalid product!');
}
else {
alert('success. product: ' + JSON.stringify(evt.products[0]));
success(evt.products[0]);
}
});
}
calling the above function as follows:
var product;
requestProduct('22credits', function(data) {
Ti.API.info(JSON.stringify(data));
product = data;
});

Getting Error Retrieving the COM class factory for component with CLSID{}

when i want to add the new customer on quick book through c#.i am getting this error:
Retrieving the COM class factory for component with CLSID {178AACCA-9DCE-42A0-A193-CF4985B930E5} failed due to the following error: 80040154.
here is a code where i found error..
Please write valid answer... thanks..
try
{
//Create the session Manager object
sessionManager = new QBSessionManager();
//Create the message set request object to hold our request
IMsgSetRequest requestMsgSet = sessionManager.CreateMsgSetRequest("US", 8, 0);
requestMsgSet.Attributes.OnError = ENRqOnError.roeContinue;
//Connect to QuickBooks and begin a session
sessionManager.OpenConnection("App1", "QuickBooks");
connectionOpen = true;
sessionManager.BeginSession(#"C:\Users\Public\Documents\Intuit\QuickBooks\Company Files\PSNew.QBW", ENOpenMode.omDontCare);
sessionBegun = true;
ICustomerAdd customerAddRq = requestMsgSet.AppendCustomerAddRq();
customerAddRq.Name.SetValue(CP.CustomerName);
customerAddRq.LastName.SetValue(CP.CustomerLastName);
customerAddRq.Email.SetValue(CP.CustomerEmail);
//Send the request and get the response from QuickBooks
IMsgSetResponse responseMsgSet = sessionManager.DoRequests(requestMsgSet);
IResponse response = responseMsgSet.ResponseList.GetAt(0);
ICustomerRet customerRet = (ICustomerRet)response.Detail;
CP.GetCustomerId = customerRet.ListID.GetValue();
CP.GetCustomerName = customerRet.Name.GetValue();
CP.GetCustomerEmail = customerRet.Email.GetValue();
//CP.customerAddRq1 = customerAddRq.Name.GetValue();
}
catch (Exception)
{
throw;
}
finally
{
//End the session and close the connection to QuickBooks
if (sessionBegun)
{
sessionManager.EndSession();
}
if (connectionOpen)
{
sessionManager.CloseConnection();
}
make sure that your app is compiled with the project build configurations set to x86 for the target platform. This is the most common solution on the net given that Intuit integration dlls are 32-bit. However in my case when I faced this problem, I decided to install the QuickBooks SDK to the client machine and that's when I succeeded in solving it.

Iphone Phonegap in-app purchase not working

I have a phonegap project using which i have submitted my application at iPhone app store.
I m using cordova-2.2.0.js. Now I want to implement in-app purchase plugin to provide in-app purchase in my application.
I am trying to do it by adding in-app plugin from the link below:
https://github.com/phonegap/phonegap-plugins/tree/master/iPhone/InAppPurchaseManager
I then added InAppPurchase plugin to cordova.plist file.
When I write below mentioned code
(a) in my javascript, the control goes to InAppPurchaseManager.js plugin and code
(b) is executed.
(a)
window.plugins.inAppPurchaseManager.requestProductData(
"org.xxx.abcd.pqr",
function(productId, title, description, price) {
alert("data retrieved");
//window.plugins.inAppPurchaseManager.makePurchase(productId, 1);
},
function(id) {
alert("Invalid product id: " + id);
}
);
(b)
InAppPurchaseManager.prototype.requestProductData = function(productId, successCallback, failCallback) {
var key = 'f' + this.callbackIdx++;
window.plugins.inAppPurchaseManager.callbackMap[key] = {
success: function(productId, title, description, price ) {
if (productId == '__DONE') {
delete window.plugins.inAppPurchaseManager.callbackMap[key]
return;
}
successCallback(productId, title, description, price);
},
fail: failCallback
}
alert("product id: " + productId + "key: " + key);
var callback = 'window.plugins.inAppPurchaseManager.callbackMap.' + key;
cordova.exec('InAppPurchaseManager.requestProductData', productId, callback + ' .success', callback + '.fail');
}
In code (b), everything works fine, till the line below:
cordova.exec('InAppPurchaseManager.requestProductData', productId, callback + '.success', callback + '.fail');
The question is: Why the app get stop at the above mentioned line. Also the alert box is displayed in code (b) which belongs to InAppPurchaseManager.js.
I have added an in-app item at itunesconnect and it is in "ready to submit" mode.
Problem solved.
In phonegap 1.8.1, we have to remove the prefix cdvjk_ from cdvjk_JSONRepresentation and all other variables from InAppPurchaseManager.m file.
I was able to perform in-app successfully..
Got it working somehow..
There was some problem in sandboxing the application. I also moved to Xcode 4.3 from 4.2.
Now I am able to fetch product details and get the log as below:
- Getting product data..
- Got iap product response..
- Sending js for "abc.pqr.xyz.productid" (product id)
followed by the exception:
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSArrayI cdvjk_JSONRepresentation]: unrecognized selector sent to instance 0x9156f40'
Googled it but didn't find much.. I am using cordova-1.8.1.
Any solutions??

ErrorCode, Ti.storekit-1.6.0

I develop now using Ti.storekit-1.6.0.
(TitaniumStudio SDK-2.1.3GA)
Description below shows the current my code
$btnItem1.addEventListener('click', function(e){
// 250
var product = 'net.oratta.info.0250';
var Storekit = require('ti.storekit');
Storekit.purchase(product, function (evt) {
switch (evt.state) {
case Storekit.FAILED:
alert('ERROR: Buying failed!');
break;
case Storekit.PURCHASED:
case Storekit.RESTORED:
alert('Thanks!');
//markProductAsPurchased(product.identifier);
break;
}
});
});
The information of iTuensConnect has become like below
Apple ID : 567415203
Bundle ID : net.oratta.info
[In-App Purchase Summary]
Reference Name: 250 Coin
Product ID: net.oratta.info.0250
Type: Consumable
Apple ID: 568619867
But, following kind of error coming out, it does not operate normally
"-[__NSCFString product]: unrecognized selector sent to instance 0x1d4f7c20"
When how it does, this error can be evaded?
I request your advice.
Thanks,