1

I'm trying to create a charge with a test account on stripe.

Here is my parse cloud function:

Parse.Cloud.define("charge", function(request, response) {
 var Stripe = require('stripe'); 
 Stripe.initialize('...');

 Stripe.Charges.create({
    amount: 1000, 
    currency: "usd",
    customer: "..."
   },{
   success: function(httpResponse) {
       response.success("Purchase made!");
    },
   error: function(httpResponse) {
      response.error("Uh oh, something went wrong");
   }
  });
 }); 

I've hard coded the customerID into the function just for testing.

When I call the function from my app, I get the following error:

TypeError: Object [object Object] has no method '_each'

at request (stripe.js:58:11)

at post (stripe.js:117:12)

at Object.module.exports.Charges.create (stripe.js:157:16)

at main.js:19:18 (Code: 141, Version: 1.6.2)

Can anyone help?

martonp
  • 13
  • 4

3 Answers3

2

@user3707419 I get the same error when trying to add a customer. Comment out that line and instead add the following:

 card: stripeToken //this is the token you generated

Also, if that doesn't work, you need to revert you parse cloud code version to 1.5.0 (you are probably running the latest version 1.6.0 which does not work. The way you do this is type the following into your console:

parse jssdk 1.5.0

All of my working code on version 1.5.0 is located at this post: Complete working Stripe + Parse.com working code on version 1.5.0

We may have to revert back even further to get customer: customer.id working I'm not sure. Let me know if you figure a different solution out. Hope this helps.

Community
  • 1
  • 1
Ibdakine
  • 504
  • 4
  • 17
  • 1
    Thanks! Reverting the jssdk version worked. I've only been doing charges and I haven't been creating customers, but I'll let you know if it doesn't and I have to revert back even further. – martonp Sep 15 '15 at 17:29
0

For what it's worth, your code looks very similar to my cloud code that works. However, I do not have a semicolon after the first }). Just after the final one. If that's not the error, then i'm not very sure how to interpret your errors because i cannot see the code at the mentioned lines. Best of luck

  • Javascript adds in the semicolons itself in the right place (usually), so that wouldn't be an issue, but thanks for the help! – martonp Sep 15 '15 at 17:32
0

Just so you know the real reason: Parse removed underscore lib , stripe.js thats built into parse cloud code relied on it. Hence failure like this.

Parse 1.6.X no longer supports modules, they removed them from API doc as well.

jeveloper
  • 890
  • 8
  • 10