collab: Add support for launching a general-purpose billing portal session (#28785)
This PR adds a new `ManageSubscriptionIntent` that allows uses to launch a general-purpose billing portal session to manage their subscription. Release Notes: - N/A
This commit is contained in:
parent
05fc9ee396
commit
b6cce1ed91
1 changed files with 8 additions and 3 deletions
|
@ -313,6 +313,10 @@ async fn create_billing_subscription(
|
||||||
#[derive(Debug, PartialEq, Deserialize)]
|
#[derive(Debug, PartialEq, Deserialize)]
|
||||||
#[serde(rename_all = "snake_case")]
|
#[serde(rename_all = "snake_case")]
|
||||||
enum ManageSubscriptionIntent {
|
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.
|
/// The user intends to cancel their subscription.
|
||||||
Cancel,
|
Cancel,
|
||||||
/// The user intends to stop the cancellation of their subscription.
|
/// The user intends to stop the cancellation of their subscription.
|
||||||
|
@ -400,7 +404,8 @@ async fn manage_billing_subscription(
|
||||||
}
|
}
|
||||||
|
|
||||||
let flow = match body.intent {
|
let flow = match body.intent {
|
||||||
ManageSubscriptionIntent::Cancel => CreateBillingPortalSessionFlowData {
|
ManageSubscriptionIntent::ManageSubscription => None,
|
||||||
|
ManageSubscriptionIntent::Cancel => Some(CreateBillingPortalSessionFlowData {
|
||||||
type_: CreateBillingPortalSessionFlowDataType::SubscriptionCancel,
|
type_: CreateBillingPortalSessionFlowDataType::SubscriptionCancel,
|
||||||
after_completion: Some(CreateBillingPortalSessionFlowDataAfterCompletion {
|
after_completion: Some(CreateBillingPortalSessionFlowDataAfterCompletion {
|
||||||
type_: stripe::CreateBillingPortalSessionFlowDataAfterCompletionType::Redirect,
|
type_: stripe::CreateBillingPortalSessionFlowDataAfterCompletionType::Redirect,
|
||||||
|
@ -416,12 +421,12 @@ async fn manage_billing_subscription(
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
}),
|
||||||
ManageSubscriptionIntent::StopCancellation => unreachable!(),
|
ManageSubscriptionIntent::StopCancellation => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
let mut params = CreateBillingPortalSession::new(customer_id);
|
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());
|
let return_url = format!("{}/account", app.config.zed_dot_dev_url());
|
||||||
params.return_url = Some(&return_url);
|
params.return_url = Some(&return_url);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue