Parse + Stripe iOS main.js

I am really trying to get Parse + Stripe to work in my project. At the moment, I want a simple working version that allows me to charge the user.

The closest thing I found for an answer is this: The simplest example I found

When I use the corrected code from the link above, with my secret, I get the following error:

Input: {"token":"tok_16kNOcIPNR1PIJsTyhvwTFJ9"} Result: 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:19:31 

Please help = ** (this is so frustrating.

------------- UPDATE ----------------

Several other posts have had similar errors, and it seems that the most recent version of Parse Cloud code is to blame: 1.6.0. Revert to version 1.5.0 using the following command prompt in the console view:

 parse jssdk 1.5.0 

Now, unfortunately, I am still getting the following error (but I think it is related to my main.js file of my cloud code. I will continue this flow when I finally figure out how to populate the cloud code file.

 Error Domain=Parse Code=141 "success/error was not called" UserInfo=0x1740e5700 {code=141, temporary=0, error=success/error was not called, NSLocalizedDescription=success/error was not called} 
+6
source share
2 answers

Finally. So, here is the most basic code that WORKS for using Parse + Stripe.

IOS code

 - (IBAction)save:(id)sender { STPCard *card = [[STPCard alloc] init]; card.number = self.paymentTextField.cardNumber; card.expMonth = self.paymentTextField.expirationMonth; card.expYear = self.paymentTextField.expirationYear; card.cvc = self.paymentTextField.cvc; NSLog(@"%@, %@", self.paymentTextField.cvc, self.paymentTextField.cardNumber); [[STPAPIClient sharedClient] createTokenWithCard:card completion:^(STPToken *token, NSError *error) { if (error) { NSLog(@"up here"); NSLog(@"error - %@", error); } else { //[self createBackendChargeWithToken:token]; NSLog(@"down here"); NSString *myVal = token.tokenId; NSLog(@"%@",token); [PFCloud callFunctionInBackground:@"hello" withParameters:@{@"token":myVal} block:^(NSString *result, NSError *error) { if (!error) { NSLog(@"from Cloud Code Res: %@",result); } else { NSLog(@"from Cloud Code: %@",error); } }]; } }]; } 

And then the main.js code:

 var Stripe = require('stripe'); Stripe.initialize('sk_test_********'); //replace *** with your key values Parse.Cloud.define("hello", function(request, response) { var stripeToken = request.params.token; var charge = Stripe.Charges.create({ amount: 1000, // express dollars 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'); }); }); 

Now again, it ONLY WORKS if you RETURN TO YOUR CLASS version 1.5.0 (as others have helped me). Hope this helps someone else too.

+9
source

Just to be more explicit from above:

cd into your cloud code directory and run parse jssdk 1.5.0 and parse deploy .

+3
source

All Articles