feat(router): Create a merchant config for enable processor agnostic MIT (#4025)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Shankar Singh C
2024-04-03 20:30:07 +05:30
committed by GitHub
parent 49cfe72cd2
commit 2a691a5c05
7 changed files with 84 additions and 54 deletions

View File

@ -273,9 +273,9 @@ pub async fn update_business_profile_active_algorithm_ref(
pub async fn get_merchant_connector_agnostic_mandate_config(
db: &dyn StorageInterface,
merchant_id: &str,
business_profile_id: &str,
) -> RouterResult<Vec<routing_types::DetailedConnectorChoice>> {
let key = get_pg_agnostic_mandate_config_key(merchant_id);
let key = get_pg_agnostic_mandate_config_key(business_profile_id);
let maybe_config = db.find_config_by_key(&key).await;
match maybe_config {
@ -312,29 +312,6 @@ pub async fn get_merchant_connector_agnostic_mandate_config(
}
}
pub async fn update_merchant_connector_agnostic_mandate_config(
db: &dyn StorageInterface,
merchant_id: &str,
mandate_config: Vec<routing_types::DetailedConnectorChoice>,
) -> RouterResult<Vec<routing_types::DetailedConnectorChoice>> {
let key = get_pg_agnostic_mandate_config_key(merchant_id);
let mandate_config_str = mandate_config
.encode_to_string_of_json()
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("unable to serialize pg agnostic mandate config during update")?;
let config_update = configs::ConfigUpdate::Update {
config: Some(mandate_config_str),
};
db.update_config_by_key(&key, config_update)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("error saving pg agnostic mandate config to db")?;
Ok(mandate_config)
}
pub async fn validate_connectors_in_routing_config(
db: &dyn StorageInterface,
key_store: &domain::MerchantKeyStore,
@ -465,8 +442,8 @@ pub fn get_routing_dictionary_key(merchant_id: &str) -> String {
/// Provides the identifier for the specific merchant's agnostic_mandate_config
#[inline(always)]
pub fn get_pg_agnostic_mandate_config_key(merchant_id: &str) -> String {
format!("pg_agnostic_mandate_{merchant_id}")
pub fn get_pg_agnostic_mandate_config_key(business_profile_id: &str) -> String {
format!("pg_agnostic_mandate_{business_profile_id}")
}
/// Provides the identifier for the specific merchant's default_config