支付模块
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

pay_by_own.go 1.9 KiB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. package pay
  2. import (
  3. "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/lib/local_alipay"
  4. "code.fnuoos.com/go_rely_warehouse/zyos_go_pay.git/md"
  5. zhios_tool_e "code.fnuoos.com/go_rely_warehouse/zyos_go_tools.git/e"
  6. zhios_tool_utils "code.fnuoos.com/go_rely_warehouse/zyos_go_tools.git/utils"
  7. "fmt"
  8. "xorm.io/xorm"
  9. )
  10. //自有支付 支付宝
  11. func Alipay(eg *xorm.Engine, args map[string]string) (string, error) {
  12. args = OwnCustomAlipayConfig(eg, args)
  13. var paySet = &md.PayData{
  14. PayAppCertSn: args["pay_app_cert_sn"],
  15. PayAlipayRootCertSn: args["pay_alipay_root_cert_sn"],
  16. PayAlipayrsaPublicKey: args["pay_alipayrsa_public_key"],
  17. PayAliUseType: args["pay_ali_use_type"],
  18. WxAppletFilepathUrl: args["wx_applet_filepath_url"],
  19. }
  20. if args["private_key"] == "" || args["app_id"] == "" {
  21. return "", zhios_tool_e.NewErr(400, "请在后台正确配置支付宝")
  22. }
  23. var param interface{}
  24. var err error
  25. switch args["platform"] {
  26. case md.PLATFORM_ALIPAY_APPLET:
  27. 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)
  28. case md.PLATFORM_WAP:
  29. 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)
  30. case md.PLATFORM_ANDROID, md.PLATFORM_IOS:
  31. 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)
  32. default:
  33. return "", zhios_tool_e.NewErr(400, "支付平台不存在")
  34. }
  35. if err != nil {
  36. fmt.Println("支付宝错误日志")
  37. fmt.Println(param)
  38. fmt.Println(err)
  39. return "", zhios_tool_e.NewErr(400, "支付宝订单创建失败")
  40. }
  41. return zhios_tool_utils.AnyToString(param), nil
  42. }