Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(router): get apple pay certificates only from metadata during the session call #6517

Merged
merged 2 commits into from
Nov 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 5 additions & 14 deletions crates/router/src/core/payments/flows/session_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,20 +189,11 @@ async fn create_applepay_session_token(
)
} else {
// Get the apple pay metadata
let connector_apple_pay_wallet_details =
helpers::get_applepay_metadata(router_data.connector_wallets_details.clone())
.map_err(|error| {
logger::debug!(
"Apple pay connector wallets details parsing failed in create_applepay_session_token {:?}",
error
)
})
.ok();

let apple_pay_metadata = match connector_apple_pay_wallet_details {
Some(apple_pay_wallet_details) => apple_pay_wallet_details,
None => helpers::get_applepay_metadata(router_data.connector_meta_data.clone())?,
};
let apple_pay_metadata =
helpers::get_applepay_metadata(router_data.connector_meta_data.clone())
.attach_printable(
"Failed to to fetch apple pay certificates during session call",
)?;

// Get payment request data , apple pay session request and merchant keys
let (
Expand Down
32 changes: 6 additions & 26 deletions crates/router/src/core/payments/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4788,32 +4788,17 @@ pub fn validate_customer_access(

pub fn is_apple_pay_simplified_flow(
connector_metadata: Option<pii::SecretSerdeValue>,
connector_wallets_details: Option<pii::SecretSerdeValue>,
connector_name: Option<&String>,
) -> CustomResult<bool, errors::ApiErrorResponse> {
let connector_apple_pay_wallet_details =
get_applepay_metadata(connector_wallets_details)
.map_err(|error| {
logger::debug!(
"Apple pay connector wallets details parsing failed for {:?} in is_apple_pay_simplified_flow {:?}",
connector_name,
error
)
})
.ok();

let option_apple_pay_metadata = match connector_apple_pay_wallet_details {
Some(apple_pay_wallet_details) => Some(apple_pay_wallet_details),
None => get_applepay_metadata(connector_metadata)
.map_err(|error| {
logger::debug!(
"Apple pay metadata parsing failed for {:?} in is_apple_pay_simplified_flow {:?}",
let option_apple_pay_metadata = get_applepay_metadata(connector_metadata)
.map_err(|error| {
logger::info!(
"Apple pay metadata parsing for {:?} in is_apple_pay_simplified_flow {:?}",
connector_name,
error
)
})
.ok(),
};
})
.ok();

// return true only if the apple flow type is simplified
Ok(matches!(
Expand Down Expand Up @@ -4999,7 +4984,6 @@ where

let connector_data_list = if is_apple_pay_simplified_flow(
merchant_connector_account_type.get_metadata(),
merchant_connector_account_type.get_connector_wallets_details(),
merchant_connector_account_type
.get_connector_name()
.as_ref(),
Expand Down Expand Up @@ -5027,10 +5011,6 @@ where
for merchant_connector_account in profile_specific_merchant_connector_account_list {
if is_apple_pay_simplified_flow(
merchant_connector_account.metadata.clone(),
merchant_connector_account
.connector_wallets_details
.as_deref()
.cloned(),
Some(&merchant_connector_account.connector_name),
)? {
let connector_data = api::ConnectorData::get_connector_by_name(
Expand Down
Loading