Browse Source

更新

master
huangjiajun 1 month ago
parent
commit
f797cde3e3
3 changed files with 56 additions and 21 deletions
  1. +21
    -5
      lib/local_wechat/api.go
  2. +6
    -6
      pay/alipay.go
  3. +29
    -10
      pay/pay_by_own.go

+ 21
- 5
lib/local_wechat/api.go View File

@@ -98,14 +98,13 @@ func TradeShowQuery(client *wechat.Client, transactionId string) (*wechat.QueryO
}
return wxRsp, resBm, nil
}

func TradeShowRefundQuery(client *wechat.Client, transactionId string) (*wechat.QueryRefundResponse, gopay.BodyMap, error) {
func TradeShowQuery1(client *wechat.Client, transactionId string) (*wechat.QueryOrderResponse, gopay.BodyMap, error) {
// 初始化 BodyMap
bm := make(gopay.BodyMap)
bm.Set("transaction_id", transactionId).
bm.Set("out_trade_no", transactionId).
Set("nonce_str", util.GetRandomString(32)).
Set("sign_type", wechat.SignType_MD5)
wxRsp, resBm, err := client.QueryRefund(bm)
wxRsp, resBm, err := client.QueryOrder(bm)
fmt.Println(wxRsp)
fmt.Println(resBm)
if err != nil {
@@ -116,6 +115,23 @@ func TradeShowRefundQuery(client *wechat.Client, transactionId string) (*wechat.
return wxRsp, resBm, nil
}

func TradeShowRefundQuery(client *wechat.Client, transactionId string) (*wechat.QueryRefundResponse, gopay.BodyMap, error) {
// 初始化 BodyMap
bm := make(gopay.BodyMap)
bm.Set("transaction_id", transactionId).
Set("nonce_str", util.GetRandomString(32)).
Set("sign_type", wechat.SignType_MD5)
wxRsp, resBm, err := client.QueryRefund(bm)
//fmt.Println(wxRsp)
//fmt.Println(resBm)
if err != nil {
//xlog.Error(err)
//fmt.Println(err)
return wxRsp, resBm, err
}
return wxRsp, resBm, nil
}

// TradeAppPay is 微信APP支付
func TradeAppPay(client *wechat.Client, subject, orderID, amount, notifyUrl string) (map[string]string, error) {
// 初始化 BodyMap
@@ -307,7 +323,7 @@ func TradeAppPayV3(client *v3.ClientV3, subject, orderID, amount, notifyUrl stri
return nil, nil
}

//// TradeJSAPIPay is 微信JSAPI支付
// // TradeJSAPIPay is 微信JSAPI支付
func TradeJSAPIPay(client *wechat.Client, subject, orderID, amount, notifyUrl, openid string) (map[string]string, error) {
// 初始化 BodyMap
bm := make(gopay.BodyMap)


+ 6
- 6
pay/alipay.go View File

@@ -137,7 +137,7 @@ func CreditagreementQuery(args map[string]string) (*md.ZhimaCreditPayafteruseCre
return res, nil
}

//信用下单
// 信用下单
func CreditagreementOrder(args map[string]string) (*md.ZhimaCreditPayafteruseCreditbizorderOrder, error) {
client := Comm(args)
client.AppAuthToken = args["app_auth_token"]
@@ -166,7 +166,7 @@ func CreditagreementOrder(args map[string]string) (*md.ZhimaCreditPayafteruseCre
return res, nil
}

//查询信用订单
// 查询信用订单
func CreditagreementOrderQuery(args map[string]string) (*md.ZhimaCreditPayafteruseCreditbizorderQuery, error) {
client := Comm(args)
client.AppAuthToken = args["app_auth_token"]
@@ -190,7 +190,7 @@ func CreditagreementOrderQuery(args map[string]string) (*md.ZhimaCreditPayafteru
return res, nil
}

//转账
// 转账
func AlipayFundTransUniTransfer(args map[string]string) (*md.AlipayFundTransUniTransfer, error) {
client := Comm(args)
if client == nil {
@@ -245,7 +245,7 @@ func AlipayFundTransCommonQuery(args map[string]string) (*md.AlipayFundTransComm
return res, nil
}

//扣款
// 扣款
func AlipayTradePay(args map[string]string) (*md.AlipayTradePay, error) {
client := Comm(args)
if args["notify_url"] != "" {
@@ -300,7 +300,7 @@ func AlipayTradeQuery(args map[string]string) (*md.AlipayFundTransUniTransfer, e
return res, nil
}

//结束信用服务订单
// 结束信用服务订单
func CreditagreementOrderFinish(args map[string]string) (*md.ZhimaCreditPayafteruseCreditbizorderFinish, error) {
client := Comm(args)
client.AppAuthToken = args["app_auth_token"]
@@ -438,7 +438,7 @@ func checkPublicParam(a *alipay.Client, bm gopay.BodyMap) {
}
}

//原路退回
// 原路退回
func AlipayTradeRefund(args map[string]string) (*md.AlipayTradeRefund, error) {
client := Comm(args)
if client == nil {


+ 29
- 10
pay/pay_by_own.go View File

@@ -82,19 +82,33 @@ func AlipayWap(args map[string]string) (string, error) {
return zhios_pay_utils.AnyToString(param), nil
}

func AlipayApplet(args map[string]string) (string, error) {
paySet := AlipayCofing(args)
if args["private_key"] == "" || args["app_id"] == "" {
return "", errors.New("请在后台正确配置支付宝")
func AlipayApplet(args map[string]string, isPrd bool) (string, error) {
var url string
if isPrd == true {
url = md.ZHIOS_PAY_URL_PRD + "/kuDianPay/Pay/aliAppPay"
} else {
url = md.ZHIOS_PAY_URL_DEV + "/kuDianPay/Pay/aliAppPay"
}
config := map[string]string{
"pay_ali_app_id": args["pay_ali_app_id"],
"pay_ali_private_key": args["pay_ali_private_key"],
"pay_ali_public_key": args["pay_ali_public_key"],
}
param, err := local_alipay.TradeCreate(args["app_id"], args["private_key"], args["subject"], args["ord_id"], args["amount"], args["notify_url"], args["rsa"], args["pkcs"], paySet)
payParams := map[string]interface{}{
"notify_url": args["notify_url"],
"op_app_id": args["op_app_id"],
"buyer_id": args["buyer_id"],
"total_amount": args["amount"],
"out_trade_no": args["out_trade_no"],
"subject": args["subject"],
"app_auth_token": args["app_auth_token"],
"config": config,
}
bytes, err := zhios_pay_utils.CurlPost(url, zhios_pay_utils.Serialize(payParams), nil)
if err != nil {
fmt.Println("支付宝错误日志")
fmt.Println(param)
fmt.Println(err)
return "", errors.New("支付宝订单创建失败")
return "", err
}
return zhios_pay_utils.AnyToString(param), nil
return string(bytes), nil
}

// 微信app支付v2
@@ -152,6 +166,11 @@ func WxShowQuery(params map[string]string) (*wechat.QueryOrderResponse, gopay.Bo
r, r1, err := local_wxpay.TradeShowQuery(client, params["transaction_id"])
return r, r1, err
}
func WxShowQuery1(params map[string]string) (*wechat.QueryOrderResponse, gopay.BodyMap, error) {
client := local_wxpay.NewClient(params["pay_wx_appid"], params["pay_wx_mch_id"], params["pay_wx_api_key"], true)
r, r1, err := local_wxpay.TradeShowQuery1(client, params["transaction_id"])
return r, r1, err
}
func TradeShowRefundQuery(params map[string]string) (*wechat.QueryRefundResponse, gopay.BodyMap, error) {
client := local_wxpay.NewClient(params["pay_wx_appid"], params["pay_wx_mch_id"], params["pay_wx_api_key"], true)
r, r1, err := local_wxpay.TradeShowRefundQuery(client, params["transaction_id"])


Loading…
Cancel
Save