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
refactor(merchant_account_v2): recreate id and remove deprecated fields from merchant account (#5493)
Narayan Bhat49892b261ef9
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.jsonindex 040df7d84f..a3e67c1d1c 100644--- a/api-reference/openapi_spec.json+++ b/api-reference/openapi_spec.json@@ -7059,7 +7059,7 @@},"metadata": {"type": "object",- "description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.",+ "description": "Metadata is useful for storing additional, unstructured information on an object.","nullable": true},"routing_algorithm": {@@ -7221,7 +7221,7 @@},"metadata": {"type": "object",- "description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.",+ "description": "Metadata is useful for storing additional, unstructured information on an object.","nullable": true},"routing_algorithm": {@@ -11757,7 +11757,7 @@},"metadata": {"type": "object",- "description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.",+ "description": "Metadata is useful for storing additional, unstructured information on an object.","nullable": true},"publishable_key": {@@ -11889,7 +11889,7 @@},"metadata": {"type": "object",- "description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.",+ "description": "Metadata is useful for storing additional, unstructured information on an object.","nullable": true},"test_mode": {@@ -11999,7 +11999,7 @@},"metadata": {"type": "object",- "description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.",+ "description": "Metadata is useful for storing additional, unstructured information on an object.","nullable": true}}@@ -12118,7 +12118,7 @@},"metadata": {"type": "object",- "description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.",+ "description": "Metadata is useful for storing additional, unstructured information on an object.","nullable": true},"test_mode": {@@ -12285,7 +12285,7 @@},"metadata": {"type": "object",- "description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.",+ "description": "Metadata is useful for storing additional, unstructured information on an object.","nullable": true},"test_mode": {@@ -12436,7 +12436,7 @@},"metadata": {"type": "object",- "description": "You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.",+ "description": "Metadata is useful for storing additional, unstructured information on an object.","nullable": true},"test_mode": {diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rsindex c80a188534..c6a6fe1722 100644--- a/crates/api_models/src/admin.rs+++ b/crates/api_models/src/admin.rs@@ -260,6 +260,11 @@ pub struct MerchantAccountMetadata {#[serde(flatten)]pub data: Option<pii::SecretSerdeValue>,}++#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]#[derive(Clone, Debug, Deserialize, ToSchema, Serialize)]#[serde(deny_unknown_fields)]pub struct MerchantAccountUpdate {@@ -310,7 +315,7 @@ pub struct MerchantAccountUpdate {#[schema(default = false, example = true)]pub redirect_to_merchant_with_http_post: Option<bool>,- /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.+ /// Metadata is useful for storing additional, unstructured information on an object.#[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]pub metadata: Option<pii::SecretSerdeValue>,@@ -339,6 +344,110 @@ pub struct MerchantAccountUpdate {pub pm_collect_link_config: Option<BusinessCollectLinkConfig>,}+#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]+impl MerchantAccountUpdate {+ pub fn get_primary_details_as_value(+ &self,+ ) -> CustomResult<Option<serde_json::Value>, errors::ParsingError> {+ self.primary_business_details+ .as_ref()+ .map(|primary_business_details| primary_business_details.encode_to_value())+ .transpose()+ }++ pub fn get_pm_link_config_as_value(+ &self,+ ) -> CustomResult<Option<serde_json::Value>, errors::ParsingError> {+ self.pm_collect_link_config+ .as_ref()+ .map(|pm_collect_link_config| pm_collect_link_config.encode_to_value())+ .transpose()+ }++ pub fn get_merchant_details_as_secret(+ &self,+ ) -> CustomResult<Option<pii::SecretSerdeValue>, errors::ParsingError> {+ self.merchant_details+ .as_ref()+ .map(|merchant_details| merchant_details.encode_to_value().map(Secret::new))+ .transpose()+ }++ pub fn get_metadata_as_secret(+ &self,+ ) -> CustomResult<Option<pii::SecretSerdeValue>, errors::ParsingError> {+ self.metadata+ .as_ref()+ .map(|metadata| metadata.encode_to_value().map(Secret::new))+ .transpose()+ }++ pub fn get_webhook_details_as_value(+ &self,+ ) -> CustomResult<Option<serde_json::Value>, errors::ParsingError> {+ self.webhook_details+ .as_ref()+ .map(|webhook_details| webhook_details.encode_to_value())+ .transpose()+ }++ pub fn parse_routing_algorithm(&self) -> CustomResult<(), errors::ParsingError> {+ match self.routing_algorithm {+ Some(ref routing_algorithm) => {+ let _: routing::RoutingAlgorithm =+ routing_algorithm.clone().parse_value("RoutingAlgorithm")?;+ Ok(())+ }+ None => Ok(()),+ }+ }++ // Get the enable payment response hash as a boolean, where the default value is true+ pub fn get_enable_payment_response_hash(&self) -> bool {+ self.enable_payment_response_hash.unwrap_or(true)+ }+}++#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]+#[derive(Clone, Debug, Deserialize, ToSchema, Serialize)]+#[serde(deny_unknown_fields)]+pub struct MerchantAccountUpdate {+ /// Name of the Merchant Account+ #[schema(example = "NewAge Retailer")]+ pub merchant_name: Option<String>,++ /// Details about the merchant+ pub merchant_details: Option<MerchantDetails>,++ /// Metadata is useful for storing additional, unstructured information on an object.+ #[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]+ pub metadata: Option<pii::SecretSerdeValue>,+}++#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]+impl MerchantAccountUpdate {+ pub fn get_merchant_details_as_secret(+ &self,+ ) -> CustomResult<Option<pii::SecretSerdeValue>, errors::ParsingError> {+ self.merchant_details+ .as_ref()+ .map(|merchant_details| merchant_details.encode_to_value().map(Secret::new))+ .transpose()+ }++ pub fn get_metadata_as_secret(+ &self,+ ) -> CustomResult<Option<pii::SecretSerdeValue>, errors::ParsingError> {+ self.metadata+ .as_ref()+ .map(|metadata| metadata.encode_to_value().map(Secret::new))+ .transpose()+ }+}+#[cfg(all(any(feature = "v1", feature = "v2"),not(feature = "merchant_account_v2")@@ -462,9 +571,6 @@ pub struct MerchantAccountResponse {#[schema(value_type = String, max_length = 64, min_length = 1, example = "org_q98uSGAYbjEwqs0mJwnz")]pub organization_id: id_type::OrganizationId,- /// A boolean value to indicate if the merchant has recon service is enabled or not, by default value is false- pub is_recon_enabled: bool,-/// Used to indicate the status of the recon module for a merchant account#[schema(value_type = ReconStatus, example = "not_requested")]pub recon_status: api_enums::ReconStatus,@@ -636,7 +742,7 @@ pub struct MerchantConnectorCreate {}))]pub connector_webhook_details: Option<MerchantConnectorWebhookDetails>,- /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.+ /// Metadata is useful for storing additional, unstructured information on an object.#[schema(value_type = Option<Object>,max_length = 255,example = json!({ "city": "NY", "unit": "245" }))]pub metadata: Option<pii::SecretSerdeValue>,@@ -766,7 +872,7 @@ pub struct MerchantConnectorCreate {}))]pub connector_webhook_details: Option<MerchantConnectorWebhookDetails>,- /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.+ /// Metadata is useful for storing additional, unstructured information on an object.#[schema(value_type = Option<Object>,max_length = 255,example = json!({ "city": "NY", "unit": "245" }))]pub metadata: Option<pii::SecretSerdeValue>,@@ -1001,7 +1107,7 @@ pub struct MerchantConnectorResponse {}))]pub connector_webhook_details: Option<MerchantConnectorWebhookDetails>,- /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.+ /// Metadata is useful for storing additional, unstructured information on an object.#[schema(value_type = Option<Object>,max_length = 255,example = json!({ "city": "NY", "unit": "245" }))]pub metadata: Option<pii::SecretSerdeValue>,@@ -1108,7 +1214,7 @@ pub struct MerchantConnectorResponse {}))]pub connector_webhook_details: Option<MerchantConnectorWebhookDetails>,- /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.+ /// Metadata is useful for storing additional, unstructured information on an object.#[schema(value_type = Option<Object>,max_length = 255,example = json!({ "city": "NY", "unit": "245" }))]pub metadata: Option<pii::SecretSerdeValue>,@@ -1220,7 +1326,7 @@ pub struct MerchantConnectorListResponse {]))]pub payment_methods_enabled: Option<Vec<PaymentMethodsEnabled>>,- /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.+ /// Metadata is useful for storing additional, unstructured information on an object.#[schema(value_type = Option<Object>,max_length = 255,example = json!({ "city": "NY", "unit": "245" }))]pub metadata: Option<pii::SecretSerdeValue>,@@ -1329,7 +1435,7 @@ pub struct MerchantConnectorListResponse {]))]pub payment_methods_enabled: Option<Vec<PaymentMethodsEnabled>>,- /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.+ /// Metadata is useful for storing additional, unstructured information on an object.#[schema(value_type = Option<Object>,max_length = 255,example = json!({ "city": "NY", "unit": "245" }))]pub metadata: Option<pii::SecretSerdeValue>,@@ -1424,7 +1530,7 @@ pub struct MerchantConnectorUpdate {}))]pub connector_webhook_details: Option<MerchantConnectorWebhookDetails>,- /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.+ /// Metadata is useful for storing additional, unstructured information on an object.#[schema(value_type = Option<Object>,max_length = 255,example = json!({ "city": "NY", "unit": "245" }))]pub metadata: Option<pii::SecretSerdeValue>,@@ -1722,7 +1828,7 @@ pub struct MerchantConnectorDetails {/// Account details of the Connector. You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Useful for storing additional, structured information on an object.#[schema(value_type = Option<Object>,example = json!({ "auth_type": "HeaderKey","api_key": "Basic MyVerySecretApiKey" }))]pub connector_account_details: pii::SecretSerdeValue,- /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.+ /// Metadata is useful for storing additional, unstructured information on an object.#[schema(value_type = Option<Object>,max_length = 255,example = json!({ "city": "NY", "unit": "245" }))]pub metadata: Option<pii::SecretSerdeValue>,}@@ -1752,7 +1858,7 @@ pub struct BusinessProfileCreate {/// Webhook related detailspub webhook_details: Option<WebhookDetails>,- /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.+ /// Metadata is useful for storing additional, unstructured information on an object.#[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]pub metadata: Option<pii::SecretSerdeValue>,@@ -1845,7 +1951,7 @@ pub struct BusinessProfileResponse {#[schema(value_type = Option<WebhookDetails>)]pub webhook_details: Option<pii::SecretSerdeValue>,- /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.+ /// Metadata is useful for storing additional, unstructured information on an object.#[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]pub metadata: Option<pii::SecretSerdeValue>,@@ -1933,7 +2039,7 @@ pub struct BusinessProfileUpdate {/// Webhook related detailspub webhook_details: Option<WebhookDetails>,- /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. Metadata is useful for storing additional, structured information on an object.+ /// Metadata is useful for storing additional, unstructured information on an object.#[schema(value_type = Option<Object>, example = r#"{ "city": "NY", "unit": "245" }"#)]pub metadata: Option<pii::SecretSerdeValue>,diff --git a/crates/api_models/src/conditional_configs.rs b/crates/api_models/src/conditional_configs.rsindex 46bad3e9e8..555e7bd955 100644--- a/crates/api_models/src/conditional_configs.rs+++ b/crates/api_models/src/conditional_configs.rs@@ -97,6 +97,7 @@ pub struct DecisionManagerRequest {pub name: Option<String>,pub program: Option<Program<ConditionalConfigs>>,}+#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]#[serde(untagged)]pub enum DecisionManager {diff --git a/crates/diesel_models/src/merchant_account.rs b/crates/diesel_models/src/merchant_account.rsindex 3aa4088f3b..907162da7c 100644--- a/crates/diesel_models/src/merchant_account.rs+++ b/crates/diesel_models/src/merchant_account.rs@@ -146,32 +146,18 @@ impl From<MerchantAccountSetter> for MerchantAccount {)]#[diesel(table_name = merchant_account, primary_key(id), check_for_backend(diesel::pg::Pg))]pub struct MerchantAccount {- pub return_url: Option<String>,- pub enable_payment_response_hash: bool,- pub payment_response_hash_key: Option<String>,- pub redirect_to_merchant_with_http_post: bool,pub merchant_name: Option<Encryption>,pub merchant_details: Option<Encryption>,- pub webhook_details: Option<serde_json::Value>,- pub sub_merchants_enabled: Option<bool>,- pub parent_merchant_id: Option<common_utils::id_type::MerchantId>,pub publishable_key: Option<String>,pub storage_scheme: storage_enums::MerchantStorageScheme,- pub locker_id: Option<String>,pub metadata: Option<pii::SecretSerdeValue>,pub routing_algorithm: Option<serde_json::Value>,- pub primary_business_details: serde_json::Value,- pub intent_fulfillment_time: Option<i64>,pub created_at: time::PrimitiveDateTime,pub modified_at: time::PrimitiveDateTime,pub frm_routing_algorithm: Option<serde_json::Value>,pub payout_routing_algorithm: Option<serde_json::Value>,pub organization_id: common_utils::id_type::OrganizationId,- pub is_recon_enabled: bool,- pub default_profile: Option<String>,pub recon_status: storage_enums::ReconStatus,- pub payment_link_config: Option<serde_json::Value>,- pub pm_collect_link_config: Option<serde_json::Value>,pub id: common_utils::id_type::MerchantId,}@@ -180,32 +166,18 @@ impl From<MerchantAccountSetter> for MerchantAccount {fn from(item: MerchantAccountSetter) -> Self {Self {id: item.id,- return_url: item.return_url,- enable_payment_response_hash: item.enable_payment_response_hash,- payment_response_hash_key: item.payment_response_hash_key,- redirect_to_merchant_with_http_post: item.redirect_to_merchant_with_http_post,merchant_name: item.merchant_name,merchant_details: item.merchant_details,- webhook_details: item.webhook_details,- sub_merchants_enabled: item.sub_merchants_enabled,- parent_merchant_id: item.parent_merchant_id,publishable_key: item.publishable_key,storage_scheme: item.storage_scheme,- locker_id: item.locker_id,metadata: item.metadata,- routing_algorithm: item.routing_algorithm,- primary_business_details: item.primary_business_details,- intent_fulfillment_time: item.intent_fulfillment_time,created_at: item.created_at,modified_at: item.modified_at,frm_routing_algorithm: item.frm_routing_algorithm,+ routing_algorithm: item.routing_algorithm,payout_routing_algorithm: item.payout_routing_algorithm,organization_id: item.organization_id,- is_recon_enabled: item.is_recon_enabled,- default_profile: item.default_profile,recon_status: item.recon_status,- payment_link_config: item.payment_link_config,- pm_collect_link_config: item.pm_collect_link_config,}}}@@ -213,32 +185,18 @@ impl From<MerchantAccountSetter> for MerchantAccount {#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]pub struct MerchantAccountSetter {pub id: common_utils::id_type::MerchantId,- pub return_url: Option<String>,- pub enable_payment_response_hash: bool,- pub payment_response_hash_key: Option<String>,- pub redirect_to_merchant_with_http_post: bool,pub merchant_name: Option<Encryption>,pub merchant_details: Option<Encryption>,- pub webhook_details: Option<serde_json::Value>,- pub sub_merchants_enabled: Option<bool>,- pub parent_merchant_id: Option<common_utils::id_type::MerchantId>,pub publishable_key: Option<String>,pub storage_scheme: storage_enums::MerchantStorageScheme,- pub locker_id: Option<String>,pub metadata: Option<pii::SecretSerdeValue>,pub routing_algorithm: Option<serde_json::Value>,- pub primary_business_details: serde_json::Value,- pub intent_fulfillment_time: Option<i64>,pub created_at: time::PrimitiveDateTime,pub modified_at: time::PrimitiveDateTime,pub frm_routing_algorithm: Option<serde_json::Value>,pub payout_routing_algorithm: Option<serde_json::Value>,pub organization_id: common_utils::id_type::OrganizationId,- pub is_recon_enabled: bool,- pub default_profile: Option<String>,pub recon_status: storage_enums::ReconStatus,- pub payment_link_config: Option<serde_json::Value>,- pub pm_collect_link_config: Option<serde_json::Value>,}impl MerchantAccount {@@ -298,33 +256,40 @@ pub struct MerchantAccountNew {pub struct MerchantAccountNew {pub merchant_name: Option<Encryption>,pub merchant_details: Option<Encryption>,- pub return_url: Option<String>,- pub webhook_details: Option<serde_json::Value>,- pub sub_merchants_enabled: Option<bool>,- pub parent_merchant_id: Option<common_utils::id_type::MerchantId>,- pub enable_payment_response_hash: Option<bool>,- pub payment_response_hash_key: Option<String>,- pub redirect_to_merchant_with_http_post: Option<bool>,pub publishable_key: Option<String>,- pub locker_id: Option<String>,pub metadata: Option<pii::SecretSerdeValue>,pub routing_algorithm: Option<serde_json::Value>,- pub primary_business_details: serde_json::Value,- pub intent_fulfillment_time: Option<i64>,pub created_at: time::PrimitiveDateTime,pub modified_at: time::PrimitiveDateTime,pub frm_routing_algorithm: Option<serde_json::Value>,pub payout_routing_algorithm: Option<serde_json::Value>,pub organization_id: common_utils::id_type::OrganizationId,- pub is_recon_enabled: bool,- pub default_profile: Option<String>,pub recon_status: storage_enums::ReconStatus,- pub payment_link_config: Option<serde_json::Value>,- pub pm_collect_link_config: Option<serde_json::Value>,pub id: common_utils::id_type::MerchantId,}-#[derive(Clone, Debug, Default, AsChangeset, router_derive::DebugAsDisplay)]+#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]+#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]+#[diesel(table_name = merchant_account)]+pub struct MerchantAccountUpdateInternal {+ pub merchant_name: Option<Encryption>,+ pub merchant_details: Option<Encryption>,+ pub publishable_key: Option<String>,+ pub storage_scheme: Option<storage_enums::MerchantStorageScheme>,+ pub metadata: Option<pii::SecretSerdeValue>,+ pub routing_algorithm: Option<serde_json::Value>,+ pub modified_at: time::PrimitiveDateTime,+ pub frm_routing_algorithm: Option<serde_json::Value>,+ pub payout_routing_algorithm: Option<serde_json::Value>,+ pub organization_id: Option<common_utils::id_type::OrganizationId>,+ pub recon_status: Option<storage_enums::ReconStatus>,+}++#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]+#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]#[diesel(table_name = merchant_account)]pub struct MerchantAccountUpdateInternal {pub merchant_name: Option<Encryption>,@@ -342,12 +307,12 @@ pub struct MerchantAccountUpdateInternal {pub metadata: Option<pii::SecretSerdeValue>,pub routing_algorithm: Option<serde_json::Value>,pub primary_business_details: Option<serde_json::Value>,- pub modified_at: Option<time::PrimitiveDateTime>,+ pub modified_at: time::PrimitiveDateTime,pub intent_fulfillment_time: Option<i64>,pub frm_routing_algorithm: Option<serde_json::Value>,pub payout_routing_algorithm: Option<serde_json::Value>,pub organization_id: Option<common_utils::id_type::OrganizationId>,- pub is_recon_enabled: bool,+ pub is_recon_enabled: Option<bool>,pub default_profile: Option<Option<String>>,pub recon_status: Option<storage_enums::ReconStatus>,pub payment_link_config: Option<serde_json::Value>,diff --git a/crates/diesel_models/src/schema_v2.rs b/crates/diesel_models/src/schema_v2.rsindex 23f9dff31e..91c02b6903 100644--- a/crates/diesel_models/src/schema_v2.rs+++ b/crates/diesel_models/src/schema_v2.rs@@ -639,39 +639,20 @@ diesel::table! {use crate::enums::diesel_exports::*;merchant_account (id) {- #[max_length = 255]- return_url -> Nullable<Varchar>,- enable_payment_response_hash -> Bool,- #[max_length = 255]- payment_response_hash_key -> Nullable<Varchar>,- redirect_to_merchant_with_http_post -> Bool,merchant_name -> Nullable<Bytea>,merchant_details -> Nullable<Bytea>,- webhook_details -> Nullable<Json>,- sub_merchants_enabled -> Nullable<Bool>,- #[max_length = 64]- parent_merchant_id -> Nullable<Varchar>,#[max_length = 128]publishable_key -> Nullable<Varchar>,storage_scheme -> MerchantStorageScheme,- #[max_length = 64]- locker_id -> Nullable<Varchar>,metadata -> Nullable<Jsonb>,routing_algorithm -> Nullable<Json>,- primary_business_details -> Json,- intent_fulfillment_time -> Nullable<Int8>,created_at -> Timestamp,modified_at -> Timestamp,frm_routing_algorithm -> Nullable<Jsonb>,payout_routing_algorithm -> Nullable<Jsonb>,#[max_length = 32]organization_id -> Varchar,- is_recon_enabled -> Bool,- #[max_length = 64]- default_profile -> Nullable<Varchar>,recon_status -> ReconStatus,- payment_link_config -> Nullable<Jsonb>,- pm_collect_link_config -> Nullable<Jsonb>,#[max_length = 64]id -> Varchar,}diff --git a/crates/hyperswitch_domain_models/src/merchant_account.rs b/crates/hyperswitch_domain_models/src/merchant_account.rsindex ce11cd566c..2452e5091f 100644--- a/crates/hyperswitch_domain_models/src/merchant_account.rs+++ b/crates/hyperswitch_domain_models/src/merchant_account.rs@@ -130,65 +130,52 @@ impl From<MerchantAccountSetter> for MerchantAccount {/// Set the private fields of merchant accountpub struct MerchantAccountSetter {pub id: common_utils::id_type::MerchantId,- pub return_url: Option<String>,- pub enable_payment_response_hash: bool,- pub payment_response_hash_key: Option<String>,- pub redirect_to_merchant_with_http_post: bool,pub merchant_name: OptionalEncryptableName,pub merchant_details: OptionalEncryptableValue,- pub webhook_details: Option<serde_json::Value>,- pub sub_merchants_enabled: Option<bool>,- pub parent_merchant_id: Option<common_utils::id_type::MerchantId>,pub publishable_key: String,pub storage_scheme: MerchantStorageScheme,- pub locker_id: Option<String>,pub metadata: Option<pii::SecretSerdeValue>,pub routing_algorithm: Option<serde_json::Value>,- pub primary_business_details: serde_json::Value,pub frm_routing_algorithm: Option<serde_json::Value>,pub created_at: time::PrimitiveDateTime,pub modified_at: time::PrimitiveDateTime,- pub intent_fulfillment_time: Option<i64>,pub payout_routing_algorithm: Option<serde_json::Value>,pub organization_id: common_utils::id_type::OrganizationId,- pub is_recon_enabled: bool,- pub default_profile: Option<String>,pub recon_status: diesel_models::enums::ReconStatus,- pub payment_link_config: Option<serde_json::Value>,- pub pm_collect_link_config: Option<serde_json::Value>,}#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]impl From<MerchantAccountSetter> for MerchantAccount {fn from(item: MerchantAccountSetter) -> Self {+ let MerchantAccountSetter {+ id,+ merchant_name,+ merchant_details,+ publishable_key,+ storage_scheme,+ metadata,+ routing_algorithm,+ frm_routing_algorithm,+ created_at,+ modified_at,+ payout_routing_algorithm,+ organization_id,+ recon_status,+ } = item;Self {- id: item.id,- return_url: item.return_url,- enable_payment_response_hash: item.enable_payment_response_hash,- payment_response_hash_key: item.payment_response_hash_key,- redirect_to_merchant_with_http_post: item.redirect_to_merchant_with_http_post,- merchant_name: item.merchant_name,- merchant_details: item.merchant_details,- webhook_details: item.webhook_details,- sub_merchants_enabled: item.sub_merchants_enabled,- parent_merchant_id: item.parent_merchant_id,- publishable_key: item.publishable_key,- storage_scheme: item.storage_scheme,- locker_id: item.locker_id,- metadata: item.metadata,- routing_algorithm: item.routing_algorithm,- primary_business_details: item.primary_business_details,- frm_routing_algorithm: item.frm_routing_algorithm,- created_at: item.created_at,- modified_at: item.modified_at,- intent_fulfillment_time: item.intent_fulfillment_time,- payout_routing_algorithm: item.payout_routing_algorithm,- organization_id: item.organization_id,- is_recon_enabled: item.is_recon_enabled,- default_profile: item.default_profile,- recon_status: item.recon_status,- payment_link_config: item.payment_link_config,- pm_collect_link_config: item.pm_collect_link_config,+ id,+ merchant_name,+ merchant_details,+ publishable_key,+ storage_scheme,+ metadata,+ routing_algorithm,+ frm_routing_algorithm,+ created_at,+ modified_at,+ payout_routing_algorithm,+ organization_id,+ recon_status,}}}@@ -197,32 +184,18 @@ impl From<MerchantAccountSetter> for MerchantAccount {#[derive(Clone, Debug, serde::Serialize)]pub struct MerchantAccount {id: common_utils::id_type::MerchantId,- pub return_url: Option<String>,- pub enable_payment_response_hash: bool,- pub payment_response_hash_key: Option<String>,- pub redirect_to_merchant_with_http_post: bool,pub merchant_name: OptionalEncryptableName,pub merchant_details: OptionalEncryptableValue,- pub webhook_details: Option<serde_json::Value>,- pub sub_merchants_enabled: Option<bool>,- pub parent_merchant_id: Option<common_utils::id_type::MerchantId>,pub publishable_key: String,pub storage_scheme: MerchantStorageScheme,- pub locker_id: Option<String>,pub metadata: Option<pii::SecretSerdeValue>,pub routing_algorithm: Option<serde_json::Value>,- pub primary_business_details: serde_json::Value,pub frm_routing_algorithm: Option<serde_json::Value>,pub created_at: time::PrimitiveDateTime,pub modified_at: time::PrimitiveDateTime,- pub intent_fulfillment_time: Option<i64>,pub payout_routing_algorithm: Option<serde_json::Value>,pub organization_id: common_utils::id_type::OrganizationId,- pub is_recon_enabled: bool,- pub default_profile: Option<String>,pub recon_status: diesel_models::enums::ReconStatus,- pub payment_link_config: Option<serde_json::Value>,- pub pm_collect_link_config: Option<serde_json::Value>,}impl MerchantAccount {@@ -242,6 +215,10 @@ impl MerchantAccount {}}+#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]#[allow(clippy::large_enum_variant)]#[derive(Debug)]pub enum MerchantAccountUpdate {@@ -277,6 +254,33 @@ pub enum MerchantAccountUpdate {ModifiedAtUpdate,}+#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]+#[allow(clippy::large_enum_variant)]+#[derive(Debug)]+pub enum MerchantAccountUpdate {+ Update {+ merchant_name: OptionalEncryptableName,+ merchant_details: OptionalEncryptableValue,+ publishable_key: Option<String>,+ metadata: Option<pii::SecretSerdeValue>,+ routing_algorithm: Option<serde_json::Value>,+ frm_routing_algorithm: Option<serde_json::Value>,+ payout_routing_algorithm: Option<serde_json::Value>,+ },+ StorageSchemeUpdate {+ storage_scheme: MerchantStorageScheme,+ },+ ReconUpdate {+ recon_status: diesel_models::enums::ReconStatus,+ },+ ModifiedAtUpdate,+}++#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]+impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {fn from(merchant_account_update: MerchantAccountUpdate) -> Self {let now = date_time::now();@@ -285,8 +289,8 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {MerchantAccountUpdate::Update {merchant_name,merchant_details,- return_url,webhook_details,+ return_url,routing_algorithm,sub_merchants_enabled,parent_merchant_id,@@ -307,11 +311,11 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {merchant_name: merchant_name.map(Encryption::from),merchant_details: merchant_details.map(Encryption::from),frm_routing_algorithm,- return_url,webhook_details,routing_algorithm,sub_merchants_enabled,parent_merchant_id,+ return_url,enable_payment_response_hash,payment_response_hash_key,redirect_to_merchant_with_http_post,@@ -319,32 +323,194 @@ impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {locker_id,metadata,primary_business_details,- modified_at: Some(now),+ modified_at: now,intent_fulfillment_time,payout_routing_algorithm,default_profile,payment_link_config,pm_collect_link_config,- ..Default::default()+ storage_scheme: None,+ organization_id: None,+ is_recon_enabled: None,+ recon_status: None,},MerchantAccountUpdate::StorageSchemeUpdate { storage_scheme } => Self {storage_scheme: Some(storage_scheme),- modified_at: Some(now),- ..Default::default()+ modified_at: now,+ merchant_name: None,+ merchant_details: None,+ return_url: None,+ webhook_details: None,+ sub_merchants_enabled: None,+ parent_merchant_id: None,+ enable_payment_response_hash: None,+ payment_response_hash_key: None,+ redirect_to_merchant_with_http_post: None,+ publishable_key: None,+ locker_id: None,+ metadata: None,+ routing_algorithm: None,+ primary_business_details: None,+ intent_fulfillment_time: None,+ frm_routing_algorithm: None,+ payout_routing_algorithm: None,+ organization_id: None,+ is_recon_enabled: None,+ default_profile: None,+ recon_status: None,+ payment_link_config: None,+ pm_collect_link_config: None,},MerchantAccountUpdate::ReconUpdate { recon_status } => Self {recon_status: Some(recon_status),- modified_at: Some(now),- ..Default::default()+ modified_at: now,+ merchant_name: None,+ merchant_details: None,+ return_url: None,+ webhook_details: None,+ sub_merchants_enabled: None,+ parent_merchant_id: None,+ enable_payment_response_hash: None,+ payment_response_hash_key: None,+ redirect_to_merchant_with_http_post: None,+ publishable_key: None,+ storage_scheme: None,+ locker_id: None,+ metadata: None,+ routing_algorithm: None,+ primary_business_details: None,+ intent_fulfillment_time: None,+ frm_routing_algorithm: None,+ payout_routing_algorithm: None,+ organization_id: None,+ is_recon_enabled: None,+ default_profile: None,+ payment_link_config: None,+ pm_collect_link_config: None,},MerchantAccountUpdate::UnsetDefaultProfile => Self {default_profile: Some(None),- modified_at: Some(now),- ..Default::default()+ modified_at: now,+ merchant_name: None,+ merchant_details: None,+ return_url: None,+ webhook_details: None,+ sub_merchants_enabled: None,+ parent_merchant_id: None,+ enable_payment_response_hash: None,+ payment_response_hash_key: None,+ redirect_to_merchant_with_http_post: None,+ publishable_key: None,+ storage_scheme: None,+ locker_id: None,+ metadata: None,+ routing_algorithm: None,+ primary_business_details: None,+ intent_fulfillment_time: None,+ frm_routing_algorithm: None,+ payout_routing_algorithm: None,+ organization_id: None,+ is_recon_enabled: None,+ recon_status: None,+ payment_link_config: None,+ pm_collect_link_config: None,+ },+ MerchantAccountUpdate::ModifiedAtUpdate => Self {+ modified_at: now,+ merchant_name: None,+ merchant_details: None,+ return_url: None,+ webhook_details: None,+ sub_merchants_enabled: None,+ parent_merchant_id: None,+ enable_payment_response_hash: None,+ payment_response_hash_key: None,+ redirect_to_merchant_with_http_post: None,+ publishable_key: None,+ storage_scheme: None,+ locker_id: None,+ metadata: None,+ routing_algorithm: None,+ primary_business_details: None,+ intent_fulfillment_time: None,+ frm_routing_algorithm: None,+ payout_routing_algorithm: None,+ organization_id: None,+ is_recon_enabled: None,+ default_profile: None,+ recon_status: None,+ payment_link_config: None,+ pm_collect_link_config: None,+ },+ }+ }+}++#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]+impl From<MerchantAccountUpdate> for MerchantAccountUpdateInternal {+ fn from(merchant_account_update: MerchantAccountUpdate) -> Self {+ let now = date_time::now();++ match merchant_account_update {+ MerchantAccountUpdate::Update {+ merchant_name,+ merchant_details,+ routing_algorithm,+ publishable_key,+ metadata,+ frm_routing_algorithm,+ payout_routing_algorithm,+ } => Self {+ merchant_name: merchant_name.map(Encryption::from),+ merchant_details: merchant_details.map(Encryption::from),+ frm_routing_algorithm,+ routing_algorithm,+ publishable_key,+ metadata,+ modified_at: now,+ payout_routing_algorithm,+ storage_scheme: None,+ organization_id: None,+ recon_status: None,+ },+ MerchantAccountUpdate::StorageSchemeUpdate { storage_scheme } => Self {+ storage_scheme: Some(storage_scheme),+ modified_at: now,+ merchant_name: None,+ merchant_details: None,+ publishable_key: None,+ metadata: None,+ routing_algorithm: None,+ frm_routing_algorithm: None,+ payout_routing_algorithm: None,+ organization_id: None,+ recon_status: None,+ },+ MerchantAccountUpdate::ReconUpdate { recon_status } => Self {+ recon_status: Some(recon_status),+ modified_at: now,+ merchant_name: None,+ merchant_details: None,+ publishable_key: None,+ storage_scheme: None,+ metadata: None,+ routing_algorithm: None,+ frm_routing_algorithm: None,+ payout_routing_algorithm: None,+ organization_id: None,},MerchantAccountUpdate::ModifiedAtUpdate => Self {- modified_at: Some(date_time::now()),- ..Default::default()+ modified_at: now,+ merchant_name: None,+ merchant_details: None,+ publishable_key: None,+ storage_scheme: None,+ metadata: None,+ routing_algorithm: None,+ frm_routing_algorithm: None,+ payout_routing_algorithm: None,+ organization_id: None,+ recon_status: None,},}}@@ -360,32 +526,18 @@ impl super::behaviour::Conversion for MerchantAccount {let setter = diesel_models::merchant_account::MerchantAccountSetter {id,- return_url: self.return_url,- enable_payment_response_hash: self.enable_payment_response_hash,- payment_response_hash_key: self.payment_response_hash_key,- redirect_to_merchant_with_http_post: self.redirect_to_merchant_with_http_post,merchant_name: self.merchant_name.map(|name| name.into()),merchant_details: self.merchant_details.map(|details| details.into()),- webhook_details: self.webhook_details,- sub_merchants_enabled: self.sub_merchants_enabled,- parent_merchant_id: self.parent_merchant_id,publishable_key: Some(self.publishable_key),storage_scheme: self.storage_scheme,- locker_id: self.locker_id,metadata: self.metadata,routing_algorithm: self.routing_algorithm,- primary_business_details: self.primary_business_details,created_at: self.created_at,modified_at: self.modified_at,- intent_fulfillment_time: self.intent_fulfillment_time,frm_routing_algorithm: self.frm_routing_algorithm,payout_routing_algorithm: self.payout_routing_algorithm,organization_id: self.organization_id,- is_recon_enabled: self.is_recon_enabled,- default_profile: self.default_profile,recon_status: self.recon_status,- payment_link_config: self.payment_link_config,- pm_collect_link_config: self.pm_collect_link_config,};Ok(diesel_models::MerchantAccount::from(setter))@@ -410,10 +562,6 @@ impl super::behaviour::Conversion for MerchantAccount {async {Ok::<Self, error_stack::Report<common_utils::errors::CryptoError>>(Self {id,- return_url: item.return_url,- enable_payment_response_hash: item.enable_payment_response_hash,- payment_response_hash_key: item.payment_response_hash_key,- redirect_to_merchant_with_http_post: item.redirect_to_merchant_with_http_post,merchant_name: item.merchant_name.async_lift(|inner| {@@ -426,26 +574,16 @@ impl super::behaviour::Conversion for MerchantAccount {decrypt_optional(state, inner, key_manager_identifier.clone(), key.peek())}).await?,- webhook_details: item.webhook_details,- sub_merchants_enabled: item.sub_merchants_enabled,- parent_merchant_id: item.parent_merchant_id,publishable_key,storage_scheme: item.storage_scheme,- locker_id: item.locker_id,metadata: item.metadata,routing_algorithm: item.routing_algorithm,frm_routing_algorithm: item.frm_routing_algorithm,- primary_business_details: item.primary_business_details,created_at: item.created_at,modified_at: item.modified_at,- intent_fulfillment_time: item.intent_fulfillment_time,payout_routing_algorithm: item.payout_routing_algorithm,organization_id: item.organization_id,- is_recon_enabled: item.is_recon_enabled,- default_profile: item.default_profile,recon_status: item.recon_status,- payment_link_config: item.payment_link_config,- pm_collect_link_config: item.pm_collect_link_config,})}.await@@ -460,29 +598,15 @@ impl super::behaviour::Conversion for MerchantAccount {id: self.id,merchant_name: self.merchant_name.map(Encryption::from),merchant_details: self.merchant_details.map(Encryption::from),- return_url: self.return_url,- webhook_details: self.webhook_details,- sub_merchants_enabled: self.sub_merchants_enabled,- parent_merchant_id: self.parent_merchant_id,- enable_payment_response_hash: Some(self.enable_payment_response_hash),- payment_response_hash_key: self.payment_response_hash_key,- redirect_to_merchant_with_http_post: Some(self.redirect_to_merchant_with_http_post),publishable_key: Some(self.publishable_key),- locker_id: self.locker_id,metadata: self.metadata,routing_algorithm: self.routing_algorithm,- primary_business_details: self.primary_business_details,created_at: now,modified_at: now,- intent_fulfillment_time: self.intent_fulfillment_time,frm_routing_algorithm: self.frm_routing_algorithm,payout_routing_algorithm: self.payout_routing_algorithm,organization_id: self.organization_id,- is_recon_enabled: self.is_recon_enabled,- default_profile: self.default_profile,recon_status: self.recon_status,- payment_link_config: self.payment_link_config,- pm_collect_link_config: self.pm_collect_link_config,})}}diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rsindex 925fd3c61e..b8e9d7c4f1 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -7,7 +7,7 @@ use api_models::{use base64::Engine;use common_utils::{date_time,- ext_traits::{AsyncExt, ConfigExt, Encode, ValueExt},+ ext_traits::{AsyncExt, Encode, ValueExt},id_type, pii,types::keymanager::{self as km_types, KeyManagerState},};@@ -15,7 +15,6 @@ use diesel_models::configs;#[cfg(all(any(feature = "v1", feature = "v2"), feature = "olap"))]use diesel_models::organization::OrganizationBridge;use error_stack::{report, FutureExt, ResultExt};-use futures::future::try_join_all;use masking::{ExposeInterface, PeekInterface, Secret};use pm_auth::{connector::plaid::transformers::PlaidAuthType, types as pm_auth_types};use regex::Regex;@@ -230,7 +229,7 @@ pub async fn create_merchant_account(};let domain_merchant_account = req- .create_domain_model_from_request(&state, key_store.clone())+ .create_domain_model_from_request(&state, key_store.clone(), &merchant_id).await?;let key_manager_state = &(&state).into();db.insert_merchant_key_store(@@ -264,6 +263,7 @@ trait MerchantAccountCreateBridge {self,state: &SessionState,key: domain::MerchantKeyStore,+ identifier: &id_type::MerchantId,) -> RouterResult<domain::MerchantAccount>;}@@ -278,6 +278,7 @@ impl MerchantAccountCreateBridge for api::MerchantAccountCreate {self,state: &SessionState,key_store: domain::MerchantKeyStore,+ identifier: &id_type::MerchantId,) -> RouterResult<domain::MerchantAccount> {let db = &*state.store;let publishable_key = create_merchant_publishable_key();@@ -341,7 +342,7 @@ impl MerchantAccountCreateBridge for api::MerchantAccountCreate {let merchant_account = async {Ok::<_, error_stack::Report<common_utils::errors::CryptoError>>(domain::MerchantAccountSetter {- merchant_id: self.merchant_id,+ merchant_id: identifier.clone(),merchant_name: self.merchant_name.async_lift(|inner| {@@ -618,6 +619,7 @@ impl MerchantAccountCreateBridge for api::MerchantAccountCreate {self,state: &SessionState,key_store: domain::MerchantKeyStore,+ identifier: &id_type::MerchantId,) -> RouterResult<domain::MerchantAccount> {let publishable_key = create_merchant_publishable_key();let db = &*state.store;@@ -634,18 +636,12 @@ impl MerchantAccountCreateBridge for api::MerchantAccountCreate {},)?;- let primary_business_details = self.get_primary_details_as_value().change_context(- errors::ApiErrorResponse::InvalidDataValue {- field_name: "primary_business_details",- },- )?;-let organization = CreateOrValidateOrganization::new(self.organization_id.clone()).create_or_validate(db).await?;let key = key_store.key.into_inner();- let id = self.get_merchant_reference_id().to_owned();+ let id = identifier.to_owned();let key_manager_state = state.into();let identifier = km_types::Identifier::Merchant(id.clone());@@ -673,33 +669,19 @@ impl MerchantAccountCreateBridge for api::MerchantAccountCreate {)}).await?,- return_url: None,- webhook_details: None,routing_algorithm: Some(serde_json::json!({"algorithm_id": null,"timestamp": 0})),- sub_merchants_enabled: None,- parent_merchant_id: None,- enable_payment_response_hash: true,- payment_response_hash_key: None,- redirect_to_merchant_with_http_post: true,publishable_key,- locker_id: None,metadata,storage_scheme: MerchantStorageScheme::PostgresOnly,- primary_business_details,created_at: date_time::now(),modified_at: date_time::now(),- intent_fulfillment_time: None,frm_routing_algorithm: None,payout_routing_algorithm: None,organization_id: organization.get_organization_id(),- is_recon_enabled: false,- default_profile: None,recon_status: diesel_models::enums::ReconStatus::NotRequested,- payment_link_config: None,- pm_collect_link_config: None,}),)}@@ -762,7 +744,10 @@ pub async fn get_merchant_account())}-#[cfg(any(feature = "v1", feature = "v2"))]+#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]/// For backwards compatibility, whenever new business labels are passed in/// primary_business_details, create a business profilepub async fn create_business_profile_from_business_labels(@@ -832,74 +817,222 @@ pub async fn create_business_profile_from_business_labels(Ok(())}-/// For backwards compatibility-/// If any of the fields of merchant account are updated, then update these fields in business profiles-pub async fn update_business_profile_cascade(- state: SessionState,- merchant_account_update: api::MerchantAccountUpdate,- merchant_id: id_type::MerchantId,-) -> RouterResult<()> {- if merchant_account_update.return_url.is_some()- || merchant_account_update.webhook_details.is_some()- || merchant_account_update- .enable_payment_response_hash- .is_some()- || merchant_account_update- .redirect_to_merchant_with_http_post- .is_some()- {- // Update these fields in all the business profiles- let business_profiles = state- .store- .list_business_profile_by_merchant_id(&merchant_id)- .await- .to_not_found_response(errors::ApiErrorResponse::BusinessProfileNotFound {- id: merchant_id.get_string_repr().to_owned(),- })?;+#[cfg(any(feature = "v1", feature = "v2", feature = "olap"))]+#[async_trait::async_trait]+trait MerchantAccountUpdateBridge {+ async fn get_update_merchant_object(+ self,+ state: &SessionState,+ merchant_id: &id_type::MerchantId,+ key_store: &domain::MerchantKeyStore,+ ) -> RouterResult<storage::MerchantAccountUpdate>;+}- let business_profile_update = admin_types::BusinessProfileUpdate {- profile_name: None,- return_url: merchant_account_update.return_url,- enable_payment_response_hash: merchant_account_update.enable_payment_response_hash,- payment_response_hash_key: merchant_account_update.payment_response_hash_key,- redirect_to_merchant_with_http_post: merchant_account_update- .redirect_to_merchant_with_http_post,- webhook_details: merchant_account_update.webhook_details,- metadata: None,- routing_algorithm: None,+#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]+#[async_trait::async_trait]+impl MerchantAccountUpdateBridge for api::MerchantAccountUpdate {+ async fn get_update_merchant_object(+ self,+ state: &SessionState,+ merchant_id: &id_type::MerchantId,+ key_store: &domain::MerchantKeyStore,+ ) -> RouterResult<storage::MerchantAccountUpdate> {+ use common_utils::ext_traits::ConfigExt;++ let key_manager_state = &state.into();+ let key = key_store.key.get_inner().peek();++ let db = state.store.as_ref();++ let primary_business_details = self.get_primary_details_as_value().change_context(+ errors::ApiErrorResponse::InvalidDataValue {+ field_name: "primary_business_details",+ },+ )?;++ let pm_collect_link_config = self.get_pm_link_config_as_value().change_context(+ errors::ApiErrorResponse::InvalidDataValue {+ field_name: "pm_collect_link_config",+ },+ )?;++ let merchant_details = self.get_merchant_details_as_secret().change_context(+ errors::ApiErrorResponse::InvalidDataValue {+ field_name: "merchant_details",+ },+ )?;++ self.parse_routing_algorithm().change_context(+ errors::ApiErrorResponse::InvalidDataValue {+ field_name: "routing_algorithm",+ },+ )?;++ let webhook_details = self.get_webhook_details_as_value().change_context(+ errors::ApiErrorResponse::InvalidDataValue {+ field_name: "webhook_details",+ },+ )?;++ let parent_merchant_id = get_parent_merchant(+ state,+ self.sub_merchants_enabled,+ self.parent_merchant_id.as_ref(),+ key_store,+ )+ .await?;++ // This supports changing the business profile by passing in the profile_id+ let business_profile_id_update = if let Some(ref profile_id) = self.default_profile {+ if !profile_id.is_empty_after_trim() {+ // Validate whether profile_id passed in request is valid and is linked to the merchant+ core_utils::validate_and_get_business_profile(+ state.store.as_ref(),+ Some(profile_id),+ merchant_id,+ )+ .await?+ .map(|business_profile| Some(business_profile.profile_id))+ } else {+ // If empty, Update profile_id to None in the database+ Some(None)+ }+ } else {+ None+ };++ #[cfg(any(feature = "v1", feature = "v2"))]+ // In order to support backwards compatibility, if a business_labels are passed in the update+ // call, then create new business_profiles with the profile_name as business_label+ self.primary_business_details+ .clone()+ .async_map(|primary_business_details| async {+ let _ = create_business_profile_from_business_labels(+ state,+ db,+ key_store,+ merchant_id,+ primary_business_details,+ )+ .await;+ })+ .await;++ let identifier = km_types::Identifier::Merchant(key_store.merchant_id.clone());+ Ok(storage::MerchantAccountUpdate::Update {+ merchant_name: self+ .merchant_name+ .map(Secret::new)+ .async_lift(|inner| {+ domain_types::encrypt_optional(+ key_manager_state,+ inner,+ identifier.clone(),+ key,+ )+ })+ .await+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Unable to encrypt merchant name")?,+ merchant_details: merchant_details+ .async_lift(|inner| {+ domain_types::encrypt_optional(+ key_manager_state,+ inner,+ km_types::Identifier::Merchant(key_store.merchant_id.clone()),+ key,+ )+ })+ .await+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Unable to encrypt merchant details")?,+ return_url: self.return_url.map(|a| a.to_string()),+ webhook_details,+ sub_merchants_enabled: self.sub_merchants_enabled,+ parent_merchant_id,+ enable_payment_response_hash: self.enable_payment_response_hash,+ payment_response_hash_key: self.payment_response_hash_key,+ redirect_to_merchant_with_http_post: self.redirect_to_merchant_with_http_post,+ locker_id: self.locker_id,+ metadata: self.metadata,+ publishable_key: None,+ primary_business_details,+ frm_routing_algorithm: self.frm_routing_algorithm,intent_fulfillment_time: None,- frm_routing_algorithm: None,#[cfg(feature = "payouts")]+ payout_routing_algorithm: self.payout_routing_algorithm,+ #[cfg(not(feature = "payouts"))]payout_routing_algorithm: None,- applepay_verified_domains: None,+ default_profile: business_profile_id_update,payment_link_config: None,- session_expiry: None,- authentication_connector_details: None,- payout_link_config: None,- extended_card_info_config: None,- use_billing_as_payment_method_billing: None,- collect_shipping_details_from_wallet_connector: None,- collect_billing_details_from_wallet_connector: None,- is_connector_agnostic_mit_enabled: None,- outgoing_webhook_custom_http_headers: None,- };+ pm_collect_link_config,+ routing_algorithm: self.routing_algorithm,+ })+ }+}- let update_futures = business_profiles.iter().map(|business_profile| async {- let profile_id = &business_profile.profile_id;+#[cfg(all(any(feature = "v1", feature = "v2"), feature = "merchant_account_v2",))]+#[async_trait::async_trait]+impl MerchantAccountUpdateBridge for api::MerchantAccountUpdate {+ async fn get_update_merchant_object(+ self,+ state: &SessionState,+ _merchant_id: &id_type::MerchantId,+ key_store: &domain::MerchantKeyStore,+ ) -> RouterResult<storage::MerchantAccountUpdate> {+ let key_manager_state = &state.into();+ let key = key_store.key.get_inner().peek();- update_business_profile(- state.clone(),- profile_id,- &merchant_id,- business_profile_update.clone(),- )- .await- });+ let merchant_details = self.get_merchant_details_as_secret().change_context(+ errors::ApiErrorResponse::InvalidDataValue {+ field_name: "merchant_details",+ },+ )?;- try_join_all(update_futures).await?;- }+ let metadata = self.get_metadata_as_secret().change_context(+ errors::ApiErrorResponse::InvalidDataValue {+ field_name: "metadata",+ },+ )?;- Ok(())+ let identifier = km_types::Identifier::Merchant(key_store.merchant_id.clone());+ Ok(storage::MerchantAccountUpdate::Update {+ merchant_name: self+ .merchant_name+ .map(Secret::new)+ .async_lift(|inner| {+ domain_types::encrypt_optional(+ key_manager_state,+ inner,+ identifier.clone(),+ key,+ )+ })+ .await+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Unable to encrypt merchant name")?,+ merchant_details: merchant_details+ .async_lift(|inner| {+ domain_types::encrypt_optional(+ key_manager_state,+ inner,+ km_types::Identifier::Merchant(key_store.merchant_id.clone()),+ key,+ )+ })+ .await+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("Unable to encrypt merchant details")?,+ metadata,+ publishable_key: None,+ frm_routing_algorithm: None,+ payout_routing_algorithm: None,+ routing_algorithm: None,+ })+ }}pub async fn merchant_account_update(@@ -913,169 +1046,27 @@ pub async fn merchant_account_update(let key_store = db.get_merchant_key_store_by_merchant_id(key_manager_state,- &req.merchant_id,+ merchant_id,&db.get_master_key().to_vec().into(),).await.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;- if &req.merchant_id != merchant_id {- Err(report!(errors::ValidationError::IncorrectValueProvided {- field_name: "parent_merchant_id"- })- .attach_printable(- "If `sub_merchants_enabled` is true, then `parent_merchant_id` is mandatory",- )- .change_context(errors::ApiErrorResponse::InvalidDataValue {- field_name: "parent_merchant_id",- }))?;- }-- if let Some(ref routing_algorithm) = req.routing_algorithm {- let _: api_models::routing::RoutingAlgorithm = routing_algorithm- .clone()- .parse_value("RoutingAlgorithm")- .change_context(errors::ApiErrorResponse::InvalidDataValue {- field_name: "routing_algorithm",- })- .attach_printable("Invalid routing algorithm given")?;- }-- let primary_business_details = req- .primary_business_details- .as_ref()- .map(|primary_business_details| {- primary_business_details.encode_to_value().change_context(- errors::ApiErrorResponse::InvalidDataValue {- field_name: "primary_business_details",- },- )- })- .transpose()?;-- let pm_collect_link_config = req- .pm_collect_link_config- .as_ref()- .map(|c| {- c.encode_to_value()- .change_context(errors::ApiErrorResponse::InvalidDataValue {- field_name: "pm_collect_link_config",- })- })- .transpose()?;-- #[cfg(any(feature = "v1", feature = "v2"))]- // In order to support backwards compatibility, if a business_labels are passed in the update- // call, then create new business_profiles with the profile_name as business_label- req.primary_business_details- .clone()- .async_map(|primary_business_details| async {- let _ = create_business_profile_from_business_labels(- &state,- db,- &key_store,- merchant_id,- primary_business_details,- )- .await;- })- .await;-- let key = key_store.key.get_inner().peek();-- let business_profile_id_update = if let Some(ref profile_id) = req.default_profile {- if !profile_id.is_empty_after_trim() {- // Validate whether profile_id passed in request is valid and is linked to the merchant- core_utils::validate_and_get_business_profile(db, Some(profile_id), merchant_id)- .await?- .map(|business_profile| Some(business_profile.profile_id))- } else {- // If empty, Update profile_id to None in the database- Some(None)- }- } else {- None- };-- // Update the business profile, This is for backwards compatibility- update_business_profile_cascade(state.clone(), req.clone(), merchant_id.to_owned()).await?;-- let identifier = km_types::Identifier::Merchant(key_store.merchant_id.clone());- let updated_merchant_account = storage::MerchantAccountUpdate::Update {- merchant_name: req- .merchant_name- .map(Secret::new)- .async_lift(|inner| {- domain_types::encrypt_optional(key_manager_state, inner, identifier.clone(), key)- })- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Unable to encrypt merchant name")?,-- merchant_details: req- .merchant_details- .as_ref()- .map(Encode::encode_to_value)- .transpose()- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Unable to convert merchant_details to a value")?- .map(Secret::new)- .async_lift(|inner| {- domain_types::encrypt_optional(key_manager_state, inner, identifier.clone(), key)- })- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("Unable to encrypt merchant details")?,-- return_url: req.return_url.map(|a| a.to_string()),-- webhook_details: req- .webhook_details- .as_ref()- .map(Encode::encode_to_value)- .transpose()- .change_context(errors::ApiErrorResponse::InternalServerError)?,-- routing_algorithm: req.routing_algorithm,- sub_merchants_enabled: req.sub_merchants_enabled,-- parent_merchant_id: get_parent_merchant(- &state,- req.sub_merchants_enabled,- req.parent_merchant_id.as_ref(),- &key_store,- )- .await?,- enable_payment_response_hash: req.enable_payment_response_hash,- payment_response_hash_key: req.payment_response_hash_key,- redirect_to_merchant_with_http_post: req.redirect_to_merchant_with_http_post,- locker_id: req.locker_id,- metadata: req.metadata,- publishable_key: None,- primary_business_details,- frm_routing_algorithm: req.frm_routing_algorithm,- intent_fulfillment_time: None,- #[cfg(feature = "payouts")]- payout_routing_algorithm: req.payout_routing_algorithm,- #[cfg(not(feature = "payouts"))]- payout_routing_algorithm: None,- default_profile: business_profile_id_update,- payment_link_config: None,- pm_collect_link_config,- };+ let merchant_account_storage_object = req+ .get_update_merchant_object(&state, merchant_id, &key_store)+ .await+ .attach_printable("Failed to create merchant account update object")?;let response = db.update_specific_fields_in_merchant(key_manager_state,merchant_id,- updated_merchant_account,+ merchant_account_storage_object,&key_store,).await.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;- // If there are any new business labels generated, create business profile-Ok(service_api::ApplicationResponse::Json(api::MerchantAccountResponse::foreign_try_from(response).change_context(errors::ApiErrorResponse::InternalServerError)@@ -1153,6 +1144,10 @@ pub async fn merchant_account_delete(Ok(service_api::ApplicationResponse::Json(response))}+#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]async fn get_parent_merchant(state: &SessionState,sub_merchants_enabled: Option<bool>,@@ -1181,6 +1176,10 @@ async fn get_parent_merchant(})}+#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]async fn validate_merchant_id(state: &SessionState,merchant_id: &id_type::MerchantId,@@ -2207,7 +2206,8 @@ trait MerchantConnectorAccountCreateBridge {#[cfg(all(feature = "v2",feature = "merchant_connector_account_v2",- feature = "olap"+ feature = "olap",+ feature = "merchant_account_v2"))]#[async_trait::async_trait]impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {@@ -2359,7 +2359,8 @@ impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {#[cfg(all(any(feature = "v1", feature = "v2", feature = "olap"),- not(feature = "merchant_connector_account_v2")+ not(feature = "merchant_connector_account_v2"),+ not(feature = "merchant_account_v2")))]#[async_trait::async_trait]impl MerchantConnectorAccountCreateBridge for api::MerchantConnectorCreate {@@ -2580,7 +2581,7 @@ pub async fn create_payment_connector(#[cfg(all(any(feature = "v1", feature = "v2"),- not(feature = "merchant_connector_account_v2")+ not(feature = "merchant_account_v2")))]helpers::validate_business_details(req.business_country,@@ -3157,9 +3158,19 @@ pub async fn create_and_insert_business_profile(merchant_account: domain::MerchantAccount,key_store: &domain::MerchantKeyStore,) -> RouterResult<storage::business_profile::BusinessProfile> {+ #[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+ ))]let business_profile_new =admin::create_business_profile(state, merchant_account, request, key_store).await?;+ #[cfg(all(feature = "v2", feature = "merchant_account_v2"))]+ let business_profile_new = {+ let _ = merchant_account;+ admin::create_business_profile(state, request, key_store).await?+ };+let profile_name = business_profile_new.profile_name.clone();state@@ -3174,6 +3185,10 @@ pub async fn create_and_insert_business_profile(.attach_printable("Failed to insert Business profile because of duplication error")}+#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]pub async fn create_business_profile(state: SessionState,request: api::BusinessProfileCreate,@@ -3239,6 +3254,15 @@ pub async fn create_business_profile())}+#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]+pub async fn create_business_profile(+ _state: SessionState,+ _request: api::BusinessProfileCreate,+ _merchant_id: &id_type::MerchantId,+) -> RouterResponse<api_models::admin::BusinessProfileResponse> {+ todo!()+}+pub async fn list_business_profile(state: SessionState,merchant_id: id_type::MerchantId,diff --git a/crates/router/src/core/fraud_check.rs b/crates/router/src/core/fraud_check.rsindex df3a5a2ca2..64fadd0e33 100644--- a/crates/router/src/core/fraud_check.rs+++ b/crates/router/src/core/fraud_check.rs@@ -2,6 +2,7 @@ use std::fmt::Debug;use api_models::{admin::FrmConfigs, enums as api_enums};use common_enums::CaptureMethod;+use common_utils::ext_traits::OptionExt;use error_stack::ResultExt;use masking::{ExposeInterface, PeekInterface};use router_env::{@@ -21,7 +22,6 @@ use crate::{core::{errors::{self, RouterResult},payments::{self, flows::ConstructFlowSpecificData, operations::BoxedOperation},- utils as core_utils,},db::StorageInterface,routes::{app::ReqState, SessionState},@@ -145,16 +145,14 @@ where}).attach_printable("Data field not found in frm_routing_algorithm")?;- let profile_id = core_utils::get_profile_id_from_business_details(- payment_data.payment_intent.business_country,- payment_data.payment_intent.business_label.as_ref(),- merchant_account,- payment_data.payment_intent.profile_id.as_ref(),- db,- false,- )- .await- .attach_printable("Could not find profile id from business details")?;+ let profile_id = payment_data+ .payment_intent+ .profile_id+ .as_ref()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("profile_id is not set in payment_intent")?+ .clone();#[cfg(all(any(feature = "v1", feature = "v2"),diff --git a/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs b/crates/router/src/core/fraud_check/flows/fulfillment_flow.rsindex a16dc2b16e..c99636581c 100644--- a/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs+++ b/crates/router/src/core/fraud_check/flows/fulfillment_flow.rs@@ -1,4 +1,4 @@-use common_utils::ext_traits::ValueExt;+use common_utils::ext_traits::{OptionExt, ValueExt};use error_stack::ResultExt;use router_env::tracing::{self, instrument};@@ -26,17 +26,13 @@ pub async fn construct_fulfillment_router_data<'a>(connector: String,fulfillment_request: FrmFulfillmentRequest,) -> RouterResult<FrmFulfillmentRouterData> {- let profile_id = core_utils::get_profile_id_from_business_details(- payment_intent.business_country,- payment_intent.business_label.as_ref(),- merchant_account,- payment_intent.profile_id.as_ref(),- &*state.store,- false,- )- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("profile_id is not set in payment_intent")?;+ let profile_id = payment_intent+ .profile_id+ .as_ref()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("profile_id is not set in payment_intent")?+ .clone();let merchant_connector_account = helpers::get_merchant_connector_account(state,diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rsindex b919541ade..17745517b6 100644--- a/crates/router/src/core/payment_methods/cards.rs+++ b/crates/router/src/core/payment_methods/cards.rs@@ -2335,16 +2335,12 @@ pub async fn list_payment_methods(let profile_id = payment_intent.as_ref().async_map(|payment_intent| async {- crate::core::utils::get_profile_id_from_business_details(- payment_intent.business_country,- payment_intent.business_label.as_ref(),- &merchant_account,- payment_intent.profile_id.as_ref(),- db,- false,- )- .await- .attach_printable("Could not find profile id from business details")+ payment_intent+ .profile_id+ .clone()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("profile_id is not set in payment_intent")}).await.transpose()?;@@ -2667,7 +2663,7 @@ pub async fn list_payment_methods(for inner_config in config.enabled_payment_methods.iter() {let is_active_mca = all_mcas.iter()- .any(|mca| mca.merchant_connector_id == inner_config.mca_id);+ .any(|mca| mca.get_id() == inner_config.mca_id);if inner_config.payment_method_type == *payment_method_type && is_active_mca{@@ -3738,16 +3734,12 @@ pub async fn list_customer_payment_method(let profile_id = payment_intent.as_ref().async_map(|payment_intent| async {- core_utils::get_profile_id_from_business_details(- payment_intent.business_country,- payment_intent.business_label.as_ref(),- &merchant_account,- payment_intent.profile_id.as_ref(),- db,- false,- )- .await- .attach_printable("Could not find profile id from business details")+ payment_intent+ .profile_id+ .clone()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("profile_id is not set in payment_intent")}).await.transpose()?;diff --git a/crates/router/src/core/payment_methods/validator.rs b/crates/router/src/core/payment_methods/validator.rsindex c45f6df837..d9ec794151 100644--- a/crates/router/src/core/payment_methods/validator.rs+++ b/crates/router/src/core/payment_methods/validator.rs@@ -1,5 +1,5 @@use api_models::{admin, payment_methods::PaymentMethodCollectLinkRequest};-use common_utils::{ext_traits::ValueExt, link_utils};+use common_utils::link_utils;use diesel_models::generic_link::PaymentMethodCollectLinkData;use error_stack::ResultExt;use masking::Secret;@@ -62,18 +62,28 @@ pub async fn validate_request_and_initiate_payment_method_collect_link(// Fetch all configslet default_config = &state.conf.generic_link.payment_method_collect;++ #[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+ ))]let merchant_config = merchant_account.pm_collect_link_config.as_ref().map(|config| {- config- .clone()- .parse_value::<admin::BusinessCollectLinkConfig>("BusinessCollectLinkConfig")+ common_utils::ext_traits::ValueExt::parse_value::<admin::BusinessCollectLinkConfig>(+ config.clone(),+ "BusinessCollectLinkConfig",+ )}).transpose().change_context(errors::ApiErrorResponse::InvalidDataValue {field_name: "pm_collect_link_config in merchant_account",})?;++ #[cfg(all(feature = "v2", feature = "merchant_account_v2"))]+ let merchant_config = Option::<admin::BusinessCollectLinkConfig>::None;+let merchant_ui_config = merchant_config.as_ref().map(|c| c.config.ui_config.clone());let ui_config = req.ui_configdiff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 78d0d8fd79..8d7266c499 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -1967,16 +1967,14 @@ where{connector_label} else {- let profile_id = utils::get_profile_id_from_business_details(- payment_data.payment_intent.business_country,- payment_data.payment_intent.business_label.as_ref(),- merchant_account,- payment_data.payment_intent.profile_id.as_ref(),- &*state.store,- false,- )- .await- .attach_printable("Could not find profile id from business details")?;+ let profile_id = payment_data+ .payment_intent+ .profile_id+ .as_ref()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("profile_id is not set in payment_intent")?+ .clone();format!("{connector_name}_{profile_id}")};@@ -2243,22 +2241,19 @@ pub async fn construct_profile_id_and_get_mca<'a, F>(connector_name: &str,merchant_connector_id: Option<&String>,key_store: &domain::MerchantKeyStore,- should_validate: bool,+ _should_validate: bool,) -> RouterResult<helpers::MerchantConnectorAccountType>whereF: Clone,{- let profile_id = utils::get_profile_id_from_business_details(- payment_data.payment_intent.business_country,- payment_data.payment_intent.business_label.as_ref(),- merchant_account,- payment_data.payment_intent.profile_id.as_ref(),- &*state.store,- should_validate,- )- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("profile_id is not set in payment_intent")?;+ let profile_id = payment_data+ .payment_intent+ .profile_id+ .as_ref()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("profile_id is not set in payment_intent")?+ .clone();let merchant_connector_account = helpers::get_merchant_connector_account(state,diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rsindex 53fc1e1938..9f661a8b0c 100644--- a/crates/router/src/core/payments/helpers.rs+++ b/crates/router/src/core/payments/helpers.rs@@ -2942,6 +2942,10 @@ pub async fn verify_payment_intent_time_and_client_secret(.transpose()}+#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]/// Check whether the business details are configured in the merchant accountpub fn validate_business_details(business_country: Option<api_enums::CountryAlpha2>,@@ -2974,41 +2978,6 @@ pub fn validate_business_details(Ok(())}-/// Do lazy parsing of primary business details-/// If both country and label are passed, no need to parse business details from merchant_account-/// If any one is missing, get it from merchant_account-/// If there is more than one label or country configured in merchant account, then-/// passing business details for payment is mandatory to avoid ambiguity-pub fn get_business_details(- business_country: Option<api_enums::CountryAlpha2>,- business_label: Option<&String>,- merchant_account: &domain::MerchantAccount,-) -> RouterResult<(api_enums::CountryAlpha2, String)> {- let primary_business_details = merchant_account- .primary_business_details- .clone()- .parse_value::<Vec<api_models::admin::PrimaryBusinessDetails>>("PrimaryBusinessDetails")- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("failed to parse primary business details")?;-- match business_country.zip(business_label) {- Some((business_country, business_label)) => {- Ok((business_country.to_owned(), business_label.to_owned()))- }- _ => match primary_business_details.first() {- Some(business_details) if primary_business_details.len() == 1 => Ok((- business_country.unwrap_or_else(|| business_details.country.to_owned()),- business_label- .map(ToString::to_string)- .unwrap_or_else(|| business_details.business.to_owned()),- )),- _ => Err(report!(errors::ApiErrorResponse::MissingRequiredField {- field_name: "business_country, business_label"- })),- },- }-}-#[inline]pub(crate) fn get_payment_id_from_client_secret(cs: &str) -> RouterResult<String> {let (payment_id, _) = csdiff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex 1723084d0f..94eddff25d 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -80,6 +80,10 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa.get_payment_intent_id().change_context(errors::ApiErrorResponse::PaymentNotFound)?;+ #[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+ ))]helpers::validate_business_details(request.business_country,request.business_label.as_ref(),@@ -87,6 +91,10 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa)?;// If profile id is not passed, get it from the business_country and business_label+ #[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+ ))]let profile_id = core_utils::get_profile_id_from_business_details(request.business_country,request.business_label.as_ref(),@@ -97,6 +105,15 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa).await?;+ // Profile id will be mandatory in v2 in the request / headers+ #[cfg(all(feature = "v2", feature = "merchant_account_v2"))]+ let profile_id = request+ .profile_id+ .clone()+ .get_required_value("profile_id")+ .attach_printable("Profile id is a mandatory parameter")?;++ // TODO: eliminate a redundant db call to fetch the business profile// Validate whether profile_id passed in request is valid and is linked to the merchantlet business_profile = if let Some(business_profile) =core_utils::validate_and_get_business_profile(db, Some(&profile_id), merchant_id)diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rsindex 5e384021e5..f061fc2f07 100644--- a/crates/router/src/core/payments/operations/payment_session.rs+++ b/crates/router/src/core/payments/operations/payment_session.rs@@ -368,16 +368,12 @@ where.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Database error when querying for merchant connector accounts")?;- let profile_id = crate::core::utils::get_profile_id_from_business_details(- payment_intent.business_country,- payment_intent.business_label.as_ref(),- merchant_account,- payment_intent.profile_id.as_ref(),- &*state.store,- false,- )- .await- .attach_printable("Could not find profile id from business details")?;+ let profile_id = payment_intent+ .profile_id+ .clone()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("profile_id is not set in payment_intent")?;let filtered_connector_accounts =helpers::filter_mca_based_on_business_profile(all_connector_accounts, Some(profile_id));diff --git a/crates/router/src/core/payouts/validator.rs b/crates/router/src/core/payouts/validator.rsindex f9a2939eb0..8dbdc73cea 100644--- a/crates/router/src/core/payouts/validator.rs+++ b/crates/router/src/core/payouts/validator.rs@@ -118,7 +118,10 @@ pub async fn validate_create_request(None => None,};- // Profile ID+ #[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+ ))]let profile_id = core_utils::get_profile_id_from_business_details(req.business_country,req.business_label.as_ref(),@@ -129,6 +132,16 @@ pub async fn validate_create_request().await?;+ #[cfg(all(feature = "v2", feature = "merchant_account_v2"))]+ // Profile id will be mandatory in v2 in the request / headers+ let profile_id = req+ .profile_id+ .clone()+ .ok_or(errors::ApiErrorResponse::MissingRequiredField {+ field_name: "profile_id",+ })+ .attach_printable("Profile id is a mandatory parameter")?;+Ok((payout_id, payout_method_data, profile_id))}diff --git a/crates/router/src/core/routing/helpers.rs b/crates/router/src/core/routing/helpers.rsindex f550c7e501..6444f6bc45 100644--- a/crates/router/src/core/routing/helpers.rs+++ b/crates/router/src/core/routing/helpers.rs@@ -119,6 +119,10 @@ pub async fn update_merchant_routing_dictionary(/// This will help make one of all configured algorithms to be in active state for a particular/// merchant+#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]pub async fn update_merchant_active_algorithm_ref(state: &SessionState,key_store: &domain::MerchantKeyStore,@@ -152,6 +156,7 @@ pub async fn update_merchant_active_algorithm_ref(payment_link_config: None,pm_collect_link_config: None,};+let db = &*state.store;db.update_specific_fields_in_merchant(&state.into(),@@ -170,7 +175,19 @@ pub async fn update_merchant_active_algorithm_ref(Ok(())}-// TODO: Move it to business_profile++#[cfg(all(any(feature = "v1", feature = "v2"), feature = "merchant_account_v2"))]+#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]+pub async fn update_merchant_active_algorithm_ref(+ _state: &SessionState,+ _key_store: &domain::MerchantKeyStore,+ _config_key: cache::CacheKind<'_>,+ _algorithm_id: routing_types::RoutingAlgorithmRef,+) -> RouterResult<()> {+ // TODO: handle updating the active routing algorithm for v2 in merchant account+ Ok(())+}+pub async fn update_business_profile_active_algorithm_ref(db: &dyn StorageInterface,current_business_profile: BusinessProfile,diff --git a/crates/router/src/core/utils.rs b/crates/router/src/core/utils.rsindex f25e13161a..1500721cc7 100644--- a/crates/router/src/core/utils.rs+++ b/crates/router/src/core/utils.rs@@ -229,24 +229,19 @@ pub async fn construct_refund_router_data<'a, F>(creds_identifier: Option<String>,charges: Option<types::ChargeRefunds>,) -> RouterResult<types::RefundsRouterData<F>> {- let profile_id = get_profile_id_from_business_details(- payment_intent.business_country,- payment_intent.business_label.as_ref(),- merchant_account,- payment_intent.profile_id.as_ref(),- &*state.store,- false,- )- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("profile_id is not set in payment_intent")?;+ let profile_id = payment_intent+ .profile_id+ .as_ref()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("profile_id is not set in payment_intent")?;let merchant_connector_account = helpers::get_merchant_connector_account(state,merchant_account.get_id(),creds_identifier,key_store,- &profile_id,+ profile_id,connector_id,payment_attempt.merchant_connector_id.as_ref(),)@@ -524,17 +519,13 @@ pub async fn construct_accept_dispute_router_data<'a>(key_store: &domain::MerchantKeyStore,dispute: &storage::Dispute,) -> RouterResult<types::AcceptDisputeRouterData> {- let profile_id = get_profile_id_from_business_details(- payment_intent.business_country,- payment_intent.business_label.as_ref(),- merchant_account,- payment_intent.profile_id.as_ref(),- &*state.store,- false,- )- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("profile_id is not set in payment_intent")?;+ let profile_id = payment_intent+ .profile_id+ .as_ref()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("profile_id is not set in payment_intent")?+ .clone();let merchant_connector_account = helpers::get_merchant_connector_account(state,@@ -623,17 +614,13 @@ pub async fn construct_submit_evidence_router_data<'a>(submit_evidence_request_data: types::SubmitEvidenceRequestData,) -> RouterResult<types::SubmitEvidenceRouterData> {let connector_id = &dispute.connector;- let profile_id = get_profile_id_from_business_details(- payment_intent.business_country,- payment_intent.business_label.as_ref(),- merchant_account,- payment_intent.profile_id.as_ref(),- &*state.store,- false,- )- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("profile_id is not set in payment_intent")?;+ let profile_id = payment_intent+ .profile_id+ .as_ref()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("profile_id is not set in payment_intent")?+ .clone();let merchant_connector_account = helpers::get_merchant_connector_account(state,@@ -720,17 +707,13 @@ pub async fn construct_upload_file_router_data<'a>(connector_id: &str,file_key: String,) -> RouterResult<types::UploadFileRouterData> {- let profile_id = get_profile_id_from_business_details(- payment_intent.business_country,- payment_intent.business_label.as_ref(),- merchant_account,- payment_intent.profile_id.as_ref(),- &*state.store,- false,- )- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("profile_id is not set in payment_intent")?;+ let profile_id = payment_intent+ .profile_id+ .as_ref()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("profile_id is not set in payment_intent")?+ .clone();let merchant_connector_account = helpers::get_merchant_connector_account(state,@@ -821,17 +804,13 @@ pub async fn construct_defend_dispute_router_data<'a>() -> RouterResult<types::DefendDisputeRouterData> {let _db = &*state.store;let connector_id = &dispute.connector;- let profile_id = get_profile_id_from_business_details(- payment_intent.business_country,- payment_intent.business_label.as_ref(),- merchant_account,- payment_intent.profile_id.as_ref(),- &*state.store,- false,- )- .await- .change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("profile_id is not set in payment_intent")?;+ let profile_id = payment_intent+ .profile_id+ .as_ref()+ .get_required_value("profile_id")+ .change_context(errors::ApiErrorResponse::InternalServerError)+ .attach_printable("profile_id is not set in payment_intent")?+ .clone();let merchant_connector_account = helpers::get_merchant_connector_account(state,@@ -1090,6 +1069,10 @@ pub fn get_connector_label(})}+#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]/// If profile_id is not passed, use default profile if available, or/// If business_details (business_country and business_label) are passed, get the business_profile/// or return a `MissingRequiredField` errordiff --git a/crates/router/src/db/merchant_account.rs b/crates/router/src/db/merchant_account.rsindex 2e43d46981..5a828ebb0c 100644--- a/crates/router/src/db/merchant_account.rs+++ b/crates/router/src/db/merchant_account.rs@@ -580,6 +580,10 @@ async fn publish_and_redact_merchant_account_cache(.as_ref().map(|publishable_key| CacheKind::Accounts(publishable_key.into()));+ #[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+ ))]let cgraph_key = merchant_account.default_profile.as_ref().map(|profile_id| {CacheKind::CGraph(format!(@@ -591,6 +595,10 @@ async fn publish_and_redact_merchant_account_cache()});+ // TODO: we will not have default profile in v2+ #[cfg(all(feature = "v2", feature = "merchant_account_v2"))]+ let cgraph_key = None;+let mut cache_keys = vec![CacheKind::Accounts(merchant_account.get_id().get_string_repr().into(),)];diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rsindex 0b42c71944..045a455ebb 100644--- a/crates/router/src/routes/app.rs+++ b/crates/router/src/routes/app.rs@@ -1097,6 +1097,11 @@ impl MerchantAccount {web::scope("/v2/accounts").app_data(web::Data::new(state)).service(web::resource("").route(web::post().to(merchant_account_create)))+ .service(+ web::resource("/{id}")+ .route(web::get().to(retrieve_merchant_account))+ .route(web::post().to(update_merchant_account)),+ )}}diff --git a/crates/router/src/types/api/admin.rs b/crates/router/src/types/api/admin.rsindex acbca54f4b..683bbd895c 100644--- a/crates/router/src/types/api/admin.rs+++ b/crates/router/src/types/api/admin.rs@@ -11,19 +11,16 @@ pub use api_models::{},organization::{OrganizationId, OrganizationRequest, OrganizationResponse},};-use common_utils::{- ext_traits::{AsyncExt, Encode, ValueExt},- types::keymanager::Identifier,-};+use common_utils::{ext_traits::ValueExt, types::keymanager::Identifier};use diesel_models::organization::OrganizationBridge;-use error_stack::{report, ResultExt};+use error_stack::ResultExt;use hyperswitch_domain_models::{merchant_key_store::MerchantKeyStore, type_encryption::decrypt_optional,};use masking::{ExposeInterface, PeekInterface, Secret};use crate::{- core::{errors, payment_methods::cards::create_encrypted_data},+ core::errors,routes::SessionState,types::{domain, storage, transformers::ForeignTryFrom, ForeignFrom},};@@ -106,7 +103,6 @@ impl ForeignTryFrom<domain::MerchantAccount> for MerchantAccountResponse {publishable_key: item.publishable_key,metadata: item.metadata,organization_id: item.organization_id,- is_recon_enabled: item.is_recon_enabled,recon_status: item.recon_status,})}@@ -179,7 +175,23 @@ pub async fn business_profile_response(})}-#[cfg(any(feature = "v1", feature = "v2"))]+#[cfg(all(feature = "v2", feature = "merchant_account_v2"))]++pub async fn create_business_profile(+ _state: &SessionState,+ _request: BusinessProfileCreate,+ _key_store: &MerchantKeyStore,+) -> Result<+ storage::business_profile::BusinessProfileNew,+ error_stack::Report<errors::ApiErrorResponse>,+> {+ todo!()+}++#[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+))]pub async fn create_business_profile(state: &SessionState,merchant_account: domain::MerchantAccount,@@ -189,6 +201,10 @@ pub async fn create_business_profile(storage::business_profile::BusinessProfileNew,error_stack::Report<errors::ApiErrorResponse>,> {+ use common_utils::ext_traits::{AsyncExt, Encode};++ use crate::core;+// Generate a unique profile idlet profile_id = common_utils::generate_id_with_default_len("pro");let merchant_id = merchant_account.get_id().to_owned();@@ -224,7 +240,9 @@ pub async fn create_business_profile(.transpose()?;let outgoing_webhook_custom_http_headers = request.outgoing_webhook_custom_http_headers- .async_map(|headers| create_encrypted_data(state, key_store, headers))+ .async_map(|headers| {+ core::payment_methods::cards::create_encrypted_data(state, key_store, headers)+ }).await.transpose().change_context(errors::ApiErrorResponse::InternalServerError)@@ -239,9 +257,11 @@ pub async fn create_business_profile(field_name: "payout_link_config",},),- Err(e) => Err(report!(errors::ApiErrorResponse::InvalidRequestData {- message: e.to_string()- })),+ Err(e) => Err(error_stack::report!(+ errors::ApiErrorResponse::InvalidRequestData {+ message: e.to_string()+ }+ )),}).transpose()?;diff --git a/crates/router/src/utils.rs b/crates/router/src/utils.rsindex 1e8761d137..6fad1e2195 100644--- a/crates/router/src/utils.rs+++ b/crates/router/src/utils.rs@@ -51,7 +51,7 @@ use crate::{core::{authentication::types::ExternalThreeDSConnectorMetadata,errors::{self, CustomResult, RouterResult, StorageErrorExt},- utils, webhooks as webhooks_core,+ webhooks as webhooks_core,},logger,routes::{metrics, SessionState},@@ -441,20 +441,14 @@ pub async fn get_mca_from_payment_intent(}}None => {- let profile_id = match payment_intent.profile_id {- Some(profile_id) => profile_id,- None => utils::get_profile_id_from_business_details(- payment_intent.business_country,- payment_intent.business_label.as_ref(),- merchant_account,- payment_intent.profile_id.as_ref(),- db,- false,- )- .await+ let profile_id = payment_intent+ .profile_id+ .as_ref()+ .get_required_value("profile_id").change_context(errors::ApiErrorResponse::InternalServerError)- .attach_printable("profile_id is not set in payment_intent")?,- };+ .attach_printable("profile_id is not set in payment_intent")?+ .clone();+#[cfg(all(any(feature = "v1", feature = "v2"),not(feature = "merchant_connector_account_v2")@@ -579,7 +573,17 @@ pub async fn get_mca_from_object_reference_id(key_store: &domain::MerchantKeyStore,) -> CustomResult<domain::MerchantConnectorAccount, errors::ApiErrorResponse> {let db = &*state.store;- match merchant_account.default_profile.as_ref() {++ #[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+ ))]+ let default_profile_id = merchant_account.default_profile.as_ref();++ #[cfg(all(feature = "v2", feature = "merchant_account_v2"))]+ let default_profile_id = Option::<&String>::None;++ match default_profile_id {Some(profile_id) => {#[cfg(all(any(feature = "v1", feature = "v2"),@@ -601,8 +605,8 @@ pub async fn get_mca_from_object_reference_id(}#[cfg(all(feature = "v2", feature = "merchant_connector_account_v2"))]{- let _ = db;- let _ = profile_id;+ let _db = db;+ let _profile_id = profile_id;todo!()}}diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rsindex 86607234d4..303f02acc6 100644--- a/crates/router/src/utils/user/sample_data.rs+++ b/crates/router/src/utils/user/sample_data.rs@@ -43,25 +43,44 @@ pub async fn generate_sample_data(.await.change_context::<SampleDataError>(SampleDataError::DataDoesNotExist)?;- let merchant_parsed_details: Vec<api_models::admin::PrimaryBusinessDetails> =- serde_json::from_value(merchant_from_db.primary_business_details.clone())- .change_context(SampleDataError::InternalServerError)- .attach_printable("Error while parsing primary business details")?;-- let business_country_default = merchant_parsed_details.first().map(|x| x.country);-- let business_label_default = merchant_parsed_details.first().map(|x| x.business.clone());-- let profile_id = match crate::core::utils::get_profile_id_from_business_details(- business_country_default,- business_label_default.as_ref(),- &merchant_from_db,- req.profile_id.as_ref(),- &*state.store,- false,- )- .await- {+ #[cfg(all(+ any(feature = "v1", feature = "v2"),+ not(feature = "merchant_account_v2")+ ))]+ let (profile_id_result, business_country_default, business_label_default) = {+ let merchant_parsed_details: Vec<api_models::admin::PrimaryBusinessDetails> =+ serde_json::from_value(merchant_from_db.primary_business_details.clone())+ .change_context(SampleDataError::InternalServerError)+ .attach_printable("Error while parsing primary business details")?;++ let business_country_default = merchant_parsed_details.first().map(|x| x.country);++ let business_label_default = merchant_parsed_details.first().map(|x| x.business.clone());++ let profile_id = crate::core::utils::get_profile_id_from_business_details(+ business_country_default,+ business_label_default.as_ref(),+ &merchant_from_db,+ req.profile_id.as_ref(),+ &*state.store,+ false,+ )+ .await;+ (profile_id, business_country_default, business_label_default)+ };++ #[cfg(all(feature = "v2", feature = "merchant_account_v2"))]+ let (profile_id_result, business_country_default, business_label_default) = {+ let profile_id = req+ .profile_id.clone()+ .ok_or(hyperswitch_domain_models::errors::api_error_response::ApiErrorResponse::MissingRequiredField {+ field_name: "profile_id",+ });++ (profile_id, None, None)+ };++ let profile_id = match profile_id_result {Ok(id) => id.clone(),Err(error) => {router_env::logger::error!(diff --git a/justfile b/justfileindex 1823c1ec19..00a6187f41 100644--- a/justfile+++ b/justfile@@ -55,12 +55,12 @@ check_v2 *FLAGS:jq -r '[ ( .workspace_members | sort ) as $package_ids # Store workspace crate package IDs in `package_ids` array| .packages[] | select( IN(.id; $package_ids[]) ) | .features | keys[] ] | unique # Select all unique features from all workspace crates- | del( .[] | select( any( . ; . == ("v1", "merchant_account_v2", "payment_v2","routing_v2") ) ) ) # Exclude some features from features list+ | del( .[] | select( any( . ; . == ("v1") ) ) ) # Exclude some features from features list| join(",") # Construct a comma-separated string of features for passing to `cargo`')"set -x- cargo clippy {{ check_flags }} --features "${FEATURES}" {{ FLAGS }}+ cargo check {{ check_flags }} --features "${FEATURES}" {{ FLAGS }}set +xcheck *FLAGS:@@ -76,7 +76,7 @@ check *FLAGS:')"set -x- cargo clippy {{ check_flags }} --features "${FEATURES}" {{ FLAGS }}+ cargo check {{ check_flags }} --features "${FEATURES}" {{ FLAGS }}set +xalias cl := clippydiff --git a/v2_migrations/2024-07-26-065428_remove_deprecated_field_from_merchant_account/down.sql b/v2_migrations/2024-07-26-065428_remove_deprecated_field_from_merchant_account/down.sqlnew file mode 100644index 0000000000..60e6c17b08--- /dev/null+++ b/v2_migrations/2024-07-26-065428_remove_deprecated_field_from_merchant_account/down.sql@@ -0,0 +1,46 @@+-- This file should undo anything in `up.sql`+ALTER TABLE merchant_account+ADD COLUMN return_url VARCHAR(255);++ALTER TABLE merchant_account+ADD COLUMN enable_payment_response_hash BOOLEAN DEFAULT FALSE;++ALTER TABLE merchant_account+ADD COLUMN payment_response_hash_key VARCHAR(255);++ALTER TABLE merchant_account+ADD COLUMN redirect_to_merchant_with_http_post BOOLEAN DEFAULT FALSE;++ALTER TABLE merchant_account+ADD COLUMN sub_merchants_enabled BOOLEAN DEFAULT FALSE;++ALTER TABLE merchant_account+ADD COLUMN parent_merchant_id VARCHAR(64);++-- The default value is for temporary purpose only+ALTER TABLE merchant_account+ADD COLUMN primary_business_details JSON NOT NULL DEFAULT '[{"country": "US", "business": "default"}]';++ALTER TABLE merchant_account+ALTER COLUMN primary_business_details DROP DEFAULT;++ALTER TABLE merchant_account+ADD COLUMN locker_id VARCHAR(64);++ALTER TABLE merchant_account+ADD COLUMN intent_fulfillment_time BIGINT;++ALTER TABLE merchant_account+ADD COLUMN default_profile VARCHAR(64);++ALTER TABLE merchant_account+ADD COLUMN payment_link_config JSONB NULL;++ALTER TABLE merchant_account+ADD COLUMN pm_collect_link_config JSONB NULL;++ALTER TABLE merchant_account+ADD COLUMN is_recon_enabled BOOLEAN NOT NULL DEFAULT FALSE;++ALTER TABLE merchant_account+ADD COLUMN webhook_details JSONB NULL;diff --git a/v2_migrations/2024-07-26-065428_remove_deprecated_field_from_merchant_account/up.sql b/v2_migrations/2024-07-26-065428_remove_deprecated_field_from_merchant_account/up.sqlnew file mode 100644index 0000000000..e9a349e613--- /dev/null+++ b/v2_migrations/2024-07-26-065428_remove_deprecated_field_from_merchant_account/up.sql@@ -0,0 +1,28 @@+-- Your SQL goes here+ALTER TABLE merchant_account DROP COLUMN return_url;++ALTER TABLE merchant_account DROP enable_payment_response_hash;++ALTER TABLE merchant_account DROP payment_response_hash_key;++ALTER TABLE merchant_account DROP redirect_to_merchant_with_http_post;++ALTER TABLE merchant_account DROP sub_merchants_enabled;++ALTER TABLE merchant_account DROP parent_merchant_id;++ALTER TABLE merchant_account DROP primary_business_details;++ALTER TABLE merchant_account DROP locker_id;++ALTER TABLE merchant_account DROP intent_fulfillment_time;++ALTER TABLE merchant_account DROP default_profile;++ALTER TABLE merchant_account DROP payment_link_config;++ALTER TABLE merchant_account DROP pm_collect_link_config;++ALTER TABLE merchant_account DROP is_recon_enabled;++ALTER TABLE merchant_account DROP webhook_details;