const stripe = require('stripe')(process.env.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); export default async function handler(req, res) { if (req.method === 'POST') { try { // Create Checkout Sessions from body params. const session = await stripe.checkout.sessions.create({ line_items: [ { // Provide the exact Price ID (for example, pr_1234) of the product you want to sell price: '{{PRICE_ID}}', quantity: 1, }, ], mode: 'payment', success_url: `${req.headers.origin}/?success=true`, cancel_url: `${req.headers.origin}/?canceled=true`, }); res.redirect(303, session.url); } catch (err) { res.status(err.statusCode || 500).json(err.message); } } else { res.setHeader('Allow', 'POST'); res.status(405).end('Method Not Allowed'); } }
top of page
bottom of page