Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions apps/labrinth/src/routes/internal/billing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1789,6 +1789,7 @@ pub async fn initiate_payment(
},
attached_charge: AttachedCharge::from_charge_request_type(
&**pool,
&user,
payment_request.charge,
)
.await
Expand Down
2 changes: 2 additions & 0 deletions apps/labrinth/src/routes/internal/billing/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,13 +139,15 @@ impl AttachedCharge {

pub async fn from_charge_request_type(
exec: impl crate::database::Executor<'_, Database = sqlx::Postgres>,
user: &User,
charge_request_type: ChargeRequestType,
) -> Result<Self, ApiError> {
Ok(match charge_request_type {
ChargeRequestType::Existing { id } => AttachedCharge::UseExisting {
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()
})?,
Expand Down
Loading