Debugging WeChat Pay Callbacks: Did the Request Arrive
When a customer pays and the order stays pending, the callback either never arrived or arrived and failed processing. This tutorial checks four things in order: whether the request reaches the server, whether the response is accepted, whether signature verification passes, and whether business handling is idempotent.
Steps
- Verify the callback URL is public
notify_url must be a publicly reachable HTTPS address with no query string, no internal address and no dependency on a login session. Request it from outside with curl and confirm you get your own response rather than a 404 or a certificate error.
- Log the raw request at the entry point
On the very first line of the handler, log headers, raw body and source IP before any parsing. No log entry means the request never arrived, so the problem is DNS, certificate, firewall or a WAF, not business code.
- Check whether the response is accepted
APIv3 callbacks expect HTTP 200 (or 204) to acknowledge receipt; APIv2 expects its documented success response. Returning 200 with the wrong body, or a 302 redirect, is treated as failure and retried, which looks like intermittent updates.
- Investigate verification failures
APIv3 verification uses the platform certificate or WeChat Pay public key, which is a different key pair from the merchant private key used to sign requests. Confirm the serial number matches the current platform certificate and update it when certificates rotate, or everything starts failing at once.
- Make handling idempotent
The same order can notify more than once. Enforce uniqueness on the merchant order number or check a state machine, and return success for already-processed notifications without shipping twice or crediting twice. Move slow work out of the handler so the response is not late.
- Fall back to order queries
When callbacks never arrive, query the order by merchant order number and process accordingly. Reconcile against the daily bill so the remaining differences are the only items needing human attention.
Practical tips
- Confirm arrival before debugging signatures; the reverse order wastes hours
- HTTP 200 alone is not enough, the body must follow the specification
- Do not put the callback path behind a login or a challenge page
FAQ
Can notify_url use HTTP?
No. It must be HTTPS with a valid certificate. Self-signed certificates fail platform validation.
Do callback failures stop customers from paying?
No, but orders stop updating and the platform keeps retrying. Prolonged failures can affect merchant risk scoring.
Related news
Explain your case first, then confirm the scope
Tell us your entity, business model and current progress. We will confirm what we can assist with and what you need to do before discussing fees.
