|
- package pay
-
- import (
- "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/local_alipay"
- "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/md"
- "code.fnuoos.com/go_rely_warehouse/zyos_go_tools.git/e"
- "code.fnuoos.com/go_rely_warehouse/zyos_go_tools.git/utils"
- "fmt"
- "xorm.io/xorm"
- )
-
- //自有支付 支付宝
- func Alipay(eg *xorm.Engine, args map[string]string) (string, error) {
- args = OwnCustomAlipayConfig(eg, args)
- 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"],
- }
- if args["private_key"] == "" || args["app_id"] == "" {
- return "", e.NewErr(400, "请在后台正确配置支付宝")
- }
- var param interface{}
- var err error
- switch args["platform"] {
- case md.PLATFORM_ALIPAY_APPLET:
- 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)
- case md.PLATFORM_WAP:
- param, err = local_alipay.TradeWapPay(args["app_id"], args["private_key"], args["subject"], args["ord_id"], args["amount"], args["notify_url"], args["rsa"], args["pkcs"], args["page_url"], paySet)
- case md.PLATFORM_ANDROID, md.PLATFORM_IOS:
- param, err = local_alipay.TradeAppPay(args["app_id"], args["private_key"], args["subject"], args["ord_id"], args["amount"], args["notify_url"], args["rsa"], args["pkcs"], paySet)
- default:
- return "", e.NewErr(400, "支付平台不存在")
- }
- if err != nil {
- fmt.Println("支付宝错误日志")
- fmt.Println(param)
- fmt.Println(err)
- return "", e.NewErr(400, "支付宝订单创建失败")
- }
- return utils.AnyToString(param), nil
-
- }
|