feat(pm_auth): Added pm_auth_config to merchant_connector_account (#2183)

Co-authored-by: Sarthak Soni <sarthak.soni@juspay.in>
This commit is contained in:
Sarthak Soni
2023-10-03 13:07:43 +05:30
committed by GitHub
parent f12ce9c72d
commit abfdea20b0
12 changed files with 42 additions and 1 deletions

View File

@ -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)]
@ -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."
@ -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

View File

@ -208,6 +208,8 @@ pub enum ConnectorType {
NonBankingFinance,
/// Acquirers, Gateways etc
PayoutProcessor,
/// PaymentMethods Auth Services
PaymentMethodAuth,
}
#[allow(clippy::upper_case_acronyms)]

View File

@ -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)]
@ -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)]
@ -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 {
@ -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
}

View File

@ -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>,
}
}

View File

@ -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

View File

@ -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

View File

@ -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)

View File

@ -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)]
@ -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>,
},
}
@ -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<MerchantConnectorAccountUpdate> for MerchantConnectorAccountUpdateInte
frm_configs,
connector_webhook_details,
applepay_verified_domains,
pm_auth_config,
} => Self {
merchant_id,
connector_type,
@ -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,
},
}
}

View File

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

View File

@ -0,0 +1,2 @@
-- This file should undo anything in `up.sql`
ALTER TABLE merchant_connector_account DROP COLUMN IF EXISTS pm_auth_config;

View File

@ -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';

View File

@ -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
}
}
},