Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(pm_auth): Added mca status check in pml (#5421)

Sarthak Sonie9bd345464f2
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 8cb64d1e0d..b919541ade 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -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);
@@ -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());
+ }
+ }
};
}
}