payment

package
v0.0.0-...-9d4beaf Latest Latest
Warning

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

Go to latest
Published: Oct 29, 2019 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package payment provides the use-case of payments management. Used by views facing an administrator.

Index

Constants

This section is empty.

Variables

View Source
var ErrInvalidArgument = errors.New("invalid argument")

ErrInvalidArgument is returned when one or more arguments are invalid.

Functions

func MakeHandler

func MakeHandler(s Service, logger kitlog.Logger) http.Handler

MakeHandler returns a handler for the payment service.

Types

type ErrorResp

type ErrorResp struct {
	Error error `json:"error"`
}

func (*ErrorResp) MarshalJSON

func (r *ErrorResp) MarshalJSON() ([]byte, error)

func (*ErrorResp) StatusCode

func (r *ErrorResp) StatusCode() int

type Payment

type Payment struct {
	ID          wallet.PaymentID        `json:"id"`
	Account     wallet.AccountID        `json:"account"`
	ToAccount   wallet.AccountID        `json:"to_account"`
	FromAccount wallet.AccountID        `json:"from_account"`
	Amount      wallet.Money            `json:"amount"`
	Direction   wallet.PaymentDirection `json:"direction"`
	CreatedAt   time.Time               `json:"created_at"`

	IdempotencyKey uuid.UUID `json:"-"`
}

Payment is a read model for payment views.

type Service

type Service interface {
	// List shows all available payments
	List(ctx context.Context) ([]Payment, error)

	// One shows payment details
	One(ctx context.Context, id wallet.PaymentID) (Payment, error)

	// Perform creates payment object and cares about money transfer
	Perform(ctx context.Context, idempotencyKey uuid.UUID, payment *wallet.Payment) (Payment, error)
}

Service provides payment related methods.

func NewInstrumenting

func NewInstrumenting(counter metrics.Counter, latency metrics.Histogram, s Service) Service

NewInstrumenting returns an instance of an instrumenting Service.

func NewLoggingService

func NewLoggingService(logger log.Logger, s Service) Service

NewLoggingService returns a new instance of a logging Service.

func NewService

func NewService(logger log.Logger, db *pg.DB, payments wallet.PaymentRepository, accounts wallet.AccountRepository) Service

NewService service constructor

Jump to

Keyboard shortcuts

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