Double-entry ledger
Definition
A double-entry ledger records each business event as a transaction of immutable entries across two or more accounts whose amounts sum to zero; balances are derived from the entries.
In practice
Because every transaction balances, money cannot appear or vanish unnoticed, and the sum of all accounts is always zero. Entries are never updated or deleted: refunds, chargebacks and fixes are new transactions, which gives a complete audit trail. Balances can be cached in rows updated in the same database transaction.
A strongly consistent relational database is the usual home, which caps write throughput on hot accounts; very large systems partition by account. Floating-point amounts cause rounding errors, so store integer minor units with a currency. The ledger records what you believe happened; reconciliation checks it against the outside world.
Example
A 50.00 EUR payment writes customer_funds -5000 and merchant_payable +5000 in one transaction; a refund adds the reverse pair rather than deleting the first.