mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 01:57:45 +08:00 
			
		
		
		
	fix: amount_captured goes to 0 for 3ds payments (#2954)
This commit is contained in:
		| @ -601,19 +601,19 @@ pub fn validate_request_amount_and_amount_to_capture( | ||||
|     } | ||||
| } | ||||
|  | ||||
| /// if confirm = true and capture method = automatic, amount_to_capture(if provided) must be equal to amount | ||||
| /// if capture method = automatic, amount_to_capture(if provided) must be equal to amount | ||||
| #[instrument(skip_all)] | ||||
| pub fn validate_amount_to_capture_in_create_call_request( | ||||
|     request: &api_models::payments::PaymentsRequest, | ||||
| ) -> CustomResult<(), errors::ApiErrorResponse> { | ||||
|     if request.capture_method.unwrap_or_default() == api_enums::CaptureMethod::Automatic | ||||
|         && request.confirm.unwrap_or(false) | ||||
|     { | ||||
|         if let Some((amount_to_capture, amount)) = request.amount_to_capture.zip(request.amount) { | ||||
|             let amount_int: i64 = amount.into(); | ||||
|             utils::when(amount_to_capture != amount_int, || { | ||||
|     if request.capture_method.unwrap_or_default() == api_enums::CaptureMethod::Automatic { | ||||
|         let total_capturable_amount = request.get_total_capturable_amount(); | ||||
|         if let Some((amount_to_capture, total_capturable_amount)) = | ||||
|             request.amount_to_capture.zip(total_capturable_amount) | ||||
|         { | ||||
|             utils::when(amount_to_capture != total_capturable_amount, || { | ||||
|                 Err(report!(errors::ApiErrorResponse::PreconditionFailed { | ||||
|                     message: "amount_to_capture must be equal to amount when confirm = true and capture_method = automatic".into() | ||||
|                     message: "amount_to_capture must be equal to total_capturable_amount when capture_method = automatic".into() | ||||
|                 })) | ||||
|             }) | ||||
|         } else { | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Hrithikesh
					Hrithikesh