Skip to content

Commit

Permalink
fix(pm_auth): Added mca status check in pml (#5421)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sarthak1799 authored Aug 2, 2024
1 parent f3677f2 commit e9bd345
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions crates/router/src/core/payment_methods/cards.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2356,7 +2356,8 @@ pub async fn list_payment_methods(
.await?;

// filter out connectors based on the business country
let filtered_mcas = helpers::filter_mca_based_on_business_profile(all_mcas, profile_id.clone());
let filtered_mcas =
helpers::filter_mca_based_on_business_profile(all_mcas.clone(), profile_id.clone());

logger::debug!(mca_before_filtering=?filtered_mcas);

Expand Down Expand Up @@ -2663,33 +2664,34 @@ pub async fn list_payment_methods(
});

if let Some(config) = pm_auth_config {
config
.enabled_payment_methods
.iter()
.for_each(|inner_config| {
if inner_config.payment_method_type == *payment_method_type {
let pm = pmt_to_auth_connector
.get(&inner_config.payment_method)
.cloned();

let inner_map = if let Some(mut inner_map) = pm {
inner_map.insert(
*payment_method_type,
inner_config.connector_name.clone(),
);
inner_map
} else {
HashMap::from([(
*payment_method_type,
inner_config.connector_name.clone(),
)])
};

pmt_to_auth_connector
.insert(inner_config.payment_method, inner_map);
val.push(inner_config.clone());
}
});
for inner_config in config.enabled_payment_methods.iter() {
let is_active_mca = all_mcas
.iter()
.any(|mca| mca.merchant_connector_id == inner_config.mca_id);

if inner_config.payment_method_type == *payment_method_type && is_active_mca
{
let pm = pmt_to_auth_connector
.get(&inner_config.payment_method)
.cloned();

let inner_map = if let Some(mut inner_map) = pm {
inner_map.insert(
*payment_method_type,
inner_config.connector_name.clone(),
);
inner_map
} else {
HashMap::from([(
*payment_method_type,
inner_config.connector_name.clone(),
)])
};

pmt_to_auth_connector.insert(inner_config.payment_method, inner_map);
val.push(inner_config.clone());
}
}
};
}
}
Expand Down

0 comments on commit e9bd345

Please # to comment.