How to solve the problem of garbled characters in WeChat payment API v3 callback notifications

藏色散人
Release: 2021-07-15 13:55:26
forward
4704 people have browsed it

WeChat Payment API v3 Callback Notification Signature Verification Is there a PHPdemo?

Detailed problem introduction:

How to solve the problem of garbled characters in WeChat payment API v3 callback notifications

How to solve the problem of garbled characters in WeChat payment API v3 callback notifications

##Return the wechatpay-signature field received by WeChat callback Signature verification failed. Later, the interruption point found that

decoded the wechatpay-signature field received by the WeChat callback with base64_decode to get the garbled code,

How to solve the problem of garbled characters in WeChat payment API v3 callback notifications

What's the problem? The callback fails to verify the signature. The problem is urgent! ! !

The certificate used for confirmation is the platform certificate, which is also the latest one.

Solution:

Problem solved! ! !

My problem is because I used the framework's method of obtaining parameters in the body, which caused the order of the fields in the body parameters to be inconsistent with what was sent from WeChat. (I was inspired by reading an article about Java implementation. ), it is strongly recommended to use the native programming language to obtain parameters. Our php is file_get_contents("php://input");

Note: After decoding the WeChat signature base64_decode, it is garbled. This is not WeChat's. The signature is wrong, that’s how it is originally

Anyway, to rule out issues such as certificates and serial numbers, it depends on the parameters

How to solve the problem of garbled characters in WeChat payment API v3 callback notifications

Comments are adjusted This is the way I originally obtained the parameters and constructed the signature string. Now I use the native method to verify it.

I hope it can help everyone.

The above is the detailed content of How to solve the problem of garbled characters in WeChat payment API v3 callback notifications. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:Newzers
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template