0
votes

I'm experimenting with the Parse Cloud Code Stripe module and I keep getting a 400 bad request error with the following message:

code: 141, message: "TypeError: Object [object Object] has no method 'i…es.create (stripe.js:157:16)↵ at main.js:11:31

The cloud code runs as long as I don't reference Stripe. The token should be good, as I just created it, although even if it wasn't I would expect a vastly different error message. After tearing my hair out for hours I'm lost for other ideas, and would really, really appreciate any assistance:

var Stripe = require('stripe');
Stripe.initialize('sk_test_oBhEeXgs9x...'); //dots added for confidentiality

Parse.Cloud.define("pay", function(request, response) {
    Stripe.Charges.create({
        amount: 100 * 10, // $10 expressed in cents
        currency: "usd",
        card: "tok_3TnIVhEv9..." // dots added for confidentiality
    },{
        success: function(httpResponse) {
            response.success("Purchase made!");
        },
        error: function(httpResponse) {
            response.error("Uh oh, something went wrong");
        }
    });
});

and my client side code is:

<script>
Parse.initialize("CGqOtFjaHZIs6vG57hAWc...", "j4hDZ7N0s4jwfQIl0t...");

Parse.Cloud.run('pay', {}, {
    success: function (result) {
        console.log(result);
    },
    error: function (error) {
        console.log(error);
    }
});
</script>
1
should be stripe.Charges instead of Stripe.Charges to match the variable from line 1 - Matthew Arkin
That is true. Thank you for picking that up. Unfortunately that was just a silly mistake when I was cleaning up the code before posting it here, and the problem of "i...es.create' still persists. - J. Ellis
I believe they removed all modules in version 1.6.X . - jeveloper

1 Answers

0
votes

I had same problem. I reverted to 1.5.0 using: parse jssdk 1.5.0 in the project directory in the terminal. That fixed it for me.