model

package
v1.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Dec 8, 2023 License: MIT Imports: 4 Imported by: 0

Documentation

Index

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) * 10
	SUCCESS
	REFUND
	CLOSED
	ERROR
)

支付状态

View Source
const (
	Wx       = "Wx"
	WxPub    = "WxPub"
	WxLite   = "WxLite"
	WxApp    = "WxApp"
	WxNative = "WxNative"

	Ali       = "Ali"
	AlipayPc  = "AlipayPc"
	AlipayWap = "AlipayWap"
	AlipayApp = "AlipayApp"
	AlipayQr  = "AlipayQr"
	AlipayBar = "AlipayBar"
	Mock      = "mock"
	Wallet    = "wallet"
)

支付渠道

Variables

This section is empty.

Functions

func ParseDate

func ParseDate(timeStr string) time.Time

Types

type Client

type Client interface {
	// Init 初始化
	Init() error
	// UnifiedOrder 统一下单
	UnifiedOrder(context.Context, OrderUnifiedReq) (*OrderResp, error)
	// GetId 获取渠道id
	GetId() uint64
	// GetOrder 获得支付订单
	GetOrder(context.Context, string) (*OrderResp, error)
	// Refresh 刷新配置
	Refresh(config ClientConfig) error
	// UnifiedRefund 退款 返回 WAIT 状态. 后续 job 会轮询
	UnifiedRefund(context.Context, RefundUnifiedReq) (*RefundResp, error)
	// ParseOrderNotify 解析支付回调
	ParseOrderNotify(r *http.Request) (*OrderResp, error)
}

Client 支付客户端

type ClientConfig

type ClientConfig interface {
	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 CloseOf

func CloseOf(channelErrorCode, channelErrorMsg, outTradeNo string, rawData any) *OrderResp

func Of

func Of(status uint8, channelOrderNo string, channelUserId *string, successTime time.Time, outTradeNo string, rawData any) *OrderResp

Of 创建支付订单

func SuccessOf

func SuccessOf(channelOrderNo string, channelUserId string, successTime time.Time, outTradeNo string, rawData any) *OrderResp

SuccessOf 创建支付成功订单

func WaitingOf

func WaitingOf(displayMode, displayContent *string, outTradeNo string, rawData any) *OrderResp

WaitingOf 创建等待支付订单

type OrderUnifiedReq

type OrderUnifiedReq struct {
	UserIp        string
	OutTradeNo    string
	Subject       string
	Body          string
	NotifyUrl     string
	ReturnUrl     string
	Price         int32
	ExpireTime    time.Time
	ChannelExtras map[string]string
	DisplayMode   string
}

type Properties

type Properties struct {
	OrderNotifyUrl  string
	RefundNotifyUrl string
	OrderNoPrefix   string
	RefundNoPrefix  string
}

Properties 支付配置

type RefundResp

type RefundResp struct {
	Status           uint8
	OutRefundNo      string
	ChannelRefundNo  string
	SuccessTime      time.Time
	RawData          any
	ChannelErrorCode string
	ChannelErrorMsg  string
}

type RefundUnifiedReq

type RefundUnifiedReq struct {
	OutTradeNo  string
	OutRefundNo string
	Reason      string
	PayPrice    int32
	RefundPrice int32
	NotifyUrl   string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL