fix(router): return missing required field error when a domain is missing during apple pay session call (#5596)

This commit is contained in:
Shankar Singh C
2024-08-13 18:01:09 +05:30
committed by GitHub
parent f5b2eec015
commit 751ba15482

View File

@ -411,10 +411,8 @@ async fn create_applepay_session_token(
"Retry apple pay session call with the merchant configured domain {error:?}" "Retry apple pay session call with the merchant configured domain {error:?}"
); );
let merchant_configured_domain = merchant_configured_domain_optional let merchant_configured_domain = merchant_configured_domain_optional
.ok_or(errors::ApiErrorResponse::InternalServerError) .get_required_value("apple pay domain")
.attach_printable( .attach_printable("Failed to get domain for apple pay session call")?;
"Failed to get initiative_context for apple pay session call retry",
)?;
let apple_pay_retry_session_request = let apple_pay_retry_session_request =
payment_types::ApplepaySessionRequest { payment_types::ApplepaySessionRequest {
initiative_context: merchant_configured_domain, initiative_context: merchant_configured_domain,
@ -496,15 +494,16 @@ fn get_session_request_for_manual_apple_pay(
session_token_data: payment_types::SessionTokenInfo, session_token_data: payment_types::SessionTokenInfo,
merchant_domain: Option<String>, merchant_domain: Option<String>,
) -> RouterResult<payment_types::ApplepaySessionRequest> { ) -> RouterResult<payment_types::ApplepaySessionRequest> {
let initiative_context = session_token_data let initiative_context = merchant_domain
.initiative_context .or_else(|| session_token_data.initiative_context.clone())
.ok_or(errors::ApiErrorResponse::InternalServerError) .get_required_value("apple pay domain")
.attach_printable("Failed to get initiative_context for apple pay session call")?; .attach_printable("Failed to get domain for apple pay session call")?;
Ok(payment_types::ApplepaySessionRequest { Ok(payment_types::ApplepaySessionRequest {
merchant_identifier: session_token_data.merchant_identifier.clone(), merchant_identifier: session_token_data.merchant_identifier.clone(),
display_name: session_token_data.display_name.clone(), display_name: session_token_data.display_name.clone(),
initiative: session_token_data.initiative.to_string(), initiative: session_token_data.initiative.to_string(),
initiative_context: merchant_domain.unwrap_or(initiative_context), initiative_context,
}) })
} }