Payment sessions
A payment session is one checkout for one amount, hosted on checkout.borga.is or embedded on your page.
Creating a session creates a Payment and a checkout to collect it. Hosted sessions return a url to redirect the payer to; embedded sessions return a client_secret for borga.js. Sessions expire after 24 hours.
The payment session object
ps_.null for embedded sessions.pcs_.open, complete or expired.hosted or embedded. This is the checkout mode, not test or live.card, apple_pay, google_pay, bank_invoice.?session=ps_… appended. Empty for embedded sessions.is or en.Create a payment session
Either amount or payment is required. Hosted sessions also require return_url and cancel_url; embedded sessions created with a secret key require origin. Publishable keys may only create embedded sessions, and the browser's Origin header must be on the key's allow-list.
Body
payment is set.ISK (no minor unit), EUR, USD, GBP, DKK, NOK, SEK
created instead of creating one.hosted redirects to checkout.borga.is; embedded returns a client_secret for borga.js.http://localhost is allowed in test mode.return_url.https://host of the page that opens the modal. Ignored for publishable keys, which use the request's Origin.save_payment_method to attach the card somewhere you can find it.bank_invoice to offer krafa (hosted only, PayDay required).is or en.{ items: [{ price, quantity? }] }. Starts a subscription with these recurring prices when the payment succeeds. Implies save_payment_method.const session = await borga.paymentSessions.create(
{
amount: 12900,
currency: "ISK",
customer_email: "anna@example.is",
external_reference: "order_5678",
return_url: "https://yoursite.is/order/complete",
cancel_url: "https://yoursite.is/cart",
enabled_methods: ["card", "apple_pay", "google_pay"],
locale: "is",
metadata: { order_id: "5678" },
},
// Your own idempotency key makes retries across processes safe too.
{ idempotencyKey: "order_5678_checkout" },
);
// Send the payer to the hosted page.
redirect(session.url!);curl https://api.borga.is/v1/payment_sessions \
-H "Authorization: Bearer sk_test_…" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: order_5678_checkout" \
-d '{
"amount": 12900,
"currency": "ISK",
"customer_email": "anna@example.is",
"external_reference": "order_5678",
"return_url": "https://yoursite.is/order/complete",
"cancel_url": "https://yoursite.is/cart",
"enabled_methods": ["card", "apple_pay", "google_pay"],
"locale": "is",
"metadata": { "order_id": "5678" }
}'{
"id": "ps_3kD9mQ2vXb7LpR4tYw8Nz1Ha",
"payment": "pay_7Hs2Kq9LmW4xZc1Vb8Ny3Rt6",
"url": "https://checkout.borga.is/ps_3kD9mQ2vXb7LpR4tYw8Nz1Ha",
"return_url": "https://example.is/order/complete",
"cancel_url": "https://example.is/cart",
"expires_at": "2026-09-08T12:00:00.000Z",
"status": "open",
"enabled_methods": ["card", "apple_pay", "google_pay"],
"mode": "hosted",
"locale": "is",
"customer_email": null,
"customer_kennitala": null,
"created_at": "2026-09-07T12:00:00.000Z",
"client_secret": null
}Errors: missing_amount, missing_redirect_urls, redirect_url_not_allowed, missing_origin, origin_not_allowed, publishable_key_not_allowed, bank_invoice_not_enabled, invalid_kennitala, resource_not_found.
Retrieve a payment session
Returns the session with payment_status, which saves a second call on your return page. client_secret is never returned here.
curl https://api.borga.is/v1/payment_sessions/ps_3kD9mQ2vXb7LpR4tYw8Nz1Ha \
-H "Authorization: Bearer sk_test_…"There is no list endpoint for sessions and no way to cancel one early; unpaid sessions expire on their own.