mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-30 09:38:33 +08:00 
			
		
		
		
	fix: make amount_capturable zero when payment intent status is processing (#2163)
This commit is contained in:
		| @ -18,7 +18,10 @@ use crate::{ | |||||||
|     services::RedirectForm, |     services::RedirectForm, | ||||||
|     types::{ |     types::{ | ||||||
|         self, api, |         self, api, | ||||||
|         storage::{self, enums, payment_attempt::PaymentAttemptExt}, |         storage::{ | ||||||
|  |             self, enums, | ||||||
|  |             payment_attempt::{AttemptStatusExt, PaymentAttemptExt}, | ||||||
|  |         }, | ||||||
|         transformers::ForeignTryFrom, |         transformers::ForeignTryFrom, | ||||||
|         CaptureSyncResponse, |         CaptureSyncResponse, | ||||||
|     }, |     }, | ||||||
| @ -320,7 +323,11 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>( | |||||||
|                             error_message: Some(Some(err.message)), |                             error_message: Some(Some(err.message)), | ||||||
|                             error_code: Some(Some(err.code)), |                             error_code: Some(Some(err.code)), | ||||||
|                             error_reason: Some(err.reason), |                             error_reason: Some(err.reason), | ||||||
|                             amount_capturable: if status.is_terminal_status() { |                             amount_capturable: if status.is_terminal_status() | ||||||
|  |                                 || router_data | ||||||
|  |                                     .status | ||||||
|  |                                     .maps_to_intent_status(enums::IntentStatus::Processing) | ||||||
|  |                             { | ||||||
|                                 Some(0) |                                 Some(0) | ||||||
|                             } else { |                             } else { | ||||||
|                                 None |                                 None | ||||||
| @ -432,7 +439,11 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>( | |||||||
|                                 error_message: error_status.clone(), |                                 error_message: error_status.clone(), | ||||||
|                                 error_reason: error_status, |                                 error_reason: error_status, | ||||||
|                                 connector_response_reference_id, |                                 connector_response_reference_id, | ||||||
|                                 amount_capturable: if router_data.status.is_terminal_status() { |                                 amount_capturable: if router_data.status.is_terminal_status() | ||||||
|  |                                     || router_data | ||||||
|  |                                         .status | ||||||
|  |                                         .maps_to_intent_status(enums::IntentStatus::Processing) | ||||||
|  |                                 { | ||||||
|                                     Some(0) |                                     Some(0) | ||||||
|                                 } else { |                                 } else { | ||||||
|                                     None |                                     None | ||||||
|  | |||||||
| @ -69,6 +69,16 @@ impl PaymentAttemptExt for PaymentAttempt { | |||||||
|     } |     } | ||||||
| } | } | ||||||
|  |  | ||||||
|  | pub trait AttemptStatusExt { | ||||||
|  |     fn maps_to_intent_status(self, intent_status: enums::IntentStatus) -> bool; | ||||||
|  | } | ||||||
|  |  | ||||||
|  | impl AttemptStatusExt for enums::AttemptStatus { | ||||||
|  |     fn maps_to_intent_status(self, intent_status: enums::IntentStatus) -> bool { | ||||||
|  |         enums::IntentStatus::foreign_from(self) == intent_status | ||||||
|  |     } | ||||||
|  | } | ||||||
|  |  | ||||||
| #[cfg(test)] | #[cfg(test)] | ||||||
| #[cfg(feature = "dummy_connector")] | #[cfg(feature = "dummy_connector")] | ||||||
| mod tests { | mod tests { | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Hrithikesh
					Hrithikesh