Esempi di codice
Esempi da copiare e incollare per i flussi più comuni, in cURL, Node e Python.
Non ancora attivo — api.baynoy.com non risolve, quindi gli esempi qui sotto oggi non funzioneranno. Descrivono il contratto verso cui stiamo lavorando e le forme in questa pagina possono ancora cambiare.
Create a payment link
The same call in three shapes — plain HTTPS, no library.
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/k3x9q2Node
// Node 18+, no package needed
const res = await fetch("https://api.baynoy.com/v1/catalog/links", {
method: "POST",
headers: {
authorization: `Bearer ${process.env.BAYNOY_SECRET_KEY}`,
"content-type": "application/json",
},
// amounts are strings of integer minor units — never floats
body: JSON.stringify({ title: "Design retainer", amountMinor: "4900", assetKey: "fiat:EUR" }),
});
const { slug } = await res.json();
console.log(`https://baynoy.com/pay/${slug}`);Python
import os, requests
r = requests.post(
"https://api.baynoy.com/v1/catalog/links",
headers={"Authorization": f"Bearer {os.environ['BAYNOY_SECRET_KEY']}"},
json={"title": "Design retainer", "amountMinor": "4900", "assetKey": "fiat:EUR"},
)
print("https://baynoy.com/pay/" + r.json()["slug"])