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(frm_routing_algorithm): added frm_routing_algorithm to merchant_account table, to be consumed for frm selection (#1161)
rishavkarea9814531880
diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rsindex 1d6155b08c..6fed9c4dbd 100644--- a/crates/api_models/src/admin.rs+++ b/crates/api_models/src/admin.rs@@ -71,6 +71,11 @@ pub struct MerchantAccountCreate {#[cfg(not(feature = "multiple_mca"))]#[schema(value_type = Option<PrimaryBusinessDetails>)]pub primary_business_details: Option<Vec<PrimaryBusinessDetails>>,++ /// The frm routing algorithm to be used for routing payments to desired FRM's+ #[schema(value_type = Option<Object>,example = json!({"type": "single", "data": "signifyd"}))]+ pub frm_routing_algorithm: Option<serde_json::Value>,+///Will be used to expire client secret after certain amount of time to be supplied in seconds///(900) for 15 mins#[schema(example = 900)]@@ -136,6 +141,10 @@ pub struct MerchantAccountUpdate {///Default business details for connector routingpub primary_business_details: Option<Vec<PrimaryBusinessDetails>>,+ /// The frm routing algorithm to be used for routing payments to desired FRM's+ #[schema(value_type = Option<Object>,example = json!({"type": "single", "data": "signifyd"}))]+ pub frm_routing_algorithm: Option<serde_json::Value>,+///Will be used to expire client secret after certain amount of time to be supplied in seconds///(900) for 15 minspub intent_fulfillment_time: Option<u32>,@@ -202,6 +211,10 @@ pub struct MerchantAccountResponse {#[schema(value_type = Vec<PrimaryBusinessDetails>)]pub primary_business_details: Vec<PrimaryBusinessDetails>,+ /// The frm routing algorithm to be used to process the incoming request from merchant to outgoing payment FRM.+ #[schema(value_type = Option<RoutingAlgorithm>, max_length = 255, example = r#"{"type": "single", "data": "stripe" }"#)]+ pub frm_routing_algorithm: Option<serde_json::Value>,+///Will be used to expire client secret after certain amount of time to be supplied in seconds///(900) for 15 minspub intent_fulfillment_time: Option<i64>,diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rsindex 08767c3736..476d121eec 100644--- a/crates/api_models/src/enums.rs+++ b/crates/api_models/src/enums.rs@@ -630,6 +630,7 @@ pub enum Connector {Worldline,Worldpay,Zen,+ Signifyd,}impl Connector {diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rsindex f32d92298e..74e45036ff 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -121,6 +121,7 @@ pub async fn create_merchant_account(locker_id: req.locker_id,metadata: req.metadata,primary_business_details,+ frm_routing_algorithm: req.frm_routing_algorithm,intent_fulfillment_time: req.intent_fulfillment_time.map(i64::from),};@@ -228,6 +229,7 @@ pub async fn merchant_account_update(metadata: req.metadata,publishable_key: None,primary_business_details,+ frm_routing_algorithm: req.frm_routing_algorithm,intent_fulfillment_time: req.intent_fulfillment_time.map(i64::from),};diff --git a/crates/router/src/db/merchant_account.rs b/crates/router/src/db/merchant_account.rsindex daca13e581..1904854940 100644--- a/crates/router/src/db/merchant_account.rs+++ b/crates/router/src/db/merchant_account.rs@@ -208,6 +208,7 @@ impl MerchantAccountInterface for MockDb {primary_business_details: merchant_account.primary_business_details,created_at: common_utils::date_time::now(),modified_at: common_utils::date_time::now(),+ frm_routing_algorithm: merchant_account.frm_routing_algorithm,intent_fulfillment_time: merchant_account.intent_fulfillment_time,};accounts.push(account.clone());diff --git a/crates/router/src/types/api/admin.rs b/crates/router/src/types/api/admin.rsindex 70f9df7805..5272ebfbf6 100644--- a/crates/router/src/types/api/admin.rs+++ b/crates/router/src/types/api/admin.rs@@ -35,6 +35,7 @@ impl ForeignTryFrom<storage::MerchantAccount> for MerchantAccountResponse {metadata: item.metadata,locker_id: item.locker_id,primary_business_details,+ frm_routing_algorithm: item.frm_routing_algorithm,intent_fulfillment_time: item.intent_fulfillment_time,})}diff --git a/crates/storage_models/src/merchant_account.rs b/crates/storage_models/src/merchant_account.rsindex 27446ec69b..463379966a 100644--- a/crates/storage_models/src/merchant_account.rs+++ b/crates/storage_models/src/merchant_account.rs@@ -36,6 +36,7 @@ pub struct MerchantAccount {pub intent_fulfillment_time: Option<i64>,pub created_at: time::PrimitiveDateTime,pub modified_at: time::PrimitiveDateTime,+ pub frm_routing_algorithm: Option<serde_json::Value>,}#[derive(Clone, Debug, Default, Insertable, router_derive::DebugAsDisplay)]@@ -57,6 +58,7 @@ pub struct MerchantAccountNew {pub routing_algorithm: Option<serde_json::Value>,pub primary_business_details: serde_json::Value,pub intent_fulfillment_time: Option<i64>,+ pub frm_routing_algorithm: Option<serde_json::Value>,}#[derive(Debug)]@@ -77,6 +79,7 @@ pub enum MerchantAccountUpdate {routing_algorithm: Option<serde_json::Value>,primary_business_details: Option<serde_json::Value>,intent_fulfillment_time: Option<i64>,+ frm_routing_algorithm: Option<serde_json::Value>,},StorageSchemeUpdate {storage_scheme: storage_enums::MerchantStorageScheme,@@ -103,6 +106,7 @@ pub struct MerchantAccountUpdateInternal {primary_business_details: Option<serde_json::Value>,modified_at: Option<time::PrimitiveDateTime>,intent_fulfillment_time: Option<i64>,+ frm_routing_algorithm: Option<serde_json::Value>,}impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {@@ -124,6 +128,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {metadata,primary_business_details,intent_fulfillment_time,+ frm_routing_algorithm,} => Self {merchant_name,merchant_details,@@ -141,6 +146,7 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {primary_business_details,modified_at: Some(common_utils::date_time::now()),intent_fulfillment_time,+ frm_routing_algorithm,..Default::default()},MerchantAccountUpdate::StorageSchemeUpdate { storage_scheme } => Self {diff --git a/crates/storage_models/src/schema.rs b/crates/storage_models/src/schema.rsindex 1f70b45bb5..062b787c9b 100644--- a/crates/storage_models/src/schema.rs+++ b/crates/storage_models/src/schema.rs@@ -252,6 +252,7 @@ diesel::table! {intent_fulfillment_time -> Nullable<Int8>,created_at -> Timestamp,modified_at -> Timestamp,+ frm_routing_algorithm -> Nullable<Jsonb>,}}diff --git a/migrations/2023-04-25-091017_merchant_account_add_frm_routing_algorithm.sql/down.sql b/migrations/2023-04-25-091017_merchant_account_add_frm_routing_algorithm.sql/down.sqlnew file mode 100644index 0000000000..9de08421fb--- /dev/null+++ b/migrations/2023-04-25-091017_merchant_account_add_frm_routing_algorithm.sql/down.sql@@ -0,0 +1,2 @@++ALTER TABLE merchant_account DROP COLUMN frm_routing_algorithm;\ No newline at end of filediff --git a/migrations/2023-04-25-091017_merchant_account_add_frm_routing_algorithm.sql/up.sql b/migrations/2023-04-25-091017_merchant_account_add_frm_routing_algorithm.sql/up.sqlnew file mode 100644index 0000000000..48e02db308--- /dev/null+++ b/migrations/2023-04-25-091017_merchant_account_add_frm_routing_algorithm.sql/up.sql@@ -0,0 +1,3 @@++ALTER TABLE merchant_account+ADD COLUMN frm_routing_algorithm JSONB NULL;\ No newline at end of file