collab: Limit customers to one free trial (#29232)

This PR makes it so customers can only subscribe to the trial once.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2025-04-22 16:41:17 -04:00 committed by GitHub
parent abf2b9d7d3
commit a0eaede13d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 36 additions and 3 deletions

View file

@ -11,6 +11,7 @@ pub struct UpdateBillingCustomerParams {
pub user_id: ActiveValue<UserId>,
pub stripe_customer_id: ActiveValue<String>,
pub has_overdue_invoices: ActiveValue<bool>,
pub trial_started_at: ActiveValue<Option<DateTime>>,
}
impl Database {
@ -45,7 +46,8 @@ impl Database {
user_id: params.user_id.clone(),
stripe_customer_id: params.stripe_customer_id.clone(),
has_overdue_invoices: params.has_overdue_invoices.clone(),
..Default::default()
trial_started_at: params.trial_started_at.clone(),
created_at: ActiveValue::not_set(),
})
.exec(&*tx)
.await?;

View file

@ -10,6 +10,7 @@ pub struct Model {
pub user_id: UserId,
pub stripe_customer_id: String,
pub has_overdue_invoices: bool,
pub trial_started_at: Option<DateTime>,
pub created_at: DateTime,
}