Minor refactor

This commit is contained in:
vishnukvmd 2024-03-21 13:31:46 +05:30
parent 5635e63cb7
commit 78e5e3bdb1

View file

@ -348,10 +348,6 @@ func (c *StripeController) handleCustomerSubscriptionUpdated(event stripe.Event,
}
userID := currentSubscription.UserID
newSubscription, err := c.getEnteSubscriptionFromStripeSubscription(userID, stripeSubscription)
if err != nil {
return ente.StripeEventLog{}, stacktrace.Propagate(err, "")
}
if stripeSubscription.Status == stripe.SubscriptionStatusPastDue {
user, err := c.UserRepo.Get(userID)
if err != nil {
@ -365,6 +361,11 @@ func (c *StripeController) handleCustomerSubscriptionUpdated(event stripe.Event,
return ente.StripeEventLog{}, stacktrace.Propagate(err, "")
}
}
newSubscription, err := c.getEnteSubscriptionFromStripeSubscription(userID, stripeSubscription)
if err != nil {
return ente.StripeEventLog{}, stacktrace.Propagate(err, "")
}
// If the customer has changed the plan, we update state in the database. If
// the plan has not changed, we will ignore this webhook and rely on other
// events to update the state