Documentation
¶
Overview ¶
Package pay 微信支付的相关接口
Index ¶
- Constants
- Variables
- func NonceString() string
- func Sign(apikey, signType string, params map[string]string) (string, error)
- type Coupon
- type Pay
- func (p *Pay) APIKey() string
- func (p *Pay) AppID() string
- func (p *Pay) CloseOrder(params map[string]string) (map[string]string, error)
- func (p *Pay) DownloadBill(params map[string]string) (map[string]string, error)
- func (p *Pay) MchID() string
- func (p *Pay) OrderQuery(params map[string]string) (map[string]string, error)
- func (p *Pay) Post(url string, params map[string]string) (map[string]string, error)
- func (p *Pay) Refund(params map[string]string) (map[string]string, error)
- func (p *Pay) RefundQuery(params map[string]string) (map[string]string, error)
- func (p *Pay) Report(params map[string]string) (map[string]string, error)
- func (p *Pay) Sign(signType string, params map[string]string) (string, error)
- func (p *Pay) UnifiedOrder(params map[string]string) (map[string]string, error)
- func (p *Pay) ValidateAll(signType string, params map[string]string) error
- func (p *Pay) ValidateResult(params map[string]string) error
- func (p *Pay) ValidateReturn(params map[string]string) error
- func (p *Pay) ValidateSign(signType string, params map[string]string) error
Constants ¶
View Source
const ( Success = "SUCCESS" Fail = "FAIL" )
返回状态的值
View Source
const ( UnifiedOrderURL = "https://api.mch.weixin.qq.com/pay/unifiedorder" OrderQueryURL = "https://api.mch.weixin.qq.com/pay/orderquery" CloseOrderURL = "https://api.mch.weixin.qq.com/pay/closeorder" RefundURL = "https://api.mch.weixin.qq.com/secapi/pay/refund" RefundQueryURL = "https://api.mch.weixin.qq.com/pay/refundquery" DownloadBillURL = "https://api.mch.weixin.qq.com/pay/downloadbill" ReportURL = "https://api.mch.weixin.qq.com/payitil/report" )
接口地址
View Source
const ( TradeTypeJSAPI = "JSAPI" // 公众号 TradeTypeNative = "NATIVE" // 扫码 TradeTypeApp = "APP" )
交易类型
View Source
const ( SignTypeMD5 = "MD5" SignTypeHmacSha256 = "HMAC-SHA256" )
签名的类型
View Source
const ( RefundSourceRechargeFunds = "REFUND_SOURCE_UNSETTLED_FUNDS" // 可用余额退款 RefundSourceUnsettledFunds = "REFUND_SOURCE_UNSETTLED_FUNDS" // 未结算资金退款(默认使用未结算资金退款) )
退款奖金来源
View Source
const ( RefundChannelOriginal = "ORIGINAL" // 原路退款 RefundChannelBalance = "BALANCE" // 退回到余额 )
退款渠道
View Source
const ( CouponTypeCash = "CASH" // 充值代金券 CouponTypeNoCash = "NO_CASH" // 非充值代金券 )
代金券类型
View Source
const DateFormat = "20060102150405"
DateFormat 日期格式
View Source
const TimeFixed time.Duration = 3600 * 8
TimeFixed 时间戳调整,东八区
Variables ¶
View Source
var ( ErrInvalidAppid = errors.New("返回的 appid 与当前的不匹配") ErrInvalidMchid = errors.New("返回的 mch_id 与当前的不匹配") ErrInvalidSign = errors.New("不存在签名或是签名无法验证") )
预定义的错误类型
Functions ¶
Types ¶
type Coupon ¶
type Coupon struct { ID int // 代金券ID Type string // 代金券类型,CASH--充值代金券、NO_CASH--非充值代金券 Fee int // 单个代金券支付金额 }
Coupon 代金券
type Pay ¶
type Pay struct {
// contains filtered or unexported fields
}
Pay 支付的基本配置
func (*Pay) CloseOrder ¶
CloseOrder 关闭订单
func (*Pay) DownloadBill ¶
DownloadBill 下载对账单
func (*Pay) OrderQuery ¶
OrderQuery 订单查询
func (*Pay) Post ¶
Post 发送请求,会优先使用 params 中的相关参数。 比如:若已经指定了 appid,会不会使用 pay.AppID; 若使用了 sign,则不会再计算 sign 值。
func (*Pay) RefundQuery ¶
RefundQuery 退款查询
func (*Pay) UnifiedOrder ¶
UnifiedOrder 执行统一下单
func (*Pay) ValidateAll ¶
ValidateAll 验证 ValidateSign 和 appid 及 mchid 是否匹配
func (*Pay) ValidateResult ¶
ValidateResult 验证从微信端返回的数据,同时验证 return_code 和 result_code
func (*Pay) ValidateReturn ¶
ValidateReturn 验证从微信端返回的数据,仅验证 return_code
Directories
¶
Path | Synopsis |
---|---|
Package notify 用于处理微信回调通知
|
Package notify 用于处理微信回调通知 |
Package refund 执行退款操作
|
Package refund 执行退款操作 |
Package unifiedorder 执行微信的下单操作
|
Package unifiedorder 执行微信的下单操作 |
Click to show internal directories.
Click to hide internal directories.