SatLane
Skip to documentation
Read as Markdown ↗
Browse documentation
On this page

Hosted and custom checkout

You have two options.

Option A: Hosted checkout (easiest)

JavaScript2 lines
const { invoice } = await createInvoice(...);
res.redirect(invoice.hosted_checkout_url);

For a Live invoice with a payable destination, the buyer sees a mobile-first payment page with QR code, address, countdown, status pill, and "Open in wallet". Enabled Sandbox instead displays a simulated-payment view with no payable QR, address or wallet link. The page uses live updates and can redirect to your success_url after the payment flow completes. A browser redirect alone must never trigger order fulfillment; use a verified webhook or authenticated server-side invoice lookup.

Option B: Custom checkout UI

Render your own frontend. SatLane exposes public (unauthenticated) buyer endpoints:

JavaScript21 lines
// 1. Fetch the snapshot (invoice ID is the credential)
const res = await fetch(`https://api.satlane.com/pay/invoices/${invoiceId}`);
const { invoice, store, live } = await res.json();

// 2. Render invoice.payment_uri as a QR code

// 3. Subscribe to live status updates via SSE
const es = new EventSource(`https://api.satlane.com${live.events_url}`);
// SatLane sends ordinary message events, not named SSE events.
es.onmessage = (event) => {
  const payload = JSON.parse(event.data);
  renderInvoiceStatus(payload.invoice);
  // payload.event_type distinguishes lifecycle changes.
  // UI updates are not proof for server-side order fulfillment.
};
es.onerror = () => {
  // EventSource reconnects automatically. Refetch the snapshot
  // after reconnection; do not assume replay of every missed event.
};
// Close when the checkout component unmounts:
// es.close();

For WebSocket, resolve the relative live.stream_url against the API origin and change HTTPS to WSS. It carries the same live UI payload. These connections do not guarantee replay of missed events; refetch the invoice snapshot when reconnecting.

JavaScript8 lines
const url = new URL(live.stream_url, 'https://api.satlane.com');
url.protocol = 'wss:';
const socket = new WebSocket(url);
socket.onmessage = (event) => {
  const payload = JSON.parse(event.data);
  renderInvoiceStatus(payload.invoice);
};
// Close the socket when your checkout component unmounts.

CORS is open (Access-Control-Allow-Origin: *) on /pay/* so vendor frontends on any domain can call these directly.