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

fix(router): skip external three_ds flow for recurring payments (#5730)

Sai Harsha Vardhan64836ba40518
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 04bcae4c56..0aa917166e 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -969,7 +969,7 @@ pub struct VerifyRequest {
pub merchant_connector_details: Option<admin::MerchantConnectorDetailsWrap>,
}
-#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, Eq, PartialEq, Copy)]
#[serde(rename_all = "snake_case")]
pub enum MandateTransactionType {
NewMandateTransaction,
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 586d1989de..1af097114f 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -264,6 +264,7 @@ where
&connector_details,
&business_profile,
&key_store,
+ mandate_type,
)
.await?;
if should_continue_transaction {
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 181e2232d9..d6c2a3971c 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -5016,6 +5016,7 @@ pub async fn get_payment_external_authentication_flow_during_confirm<F: Clone>(
business_profile: &domain::BusinessProfile,
payment_data: &mut PaymentData<F>,
connector_call_type: &api::ConnectorCallType,
+ mandate_type: Option<api_models::payments::MandateTransactionType>,
) -> RouterResult<Option<PaymentExternalAuthenticationFlow>> {
let authentication_id = payment_data.payment_attempt.authentication_id.clone();
let is_authentication_type_3ds = payment_data.payment_attempt.authentication_type
@@ -5050,7 +5051,11 @@ pub async fn get_payment_external_authentication_flow_during_confirm<F: Clone>(
authentication_id.map(|authentication_id| {
PaymentExternalAuthenticationFlow::PostAuthenticationFlow { authentication_id }
})
- } else if separate_authentication_requested && is_authentication_type_3ds {
+ } else if separate_authentication_requested
+ && is_authentication_type_3ds
+ && mandate_type
+ != Some(api_models::payments::MandateTransactionType::RecurringMandateTransaction)
+ {
if let Some((connector_data, card_number)) =
connector_supports_separate_authn.zip(card_number)
{
diff --git a/crates/router/src/core/payments/operations.rs b/crates/router/src/core/payments/operations.rs
index 84da4e260d..8efa124b49 100644
--- a/crates/router/src/core/payments/operations.rs
+++ b/crates/router/src/core/payments/operations.rs
@@ -166,6 +166,7 @@ pub trait Domain<F: Clone, R>: Send + Sync {
Ok(())
}
+ #[allow(clippy::too_many_arguments)]
async fn call_external_three_ds_authentication_if_eligible<'a>(
&'a self,
_state: &SessionState,
@@ -174,6 +175,7 @@ pub trait Domain<F: Clone, R>: Send + Sync {
_connector_call_type: &ConnectorCallType,
_merchant_account: &domain::BusinessProfile,
_key_store: &domain::MerchantKeyStore,
+ _mandate_type: Option<api_models::payments::MandateTransactionType>,
) -> CustomResult<(), errors::ApiErrorResponse> {
Ok(())
}
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index c4b93a4b30..b0a7e09142 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -529,7 +529,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
})?;
let m_state = state.clone();
- let m_mandate_type = mandate_type.clone();
+ let m_mandate_type = mandate_type;
let m_merchant_account = merchant_account.clone();
let m_request = request.clone();
let m_key_store = key_store.clone();
@@ -853,6 +853,7 @@ impl<F: Clone + Send> Domain<F, api::PaymentsRequest> for PaymentConfirm {
populate_surcharge_details(state, payment_data).await
}
+ #[allow(clippy::too_many_arguments)]
async fn call_external_three_ds_authentication_if_eligible<'a>(
&'a self,
state: &SessionState,
@@ -861,6 +862,7 @@ impl<F: Clone + Send> Domain<F, api::PaymentsRequest> for PaymentConfirm {
connector_call_type: &ConnectorCallType,
business_profile: &domain::BusinessProfile,
key_store: &domain::MerchantKeyStore,
+ mandate_type: Option<api_models::payments::MandateTransactionType>,
) -> CustomResult<(), errors::ApiErrorResponse> {
let external_authentication_flow =
helpers::get_payment_external_authentication_flow_during_confirm(
@@ -869,6 +871,7 @@ impl<F: Clone + Send> Domain<F, api::PaymentsRequest> for PaymentConfirm {
business_profile,
payment_data,
connector_call_type,
+ mandate_type,
)
.await?;
payment_data.authentication = match external_authentication_flow {
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index 0ba859f3e1..753cb4f1b7 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -170,7 +170,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
} = helpers::get_token_pm_type_mandate_details(
state,
request,
- mandate_type.clone(),
+ mandate_type,
merchant_account,
merchant_key_store,
None,