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

This commit is contained in:
Riddhiagrawal001
2024-10-14 15:41:56 +05:30
committed by GitHub
parent a7c6f57668
commit 1ac8c92c4b
4 changed files with 13 additions and 0 deletions

View File

@ -4389,6 +4389,8 @@ pub struct PaymentListFilterConstraints {
/// The order in which payments list should be sorted /// The order in which payments list should be sorted
#[serde(default)] #[serde(default)]
pub order: Order, 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)] #[derive(Clone, Debug, serde::Serialize)]
pub struct PaymentListFilters { pub struct PaymentListFilters {
@ -4418,6 +4420,8 @@ pub struct PaymentListFiltersV2 {
pub payment_method: HashMap<enums::PaymentMethod, HashSet<enums::PaymentMethodType>>, pub payment_method: HashMap<enums::PaymentMethod, HashSet<enums::PaymentMethodType>>,
/// The list of available authentication types /// The list of available authentication types
pub authentication_type: Vec<enums::AuthenticationType>, pub authentication_type: Vec<enums::AuthenticationType>,
/// The list of available card networks
pub card_network: Vec<enums::CardNetwork>,
} }
#[derive(Clone, Debug, serde::Serialize)] #[derive(Clone, Debug, serde::Serialize)]

View File

@ -1294,6 +1294,7 @@ pub struct PaymentIntentListParams {
pub ending_before_id: Option<id_type::PaymentId>, pub ending_before_id: Option<id_type::PaymentId>,
pub limit: Option<u32>, pub limit: Option<u32>,
pub order: api_models::payments::Order, pub order: api_models::payments::Order,
pub card_network: Option<Vec<storage_enums::CardNetwork>>,
} }
impl From<api_models::payments::PaymentListConstraints> for PaymentIntentFetchConstraints { 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, ending_before_id: ending_before,
limit: Some(std::cmp::min(limit, PAYMENTS_LIST_MAX_LIMIT_V1)), limit: Some(std::cmp::min(limit, PAYMENTS_LIST_MAX_LIMIT_V1)),
order: Default::default(), order: Default::default(),
card_network: None,
})) }))
} }
} }
@ -1351,6 +1353,7 @@ impl From<common_utils::types::TimeRange> for PaymentIntentFetchConstraints {
ending_before_id: None, ending_before_id: None,
limit: None, limit: None,
order: Default::default(), order: Default::default(),
card_network: None,
})) }))
} }
} }
@ -1373,6 +1376,7 @@ impl From<api_models::payments::PaymentListFilterConstraints> for PaymentIntentF
authentication_type, authentication_type,
merchant_connector_id, merchant_connector_id,
order, order,
card_network,
} = value; } = value;
if let Some(payment_intent_id) = payment_id { if let Some(payment_intent_id) = payment_id {
Self::Single { payment_intent_id } Self::Single { payment_intent_id }
@ -1395,6 +1399,7 @@ impl From<api_models::payments::PaymentListFilterConstraints> for PaymentIntentF
ending_before_id: None, ending_before_id: None,
limit: Some(std::cmp::min(limit, PAYMENTS_LIST_MAX_LIMIT_V2)), limit: Some(std::cmp::min(limit, PAYMENTS_LIST_MAX_LIMIT_V2)),
order, order,
card_network,
})) }))
} }
} }

View File

@ -3902,6 +3902,7 @@ pub async fn get_payment_filters(
status: enums::IntentStatus::iter().collect(), status: enums::IntentStatus::iter().collect(),
payment_method: payment_method_types_map, payment_method: payment_method_types_map,
authentication_type: enums::AuthenticationType::iter().collect(), authentication_type: enums::AuthenticationType::iter().collect(),
card_network: enums::CardNetwork::iter().collect(),
}, },
)) ))
} }

View File

@ -939,6 +939,9 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
None => query, None => query,
}; };
if let Some(card_network) = &params.card_network {
query = query.filter(pa_dsl::card_network.eq_any(card_network.clone()));
}
query query
} }
}; };