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: Add intent for updating payment method (#30306)

Marshall Bowers660b4cee768f
diff --git a/crates/collab/src/api/billing.rs b/crates/collab/src/api/billing.rs
index 8f8789ec1ce..b3ab87e0eac 100644
--- a/crates/collab/src/api/billing.rs
+++ b/crates/collab/src/api/billing.rs
@@ -429,6 +429,8 @@ enum ManageSubscriptionIntent {
///
/// This will open the Stripe billing portal without putting the user in a specific flow.
ManageSubscription,
+ /// The user intends to update their payment method.
+ UpdatePaymentMethod,
/// The user intends to upgrade to Zed Pro.
UpgradeToPro,
/// The user intends to cancel their subscription.
@@ -589,6 +591,17 @@ async fn manage_billing_subscription(
..Default::default()
})
}
+ ManageSubscriptionIntent::UpdatePaymentMethod => Some(CreateBillingPortalSessionFlowData {
+ type_: CreateBillingPortalSessionFlowDataType::PaymentMethodUpdate,
+ after_completion: Some(CreateBillingPortalSessionFlowDataAfterCompletion {
+ type_: stripe::CreateBillingPortalSessionFlowDataAfterCompletionType::Redirect,
+ redirect: Some(CreateBillingPortalSessionFlowDataAfterCompletionRedirect {
+ return_url: format!("{}/account", app.config.zed_dot_dev_url()),
+ }),
+ ..Default::default()
+ }),
+ ..Default::default()
+ }),
ManageSubscriptionIntent::Cancel => Some(CreateBillingPortalSessionFlowData {
type_: CreateBillingPortalSessionFlowDataType::SubscriptionCancel,
after_completion: Some(CreateBillingPortalSessionFlowDataAfterCompletion {