|
@@ -19,28 +19,26 @@ subject //描述 |
|
|
order_type //订单类型 |
|
|
order_type //订单类型 |
|
|
notify_url //自有支付回调地址 |
|
|
notify_url //自有支付回调地址 |
|
|
platform //平台 由前端header传来的 |
|
|
platform //平台 由前端header传来的 |
|
|
pay_app_cert_sn //应用公钥证书存放路径 |
|
|
|
|
|
pay_alipay_root_cert_sn //支付宝根证书存放路径 |
|
|
|
|
|
pay_alipayrsa_public_key //支付宝公钥证书存放路径 |
|
|
|
|
|
|
|
|
pay_app_cert_sn //应用公钥证书 值 |
|
|
|
|
|
pay_alipayrsa_public_key //支付宝公钥证书 值 |
|
|
pay_ali_use_type //支付宝选择版本 0旧版 1新版 |
|
|
pay_ali_use_type //支付宝选择版本 0旧版 1新版 |
|
|
private_key //支付宝商户私钥 数据库字段 旧版 pay_ali_private_key 新版 pay_ali_new_private_key |
|
|
private_key //支付宝商户私钥 数据库字段 旧版 pay_ali_private_key 新版 pay_ali_new_private_key |
|
|
app_id //支付宝appId 数据库字段 旧版 pay_ali_app_id 新版 pay_ali_new_app_id |
|
|
app_id //支付宝appId 数据库字段 旧版 pay_ali_app_id 新版 pay_ali_new_app_id |
|
|
rsa //支付宝密钥长度 旧版使用 数据库字段 pay_ali_key_len_type |
|
|
rsa //支付宝密钥长度 旧版使用 数据库字段 pay_ali_key_len_type |
|
|
pkcs //支付宝密钥格式 旧版使用 数据库字段 pay_ali_key_format_type |
|
|
pkcs //支付宝密钥格式 旧版使用 数据库字段 pay_ali_key_format_type |
|
|
|
|
|
|
|
|
page_url //支付宝wap支付成功跳转链接 |
|
|
page_url //支付宝wap支付成功跳转链接 |
|
|
|
|
|
|
|
|
wx_applet_filepath_url //这是服务器的路径 cfg.WxappletFilepath.URL |
|
|
|
|
|
*/ |
|
|
*/ |
|
|
|
|
|
|
|
|
func AlipayApp(args map[string]string) (string, error) { |
|
|
|
|
|
|
|
|
func AlipayCofing(args map[string]string) *md.PayData { |
|
|
var paySet = &md.PayData{ |
|
|
var paySet = &md.PayData{ |
|
|
PayAppCertSn: args["pay_app_cert_sn"], |
|
|
PayAppCertSn: args["pay_app_cert_sn"], |
|
|
PayAlipayRootCertSn: args["pay_alipay_root_cert_sn"], |
|
|
|
|
|
PayAlipayrsaPublicKey: args["pay_alipayrsa_public_key"], |
|
|
PayAlipayrsaPublicKey: args["pay_alipayrsa_public_key"], |
|
|
PayAliUseType: args["pay_ali_use_type"], |
|
|
PayAliUseType: args["pay_ali_use_type"], |
|
|
WxAppletFilepathUrl: args["wx_applet_filepath_url"], |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
return paySet |
|
|
|
|
|
} |
|
|
|
|
|
func AlipayApp(args map[string]string) (string, error) { |
|
|
|
|
|
paySet := AlipayCofing(args) |
|
|
if args["private_key"] == "" || args["app_id"] == "" { |
|
|
if args["private_key"] == "" || args["app_id"] == "" { |
|
|
return "", errors.New("请在后台正确配置支付宝") |
|
|
return "", errors.New("请在后台正确配置支付宝") |
|
|
} |
|
|
} |
|
@@ -55,14 +53,7 @@ func AlipayApp(args map[string]string) (string, error) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func AlipayWap(args map[string]string) (string, error) { |
|
|
func AlipayWap(args map[string]string) (string, error) { |
|
|
|
|
|
|
|
|
var paySet = &md.PayData{ |
|
|
|
|
|
PayAppCertSn: args["pay_app_cert_sn"], |
|
|
|
|
|
PayAlipayRootCertSn: args["pay_alipay_root_cert_sn"], |
|
|
|
|
|
PayAlipayrsaPublicKey: args["pay_alipayrsa_public_key"], |
|
|
|
|
|
PayAliUseType: args["pay_ali_use_type"], |
|
|
|
|
|
WxAppletFilepathUrl: args["wx_applet_filepath_url"], |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
paySet := AlipayCofing(args) |
|
|
if args["private_key"] == "" || args["app_id"] == "" { |
|
|
if args["private_key"] == "" || args["app_id"] == "" { |
|
|
return "", errors.New("请在后台正确配置支付宝") |
|
|
return "", errors.New("请在后台正确配置支付宝") |
|
|
} |
|
|
} |
|
@@ -77,13 +68,7 @@ func AlipayWap(args map[string]string) (string, error) { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
func AlipayApplet(args map[string]string) (string, error) { |
|
|
func AlipayApplet(args map[string]string) (string, error) { |
|
|
var paySet = &md.PayData{ |
|
|
|
|
|
PayAppCertSn: args["pay_app_cert_sn"], |
|
|
|
|
|
PayAlipayRootCertSn: args["pay_alipay_root_cert_sn"], |
|
|
|
|
|
PayAlipayrsaPublicKey: args["pay_alipayrsa_public_key"], |
|
|
|
|
|
PayAliUseType: args["pay_ali_use_type"], |
|
|
|
|
|
WxAppletFilepathUrl: args["wx_applet_filepath_url"], |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
paySet := AlipayCofing(args) |
|
|
if args["private_key"] == "" || args["app_id"] == "" { |
|
|
if args["private_key"] == "" || args["app_id"] == "" { |
|
|
return "", errors.New("请在后台正确配置支付宝") |
|
|
return "", errors.New("请在后台正确配置支付宝") |
|
|
} |
|
|
} |
|
@@ -99,51 +84,34 @@ func AlipayApplet(args map[string]string) (string, error) { |
|
|
|
|
|
|
|
|
// 微信app支付v2 |
|
|
// 微信app支付v2 |
|
|
func WxAppPay(params map[string]string) (map[string]string, error) { |
|
|
func WxAppPay(params map[string]string) (map[string]string, error) { |
|
|
appId := params["pay_wx_appid"] |
|
|
|
|
|
mchId := params["pay_wx_mch_id"] |
|
|
|
|
|
apiKey := params["pay_wx_api_key"] |
|
|
|
|
|
notifyUrl := params["notify_url"] |
|
|
|
|
|
client := local_wxpay.NewClient(appId, mchId, apiKey, true) |
|
|
|
|
|
r, err := local_wxpay.TradeAppPay(client, params["subject"], params["ord_id"], params["amount"], notifyUrl) |
|
|
|
|
|
|
|
|
client := local_wxpay.NewClient(params["pay_wx_appid"], params["pay_wx_mch_id"], params["pay_wx_api_key"], true) |
|
|
|
|
|
r, err := local_wxpay.TradeAppPay(client, params["subject"], params["ord_id"], params["amount"], params["notify_url"]) |
|
|
return r, err |
|
|
return r, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 微信H5支付v2 |
|
|
// 微信H5支付v2 |
|
|
func WxH5Pay(params map[string]string) (map[string]string, error) { |
|
|
func WxH5Pay(params map[string]string) (map[string]string, error) { |
|
|
appId := params["pay_wx_appid"] |
|
|
|
|
|
mchId := params["pay_wx_mch_id"] |
|
|
|
|
|
apiKey := params["pay_wx_api_key"] |
|
|
|
|
|
notifyUrl := params["notify_url"] |
|
|
|
|
|
client := local_wxpay.NewClient(appId, mchId, apiKey, true) |
|
|
|
|
|
r, err := local_wxpay.TradeH5Pay(client, params["subject"], params["ord_id"], params["amount"], notifyUrl) |
|
|
|
|
|
|
|
|
client := local_wxpay.NewClient(params["pay_wx_appid"], params["pay_wx_mch_id"], params["pay_wx_api_key"], true) |
|
|
|
|
|
r, err := local_wxpay.TradeH5Pay(client, params["subject"], params["ord_id"], params["amount"], params["notify_url"]) |
|
|
return r, err |
|
|
return r, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 微信小程序v2 |
|
|
// 微信小程序v2 |
|
|
func WxMiniProgPay(params map[string]string) (map[string]string, error) { |
|
|
func WxMiniProgPay(params map[string]string) (map[string]string, error) { |
|
|
appId := params["pay_wx_appid"] |
|
|
|
|
|
mchId := params["pay_wx_mch_id"] |
|
|
|
|
|
apiKey := params["pay_wx_api_key"] |
|
|
|
|
|
notifyUrl := params["notify_url"] |
|
|
|
|
|
client := local_wxpay.NewClient(appId, mchId, apiKey, true) |
|
|
|
|
|
|
|
|
client := local_wxpay.NewClient(params["pay_wx_appid"], params["pay_wx_mch_id"], params["pay_wx_api_key"], true) |
|
|
if params["third_party_wechat_openid"] == "" { |
|
|
if params["third_party_wechat_openid"] == "" { |
|
|
return nil, errors.New("请先授权微信") |
|
|
return nil, errors.New("请先授权微信") |
|
|
} |
|
|
} |
|
|
r, err := local_wxpay.TradeMiniProgPay(client, params["subject"], params["ord_id"], params["amount"], notifyUrl, params["third_party_wechat_openid"]) |
|
|
|
|
|
|
|
|
r, err := local_wxpay.TradeMiniProgPay(client, params["subject"], params["ord_id"], params["amount"], params["notify_url"], params["third_party_wechat_openid"]) |
|
|
return r, err |
|
|
return r, err |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 微信JSAPI支付 |
|
|
// 微信JSAPI支付 |
|
|
func WxAppJSAPIPay(params map[string]string) (map[string]string, error) { |
|
|
func WxAppJSAPIPay(params map[string]string) (map[string]string, error) { |
|
|
appId := params["pay_wx_appid"] |
|
|
|
|
|
mchId := params["pay_wx_mch_id"] |
|
|
|
|
|
apiKey := params["pay_wx_api_key"] |
|
|
|
|
|
notifyUrl := params["notify_url"] |
|
|
|
|
|
|
|
|
|
|
|
client := local_wxpay.NewClient(appId, mchId, apiKey, true) |
|
|
|
|
|
|
|
|
client := local_wxpay.NewClient(params["pay_wx_appid"], params["pay_wx_mch_id"], params["pay_wx_api_key"], true) |
|
|
if params["third_party_wechat_openid"] == "" { |
|
|
if params["third_party_wechat_openid"] == "" { |
|
|
return nil, errors.New("请先授权微信") |
|
|
return nil, errors.New("请先授权微信") |
|
|
} |
|
|
} |
|
|
r, err := local_wxpay.TradeJSAPIPay(client, params["subject"], params["ord_id"], params["amount"], notifyUrl, params["third_party_wechat_openid"]) |
|
|
|
|
|
|
|
|
r, err := local_wxpay.TradeJSAPIPay(client, params["subject"], params["ord_id"], params["amount"], params["notify_url"], params["third_party_wechat_openid"]) |
|
|
return r, err |
|
|
return r, err |
|
|
} |
|
|
} |