collab: Subscribe to Zed Free when a subscription is canceled or paused (#30965)

This PR makes it so that when a Stripe subscription is canceled or
paused we'll subscribe the user to Zed Free.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-05-19 13:35:03 -04:00 committed by GitHub
parent 9041f734fd
commit fdec966226
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 0 deletions

View file

@ -263,6 +263,24 @@ impl StripeBilling {
Ok(session.url.context("no checkout session URL")?)
}
pub async fn subscribe_to_zed_free(
&self,
customer_id: stripe::CustomerId,
) -> Result<stripe::Subscription> {
let zed_free_price_id = self.zed_free_price_id().await?;
let mut params = stripe::CreateSubscription::new(customer_id);
params.items = Some(vec![stripe::CreateSubscriptionItems {
price: Some(zed_free_price_id.to_string()),
quantity: Some(1),
..Default::default()
}]);
let subscription = stripe::Subscription::create(&self.client, params).await?;
Ok(subscription)
}
pub async fn checkout_with_zed_free(
&self,
customer_id: stripe::CustomerId,