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>