Răsfoiți Sursa

Add project id to stripe metadata

Mauricio Araujo 2 ani în urmă
părinte
comite
e84c59c239
1 a modificat fișierele cu 5 adăugiri și 0 ștergeri
  1. 5 0
      internal/billing/stripe.go

+ 5 - 0
internal/billing/stripe.go

@@ -3,6 +3,7 @@ package billing
 import (
 	"context"
 	"fmt"
+	"strconv"
 
 	"github.com/porter-dev/porter/api/types"
 	"github.com/porter-dev/porter/internal/models"
@@ -34,9 +35,13 @@ func (s *StripeBillingManager) CreateCustomer(ctx context.Context, userEmail str
 	if proj.BillingID == "" {
 		// Create customer if not exists
 		customerName := fmt.Sprintf("project_%s", proj.Name)
+		projectIDStr := strconv.FormatUint(uint64(proj.ID), 10)
 		params := &stripe.CustomerParams{
 			Name:  stripe.String(customerName),
 			Email: stripe.String(userEmail),
+			Metadata: map[string]string{
+				"porter_project_id": projectIDStr,
+			},
 		}
 
 		// Create in Stripe