Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
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)
Click to show internal directories.
Click to hide internal directories.