Skip to content

Instantly share code, notes, and snippets.

@glennblock
Forked from Manny7311/node.js
Last active November 25, 2016 06:38
Show Gist options
  • Save glennblock/332df8ad90a978c172c0ea9c72ed5740 to your computer and use it in GitHub Desktop.
Save glennblock/332df8ad90a978c172c0ea9c72ed5740 to your computer and use it in GitHub Desktop.
Webtask Stripe
'use latest';
import stripe from 'stripe';
module.exports = function(ctx,cb) {
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!';
cb({message:message});
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment