Skip to content

Commit

Permalink
feat(pm_auth): Added pm_auth_config to merchant_connector_account (#2183
Browse files Browse the repository at this point in the history
)

Co-authored-by: Sarthak Soni <[email protected]>
  • Loading branch information
Sarthak1799 and Sarthak1799 authored Oct 3, 2023
1 parent f12ce9c commit abfdea2
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 1 deletion.
6 changes: 6 additions & 0 deletions crates/api_models/src/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -633,6 +633,8 @@ pub struct MerchantConnectorCreate {
pub connector_webhook_details: Option<MerchantConnectorWebhookDetails>,
/// Identifier for the business profile, if not provided default will be chosen from merchant account
pub profile_id: Option<String>,

pub pm_auth_config: Option<serde_json::Value>,
}

#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]
Expand Down Expand Up @@ -736,6 +738,8 @@ pub struct MerchantConnectorResponse {
pub profile_id: Option<String>,
/// identifier for the verified domains of a particular connector account
pub applepay_verified_domains: Option<Vec<String>>,

pub pm_auth_config: Option<serde_json::Value>,
}

/// 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."
Expand Down Expand Up @@ -805,6 +809,8 @@ pub struct MerchantConnectorUpdate {
}
}))]
pub connector_webhook_details: Option<MerchantConnectorWebhookDetails>,

pub pm_auth_config: Option<serde_json::Value>,
}

///Details of FrmConfigs are mentioned here... it should be passed in payment connector create api call, and stored in merchant_connector_table
Expand Down
2 changes: 2 additions & 0 deletions crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,8 @@ pub enum ConnectorType {
NonBankingFinance,
/// Acquirers, Gateways etc
PayoutProcessor,
/// PaymentMethods Auth Services
PaymentMethodAuth,
}

#[allow(clippy::upper_case_acronyms)]
Expand Down
4 changes: 4 additions & 0 deletions crates/diesel_models/src/merchant_connector_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ pub struct MerchantConnectorAccount {
pub profile_id: Option<String>,
#[diesel(deserialize_as = super::OptionalDieselArray<String>)]
pub applepay_verified_domains: Option<Vec<String>>,
pub pm_auth_config: Option<serde_json::Value>,
}

#[derive(Clone, Debug, Insertable, router_derive::DebugAsDisplay)]
Expand Down Expand Up @@ -68,6 +69,7 @@ pub struct MerchantConnectorAccountNew {
pub profile_id: Option<String>,
#[diesel(deserialize_as = super::OptionalDieselArray<String>)]
pub applepay_verified_domains: Option<Vec<String>>,
pub pm_auth_config: Option<serde_json::Value>,
}

#[derive(Clone, Debug, AsChangeset, router_derive::DebugAsDisplay)]
Expand All @@ -89,6 +91,7 @@ pub struct MerchantConnectorAccountUpdateInternal {
pub frm_config: Option<Vec<Secret<serde_json::Value>>>,
#[diesel(deserialize_as = super::OptionalDieselArray<String>)]
pub applepay_verified_domains: Option<Vec<String>>,
pub pm_auth_config: Option<serde_json::Value>,
}

impl MerchantConnectorAccountUpdateInternal {
Expand All @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions crates/diesel_models/src/schema.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ diesel::table! {
#[max_length = 64]
profile_id -> Nullable<Varchar>,
applepay_verified_domains -> Nullable<Array<Nullable<Text>>>,
pm_auth_config -> Nullable<Jsonb>,
}
}

Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/core/admin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/core/verification/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions crates/router/src/db/merchant_connector_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
7 changes: 7 additions & 0 deletions crates/router/src/types/domain/merchant_connector_account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ pub struct MerchantConnectorAccount {
pub connector_webhook_details: Option<pii::SecretSerdeValue>,
pub profile_id: Option<String>,
pub applepay_verified_domains: Option<Vec<String>>,
pub pm_auth_config: Option<serde_json::Value>,
}

#[derive(Debug)]
Expand All @@ -51,6 +52,7 @@ pub enum MerchantConnectorAccountUpdate {
frm_configs: Option<Vec<Secret<serde_json::Value>>>,
connector_webhook_details: Option<pii::SecretSerdeValue>,
applepay_verified_domains: Option<Vec<String>>,
pm_auth_config: Option<serde_json::Value>,
},
}

Expand Down Expand Up @@ -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,
},
)
}
Expand Down Expand Up @@ -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,
})
}

Expand All @@ -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,
})
}
}
Expand All @@ -169,6 +174,7 @@ impl From<MerchantConnectorAccountUpdate> for MerchantConnectorAccountUpdateInte
frm_configs,
connector_webhook_details,
applepay_verified_domains,
pm_auth_config,
} => Self {
merchant_id,
connector_type,
Expand All @@ -184,6 +190,7 @@ impl From<MerchantConnectorAccountUpdate> for MerchantConnectorAccountUpdateInte
modified_at: Some(common_utils::date_time::now()),
connector_webhook_details,
applepay_verified_domains,
pm_auth_config,
},
}
}
Expand Down
1 change: 1 addition & 0 deletions crates/router/src/types/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -668,6 +668,7 @@ impl TryFrom<domain::MerchantConnectorAccount> 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,
})
}
}
Expand Down
2 changes: 2 additions & 0 deletions migrations/2023-09-18-104900_add_pm_auth_config_mca/down.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
ALTER TABLE merchant_connector_account DROP COLUMN IF EXISTS pm_auth_config;
3 changes: 3 additions & 0 deletions migrations/2023-09-18-104900_add_pm_auth_config_mca/up.sql
Original file line number Diff line number Diff line change
@@ -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';
12 changes: 11 additions & 1 deletion openapi/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -3922,7 +3922,8 @@
"networks",
"banking_entities",
"non_banking_finance",
"payout_processor"
"payout_processor",
"payment_method_auth"
]
},
"CountryAlpha2": {
Expand Down Expand Up @@ -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
}
}
},
Expand Down Expand Up @@ -6746,6 +6750,9 @@
},
"description": "identifier for the verified domains of a particular connector account",
"nullable": true
},
"pm_auth_config": {
"nullable": true
}
}
},
Expand Down Expand Up @@ -6843,6 +6850,9 @@
}
],
"nullable": true
},
"pm_auth_config": {
"nullable": true
}
}
},
Expand Down

0 comments on commit abfdea2

Please sign in to comment.