Create {Payment|Setup}Intents Endpoint
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);
});
no comments