Skip to content

Commit 04e9734

Browse files
fix(core): validate amount_to_capture in payment update (#3830)
1 parent 0626ca9 commit 04e9734

File tree

2 files changed

+6
-2
lines changed
  • crates/router/src/core/payments
  • postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario23- Update Amount/Payments - Update

2 files changed

+6
-2
lines changed

crates/router/src/core/payments/helpers.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -677,8 +677,11 @@ pub fn validate_amount_to_capture_and_capture_method(
677677
.unwrap_or(0);
678678
let total_capturable_amount =
679679
original_amount.map(|original_amount| original_amount + surcharge_amount);
680+
let amount_to_capture = request
681+
.amount_to_capture
682+
.or(payment_attempt.and_then(|pa| pa.amount_to_capture));
680683
if let Some((total_capturable_amount, amount_to_capture)) =
681-
total_capturable_amount.zip(request.amount_to_capture)
684+
total_capturable_amount.zip(amount_to_capture)
682685
{
683686
utils::when(amount_to_capture != total_capturable_amount, || {
684687
Err(report!(errors::ApiErrorResponse::PreconditionFailed {

postman/collection-dir/stripe/Flow Testcases/Happy Cases/Scenario23- Update Amount/Payments - Update/request.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@
1818
}
1919
},
2020
"raw_json_formatted": {
21-
"amount": 1000
21+
"amount": 1000,
22+
"amount_to_capture": 1000
2223
}
2324
},
2425
"url": {

0 commit comments

Comments
 (0)