All guides

Take payments from your own app

Create checkouts from your server and get a webhook when they're paid. · 8 min read

  1. 1
    Get a secret key

    Dashboard → Developers → Create secret key. Keep it on your server only.

  2. 2
    Create a checkout session

    Send the amount and what it's for. You get back a url.

  3. 3
    Send the customer there

    Redirect to the session's url. After paying, they're sent to your success_url.

  4. 4
    Fulfil 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.url

Store 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.