互动
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.

86 lines
4.7 KiB

5 years ago
5 years ago
5 years ago
  1. package pay_service
  2. import (
  3. "fmt"
  4. "hudongzhuanjia/utils/define"
  5. )
  6. var (
  7. WxCertPath = `./cacert/apiclient_cert.pem`
  8. WxKeyPath = `./cacert/apiclient_key.pem`
  9. WxCaPath = `./cacert/rootca.pem`
  10. Appid = "wx7b0bcf476552c5e9"
  11. Secret = "f6aabdd40ea25272f4442603a7dc8028"
  12. Mchid = `1394404502`
  13. ApiKey = `2c82c64ceec6ba89ffc9f593c671a12f`
  14. mainHost = `https://api.mch.weixin.qq.com`
  15. backHost = `https://api2.mch.weixin.qq.com`
  16. )
  17. var (
  18. NotifyURL = fmt.Sprintf("%s/wechat/callback", define.HOST) // 微信回调通知
  19. UnifiedOrderURL = fmt.Sprintf("%s/pay/unifiedorder", mainHost) // 统一下单url
  20. QueryOrderURL = fmt.Sprintf("%s/pay/orderquery", mainHost) // 微信查询订单
  21. CloseOrderURL = fmt.Sprintf("%s/pay/closeorder", mainHost) // 微信关闭订单
  22. RefundURL = fmt.Sprintf("%s/secapi/pay/refund", mainHost) // 微信退款
  23. RefundQueryURL = fmt.Sprintf("%s/pay/refundquery", mainHost) // 微信查询退款
  24. DownloadBillURL = fmt.Sprintf("%s/pay/downloadbill", mainHost) // 微信下载账单
  25. DownloadFundFlowURL = fmt.Sprintf("%s/pay/downloadfundflow", mainHost)
  26. TransfersURL = fmt.Sprintf("%s/mmpaymkttransfers/promotion/transfers", mainHost)
  27. SendRedPackURL = fmt.Sprintf("%s/mmpaymkttransfers/sendredpack", mainHost)
  28. QueryRedPackURL = fmt.Sprintf("%s/mmpaymkttransfers/gethbinfo", mainHost)
  29. )
  30. const (
  31. CODE_SUCCESS = "SUCCESS" // 成功
  32. CODE_FAIL = "FAIL" // 失败
  33. CODE_NOTPAY = "NOTPAY" // 未支付
  34. CODE_CHANGE = "CHANGE" // 退款异常
  35. CODE_REFUNDCLOSE = "REFUNDCLOSE" // 退款关闭
  36. CODE_ERROR = "ERROR" // 业务错误
  37. CODE_INVALID_REQUEST = "INVALID_REQUEST" // 无效请求
  38. CODE_NOAUTH = "NOAUTH" // 异常IP请求不予受理
  39. CODE_NOTENOUGH = "NOTENOUGH" // 余额不足
  40. CODE_ORDERPAID = "ORDERPAID" // 订单已支付
  41. CODE_ORDERCLOSED = "ORDERCLOSED" // 订单已关闭
  42. CODE_SYSTEMERROR = "SYSTEMERROR" // 系统错误
  43. CODE_APPID_NOT_EXIST = "APPID_NOT_EXIST" // APPID不存在
  44. CODE_MCHID_NOT_EXIST = "MCHID_NOT_EXIST" // MCHID不存在
  45. CODE_APPID_MCHID_NOT_MATCH = "APPID_MCHID_NOT_MATCH" // APPID MCHID 不匹配
  46. CODE_LACK_PARAMS = "LACK_PARAMS" // 缺少参数
  47. CODE_OUT_TRADE_NO_USED = "OUT_TRADE_NO_USED" // 商户订单号重复
  48. CODE_SIGNERROR = "SIGNERROR" // 签名错误
  49. CODE_XML_FORMAT_ERROR = "XML_FORMAT_ERROR" // xml格式错误
  50. CODE_REQUIRE_POST_METHOD = "REQUIRE_POST_METHOD" // 请使用post请求方法
  51. CODE_POST_DATA_EMPTY = "POST_DATA_EMPTY" // post数据为空
  52. CODE_NOT_UTF8 = "NOT_UTF8" // 编码错误
  53. CODE_ORDERNOTEXIST = "ORDERNOTEXIST" // 交易订单号不存在
  54. CODE_BIZERR_NEED_RETRY = "BIZERR_NEED_RETRY" // 退款业务流程错误,需要商户触发重试来解决
  55. CODE_TRADE_OVERDUE = "TRADE_OVERDUE" // 订单已经超过退款期限
  56. CODE_USER_ACCOUNT_ABNORMAL = "USER_ACCOUNT_ABNORMAL" // 退款请求失败用户帐号注销
  57. CODE_INVALID_REQ_TOO_MUCH = "INVALID_REQ_TOO_MUCH" // 无效请求过多
  58. CODE_INVALID_TRANSACTIONID = "INVALID_TRANSACTIONID" // 无效transaction_id
  59. CODE_PARAM_ERROR = "PARAM_ERROR" // 参数错误
  60. CODE_FREQUENCY_LIMITED = "FREQUENCY_LIMITED" // 请求频率限制
  61. CODE_TRADE_SUCCESS = "SUCCESS" // 交易成功
  62. CODE_TRADE_REFUND = "REFUND" // 转入退款
  63. CODE_TRADE_NOTPAY = "NOTPAY" // 尚未支付
  64. CODE_TRADE_CLOSED = "CLOSED" // 已关闭
  65. CODE_TRADE_REVOKED = "REVOKED" // 已撤销
  66. CODE_TRADE_USERPAYING = "USERPAYING" // 用户支付中
  67. CODE_TRADE_PAYERROR = "PAYERROR" // 支付失败
  68. CODE_TRANSFER_PROCESSING = "PROCESSING" // 转账处理中
  69. CODE_TRANSFER_NOT_FOUND = "NOT_FOUND" // 账单消息
  70. )
  71. type CommonReturn struct {
  72. ReturnCode string `xml:"return_code,omitempty" json:"return_code,omitempty"`
  73. ReturnMsg string `xml:"return_msg,omitempty" json:"return_msg,omitempty"`
  74. }
  75. type CommonResult struct {
  76. ResultCode string `xml:"result_code,omitempty" json:"result_code,omitempty"`
  77. ResultMsg string `xml:"result_msg,omitempty" json:"result_msg,omitempty"`
  78. ErrCode string `xml:"err_code,omitempty" json:"err_code,omitempty"`
  79. ErrCodeDes string `xml:"err_code_des,omitempty" json:"err_code_des,omitempty"`
  80. }