
Overview
WeChat JSAPI enables payments inside an Official Account web page viewed within WeChat. This method is ideal for:- Official Account H5 stores
- In-app service flows
- QR campaigns opening inside WeChat
For merchants in Canada, refer to
/docs/online-shop/alipay/alipay-web-payments
wherepay_type = 800207.
Integration Methods
Method 1 — Merchant’s Own Official Account
Merchants use their verified WeChat Official Account. Requirements- Official Account verified & linked to QFPay
- Obtain user
openid - Domain added to JSAPI whitelist
- https://developers.weixin.qq.com/doc/offiaccount/en/Getting_Started/Overview.html
- https://pay.weixin.qq.com/wiki/doc/api/jsapi.php
Method 2 — QFPay Official Account (Indirect Settlement)
For merchants without a verified account, QFPay provides an Official Account.Payment Flow Overview
- User opens payment page inside WeChat
- Retrieve OAuth code
- Exchange code → obtain
openid - Submit payment request
- Redirect to WeChat JSAPI payment module
- Verify payment result via backend
Step 1 — Obtain WeChat OAuth Code
Request GET/tool/v1/get_weixin_oauth_code
This endpoint must be opened inside WeChat.
app_code and sign must be sent as query parameters, not headers.Parameters
| Name | Param | Required | Description |
|---|---|---|---|
| App Code | app_code | Yes | Provided by QFPay |
| Redirect URL | redirect_uri | Yes | URL after authorization |
| Merchant ID | mchid | No | Provided if applicable |
| Signature | sign | Yes | MD5 signature using client_key |
Step 2 — Exchange Code for openid
Request
GET /tool/v1/get_weixin_openid
Parameters
| Parameter | Required | Description |
|---|---|---|
code | Yes | OAuth code from Step 1 |
mchid | No | Required for some merchants |
X-QF-APPCODEX-QF-SIGN
A new OAuth code and openid must be obtained for each payment attempt.
Do not cache or reuse.
Do not cache or reuse.
Step 3 — Submit Payment Request
Endpoint POST/trade/v1/payment
PayType: 800207 (WeChat JSAPI)
Required Fields
| Field | Required | Description |
|---|---|---|
sub_openid | Yes | openid from Step 2 |
| Common Parameters | Yes | amount, currency, timestamp, order no |
limit_pay | No | restrict payment methods |
extend_info | No | real-name verification (Mainland China only) |
pay_params Response
| Field | Description |
|---|---|
appId | Official Account AppID |
timeStamp | timestamp |
nonceStr | random string |
package | prepay package |
signType | signature method |
paySign | payment signature |
Step 4 — Redirect to WeChat Payment Module
Redirect the user’s browser to:GET https://o2-hk.qfapi.com/q/direct
Required Parameters
| Parameter | Description |
|---|---|
mchntnm | Merchant display name |
txamt | Amount |
currency | Currency |
redirect_url | URL after payment |
package | from pay_params |
timeStamp | from pay_params |
signType | from pay_params |
paySign | from pay_params |
appId | from pay_params |
nonceStr | from pay_params |
This request is sent directly from the user’s browser.
No authentication headers are required.
No authentication headers are required.
Additional Notes
- JSAPI flow must be executed sequentially
- Do not reuse OAuth codes or openid
- If payment result is delayed, verify via
Transaction Enquiry API - Real-name verification is optional and depends on merchant configuration
