支付回调处理
This commit is contained in:
parent
2d4d674145
commit
68b9e16864
|
@ -72,9 +72,6 @@ func WxCallback(c *gin.Context) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// ====↓↓↓====异步通知应答====↓↓↓====
|
|
||||||
// 退款通知http应答码为200且返回状态码为SUCCESS才会当做商户接收成功,否则会重试。
|
|
||||||
// 注意:重试过多会导致微信支付端积压过多通知而堵塞,影响其他正常通知。
|
|
||||||
c.JSON(http.StatusOK, &wechat.V3NotifyRsp{Code: gopay.SUCCESS, Message: "成功"})
|
c.JSON(http.StatusOK, &wechat.V3NotifyRsp{Code: gopay.SUCCESS, Message: "成功"})
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
@ -105,28 +102,18 @@ func AliCallback(c *gin.Context) {
|
||||||
}
|
}
|
||||||
|
|
||||||
var aliConfig paymentService.AliPay
|
var aliConfig paymentService.AliPay
|
||||||
var aliConfigModel struct {
|
err := json.Unmarshal([]byte(payChannelModel.ExtJson), &aliConfig)
|
||||||
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)
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Error(c, "AliCallback-回调数据解析支付配置错误", fmt.Sprintf("错误原因:%s", err.Error()))
|
logger.Error(c, "AliCallback-回调数据解析支付配置错误", fmt.Sprintf("错误原因:%s", err.Error()))
|
||||||
c.String(http.StatusBadRequest, "%s", "fail")
|
c.String(http.StatusBadRequest, "%s", "fail")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
if aliConfigModel.AlipayPublicCert == "" || aliConfigModel.PrivateKey == "" || aliConfigModel.AppPublicCert == "" || aliConfigModel.AlipayRootCert == "" {
|
if aliConfig.AlipayPublicCert == "" || aliConfig.PrivateKey == "" || aliConfig.AppPublicCert == "" || aliConfig.AlipayRootCert == "" {
|
||||||
logger.Error(c, "AliCallback-回调数据解析支付配置错误,解析出来的信息为空")
|
logger.Error(c, "AliCallback-回调数据解析支付配置错误,解析出来的信息为空")
|
||||||
c.String(http.StatusBadRequest, "%s", "fail")
|
c.String(http.StatusBadRequest, "%s", "fail")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
aliConfig.AppId = payChannelModel.AppId
|
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 框架的写法
|
notifyReq, err := alipay.ParseNotifyToBodyMap(c.Request) // c.Request 是 gin 框架的写法
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
|
@ -35,7 +35,7 @@ func TestMarketSendRequest_Market(t *testing.T) {
|
||||||
request := PayOrderRequest{
|
request := PayOrderRequest{
|
||||||
OrderId: 12312312312,
|
OrderId: 12312312312,
|
||||||
PayChannelId: 8935141660703064070,
|
PayChannelId: 8935141660703064070,
|
||||||
ChannelType: 2,
|
ChannelType: 6,
|
||||||
Description: "测试商品",
|
Description: "测试商品",
|
||||||
Amount: 1,
|
Amount: 1,
|
||||||
PayerClientIp: "192.168.110.235",
|
PayerClientIp: "192.168.110.235",
|
||||||
|
|
Loading…
Reference in New Issue