mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-31 01:57:45 +08:00
feat(payments): support for card_network filter in payments list (#5994)
This commit is contained in:
@ -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)]
|
||||
|
||||
@ -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,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@ -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(),
|
||||
},
|
||||
))
|
||||
}
|
||||
|
||||
@ -939,6 +939,9 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
None => query,
|
||||
};
|
||||
|
||||
if let Some(card_network) = ¶ms.card_network {
|
||||
query = query.filter(pa_dsl::card_network.eq_any(card_network.clone()));
|
||||
}
|
||||
query
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user