Avvio rapido
Da una chiave di prova a un webhook ricevuto, nell'ordine che evita di riscrivere tutto.
Non ancora attivo — api.baynoy.com non risolve, quindi gli esempi qui sotto oggi non funzioneranno. Queste forme sono definitive: progetta su di esse ora e nulla cambierà quando le chiavi andranno in produzione.
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.
# 1. create a payment link
curl https://api.baynoy.com/v1/payment_links \\
-H "Authorization: Bearer bk_test_..." \\
-H "Idempotency-Key: $(uuidgen)" \\
-d amount=4900 -d currency=EUR -d title="First sale"The two rules that save you a rewrite
Amounts are integers in the currency's smallest unit with an explicit currency — 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.
import Baynoy from "@baynoy/sdk";
const baynoy = new Baynoy(process.env.BAYNOY_SECRET_KEY);
// 1. create a link and share the URL
const link = await baynoy.paymentLinks.create({
amount: 4900, // integer minor units
currency: "EUR",
title: "First sale",
});
console.log(link.url);
// 2. fulfil on the webhook, never on the redirect
app.post("/hooks/baynoy", async (req, res) => {
const event = baynoy.webhooks.construct(req.rawBody, req.headers["baynoy-signature"]);
if (event.type === "payment.succeeded") await fulfil(event.data.reference);
res.sendStatus(200);
});Then what
Hosted checkout for a full cart, the widget for an inline form, invoices for B2B terms, subscriptions for recurring — each is the same object model with a different surface. Start where your customers already are.