Skip to content

Commit

Permalink
Remove arg
Browse files Browse the repository at this point in the history
  • Loading branch information
MauAraujo committed May 16, 2024
1 parent ecd6075 commit 9e9749f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 9 deletions.
6 changes: 1 addition & 5 deletions api/server/handlers/billing/create.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"net/http"
"time"

"github.com/porter-dev/porter/api/server/handlers"
"github.com/porter-dev/porter/api/server/shared"
Expand Down Expand Up @@ -147,12 +146,9 @@ func (c *CreateBillingHandler) grantRewardIfReferral(ctx context.Context, referr
}

if referral != nil && referral.Status != models.ReferralStatusCompleted {
// Lago requires an expiration to be passed in, so we set it to 5 years which in
// practice will mean the credits will most likely run out before expiring
expiresAt := time.Now().AddDate(5, 0, 0)
name := "Referral reward"
rewardAmount := c.Config().BillingManager.LagoClient.DefaultRewardAmountCents
err := c.Config().BillingManager.LagoClient.CreateCreditsGrant(ctx, referrerProject.ID, name, rewardAmount, &expiresAt, referrerProject.EnableSandbox)
err := c.Config().BillingManager.LagoClient.CreateCreditsGrant(ctx, referrerProject.ID, name, rewardAmount, referrerProject.EnableSandbox)
if err != nil {
return telemetry.Error(ctx, span, err, "failed to grand credits reward")
}
Expand Down
6 changes: 2 additions & 4 deletions internal/billing/usage.go
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,7 @@ func (m LagoClient) CreateCustomerWithPlan(ctx context.Context, userEmail string
}

walletName := "Porter Credits"
expiresAt := time.Now().UTC().AddDate(0, 1, 0).Truncate(24 * time.Hour)

err = m.CreateCreditsGrant(ctx, projectID, walletName, defaultStarterCreditsCents, &expiresAt, sandboxEnabled)
err = m.CreateCreditsGrant(ctx, projectID, walletName, defaultStarterCreditsCents, sandboxEnabled)
if err != nil {
return telemetry.Error(ctx, span, err, "error while creating starter credits grant")
}
Expand Down Expand Up @@ -261,7 +259,7 @@ func (m LagoClient) CheckCustomerCouponExpiration(ctx context.Context, projectID
}

// CreateCreditsGrant will create a new credit grant for the customer with the specified amount
func (m LagoClient) CreateCreditsGrant(ctx context.Context, projectID uint, name string, grantAmount int64, expiresAt *time.Time, sandboxEnabled bool) (err error) {
func (m LagoClient) CreateCreditsGrant(ctx context.Context, projectID uint, name string, grantAmount int64, sandboxEnabled bool) (err error) {
ctx, span := telemetry.NewSpan(ctx, "create-credits-grant")
defer span.End()

Expand Down

0 comments on commit 9e9749f

Please sign in to comment.