waffo

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 10 Imported by: 0

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

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 New

func New(cfg Config, opts ...Option) *Adapter

New constructs a Waffo adapter. Returns nil when not configured.

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

func (a *Adapter) Configured() bool

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) Provider

func (a *Adapter) Provider() payment.Provider

Provider returns the gateway identifier.

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"
)

type Option

type Option func(*Config)

Option mutates Config.

func WithHTTPTimeout

func WithHTTPTimeout(d time.Duration) Option

WithHTTPTimeout sets the outbound HTTP timeout.

Jump to

Keyboard shortcuts

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