Multi-Merchant Payment Gateway Setup Notes: WeChat & Alipay API Integration and Sandbox Testing Pitfalls
Multi-Merchant Payment Gateway Setup Notes: WeChat & Alipay API Integration and Sandbox Testing Pitfalls
Disclaimer: This article is for technical education and demonstration only. It is not professional or financial advice. Any real-world deployment must comply with applicable laws and regulations.
I recently helped a client deploy a multi-merchant checkout gateway system — the kind of platform where the backend can hold multiple merchant accounts and aggregate WeChat and Alipay API endpoints. The client runs an e-commerce marketing system and needed a demo payment routing module. It took two and a half days, and I hit plenty of snags along the way. Here’s a problem-by-problem retrospective to save anyone else doing a similar deployment some time.

How to Set Up the Environment: Don’t Skimp on Config
My environment: CentOS 7.9 + Nginx 1.22 + PHP 7.4 (must be 7.4 — 8.0 throws a pile of deprecation warnings) + MySQL 5.7. Installed via BaoTa panel, but a few things needed manual changes:
First, PHP must have the fileinfo and sg11 extensions installed. Some files in this system are encrypted; without sg11 you get a blank screen, and the error is maddeningly vague — the log only says “Class not found”. I initially assumed it was an incomplete composer install and wasted forty minutes on that.
Second, the rewrite rules. The official rules are written for Apache; Nginx needs a conversion. Here’s what I used:
location / { if (!-e $request_filename){ rewrite ^(.*)$ /index.php?s=$1 last; } }
Before converting, every backend route returned 404. After converting, everything worked.
Third, database import. The SQL file is around 18MB, and phpMyAdmin’s default upload limit is 2MB. Importing from the command line is much faster: mysql -u root -p dbname < db.sql — finished in about 20 seconds.

Merchant API Configuration: Round-Robin Tripped Me Up Twice
Pitfall 1: Round-robin not taking effect
The system supports round-robin task distribution across multiple fixed payment endpoints — several collection interfaces take turns receiving orders based on weights. I configured 3 test merchant accounts with weights 2:1:1, yet the first few orders all went to the first one. After digging around, the culprit was the merchant status field — the backend showed "enabled", but the status value in the database was 0 and the cache hadn't refreshed. Clearing the runtime cache directory and restarting php-fpm fixed the round-robin immediately.
Pitfall 2: Callback signature verification failing
During sandbox testing, callback signature verification kept failing with a "sign error". After a long investigation, it turned out Nginx was forcing an HTTPS redirect, and after the 301 the POST data from the callback was lost. The fix: write the callback URL as a full https path directly, don't rely on redirects. Also, on the WeChat side you need to whitelist the callback domain in the merchant platform, otherwise requests never even reach your server.
Recommendation: run every payment API through the full flow in sandbox/demo mode first, then switch to production parameters. This system has a demo toggle in the backend, so test data never lands in the real reconciliation tables — a big relief.

Backend Features and Customization: A Few Things Worth Changing
The backend is built on ThinkPHP with a reasonably clean structure. A few places I actually modified:
Reconciliation module: it aggregates by day by default; the client wanted hourly granularity. Changing one group field in the Order model plus adding a column on the front and back end took half a day.
Multi-language: the system ships with Chinese and English language packs — just switch the locale in config. But the English translation only covers about 70%, so you'll need to fill in the rest of the lang files yourself.
Channel extensions: besides WeChat and Alipay, it has a built-in Shouqianba channel interface. To develop a new channel, you mainly implement the pay() and notify() methods — copying the structure from the Shouqianba class is the easiest path.
Security hardening: definitely change the default backend path (it defaults to /admin — this must be changed), and move the database backup directory out of the web root. This system's default backup path sits under public/, which is an obvious deployment oversight.

FAQ
Q: The homepage loads after deployment, but the backend login keeps saying the captcha is wrong?
A: Nine times out of ten it's a session write permission issue. Check that the runtime directory is writable; after chmod -R 755, confirm the owner is the www user.
Q: The WeChat API works in sandbox testing but nothing happens in production?
A: Check whether the API key and certificate in the merchant platform have been switched over, and confirm your server IP has been added to the merchant platform's IP whitelist — that's the easiest one to miss.
Q: Can round-robin distribution split traffic by amount?
A: Yes. The backend scheduling strategy offers two modes: by weight and by amount range. Amount-based splitting suits scenarios where large and small transactions go through different endpoints. When configuring, make sure the ranges cover continuously, otherwise you'll get a "no available endpoint" error.
Q: Does the system support secondary development?
A: It's a standard ThinkPHP structure, the code isn't fully encrypted, and the core logic is readable — anyone with PHP basics can modify it. The encrypted parts are mainly license verification and don't affect business-layer customization.
Overall, this system is moderately difficult to deploy, with the pitfalls concentrated in environment extensions and callback configuration. Follow the checklist above and, if things go smoothly, you can get the full sandbox flow running within a day.
Disclaimer: This article is a technical deployment record of payment API integration and checkout system architecture only. All demonstrations are based on a sandbox testing environment. When using related systems, comply with applicable laws and regulations; any unlawful use is prohibited.
Disclaimer: This article is for technical education and demonstration only. It is not professional or financial advice. Any real-world deployment must comply with applicable laws and regulations.
#Payment System #Deployment Notes #API Integration #Pitfall Retrospective #ThinkPHP
-
Alipay QR Code Scan
-
WeChat Scan Pay