|
|
@@ -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) { |
|
|
|