One signed POST creates an invoice. The amount goes up as minor units of a fiat currency and the buyer picks the coin later, at checkout โ so nothing here commits you to a chain.
https://api2.havala.ioEvery gateway call under /api/v1 is signed. Three headers carry it:
import { createHash, createHmac, randomUUID } from "node:crypto";
// Serialise once: the signature covers these exact bytes.
const body = JSON.stringify({
orderId: "order-8814",
amount: "12500", // minor units of currency โ 12500 is USD 125.00
currency: "USD", // you price in fiat; the buyer picks the crypto at checkout
returnUrl: "https://merchant.example.com/checkout/success",
});
// Canonical string: {t}\nPOST\n{path}\n{idempotencyKey}\n{sha256(body)}
// The idempotency line belongs to write methods; a GET signs four lines, not five.
const t = Math.floor(Date.now() / 1000);
const idempotencyKey = randomUUID();
const bodyHash = createHash("sha256").update(body).digest("hex");
const v1 = createHmac("sha256", process.env.HAVALA_API_SECRET)
.update([t, "POST", "/api/v1/invoices", idempotencyKey, bodyHash].join("\n"))
.digest("hex");
const response = await fetch("https://api2.havala.io/api/v1/invoices", {
method: "POST",
headers: {
"Content-Type": "application/json",
"X-API-Key": process.env.HAVALA_API_KEY,
"X-Signature": `t=${t},v1=${v1}`,
"Idempotency-Key": idempotencyKey,
},
body,
});
// Every gateway response is wrapped: { success, data, timestamp, requestId }.
const { data: invoice } = await response.json();
// => { id: "clyv3n8x40001qh7m2k9d5b1t", referenceId: "INV-260826-041C", status: "OPEN", โฆ }In this order, because each step needs the credentials, signature or invoice the one before it produced.
The gateway you sign and the checkout the buyer sees โ the two surfaces an integration calls.
The core of a Havala integration. Create a fiat-denominated invoice, check it out onto a chain and token, and follow it through to PAID. Signed with your merchant point credentials.
View endpointsThe on-chain half of an invoice: the leased deposit address, the amount actually received, confirmation progress and the transaction hash. Filterable by status and blockchain.
View endpointsThe unauthenticated API behind the hosted payment page. Read an invoice as the buyer sees it, pick a chain and currency, and poll the payment that comes back. Possession of the invoice id is the capability โ nothing is signed.
View endpointsThese docs are machine-readable โ bring your assistant.