Reputation: 91
I went from using the old parse cloud code to open source parse server on AWS and this part of the main.js
does not work.
var Stripe = require('stripe');
Stripe.initialize('sk_live_mylivekey');
var Mailgun = require('mailgun');
Mailgun.initialize("mydomain.mailgun.org");
Upvotes: 2
Views: 181
Reputation: 165
I switched from using cloud code for making charges to creating a route in my index.js file for making charges. In index.js create a route as such
var stripe = require('stripe')('sk_test_****');
var bodyParser = require('body-parser');
app.use(bodyParser.urlencoded({
extended: false
}));
app.post('/charge', function(req, res){
var token = req.body.token;
var amount = req.body.amount;
stripe.charges.create({
amount: amount,
currency: 'usd',
source: token,
}, function(err, charge){
if(err)
// Error check
else
res.send('Payment successful!');
}
});
I call this route using jQuery post however, you could also call it in a form
var handler = StripeCheckout.configure({
key: 'pk_test_****',
locale: 'auto',
token: function(token){
$.post('/charge', {
token: token.id,
amount: total,
}, function(data, status){
alert(data);
});
}
});
Upvotes: 0
Reputation: 3953
Native Cloud code modules like Stripe, Mailgun, Sendgrid, Twilio etc. are not available in the open sourced Parse server.
Use official npm modules for the same:
Reference: Migrate an existing Parse app - Github
Note:
Because the Parse hosted Cloud Code isn’t running a full node environment, there may be subtle differences in how your Cloud Code runs in Parse Server. We recommend exercising all your critical code paths to ensure full functionality.
Upvotes: 1