Bläddra i källkod

test

tags/v1.6.1^2
huangjiajun 1 år sedan
förälder
incheckning
cae439d4da
2 ändrade filer med 68 tillägg och 1 borttagningar
  1. +54
    -0
      lib/local_alipay/api.go
  2. +14
    -1
      pay/pay_by_own.go

+ 54
- 0
lib/local_alipay/api.go Visa fil

@@ -65,6 +65,60 @@ func TradeAppPay(appID, priKey, subject, orderID, amount, notiURL, RSA, PKCS str
}
return payParam, nil
}
func TradeAppPc(appID, priKey, subject, orderID, amount, notiURL, RSA, PKCS string, paySet *md.PayData) (string, error) {
//初始化支付宝客户端
// appID 是在支付宝申请的APPID
// priKey 是支付宝私钥
// subject 是支付订单的主题
// orderID 是智莺这边生成的订单id
// amount 是付费金额
// notiURL 通知地址url
// passback_params 回调通知参数

client := alipay.NewClient(appID, priKey, true)
client.DebugSwitch = gopay.DebugOn
//判断密钥的类型
rsa_type := alipay.RSA2
pkcs_type := alipay.PKCS1
if RSA == "1" {
rsa_type = alipay.RSA
}
if PKCS == "1" {
pkcs_type = alipay.PKCS8
}
if paySet.PayAliUseType == "1" {
rsa_type = alipay.RSA2
pkcs_type = alipay.PKCS8
}
//配置公共参数
client.SetCharset("utf-8").
SetSignType(rsa_type).
SetPrivateKeyType(pkcs_type)
if notiURL != "" {
client.SetNotifyUrl(notiURL)
}
//新支付宝支付
if paySet.PayAliUseType == "1" {
client.SetAppCertSN(paySet.PayAppCertSn)
aliPayRootCertSN := "687b59193f3f462dd5336e5abf83c5d8_02941eef3187dddf3d3b83462e1dfcf6"
client.SetAliPayRootCertSN(aliPayRootCertSN)
client.SetAliPayPublicCertSN(paySet.PayAlipayrsaPublicKey)
}
fmt.Println(client)
//请求参数
body := make(gopay.BodyMap)
body.Set("subject", subject)
body.Set("out_trade_no", orderID)
body.Set("total_amount", amount)
body.Set("timeout_express", "30m")
body.Set("product_code", "FAST_INSTANT_TRADE_PAY")
// body.Set("passback_params", orderID)
payParam, err := client.TradePagePay(body)
if err != nil {
return "", err
}
return payParam, nil
}

// TradeAppPay is 支付宝H5支付
func TradeWapPay(appID, priKey, subject, orderID, amount, notiURL, RSA, PKCS, page_url string, paySet *md.PayData) (string, error) {


+ 14
- 1
pay/pay_by_own.go Visa fil

@@ -51,7 +51,20 @@ func AlipayApp(args map[string]string) (string, error) {
}
return zhios_pay_utils.AnyToString(param), nil
}

func AlipayPc(args map[string]string) (string, error) {
paySet := AlipayCofing(args)
if args["private_key"] == "" || args["app_id"] == "" {
return "", errors.New("请在后台正确配置支付宝")
}
param, err := local_alipay.TradeAppPc(args["app_id"], args["private_key"], args["subject"], args["ord_id"], args["amount"], args["notify_url"], args["rsa"], args["pkcs"], paySet)
if err != nil {
fmt.Println("支付宝错误日志")
fmt.Println(param)
fmt.Println(err)
return "", errors.New("支付宝订单创建失败")
}
return zhios_pay_utils.AnyToString(param), nil
}
func AlipayWap(args map[string]string) (string, error) {
paySet := AlipayCofing(args)
if args["private_key"] == "" || args["app_id"] == "" {


Laddar…
Avbryt
Spara