feat(router): add v2 endpoint retrieve payment aggregate based on merchant profile (#7196)

Co-authored-by: Aniket Burman <aniket.burman@Aniket-Burman-JDXHW2PH34.local>
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Aniket Burman
2025-02-14 18:21:57 +05:30
committed by GitHub
parent 0ba4ccfc8b
commit c17eb01e35
7 changed files with 43 additions and 8 deletions

View File

@ -102,7 +102,7 @@ pub trait PaymentIntentInterface {
storage_scheme: common_enums::MerchantStorageScheme,
) -> error_stack::Result<Vec<PaymentIntent>, errors::StorageError>;
#[cfg(all(feature = "v1", feature = "olap"))]
#[cfg(feature = "olap")]
async fn get_intent_status_with_count(
&self,
merchant_id: &id_type::MerchantId,

View File

@ -5408,7 +5408,7 @@ pub async fn get_payment_filters(
))
}
#[cfg(all(feature = "olap", feature = "v1"))]
#[cfg(feature = "olap")]
pub async fn get_aggregates_for_payments(
state: SessionState,
merchant: domain::MerchantAccount,

View File

@ -1876,8 +1876,7 @@ impl PaymentIntentInterface for KafkaStore {
)
.await
}
#[cfg(all(feature = "olap", feature = "v1"))]
#[cfg(feature = "olap")]
async fn get_intent_status_with_count(
&self,
merchant_id: &id_type::MerchantId,

View File

@ -571,6 +571,13 @@ impl Payments {
.service(
web::resource("/create-intent")
.route(web::post().to(payments::payments_create_intent)),
)
.service(
web::resource("/aggregate").route(web::get().to(payments::get_payments_aggregates)),
)
.service(
web::resource("/profile/aggregate")
.route(web::get().to(payments::get_payments_aggregates_profile)),
);
route =

View File

@ -1407,7 +1407,7 @@ pub async fn get_payment_filters_profile(
}
#[instrument(skip_all, fields(flow = ?Flow::PaymentsAggregate))]
#[cfg(all(feature = "olap", feature = "v1"))]
#[cfg(feature = "olap")]
pub async fn get_payments_aggregates(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
@ -2228,6 +2228,35 @@ pub async fn get_payments_aggregates_profile(
))
.await
}
#[instrument(skip_all, fields(flow = ?Flow::PaymentsAggregate))]
#[cfg(all(feature = "olap", feature = "v2"))]
pub async fn get_payments_aggregates_profile(
state: web::Data<app::AppState>,
req: actix_web::HttpRequest,
payload: web::Query<common_utils::types::TimeRange>,
) -> impl Responder {
let flow = Flow::PaymentsAggregate;
let payload = payload.into_inner();
Box::pin(api::server_wrap(
flow,
state,
&req,
payload,
|state, auth: auth::AuthenticationData, req, _| {
payments::get_aggregates_for_payments(
state,
auth.merchant_account,
Some(vec![auth.profile.get_id().clone()]),
req,
)
},
&auth::JWTAuth {
permission: Permission::ProfilePaymentRead,
},
api_locking::LockAction::NotApplicable,
))
.await
}
#[cfg(feature = "v2")]
/// A private module to hold internal types to be used in route handlers.

View File

@ -41,7 +41,7 @@ impl PaymentIntentInterface for MockDb {
Err(StorageError::MockDbError)?
}
#[cfg(all(feature = "v1", feature = "olap"))]
#[cfg(feature = "olap")]
async fn get_intent_status_with_count(
&self,
_merchant_id: &common_utils::id_type::MerchantId,

View File

@ -412,7 +412,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for KVRouterStore<T> {
.await
}
#[cfg(all(feature = "v1", feature = "olap"))]
#[cfg(feature = "olap")]
async fn get_intent_status_with_count(
&self,
merchant_id: &common_utils::id_type::MerchantId,
@ -829,7 +829,7 @@ impl<T: DatabaseStore> PaymentIntentInterface for crate::RouterStore<T> {
.await
}
#[cfg(all(feature = "v1", feature = "olap"))]
#[cfg(feature = "olap")]
#[instrument(skip_all)]
async fn get_intent_status_with_count(
&self,