Create new subs only if the existing subscription is in a cancelled state
This commit is contained in:
parent
3cf680eec1
commit
b95d7c241d
1 changed files with 9 additions and 3 deletions
|
@ -86,9 +86,15 @@ func (c *StripeController) GetCheckoutSession(productID string, userID int64, re
|
|||
return "", stacktrace.Propagate(ente.ErrBadRequest, "")
|
||||
}
|
||||
}
|
||||
if subscription.PaymentProvider == ente.Stripe && !subscription.Attributes.IsCancelled {
|
||||
// TODO: Check Stripe's cancellation state instead of our own
|
||||
return "", stacktrace.Propagate(err, "")
|
||||
if hasStripeSubscription {
|
||||
client := c.StripeClients[subscription.Attributes.StripeAccountCountry]
|
||||
stripeSubscription, err := client.Subscriptions.Get(subscription.OriginalTransactionID, nil)
|
||||
if err != nil {
|
||||
return "", stacktrace.Propagate(err, "")
|
||||
}
|
||||
if stripeSubscription.Status != stripe.SubscriptionStatusCanceled {
|
||||
return "", stacktrace.Propagate(ente.ErrBadRequest, "")
|
||||
}
|
||||
}
|
||||
stripeSuccessURL := redirectRootURL + viper.GetString("stripe.path.success")
|
||||
stripeCancelURL := redirectRootURL + viper.GetString("stripe.path.cancel")
|
||||
|
|
Loading…
Add table
Reference in a new issue