mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 17:19:15 +08:00
feat(router): add profile id and extra filters in lists (#2379)
This commit is contained in:
@ -79,12 +79,15 @@ pub trait PaymentAttemptInterface {
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<PaymentListFilters, errors::StorageError>;
|
||||
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
async fn get_total_count_of_filtered_payment_attempts(
|
||||
&self,
|
||||
merchant_id: &str,
|
||||
active_attempt_ids: &[String],
|
||||
connector: Option<Vec<Connector>>,
|
||||
payment_methods: Option<Vec<storage_enums::PaymentMethod>>,
|
||||
payment_method: Option<Vec<storage_enums::PaymentMethod>>,
|
||||
payment_method_type: Option<Vec<storage_enums::PaymentMethodType>>,
|
||||
authentication_type: Option<Vec<storage_enums::AuthenticationType>>,
|
||||
storage_scheme: MerchantStorageScheme,
|
||||
) -> error_stack::Result<i64, errors::StorageError>;
|
||||
}
|
||||
@ -147,6 +150,8 @@ pub struct PaymentListFilters {
|
||||
pub currency: Vec<storage_enums::Currency>,
|
||||
pub status: Vec<storage_enums::IntentStatus>,
|
||||
pub payment_method: Vec<storage_enums::PaymentMethod>,
|
||||
pub payment_method_type: Vec<storage_enums::PaymentMethodType>,
|
||||
pub authentication_type: Vec<storage_enums::AuthenticationType>,
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug, Default, Serialize, Deserialize)]
|
||||
|
||||
@ -391,57 +391,66 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
|
||||
}
|
||||
|
||||
pub enum PaymentIntentFetchConstraints {
|
||||
Single {
|
||||
payment_intent_id: String,
|
||||
},
|
||||
List {
|
||||
offset: u32,
|
||||
starting_at: Option<PrimitiveDateTime>,
|
||||
ending_at: Option<PrimitiveDateTime>,
|
||||
connector: Option<Vec<api_models::enums::Connector>>,
|
||||
currency: Option<Vec<storage_enums::Currency>>,
|
||||
status: Option<Vec<storage_enums::IntentStatus>>,
|
||||
payment_methods: Option<Vec<storage_enums::PaymentMethod>>,
|
||||
customer_id: Option<String>,
|
||||
starting_after_id: Option<String>,
|
||||
ending_before_id: Option<String>,
|
||||
limit: Option<u32>,
|
||||
},
|
||||
Single { payment_intent_id: String },
|
||||
List(Box<PaymentIntentListParams>),
|
||||
}
|
||||
|
||||
pub struct PaymentIntentListParams {
|
||||
pub offset: u32,
|
||||
pub starting_at: Option<PrimitiveDateTime>,
|
||||
pub ending_at: Option<PrimitiveDateTime>,
|
||||
pub connector: Option<Vec<api_models::enums::Connector>>,
|
||||
pub currency: Option<Vec<storage_enums::Currency>>,
|
||||
pub status: Option<Vec<storage_enums::IntentStatus>>,
|
||||
pub payment_method: Option<Vec<storage_enums::PaymentMethod>>,
|
||||
pub payment_method_type: Option<Vec<storage_enums::PaymentMethodType>>,
|
||||
pub authentication_type: Option<Vec<storage_enums::AuthenticationType>>,
|
||||
pub profile_id: Option<String>,
|
||||
pub customer_id: Option<String>,
|
||||
pub starting_after_id: Option<String>,
|
||||
pub ending_before_id: Option<String>,
|
||||
pub limit: Option<u32>,
|
||||
}
|
||||
|
||||
impl From<api_models::payments::PaymentListConstraints> for PaymentIntentFetchConstraints {
|
||||
fn from(value: api_models::payments::PaymentListConstraints) -> Self {
|
||||
Self::List {
|
||||
Self::List(Box::new(PaymentIntentListParams {
|
||||
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,
|
||||
currency: None,
|
||||
status: None,
|
||||
payment_methods: None,
|
||||
payment_method: None,
|
||||
payment_method_type: None,
|
||||
authentication_type: None,
|
||||
profile_id: None,
|
||||
customer_id: value.customer_id,
|
||||
starting_after_id: value.starting_after,
|
||||
ending_before_id: value.ending_before,
|
||||
limit: Some(std::cmp::min(value.limit, PAYMENTS_LIST_MAX_LIMIT_V1)),
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<api_models::payments::TimeRange> for PaymentIntentFetchConstraints {
|
||||
fn from(value: api_models::payments::TimeRange) -> Self {
|
||||
Self::List {
|
||||
Self::List(Box::new(PaymentIntentListParams {
|
||||
offset: 0,
|
||||
starting_at: Some(value.start_time),
|
||||
ending_at: value.end_time,
|
||||
connector: None,
|
||||
currency: None,
|
||||
status: None,
|
||||
payment_methods: None,
|
||||
payment_method: None,
|
||||
payment_method_type: None,
|
||||
authentication_type: None,
|
||||
profile_id: None,
|
||||
customer_id: None,
|
||||
starting_after_id: None,
|
||||
ending_before_id: None,
|
||||
limit: None,
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
||||
@ -450,19 +459,22 @@ impl From<api_models::payments::PaymentListFilterConstraints> for PaymentIntentF
|
||||
if let Some(payment_intent_id) = value.payment_id {
|
||||
Self::Single { payment_intent_id }
|
||||
} else {
|
||||
Self::List {
|
||||
Self::List(Box::new(PaymentIntentListParams {
|
||||
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,
|
||||
currency: value.currency,
|
||||
status: value.status,
|
||||
payment_methods: value.payment_methods,
|
||||
customer_id: None,
|
||||
payment_method: value.payment_method,
|
||||
payment_method_type: value.payment_method_type,
|
||||
authentication_type: value.authentication_type,
|
||||
profile_id: value.profile_id,
|
||||
customer_id: value.customer_id,
|
||||
starting_after_id: None,
|
||||
ending_before_id: None,
|
||||
limit: Some(std::cmp::min(value.limit, PAYMENTS_LIST_MAX_LIMIT_V2)),
|
||||
}
|
||||
}))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user