Reconciliation & Settlement
- Explain why reconciliation is mandatory even in a "correct" system, and what classes of error it catches.
- Distinguish internal reconciliation (ledger vs sub-systems) from external reconciliation (PSP settlement files, bank statements, scheme reports).
- Apply exact, tolerant (fuzzy) and many-to-one matching, and classify breaks.
- Design a reconciliation service: ingestion, normalization, matching engine, exception workflow and adjustments.
- Choose between T+1 batch and near-real-time reconciliation for a given flow.
TL;DR
- Reconciliation compares two or more independent records of the same money and explains every difference. It is how you find out that something went wrong in a distributed system you don't fully control.
- Internal: ledger vs payment service vs order service vs GL. External: your records vs PSP/acquirer settlement reports, bank statements (MT940/camt.053), scheme or switch reports (e.g. NAPAS).
- A typical marketplace runs a three-way match: orders/payments (internal) ↔ PSP transaction report ↔ bank statement credit (the net payout).
- Matching strategies: exact on a reference, tolerant (amount within FX tolerance, date within a window), and many-to-one / one-to-many (one bank credit = a PSP batch of many transactions minus fees and refunds).
- Unmatched items are breaks: missing internally, missing externally, amount mismatch, duplicate, or timing (in transit). Each one gets an owner, an age and a resolution. Adjustments go through the ledger using suspense accounts, never by editing data.
- T+1 batch is still the default because external files arrive daily. Near-real-time matching on event streams catches problems in minutes, and the daily file stays the final word.
Why it matters
Every component in a payment flow can be individually "correct" and still disagree with the others. A PSP timed out but charged the card. A webhook was lost. A refund was processed twice by an operator. A bank posted a payout with a different value date. An FX conversion used a slightly different rate. Without reconciliation, those differences stay invisible until a customer complains or the auditor finds a hole in the balance sheet.
In banks, reconciliation is a regulatory and audit expectation: nostro accounts, card settlement, ATM cash, interbank clearing (for example against NAPAS reports), and GL vs sub-ledger all get reconciled daily. In e-commerce, it decides whether you pay sellers the right amount and whether "paid" orders really were paid. Interviewers like it because it shows whether you accept that distributed systems fail and plan for detection and repair, rather than assuming exactly-once everywhere.
Core concepts
What gets reconciled against what
| Reconciliation | Sources | Typical frequency | What it catches |
|---|---|---|---|
| Payment ↔ ledger | Payment service, ledger postings | Continuous or hourly | Missed or duplicate postings, failed outbox events |
| Sub-ledger ↔ GL | Customer account totals, GL control accounts | Daily | Missing GL mappings, manual GL journals |
| Transactions ↔ PSP report | Our payment attempts, PSP transaction-level report | Daily (T+1) | Unknown-outcome payments, captures we didn't record, fees different from contract |
| PSP payout ↔ bank statement | PSP settlement summary, bank statement line | Daily | Payouts not received, wrong net amount, withheld reserves |
| Interbank / switch ↔ bank | Switch settlement report, our postings | Per settlement cycle or daily | Transfers we think failed but the switch settled, and vice versa |
| Cash (ATM, branch) | Device counters, vault records, postings | Daily / on replenishment | Dispense errors, theft, posting errors |
Anatomy of a settlement file
PSP and acquirer reports differ, but usually contain:
- Transaction-level rows: PSP reference, merchant reference (your payment id or order id), type (capture, refund, chargeback, fee, adjustment), gross amount, currency, fees (interchange, scheme, PSP markup), net amount, transaction date, settlement date, batch or payout id.
- Payout summary: payout id, total gross, total fees, total refunds and chargebacks, reserve held or released, net amount paid to your bank, expected value date.
Bank statements (ISO 20022 camt.053 end-of-day, camt.054 intraday notifications, or legacy SWIFT MT940/MT942) list each credit and debit with amount, value date, bank reference and a remittance field that may or may not contain the payout id.
Matching strategies
Exact match on a key. The best case: your payment id travels through the PSP and comes back as merchant_reference. Match on (reference, type, amount, currency).
Tolerant (fuzzy) match. Needed when keys are missing or mangled:
- Amount within a tolerance (FX rounding, a few units of currency).
- Date within a window (T to T+3) because of cut-offs and weekends.
- Normalized references: strip spaces and punctuation, uppercase, extract an order-id pattern from free text such as "CK DH 12345 NGUYEN VAN A".
- Score candidates and auto-match only above a confidence threshold. Below it, propose the match to a human.
Many-to-one / one-to-many.
- One bank credit of 97,450,000 VND = the PSP payout for 1,203 captures minus fees minus 14 refunds minus 1 chargeback. You match the bank line to the payout summary (one-to-one), then the payout summary to its transaction rows (one-to-many), then each row to your payments (one-to-one).
- One order paid by two attempts or two methods (wallet + card) = many-to-one on the internal side.
- Batch payouts to sellers: one bank debit = many seller payouts.
(101,200,000 − 2,150,000 − 600,000 − 1,000,000 = 97,450,000. Illustrative numbers.)
Breaks and exception handling
A break is anything that doesn't match. Classify each one, because the class decides who fixes it and how:
| Break type | Example | Usual cause | Resolution |
|---|---|---|---|
| Missing internally | PSP shows a capture we have as UNKNOWN or don't have at all | Timeout, lost webhook | Update payment state from evidence, fulfil or refund the order |
| Missing externally | We show captured, PSP has nothing | Capture call never reached the PSP, or it's in the next file | Wait one cycle (timing), then retry the capture or cancel |
| Amount mismatch | We expect a fee of 20,000, PSP charged 22,000 | Contract or fee schedule change, FX | Post the difference to an expense or receivable, raise it with the PSP |
| Duplicate | Two captures for one payment | Retry with a new key, operator error | Refund the duplicate, fix the root cause |
| Timing | Captured at 23:58, PSP books it next day | Cut-off differences | Auto-carry forward. Alert only if still open after N days |
| Unexplained bank line | Credit with no payout reference | Customer bank transfer with bad reference, misdirected funds | Suspense account, investigation, return funds if unclaimed |
Exception workflow essentials:
- Auto-resolution rules for known patterns (timing breaks that clear the next day, small FX tolerances posted to an FX difference account).
- Ownership and aging: every open break has an assignee, a category and an age. Dashboards show amount and count by age bucket (0–1 days, 2–7, 8–30, 30+). Old breaks are a finance and audit risk.
- Adjustments through the ledger: a resolved break produces a journal entry (for example debit PSP fee expense, credit Receivable from PSP) with a reference to the break id. Unexplained money sits in a suspense account until resolved. Suspense balances must trend to zero.
- Maker-checker for manual matches and adjustments above a threshold (see Compliance).
- Feedback into systems: breaks are bug reports. A recurring "missing internally" break pattern means a webhook or inquiry path is broken, so fix the cause, not only the data.
A second axis: can you explain it, and is the fix worth automating? The table above sorts breaks by what happened. To decide where each one goes, also ask whether its cause is known and whether coding the fix pays off. The payment chapter of System Design Interview Vol. 2 sorts mismatches this way (see Ch 11 · Payment System):
| Cause known? | Automate the fix? | Route to | Example |
|---|---|---|---|
| Yes | Yes: frequent, rule-based, cheap to code | An auto-adjust job after each matching run, posting entries linked to the break id | Lost webhook: the PSP captured, we still show UNKNOWN. Move the payment forward and post the entries |
| Yes | No: rare, or the code would cost more than the manual work | A finance work queue with a written playbook and maker-checker | A one-off fee correction by the PSP |
| No | Not yet | An investigation queue with its own owner and SLA | A PSP capture with no payment at all on our side |
Breaks should move up this table over time. When an investigated break turns out to have a repeatable cause, write the playbook. When a manual fix recurs often enough that code is cheaper than people, automate it. Track the share of breaks in each row: a growing "unknown" share usually means a matching key or an integration is broken.
Batch vs near-real-time
| Aspect | T+1 batch | Near-real-time |
|---|---|---|
| Input | Daily files (SFTP, API download) | Event streams, webhooks, intraday camt.054, PSP APIs |
| Detection delay | Up to a day or more | Minutes |
| Completeness | Authoritative, closed period | Provisional, data still arriving |
| Complexity | Simpler, set-based SQL | Windows, late data, state per open item |
| Use | Financial close, audit evidence, payouts | Alerting (e.g. "captures without ledger posting > 0 for 10 minutes"), operational fixes before customers notice |
Most mature systems do both: streaming matching for early warning and internal consistency, and the daily batch as the book of record. See Batch & Stream Processing.
Designing a reconciliation service
Design points:
- Store raw files immutably with checksum, source, received time and file sequence number. Detect missing files (no report by 09:00 is itself an alert) and duplicates (same file delivered twice).
- Canonical record:
source, source_ref, our_ref, type, amount_minor, currency, txn_date, value_date, counterparty, batch_id, raw_line_ref. Parsers per source version, with tests built from real anonymized samples. - Rules as configuration per source pair: key fields, tolerances, date windows, many-to-one grouping keys. Version them, because changing a rule changes historical results.
- Idempotent re-runs: re-processing a day must produce the same matches. Store match results with a run id, and make manual matches sticky across re-runs.
- Set-based matching in SQL or a dataframe engine for batch. Per-key state in a stream processor for near-real-time.
- Security: settlement files contain sensitive data (possibly masked PANs, customer names). Encrypt at rest and restrict access. Never ingest full PANs if you can avoid it.
Example batch match in SQL (exact key, then tolerant pass):
-- Pass 1: exact match on reference, type, amount, currency.
INSERT INTO recon_matches (run_id, internal_id, external_id, rule)
SELECT :run_id, i.id, e.id, 'exact_ref'
FROM recon_internal i
JOIN recon_external e
ON e.our_ref = i.our_ref
AND e.type = i.type
AND e.amount_minor = i.amount_minor
AND e.currency = i.currency
WHERE i.recon_date = :d AND e.recon_date BETWEEN :d AND :d + 2
AND NOT EXISTS (SELECT 1 FROM recon_matches m WHERE m.internal_id = i.id)
AND NOT EXISTS (SELECT 1 FROM recon_matches m WHERE m.external_id = e.id);
-- Pass 2: tolerant match for leftovers: same ref, amount within 1%.
INSERT INTO recon_matches (run_id, internal_id, external_id, rule)
SELECT DISTINCT ON (i.id) :run_id, i.id, e.id, 'ref_amount_tolerance'
FROM recon_internal i
JOIN recon_external e
ON e.our_ref = i.our_ref
AND e.currency = i.currency
AND abs(e.amount_minor - i.amount_minor) <= greatest(1, i.amount_minor / 100)
WHERE i.recon_date = :d
AND NOT EXISTS (SELECT 1 FROM recon_matches m WHERE m.internal_id = i.id)
AND NOT EXISTS (SELECT 1 FROM recon_matches m WHERE m.external_id = e.id)
ORDER BY i.id, abs(e.amount_minor - i.amount_minor);
Everything left unmatched after the passes becomes a break.
Trade-offs
| Option | Strengths | Weaknesses | Choose when |
|---|---|---|---|
| Build in-house recon service | Fits your sources and rules, integrates with your ledger | Parser maintenance per source, needs a finance-ops UI | Many internal flows, unusual sources, strong engineering team |
| Commercial recon platform | Mature exception workflows, audit features, many parsers | License cost, integration effort, less flexible matching | Bank back-office, large volume of standard formats |
| Spreadsheet / manual recon | Zero build cost | Doesn't scale, error-prone, weak audit trail | Very early stage only, and plan the exit |
| Exact matching only | Simple, explainable, no false positives | Many breaks when references are mangled | Sources you control end to end |
| Tolerant / scored matching | Fewer manual items | False matches possible, rules harder to audit | Bank transfers with free-text references, FX flows |
| Near-real-time matching | Early detection, fewer customer-facing incidents | Late-data complexity, provisional results | High volume flows where a day's delay is costly |
In practice
- Pass references end to end. The cheapest reconciliation improvement is making your payment id appear in every external record: PSP
merchant_reference, bank transfer remittance info, VietQR reference fields, payout descriptors. Design this in at integration time. - Track match rate (auto-matched / total) per source per day. A sudden drop, say from 99.5% to 92%, usually means a format change or an integration bug, not suddenly worse data. Treat the numbers as indicators, and baseline your own.
- Cut-off alignment: know each source's cut-off time and time zone. A PSP in UTC and a bank in UTC+7 split "the same day" differently.
- Seller payouts: pay sellers from reconciled, settled funds, or at least cap payouts by settled funds. Paying out against authorized or captured-only funds exposes the platform to chargebacks and failed settlements.
- Close the period: finance needs a "reconciled as of" date per account. After close, changes go in as adjustments in the next period.
A small Go matcher for the many-to-one payout check:
package recon
import "fmt"
type Row struct {
PayoutID string
Type string // capture, refund, chargeback, fee
NetMinor int64 // signed: captures +, refunds/chargebacks/fees -
OurRef string
}
type BankLine struct {
Ref string // payout id parsed from remittance info
AmountMinor int64
}
// CheckPayout verifies that a bank credit equals the sum of its payout rows.
func CheckPayout(line BankLine, rows []Row) error {
var sum int64
for _, r := range rows {
if r.PayoutID != line.Ref {
return fmt.Errorf("row %s belongs to payout %s, not %s", r.OurRef, r.PayoutID, line.Ref)
}
sum += r.NetMinor
}
if sum != line.AmountMinor {
return fmt.Errorf("payout %s: bank %d, rows %d, diff %d",
line.Ref, line.AmountMinor, sum, line.AmountMinor-sum)
}
return nil
}
Common pitfalls
- No reconciliation until finance asks. Symptom: months of accumulated breaks that nobody can explain anymore, because the logs have expired.
- Matching on amount and date only. Symptom: false matches when many orders share common prices (99,000 VND), which hides real breaks.
- Fixing breaks by editing order or payment rows. Symptom: the ledger and audit trail no longer explain balances, and auditors flag it.
- Ignoring timing breaks. Symptom: alert fatigue from items that clear the next day, while real breaks get lost in the noise.
- Not detecting missing files. Symptom: "100% matched" on a day when the PSP file never arrived, so everything was compared against nothing.
- Suspense account used as a dumping ground. Symptom: a growing suspense balance, and nobody can return unclaimed funds to their rightful owners.
- Reconciling against your own copy of external data. Symptom: if your webhook handler wrote both sides, the reconciliation proves nothing. Sources must be independent.
Interview angle
- Where it shows up: as the follow-up to "design a payment system", "design a wallet" or "design seller payouts": "How do you know your system is correct?" or "The PSP charged the customer but you have no record — how do you find out?"
- A strong answer: names independent sources, a daily three-way match, a canonical record model, matching passes (exact → tolerant → many-to-one), break classification with aging and ownership, adjustments through ledger and suspense accounts, missing-file detection, and near-real-time checks for early warning.
- Follow-ups: How do you handle a PSP that changes its file format? How do you make re-runs idempotent? How do you scale to tens of millions of rows per day (partition by date and source, set-based joins)? What do you do with unclaimed funds?
- Red flags: "we use exactly-once so we don't need reconciliation", reconciling against data you produced yourself, or manual spreadsheets as the plan.
Self-check
1. Why is reconciliation needed even if every service uses idempotency keys and the outbox pattern?
Those patterns protect consistency inside your boundary. External parties (PSPs, banks, switches) have their own failures, cut-offs, fees and manual operations. Your own code can also have bugs. Reconciliation compares independent records and is the only way to detect and prove agreement across organizational boundaries.
2. Describe a three-way match for a marketplace using a card PSP.
- Internal payments/captures/refunds ↔ PSP transaction-level report, matched by our payment id, type and amount.
- PSP payout summary ↔ the sum of its transaction rows (net of fees, refunds, chargebacks, reserves).
- PSP payout ↔ the bank statement credit, matched by payout id in the remittance info and the net amount, within a value-date window.
Breaks at any step become exceptions.
3. A bank credit of 50,000,000 VND arrives with remittance text "thanh toan don hang" and no reference. What does your system do?
It tries tolerant matching (amount against open expected payments, customer name, date window). If there's no confident match, it books the credit to a suspense account and creates a break of type "unexplained bank line" with an owner. Operations investigates (contacts the bank or customer). Once identified, a ledger adjustment moves the money from suspense to the right receivable or order. If it stays unclaimed past policy, it gets returned.
4. What is a timing break and how should the system treat it?
A difference caused by the two sources recording the same event in different periods, such as a capture at 23:58 that the PSP books the next day. The system carries it forward and auto-resolves it when the counterpart arrives within the expected window. It alerts only if the break is still open after that window.
5. How do you make a reconciliation run idempotent and auditable?
Store raw files immutably with checksums. Parse them into canonical records keyed by source and source reference (dedup on load). Run matching with versioned rules under a run id. Keep manual matches and resolutions as sticky records that survive re-runs. Post adjustments as ledger entries linked to break ids, so any balance can be traced to the file lines and decisions behind it.
6. When is near-real-time reconciliation worth the complexity?
When a day's delay costs real money or customer trust: high-volume payments where an integration bug could affect thousands of orders before the batch runs, instant payments where funds are final, or wallet top-ups where customers expect balances immediately. Even then, the daily batch on authoritative files remains the book of record.
Exercise
Build a reconciliation prototype for a PSP:
- Generate synthetic data: 100,000 internal payments for a day, and a PSP report with 99.3% of them, a few amount differences (fee changes), 20 duplicates, 50 rows shifted to the next day, and 10 rows you don't have internally.
- Write the canonical record schema and a loader that is idempotent (loading the same file twice changes nothing).
- Implement matching passes: exact, tolerant, and the payout many-to-one check against a synthetic bank statement line.
- Produce a break report grouped by type with counts and amounts, and verify it matches what you injected.
- Write the ledger adjustment entries you would post for the fee differences and the duplicates.
Done when: every injected anomaly appears in exactly one break category, re-running the job gives identical results, and the adjustments balance.
Further reading
- Alex Xu & Sahn Lam, System Design Interview Vol. 2, "Payment System" chapter — the reconciliation section.
- Martin Kleppmann, Designing Data-Intensive Applications, chapters on batch and stream processing (for matching at scale).
- ISO 20022 message definitions for camt.053 and camt.054 (iso20022.org).
- Your PSP's settlement report documentation (Stripe, Adyen and most local PSPs publish report field definitions).
- Modern Treasury, "Accounting for Developers" — reconciliation and suspense accounts.
Related
- Double-Entry Ledger Design — where adjustments and suspense accounts live.
- Payments & Card Flows — the unknown-outcome cases that reconciliation finally resolves.
- Core Banking Concepts — sub-ledger vs GL reconciliation.
- Batch & Stream Processing — engines for batch and near-real-time matching.
- Payment System — reconciliation in an interview-style design.
- Bank Transfer System — interbank settlement reconciliation.
- Big Data Platforms & the Lakehouse — where high-volume matching and historical analysis run.
Do the self-check first. Marking it complete schedules spaced reviews (1, 3, 7, 14, 30… days).