Add crypto to your existing checkout
The end-to-end walkthrough: a 'Pay with crypto' row beside Card and PayPal, the invoice created on your server, the pop-up or embed, and fulfilment on the invoice.paid webhook only.
Your checkout already takes cards, maybe PayPal. This adds one more option, Pay with crypto, without replacing anything: your customer picks it from your own list, pays in a pop-up with whatever token they hold, and you receive a USD stablecoin or native Bitcoin at your own address.
Four steps, and the last one is the only one that ships anything:
- Show the option beside your other payment methods.
- Create the invoice on your server when the order is placed.
- Open the pop-up (or mount the checkout inline) with that invoice.
- Fulfil on the
invoice.paidwebhook. Only there.
Complete, runnable versions: Next.js, Express, plain PHP.
1. Show the option
Section titled “1. Show the option”React:
import { PaymentMethodOption } from "@intents-fi/react";
<PaymentMethodOption selected={method === "crypto"} onSelect={() => setMethod("crypto")} />Any other site: load https://pay.intents.fi/v1/option.css and paste the row’s markup. Both are
on the “Pay with crypto” option; the logos are in the
logo pack. Selecting the row takes no payment: it only records the
customer’s choice, like your Card row does.
2. Create the invoice on your server
Section titled “2. Create the invoice on your server”When the order is placed with crypto selected, your server creates an invoice for that order.
import { createInvoice } from "@intents-fi/sdk";
const invoice = await createInvoice({ amount: order.total, reference: order.id });// → { id, clientSecret, url, … }: send id and clientSecret to the page- The amount comes from your records, in USD, never from the browser.
referenceis your order id. Creating twice for the same order (a retry, a double click) returns the same invoice, so a customer is never asked to pay twice.- Use a secret key (
ik_test_…while you build). It never reaches the browser.
PHP shops use intents-php:
$intents->createInvoice(['amount' => '42.00', 'reference' => $orderId]).
3. Open the pop-up
Section titled “3. Open the pop-up”// React<PayButton invoiceId={invoice.id} clientSecret={invoice.clientSecret} onPaid={() => router.push("/thanks")} /><!-- anything else --><script src="https://pay.intents.fi/v1/checkout.js"></script><script> IntentsCheckout.open({ invoiceId, clientSecret, onPaid: () => location.assign("/thanks") });</script>To keep the checkout on your page instead of a pop-up, mount <CheckoutEmbed> or pass
container to IntentsCheckout.open(). See the embedded widget. The
customer sees the price first, then picks a token and network, and gets the exact amount, the
address, a QR code, a countdown and a refund address field.
onPaid is for your page: close the pop-up, show a thank-you. It is not proof of payment.
Anyone can call it from the browser console.
4. Fulfil on the webhook
Section titled “4. Fulfil on the webhook”Add a webhook endpoint in the dashboard (Webhooks, for invoice.paid), and ship from it:
import { isTestEvent, verifyWebhook, WebhookSignatureError } from "@intents-fi/sdk";
export async function POST(request: Request) { try { const event = await verifyWebhook(await request.text(), request.headers, process.env.INTENTS_WEBHOOK_SECRET); if (event.type === "invoice.paid" && !isTestEvent(event)) await markPaid(event.data.reference); return new Response(null, { status: 204 }); } catch (e) { if (e instanceof WebhookSignatureError) return new Response("bad signature", { status: 400 }); throw e; }}- Verify over the raw body. In Express, mount
express.raw()on this route. markPaidmust be safe to run twice: the same event can arrive again.- Events can arrive out of order: act on
event.data.status.
Verify and test webhooks covers each of these, and how to try your receiver with Send test event and Resend.
Before you go live
Section titled “Before you go live”- Run the whole flow with test keys: test mode moves no money.
- Send test event from the dashboard: your receiver answers 2xx and ships nothing.
- Resend a real delivery: the order is still shipped once.
- Then swap in live keys once your account is live (the dashboard’s go-live checklist).
Using Stripe? A guide to listing “Pay with crypto” inside Stripe’s Payment Element is coming.