Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
collab: Add support for launching a general-purpose billing portal session (#28785)
Marshall Bowersb6cce1ed91ef
diff --git a/crates/collab/src/api/billing.rs b/crates/collab/src/api/billing.rsindex 4fba728cae4..dfc0a4a9513 100644--- a/crates/collab/src/api/billing.rs+++ b/crates/collab/src/api/billing.rs@@ -313,6 +313,10 @@ async fn create_billing_subscription(#[derive(Debug, PartialEq, Deserialize)]#[serde(rename_all = "snake_case")]enum ManageSubscriptionIntent {+ /// The user intends to manage their subscription.+ ///+ /// This will open the Stripe billing portal without putting the user in a specific flow.+ ManageSubscription,/// The user intends to cancel their subscription.Cancel,/// The user intends to stop the cancellation of their subscription.@@ -400,7 +404,8 @@ async fn manage_billing_subscription(}let flow = match body.intent {- ManageSubscriptionIntent::Cancel => CreateBillingPortalSessionFlowData {+ ManageSubscriptionIntent::ManageSubscription => None,+ ManageSubscriptionIntent::Cancel => Some(CreateBillingPortalSessionFlowData {type_: CreateBillingPortalSessionFlowDataType::SubscriptionCancel,after_completion: Some(CreateBillingPortalSessionFlowDataAfterCompletion {type_: stripe::CreateBillingPortalSessionFlowDataAfterCompletionType::Redirect,@@ -416,12 +421,12 @@ async fn manage_billing_subscription(},),..Default::default()- },+ }),ManageSubscriptionIntent::StopCancellation => unreachable!(),};let mut params = CreateBillingPortalSession::new(customer_id);- params.flow_data = Some(flow);+ params.flow_data = flow;let return_url = format!("{}/account", app.config.zed_dot_dev_url());params.return_url = Some(&return_url);