epay

package
v1.15.9 Latest Latest
Warning

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

Go to latest
Published: Jul 28, 2026 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrQueryNotSupported = errors.New("gateway does not support order query API")

ErrQueryNotSupported is returned when the payment gateway implements neither the standard EPay order query API nor the EasyPay-compatible fallback API — the endpoint returns HTTP 404 or answers with something that is not JSON at all (e.g. an HTML error page).

Functions

func FormatMoney added in v1.14.0

func FormatMoney(amount float64) string

FormatMoney returns the exact two-decimal amount sent to an EPay-compatible gateway. It intentionally preserves the historical truncation behaviour.

func ParseMoney added in v1.14.0

func ParseMoney(value string) (int64, error)

ParseMoney converts a non-negative decimal amount to its integer minor unit. It rejects floats, exponents and values with more than two decimal places.

Types

type Client

type Client struct {
	Pid  string
	Url  string
	Key  string
	Type string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(pid, url, key string, Type string) *Client

func (*Client) CreatePayUrl

func (c *Client) CreatePayUrl(order Order) (string, error)

CreatePayUrl builds the browser redirect URL for EPay's submit.php endpoint.

func (*Client) QueryOrder added in v1.14.0

func (c *Client) QueryOrder(orderNo string) (*QueryResult, error)

QueryOrder obtains payment details directly from the gateway. It first uses the standard EPay api.php protocol. When that endpoint is absent, it falls back to a known EasyPay-compatible POST protocol that exposes only status.

func (*Client) QueryOrderStatus

func (c *Client) QueryOrderStatus(orderNo string) bool

QueryOrderStatus is kept for callers that only need a status boolean.

func (*Client) VerifySign

func (c *Client) VerifySign(params map[string]string) bool

type Order

type Order struct {
	Name      string
	OrderNo   string
	Amount    float64
	SignType  string
	NotifyUrl string
	ReturnUrl string
}

type QueryResult added in v1.14.0

type QueryResult struct {
	MerchantID string
	TradeNo    string
	OrderNo    string
	Type       string
	Money      string
	Paid       bool
	Message    string
	// StatusOnly reports that the gateway query API returned only a payment
	// status. Callers must not treat omitted payment details as verified.
	StatusOnly bool
}

Jump to

Keyboard shortcuts

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