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,
Related
I'm trying to implement unity iap and I need to send PaymentSucceed event to my analytics in order to track purchases!
I'm Calling PaymentSucceed event in my
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
function, but the issue is that when user re-installs application the ProcessPurchase event is called again on android to restore purchases, and sents event for my analytics, but that's not a revenue event, so that's not correct to count it as Payment, can you share please some thoughts how I can understand is it restore or actual payment in the correct way?
here is my ProcessPurchase script
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
{
// A consumable product has been purchased by this user.
if (String.Equals(args.purchasedProduct.definition.id, kProductIDNoAds, StringComparison.Ordinal))
{
Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
PlayerPrefs.SetInt("noads",1);
BannerAdManager.Instance.HideBanner();
CheckNoAds();
var prodID = args.purchasedProduct.definition.id;
var price = ReplaceCommas(args.purchasedProduct.metadata.localizedPrice.ToString());
var currency = args.purchasedProduct.metadata.isoCurrencyCode;
var receipt = args.purchasedProduct.receipt;
var param = new Dictionary<string, string>();
param["af_quantity"] = "1";
param["af_content_type"] = "general";
var recptToJSON = (Dictionary<string, object>)AFMiniJSON.Json.Deserialize(receipt);
var receiptPayload = (Dictionary<string, object>)AFMiniJSON.Json.Deserialize((string)recptToJSON["Payload"]);
var purchaseData = (string)receiptPayload["json"];
var signature = (string)receiptPayload["signature"];
Debug.LogError("Purchase Event Sent Start");
AppsFlyerAndroid appsFlyerAndroid = new AppsFlyerAndroid();
appsFlyerAndroid.validateAndSendInAppPurchase(
"111",
signature,
purchaseData,
price,
currency,
param,
this);
Debug.LogError("Purchase Event Sent Finish");
PaymentSucceed(args.purchasedProduct.definition.id,args.purchasedProduct.metadata.isoCurrencyCode,(float)args.purchasedProduct.metadata.localizedPrice,"noads");
}
// Or ... an unknown product has been purchased by this user. Fill in additional products here....
else
{
Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id));
}
// Return a flag indicating whether this product has completely been received, or if the application needs
// to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still
// saving purchased products to the cloud, and when that save is delayed.
return PurchaseProcessingResult.Complete;
}
I am trying to capture a charge with a different amount, but I get an error saying that there's "no such charge" and sometimes that the amount should be lower than the charge, which it is. However, the most frequent error is the "no such charge" one, although the charge is not nil.
This is the Cloud Code function in node.js:
Parse.Cloud.define("cancellationFee", function(request, response){
stripe.charges.capture({
charge: request.params.charge,
amount: 500,
destination: 500
}, function(err, charge) {
if(err){
console.log(err);
response.error(err);
}else{
console.log("Successfully captured cancellation fee");
response.success("captured cancellation fee");
}
});
});
Swift Code
The charge variable is not nil.
PFCloud.callFunctionInBackground("cancellationFee", withParameters: ["charge": chargeID]) { (success: AnyObject?, error: NSError?) -> Void in
if error == nil{
// code
}else{
// code
}
}
For some folks that are still experiencing this problem the correct solution is first passing the charge_id as String and then as a second parameter the amount inside an object like this:
stripe.charges.capture( 'chargeIdExample3242', {amount: 23} );
Source
Are you sure your error isn't due to setting destination to a number? Destination should be an account id. And also should be set when creating a charge, not capturing the charge. You shouldn't be passing any additional parameters to the charge method than the charge you're capturing.
You also shouldn't be setting the charge amount here.
I've got an Azure Mobile Service with a custom API. I have tested this API in the past from iOS and it seems to work fine. I am now testing this API on Android. This is the API method in question:
exports.post = function(request, response) {
var body = request.body;
var email = body.email;
var tables = request.service.tables;
var users = tables.getTable('User');
users.where({ email: email }).read({
success: function (userList) {
if (userList.length === 0) {
response.send(200, { Status: 'Error', Error: 'Email not found.' });
} else {
var user = userList[0];
var providerId = user.ObjectId;
var accounts = tables.getTable('Account');
accounts.where({ User: providerId }).read({
success: function (accountList) {
if (accountList.length === 0) {
response.send(200, { Status: 'Error', Error: 'Internal server error.' });
} else {
var account = accountList[0];
var mssql = request.service.mssql;
var sql = "EXEC [db].[usp_RequestPasswordReset] ?;";
mssql.query(sql, [account.id], {
success: function (results) {
console.log(results);
var codeRow = results[0];
if (codeRow == undefined) {
console.log("codeRow is undefined");
} else {
console.log(codeRow);
}
var code = codeRow.Code;
response.send(200, { Status: 'Success', Message: 'Please check your email for further instructions.', Code: code });
sendEmail(email, user.Name, code);
}
});
}
}
});
}
}
});
};
Now, sendEmail is a separate function that sends an email using Azure's SendGrid feature.
What is really perplexing me is that all of the code appears to be working fine.
The stored procedure executes just fine.
The database is updated exactly as I would expect.
The email comes through the SendGrid service exactly as expected.
The console.log messages that I have in the code display the expected values.
The only thing that is funky is that the call is returning a "500: Internal Server Error" error.
This is true both in my Android client and also in the API log on the Azure Management Portal.
The error message I am getting is telling me that var code = codeRow.Code; is trying to access 'Code' of 'undefined'. But it's not undefined.
Going back and checking my iOS client against this produces the same results.
Everything works fine except for the message returned to the user.
To be clear, the error code is 500, not 200, since it's possible for my code to return an "Internal Server Error" message.
Also, I am very sure that my mssql.query success block is firing, based on the console log messages and the outcome.
So, what gives?
mssql.query can call your callback more than once depending on what's in your stored procedure. You can define a variable outside your callback, e.g.
var callbackReceived = false;
and then in your callback, only send a response for the call that actually receives the updated record:
if (callbackReceived === false && results && results.length > 0) {
callbackReceived = true;
// continue as before
}
See also this question answered by one of the Azure developers:
Azure mobile service custom API calling SQL SP multiple times
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;
});
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??