Documentation
¶
Overview ¶
Package payment provides handlers for work with payments in the system.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Payment ¶
type Payment struct { ID uuid.UUID `json:"-" sql:"id,pk,type:varchar(36)"` Account account.ID `json:"account" sql:"type:varchar(255)" pg:"fk:base_account_id"` Amount decimal.Decimal `json:"amount" sql:"amount,notnull,type:'decimal(16,4)'"` ToAccount account.ID `json:"to_account,omitempty" sql:"to_account,type:varchar(255)" pg:"fk:to_account_id"` FromAccount account.ID `json:"from_account,omitempty" sql:"from_account,type:varchar(255)" pg:"fk:from_account_id"` Direction Direction `json:"direction" sql:"direction,notnull,type:varchar(16)"` Deleted bool `json:"-" sql:"deleted,notnull"` }
Payment holding a money transfer between two accounts in the system.
type Repository ¶
type Repository interface { // Store payments in the repository. Store(payment ...*Payment) error // Find payments list for an account. Find(id account.ID) []*Payment // FindAll returns all payments, registered in the system. FindAll() []*Payment // MarkDeleted is mark as deleted specified payment in the system MarkDeleted(id uuid.UUID) error }
Repository interface for payment storing and operations.
type Service ¶
type Service interface { // New registers a new payment in the system. New(fromAccountID account.ID, amount decimal.Decimal, toAccountID account.ID) error // Load returns payments list for an account. Load(accountID account.ID) []*Payment // LoadAll returns all payments, registered in the system. LoadAll() []*Payment }
Service is the interface that provides payment methods.
func NewLoggingService ¶
NewLoggingService returns a new instance of a logging Service.
func NewMetricsService ¶
NewMetricsService returns an instance of a metrics Service.
func NewService ¶
func NewService(payments Repository, accounts account.Repository) Service
NewService creates a payment service with necessary dependencies.
Click to show internal directories.
Click to hide internal directories.