Skip to content

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

feat(revenue_recovery): add merchant and profile views to recovery-list (#15140)

CHALLA NISHANTH BABUc95994c280bb
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index 1551e07bd7..e5b448834b 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -897,6 +897,10 @@ impl Payments {
web::resource("/recovery-list")
.route(web::get().to(payments::revenue_recovery_invoices_list)),
)
+ .service(
+ web::resource("/profile/recovery-list")
+ .route(web::get().to(payments::revenue_recovery_invoices_list_profile)),
+ )
.service(
web::resource("/aggregate").route(web::get().to(payments::get_payments_aggregates)),
)
diff --git a/crates/router/src/routes/payments.rs b/crates/router/src/routes/payments.rs
index 55eae3d8d2..b1220fad89 100644
--- a/crates/router/src/routes/payments.rs
+++ b/crates/router/src/routes/payments.rs
@@ -2373,15 +2373,8 @@ pub async fn revenue_recovery_invoices_list(
state,
&req,
payload,
- |state, auth: auth::AuthenticationData, mut req, _| async move {
- if let Some(profile_id) = req.profile_id.take() {
- crate::core::utils::validate_profile_id_from_auth_layer(
- Some(profile_id),
- &auth.profile,
- )?;
- }
- req.profile_id = Some(auth.profile.get_id().clone());
- payments::list::revenue_recovery_list_payments(state, auth.platform, req).await
+ |state, auth: auth::AuthenticationData, req, _| {
+ payments::list::revenue_recovery_list_payments(state, auth.platform, req)
},
auth::auth_type(
&auth::V2ApiKeyAuth {
@@ -2400,6 +2393,35 @@ pub async fn revenue_recovery_invoices_list(
.await
}
+/// Profile scoped [`revenue_recovery_invoices_list`]; the profile comes from auth.
+#[instrument(skip_all, fields(flow = ?Flow::PaymentsList))]
+#[cfg(all(feature = "olap", feature = "v2"))]
+pub async fn revenue_recovery_invoices_list_profile(
+ state: web::Data<app::AppState>,
+ req: actix_web::HttpRequest,
+ payload: web::Query<payment_types::PaymentListConstraints>,
+) -> impl Responder {
+ let flow = Flow::PaymentsList;
+ let payload = payload.into_inner();
+ Box::pin(api::server_wrap(
+ flow,
+ state,
+ &req,
+ payload,
+ |state, auth: auth::AuthenticationData, mut req, _| {
+ req.profile_id = Some(auth.profile.get_id().clone());
+ payments::list::revenue_recovery_list_payments(state, auth.platform, req)
+ },
+ &auth::JWTAuth {
+ permission: Permission::ProfilePaymentRead,
+ allow_connected: false,
+ allow_platform: false,
+ },
+ api_locking::LockAction::NotApplicable,
+ ))
+ .await
+}
+
#[cfg(feature = "v2")]
pub async fn payments_list(
state: web::Data<app::AppState>,