Create {Payment|Setup}Intents Endpoint

node v10.24.1
version: 2.0.0
endpointsharetweet
const stripe = require("stripe")(process.env.STRIPE_SECRET_TEST_KEY); const express = require("@runkit/runkit/express-endpoint/1.0.0"); const app = express(exports); const bodyParser = require('body-parser'); app.use(bodyParser.json()); app.use("/", function(req, res, next) { // Allow requests from localhost. const origin = req.headers.origin; res.setHeader("Access-Control-Allow-Headers", "*"); res.setHeader('Access-Control-Allow-Origin', "*"); next(); }); app.post("/payment_intents", async (req, res) => { const { options } = req.body; const paymentIntent = await stripe.paymentIntents.create(options); res.json(paymentIntent); }); app.post("/setup_intents", async (req, res) => { const { options } = req.body; const setupIntent = await stripe.setupIntents.create(options); res.json(setupIntent); });
Loading…

no comments

    sign in to comment