Design and Architecture of Payment Business Systems
This article analyzes the complexities of payment business logic, breaks down the workflow into modular components, illustrates sequence diagrams, discusses related domains such as product and coupon management, and summarizes key technical considerations like transaction handling, locking, and settlement.
Business Background
Payment-related functions are common in business systems, and inexperienced developers often feel nervous about handling payment settlement logic because any detail can cause reconciliation errors, leading to costly fixes and manual interventions.
Payment Business
1. Process Decomposition – Complex business should be split into modules and managed individually before integrating them into a complete workflow.
The typical transaction scenario can be divided into four modules:
Account Management: manage user funds such as available balance, frozen amount, and statements.
Transaction Flow: record all fund movements, including recharge, withdrawal, and refund.
Payment Integration: handle third‑party payment requests and record request/response messages.
Order Structure: manage order models, split strategies, and product specifications.
2. Process Sequence – A sequence diagram shows three core stages: pre‑payment (order creation, fund freezing), payment integration (third‑party request and notification), and post‑payment (status update, fund settlement, inventory adjustment).
3. Structure Design – Based on the analysis, a basic data model includes account management, transaction records, transaction details, payment integration logs, order records, and order details.
Associated Business
Beyond the core payment flow, related domains such as product management, inventory, logistics, and coupon rules interact with the payment process, affecting stock checks, discount application, and refund handling.
Practical Summary
Business Model: clear understanding and modular decomposition of core nodes.
Transaction Management: use TCC (Try‑Confirm‑Cancel) pattern.
Locking & Retry: lock order IDs during asynchronous processing to avoid duplicate handling.
Fund Settlement: ensure precise calculations to pass reconciliation.
Process Maintenance: provide visual workflow tools and manual maintenance mechanisms.
Effective design and iterative refinement are essential for handling complex payment scenarios.
Top Architect
Top Architect focuses on sharing practical architecture knowledge, covering enterprise, system, website, large‑scale distributed, and high‑availability architectures, plus architecture adjustments using internet technologies. We welcome idea‑driven, sharing‑oriented architects to exchange and learn together.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.