Documentation ¶
Index ¶
- Constants
- Variables
- func IsClosed(status string) bool
- func IsFinished(status string) bool
- func IsOK(err error) bool
- func IsProcessing(status string) bool
- func IsSuccess(status string) bool
- func IsWaitPay(status string) bool
- func ParseMultiAccount(cfg string, subtype string) string
- func RegisterAccountSetDefaults(platform string, fn func(a *Account))
- func UnregisterAccountSetDefaults(platform string)
- type Account
- func (c *Account) FromStore(v echo.Store) *Account
- func (c *Account) HasCurrency(currencies ...string) bool
- func (c *Account) Lite() *AccountLite
- func (c *Account) ParseAppID(subtype string) (appID string)
- func (c *Account) ParseAppSecret(subtype string) (appSecret string)
- func (c *Account) SetDefaults(platform string) *Account
- type AccountLite
- type Currency
- type Device
- type GoodsType
- type OK
- type OKer
- type Options
- type Pay
- type PayResponse
- type Query
- type Refund
- type RefundItem
- type Result
- type SortByAccount
- type Subtype
- type SubtypeOption
- type Support
- type Supports
Constants ¶
View Source
const ( // OperationPayment 付款操作 OperationPayment = "payment" // OperationRefund 退款操作 OperationRefund = "refund" )
View Source
const ( // TradeStatusWaitBuyerPay 交易创建,等待买家付款 TradeStatusWaitBuyerPay = "WAIT_BUYER_PAY" // TradeStatusClosed 未付款交易超时关闭,或支付完成后全额退款 TradeStatusClosed = "TRADE_CLOSED" // TradeStatusSuccess 交易支付成功 TradeStatusSuccess = "TRADE_SUCCESS" // TradeStatusFinished 交易结束,不可退款 TradeStatusFinished = "TRADE_FINISHED" // TradeStatusException 交易异常(用于退款) TradeStatusException = "TRADE_EXCEPTION" // TradeStatusProcessing 交易中(用于退款) TradeStatusProcessing = "TRADE_PROCESSING" )
Variables ¶
View Source
var ( ErrTradeAlreadyExists = errors.New("payment trade already exists") ErrUnknownDevice = errors.New("unknown device type") ErrSignature = errors.New("signature error") ErrPaymentFailed = errors.New("payment failed") ErrRefundAlreadyExists = errors.New("refund request already exists") ErrRefundFailed = errors.New("refund failed") ErrUnsupported = errors.New("unsupported") ErrAppIDRequired = errors.New(`AppID required`) ErrAppSecretRequired = errors.New(`AppSecret required`) ErrSubtypeRequired = errors.New(`Subtype required`) )
Functions ¶
func IsFinished ¶ added in v0.0.21
func ParseMultiAccount ¶ added in v0.3.14
func RegisterAccountSetDefaults ¶ added in v0.2.2
func UnregisterAccountSetDefaults ¶ added in v0.2.2
func UnregisterAccountSetDefaults(platform string)
Types ¶
type Account ¶
type Account struct { Debug bool `json:"debug"` //是否debug环境(如果支持沙箱环境则自动采用沙箱环境) AppID string `json:"appID,omitempty"` //即AppID AppSecret string `json:"appSecret,omitempty"` //即AppKey MerchantID string `json:"merchantID,omitempty"` //商家ID PublicKey string `json:"publicKey,omitempty"` //公钥 PrivateKey string `json:"privateKey,omitempty"` //私钥 CertPath string `json:"certPath,omitempty"` //证书路径 WebhookID string `json:"webhookID,omitempty"` //Paypal使用的webhook id Currencies []string `json:"currencies,omitempty"` //支持的币种 Subtype *Subtype `json:"subtype,omitempty"` //子类型(用于选择第四方平台内支持的支付方式) Sort int `json:"sort"` //排序编号 Options Options `json:"options,omitempty"` //其它选项 }
Account 付款平台账号参数
func NewAccount ¶
func NewAccount() *Account
func (*Account) HasCurrency ¶ added in v0.6.2
func (*Account) Lite ¶ added in v0.2.13
func (c *Account) Lite() *AccountLite
func (*Account) ParseAppID ¶ added in v0.3.14
func (*Account) ParseAppSecret ¶ added in v0.3.14
func (*Account) SetDefaults ¶ added in v0.2.2
type AccountLite ¶ added in v0.2.13
type AccountLite struct { Debug bool `json:"debug"` //是否debug环境(如果支持沙箱环境则自动采用沙箱环境) Currencies []string `json:"currencies,omitempty"` //支持的币种 Subtype *Subtype `json:"subtype,omitempty"` //子类型(用于选择第四方平台内支持的支付方式) Sort int `json:"sort"` //排序编号 Options Options `json:"options,omitempty"` //其它选项 }
AccountLite Account脱敏后的结构体
func (*AccountLite) HasCurrency ¶ added in v0.6.2
func (c *AccountLite) HasCurrency(currencies ...string) bool
type Currency ¶ added in v0.0.5
type Currency string
Currency 币种
const ( // USD 美元 USD Currency = `USD` // CNY 人民币 CNY Currency = `CNY` // RUB 俄罗斯卢布 RUB Currency = `RUB` // EUR 欧元 EUR Currency = `EUR` // GBP 英镑 GBP Currency = `GBP` // HKD 港元 HKD Currency = `HKD` // JPY 日元 JPY Currency = `JPY` // KRW 韩元 KRW Currency = `KRW` // AUD 澳元 AUD Currency = `AUD` // CAD 加元 CAD Currency = `CAD` )
type Device ¶
type Device string
Device 设备类型
func DeviceList ¶ added in v0.0.22
func DeviceList() []Device
func (Device) IsSupported ¶ added in v0.0.22
IsSupported 是否是支持的设备
type Pay ¶
type Pay struct { Platform string //付款平台(alipay/wechat/paypal) Subtype string //子类型(用于选择第四方平台内支持的支付方式) Device Device //付款时的设备 NotifyURL string //接收付款结果通知的网址 ReturnURL string //支付操作后返回的网址 CancelURL string //取消付款后返回的网址 Subject string //主题描述 OutTradeNo string //业务方的交易号(我们的订单号) Amount float64 //支付金额 Currency Currency //币种 GoodsType GoodsType //商品类型 PassbackParams string //回传参数 ExpiredAt time.Time //支付过期时间 Options echo.H //其它选项 }
Pay 付款参数
func (*Pay) GoodsTypeName ¶
type PayResponse ¶ added in v0.0.20
type Query ¶ added in v0.0.12
type Query struct { Platform string //付款平台 Subtype string //子类型(用于选择第四方平台内支持的支付方式) TradeNo string //付款平台的交易号 OutTradeNo string //业务方的交易号(我们的订单号) RefundNo string //付款平台的退款单号 (退款查询时有效) OutRefundNo string //业务方的退款单号 (退款查询时有效) Options echo.H //其它选项 }
Query 查询参数
func (*Query) CopyFromRefund ¶ added in v0.1.1
type Refund ¶
type Refund struct { Platform string //付款平台 Subtype string //子类型(用于选择第四方平台内支持的支付方式) TradeNo string //付款平台的交易号 OutTradeNo string //业务方的交易号(我们的订单号) RefundNo string //付款平台退单号 OutRefundNo string //业务方退单号 TotalAmount float64 //订单总金额(alipay可不传) RefundAmount float64 //退款金额 RefundReason string //退款原因(选填) Currency Currency //币种 NotifyURL string //接收退款结果通知的网址 Options echo.H //其它选项 }
Refund 退款参数
type RefundItem ¶ added in v0.0.20
type RefundItem struct { Status string // 退款状态 RefundFee float64 // 退款金额 OutRefundNo string // 业务方退款单号 RefundNo string // 支付网关退款号 }
RefundItem 退款项数据
type Result ¶ added in v0.0.20
type Result struct { Operation string // 操作类型 Status string // 状态 TradeNo string // 支付网关交易号 OutTradeNo string // 业务方交易号 TotalAmount float64 // 订单总金额 Currency string // 币种 PayAmount float64 // 在网关支付的金额(如果为0,表示和订单的金额一致) PayCurrency string // 在网关支付的币种(如果为空,表示和订单的币种一样) TransactionFeeValue float64 // 交易手续费金额 TransactionFeeCurrency string // 交易手续费币种 Reason string // 失败原因 PassbackParams string // 原样回传参数 OutRefundNo string // 本地退款单号(退款时有效) RefundNo string // 支付网关退款号 RefundFee float64 // 退款金额(退款时有效) RefundItems []*RefundItem // 退款项列表 // - 原始数据 - Raw interface{} }
Result 付款或退款结果数据
func (*Result) AddRefundItem ¶ added in v0.0.20
func (r *Result) AddRefundItem(items ...*RefundItem) *Result
AddRefundItem 添加退款项数据
func (*Result) GetPayAmount ¶ added in v0.0.32
func (*Result) GetPayCurrency ¶ added in v0.0.33
func (*Result) GetRefundItem ¶ added in v0.0.20
func (r *Result) GetRefundItem(outRefundNo string, refundNo string) *RefundItem
GetRefundItem 获取退款项数据
type SortByAccount ¶ added in v0.2.13
type SortByAccount []*Account
func (SortByAccount) Len ¶ added in v0.2.13
func (s SortByAccount) Len() int
func (SortByAccount) Less ¶ added in v0.2.13
func (s SortByAccount) Less(i, j int) bool
func (SortByAccount) Lite ¶ added in v0.2.13
func (s SortByAccount) Lite() []*AccountLite
func (SortByAccount) Sort ¶ added in v0.2.13
func (s SortByAccount) Sort() SortByAccount
func (SortByAccount) Swap ¶ added in v0.2.13
func (s SortByAccount) Swap(i, j int)
type Subtype ¶ added in v0.2.1
type Subtype struct { Label string `json:"label"` Options []*SubtypeOption `json:"options"` }
func NewSubtype ¶ added in v0.2.2
func NewSubtype(label string, options ...*SubtypeOption) *Subtype
func (*Subtype) Add ¶ added in v0.2.2
func (s *Subtype) Add(o ...*SubtypeOption) *Subtype
func (*Subtype) GetOption ¶ added in v0.2.7
func (s *Subtype) GetOption(value string) *SubtypeOption
type SubtypeOption ¶ added in v0.2.1
Click to show internal directories.
Click to hide internal directories.