diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index 2cd62fbd4914..b4bd677df5b2 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -3799,17 +3799,22 @@ pub async fn get_gsm_record( pub fn validate_order_details_amount( order_details: Vec, amount: i64, + should_validate: bool, ) -> Result<(), errors::ApiErrorResponse> { - let total_order_details_amount: i64 = order_details - .iter() - .map(|order| order.amount * i64::from(order.quantity)) - .sum(); + if should_validate { + let total_order_details_amount: i64 = order_details + .iter() + .map(|order| order.amount * i64::from(order.quantity)) + .sum(); - if total_order_details_amount != amount { - Err(errors::ApiErrorResponse::InvalidRequestData { - message: "Total sum of order details doesn't match amount in payment request" - .to_string(), - }) + if total_order_details_amount != amount { + Err(errors::ApiErrorResponse::InvalidRequestData { + message: "Total sum of order details doesn't match amount in payment request" + .to_string(), + }) + } else { + Ok(()) + } } else { Ok(()) } diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs index 58983f264c70..36b258bf5f0f 100644 --- a/crates/router/src/core/payments/operations/payment_confirm.rs +++ b/crates/router/src/core/payments/operations/payment_confirm.rs @@ -105,6 +105,7 @@ impl helpers::validate_order_details_amount( order_details.to_owned(), payment_intent.amount, + false, )?; } diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs index 798678e64df3..3314f09c8c9c 100644 --- a/crates/router/src/core/payments/operations/payment_create.rs +++ b/crates/router/src/core/payments/operations/payment_create.rs @@ -190,6 +190,7 @@ impl helpers::validate_order_details_amount( order_details.to_owned(), payment_intent.amount, + false, )?; } diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs index 153ded14f4b8..530a19a4d6b1 100644 --- a/crates/router/src/core/payments/operations/payment_update.rs +++ b/crates/router/src/core/payments/operations/payment_update.rs @@ -64,6 +64,7 @@ impl helpers::validate_order_details_amount( order_details.to_owned(), payment_intent.amount, + false, )?; }