collab: Update Stripe customer email before checkout (#32669)

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2025-06-16 19:55:27 -06:00 committed by GitHub
parent 783412fa1d
commit dfa7ed55be
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 66 additions and 6 deletions

View file

@ -31,7 +31,7 @@ use crate::llm::{AGENT_EXTENDED_TRIAL_FEATURE_FLAG, DEFAULT_MAX_MONTHLY_SPEND};
use crate::rpc::{ResultExt as _, Server};
use crate::stripe_client::{
StripeCancellationDetailsReason, StripeClient, StripeCustomerId, StripeSubscription,
StripeSubscriptionId,
StripeSubscriptionId, UpdateCustomerParams,
};
use crate::{AppState, Error, Result};
use crate::{db::UserId, llm::db::LlmDatabase};
@ -353,7 +353,17 @@ async fn create_billing_subscription(
}
let customer_id = if let Some(existing_customer) = &existing_billing_customer {
StripeCustomerId(existing_customer.stripe_customer_id.clone().into())
let customer_id = StripeCustomerId(existing_customer.stripe_customer_id.clone().into());
if let Some(email) = user.email_address.as_deref() {
stripe_billing
.client()
.update_customer(&customer_id, UpdateCustomerParams { email: Some(email) })
.await
// Update of email address is best-effort - continue checkout even if it fails
.context("error updating stripe customer email address")
.log_err();
}
customer_id
} else {
stripe_billing
.find_or_create_customer_by_email(user.email_address.as_deref())