mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat(router): verify service for applepay merchant registration v2 (#8999)
This commit is contained in:
@ -117,11 +117,16 @@ pub async fn get_verified_apple_domains_with_mid_mca_id(
|
||||
.unwrap_or_default();
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
let verified_domains = {
|
||||
let _ = merchant_connector_id;
|
||||
let _ = key_store;
|
||||
todo!()
|
||||
};
|
||||
let verified_domains = db
|
||||
.find_merchant_connector_account_by_id(
|
||||
key_manager_state,
|
||||
&merchant_connector_id,
|
||||
&key_store,
|
||||
)
|
||||
.await
|
||||
.change_context(errors::ApiErrorResponse::ResourceIdNotFound)?
|
||||
.applepay_verified_domains
|
||||
.unwrap_or_default();
|
||||
|
||||
Ok(services::api::ApplicationResponse::Json(
|
||||
verifications::ApplepayVerifiedDomainsResponse { verified_domains },
|
||||
|
||||
@ -43,12 +43,15 @@ pub async fn check_existence_and_add_domain_to_db(
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)?;
|
||||
|
||||
#[cfg(feature = "v2")]
|
||||
let merchant_connector_account: hyperswitch_domain_models::merchant_connector_account::MerchantConnectorAccount = {
|
||||
let _ = merchant_connector_id;
|
||||
let _ = key_store;
|
||||
let _ = domain_from_req;
|
||||
todo!()
|
||||
};
|
||||
let merchant_connector_account = state
|
||||
.store
|
||||
.find_merchant_connector_account_by_id(
|
||||
key_manager_state,
|
||||
&merchant_connector_id,
|
||||
&key_store,
|
||||
)
|
||||
.await
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)?;
|
||||
utils::validate_profile_id_from_auth_layer(
|
||||
profile_id_from_auth_layer,
|
||||
&merchant_connector_account,
|
||||
|
||||
@ -198,6 +198,11 @@ pub fn mk_app(
|
||||
.service(routes::Routing::server(state.clone()))
|
||||
.service(routes::Chat::server(state.clone()));
|
||||
|
||||
#[cfg(all(feature = "olap", any(feature = "v1", feature = "v2")))]
|
||||
{
|
||||
server_app = server_app.service(routes::Verify::server(state.clone()));
|
||||
}
|
||||
|
||||
#[cfg(feature = "v1")]
|
||||
{
|
||||
server_app = server_app
|
||||
@ -208,7 +213,6 @@ pub fn mk_app(
|
||||
.service(routes::ApplePayCertificatesMigration::server(state.clone()))
|
||||
.service(routes::PaymentLink::server(state.clone()))
|
||||
.service(routes::ConnectorOnboarding::server(state.clone()))
|
||||
.service(routes::Verify::server(state.clone()))
|
||||
.service(routes::Analytics::server(state.clone()))
|
||||
.service(routes::WebhookEvents::server(state.clone()))
|
||||
.service(routes::FeatureMatrix::server(state.clone()));
|
||||
|
||||
@ -56,7 +56,7 @@ use super::refunds;
|
||||
use super::routing;
|
||||
#[cfg(all(feature = "oltp", feature = "v2"))]
|
||||
use super::tokenization as tokenization_routes;
|
||||
#[cfg(all(feature = "olap", feature = "v1"))]
|
||||
#[cfg(all(feature = "olap", any(feature = "v1", feature = "v2")))]
|
||||
use super::verification::{apple_pay_merchant_registration, retrieve_apple_pay_verified_domains};
|
||||
#[cfg(feature = "oltp")]
|
||||
use super::webhooks::*;
|
||||
@ -2362,7 +2362,6 @@ impl ThreeDsDecisionRule {
|
||||
|
||||
#[cfg(feature = "olap")]
|
||||
pub struct Verify;
|
||||
|
||||
#[cfg(all(feature = "olap", feature = "v1"))]
|
||||
impl Verify {
|
||||
pub fn server(state: AppState) -> Scope {
|
||||
@ -2379,6 +2378,22 @@ impl Verify {
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "olap", feature = "v2"))]
|
||||
impl Verify {
|
||||
pub fn server(state: AppState) -> Scope {
|
||||
web::scope("/v2/verify")
|
||||
.app_data(web::Data::new(state))
|
||||
.service(
|
||||
web::resource("/apple-pay/{merchant_id}")
|
||||
.route(web::post().to(apple_pay_merchant_registration)),
|
||||
)
|
||||
.service(
|
||||
web::resource("/applepay-verified-domains")
|
||||
.route(web::get().to(retrieve_apple_pay_verified_domains)),
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
pub struct UserDeprecated;
|
||||
|
||||
#[cfg(all(feature = "olap", feature = "v2"))]
|
||||
|
||||
@ -46,6 +46,44 @@ pub async fn apple_pay_merchant_registration(
|
||||
.await
|
||||
}
|
||||
|
||||
#[cfg(all(feature = "olap", feature = "v2"))]
|
||||
#[instrument(skip_all, fields(flow = ?Flow::Verification))]
|
||||
pub async fn apple_pay_merchant_registration(
|
||||
state: web::Data<AppState>,
|
||||
req: HttpRequest,
|
||||
json_payload: web::Json<verifications::ApplepayMerchantVerificationRequest>,
|
||||
path: web::Path<common_utils::id_type::MerchantId>,
|
||||
) -> impl Responder {
|
||||
let flow = Flow::Verification;
|
||||
let merchant_id = path.into_inner();
|
||||
Box::pin(api::server_wrap(
|
||||
flow,
|
||||
state,
|
||||
&req,
|
||||
json_payload.into_inner(),
|
||||
|state, auth: auth::AuthenticationData, body, _| {
|
||||
verification::verify_merchant_creds_for_applepay(
|
||||
state.clone(),
|
||||
body,
|
||||
merchant_id.clone(),
|
||||
Some(auth.profile.get_id().clone()),
|
||||
)
|
||||
},
|
||||
auth::auth_type(
|
||||
&auth::V2ApiKeyAuth {
|
||||
is_connected_allowed: false,
|
||||
is_platform_allowed: false,
|
||||
},
|
||||
&auth::JWTAuth {
|
||||
permission: Permission::ProfileAccountWrite,
|
||||
},
|
||||
req.headers(),
|
||||
),
|
||||
api_locking::LockAction::NotApplicable,
|
||||
))
|
||||
.await
|
||||
}
|
||||
|
||||
#[instrument(skip_all, fields(flow = ?Flow::Verification))]
|
||||
pub async fn retrieve_apple_pay_verified_domains(
|
||||
state: web::Data<AppState>,
|
||||
|
||||
Reference in New Issue
Block a user