Skip to content

Commit

Permalink
Merge branch 'feat/block_paymentmethod' of https://github.com/juspay/…
Browse files Browse the repository at this point in the history
…hyperswitch into feat/block_paymentmethod
  • Loading branch information
prajjwalkumar17 committed Dec 5, 2023
2 parents 0348d18 + d434bf2 commit ee32675
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 27 deletions.
2 changes: 1 addition & 1 deletion crates/api_models/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ pub mod cards_info;
pub mod conditional_configs;
pub mod connector_onboarding;
pub mod currency;
pub mod pm_blacklist;
pub mod customers;
pub mod disputes;
pub mod enums;
Expand All @@ -24,6 +23,7 @@ pub mod payment_methods;
pub mod payments;
#[cfg(feature = "payouts")]
pub mod payouts;
pub mod pm_blacklist;
pub mod refunds;
pub mod routing;
pub mod surcharge_decision_configs;
Expand Down
1 change: 0 additions & 1 deletion crates/api_models/src/pm_blacklist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,3 @@ pub struct BlacklistPmResponse {

impl ApiEventMetric for BlacklistPmRequest {}
impl ApiEventMetric for BlacklistPmResponse {}

4 changes: 2 additions & 2 deletions crates/router/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ pub mod configs;
pub mod connector_onboarding;
#[cfg(any(feature = "olap", feature = "oltp"))]
pub mod currency;
#[cfg(any(feature = "olap", feature = "oltp"))]
pub mod pm_blacklist;
pub mod customers;
pub mod disputes;
pub mod errors;
Expand All @@ -24,6 +22,8 @@ pub mod payment_methods;
pub mod payments;
#[cfg(feature = "payouts")]
pub mod payouts;
#[cfg(any(feature = "olap", feature = "oltp"))]
pub mod pm_blacklist;
pub mod refunds;
pub mod routing;
pub mod surcharge_decision_config;
Expand Down
14 changes: 8 additions & 6 deletions crates/router/src/core/pm_blacklist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,26 @@ use crate::{
core::errors::{self, api_error_response},
headers, logger,
routes::AppState,
services, types::{self, domain},
services,
types::{self, domain},
};

pub async fn block_payment_method(
state: AppState,
_req: &actix_web::HttpRequest,
body: pm_blacklist::BlacklistPmRequest,
merchant_account: domain::MerchantAccount
merchant_account: domain::MerchantAccount,
) -> CustomResult<
services::ApplicationResponse<pm_blacklist::BlacklistPmResponse>,
api_error_response::ApiErrorResponse,
> {
let fingerprints_to_block = body.pm_to_block;
println!(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> {:?}",merchant_account);
println!(">>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> {:?}", merchant_account);

Ok(services::api::ApplicationResponse::Json(
pm_blacklist::BlacklistPmResponse { status_message: "success".to_string() , fingerprints_blocked: fingerprints_to_block}
pm_blacklist::BlacklistPmResponse {
status_message: "success".to_string(),
fingerprints_blocked: fingerprints_to_block,
},
))

}

1 change: 1 addition & 0 deletions crates/router/src/core/pm_blacklist/utils.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

8 changes: 4 additions & 4 deletions crates/router/src/routes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,6 @@ pub mod configs;
pub mod connector_onboarding;
#[cfg(any(feature = "olap", feature = "oltp"))]
pub mod currency;
#[cfg(any(feature = "olap", feature = "oltp"))]
pub mod pm_blacklist;
pub mod customers;
pub mod disputes;
#[cfg(feature = "dummy_connector")]
Expand All @@ -26,6 +24,8 @@ pub mod payment_methods;
pub mod payments;
#[cfg(feature = "payouts")]
pub mod payouts;
#[cfg(any(feature = "olap", feature = "oltp"))]
pub mod pm_blacklist;
pub mod refunds;
#[cfg(feature = "olap")]
pub mod routing;
Expand All @@ -44,10 +44,10 @@ pub mod locker_migration;
pub use self::app::DummyConnector;
#[cfg(any(feature = "olap", feature = "oltp"))]
pub use self::app::Forex;
#[cfg(any(feature = "olap", feature = "oltp"))]
pub use self::app::PmBlacklist;
#[cfg(feature = "payouts")]
pub use self::app::Payouts;
#[cfg(any(feature = "olap", feature = "oltp"))]
pub use self::app::PmBlacklist;
#[cfg(feature = "olap")]
pub use self::app::Routing;
#[cfg(all(feature = "olap", feature = "kms"))]
Expand Down
14 changes: 5 additions & 9 deletions crates/router/src/routes/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ use tokio::sync::oneshot;

#[cfg(any(feature = "olap", feature = "oltp"))]
use super::currency;
#[cfg(any(feature = "olap", feature = "oltp"))]
use super::pm_blacklist;
#[cfg(feature = "dummy_connector")]
use super::dummy_connector::*;
#[cfg(feature = "payouts")]
use super::payouts::*;
#[cfg(any(feature = "olap", feature = "oltp"))]
use super::pm_blacklist;
#[cfg(feature = "olap")]
use super::routing as cloud_routing;
#[cfg(all(feature = "olap", feature = "kms"))]
Expand Down Expand Up @@ -389,14 +389,10 @@ impl PmBlacklist {
web::scope("/pm")
.app_data(web::Data::new(state.clone()))
.service(
web::resource("/block").route(web::post().to(pm_blacklist::block_payment_method))
)
.service(
web::resource("/unblock").route(web::post().to(currency::convert_forex))
)
.service(
web::resource("/blacklist").route(web::post().to(currency::convert_forex))
web::resource("/block").route(web::post().to(pm_blacklist::block_payment_method)),
)
.service(web::resource("/unblock").route(web::post().to(currency::convert_forex)))
.service(web::resource("/blacklist").route(web::post().to(currency::convert_forex)))
}
}

Expand Down
8 changes: 4 additions & 4 deletions crates/router/src/routes/pm_blacklist.rs
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
use actix_web::{web, HttpRequest, HttpResponse};
use router_env::Flow;
use api_models::pm_blacklist as pm_blacklist_model;
use router_env::Flow;

use crate::{
core::{api_locking, pm_blacklist},
routes::AppState,
services::{api, authentication as auth, authorization::permissions::Permission},
};


pub async fn block_payment_method(
state: web::Data<AppState>,
req: HttpRequest,
Expand All @@ -20,7 +19,9 @@ pub async fn block_payment_method(
state,
&req,
json_payload.into_inner(),
|state, auth: auth::AuthenticationData, body| pm_blacklist::block_payment_method(state, &req, body, auth.merchant_account),
|state, auth: auth::AuthenticationData, body| {
pm_blacklist::block_payment_method(state, &req, body, auth.merchant_account)
},
auth::auth_type(
&auth::ApiKeyAuth,
&auth::JWTAuth(Permission::MerchantAccountRead),
Expand All @@ -30,4 +31,3 @@ pub async fn block_payment_method(
))
.await
}

0 comments on commit ee32675

Please sign in to comment.