payment_application

package
v0.0.0-...-d4643ec Latest Latest
Warning

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

Go to latest
Published: May 3, 2024 License: MIT Imports: 16 Imported by: 0

README

Use Case: UC-03 Works with payment

Functional Requirements:

  1. CRUD payment (Create, Read, List, Update, Delete)

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrApprovePayment = fmt.Errorf("Payment was successfully created, but its status could not be received")
View Source
var ErrCreatePayment = fmt.Errorf("error create a new payment")
View Source
var EventList map[string]uint32

EventList - event notify list

Functions

func CommandPaymentApprove

func CommandPaymentApprove(ctx context.Context, in *billing.Payment) (*eventsourcing.BaseCommand, error)

func CommandPaymentClose

func CommandPaymentClose(ctx context.Context, in *billing.Payment) (*eventsourcing.BaseCommand, error)

func CommandPaymentCreate

func CommandPaymentCreate(ctx context.Context, in *billing.Payment) (*eventsourcing.BaseCommand, error)

func CommandPaymentReject

func CommandPaymentReject(ctx context.Context, in *billing.Payment) (*eventsourcing.BaseCommand, error)

func CommandPaymentUpdateBalance

func CommandPaymentUpdateBalance(ctx context.Context, in *billing.Payment) (*eventsourcing.BaseCommand, error)

Types

type IncorrectStatusOfPaymentError

type IncorrectStatusOfPaymentError struct {
	Status string
}

func (*IncorrectStatusOfPaymentError) Error

type NotFoundCommandError

type NotFoundCommandError struct {
	Type string
}

func (*NotFoundCommandError) Error

func (e *NotFoundCommandError) Error() string

type NotFoundEventError

type NotFoundEventError struct {
	Type string
}

func (*NotFoundEventError) Error

func (e *NotFoundEventError) Error() string

type Payment

type Payment struct {
	*eventsourcing.BaseAggregate
	*billing.Payment
}

func (*Payment) ApplyChange

func (p *Payment) ApplyChange(event *eventsourcing.Event) error

ApplyChange to payment

func (*Payment) HandleCommand

func (p *Payment) HandleCommand(ctx context.Context, command *eventsourcing.BaseCommand) error

HandleCommand create events and validate based on such command

type PaymentService

type PaymentService struct {

	// EventSourcing
	eventsourcing.CommandHandle
	// contains filtered or unexported fields
}

func New

func New(log logger.Logger, paymentRepository es.EventSourcing) (*PaymentService, error)

func (*PaymentService) Add

Add - Create a payment

func (*PaymentService) Approve

func (p *PaymentService) Approve(ctx context.Context, id string) error

func (*PaymentService) Close

func (p *PaymentService) Close(ctx context.Context, id string) error

func (*PaymentService) Get

func (p *PaymentService) Get(ctx context.Context, aggregateId string) (*billing.Payment, error)

func (*PaymentService) Handle

func (p *PaymentService) Handle(ctx context.Context, aggregate *Payment, command *eventsourcing.BaseCommand) error

func (*PaymentService) List

func (p *PaymentService) List(ctx context.Context, filter any) ([]*billing.Payment, error)

func (*PaymentService) PublishEvents

func (p *PaymentService) PublishEvents(ctx context.Context, events []*eventsourcing.Event) error

PublishEvents - send message about a new events

func (*PaymentService) Reject

func (p *PaymentService) Reject(ctx context.Context, id string) error

func (*PaymentService) UpdateBalance

func (p *PaymentService) UpdateBalance(ctx context.Context, in *billing.Payment) (*billing.Payment, error)

Jump to

Keyboard shortcuts

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