Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

collab: Only subscribe to Zed Free if there isn't an existing active subscription (#30967)

Marshall Bowers05f8001ee904
diff --git a/crates/collab/src/api/billing.rs b/crates/collab/src/api/billing.rs
index f1ed25ed88a..3852b028119 100644
--- a/crates/collab/src/api/billing.rs
+++ b/crates/collab/src/api/billing.rs
@@ -1183,14 +1183,20 @@ async fn sync_subscription(
if subscription.status == SubscriptionStatus::Canceled
|| subscription.status == SubscriptionStatus::Paused
{
- 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)
+ let already_has_active_billing_subscription = app
+ .db
+ .has_active_billing_subscription(billing_customer.user_id)
.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?;
+ }
}
}