微信支付退款

This commit is contained in:
gazebo
2019-11-21 09:20:56 +08:00
parent 75caa1fffd
commit db9e80212f
8 changed files with 207 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
package controllers
import (
"fmt"
"net/http"
"git.rosy.net.cn/baseapi/platformapi/wxpay"
@@ -16,15 +17,18 @@ type WXPayController struct {
func (c *WXPayController) Msg() {
if c.Ctx.Input.Method() == http.MethodPost {
msg, callbackResponse := api.WxpayAPI.GetCallbackMsg(c.Ctx.Request)
var err error
if callbackResponse == nil {
if err := localjx.OnWxPayCallback(msg); err != nil {
if msg.MsgType != wxpay.MsgTypeUnkown {
callbackResponse = wxpay.Err2CallbackResponse(err, "")
}
if msg.MsgType != wxpay.MsgTypeUnkown {
err = fmt.Errorf("未知的微信支付回调类型:%d", msg.MsgType)
} else {
err = localjx.OnWxPayCallback(msg)
}
}
if callbackResponse == nil {
callbackResponse = wxpay.SuccessResponse
} else if err != nil {
callbackResponse = wxpay.Err2CallbackResponse(err, "")
}
c.Data["xml"] = callbackResponse
c.ServeXML()