0
私はParse + Stripeを使っています。私のパーズクラウドコードバージョンは1.5.0ですが、ここで私のソースコードはアプリ側です。Parse + Stripe iOS Swift 2 main.js
func performStripeOperation() {
STPAPIClient.sharedClient().createTokenWithCard(stripCard, completion: { (token: STPToken?, error: NSError?) -> Void in
if error == nil {
// credit card details are correct
print(token!.tokenId)
var myVal: String = token!.tokenId
NSLog("%@", token!)
PFCloud.callFunctionInBackground("pay", withParameters: ["token": myVal], block: {(result: AnyObject?, error: NSError?) -> Void in
if (error == nil) {
NSLog("from Cloud Code Res: %@", result as! String)
}
else {
NSLog("from Cloud Code: %@", error!)
}
})
} else {
print("Token error.")
// Handle Error here
NSLog("ERRRRR = %@", error!)
let alert = UIAlertController(title: "Please try again", message: "\(error!.localizedDescription)", preferredStyle: .Alert)
let actionOk = UIAlertAction(title: "Ok", style: .Default, handler: nil)
alert.addAction(actionOk)
self.presentViewController(alert, animated: true, completion: nil)
//let alert: UIAlertView = UIAlertView(title: "Please try again", message: "\(error!.localizedDescription)", delegate: nil, cancelButtonTitle: "OK", otherButtonTitles: "")
//alert.show()
}
})
}
と私は今here
var Stripe = require('stripe');
Stripe.initialize('sk_test_******************');
Parse.Cloud.define("pay", function(request, response) {
var stripeToken = request.params.token;
var charge = Stripe.Charges.create({
amount: 1000, // in cents
currency: 'usd',
card: stripeToken
}).then(null, function(error) {
console.log('Charging with stripe failed. Error: ' + error);
}).then(function() {
// And we're done!
response.success('Success');
});
});
からソースコードを追っmain.jsため、私はこのエラー
[Error]: TypeError: Object [object Object] has no method 'isString'
at request (stripe.js:49:25)
at post (stripe.js:117:12)
at Object.module.exports.Charges.create (stripe.js:157:16)
at main.js:27:29 (Code: 141, Version: 1.12.0)
2016-04-05 22:56:35.886 Muzicue[39049:832833] from Cloud Code: Error Domain=Parse Code=141 "TypeError: Object [object Object] has no method 'isString'
at request (stripe.js:49:25)
at post (stripe.js:117:12)
at Object.module.exports.Charges.create (stripe.js:157:16)
at main.js:27:29" UserInfo={code=141, temporary=0, error=TypeError: Object [object Object] has no method 'isString'
at request (stripe.js:49:25)
at post (stripe.js:117:12)
at Object.module.exports.Charges.create (stripe.js:157:16)
at main.js:27:29, NSLocalizedDescription=TypeError: Object [object Object] has no method 'isString'
at request (stripe.js:49:25)
at post (stripe.js:117:12)
at Object.module.exports.Charges.create (stripe.js:157:16)
at main.js:27:29}
私が間違ってやっている任意のアイデアを得ましたか。ありがとう...