collab: Only subscribe to Zed Free if there isn't an existing active subscription (#30967)
This PR adds a sanity check to ensure that we only subscribe the user to Zed Free if they don't already have an active subscription. Release Notes: - N/A
This commit is contained in:
parent
b93c67438c
commit
05f8001ee9
1 changed files with 13 additions and 7 deletions
|
@ -1183,14 +1183,20 @@ async fn sync_subscription(
|
||||||
if subscription.status == SubscriptionStatus::Canceled
|
if subscription.status == SubscriptionStatus::Canceled
|
||||||
|| subscription.status == SubscriptionStatus::Paused
|
|| subscription.status == SubscriptionStatus::Paused
|
||||||
{
|
{
|
||||||
let stripe_customer_id = billing_customer
|
let already_has_active_billing_subscription = app
|
||||||
.stripe_customer_id
|
.db
|
||||||
.parse::<stripe::CustomerId>()
|
.has_active_billing_subscription(billing_customer.user_id)
|
||||||
.context("failed to parse Stripe customer ID from database")?;
|
|
||||||
|
|
||||||
stripe_billing
|
|
||||||
.subscribe_to_zed_free(stripe_customer_id)
|
|
||||||
.await?;
|
.await?;
|
||||||
|
if !already_has_active_billing_subscription {
|
||||||
|
let stripe_customer_id = billing_customer
|
||||||
|
.stripe_customer_id
|
||||||
|
.parse::<stripe::CustomerId>()
|
||||||
|
.context("failed to parse Stripe customer ID from database")?;
|
||||||
|
|
||||||
|
stripe_billing
|
||||||
|
.subscribe_to_zed_free(stripe_customer_id)
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue