mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 03:13:56 +08:00
feat(payments): add PaymentListFilterConstraints and payments_list_by_filter endpoint for v2 (#8794)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -65,12 +65,12 @@ impl PaymentAttemptInterface for MockDb {
|
||||
&self,
|
||||
_merchant_id: &id_type::MerchantId,
|
||||
_active_attempt_ids: &[String],
|
||||
_connector: Option<api_models::enums::Connector>,
|
||||
_payment_method_type: Option<common_enums::PaymentMethod>,
|
||||
_payment_method_subtype: Option<common_enums::PaymentMethodType>,
|
||||
_authentication_type: Option<common_enums::AuthenticationType>,
|
||||
_merchanat_connector_id: Option<id_type::MerchantConnectorAccountId>,
|
||||
_card_network: Option<storage_enums::CardNetwork>,
|
||||
_connector: Option<Vec<api_models::enums::Connector>>,
|
||||
_payment_method_type: Option<Vec<common_enums::PaymentMethod>>,
|
||||
_payment_method_subtype: Option<Vec<common_enums::PaymentMethodType>>,
|
||||
_authentication_type: Option<Vec<common_enums::AuthenticationType>>,
|
||||
_merchant_connector_id: Option<Vec<id_type::MerchantConnectorAccountId>>,
|
||||
_card_network: Option<Vec<storage_enums::CardNetwork>>,
|
||||
_storage_scheme: storage_enums::MerchantStorageScheme,
|
||||
) -> CustomResult<i64, StorageError> {
|
||||
Err(StorageError::MockDbError)?
|
||||
|
||||
@ -546,12 +546,12 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
|
||||
&self,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
active_attempt_ids: &[String],
|
||||
connector: Option<api_models::enums::Connector>,
|
||||
payment_method_type: Option<common_enums::PaymentMethod>,
|
||||
payment_method_subtype: Option<common_enums::PaymentMethodType>,
|
||||
authentication_type: Option<common_enums::AuthenticationType>,
|
||||
merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,
|
||||
card_network: Option<common_enums::CardNetwork>,
|
||||
connector: Option<Vec<api_models::enums::Connector>>,
|
||||
payment_method_type: Option<Vec<common_enums::PaymentMethod>>,
|
||||
payment_method_subtype: Option<Vec<common_enums::PaymentMethodType>>,
|
||||
authentication_type: Option<Vec<common_enums::AuthenticationType>>,
|
||||
merchant_connector_id: Option<Vec<common_utils::id_type::MerchantConnectorAccountId>>,
|
||||
card_network: Option<Vec<common_enums::CardNetwork>>,
|
||||
_storage_scheme: MerchantStorageScheme,
|
||||
) -> CustomResult<i64, errors::StorageError> {
|
||||
let conn = self
|
||||
@ -565,7 +565,9 @@ impl<T: DatabaseStore> PaymentAttemptInterface for RouterStore<T> {
|
||||
&conn,
|
||||
merchant_id,
|
||||
active_attempt_ids,
|
||||
connector.map(|val| val.to_string()),
|
||||
connector
|
||||
.as_ref()
|
||||
.map(|vals| vals.iter().map(|v| v.to_string()).collect()),
|
||||
payment_method_type,
|
||||
payment_method_subtype,
|
||||
authentication_type,
|
||||
@ -1713,12 +1715,12 @@ impl<T: DatabaseStore> PaymentAttemptInterface for KVRouterStore<T> {
|
||||
&self,
|
||||
merchant_id: &common_utils::id_type::MerchantId,
|
||||
active_attempt_ids: &[String],
|
||||
connector: Option<api_models::enums::Connector>,
|
||||
payment_method_type: Option<common_enums::PaymentMethod>,
|
||||
payment_method_subtype: Option<common_enums::PaymentMethodType>,
|
||||
authentication_type: Option<common_enums::AuthenticationType>,
|
||||
merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,
|
||||
card_network: Option<common_enums::CardNetwork>,
|
||||
connector: Option<Vec<api_models::enums::Connector>>,
|
||||
payment_method_type: Option<Vec<common_enums::PaymentMethod>>,
|
||||
payment_method_subtype: Option<Vec<common_enums::PaymentMethodType>>,
|
||||
authentication_type: Option<Vec<common_enums::AuthenticationType>>,
|
||||
merchant_connector_id: Option<Vec<common_utils::id_type::MerchantConnectorAccountId>>,
|
||||
card_network: Option<Vec<common_enums::CardNetwork>>,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> CustomResult<i64, errors::StorageError> {
|
||||
self.router_store
|
||||
|
||||
@ -1361,9 +1361,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
.into_boxed();
|
||||
|
||||
query = match constraints {
|
||||
PaymentIntentFetchConstraints::Single { payment_intent_id } => {
|
||||
query.filter(pi_dsl::id.eq(payment_intent_id.to_owned()))
|
||||
}
|
||||
PaymentIntentFetchConstraints::List(params) => {
|
||||
query = match params.order {
|
||||
Order {
|
||||
@ -1457,50 +1454,54 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
};
|
||||
|
||||
query = match ¶ms.currency {
|
||||
Some(currency) => query.filter(pi_dsl::currency.eq(*currency)),
|
||||
Some(currency) => query.filter(pi_dsl::currency.eq_any(currency.clone())),
|
||||
None => query,
|
||||
};
|
||||
|
||||
query = match ¶ms.connector {
|
||||
Some(connector) => query.filter(pa_dsl::connector.eq(*connector)),
|
||||
Some(connector) => query.filter(pa_dsl::connector.eq_any(connector.clone())),
|
||||
None => query,
|
||||
};
|
||||
|
||||
query = match ¶ms.status {
|
||||
Some(status) => query.filter(pi_dsl::status.eq(*status)),
|
||||
Some(status) => query.filter(pi_dsl::status.eq_any(status.clone())),
|
||||
None => query,
|
||||
};
|
||||
|
||||
query = match ¶ms.payment_method_type {
|
||||
Some(payment_method_type) => {
|
||||
query.filter(pa_dsl::payment_method_type_v2.eq(*payment_method_type))
|
||||
}
|
||||
Some(payment_method_type) => query
|
||||
.filter(pa_dsl::payment_method_type_v2.eq_any(payment_method_type.clone())),
|
||||
None => query,
|
||||
};
|
||||
|
||||
query = match ¶ms.payment_method_subtype {
|
||||
Some(payment_method_subtype) => {
|
||||
query.filter(pa_dsl::payment_method_subtype.eq(*payment_method_subtype))
|
||||
}
|
||||
Some(payment_method_subtype) => query.filter(
|
||||
pa_dsl::payment_method_subtype.eq_any(payment_method_subtype.clone()),
|
||||
),
|
||||
None => query,
|
||||
};
|
||||
|
||||
query = match ¶ms.authentication_type {
|
||||
Some(authentication_type) => {
|
||||
query.filter(pa_dsl::authentication_type.eq(*authentication_type))
|
||||
}
|
||||
Some(authentication_type) => query
|
||||
.filter(pa_dsl::authentication_type.eq_any(authentication_type.clone())),
|
||||
None => query,
|
||||
};
|
||||
|
||||
query = match ¶ms.merchant_connector_id {
|
||||
Some(merchant_connector_id) => query
|
||||
.filter(pa_dsl::merchant_connector_id.eq(merchant_connector_id.clone())),
|
||||
Some(merchant_connector_id) => query.filter(
|
||||
pa_dsl::merchant_connector_id.eq_any(merchant_connector_id.clone()),
|
||||
),
|
||||
None => query,
|
||||
};
|
||||
|
||||
if let Some(card_network) = ¶ms.card_network {
|
||||
query = query.filter(pa_dsl::card_network.eq(card_network.clone()));
|
||||
query = query.filter(pa_dsl::card_network.eq_any(card_network.clone()));
|
||||
}
|
||||
|
||||
if let Some(payment_id) = ¶ms.payment_id {
|
||||
query = query.filter(pi_dsl::id.eq(payment_id.clone()));
|
||||
}
|
||||
|
||||
query
|
||||
}
|
||||
};
|
||||
@ -1561,9 +1562,6 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
.into_boxed();
|
||||
|
||||
query = match constraints {
|
||||
PaymentIntentFetchConstraints::Single { payment_intent_id } => {
|
||||
query.filter(pi_dsl::id.eq(payment_intent_id.to_owned()))
|
||||
}
|
||||
PaymentIntentFetchConstraints::List(params) => {
|
||||
if let Some(customer_id) = ¶ms.customer_id {
|
||||
query = query.filter(pi_dsl::customer_id.eq(customer_id.clone()));
|
||||
@ -1604,15 +1602,19 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
||||
};
|
||||
|
||||
query = match ¶ms.currency {
|
||||
Some(currency) => query.filter(pi_dsl::currency.eq(*currency)),
|
||||
Some(currency) => query.filter(pi_dsl::currency.eq_any(currency.clone())),
|
||||
None => query,
|
||||
};
|
||||
|
||||
query = match ¶ms.status {
|
||||
Some(status) => query.filter(pi_dsl::status.eq(*status)),
|
||||
Some(status) => query.filter(pi_dsl::status.eq_any(status.clone())),
|
||||
None => query,
|
||||
};
|
||||
|
||||
if let Some(payment_id) = ¶ms.payment_id {
|
||||
query = query.filter(pi_dsl::id.eq(payment_id.clone()));
|
||||
}
|
||||
|
||||
query
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user