Documentation
¶
Overview ¶
Package pg is the Payment Gateway v1 HTTP client, authenticated with a broker-minted product credential.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type CheckoutParams ¶
type CheckoutParams struct {
Operation string // PURCHASE | VERIFY
PaymentMethod string // BANK_TRANSFER | CARD | NAPAS_BANK_TRANSFER (optional)
OrderAmount string
Currency string // VND
InvoiceNumber string
Description string
CustomerID string
SuccessURL string
ErrorURL string
CancelURL string
}
CheckoutParams are the checkout/init fields; merchant comes from the credential.
type Client ¶
type Client struct {
MaxRetries int
// CheckoutURL is the hosted-checkout host, separate from the REST API host.
CheckoutURL string
// Logf, if set, reports progress such as a 429 retry.
Logf func(format string, args ...any)
// contains filtered or unexported fields
}
Client calls the Payment Gateway v1 REST API over HTTP.
func NewClient ¶
NewClient returns a PG client for baseURL, minting its Basic credential from creds.
func (*Client) InitCheckout ¶
InitCheckout POSTs a signed checkout/init and returns the payment page URL (the 302 Location). Only the signature is sent, never the secret. Field order must match PaymentGatewayFeature::signFields.
type Meta ¶
type Meta struct {
PerPage int `json:"per_page"`
Total int `json:"total"`
HasMore bool `json:"has_more"`
CurrentPage int `json:"current_page"`
PageCount int `json:"page_count"`
}
Meta is a PG list response's paging block.
type Response ¶
type Response struct {
Raw json.RawMessage
Data json.RawMessage
Meta *Meta
Message string
}
Response is a PG v1 success body. Some endpoints skip the "data" wrapper, so Raw keeps the whole body.