domain

package
v0.0.0-...-ffaedda Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2022 License: Apache-2.0, MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrDomain = errors.New(`domain`)

	ErrInsufficientFunds = errors.New(`insufficient funds to pay`)
	ErrCanceledPayment   = errors.New(`compelete canceled payment`)
	ErrFailedPayment     = errors.New(`cancel failed payment`)
)

Functions

This section is empty.

Types

type Balance

type Balance struct {
	CustomerID uuid.UUID
	Amount     decimal.Decimal
	Reserved   decimal.Decimal
}

func (Balance) Apply

func (b Balance) Apply(payment Payment) (balance Balance, err error)

func (Balance) CompletePayment

func (b Balance) CompletePayment(payment Payment) Balance

func (Balance) Refund

func (b Balance) Refund(payment Payment) Balance

func (Balance) ReserveAmount

func (b Balance) ReserveAmount(payment Payment) (Balance, error)

func (Balance) Transaction

func (b Balance) Transaction(tx Tx) (Balance, Payment, error)

type Cancel

type Cancel struct {
	PaymentID uuid.UUID
}

func (Cancel) GetID

func (e Cancel) GetID() uuid.UUID

type CanceledPayment

type CanceledPayment struct {
	ID     uuid.UUID
	Amount decimal.Decimal
}

func (CanceledPayment) GetAmount

func (p CanceledPayment) GetAmount() decimal.Decimal

func (CanceledPayment) GetID

func (p CanceledPayment) GetID() uuid.UUID

type Complete

type Complete struct {
	PaymentID uuid.UUID
}

func (Complete) GetID

func (e Complete) GetID() uuid.UUID

type CompletedPayment

type CompletedPayment struct {
	ID     uuid.UUID
	Amount decimal.Decimal
}

func (CompletedPayment) GetAmount

func (p CompletedPayment) GetAmount() decimal.Decimal

func (CompletedPayment) GetID

func (p CompletedPayment) GetID() uuid.UUID

type Event

type Event interface {
	GetID() uuid.UUID
}

type FailedPayment

type FailedPayment struct {
	ID      uuid.UUID
	OrderID uuid.UUID
	Amount  decimal.Decimal
}

func FailPayment

func FailPayment(payment Payment) FailedPayment

func (FailedPayment) GetAmount

func (p FailedPayment) GetAmount() decimal.Decimal

func (FailedPayment) GetID

func (p FailedPayment) GetID() uuid.UUID

func (FailedPayment) GetOrderID

func (p FailedPayment) GetOrderID() uuid.UUID

type NewPayment

type NewPayment struct {
	ID      uuid.UUID
	OrderID uuid.UUID
	Amount  decimal.Decimal
}

func (NewPayment) GetAmount

func (p NewPayment) GetAmount() decimal.Decimal

func (NewPayment) GetID

func (p NewPayment) GetID() uuid.UUID

func (NewPayment) GetOrderID

func (p NewPayment) GetOrderID() uuid.UUID

type Payment

type Payment interface {
	GetID() uuid.UUID
	GetAmount() decimal.Decimal
}

func Apply

func Apply(payment Payment, event Event) (Payment, error)

func CancelPayment

func CancelPayment(payment Payment) (Payment, error)

func CompletePayment

func CompletePayment(payment Payment) (Payment, error)

type Reserve

type Reserve struct {
	OrderID uuid.UUID
	Amount  decimal.Decimal
}

func (Reserve) GetID

func (e Reserve) GetID() uuid.UUID

type ResultPayment

type ResultPayment interface {
	Payment
	GetOrderID() uuid.UUID
}

type Tx

type Tx struct {
	Payment Payment
	Event   Event
}

Jump to

Keyboard shortcuts

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