Skip to content
Merged
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
14 changes: 6 additions & 8 deletions apps/labrinth/src/routes/internal/billing/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -214,6 +214,8 @@ pub async fn create_or_update_payment_intent(
)
.await?;

let mut intent_uses_confirmation_token = false;

let payment_method = match &payment_session {
PaymentSession::Interactive {
payment_request_type: PaymentRequestType::PaymentMethod { id },
Expand All @@ -232,6 +234,8 @@ pub async fn create_or_update_payment_intent(
payment_request_type:
PaymentRequestType::ConfirmationToken { token },
} => {
intent_uses_confirmation_token = true;

#[derive(Deserialize)]
struct ConfirmationToken {
payment_method_preview: Option<PaymentMethod>,
Expand Down Expand Up @@ -544,10 +548,7 @@ pub async fn create_or_update_payment_intent(
//
// The PaymentIntent will be confirmed using the confirmation token
// by the client.
if let PaymentSession::Interactive {
payment_request_type: PaymentRequestType::PaymentMethod { .. },
} = &payment_session
{
if !intent_uses_confirmation_token {
update_payment_intent.payment_method =
Some(payment_method.id.clone());
}
Expand Down Expand Up @@ -575,10 +576,7 @@ pub async fn create_or_update_payment_intent(
intent.customer = Some(customer_id);
intent.metadata = Some(metadata);
intent.receipt_email = user.email.as_deref();
if let PaymentSession::Interactive {
payment_request_type: PaymentRequestType::PaymentMethod { .. },
} = &payment_session
{
if !intent_uses_confirmation_token {
intent.payment_method = Some(payment_method.id.clone());
}

Expand Down