Merchant registration, product activation, and credentials happen on WeChat’s side. Put secrets only in backend secret management (Edge Function Secrets) — never in chat, frontend code, or Git. Generated variable names in a project may differ slightly from the table; follow the Secrets named in the conversation.
Pick the product first
The three products use different APIs. Do not mix them. Do not treat a mini program as H5, and do not callwx.requestPayment from a WebView.
Tip: Use free Consult first to lock “mobile H5 / mini-program JSAPI / desktop scan”, then run the integration so you do not enable the wrong product.
1. Register a merchant
- Open pay.weixin.qq.com
- Click Become a merchant
- Choose enterprise or individual business and upload the license, ID, settlement account, and contact
- Wait for review (usually 1–3 business days)
- After approval you will see a merchant ID (
mchid, 10 digits)
2. Collect credentials
2.1 Merchant ID
Account Center → Merchant info → WeChat Pay merchant ID.2.2 Bind an AppID
Product Center → AppID account management → associate an AppID and confirm authorization in the matching admin console.- JSAPI: bind the mini program AppID. It must be the same AppID used for mini-program login.
- H5: bind the Official Account or H5 AppID required by the merchant platform.
2.3 APIv3 key
Account Center → API security → APIv3 key. Set a string that is exactly 32 characters (32 bytes in UTF-8). Save it immediately; you cannot view it again after leaving the page.2.4 Merchant API certificate
Account Center → API security → merchant API certificate → apply and downloadcert.zip. You mainly need:
apiclient_key.pem in a text editor and copy the entire file, including the BEGIN / END lines and newlines.
2.5 Certificate serial number
Copy it from the certificate list on the API security page, or run:serial=. It must match this private key or requests fail with SIGN_ERROR.
2.6 WeChat Pay platform public key
API v3 verification of WeChat responses and payment callbacks also needs the platform public key and public key ID (not your ownapiclient_cert.pem).
- Account Center → API security — find WeChat Pay public key / platform certificate (names follow the live merchant console)
- Download or copy the platform public key PEM and its public key ID
- Keep the full PEM header, footer, and newlines
3. Enable products by scenario
Enable only what you will actually use. If the live path is mini-program JSAPI, you do not need H5 just because an older guide mentioned it.3.1 H5 (mobile browser)
Product Center → H5 Pay → apply. Fill in the payment domain, site name, and ICP filing. The domain must match production.3.2 JSAPI (mini program)
Apply for JSAPI Pay and confirm the mini-program AppID is bound both ways to the merchant. In-app payment usesPOST /v3/pay/transactions/jsapi, then the native page calls wx.requestPayment.
3.3 Native (desktop scan)
Enable Native Pay (or the scan-to-pay product on the merchant platform). H5 alone usually cannot complete payment in a desktop browser.4. Configure in superun
Set these in backend secret management (Edge Function Secrets), as shown in product. Do not use frontend environment variables.5. How payment is confirmed
For every product, a client success callback or a browser return is not paid. Trust only the server: a verified async notify, or an active order query. The same order may be notified more than once — writes must be idempotent so you do not confirm, fulfill, or charge twice.5.1 H5
- The client asks the backend to create an order
- The backend calls the H5 order API and gets
h5_url - The customer finishes payment after the redirect
- WeChat notify / backend query marks the order paid
5.2 JSAPI (mini program)
wx.requestPayment success only means the cashier UI finished. Do not flip the order to paid from that event.
5.3 Example prompts
After secrets are set, say the product and surface in chat, for example:- “Take WeChat H5 payment in the mobile browser”
- “JSAPI in the mini program:
wx.loginfor openid, nativewx.requestPayment” - “Native QR pay on desktop”
6. Unlock content after payment
- The customer pays
- WeChat posts to
notify_url; the backend verifies the signature and checks merchant, order id, and amount (integer fen) before marking paid - The client polls or receives status and shows paid content only after that
7. Common errors
SIGN_ERROR
SIGN_ERROR
The merchant serial does not match the private key, or the platform public key / key ID is not the active pair. Fix them on API security, update Secrets, and redeploy.
NO_AUTH
NO_AUTH
Enable H5, JSAPI, or Native for the path you actually use. Do not call one product’s API to patch another.
PARAM_ERROR domain mismatch
PARAM_ERROR domain mismatch
H5: the payment domain on the merchant platform does not match production. JSAPI: check AppID binding, not the H5 domain.
Login works but payment does not start
Login works but payment does not start
The pay AppID, mini-program login AppID, and the AppID bound on the merchant platform must be the same; JSAPI is enabled; openid is exchanged on the server.
Desktop payment fails
Desktop payment fails
Native is not enabled. Enable it, then ask the AI to switch the integration to PC scan.
Client shows success but content stays locked
Client shows success but content stays locked
Client success is not authoritative. Check Edge Function logs, merchant transactions, callback signature verification, and the amount.
Hosted superun Pay
Collect WeChat / Alipay without connecting your own merchant.

