service

package
v1.1.6 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type BackgroundService

type BackgroundService interface {
	StartProcessingPayments()
}

type CreatePaymentRequest

type CreatePaymentRequest struct {
	Payment Payment `json:"payment"`
}

type CreatePaymentResponse

type CreatePaymentResponse struct {
	PaymentID uuid.UUID     `json:"payment_id"`
	Status    PaymentStatus `json:"status"`
}

type GetPaymentRequest

type GetPaymentRequest struct {
	PaymentID uuid.UUID `json:"payment_id"`
}

type GetPaymentResponse

type GetPaymentResponse struct {
	Payment      Payment       `json:"payment"`
	Status       PaymentStatus `json:"status"`
	PaymentError string        `json:"payment_error,omitempty"`
}

type Payment

type Payment struct {
	ID        uuid.UUID
	CreatedAt time.Time
	UpdatedAt time.Time
	Price     decimal.Decimal
	OrderID   uuid.UUID
	Status    PaymentStatus
}

func PaymentFromPaymentCreationRequestMessage added in v1.1.6

func PaymentFromPaymentCreationRequestMessage(p messages.PaymentCreationRequestMessage) (*Payment, error)

type PaymentStatus

type PaymentStatus string
const (
	PaymentStatusPaid    PaymentStatus = "paid"
	PaymentStatusPending PaymentStatus = "pending"
	PaymentStatusFailed  PaymentStatus = "failed"
	PaymentStatusClosed  PaymentStatus = "closed"
)

func MockPaymentProcess

func MockPaymentProcess(p PaymentStatus) PaymentStatus

MockPaymentProcess is a function that simulates a payment process and returns a mock payment status. It takes a pointer to a PaymentStatus struct as input and returns a PaymentStatus value. The function generates a random payment status between paid and failed, with a preference for paid.

type Request1

type Request1 struct {
	Id      string `json:"id"`
	Message string `json:"message"`
}

define the Request and Response types here

type Request2

type Request2 struct {
	Message string `json:"message"`
}

type Request3

type Request3 struct {
}

type Response1

type Response1 struct {
	Id      string `json:"id"`
	Message string `json:"message"`
}

type Response2

type Response2 struct {
	Message string `json:"message"`
}

type Response3

type Response3 struct {
}

type Service

type Service interface {
	CreatePayment(ctx context.Context, request CreatePaymentRequest) (CreatePaymentResponse, error)
	UpdatePayment(ctx context.Context, request UpdatePaymentRequest) (UpdatePaymentResponse, error)
	GetPayment(ctx context.Context, request GetPaymentRequest) (GetPaymentResponse, error)
	StartProcessingPayments()
	StartConsumingPayments()
}

func NewService

func NewService(redisStore datastore.RedisStore) Service

type UpdatePaymentRequest

type UpdatePaymentRequest struct {
	PaymentID     uuid.UUID     `json:"payment_id"`
	PaymentStatus PaymentStatus `json:"payment_status"`
}

type UpdatePaymentResponse

type UpdatePaymentResponse struct {
	PaymentID    uuid.UUID     `json:"payment_id"`
	Status       PaymentStatus `json:"status"`
	PaymentError string        `json:"payment_error,omitempty"`
}

Jump to

Keyboard shortcuts

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