For developers
Code examples
Copy-paste starting points for the most common tasks. Replace the key with your own from the dashboard.
Create an invoice — cURL
curl https://api.xclusor.com/v1/invoices \
-H "Authorization: Bearer xlr_test_xxx" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order-1001" \
-d '{ "amount_fiat": "25.00", "currency": "USD", "order_id": "1001" }'Create an invoice — Node.js
const res = await fetch("https://api.xclusor.com/v1/invoices", {
method: "POST",
headers: {
Authorization: `Bearer ${process.env.XCLUSOR_API_KEY}`,
"Content-Type": "application/json",
"Idempotency-Key": `order-${order.id}`,
},
body: JSON.stringify({
amount_fiat: order.total, // USD — the customer picks the coin at checkout
order_id: String(order.id),
success_url: "https://yourstore.com/thanks",
}),
});
if (!res.ok) throw new Error((await res.json()).error.message);
const invoice = await res.json();
// redirect the customer to invoice.checkout_urlCreate an invoice — Python
import os, requests
r = requests.post(
"https://api.xclusor.com/v1/invoices",
headers={
"Authorization": f"Bearer {os.environ['XCLUSOR_API_KEY']}",
"Idempotency-Key": "order-1001",
},
json={"amount_fiat": "25.00", "order_id": "1001"},
timeout=15,
)
r.raise_for_status()
print(r.json()["checkout_url"])Create an invoice — PHP
$ch = curl_init("https://api.xclusor.com/v1/invoices");
curl_setopt_array($ch, [
CURLOPT_POST => true,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
"Authorization: Bearer " . getenv("XCLUSOR_API_KEY"),
"Content-Type: application/json",
"Idempotency-Key: order-1001",
],
CURLOPT_POSTFIELDS => json_encode([
"amount_fiat" => "25.00", "order_id" => "1001",
]),
]);
$invoice = json_decode(curl_exec($ch), true);
header("Location: " . $invoice["checkout_url"]);Verify a webhook — Express (Node.js)
import express from "express";
import crypto from "node:crypto";
const app = express();
app.post("/webhooks/xclusor", express.raw({ type: "application/json" }), (req, res) => {
const raw = req.body.toString("utf8");
const parts = Object.fromEntries(req.get("Xclusor-Signature").split(",").map((p) => p.split("=")));
const expected = crypto
.createHmac("sha256", process.env.XCLUSOR_WEBHOOK_SECRET)
.update(`${parts.t}.${raw}`)
.digest("hex");
const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;
const valid =
fresh && expected.length === (parts.v1 ?? "").length &&
crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));
if (!valid) return res.sendStatus(400);
const event = JSON.parse(raw);
if (event.type === "invoice.paid") {
// mark the order paid (dedupe on event.id)
}
res.sendStatus(200);
});Verify a webhook — Python (Flask)
import hmac, hashlib, os, time
from flask import Flask, request, abort
app = Flask(__name__)
@app.post("/webhooks/xclusor")
def xclusor_webhook():
raw = request.get_data(as_text=True)
parts = dict(p.split("=", 1) for p in request.headers["Xclusor-Signature"].split(","))
expected = hmac.new(os.environ["XCLUSOR_WEBHOOK_SECRET"].encode(),
f"{parts['t']}.{raw}".encode(), hashlib.sha256).hexdigest()
if abs(time.time() - int(parts["t"])) > 300 or not hmac.compare_digest(expected, parts.get("v1", "")):
abort(400)
event = request.get_json()
if event["type"] == "invoice.paid":
pass # mark the order paid (dedupe on event["id"])
return "", 200Full details: API reference · Webhook documentation
Ready to accept crypto the right way?
Set up your first invoice today. Your keys, your coins, your customers.