|
|
@@ -1,22 +1,12 @@
|
|
|
package billing
|
|
|
|
|
|
import (
|
|
|
- "fmt"
|
|
|
-
|
|
|
"github.com/porter-dev/porter/api/types"
|
|
|
"github.com/porter-dev/porter/internal/models"
|
|
|
)
|
|
|
|
|
|
// BillingManager contains methods for managing billing for a project
|
|
|
type BillingManager interface {
|
|
|
- // CreateTeam creates the concept of a billing "team". This is currently a one-to-one
|
|
|
- // mapping with projects, but this may change in the future (i.e. multiple projects
|
|
|
- // per same team)
|
|
|
- CreateTeam(user *models.User, proj *models.Project) (teamID string, err error)
|
|
|
-
|
|
|
- // DeleteTeam deletes a billing team.
|
|
|
- DeleteTeam(user *models.User, proj *models.Project) (err error)
|
|
|
-
|
|
|
// 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)
|
|
|
@@ -29,16 +19,6 @@ type BillingManager interface {
|
|
|
|
|
|
// 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
|
|
|
- GetRedirectURI(user *models.User, proj *models.Project) (url string, err error)
|
|
|
-
|
|
|
- // ParseProjectUsageFromWebhook parses the project usage from a webhook payload sent
|
|
|
- // from a billing agent
|
|
|
- ParseProjectUsageFromWebhook(payload []byte) (*models.ProjectUsage, error)
|
|
|
-
|
|
|
- // VerifySignature verifies the signature for a webhook
|
|
|
- VerifySignature(signature string, body []byte) bool
|
|
|
}
|
|
|
|
|
|
// NoopBillingManager performs no billing operations
|
|
|
@@ -63,28 +43,3 @@ func (s *NoopBillingManager) CreatePaymentMethod(proj *models.Project) (clientSe
|
|
|
func (s *NoopBillingManager) DeletePaymentMethod(paymentMethodID string) (err error) {
|
|
|
return nil
|
|
|
}
|
|
|
-
|
|
|
-// CreateTeam is a no-op
|
|
|
-func (n *NoopBillingManager) CreateTeam(user *models.User, proj *models.Project) (teamID string, err error) {
|
|
|
- return fmt.Sprintf("%d", proj.ID), nil
|
|
|
-}
|
|
|
-
|
|
|
-// DeleteTeam is a no-op
|
|
|
-func (n *NoopBillingManager) DeleteTeam(user *models.User, proj *models.Project) (err error) {
|
|
|
- return nil
|
|
|
-}
|
|
|
-
|
|
|
-// GetRedirectURI is a no-op
|
|
|
-func (n *NoopBillingManager) GetRedirectURI(user *models.User, proj *models.Project) (url string, err error) {
|
|
|
- return "", nil
|
|
|
-}
|
|
|
-
|
|
|
-// ParseProjectUsageFromWebhook is a no-op
|
|
|
-func (n *NoopBillingManager) ParseProjectUsageFromWebhook(payload []byte) (*models.ProjectUsage, error) {
|
|
|
- return nil, nil
|
|
|
-}
|
|
|
-
|
|
|
-// VerifySignature is a no-op
|
|
|
-func (n *NoopBillingManager) VerifySignature(signature string, body []byte) bool {
|
|
|
- return false
|
|
|
-}
|