Mobile Development 14 min read

Building a C++ Cross‑Platform Framework for the WeChat Pay Client

This article describes how a C++‑based cross‑platform framework was created to unify iOS and Android implementations of WeChat Pay, detailing the architectural challenges, the introduction of UseCase‑driven business flow, a routing mechanism, improved network request handling, and standardized data passing that together reduced code size, improved stability, and boosted development productivity.

Top Architect
Top Architect
Top Architect
Building a C++ Cross‑Platform Framework for the WeChat Pay Client

Background – WeChat Pay suffered from fragmented iOS and Android implementations, leading to bugs, poor scalability, inconsistent user experience, and a weak quality‑assurance system.

Solution – A C++ cross‑platform framework was built, covering iOS 7.0.4 and Android 7.0.7, reducing the core payment code by about 45% and keeping crash rates stable.

What is software architecture? – Defined as the components of a system and their communication, essentially an MVC/MVVM‑style structure ( MVC, MVVM) for WeChat Pay.

Why architecture is needed – To manage complexity, enable responsibility separation, and improve productivity.

Step 1: Abstract business flow – Introduce UseCase to encapsulate business processes and UIPage for UI, replacing scattered controller logic.

Step 2: Add routing mechanism – A unified router parses a payment‑domain model and triggers actions (open UseCase, launch UI, WebView, mini‑program, etc.). The router data model includes a type and required parameters.

Step 3: Manage network requests – Refactor CGI handling from a singleton to independent command objects ( CGI) with lifecycles bound to UseCases, eliminating one‑to‑many communication bugs.

Step 4: Standardize data passing – Remove shared mutable models, use value‑type data, enforce one‑way injection, and apply the delegate pattern for necessary callbacks, preventing data pollution.

Results – The new architecture unifies flow and special‑case handling, cuts code for new features by up to 83%, improves traceability, and provides a solid foundation for future enhancements.

Conclusion – Good software architecture manages complexity; the presented C++ cross‑platform framework demonstrates how systematic architectural evolution can solve real business problems in mobile payment systems.

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.

Mobile Developmentcross‑platformCsoftware designWeChat 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

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.