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): add PaymentListFilterConstraints and payments_list_by_filter endpoint for v2 (#8794)

Ayush Anand47ae9908e1b3
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 00d83f7965..5d302db614 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -2441,11 +2441,10 @@
"description": "The connector to filter payments list",
"required": true,
"schema": {
- "allOf": [
- {
- "$ref": "#/components/schemas/Connector"
- }
- ],
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Connector"
+ },
"nullable": true
}
},
@@ -2455,11 +2454,10 @@
"description": "The currency to filter payments list",
"required": true,
"schema": {
- "allOf": [
- {
- "$ref": "#/components/schemas/Currency"
- }
- ],
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/Currency"
+ },
"nullable": true
}
},
@@ -2469,11 +2467,10 @@
"description": "The payment status to filter payments list",
"required": true,
"schema": {
- "allOf": [
- {
- "$ref": "#/components/schemas/IntentStatus"
- }
- ],
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/IntentStatus"
+ },
"nullable": true
}
},
@@ -2483,11 +2480,10 @@
"description": "The payment method type to filter payments list",
"required": true,
"schema": {
- "allOf": [
- {
- "$ref": "#/components/schemas/PaymentMethod"
- }
- ],
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/PaymentMethod"
+ },
"nullable": true
}
},
@@ -2497,11 +2493,10 @@
"description": "The payment method subtype to filter payments list",
"required": true,
"schema": {
- "allOf": [
- {
- "$ref": "#/components/schemas/PaymentMethodType"
- }
- ],
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/PaymentMethodType"
+ },
"nullable": true
}
},
@@ -2511,11 +2506,10 @@
"description": "The authentication type to filter payments list",
"required": true,
"schema": {
- "allOf": [
- {
- "$ref": "#/components/schemas/AuthenticationType"
- }
- ],
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/AuthenticationType"
+ },
"nullable": true
}
},
@@ -2525,7 +2519,10 @@
"description": "The merchant connector id to filter payments list",
"required": true,
"schema": {
- "type": "string",
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
"nullable": true
}
},
@@ -2553,11 +2550,10 @@
"description": "The card networks to filter payments list",
"required": true,
"schema": {
- "allOf": [
- {
- "$ref": "#/components/schemas/CardNetwork"
- }
- ],
+ "type": "array",
+ "items": {
+ "$ref": "#/components/schemas/CardNetwork"
+ },
"nullable": true
}
},
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index e50c37821b..61ee499850 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -26,9 +26,39 @@ use common_utils::{
pii::{self, Email},
types::{MinorUnit, StringMajorUnit},
};
-#[cfg(feature = "v2")]
-use deserialize_form_style_query_parameter::option_form_vec_deserialize;
use error_stack::ResultExt;
+
+#[cfg(feature = "v2")]
+fn parse_comma_separated<'de, D, T>(v: D) -> Result<Option<Vec<T>>, D::Error>
+where
+ D: serde::Deserializer<'de>,
+ T: std::str::FromStr,
+ <T as std::str::FromStr>::Err: std::fmt::Debug + std::fmt::Display + std::error::Error,
+{
+ let opt_str: Option<String> = Option::deserialize(v)?;
+ match opt_str {
+ Some(s) if s.is_empty() => Ok(None),
+ Some(s) => {
+ // Estimate capacity based on comma count
+ let capacity = s.matches(',').count() + 1;
+ let mut result = Vec::with_capacity(capacity);
+
+ for item in s.split(',') {
+ let trimmed_item = item.trim();
+ if !trimmed_item.is_empty() {
+ let parsed_item = trimmed_item.parse::<T>().map_err(|e| {
+ <D::Error as serde::de::Error>::custom(format!(
+ "Invalid value '{trimmed_item}': {e}"
+ ))
+ })?;
+ result.push(parsed_item);
+ }
+ }
+ Ok(Some(result))
+ }
+ None => Ok(None),
+ }
+}
use masking::{PeekInterface, Secret, WithType};
use router_derive::Setter;
#[cfg(feature = "v1")]
@@ -6279,26 +6309,33 @@ pub struct PaymentListConstraints {
/// The end amount to filter list of transactions which are less than or equal to the end amount
pub end_amount: Option<i64>,
/// The connector to filter payments list
- #[param(value_type = Option<Connector>)]
- pub connector: Option<api_enums::Connector>,
+ #[param(value_type = Option<Vec<Connector>>)]
+ #[serde(deserialize_with = "parse_comma_separated", default)]
+ pub connector: Option<Vec<api_enums::Connector>>,
/// The currency to filter payments list
- #[param(value_type = Option<Currency>)]
- pub currency: Option<enums::Currency>,
+ #[param(value_type = Option<Vec<Currency>>)]
+ #[serde(deserialize_with = "parse_comma_separated", default)]
+ pub currency: Option<Vec<enums::Currency>>,
/// The payment status to filter payments list
- #[param(value_type = Option<IntentStatus>)]
- pub status: Option<enums::IntentStatus>,
+ #[param(value_type = Option<Vec<IntentStatus>>)]
+ #[serde(deserialize_with = "parse_comma_separated", default)]
+ pub status: Option<Vec<enums::IntentStatus>>,
/// The payment method type to filter payments list
- #[param(value_type = Option<PaymentMethod>)]
- pub payment_method_type: Option<enums::PaymentMethod>,
+ #[param(value_type = Option<Vec<PaymentMethod>>)]
+ #[serde(deserialize_with = "parse_comma_separated", default)]
+ pub payment_method_type: Option<Vec<enums::PaymentMethod>>,
/// The payment method subtype to filter payments list
- #[param(value_type = Option<PaymentMethodType>)]
- pub payment_method_subtype: Option<enums::PaymentMethodType>,
+ #[param(value_type = Option<Vec<PaymentMethodType>>)]
+ #[serde(deserialize_with = "parse_comma_separated", default)]
+ pub payment_method_subtype: Option<Vec<enums::PaymentMethodType>>,
/// The authentication type to filter payments list
- #[param(value_type = Option<AuthenticationType>)]
- pub authentication_type: Option<enums::AuthenticationType>,
+ #[param(value_type = Option<Vec<AuthenticationType>>)]
+ #[serde(deserialize_with = "parse_comma_separated", default)]
+ pub authentication_type: Option<Vec<enums::AuthenticationType>>,
/// The merchant connector id to filter payments list
- #[param(value_type = Option<String>)]
- pub merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
+ #[param(value_type = Option<Vec<String>>)]
+ #[serde(deserialize_with = "parse_comma_separated", default)]
+ pub merchant_connector_id: Option<Vec<id_type::MerchantConnectorAccountId>>,
/// The field on which the payments list should be sorted
#[serde(default)]
pub order_on: SortOn,
@@ -6306,8 +6343,9 @@ pub struct PaymentListConstraints {
#[serde(default)]
pub order_by: SortBy,
/// The card networks to filter payments list
- #[param(value_type = Option<CardNetwork>)]
- pub card_network: Option<enums::CardNetwork>,
+ #[param(value_type = Option<Vec<CardNetwork>>)]
+ #[serde(deserialize_with = "parse_comma_separated", default)]
+ pub card_network: Option<Vec<enums::CardNetwork>>,
/// The identifier for merchant order reference id
pub merchant_order_reference_id: Option<String>,
}
@@ -8004,7 +8042,7 @@ pub struct ListMethodsForPaymentsRequest {
pub client_secret: Option<String>,
/// The two-letter ISO currency code
- #[serde(deserialize_with = "option_form_vec_deserialize", default)]
+ #[serde(deserialize_with = "parse_comma_separated", default)]
#[schema(value_type = Option<Vec<CountryAlpha2>>, example = json!(["US", "UK", "IN"]))]
pub accepted_countries: Option<Vec<api_enums::CountryAlpha2>>,
@@ -8013,7 +8051,7 @@ pub struct ListMethodsForPaymentsRequest {
pub amount: Option<MinorUnit>,
/// The three-letter ISO currency code
- #[serde(deserialize_with = "option_form_vec_deserialize", default)]
+ #[serde(deserialize_with = "parse_comma_separated", default)]
#[schema(value_type = Option<Vec<Currency>>,example = json!(["USD", "EUR"]))]
pub accepted_currencies: Option<Vec<api_enums::Currency>>,
@@ -8022,7 +8060,7 @@ pub struct ListMethodsForPaymentsRequest {
pub recurring_enabled: Option<bool>,
/// Indicates whether the payment method is eligible for card networks
- #[serde(deserialize_with = "option_form_vec_deserialize", default)]
+ #[serde(deserialize_with = "parse_comma_separated", default)]
#[schema(value_type = Option<Vec<CardNetwork>>, example = json!(["visa", "mastercard"]))]
pub card_networks: Option<Vec<api_enums::CardNetwork>>,
diff --git a/crates/common_utils/src/id_type/merchant_connector_account.rs b/crates/common_utils/src/id_type/merchant_connector_account.rs
index f1bdb171b2..df8d1c3b3a 100644
--- a/crates/common_utils/src/id_type/merchant_connector_account.rs
+++ b/crates/common_utils/src/id_type/merchant_connector_account.rs
@@ -1,3 +1,5 @@
+use std::str::FromStr;
+
use crate::errors::{CustomResult, ValidationError};
crate::id_type!(
@@ -21,3 +23,11 @@ impl MerchantConnectorAccountId {
Self::try_from(std::borrow::Cow::from(merchant_connector_account_id))
}
}
+
+impl FromStr for MerchantConnectorAccountId {
+ type Err = std::fmt::Error;
+
+ fn from_str(s: &str) -> Result<Self, Self::Err> {
+ Self::try_from(std::borrow::Cow::Owned(s.to_string())).map_err(|_| std::fmt::Error)
+ }
+}
diff --git a/crates/diesel_models/src/query/payment_attempt.rs b/crates/diesel_models/src/query/payment_attempt.rs
index a7baf75f06..b1934ae5ab 100644
--- a/crates/diesel_models/src/query/payment_attempt.rs
+++ b/crates/diesel_models/src/query/payment_attempt.rs
@@ -437,12 +437,12 @@ impl PaymentAttempt {
conn: &PgPooledConn,
merchant_id: &common_utils::id_type::MerchantId,
active_attempt_ids: &[String],
- connector: Option<String>,
- payment_method_type: Option<enums::PaymentMethod>,
- payment_method_subtype: Option<enums::PaymentMethodType>,
- authentication_type: Option<enums::AuthenticationType>,
- merchant_connector_id: Option<common_utils::id_type::MerchantConnectorAccountId>,
- card_network: Option<enums::CardNetwork>,
+ connector: Option<Vec<String>>,
+ payment_method_type: Option<Vec<enums::PaymentMethod>>,
+ payment_method_subtype: Option<Vec<enums::PaymentMethodType>>,
+ authentication_type: Option<Vec<enums::AuthenticationType>>,
+ merchant_connector_id: Option<Vec<common_utils::id_type::MerchantConnectorAccountId>>,
+ card_network: Option<Vec<enums::CardNetwork>>,
) -> StorageResult<i64> {
let mut filter = <Self as HasTable>::table()
.count()
@@ -450,24 +450,24 @@ impl PaymentAttempt {
.filter(dsl::id.eq_any(active_attempt_ids.to_owned()))
.into_boxed();
- if let Some(connector) = connector {
- filter = filter.filter(dsl::connector.eq(connector));
+ if let Some(connectors) = connector {
+ filter = filter.filter(dsl::connector.eq_any(connectors));
}
- if let Some(payment_method_type) = payment_method_type {
- filter = filter.filter(dsl::payment_method_type_v2.eq(payment_method_type));
+ if let Some(payment_method_types) = payment_method_type {
+ filter = filter.filter(dsl::payment_method_type_v2.eq_any(payment_method_types));
}
- if let Some(payment_method_subtype) = payment_method_subtype {
- filter = filter.filter(dsl::payment_method_subtype.eq(payment_method_subtype));
+ if let Some(payment_method_subtypes) = payment_method_subtype {
+ filter = filter.filter(dsl::payment_method_subtype.eq_any(payment_method_subtypes));
}
- if let Some(authentication_type) = authentication_type {
- filter = filter.filter(dsl::authentication_type.eq(authentication_type));
+ if let Some(authentication_types) = authentication_type {
+ filter = filter.filter(dsl::authentication_type.eq_any(authentication_types));
}
- if let Some(merchant_connector_id) = merchant_connector_id {
- filter = filter.filter(dsl::merchant_connector_id.eq(merchant_connector_id))
+ if let Some(merchant_connector_ids) = merchant_connector_id {
+ filter = filter.filter(dsl::merchant_connector_id.eq_any(merchant_connector_ids));
}
- if let Some(card_network) = card_network {
- filter = filter.filter(dsl::card_network.eq(card_network))
+ if let Some(card_networks) = card_network {
+ filter = filter.filter(dsl::card_network.eq_any(card_networks));
}
router_env::logger::debug!(query = %debug_query::<Pg, _>(&filter).to_string());
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
index c29c4d6020..755d9f79c4 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
@@ -235,12 +235,12 @@ pub trait PaymentAttemptInterface {
&self,
merchant_id: &id_type::MerchantId,
active_attempt_ids: &[String],
- connector: Option<api_models::enums::Connector>,
- payment_method_type: Option<storage_enums::PaymentMethod>,
- payment_method_subtype: Option<storage_enums::PaymentMethodType>,
- authentication_type: Option<storage_enums::AuthenticationType>,
- merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
- card_network: Option<storage_enums::CardNetwork>,
+ connector: Option<Vec<api_models::enums::Connector>>,
+ payment_method_type: Option<Vec<storage_enums::PaymentMethod>>,
+ payment_method_subtype: Option<Vec<storage_enums::PaymentMethodType>>,
+ authentication_type: Option<Vec<storage_enums::AuthenticationType>>,
+ merchant_connector_id: Option<Vec<id_type::MerchantConnectorAccountId>>,
+ card_network: Option<Vec<storage_enums::CardNetwork>>,
storage_scheme: storage_enums::MerchantStorageScheme,
) -> error_stack::Result<i64, Self::Error>;
}
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
index 60158ebdc1..c96209d2b4 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
@@ -1340,20 +1340,14 @@ impl PaymentIntentFetchConstraints {
#[cfg(feature = "v2")]
pub enum PaymentIntentFetchConstraints {
- Single {
- payment_intent_id: id_type::GlobalPaymentId,
- },
List(Box<PaymentIntentListParams>),
}
#[cfg(feature = "v2")]
impl PaymentIntentFetchConstraints {
pub fn get_profile_id(&self) -> Option<id_type::ProfileId> {
- if let Self::List(pi_list_params) = self {
- pi_list_params.profile_id.clone()
- } else {
- None
- }
+ let Self::List(pi_list_params) = self;
+ pi_list_params.profile_id.clone()
}
}
@@ -1387,21 +1381,22 @@ pub struct PaymentIntentListParams {
pub starting_at: Option<PrimitiveDateTime>,
pub ending_at: Option<PrimitiveDateTime>,
pub amount_filter: Option<api_models::payments::AmountFilter>,
- pub connector: Option<api_models::enums::Connector>,
- pub currency: Option<common_enums::Currency>,
- pub status: Option<common_enums::IntentStatus>,
- pub payment_method_type: Option<common_enums::PaymentMethod>,
- pub payment_method_subtype: Option<common_enums::PaymentMethodType>,
- pub authentication_type: Option<common_enums::AuthenticationType>,
- pub merchant_connector_id: Option<id_type::MerchantConnectorAccountId>,
+ pub connector: Option<Vec<api_models::enums::Connector>>,
+ pub currency: Option<Vec<common_enums::Currency>>,
+ pub status: Option<Vec<common_enums::IntentStatus>>,
+ pub payment_method_type: Option<Vec<common_enums::PaymentMethod>>,
+ pub payment_method_subtype: Option<Vec<common_enums::PaymentMethodType>>,
+ pub authentication_type: Option<Vec<common_enums::AuthenticationType>>,
+ pub merchant_connector_id: Option<Vec<id_type::MerchantConnectorAccountId>>,
pub profile_id: Option<id_type::ProfileId>,
pub customer_id: Option<id_type::GlobalCustomerId>,
pub starting_after_id: Option<id_type::GlobalPaymentId>,
pub ending_before_id: Option<id_type::GlobalPaymentId>,
pub limit: Option<u32>,
pub order: api_models::payments::Order,
- pub card_network: Option<common_enums::CardNetwork>,
+ pub card_network: Option<Vec<common_enums::CardNetwork>>,
pub merchant_order_reference_id: Option<String>,
+ pub payment_id: Option<id_type::GlobalPaymentId>,
}
#[cfg(feature = "v1")]
@@ -1473,39 +1468,36 @@ impl From<api_models::payments::PaymentListConstraints> for PaymentIntentFetchCo
merchant_order_reference_id,
offset,
} = value;
- if let Some(payment_intent_id) = payment_id {
- Self::Single { payment_intent_id }
- } else {
- Self::List(Box::new(PaymentIntentListParams {
- offset: offset.unwrap_or_default(),
- starting_at: created_gte.or(created_gt).or(created),
- ending_at: created_lte.or(created_lt).or(created),
- amount_filter: (start_amount.is_some() || end_amount.is_some()).then_some({
- api_models::payments::AmountFilter {
- start_amount,
- end_amount,
- }
- }),
- connector,
- currency,
- status,
- payment_method_type,
- payment_method_subtype,
- authentication_type,
- merchant_connector_id,
- profile_id,
- customer_id,
- starting_after_id: starting_after,
- ending_before_id: ending_before,
- limit: Some(std::cmp::min(limit, PAYMENTS_LIST_MAX_LIMIT_V1)),
- order: api_models::payments::Order {
- on: order_on,
- by: order_by,
- },
- card_network,
- merchant_order_reference_id,
- }))
- }
+ Self::List(Box::new(PaymentIntentListParams {
+ offset: offset.unwrap_or_default(),
+ starting_at: created_gte.or(created_gt).or(created),
+ ending_at: created_lte.or(created_lt).or(created),
+ amount_filter: (start_amount.is_some() || end_amount.is_some()).then_some({
+ api_models::payments::AmountFilter {
+ start_amount,
+ end_amount,
+ }
+ }),
+ connector,
+ currency,
+ status,
+ payment_method_type,
+ payment_method_subtype,
+ authentication_type,
+ merchant_connector_id,
+ profile_id,
+ customer_id,
+ starting_after_id: starting_after,
+ ending_before_id: ending_before,
+ limit: Some(std::cmp::min(limit, PAYMENTS_LIST_MAX_LIMIT_V1)),
+ order: api_models::payments::Order {
+ on: order_on,
+ by: order_by,
+ },
+ card_network,
+ merchant_order_reference_id,
+ payment_id,
+ }))
}
}
diff --git a/crates/router/src/db/kafka_store.rs b/crates/router/src/db/kafka_store.rs
index 43be476f68..9eaef17b9c 100644
--- a/crates/router/src/db/kafka_store.rs
+++ b/crates/router/src/db/kafka_store.rs
@@ -1827,12 +1827,12 @@ impl PaymentAttemptInterface for KafkaStore {
&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>,
- merchant_connector_id: Option<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<id_type::MerchantConnectorAccountId>>,
+ card_network: Option<Vec<common_enums::CardNetwork>>,
storage_scheme: MerchantStorageScheme,
) -> CustomResult<i64, errors::StorageError> {
self.diesel_store
diff --git a/crates/storage_impl/src/mock_db/payment_attempt.rs b/crates/storage_impl/src/mock_db/payment_attempt.rs
index ec27f9bed6..0268bc93ac 100644
--- a/crates/storage_impl/src/mock_db/payment_attempt.rs
+++ b/crates/storage_impl/src/mock_db/payment_attempt.rs
@@ -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)?
diff --git a/crates/storage_impl/src/payments/payment_attempt.rs b/crates/storage_impl/src/payments/payment_attempt.rs
index 5ddf5d5018..5424ad964e 100644
--- a/crates/storage_impl/src/payments/payment_attempt.rs
+++ b/crates/storage_impl/src/payments/payment_attempt.rs
@@ -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
diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rs
index d054a4b165..4eb3fad60a 100644
--- a/crates/storage_impl/src/payments/payment_intent.rs
+++ b/crates/storage_impl/src/payments/payment_intent.rs
@@ -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 &params.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 &params.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 &params.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 &params.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 &params.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 &params.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 &params.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) = &params.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) = &params.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) = &params.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 &params.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 &params.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) = &params.payment_id {
+ query = query.filter(pi_dsl::id.eq(payment_id.clone()));
+ }
+
query
}
};