facadepattern

package
v0.0.0-...-0a00fa3 Latest Latest
Warning

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

Go to latest
Published: Aug 17, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CardTokenizer

type CardTokenizer interface {
	Tokenize(ctx context.Context, cardNumber string, expiryMM, expiryYY int, cvv string) (token string, err error)
}

type ChargeRequest

type ChargeRequest struct {
	Amount                     float64
	Currency                   string
	CardNumber                 string
	CardExpiryMM, CardExpiryYY int
	CVV                        string
	CustomerID                 string
	Metadata                   map[string]string
}

type ChargeResponse

type ChargeResponse struct {
	TransactionID string
	Status        string
	ProviderRef   string
	Amount        float64
	Currency      string
	Timestamp     time.Time
}

type CurrencyConverter

type CurrencyConverter interface {
	Convert(ctx context.Context, amount float64, from, to string) (converted float64, err error)
}

type FixedConverter

type FixedConverter struct {
	TargetCurrency string
	Rate           float64
}

func (*FixedConverter) Convert

func (f *FixedConverter) Convert(ctx context.Context, amount float64, from, to string) (float64, error)

type FraudChecker

type FraudChecker interface {
	Check(ctx context.Context, req ChargeRequest) (ok bool, reason string, err error)
}

type GatewayClient

type GatewayClient interface {
	Charge(ctx context.Context, token string, amount float64, currency string, metadata map[string]string) (providedRef string, err error)
}

type HttpGateway

type HttpGateway struct {
}

func (*HttpGateway) Charge

func (hg *HttpGateway) Charge(ctx context.Context, token string, amount float64, currency string, metadata map[string]string) (string, error)

type MemoryStore

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

func (*MemoryStore) Save

func (m *MemoryStore) Save(ctx context.Context, resp ChargeResponse) error

type PaymentFacade

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

func NewPaymentFacade

func NewPaymentFacade(tokenizer CardTokenizer, fraud FraudChecker, conv CurrencyConverter, client GatewayClient, store TransactionStore) *PaymentFacade

func (*PaymentFacade) ChargeCard

func (p *PaymentFacade) ChargeCard(ctx context.Context, req ChargeRequest) (ChargeResponse, error)

ChargeCard orchestrates tokenization, fraud check, conversion, gateway call, and persistence.

type SimpleFraud

type SimpleFraud struct {
}

func (*SimpleFraud) Check

func (st *SimpleFraud) Check(ctx context.Context, req ChargeRequest) (bool, string, error)

type SimpleTokenizer

type SimpleTokenizer struct {
}

func (*SimpleTokenizer) Tokenize

func (st *SimpleTokenizer) Tokenize(ctx context.Context, cardNumber string, expiryMM, expiryYY int, cvv string) (string, error)

type TransactionStore

type TransactionStore interface {
	Save(ctx context.Context, resp ChargeResponse) error
}

Jump to

Keyboard shortcuts

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