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(router): send message_version and directory_server_id in next_action block of three_ds_data for external 3ds flow (#4715)

Sai Harsha Vardhan13f6efc7e8c0
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 80be635da6..60952ee501 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -2963,6 +2963,10 @@ pub struct ThreeDsData {
pub three_ds_method_details: ThreeDsMethodData,
/// Poll config for a connector
pub poll_config: PollConfigResponse,
+ /// Message Version
+ pub message_version: Option<String>,
+ /// Directory Server ID
+ pub directory_server_id: Option<String>,
}
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, ToSchema)]
diff --git a/crates/diesel_models/src/authentication.rs b/crates/diesel_models/src/authentication.rs
index ce2f02d087..9b7c4c96ee 100644
--- a/crates/diesel_models/src/authentication.rs
+++ b/crates/diesel_models/src/authentication.rs
@@ -42,6 +42,7 @@ pub struct Authentication {
pub profile_id: String,
pub payment_id: Option<String>,
pub merchant_connector_id: String,
+ pub directory_server_id: Option<String>,
}
impl Authentication {
@@ -86,6 +87,7 @@ pub struct AuthenticationNew {
pub profile_id: String,
pub payment_id: Option<String>,
pub merchant_connector_id: String,
+ pub directory_server_id: Option<String>,
}
#[derive(Debug)]
@@ -101,6 +103,7 @@ pub enum AuthenticationUpdate {
authentication_status: common_enums::AuthenticationStatus,
acquirer_bin: Option<String>,
acquirer_merchant_id: Option<String>,
+ directory_server_id: Option<String>,
},
AuthenticationUpdate {
authentication_value: Option<String>,
@@ -159,6 +162,7 @@ pub struct AuthenticationUpdateInternal {
pub acs_reference_number: Option<String>,
pub acs_trans_id: Option<String>,
pub acs_signed_content: Option<String>,
+ pub directory_server_id: Option<String>,
}
impl Default for AuthenticationUpdateInternal {
@@ -189,6 +193,7 @@ impl Default for AuthenticationUpdateInternal {
acs_reference_number: Default::default(),
acs_trans_id: Default::default(),
acs_signed_content: Default::default(),
+ directory_server_id: Default::default(),
}
}
}
@@ -221,6 +226,7 @@ impl AuthenticationUpdateInternal {
acs_reference_number,
acs_trans_id,
acs_signed_content,
+ directory_server_id,
} = self;
Authentication {
connector_authentication_id: connector_authentication_id
@@ -252,6 +258,7 @@ impl AuthenticationUpdateInternal {
acs_reference_number: acs_reference_number.or(source.acs_reference_number),
acs_trans_id: acs_trans_id.or(source.acs_trans_id),
acs_signed_content: acs_signed_content.or(source.acs_signed_content),
+ directory_server_id: directory_server_id.or(source.directory_server_id),
..source
}
}
@@ -304,6 +311,7 @@ impl From<AuthenticationUpdate> for AuthenticationUpdateInternal {
authentication_status,
acquirer_bin,
acquirer_merchant_id,
+ directory_server_id,
} => Self {
threeds_server_transaction_id: Some(threeds_server_transaction_id),
maximum_supported_version: Some(maximum_supported_3ds_version),
@@ -315,6 +323,7 @@ impl From<AuthenticationUpdate> for AuthenticationUpdateInternal {
authentication_status: Some(authentication_status),
acquirer_bin,
acquirer_merchant_id,
+ directory_server_id,
..Default::default()
},
AuthenticationUpdate::AuthenticationUpdate {
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index 813fdd1f12..ba540f7f0b 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -115,6 +115,8 @@ diesel::table! {
payment_id -> Nullable<Varchar>,
#[max_length = 128]
merchant_connector_id -> Varchar,
+ #[max_length = 128]
+ directory_server_id -> Nullable<Varchar>,
}
}
diff --git a/crates/router/src/connector/netcetera/transformers.rs b/crates/router/src/connector/netcetera/transformers.rs
index 90cf465e82..fffacc3ea4 100644
--- a/crates/router/src/connector/netcetera/transformers.rs
+++ b/crates/router/src/connector/netcetera/transformers.rs
@@ -96,6 +96,9 @@ impl
three_ds_method_url,
message_version: maximum_supported_3ds_version,
connector_metadata: None,
+ directory_server_id: card_range
+ .as_ref()
+ .and_then(|card_range| card_range.directory_server_id.clone()),
},
)
}
diff --git a/crates/router/src/connector/threedsecureio/transformers.rs b/crates/router/src/connector/threedsecureio/transformers.rs
index d6a77fef31..fe26e509c1 100644
--- a/crates/router/src/connector/threedsecureio/transformers.rs
+++ b/crates/router/src/connector/threedsecureio/transformers.rs
@@ -108,6 +108,7 @@ impl
)
.change_context(errors::ConnectorError::ParsingFailed)?,
connector_metadata: Some(connector_metadata),
+ directory_server_id: None,
},
)
}
diff --git a/crates/router/src/core/authentication/utils.rs b/crates/router/src/core/authentication/utils.rs
index e29c8b1023..0152fb4321 100644
--- a/crates/router/src/core/authentication/utils.rs
+++ b/crates/router/src/core/authentication/utils.rs
@@ -63,6 +63,7 @@ pub async fn update_trackers<F: Clone, Req>(
three_ds_method_url,
message_version,
connector_metadata,
+ directory_server_id,
} => storage::AuthenticationUpdate::PreAuthenticationUpdate {
threeds_server_transaction_id,
maximum_supported_3ds_version,
@@ -77,6 +78,7 @@ pub async fn update_trackers<F: Clone, Req>(
.map(|acquirer_details| acquirer_details.acquirer_bin.clone()),
acquirer_merchant_id: acquirer_details
.map(|acquirer_details| acquirer_details.acquirer_merchant_id),
+ directory_server_id,
},
AuthenticationResponseData::AuthNResponse {
authn_flow_type,
@@ -181,6 +183,7 @@ pub async fn create_new_authentication(
profile_id,
payment_id,
merchant_connector_id,
+ directory_server_id: None,
};
state
.store
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index bcc71f82bc..ca068f1d59 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -603,6 +603,9 @@ where
three_ds_method_url: None,
}),
poll_config: api_models::payments::PollConfigResponse {poll_id: request_poll_id, delay_in_secs: poll_config.delay_in_secs, frequency: poll_config.frequency},
+ message_version: authentication.message_version.as_ref()
+ .map(|version| version.to_string()),
+ directory_server_id: authentication.directory_server_id.clone(),
},
})
}else{
diff --git a/crates/router/src/db/authentication.rs b/crates/router/src/db/authentication.rs
index 398af72f8b..4eff3dfdbf 100644
--- a/crates/router/src/db/authentication.rs
+++ b/crates/router/src/db/authentication.rs
@@ -147,6 +147,7 @@ impl AuthenticationInterface for MockDb {
profile_id: authentication.profile_id,
payment_id: authentication.payment_id,
merchant_connector_id: authentication.merchant_connector_id,
+ directory_server_id: authentication.directory_server_id,
};
authentications.push(authentication.clone());
Ok(authentication)
diff --git a/crates/router/src/types/authentication.rs b/crates/router/src/types/authentication.rs
index 91ab768e28..97ad8506d4 100644
--- a/crates/router/src/types/authentication.rs
+++ b/crates/router/src/types/authentication.rs
@@ -18,6 +18,7 @@ pub enum AuthenticationResponseData {
three_ds_method_url: Option<String>,
message_version: common_utils::types::SemanticVersion,
connector_metadata: Option<serde_json::Value>,
+ directory_server_id: Option<String>,
},
AuthNResponse {
authn_flow_type: AuthNFlowType,
diff --git a/migrations/2024-05-21-075556_add_directory_server_id_in_authentication/down.sql b/migrations/2024-05-21-075556_add_directory_server_id_in_authentication/down.sql
new file mode 100644
index 0000000000..7025236fe8
--- /dev/null
+++ b/migrations/2024-05-21-075556_add_directory_server_id_in_authentication/down.sql
@@ -0,0 +1 @@
+ALTER TABLE authentication DROP COLUMN IF EXISTS directory_server_id;
\ No newline at end of file
diff --git a/migrations/2024-05-21-075556_add_directory_server_id_in_authentication/up.sql b/migrations/2024-05-21-075556_add_directory_server_id_in_authentication/up.sql
new file mode 100644
index 0000000000..ecad9d16f6
--- /dev/null
+++ b/migrations/2024-05-21-075556_add_directory_server_id_in_authentication/up.sql
@@ -0,0 +1,2 @@
+-- Your SQL goes here
+ALTER TABLE authentication ADD COLUMN IF NOT EXISTS directory_server_id VARCHAR(128);
\ No newline at end of file
diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json
index 2fca38a3b8..26eb8997c1 100644
--- a/openapi/openapi_spec.json
+++ b/openapi/openapi_spec.json
@@ -18340,6 +18340,16 @@
},
"poll_config": {
"$ref": "#/components/schemas/PollConfigResponse"
+ },
+ "message_version": {
+ "type": "string",
+ "description": "Message Version",
+ "nullable": true
+ },
+ "directory_server_id": {
+ "type": "string",
+ "description": "Directory Server ID",
+ "nullable": true
}
}
},