Decode a bank's callback without credentials, in a module of its own #2

Open
opened 2026-11-21 06:27:34 +00:00 by jorijnvdgraaf · 0 comments

When bunq pushes a callback, something has to turn the body it POSTs into a payment: the bank's id, an amount, a description, how it arrived, and the account it is about. Nostro has that knowledge for the payment list (GetNewTransactions in implementations/Nostro-Bunq.cpp) but not for a callback, and what it has cannot be used where a callback arrives.

Why it cannot be used there

A callback goes to a public HTTPS endpoint, and that host is the one that should hold no bank credential. So the receiver has no connector, and it cannot ask nostrod either, which runs on another machine. It needs the decoding alone.

It also cannot link the library as it is built today. --lib brings Crafter.Network at a pinned commit with --no-quic, Crafter.DB and OpenSSL. A server that already builds Crafter.Network another way (the catcrafts.net server follows its branch, with QUIC) has its build stopped by crafter-build, for two loads of one dependency that disagree. Nostro.Checkout solved the same problem by being a module of its own with no bank code in it.

Who needs it

The catcrafts.net shop server. bunq pushes each incoming payment to it, the server decodes the payment and records a credit, and the order settles from that. The decoding is bunq code that lives in the shop today: ParseBunqCallback and ParseSignedAmountToMinor in Catcrafts.Server-Bunq.cpp, with their cases in ShouldParseBunqPayments. It is the last bunq code that would remain there once the shop reads through nostrod and registers its callback through Nostro (#1).

What arrives

A MUTATION callback, reduced to the fields the shop reads, with made-up values. bunq's production callbacks have decoded with this shape since 2026-08:

{"NotificationUrl": {"category": "MUTATION", "object": {"Payment": {
    "id": 4155999,
    "type": "EBA_SCT",
    "description": "order 1234",
    "amount": {"currency": "EUR", "value": "570.43"}
}}}}

Outgoing payments come with a negative value. The Payment looks like the object the payment list returns, so the rest of it (created, sub_type, counterparty_alias, the account's own alias) should be there too, but the shop has only ever read the four fields above: check it against a real callback. Other categories carry other objects, or none.

What it would take

  • A library of its own, built by a --product= as the checkout is, that needs no connector, no network, no OpenSSL and no Crafter.DB. lib/json.hpp is enough to read the body.
  • One call: the body of a callback in, and out what kind of event it is and, when it carries a payment, that payment in Nostro's terms: the bank's id, the amount in minor units with its sign, the currency, the description, the time, the bank's kind, and the IBAN of the account it is about, so a receiver can tell one account's payments from another's.
  • Strict reading, because bunq does not sign a callback and anyone who learns the URL can POST to it. An id is required (bunq retries, and the id is what a receiver deduplicates on), an amount that does not parse is refused rather than read as zero, another currency is not read as euro, and nothing is guessed.
  • Its documentation should say what the result is worth: a hint that something happened. A receiver that releases goods on it should confirm with the bank first.

To decide

  • Transaction and Currency are partitions of the module Nostro, which a credential-free module cannot import without the rest of it. Either the new module has types of its own, as the checkout does, or those two move somewhere both can import.
  • Whether one call should cover every bank's callbacks, taking the bank's name, so that a receiver's code names no bank.
When bunq pushes a callback, something has to turn the body it POSTs into a payment: the bank's id, an amount, a description, how it arrived, and the account it is about. Nostro has that knowledge for the payment list (`GetNewTransactions` in `implementations/Nostro-Bunq.cpp`) but not for a callback, and what it has cannot be used where a callback arrives. ## Why it cannot be used there A callback goes to a public HTTPS endpoint, and that host is the one that should hold no bank credential. So the receiver has no connector, and it cannot ask nostrod either, which runs on another machine. It needs the decoding alone. It also cannot link the library as it is built today. `--lib` brings Crafter.Network at a pinned commit with `--no-quic`, Crafter.DB and OpenSSL. A server that already builds Crafter.Network another way (the catcrafts.net server follows its branch, with QUIC) has its build stopped by crafter-build, for two loads of one dependency that disagree. `Nostro.Checkout` solved the same problem by being a module of its own with no bank code in it. ## Who needs it The catcrafts.net shop server. bunq pushes each incoming payment to it, the server decodes the payment and records a credit, and the order settles from that. The decoding is bunq code that lives in the shop today: `ParseBunqCallback` and `ParseSignedAmountToMinor` in [`Catcrafts.Server-Bunq.cpp`](https://forgejo.catcrafts.net/Catcrafts/catcrafts.net/src/commit/80668e18cdd942c3c0ce4883f14264f376067589/server/implementations/Catcrafts.Server-Bunq.cpp#L132-L224), with their cases in [`ShouldParseBunqPayments`](https://forgejo.catcrafts.net/Catcrafts/catcrafts.net/src/commit/80668e18cdd942c3c0ce4883f14264f376067589/tests/ShouldParseBunqPayments/main.cpp). It is the last bunq code that would remain there once the shop reads through nostrod and registers its callback through Nostro (#1). ## What arrives A `MUTATION` callback, reduced to the fields the shop reads, with made-up values. bunq's production callbacks have decoded with this shape since 2026-08: ```json {"NotificationUrl": {"category": "MUTATION", "object": {"Payment": { "id": 4155999, "type": "EBA_SCT", "description": "order 1234", "amount": {"currency": "EUR", "value": "570.43"} }}}} ``` Outgoing payments come with a negative `value`. The `Payment` looks like the object the payment list returns, so the rest of it (`created`, `sub_type`, `counterparty_alias`, the account's own `alias`) should be there too, but the shop has only ever read the four fields above: check it against a real callback. Other categories carry other objects, or none. ## What it would take - A library of its own, built by a `--product=` as the checkout is, that needs no connector, no network, no OpenSSL and no Crafter.DB. `lib/json.hpp` is enough to read the body. - One call: the body of a callback in, and out what kind of event it is and, when it carries a payment, that payment in Nostro's terms: the bank's id, the amount in minor units with its sign, the currency, the description, the time, the bank's kind, and the IBAN of the account it is about, so a receiver can tell one account's payments from another's. - Strict reading, because bunq does not sign a callback and anyone who learns the URL can POST to it. An id is required (bunq retries, and the id is what a receiver deduplicates on), an amount that does not parse is refused rather than read as zero, another currency is not read as euro, and nothing is guessed. - Its documentation should say what the result is worth: a hint that something happened. A receiver that releases goods on it should confirm with the bank first. ## To decide - `Transaction` and `Currency` are partitions of the module `Nostro`, which a credential-free module cannot import without the rest of it. Either the new module has types of its own, as the checkout does, or those two move somewhere both can import. - Whether one call should cover every bank's callbacks, taking the bank's name, so that a receiver's code names no bank.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
Catcrafts/Nostro#2
No description provided.