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
|
@ -489,16 +489,38 @@ impl StripeBilling {
|
|||
zed_pro_price_id: PriceId,
|
||||
customer_id: stripe::CustomerId,
|
||||
github_login: &str,
|
||||
feature_flags: Vec<String>,
|
||||
success_url: &str,
|
||||
) -> 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();
|
||||
params.subscription_data = Some(stripe::CreateCheckoutSessionSubscriptionData {
|
||||
trial_period_days: Some(14),
|
||||
trial_period_days: Some(trial_period_days),
|
||||
trial_settings: Some(stripe::CreateCheckoutSessionSubscriptionDataTrialSettings {
|
||||
end_behavior: stripe::CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehavior {
|
||||
missing_payment_method: stripe::CreateCheckoutSessionSubscriptionDataTrialSettingsEndBehaviorMissingPaymentMethod::Pause,
|
||||
}
|
||||
}),
|
||||
metadata: if !subscription_metadata.is_empty() {
|
||||
Some(subscription_metadata)
|
||||
} else {
|
||||
None
|
||||
},
|
||||
..Default::default()
|
||||
});
|
||||
params.mode = Some(stripe::CheckoutSessionMode::Subscription);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue