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

refactor(payment_methods): enable country currency filter for cards (#4056)

Chethan Rao9ae10dc4d050
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 60abf0701a..75f192f606 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -2356,15 +2356,27 @@ fn filter_pm_based_on_config<'a>(
.or_else(|| config.0.get("default"))
.and_then(|inner| match payment_method_type {
api_enums::PaymentMethodType::Credit | api_enums::PaymentMethodType::Debit => {
+ let country_currency_filter = inner
+ .0
+ .get(&settings::PaymentMethodFilterKey::PaymentMethodType(
+ *payment_method_type,
+ ))
+ .map(|value| global_country_currency_filter(value, country, currency));
+
card_network_filter(country, currency, card_network, inner);
- payment_attempt
+ let capture_method_filter = payment_attempt
.and_then(|inner| inner.capture_method)
.and_then(|capture_method| {
(capture_method == storage_enums::CaptureMethod::Manual).then(|| {
filter_pm_based_on_capture_method_used(inner, payment_method_type)
})
- })
+ });
+
+ Some(
+ country_currency_filter.unwrap_or(true)
+ && capture_method_filter.unwrap_or(true),
+ )
}
payment_method_type => inner
.0