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(payouts): add v2 filter for profile (#11493)

Sakil Mostak27ac9332ba2e
diff --git a/crates/router/src/core/payouts.rs b/crates/router/src/core/payouts.rs
index 9adc8ba902..9f5e7753cd 100644
--- a/crates/router/src/core/payouts.rs
+++ b/crates/router/src/core/payouts.rs
@@ -1021,9 +1021,15 @@ pub async fn payouts_list_available_filters_core(
pub async fn get_payout_filters_core(
state: SessionState,
platform: domain::Platform,
+ profile_id_list: Option<Vec<id_type::ProfileId>>,
) -> RouterResponse<api::PayoutListFiltersV2> {
let merchant_connector_accounts = if let services::ApplicationResponse::Json(data) =
- super::admin::list_payment_connectors(state, platform.get_processor().clone(), None).await?
+ super::admin::list_payment_connectors(
+ state,
+ platform.get_processor().clone(),
+ profile_id_list,
+ )
+ .await?
{
data
} else {
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index 6fab5c739b..ed9208a716 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -1563,11 +1563,18 @@ impl Payouts {
web::resource("/filter")
.route(web::post().to(payouts_list_available_filters_for_merchant)),
)
- .service(web::resource("/v2/filter").route(web::get().to(get_payout_filters)))
.service(
web::resource("/profile/filter")
.route(web::post().to(payouts_list_available_filters_for_profile)),
)
+ .service(
+ web::scope("/v2")
+ .service(web::resource("/filter").route(web::get().to(get_payout_filters)))
+ .service(
+ web::resource("/profile/filter")
+ .route(web::get().to(get_payout_filters_profile)),
+ ),
+ )
.service(
web::resource("/{payout_id}/manual-update")
.route(web::put().to(payouts_manual_update)),
diff --git a/crates/router/src/routes/payouts.rs b/crates/router/src/routes/payouts.rs
index bf8b83f3d5..1e340d586c 100644
--- a/crates/router/src/routes/payouts.rs
+++ b/crates/router/src/routes/payouts.rs
@@ -503,7 +503,7 @@ fn http_response<T: MessageBody + 'static>(response: T) -> HttpResponse<BoxBody>
HttpResponse::Ok().body(response)
}
-/// Payouts - Available filters for Profile
+/// Payouts - Available filters for Merchant
#[cfg(all(feature = "olap", feature = "payouts", feature = "v1"))]
#[instrument(skip_all, fields(flow = ?Flow::PayoutsFilter))]
pub async fn get_payout_filters(state: web::Data<AppState>, req: HttpRequest) -> impl Responder {
@@ -514,7 +514,47 @@ pub async fn get_payout_filters(state: web::Data<AppState>, req: HttpRequest) ->
state,
&req,
(),
- |state, auth: auth::AuthenticationData, _, _| get_payout_filters_core(state, auth.platform),
+ |state, auth: auth::AuthenticationData, _, _| {
+ get_payout_filters_core(state, auth.platform, None)
+ },
+ auth::auth_type(
+ &auth::HeaderAuth(auth::ApiKeyAuth {
+ allow_connected_scope_operation: false,
+ allow_platform_self_operation: false,
+ }),
+ &auth::JWTAuth {
+ permission: Permission::ProfilePayoutRead,
+ allow_connected: false,
+ allow_platform: false,
+ },
+ req.headers(),
+ ),
+ api_locking::LockAction::NotApplicable,
+ )
+ .await
+}
+
+/// Payouts - Available filters for Profile
+#[cfg(all(feature = "olap", feature = "payouts", feature = "v1"))]
+#[instrument(skip_all, fields(flow = ?Flow::PayoutsFilter))]
+pub async fn get_payout_filters_profile(
+ state: web::Data<AppState>,
+ req: HttpRequest,
+) -> impl Responder {
+ let flow = Flow::PayoutsFilter;
+
+ api::server_wrap(
+ flow,
+ state,
+ &req,
+ (),
+ |state, auth: auth::AuthenticationData, _, _| {
+ get_payout_filters_core(
+ state,
+ auth.platform,
+ auth.profile.map(|profile| vec![profile.get_id().clone()]),
+ )
+ },
auth::auth_type(
&auth::HeaderAuth(auth::ApiKeyAuth {
allow_connected_scope_operation: false,