mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 20:23:43 +08:00
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:
@ -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),
|
||||
|| {
|
||||
|
||||
Reference in New Issue
Block a user