Payments & Platform Access · Practical News

WeChat Pay Signature Verification Fails: A Four-Step Diagnosis

Source: Paddy Dance teamKeywords: WeChat Pay signature verification failed

Print the signature string

The APIv3 signature string has five lines: method, URL path including query, timestamp, nonce, and the request body. Each line ends with a newline, and the final line is the raw body. One missing newline or an extra space invalidates it.

The fastest diagnosis is to print the exact string you signed next to the exact bytes you sent and compare them character by character. Most problems become obvious immediately.

Keys and serial numbers

The merchant private key is the content of apiclient_key.pem with the header, footer and all newlines removed before use. Passing the raw multi-line string to the signing function never works.

The certificate serial number in the request header must be your merchant API certificate, not the platform certificate. Both are downloaded from the merchant platform and are easy to mix up.

Check the verification direction

Callback verification uses the platform certificate or WeChat Pay public key, which is a different key pair from your merchant private key. Using the wrong direction looks like requests succeed but callbacks fail.

Platform certificates rotate. Load them by serial number at runtime instead of hardcoding one, which will eventually expire.

FAQ

Are APIv2 and APIv3 signatures the same?

No. APIv2 uses MD5 or HMAC-SHA256 over a parameter string; APIv3 uses SHA256-RSA2048 with certificates. Do not mix them.

My signature differs from the official tool. Why?

Compare the raw signature string. Differences are almost always newlines, spaces or field order.

Does an expired certificate look like a signature error?

It reports certificate errors. Certificates have validity periods; replace them and update paths and serial numbers before expiry.

Related questions

WeChat Pay SIGN_ERRORAPIv3 signature implementationplatform certificate vs merchant keywhy signature verification fails

Further reading

Sources & References

The following are public sources. Always check the latest requirements on the official authority or platform page.

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.