mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 01:27:31 +08:00
feat(payments): add merchant order ref id filter (#6630)
This commit is contained in:
@ -4927,6 +4927,8 @@ pub struct PaymentListFilterConstraints {
|
|||||||
pub order: Order,
|
pub order: Order,
|
||||||
/// The List of all the card networks to filter payments list
|
/// The List of all the card networks to filter payments list
|
||||||
pub card_network: Option<Vec<enums::CardNetwork>>,
|
pub card_network: Option<Vec<enums::CardNetwork>>,
|
||||||
|
/// The identifier for merchant order reference id
|
||||||
|
pub merchant_order_reference_id: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl PaymentListFilterConstraints {
|
impl PaymentListFilterConstraints {
|
||||||
|
|||||||
@ -1002,6 +1002,7 @@ pub struct PaymentIntentListParams {
|
|||||||
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>>,
|
pub card_network: Option<Vec<storage_enums::CardNetwork>>,
|
||||||
|
pub merchant_order_reference_id: Option<String>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<api_models::payments::PaymentListConstraints> for PaymentIntentFetchConstraints {
|
impl From<api_models::payments::PaymentListConstraints> for PaymentIntentFetchConstraints {
|
||||||
@ -1036,6 +1037,7 @@ impl From<api_models::payments::PaymentListConstraints> for PaymentIntentFetchCo
|
|||||||
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,
|
card_network: None,
|
||||||
|
merchant_order_reference_id: None,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1061,6 +1063,7 @@ impl From<common_utils::types::TimeRange> for PaymentIntentFetchConstraints {
|
|||||||
limit: None,
|
limit: None,
|
||||||
order: Default::default(),
|
order: Default::default(),
|
||||||
card_network: None,
|
card_network: None,
|
||||||
|
merchant_order_reference_id: None,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1084,6 +1087,7 @@ impl From<api_models::payments::PaymentListFilterConstraints> for PaymentIntentF
|
|||||||
merchant_connector_id,
|
merchant_connector_id,
|
||||||
order,
|
order,
|
||||||
card_network,
|
card_network,
|
||||||
|
merchant_order_reference_id,
|
||||||
} = 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 }
|
||||||
@ -1107,6 +1111,7 @@ impl From<api_models::payments::PaymentListFilterConstraints> for PaymentIntentF
|
|||||||
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,
|
card_network,
|
||||||
|
merchant_order_reference_id,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,6 +1,6 @@
|
|||||||
use async_bb8_diesel::AsyncRunQueryDsl;
|
use async_bb8_diesel::AsyncRunQueryDsl;
|
||||||
use common_utils::errors::CustomResult;
|
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};
|
pub use diesel_models::dispute::{Dispute, DisputeNew, DisputeUpdate};
|
||||||
use diesel_models::{errors, query::generics::db_metrics, schema::dispute::dsl};
|
use diesel_models::{errors, query::generics::db_metrics, schema::dispute::dsl};
|
||||||
use error_stack::ResultExt;
|
use error_stack::ResultExt;
|
||||||
@ -43,9 +43,11 @@ impl DisputeDbExt for Dispute {
|
|||||||
&dispute_list_constraints.dispute_id,
|
&dispute_list_constraints.dispute_id,
|
||||||
) {
|
) {
|
||||||
search_by_payment_or_dispute_id = true;
|
search_by_payment_or_dispute_id = true;
|
||||||
filter = filter
|
filter = filter.filter(
|
||||||
.filter(dsl::payment_id.eq(payment_id.to_owned()))
|
dsl::payment_id
|
||||||
.or_filter(dsl::dispute_id.eq(dispute_id.to_owned()));
|
.eq(payment_id.to_owned())
|
||||||
|
.or(dsl::dispute_id.eq(dispute_id.to_owned())),
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
if !search_by_payment_or_dispute_id {
|
if !search_by_payment_or_dispute_id {
|
||||||
|
|||||||
@ -1,7 +1,7 @@
|
|||||||
use api_models::payments::AmountFilter;
|
use api_models::payments::AmountFilter;
|
||||||
use async_bb8_diesel::AsyncRunQueryDsl;
|
use async_bb8_diesel::AsyncRunQueryDsl;
|
||||||
use common_utils::errors::CustomResult;
|
use common_utils::errors::CustomResult;
|
||||||
use diesel::{associations::HasTable, ExpressionMethods, QueryDsl};
|
use diesel::{associations::HasTable, BoolExpressionMethods, ExpressionMethods, QueryDsl};
|
||||||
pub use diesel_models::refund::{
|
pub use diesel_models::refund::{
|
||||||
Refund, RefundCoreWorkflow, RefundNew, RefundUpdate, RefundUpdateInternal,
|
Refund, RefundCoreWorkflow, RefundNew, RefundUpdate, RefundUpdateInternal,
|
||||||
};
|
};
|
||||||
@ -67,8 +67,11 @@ impl RefundDbExt for Refund {
|
|||||||
) {
|
) {
|
||||||
search_by_pay_or_ref_id = true;
|
search_by_pay_or_ref_id = true;
|
||||||
filter = filter
|
filter = filter
|
||||||
.filter(dsl::payment_id.eq(pid.to_owned()))
|
.filter(
|
||||||
.or_filter(dsl::refund_id.eq(ref_id.to_owned()))
|
dsl::payment_id
|
||||||
|
.eq(pid.to_owned())
|
||||||
|
.or(dsl::refund_id.eq(ref_id.to_owned())),
|
||||||
|
)
|
||||||
.limit(limit)
|
.limit(limit)
|
||||||
.offset(offset);
|
.offset(offset);
|
||||||
};
|
};
|
||||||
@ -228,9 +231,11 @@ impl RefundDbExt for Refund {
|
|||||||
&refund_list_details.refund_id,
|
&refund_list_details.refund_id,
|
||||||
) {
|
) {
|
||||||
search_by_pay_or_ref_id = true;
|
search_by_pay_or_ref_id = true;
|
||||||
filter = filter
|
filter = filter.filter(
|
||||||
.filter(dsl::payment_id.eq(pid.to_owned()))
|
dsl::payment_id
|
||||||
.or_filter(dsl::refund_id.eq(ref_id.to_owned()));
|
.eq(pid.to_owned())
|
||||||
|
.or(dsl::refund_id.eq(ref_id.to_owned())),
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
if !search_by_pay_or_ref_id {
|
if !search_by_pay_or_ref_id {
|
||||||
|
|||||||
@ -871,6 +871,12 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
|
|||||||
query = query.filter(pi_dsl::customer_id.eq(customer_id.clone()));
|
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 {
|
if let Some(profile_id) = ¶ms.profile_id {
|
||||||
query = query.filter(pi_dsl::profile_id.eq_any(profile_id.clone()));
|
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 {
|
if let Some(customer_id) = ¶ms.customer_id {
|
||||||
query = query.filter(pi_dsl::customer_id.eq(customer_id.clone()));
|
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 {
|
if let Some(profile_id) = ¶ms.profile_id {
|
||||||
query = query.filter(pi_dsl::profile_id.eq_any(profile_id.clone()));
|
query = query.filter(pi_dsl::profile_id.eq_any(profile_id.clone()));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user