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 three_ds_decision_rule_algorithm to the domain and diesel models of business_profile (#8106)
Sai Harsha Vardhanc0cda41bd079
diff --git a/crates/diesel_models/src/business_profile.rs b/crates/diesel_models/src/business_profile.rsindex ec2207946b..4cb36d5685 100644--- a/crates/diesel_models/src/business_profile.rs+++ b/crates/diesel_models/src/business_profile.rs@@ -73,6 +73,7 @@ pub struct Profile {pub id: Option<common_utils::id_type::ProfileId>,pub is_iframe_redirection_enabled: Option<bool>,pub is_pre_network_tokenization_enabled: Option<bool>,+ pub three_ds_decision_rule_algorithm: Option<serde_json::Value>,}#[cfg(feature = "v1")]@@ -181,6 +182,7 @@ pub struct ProfileUpdateInternal {pub merchant_business_country: Option<common_enums::CountryAlpha2>,pub is_iframe_redirection_enabled: Option<bool>,pub is_pre_network_tokenization_enabled: Option<bool>,+ pub three_ds_decision_rule_algorithm: Option<serde_json::Value>,}#[cfg(feature = "v1")]@@ -231,6 +233,7 @@ impl ProfileUpdateInternal {merchant_business_country,is_iframe_redirection_enabled,is_pre_network_tokenization_enabled,+ three_ds_decision_rule_algorithm,} = self;Profile {profile_id: source.profile_id,@@ -310,6 +313,8 @@ impl ProfileUpdateInternal {.or(source.is_iframe_redirection_enabled),is_pre_network_tokenization_enabled: is_pre_network_tokenization_enabled.or(source.is_pre_network_tokenization_enabled),+ three_ds_decision_rule_algorithm: three_ds_decision_rule_algorithm+ .or(source.three_ds_decision_rule_algorithm),}}}@@ -369,6 +374,7 @@ pub struct Profile {pub merchant_business_country: Option<common_enums::CountryAlpha2>,pub id: common_utils::id_type::ProfileId,pub is_iframe_redirection_enabled: Option<bool>,+ pub three_ds_decision_rule_algorithm: Option<serde_json::Value>,pub routing_algorithm_id: Option<common_utils::id_type::RoutingId>,pub order_fulfillment_time: Option<i64>,pub order_fulfillment_time_origin: Option<common_enums::OrderFulfillmentTimeOrigin>,@@ -656,6 +662,7 @@ impl ProfileUpdateInternal {.or(source.is_external_vault_enabled),external_vault_connector_details: external_vault_connector_details.or(source.external_vault_connector_details),+ three_ds_decision_rule_algorithm: None,}}}diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rsindex 5994670e1d..9d4e4dab73 100644--- a/crates/diesel_models/src/schema.rs+++ b/crates/diesel_models/src/schema.rs@@ -227,6 +227,7 @@ diesel::table! {id -> Nullable<Varchar>,is_iframe_redirection_enabled -> Nullable<Bool>,is_pre_network_tokenization_enabled -> Nullable<Bool>,+ three_ds_decision_rule_algorithm -> Nullable<Jsonb>,}}diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rsindex 195b0fa429..c7f5a2cbd8 100644--- a/crates/diesel_models/src/schema_v2.rs+++ b/crates/diesel_models/src/schema_v2.rs@@ -222,6 +222,7 @@ diesel::table! {#[max_length = 64]id -> Varchar,is_iframe_redirection_enabled -> Nullable<Bool>,+ three_ds_decision_rule_algorithm -> Nullable<Jsonb>,#[max_length = 64]routing_algorithm_id -> Nullable<Varchar>,order_fulfillment_time -> Nullable<Int8>,diff --git a/crates/hyperswitch_domain_models/src/business_profile.rs b/crates/hyperswitch_domain_models/src/business_profile.rsindex ea73498c31..f7dd3f9539 100644--- a/crates/hyperswitch_domain_models/src/business_profile.rs+++ b/crates/hyperswitch_domain_models/src/business_profile.rs@@ -75,6 +75,7 @@ pub struct Profile {pub merchant_business_country: Option<common_enums::CountryAlpha2>,pub is_iframe_redirection_enabled: Option<bool>,pub is_pre_network_tokenization_enabled: bool,+ pub three_ds_decision_rule_algorithm: Option<serde_json::Value>,}#[cfg(feature = "v1")]@@ -186,6 +187,7 @@ impl From<ProfileSetter> for Profile {merchant_business_country: value.merchant_business_country,is_iframe_redirection_enabled: value.is_iframe_redirection_enabled,is_pre_network_tokenization_enabled: value.is_pre_network_tokenization_enabled,+ three_ds_decision_rule_algorithm: None, // three_ds_decision_rule_algorithm is not yet created during profile creation}}}@@ -255,6 +257,7 @@ pub enum ProfileUpdate {RoutingAlgorithmUpdate {routing_algorithm: Option<serde_json::Value>,payout_routing_algorithm: Option<serde_json::Value>,+ three_ds_decision_rule_algorithm: Option<serde_json::Value>,},DynamicRoutingAlgorithmUpdate {dynamic_routing_algorithm: Option<serde_json::Value>,@@ -369,11 +372,13 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {merchant_business_country,is_iframe_redirection_enabled,is_pre_network_tokenization_enabled,+ three_ds_decision_rule_algorithm: None,}}ProfileUpdate::RoutingAlgorithmUpdate {routing_algorithm,payout_routing_algorithm,+ three_ds_decision_rule_algorithm,} => Self {profile_name: None,modified_at: now,@@ -419,6 +424,7 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {merchant_business_country: None,is_iframe_redirection_enabled: None,is_pre_network_tokenization_enabled: None,+ three_ds_decision_rule_algorithm,},ProfileUpdate::DynamicRoutingAlgorithmUpdate {dynamic_routing_algorithm,@@ -467,6 +473,7 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {merchant_business_country: None,is_iframe_redirection_enabled: None,is_pre_network_tokenization_enabled: None,+ three_ds_decision_rule_algorithm: None,},ProfileUpdate::ExtendedCardInfoUpdate {is_extended_card_info_enabled,@@ -515,6 +522,7 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {merchant_business_country: None,is_iframe_redirection_enabled: None,is_pre_network_tokenization_enabled: None,+ three_ds_decision_rule_algorithm: None,},ProfileUpdate::ConnectorAgnosticMitUpdate {is_connector_agnostic_mit_enabled,@@ -563,6 +571,7 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {merchant_business_country: None,is_iframe_redirection_enabled: None,is_pre_network_tokenization_enabled: None,+ three_ds_decision_rule_algorithm: None,},ProfileUpdate::NetworkTokenizationUpdate {is_network_tokenization_enabled,@@ -611,6 +620,7 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {merchant_business_country: None,is_iframe_redirection_enabled: None,is_pre_network_tokenization_enabled: None,+ three_ds_decision_rule_algorithm: None,},ProfileUpdate::CardTestingSecretKeyUpdate {card_testing_secret_key,@@ -659,6 +669,7 @@ impl From<ProfileUpdate> for ProfileUpdateInternal {merchant_business_country: None,is_iframe_redirection_enabled: None,is_pre_network_tokenization_enabled: None,+ three_ds_decision_rule_algorithm: None,},}}@@ -727,6 +738,7 @@ impl super::behaviour::Conversion for Profile {merchant_business_country: self.merchant_business_country,is_iframe_redirection_enabled: self.is_iframe_redirection_enabled,is_pre_network_tokenization_enabled: Some(self.is_pre_network_tokenization_enabled),+ three_ds_decision_rule_algorithm: self.three_ds_decision_rule_algorithm,})}@@ -821,6 +833,7 @@ impl super::behaviour::Conversion for Profile {is_pre_network_tokenization_enabled: item.is_pre_network_tokenization_enabled.unwrap_or(false),+ three_ds_decision_rule_algorithm: item.three_ds_decision_rule_algorithm,})}.await@@ -1806,6 +1819,7 @@ impl super::behaviour::Conversion for Profile {is_iframe_redirection_enabled: self.is_iframe_redirection_enabled,is_external_vault_enabled: self.is_external_vault_enabled,external_vault_connector_details: self.external_vault_connector_details,+ three_ds_decision_rule_algorithm: None,})}diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rsindex 1a092c8cf6..89d0cb7bfe 100644--- a/crates/router/src/core/routing/helpers.rs+++ b/crates/router/src/core/routing/helpers.rs@@ -260,6 +260,7 @@ pub async fn update_profile_active_algorithm_ref(let business_profile_update = domain::ProfileUpdate::RoutingAlgorithmUpdate {routing_algorithm,payout_routing_algorithm,+ three_ds_decision_rule_algorithm: None,};db.update_profile_by_profile_id(diff --git a/migrations/2025-05-21-134155_add_three_ds_decision_rule_algorithm_to_business_profile/down.sql b/migrations/2025-05-21-134155_add_three_ds_decision_rule_algorithm_to_business_profile/down.sqlnew file mode 100644index 0000000000..5d33aa6cf0--- /dev/null+++ b/migrations/2025-05-21-134155_add_three_ds_decision_rule_algorithm_to_business_profile/down.sql@@ -0,0 +1,3 @@+-- This file should undo anything in `up.sql`+ALTER TABLE business_profile+DROP COLUMN three_ds_decision_rule_algorithm;\ No newline at end of filediff --git a/migrations/2025-05-21-134155_add_three_ds_decision_rule_algorithm_to_business_profile/up.sql b/migrations/2025-05-21-134155_add_three_ds_decision_rule_algorithm_to_business_profile/up.sqlnew file mode 100644index 0000000000..964680ba37--- /dev/null+++ b/migrations/2025-05-21-134155_add_three_ds_decision_rule_algorithm_to_business_profile/up.sql@@ -0,0 +1,3 @@+-- Your SQL goes here+ALTER TABLE business_profile+ADD COLUMN three_ds_decision_rule_algorithm JSONB;\ No newline at end of file