ArtisanCloud/PowerWeChat

微信通知回复问题

asd81738431 opened this issue · 8 comments

https://github.com/ArtisanCloud/PowerWeChat/blob/0b13aebc5e27a14ab30b4c6c7b3fe0fc7925510e/src/payment/notify/handler.go#L83C1-L88C1

这个部分,微信官方文档表示当成功时应该发送HTTP应答状态码200或204,无需返回应答报文,当错误的时候应该发送HTTP应答状态码5XX或4XX,同时需返回应答报文,为什么这个部分会写死发送200?

yes, u r right, I'll fix it asap.

Thank you for your code review

It's okay, I'm just curious why You wrote it this way. Your code has taught me a lot

I'v just reviewed the code from EasyWechat: https://github.com/w7corp/easywechat/blob/5.x/src/Payment/Notify/Handler.php

It seems like the return value of function "toResponse" will always be 200 as http response status.
If you are similar with the php code, pls try to read the code. and let me know I am right about this translation from php code.

Also pls paste the link described by Wechat , which specify the note "微信官方文档表示当成功时应该发送HTTP应答状态码200或204,无需返回应答报文,当错误的时候应该发送HTTP应答状态码5XX或4XX,同时需返回应答报文"

Thx again for this issue

In fact, I am also curious about why easywechat would write this way. After reading this code, I also think they did send 200 directly, and they updated the writing method in the v6 version. The official explanation I mentioned is here:

https://pay.weixin.qq.com/wiki/doc/apiv3/apis/chapter3_1_5.shtml

I have reviewed the code again,

image image

Through the response code is 200 from the callback func, but you can also rewrite the response code 50x replied to WeChat , according to the err is nil or not

As PowerWechat is translated from EasyWechat 5.x, and this version is more valuable for us to use. We'll not upgrade the version from EasyWechat 6.x in recent days, We are all in new projects PowerX + RobotChat which are open source.

PowerWechat 对我们来说,是对php的一个告别,也同时致敬一下EasyWechat 5.x.

So when the WeChat callback does not have an order number and there is an issue with the order, I replied that WeChat 200 has completed the processing. WeChat should not have sent another notification, right?

How about join our Wechat group and let me show u the way to reply with response code 50x?

How do I join?