Two step process
Must create success_url
page and cancel_url
page. Neither is guaranteed to be hit.
// Set your secret key. Remember to switch to your live secret key in production!// See your keys here: https://dashboard.stripe.com/account/apikeysconst stripe = require("stripe")(process.env.STRIPE_SECRET);(async () => {const session = await stripe.checkout.sessions.create({payment_method_types: ["card"],line_items: [{name: "Stickers",description: "Party Corgi Stickers",images: ["https://example.com/t-shirt.png"],amount: 5,currency: "usd",quantity: 1}],success_url: "https://example.com/success?session_id={CHECKOUT_SESSION_ID}",cancel_url: "https://example.com/cancel"});console.log(session);})();
gives you:
{"id": "cs_test_WUUHQmwl9kjhC","object": "checkout.session","billing_address_collection": null,"cancel_url": "https://example.com/cancel","client_reference_id": null,"customer": null,"customer_email": null,"display_items": [{"amount": 500,"currency": "usd","custom": [Object],"quantity": 1,"type": "custom"}],"livemode": false,"locale": null,"metadata": {},"mode": "payment","payment_intent": "pi_1GPhIbKsk2eVYJSpBtJpAfUp","payment_method_types": ["card"],"setup_intent": null,"shipping": null,"shipping_address_collection": null,"submit_type": null,"subscription": null,"success_url": "https://example.com/success?session_id={CHECKOUT_SESSION_ID}"}