Skip to content

Instantly share code, notes, and snippets.

@Manny7311
Created November 25, 2016 16:14
Show Gist options
  • Save Manny7311/b16e3714fdbdacf6bf73c021a2d3569d to your computer and use it in GitHub Desktop.
Save Manny7311/b16e3714fdbdacf6bf73c021a2d3569d to your computer and use it in GitHub Desktop.
import stripe from 'stripe';
var app = express();
app.use(bodyParser.json());
app.post('/payment', (req,res) => {
var ctx = req.webtaskContext;
console.log(req.body);
var STRIPE_SECRET_KEY = ctx.secrets.STRIPE_SECRET_KEY;
stripe(STRIPE_SECRET_KEY).charges.create({
amount: ctx.data.amount,
currency: ctx.data.currency,
source: ctx.body.stripeToken,
description: ctx.data.description
}, (err, charge) => {
const status = err ? 400 : 200;
const message = err ? err.message : 'Payment done!';
res.json({message:message});
});
});
module.exports = fromExpress(app);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment