- 1Get a secret key
Dashboard → Developers → Create secret key. Keep it on your server only.
- 2Create a checkout session
Send the amount and what it's for. You get back a url.
- 3Send the customer there
Redirect to the session's url. After paying, they're sent to your success_url.
- 4Fulfil on the webhook
Add your webhook URL under Developers. When a payment is verified on chain, Swipe POSTs checkout.session.completed, signed with your signing secret.
const res = await fetch("https://swipecheckout.xyz/v1/checkout/sessions", {
method: "POST",
headers: { Authorization: `Bearer ${process.env.SWIPE_SECRET_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify({ amount: "24.00", name: "Cold brew subscription", success_url: "https://yourshop.com/thanks" }),
});
const session = await res.json();
// redirect the customer to session.urlStore the event id and ignore repeats: if your server doesn't answer, Swipe retries the same event for about three days. Full details, including how to verify the signature, are in the API reference at swipecheckout.xyz/docs.