refactor(router): throw bad request error on applepay verification failure (#2607)

This commit is contained in:
Prajjwal Kumar
2023-10-17 15:18:51 +05:30
committed by GitHub
parent fdd9580012
commit cecea8718a
2 changed files with 12 additions and 9 deletions

View File

@ -449,7 +449,7 @@ where
headers.extend( headers.extend(
external_latency external_latency
.map(|latency| vec![(X_HS_LATENCY.to_string(), latency.to_string())]) .map(|latency| vec![(X_HS_LATENCY.to_string(), latency.to_string())])
.unwrap_or(vec![]), .unwrap_or_default(),
); );
} }
let output = Ok(match payment_request { let output = Ok(match payment_request {

View File

@ -85,7 +85,7 @@ pub async fn verify_merchant_creds_for_applepay(
response.change_context(api_error_response::ApiErrorResponse::InternalServerError)?; response.change_context(api_error_response::ApiErrorResponse::InternalServerError)?;
// Error is already logged // Error is already logged
Ok(match applepay_response { match applepay_response {
Ok(_) => { Ok(_) => {
utils::check_existence_and_add_domain_to_db( utils::check_existence_and_add_domain_to_db(
&state, &state,
@ -95,17 +95,20 @@ pub async fn verify_merchant_creds_for_applepay(
) )
.await .await
.change_context(api_error_response::ApiErrorResponse::InternalServerError)?; .change_context(api_error_response::ApiErrorResponse::InternalServerError)?;
services::api::ApplicationResponse::Json(ApplepayMerchantResponse { Ok(services::api::ApplicationResponse::Json(
status_message: "Applepay verification Completed".to_string(), ApplepayMerchantResponse {
}) status_message: "Applepay verification Completed".to_string(),
},
))
} }
Err(error) => { Err(error) => {
logger::error!(?error); logger::error!(?error);
services::api::ApplicationResponse::Json(ApplepayMerchantResponse { Err(api_error_response::ApiErrorResponse::InvalidRequestData {
status_message: "Applepay verification Failed".to_string(), message: "Applepay verification Failed".to_string(),
}) }
.into())
} }
}) }
} }
pub async fn get_verified_apple_domains_with_mid_mca_id( pub async fn get_verified_apple_domains_with_mid_mca_id(