Mauricio Araujo 2 лет назад
Родитель
Сommit
169b2abadd
2 измененных файлов с 19 добавлено и 0 удалено
  1. 6 0
      internal/billing/billing.go
  2. 13 0
      internal/billing/stripe..go

+ 6 - 0
internal/billing/billing.go

@@ -20,8 +20,14 @@ type BillingManager interface {
 	// CreateCustomer registers a project in the billing provider. This is currently a one-to-one
 	// mapping with projects and billing customers, because billing and usage are set per project.
 	CreateCustomer(userEmail string, proj *models.Project) (customerID string, err error)
+
+	// ListPaymentMethod will return all payment methods for the project
 	ListPaymentMethod(proj *models.Project) (paymentMethods []types.PaymentMethod, err error)
+
+	// CreatePaymentMethod will add a new payment method to the project in Stripe
 	CreatePaymentMethod(proj *models.Project) (clientSecret string, err error)
+
+	// DeletePaymentMethod will remove a payment method for the project in Stripe
 	DeletePaymentMethod(paymentMethodID string) (err error)
 
 	// GetRedirectURI gets the redirect URI to send the user to the billing portal

+ 13 - 0
internal/billing/stripe..go

@@ -15,6 +15,7 @@ type StripeBillingManager struct {
 	StripeSecretKey string
 }
 
+// CreateCustomer will create a customer in Stripe only if the project doesn't have a BillingID
 func (s *StripeBillingManager) CreateCustomer(userEmail string, proj *models.Project) (customerID string, err error) {
 	stripe.Key = s.StripeSecretKey
 
@@ -38,6 +39,7 @@ func (s *StripeBillingManager) CreateCustomer(userEmail string, proj *models.Pro
 	return customerID, nil
 }
 
+// ListPaymentMethod will return all payment methods for the project
 func (s *StripeBillingManager) ListPaymentMethod(proj *models.Project) (paymentMethods []types.PaymentMethod, err error) {
 	stripe.Key = s.StripeSecretKey
 
@@ -54,6 +56,7 @@ func (s *StripeBillingManager) ListPaymentMethod(proj *models.Project) (paymentM
 	return paymentMethods, nil
 }
 
+// CreatePaymentMethod will add a new payment method to the project in Stripe
 func (s *StripeBillingManager) CreatePaymentMethod(proj *models.Project) (clientSecret string, err error) {
 	stripe.Key = s.StripeSecretKey
 
@@ -73,6 +76,7 @@ func (s *StripeBillingManager) CreatePaymentMethod(proj *models.Project) (client
 	return intent.ClientSecret, nil
 }
 
+// DeletePaymentMethod will remove a payment method for the project in Stripe
 func (s *StripeBillingManager) DeletePaymentMethod(paymentMethodID string) (err error) {
 	stripe.Key = s.StripeSecretKey
 
@@ -85,22 +89,31 @@ func (s *StripeBillingManager) DeletePaymentMethod(paymentMethodID string) (err
 }
 
 // TODO: remove these methods when the billing tech-debt is cleaned
+// CreateTeam
 func (s *StripeBillingManager) CreateTeam(user *models.User, proj *models.Project) (teamID string, err error) {
 	return fmt.Sprintf("%d", proj.ID), nil
 }
 
+// TODO: remove these methods when the billing tech-debt is cleaned
+// DeleteTeam
 func (s *StripeBillingManager) DeleteTeam(user *models.User, proj *models.Project) (err error) {
 	return nil
 }
 
+// TODO: remove these methods when the billing tech-debt is cleaned
+// GetRedirectURI
 func (s *StripeBillingManager) GetRedirectURI(user *models.User, proj *models.Project) (url string, err error) {
 	return "", nil
 }
 
+// TODO: remove these methods when the billing tech-debt is cleaned
+// ParseProjectUsageFromWebhook
 func (s *StripeBillingManager) ParseProjectUsageFromWebhook(payload []byte) (*models.ProjectUsage, *types.FeatureFlags, error) {
 	return nil, nil, nil
 }
 
+// TODO: remove these methods when the billing tech-debt is cleaned
+// VerifySignature
 func (s *StripeBillingManager) VerifySignature(signature string, body []byte) bool {
 	return false
 }