Merpay's Payment Platform team describes a new abstraction called Exchange to unify fragmented payment APIs. Instead of separate APIs for payments, top-ups, transfers, and partner settlements, Exchange models any fund movement as a source-to-destination operation with a two-phase Authorize/Capture lifecycle. The design introduces a Value concept to unify payment methods and destinations, passes accounting codes through the API to eliminate hardcoded accounting logic, and uses a Saga pattern for failure compensation in distributed transactions. Extension points (Hooks, Steps, Decisions) allow product teams to inject use-case-specific logic like KYC checks without polluting the core. The goal is to reduce coordination overhead, clarify API responsibilities, and enable faster onboarding of new payment use cases.

15m read timeFrom engineering.mercari.com
Post cover image
Table of contents
BackgroundProblemsWhat is an Exchange?Design PhilosophyThe Anatomy of an ExchangeThe Value ConceptPractical ExampleFuture ExtensionsConclusion
306 Impressions