collab: Prevent canceling the free plan (#31292)
This PR makes it so the Zed Free plan cannot be canceled. We were already preventing this on the zed.dev side, but this will make it more airtight. Release Notes: - N/A
This commit is contained in:
parent
2f1d9284b7
commit
1683e2f144
1 changed files with 26 additions and 16 deletions
|
@ -269,7 +269,8 @@ async fn list_billing_subscriptions(
|
||||||
.and_utc()
|
.and_utc()
|
||||||
.to_rfc3339_opts(SecondsFormat::Millis, true)
|
.to_rfc3339_opts(SecondsFormat::Millis, true)
|
||||||
}),
|
}),
|
||||||
is_cancelable: subscription.stripe_subscription_status.is_cancelable()
|
is_cancelable: subscription.kind != Some(SubscriptionKind::ZedFree)
|
||||||
|
&& subscription.stripe_subscription_status.is_cancelable()
|
||||||
&& subscription.stripe_cancel_at.is_none(),
|
&& subscription.stripe_cancel_at.is_none(),
|
||||||
})
|
})
|
||||||
.collect(),
|
.collect(),
|
||||||
|
@ -591,7 +592,15 @@ async fn manage_billing_subscription(
|
||||||
}),
|
}),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
}),
|
||||||
ManageSubscriptionIntent::Cancel => Some(CreateBillingPortalSessionFlowData {
|
ManageSubscriptionIntent::Cancel => {
|
||||||
|
if subscription.kind == Some(SubscriptionKind::ZedFree) {
|
||||||
|
return Err(Error::http(
|
||||||
|
StatusCode::BAD_REQUEST,
|
||||||
|
"free subscription cannot be canceled".into(),
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
Some(CreateBillingPortalSessionFlowData {
|
||||||
type_: CreateBillingPortalSessionFlowDataType::SubscriptionCancel,
|
type_: CreateBillingPortalSessionFlowDataType::SubscriptionCancel,
|
||||||
after_completion: Some(CreateBillingPortalSessionFlowDataAfterCompletion {
|
after_completion: Some(CreateBillingPortalSessionFlowDataAfterCompletion {
|
||||||
type_: stripe::CreateBillingPortalSessionFlowDataAfterCompletionType::Redirect,
|
type_: stripe::CreateBillingPortalSessionFlowDataAfterCompletionType::Redirect,
|
||||||
|
@ -607,7 +616,8 @@ async fn manage_billing_subscription(
|
||||||
},
|
},
|
||||||
),
|
),
|
||||||
..Default::default()
|
..Default::default()
|
||||||
}),
|
})
|
||||||
|
}
|
||||||
ManageSubscriptionIntent::StopCancellation => unreachable!(),
|
ManageSubscriptionIntent::StopCancellation => unreachable!(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue