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.
wechatpayopen/const.go

77 lines
2.2 KiB

2 years ago
package wechatpayopen
import "time"
// 微信支付 API 地址
const (
2 years ago
apiUrl = "https://api.mch.weixin.qq.com"
2 years ago
WechatPayAPIServerBackup = "https://api2.mch.weixin.qq.com" // 微信支付 API 备份地址
)
2 years ago
const (
logTable = "wechatpayopen"
)
2 years ago
// SDK 相关信息
const (
Version = "1.0.15" // SDK 版本
2 years ago
UserAgentFormat = "WechatPay-Go/%s (%s) GO/%s" // UserAgent中的信息
)
// HTTP 请求报文 Header 相关常量
const (
Authorization = "Authorization" // Header 中的 Authorization 字段
Accept = "Accept" // Header 中的 Accept 字段
ContentType = "Content-Type" // Header 中的 ContentType 字段
ContentLength = "Content-Length" // Header 中的 ContentLength 字段
UserAgent = "User-Agent" // Header 中的 UserAgent 字段
)
// 常用 ContentType
const (
ApplicationJSON = "application/json"
ImageJPG = "image/jpg"
ImagePNG = "image/png"
VideoMP4 = "video/mp4"
)
// 请求报文签名相关常量
const (
SignatureMessageFormat = "%s\n%s\n%d\n%s\n%s\n" // 数字签名原文格式
// HeaderAuthorizationFormat 请求头中的 Authorization 拼接格式
HeaderAuthorizationFormat = "%s mchid=\"%s\",nonce_str=\"%s\",timestamp=\"%d\",serial_no=\"%s\",signature=\"%s\""
)
// HTTP 应答报文 Header 相关常量
const (
WechatPayTimestamp = "Wechatpay-Timestamp" // 微信支付回包时间戳
WechatPayNonce = "Wechatpay-Nonce" // 微信支付回包随机字符串
WechatPaySignature = "Wechatpay-Signature" // 微信支付回包签名信息
WechatPaySerial = "Wechatpay-Serial" // 微信支付回包平台序列号
RequestID = "Request-Id" // 微信支付回包请求ID
)
// 时间相关常量
const (
FiveMinute = 5 * 60 // 回包校验最长时间(秒)
DefaultTimeout = 30 * time.Second // HTTP 请求默认超时时间
)
func getAuthorizationType() string {
return "WECHATPAY2-" + algorithm()
}
// 返回使用的签名算法SHA256-RSA2048
func algorithm() string {
return "SHA256-RSA2048"
}
2 years ago
const (
CodeSuccess = "SUCCESS"
)
type ApiError struct {
Code string `json:"code"`
Message string `json:"message"`
}