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(Customer): Added search Feature to the Customer Page (#9619)
Venu Madhav Bandarupallie186a0f4f4c5
diff --git a/crates/api_models/src/customers.rs b/crates/api_models/src/customers.rsindex 19016e292a..62fd000ddb 100644--- a/crates/api_models/src/customers.rs+++ b/crates/api_models/src/customers.rs@@ -52,6 +52,8 @@ pub struct CustomerListRequest {/// Limit#[schema(example = 32)]pub limit: Option<u16>,+ /// Unique identifier for a customer+ pub customer_id: Option<id_type::CustomerId>,}#[cfg(feature = "v1")]diff --git a/crates/diesel_models/src/query/customers.rs b/crates/diesel_models/src/query/customers.rsindex def8d77fe7..a6121d408c 100644--- a/crates/diesel_models/src/query/customers.rs+++ b/crates/diesel_models/src/query/customers.rs@@ -20,6 +20,7 @@ impl CustomerNew {pub struct CustomerListConstraints {pub limit: i64,pub offset: Option<i64>,+ pub customer_id: Option<id_type::CustomerId>,}impl Customer {@@ -54,19 +55,66 @@ impl Customer {generics::generic_find_by_id::<<Self as HasTable>::Table, _, _>(conn, id.to_owned()).await}+ #[cfg(feature = "v1")]pub async fn list_by_merchant_id(conn: &PgPooledConn,merchant_id: &id_type::MerchantId,constraints: CustomerListConstraints,) -> StorageResult<Vec<Self>> {- generics::generic_filter::<<Self as HasTable>::Table, _, _, _>(- conn,- dsl::merchant_id.eq(merchant_id.to_owned()),- Some(constraints.limit),- constraints.offset,- Some(dsl::created_at),- )- .await+ if let Some(customer_id) = constraints.customer_id {+ let predicate = dsl::merchant_id+ .eq(merchant_id.clone())+ .and(dsl::customer_id.eq(customer_id));+ generics::generic_filter::<<Self as HasTable>::Table, _, _, Self>(+ conn,+ predicate,+ Some(constraints.limit),+ constraints.offset,+ Some(dsl::created_at),+ )+ .await+ } else {+ let predicate = dsl::merchant_id.eq(merchant_id.clone());+ generics::generic_filter::<<Self as HasTable>::Table, _, _, Self>(+ conn,+ predicate,+ Some(constraints.limit),+ constraints.offset,+ Some(dsl::created_at),+ )+ .await+ }+ }++ #[cfg(feature = "v2")]+ pub async fn list_by_merchant_id(+ conn: &PgPooledConn,+ merchant_id: &id_type::MerchantId,+ constraints: CustomerListConstraints,+ ) -> StorageResult<Vec<Self>> {+ if let Some(customer_id) = constraints.customer_id {+ let predicate = dsl::merchant_id+ .eq(merchant_id.clone())+ .and(dsl::merchant_reference_id.eq(customer_id));+ generics::generic_filter::<<Self as HasTable>::Table, _, _, Self>(+ conn,+ predicate,+ Some(constraints.limit),+ constraints.offset,+ Some(dsl::created_at),+ )+ .await+ } else {+ let predicate = dsl::merchant_id.eq(merchant_id.clone());+ generics::generic_filter::<<Self as HasTable>::Table, _, _, Self>(+ conn,+ predicate,+ Some(constraints.limit),+ constraints.offset,+ Some(dsl::created_at),+ )+ .await+ }}#[cfg(feature = "v2")]diff --git a/crates/hyperswitch_domain_models/src/customer.rs b/crates/hyperswitch_domain_models/src/customer.rsindex 5a88cb6cd4..720296cdca 100644--- a/crates/hyperswitch_domain_models/src/customer.rs+++ b/crates/hyperswitch_domain_models/src/customer.rs@@ -538,6 +538,7 @@ impl From<CustomerUpdate> for CustomerUpdateInternal {pub struct CustomerListConstraints {pub limit: u16,pub offset: Option<u32>,+ pub customer_id: Option<id_type::CustomerId>,}impl From<CustomerListConstraints> for query::CustomerListConstraints {@@ -545,6 +546,7 @@ impl From<CustomerListConstraints> for query::CustomerListConstraints {Self {limit: i64::from(value.limit),offset: value.offset.map(i64::from),+ customer_id: value.customer_id,}}}diff --git a/crates/router/src/core/customers.rs b/crates/router/src/core/customers.rsindex ffc4478103..09f12d62ba 100644--- a/crates/router/src/core/customers.rs+++ b/crates/router/src/core/customers.rs@@ -590,6 +590,7 @@ pub async fn list_customers(.limit.unwrap_or(crate::consts::DEFAULT_LIST_API_LIMIT),offset: request.offset,+ customer_id: request.customer_id,};let domain_customers = dbdiff --git a/crates/router/src/core/locker_migration.rs b/crates/router/src/core/locker_migration.rsindex e2680666e4..bea3ff4e58 100644--- a/crates/router/src/core/locker_migration.rs+++ b/crates/router/src/core/locker_migration.rs@@ -54,6 +54,7 @@ pub async fn rust_locker_migration(let constraints = CustomerListConstraints {limit: u16::MAX,offset: None,+ customer_id: None,};let domain_customers = db