Documentation
¶
Index ¶
- Constants
- Variables
- func FormatMoney(amount float64) string
- func ParseMoney(value string) (int64, error)
- type Client
- func (c *Client) CreatePayUrl(order Order) string
- func (c *Client) CreatePayment(ctx context.Context, order Order) (*PaymentResult, error)
- func (c *Client) QueryOrder(orderNo string) (*QueryResult, error)
- func (c *Client) QueryOrderStatus(orderNo string) bool
- func (c *Client) VerifySign(params map[string]string) bool
- type Order
- type PaymentResult
- type QueryResult
Constants ¶
const ( // ModeSubmit uses EPay's browser-facing submit.php endpoint. ModeSubmit = "submit" // ModeMAPI uses EPay's server-to-server mapi.php endpoint. ModeMAPI = "mapi" )
Variables ¶
var ErrQueryNotSupported = errors.New("gateway does not support order query API")
ErrQueryNotSupported is returned when the payment gateway does not implement the order query API (e.g., returns HTTP 404).
Functions ¶
func FormatMoney ¶ added in v1.14.0
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
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
Mode string
// contains filtered or unexported fields
}
func NewClient ¶
NewClient creates an EPay client. The optional mode keeps existing callers on submit mode while allowing payment configurations to opt into mapi.
func (*Client) CreatePayUrl ¶
CreatePayUrl is retained for source compatibility.
func (*Client) CreatePayment ¶ added in v1.14.20
CreatePayment starts a payment using the configured mode. Submit mode keeps the legacy browser redirect; mapi sends a form-encoded POST from this server.
func (*Client) QueryOrder ¶ added in v1.14.0
func (c *Client) QueryOrder(orderNo string) (*QueryResult, error)
QueryOrder obtains authoritative payment details directly from the gateway. A successful HTTP response is not enough: EPay-compatible gateways use code=1 to indicate a successful lookup and status=1 to indicate a paid order.
func (*Client) QueryOrderStatus ¶
QueryOrderStatus is kept for callers that only need a status boolean.
type PaymentResult ¶ added in v1.14.20
PaymentResult is the transport-neutral result of starting an EPay payment. Type is "url" for a browser redirect and "qr" when the caller should render URL as a QR code.