Mobile Development 13 min read

Cross‑Platform Architecture for WeChat Pay: Reducing Bugs, Improving Efficiency, and Managing Data Flow

The article describes how a C++‑based cross‑platform framework and a unified routing mechanism were introduced to solve iOS and Android inconsistencies in WeChat Pay, resulting in fewer bugs, 45% less code, faster feature delivery, and a more reliable data‑flow architecture.

Top Architect
Top Architect
Top Architect
Cross‑Platform Architecture for WeChat Pay: Reducing Bugs, Improving Efficiency, and Managing Data Flow

As a critical business, WeChat Pay faced severe issues caused by separate iOS and Android implementations, including frequent bugs, poor quality assurance, long iteration cycles, and inconsistent user experience.

To address these problems, a C++ cross‑platform framework was built, consolidating the core payment flow and enabling uniform behavior across iOS 7.0.4+ and Android 7.0.7+.

Step 1 – Abstract Business Flow : The traditional MVC/MVP/MVVM patterns were insufficient for complex payment processes, so a UseCase abstraction was introduced to encapsulate business logic, while UI screens were represented by UIPage . This allowed the flow to be broken into reusable, testable units.

Step 2 – Add Routing Mechanism : A routing model was defined, where each route type (e.g., open a page, launch a mini‑program, show a webview) carries the necessary data. The router parses the route and triggers the appropriate action, eliminating ad‑hoc condition checks and centralising special‑process handling.

Step 3 – Manage Network Requests : Network calls (CGI) were refactored from a singleton, one‑to‑many design into independent command objects. Each CGI instance is owned by a single UseCase , guaranteeing a one‑to‑one lifecycle and preventing stale callbacks after a use case ends.

Step 4 – Standardise Data Transfer : Public mutable models were removed in favour of immutable value types passed via dependency injection. Data now flows unidirectionally, and any required backward communication uses the delegate pattern, dramatically reducing data‑pollution bugs.

Quantitative results show a 45% reduction in code lines for the core payment flow (3512 lines vs. 6328 lines) and up to 83% fewer lines when handling special processes such as webview or mini‑program launches, while crash rates remained stable.

In summary, the new architecture manages complexity by abstracting business processes, unifying routing, isolating network requests, and enforcing clean data flow, thereby improving productivity, reliability, and maintainability of the WeChat Pay mobile client.

mobile developmentsoftware architecturecross‑platformC++Routingnetwork requestWeChat Pay
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

login 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.