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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(router): add `acquirer_country_code` in acquirer_details and send it in netcetera authentication flow (#4835)
Sai Harsha Vardhan3077421cbde3
diff --git a/crates/connector_configs/src/common_config.rs b/crates/connector_configs/src/common_config.rsindex 7604b7abe0..6129ab0005 100644--- a/crates/connector_configs/src/common_config.rs+++ b/crates/connector_configs/src/common_config.rs@@ -94,6 +94,7 @@ pub struct ApiModelMetaData {pub merchant_name: Option<String>,pub acquirer_bin: Option<String>,pub acquirer_merchant_id: Option<String>,+ pub acquirer_country_code: Option<String>,pub three_ds_requestor_name: Option<String>,pub three_ds_requestor_id: Option<String>,pub pull_mechanism_for_external_3ds_enabled: Option<bool>,@@ -209,6 +210,7 @@ pub struct DashboardMetaData {pub merchant_name: Option<String>,pub acquirer_bin: Option<String>,pub acquirer_merchant_id: Option<String>,+ pub acquirer_country_code: Option<String>,pub three_ds_requestor_name: Option<String>,pub three_ds_requestor_id: Option<String>,pub pull_mechanism_for_external_3ds_enabled: Option<bool>,diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rsindex 4bf856a857..c2d4df1507 100644--- a/crates/connector_configs/src/connector.rs+++ b/crates/connector_configs/src/connector.rs@@ -97,6 +97,7 @@ pub struct ConfigMetadata {pub merchant_name: Option<String>,pub acquirer_bin: Option<String>,pub acquirer_merchant_id: Option<String>,+ pub acquirer_country_code: Option<String>,pub three_ds_requestor_name: Option<String>,pub three_ds_requestor_id: Option<String>,pub pull_mechanism_for_external_3ds_enabled: Option<bool>,diff --git a/crates/connector_configs/src/response_modifier.rs b/crates/connector_configs/src/response_modifier.rsindex f8f41edfc6..4dc97b7a70 100644--- a/crates/connector_configs/src/response_modifier.rs+++ b/crates/connector_configs/src/response_modifier.rs@@ -329,6 +329,7 @@ impl From<ApiModelMetaData> for DashboardMetaData {merchant_name: api_model.merchant_name,acquirer_bin: api_model.acquirer_bin,acquirer_merchant_id: api_model.acquirer_merchant_id,+ acquirer_country_code: api_model.acquirer_country_code,three_ds_requestor_name: api_model.three_ds_requestor_name,three_ds_requestor_id: api_model.three_ds_requestor_id,pull_mechanism_for_external_3ds_enabled: api_modeldiff --git a/crates/connector_configs/src/transformer.rs b/crates/connector_configs/src/transformer.rsindex e2501fd50f..064da683ca 100644--- a/crates/connector_configs/src/transformer.rs+++ b/crates/connector_configs/src/transformer.rs@@ -195,6 +195,7 @@ impl DashboardRequestPayload {merchant_name: None,acquirer_bin: None,acquirer_merchant_id: None,+ acquirer_country_code: None,three_ds_requestor_name: None,three_ds_requestor_id: None,pull_mechanism_for_external_3ds_enabled: None,@@ -222,6 +223,7 @@ impl DashboardRequestPayload {let merchant_name = meta_data.merchant_name;let acquirer_bin = meta_data.acquirer_bin;let acquirer_merchant_id = meta_data.acquirer_merchant_id;+ let acquirer_country_code = meta_data.acquirer_country_code;let three_ds_requestor_name = meta_data.three_ds_requestor_name;let three_ds_requestor_id = meta_data.three_ds_requestor_id;let pull_mechanism_for_external_3ds_enabled =@@ -246,6 +248,7 @@ impl DashboardRequestPayload {merchant_name,acquirer_bin,acquirer_merchant_id,+ acquirer_country_code,three_ds_requestor_name,three_ds_requestor_id,pull_mechanism_for_external_3ds_enabled,diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.tomlindex 9b4d7b921a..1e1cb718d3 100644--- a/crates/connector_configs/toml/development.toml+++ b/crates/connector_configs/toml/development.toml@@ -780,6 +780,7 @@ label="apple"[checkout.metadata]acquirer_bin = "Acquirer Bin"acquirer_merchant_id = "Acquirer Merchant ID"+acquirer_country_code = "Acquirer Country Code"[coinbase][[coinbase.crypto]]@@ -863,6 +864,11 @@ merchant_name="Google Pay Merchant Name"gateway_merchant_id="Google Pay Merchant Key"merchant_id="Google Pay Merchant ID"+[cybersource.metadata]+acquirer_bin = "Acquirer Bin"+acquirer_merchant_id = "Acquirer Merchant ID"+acquirer_country_code = "Acquirer Country Code"+[cybersource_payout][[cybersource_payout.credit]]payment_method_type = "Mastercard"@@ -1374,6 +1380,7 @@ merchant_secret="Source verification key"[nmi.metadata]acquirer_bin = "Acquirer Bin"acquirer_merchant_id = "Acquirer Merchant ID"+acquirer_country_code = "Acquirer Country Code"[nmi.metadata.google_pay]merchant_name="Google Pay Merchant Name"diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.tomlindex 348c463f56..0652099c67 100644--- a/crates/connector_configs/toml/sandbox.toml+++ b/crates/connector_configs/toml/sandbox.toml@@ -780,6 +780,7 @@ label="apple"[checkout.metadata]acquirer_bin = "Acquirer Bin"acquirer_merchant_id = "Acquirer Merchant ID"+acquirer_country_code = "Acquirer Country Code"[coinbase][[coinbase.crypto]]@@ -863,6 +864,11 @@ merchant_name="Google Pay Merchant Name"gateway_merchant_id="Google Pay Merchant Key"merchant_id="Google Pay Merchant ID"+[cybersource.metadata]+acquirer_bin = "Acquirer Bin"+acquirer_merchant_id = "Acquirer Merchant ID"+acquirer_country_code = "Acquirer Country Code"+[cybersource_payout][[cybersource_payout.credit]]payment_method_type = "Mastercard"@@ -1374,6 +1380,7 @@ merchant_secret="Source verification key"[nmi.metadata]acquirer_bin = "Acquirer Bin"acquirer_merchant_id = "Acquirer Merchant ID"+acquirer_country_code = "Acquirer Country Code"[nmi.metadata.google_pay]merchant_name="Google Pay Merchant Name"diff --git a/crates/diesel_models/src/authentication.rs b/crates/diesel_models/src/authentication.rsindex 09e495241f..a94cbe9605 100644--- a/crates/diesel_models/src/authentication.rs+++ b/crates/diesel_models/src/authentication.rs@@ -44,6 +44,7 @@ pub struct Authentication {pub merchant_connector_id: String,pub ds_trans_id: Option<String>,pub directory_server_id: Option<String>,+ pub acquirer_country_code: Option<String>,}impl Authentication {@@ -90,6 +91,7 @@ pub struct AuthenticationNew {pub merchant_connector_id: String,pub ds_trans_id: Option<String>,pub directory_server_id: Option<String>,+ pub acquirer_country_code: Option<String>,}#[derive(Debug)]@@ -118,6 +120,7 @@ pub enum AuthenticationUpdate {acquirer_bin: Option<String>,acquirer_merchant_id: Option<String>,directory_server_id: Option<String>,+ acquirer_country_code: Option<String>,},AuthenticationUpdate {authentication_value: Option<String>,@@ -180,6 +183,7 @@ pub struct AuthenticationUpdateInternal {pub acs_signed_content: Option<String>,pub ds_trans_id: Option<String>,pub directory_server_id: Option<String>,+ pub acquirer_country_code: Option<String>,}impl Default for AuthenticationUpdateInternal {@@ -212,6 +216,7 @@ impl Default for AuthenticationUpdateInternal {acs_signed_content: Default::default(),ds_trans_id: Default::default(),directory_server_id: Default::default(),+ acquirer_country_code: Default::default(),}}}@@ -246,6 +251,7 @@ impl AuthenticationUpdateInternal {acs_signed_content,ds_trans_id,directory_server_id,+ acquirer_country_code,} = self;Authentication {connector_authentication_id: connector_authentication_id@@ -279,6 +285,7 @@ impl AuthenticationUpdateInternal {acs_signed_content: acs_signed_content.or(source.acs_signed_content),ds_trans_id: ds_trans_id.or(source.ds_trans_id),directory_server_id: directory_server_id.or(source.directory_server_id),+ acquirer_country_code: acquirer_country_code.or(source.acquirer_country_code),..source}}@@ -331,6 +338,7 @@ impl From<AuthenticationUpdate> for AuthenticationUpdateInternal {acquirer_bin,acquirer_merchant_id,directory_server_id,+ acquirer_country_code,} => Self {threeds_server_transaction_id: Some(threeds_server_transaction_id),maximum_supported_version: Some(maximum_supported_3ds_version),@@ -343,6 +351,7 @@ impl From<AuthenticationUpdate> for AuthenticationUpdateInternal {acquirer_bin,acquirer_merchant_id,directory_server_id,+ acquirer_country_code,..Default::default()},AuthenticationUpdate::AuthenticationUpdate {diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rsindex 3525730fc8..15e662fe43 100644--- a/crates/diesel_models/src/schema.rs+++ b/crates/diesel_models/src/schema.rs@@ -119,6 +119,8 @@ diesel::table! {ds_trans_id -> Nullable<Varchar>,#[max_length = 128]directory_server_id -> Nullable<Varchar>,+ #[max_length = 64]+ acquirer_country_code -> Nullable<Varchar>,}}diff --git a/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs b/crates/hyperswitch_domain_models/src/router_request_types/authentication.rsindex 3f2feaf4c2..ab36deb425 100644--- a/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs+++ b/crates/hyperswitch_domain_models/src/router_request_types/authentication.rs@@ -110,6 +110,7 @@ pub struct PreAuthenticationData {pub message_version: common_utils::types::SemanticVersion,pub acquirer_bin: Option<String>,pub acquirer_merchant_id: Option<String>,+ pub acquirer_country_code: Option<String>,pub connector_metadata: Option<serde_json::Value>,}@@ -136,6 +137,7 @@ impl TryFrom<&diesel_models::authentication::Authentication> for PreAuthenticatiacquirer_bin: authentication.acquirer_bin.clone(),acquirer_merchant_id: authentication.acquirer_merchant_id.clone(),connector_metadata: authentication.connector_metadata.clone(),+ acquirer_country_code: authentication.acquirer_country_code.clone(),})}}@@ -150,6 +152,7 @@ pub struct ThreeDsMethodData {pub struct AcquirerDetails {pub acquirer_bin: String,pub acquirer_merchant_id: String,+ pub acquirer_country_code: Option<String>,}#[derive(Clone, Debug, Deserialize)]diff --git a/crates/router/src/connector/netcetera/transformers.rs b/crates/router/src/connector/netcetera/transformers.rsindex 0fcecadef2..adcfb17f14 100644--- a/crates/router/src/connector/netcetera/transformers.rs+++ b/crates/router/src/connector/netcetera/transformers.rs@@ -516,7 +516,7 @@ impl TryFrom<&NetceteraRouterData<&types::authentication::ConnectorAuthenticatiolet acquirer_details = netcetera_types::AcquirerData {acquirer_bin: request.pre_authentication_data.acquirer_bin,acquirer_merchant_id: request.pre_authentication_data.acquirer_merchant_id,- acquirer_country_code: None,+ acquirer_country_code: request.pre_authentication_data.acquirer_country_code,};let connector_meta_data: NetceteraMetaData = item.router_datadiff --git a/crates/router/src/core/authentication/types.rs b/crates/router/src/core/authentication/types.rsindex 0492e51e0a..419f2b427a 100644--- a/crates/router/src/core/authentication/types.rs+++ b/crates/router/src/core/authentication/types.rs@@ -28,6 +28,7 @@ impl ForeignTryFrom<&storage::Authentication> for PreAuthenticationData {message_version,acquirer_bin: authentication.acquirer_bin.clone(),acquirer_merchant_id: authentication.acquirer_merchant_id.clone(),+ acquirer_country_code: authentication.acquirer_country_code.clone(),connector_metadata: authentication.connector_metadata.clone(),})}diff --git a/crates/router/src/core/authentication/utils.rs b/crates/router/src/core/authentication/utils.rsindex ec44f299c7..71380e2c9e 100644--- a/crates/router/src/core/authentication/utils.rs+++ b/crates/router/src/core/authentication/utils.rs@@ -77,7 +77,10 @@ pub async fn update_trackers<F: Clone, Req>(.as_ref().map(|acquirer_details| acquirer_details.acquirer_bin.clone()),acquirer_merchant_id: acquirer_details- .map(|acquirer_details| acquirer_details.acquirer_merchant_id),+ .as_ref()+ .map(|acquirer_details| acquirer_details.acquirer_merchant_id.clone()),+ acquirer_country_code: acquirer_details+ .and_then(|acquirer_details| acquirer_details.acquirer_country_code),directory_server_id,},AuthenticationResponseData::AuthNResponse {@@ -214,6 +217,7 @@ pub async fn create_new_authentication(merchant_connector_id,ds_trans_id: None,directory_server_id: None,+ acquirer_country_code: None,};state.storediff --git a/crates/router/src/db/authentication.rs b/crates/router/src/db/authentication.rsindex cd3bb663ec..43f30afd88 100644--- a/crates/router/src/db/authentication.rs+++ b/crates/router/src/db/authentication.rs@@ -149,6 +149,7 @@ impl AuthenticationInterface for MockDb {merchant_connector_id: authentication.merchant_connector_id,ds_trans_id: authentication.ds_trans_id,directory_server_id: authentication.directory_server_id,+ acquirer_country_code: authentication.acquirer_country_code,};authentications.push(authentication.clone());Ok(authentication)diff --git a/crates/router/src/types/api/authentication.rs b/crates/router/src/types/api/authentication.rsindex 85d4d3718c..579e3f89dc 100644--- a/crates/router/src/types/api/authentication.rs+++ b/crates/router/src/types/api/authentication.rs@@ -25,6 +25,7 @@ use crate::{connector, services, types, types::storage};pub struct AcquirerDetails {pub acquirer_bin: String,pub acquirer_merchant_mid: String,+ pub acquirer_country_code: Option<String>,}#[derive(Clone, serde::Deserialize, Debug, serde::Serialize)]diff --git a/migrations/2024-05-31-074402_add_acquirer_country_code_in_authentication/down.sql b/migrations/2024-05-31-074402_add_acquirer_country_code_in_authentication/down.sqlnew file mode 100644index 0000000000..7582099d44--- /dev/null+++ b/migrations/2024-05-31-074402_add_acquirer_country_code_in_authentication/down.sql@@ -0,0 +1 @@+ALTER TABLE authentication DROP COLUMN IF EXISTS acquirer_country_code;\ No newline at end of filediff --git a/migrations/2024-05-31-074402_add_acquirer_country_code_in_authentication/up.sql b/migrations/2024-05-31-074402_add_acquirer_country_code_in_authentication/up.sqlnew file mode 100644index 0000000000..49ada12ee2--- /dev/null+++ b/migrations/2024-05-31-074402_add_acquirer_country_code_in_authentication/up.sql@@ -0,0 +1,2 @@+-- Your SQL goes here+ALTER TABLE authentication ADD COLUMN IF NOT EXISTS acquirer_country_code VARCHAR(64);\ No newline at end of file