account

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package account provides business logic for interacting with domain entities such as accounts and transactions. It defines the Service struct and its methods for creating accounts, depositing and withdrawing funds, retrieving account details, listing transactions, and checking account balances.

The service layer follows clean architecture principles and uses the decorator pattern for transaction management. All business operations are wrapped with automatic transaction management,

error recovery, and structured logging.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Service

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

Service provides business logic for account operations including creation, deposits, withdrawals, and balance inquiries.

func New

func New(
	bus eventbus.Bus,
	uow repository.UnitOfWork,
	logger *slog.Logger,
	stripeConnectSvc stripeconnect.Service,
) *Service

New creates a new Service with the provided dependencies.

func (*Service) CreateAccount

func (s *Service) CreateAccount(
	ctx context.Context,
	create dto.AccountCreate,
) (*dto.AccountRead, error)

func (*Service) Deposit

func (s *Service) Deposit(
	ctx context.Context,
	cmd commands.Deposit,
) error

Deposit adds funds to the specified account and creates a transaction record.

func (*Service) GetAccount

func (s *Service) GetAccount(
	ctx context.Context,
	userID, accountID uuid.UUID,
) (
	account *dto.AccountRead,
	err error,
)

GetAccount retrieves an account by ID for the specified user.

func (*Service) GetBalance

func (s *Service) GetBalance(
	ctx context.Context,
	userID, accountID uuid.UUID,
) (
	balance float64,
	err error,
)

GetBalance retrieves the current balance of an account for the specified user.

func (*Service) GetTransactions

func (s *Service) GetTransactions(
	ctx context.Context,
	userID, accountID uuid.UUID,
) (
	transactions []*dto.TransactionRead,
	err error,
)

GetTransactions retrieves all transactions for a specific account.

func (*Service) ListUserAccounts added in v1.4.0

func (s *Service) ListUserAccounts(
	ctx context.Context,
	userID uuid.UUID,
) ([]*dto.AccountRead, error)

ListUserAccounts returns all accounts for a specific user.

func (*Service) Transfer

func (s *Service) Transfer(
	ctx context.Context,
	cmd commands.Transfer,
) error

Transfer moves funds from one account to another account.

func (*Service) Withdraw

func (s *Service) Withdraw(
	ctx context.Context,
	cmd commands.Withdraw,
) error

Withdraw removes funds from the specified account to an external target and creates a transaction record. It returns an error if the user has not completed Stripe Connect onboarding.

Jump to

Keyboard shortcuts

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