tlpay
This commit is contained in:
@@ -1 +1,128 @@
|
|||||||
package tlpay
|
package tlpay
|
||||||
|
|
||||||
|
const (
|
||||||
|
sigKey = "sign"
|
||||||
|
sigTypeMd5 = "MD5"
|
||||||
|
sigTypeSha256 = "HMAC-SHA256"
|
||||||
|
)
|
||||||
|
|
||||||
|
//var (
|
||||||
|
// payMap = map[string]*wxpayapi.API{
|
||||||
|
// "weixinapp": api.WxpayAPI,
|
||||||
|
// "weixinmini": api.WxpayAPI2,
|
||||||
|
// }
|
||||||
|
//)
|
||||||
|
|
||||||
|
//func (p *PayHandler) CreatePay(txDB orm.TxOrmer, subAppID string) (err error) {
|
||||||
|
// switch p.PayType {
|
||||||
|
// case PayTypeWx:
|
||||||
|
// param := &tonglianpayapi.CreateFakeOrderRes{
|
||||||
|
// Trxamt: p.Order.PayPrice,
|
||||||
|
// NotifyUrl: globals.TLPayNotifyURL,
|
||||||
|
// Reqsn: p.Order.OrderID,
|
||||||
|
// PayType: p.VendorPayType,
|
||||||
|
// }
|
||||||
|
// //暂时做兼容处理
|
||||||
|
// if p.VendorPayType == "JSAPI" {
|
||||||
|
// param.PayType = tonglianpayapi.PayTypeWxXcx
|
||||||
|
// }
|
||||||
|
// if p.VendorPayType == tonglianpayapi.PayTypeWxXcx {
|
||||||
|
// param.SubAppID = subAppID
|
||||||
|
// authInfo, err := p.Ctx.GetV2AuthInfo()
|
||||||
|
// // 微信小程序支付
|
||||||
|
// if err == nil && authInfo.GetAuthType() == weixin.AuthTypeMini && authInfo.GetAuthTypeID() == subAppID {
|
||||||
|
// param.Acct = authInfo.GetAuthID()
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if p.VendorPayType == tonglianpayapi.PayTypeZfbJS || p.VendorPayType == tonglianpayapi.PayTypeZfbApp {
|
||||||
|
// if authInfo, err := p.Ctx.GetV2AuthInfo(); err == nil {
|
||||||
|
// param.Acct = authInfo.GetAuthID()
|
||||||
|
// }
|
||||||
|
// if param.Acct == "" {
|
||||||
|
// return fmt.Errorf("未找到用户的认证ID!")
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if p.VendorPayType == tonglianpayapi.PayTypeH5 {
|
||||||
|
// param2 := &tonglianpayapi.CreateH5UnitorderOrderParam{
|
||||||
|
// Trxamt: p.Order.PayPrice,
|
||||||
|
// NotifyUrl: globals.TLPayNotifyURL,
|
||||||
|
// Body: "冲天猴",
|
||||||
|
// Charset: "UTF-8",
|
||||||
|
// }
|
||||||
|
// err = api.TLpayAPI.CreateH5UnitorderOrder(param2)
|
||||||
|
// } else {
|
||||||
|
// result, err := api.TLpayAPI.CreateUnitorderOrder(param)
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// var result2 tonglianpayapi.PayInfo
|
||||||
|
// json.Unmarshal([]byte(result.PayInfo), &result2)
|
||||||
|
// p.Order.PrepayID = result2.Package[strings.LastIndex(result2.Package, "=")+1 : len(result2.Package)]
|
||||||
|
// p.Order.TransactionID = result.TrxID
|
||||||
|
//
|
||||||
|
// if _, err = dao.UpdateEntityTx(txDB, p.Order, "PrepayID", "TransactionID"); err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// wxPay := &WxPayParam{
|
||||||
|
// Prepayid: p.Order.PrepayID,
|
||||||
|
// Noncestr: result2.NonceStr,
|
||||||
|
// Timestamp: utils.Int64ToStr(utils.MustInterface2Int64(result2.TimeStamp)),
|
||||||
|
// Package: result2.Package,
|
||||||
|
// Partnerid: "", // 商户Id
|
||||||
|
// Appid: result2.AppID,
|
||||||
|
// Sign: result2.PaySign,
|
||||||
|
// }
|
||||||
|
// p.WxPayParam = wxPay
|
||||||
|
// }
|
||||||
|
// // 暂时不支持微信直接支付
|
||||||
|
// case model.PayTypeWX:
|
||||||
|
// param := &wxpayapi.CreateOrderParam{
|
||||||
|
// OutTradeNo: p.Order.OrderID,
|
||||||
|
// Body: "冲天猴儿App账户充值",
|
||||||
|
// NotifyURL: globals.WxpayNotifyURL,
|
||||||
|
// SpbillCreateIP: p.Ctx.GetRealRemoteIP(),
|
||||||
|
// TradeType: p.VendorPayType,
|
||||||
|
// TotalFee: p.Order.PayPrice,
|
||||||
|
// TimeStart: wxpayapi.Time2PayTime(time.Now()),
|
||||||
|
// // ProfitSharing: wxpayapi.OptYes,
|
||||||
|
// }
|
||||||
|
// authBinds, err := dao.GetUserBindAuthInfo(dao.GetDB(), p.Ctx.GetUserID(), model.AuthBindTypeAuth, []string{p.Order.Way}, "", "", "")
|
||||||
|
// if err != nil {
|
||||||
|
// return err
|
||||||
|
// }
|
||||||
|
// if len(authBinds) == 0 {
|
||||||
|
// return fmt.Errorf("未绑定微信认证方式!")
|
||||||
|
// }
|
||||||
|
// param.OpenID = authBinds[0].AuthID
|
||||||
|
// result, err2 := payMap[p.Order.Way].CreateUnifiedOrder(param)
|
||||||
|
// if err2 == nil {
|
||||||
|
// param2 := make(map[string]interface{})
|
||||||
|
// param2["prepayid"] = result.PrepayID
|
||||||
|
// param2["noncestr"] = utils.GetUUID()
|
||||||
|
// param2["timestamp"] = time.Now().Unix()
|
||||||
|
// param2["package"] = "Sign=WXPay"
|
||||||
|
// param2["partnerid"] = result.MchID
|
||||||
|
// param2["appid"] = result.AppID
|
||||||
|
// sign := signParam(sigTypeMd5, param2)
|
||||||
|
// wxPay := &WxPayParam{
|
||||||
|
// Prepayid: param2["prepayid"].(string),
|
||||||
|
// Noncestr: param2["noncestr"].(string),
|
||||||
|
// Timestamp: utils.Int64ToStr(utils.MustInterface2Int64(param2["timestamp"])),
|
||||||
|
// Package: param2["package"].(string),
|
||||||
|
// Partnerid: param2["partnerid"].(string),
|
||||||
|
// Appid: param2["appid"].(string),
|
||||||
|
// Sign: sign,
|
||||||
|
// }
|
||||||
|
// p.WxPayParam = wxPay
|
||||||
|
// p.Order.PrepayID = result.PrepayID
|
||||||
|
// p.Order.Comment = result.CodeURL
|
||||||
|
// _, err = dao.UpdateEntityTx(txDB, p.Order, "PrepayID", "Comment")
|
||||||
|
// } else {
|
||||||
|
// return err2
|
||||||
|
// }
|
||||||
|
// default:
|
||||||
|
// err = fmt.Errorf("支付方式:%d当前不支持", p.PayType)
|
||||||
|
// }
|
||||||
|
// return err
|
||||||
|
//}
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ func pay4OrderByTL(ctx *jxcontext.Context, order *model.GoodsOrder, payType int,
|
|||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
payCreatedAt := time.Now()
|
payCreatedAt := time.Now()
|
||||||
param := &tonglianpayapi.CreateUnitorderOrderParam{
|
param := &tonglianpayapi.CreateUnitOrderOrderResult{
|
||||||
Trxamt: int(order.ActualPayPrice),
|
Trxamt: int(order.ActualPayPrice),
|
||||||
NotifyUrl: globals.TLPayNotifyURL,
|
NotifyUrl: globals.TLPayNotifyURL,
|
||||||
Reqsn: order.VendorOrderID,
|
Reqsn: order.VendorOrderID,
|
||||||
|
|||||||
Reference in New Issue
Block a user