mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 09:38:33 +08:00
fix(payment): fix max limit on payment intents list (#2014)
Co-authored-by: Apoorv Dixit <apoorv.dixit@juspay.in>
This commit is contained in:
@ -4,7 +4,8 @@ use serde::{Deserialize, Serialize};
|
||||
use time::PrimitiveDateTime;
|
||||
|
||||
use crate::{errors, MerchantStorageScheme};
|
||||
|
||||
const QUERY_LIMIT: u32 = 20;
|
||||
const MAX_LIMIT: u32 = 100;
|
||||
#[async_trait::async_trait]
|
||||
pub trait PaymentIntentInterface {
|
||||
async fn update_payment_intent(
|
||||
@ -353,7 +354,7 @@ pub enum PaymentIntentFetchConstraints {
|
||||
payment_intent_id: String,
|
||||
},
|
||||
List {
|
||||
offset: Option<u32>,
|
||||
offset: u32,
|
||||
starting_at: Option<PrimitiveDateTime>,
|
||||
ending_at: Option<PrimitiveDateTime>,
|
||||
connector: Option<Vec<api_models::enums::Connector>>,
|
||||
@ -370,7 +371,7 @@ pub enum PaymentIntentFetchConstraints {
|
||||
impl From<api_models::payments::PaymentListConstraints> for PaymentIntentFetchConstraints {
|
||||
fn from(value: api_models::payments::PaymentListConstraints) -> Self {
|
||||
Self::List {
|
||||
offset: None,
|
||||
offset: 0,
|
||||
starting_at: value.created_gte.or(value.created_gt).or(value.created),
|
||||
ending_at: value.created_lte.or(value.created_lt).or(value.created),
|
||||
connector: None,
|
||||
@ -380,7 +381,7 @@ impl From<api_models::payments::PaymentListConstraints> for PaymentIntentFetchCo
|
||||
customer_id: value.customer_id,
|
||||
starting_after_id: value.starting_after,
|
||||
ending_before_id: value.ending_before,
|
||||
limit: None,
|
||||
limit: Some(std::cmp::min(value.limit, MAX_LIMIT)),
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -388,7 +389,7 @@ impl From<api_models::payments::PaymentListConstraints> for PaymentIntentFetchCo
|
||||
impl From<api_models::payments::TimeRange> for PaymentIntentFetchConstraints {
|
||||
fn from(value: api_models::payments::TimeRange) -> Self {
|
||||
Self::List {
|
||||
offset: None,
|
||||
offset: 0,
|
||||
starting_at: Some(value.start_time),
|
||||
ending_at: value.end_time,
|
||||
connector: None,
|
||||
@ -409,7 +410,7 @@ impl From<api_models::payments::PaymentListFilterConstraints> for PaymentIntentF
|
||||
Self::Single { payment_intent_id }
|
||||
} else {
|
||||
Self::List {
|
||||
offset: value.offset,
|
||||
offset: value.offset.unwrap_or_default(),
|
||||
starting_at: value.time_range.map(|t| t.start_time),
|
||||
ending_at: value.time_range.and_then(|t| t.end_time),
|
||||
connector: value.connector,
|
||||
@ -419,7 +420,7 @@ impl From<api_models::payments::PaymentListFilterConstraints> for PaymentIntentF
|
||||
customer_id: None,
|
||||
starting_after_id: None,
|
||||
ending_before_id: None,
|
||||
limit: None,
|
||||
limit: Some(QUERY_LIMIT),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user