mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
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:
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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 =
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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,
|
||||
|
||||
@ -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,
|
||||
|
||||
Reference in New Issue
Block a user