With Checkout you can now redirect to the hosted Checkout page from the server side without having to make any calls from the frontend.
fastify.post("/create-checkout-session", async (request, reply) => {
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [
{
price_data: {
currency: 'usd',
product_data: {
name: 'Tiny Demos',
images: ['https://i.imgur.com/EHyR2nP.png'],
},
unit_amount: 2000,
},
quantity: 1,
},
],
mode: 'payment',
success_url: `https://${process.env.PROJECT_DOMAIN}.glitch.me/success`,
cancel_url: `https://${process.env.PROJECT_DOMAIN}.glitch.me/cancel`,
});
reply.redirect(session.url);
});
Make copies, remix, change and learn how to play with this tinydemo.
Reach out to us on any of our contact channels: