cp cmd/webdemo/env.example.sh cmd/webdemo/env.sh
$EDITOR cmd/webdemo/env.sh # fill in real gateway credentials
source cmd/webdemo/env.sh && moon run cmd/webdemo| Environment variable | Required | Meaning |
|---|---|---|
| WXPAY_APPID | yes | Merchant app id, e.g. wx1a2b3c4d5e6f7g8h |
| WXPAY_MCHID | yes | Merchant id |
| WXPAY_SERIAL_NO | yes | Serial number of the merchant API certificate |
| WXPAY_PRIVATE_KEY | yes | The API-certificate private key: PEM text, or a path to the PEM file |
| WXPAY_API_V3_KEY | yes | The APIv3 key used for callback payload decryption |
| WXPAY_BASE_URL | no | Gateway base URL (default: https://api.mch.weixin.qq.com) |
| WXPAY_PUBLIC_KEY | no | Public-key mode: the WeChat Pay public key downloaded from the merchant console (pub_key.pem), PEM text or file path |
| WXPAY_PUBLIC_KEY_ID | no | Public-key mode: the PUB_KEY_ID_… serial shown next to it — set both or neither |
| WXPAY_NOTIFY_URL | no | Callback URL sent with every order; defaults to a placeholder |
| WXPAY_APP_SECRET | no | Mini-program AppSecret (小程序 → 开发管理 → 开发设置); enables the mini-program pay panel, where the server exchanges wx.login codes for openids |
| WXPAY_MINIAPP_APPID | no | The mini program's own appid — used for the login exchange and for the panel's JSAPI orders — when it differs from WXPAY_APPID; defaults to WXPAY_APPID |
| WXPAY_MINIAPP_APP_SECRET | no | That mini program's AppSecret, when it differs from WXPAY_APP_SECRET; defaults to WXPAY_APP_SECRET |
| WXPAY_MINIAPP_MCHID / WXPAY_MINIAPP_SERIAL_NO / WXPAY_MINIAPP_PRIVATE_KEY / WXPAY_MINIAPP_API_V3_KEY | no | The panel's own merchant identity — WeChat rejects the order unless the panel's appid and mchid are bound. Set only what differs; each falls back to its WXPAY_* counterpart |
| WXPAY_MINIAPP_PUBLIC_KEY / WXPAY_MINIAPP_PUBLIC_KEY_ID | no | Public-key mode for the panel's merchant, same shape as WXPAY_PUBLIC_KEY/WXPAY_PUBLIC_KEY_ID; defaults to the pay-side values |
| Environment variable | Required | Meaning |
|---|---|---|
| ALIPAY_APPID | yes | Open-platform web-application id, e.g. 2021000000000000 |
| ALIPAY_PRIVATE_KEY | yes | The application private key (RSA2, created with the Alipay key tool): PEM text, or a path to the PEM file |
| ALIPAY_PUBLIC_KEY | yes | The Alipay public key (支付宝公钥) displayed in the open-platform console under 接口加签方式 → 公钥模式 — not your own application public key; PEM text, or a path to the PEM file |
| ALIPAY_GATEWAY_URL | no | Gateway base URL (default: https://openapi.alipay.com/gateway.do; point it at the sandbox gateway when using sandbox credentials) |
| ALIPAY_NOTIFY_URL | no | Notify URL Alipay POSTs to; defaults to a placeholder |
| Environment variable | Must be | Must not be |
|---|---|---|
| WXPAY_SERIAL_NO | The merchant API certificate serial — 40 hex chars, from apiclient_cert.pem in the certificate zip, or 商户平台 → API安全 → API证书 | A PUB_KEY_ID_… public-key serial |
| WXPAY_PRIVATE_KEY | apiclient_key.pem from the same certificate-zip request as that serial | pub_key.pem (that is the public key) or a self-generated key — WeChat looks the certificate up by the request's serial, so the private key must pair with it |
| WXPAY_API_V3_KEY | The 32-char APIv3 key set under 商户平台 → API安全 | The login password or the APIv2 key |
| WXPAY_PUBLIC_KEY | The console's 微信支付公钥 pub_key.pem (public-key mode) | Your own certificate's public key |
| WXPAY_PUBLIC_KEY_ID | The PUB_KEY_ID_… serial displayed next to pub_key.pem | The API certificate serial |
| ALIPAY_PRIVATE_KEY | The application private key from the Alipay key tool, pairing with the application public key uploaded to the console | The Alipay public key |
| ALIPAY_PUBLIC_KEY | The Alipay public key the console displays once the application public key is uploaded | Your own application public key, or the application private key — the most common Alipay mistake |
WXPAY_APPID=wx… WXPAY_MCHID=1900… WXPAY_SERIAL_NO=… \
WXPAY_PRIVATE_KEY=./apiclient_key.pem WXPAY_API_V3_KEY=… \
moon run cmd/webdemo