Mobile Development 14 min read

Designing a Cross‑Platform Architecture for WeChat Pay: From Problems to Solutions

The article analyzes the inconsistencies and maintenance challenges of separate iOS and Android implementations of WeChat Pay, then presents a C++‑based cross‑platform framework with UseCase‑driven business flow, routing, unified network handling and strict data passing, showing how these changes cut code size, keep crash rates stable and dramatically improve development productivity.

Top Architect
Top Architect
Top Architect
Designing a Cross‑Platform Architecture for WeChat Pay: From Problems to Solutions

WeChat Pay’s client side suffered from divergent iOS and Android implementations, leading to bugs, poor quality assurance, low extensibility, and inconsistent user experience.

To address these core issues, a cross‑platform framework written in C++ was built, refactoring the core payment flow and covering iOS 7.0.4+ and Android 7.0.7+.

Online impact : crash rate remained stable after launch, and the cross‑platform code reduced the core payment flow from 6,328 lines (iOS native) to 3,512 lines – a 45% reduction. Feature development time also dropped from a week per platform to a few person‑days for both platforms combined.

What is software architecture? For this project, architecture is defined as the system’s components and their communication, essentially the MVC / MVVM patterns used in mobile development.

Why architecture matters : it manages complexity by separating responsibilities, enabling reuse and higher productivity.

From zero to one :

Abstract business flow into a UseCase and UI screens into UIPage, consolidating flow logic and allowing reuse.

Introduce a routing mechanism that carries a payment‑domain model (data) to trigger actions such as opening a UseCase, a UI page, a WebView, a mini‑program, or a dialog.

Manage network requests by turning each CGI into an independent object (command pattern) with a clear lifecycle bound to its UseCase.

Standardize data transmission by eliminating shared mutable models, using immutable value types, enforcing one‑way injection, and applying the delegate pattern for necessary callbacks.

These steps unified the flow, reduced duplicated code (up to 83% for special flows), prevented data pollution, and made the architecture more traceable and maintainable.

Conclusion : Good architecture continuously evolves from real business problems; the presented cross‑platform design not only solves legacy issues but also enables further capabilities such as automated reporting, duplicate‑payment prevention, and security cross‑cutting concerns.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Design PatternsMobile DevelopmentSoftware ArchitectureroutingWeChat PayC++
Top Architect
Written by

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.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.