Overview
WeChat Pay is a leading mobile payment platform in China. This guide will walk you through the complete process of integrating WeChat H5 payment, including merchant account registration, payment credentials, permission activation, and configuration in superun.Please note
WeChat Pay integration requires users to complete merchant account registration and credential acquisition themselves. superun provides guidance for configuring environment variables. Use WeChat Pay’s test environment when testing.
Step 1: Register Merchant Account
- Open your browser and visit:
https://pay.weixin.qq.com - Click “Become a Merchant” in the top right corner
- Select registration type (Enterprise/Individual)
- Fill in the required information:
- Business license photos
- Legal representative ID card (front and back)
- Settlement bank account information
- Contact information
- Submit and wait for review (usually 1-3 business days)
- After approval, log in to see your merchant number
Step 2: Obtain Payment Credentials
2.1 Get Merchant Number (MCH_ID)
- Open:
https://pay.weixin.qq.com - Log in by scanning QR code with administrator WeChat
- Click “Account Center” in the top menu
- Click “Merchant Information” on the left
- Find “WeChat Pay Merchant Number” on the page, which is your merchant number (10 digits)
2.2 Associate AppID and Get It
- Open:
https://pay.weixin.qq.com - Click “Product Center” in the top menu
- Click “AppID Account Management” on the left
- If not associated, click “Associate AppID”:
- Enter your Official Account/Mini Program AppID
- Go to the corresponding Official Account/Mini Program backend to confirm authorization
- After successful association, copy your AppID (starts with
wx) from the list
2.3 Set APIv3 Key
- Open:
https://pay.weixin.qq.com - Click “Account Center” in the top menu
- Click “API Security” on the left
- Find “APIv3 Key” section, click “Set”
- Scan QR code with administrator WeChat to verify identity
- Enter a 32-character string as the key (can include uppercase/lowercase letters and numbers)
- Example:
Abc123DefGhi456Jkl789Mno012Pqr3
- Example:
- Click confirm, save this key immediately (cannot be viewed again after closing the page)
2.4 Apply and Download API Certificate
- Open:
https://pay.weixin.qq.com - Click “Account Center” in the top menu
- Click “API Security” on the left
- Find “Merchant API Certificate” section, click “Apply Certificate”
- Select “Use CA-issued Certificate”
- Scan QR code with administrator WeChat to verify
- Complete certificate application as prompted
- After successful application, click “Download Certificate”
- Download the
cert.zipfile
2.5 Extract Certificate File Content
Extractcert.zip to get the following files:
- Find the
apiclient_key.pemfile - Windows: Right-click → Open with → Notepad
- Mac: Right-click → Open with → TextEdit
- You’ll see content like:
- Press
Ctrl+A(Mac:Cmd+A) to select all - Press
Ctrl+C(Mac:Cmd+C) to copy - Paste into the configuration field (including the BEGIN and END lines)
2.6 Get Certificate Serial Number
Method A - Web Extraction:- Open:
https://pay.weixin.qq.com - Click “Account Center” in the top menu
- Click “API Security” on the left
- Find “API Certificate” section
- In the certificate list, find the “Certificate Serial Number” column
- Copy the serial number (about 40 characters, e.g.,
4B23C5D6E7F8A9B0C1D2E3F4A5B6C7D8E9F0A1B2)
serial=4B23C5D6E7F8A9B0C1D2E3F4... (copy the part after the equals sign)
Step 3: Enable H5 Payment Permission
- Open:
https://pay.weixin.qq.com - Click “Product Center” in the top menu
- Find “H5 Payment” in the product list
- Click “Apply to Enable”
- Fill in application information:
- H5 Payment Domain: Your website domain (e.g.,
www.example.com) - Website Name: Your website name
- Website ICP Record Number: ICP record number
- H5 Payment Domain: Your website domain (e.g.,
- Click “Submit Application”
- Wait for review (usually 1-3 business days)
- After approval, status changes to “Enabled”
Step 4: Configure Credentials in superun
Configure the following 5 environment variables in superun platform: Set the following environment variables in Build → Services → WeChat Pay:| Variable Name | Content to Fill | Source |
|---|---|---|
WECHAT_MCH_ID | Merchant Number | Account Center → Merchant Information |
WECHAT_APP_ID | AppID | Product Center → AppID Account Management |
WECHAT_API_V3_KEY | APIv3 Key | Account Center → API Security → APIv3 Key |
WECHAT_PRIVATE_KEY | Private Key File Content | apiclient_key.pem file |
WECHAT_CERT_SERIAL_NO | Certificate Serial Number | Account Center → API Security → API Certificate |
Step 5: Payment Flow
Using Chat-Driven Flow
After configuring environment variables, you can describe your needs in chat:- “Add WeChat Pay functionality, support H5 payment”
- “Set up WeChat Pay checkout for my product page”
- “Create subscription functionality using WeChat Pay”
Step 6: Common Errors
SIGN_ERROR Certificate Serial Number Incorrect
SIGN_ERROR Certificate Serial Number Incorrect
Serial number doesn’t match the private key. Verify the serial number in the API Security page, ensure
WECHAT_CERT_SERIAL_NO matches WECHAT_PRIVATE_KEY.NO_AUTH Product Permission Not Enabled
NO_AUTH Product Permission Not Enabled
H5 payment is not enabled. Go to Product Center to apply for H5 payment and wait for approval.
PARAM_ERROR Domain Mismatch
PARAM_ERROR Domain Mismatch
H5 domain is not configured. Add the correct payment domain in H5 Payment settings, ensure it matches the actual domain being used.
Other Errors
Other Errors
If you encounter other errors, please check:
- Whether environment variables are correctly configured
- Whether merchant number and AppID are correct
- Whether APIv3 key is correct
- Whether private key file content is complete (includes BEGIN and END lines)
- Whether certificate serial number is correct
Debugging and Troubleshooting
Check Configuration
- Browser Console: Check network requests and error messages
- superun Cloud Logs: Check error messages in backend logs
- WeChat Pay Merchant Platform: View transaction records and error logs in the merchant platform
Testing Recommendations
- Test payment functionality in test environment first
- Use WeChat Pay’s testing tools for verification
- Confirm all environment variables are correctly configured
- Check if H5 payment domain is correctly configured
superun Website
Learn more about product features and examples.

