collab: Add support for extended Zed Pro trial (#29612)
This PR adds support for an extended Zed Pro trial, applied based on the presence of the `agent-extended-trial` feature flag. Release Notes: - N/A
This commit is contained in:
parent
f7f44bfbed
commit
386970c29a
2 changed files with 26 additions and 1 deletions
|
@ -380,11 +380,14 @@ async fn create_billing_subscription(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let feature_flags = app.db.get_user_flags(user.id).await?;
|
||||||
|
|
||||||
stripe_billing
|
stripe_billing
|
||||||
.checkout_with_zed_pro_trial(
|
.checkout_with_zed_pro_trial(
|
||||||
app.config.zed_pro_price_id()?,
|
app.config.zed_pro_price_id()?,
|
||||||
customer_id,
|
customer_id,
|
||||||
&user.github_login,
|
&user.github_login,
|
||||||
|
feature_flags,
|
||||||
&success_url,
|
&success_url,
|
||||||
)
|
)
|
||||||
.await?
|
.await?
|
||||||
|
|
|
@ -489,16 +489,38 @@ impl StripeBilling {
|
||||||
zed_pro_price_id: PriceId,
|
zed_pro_price_id: PriceId,
|
||||||
customer_id: stripe::CustomerId,
|
customer_id: stripe::CustomerId,
|
||||||
github_login: &str,
|
github_login: &str,
|
||||||
|
feature_flags: Vec<String>,
|
||||||
success_url: &str,
|
success_url: &str,
|
||||||
) -> Result<String> {
|
) -> Result<String> {
|
||||||
|
const AGENT_EXTENDED_TRIAL_FEATURE_FLAG: &str = "agent-extended-trial";
|
||||||
|
|
||||||
|
let eligible_for_extended_trial = feature_flags
|
||||||
|
.iter()
|
||||||
|
.any(|flag| flag == AGENT_EXTENDED_TRIAL_FEATURE_FLAG);
|
||||||
|
|
||||||
|
let trial_period_days = if eligible_for_extended_trial { 60 } else { 14 };
|
||||||
|
|
||||||
|
let mut subscription_metadata = std::collections::HashMap::new();
|
||||||
|
if eligible_for_extended_trial {
|
||||||
|
subscription_metadata.insert(
|
||||||
|
"promo_feature_flag".to_string(),
|
||||||
|
AGENT_EXTENDED_TRIAL_FEATURE_FLAG.to_string(),
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
let mut params = stripe::CreateCheckoutSession::new();
|
let mut params = stripe::CreateCheckoutSession::new();
|
||||||
params.subscription_data = Some(stripe::CreateCheckoutSessionSubscriptionData {
|
params.subscription_data = Some(stripe::CreateCheckoutSessionSubscriptionData {
|
||||||
trial_period_days: Some(14),
|
trial_period_days: Some(trial_period_days),
|
||||||
trial_settings: Some(stripe::CreateCheckoutSessionSubscriptionDataTrialSettings {
|
trial_settings: Some(stripe::CreateCheckoutSessionSubscriptionDataTrialSettings {
|
||||||
end_behavior: stripe::CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehavior {
|
end_behavior: stripe::CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehavior {
|
||||||
missing_payment_method: stripe::CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod::Pause,
|
missing_payment_method: stripe::CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod::Pause,
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
|
metadata: if !subscription_metadata.is_empty() {
|
||||||
|
Some(subscription_metadata)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
..Default::default()
|
..Default::default()
|
||||||
});
|
});
|
||||||
params.mode = Some(stripe::CheckoutSessionMode::Subscription);
|
params.mode = Some(stripe::CheckoutSessionMode::Subscription);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue