HBank merchant API

Take payments on your website, in your shop or at a terminal. Version 1.

Getting started

  1. Open Business in online banking and choose your business. No business yet? Write to business@bank.thehsi.cloud.
  2. Under API keys, create a key. It's shown once: store it on your server, never in a web page or app.
  3. Under Callback URLs, add the HTTPS address HBank asks to approve your payments (see Callbacks). The hosted checkout needs one; QR code payments use it when you set one.
  4. Choose where payouts go: the business's own card, or one of your cards.

Clients for Python, TypeScript, .NET, Java, PHP, Go and Ruby: SDK downloads.

All endpoints below are relative to

https://bank.thehsi.cloud/api/v1

Authentication

Send your API key as a bearer token with every request. The key identifies your business; there's no separate merchant id.

Authorization: Bearer YOUR_API_KEY
StatusBody (text/plain)Meaning
401API key is missingNo Authorization: Bearer … header.
403Invalid API keyThe key doesn't exist, was revoked, or the business is inactive.

Responses and errors

Requests and responses are JSON (Content-Type: application/json). Successful responses have "success": true; failures have "success": false and a machine-readable error, with a 4xx/5xx status.

{ "success": false, "error": "invalid_amount" }
ErrorStatusMeaning
invalid_request400The body isn't a JSON object.
missing_parameters400A required field is missing.
invalid_amount400Not a number, not above 0, or 0 after rounding to the currency.
unknown_currency400Not a supported ISO currency code.
transaction_not_found404No such payment, or it belongs to another business.
transaction_not_payable404The payment is no longer pending, or isn't yours.
conversion_unavailable503Exchange rates can't be fetched right now. Try again later.

Amounts are decimal numbers in the currency's major unit (12.5 = 12.50). They may also be sent as strings ("12.50").

Taking a payment

  1. Create a payment request on your server with the amount and currency. You get a transaction_id: a random string like tx_8fK2mQ7xRb4Tn9WcYz3LpH6v. Store it as text (up to 40 characters), not as a number.
  2. Let the customer pay, in one of three ways:
  3. Approve it when HBank calls your callback URL (if the payment has one).
  4. Confirm it with payment details: status is completed and there's a reference. Always check on your server before handing out goods.

A pending request stays payable for one hour; after that it's removed. If the customer's card refuses the payment, the request stays pending and they can pay with another card.

POST /payment/request

Creates a pending payment request.

FieldType
amountnumberRequired. Above 0, rounded to the currency's decimals.
currencystringRequired. ISO code, e.g. EUR.
descriptionstringShown to the customer when they pay, and in their history.
callback_urlstringWhere HBank asks you to approve the payment. Must lie under one of your callback URLs. Required for the hosted checkout.
curl -X POST https://bank.thehsi.cloud/api/v1/payment/request \
  -H "Authorization: Bearer $HBANK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount": 24.90, "currency": "EUR", "description": "Order 1042",
       "callback_url": "https://shop.example.com/hbank/callback"}'
{ "success": true, "transaction_id": "tx_8fK2mQ7xRb4Tn9WcYz3LpH6v" }

POST /payment/code

Gives a pending request a QR code. Put url in a QR code (or use the ready-made qr_svg), print it on a receipt or send it as a link. Scanning it with any phone camera opens the payment page; HBank customers pay in online banking. Calling it again for the same request returns the same code.

curl -X POST https://bank.thehsi.cloud/api/v1/payment/code \
  -H "Authorization: Bearer $HBANK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"transaction_id": "tx_8fK2mQ7xRb4Tn9WcYz3LpH6v"}'
{
  "success": true,
  "code": "q3V0b2tlbl9hYmNk",
  "url": "https://bank.thehsi.cloud/p/q3V0b2tlbl9hYmNk",
  "qr_svg": "https://bank.thehsi.cloud/p/q3V0b2tlbl9hYmNk/qr.svg"
}

The page at url also offers /status (JSON) for showing progress on a screen next to the QR code.

POST /payment/details

The current state of one of your payments.

curl -X POST https://bank.thehsi.cloud/api/v1/payment/details \
  -H "Authorization: Bearer $HBANK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"transaction_id": "tx_8fK2mQ7xRb4Tn9WcYz3LpH6v"}'
{
  "success": true,
  "transaction": {
    "id": "tx_8fK2mQ7xRb4Tn9WcYz3LpH6v",
    "type": "payment",
    "amount": 24.90,
    "currency": "EUR",
    "status": "completed",
    "description": "Order 1042",
    "reference": "HB20261021AB123456",
    "payment_code": "q3V0b2tlbl9hYmNk",
    "refunded": 0.00,
    "refundable": 24.90,
    "refund_of": null,
    "subscription_id": null,
    "subscription_ids": []
  }
}

reference is set once the payment is completed; payment_code once a QR code was issued. refunded is what you've refunded so far, refundable what you still can. A refund is a transaction too (type refund), with refund_of pointing to the payment. A subscription's payment has its subscription_id; subscription_ids lists every subscription the payment belongs to (several for a checkout of several).

POST /payment/refund

Gives money back for a completed payment: all of it, or part of it, as often as you like up to the amount paid. The customer gets it back on the card and account they paid with, right away, and sees it in their history (with your reason, if you give one). The fee they paid isn't refunded.

FieldType
transaction_idstringRequired. One of your completed payments.
amountnumberIn the payment's currency. Left out: everything that's left.
reasonstringUp to 200 characters, shown to the customer.
curl -X POST https://bank.thehsi.cloud/api/v1/payment/refund \
  -H "Authorization: Bearer $HBANK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"transaction_id": "tx_8fK2mQ7xRb4Tn9WcYz3LpH6v", "amount": 10.00, "reason": "Returned one item"}'
{
  "success": true,
  "refund": { "id": "tx_Qn4Wc8TzLp2JrXv6AhYe3MsB", "amount": 10.00, "currency": "EUR", "reference": "HB20261103KQ482913", "reason": "Returned one item" },
  "transaction": { "id": "tx_8fK2mQ7xRb4Tn9WcYz3LpH6v", "amount": 24.90, "refunded": 10.00, "refundable": 14.90, … }
}

The money comes from the account the payment was paid into, as the same share of what you received for it, so a currency conversion back then doesn't cost you anything now. If the customer's account uses another currency, they get the amount converted at today's rate. You can also refund from the merchant portal: the button next to a payment under Recent activity.

ErrorStatusMeaning
transaction_not_found404No such payment, or it's another merchant's.
not_refundable409Not a completed card payment, or already refunded in full.
insufficient_funds409The account the payment went to doesn't have enough money. Nothing was refunded.
invalid_amount400Not above 0, or more decimals than the currency has.
amount_too_high400More than what can still be refunded.
invalid_reason400The reason is longer than 200 characters.
conversion_unavailable503Exchange rates can't be fetched right now. Try again later.

Failed refunds also carry a readable message. Refunds are safe to retry after a timeout: check refunded with payment details first, so you don't refund twice.

POST /subscriptions

Charges a customer automatically every period. You offer a subscription; the customer opens its link (or scans its QR code), or clicks your pay button, and subscribes in HBank's checkout, paying the first period right away. In the checkout they choose whether it ends by itself (after a number of periods or years; customers on Basic and up). After that HBank charges every period on its own, until the customer or you cancel. Each charge is an ordinary payment to you (with the usual fee, paid by the customer, and refundable), carrying subscription_id in payment details. You can also offer and cancel subscriptions in the merchant portal.

FieldType
amountnumberRequired. Per period.
currencystringRequired. ISO code, e.g. EUR.
intervalstringRequired. day, week, month or year.
interval_countnumberEvery how many intervals, 1 to 120. Default 1.
descriptionstringUp to 200 characters, shown to the customer.
curl -X POST https://bank.thehsi.cloud/api/v1/subscriptions \
  -H "Authorization: Bearer $HBANK_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"amount": 9.99, "currency": "EUR", "interval": "month", "description": "Pro plan"}'

Every subscription answer (here, from GET /subscriptions/{id}, GET /subscriptions and POST /subscriptions/{id}/cancel) looks like this:

{
  "success": true,
  "subscription": {
    "id": "sub_Hk3Rt9WzQe5NcXa2LpVb7YdF",
    "status": "active",                       // offered, active or canceled
    "active_period": true,                    // within a period that's been paid for
    "amount": 9.99, "currency": "EUR", "interval": "month", "interval_count": 1,
    "description": "Pro plan",
    "url": "https://bank.thehsi.cloud/s/Xk2dP0q_l3ZtY8rA",   // send this to the customer
    "qr_svg": "https://bank.thehsi.cloud/s/Xk2dP0q_l3ZtY8rA/qr.svg",
    "subscribed_at": "2026-10-03T09:12:44Z",  // when the customer first subscribed
    "subscribed_for_days": 31,                // how long it's been going (until now, or until it ended)
    "subscribed_for_seconds": 2698211,
    "canceled": false, "canceled_at": null, "canceled_by": null,   // customer, merchant or bank
    "current_period_start": "2026-11-03T09:12:44Z",
    "current_period_end": "2026-12-03T09:12:44Z",
    "next_charge_at": "2026-12-03T09:12:44Z", // null once canceled, or when the customer's chosen end comes first
    "ends_at": null,                          // the customer's automatic end: no renewal from then on (null = until canceled)
    "last_day": null,                         // with an end: the day the last paid period ends
    "charges": 2,
    "last_error": null,                       // why the last renewal was refused, while it's retried
    "customer": { "name": "Ada Lovelace" }
  }
}
  • Canceled subscriptions aren't charged again, but stay in their active_period until current_period_end: give access until then.
  • Renewals are charged like any payment with the customer's card: they only take the account below 0 when the customer allowed that for the card. If the card refuses one (balance too low, blocked, over a spending limit), it's retried for 3 days and then canceled (canceled_by: bank).
  • Ending by itself: customers can choose (and later change, under Subscriptions in online banking) when a subscription ends. It's then canceled at last_day with canceled_by: schedule.
  • Errors: invalid_amount, unknown_currency, invalid_interval, invalid_description (400), subscription_not_found (404), already_canceled (409).

POST /subscriptions/checkout

Lets customers subscribe with the pay button, like a payment: create the subscription and its first payment in one call (same fields as POST /subscriptions, plus callback_url), then hand the transaction_id to the button the way you would for /payment/request. The checkout tells the customer they're subscribing, shows how often it's charged and lets them choose when it ends. Paying starts the subscription. Your callback_url is asked before the first charge, like for any payment.

curl -X POST https://bank.thehsi.cloud/api/v1/subscriptions/checkout   -H "Authorization: Bearer $HBANK_API_KEY"   -H "Content-Type: application/json"   -d '{"amount": 9.99, "currency": "EUR", "interval": "month", "description": "Pro plan",
       "callback_url": "https://shop.example/hbank/callback"}'
{ "success": true, "transaction_id": "tx_Vd5sA1nXq8ZrJ2uGk7Ee0CwM", "subscription": { "id": "sub_Hk3Rt9WzQe5NcXa2LpVb7YdF", "status": "offered", ... } }

For a subscription you've already offered, POST /subscriptions/{id}/checkout (optional callback_url) returns a new transaction_id for it. Once someone has subscribed, the answer is not_open (409). The paid message the button sends carries the transaction_id; its payment details have the subscription_id.

Several subscriptions in one checkout

Send subscriptions, a list of up to 20, instead of the offer's fields. Each entry is the id of a subscription you've offered ("sub_…", or {"id": "sub_…"}) or a new offer's fields (amount, currency, interval, interval_count, description). Optional: description for the payment (left out, the subscriptions' descriptions) and callback_url. All of them have to be in the same currency. One payment charges the first period of each (their sum) and starts them all, with the end the customer chooses in the checkout; after that every subscription renews, ends and is canceled on its own.

curl -X POST https://bank.thehsi.cloud/api/v1/subscriptions/checkout   -H "Authorization: Bearer $HBANK_API_KEY"   -H "Content-Type: application/json"   -d '{"subscriptions": ["sub_Hk3Rt9WzQe5NcXa2LpVb7YdF", {"amount": 2.50, "currency": "EUR", "interval": "week", "description": "Support"}],
       "callback_url": "https://shop.example/hbank/callback"}'
{ "success": true, "transaction_id": "tx_Vd5sA1nXq8ZrJ2uGk7Ee0CwM", "subscriptions": [ { "id": "sub_Hk3Rt9WzQe5NcXa2LpVb7YdF", "status": "offered", ... }, { "id": "sub_…", ... } ] }
  • The subscriptions come back in the order you listed them. When one is refused, nothing is offered and the answer says which ("Subscription 2: …").
  • If one of them gets subscribed to some other way before this payment, the payment can no longer be made and none of them start.
  • The payment's details list every subscription it started in subscription_ids (subscription_id stays for payments of one subscription).
  • Errors: invalid_subscriptions, duplicate_subscription, mixed_currencies, an offer's errors (400), subscription_not_found (404), not_open (409).

Hosted checkout

For customers paying with card number and PIN. After creating the request, open this page in a popup (the pay button does it, or window.open() from your page: the checkout reports to the window that opened it, and closes itself without one):

https://bank.thehsi.cloud/api/payment?tid=TRANSACTION_ID

The customer sees your business name, the description and the amount, signs in with their card and PIN, and confirms. The request needs an authorized callback_url; HBank calls it before charging the card. Closing the pay button's popup without paying marks the payment aborted.

What /api/payment?tid=… answers, and to whom

RequestAnswer
A page load: the popup, a tab, a link (Sec-Fetch-Mode: navigate, or anything that isn't the lookup below) 302 to /pay/request, the checkout page, with a cookie for this payment. Errors (missing, malformed or unknown tid) get a small HTML error page with status 400 / 404.
The pay button's lookup: a script's fetch(), recognized by Sec-Fetch-Mode: cors with Sec-Fetch-Dest: empty (browsers without fetch metadata: an Origin header) An empty 204 with Access-Control-Allow-Origin: * and Cache-Control: no-store (400 / 404, also empty, when the tid is missing, malformed or unknown). No cookie, no redirect: it only tells the SDK that this is HBank's checkout.

Until 9 November 2026 the lookup got {"success": true, "transaction_id": …}; nothing read it. When in doubt HBank treats a request as a page load, so a window never shows that answer.

How long a checkout link works

  • The link (/api/payment?tid=…) works as long as the payment is pending: up to one hour, then the request is removed.
  • Once opened, the checkout must be finished within 5 minutes: the cookie for the payment lasts that long. After that, the next step ends on error page 1000. Opening the link again starts over.

The checkout's error pages:

PageShowsWhy
/error/0Unknown ErrorThe checkout has no window that opened it (a link opened in a tab, noopener), or its page data is missing.
/error/1000Invalid Transaction IDNo payment cookie: the checkout wasn't opened through /api/payment, or its 5 minutes are up.
/error/1001Transaction Not FoundThe payment doesn't exist (any more): removed after an hour, or never created.
/error/1002Transaction isn't PendingIt's already paid, aborted or declined; or a subscription's offer that's no longer open.
/error/1003Redirect URL InvalidThe request has no callback_url, or it isn't under one of your authorized callback URLs.
/error/1004Transaction Currency InvalidThe payment's currency isn't supported.

Pay button

A ready-made "Pay with HBank" button for your website. Include the SDK:

<script
    src="https://bank.thehsi.cloud/assets/hbank.js?v=v26w45.94828a9"
    integrity="sha384-/61FBwv6TvRqKv9idlAtgXLSgOLmbLdWpI/2Pg2IrdhQ6axQ+FfNcOjkofiZzS+n"
    crossorigin="anonymous"
    defer></script>

Readable source of this build: /assets/hbank.src.js?v=v26w45.94828a9; its source map (browsers' developer tools load it by themselves): /assets/hbank.js.map?v=v26w45.94828a9. Every build and what changed: SDK changelog.

and place the button (one per page):

<hbank-pay-button endpoint="/checkout/hbank?cart=1042"></hbank-pay-button>

When it's clicked, the button uses an endpoint on your site (its endpoint attribute, default /pay). Your endpoint creates the payment request (server side, with your API key) and redirects to the hosted checkout. The checkout opens in a popup that only ever shows HBank's pages: the SDK requests your endpoint itself and opens the checkout it redirects to, while the popup shows HBank's loading page.

Your endpoint: the contract

  • Where: on the same scheme, host and port as the page the button is on: a path (/checkout/hbank) or such a full URL. Anything else is refused and the button doesn't start (failed, invalid_endpoint). It may have its own query string; the button adds data (the data attribute as JSON). You can change the attribute at any time.
  • How it's called: on a click, the SDK requests it from your page with
    fetch(endpoint + "?…&data=…", {
      credentials: "same-origin",   // with your cookies (same origin)
      redirect: "follow",
      cache: "no-store",
      headers: { Accept: "text/html,application/xhtml+xml,*/*;q=0.8" },
    });
    The browser sends Sec-Fetch-Mode: cors and Sec-Fetch-Dest: empty. If that lookup can't tell where the checkout is (below), the popup opens the same address as a page (Sec-Fetch-Mode: navigate), so be ready for a second call.
  • Success: answer with a redirect (302 / 303, more hops on your own site are fine) to https://bank.thehsi.cloud/api/payment?tid=<transaction_id>. The lookup counts as found when it ends there with a 2xx and a tid shaped like a transaction id (tx_…).
  • CORS: nothing for you to set. Your endpoint is on your page's origin; HBank's answer at the end of the redirect carries Access-Control-Allow-Origin: * (see the checkout entry).
  • Content Security Policy: allow HBank in connect-src (the lookup follows your redirect to it), and in script-src and frame-src. Without connect-src, the lookup fails and the popup opens your endpoint.
  • Time: 15 seconds for the lookup (the loading page says it's taking longer than usual after 5). When the popup opens your endpoint instead, it must arrive at HBank's checkout within 5 seconds. Otherwise: failed, checkout_timeout.
  • Errors: answer 4xx with JSON {"error": "…"} (next section).

When the endpoint can't create a payment

An empty cart, an expired checkout, an order that's already paid: answer with a 4xx (or 5xx) and JSON, and don't redirect.

HTTP/1.1 409 Conflict
Content-Type: application/json

{"error": "Your cart is empty."}

The payment ends as failed with reason endpoint_error and message your text (up to 200 characters), the popup closes, and your endpoint isn't called again. Show the message in your page. This needs SDK v26w45.94828a9 or newer; with older builds the popup opens your endpoint, shows its answer, and closes after 5 seconds with checkout_timeout. If HBank doesn't know the tid you redirected to, it ends with checkout_not_found.

One click can call your endpoint twice

If the lookup can't tell where your endpoint leads (a network or CORS failure, a page instead of a redirect), the popup opens the endpoint again, and an endpoint that creates a payment request on every call creates a second one. Make it safe to call twice: for the same order, reuse a request that's still pending (check it with payment details) instead of creating another. You can tell the two calls apart by Sec-Fetch-Mode (cors, then navigate), but don't rely on it.

// Your server, e.g. Express
app.get("/checkout/hbank", async (req, res) => {
  const cart = await carts.forSession(req);
  if (!cart || cart.items.length === 0) return res.status(409).json({ error: "Your cart is empty." });

  // Called twice for one click? Reuse the order's request while it's still pending.
  let tid = cart.hbankTransactionId;
  if (tid && (await hbank("/payment/details", { transaction_id: tid })).transaction?.status !== "pending") tid = null;
  if (!tid) {
    const r = await hbank("/payment/request", {
      amount: cart.total, currency: "EUR", description: `Order ${cart.id}`,
      callback_url: "https://shop.example.com/hbank/callback",
    });
    if (!r.success) return res.status(502).json({ error: "We can't take payments right now. Please try again." });
    tid = r.transaction_id;
    await carts.saveTransaction(cart.id, tid);
  }
  res.redirect(`https://bank.thehsi.cloud/api/payment?tid=${tid}`);
});

async function hbank(path, body) {
  const res = await fetch("https://bank.thehsi.cloud/api/v1" + path, {
    method: "POST",
    headers: { Authorization: `Bearer ${process.env.HBANK_API_KEY}`, "Content-Type": "application/json" },
    body: JSON.stringify(body),
  });
  return res.json();   // { success: false, error: "…" } on failure
}

Give the endpoint details of the purchase with the data attribute (JSON); it arrives as the data query parameter, e.g. /checkout/hbank?cart=1042&data=%7B%22size%22%3A%22L%22%7D. Don't trust it for prices: the amount comes from your server.

Following the payment

Each payment goes through these statuses, only forwards:

startedThe checkout popup opened (your endpoint is creating the request).
pendingHBank's checkout is showing; transaction_id is known.
paidPaid: transaction_id, reference, amount, currency. Final.
abortedThe popup was closed without paying (the payment is marked aborted; reason closed). Final.
failedIt couldn't start or was stopped. Final. reason: popup_blocked, invalid_endpoint, endpoint_error (with your message), checkout_not_found, checkout_timeout (your endpoint didn't lead to HBank's checkout in time), left_checkout (the popup went to another site) or declined (an app of the customer's declined it, with the reason as message; the payment is declined).
const button = document.querySelector("hbank-pay-button");

// Every change, as it happens (the event bubbles, so document.addEventListener works too):
button.addEventListener("hbank-payment", (e) => console.log(e.detail.status, e.detail));

// Or wait for the end of the payment:
const result = await button.waitForPayment();
if (result.status === "paid") location.href = `/thanks?order=1042`;
else if (result.reason === "endpoint_error") showError(result.message);

// Or ask any time: null before the button was used.
button.getPaymentStatus();

e.detail, waitForPayment() and getPaymentStatus() give the same status object (HBankPaymentRequestStatus). These are all its fields; anything else is internal:

FieldType
statusstringstarted, pending, paid, aborted or failed.
transaction_idstring | nullKnown from pending on.
referencestring | nullWhen paid.
amountnumber | nullWhen paid, with currency.
currencystring | nullWhen paid.
reasonstring | nullWhen aborted or failed (codes above).
messagestring | nullText for the customer, when there is one (endpoint_error, declined). SDK v26w45.94828a9 and newer.
finishedbooleanstatus === "paid".
failedbooleanaborted or failed.
ongoingbooleanNeither.
  • The hbank-payment event is dispatched on the hbank-pay-button element for every status and bubbles.
  • waitForPayment() resolves only with a final status (paid, aborted, failed) and never rejects; if the current payment already ended, it resolves at once with that.
  • The button and the SDK talk with postMessage; those messages (with duplicates like transactionId and error, kept for old builds) are internal. Don't listen to them: they may change.
  • Treat the status as a hint for the page; confirm with payment details on your server before handing out goods.

Placing the button

  • It's transparent. The button is a rounded pill inside a transparent frame (180 × 40 px by default; size the hbank-pay-button element with CSS to change it). Your page's background shows around it, so it fits light and dark designs alike.
  • It needs to know your page's address. The button runs on HBank's site in a frame and learns which site it's on from document.referrer. It only talks to that origin, and only opens endpoints on it. If your page sends Referrer-Policy: no-referrer (as a header or a <meta name="referrer"> tag), the referrer is empty and the button stays disabled. Allow at least your origin to be sent to HBank: the browsers' default strict-origin-when-cross-origin works, as does origin. same-origin and no-referrer don't.
  • HBank must be allowed to load. With a Content Security Policy, allow script-src, frame-src and connect-src for https://bank.thehsi.cloud. The checkout opens in a popup, so don't block popups from the button's click.
Referrer-Policy: strict-origin-when-cross-origin
Content-Security-Policy: script-src 'self' https://bank.thehsi.cloud; frame-src https://bank.thehsi.cloud; connect-src 'self' https://bank.thehsi.cloud

Callbacks

If a payment has a callback_url, HBank asks it to approve the payment right before charging the customer:

POST https://shop.example.com/hbank/callback
Content-Type: application/json
HBank-Event: payment.approval
HBank-Signature: t=1700000000,v1=ecafa4f7ee46afc951d376d4086a6200c3e600d87a3414b53c8141b75fc2403f

{"id":"tx_8fK2mQ7xRb4Tn9WcYz3LpH6v","amount":24.9,"currency":"EUR","status":"awaiting_approval","description":"Order 1042"}

status is always awaiting_approval: nothing is charged yet. (Until 9 November 2026 it said completed.) Answer with status 200 and JSON within 10 seconds:

{ "resume": true }                                  // charge the customer
{ "resume": false, "error": "Out of stock" }        // refuse; the customer sees the error

Anything else (another status, no JSON, a timeout) refuses the payment. Callback URLs must use HTTPS, and lie under one of the callback URLs in your business settings: same host and port, and the same path or one below it. https://shop.example.com/hbank allows https://shop.example.com/hbank/callback, but not https://shop.example.com/hbankfoo.

Checking the signature

Every callback is signed with your business's signing secret (Business → your business → Callback URLs; you can replace it there). v1 is the hex HMAC-SHA256 of "<t>.<raw body>" with the secret, t the time in Unix seconds, like webhooks (the example above is signed with the secret hbcb_example). Refuse a callback whose signature doesn't match or whose t is more than 5 minutes off. Check it on the raw body, before parsing it.

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

app.post("/hbank/callback", express.raw({ type: "application/json" }), (req, res) => {
  const sig = Object.fromEntries((req.get("HBank-Signature") ?? "").split(",").map((p) => p.split("=")));
  const expected = createHmac("sha256", process.env.HBANK_CALLBACK_SECRET).update(`${sig.t}.`).update(req.body).digest("hex");
  const fresh = Math.abs(Date.now() / 1000 - Number(sig.t)) <= 300;
  if (!fresh || !sig.v1 || sig.v1.length !== expected.length || !timingSafeEqual(Buffer.from(sig.v1), Buffer.from(expected)))
    return res.json({ resume: false, error: "Invalid callback" });

  const cb = JSON.parse(req.body);
  res.json(orders.matches(cb.id, cb.amount) ? { resume: true } : { resume: false, error: "Out of stock" });
});

The SDKs do this for you (verify_signature / verifySignature / VerifySignature). Also check that id and amount match an order you created, and confirm with payment details before handing out goods.

GET /currency/convert   GET /currency/rate

Exchange rates as HBank uses them. Parameters go in the query string (or a JSON body).

curl "https://bank.thehsi.cloud/api/v1/currency/convert?amount=100&currency_from=EUR&currency_to=USD" \
  -H "Authorization: Bearer $HBANK_API_KEY"
{ "success": true, "amount": 108.37 }

curl "https://bank.thehsi.cloud/api/v1/currency/rate?currency_from=EUR&currency_to=USD" \
  -H "Authorization: Bearer $HBANK_API_KEY"
{ "success": true, "from_rate": 0.9228, "to_rate": 1.0837 }

to_rate converts currency_from into currency_to; from_rate the other way. Rates aren't rounded.

GET /currencies

Every currency HBank supports: the codes accepted wherever an endpoint takes a currency.

curl https://bank.thehsi.cloud/api/v1/currencies \
  -H "Authorization: Bearer $HBANK_API_KEY"
{ "success": true, "currencies": [
  { "code": "USD", "name": "United States Dollar", "symbol": "$", "decimal_places": 2 },
  { "code": "EUR", "name": "Euro", "symbol": "€", "decimal_places": 2 },
  { "code": "CHF", "name": "Swiss franc", "symbol": "CHF", "decimal_places": 2 }
] }

Statuses

pendingCreated, waiting to be paid.
completedPaid. reference is set. Final.
abortedThe customer closed the checkout without paying. Final.
declinedAn app the customer let into the checkout declined it (see Apps in the checkout). Final.

Fees

Payments of 100 or more (in the payment's currency) carry a 2% fee, paid by the customer on top of the amount; smaller payments are free. You receive the full amount, converted into your payout account's currency.

SDK changelog

Each build of hbank.js has its own address and never changes once published, so you can pin it with its integrity hash. Newest first. Moving to a newer build is a matter of replacing the script tag; the migration notes say what else, if anything.

Support: every build listed here is still served and works. A build that has to stop working is announced here at least 6 months before. The button frame and the checkout run on HBank's side, so changes there reach every build, pinned or not; they're listed below with their date.

v26w45.94828a9 9 November 2026 latest

Errors from your endpoint, a readable build.

  • An endpoint that can't create a payment can say so: a 4xx/5xx answer (with JSON {"error": "…"}) ends the payment as failed, reason endpoint_error, message your text. Before, the popup opened your error page and closed after 5 seconds with checkout_timeout.
  • A checkout HBank doesn't know (a wrong or deleted tid) fails with checkout_not_found.
  • In both cases your endpoint isn't called a second time.
  • Status objects have message.
  • Not obfuscated any more: minified with a source map, and a readable copy (links below).

Migrating: Optional: answer errors with a 4xx and JSON {"error": "…"} (see When the endpoint can't create a payment). Endpoints that only redirect need nothing.

<script src="https://bank.thehsi.cloud/assets/hbank.js?v=v26w45.94828a9"
        integrity="sha384-/61FBwv6TvRqKv9idlAtgXLSgOLmbLdWpI/2Pg2IrdhQ6axQ+FfNcOjkofiZzS+n" crossorigin="anonymous" defer></script>

Readable: /assets/hbank.src.js?v=v26w45.94828a9 · source map: /assets/hbank.js.map?v=v26w45.94828a9

v26w45.0675797 9 November 2026

The popup only shows HBank's pages.

  • On a click, the SDK requests your endpoint itself with fetch() and opens the checkout it redirects to; the popup shows HBank's loading page meanwhile, never your site.
  • If the lookup doesn't work (no redirect to the checkout, a CORS or network failure, a CSP without connect-src for HBank), it opens your endpoint in the popup like before.

Migrating: Allow HBank in your Content Security Policy's connect-src, and make sure your endpoint answers a plain GET (with your cookies) with a redirect to the checkout. See the contract.

<script src="https://bank.thehsi.cloud/assets/hbank.js?v=v26w45.0675797"
        integrity="sha384-G8d+C5/XhvSdng41aPTvNhmJs8J7HkPfj7dSm2a9iZ9LEspm8roQvH0tfbsIFYfH" crossorigin="anonymous" defer></script>

Obfuscated; no readable copy was kept for this build.

v26w44.0314dd3 2 November 2026

Your own endpoint, events, and waiting for the result.

  • The endpoint attribute: any path on your page's host (before: always /pay). It may change at any time.
  • The data attribute, passed to the endpoint as ?data=.
  • The hbank-payment event and waitForPayment(); statuses started, pending, paid, aborted, failed.

Migrating: Nothing required. Set endpoint to use another address than /pay.

<script src="https://bank.thehsi.cloud/assets/hbank.js?v=v26w44.0314dd3"
        integrity="sha384-VF4QDnjs8pWleXdzC25mHMFBPojhLCmvuyAcEMojH9aZ7nfux9C4e+bi5aV2+l3q" crossorigin="anonymous" defer></script>

Obfuscated; no readable copy was kept for this build.

v26w30.3a64958 2 August 2026

Maintenance build.

  • Same behaviour as v26w08 for your page.
<script src="https://bank.thehsi.cloud/assets/hbank.js?v=v26w30.3a64958"
        integrity="sha384-rnZvpL+XbXuwKgvLN3fQqb2VCuiX6lva5Zarf+o87cy+BE0NgEg2lkynCggo3pG3" crossorigin="anonymous" defer></script>

Obfuscated; no readable copy was kept for this build.

v26w30.db9b50e 2 August 2026

Maintenance build.

  • Same behaviour as v26w08 for your page.
<script src="https://bank.thehsi.cloud/assets/hbank.js?v=v26w30.db9b50e"
        integrity="sha384-9He5irMfZfZaXCHDHeH89eIMumCWLM6xfUi2s7ZfHDnCEsT/y0ScqJvzgwHCdCVx" crossorigin="anonymous" defer></script>

Obfuscated; no readable copy was kept for this build.

v26w13.47871e8 4 April 2026

Maintenance build.

  • Same behaviour as v26w08 for your page: always opens /pay.
<script src="https://bank.thehsi.cloud/assets/hbank.js?v=v26w13.47871e8"
        integrity="sha384-Vi/dkp7AbqndUB90WJD+BMtpJs7gX6lDTwQZCrOtfhGVD6qYQzHuhPADUixbBsFf" crossorigin="anonymous" defer></script>

Obfuscated; no readable copy was kept for this build.

v26w08.6e1b21f 28 February 2026

The first published build.

  • <hbank-pay-button> and getPaymentStatus(). A click opens /pay on your site in the checkout popup.
  • No detailed notes were kept for builds before v26w44; they behave alike.
<script src="https://bank.thehsi.cloud/assets/hbank.js?v=v26w08.6e1b21f"
        integrity="sha384-QvZIm4SrsWXPjRGSlZINYr/CH7bJU507v56cj/wWr6j92Er+qosz0NLRN/f51Tb6" crossorigin="anonymous" defer></script>

Obfuscated; no readable copy was kept for this build.

Changes on HBank's side (all builds)

11 November 2026: Transaction ids are random strings (all builds)

  • transaction_id is no longer a number that counts up but a random string like tx_8fK2mQ7xRb4Tn9WcYz3LpH6v: in the API's answers, in /api/payment?tid=…, in the callback's id, and in what the button reports. Store it as text (up to 40 characters).
  • /api/payment?tid=… only accepts the new id. payment/details, payment/code and payment/refund still accept the number of a payment made before, with your API key.
  • Nothing changes in the button itself: every build passes the id through as it is.
  • Subscriptions, accounts, cards and customers get random ids too: sub_…, acc_…, card_… and cus_… (strings, up to 40 characters). A subscription's id and the subscription_id in a payment's details are sub_…; GET /subscriptions/{id}, /cancel and /checkout take it; the number of a subscription isn't accepted any more. The same goes for the user API (/me, accounts, cards, from_account_id and to_account_id of a transfer), the webhooks' account_id, card_id and subscription_id, and what apps in the checkout are sent.

9 November 2026: Checkout lookups get an empty answer; callbacks are signed

  • /api/payment?tid=… answers a script's fetch() (and only that) with an empty 204 instead of JSON; page loads get the checkout. See the checkout entry.
  • Payment approval callbacks carry HBank-Signature, and "status": "awaiting_approval" instead of "completed". See Callbacks.
  • A payment an app of the customer's declines in the checkout (see Apps in the checkout) ends as failed with reason declined right away, instead of only aborted once the popup is closed.

9 November 2026: The checkout popup only ever shows HBank's pages (all builds)

  • Builds before v26w45 still open your endpoint in the popup, but it must now reach HBank's checkout within 5 seconds, or the button closes it and the payment fails with checkout_timeout. Before, there was no limit.
  • A popup that leaves HBank once it's there is closed at once: failed, left_checkout.
  • For v26w45 and newer: your endpoint gets 15 seconds to answer the lookup; the loading page says it's taking longer than usual after 5.

User API

Customers can use their own account from scripts and apps: their balances, history and subscriptions, and sending money. We don't recommend it to most customers: a token works without the password, two-factor sign-in and payment codes.

Every token has only the permissions it was given, so one can read the history while another only sends money. Each permission is a bit; a set of permissions is one number, the sum of their bits, and that number is the scope of the authorize link (names, space- or plus-separated, still work). The bits never change. Tick what you need, or type a number to see what it holds:

PermissionWhat it allowsBit
profile:read See your name and email address 1
accounts:read See your accounts, balances and cards 2
transactions:read See your transaction history 4
subscriptions:read See your subscriptions 8
subscriptions:cancel End your subscriptions 16
transfers:send Send money from your accounts, without a payment code 32
checkout:hook Hear about your payments in the checkout as they happen (the amount) 64
checkout:card See which card you pay with in the checkout · needs checkout:hook 128
checkout:merchant See which shop you pay in the checkout, and its account · needs checkout:hook 256
checkout:user See your name and email address when you pay · needs checkout:hook 512
checkout:page Show its own page while you pay, before the payment can go on · needs checkout:hook 1024
checkout:decline Decline your payments in the checkout · needs checkout:hook 2048
accounts:read transactions:read

Any checkout:… permission brings checkout:hook along. Checkout permissions are only for registered apps (with a checkout address), not personal tokens. Tokens and GET /me carry both forms: scope/permissions (names) and scope_bits/permission_bits (the number).

A personal token: Profile → Advanced → Create a personal token. Name it, pick its permissions, wait out the warning, confirm with the code from the email, and copy the token (it starts with hbu_ and is shown once). Send it like an API key:

Authorization: Bearer hbu_…

Cards. When a permission reaches cards or accounts (all but profile:read), the customer either allows all cards (including ones added later) or selects cards, and can change it at any time in Profile → Advanced. With selected cards, a token sees only those cards, the accounts they belong to, the transactions that went through them (or through no card on such an account) and the subscriptions paid with them; it can only send money from (and between) those accounts. Anything else answers as if it didn't exist. GET /me says which: "card_access": "all" or "selected".

An endpoint the token has no permission for answers 403 with {"success": false, "error": "missing_permission", "permission": "…"}; a missing, unknown or revoked token 401.

Registering an app

An app other customers can let in needs registering first, like a GitHub OAuth app: Profile → Advanced → Your apps (for developers) (/profile/apps). Give it a name (customers see it), optionally a description and homepage, and the redirect addresses customers may be sent back to (HTTPS, exact match, up to 5). You get

  • a client ID (app_…): public, it goes in the link;
  • a client secret (hbs_…): shown once, kept on your server. You can make a new one at any time.

If you own a business, you can publish the app under it (Published by, when registering or in the app's settings): customers then see the business as its developer, on the consent page and in their settings, and the business's page lists it. You keep managing the app.

The app's page shows how many customers use it and how old it is; customers see the same on the consent page, and a warning while the app is less than 30 days old. Deleting the app revokes everyone's access.

Letting an app in

Send the customer to

https://bank.thehsi.cloud/authorize?client_id=app_…&redirect_uri=https://your.app/callback&scope=6&state=RANDOM

redirect_uri must be one of the app's; it can be left out when the app has only one. They see a full-screen page with your app's name, description, how many people use it and how old it is, the permissions, which cards it may see, a warning they have to read for 10 seconds (3 seconds and a milder note when you only ask for …:read permissions), and confirm with a code from their email. Ask only for what you need. Then they come back to

https://your.app/callback?code=ONE_TIME_CODE&state=RANDOM

(or ?error=access_denied&state=… when they cancel). Check state, then, from your server, exchange the code within 5 minutes, once:

POST https://bank.thehsi.cloud/api/v1/oauth/token
Content-Type: application/x-www-form-urlencoded

code=ONE_TIME_CODE&redirect_uri=https://your.app/callback&client_id=app_…&client_secret=hbs_…

(The client ID and secret may also go in an Authorization: Basic header.)

{"success": true, "access_token": "hbu_…", "token_type": "bearer", "scope": "accounts:read transactions:read", "scope_bits": 6}

A missing client ID or secret: 401 invalid_client. A wrong secret, a wrong, used or expired code, another app's code or another redirect_uri: 400 invalid_grant. A customer who lets the app in again replaces its earlier access; they can revoke it at any time.

User endpoints

EndpointPermission
GET /meanyThe customer's id, the token's permissions and card_access; name, email and plan with profile:read (else null).
GET /me/accountsaccounts:readAccounts with balance and cards.
GET /me/transactionstransactions:readNewest first. account_id (an account's id), limit (up to 100), before (the next_before of the last page, a transaction id). direction is out (amount with fees) or in (what arrived, in the receiving account's currency).
GET /me/subscriptionssubscriptions:readAll subscriptions.
POST /me/subscriptions/{id}/cancelsubscriptions:cancelEnds it; it runs until the paid period ends.
POST /me/transferstransfers:sendJSON from_account_id (an account's id, like acc_…), amount, note, and to_card_number (anyone's card) or to_account_id (an own account's id). Returns the reference.

Apps in the checkout

An app with checkout permissions takes part in the payments of the customers who let it in: a budget guard can stop a payment, a parental-control app can ask first, a loyalty app can show something. It works for every payment in HBank's checkout, a subscription's first payment included (not for automatic renewals, which have nobody to show a page to). Set your app's checkout address on its page (Settings); a signing secret appears under Checkout.

1. HBank asks your server

After the customer entered card and PIN (and the code from the email, if they ask for one), and before they confirm, HBank POSTs to your checkout address, once per payment and app. Only payments with a card the customer let your app see (all cards, or the selected ones) are sent. With several apps, they're asked in the order they were let in.

POST https://your.app/hbank/checkout
HBank-Event: checkout
HBank-Signature: t=1700000000,v1=HMAC-SHA256(signing secret, "1700000000.<body>")

{
  "type": "checkout",
  "step_id": "cs_…",
  "payment": {"amount": 12.5, "currency": "EUR", "subscription": null},
  "card": {"id": "card_8fK2…", "number": "DE •••• •••• 01", "label": "Main card", "account_id": "acc_Zq7…"}, // checkout:card
  "merchant": {"id": 2, "name": "Test Shop", "account_id": "acc_Vd5…", "card_number": "DE •••• •••• 99"}, // checkout:merchant
  "user": {"id": "cus_Xe0…", "name": "Ada Lovelace", "email": "ada@example.com"},             // checkout:user
  "permissions": ["checkout:hook", "checkout:card", …],
  "permission_bits": 1216
}

subscription is {"interval": "month", "interval_count": 1} for a subscription's first payment. subscriptions lists every subscription the payment starts (amount, currency, interval, interval_count, description): one, or several when a merchant puts more than one in a checkout (subscription is then null); null for an ordinary payment. Check the signature (and that t is recent) like a webhook's.

2. You answer, within 5 seconds

{"action": "continue"}Nothing to add: the payment goes on.
{"action": "decline", "reason": "Over your weekly budget"}Needs checkout:decline. The payment is declined; the customer sees "Your App declined this payment: …" (the reason, up to 200 characters, is optional).
{"action": "page", "url": "https://your.app/hbank/ask?step=cs_…", "continue_button": true, "resume": "page"} Needs checkout:page. Your page is shown as a step of the checkout (below). url must be on your checkout address's scheme, host and port. continue_button (default true): the customer also gets HBank's Continue button; false: only you can let the payment go on (the customer can still cancel it). resume: page (default; your page or your server can resume) or server (only your server).

No answer in time, an error status, unknown JSON, or an action you don't have the permission for: your app is passed over and the payment goes on. A decision that must hold (a parent's approval) belongs on your server: "continue_button": false, "resume": "server".

3. Your page in the checkout

HBank fetches your page and shows it in the checkout in an iframe, under a banner of its own that names your app and says the step isn't HBank's. /checkout/frame/cs_…/p/<path> is <path> on your host, so relative links, your page's own files and forms (GET and POST) work; root-relative (/…) and other hosts' addresses don't. Your server sees neither the customer's cookies nor IP: requests come from HBank with HBank-Checkout-Step: cs_… and HBank-Signature: t=…,v1=HMAC(secret, "t.cs_…"). Cookies you set aren't passed on; carry what you need in the address. The page is sandboxed (scripts and forms run, with no access to HBank's page) and works for 30 minutes. Redirects stay within your host. HTML, CSS, JavaScript, JSON, images and fonts up to 2 MB.

Your page gets a small API:

HBank.checkout.step           // "cs_…"
HBank.checkout.resume()       // let the payment go on (with "resume": "page")
HBank.checkout.decline(reason) // decline it (checkout:decline)

These run in the customer's browser. From your server, with the customer's token:

EndpointPermission
GET /checkout/steps/{step_id}checkout:hookstatus (continued, page, resumed, declined, failed), resolved_by, payment_status.
POST /checkout/steps/{step_id}/resumecheckout:pageLets the payment go on; the checkout notices within seconds.
POST /checkout/steps/{step_id}/declinecheckout:declineJSON reason (optional). Declines the payment.

A step that's already resumed or declined answers 409 step_closed. A declined payment can't be paid any more and shows in the customer's history as declined by your app.

Webhooks

Customers add up to five webhooks in Profile → Advanced, each with the events it gets:

transaction.createdA payment or transfer from one of their accounts (card payments, sent money, paid requests, subscription renewals).
money.receivedMoney arrived from someone else.
subscription.createdThey subscribed to something.
settings.changedA setting changed: data.setting says which (profile, password, two_factor, banking, webhook.created…).
login.newA sign-in to online banking, with IP, location and whether it's a new place.
pingThe Send test button.

Each is a POST with a JSON body {"id": "evt_…", "type": "…", "created_at": "…", "data": {…}} and the headers HBank-Event, HBank-Delivery (the id) and

HBank-Signature: t=UNIX_TIME,v1=HEX

where v1 is HMAC-SHA256 with the webhook's signing secret over t + "." + body. Check it, and reject old ts. Answer with a 2xx; anything else is tried again after 10 seconds and after a minute.