mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	fix(update_trackers): handle preprocessing steps status update (#1496)
Co-authored-by: Sangamesh <sangamesh.kulkarni@juspay.in>
This commit is contained in:
		| @ -950,6 +950,7 @@ impl<F, T> | ||||
|                     }, | ||||
|                 ))), | ||||
|             }), | ||||
|             status: storage_models::enums::AttemptStatus::Pending, | ||||
|             ..item.data | ||||
|         }) | ||||
|     } | ||||
|  | ||||
| @ -553,13 +553,15 @@ where | ||||
|         payment_data.sessions_token.push(session_token); | ||||
|     }; | ||||
|  | ||||
|     let connector_request = if should_continue_further { | ||||
|     // In case of authorize flow, pre-task and post-tasks are being called in build request | ||||
|     // if we do not want to proceed further, then the function will return Ok(None, false) | ||||
|     let (connector_request, should_continue_further) = if should_continue_further { | ||||
|         // Check if the actual flow specific request can be built with available data | ||||
|         router_data | ||||
|             .build_flow_specific_connector_request(state, &connector, call_connector_action.clone()) | ||||
|             .await? | ||||
|     } else { | ||||
|         None | ||||
|         (None, false) | ||||
|     }; | ||||
|  | ||||
|     // Update the payment trackers just before calling the connector | ||||
| @ -576,11 +578,12 @@ where | ||||
|         ) | ||||
|         .await?; | ||||
|  | ||||
|     // The status of payment_attempt and intent will be updated in the previous step | ||||
|     // This field will be used by the connector | ||||
|     router_data.status = payment_data.payment_attempt.status; | ||||
|  | ||||
|     let router_data_res = if should_continue_further { | ||||
|         // The status of payment_attempt and intent will be updated in the previous step | ||||
|         // update this in router_data. | ||||
|         // This is added because few connector integrations do not update the status, | ||||
|         // and rely on previous status set in router_data | ||||
|         router_data.status = payment_data.payment_attempt.status; | ||||
|         router_data | ||||
|             .decide_flows( | ||||
|                 state, | ||||
|  | ||||
| @ -97,13 +97,14 @@ pub trait Feature<F, T> { | ||||
|         Ok(None) | ||||
|     } | ||||
|  | ||||
|     /// Returns the connector request and a bool which specifies whether to proceed with further | ||||
|     async fn build_flow_specific_connector_request( | ||||
|         &mut self, | ||||
|         _state: &AppState, | ||||
|         _connector: &api::ConnectorData, | ||||
|         _call_connector_action: payments::CallConnectorAction, | ||||
|     ) -> RouterResult<Option<services::Request>> { | ||||
|         Ok(None) | ||||
|     ) -> RouterResult<(Option<services::Request>, bool)> { | ||||
|         Ok((None, true)) | ||||
|     } | ||||
| } | ||||
|  | ||||
|  | ||||
| @ -146,7 +146,7 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu | ||||
|         state: &AppState, | ||||
|         connector: &api::ConnectorData, | ||||
|         call_connector_action: payments::CallConnectorAction, | ||||
|     ) -> RouterResult<Option<services::Request>> { | ||||
|     ) -> RouterResult<(Option<services::Request>, bool)> { | ||||
|         match call_connector_action { | ||||
|             payments::CallConnectorAction::Trigger => { | ||||
|                 let connector_integration: services::BoxedConnectorIntegration< | ||||
| @ -179,14 +179,17 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu | ||||
|                     self.decide_authentication_type(); | ||||
|                     logger::debug!(auth_type=?self.auth_type); | ||||
|  | ||||
|                     connector_integration | ||||
|                         .build_request(self, &state.conf.connectors) | ||||
|                         .to_payment_failed_response() | ||||
|                     Ok(( | ||||
|                         connector_integration | ||||
|                             .build_request(self, &state.conf.connectors) | ||||
|                             .to_payment_failed_response()?, | ||||
|                         true, | ||||
|                     )) | ||||
|                 } else { | ||||
|                     Ok(None) | ||||
|                     Ok((None, false)) | ||||
|                 } | ||||
|             } | ||||
|             _ => Ok(None), | ||||
|             _ => Ok((None, true)), | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -89,8 +89,8 @@ impl Feature<api::Void, types::PaymentsCancelData> | ||||
|         state: &AppState, | ||||
|         connector: &api::ConnectorData, | ||||
|         call_connector_action: payments::CallConnectorAction, | ||||
|     ) -> RouterResult<Option<services::Request>> { | ||||
|         match call_connector_action { | ||||
|     ) -> RouterResult<(Option<services::Request>, bool)> { | ||||
|         let request = match call_connector_action { | ||||
|             payments::CallConnectorAction::Trigger => { | ||||
|                 let connector_integration: services::BoxedConnectorIntegration< | ||||
|                     '_, | ||||
| @ -101,9 +101,11 @@ impl Feature<api::Void, types::PaymentsCancelData> | ||||
|  | ||||
|                 connector_integration | ||||
|                     .build_request(self, &state.conf.connectors) | ||||
|                     .to_payment_failed_response() | ||||
|                     .to_payment_failed_response()? | ||||
|             } | ||||
|             _ => Ok(None), | ||||
|         } | ||||
|             _ => None, | ||||
|         }; | ||||
|  | ||||
|         Ok((request, true)) | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -81,8 +81,8 @@ impl Feature<api::Capture, types::PaymentsCaptureData> | ||||
|         state: &AppState, | ||||
|         connector: &api::ConnectorData, | ||||
|         call_connector_action: payments::CallConnectorAction, | ||||
|     ) -> RouterResult<Option<services::Request>> { | ||||
|         match call_connector_action { | ||||
|     ) -> RouterResult<(Option<services::Request>, bool)> { | ||||
|         let request = match call_connector_action { | ||||
|             payments::CallConnectorAction::Trigger => { | ||||
|                 let connector_integration: services::BoxedConnectorIntegration< | ||||
|                     '_, | ||||
| @ -93,9 +93,11 @@ impl Feature<api::Capture, types::PaymentsCaptureData> | ||||
|  | ||||
|                 connector_integration | ||||
|                     .build_request(self, &state.conf.connectors) | ||||
|                     .to_payment_failed_response() | ||||
|                     .to_payment_failed_response()? | ||||
|             } | ||||
|             _ => Ok(None), | ||||
|         } | ||||
|             _ => None, | ||||
|         }; | ||||
|  | ||||
|         Ok((request, true)) | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -97,8 +97,8 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData> | ||||
|         state: &AppState, | ||||
|         connector: &api::ConnectorData, | ||||
|         call_connector_action: payments::CallConnectorAction, | ||||
|     ) -> RouterResult<Option<services::Request>> { | ||||
|         match call_connector_action { | ||||
|     ) -> RouterResult<(Option<services::Request>, bool)> { | ||||
|         let request = match call_connector_action { | ||||
|             payments::CallConnectorAction::Trigger => { | ||||
|                 let connector_integration: services::BoxedConnectorIntegration< | ||||
|                     '_, | ||||
| @ -109,9 +109,11 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData> | ||||
|  | ||||
|                 connector_integration | ||||
|                     .build_request(self, &state.conf.connectors) | ||||
|                     .to_payment_failed_response() | ||||
|                     .to_payment_failed_response()? | ||||
|             } | ||||
|             _ => Ok(None), | ||||
|         } | ||||
|             _ => None, | ||||
|         }; | ||||
|  | ||||
|         Ok((request, true)) | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -81,8 +81,8 @@ impl Feature<api::PSync, types::PaymentsSyncData> | ||||
|         state: &AppState, | ||||
|         connector: &api::ConnectorData, | ||||
|         call_connector_action: payments::CallConnectorAction, | ||||
|     ) -> RouterResult<Option<services::Request>> { | ||||
|         match call_connector_action { | ||||
|     ) -> RouterResult<(Option<services::Request>, bool)> { | ||||
|         let request = match call_connector_action { | ||||
|             payments::CallConnectorAction::Trigger => { | ||||
|                 let connector_integration: services::BoxedConnectorIntegration< | ||||
|                     '_, | ||||
| @ -93,9 +93,11 @@ impl Feature<api::PSync, types::PaymentsSyncData> | ||||
|  | ||||
|                 connector_integration | ||||
|                     .build_request(self, &state.conf.connectors) | ||||
|                     .to_payment_failed_response() | ||||
|                     .to_payment_failed_response()? | ||||
|             } | ||||
|             _ => Ok(None), | ||||
|         } | ||||
|             _ => None, | ||||
|         }; | ||||
|  | ||||
|         Ok((request, true)) | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -118,7 +118,7 @@ impl Feature<api::Verify, types::VerifyRequestData> for types::VerifyRouterData | ||||
|         state: &AppState, | ||||
|         connector: &api::ConnectorData, | ||||
|         call_connector_action: payments::CallConnectorAction, | ||||
|     ) -> RouterResult<Option<services::Request>> { | ||||
|     ) -> RouterResult<(Option<services::Request>, bool)> { | ||||
|         match call_connector_action { | ||||
|             payments::CallConnectorAction::Trigger => { | ||||
|                 let connector_integration: services::BoxedConnectorIntegration< | ||||
| @ -128,11 +128,14 @@ impl Feature<api::Verify, types::VerifyRequestData> for types::VerifyRouterData | ||||
|                     types::PaymentsResponseData, | ||||
|                 > = connector.connector.get_connector_integration(); | ||||
|  | ||||
|                 connector_integration | ||||
|                     .build_request(self, &state.conf.connectors) | ||||
|                     .to_payment_failed_response() | ||||
|                 Ok(( | ||||
|                     connector_integration | ||||
|                         .build_request(self, &state.conf.connectors) | ||||
|                         .to_payment_failed_response()?, | ||||
|                     true, | ||||
|                 )) | ||||
|             } | ||||
|             _ => Ok(None), | ||||
|             _ => Ok((None, true)), | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Narayan Bhat
					Narayan Bhat