HomeCase studiesHigh-Throughput Digital Payment Orchestration & Settlement Platform

Case study · Singapore, Singapore

High-Throughput Digital Payment Orchestration & Settlement Platform

Real-Time Merchant Payments & Settlement

Payment aggregators serving high-volume retail and e-commerce merchants face severe reconciliation headaches when card networks, local QR rails, and banking settlement files report outcomes asynchronously. We architected a digital payment orchestration and settlement platform using Java, Spring Boot, and PostgreSQL, anchored by Kafka event streaming and strict idempotency controls. The platform processes real-time merchant authorizations, maintains an immutable double-entry clearing ledger, and automates multi-rail payout reconciliation.

Industry
Real-Time Merchant Payments & Settlement
Solution
A high-availability Java and Spring Boot payment orchestration engine, PostgreSQL clearing ledger, merchant API suite, and settlement operations portal.
Platforms
Web & API
Stack
Java · Spring Boot · PostgreSQL · Kafka · Redis · React
Location
Singapore, Singapore · delivered remotely
Role
Engineering, with the team behind for mobile and QA

Delivered remotely for a business based in Singapore, Singapore. Names withheld by agreement.

Project Overview

In Singapore's fast-moving retail and e-commerce ecosystem, merchants accept cards, local instant QR transfers, and digital wallets through a patchwork of acquiring banks and regional gateways. When every payment rail exposes incompatible state codes, partial-refund rules, and T+1 clearing schedules, engineering teams waste cycles debugging ghost transactions and mismatched end-of-day bank deposits.

We built a unified digital payment orchestration and settlement platform in Java and Spring Boot backed by PostgreSQL and Kafka. The platform exposes a single deterministic API for payment intents, captures, voids, and refunds, routes traffic dynamically across acquiring connectors, records every financial movement inside a balanced double-entry ledger, and reconciles bank settlement batches into clean merchant payouts.

Acquiring & Settlement Bottlenecks

Operating real-time money movement across heterogeneous payment rails introduces subtle failure modes that standard CRUD architectures cannot survive:

  • Retry storms during checkout spikes: Flaky mobile networks cause browsers and POS terminals to fire duplicate authorization requests; without strict server-side idempotency, customers suffer double debits.
  • Ambiguous network timeouts: If an acquiring bank processes a debit right as an upstream socket drops, naively marking the payment failed creates unrecorded liabilities until angry reconciliation calls arrive days later.
  • Asymmetric settlement timing: Instant QR transfers clear within seconds while card schemes settle net of interchange and rolling reserves days later, complicating merchant payout calculations.
  • Coupled side effects: Sending merchant webhooks, updating analytics, and running fraud checks inside the synchronous payment request thread inflates tail latency and risks cascading outages.

Architectural Strategy

We structured the platform around an explicit finite-state payment machine coupled with an asynchronous outbox ledger. Every payment intent moves strictly through validated transitions (Created → Authorized → Captured / Voided → Settled / Refunded), persisted atomically in PostgreSQL alongside an outbox event row in the same database transaction.

Spring Boot virtual threads and resilient WebClient pools isolate upstream acquirer latency per connector via circuit breakers. Meanwhile, Apache Kafka decouples downstream consumers—webhook delivery, merchant dashboard projections, risk velocity counters, and settlement batching—so merchant checkout endpoints stay fast even during heavy reporting activity.

Core Capabilities

  • Unified Payment Orchestration API: Normalizes card authorizations, two-step captures, instant QR intents, and partial refunds behind one consistent REST contract and error taxonomy.
  • Smart Acquirer Routing & Failover: Routes transactions across primary and secondary connectors using BIN rules, currency corridors, and live circuit-breaker health metrics.
  • Double-Entry Clearing & Reserve Ledger: Tracks gross capture, processing fees, rolling reserves, and net merchant payable balances with zero unallocated cents.
  • Automated Bank File Reconciliation: Ingests daily acquirer clearing reports, flags fee discrepancies or missing settlements, and releases verified payouts on configurable schedules.
  • Merchant & Treasury Operations Console: Gives merchants real-time transaction timelines, webhook replay tools, and downloadable payout statements through a React web interface.

Technical Architecture

Incoming checkout calls pass through an API gateway enforcing mTLS or signed bearer credentials before hitting the Spring Boot orchestration cluster. Redis checks velocity limits and in-flight idempotency locks, while PostgreSQL persists the initial payment intent and ledger reservation atomically.

Flow: Merchant API Ingress → Spring Boot Orchestrator (Redis Idempotency & Routing) → Tokenized Acquirer Connectors → PostgreSQL Ledger & Transactional Outbox → Kafka Event Streams → Webhook Dispatcher, Reconciliation Engine & React Ops Portal

Once an acquirer responds, a single PostgreSQL transaction updates the payment state, writes balanced ledger postings across clearing and fee accounts, and inserts a transactional outbox record. A Debezium/outbox relay publishes the committed event to Kafka, guaranteeing that webhooks and analytical projections never emit phantom notifications for rolled-back transactions.

Technology Stack

Category Technology detail
Core Payment Services Java 21 with Spring Boot microservices for orchestration, routing, and settlement
Authoritative Clearing Ledger PostgreSQL with serializable double-entry postings and partitioned event logs
Asynchronous Event Bus Apache Kafka for decoupled webhook dispatch, ledger projections, and risk scoring
Idempotency & Rate Control Redis cluster caching idempotency keys, circuit states, and velocity counters
Merchant & Ops Dashboard React TypeScript portal for live payment traces, refunds, and payout statements
API Security & Signing Mutual TLS (mTLS), HMAC-SHA256 webhook signatures, and scoped OAuth2 API credentials
Container Orchestration Kubernetes with automated health probes, rolling deployments, and isolated vault namespaces
Observability & Tracing OpenTelemetry distributed traces, Prometheus metrics, and structured correlation IDs

Engineering Trade-offs & Solutions

Engineering Challenge Solution & Trade-off
Distributed two-phase commits across PostgreSQL and Kafka are brittle Adopted the transactional outbox pattern in PostgreSQL paired with idempotent Kafka consumers; accepts sub-second eventual consistency on webhooks in exchange for zero split-brain ledger states.
High contention on hot merchant balance rows during flash sales Partitioned real-time capture postings into append-only ledger entries and computed net available payout snapshots asynchronously during settlement runs rather than locking one balance row per payment.
Acquirer connector failures dragging down thread pools across other rails Isolated each upstream bank adapter behind dedicated Resilience4j bulkheads and circuit breakers so a stalled QR provider never starves card authorization threads.
Auditing historical fee rules during delayed chargebacks or refunds Versioned merchant pricing schedules with effective timestamps and bound the active fee version ID directly onto each payment intent at authorization time.

Security & Reliability

Payment infrastructure must assume hostile traffic and partial infrastructure failures simultaneously. Inbound merchant endpoints enforce strict JSON schema validation, HMAC-signed webhook payloads with timestamp replay protection, and tenant-scoped API keys whose secrets are stored exclusively as salted hashes.

Inside Kubernetes, card tokenization runs in an isolated, tightly egress-restricted namespace so raw primary account numbers never touch application logs or PostgreSQL tables. Every ledger entry is append-only—corrections, partial refunds, and chargeback adjustments write compensating contra-entries rather than mutating historical rows, preserving a forensic audit trail aligned with Singapore regulatory expectations.

Performance & Scale

Flash-sale traffic requires predictable latency without sacrificing transactional safety. Using Java 21 virtual threads inside Spring Boot allowed blocking JDBC calls and concurrent acquirer status probes to scale efficiently without complex reactive callback chains. PostgreSQL ledger tables are time-partitioned monthly, keeping active B-tree indexes compact in memory while preserving years of queryable history.

Read-heavy traffic from the React merchant portal queries dedicated read replicas and Kafka-hydrated summary views, shielding primary write connections strictly for payment state transitions and settlement commits.

Operational Outcomes

Replacing fragmented acquirer scripts with a disciplined Spring Boot and PostgreSQL core streamlined both merchant onboarding and daily treasury operations:

  • Eliminated duplicate-charge incidents: Deterministic idempotency across Redis and PostgreSQL cleanly absorbed client retries during high-concurrency retail campaigns.
  • Transparent end-to-end traceability: Support and risk teams inspect one unified timeline from initial checkout intent through acquirer trace ID and final bank payout batch.
  • Faster exception resolution: Automated clearing-file reconciliation surfaces missing settlements and fee mismatches directly in the ops queue rather than hiding inside spreadsheets.
  • Safer connector expansion: Adding new regional payment methods requires implementing a bounded adapter interface without touching core ledger or merchant API contracts.

01 — Questions

asked about this kind of project

How does the platform guarantee a retried merchant checkout call never double-charges a buyer?

Every write endpoint requires a client-supplied Idempotency-Key header scoped to the merchant account and request payload hash. Redis intercepts rapid concurrent retries with an in-flight lock, while PostgreSQL enforces a unique constraint so completed keys always replay the exact original authorization response.

Why keep the clearing ledger inside PostgreSQL instead of relying solely on event logs in Kafka?

Kafka excels at high-throughput fan-out, but settlement accounting requires strict atomic balance checks across merchant reserves, platform fees, and refund liabilities. PostgreSQL provides ACID transactions and constraint guarantees that prevent negative available balances during simultaneous captures and refunds.

How do you handle upstream acquirer timeouts where the transaction state is unknown?

When a gateway call times out past its circuit threshold, the Spring Boot orchestrator transitions the payment to an explicit PendingReconciliation state rather than assuming failure. A scheduled inquiry worker polls the upstream rail's status endpoint until a definitive settlement or decline code resolves the ledger.

How are merchant webhooks delivered reliably when a merchant's server goes down temporarily?

Payment state transitions publish events onto Kafka topics consumed by an isolated webhook dispatcher. Failed deliveries back off exponentially with jitter, record HTTP diagnostics in the merchant portal, and move to a replayable dead-letter queue after exhaustion without blocking core payment throughput.

How is sensitive cardholder data kept isolated from the core Spring Boot ledger?

Card PANs never enter the general orchestration database. An isolated tokenization boundary encrypts raw credentials immediately at edge ingress and returns opaque vault tokens, leaving downstream Spring Boot services and PostgreSQL ledger tables free of raw cardholder payloads.

How does the settlement engine reconcile bank clearing files against real-time authorizations?

An ingestion parser normalizes daily ISO 20022 and acquirer CSV clearing batches, matching each line item against expected ledger receivables by network trace ID. Fee variances, chargebacks, and unmatched items route automatically to an exceptions queue in the React operations console.

03 — Similar project?

describe what is different about yours

Build yours.

Tell me what exists, what you need and the deadline. Fixed price for a defined scope, or $55/day (8–9 hours work) with a written plan first.

Solitaire Corporate Park, Makarba, Ahmedabad, Gujarat 380015, India · IST (UTC+5:30) · --:-- IST · Mon–Fri 09:00–18:00 IST · US & EU overlap daily

No newsletter, no CRM. Just a reply.