新增支付平台通联宝测试

This commit is contained in:
苏尹岚
2020-02-26 15:35:25 +08:00
parent 77cb160f64
commit d50d796d31
9 changed files with 126 additions and 3 deletions

View File

@@ -0,0 +1,41 @@
package controllers
import (
"fmt"
"net/http"
"git.rosy.net.cn/baseapi/platformapi/wxpayapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/partner/purchase/jx/localjx"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/jx-callback/globals/api"
"github.com/astaxie/beego"
)
type TongLianController struct {
beego.Controller
}
func (c *TongLianController) Msg() {
if c.Ctx.Input.Method() == http.MethodPost {
msg, callbackResponse := api.WxpayAPI.GetCallbackMsg(c.Ctx.Request)
globals.SugarLogger.Debugf("tonglianapi callback msg:%s, callbackResponse:%s, %t", utils.Format4Output(msg, true), utils.Format4Output(callbackResponse, true), callbackResponse == nil)
var err error
if callbackResponse == nil {
if msg.MsgType == wxpayapi.MsgTypeUnkown {
err = fmt.Errorf("未知的通联宝支付回调类型:%d", msg.MsgType)
} else {
err = localjx.OnWxPayCallback(msg)
}
}
if callbackResponse == nil {
callbackResponse = wxpayapi.SuccessResponse
} else if err != nil {
callbackResponse = wxpayapi.Err2CallbackResponse(err, "")
}
c.Data["json"] = callbackResponse
c.ServeJSON()
} else {
c.Abort("404")
}
}