新增支付平台通联宝测试

This commit is contained in:
苏尹岚
2020-02-26 15:56:39 +08:00
parent d50d796d31
commit 92a244c3aa
2 changed files with 17 additions and 2 deletions

View File

@@ -1,11 +1,13 @@
package localjx
import (
"encoding/json"
"time"
"git.rosy.net.cn/jx-callback/globals"
"git.rosy.net.cn/baseapi/platformapi/tonglianpayapi"
"git.rosy.net.cn/baseapi/platformapi/wxpayapi"
"git.rosy.net.cn/baseapi/utils"
"git.rosy.net.cn/jx-callback/business/auth2/authprovider/weixin"
@@ -39,6 +41,8 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayTyp
}
result, err := api.TLpayAPI.CreateUnitorderOrder(param)
if err == nil {
result2 := &wxpayapi.CreateOrderResult{}
json.Unmarshal([]byte(result.PayInfo), &result2)
orderPay = &model.OrderPay{
PayOrderID: param.Reqsn,
PayType: model.PayTypeTL,
@@ -48,10 +52,21 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, vendorPayTyp
VendorID: order.VendorID,
Status: 0,
PayCreatedAt: payCreatedAt,
PrepayID: result.TrxID,
PrepayID: result2.PrepayID,
CodeURL: utils.LimitUTF8StringLen(result.PayInfo, 3200),
TotalFee: int(order.ActualPayPrice),
}
}
return orderPay, err
}
func OnTLPayCallback(msg *wxpayapi.CallbackMsg) (err error) {
globals.SugarLogger.Debugf("OnTLPayCallback msg:%s", utils.Format4Output(msg, true))
switch msg.MsgType {
case wxpayapi.MsgTypePay:
err = onWxpayFinished(msg.Data.(*wxpayapi.PayResultMsg))
case wxpayapi.MsgTypeRefund:
err = onWxpayRefund(msg.Data.(*wxpayapi.RefundResultMsg))
}
return err
}

View File

@@ -25,7 +25,7 @@ func (c *TongLianController) Msg() {
if msg.MsgType == wxpayapi.MsgTypeUnkown {
err = fmt.Errorf("未知的通联宝支付回调类型:%d", msg.MsgType)
} else {
err = localjx.OnWxPayCallback(msg)
err = localjx.OnTLPayCallback(msg)
}
}
if callbackResponse == nil {