fix(core): Add Validation Check for Amount in Capture Flow (#9434)

Co-authored-by: Anurag Singh <anurag.singh.001@MacBookPro.lan>
Co-authored-by: Anurag Singh <anurag.singh.001@Anurag-Singh-WPMHJ5619X.local>
This commit is contained in:
Anurag
2025-09-19 12:30:37 +05:30
committed by GitHub
parent 8930e1ed28
commit 87fc0066f6
5 changed files with 108 additions and 24 deletions

View File

@ -2966,6 +2966,13 @@ pub(crate) fn validate_amount_to_capture(
amount: i64,
amount_to_capture: Option<i64>,
) -> RouterResult<()> {
utils::when(amount_to_capture.is_some_and(|value| value <= 0), || {
Err(report!(errors::ApiErrorResponse::InvalidDataFormat {
field_name: "amount".to_string(),
expected_format: "positive integer".to_string(),
}))
})?;
utils::when(
amount_to_capture.is_some() && (Some(amount) < amount_to_capture),
|| {