payment

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2026 License: AGPL-3.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type InitializePaymentRequest

type InitializePaymentRequest struct {
	Amount int64
	// The caller will put a fonbnk.Options struct or yellowcard.Options struct here.
	ProviderOptions any
}

InitializePaymentRequest contains parameters for initializing a payment.

type PaymentProvider

type PaymentProvider interface {
	// GetRate returns the exchange rate for a specified currency depending on the provider
	GetRate(ctx context.Context, currency string) (int64, error)

	// InitializePayment initiates a payment and returns a transaction ID or error.
	InitializePayment(ctx context.Context, req InitializePaymentRequest) (string, error)

	// ProcessPayment processes a payment for a given transaction ID.
	ProcessPayment(ctx context.Context, transactionID string) (PaymentStatus, error)

	// GetPaymentStatus retrieves the status of a payment.
	GetPaymentStatus(ctx context.Context, transactionID string) (PaymentStatus, error)
}

PaymentProvider defines the abstract behavior of a payment service.

type PaymentStatus

type PaymentStatus string

PaymentStatus defines the possible states of a payment.

const (
	StatusPending   PaymentStatus = "PENDING"
	StatusSucceeded PaymentStatus = "SUCCEEDED"
	StatusFailed    PaymentStatus = "FAILED"
)

Define constants for payment statuses.

type Service

type Service struct {
	// contains filtered or unexported fields
}

Service acts as a registry for all available payment providers.

func NewService

func NewService() *Service

NewService creates a new, empty payment service.

func (*Service) Get

func (s *Service) Get(name string) (PaymentProvider, error)

Get retrieves a specific provider from the registry by its name.

func (*Service) RegisterProvider

func (s *Service) RegisterProvider(name string, provider PaymentProvider)

RegisterProvider adds a new payment provider to the registry.

Directories

Path Synopsis
Package yellowcard provides types and client for the YellowCard payment API.
Package yellowcard provides types and client for the YellowCard payment API.

Jump to

Keyboard shortcuts

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