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: Use the right `zed.dev` URL for the environment (#15566)

Marshall Bowers2bc0a58f32a5
diff --git a/crates/collab/src/api/billing.rs b/crates/collab/src/api/billing.rs
index b33344c53ca..bd8890019b7 100644
--- a/crates/collab/src/api/billing.rs
+++ b/crates/collab/src/api/billing.rs
@@ -153,7 +153,8 @@ async fn create_billing_subscription(
quantity: Some(1),
..Default::default()
}]);
- params.success_url = Some("https://zed.dev/billing/success");
+ let success_url = format!("{}/settings", app.config.zed_dot_dev_url());
+ params.success_url = Some(&success_url);
CheckoutSession::create(&stripe_client, params).await?
};
@@ -260,7 +261,7 @@ async fn manage_billing_subscription(
after_completion: Some(CreateBillingPortalSessionFlowDataAfterCompletion {
type_: stripe::CreateBillingPortalSessionFlowDataAfterCompletionType::Redirect,
redirect: Some(CreateBillingPortalSessionFlowDataAfterCompletionRedirect {
- return_url: "https://zed.dev/settings".into(),
+ return_url: format!("{}/settings", app.config.zed_dot_dev_url()),
}),
..Default::default()
}),
@@ -277,7 +278,8 @@ async fn manage_billing_subscription(
let mut params = CreateBillingPortalSession::new(customer_id);
params.flow_data = Some(flow);
- params.return_url = Some("https://zed.dev/settings");
+ let return_url = format!("{}/settings", app.config.zed_dot_dev_url());
+ params.return_url = Some(&return_url);
let session = BillingPortalSession::create(&stripe_client, params).await?;
diff --git a/crates/collab/src/lib.rs b/crates/collab/src/lib.rs
index 89705428aa6..b45c961efda 100644
--- a/crates/collab/src/lib.rs
+++ b/crates/collab/src/lib.rs
@@ -163,6 +163,15 @@ impl Config {
pub fn is_development(&self) -> bool {
self.zed_environment == "development".into()
}
+
+ /// Returns the base `zed.dev` URL.
+ pub fn zed_dot_dev_url(&self) -> &str {
+ match self.zed_environment.as_ref() {
+ "development" => "http://localhost:3000",
+ "staging" => "https://staging.zed.dev",
+ _ => "https://zed.dev",
+ }
+ }
}
pub struct AppState {