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

feat(payments): support for card_network filter in payments list (#5994)

Riddhiagrawal0011ac8c92c4bd2
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index cda790b595..c7c998cc2b 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -4389,6 +4389,8 @@ pub struct PaymentListFilterConstraints {
/// The order in which payments list should be sorted
#[serde(default)]
pub order: Order,
+ /// The List of all the card networks to filter payments list
+ pub card_network: Option<Vec<enums::CardNetwork>>,
}
#[derive(Clone, Debug, serde::Serialize)]
pub struct PaymentListFilters {
@@ -4418,6 +4420,8 @@ pub struct PaymentListFiltersV2 {
pub payment_method: HashMap<enums::PaymentMethod, HashSet<enums::PaymentMethodType>>,
/// The list of available authentication types
pub authentication_type: Vec<enums::AuthenticationType>,
+ /// The list of available card networks
+ pub card_network: Vec<enums::CardNetwork>,
}
#[derive(Clone, Debug, serde::Serialize)]
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
index 562e5d205c..be2b354711 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
@@ -1294,6 +1294,7 @@ pub struct PaymentIntentListParams {
pub ending_before_id: Option<id_type::PaymentId>,
pub limit: Option<u32>,
pub order: api_models::payments::Order,
+ pub card_network: Option<Vec<storage_enums::CardNetwork>>,
}
impl From<api_models::payments::PaymentListConstraints> for PaymentIntentFetchConstraints {
@@ -1327,6 +1328,7 @@ impl From<api_models::payments::PaymentListConstraints> for PaymentIntentFetchCo
ending_before_id: ending_before,
limit: Some(std::cmp::min(limit, PAYMENTS_LIST_MAX_LIMIT_V1)),
order: Default::default(),
+ card_network: None,
}))
}
}
@@ -1351,6 +1353,7 @@ impl From<common_utils::types::TimeRange> for PaymentIntentFetchConstraints {
ending_before_id: None,
limit: None,
order: Default::default(),
+ card_network: None,
}))
}
}
@@ -1373,6 +1376,7 @@ impl From<api_models::payments::PaymentListFilterConstraints> for PaymentIntentF
authentication_type,
merchant_connector_id,
order,
+ card_network,
} = value;
if let Some(payment_intent_id) = payment_id {
Self::Single { payment_intent_id }
@@ -1395,6 +1399,7 @@ impl From<api_models::payments::PaymentListFilterConstraints> for PaymentIntentF
ending_before_id: None,
limit: Some(std::cmp::min(limit, PAYMENTS_LIST_MAX_LIMIT_V2)),
order,
+ card_network,
}))
}
}
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index c581b10473..f148bcdfbf 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -3902,6 +3902,7 @@ pub async fn get_payment_filters(
status: enums::IntentStatus::iter().collect(),
payment_method: payment_method_types_map,
authentication_type: enums::AuthenticationType::iter().collect(),
+ card_network: enums::CardNetwork::iter().collect(),
},
))
}
diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rs
index 4c7232f6f3..f5c3deeb18 100644
--- a/crates/storage_impl/src/payments/payment_intent.rs
+++ b/crates/storage_impl/src/payments/payment_intent.rs
@@ -939,6 +939,9 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
None => query,
};
+ if let Some(card_network) = &params.card_network {
+ query = query.filter(pa_dsl::card_network.eq_any(card_network.clone()));
+ }
query
}
};