Skip to main content
Use this page when you collect money with your own WeChat Pay merchant. superun generates the order and callback logic for the product you choose. If you only need WeChat / Alipay collection in China and do not want to apply for a merchant account, use hosted superun Pay instead. You do not fill in the secrets below.
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 call wx.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

  1. Open pay.weixin.qq.com
  2. Click Become a merchant
  3. Choose enterprise or individual business and upload the license, ID, settlement account, and contact
  4. Wait for review (usually 1–3 business days)
  5. 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 download cert.zip. You mainly need:
Open 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:
Use the value after 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 own apiclient_cert.pem).
  1. Account Center → API security — find WeChat Pay public key / platform certificate (names follow the live merchant console)
  2. Download or copy the platform public key PEM and its public key ID
  3. 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 uses POST /v3/pay/transactions/jsapi, then the native page calls wx.requestPayment.
Do not call wx.requestPayment from H5 or a WebView. Exchange openid on the server with jscode2session. Never send the AppSecret to the client.

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.
Never paste the private key, APIv3 key, platform public key, or mini-program AppSecret into chat. After updating Secrets, redeploy the Edge Function — a successful save in the console is not enough.

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

  1. The client asks the backend to create an order
  2. The backend calls the H5 order API and gets h5_url
  3. The customer finishes payment after the redirect
  4. 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.login for openid, native wx.requestPayment”
  • “Native QR pay on desktop”

6. Unlock content after payment

  1. The customer pays
  2. WeChat posts to notify_url; the backend verifies the signature and checks merchant, order id, and amount (integer fen) before marking paid
  3. The client polls or receives status and shows paid content only after that

7. Common errors

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.
Enable H5, JSAPI, or Native for the path you actually use. Do not call one product’s API to patch another.
H5: the payment domain on the merchant platform does not match production. JSAPI: check AppID binding, not the H5 domain.
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.
Native is not enabled. Enable it, then ask the AI to switch the integration to PC scan.
Client success is not authoritative. Check Edge Function logs, merchant transactions, callback signature verification, and the amount.
For debugging, use the browser network panel, superun Cloud logs, and merchant transaction history. Before live charges, run a small payment through create → pay → notify / query → confirm once.

Hosted superun Pay

Collect WeChat / Alipay without connecting your own merchant.