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(authentication): add force_3ds and exemption support for juspayThreeds Server (#10181)

Sahkal Poddare7a2c0530133
diff --git a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs
index f2d6e5f73b..2ee020480e 100644
--- a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs
+++ b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs
@@ -37,7 +37,7 @@ use hyperswitch_interfaces::{
ConnectorValidation,
},
configs::Connectors,
- consts::NO_ERROR_MESSAGE,
+ consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE},
errors,
events::connector_api_logs::ConnectorEvent,
types::{self, Response},
@@ -144,7 +144,7 @@ impl ConnectorCommon for UnifiedAuthenticationService {
Ok(ErrorResponse {
status_code: res.status_code,
- code: response.error.clone(),
+ code: NO_ERROR_CODE.to_owned(),
message: NO_ERROR_MESSAGE.to_owned(),
reason: Some(response.error),
attempt_status: None,
diff --git a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs
index a3f899eaf0..ce6925eeeb 100644
--- a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service/transformers.rs
@@ -143,6 +143,8 @@ pub enum MessageCategory {
pub struct ThreeDSData {
pub preferred_protocol_version: common_utils::types::SemanticVersion,
pub threeds_method_comp_ind: api_models::payments::ThreeDsCompletionIndicator,
+ pub force_3ds_challenge: Option<bool>,
+ pub psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>,
}
#[derive(Default, Clone, Debug, Serialize, Deserialize, PartialEq)]
@@ -922,6 +924,16 @@ impl TryFrom<&UnifiedAuthenticationServiceRouterData<&UasAuthenticationRouterDat
.message_version
.clone(),
threeds_method_comp_ind: item.router_data.request.threeds_method_comp_ind.clone(),
+ force_3ds_challenge: item
+ .router_data
+ .request
+ .transaction_details
+ .force_3ds_challenge,
+ psd2_sca_exemption_type: item
+ .router_data
+ .request
+ .transaction_details
+ .psd2_sca_exemption_type,
};
let device_details = DeviceDetails {
diff --git a/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs b/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs
index 88eb637762..fa71d3379d 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types/unified_authentication_service.rs
@@ -86,6 +86,8 @@ pub struct TransactionDetails {
pub currency: Option<common_enums::Currency>,
pub device_channel: Option<DeviceChannel>,
pub message_category: Option<super::authentication::MessageCategory>,
+ pub force_3ds_challenge: Option<bool>,
+ pub psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>,
}
#[derive(Clone, Debug)]
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 5e43d61611..a45720e28b 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -10489,6 +10489,8 @@ pub async fn payment_external_authentication<F: Clone + Sync>(
&merchant_connector_account,
&authentication_connector,
Some(payment_intent.payment_id),
+ authentication.force_3ds_challenge,
+ authentication.psd2_sca_exemption_type,
)
.await?;
let authentication = external_authentication_update_trackers(
diff --git a/crates/router/src/core/unified_authentication_service.rs b/crates/router/src/core/unified_authentication_service.rs
index 2a2b83a544..ce2d95c1d4 100644
--- a/crates/router/src/core/unified_authentication_service.rs
+++ b/crates/router/src/core/unified_authentication_service.rs
@@ -104,6 +104,8 @@ impl UnifiedAuthenticationService for ClickToPay {
currency,
device_channel: None,
message_category: None,
+ force_3ds_challenge: None,
+ psd2_sca_exemption_type: None,
};
let authentication_info = Some(AuthenticationInfo {
@@ -331,6 +333,8 @@ impl UnifiedAuthenticationService for ExternalAuthentication {
currency,
device_channel: None,
message_category: None,
+ force_3ds_challenge: None,
+ psd2_sca_exemption_type: None,
};
Ok(UasPreAuthenticationRequestData {
service_details: None,
@@ -408,6 +412,8 @@ impl UnifiedAuthenticationService for ExternalAuthentication {
threeds_method_comp_ind: payments::ThreeDsCompletionIndicator,
email: Option<common_utils::pii::Email>,
webhook_url: String,
+ force_3ds_challenge: Option<bool>,
+ psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>,
) -> RouterResult<UasAuthenticationRequestData> {
Ok(UasAuthenticationRequestData {
browser_details,
@@ -416,6 +422,8 @@ impl UnifiedAuthenticationService for ExternalAuthentication {
currency,
device_channel: Some(device_channel),
message_category: Some(message_category),
+ force_3ds_challenge,
+ psd2_sca_exemption_type,
},
pre_authentication_data: PreAuthenticationData {
threeds_server_transaction_id: authentication.threeds_server_transaction_id.ok_or(
@@ -460,6 +468,8 @@ impl UnifiedAuthenticationService for ExternalAuthentication {
merchant_connector_account: &MerchantConnectorAccountType,
connector_name: &str,
payment_id: Option<common_utils::id_type::PaymentId>,
+ force_3ds_challenge: Option<bool>,
+ psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>,
) -> RouterResult<UasAuthenticationRouterData> {
let authentication_data =
<Self as UnifiedAuthenticationService>::get_authentication_request_data(
@@ -474,6 +484,8 @@ impl UnifiedAuthenticationService for ExternalAuthentication {
threeds_method_comp_ind,
email,
webhook_url,
+ force_3ds_challenge,
+ psd2_sca_exemption_type,
)?;
let auth_router_data: UasAuthenticationRouterData = utils::construct_uas_router_data(
state,
@@ -1391,6 +1403,8 @@ pub async fn authentication_authenticate_core(
&three_ds_connector_account,
&authentication_connector.to_string(),
None,
+ authentication.force_3ds_challenge,
+ authentication.psd2_sca_exemption_type,
)
.await?;
@@ -1824,6 +1838,8 @@ pub async fn authentication_sync_core(
currency: authentication.currency,
device_channel: None,
message_category: None,
+ force_3ds_challenge: authentication.force_3ds_challenge,
+ psd2_sca_exemption_type: authentication.psd2_sca_exemption_type,
};
let authentication_info = Some(AuthenticationInfo {
diff --git a/crates/router/src/core/unified_authentication_service/types.rs b/crates/router/src/core/unified_authentication_service/types.rs
index 027bc41f56..69eac79069 100644
--- a/crates/router/src/core/unified_authentication_service/types.rs
+++ b/crates/router/src/core/unified_authentication_service/types.rs
@@ -91,6 +91,8 @@ pub trait UnifiedAuthenticationService {
_threeds_method_comp_ind: payments::ThreeDsCompletionIndicator,
_email: Option<common_utils::pii::Email>,
_webhook_url: String,
+ _force_3ds_challenge: Option<bool>,
+ _psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>,
) -> RouterResult<UasAuthenticationRequestData> {
Err(errors::ApiErrorResponse::NotImplemented {
message: NotImplementedMessage::Reason(
@@ -119,6 +121,8 @@ pub trait UnifiedAuthenticationService {
_merchant_connector_account: &MerchantConnectorAccountType,
_connector_name: &str,
_payment_id: Option<common_utils::id_type::PaymentId>,
+ _force_3ds_challenge: Option<bool>,
+ _psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>,
) -> RouterResult<hyperswitch_domain_models::types::UasAuthenticationRouterData> {
Err(errors::ApiErrorResponse::NotImplemented {
message: NotImplementedMessage::Reason("authentication".to_string()),