Documentation
¶
Index ¶
- Constants
- func ParseDate(timeStr string) time.Time
- func ParseOrderNotify(code string, r *http.Request) (req []byte, err error)
- type Client
- type ClientConfig
- type OrderResp
- func CloseOf(channelErrorCode, channelErrorMsg, outTradeNo string, rawData any) *OrderResp
- func Of(status uint8, channelOrderNo string, channelUserId *string, ...) *OrderResp
- func SuccessOf(channelOrderNo string, channelUserId string, successTime time.Time, ...) *OrderResp
- func WaitingOf(displayMode, displayContent *string, outTradeNo string, rawData any) *OrderResp
- type OrderUnifiedReq
- type PayStrategy
- type Properties
- type RefundResp
- type RefundUnifiedReq
Constants ¶
View Source
const ( Url = "url" Iframe = "iframe" From = "from" QrCode = "qr_code" QrCodeUrl = "qr_code_url" BarCode = "bar_code" App = "app" )
支付方式
View Source
const ( WAITING uint8 = iota + 1 SUCCESS REFUND CLOSED ERROR )
支付状态
View Source
const ( Wx = "Wx" WxPub = "WxPub" WxLite = "WxLite" WxApp = "WxApp" WxNative = "WxNative" Ali = "Ali" AlipayPc = "AlipayPc" AlipayWap = "AlipayWap" AlipayQr = "AlipayQr" AlipayBar = "AlipayBar" Mock = "mock" )
支付渠道
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client interface {
// Init 初始化
Init() error
// UnifiedOrder 统一下单
UnifiedOrder(context.Context, string, OrderUnifiedReq) (*OrderResp, error)
// GetOrder 获得支付订单
GetOrder(context.Context, string) (*OrderResp, error)
// Refresh 刷新配置
Refresh(config ClientConfig) error
// UnifiedRefund 退款 返回 WAIT 状态. 后续 job 会轮询
UnifiedRefund(context.Context, RefundUnifiedReq) (*RefundResp, error)
// ParseOrderNotify 解析支付回调
ParseOrderNotify([]byte) (*OrderResp, error)
}
Client 支付客户端
type ClientConfig ¶
type ClientConfig interface {
// Validate 参数校验
Validate() error
}
ClientConfig 支付客户端配置
type OrderResp ¶
type OrderResp struct {
Status uint8
OutTradeNo string
ChannelOrderNo string
ChannelUserId *string
SuccessTime time.Time
RawData any
DisplayMode *string
DisplayContent *string
ChannelErrorCode *string
ChannelErrorMsg *string
}
func Of ¶
func Of(status uint8, channelOrderNo string, channelUserId *string, successTime time.Time, outTradeNo string, rawData any) *OrderResp
Of 创建支付订单
type OrderUnifiedReq ¶
type PayStrategy ¶
type PayStrategy interface {
UnifiedOrder(ctx context.Context, req OrderUnifiedReq) (*OrderResp, error)
}
type Properties ¶
type Properties struct {
OrderNotifyUrl string `json:",env=ORDER_NOTIFY_URL"`
RefundNotifyUrl string `json:",env=REFUND_NOTIFY_URL"`
OrderNoPrefix string `json:",default=P"`
RefundNoPrefix string `json:",default=R"`
}
Properties 支付配置
type RefundResp ¶
Click to show internal directories.
Click to hide internal directories.