支付模块
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.7 KiB

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