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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(payments): add merchant order ref id filter (#6630)
Apoorv Dixit57e64c26ca42
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rsindex 06dd7dc796..c0cf816c68 100644--- a/crates/api_models/src/payments.rs+++ b/crates/api_models/src/payments.rs@@ -4927,6 +4927,8 @@ pub struct PaymentListFilterConstraints {pub order: Order,/// The List of all the card networks to filter payments listpub card_network: Option<Vec<enums::CardNetwork>>,+ /// The identifier for merchant order reference id+ pub merchant_order_reference_id: Option<String>,}impl PaymentListFilterConstraints {diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rsindex d10dafe883..b0ffe519d6 100644--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs@@ -1002,6 +1002,7 @@ pub struct PaymentIntentListParams {pub limit: Option<u32>,pub order: api_models::payments::Order,pub card_network: Option<Vec<storage_enums::CardNetwork>>,+ pub merchant_order_reference_id: Option<String>,}impl From<api_models::payments::PaymentListConstraints> for PaymentIntentFetchConstraints {@@ -1036,6 +1037,7 @@ impl From<api_models::payments::PaymentListConstraints> for PaymentIntentFetchColimit: Some(std::cmp::min(limit, PAYMENTS_LIST_MAX_LIMIT_V1)),order: Default::default(),card_network: None,+ merchant_order_reference_id: None,}))}}@@ -1061,6 +1063,7 @@ impl From<common_utils::types::TimeRange> for PaymentIntentFetchConstraints {limit: None,order: Default::default(),card_network: None,+ merchant_order_reference_id: None,}))}}@@ -1084,6 +1087,7 @@ impl From<api_models::payments::PaymentListFilterConstraints> for PaymentIntentFmerchant_connector_id,order,card_network,+ merchant_order_reference_id,} = value;if let Some(payment_intent_id) = payment_id {Self::Single { payment_intent_id }@@ -1107,6 +1111,7 @@ impl From<api_models::payments::PaymentListFilterConstraints> for PaymentIntentFlimit: Some(std::cmp::min(limit, PAYMENTS_LIST_MAX_LIMIT_V2)),order,card_network,+ merchant_order_reference_id,}))}}diff --git a/crates/router/src/types/storage/dispute.rs b/crates/router/src/types/storage/dispute.rsindex 2d42aaa0a8..cf1ff52960 100644--- a/crates/router/src/types/storage/dispute.rs+++ b/crates/router/src/types/storage/dispute.rs@@ -1,6 +1,6 @@use async_bb8_diesel::AsyncRunQueryDsl;use common_utils::errors::CustomResult;-use diesel::{associations::HasTable, ExpressionMethods, QueryDsl};+use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, QueryDsl};pub use diesel_models::dispute::{Dispute, DisputeNew, DisputeUpdate};use diesel_models::{errors, query::generics::db_metrics, schema::dispute::dsl};use error_stack::ResultExt;@@ -43,9 +43,11 @@ impl DisputeDbExt for Dispute {&dispute_list_constraints.dispute_id,) {search_by_payment_or_dispute_id = true;- filter = filter- .filter(dsl::payment_id.eq(payment_id.to_owned()))- .or_filter(dsl::dispute_id.eq(dispute_id.to_owned()));+ filter = filter.filter(+ dsl::payment_id+ .eq(payment_id.to_owned())+ .or(dsl::dispute_id.eq(dispute_id.to_owned())),+ );};if !search_by_payment_or_dispute_id {diff --git a/crates/router/src/types/storage/refund.rs b/crates/router/src/types/storage/refund.rsindex 8076c2c7a6..e46fc1a3f4 100644--- a/crates/router/src/types/storage/refund.rs+++ b/crates/router/src/types/storage/refund.rs@@ -1,7 +1,7 @@use api_models::payments::AmountFilter;use async_bb8_diesel::AsyncRunQueryDsl;use common_utils::errors::CustomResult;-use diesel::{associations::HasTable, ExpressionMethods, QueryDsl};+use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, QueryDsl};pub use diesel_models::refund::{Refund, RefundCoreWorkflow, RefundNew, RefundUpdate, RefundUpdateInternal,};@@ -67,8 +67,11 @@ impl RefundDbExt for Refund {) {search_by_pay_or_ref_id = true;filter = filter- .filter(dsl::payment_id.eq(pid.to_owned()))- .or_filter(dsl::refund_id.eq(ref_id.to_owned()))+ .filter(+ dsl::payment_id+ .eq(pid.to_owned())+ .or(dsl::refund_id.eq(ref_id.to_owned())),+ ).limit(limit).offset(offset);};@@ -228,9 +231,11 @@ impl RefundDbExt for Refund {&refund_list_details.refund_id,) {search_by_pay_or_ref_id = true;- filter = filter- .filter(dsl::payment_id.eq(pid.to_owned()))- .or_filter(dsl::refund_id.eq(ref_id.to_owned()));+ filter = filter.filter(+ dsl::payment_id+ .eq(pid.to_owned())+ .or(dsl::refund_id.eq(ref_id.to_owned())),+ );};if !search_by_pay_or_ref_id {diff --git a/crates/storage_impl/src/payments/payment_intent.rs b/crates/storage_impl/src/payments/payment_intent.rsindex f26cf876ad..15f1aa2437 100644--- a/crates/storage_impl/src/payments/payment_intent.rs+++ b/crates/storage_impl/src/payments/payment_intent.rs@@ -871,6 +871,12 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {query = query.filter(pi_dsl::customer_id.eq(customer_id.clone()));}+ if let Some(merchant_order_reference_id) = ¶ms.merchant_order_reference_id {+ query = query.filter(+ pi_dsl::merchant_order_reference_id.eq(merchant_order_reference_id.clone()),+ )+ }+if let Some(profile_id) = ¶ms.profile_id {query = query.filter(pi_dsl::profile_id.eq_any(profile_id.clone()));}@@ -1041,6 +1047,11 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {if let Some(customer_id) = ¶ms.customer_id {query = query.filter(pi_dsl::customer_id.eq(customer_id.clone()));}+ if let Some(merchant_order_reference_id) = ¶ms.merchant_order_reference_id {+ query = query.filter(+ pi_dsl::merchant_order_reference_id.eq(merchant_order_reference_id.clone()),+ )+ }if let Some(profile_id) = ¶ms.profile_id {query = query.filter(pi_dsl::profile_id.eq_any(profile_id.clone()));}