Cross‑Platform Architecture for WeChat Pay: Reducing Bugs and Boosting Productivity
The article describes how a C++‑based cross‑platform framework, combined with UseCase abstraction, routing mechanisms, unified network request handling, and strict data‑transfer rules, solved iOS/Android inconsistencies in WeChat Pay, cut code size by 45%, kept crash rates stable, and dramatically improved development efficiency.
Background: WeChat Pay’s client suffered from platform‑specific implementations, leading to bugs, poor quality assurance, long iteration cycles, inconsistent user experience, and difficulty maintaining shared business logic across iOS and Android.
Solution Overview: A unified cross‑platform framework written in C++ was introduced to replace separate native implementations. Core payment flows were refactored, and the new architecture was rolled out from version 7.0.4 (iOS) and 7.0.7 (Android).
Key Architectural Steps:
Abstract business processes into independent UseCase objects and represent UI screens as UIPage , enabling reuse and clear separation of concerns.
Introduce a routing mechanism that carries a domain‑specific data model, allowing the system to decide whether to launch a UseCase, open a page, a WebView, a mini‑program, or a dialog.
Manage network requests by turning each CGI into a discrete command object (instead of a singleton), binding its lifecycle to the owning UseCase and providing unified caching, encryption, and error handling.
Standardize data transmission by eliminating shared mutable models, using immutable value types, enforcing one‑way injection, and applying the delegate pattern for necessary callbacks.
Results: The cross‑platform code for the core payment flow reduced from 6,328 lines (iOS native) to 3,512 lines, a 45% reduction. Crash rates remained stable after launch, and the new routing and request handling cut development effort for new features from a week to a few days, improving productivity by up to 83% for special‑flow implementations.
Conclusion: By treating software architecture as a means to manage complexity, the evolved architecture not only eliminated long‑standing bugs and data‑pollution issues but also provided a solid foundation for future enhancements such as automated data reporting, anti‑duplicate payment safeguards, and security cross‑cutting concerns.
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.