mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat: Kv changes for V2 feature (#8198)
Co-authored-by: Akshay S <akshay.s@juspay.in> Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -116,7 +116,7 @@ pub fn mk_app(
|
||||
> {
|
||||
let mut server_app = get_application_builder(request_body_limit, state.conf.cors.clone());
|
||||
|
||||
#[cfg(all(feature = "dummy_connector", feature = "v1"))]
|
||||
#[cfg(feature = "dummy_connector")]
|
||||
{
|
||||
use routes::DummyConnector;
|
||||
server_app = server_app.service(DummyConnector::server(state.clone()));
|
||||
|
||||
@ -915,6 +915,7 @@ pub async fn connector_delete(
|
||||
/// Merchant Account - Toggle KV
|
||||
///
|
||||
/// Toggle KV mode for the Merchant Account
|
||||
#[cfg(feature = "v1")]
|
||||
#[instrument(skip_all)]
|
||||
pub async fn merchant_account_toggle_kv(
|
||||
state: web::Data<AppState>,
|
||||
@ -938,6 +939,29 @@ pub async fn merchant_account_toggle_kv(
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[instrument(skip_all)]
|
||||
pub async fn merchant_account_toggle_kv(
|
||||
state: web::Data<AppState>,
|
||||
req: HttpRequest,
|
||||
path: web::Path<common_utils::id_type::MerchantId>,
|
||||
json_payload: web::Json<admin::ToggleKVRequest>,
|
||||
) -> HttpResponse {
|
||||
let flow = Flow::ConfigKeyUpdate;
|
||||
let mut payload = json_payload.into_inner();
|
||||
payload.merchant_id = path.into_inner();
|
||||
|
||||
api::server_wrap(
|
||||
flow,
|
||||
state,
|
||||
&req,
|
||||
payload,
|
||||
|state, _, payload, _| kv_for_merchant(state, payload.merchant_id, payload.kv_enabled),
|
||||
&auth::V2AdminApiAuth,
|
||||
api_locking::LockAction::NotApplicable,
|
||||
)
|
||||
.await
|
||||
}
|
||||
/// Merchant Account - Transfer Keys
|
||||
///
|
||||
/// Transfer Merchant Encryption key to keymanager
|
||||
@ -965,6 +989,7 @@ pub async fn merchant_account_toggle_all_kv(
|
||||
/// Merchant Account - KV Status
|
||||
///
|
||||
/// Toggle KV mode for the Merchant Account
|
||||
#[cfg(feature = "v1")]
|
||||
#[instrument(skip_all)]
|
||||
pub async fn merchant_account_kv_status(
|
||||
state: web::Data<AppState>,
|
||||
@ -986,6 +1011,27 @@ pub async fn merchant_account_kv_status(
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
#[instrument(skip_all)]
|
||||
pub async fn merchant_account_kv_status(
|
||||
state: web::Data<AppState>,
|
||||
req: HttpRequest,
|
||||
path: web::Path<common_utils::id_type::MerchantId>,
|
||||
) -> HttpResponse {
|
||||
let flow = Flow::ConfigKeyFetch;
|
||||
let merchant_id = path.into_inner();
|
||||
|
||||
api::server_wrap(
|
||||
flow,
|
||||
state,
|
||||
&req,
|
||||
merchant_id,
|
||||
|state, _, req, _| check_merchant_account_kv_status(state, req),
|
||||
&auth::V2AdminApiAuth,
|
||||
api_locking::LockAction::NotApplicable,
|
||||
)
|
||||
.await
|
||||
}
|
||||
/// Merchant Account - KV Status
|
||||
///
|
||||
/// Toggle KV mode for the Merchant Account
|
||||
|
||||
@ -600,6 +600,22 @@ impl DummyConnector {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "dummy_connector", feature = "v2"))]
|
||||
impl DummyConnector {
|
||||
pub fn server(state: AppState) -> Scope {
|
||||
let mut routes_with_restricted_access = web::scope("");
|
||||
#[cfg(not(feature = "external_access_dc"))]
|
||||
{
|
||||
routes_with_restricted_access =
|
||||
routes_with_restricted_access.guard(actix_web::guard::Host("localhost"));
|
||||
}
|
||||
routes_with_restricted_access = routes_with_restricted_access
|
||||
.service(web::resource("/payment").route(web::post().to(dummy_connector_payment)));
|
||||
web::scope("/dummy-connector")
|
||||
.app_data(web::Data::new(state))
|
||||
.service(routes_with_restricted_access)
|
||||
}
|
||||
}
|
||||
pub struct Payments;
|
||||
|
||||
#[cfg(all(any(feature = "olap", feature = "oltp"), feature = "v2"))]
|
||||
@ -1556,6 +1572,11 @@ impl MerchantAccount {
|
||||
)
|
||||
.service(
|
||||
web::resource("/profiles").route(web::get().to(profiles::profiles_list)),
|
||||
)
|
||||
.service(
|
||||
web::resource("/kv")
|
||||
.route(web::post().to(admin::merchant_account_toggle_kv))
|
||||
.route(web::get().to(admin::merchant_account_kv_status)),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
@ -61,7 +61,7 @@ pub async fn dummy_connector_complete_payment(
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "dummy_connector", feature = "v1"))]
|
||||
#[cfg(feature = "dummy_connector")]
|
||||
#[instrument(skip_all, fields(flow = ?types::Flow::DummyPaymentCreate))]
|
||||
pub async fn dummy_connector_payment(
|
||||
state: web::Data<app::AppState>,
|
||||
@ -82,7 +82,7 @@ pub async fn dummy_connector_payment(
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "dummy_connector", feature = "v1"))]
|
||||
#[cfg(feature = "dummy_connector")]
|
||||
#[instrument(skip_all, fields(flow = ?types::Flow::DummyPaymentRetrieve))]
|
||||
pub async fn dummy_connector_payment_data(
|
||||
state: web::Data<app::AppState>,
|
||||
|
||||
@ -9,7 +9,7 @@ use crate::{
|
||||
utils::OptionExt,
|
||||
};
|
||||
|
||||
#[cfg(all(feature = "dummy_connector", feature = "v1"))]
|
||||
#[cfg(feature = "dummy_connector")]
|
||||
pub async fn payment(
|
||||
state: SessionState,
|
||||
req: types::DummyConnectorPaymentRequest,
|
||||
|
||||
Reference in New Issue
Block a user