Documentation
¶
Overview ¶
Package waffo implements the payment.PaymentProvider interface for Waffo Payment Services (https://waffo.com) using the official github.com/waffo-com/waffo-go SDK.
Waffo is a global payment gateway focused on Southeast Asia. The adapter creates orders via the SDK and verifies webhook signatures using the Waffo public key.
The adapter is stateless after construction and safe for concurrent use.
Index ¶
- type Adapter
- func (a *Adapter) BuildWebhookResponse(ctx context.Context, success bool, msg string) (*payment.WebhookResponse, error)
- func (a *Adapter) Configured() bool
- func (a *Adapter) CreateCheckout(ctx context.Context, req *payment.CheckoutRequest) (*payment.CheckoutResult, error)
- func (a *Adapter) Provider() payment.Provider
- func (a *Adapter) QueryOrder(ctx context.Context, req *payment.OrderQuery) (*payment.OrderQueryResult, error)
- func (a *Adapter) VerifyWebhook(ctx context.Context, req *payment.WebhookVerifyRequest) (*payment.WebhookEvent, error)
- type Config
- type Environment
- type Option
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Adapter ¶
type Adapter struct {
// contains filtered or unexported fields
}
Adapter implements payment.PaymentProvider for Waffo.
func (*Adapter) BuildWebhookResponse ¶
func (a *Adapter) BuildWebhookResponse(ctx context.Context, success bool, msg string) (*payment.WebhookResponse, error)
BuildWebhookResponse returns a signed JSON response body as required by the Waffo webhook protocol. The X-SIGNATURE header is placed in response.Headers["X-SIGNATURE"].
func (*Adapter) Configured ¶
Configured reports whether the adapter has the minimum credentials.
func (*Adapter) CreateCheckout ¶
func (a *Adapter) CreateCheckout(ctx context.Context, req *payment.CheckoutRequest) (*payment.CheckoutResult, error)
CreateCheckout creates a Waffo order and returns the payment redirect URL.
func (*Adapter) QueryOrder ¶
func (a *Adapter) QueryOrder(ctx context.Context, req *payment.OrderQuery) (*payment.OrderQueryResult, error)
QueryOrder queries the Waffo order detail API for the current status.
func (*Adapter) VerifyWebhook ¶
func (a *Adapter) VerifyWebhook(ctx context.Context, req *payment.WebhookVerifyRequest) (*payment.WebhookEvent, error)
VerifyWebhook verifies the X-SIGNATURE header using the Waffo public key and parses the JSON payload into a normalized WebhookEvent.
type Config ¶
type Config struct {
// Environment selects sandbox vs production.
Environment Environment
// APIKey is the merchant API key.
APIKey string
// PrivateKey is the merchant RSA private key (base64-encoded).
PrivateKey string
// PublicKey is the Waffo platform public key (base64-encoded),
// used to verify webhook signatures.
PublicKey string
// MerchantID is the merchant id assigned by Waffo.
MerchantID string
// HTTPTimeout is the timeout for outbound API calls. Defaults to 30s.
HTTPTimeout time.Duration
}
Config holds the Waffo SDK credentials.
type Environment ¶
type Environment string
Environment selects the Waffo API environment.
const ( EnvSandbox Environment = "sandbox" EnvProduction Environment = "production" )