Mobile Development 13 min read

Cross‑Platform Architecture for WeChat Pay: Reducing Bugs and Boosting Productivity with a C++ Framework

The article describes how a C++‑based cross‑platform framework was built to unify iOS and Android implementations of WeChat Pay, addressing bugs, scalability, quality assurance, routing, network request management, and data‑flow discipline, ultimately improving development efficiency and user experience.

Architect's Guide
Architect's Guide
Architect's Guide
Cross‑Platform Architecture for WeChat Pay: Reducing Bugs and Boosting Productivity with a C++ Framework

As an Internet architect, the author explains the challenges of maintaining separate iOS and Android implementations for WeChat Pay, including frequent bugs, poor scalability, inconsistent user experience, and inadequate quality‑assurance processes.

To solve these core problems, a cross‑platform framework written in C++ was introduced, covering all versions from iOS 7.0.4 and Android 7.0.7 onward.

Key performance indicators show stable crash rates after launch and a 45% reduction in code lines for the core payment flow (3512 lines vs. 6328 lines native), as well as faster feature delivery (e.g., 3 person‑days for a new checkout UI versus a week in native implementations).

The article defines software architecture as the composition of system components and their communication, emphasizing patterns such as MVC , MVP , and MVVM . For WeChat Pay, the architecture abstracts business processes into UseCase objects and UI screens into UIPage , enabling reuse and clearer responsibility separation.

Step 1 abstracts the business flow; Step 2 adds a routing mechanism that routes data‑driven actions (e.g., opening a webview, mini‑program, or dialog) based on a unified payment domain model; Step 3 refactors network requests by turning each CGI call into an independent command object with a well‑defined lifecycle tied to its UseCase .

Step 4 enforces disciplined data transmission by eliminating shared mutable models, using value‑type data, single‑direction flow, and delegate patterns for necessary callbacks, thereby preventing data pollution and making the data flow traceable.

Overall, the evolved architecture unifies process flow, reduces duplicated code (up to 83% in special‑process handling), improves reliability, and provides a solid foundation for future enhancements such as automated reporting and security cross‑cutting concerns.

cross‑platformC++Routingmobile architectureWeChat PayUseCase
Architect's Guide
Written by

Architect's Guide

Dedicated to sharing programmer-architect skills—Java backend, system, microservice, and distributed architectures—to help you become a senior architect.

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.