From c05f10288b4f2e2642d6db169712b1e0b3f1955a Mon Sep 17 00:00:00 2001 From: Jerry <85411418@qq.com> Date: Tue, 16 Mar 2021 17:58:54 +0800 Subject: [PATCH] =?UTF-8?q?=E6=96=B0=E5=A2=9E=E5=BE=AE=E4=BF=A1V3=E5=9B=9E?= =?UTF-8?q?=E8=B0=83=E9=AA=8C=E7=AD=BE=E5=92=8C=E9=80=9A=E7=9F=A5=E8=A7=A3?= =?UTF-8?q?=E5=AF=86=E8=AF=B4=E6=98=8E?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 19701369..58c281e5 100644 --- a/README.md +++ b/README.md @@ -550,18 +550,45 @@ import ( "github.com/iGoogle-ink/gopay/pkg/xlog" ) -// 微信V3验签 +// ========同步微信V3支付验签======== wxRsp, err := client.V3TransactionJsapi(bm) if err != nil { xlog.Error(err) return } - err = wechat.V3VerifySign(wxRsp.SignInfo.HeaderTimestamp, wxRsp.SignInfo.HeaderNonce, wxRsp.SignInfo.SignBody, wxRsp.SignInfo.HeaderSignature, WxPkContent) if err != nil { xlog.Error(err) return } + +// ========异步通知验签======== +notifyReq, err := wechat.V3ParseNotify() +if err != nil { + xlog.Error(err) + return +} +err = notifyReq.VerifySign(WxPkContent) +if err != nil { + xlog.Error(err) + return +} +// ========异步通知解密======== +// 普通支付通知解密 +result, err := notifyReq.DecryptCipherText(apiV3Key) +// 合单支付通知解密 +result, err := notifyReq.DecryptCombineCipherText(apiV3Key) +// 退款通知解密 +result, err := notifyReq.DecryptRefundCipherText(apiV3Key) + +// ========异步通知应答======== +// 退款通知http应答码为200且返回状态码为SUCCESS才会当做商户接收成功,否则会重试。 +// 注意:重试过多会导致微信支付端积压过多通知而堵塞,影响其他正常通知。 + +// 此写法是 gin 框架返回微信的写法 +c.JSON(http.StatusOK, &wechat.V3NotifyRsp{Code: gopay.SUCCESS, Message: "成功"}) +// 此写法是 echo 框架返回微信的写法 +return c.JSON(http.StatusOK, &wechat.V3NotifyRsp{Code: gopay.SUCCESS, Message: "成功"}) ``` * #### 微信V2 @@ -614,8 +641,10 @@ rsp := new(wechat.NotifyResponse) // 回复微信的数据 rsp.ReturnCode = gopay.SUCCESS rsp.ReturnMsg = gopay.OK -return c.String(http.StatusOK, rsp.ToXmlString()) // 此写法是 echo 框架返回微信的写法 -c.String(http.StatusOK, "%s", rsp.ToXmlString()) // 此写法是 gin 框架返回微信的写法 +// 此写法是 gin 框架返回微信的写法 +c.String(http.StatusOK, "%s", rsp.ToXmlString()) +// 此写法是 echo 框架返回微信的写法 +return c.String(http.StatusOK, rsp.ToXmlString()) ``` * #### 支付宝