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(core): add support for consuming eci for AuthNResponse in Authentication flow (#8225)

Debarati Ghatak33cd60e64288
diff --git a/crates/diesel_models/src/authentication.rs b/crates/diesel_models/src/authentication.rs
index 7bfea7e2b6..0c7ac7338e 100644
--- a/crates/diesel_models/src/authentication.rs
+++ b/crates/diesel_models/src/authentication.rs
@@ -139,6 +139,7 @@ pub enum AuthenticationUpdate {
connector_metadata: Option<serde_json::Value>,
authentication_status: common_enums::AuthenticationStatus,
ds_trans_id: Option<String>,
+ eci: Option<String>,
},
PostAuthenticationUpdate {
trans_status: common_enums::TransactionStatus,
@@ -373,6 +374,7 @@ impl From<AuthenticationUpdate> for AuthenticationUpdateInternal {
connector_metadata,
authentication_status,
ds_trans_id,
+ eci,
} => Self {
trans_status: Some(trans_status),
authentication_type: Some(authentication_type),
@@ -384,6 +386,7 @@ impl From<AuthenticationUpdate> for AuthenticationUpdateInternal {
connector_metadata,
authentication_status: Some(authentication_status),
ds_trans_id,
+ eci,
..Default::default()
},
AuthenticationUpdate::PostAuthenticationUpdate {
diff --git a/crates/hyperswitch_connectors/src/connectors/archipel/transformers.rs b/crates/hyperswitch_connectors/src/connectors/archipel/transformers.rs
index aaa7f92d1f..2f5e58db16 100644
--- a/crates/hyperswitch_connectors/src/connectors/archipel/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/archipel/transformers.rs
@@ -3,7 +3,7 @@ use common_enums::{
self, AttemptStatus, AuthorizationStatus, CaptureMethod, Currency, FutureUsage,
PaymentMethodStatus, RefundStatus,
};
-use common_utils::{ext_traits::Encode, pii, types::MinorUnit};
+use common_utils::{date_time, ext_traits::Encode, pii, types::MinorUnit};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
address::AddressDetails,
@@ -163,23 +163,24 @@ pub struct Archipel3DS {
three_ds_version: Option<common_utils::types::SemanticVersion>,
authentication_value: Secret<String>,
authentication_method: Option<Secret<String>>,
- eci: Option<Secret<String>>,
+ eci: Option<String>,
}
impl From<AuthenticationData> for Archipel3DS {
fn from(three_ds_data: AuthenticationData) -> Self {
+ let now = date_time::date_as_yyyymmddthhmmssmmmz().ok();
Self {
acs_trans_id: None,
ds_trans_id: three_ds_data.ds_trans_id.map(Secret::new),
three_ds_requestor_name: None,
- three_ds_auth_date: None,
+ three_ds_auth_date: now,
three_ds_auth_amt: None,
three_ds_auth_status: None,
three_ds_max_supported_version: THREE_DS_MAX_SUPPORTED_VERSION.into(),
three_ds_version: three_ds_data.message_version,
authentication_value: three_ds_data.cavv,
authentication_method: None,
- eci: three_ds_data.eci.map(Secret::new),
+ eci: three_ds_data.eci,
}
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/gpayments/transformers.rs b/crates/hyperswitch_connectors/src/connectors/gpayments/transformers.rs
index e959218745..b35679bd99 100644
--- a/crates/hyperswitch_connectors/src/connectors/gpayments/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/gpayments/transformers.rs
@@ -294,6 +294,7 @@ impl
authentication_value: response_auth.authentication_value,
ds_trans_id: Some(response_auth.ds_trans_id),
connector_metadata: None,
+ eci: None,
});
Ok(Self {
response,
diff --git a/crates/hyperswitch_connectors/src/connectors/netcetera/transformers.rs b/crates/hyperswitch_connectors/src/connectors/netcetera/transformers.rs
index c0574c1c4f..37238722b7 100644
--- a/crates/hyperswitch_connectors/src/connectors/netcetera/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/netcetera/transformers.rs
@@ -163,6 +163,7 @@ impl
trans_status: response.trans_status,
connector_metadata: None,
ds_trans_id: response.authentication_response.ds_trans_id,
+ eci: response.eci,
})
}
NetceteraAuthenticationResponse::Error(error_response) => Err(ErrorResponse {
diff --git a/crates/hyperswitch_connectors/src/connectors/threedsecureio/transformers.rs b/crates/hyperswitch_connectors/src/connectors/threedsecureio/transformers.rs
index d74d667b08..82387266ed 100644
--- a/crates/hyperswitch_connectors/src/connectors/threedsecureio/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/threedsecureio/transformers.rs
@@ -183,6 +183,7 @@ impl
authentication_value: response.authentication_value,
connector_metadata: None,
ds_trans_id: Some(response.ds_trans_id),
+ eci: None,
})
}
ThreedsecureioAuthenticationResponse::Error(err_response) => match *err_response {
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 5c2435881e..6939a18595 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
@@ -110,6 +110,7 @@ pub struct AuthenticationDetails {
pub trans_status: common_enums::TransactionStatus,
pub connector_metadata: Option<serde_json::Value>,
pub ds_trans_id: Option<String>,
+ pub eci: Option<String>,
}
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone)]
diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs
index 920714044a..bdf04e0328 100644
--- a/crates/hyperswitch_domain_models/src/router_response_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_response_types.rs
@@ -542,6 +542,7 @@ pub enum AuthenticationResponseData {
trans_status: common_enums::TransactionStatus,
connector_metadata: Option<serde_json::Value>,
ds_trans_id: Option<String>,
+ eci: Option<String>,
},
PostAuthNResponse {
trans_status: common_enums::TransactionStatus,
diff --git a/crates/router/src/core/authentication/utils.rs b/crates/router/src/core/authentication/utils.rs
index f3554d6d70..0d9045ba38 100644
--- a/crates/router/src/core/authentication/utils.rs
+++ b/crates/router/src/core/authentication/utils.rs
@@ -95,6 +95,7 @@ pub async fn update_trackers<F: Clone, Req>(
trans_status,
connector_metadata,
ds_trans_id,
+ eci,
} => {
authentication_value
.async_map(|auth_val| {
@@ -123,6 +124,7 @@ pub async fn update_trackers<F: Clone, Req>(
authentication_status,
connector_metadata,
ds_trans_id,
+ eci,
}
}
AuthenticationResponseData::PostAuthNResponse {
diff --git a/crates/router/src/core/unified_authentication_service/utils.rs b/crates/router/src/core/unified_authentication_service/utils.rs
index bab5d41235..371846a51f 100644
--- a/crates/router/src/core/unified_authentication_service/utils.rs
+++ b/crates/router/src/core/unified_authentication_service/utils.rs
@@ -217,6 +217,7 @@ pub async fn external_authentication_update_trackers<F: Clone, Req>(
authentication_status,
connector_metadata: authentication_details.connector_metadata,
ds_trans_id: authentication_details.ds_trans_id,
+ eci: authentication_details.eci,
},
)
}