mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 10:06:32 +08:00 
			
		
		
		
	fix(core): validate amount_to_capture in payment update (#3830)
This commit is contained in:
		| @ -677,8 +677,11 @@ pub fn validate_amount_to_capture_and_capture_method( | |||||||
|             .unwrap_or(0); |             .unwrap_or(0); | ||||||
|         let total_capturable_amount = |         let total_capturable_amount = | ||||||
|             original_amount.map(|original_amount| original_amount + surcharge_amount); |             original_amount.map(|original_amount| original_amount + surcharge_amount); | ||||||
|  |         let amount_to_capture = request | ||||||
|  |             .amount_to_capture | ||||||
|  |             .or(payment_attempt.and_then(|pa| pa.amount_to_capture)); | ||||||
|         if let Some((total_capturable_amount, amount_to_capture)) = |         if let Some((total_capturable_amount, amount_to_capture)) = | ||||||
|             total_capturable_amount.zip(request.amount_to_capture) |             total_capturable_amount.zip(amount_to_capture) | ||||||
|         { |         { | ||||||
|             utils::when(amount_to_capture != total_capturable_amount, || { |             utils::when(amount_to_capture != total_capturable_amount, || { | ||||||
|                 Err(report!(errors::ApiErrorResponse::PreconditionFailed { |                 Err(report!(errors::ApiErrorResponse::PreconditionFailed { | ||||||
|  | |||||||
| @ -18,7 +18,8 @@ | |||||||
|       } |       } | ||||||
|     }, |     }, | ||||||
|     "raw_json_formatted": { |     "raw_json_formatted": { | ||||||
|       "amount": 1000 |       "amount": 1000, | ||||||
|  |       "amount_to_capture": 1000 | ||||||
|     } |     } | ||||||
|   }, |   }, | ||||||
|   "url": { |   "url": { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Hrithikesh
					Hrithikesh