From 68b9e168648647ac29f381876d91b41bb81276e1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=99=88=E4=BF=8A=E5=AE=8F?= <389838709@qq.com> Date: Tue, 6 Aug 2024 18:00:49 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=AF=E4=BB=98=E5=9B=9E=E8=B0=83=E5=A4=84?= =?UTF-8?q?=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controllers/front/payment_controller.go | 17 ++--------------- app/third/paymentService/payment_test.go | 2 +- 2 files changed, 3 insertions(+), 16 deletions(-) diff --git a/app/http/controllers/front/payment_controller.go b/app/http/controllers/front/payment_controller.go index 874999b..3bc2f92 100644 --- a/app/http/controllers/front/payment_controller.go +++ b/app/http/controllers/front/payment_controller.go @@ -72,9 +72,6 @@ func WxCallback(c *gin.Context) { return } - // ====↓↓↓====异步通知应答====↓↓↓==== - // 退款通知http应答码为200且返回状态码为SUCCESS才会当做商户接收成功,否则会重试。 - // 注意:重试过多会导致微信支付端积压过多通知而堵塞,影响其他正常通知。 c.JSON(http.StatusOK, &wechat.V3NotifyRsp{Code: gopay.SUCCESS, Message: "成功"}) return } @@ -105,28 +102,18 @@ func AliCallback(c *gin.Context) { } var aliConfig paymentService.AliPay - var aliConfigModel struct { - PrivateKey string `json:"private_key"` // 应用私钥 - AppPublicCert string `json:"app_public_cert"` // 应用公钥 - AlipayRootCert string `json:"alipay_root_cert"` // 支付宝根证书 - AlipayPublicCert string `json:"alipay_public_cert"` // 支付宝公钥 - } - err := json.Unmarshal([]byte(payChannelModel.ExtJson), &aliConfigModel) + err := json.Unmarshal([]byte(payChannelModel.ExtJson), &aliConfig) if err != nil { logger.Error(c, "AliCallback-回调数据解析支付配置错误", fmt.Sprintf("错误原因:%s", err.Error())) c.String(http.StatusBadRequest, "%s", "fail") return } - if aliConfigModel.AlipayPublicCert == "" || aliConfigModel.PrivateKey == "" || aliConfigModel.AppPublicCert == "" || aliConfigModel.AlipayRootCert == "" { + if aliConfig.AlipayPublicCert == "" || aliConfig.PrivateKey == "" || aliConfig.AppPublicCert == "" || aliConfig.AlipayRootCert == "" { logger.Error(c, "AliCallback-回调数据解析支付配置错误,解析出来的信息为空") c.String(http.StatusBadRequest, "%s", "fail") return } aliConfig.AppId = payChannelModel.AppId - aliConfig.PrivateKey = aliConfigModel.PrivateKey - aliConfig.AppPublicCert = aliConfigModel.AppPublicCert - aliConfig.AlipayRootCert = aliConfigModel.AlipayRootCert - aliConfig.AlipayPublicCert = aliConfigModel.AlipayPublicCert notifyReq, err := alipay.ParseNotifyToBodyMap(c.Request) // c.Request 是 gin 框架的写法 if err != nil { diff --git a/app/third/paymentService/payment_test.go b/app/third/paymentService/payment_test.go index f2a8a82..a14156b 100644 --- a/app/third/paymentService/payment_test.go +++ b/app/third/paymentService/payment_test.go @@ -35,7 +35,7 @@ func TestMarketSendRequest_Market(t *testing.T) { request := PayOrderRequest{ OrderId: 12312312312, PayChannelId: 8935141660703064070, - ChannelType: 2, + ChannelType: 6, Description: "测试商品", Amount: 1, PayerClientIp: "192.168.110.235",