Directory and appid must line up
The JSAPI payment directory configured in the merchant platform must cover the actual page path that initiates payment. One level more or less fails, and the trailing slash matters. Changes take time to propagate, so do not retry immediately.
The appid used for the order must match the appid that issued the openid. An openid from account A with an order under appid B returns an openid/appid mismatch.
Why signatures keep failing
The front end needs a paySign computed over appId, timeStamp, nonceStr, package and signType, signed with the merchant API key, or with the merchant private key under APIv3. It is not the official account appSecret.
The most common mistake is passing the order response sign straight to the front end. That sign covers a different field set and is not interchangeable.
Debug order
Confirm the server-side order succeeded and returned a prepay_id, then check that front-end parameters are complete, then read the exact WeChat error code. The code already distinguishes signature, directory and openid problems.
For payment issues we ask for full request and response logs. Reading the error code beats repeatedly editing configuration.
FAQ
Can H5 payment be used inside the WeChat app?
No. In-app payment must use JSAPI. H5 payment is for mobile browsers outside WeChat.
Can the authorisation directory be a domain?
It must include a path. Entering https://yourdomain/pay/ authorises that directory and its subpaths.
openid or unionid for the order?
Use the openid issued under the current appid. unionid identifies the user across apps and cannot be used to place an order.
Related questions
Further reading
- WeChat Pay Merchant Setup Service details
- Debugging WeChat Pay Callbacks: Did the Request Arrive
- What Are the Common API Configuration Errors in Official Account Development? A Checklist Approach
- What to Do When Alipay Merchant Setup Documents Are Rejected? Correction Tips and Document Checklist
- Why WeChat Pay Settlements Get Delayed: Checking Order, Records and Bank Side
Sources & References
The following are public sources. Always check the latest requirements on the official authority or platform page.
