collab: Add intent for updating payment method (#30306)

This PR adds a new `ManageSubscriptionIntent` for initiating a session
to update the user's payment method.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-05-08 16:17:19 -04:00 committed by GitHub
parent e74ae89c84
commit 660b4cee76
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -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 {