collab: Require product code for POST /billing/subscriptions
(#30968)
This PR makes the `product` field required in the request body for `POST /billing/subscriptions`. We were already passing this everywhere, in practice. Release Notes: - N/A
This commit is contained in:
parent
fdec966226
commit
b93c67438c
1 changed files with 4 additions and 10 deletions
|
@ -291,7 +291,7 @@ enum ProductCode {
|
||||||
#[derive(Debug, Deserialize)]
|
#[derive(Debug, Deserialize)]
|
||||||
struct CreateBillingSubscriptionBody {
|
struct CreateBillingSubscriptionBody {
|
||||||
github_user_id: i32,
|
github_user_id: i32,
|
||||||
product: Option<ProductCode>,
|
product: ProductCode,
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Serialize)]
|
#[derive(Debug, Serialize)]
|
||||||
|
@ -383,12 +383,12 @@ async fn create_billing_subscription(
|
||||||
);
|
);
|
||||||
|
|
||||||
let checkout_session_url = match body.product {
|
let checkout_session_url = match body.product {
|
||||||
Some(ProductCode::ZedPro) => {
|
ProductCode::ZedPro => {
|
||||||
stripe_billing
|
stripe_billing
|
||||||
.checkout_with_zed_pro(customer_id, &user.github_login, &success_url)
|
.checkout_with_zed_pro(customer_id, &user.github_login, &success_url)
|
||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
Some(ProductCode::ZedProTrial) => {
|
ProductCode::ZedProTrial => {
|
||||||
if let Some(existing_billing_customer) = &existing_billing_customer {
|
if let Some(existing_billing_customer) = &existing_billing_customer {
|
||||||
if existing_billing_customer.trial_started_at.is_some() {
|
if existing_billing_customer.trial_started_at.is_some() {
|
||||||
return Err(Error::http(
|
return Err(Error::http(
|
||||||
|
@ -409,17 +409,11 @@ async fn create_billing_subscription(
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
Some(ProductCode::ZedFree) => {
|
ProductCode::ZedFree => {
|
||||||
stripe_billing
|
stripe_billing
|
||||||
.checkout_with_zed_free(customer_id, &user.github_login, &success_url)
|
.checkout_with_zed_free(customer_id, &user.github_login, &success_url)
|
||||||
.await?
|
.await?
|
||||||
}
|
}
|
||||||
None => {
|
|
||||||
return Err(Error::http(
|
|
||||||
StatusCode::BAD_REQUEST,
|
|
||||||
"No product selected".into(),
|
|
||||||
));
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Ok(Json(CreateBillingSubscriptionResponse {
|
Ok(Json(CreateBillingSubscriptionResponse {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue