Documentation
¶
Index ¶
- type APIVersion
- type CloseOrderParam
- type CloseOrderResult
- type Datetime
- type GoodsDetailItem
- type OrderQueryParam
- type OrderQueryResult
- type Pay
- func (pay *Pay) CloseOrder(ctx context.Context, p *CloseOrderParam, l wx.Logger) (r *CloseOrderResult, err error)
- func (pay *Pay) OrderQuery(ctx context.Context, p *OrderQueryParam, l wx.Logger) (r *OrderQueryResult, err error)
- func (pay *Pay) PaymentNotify(r io.Reader, l wx.Logger) (*OrderQueryResult, error)
- func (pay *Pay) Refund(ctx context.Context, p *RefundParam, l wx.Logger) (r *RefundResult, err error)
- func (pay *Pay) UnifiedOrder(ctx context.Context, p *UnifiedOrderParam, l wx.Logger) (r *UnifiedOrderResult, err error)
- type PayParam
- type PayResult
- type PromotionDetailInfo
- type PromotionDetailItem
- type RefundParam
- type RefundResult
- type SignType
- type TradeState
- type TradeType
- type UnifiedOrderParam
- type UnifiedOrderResult
- type YN
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type APIVersion ¶
type APIVersion string
const ( API_VERSION_DEFAULT APIVersion = "" API_VERSION_1_0 APIVersion = "1.0" )
type CloseOrderParam ¶
type CloseOrderResult ¶
type CloseOrderResult struct {
PayResult
}
type GoodsDetailItem ¶
type OrderQueryParam ¶
type OrderQueryParam struct {
PayParam
// --- Required one of the two
TransactionID string `wx_pay:"transaction_id"`
OutTradeNO string `wx_pay:"out_trade_no"`
Version APIVersion `wx_pay:"version"`
}
type OrderQueryResult ¶
type OrderQueryResult struct {
PayResult
DeviceInfo string `wx_pay:"device_info"`
OpenID string `wx_pay:"openid"`
IsSubscribe YN `wx_pay:"is_subscribe"`
TradeType TradeType `wx_pay:"trade_type"`
TradeState TradeState `wx_pay:"trade_state"`
BankType string `wx_pay:"bank_type"`
TotalFee uint32 `wx_pay:"total_fee"`
SettlementTotalFee uint32 `wx_pay:"settlement_total_fee"` // Do not use this
FeeType string `wx_pay:"fee_type"`
CashFee uint32 `wx_pay:"cash_fee"`
CashFeeType string `wx_pay:"cash_fee_type"`
TransactionID string `wx_pay:"transaction_id"`
OutTradeNO string `wx_pay:"out_trade_no"`
Attach string `wx_pay:"attach"`
TimeEnd Datetime `wx_pay:"time_end"`
TradeStateDesc string `wx_pay:"trade_state_desc"`
// Version notes: recommend to use API_VERSION_1_0
//
// For API_VERSION_DEFAULT (default value), the following fields are presented:
// coupon_fee: the sum fee of coupons used in this order
// coupon_count: the number of coupons used in this order
// coupon_id_$n (dynamic): the id of each coupon
// coupon_type_$n (dynamic): the type of each coupon -> CASH/NO_CASH
// coupon_fee_$n (dynamic): the fee of each coupon
// The last three has dynamic field names so they are stored in Extra
//
// For API_VERSION_1_0, the following fields are NOT presented:
// coupon_fee/coupon_count/coupon_id_$n/coupon_type_$n/coupon_fee_$n
// Instead, these information is encapsulated in a JSON field promotion_detail. See PromotionDetailSt.
//
Version APIVersion `wx_pay:"version"`
CouponFee uint32 `wx_pay:"coupon_fee"`
CouponCount uint32 `wx_pay:"coupon_count"`
PromotionDetail PromotionDetailInfo `wx_pay:"promotion_detail"`
Extra map[string]string `wx_pay:"*"`
UnifiedPromotionDetail *PromotionDetailInfo
}
type Pay ¶
type Pay struct {
// MD5 or HMAC-SHA256.
DefaultSignType SignType
// Max size when reading incoming result. Default to 8k.
MaxResultSize int
// contains filtered or unexported fields
}
Communicate to Wechat's payment service.
func NewPay ¶
Create Pay instance from app config and optinal a HTTP client. NOTE: some Pay APIs need tls client cert verification, if you want to use a custom client, remember to set its tls config, see: AppConfig.PayClientTLSConfig
func (*Pay) CloseOrder ¶
func (pay *Pay) CloseOrder(ctx context.Context, p *CloseOrderParam, l wx.Logger) ( r *CloseOrderResult, err error)
func (*Pay) OrderQuery ¶
func (pay *Pay) OrderQuery(ctx context.Context, p *OrderQueryParam, l wx.Logger) ( r *OrderQueryResult, err error)
func (*Pay) PaymentNotify ¶
func (*Pay) Refund ¶
func (pay *Pay) Refund(ctx context.Context, p *RefundParam, l wx.Logger) ( r *RefundResult, err error)
func (*Pay) UnifiedOrder ¶
func (pay *Pay) UnifiedOrder(ctx context.Context, p *UnifiedOrderParam, l wx.Logger) ( r *UnifiedOrderResult, err error)
type PayParam ¶
type PayParam struct {
AppID string `wx_pay:"appid"`
MchID string `wx_pay:"mch_id"`
NonceStr string `wx_pay:"nonce_str"`
}
Common part of Pay parameters.
type PayResult ¶
type PayResult struct {
ReturnCode string `wx_pay:"return_code"`
ReturnMsg string `wx_pay:"return_msg"`
ResultCode string `wx_pay:"result_code"`
ResultMsg string `wx_pay:"result_msg"`
ErrCode string `wx_pay:"err_code"`
ErrCodeDes string `wx_pay:"err_code_des"`
Sign string `wx_pay:"sign"`
AppID string `wx_pay:"appid"`
MchID string `wx_pay:"mch_id"`
NonceStr string `wx_pay:"nonce_str"`
}
Common part of Pay results.
type PromotionDetailInfo ¶
type PromotionDetailInfo struct {
Items []PromotionDetailItem `json:"promotion_detail"`
}
type PromotionDetailItem ¶
type PromotionDetailItem struct {
ActivityID string `json:"activity_id"` // 微信商户后台配置的批次 ID
PromotionID string `json:"promotion_id"` // 券或者立减优惠 ID
Name string `json:"name"` // 优惠名称
Scope string `json:"scope"` // GLOBAL- 全场代金券/SINGLE- 单品优惠
Type string `json:"type"` // COUPON- 预充代金券(走结算资金)/DISCOUNT- 免充优惠券
Amount uint32 `json:"amount"` // 金额 = 微信出资金额 + 商家出资金额 + 其他出资方金额
WXPayContribute uint32 `json:"wxpay_contribute"` // 微信出资金额
MerchantContribute uint32 `json:"merchant_contribute"` // 商家出资金额
OtherContribute uint32 `json:"other_contribute"` // 其他出资方金额
GoodsDetail []GoodsDetailItem // 单品信息
}
type RefundParam ¶
type RefundParam struct {
PayParam
// --- Required one of the two
TransactionID string `wx_pay:"transaction_id"`
OutTradeNO string `wx_pay:"out_trade_no"`
// --- Required
OutRefundNO string `wx_pay:"out_refund_no"`
TotalFee uint32 `wx_pay:"total_fee"`
RefundFee uint32 `wx_pay:"refund_fee"`
// --- Optional
RefundFeeType string `wx_pay:"refund_fee_type"`
RefundAccount string `wx_pay:"refund_account"`
OpUserID string `wx_pay:"op_user_id"`
DeviceInfo string `wx_pay:"device_info"`
}
type RefundResult ¶
type RefundResult struct {
PayResult
TransactionID string `wx_pay:"transaction_id"`
OutTradeNO string `wx_pay:"out_trade_no"`
OutRefundNO string `wx_pay:"out_refund_no"`
RefundID string `wx_pay:"refund_id"`
RefundFee uint32 `wx_pay:"refund_fee"`
SettlementRefundFee uint32 `wx_pay:"settlement_refund_fee"`
TotalFee uint32 `wx_pay:"total_fee"`
SettlementTotalFee uint32 `wx_pay:"settlement_total_fee"`
FeeType string `wx_pay:"fee_type"`
CashFee uint32 `wx_pay:"cash_fee"`
CashFeeType string `wx_pay:"cash_fee_type"`
CashRefundFee uint32 `wx_pay:"cash_refund_fee"`
CouponRefundFee uint32 `wx_pay:"coupon_refund_fee"`
CouponRefundCount uint32 `wx_pay:"coupon_refund_count"`
Extra map[string]string
}
type TradeState ¶
type TradeState string
const ( TRADE_STATE_SUCCESS TradeState = "SUCCESS" TRADE_STATE_REFUND TradeState = "REFUND" TRADE_STATE_NOTPAY TradeState = "NOTPAY" TRADE_STATE_CLOSED TradeState = "CLOSED" TRADE_STATE_REVOKED TradeState = "REVOKED" TRADE_STATE_USERPAYING TradeState = "USERPAYING" TRADE_STATE_PAYERROR TradeState = "PAYERROR" )
type UnifiedOrderParam ¶
type UnifiedOrderParam struct {
PayParam
// --- Required
TradeType TradeType `wx_pay:"trade_type"`
Body string `wx_pay:"body"`
OutTradeNO string `wx_pay:"out_trade_no"`
TotalFee uint32 `wx_pay:"total_fee"`
SpbillCreateIP string `wx_pay:"spbill_create_ip"`
NotifyURL string `wx_pay:"notify_url"`
// --- Required in some cases
ProductID string `wx_pay:"product_id"`
OpenID string `wx_pay:"openid"`
// --- Optional
DeviceInfo string `wx_pay:"device_info"`
Detail string `wx_pay:"detail"`
Attach string `wx_pay:"attach"`
FeeType string `wx_pay:"fee_type"`
TimeStart Datetime `wx_pay:"time_start"`
TimeExpire Datetime `wx_pay:"time_expire"`
GoodsTag string `wx_pay:"goods_tag"`
LimitPay string `wx_pay:"limit_pay"`
}
type UnifiedOrderResult ¶
Click to show internal directories.
Click to hide internal directories.