Documentation ¶
Index ¶
- Constants
- Variables
- func CurrentTimeStamp() int64
- func CurrentTimeStampMS() int64
- func CurrentTimeStampNS() int64
- func CurrentTimeStampString() string
- func EditAddressParameters(url string, token *oauth.ResAccessToken) (string, error)
- func GenerateNonceStr() string
- func GenerateSignature(reqData PayData, key string, signType SignType) (string, error)
- func GenerateUUID() string
- func IsSignatureValid(xml, key string) bool
- func JsonApiParameters(data PayData) (string, error)
- func MakeSignHMACSHA256(data, key string) string
- func MakeSignMD5(data string) string
- func MapToString(data PayData) string
- func MapToXml(reqData PayData) (string, error)
- func NewPayDomainSimple() *payDomainSimpleImpl
- func ParseInt(b bool) (i int)
- func SHA1(s string) string
- func SandboxSignKey() (string, error)
- func ToUrlParams(data PayData) string
- type CDATA
- type DomainInfo
- type DomainStatics
- type Pay
- func (pay *Pay) ApplySandBox(url string) string
- func (pay *Pay) AuthCodeToOpenid(data PayData) (PayData, error)
- func (pay *Pay) AuthCodeToOpenidTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
- func (pay *Pay) CloseOrder(data PayData) (PayData, error)
- func (pay *Pay) CloseOrderTimeout(data PayData, connectTimeoutMs, readTimeoutMs int) (PayData, error)
- func (pay *Pay) DownloadBill(data PayData) (PayData, error)
- func (pay *Pay) DownloadBillTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
- func (pay *Pay) FillRequestData(data PayData) (PayData, error)
- func (pay *Pay) MicroPay(data PayData) (PayData, error)
- func (pay *Pay) MicroPayTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
- func (pay *Pay) MicroPayWithPos(data PayData) (PayData, error)
- func (pay *Pay) MicroPayWithPosConnectTimeout(data PayData, connectTimeoutMs int) (PayData, error)
- func (pay *Pay) QueryOrder(data PayData) (PayData, error)
- func (pay *Pay) QueryOrderTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
- func (pay *Pay) QueryRefund(data PayData) (PayData, error)
- func (pay *Pay) QueryRefundTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
- func (pay *Pay) Refund(data PayData) (PayData, error)
- func (pay *Pay) RefundTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
- func (pay *Pay) Report(data PayData) (PayData, error)
- func (pay *Pay) ReportTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
- func (pay *Pay) RequestWithCert(url string, data PayData) (string, error)
- func (pay *Pay) RequestWithCertTimeout(url string, data PayData, connectTimeoutMs, readTimeoutMs int) (string, error)
- func (pay *Pay) RequestWithoutCert(url string, data PayData) (string, error)
- func (pay *Pay) RequestWithoutCertTimeout(url string, data PayData, connectTimeoutMs, readTimeoutMs int) (string, error)
- func (pay *Pay) ReverseOrder(data PayData) (PayData, error)
- func (pay *Pay) ReverseOrderTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
- func (pay *Pay) SetSandBox(useSandbox bool) *Pay
- func (pay *Pay) ShortUrl(data PayData) (PayData, error)
- func (pay *Pay) ShortUrlTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
- func (pay *Pay) UnifiedOrder(data PayData) (PayData, error)
- func (pay *Pay) UnifiedOrderTimeout(data PayData, connectTimeoutMs, readTimeoutMs int) (PayData, error)
- type PayConfig
- type PayConfigImpl
- func (impl *PayConfigImpl) AppID() string
- func (impl *PayConfigImpl) AutoReport() bool
- func (impl *PayConfigImpl) Cert() []byte
- func (impl *PayConfigImpl) ConnectTimeoutMs() int
- func (impl *PayConfigImpl) Key() string
- func (impl *PayConfigImpl) MchID() string
- func (impl *PayConfigImpl) PayDomainInstance() PayDomain
- func (impl *PayConfigImpl) ReadTimeoutMs() int
- func (impl *PayConfigImpl) ReportBatchSize() int
- func (impl *PayConfigImpl) ReportQueueMaxSize() int
- func (impl *PayConfigImpl) ReportWorkNum() int
- type PayData
- func AuthCodeToOpenid(data PayData) (PayData, error)
- func CloseOrder(data PayData) (PayData, error)
- func DownloadBill(data PayData) (PayData, error)
- func MicroPay(data PayData) (PayData, error)
- func MicroPayWithPos(data PayData) (PayData, error)
- func QueryOrder(data PayData) (PayData, error)
- func QueryRefund(data PayData) (PayData, error)
- func Refund(data PayData) (PayData, error)
- func Report(data PayData) (PayData, error)
- func ReverseOrder(data PayData) (PayData, error)
- func ShortUrl(data PayData) (PayData, error)
- func UnifiedOrder(data PayData) (PayData, error)
- func XmlToMap(contentXml string) PayData
- type PayDomain
- type PayReport
- type PayRequest
- func (request *PayRequest) RequestOnce(domain, urlSuffix, uuid, data string, connectTimeoutMs, readTimeoutMs int, ...) (string, error)
- func (request *PayRequest) RequestWithCert(urlSuffix, uuid, data string, autoReport bool) (string, error)
- func (request *PayRequest) RequestWithCertTimeout(urlSuffix, uuid, data string, connectTimeoutMs, readTimeoutMs int, ...) (string, error)
- func (request *PayRequest) RequestWithoutCert(urlSuffix, uuid, data string, autoReport bool) (string, error)
- func (request *PayRequest) RequestWithoutCertTimeout(urlSuffix, uuid, data string, connectTimeoutMs, readTimeoutMs int, ...) (string, error)
- type ReportInfo
- type RequestFunc
- type SignType
Constants ¶
const AUTHCODETOOPENID_URL_SUFFIX = "/tools/authcodetoopenid"
const BANKERROR = "BANKERROR"
const CLOSEORDER_URL_SUFFIX = "/pay/closeorder"
const CUSTOM_HEADER = `<?xml version="1.0" encoding="UTF-8" standalone="no"?>`
const DEFAULT_CONNECT_TIMEOUT_MS = 6 * 1000
const DEFAULT_READ_TIMEOUT_MS = 8 * 1000
const DOMAIN_API = "api.mch.weixin.qq.com"
const DOMAIN_API2 = "api2.mch.weixin.qq.com"
const DOMAIN_APIHK = "apihk.mch.weixin.qq.com"
const DOMAIN_APIUS = "apius.mch.weixin.qq.com"
const DOWNLOADBILL_URL_SUFFIX = "/pay/downloadbill"
const FAIL = "FAIL"
const FIELD_SIGN = "sign"
const FIELD_SIGN_TYPE = "sign_type"
const HMACSHA256 = "HMAC-SHA256"
const MD5 = "MD5"
const MICROPAY_URL_SUFFIX = "/pay/micropay"
const MIN_SWITCH_PRIMARY_MSEC = 3 * 60 * 1000
const ORDERQUERY_URL_SUFFIX = "/pay/orderquery"
const REFUNDQUERY_URL_SUFFIX = "/pay/refundquery"
const REFUND_URL_SUFFIX = "/secapi/pay/refund"
const REPORT_URL = "http://report.mch.weixin.qq.com/wxpay/report/default"
const REPORT_URL_SUFFIX = "/payitil/report"
const REVERSE_URL_SUFFIX = "/secapi/pay/reverse"
const SANDBOX_SIGNKEY_URL_SUFFIX = "/sandboxnew/pay/getsignkey"
const SANDBOX_URL_SUFFIX = "/sandboxnew"
const SHORTURL_URL_SUFFIX = "/tools/shorturl"
const SSLCERT_PATH = "./cert/apiclient_cert.pem"
const SSLKEY_PATH = "./cert/apiclient_key.pem"
const SUCCESS = "SUCCESS"
const SYSTEMERROR = "SYSTEMERROR"
const UNIFIEDORDER_URL_SUFFIX = "/pay/unifiedorder"
const USERPAYING = "USERPAYING"
Variables ¶
var ( ErrprConnectTimeout = errors.New("ErrorConnectTimeout") ErrorUnknownHost = errors.New("ErrorUnknownHostException") )
Functions ¶
func CurrentTimeStampMS ¶
func CurrentTimeStampMS() int64
CurrentTimeStampMS get current time with millisecond
func CurrentTimeStampNS ¶
func CurrentTimeStampNS() int64
CurrentTimeStampNS get current time with nanoseconds
func CurrentTimeStampString ¶
func CurrentTimeStampString() string
func EditAddressParameters ¶
func EditAddressParameters(url string, token *oauth.ResAccessToken) (string, error)
func GenerateNonceStr ¶
func GenerateNonceStr() string
func GenerateSignature ¶
GenerateSignature make sign from map data
func GenerateUUID ¶
func GenerateUUID() string
func JsonApiParameters ¶
func MakeSignHMACSHA256 ¶
MakeSignHMACSHA256 make sign with hmac-sha256
func NewPayDomainSimple ¶
func NewPayDomainSimple() *payDomainSimpleImpl
func SandboxSignKey ¶
SandboxSignKey get wechat sandbox sign key
func ToUrlParams ¶
Types ¶
type DomainInfo ¶
type DomainInfo struct { Domain string //域名 PrimaryDomain bool //该域名是否为主域名。例如:api.mch.weixin.qq.com为主域名 }
func NewDomainInfo ¶
func NewDomainInfo(domain string, primary bool) *DomainInfo
func (*DomainInfo) String ¶
func (info *DomainInfo) String() string
type DomainStatics ¶
type DomainStatics struct {
// contains filtered or unexported fields
}
func NewDomainStatics ¶
func NewDomainStatics(domain string) *DomainStatics
type Pay ¶
type Pay struct {
// contains filtered or unexported fields
}
func (*Pay) ApplySandBox ¶
func (*Pay) AuthCodeToOpenid ¶
* AuthCodeToOpenid * 作用: 授权码查询OPENID接口 * 场景:刷卡支付 * @param data 向wxpay post的请求数据 * @return PayData, error API返回数据
func (*Pay) AuthCodeToOpenidTimeout ¶
func (pay *Pay) AuthCodeToOpenidTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
* AuthCodeToOpenidTimeout * 作用: 授权码查询OPENID接口 * 场景:刷卡支付 * @param data 向wxpay post的请求数据 * @param connectTimeoutMs 连接超时时间,单位是毫秒 * @param readTimeoutMs 读超时时间,单位是毫秒 * @return PayData, error API返回数据
func (*Pay) CloseOrder ¶
* * 作用:关闭订单 * 场景:公共号支付、扫码支付、APP支付 * @param data 向wxpay post的请求数据 * @return PayData, error API返回数据
func (*Pay) CloseOrderTimeout ¶
func (pay *Pay) CloseOrderTimeout(data PayData, connectTimeoutMs, readTimeoutMs int) (PayData, error)
* CloseOrderTimeout * 作用:关闭订单 * 场景:公共号支付、扫码支付、APP支付 * @param data 向wxpay post的请求数据 * @param connectTimeoutMs 连接超时时间,单位是毫秒 * @param readTimeoutMs 读超时时间,单位是毫秒 * @return PayData, error API返回数据
func (*Pay) DownloadBill ¶
* DownloadBill * 作用:对账单下载 * 场景:刷卡支付、公共号支付、扫码支付、APP支付 * 其他:无论是否成功都返回Map。若成功,返回的Map中含有return_code、return_msg、data, * 其中return_code为`SUCCESS`,data为对账单数据。 * @param data 向wxpay post的请求数据 * @return PayData, error 经过封装的API返回数据
func (*Pay) DownloadBillTimeout ¶
func (pay *Pay) DownloadBillTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
* DownloadBillTimeout * 作用:对账单下载 * 场景:刷卡支付、公共号支付、扫码支付、APP支付 * 其他:无论是否成功都返回Map。若成功,返回的Map中含有return_code、return_msg、data, * 其中return_code为`SUCCESS`,data为对账单数据。 * @param data 向wxpay post的请求数据 * @param connectTimeoutMs 连接超时时间,单位是毫秒 * @param readTimeoutMs 读超时时间,单位是毫秒 * @return PayData, error 经过封装的API返回数据
func (*Pay) MicroPay ¶
* MicroPay * 作用:提交刷卡支付 * 场景:刷卡支付 * @param data 向wxpay post的请求数据 * @return PayData, error API返回数据
func (*Pay) MicroPayTimeout ¶
func (pay *Pay) MicroPayTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
* MicroPayTimeout * 作用:提交刷卡支付 * 场景:刷卡支付 * @param data 向wxpay post的请求数据 * @param connectTimeoutMs 连接超时时间,单位是毫秒 * @param readTimeoutMs 读超时时间,单位是毫秒 * @return PayData, error API返回数据
func (*Pay) MicroPayWithPos ¶
* MicroPayWithPos * 提交刷卡支付,针对软POS,尽可能做成功 * 内置重试机制,最多60s * @param data * @return PayData, error
func (*Pay) MicroPayWithPosConnectTimeout ¶
* MicroPayWithPosConnectTimeout * 提交刷卡支付,针对软POS,尽可能做成功 * 内置重试机制,最多60s * @param data * @param connectTimeoutMs 连接超时时间,单位是毫秒 * @return PayData, error
func (*Pay) QueryOrder ¶
* QueryOrder * 作用:查询订单 * 场景:刷卡支付、公共号支付、扫码支付、APP支付 * @param data 向wxpay post的请求数据 * @return PayData, error API返回数据
func (*Pay) QueryOrderTimeout ¶
func (pay *Pay) QueryOrderTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
* QueryOrder * 作用:查询订单 * 场景:刷卡支付、公共号支付、扫码支付、APP支付 * @param data 向wxpay post的请求数据 * @param connectTimeoutMs 连接超时时间,单位是毫秒 * @param readTimeoutMs 读超时时间,单位是毫秒 * @return PayData, error API返回数据
func (*Pay) QueryRefundTimeout ¶
func (*Pay) Refund ¶
* Refund * 作用:申请退款 * 场景:刷卡支付、公共号支付、扫码支付、APP支付 * 其他:需要证书 * @param data 向wxpay post的请求数据 * @return PayData, error API返回数据
func (*Pay) RefundTimeout ¶
func (pay *Pay) RefundTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
* RefundTimeout * 作用:申请退款 * 场景:刷卡支付、公共号支付、扫码支付、APP支付 * 其他:需要证书 * @param data 向wxpay post的请求数据 * @param connectTimeoutMs 连接超时时间,单位是毫秒 * @param readTimeoutMs 读超时时间,单位是毫秒 * @return PayData, error API返回数据
func (*Pay) Report ¶
* Report * 作用:交易保障 * 场景:刷卡支付、公共号支付、扫码支付、APP支付 * @param data 向wxpay post的请求数据 * @return PayData, error API返回数据
func (*Pay) ReportTimeout ¶
func (pay *Pay) ReportTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
* ReportTimeout * 作用:交易保障 * 场景:刷卡支付、公共号支付、扫码支付、APP支付 * @param data 向wxpay post的请求数据 * @param connectTimeoutMs 连接超时时间,单位是毫秒 * @param readTimeoutMs 读超时时间,单位是毫秒 * @return PayData, error API返回数据
func (*Pay) RequestWithCert ¶
func (*Pay) RequestWithCertTimeout ¶
func (*Pay) RequestWithoutCert ¶
func (*Pay) RequestWithoutCertTimeout ¶
func (*Pay) ReverseOrder ¶
* ReverseOrder * 作用:撤销订单 * 场景:刷卡支付 * @param data 向wxpay post的请求数据 * @return API返回数据
func (*Pay) ReverseOrderTimeout ¶
func (pay *Pay) ReverseOrderTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
* ReverseOrderTimeout * 作用:撤销订单 * 场景:刷卡支付 * @param data 向wxpay post的请求数据 * @param connectTimeoutMs 连接超时时间,单位是毫秒 * @param readTimeoutMs 读超时时间,单位是毫秒 * @return API返回数据
func (*Pay) SetSandBox ¶
func (*Pay) ShortUrl ¶
* ShortUrl * 作用:转换短链接 * 场景:刷卡支付、扫码支付 * @param data 向wxpay post的请求数据 * @return PayData, error API返回数据
func (*Pay) ShortUrlTimeout ¶
func (pay *Pay) ShortUrlTimeout(data PayData, connectTimeoutMs int, readTimeoutMs int) (PayData, error)
* ShortUrlTimeout * 作用:转换短链接 * 场景:刷卡支付、扫码支付 * @param data 向wxpay post的请求数据 * @param connectTimeoutMs 连接超时时间,单位是毫秒 * @param readTimeoutMs 读超时时间,单位是毫秒 * @return PayData, error API返回数据
func (*Pay) UnifiedOrder ¶
* UnifiedOrder * 作用:统一下单 * 场景:公共号支付、扫码支付、APP支付 * @param data 向wxpay post的请求数据 * @return PayData, error API返回数据
func (*Pay) UnifiedOrderTimeout ¶
func (pay *Pay) UnifiedOrderTimeout(data PayData, connectTimeoutMs, readTimeoutMs int) (PayData, error)
* UnifiedOrder * 作用:统一下单 * 场景:公共号支付、扫码支付、APP支付 * @param data 向wxpay post的请求数据 * @param connectTimeoutMs 连接超时时间,单位是毫秒 * @param readTimeoutMs 读超时时间,单位是毫秒 * @return PayData, error API返回数据
type PayConfig ¶
type PayConfig interface { AppID() string MchID() string Key() string Cert() []byte ConnectTimeoutMs() int ReadTimeoutMs() int PayDomainInstance() PayDomain AutoReport() bool ReportWorkNum() int ReportQueueMaxSize() int ReportBatchSize() int }
func NewPayConfig ¶
func NewPayConfig() PayConfig
func PayConfigInstance ¶
func PayConfigInstance() PayConfig
func SetPayConfig ¶
type PayConfigImpl ¶
type PayConfigImpl struct {
// contains filtered or unexported fields
}
func (*PayConfigImpl) AppID ¶
func (impl *PayConfigImpl) AppID() string
func (*PayConfigImpl) AutoReport ¶
func (impl *PayConfigImpl) AutoReport() bool
func (*PayConfigImpl) Cert ¶
func (impl *PayConfigImpl) Cert() []byte
func (*PayConfigImpl) ConnectTimeoutMs ¶
func (impl *PayConfigImpl) ConnectTimeoutMs() int
func (*PayConfigImpl) Key ¶
func (impl *PayConfigImpl) Key() string
func (*PayConfigImpl) MchID ¶
func (impl *PayConfigImpl) MchID() string
func (*PayConfigImpl) PayDomainInstance ¶
func (impl *PayConfigImpl) PayDomainInstance() PayDomain
func (*PayConfigImpl) ReadTimeoutMs ¶
func (impl *PayConfigImpl) ReadTimeoutMs() int
func (*PayConfigImpl) ReportBatchSize ¶
func (impl *PayConfigImpl) ReportBatchSize() int
func (*PayConfigImpl) ReportQueueMaxSize ¶
func (impl *PayConfigImpl) ReportQueueMaxSize() int
func (*PayConfigImpl) ReportWorkNum ¶
func (impl *PayConfigImpl) ReportWorkNum() int
type PayDomain ¶
type PayDomain interface { Report(string, int64, error) GetDomainInfo() *DomainInfo }
func PayDomainSimpleInstance ¶
func PayDomainSimpleInstance() PayDomain
type PayReport ¶
type PayReport struct {
// contains filtered or unexported fields
}
func PayReportInstance ¶
type PayRequest ¶
type PayRequest struct {
// contains filtered or unexported fields
}
func NewPayRequest ¶
func NewPayRequest(config PayConfig) *PayRequest
func (*PayRequest) RequestOnce ¶
func (request *PayRequest) RequestOnce(domain, urlSuffix, uuid, data string, connectTimeoutMs, readTimeoutMs int, useCert bool) (string, error)
*
- 请求,只请求一次,不做重试
- @param domain
- @param urlSuffix
- @param uuid
- @param data
- @param connectTimeoutMs
- @param readTimeoutMs
- @param useCert 是否使用证书,针对退款、撤销等操作
- @return
- @throws Exception
func (*PayRequest) RequestWithCert ¶
func (request *PayRequest) RequestWithCert(urlSuffix, uuid, data string, autoReport bool) (string, error)
func (*PayRequest) RequestWithCertTimeout ¶
func (*PayRequest) RequestWithoutCert ¶
func (request *PayRequest) RequestWithoutCert(urlSuffix, uuid, data string, autoReport bool) (string, error)
func (*PayRequest) RequestWithoutCertTimeout ¶
type ReportInfo ¶
type ReportInfo struct { // 基本信息 Version string Sdk string Uuid string // 交易的标识 Timestamp int64 // 上报时的时间戳,单位秒 ElapsedTimeMillis int64 // 耗时,单位 毫秒 // 针对主域名 FirstDomain string // 第1次请求的域名 PrimaryDomain bool //是否主域名 FirstConnectTimeoutMillis int // 第1次请求设置的连接超时时间,单位 毫秒 FirstReadTimeoutMillis int // 第1次请求设置的读写超时时间,单位 毫秒 FirstHasDnsError int // 第1次请求是否出现dns问题 FirstHasConnectTimeout int // 第1次请求是否出现连接超时 FirstHasReadTimeout int // 第1次请求是否出现连接超时 }
func NewReportInfo ¶
func (*ReportInfo) ToLineString ¶
func (r *ReportInfo) ToLineString(key string) string
func (*ReportInfo) ToString ¶
func (r *ReportInfo) ToString() string