feat(refunds_v2): Add refunds list flow in v2 apis (#7966)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Amey Wale
2025-05-12 19:27:05 +05:30
committed by GitHub
parent 28b62e2693
commit 839eb2e8fb
14 changed files with 716 additions and 17 deletions

View File

@ -17,6 +17,7 @@ v2 = ["api_models/v2", "diesel_models/v2", "common_utils/v2", "common_types/v2"]
v1 = ["api_models/v1", "diesel_models/v1", "common_utils/v1", "common_types/v1"]
customer_v2 = ["api_models/customer_v2", "diesel_models/customer_v2"]
payment_methods_v2 = ["api_models/payment_methods_v2", "diesel_models/payment_methods_v2"]
refunds_v2 = ["api_models/refunds_v2"]
dummy_connector = []
revenue_recovery= []

View File

@ -1,5 +1,9 @@
#[cfg(all(feature = "v2", feature = "refunds_v2"))]
use crate::business_profile::Profile;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
use crate::errors;
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
pub struct RefundListConstraints {
pub payment_id: Option<common_utils::id_type::PaymentId>,
pub refund_id: Option<String>,
@ -14,6 +18,22 @@ pub struct RefundListConstraints {
pub refund_status: Option<Vec<common_enums::RefundStatus>>,
}
#[cfg(all(feature = "v2", feature = "refunds_v2"))]
pub struct RefundListConstraints {
pub payment_id: Option<common_utils::id_type::GlobalPaymentId>,
pub refund_id: Option<common_utils::id_type::GlobalRefundId>,
pub profile_id: common_utils::id_type::ProfileId,
pub limit: Option<i64>,
pub offset: Option<i64>,
pub time_range: Option<common_utils::types::TimeRange>,
pub amount_filter: Option<api_models::payments::AmountFilter>,
pub connector: Option<Vec<String>>,
pub connector_id_list: Option<Vec<common_utils::id_type::MerchantConnectorAccountId>>,
pub currency: Option<Vec<common_enums::Currency>>,
pub refund_status: Option<Vec<common_enums::RefundStatus>>,
}
#[cfg(all(any(feature = "v1", feature = "v2"), not(feature = "refunds_v2")))]
impl
TryFrom<(
api_models::refunds::RefundListRequest,
@ -80,3 +100,35 @@ impl
})
}
}
#[cfg(all(feature = "v2", feature = "refunds_v2"))]
impl From<(api_models::refunds::RefundListRequest, Profile)> for RefundListConstraints {
fn from((value, profile): (api_models::refunds::RefundListRequest, Profile)) -> Self {
let api_models::refunds::RefundListRequest {
payment_id,
refund_id,
connector,
currency,
refund_status,
limit,
offset,
time_range,
amount_filter,
connector_id_list,
} = value;
Self {
payment_id,
refund_id,
profile_id: profile.get_id().to_owned(),
limit,
offset,
time_range,
amount_filter,
connector,
connector_id_list,
currency,
refund_status,
}
}
}