Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat: Add configurable granular preprocessing flow for authentication bloated connectors (#10567)

Hrithikeshe39e6a51beb4
diff --git a/crates/hyperswitch_connectors/src/connectors/cybersource.rs b/crates/hyperswitch_connectors/src/connectors/cybersource.rs
index 209f613015..22b6ff9be1 100644
--- a/crates/hyperswitch_connectors/src/connectors/cybersource.rs
+++ b/crates/hyperswitch_connectors/src/connectors/cybersource.rs
@@ -2300,36 +2300,6 @@ impl ConnectorSpecifications for Cybersource {
}
}
}
- fn decide_should_continue_after_preprocessing(
- &self,
- current_flow: api::CurrentFlowInfo<'_>,
- pre_processing_flow_name: api::PreProcessingFlowName,
- preprocessing_flow_response: api::PreProcessingFlowResponse<'_>,
- ) -> bool {
- match (current_flow, pre_processing_flow_name) {
- (api::CurrentFlowInfo::Authorize { .. }, _) => {
- // during authorize flow, there is no pre processing flow. Only alternate PreAuthenticate flow
- true
- }
- (
- api::CurrentFlowInfo::CompleteAuthorize { .. },
- api::PreProcessingFlowName::Authenticate,
- )
- | (
- api::CurrentFlowInfo::CompleteAuthorize { .. },
- api::PreProcessingFlowName::PostAuthenticate,
- ) => {
- (matches!(
- preprocessing_flow_response.response,
- Ok(PaymentsResponseData::TransactionResponse {
- ref redirection_data,
- ..
- }) if redirection_data.is_none()
- ) && preprocessing_flow_response.attempt_status
- != common_enums::AttemptStatus::AuthenticationFailed)
- }
- }
- }
fn get_alternate_flow_if_needed(
&self,
current_flow: api::CurrentFlowInfo<'_>,
@@ -2349,6 +2319,56 @@ impl ConnectorSpecifications for Cybersource {
api::CurrentFlowInfo::CompleteAuthorize { .. } => None,
}
}
+ fn is_pre_authentication_flow_required(&self, current_flow: api::CurrentFlowInfo<'_>) -> bool {
+ match current_flow {
+ api::CurrentFlowInfo::Authorize {
+ request_data,
+ auth_type,
+ } => self.is_3ds_setup_required(request_data, *auth_type),
+ // No alternate flow for complete authorize
+ api::CurrentFlowInfo::CompleteAuthorize { .. } => false,
+ }
+ }
+ /// Check if authentication flow is required
+ fn is_authentication_flow_required(&self, current_flow: api::CurrentFlowInfo<'_>) -> bool {
+ match current_flow {
+ api::CurrentFlowInfo::Authorize { .. } => {
+ // during authorize flow, there is no post_authentication call needed
+ false
+ }
+ api::CurrentFlowInfo::CompleteAuthorize { request_data } => {
+ // TODO: add logic before deciding the pre processing flow Authenticate or PostAuthenticate
+ let redirection_params = request_data
+ .redirect_response
+ .as_ref()
+ .and_then(|redirect_response| redirect_response.params.as_ref());
+ match redirection_params {
+ Some(param) if !param.peek().is_empty() => true,
+ Some(_) | None => false,
+ }
+ }
+ }
+ }
+ /// Check if post-authentication flow is required
+ fn is_post_authentication_flow_required(&self, current_flow: api::CurrentFlowInfo<'_>) -> bool {
+ match current_flow {
+ api::CurrentFlowInfo::Authorize { .. } => {
+ // during authorize flow, there is no post_authentication call needed
+ false
+ }
+ api::CurrentFlowInfo::CompleteAuthorize { request_data } => {
+ // TODO: add logic before deciding the pre processing flow Authenticate or PostAuthenticate
+ let redirection_params = request_data
+ .redirect_response
+ .as_ref()
+ .and_then(|redirect_response| redirect_response.params.as_ref());
+ match redirection_params {
+ Some(param) if !param.peek().is_empty() => false,
+ Some(_) | None => true,
+ }
+ }
+ }
+ }
}
impl Cybersource {
diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs
index eb9bc4dacc..de1af03444 100644
--- a/crates/hyperswitch_interfaces/src/api.rs
+++ b/crates/hyperswitch_interfaces/src/api.rs
@@ -417,9 +417,9 @@ pub enum AlternateFlow {
/// Or PostAuthenticate flow must be made before CompleteAuthorize flow for cybersource.
#[derive(Debug, Clone, Copy)]
pub enum PreProcessingFlowName {
- /// Authentication flow must be made before the actual flow
+ /// Authentication flow
Authenticate,
- /// Post-authentication flow must be made before the actual flow
+ /// Post-authentication flow
PostAuthenticate,
}
@@ -434,6 +434,18 @@ pub struct PreProcessingFlowResponse<'a> {
/// The trait that provides specifications about the connector
pub trait ConnectorSpecifications {
+ /// Check if pre-authentication flow is required
+ fn is_pre_authentication_flow_required(&self, _current_flow: CurrentFlowInfo<'_>) -> bool {
+ false
+ }
+ /// Check if authentication flow is required
+ fn is_authentication_flow_required(&self, _current_flow: CurrentFlowInfo<'_>) -> bool {
+ false
+ }
+ /// Check if post-authentication flow is required
+ fn is_post_authentication_flow_required(&self, _current_flow: CurrentFlowInfo<'_>) -> bool {
+ false
+ }
/// Preprocessing flow name if any, that must be made before the current flow.
fn get_preprocessing_flow_if_needed(
&self,
@@ -441,17 +453,6 @@ pub trait ConnectorSpecifications {
) -> Option<PreProcessingFlowName> {
None
}
- /// Based on the current flow and preprocessing_flow_response, decide if the main flow must be called or not
- ///
- /// By default, always continue with the main flow after the preprocessing flow.
- fn decide_should_continue_after_preprocessing(
- &self,
- _current_flow: CurrentFlowInfo<'_>,
- _pre_processing_flow_name: PreProcessingFlowName,
- _preprocessing_flow_response: PreProcessingFlowResponse<'_>,
- ) -> bool {
- true
- }
/// If Some is returned, the returned api flow must be made instead of the current flow.
fn get_alternate_flow_if_needed(
&self,
diff --git a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
index f3589037a3..1365ad2ea5 100644
--- a/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
+++ b/crates/hyperswitch_interfaces/src/connector_integration_interface.rs
@@ -532,23 +532,22 @@ impl ConnectorValidation for ConnectorEnum {
}
impl ConnectorSpecifications for ConnectorEnum {
- fn decide_should_continue_after_preprocessing(
- &self,
- current_flow: api::CurrentFlowInfo<'_>,
- pre_processing_flow_name: api::PreProcessingFlowName,
- preprocessing_flow_response: api::PreProcessingFlowResponse<'_>,
- ) -> bool {
+ fn is_pre_authentication_flow_required(&self, current_flow: api::CurrentFlowInfo<'_>) -> bool {
match self {
- Self::Old(connector) => connector.decide_should_continue_after_preprocessing(
- current_flow,
- pre_processing_flow_name,
- preprocessing_flow_response,
- ),
- Self::New(connector) => connector.decide_should_continue_after_preprocessing(
- current_flow,
- pre_processing_flow_name,
- preprocessing_flow_response,
- ),
+ Self::Old(connector) => connector.is_pre_authentication_flow_required(current_flow),
+ Self::New(connector) => connector.is_pre_authentication_flow_required(current_flow),
+ }
+ }
+ fn is_authentication_flow_required(&self, current_flow: api::CurrentFlowInfo<'_>) -> bool {
+ match self {
+ Self::Old(connector) => connector.is_authentication_flow_required(current_flow),
+ Self::New(connector) => connector.is_authentication_flow_required(current_flow),
+ }
+ }
+ fn is_post_authentication_flow_required(&self, current_flow: api::CurrentFlowInfo<'_>) -> bool {
+ match self {
+ Self::Old(connector) => connector.is_post_authentication_flow_required(current_flow),
+ Self::New(connector) => connector.is_post_authentication_flow_required(current_flow),
}
}
fn get_preprocessing_flow_if_needed(
diff --git a/crates/router/src/configs/secrets_transformers.rs b/crates/router/src/configs/secrets_transformers.rs
index a6522c76b6..c612acb28d 100644
--- a/crates/router/src/configs/secrets_transformers.rs
+++ b/crates/router/src/configs/secrets_transformers.rs
@@ -579,6 +579,7 @@ pub(crate) async fn fetch_raw_secrets(
theme: conf.theme,
platform: conf.platform,
l2_l3_data_config: conf.l2_l3_data_config,
+ preprocessing_flow_config: conf.preprocessing_flow_config.clone(),
authentication_providers: conf.authentication_providers,
open_router: conf.open_router,
#[cfg(feature = "v2")]
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index 6fca1eb9c4..5aaa08e8c6 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -169,6 +169,7 @@ pub struct Settings<S: SecretState> {
pub revenue_recovery: revenue_recovery::RevenueRecoverySettings,
pub clone_connector_allowlist: Option<CloneConnectorAllowlistConfig>,
pub merchant_id_auth: MerchantIdAuthSettings,
+ pub preprocessing_flow_config: Option<PreProcessingFlowConfig>,
pub internal_merchant_id_profile_id_auth: InternalMerchantIdProfileIdAuthSettings,
#[serde(default)]
pub infra_values: Option<HashMap<String, String>>,
@@ -181,6 +182,12 @@ pub struct Settings<S: SecretState> {
pub comparison_service: Option<ComparisonServiceConfig>,
}
+#[derive(Debug, Deserialize, Clone, Default)]
+pub struct PreProcessingFlowConfig {
+ #[serde(deserialize_with = "deserialize_hashset")]
+ pub authentication_bloated_connectors: HashSet<enums::Connector>,
+}
+
#[derive(Debug, Deserialize, Clone, Default)]
pub struct DebitRoutingConfig {
#[serde(deserialize_with = "deserialize_hashmap")]
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index ee97116722..7ba6da9274 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -4142,7 +4142,6 @@ where
)
.await?;
- #[cfg(feature = "v1")]
if let Some(connector_customer_id) = {
core_utils::get_connector_customer_id(
&state.conf,
@@ -4176,15 +4175,52 @@ where
should_continue_further,
);
- (router_data, should_continue_further) = complete_preprocessing_steps_if_required(
- state,
- &connector,
- payment_data,
- router_data,
- operation,
- should_continue_further,
- )
- .await?;
+ (router_data, should_continue_further) = if state
+ .conf
+ .preprocessing_flow_config
+ .as_ref()
+ .is_some_and(|config| {
+ config
+ .authentication_bloated_connectors
+ .contains(&connector.connector_name)
+ }) {
+ logger::info!(
+ "Using granular authentication steps for connector: {}",
+ connector.connector_name
+ );
+ let (router_data, should_continue_further) = if should_continue_further {
+ router_data
+ .pre_authentication_step(state, &connector, &context)
+ .await?
+ } else {
+ (router_data, false)
+ };
+ let (router_data, should_continue_further) = if should_continue_further {
+ router_data
+ .authentication_step(state, &connector, &context)
+ .await?
+ } else {
+ (router_data, false)
+ };
+ let (router_data, should_continue_further) = if should_continue_further {
+ router_data
+ .post_authentication_step(state, &connector, &context)
+ .await?
+ } else {
+ (router_data, false)
+ };
+ (router_data, should_continue_further)
+ } else {
+ complete_preprocessing_steps_if_required(
+ state,
+ &connector,
+ payment_data,
+ router_data,
+ operation,
+ should_continue_further,
+ )
+ .await?
+ };
if let Ok(router_types::PaymentsResponseData::PreProcessingResponse {
session_token: Some(session_token),
diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs
index 45142d45c7..982090dc34 100644
--- a/crates/router/src/core/payments/flows.rs
+++ b/crates/router/src/core/payments/flows.rs
@@ -27,7 +27,6 @@ use hyperswitch_domain_models::router_flow_types::{
use hyperswitch_domain_models::{
payments as domain_payments, router_request_types::PaymentsCaptureData,
};
-use hyperswitch_interfaces::api as api_interfaces;
use crate::{
core::{
@@ -146,10 +145,49 @@ pub trait Feature<F, T> {
})
}
- async fn preprocessing_steps<'a>(
+ async fn pre_authentication_step<'a>(
+ self,
+ _state: &SessionState,
+ _connector: &api::ConnectorData,
+ _gateway_context: &gateway_context::RouterGatewayContext,
+ ) -> RouterResult<(Self, bool)>
+ where
+ F: Clone,
+ Self: Sized,
+ {
+ Ok((self, true))
+ }
+
+ async fn authentication_step<'a>(
+ self,
+ _state: &SessionState,
+ _connector: &api::ConnectorData,
+ _gateway_context: &gateway_context::RouterGatewayContext,
+ ) -> RouterResult<(Self, bool)>
+ where
+ F: Clone,
+ Self: Sized,
+ {
+ Ok((self, true))
+ }
+
+ async fn post_authentication_step<'a>(
self,
_state: &SessionState,
_connector: &api::ConnectorData,
+ _gateway_context: &gateway_context::RouterGatewayContext,
+ ) -> RouterResult<(Self, bool)>
+ where
+ F: Clone,
+ Self: Sized,
+ {
+ Ok((self, true))
+ }
+
+ async fn preprocessing_steps<'a>(
+ self,
+ _state: &SessionState,
+ _connector_data: &api::ConnectorData,
) -> RouterResult<Self>
where
F: Clone,
@@ -217,10 +255,6 @@ pub trait Feature<F, T> {
) {
}
- fn get_current_flow_info(&self) -> Option<api_interfaces::CurrentFlowInfo<'_>> {
- None
- }
-
async fn call_preprocessing_through_unified_connector_service<'a>(
self,
_state: &SessionState,
diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs
index 59f4ee91d0..162735e6fb 100644
--- a/crates/router/src/core/payments/flows/authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/authorize_flow.rs
@@ -186,12 +186,6 @@ impl
#[async_trait]
impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAuthorizeRouterData {
- fn get_current_flow_info(&self) -> Option<api_interface::CurrentFlowInfo<'_>> {
- Some(api_interface::CurrentFlowInfo::Authorize {
- auth_type: &self.auth_type,
- request_data: &self.request,
- })
- }
async fn decide_flows<'a>(
mut self,
state: &SessionState,
@@ -316,6 +310,61 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
.await
}
+ async fn pre_authentication_step<'a>(
+ self,
+ state: &SessionState,
+ connector: &api::ConnectorData,
+ gateway_context: &gateway_context::RouterGatewayContext,
+ ) -> RouterResult<(Self, bool)>
+ where
+ Self: Sized,
+ {
+ if connector.connector.is_pre_authentication_flow_required(
+ api_interface::CurrentFlowInfo::Authorize {
+ auth_type: &self.auth_type,
+ request_data: &self.request,
+ },
+ ) {
+ logger::info!(
+ "Pre-authentication flow is required for connector: {}",
+ connector.connector_name
+ );
+ let authorize_request_data = self.request.clone();
+ let pre_authenticate_request_data =
+ types::PaymentsPreAuthenticateData::try_from(self.request.to_owned())?;
+ let pre_authenticate_response_data: Result<
+ types::PaymentsResponseData,
+ types::ErrorResponse,
+ > = Err(types::ErrorResponse::default());
+ let pre_authenticate_router_data =
+ helpers::router_data_type_conversion::<_, api::PreAuthenticate, _, _, _, _>(
+ self.clone(),
+ pre_authenticate_request_data,
+ pre_authenticate_response_data,
+ );
+ let pre_authenticate_router_data = Box::pin(handle_pre_authenticate_connector_call(
+ state,
+ pre_authenticate_router_data,
+ connector,
+ gateway_context,
+ ))
+ .await?;
+ // Convert back to CompleteAuthorize router data while preserving preprocessing response data
+ let pre_authenticate_response = pre_authenticate_router_data.response.clone();
+ let authorize_router_data =
+ helpers::router_data_type_conversion::<_, api::Authorize, _, _, _, _>(
+ pre_authenticate_router_data,
+ authorize_request_data,
+ pre_authenticate_response,
+ );
+ // After doing pre_authentication, step, we should not proceed with authorize call.
+ // control must be returned to SDK.
+ Ok((authorize_router_data, false))
+ } else {
+ Ok((self, true))
+ }
+ }
+
async fn preprocessing_steps<'a>(
self,
state: &SessionState,
@@ -1229,6 +1278,42 @@ async fn call_unified_connector_service_pre_authenticate(
Ok(())
}
+pub async fn handle_pre_authenticate_connector_call(
+ state: &SessionState,
+ router_data: types::RouterData<
+ api::PreAuthenticate,
+ types::PaymentsPreAuthenticateData,
+ types::PaymentsResponseData,
+ >,
+ connector: &api::ConnectorData,
+ _gateway_context: &gateway_context::RouterGatewayContext,
+) -> RouterResult<
+ types::RouterData<
+ api::PreAuthenticate,
+ types::PaymentsPreAuthenticateData,
+ types::PaymentsResponseData,
+ >,
+> {
+ let connector_integration: services::BoxedPaymentConnectorIntegrationInterface<
+ api::PreAuthenticate,
+ types::PaymentsPreAuthenticateData,
+ types::PaymentsResponseData,
+ > = connector.connector.get_connector_integration();
+ // TODO: Handle gateway_context later
+ let resp = services::execute_connector_processing_step(
+ state,
+ connector_integration,
+ &router_data,
+ payments::CallConnectorAction::Trigger,
+ None,
+ None,
+ // gateway_context.clone(),
+ )
+ .await
+ .to_payment_failed_response()?;
+ Ok(resp)
+}
+
#[allow(clippy::too_many_arguments)]
async fn call_unified_connector_service_repeat_payment(
router_data: &mut types::RouterData<
diff --git a/crates/router/src/core/payments/flows/complete_authorize_flow.rs b/crates/router/src/core/payments/flows/complete_authorize_flow.rs
index eb33ebecd0..678f8b6616 100644
--- a/crates/router/src/core/payments/flows/complete_authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/complete_authorize_flow.rs
@@ -236,6 +236,149 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
complete_authorize_preprocessing_steps(state, &self, true, connector).await
}
+ async fn authentication_step<'a>(
+ self,
+ state: &SessionState,
+ connector: &api::ConnectorData,
+ gateway_context: &gateway_context::RouterGatewayContext,
+ ) -> RouterResult<(Self, bool)>
+ where
+ Self: Sized,
+ {
+ if connector.connector.is_authentication_flow_required(
+ api_interface::CurrentFlowInfo::CompleteAuthorize {
+ request_data: &self.request,
+ },
+ ) {
+ let router_data = self;
+ logger::info!(
+ "Authentication flow is required for connector: {}",
+ connector.connector_name
+ );
+ let mut complete_authorize_request_data = router_data.request.clone();
+ let authenticate_request_data =
+ types::PaymentsAuthenticateData::try_from(router_data.request.to_owned())?;
+ let authenticate_response_data: Result<
+ types::PaymentsResponseData,
+ types::ErrorResponse,
+ > = Err(types::ErrorResponse::default());
+ let authenticate_router_data =
+ helpers::router_data_type_conversion::<_, api::Authenticate, _, _, _, _>(
+ router_data.clone(),
+ authenticate_request_data,
+ authenticate_response_data,
+ );
+
+ // Call UCS for Authenticate flow and store authentication result for next step
+ let authenticate_router_data = Box::pin(handle_authenticate_connector_call(
+ state,
+ authenticate_router_data,
+ connector,
+ gateway_context,
+ ))
+ .await?;
+
+ // Convert back to CompleteAuthorize router data while preserving preprocessing response data
+ let authenticate_response = authenticate_router_data.response.clone();
+ if let Ok(types::PaymentsResponseData::TransactionResponse {
+ connector_metadata, ..
+ }) = &authenticate_router_data.response
+ {
+ connector_metadata.clone_into(&mut complete_authorize_request_data.connector_meta);
+ };
+ let complete_authorize_router_data =
+ helpers::router_data_type_conversion::<_, api::CompleteAuthorize, _, _, _, _>(
+ authenticate_router_data,
+ complete_authorize_request_data,
+ authenticate_response,
+ );
+ // check if redirection is not present in the response and attempt status is not AuthenticationFailed
+ // if condition does not satisfy, then we don't need to proceed further
+ let should_continue = (matches!(
+ complete_authorize_router_data.response,
+ Ok(types::PaymentsResponseData::TransactionResponse {
+ ref redirection_data,
+ ..
+ }) if redirection_data.is_none()
+ ) && complete_authorize_router_data.status
+ != common_enums::AttemptStatus::AuthenticationFailed);
+ Ok((complete_authorize_router_data, should_continue))
+ } else {
+ Ok((self, true))
+ }
+ }
+
+ async fn post_authentication_step<'a>(
+ self,
+ state: &SessionState,
+ connector: &api::ConnectorData,
+ gateway_context: &gateway_context::RouterGatewayContext,
+ ) -> RouterResult<(Self, bool)>
+ where
+ Self: Sized,
+ {
+ if connector.connector.is_post_authentication_flow_required(
+ api_interface::CurrentFlowInfo::CompleteAuthorize {
+ request_data: &self.request,
+ },
+ ) {
+ let router_data = self;
+ logger::info!(
+ "Post-authentication flow is required for connector: {}",
+ connector.connector_name
+ );
+ // Convert CompleteAuthorize to PostAuthenticate for UCS call
+ let mut complete_authorize_request_data = router_data.request.clone();
+ let post_authenticate_request_data =
+ types::PaymentsPostAuthenticateData::try_from(router_data.request.to_owned())?;
+ let post_authenticate_response_data: Result<
+ types::PaymentsResponseData,
+ types::ErrorResponse,
+ > = Err(types::ErrorResponse::default());
+ let post_authenticate_router_data =
+ helpers::router_data_type_conversion::<_, api::PostAuthenticate, _, _, _, _>(
+ router_data.clone(),
+ post_authenticate_request_data,
+ post_authenticate_response_data,
+ );
+
+ let post_authenticate_router_data = Box::pin(handle_post_authenticate_connector_call(
+ state,
+ post_authenticate_router_data,
+ connector,
+ gateway_context,
+ ))
+ .await?;
+ // Convert back to CompleteAuthorize router data while preserving preprocessing response data
+ let post_authenticate_response = post_authenticate_router_data.response.clone();
+ if let Ok(types::PaymentsResponseData::TransactionResponse {
+ connector_metadata, ..
+ }) = &post_authenticate_router_data.response
+ {
+ connector_metadata.clone_into(&mut complete_authorize_request_data.connector_meta);
+ };
+ let complete_authorize_router_data =
+ helpers::router_data_type_conversion::<_, api::CompleteAuthorize, _, _, _, _>(
+ post_authenticate_router_data,
+ complete_authorize_request_data,
+ post_authenticate_response,
+ );
+ // check if redirection is not present in the response and attempt status is not AuthenticationFailed
+ // if condition does not satisfy, then we don't need to proceed further
+ let should_continue = (matches!(
+ complete_authorize_router_data.response,
+ Ok(types::PaymentsResponseData::TransactionResponse {
+ ref redirection_data,
+ ..
+ }) if redirection_data.is_none()
+ ) && complete_authorize_router_data.status
+ != common_enums::AttemptStatus::AuthenticationFailed);
+ Ok((complete_authorize_router_data, should_continue))
+ } else {
+ Ok((self, true))
+ }
+ }
+
async fn call_preprocessing_through_unified_connector_service<'a>(
self,
state: &SessionState,
@@ -271,20 +414,16 @@ impl Feature<api::CompleteAuthorize, types::CompleteAuthorizeData>
preprocessing_flow,
))
.await?;
- let pre_processing_flow_response = api_interface::PreProcessingFlowResponse {
- response: &updated_router_data.response,
- attempt_status: updated_router_data.status,
- };
- let current_flow = api_interface::CurrentFlowInfo::CompleteAuthorize {
- request_data: &updated_router_data.request,
- };
- let should_continue = connector_data
- .connector
- .decide_should_continue_after_preprocessing(
- current_flow,
- preprocessing_flow,
- pre_processing_flow_response,
- );
+ // check if redirection is not present in the response and attempt status is not AuthenticationFailed
+ // if condition does not satisfy, then we don't need to proceed further
+ let should_continue = (matches!(
+ updated_router_data.response,
+ Ok(types::PaymentsResponseData::TransactionResponse {
+ ref redirection_data,
+ ..
+ }) if redirection_data.is_none()
+ ) && updated_router_data.status
+ != common_enums::AttemptStatus::AuthenticationFailed);
Ok((updated_router_data, should_continue))
}
None => Ok((self, true)),
@@ -435,6 +574,79 @@ async fn handle_preprocessing_through_unified_connector_service(
}
}
+pub async fn handle_authenticate_connector_call(
+ state: &SessionState,
+ router_data: types::RouterData<
+ api::Authenticate,
+ types::PaymentsAuthenticateData,
+ types::PaymentsResponseData,
+ >,
+ connector: &api::ConnectorData,
+ _gateway_context: &gateway_context::RouterGatewayContext,
+) -> RouterResult<
+ types::RouterData<
+ api::Authenticate,
+ types::PaymentsAuthenticateData,
+ types::PaymentsResponseData,
+ >,
+> {
+ let connector_integration: services::BoxedPaymentConnectorIntegrationInterface<
+ api::Authenticate,
+ types::PaymentsAuthenticateData,
+ types::PaymentsResponseData,
+ > = connector.connector.get_connector_integration();
+
+ // TODO: Handle gateway_context later
+ let resp = services::execute_connector_processing_step(
+ state,
+ connector_integration,
+ &router_data,
+ payments::CallConnectorAction::Trigger,
+ None,
+ None,
+ // gateway_context.clone(),
+ )
+ .await
+ .to_payment_failed_response()?;
+ Ok(resp)
+}
+
+pub async fn handle_post_authenticate_connector_call(
+ state: &SessionState,
+ router_data: types::RouterData<
+ api::PostAuthenticate,
+ types::PaymentsPostAuthenticateData,
+ types::PaymentsResponseData,
+ >,
+ connector: &api::ConnectorData,
+ _gateway_context: &gateway_context::RouterGatewayContext,
+) -> RouterResult<
+ types::RouterData<
+ api::PostAuthenticate,
+ types::PaymentsPostAuthenticateData,
+ types::PaymentsResponseData,
+ >,
+> {
+ let connector_integration: services::BoxedPaymentConnectorIntegrationInterface<
+ api::PostAuthenticate,
+ types::PaymentsPostAuthenticateData,
+ types::PaymentsResponseData,
+ > = connector.connector.get_connector_integration();
+ // TODO: Handle gateway_context later
+ let resp = services::execute_connector_processing_step(
+ state,
+ connector_integration,
+ &router_data,
+ payments::CallConnectorAction::Trigger,
+ None,
+ None,
+ // gateway_context.clone(),
+ )
+ .await
+ .to_payment_failed_response()?;
+ Ok(resp)
+}
+
fn transform_redirection_response_for_authenticate_flow(
connector: connector_enums::Connector,
response_data: router_response_types::RedirectForm,