payment

package
v0.0.0-...-531b5da Latest Latest
Warning

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

Go to latest
Published: Apr 16, 2024 License: AGPL-3.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func PrepareBalanceClosedEvent

func PrepareBalanceClosedEvent(bal *pb.CustomerBalance) ([]byte, string, error)

func PrepareBalanceCreatedEvent

func PrepareBalanceCreatedEvent(bal *pb.CustomerBalance) ([]byte, string, error)

func PrepareBalanceCreditedEvent

func PrepareBalanceCreditedEvent(customerId string, amount float32, newBalance float32) ([]byte, string, error)

func PrepareBalanceDebitedEvent

func PrepareBalanceDebitedEvent(customerId string, amount float32, newBalance float32) ([]byte, string, error)

func PreparePaymentProcessedEvent_Failure

func PreparePaymentProcessedEvent_Failure(orderId string, customerId string, amount float32) ([]byte, string, error)

func PreparePaymentProcessedEvent_Success

func PreparePaymentProcessedEvent_Success(transaction *pb.Transaction) ([]byte, string, error)

func PrepareTransactionLoggedEvent

func PrepareTransactionLoggedEvent(transaction *pb.Transaction) ([]byte, string, error)

func PrepareTransactionReversedEvent

func PrepareTransactionReversedEvent(transaction *pb.Transaction) ([]byte, string, error)

Types

type ConsumerController

type ConsumerController interface {
	messaging.ConsumerController

	Attach(svc pb.PaymentServiceServer)
}

Interface for event consumption Flexibility for seperate controllers for different messaging systems (e.g. Kafka, NATS, etc)

type PaymentService

type PaymentService struct {
	pb.UnimplementedPaymentServiceServer
	// contains filtered or unexported fields
}

Interface for the service

func NewPaymentService

func NewPaymentService(cfg *ServiceConfig, store StorageController) *PaymentService

Create the payment service

func (PaymentService) ProcessShipmentAllocationEvent

func (svc PaymentService) ProcessShipmentAllocationEvent(ctx context.Context, req *eventpb.ShipmentAllocationEvent) (*emptypb.Empty, error)

func (PaymentService) ProcessUserCreatedEvent

func (svc PaymentService) ProcessUserCreatedEvent(ctx context.Context, req *eventpb.UserCreatedEvent) (*emptypb.Empty, error)

func (PaymentService) ProcessUserDeletedEvent

func (svc PaymentService) ProcessUserDeletedEvent(ctx context.Context, req *eventpb.UserDeletedEvent) (*emptypb.Empty, error)

func (PaymentService) ServiceInfo

func (PaymentService) ViewBalance

func (PaymentService) ViewTransaction

type ServiceConfig

type ServiceConfig struct {
	// Core Configuration
	Shared config.SharedConfig

	// Dynamically loaded configuration
	Postgres config.PostgresConfig
	Kafka    config.KafkaConfig
}

Order Service Configuration

func NewServiceConfig

func NewServiceConfig() (*ServiceConfig, error)

load the base service configuration

type StorageController

type StorageController interface {
	GetBalance(ctx context.Context, customerId string) (*pb.CustomerBalance, error)
	GetTransaction(ctx context.Context, transactionId string) (*pb.Transaction, error)

	CreateBalance(ctx context.Context, customerId string) error
	CreditBalance(ctx context.Context, customerId string, amount float32) error
	DebitBalance(ctx context.Context, customerId string, amount float32, orderId *string) (*pb.Transaction, error)
	CloseBalance(ctx context.Context, customerId string) error

	PaymentForOrder(ctx context.Context, orderId string, customerId string, amount float32) error
}

Interface for database methods Flexibility for implementing seperate controllers for different databases (e.g. Postgres, MongoDB, etc)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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