From 945fae2ee8fed0e3aeecee57689001acb748b68a Mon Sep 17 00:00:00 2001 From: Sarthak Soni Date: Wed, 13 Sep 2023 16:14:54 +0530 Subject: [PATCH 01/12] feat(mca): Updated mca schema to accomodate for pm_auth_config --- crates/api_models/src/admin.rs | 6 ++++++ crates/api_models/src/enums.rs | 1 + crates/common_enums/src/enums.rs | 2 ++ crates/diesel_models/src/merchant_connector_account.rs | 4 ++++ crates/diesel_models/src/schema.rs | 1 + crates/router/src/core/admin.rs | 4 ++++ crates/router/src/db/merchant_connector_account.rs | 2 ++ crates/router/src/types/api.rs | 5 +++++ .../router/src/types/domain/merchant_connector_account.rs | 7 +++++++ crates/router/src/types/transformers.rs | 1 + .../2023-09-12-132509_add_pm_auth_config_mca/down.sql | 2 ++ migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql | 2 ++ 12 files changed, 37 insertions(+) create mode 100644 migrations/2023-09-12-132509_add_pm_auth_config_mca/down.sql create mode 100644 migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs index d0b27e53f414..5e8833ac2101 100644 --- a/crates/api_models/src/admin.rs +++ b/crates/api_models/src/admin.rs @@ -634,6 +634,8 @@ pub struct MerchantConnectorCreate { /// 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)] @@ -735,6 +737,8 @@ pub struct MerchantConnectorResponse { /// default value from merchant account is taken if not passed #[schema(max_length = 64)] pub profile_id: 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." @@ -804,6 +808,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/api_models/src/enums.rs b/crates/api_models/src/enums.rs index 21725d99a96d..f63965a6a06a 100644 --- a/crates/api_models/src/enums.rs +++ b/crates/api_models/src/enums.rs @@ -119,6 +119,7 @@ pub enum Connector { Worldpay, Zen, Signifyd, + Plaid, } impl Connector { diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 27b43844f0b4..756767fd5fed 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 5ccfea2bb03e..86f0c5ec4e81 100644 --- a/crates/diesel_models/src/merchant_connector_account.rs +++ b/crates/diesel_models/src/merchant_connector_account.rs @@ -39,6 +39,7 @@ pub struct MerchantConnectorAccount { #[diesel(deserialize_as = super::OptionalDieselArray)] pub frm_config: Option>>, pub profile_id: Option, + pub pm_auth_config: Option, } #[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)] @@ -64,6 +65,7 @@ pub struct MerchantConnectorAccountNew { #[diesel(deserialize_as = super::OptionalDieselArray)] pub frm_config: Option>>, pub profile_id: Option, + pub pm_auth_config: Option, } #[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)] @@ -83,6 +85,7 @@ pub struct MerchantConnectorAccountUpdateInternal { pub connector_webhook_details: Option, #[diesel(deserialize_as = super::OptionalDieselArray)] pub frm_config: Option>>, + pub pm_auth_config: Option, } impl MerchantConnectorAccountUpdateInternal { @@ -104,6 +107,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 2237f466c15c..832f468c2b87 100644 --- a/crates/diesel_models/src/schema.rs +++ b/crates/diesel_models/src/schema.rs @@ -471,6 +471,7 @@ diesel::table! { frm_config -> Nullable>>, #[max_length = 64] profile_id -> Nullable, + pm_auth_config -> Nullable, } } diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs index 7a3a6055f74c..f4179c5873b6 100644 --- a/crates/router/src/core/admin.rs +++ b/crates/router/src/core/admin.rs @@ -669,6 +669,7 @@ pub async fn create_payment_connector( None => None, }, profile_id: Some(profile_id.clone()), + pm_auth_config: req.pm_auth_config.clone(), }; let mca = store @@ -829,6 +830,7 @@ pub async fn update_payment_connector( } None => None, }, + pm_auth_config: req.pm_auth_config, }; let updated_mca = db @@ -1377,5 +1379,7 @@ pub(crate) fn validate_auth_type( Err(report!(errors::ConnectorError::InvalidConnectorName) .attach_printable(format!("invalid connector name: {connector_name}"))) } + api_enums::Connector::Plaid => Err(report!(errors::ConnectorError::InvalidConnectorName) + .attach_printable(format!("invalid connector name: {connector_name}"))), } } diff --git a/crates/router/src/db/merchant_connector_account.rs b/crates/router/src/db/merchant_connector_account.rs index 954dead0269a..88a8da38728d 100644 --- a/crates/router/src/db/merchant_connector_account.rs +++ b/crates/router/src/db/merchant_connector_account.rs @@ -649,6 +649,7 @@ impl MerchantConnectorAccountInterface for MockDb { modified_at: common_utils::date_time::now(), connector_webhook_details: t.connector_webhook_details, profile_id: t.profile_id, + pm_auth_config: t.pm_auth_config, }; accounts.push(account.clone()); account @@ -843,6 +844,7 @@ mod merchant_connector_account_cache_tests { modified_at: date_time::now(), connector_webhook_details: None, profile_id: Some(profile_id.to_string()), + pm_auth_config: None, }; db.insert_merchant_connector_account(mca.clone(), &merchant_key) diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index 23c9f850dab9..4768c0c75200 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -336,6 +336,11 @@ impl ConnectorData { .attach_printable(format!("invalid connector name: {connector_name}"))) .change_context(errors::ApiErrorResponse::InternalServerError) } + enums::Connector::Plaid => { + Err(report!(errors::ConnectorError::InvalidConnectorName) + .attach_printable(format!("invalid connector name: {connector_name}"))) + .change_context(errors::ApiErrorResponse::InternalServerError) + } }, Err(_) => Err(report!(errors::ConnectorError::InvalidConnectorName) .attach_printable(format!("invalid connector name: {connector_name}"))) diff --git a/crates/router/src/types/domain/merchant_connector_account.rs b/crates/router/src/types/domain/merchant_connector_account.rs index 8be60f6cb240..bf285bec7100 100644 --- a/crates/router/src/types/domain/merchant_connector_account.rs +++ b/crates/router/src/types/domain/merchant_connector_account.rs @@ -33,6 +33,7 @@ pub struct MerchantConnectorAccount { pub modified_at: time::PrimitiveDateTime, pub connector_webhook_details: Option, pub profile_id: Option, + pub pm_auth_config: Option, } #[derive(Debug)] @@ -49,6 +50,7 @@ pub enum MerchantConnectorAccountUpdate { metadata: Option, frm_configs: Option>>, connector_webhook_details: Option, + pm_auth_config: Option, }, } @@ -82,6 +84,7 @@ impl behaviour::Conversion for MerchantConnectorAccount { modified_at: self.modified_at, connector_webhook_details: self.connector_webhook_details, profile_id: self.profile_id, + pm_auth_config: self.pm_auth_config, }, ) } @@ -119,6 +122,7 @@ impl behaviour::Conversion for MerchantConnectorAccount { modified_at: other.modified_at, connector_webhook_details: other.connector_webhook_details, profile_id: other.profile_id, + pm_auth_config: other.pm_auth_config, }) } @@ -144,6 +148,7 @@ impl behaviour::Conversion for MerchantConnectorAccount { modified_at: now, connector_webhook_details: self.connector_webhook_details, profile_id: self.profile_id, + pm_auth_config: self.pm_auth_config, }) } } @@ -163,6 +168,7 @@ impl From for MerchantConnectorAccountUpdateInte metadata, frm_configs, connector_webhook_details, + pm_auth_config, } => Self { merchant_id, connector_type, @@ -177,6 +183,7 @@ impl From for MerchantConnectorAccountUpdateInte frm_config: frm_configs, modified_at: Some(common_utils::date_time::now()), connector_webhook_details, + pm_auth_config, }, } } diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs index 9a0e0a385e2e..e414956e37d1 100644 --- a/crates/router/src/types/transformers.rs +++ b/crates/router/src/types/transformers.rs @@ -667,6 +667,7 @@ impl TryFrom for api_models::admin::MerchantCo }) .transpose()?, profile_id: item.profile_id, + pm_auth_config: item.pm_auth_config, }) } } diff --git a/migrations/2023-09-12-132509_add_pm_auth_config_mca/down.sql b/migrations/2023-09-12-132509_add_pm_auth_config_mca/down.sql new file mode 100644 index 000000000000..d4fc2b581edf --- /dev/null +++ b/migrations/2023-09-12-132509_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-12-132509_add_pm_auth_config_mca/up.sql b/migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql new file mode 100644 index 000000000000..1397fb6dac44 --- /dev/null +++ b/migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql @@ -0,0 +1,2 @@ +-- Your SQL goes here +ALTER TABLE merchant_connector_account ADD COLUMN IF NOT EXISTS pm_auth_config JSONB DEFAULT NULL; \ No newline at end of file From 51fd53999db61c757756ba6f41daeb01c5ed276f Mon Sep 17 00:00:00 2001 From: Sarthak Soni Date: Sat, 16 Sep 2023 16:20:11 +0530 Subject: [PATCH 02/12] fix(mca): Updated mca query --- migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql b/migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql index 1397fb6dac44..e30cfccfcb88 100644 --- a/migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql +++ b/migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql @@ -1,2 +1,3 @@ -- Your SQL goes here -ALTER TABLE merchant_connector_account ADD COLUMN IF NOT EXISTS pm_auth_config JSONB DEFAULT NULL; \ No newline at end of file +ALTER TABLE merchant_connector_account ADD COLUMN IF NOT EXISTS pm_auth_config JSONB DEFAULT NULL; +ALTER TYPE "ConnectorType" ADD VALUE IF NOT EXISTS "payment_method_auth"; \ No newline at end of file From 6dc3c9bb32b742b93825127dcbe1ab807702a149 Mon Sep 17 00:00:00 2001 From: Sarthak Soni Date: Sat, 16 Sep 2023 16:31:14 +0530 Subject: [PATCH 03/12] fix(mca): Schema fix --- crates/diesel_models/src/schema.rs | 254 ++++++++++++++++++++++++++++- 1 file changed, 253 insertions(+), 1 deletion(-) diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs index 39c74158b9aa..724ed6f621cd 100644 --- a/crates/diesel_models/src/schema.rs +++ b/crates/diesel_models/src/schema.rs @@ -200,6 +200,29 @@ diesel::table! { } } +diesel::table! { + use diesel::sql_types::*; + use crate::enums::diesel_exports::*; + + dashboard_metadata (id) { + id -> Int4, + #[max_length = 64] + user_id -> Nullable, + #[max_length = 64] + merchant_id -> Varchar, + #[max_length = 64] + org_id -> Varchar, + data_key -> DashboardMetadata, + data_value -> Json, + #[max_length = 64] + created_by -> Varchar, + created_at -> Timestamp, + #[max_length = 64] + last_modified_by -> Varchar, + last_modified_at -> Timestamp, + } +} + diesel::table! { use diesel::sql_types::*; use crate::enums::diesel_exports::*; @@ -261,6 +284,23 @@ diesel::table! { } } +diesel::table! { + use diesel::sql_types::*; + use crate::enums::diesel_exports::*; + + feedbacks (id) { + id -> Int4, + #[max_length = 255] + email -> Varchar, + #[max_length = 255] + description -> Nullable, + rating -> Nullable, + #[max_length = 255] + category -> Nullable, + created_at -> Timestamp, + } +} + diesel::table! { use diesel::sql_types::*; use crate::enums::diesel_exports::*; @@ -320,6 +360,32 @@ diesel::table! { } } +diesel::table! { + use diesel::sql_types::*; + use crate::enums::diesel_exports::*; + + gateway_status_map (connector, flow, sub_flow, code, message) { + #[max_length = 64] + connector -> Varchar, + #[max_length = 64] + flow -> Varchar, + #[max_length = 64] + sub_flow -> Varchar, + #[max_length = 255] + code -> Varchar, + #[max_length = 1024] + message -> Varchar, + #[max_length = 64] + status -> Varchar, + #[max_length = 64] + router_error -> Nullable, + #[max_length = 64] + decision -> Varchar, + created_at -> Timestamp, + last_modified -> Timestamp, + } +} + diesel::table! { use diesel::sql_types::*; use crate::enums::diesel_exports::*; @@ -334,7 +400,7 @@ diesel::table! { card_fingerprint -> Varchar, #[max_length = 255] card_global_fingerprint -> Varchar, - #[max_length = 255] + #[max_length = 64] merchant_id -> Varchar, #[max_length = 255] card_number -> Varchar, @@ -488,6 +554,32 @@ diesel::table! { } } +diesel::table! { + use diesel::sql_types::*; + use crate::enums::diesel_exports::*; + + onboarding_data (id) { + id -> Int4, + #[max_length = 64] + user_id -> Varchar, + onboarding_step -> Int4, + created_at -> Timestamp, + last_modified -> Timestamp, + subscribed -> Nullable, + } +} + +diesel::table! { + use diesel::sql_types::*; + use crate::enums::diesel_exports::*; + + organization (org_id) { + #[max_length = 32] + org_id -> Varchar, + org_name -> Nullable, + } +} + diesel::table! { use diesel::sql_types::*; use crate::enums::diesel_exports::*; @@ -718,6 +810,36 @@ diesel::table! { } } +diesel::table! { + use diesel::sql_types::*; + use crate::enums::diesel_exports::*; + + plan (plan_id) { + #[max_length = 64] + plan_id -> Varchar, + #[max_length = 255] + plan_name -> Varchar, + #[max_length = 64] + merchant_id -> Varchar, + currency -> Currency, + amount -> Int4, + #[max_length = 64] + status -> Varchar, + #[max_length = 64] + billing_unit -> Varchar, + billing_length -> Int4, + billing_cycle -> Int4, + #[max_length = 64] + trial_unit -> Nullable, + trial_length -> Nullable, + #[max_length = 64] + pricing_type -> Varchar, + trial_requires_payment_info -> Bool, + created_at -> Timestamp, + modified_at -> Timestamp, + } +} + diesel::table! { use diesel::sql_types::*; use crate::enums::diesel_exports::*; @@ -744,6 +866,42 @@ diesel::table! { } } +diesel::table! { + use diesel::sql_types::*; + use crate::enums::diesel_exports::*; + + prod_intent (id) { + id -> Int4, + #[max_length = 255] + user_id -> Varchar, + #[max_length = 255] + merchant_id -> Varchar, + #[max_length = 255] + legal_business_name -> Nullable, + #[max_length = 255] + business_label -> Nullable, + business_location -> Nullable, + #[max_length = 255] + display_name -> Nullable, + #[max_length = 255] + poc_email -> Nullable, + #[max_length = 255] + business_type -> Nullable, + #[max_length = 255] + business_identifier -> Nullable, + #[max_length = 255] + business_website -> Nullable, + #[max_length = 255] + poc_name -> Nullable, + #[max_length = 255] + poc_contact -> Nullable, + comments -> Nullable, + is_completed -> Bool, + created_at -> Timestamp, + modified_at -> Timestamp, + } +} + diesel::table! { use diesel::sql_types::*; use crate::enums::diesel_exports::*; @@ -806,6 +964,90 @@ diesel::table! { } } +diesel::table! { + use diesel::sql_types::*; + use crate::enums::diesel_exports::*; + + subscriptions (subscription_id) { + #[max_length = 64] + subscription_id -> Varchar, + #[max_length = 64] + plan_id -> Varchar, + #[max_length = 64] + customer_id -> Varchar, + #[max_length = 64] + merchant_id -> Varchar, + #[max_length = 64] + mandate_id -> Nullable, + currency -> Currency, + amount -> Int4, + subscription_balance -> Int4, + #[max_length = 64] + status -> Varchar, + next_billing_date -> Timestamp, + #[max_length = 64] + billing_unit -> Varchar, + billing_length -> Int4, + billing_cycle -> Int4, + #[max_length = 64] + trial_unit -> Nullable, + trial_length -> Nullable, + start_date -> Nullable, + end_date -> Nullable, + is_retry_initiated -> Nullable, + created_at -> Timestamp, + modified_at -> Timestamp, + } +} + +diesel::table! { + use diesel::sql_types::*; + use crate::enums::diesel_exports::*; + + user_roles (id) { + id -> Int4, + #[max_length = 64] + user_id -> Varchar, + #[max_length = 64] + merchant_id -> Varchar, + #[max_length = 64] + role_id -> Varchar, + status -> UserStatus, + #[max_length = 64] + created_by -> Varchar, + #[max_length = 64] + last_modified_by -> Varchar, + created_at -> Timestamp, + last_modified -> Timestamp, + #[max_length = 32] + org_id -> Nullable, + } +} + +diesel::table! { + use diesel::sql_types::*; + use crate::enums::diesel_exports::*; + + users (id) { + id -> Int4, + #[max_length = 64] + user_id -> Varchar, + #[max_length = 255] + email -> Varchar, + #[max_length = 255] + name -> Varchar, + #[max_length = 255] + password -> Varchar, + #[max_length = 64] + merchant_id -> Nullable, + is_verified -> Bool, + created_at -> Timestamp, + last_modified -> Timestamp, + metadata -> Nullable, + sandbox_integration -> Nullable, + } +} + diesel::allow_tables_to_appear_in_same_query!( address, api_keys, @@ -815,21 +1057,31 @@ diesel::allow_tables_to_appear_in_same_query!( configs, connector_response, customers, + dashboard_metadata, dispute, events, + feedbacks, file_metadata, fraud_check, + gateway_status_map, locker_mock_up, mandate, merchant_account, merchant_connector_account, merchant_key_store, + onboarding_data, + organization, payment_attempt, payment_intent, payment_methods, payout_attempt, payouts, + plan, process_tracker, + prod_intent, refund, reverse_lookup, + subscriptions, + user_roles, + users, ); From 43e827bde4107c2bc925a91043c774ee3bf28eef Mon Sep 17 00:00:00 2001 From: Sarthak Soni Date: Sat, 16 Sep 2023 16:40:30 +0530 Subject: [PATCH 04/12] Revert "fix(mca): Schema fix" This reverts commit 6dc3c9bb32b742b93825127dcbe1ab807702a149. --- crates/diesel_models/src/schema.rs | 254 +---------------------------- 1 file changed, 1 insertion(+), 253 deletions(-) diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs index 724ed6f621cd..39c74158b9aa 100644 --- a/crates/diesel_models/src/schema.rs +++ b/crates/diesel_models/src/schema.rs @@ -200,29 +200,6 @@ diesel::table! { } } -diesel::table! { - use diesel::sql_types::*; - use crate::enums::diesel_exports::*; - - dashboard_metadata (id) { - id -> Int4, - #[max_length = 64] - user_id -> Nullable, - #[max_length = 64] - merchant_id -> Varchar, - #[max_length = 64] - org_id -> Varchar, - data_key -> DashboardMetadata, - data_value -> Json, - #[max_length = 64] - created_by -> Varchar, - created_at -> Timestamp, - #[max_length = 64] - last_modified_by -> Varchar, - last_modified_at -> Timestamp, - } -} - diesel::table! { use diesel::sql_types::*; use crate::enums::diesel_exports::*; @@ -284,23 +261,6 @@ diesel::table! { } } -diesel::table! { - use diesel::sql_types::*; - use crate::enums::diesel_exports::*; - - feedbacks (id) { - id -> Int4, - #[max_length = 255] - email -> Varchar, - #[max_length = 255] - description -> Nullable, - rating -> Nullable, - #[max_length = 255] - category -> Nullable, - created_at -> Timestamp, - } -} - diesel::table! { use diesel::sql_types::*; use crate::enums::diesel_exports::*; @@ -360,32 +320,6 @@ diesel::table! { } } -diesel::table! { - use diesel::sql_types::*; - use crate::enums::diesel_exports::*; - - gateway_status_map (connector, flow, sub_flow, code, message) { - #[max_length = 64] - connector -> Varchar, - #[max_length = 64] - flow -> Varchar, - #[max_length = 64] - sub_flow -> Varchar, - #[max_length = 255] - code -> Varchar, - #[max_length = 1024] - message -> Varchar, - #[max_length = 64] - status -> Varchar, - #[max_length = 64] - router_error -> Nullable, - #[max_length = 64] - decision -> Varchar, - created_at -> Timestamp, - last_modified -> Timestamp, - } -} - diesel::table! { use diesel::sql_types::*; use crate::enums::diesel_exports::*; @@ -400,7 +334,7 @@ diesel::table! { card_fingerprint -> Varchar, #[max_length = 255] card_global_fingerprint -> Varchar, - #[max_length = 64] + #[max_length = 255] merchant_id -> Varchar, #[max_length = 255] card_number -> Varchar, @@ -554,32 +488,6 @@ diesel::table! { } } -diesel::table! { - use diesel::sql_types::*; - use crate::enums::diesel_exports::*; - - onboarding_data (id) { - id -> Int4, - #[max_length = 64] - user_id -> Varchar, - onboarding_step -> Int4, - created_at -> Timestamp, - last_modified -> Timestamp, - subscribed -> Nullable, - } -} - -diesel::table! { - use diesel::sql_types::*; - use crate::enums::diesel_exports::*; - - organization (org_id) { - #[max_length = 32] - org_id -> Varchar, - org_name -> Nullable, - } -} - diesel::table! { use diesel::sql_types::*; use crate::enums::diesel_exports::*; @@ -810,36 +718,6 @@ diesel::table! { } } -diesel::table! { - use diesel::sql_types::*; - use crate::enums::diesel_exports::*; - - plan (plan_id) { - #[max_length = 64] - plan_id -> Varchar, - #[max_length = 255] - plan_name -> Varchar, - #[max_length = 64] - merchant_id -> Varchar, - currency -> Currency, - amount -> Int4, - #[max_length = 64] - status -> Varchar, - #[max_length = 64] - billing_unit -> Varchar, - billing_length -> Int4, - billing_cycle -> Int4, - #[max_length = 64] - trial_unit -> Nullable, - trial_length -> Nullable, - #[max_length = 64] - pricing_type -> Varchar, - trial_requires_payment_info -> Bool, - created_at -> Timestamp, - modified_at -> Timestamp, - } -} - diesel::table! { use diesel::sql_types::*; use crate::enums::diesel_exports::*; @@ -866,42 +744,6 @@ diesel::table! { } } -diesel::table! { - use diesel::sql_types::*; - use crate::enums::diesel_exports::*; - - prod_intent (id) { - id -> Int4, - #[max_length = 255] - user_id -> Varchar, - #[max_length = 255] - merchant_id -> Varchar, - #[max_length = 255] - legal_business_name -> Nullable, - #[max_length = 255] - business_label -> Nullable, - business_location -> Nullable, - #[max_length = 255] - display_name -> Nullable, - #[max_length = 255] - poc_email -> Nullable, - #[max_length = 255] - business_type -> Nullable, - #[max_length = 255] - business_identifier -> Nullable, - #[max_length = 255] - business_website -> Nullable, - #[max_length = 255] - poc_name -> Nullable, - #[max_length = 255] - poc_contact -> Nullable, - comments -> Nullable, - is_completed -> Bool, - created_at -> Timestamp, - modified_at -> Timestamp, - } -} - diesel::table! { use diesel::sql_types::*; use crate::enums::diesel_exports::*; @@ -964,90 +806,6 @@ diesel::table! { } } -diesel::table! { - use diesel::sql_types::*; - use crate::enums::diesel_exports::*; - - subscriptions (subscription_id) { - #[max_length = 64] - subscription_id -> Varchar, - #[max_length = 64] - plan_id -> Varchar, - #[max_length = 64] - customer_id -> Varchar, - #[max_length = 64] - merchant_id -> Varchar, - #[max_length = 64] - mandate_id -> Nullable, - currency -> Currency, - amount -> Int4, - subscription_balance -> Int4, - #[max_length = 64] - status -> Varchar, - next_billing_date -> Timestamp, - #[max_length = 64] - billing_unit -> Varchar, - billing_length -> Int4, - billing_cycle -> Int4, - #[max_length = 64] - trial_unit -> Nullable, - trial_length -> Nullable, - start_date -> Nullable, - end_date -> Nullable, - is_retry_initiated -> Nullable, - created_at -> Timestamp, - modified_at -> Timestamp, - } -} - -diesel::table! { - use diesel::sql_types::*; - use crate::enums::diesel_exports::*; - - user_roles (id) { - id -> Int4, - #[max_length = 64] - user_id -> Varchar, - #[max_length = 64] - merchant_id -> Varchar, - #[max_length = 64] - role_id -> Varchar, - status -> UserStatus, - #[max_length = 64] - created_by -> Varchar, - #[max_length = 64] - last_modified_by -> Varchar, - created_at -> Timestamp, - last_modified -> Timestamp, - #[max_length = 32] - org_id -> Nullable, - } -} - -diesel::table! { - use diesel::sql_types::*; - use crate::enums::diesel_exports::*; - - users (id) { - id -> Int4, - #[max_length = 64] - user_id -> Varchar, - #[max_length = 255] - email -> Varchar, - #[max_length = 255] - name -> Varchar, - #[max_length = 255] - password -> Varchar, - #[max_length = 64] - merchant_id -> Nullable, - is_verified -> Bool, - created_at -> Timestamp, - last_modified -> Timestamp, - metadata -> Nullable, - sandbox_integration -> Nullable, - } -} - diesel::allow_tables_to_appear_in_same_query!( address, api_keys, @@ -1057,31 +815,21 @@ diesel::allow_tables_to_appear_in_same_query!( configs, connector_response, customers, - dashboard_metadata, dispute, events, - feedbacks, file_metadata, fraud_check, - gateway_status_map, locker_mock_up, mandate, merchant_account, merchant_connector_account, merchant_key_store, - onboarding_data, - organization, payment_attempt, payment_intent, payment_methods, payout_attempt, payouts, - plan, process_tracker, - prod_intent, refund, reverse_lookup, - subscriptions, - user_roles, - users, ); From d2247a388d0728aafff1689207bb19f7baab8c64 Mon Sep 17 00:00:00 2001 From: Sarthak Soni Date: Sat, 16 Sep 2023 16:50:55 +0530 Subject: [PATCH 05/12] fix(mca): Fixed schema --- migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql b/migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql index e30cfccfcb88..15cdafdbaccf 100644 --- a/migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql +++ b/migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql @@ -1,3 +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 IF NOT EXISTS "payment_method_auth"; \ No newline at end of file +ALTER TYPE "ConnectorType" ADD VALUE 'payment_method_auth'; \ No newline at end of file From 1036b7372ad2dc2eab0afad745a81cb4528532e2 Mon Sep 17 00:00:00 2001 From: Sarthak Soni Date: Mon, 18 Sep 2023 15:58:59 +0530 Subject: [PATCH 06/12] fix(pm_auth): Fixed connector enum match --- crates/router/src/core/admin.rs | 2 -- crates/router/src/types/api.rs | 5 ----- 2 files changed, 7 deletions(-) diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs index be03644a52c5..f738a075255d 100644 --- a/crates/router/src/core/admin.rs +++ b/crates/router/src/core/admin.rs @@ -1389,8 +1389,6 @@ pub(crate) fn validate_auth_type( Err(report!(errors::ConnectorError::InvalidConnectorName) .attach_printable(format!("invalid connector name: {connector_name}"))) } - api_enums::Connector::Plaid => Err(report!(errors::ConnectorError::InvalidConnectorName) - .attach_printable(format!("invalid connector name: {connector_name}"))), } } diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index a7df06dac9e1..549b3f41bd4d 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -346,11 +346,6 @@ impl ConnectorData { .attach_printable(format!("invalid connector name: {connector_name}"))) .change_context(errors::ApiErrorResponse::InternalServerError) } - enums::Connector::Plaid => { - Err(report!(errors::ConnectorError::InvalidConnectorName) - .attach_printable(format!("invalid connector name: {connector_name}"))) - .change_context(errors::ApiErrorResponse::InternalServerError) - } }, Err(_) => Err(report!(errors::ConnectorError::InvalidConnectorName) .attach_printable(format!("invalid connector name: {connector_name}"))) From d35032a053f7b0c43f34b0307a3b4eae6ec34f48 Mon Sep 17 00:00:00 2001 From: Sarthak Soni Date: Mon, 18 Sep 2023 16:22:03 +0530 Subject: [PATCH 07/12] fix(migration): Fixed migration inconsistencies --- .../down.sql | 0 .../up.sql | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename migrations/{2023-09-12-132509_add_pm_auth_config_mca => 2023-09-18-104900_add_pm_auth_config_mca}/down.sql (100%) rename migrations/{2023-09-12-132509_add_pm_auth_config_mca => 2023-09-18-104900_add_pm_auth_config_mca}/up.sql (100%) diff --git a/migrations/2023-09-12-132509_add_pm_auth_config_mca/down.sql b/migrations/2023-09-18-104900_add_pm_auth_config_mca/down.sql similarity index 100% rename from migrations/2023-09-12-132509_add_pm_auth_config_mca/down.sql rename to migrations/2023-09-18-104900_add_pm_auth_config_mca/down.sql diff --git a/migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql b/migrations/2023-09-18-104900_add_pm_auth_config_mca/up.sql similarity index 100% rename from migrations/2023-09-12-132509_add_pm_auth_config_mca/up.sql rename to migrations/2023-09-18-104900_add_pm_auth_config_mca/up.sql From 1b44bbb1f30b03323804b8f1da7e23480b5239a2 Mon Sep 17 00:00:00 2001 From: Sarthak Soni Date: Mon, 18 Sep 2023 16:53:37 +0530 Subject: [PATCH 08/12] fix(mca): Fixed clippy errors --- crates/router/src/core/verification/utils.rs | 1 + 1 file changed, 1 insertion(+) 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 From d5df52a4650e96fd0621ab34f7a4bfdd1e335ac0 Mon Sep 17 00:00:00 2001 From: Sarthak Soni Date: Wed, 20 Sep 2023 13:01:09 +0530 Subject: [PATCH 09/12] fix(pm_auth): Fixed openApi Sepc --- openapi/openapi_spec.json | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json index 61faf9deeb50..d7e6e1b4c6a2 100644 --- a/openapi/openapi_spec.json +++ b/openapi/openapi_spec.json @@ -3915,7 +3915,8 @@ "networks", "banking_entities", "non_banking_finance", - "payout_processor" + "payout_processor", + "payment_method_auth" ] }, "CountryAlpha2": { @@ -6510,6 +6511,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 } } }, @@ -6734,6 +6738,9 @@ }, "description": "identifier for the verified domains of a particular connector account", "nullable": true + }, + "pm_auth_config": { + "nullable": true } } }, @@ -6831,6 +6838,9 @@ } ], "nullable": true + }, + "pm_auth_config": { + "nullable": true } } }, From 299462d0d90f8e579f99dbef2a639d9953392af1 Mon Sep 17 00:00:00 2001 From: Sarthak Soni Date: Mon, 25 Sep 2023 16:28:28 +0530 Subject: [PATCH 10/12] feat(pm_auth): Support for bank details in pmd --- crates/api_models/src/payment_methods.rs | 16 ++++++++++++++++ crates/diesel_models/src/payment_method.rs | 19 +++++++++++++++++-- .../router/src/core/payment_methods/cards.rs | 12 +++++++----- 3 files changed, 40 insertions(+), 7 deletions(-) diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs index 4e67ed4d45fe..7f65d25d3996 100644 --- a/crates/api_models/src/payment_methods.rs +++ b/crates/api_models/src/payment_methods.rs @@ -147,6 +147,7 @@ pub struct PaymentMethodResponse { #[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)] pub enum PaymentMethodsData { Card(CardDetailsPaymentMethod), + BankDetails(PaymentMethodDataBankCreds), } #[derive(Clone, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize)] pub struct CardDetailsPaymentMethod { @@ -158,6 +159,21 @@ pub struct CardDetailsPaymentMethod { pub card_holder_name: Option>, } +#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct PaymentMethodDataBankCreds { + pub mask: String, + pub hash: String, + pub payment_method_type: api_enums::PaymentMethodType, + pub connector_details: Vec, +} + +#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)] +pub struct BankAccountConnectorDetails { + pub connector: String, + pub account_id: String, + pub access_token: String, +} + #[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)] pub struct CardDetailFromLocker { pub scheme: Option, diff --git a/crates/diesel_models/src/payment_method.rs b/crates/diesel_models/src/payment_method.rs index 8029c20038a5..d8b46c1932ef 100644 --- a/crates/diesel_models/src/payment_method.rs +++ b/crates/diesel_models/src/payment_method.rs @@ -99,13 +99,19 @@ pub struct TokenizeCoreWorkflow { #[derive(Debug, Serialize, Deserialize)] pub enum PaymentMethodUpdate { - MetadataUpdate { metadata: Option }, + MetadataUpdate { + metadata: Option, + }, + PaymentMethodDataUpdate { + payment_method_data: Option, + }, } #[derive(Clone, Debug, Default, AsChangeset, router_derive::DebugAsDisplay)] #[diesel(table_name = payment_methods)] pub struct PaymentMethodUpdateInternal { metadata: Option, + payment_method_data: Option, } impl PaymentMethodUpdateInternal { @@ -119,7 +125,16 @@ impl PaymentMethodUpdateInternal { impl From for PaymentMethodUpdateInternal { fn from(payment_method_update: PaymentMethodUpdate) -> Self { match payment_method_update { - PaymentMethodUpdate::MetadataUpdate { metadata } => Self { metadata }, + PaymentMethodUpdate::MetadataUpdate { metadata } => Self { + metadata, + payment_method_data: None, + }, + PaymentMethodUpdate::PaymentMethodDataUpdate { + payment_method_data, + } => Self { + metadata: None, + payment_method_data, + }, } } } diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index 7cc4eacbe355..3a5083a9723e 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -7,9 +7,10 @@ use api_models::{ admin::{self, PaymentMethodsEnabled}, enums::{self as api_enums}, payment_methods::{ - CardDetailsPaymentMethod, CardNetworkTypes, PaymentExperienceTypes, PaymentMethodsData, - RequestPaymentMethodTypes, RequiredFieldInfo, ResponsePaymentMethodIntermediate, - ResponsePaymentMethodTypes, ResponsePaymentMethodsEnabled, + CardDetailsPaymentMethod, CardNetworkTypes, PaymentExperienceTypes, + PaymentMethodDataBankCreds, PaymentMethodsData, RequestPaymentMethodTypes, + RequiredFieldInfo, ResponsePaymentMethodIntermediate, ResponsePaymentMethodTypes, + ResponsePaymentMethodsEnabled, }, payments::BankCodeResponse, }; @@ -1962,8 +1963,9 @@ async fn get_card_details( .flatten() .map(|x| x.into_inner().expose()) .and_then(|v| serde_json::from_value::(v).ok()) - .map(|pmd| match pmd { - PaymentMethodsData::Card(crd) => api::CardDetailFromLocker::from(crd), + .and_then(|pmd| match pmd { + PaymentMethodsData::Card(crd) => Some(api::CardDetailFromLocker::from(crd)), + _ => None, }); Ok(Some( From 9a332e9003ea63f41a4099b04a9a5c125d390d56 Mon Sep 17 00:00:00 2001 From: Sarthak Soni Date: Tue, 26 Sep 2023 15:01:18 +0530 Subject: [PATCH 11/12] fix(pm_auth): Fixed imports --- crates/router/src/core/payment_methods/cards.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index 3a5083a9723e..3a5e88191d0f 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -7,10 +7,9 @@ use api_models::{ admin::{self, PaymentMethodsEnabled}, enums::{self as api_enums}, payment_methods::{ - CardDetailsPaymentMethod, CardNetworkTypes, PaymentExperienceTypes, - PaymentMethodDataBankCreds, PaymentMethodsData, RequestPaymentMethodTypes, - RequiredFieldInfo, ResponsePaymentMethodIntermediate, ResponsePaymentMethodTypes, - ResponsePaymentMethodsEnabled, + CardDetailsPaymentMethod, CardNetworkTypes, PaymentExperienceTypes, PaymentMethodsData, + RequestPaymentMethodTypes, RequiredFieldInfo, ResponsePaymentMethodIntermediate, + ResponsePaymentMethodTypes, ResponsePaymentMethodsEnabled, }, payments::BankCodeResponse, }; From 39521ae24275dfd644d4fd9846047e93defd06bd Mon Sep 17 00:00:00 2001 From: Sarthak Soni Date: Tue, 3 Oct 2023 19:32:41 +0530 Subject: [PATCH 12/12] refactor(payment_methods): Refactored bank account access creds --- crates/api_models/src/payment_methods.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/crates/api_models/src/payment_methods.rs b/crates/api_models/src/payment_methods.rs index 7f65d25d3996..e69b9fc82641 100644 --- a/crates/api_models/src/payment_methods.rs +++ b/crates/api_models/src/payment_methods.rs @@ -171,9 +171,13 @@ pub struct PaymentMethodDataBankCreds { pub struct BankAccountConnectorDetails { pub connector: String, pub account_id: String, - pub access_token: String, + pub access_token: BankAccountAccessCreds, } +#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)] +pub enum BankAccountAccessCreds { + AccessToken(String), +} #[derive(Debug, serde::Deserialize, serde::Serialize, Clone, ToSchema)] pub struct CardDetailFromLocker { pub scheme: Option,