pay

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 24, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlipayConfig

type AlipayConfig struct {
	AppID               string `json:"app_id"`
	PrivateKeyPath      string `json:"private_key_path"`
	AlipayPublicKeyPath string `json:"alipay_public_key_path"`
	NotifyURL           string `json:"notify_url"`
	ReturnURL           string `json:"return_url"`
	Sandbox             bool   `json:"sandbox"`
}

type CaptureRequest

type CaptureRequest struct {
	OutTradeNo    string `json:"out_trade_no"`
	ProviderTxnId string `json:"provider_txn_id"`
	Amount        int64  `json:"amount"`
}

type CaptureResult

type CaptureResult struct {
	Success bool           `json:"success"`
	Raw     map[string]any `json:"raw"`
}

type CardConfig

type CardConfig struct {
	Gateway        string `json:"gateway"`
	MerchantID     string `json:"merchant_id"`
	PrivateKeyPath string `json:"private_key_path"`
	PublicKeyPath  string `json:"public_key_path"`
	NotifyURL      string `json:"notify_url"`
	ThreeDSEnabled bool   `json:"threeds_enabled"`
}

type ClientAction

type ClientAction struct {
	Kind ClientActionKind  `json:"kind"`
	Data map[string]string `json:"data"`
}

type ClientActionKind

type ClientActionKind string
const (
	ActionRedirect   ClientActionKind = "redirect"
	ActionQRCode     ClientActionKind = "qrcode"
	ActionInvokeSDK  ClientActionKind = "invokeSDK"
	ActionDeepLink   ClientActionKind = "deeplink"
	ActionMiniParams ClientActionKind = "miniProgramParams"
)

type CloseRequest

type CloseRequest struct {
	OutTradeNo string `json:"out_trade_no"`
}

type CombinedCreateRequest

type CombinedCreateRequest struct {
	CombineOutTradeNo string             `json:"combine_out_trade_no"`
	Scene             PayScene           `json:"scene"`
	SubOrders         []CombinedSubOrder `json:"sub_orders"`
	NotifyURL         string             `json:"notify_url"`
}

type CombinedSubOrder

type CombinedSubOrder struct {
	MchID       string `json:"mchid"`
	AppID       string `json:"appid"`
	OutTradeNo  string `json:"out_trade_no"`
	Amount      int64  `json:"amount"`
	Description string `json:"description"`
	PayerOpenID string `json:"payer_openid"`
}

type NotifyEvent

type NotifyEvent struct {
	EventType      string        `json:"event_type"`
	Transaction    *Transaction  `json:"transaction"`
	Refund         *RefundResult `json:"refund"`
	IdempotencyKey string        `json:"idempotency_key"`
}

type PayChannel

type PayChannel string
const (
	ChannelAlipay PayChannel = "ALIPAY"
	ChannelWechat PayChannel = "WECHAT"
	ChannelCard   PayChannel = "CARD"
)

type PayDriver

type PayDriver interface {
	Create(ctx context.Context, intent *PayIntent) (*ClientAction, *Transaction, error)
	Query(ctx context.Context, req *QueryRequest) (*Transaction, error)
	Close(ctx context.Context, req *CloseRequest) error
	Refund(ctx context.Context, req *RefundRequest) (*RefundResult, error)
	Capture(ctx context.Context, req *CaptureRequest) (*CaptureResult, error)
	ParseNotify(ctx context.Context, headers map[string]string, body []byte) (*NotifyEvent, error)
	ProfitShare(ctx context.Context, req *ProfitShareRequest) (*ProfitShareResult, error)
	CreateCombined(ctx context.Context, req *CombinedCreateRequest) (*ClientAction, error)
}

type PayIntent

type PayIntent struct {
	OutTradeNo  string            `json:"out_trade_no"`
	Amount      int64             `json:"amount"`
	Currency    string            `json:"currency"`
	Subject     string            `json:"subject"`
	Description string            `json:"description"`
	Scene       PayScene          `json:"scene"`
	Channel     PayChannel        `json:"channel"`
	NotifyURL   string            `json:"notify_url"`
	ReturnURL   string            `json:"return_url"`
	ExpireAt    time.Time         `json:"expire_at"`
	Payer       PayerInfo         `json:"payer"`
	Attach      map[string]string `json:"attach"`
	Extra       map[string]string `json:"extra"`
	Split       []SplitInfo       `json:"split"`
}

type PayScene

type PayScene string
const (
	SceneAPP         PayScene = "APP"
	SceneH5          PayScene = "H5"
	ScenePCQR        PayScene = "PC_QR"
	SceneJSAPI       PayScene = "JSAPI"
	SceneMiniProgram PayScene = "MINI_PROGRAM"
	SceneNative      PayScene = "NATIVE"
	SceneMicroPay    PayScene = "MICROPAY"
	ScenePreAuth     PayScene = "PREAUTH"
)

type PayerInfo

type PayerInfo struct {
	OpenID    string `json:"open_id"`
	UserID    string `json:"user_id"`
	CardToken string `json:"card_token"`
}

type PaymentError

type PaymentError struct {
	Code        string
	Message     string
	Retryable   bool
	ProviderRaw map[string]any
}

func (*PaymentError) Error

func (e *PaymentError) Error() string

type ProfitShareReceiver

type ProfitShareReceiver struct {
	Type    string `json:"type"`
	Account string `json:"account"`
	Amount  int64  `json:"amount"`
	Desc    string `json:"desc"`
}

type ProfitShareRequest

type ProfitShareRequest struct {
	OutTradeNo      string                `json:"out_trade_no"`
	ProviderTxnId   string                `json:"provider_txn_id"`
	OutOrderNo      string                `json:"out_order_no"`
	Receivers       []ProfitShareReceiver `json:"receivers"`
	UnfreezeUnsplit bool                  `json:"unfreeze_unsplit"`
}

type ProfitShareResult

type ProfitShareResult struct {
	Success bool           `json:"success"`
	Raw     map[string]any `json:"raw"`
}

type QueryRequest

type QueryRequest struct {
	OutTradeNo    string `json:"out_trade_no"`
	ProviderTxnId string `json:"provider_txn_id"`
}

type RefundRequest

type RefundRequest struct {
	OutRefundNo   string            `json:"out_refund_no"`
	OutTradeNo    string            `json:"out_trade_no"`
	ProviderTxnId string            `json:"provider_txn_id"`
	Amount        int64             `json:"amount"`
	Reason        string            `json:"reason"`
	Attach        map[string]string `json:"attach"`
}

type RefundResult

type RefundResult struct {
	Success     bool           `json:"success"`
	OutRefundNo string         `json:"out_refund_no"`
	RefundId    string         `json:"refund_id"`
	Raw         map[string]any `json:"raw"`
}

type SplitInfo

type SplitInfo struct {
	Receiver string `json:"receiver"`
	Amount   int64  `json:"amount"`
	Desc     string `json:"desc"`
}

type Transaction

type Transaction struct {
	Status        TransactionStatus `json:"status"`
	Provider      string            `json:"provider"`
	Channel       PayChannel        `json:"channel"`
	Scene         PayScene          `json:"scene"`
	OutTradeNo    string            `json:"out_trade_no"`
	ProviderTxnId string            `json:"provider_txn_id"`
	Amount        int64             `json:"amount"`
	Currency      string            `json:"currency"`
	Payer         PayerInfo         `json:"payer"`
	Raw           map[string]any    `json:"raw"`
}

type TransactionStatus

type TransactionStatus string
const (
	TxCreated           TransactionStatus = "CREATED"
	TxPending           TransactionStatus = "PENDING"
	TxPaid              TransactionStatus = "PAID"
	TxAuthorized        TransactionStatus = "AUTHORIZED"
	TxCaptured          TransactionStatus = "CAPTURED"
	TxClosed            TransactionStatus = "CLOSED"
	TxRefunded          TransactionStatus = "REFUNDED"
	TxPartiallyRefunded TransactionStatus = "PARTIALLY_REFUNDED"
	TxFailed            TransactionStatus = "FAILED"
	TxExpired           TransactionStatus = "EXPIRED"
)

type WechatConfig

type WechatConfig struct {
	MchID            string `json:"mch_id"`
	AppID            string `json:"app_id"`
	ApiV3Key         string `json:"api_v3_key"`
	SerialNo         string `json:"serial_no"`
	PrivateKeyPath   string `json:"private_key_path"`
	PlatformCertPath string `json:"platform_cert_path"`
	NotifyURL        string `json:"notify_url"`
}

Source Files

  • config.go
  • types.go

Jump to

Keyboard shortcuts

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