From abfdea20b06a8804ec83fe9431f9a034465bb924 Mon Sep 17 00:00:00 2001 From: Sarthak Soni <76486416+Sarthak1799@users.noreply.github.com> Date: Tue, 3 Oct 2023 13:07:43 +0530 Subject: [PATCH] feat(pm_auth): Added pm_auth_config to merchant_connector_account (#2183) Co-authored-by: Sarthak Soni --- crates/api_models/src/admin.rs | 6 ++++++ crates/common_enums/src/enums.rs | 2 ++ .../diesel_models/src/merchant_connector_account.rs | 4 ++++ crates/diesel_models/src/schema.rs | 1 + crates/router/src/core/admin.rs | 2 ++ crates/router/src/core/verification/utils.rs | 1 + crates/router/src/db/merchant_connector_account.rs | 2 ++ .../src/types/domain/merchant_connector_account.rs | 7 +++++++ crates/router/src/types/transformers.rs | 1 + .../down.sql | 2 ++ .../2023-09-18-104900_add_pm_auth_config_mca/up.sql | 3 +++ openapi/openapi_spec.json | 12 +++++++++++- 12 files changed, 42 insertions(+), 1 deletion(-) create mode 100644 migrations/2023-09-18-104900_add_pm_auth_config_mca/down.sql create mode 100644 migrations/2023-09-18-104900_add_pm_auth_config_mca/up.sql diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs index 94d7c5b4a8bc..a1b13c5ff315 100644 --- a/crates/api_models/src/admin.rs +++ b/crates/api_models/src/admin.rs @@ -633,6 +633,8 @@ pub struct MerchantConnectorCreate { pub connector_webhook_details: Option, /// Identifier for the business profile, if not provided default will be chosen from merchant account pub profile_id: Option, + + pub pm_auth_config: Option, } #[derive(Debug, Clone, Serialize, Deserialize, ToSchema)] @@ -736,6 +738,8 @@ pub struct MerchantConnectorResponse { pub profile_id: Option, /// identifier for the verified domains of a particular connector account pub applepay_verified_domains: Option>, + + pub pm_auth_config: Option, } /// Create a new Merchant Connector for the merchant account. The connector could be a payment processor / facilitator / acquirer or specialized services like Fraud / Accounting etc." @@ -805,6 +809,8 @@ pub struct MerchantConnectorUpdate { } }))] pub connector_webhook_details: Option, + + pub pm_auth_config: Option, } ///Details of FrmConfigs are mentioned here... it should be passed in payment connector create api call, and stored in merchant_connector_table diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 779a4f05dd73..c693ea57fc58 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -208,6 +208,8 @@ pub enum ConnectorType { NonBankingFinance, /// Acquirers, Gateways etc PayoutProcessor, + /// PaymentMethods Auth Services + PaymentMethodAuth, } #[allow(clippy::upper_case_acronyms)] diff --git a/crates/diesel_models/src/merchant_connector_account.rs b/crates/diesel_models/src/merchant_connector_account.rs index cd5b66f523a0..ce2684c937ab 100644 --- a/crates/diesel_models/src/merchant_connector_account.rs +++ b/crates/diesel_models/src/merchant_connector_account.rs @@ -41,6 +41,7 @@ pub struct MerchantConnectorAccount { pub profile_id: Option, #[diesel(deserialize_as = super::OptionalDieselArray)] pub applepay_verified_domains: Option>, + pub pm_auth_config: Option, } #[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)] @@ -68,6 +69,7 @@ pub struct MerchantConnectorAccountNew { pub profile_id: Option, #[diesel(deserialize_as = super::OptionalDieselArray)] pub applepay_verified_domains: Option>, + pub pm_auth_config: Option, } #[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)] @@ -89,6 +91,7 @@ pub struct MerchantConnectorAccountUpdateInternal { pub frm_config: Option>>, #[diesel(deserialize_as = super::OptionalDieselArray)] pub applepay_verified_domains: Option>, + pub pm_auth_config: Option, } impl MerchantConnectorAccountUpdateInternal { @@ -110,6 +113,7 @@ impl MerchantConnectorAccountUpdateInternal { payment_methods_enabled: self.payment_methods_enabled, frm_config: self.frm_config, modified_at: self.modified_at.unwrap_or(source.modified_at), + pm_auth_config: self.pm_auth_config, ..source } diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs index 8d84475ddd45..3a6e2cd2a936 100644 --- a/crates/diesel_models/src/schema.rs +++ b/crates/diesel_models/src/schema.rs @@ -476,6 +476,7 @@ diesel::table! { #[max_length = 64] profile_id -> Nullable, applepay_verified_domains -> Nullable>>, + pm_auth_config -> Nullable, } } diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs index a6847968c286..fab416c431ba 100644 --- a/crates/router/src/core/admin.rs +++ b/crates/router/src/core/admin.rs @@ -682,6 +682,7 @@ pub async fn create_payment_connector( }, profile_id: Some(profile_id.clone()), applepay_verified_domains: None, + pm_auth_config: req.pm_auth_config.clone(), }; let mca = state @@ -847,6 +848,7 @@ pub async fn update_payment_connector( None => None, }, applepay_verified_domains: None, + pm_auth_config: req.pm_auth_config, }; let updated_mca = db diff --git a/crates/router/src/core/verification/utils.rs b/crates/router/src/core/verification/utils.rs index 36bf4b7d7167..056cc8c2e54f 100644 --- a/crates/router/src/core/verification/utils.rs +++ b/crates/router/src/core/verification/utils.rs @@ -58,6 +58,7 @@ pub async fn check_existence_and_add_domain_to_db( frm_configs: None, connector_webhook_details: None, applepay_verified_domains: Some(already_verified_domains.clone()), + pm_auth_config: None, }; state .store diff --git a/crates/router/src/db/merchant_connector_account.rs b/crates/router/src/db/merchant_connector_account.rs index e6377ea265bc..491e5b788103 100644 --- a/crates/router/src/db/merchant_connector_account.rs +++ b/crates/router/src/db/merchant_connector_account.rs @@ -650,6 +650,7 @@ impl MerchantConnectorAccountInterface for MockDb { connector_webhook_details: t.connector_webhook_details, profile_id: t.profile_id, applepay_verified_domains: t.applepay_verified_domains, + pm_auth_config: t.pm_auth_config, }; accounts.push(account.clone()); account @@ -845,6 +846,7 @@ mod merchant_connector_account_cache_tests { connector_webhook_details: None, profile_id: Some(profile_id.to_string()), applepay_verified_domains: None, + pm_auth_config: None, }; db.insert_merchant_connector_account(mca.clone(), &merchant_key) diff --git a/crates/router/src/types/domain/merchant_connector_account.rs b/crates/router/src/types/domain/merchant_connector_account.rs index 7c23890345de..a8dce1e6f078 100644 --- a/crates/router/src/types/domain/merchant_connector_account.rs +++ b/crates/router/src/types/domain/merchant_connector_account.rs @@ -34,6 +34,7 @@ pub struct MerchantConnectorAccount { pub connector_webhook_details: Option, pub profile_id: Option, pub applepay_verified_domains: Option>, + pub pm_auth_config: Option, } #[derive(Debug)] @@ -51,6 +52,7 @@ pub enum MerchantConnectorAccountUpdate { frm_configs: Option>>, connector_webhook_details: Option, applepay_verified_domains: Option>, + pm_auth_config: Option, }, } @@ -85,6 +87,7 @@ impl behaviour::Conversion for MerchantConnectorAccount { connector_webhook_details: self.connector_webhook_details, profile_id: self.profile_id, applepay_verified_domains: self.applepay_verified_domains, + pm_auth_config: self.pm_auth_config, }, ) } @@ -123,6 +126,7 @@ impl behaviour::Conversion for MerchantConnectorAccount { connector_webhook_details: other.connector_webhook_details, profile_id: other.profile_id, applepay_verified_domains: other.applepay_verified_domains, + pm_auth_config: other.pm_auth_config, }) } @@ -149,6 +153,7 @@ impl behaviour::Conversion for MerchantConnectorAccount { connector_webhook_details: self.connector_webhook_details, profile_id: self.profile_id, applepay_verified_domains: self.applepay_verified_domains, + pm_auth_config: self.pm_auth_config, }) } } @@ -169,6 +174,7 @@ impl From for MerchantConnectorAccountUpdateInte frm_configs, connector_webhook_details, applepay_verified_domains, + pm_auth_config, } => Self { merchant_id, connector_type, @@ -184,6 +190,7 @@ impl From for MerchantConnectorAccountUpdateInte modified_at: Some(common_utils::date_time::now()), connector_webhook_details, applepay_verified_domains, + pm_auth_config, }, } } diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index 5bdb63814e84..f114bf38b62e 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -668,6 +668,7 @@ impl TryFrom for api_models::admin::MerchantCo .transpose()?, profile_id: item.profile_id, applepay_verified_domains: item.applepay_verified_domains, + pm_auth_config: item.pm_auth_config, }) } } diff --git a/migrations/2023-09-18-104900_add_pm_auth_config_mca/down.sql b/migrations/2023-09-18-104900_add_pm_auth_config_mca/down.sql new file mode 100644 index 000000000000..d4fc2b581edf --- /dev/null +++ b/migrations/2023-09-18-104900_add_pm_auth_config_mca/down.sql @@ -0,0 +1,2 @@ +-- This file should undo anything in `up.sql` +ALTER TABLE merchant_connector_account DROP COLUMN IF EXISTS pm_auth_config; \ No newline at end of file diff --git a/migrations/2023-09-18-104900_add_pm_auth_config_mca/up.sql b/migrations/2023-09-18-104900_add_pm_auth_config_mca/up.sql new file mode 100644 index 000000000000..15cdafdbaccf --- /dev/null +++ b/migrations/2023-09-18-104900_add_pm_auth_config_mca/up.sql @@ -0,0 +1,3 @@ +-- Your SQL goes here +ALTER TABLE merchant_connector_account ADD COLUMN IF NOT EXISTS pm_auth_config JSONB DEFAULT NULL; +ALTER TYPE "ConnectorType" ADD VALUE 'payment_method_auth'; \ No newline at end of file diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index 2bce9585fdf4..1d943117c8e9 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -3922,7 +3922,8 @@ "networks", "banking_entities", "non_banking_finance", - "payout_processor" + "payout_processor", + "payment_method_auth" ] }, "CountryAlpha2": { @@ -6522,6 +6523,9 @@ "type": "string", "description": "Identifier for the business profile, if not provided default will be chosen from merchant account", "nullable": true + }, + "pm_auth_config": { + "nullable": true } } }, @@ -6746,6 +6750,9 @@ }, "description": "identifier for the verified domains of a particular connector account", "nullable": true + }, + "pm_auth_config": { + "nullable": true } } }, @@ -6843,6 +6850,9 @@ } ], "nullable": true + }, + "pm_auth_config": { + "nullable": true } } },