From ecd6075e0e120318e43e414903fdfc3b3bde0d57 Mon Sep 17 00:00:00 2001 From: Mauricio Araujo Date: Thu, 16 May 2024 13:21:45 -0400 Subject: [PATCH] Fix wallets request --- api/server/handlers/billing/ingest.go | 2 +- api/server/handlers/billing/plan.go | 4 ++-- internal/billing/usage.go | 9 ++++----- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/api/server/handlers/billing/ingest.go b/api/server/handlers/billing/ingest.go index 811d9b8ce7..3771cf050f 100644 --- a/api/server/handlers/billing/ingest.go +++ b/api/server/handlers/billing/ingest.go @@ -71,7 +71,7 @@ func (c *IngestEventsHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) } } - plan, err := c.Config().BillingManager.LagoClient.GetCustomeActivePlan(ctx, proj.ID, proj.EnableSandbox) + plan, err := c.Config().BillingManager.LagoClient.GetCustomerActivePlan(ctx, proj.ID, proj.EnableSandbox) if err != nil { err := telemetry.Error(ctx, span, err, "error getting active subscription") c.HandleAPIError(w, r, apierrors.NewErrInternal(err)) diff --git a/api/server/handlers/billing/plan.go b/api/server/handlers/billing/plan.go index ea78fb4657..0f7a2b1d93 100644 --- a/api/server/handlers/billing/plan.go +++ b/api/server/handlers/billing/plan.go @@ -43,7 +43,7 @@ func (c *ListPlansHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { return } - plan, err := c.Config().BillingManager.LagoClient.GetCustomeActivePlan(ctx, proj.ID, proj.EnableSandbox) + plan, err := c.Config().BillingManager.LagoClient.GetCustomerActivePlan(ctx, proj.ID, proj.EnableSandbox) if err != nil { err := telemetry.Error(ctx, span, err, "error getting active subscription") c.HandleAPIError(w, r, apierrors.NewErrInternal(err)) @@ -154,7 +154,7 @@ func (c *ListCustomerUsageHandler) ServeHTTP(w http.ResponseWriter, r *http.Requ return } - plan, err := c.Config().BillingManager.LagoClient.GetCustomeActivePlan(ctx, proj.ID, proj.EnableSandbox) + plan, err := c.Config().BillingManager.LagoClient.GetCustomerActivePlan(ctx, proj.ID, proj.EnableSandbox) if err != nil { err := telemetry.Error(ctx, span, err, "error getting active subscription") c.HandleAPIError(w, r, apierrors.NewErrInternal(err)) diff --git a/internal/billing/usage.go b/internal/billing/usage.go index 4125b1462b..0c7b34e645 100644 --- a/internal/billing/usage.go +++ b/internal/billing/usage.go @@ -145,8 +145,8 @@ func (m LagoClient) CheckIfCustomerExists(ctx context.Context, projectID uint, e return true, nil } -// GetCustomeActivePlan will return the active plan for the customer -func (m LagoClient) GetCustomeActivePlan(ctx context.Context, projectID uint, sandboxEnabled bool) (plan types.Plan, err error) { +// GetCustomerActivePlan will return the active plan for the customer +func (m LagoClient) GetCustomerActivePlan(ctx context.Context, projectID uint, sandboxEnabled bool) (plan types.Plan, err error) { ctx, span := telemetry.NewSpan(ctx, "get-active-subscription") defer span.End() @@ -283,13 +283,12 @@ func (m LagoClient) CreateCreditsGrant(ctx context.Context, projectID uint, name Currency: lago.USD, GrantedCredits: strconv.FormatInt(grantAmount, 10), // Rate is 1 credit = 1 cent - RateAmount: "0.01", - ExpirationAt: expiresAt, + RateAmount: "0.01", } _, lagoErr := m.client.Wallet().Create(ctx, walletInput) if lagoErr != nil { - return telemetry.Error(ctx, span, fmt.Errorf(lagoErr.ErrorCode), "failed to create credits grant") + return telemetry.Error(ctx, span, fmt.Errorf(lagoErr.ErrorCode), "failed to create wallet") } return nil