feat(router): profile specific fallback derivation while routing payments (#2806)

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
Co-authored-by: Aprabhat19 <amishaprabhat@gmail.com>
Co-authored-by: Amisha Prabhat <55580080+Aprabhat19@users.noreply.github.com>
This commit is contained in:
Prajjwal Kumar
2023-11-13 14:57:34 +05:30
committed by GitHub
parent f88eee7362
commit 8e538dbd5c
8 changed files with 312 additions and 34 deletions

View File

@ -916,13 +916,16 @@ pub async fn create_payment_connector(
let mut default_routing_config =
routing_helpers::get_merchant_default_config(&*state.store, merchant_id).await?;
let mut default_routing_config_for_profile =
routing_helpers::get_merchant_default_config(&*state.clone().store, &profile_id).await?;
let mca = state
.store
.insert_merchant_connector_account(merchant_connector_account, &key_store)
.await
.to_duplicate_response(
errors::ApiErrorResponse::DuplicateMerchantConnectorAccount {
profile_id,
profile_id: profile_id.clone(),
connector_name: req.connector_name.to_string(),
},
)?;
@ -939,7 +942,7 @@ pub async fn create_payment_connector(
};
if !default_routing_config.contains(&choice) {
default_routing_config.push(choice);
default_routing_config.push(choice.clone());
routing_helpers::update_merchant_default_config(
&*state.store,
merchant_id,
@ -947,6 +950,15 @@ pub async fn create_payment_connector(
)
.await?;
}
if !default_routing_config_for_profile.contains(&choice.clone()) {
default_routing_config_for_profile.push(choice);
routing_helpers::update_merchant_default_config(
&*state.store,
&profile_id.clone(),
default_routing_config_for_profile,
)
.await?;
}
}
metrics::MCA_CREATE.add(