Швидкий старт

Від тестового ключа до отриманої події Webhooks — у порядку, який позбавляє переробок.

Ще не запущено — домен api.baynoy.com не резолвиться, тож приклади нижче сьогодні не виконаються. Вони описують контракт, до якого ми йдемо, і схеми на цій сторінці ще можуть змінитися.

Take your first payment in four steps

Get a test key from the dashboard, create a payment link, pay it with a test card, and receive the webhook. Nothing about that flow changes when you move to live keys — only the key prefix does.

cURL
curl https://api.baynoy.com/v1/catalog/links \
  -H "Authorization: Bearer bk_test_..." \
  -H "Content-Type: application/json" \
  -d '{"title": "Design retainer", "amountMinor": "4900", "assetKey": "fiat:EUR"}'

# -> {"id": "lnk_...", "slug": "k3x9q2"}  — the page is https://baynoy.com/pay/k3x9q2

The two rules that save you a rewrite

Amounts are integers in the currency's smallest unit, sent as strings, with an explicit asset key such as fiat:EUR — never floats. And you fulfil on the signed webhook, not on the browser redirect: the redirect tells the customer what happened, the webhook tells your system.

Node
import { createHmac, timingSafeEqual } from "node:crypto";

// Fulfil on the webhook, never on the redirect.
// Header: Baynoy-Signature: t=<unix seconds>,v1=<hex HMAC-SHA256 of "<t>.<raw body>">
app.post("/hooks/baynoy", express.raw({ type: "application/json" }), (req, res) => {
  const parts = Object.fromEntries(req.get("baynoy-signature").split(",").map((p) => p.split("=")));
  const expected = createHmac("sha256", process.env.BAYNOY_WEBHOOK_SECRET)
    .update(`${parts.t}.${req.body}`).digest("hex");
  const fresh = Math.abs(Date.now() / 1000 - Number(parts.t)) < 300;
  if (!fresh || !timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1 ?? ""))) return res.sendStatus(400);
  const event = JSON.parse(req.body);
  if (event.type === "payment.captured") fulfil(event.data);
  res.sendStatus(200);
});

Then what

The widget for an inline form, QR codes for a counter, invoices for B2B terms — each is the same payment underneath, on a different surface. Subscriptions are coming later; they are not in the API today.