Coinfat

Checkout SDK

Quickstart

Go from an invoice ulid to a rendered checkout in a few lines. This is the whole loop, so you can see where the ulid comes from.

1. Your server creates the invoice

On your backend, create the invoice with your secret key through the Create an invoice API and keep the returned ulid. This is the only step that uses your secret key, and it never runs in the browser.

2. Your page renders the checkout

Create a client with Coinfat(...), then call checkout(...) with the ulid. For an inline widget, give it a mount target — a CSS selector or an element — and the SDK renders the coin picker, deposit address, QR, and live status there.

import {Coinfat} from "@coinfat/checkout";
const coinfat = Coinfat({environment: "production"});
coinfat.checkout({
invoice: ulid, // the ulid your server created
display: "inline",
mount: "#pay",
onCompleted: (invoice) => console.log("paid", invoice.ulid)
});
Server
// Node — create the invoice with your SECRET key, return the ulid.
// See "Create an invoice". Never do this in the browser.
const res = await fetch("https://api.coinfat.com/api/invoices", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.COINFAT_API_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({amount: "49.99", duration: "1h"})
});
const {ulid} = await res.json();