Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

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

Prajjwal Kumarcecea8718a48
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index b0a328accb..66453315d4 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -449,7 +449,7 @@ where
headers.extend(
external_latency
.map(|latency| vec![(X_HS_LATENCY.to_string(), latency.to_string())])
- .unwrap_or(vec![]),
+ .unwrap_or_default(),
);
}
let output = Ok(match payment_request {
diff --git a/crates/router/src/core/verification.rs b/crates/router/src/core/verification.rs
index c1dac8f838..fa700b4cd6 100644
--- a/crates/router/src/core/verification.rs
+++ b/crates/router/src/core/verification.rs
@@ -85,7 +85,7 @@ pub async fn verify_merchant_creds_for_applepay(
response.change_context(api_error_response::ApiErrorResponse::InternalServerError)?;
// Error is already logged
- Ok(match applepay_response {
+ match applepay_response {
Ok(_) => {
utils::check_existence_and_add_domain_to_db(
&state,
@@ -95,17 +95,20 @@ pub async fn verify_merchant_creds_for_applepay(
)
.await
.change_context(api_error_response::ApiErrorResponse::InternalServerError)?;
- services::api::ApplicationResponse::Json(ApplepayMerchantResponse {
- status_message: "Applepay verification Completed".to_string(),
- })
+ Ok(services::api::ApplicationResponse::Json(
+ ApplepayMerchantResponse {
+ status_message: "Applepay verification Completed".to_string(),
+ },
+ ))
}
Err(error) => {
logger::error!(?error);
- services::api::ApplicationResponse::Json(ApplepayMerchantResponse {
- status_message: "Applepay verification Failed".to_string(),
- })
+ Err(api_error_response::ApiErrorResponse::InvalidRequestData {
+ message: "Applepay verification Failed".to_string(),
+ }
+ .into())
}
- })
+ }
}
pub async fn get_verified_apple_domains_with_mid_mca_id(