Created
April 22, 2017 01:16
-
-
Save ColeTownsend/1c17cfe0f1101609bffaeb7027c121f7 to your computer and use it in GitHub Desktop.
For Micro Stripe Demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require('dotenv').config(); // we need our dotenv stuff | |
const {send, json} = require('micro'); | |
const post = require('./post'); // we'll make this soon don't worry. | |
const stripe = require('stripe')(process.env.STRIPE_SECRET_KEY); // this is our stripe key! use your testing key for now. | |
module.exports = post(async (req, res) => { | |
const data = await json(req); | |
stripe.charges.create(data, (err, resp) => { | |
if (err) { | |
send(res, 400, {error: `Charge could not be created.`}) | |
} | |
else { | |
send(res, 200, {message: `Charge created.`}) | |
} | |
}) | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment