Skip to content

Commit

Permalink
Merge branch 'hotfix-1.105.0' into boa-meta-hot-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
deepanshu-iiitu authored Jan 11, 2024
2 parents c16dcf8 + b54603c commit 7e2e366
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 9 deletions.
23 changes: 14 additions & 9 deletions crates/router/src/core/payments/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3799,17 +3799,22 @@ pub async fn get_gsm_record(
pub fn validate_order_details_amount(
order_details: Vec<api_models::payments::OrderDetailsWithAmount>,
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(())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
helpers::validate_order_details_amount(
order_details.to_owned(),
payment_intent.amount,
false,
)?;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
helpers::validate_order_details_amount(
order_details.to_owned(),
payment_intent.amount,
false,
)?;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
helpers::validate_order_details_amount(
order_details.to_owned(),
payment_intent.amount,
false,
)?;
}

Expand Down

0 comments on commit 7e2e366

Please sign in to comment.