Building a Reconciliation Engine for Currency Mismatch
A payment gateway settles in USD. Your ledger records the transaction in IDR at the mid-market rate. The provider's settlement arrives 48 hours later at a different rate. The amounts do not match. Your reconciliation report flags a discrepancy. Someone on the finance team spends two hours tracing a $0.47 gap that no one caused and no one can fix.
I have watched this scenario repeat across payment systems. The root cause is the assumption that reconciliation means matching exact amounts. When multiple currencies and FX rates enter the picture, exact matching breaks. You need a reconciliation engine designed for imprecision.
Why Currency Mismatch Happens
Three forces create mismatches: rate timing (authorization vs settlement rate), provider markups (FX spreads), and rounding differences (different precision levels).
Designing the Reconciliation Engine
The engine has four layers:
Normalization. Convert both sides to a common currency using a reference rate from a neutral provider.
Threshold-based matching. Define acceptable variance thresholds per currency pair and transaction size. Use both percentage (for large amounts) and absolute (for rounding artifacts).
Rate attribution. Record the implied rate for every matched transaction with variance.
Exception classification. Not all exceptions carry the same weight. FX_VARIANCE routes to a dashboard for bulk approval. SUSPICIOUS triggers an alert.
Lessons from Production
Thresholds need calibration (FX markets shift). Audit every decision (regulators will ask). Separate FX variance from genuine errors (finance teams should not investigate 30-cent gaps with the same urgency as missing $5,000 settlements).
$ /related
CQRS in Practice: When Textbook Patterns Meet Real Constraints
CQRS looks elegant in architecture diagrams. In production, it introduces complexity you didn't plan for. Here's what I learned applying it under real constraints.
Event-Driven Architecture Without Event Sourcing Complexity
Event-driven doesn't require event sourcing. You can decouple services with lightweight event patterns — no Kafka cluster or distributed systems PhD needed.
Idempotent Payment Endpoints: Lessons from Production
Duplicate payments from retry logic cost real money and trust. Idempotency keys prevent them, and most payment APIs get the implementation wrong.