i had issues with this today
I did it by trial and error, here is what i remember
https://www.npmjs.com/package/stripe <- thats where i got the cloud code from
- in the root directory of your parse-server through command prompt i executed the following - npm install stripe
- then i added the stripe dependancy to package.json (this stack overflow post was the missing key) "stripe": "~4.9.0",
- the cloud code is as follows
Parse.Cloud.define("charge", function(request, response) {
var stripe = require('stripe')('sk_test_****');
stripe.customers.create({
email: theEmailAddress
}).then(function(customer) {
return stripe.charges.create({
amount: yourAmount,
currency: yourCurrency,
card: yourToken,
description: yourDescription
});
}).then(function(charge) {
// New charge created on a new customer
}).catch(function(err) {
// Deal with an error
});
});
- use that cloud code through your app and see if it works in your stripe dashboard (you must check in the dashboard)
so the two 'breakthroughs' came when i added stripe as a dependancy in package.json and also can you see that var stripe = require
is inside the the cloud code function
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…