internal

package
v0.0.0-...-ddc95ab Latest Latest
Warning

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

Go to latest
Published: Feb 2, 2026 License: Apache-2.0 Imports: 26 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenGRPC

func ListenGRPC(service Service, orderURL string, port int) error

func StartServers

func StartServers(service Service, consumer sarama.Consumer, orderURL string, grpcPort, webhookPort int) error

StartServers runs both gRPC and HTTP webhook servers concurrently

Types

type EventConsumer

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

func NewEventConsumer

func NewEventConsumer(consumer sarama.Consumer, service Service) *EventConsumer

func (*EventConsumer) GetConsumer

func (ec *EventConsumer) GetConsumer() sarama.Consumer

func (*EventConsumer) StartProductEventsConsumer

func (ec *EventConsumer) StartProductEventsConsumer(ctx context.Context) error

type PaymentClient

type PaymentClient interface {
	CreateProduct(ctx context.Context,
		name string, price int64,
		currency dodopayments.Currency,
		taxCategory dodopayments.TaxCategory,
		customerId, productId string) (*dodopayments.Product, error)
	UpdateProduct(ctx context.Context,
		productId string,
		name string, price int64) error
	ArchiveProduct(ctx context.Context, productId string) error

	CreateCustomer(ctx context.Context, userId uint64, email, name string) (*models.Customer, error)
	CreateCustomerSession(ctx context.Context, customerId string) (string, error)

	CreateCheckoutSession(ctx context.Context,
		userId uint64,
		customerId string, redirect string,
		dodoProducts []dodopayments.CheckoutSessionRequestProductCartParam, orderId uint64) (checkoutURL string, err error)

	HandleWebhook(w http.ResponseWriter, r *http.Request) (*models.Transaction, error)
}

func NewDodoClient

func NewDodoClient(apiKey string, testMode bool) PaymentClient

type Repository

type Repository interface {
	Close()

	GetCustomerByCustomerID(ctx context.Context, customerId string) (*models.Customer, error)
	GetCustomerByUserID(ctx context.Context, userId uint64) (*models.Customer, error)
	SaveCustomer(ctx context.Context, customer *models.Customer) error

	GetProductByProductID(ctx context.Context, productId string) (*models.Product, error)
	GetProductsByIDs(ctx context.Context, productIds []string) ([]*models.Product, error)
	SaveProduct(ctx context.Context, product *models.Product) error
	UpdateProduct(ctx context.Context, product *models.Product) error
	DeleteProduct(ctx context.Context, productId string) error

	RegisterTransaction(ctx context.Context, transaction *models.Transaction) error
	UpdateTransaction(ctx context.Context, transaction *models.Transaction) error
}

func NewPostgresRepository

func NewPostgresRepository(db *gorm.DB) (Repository, error)

type Service

type Service interface {
	RegisterProduct(ctx context.Context,
		name string, price int64,
		customerId, productId string) error
	UpdateProduct(ctx context.Context, productId string, name string, price int64) error
	DeleteProduct(ctx context.Context, productId string) error

	CreateCustomerPortalSession(ctx context.Context,
		customer *models.Customer) (string, error)
	FindOrCreateCustomer(ctx context.Context,
		userId uint64,
		email, name string) (*models.Customer, error)

	CreateCheckoutSession(ctx context.Context,
		userId uint64,
		customerId string,
		redirect string,
		products []*pb.CartItem, orderId uint64,
	) (checkoutURL string, err error)

	HandlePaymentWebhook(ctx context.Context, w http.ResponseWriter, r *http.Request) (*models.Transaction, error)
}

func NewPaymentService

func NewPaymentService(client PaymentClient, paymentRepository Repository) Service

type WebhookServer

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

func (*WebhookServer) HandlePaymentWebhook

func (s *WebhookServer) HandlePaymentWebhook(w http.ResponseWriter, r *http.Request)

Jump to

Keyboard shortcuts

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