Fintech & Banking
Payment Systems Fundamentals: Ledgers, Clearing and Settlement
Beginner9 min readReviewed by Mariem Ouled on Updated
A payment is not money travelling down a wire — it is an obligation being transferred and then discharged between institutions. This guide builds the mental model an engineer needs: accounts and double-entry ledgers, the instrument families, the difference between clearing and settlement, how account identifiers and message formats are constructed, and the software concerns that make payment systems hard.
What you will learn
- Describe a payment as a transfer of obligations recorded in ledgers rather than a movement of physical value
- Apply double-entry bookkeeping to model balances, holds and reversals in software
- Distinguish push and pull instruments, and clearing from settlement in gross and net systems
- Read an IBAN, verify its check digits, and recognise the shape of an ISO 20022 message
- Design a payment service that is idempotent, auditable and reconcilable
Most software engineers meet payments through an API: post a request, get a status back, hope it says ACCEPTED. That view survives until the first production incident — a duplicate debit, a payment stuck in PENDING for two days, a reconciliation file that does not balance — and then the abstraction has to be opened up. Underneath the API there is a chain of institutions, ledgers, cut-off times and legal obligations, and almost every awkward behaviour in a payment API is an honest reflection of something real in that chain.
This guide builds the model from the bottom. It deliberately stays away from cards, which have their own four-party choreography and are covered in card payments, and away from the regulated third-party access introduced by European legislation, covered in PSD2 and open banking. What follows is the substrate all of those sit on.
A payment is a transfer of obligations
The balance shown in a banking app is not a box of money with your name on it. It is a liability: an amount the institution owes you, repayable on demand. When you pay someone at another institution, no value is teleported. Your bank reduces what it owes you and simultaneously takes on an obligation towards the beneficiary's bank; the beneficiary's bank increases what it owes its customer. The two banks are now out of position with each other, and that imbalance has to be squared up separately.
That squaring up happens in central bank money — balances the commercial banks hold at their central bank, which is the only claim in the system that carries no counterparty credit risk. Everything a retail user experiences is commercial bank money, a claim on a private institution. The distinction explains a great deal: why a bank failure is contagious, why settlement systems are run by public institutions, and why "the payment has been sent" and "the payment is final" are different statements.
Three roles recur in every scheme: the payer (whose account is debited), the payee or beneficiary (whose account is credited), and one or more payment service providers acting for them. A scheme is the rulebook the providers agree to: message formats, timings, liability, and what happens when something goes wrong.
Accounts, ledgers and double entry
The core data structure of every payment system is a ledger, and the discipline that keeps it honest is double-entry bookkeeping. Every economic event is recorded as two or more postings whose signed amounts sum to zero. Nothing is ever updated in place; corrections are new entries. A balance is not a column you overwrite, it is the sum of the postings against an account.
Transaction T-8841 — customer pays 250.00 EUR to a supplier
account debit credit
---------------------------------------------
customer:4711 250.00
clearing:sepa-outbound 250.00
------ ------
250.00 250.00 -> balanced
The conventions confuse newcomers because they are written from the institution's point of view: a customer's deposit is a liability of the bank, so crediting the customer account increases what the bank owes. Rather than argue about signs, most engineering teams store a signed integer in minor units (cents, not floats) and a direction flag, and derive the accounting presentation later.
A ledger schema that survives audit tends to look like this:
CREATE TABLE ledger_entry (
id BIGSERIAL PRIMARY KEY,
transaction_id UUID NOT NULL,
account_id BIGINT NOT NULL,
amount_minor BIGINT NOT NULL, -- signed, in minor units
currency CHAR(3) NOT NULL,
booked_at TIMESTAMPTZ NOT NULL DEFAULT now(),
value_date DATE NOT NULL
);
CREATE INDEX ON ledger_entry (account_id, booked_at);
-- invariant, enforced in the write path and re-checked by a nightly job:
-- SELECT transaction_id FROM ledger_entry
-- GROUP BY transaction_id, currency HAVING SUM(amount_minor) <> 0;
Two details matter more than they look. Never mix currencies inside one balanced transaction without an explicit exchange account, otherwise the zero-sum invariant is meaningless. And distinguish booked_at (when your system recorded the entry) from value_date (when the money is economically effective) — interest, cut-offs and disputes all depend on the second, not the first. Holds and authorisations are modelled as postings to a dedicated reserved-funds account, so an available balance is a query over the ledger rather than a mutable field that can drift. The design considerations here overlap heavily with database design and normalisation; append-only tables with derived aggregates are the norm.
The instrument families
Instruments differ mainly in who initiates, who bears the risk of reversal, and how long finality takes.
| Instrument | Initiated by | Typical finality | Reversal risk |
|---|---|---|---|
| Credit transfer | Payer (push) | Same or next business day | Very low once credited |
| Instant credit transfer | Payer (push) | Seconds, irrevocable | None by design |
| Direct debit | Payee (pull, under a mandate) | Days, with a refund window | High during the refund window |
| Card payment | Payee, on the payer's authorisation | Days to settlement | Chargeback risk for months |
| Cheque | Payer, on paper | Days, subject to return | High until cleared |
| Wallet or account-to-account app | Either, over an underlying rail | Depends on the rail beneath | Inherited from the rail |
The push versus pull distinction is the one to internalise. A push instrument cannot overdraw an account the payer does not control, so fraud tends to be social engineering. A pull instrument lets a merchant reach into an account, so schemes compensate with mandates, pre-notification and generous refund rights — which is why a direct debit collection is not revenue you can safely recognise on day one. A wallet is not a separate rail at all; it is a user experience layered on cards, transfers or a stored balance, and its risk profile is whatever sits underneath.
Clearing versus settlement
Clearing is the exchange and validation of instructions between institutions, including the calculation of who owes what. Settlement is the final discharge of those obligations. Systems differ in how they combine the two.
A real-time gross settlement (RTGS) system settles each instruction individually and immediately in central bank money. There is no netting and no credit exposure between participants, but every payment must be funded at the moment it is made, so participants need large intraday liquidity. High-value and time-critical payments run this way.
A deferred net settlement system accumulates instructions over a cycle and settles only the net positions.
Gross obligations during one clearing cycle (millions)
A -> B 40 B -> A 25 A -> C 30
C -> A 15 B -> C 20 C -> B 35
Multilateral net positions
A: pays 70, receives 40 -> -30 (must fund 30)
B: pays 60, receives 75 -> +15
C: pays 50, receives 65 -> +15
----
sum of net positions 0 (always true)
Gross value exchanged 165, actual settlement 30 -> ~82% liquidity saving
Netting is enormously efficient and correspondingly risky: between the moment an instruction is cleared and the moment the cycle settles, participants are exposed to each other. Modern systems mitigate this with prefunding, collateral, loss-sharing rules and shorter cycles. Whenever you see an unfamiliar constraint in a payment scheme — cut-off times, ceilings on amounts, mandatory prefunding — it usually traces back to managing that window.
Identifying the account: IBAN and BIC
An IBAN identifies an account internationally: a two-letter country code, two check digits, then the national account identifier (the BBAN), up to 34 characters. Its best feature is that a typo can be caught client-side, before any money moves, using a mod-97 check defined in the ISO standard.
IBAN: GB11 ABCD 1234 5678 9012 34
1. Move the first four characters to the end:
ABCD12345678901234 GB11
2. Replace each letter by its position in the alphabet + 9 (A=10 ... Z=35):
1011121312345678901234161111
3. Take that (very large) integer modulo 97:
1011121312345678901234161111 mod 97 = 1
4. A remainder of exactly 1 means the check digits are consistent.
To generate the check digits instead, place 00 in their position, compute the remainder of the rearranged string, and use 98 - remainder. Because the number exceeds any native integer type, implementations fold it in chunks:
static int mod97(String rearranged) {
int remainder = 0;
for (int i = 0; i < rearranged.length(); i++) {
char c = rearranged.charAt(i);
int value = Character.isDigit(c) ? c - '0' : c - 'A' + 10;
remainder = (remainder * (value > 9 ? 100 : 10) + value) % 97;
}
return remainder;
}
// valid when mod97(iban.substring(4) + iban.substring(0, 4)) == 1
A valid check digit proves only that the string is internally consistent — not that the account exists, is open, or belongs to the person named. A BIC (sometimes still called a SWIFT code) identifies the institution rather than the account: four letters for the institution, two for the country, two for the location and an optional three-character branch suffix. Within many domestic and European flows the BIC is now derived rather than supplied.
SEPA, correspondent banking and ISO 20022
Within the euro area, the Single Euro Payments Area harmonised euro payments into a small set of schemes governed by public rulebooks: a credit transfer scheme, a direct debit scheme in core and business-to-business variants, and an instant credit transfer scheme that delivers funds within seconds, around the clock, up to a scheme ceiling. The engineering consequence of instant schemes is severe: there is no overnight batch window in which to run fraud checks, sanctions screening and liquidity management, so all of it must happen inline, in a few hundred milliseconds, with no option to say "we will fix it tomorrow".
Cross-border payments outside a common scheme use correspondent banking. A bank that has no account with the destination bank routes through an intermediary with which it holds accounts — a nostro account (our money held with them) mirrored by their vostro account. Each hop adds a fee, a cut-off and a screening step, which is why traditional cross-border payments are slow and why tracking them is a product in itself.
Messaging across all of these is converging on ISO 20022, a data dictionary plus XML (and increasingly JSON) message definitions with names such as pain.001 (customer credit transfer initiation), pacs.008 (interbank credit transfer) and camt.053 (bank-to-customer statement). Compared with the older fixed-line telex-era formats, it carries structured parties, remittance information and rich purpose codes, which makes automatic reconciliation and screening far more accurate.
<CdtTrfTxInf>
<PmtId><EndToEndId>INV-2026-000871</EndToEndId></PmtId>
<Amt><InstdAmt Ccy="EUR">1250.00</InstdAmt></Amt>
<Cdtr><Nm>Beneficiary Company Ltd</Nm></Cdtr>
<CdtrAcct><Id><IBAN>GB11ABCD12345678901234</IBAN></Id></CdtrAcct>
<RmtInf><Ustrd>Invoice 2026-000871</Ustrd></RmtInf>
</CdtTrfTxInf>
Note EndToEndId: a reference chosen by the originator that every institution must carry unchanged to the beneficiary. It is the hook that makes end-to-end reconciliation possible, and passing a random UUID there instead of your own business reference is a mistake you will regret at month-end.
Writing payment software that survives
A payment service is a distributed system in which one participant — the outside world — never rolls back. Four habits do most of the work.
Be idempotent at the boundary. Every instruction carries a client-supplied key; the server stores it with the resulting payment and returns the original response on any retry. Without this, a socket timeout becomes a double debit.
POST /v1/payments HTTP/1.1
Content-Type: application/json
Idempotency-Key: 4f0a2c1e-9d3b-4a77-8c0e-6a1f7b2d5c93
{"debtorAccount":"GB11ABCD12345678901234",
"amount":{"currency":"EUR","value":"1250.00"},
"endToEndId":"INV-2026-000871"}
Model the payment as an explicit state machine. RECEIVED → VALIDATED → SUBMITTED → SETTLED, with REJECTED and RETURNED as terminal branches, and every transition written to the ledger and an audit log. Resist the urge to collapse states; "sent to the scheme" and "confirmed by the scheme" carry different liability.
Never trust a single system of record. Reconcile your ledger against the account statements the scheme or correspondent sends, every day, automatically, and alert on any break rather than any difference in totals — a two-sided error can net to zero and still be two errors. This is where a structured EndToEndId earns its keep.
Prefer messaging semantics you can defend. Payment rails deliver at least once and occasionally out of order; deduplication and ordering are your problem, exactly as described in messaging patterns and guarantees. Where a business operation spans services, use compensating transactions rather than two-phase commit across institutional boundaries, as discussed in distributed transactions and consistency.
Two closing cautions. Money is never a floating-point number: store minor units as integers and carry the currency alongside, because rounding rules differ by currency and by scheme. And treat cancellation as a request, not a command — once an instruction has been passed to a scheme, the only honest API is "recall requested", whose outcome depends on another institution's goodwill.
Key takeaways
- A payment transfers an obligation between institutions; what actually moves between them is a message, with the imbalance discharged later in central bank money.
- Double-entry ledgers with append-only postings in integer minor units give you balances, holds, reversals and an audit trail that reconciles.
- Push instruments protect the payer, pull instruments protect the payee with mandates and refund windows — pick with the reversal risk in mind.
- Clearing agrees who owes what; settlement discharges it. Gross settlement removes credit risk at the cost of liquidity, netting does the reverse.
- IBAN check digits catch typos client-side, and ISO 20022 messages carry the structured references that make reconciliation automatic.
- Idempotency keys, explicit state machines, daily reconciliation and compensating transactions are the four habits that keep a payment service honest.
Sources and further reading
Frequently asked questions
- Does money actually move when I make a bank transfer?
- No physical value moves anywhere. Your bank reduces the balance it owes you and takes on an obligation towards the beneficiary's bank; that obligation is later discharged when the two banks exchange central bank money in a settlement system. What travels between the institutions is a message describing the obligation, not the value itself.
- What is the difference between clearing and settlement?
- Clearing is the exchange, validation and often netting of payment instructions between institutions: agreeing who owes what. Settlement is the final, irrevocable discharge of those positions, normally by debiting and crediting accounts held at a central bank. A payment can be cleared within seconds and settled hours later, which is exactly where credit risk lives.
- Why do payment APIs insist on an idempotency key?
- Networks time out, clients retry, and a duplicated instruction means a duplicated debit that must then be refunded manually. An idempotency key lets the server recognise a retry of the same logical instruction and return the original outcome instead of creating a second payment. It turns an at-least-once transport into effectively-once business behaviour.
- Is an instant payment settled instantly?
- In an instant scheme the beneficiary receives irrevocably usable funds within seconds, and the scheme guarantees that outcome, but the interbank leg may settle on a prefunded or continuous basis behind the scenes. The user-visible finality and the interbank settlement mechanics are separate things, which is why instant schemes impose strict prefunding or liquidity rules.