Versions in this module Expand all Collapse all v0 v0.1.0 Jun 24, 2026 Changes in this version + var ErrAmountMismatch = errors.New("webhook amount/currency mismatch") + var ErrTransactionNotFound = errors.New("payment transaction not found") + var ErrUnsupportedWebhookStatus = errors.New("unsupported webhook status") + type CreateCheckoutRequest struct + Amount decimal.Decimal + CancelRedirectURL string + Currency string + ExpiresAt time.Time + GatewayID string + Metadata map[string]string + SuccessRedirectURL string + type CreateCheckoutResponse struct + CheckoutURL string + ExpiresIn int + Instructions string + ReferenceNumber string + SessionID string + Type InteractionType + type EventData struct + AmountPaid decimal.Decimal + ConfirmedAt string + Currency string + GatewayTransactionID string + ReferenceNumber string + Status PaymentStatus + TaskID string + type Factory func(config json.RawMessage) (PaymentGateway, error) + type GatewayInfo struct + Config json.RawMessage + ID string + IsActive bool + RenderInfo RenderInfo + type GatewayRegistry interface + Get func(id string) (PaymentGateway, error) + ListInfo func() []GatewayInfo + func NewRegistry(configPath string, factories map[string]Factory) (GatewayRegistry, error) + type HTTPHandler struct + func NewHTTPHandler(service PaymentService) *HTTPHandler + func (h *HTTPHandler) HandleValidateReference(w http.ResponseWriter, r *http.Request) + func (h *HTTPHandler) HandleWebhook(w http.ResponseWriter, r *http.Request) + type InteractionType string + const FlowTypeInstruction + const FlowTypeRedirect + type InternalPaymentEvent struct + Data EventData + EventType string + type PaymentGateway interface + CreateSession func(ctx context.Context, req SessionRequest) (*SessionResponse, error) + ExtractReferenceNumber func(ctx context.Context, reqData json.RawMessage) (string, error) + GetFlowType func() InteractionType + HandleValidateReference func(ctx context.Context, tx *ValidationTransaction, isPayable bool, ...) (*ValidationResponse, error) + ParseWebhook func(ctx context.Context, body []byte, headers map[string][]string) (*WebhookPayload, *WebhookResponse, error) + type PaymentRepository interface + Create func(ctx context.Context, tx *PaymentTransaction) error + GetByReferenceNumber func(ctx context.Context, referenceNumber string) (*PaymentTransaction, error) + GetByReferenceNumberForUpdate func(ctx context.Context, referenceNumber string) (*PaymentTransaction, error) + GetByTaskID func(ctx context.Context, taskID string) (*PaymentTransaction, error) + RunInTransaction func(ctx context.Context, fn func(repo PaymentRepository) error) error + Update func(ctx context.Context, tx *PaymentTransaction) error + UpdateStatus func(ctx context.Context, referenceNumber string, status PaymentStatus) error + WithTx func(tx *gorm.DB) PaymentRepository + func NewPaymentRepository(db *gorm.DB) PaymentRepository + type PaymentService interface + CreateCheckoutSession func(ctx context.Context, req CreateCheckoutRequest) (*CreateCheckoutResponse, error) + ListAvailableMethods func(ctx context.Context) ([]GatewayInfo, error) + ProcessWebhook func(ctx context.Context, gatewayID string, body []byte, ...) (*WebhookResponse, error) + SetTaskCompleter func(completer TaskCompleter) + ValidateReference func(ctx context.Context, gatewayID string, rawBody json.RawMessage) (*ValidationResponse, error) + func NewPaymentService(repo PaymentRepository, registry GatewayRegistry) PaymentService + type PaymentStatus string + const PaymentStatusFailed + const PaymentStatusPending + const PaymentStatusSuccess + type PaymentTransaction struct + Amount decimal.Decimal + CreatedAt time.Time + Currency string + ExpiryDate time.Time + GatewayID string + GatewayMetadata map[string]string + ID string + PaymentMethod string + ReferenceNumber string + SessionID string + Status PaymentStatus + TaskID string + UpdatedAt time.Time + type RenderInfo struct + Description string + DisplayName string + DisplayOrder int + LogoURL string + PrimaryColor string + type SessionRequest struct + Amount decimal.Decimal + CancelRedirectURL string + Currency string + SuccessRedirectURL string + type SessionResponse struct + CheckoutURL string + Instructions string + SessionID string + Type InteractionType + type TaskCompleter interface + CompleteTaskStep func(ctx context.Context, taskID string, payload map[string]any) error + type ValidateReferenceRequest struct + PaymentReference string + ServiceType string + type ValidateReferenceResponse struct + Amount decimal.Decimal + Currency string + ExpiryDate string + IsPayable bool + OGAName string + Remarks string + TraderName string + type ValidationResponse struct + HTTPStatus int + Payload json.RawMessage + type ValidationTransaction struct + Amount decimal.Decimal + Currency string + ExpiryDate time.Time + Metadata map[string]string + ReferenceNumber string + Status string + type WebhookPayload struct + Amount decimal.Decimal + Currency string + GatewayTransactionID string + Metadata map[string]string + PaymentMethod string + ReferenceNumber string + SessionID string + Status WebhookStatus + Timestamp string + type WebhookResponse struct + HTTPStatus int + Payload json.RawMessage + type WebhookStatus string + const WebhookStatusFailed + const WebhookStatusPending + const WebhookStatusSuccess