diff --git a/apps/labrinth/src/routes/internal/billing.rs b/apps/labrinth/src/routes/internal/billing.rs index d3cb8004291..d013969873c 100644 --- a/apps/labrinth/src/routes/internal/billing.rs +++ b/apps/labrinth/src/routes/internal/billing.rs @@ -1789,6 +1789,7 @@ pub async fn initiate_payment( }, attached_charge: AttachedCharge::from_charge_request_type( &**pool, + &user, payment_request.charge, ) .await diff --git a/apps/labrinth/src/routes/internal/billing/payments.rs b/apps/labrinth/src/routes/internal/billing/payments.rs index 00a2c179522..31da2c6da66 100644 --- a/apps/labrinth/src/routes/internal/billing/payments.rs +++ b/apps/labrinth/src/routes/internal/billing/payments.rs @@ -139,6 +139,7 @@ impl AttachedCharge { pub async fn from_charge_request_type( exec: impl crate::database::Executor<'_, Database = sqlx::Postgres>, + user: &User, charge_request_type: ChargeRequestType, ) -> Result { Ok(match charge_request_type { @@ -146,6 +147,7 @@ impl AttachedCharge { charge: DBCharge::get(id.into(), exec) .await .wrap_internal_err("fetching charge from database")? + .filter(|charge| charge.user_id == user.id.into()) .wrap_request_err_with(|| { "could not find charge".to_string() })?,