diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs index 53ec01298967..041fb52091ba 100644 --- a/crates/router/src/core/payment_methods.rs +++ b/crates/router/src/core/payment_methods.rs @@ -588,6 +588,7 @@ pub async fn retrieve_payment_method_with_token( mandate_id, payment_method_info, business_profile, + payment_attempt.connector.clone(), ) .await .map(|card| Some((card, enums::PaymentMethod::Card)))? @@ -622,6 +623,7 @@ pub async fn retrieve_payment_method_with_token( mandate_id, payment_method_info, business_profile, + payment_attempt.connector.clone(), ) .await .map(|card| Some((card, enums::PaymentMethod::Card)))? diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs index 01bac9a21242..923f6d24fe83 100644 --- a/crates/router/src/core/payments/helpers.rs +++ b/crates/router/src/core/payments/helpers.rs @@ -1916,6 +1916,7 @@ pub async fn retrieve_card_with_permanent_token( mandate_id: Option, payment_method_info: Option, business_profile: &domain::Profile, + connector: Option, ) -> RouterResult { let customer_id = payment_intent .customer_id @@ -1986,7 +1987,28 @@ pub async fn retrieve_card_with_permanent_token( .attach_printable("Payment method data is not present"), (Some(ref pm_data), None) => { // Regular (non-mandate) Payment flow - if let Some(token_ref) = pm_data.network_token_requestor_reference_id.clone() { + let network_tokenization_supported_connectors = &state + .conf + .network_tokenization_supported_connectors + .connector_list; + let connector_variant = connector + .as_ref() + .map(|conn| { + api_enums::Connector::from_str(conn.as_str()) + .change_context(errors::ApiErrorResponse::InvalidDataValue { + field_name: "connector", + }) + .attach_printable_lazy(|| { + format!("unable to parse connector name {connector:?}") + }) + }) + .transpose()?; + if let (Some(_conn), Some(token_ref)) = ( + connector_variant + .filter(|conn| network_tokenization_supported_connectors.contains(conn)), + pm_data.network_token_requestor_reference_id.clone(), + ) { + logger::info!("Fetching network token data from tokenization service"); match network_tokenization::get_token_from_tokenization_service( state, token_ref, pm_data, ) @@ -2016,6 +2038,8 @@ pub async fn retrieve_card_with_permanent_token( } } } else { + logger::info!("Either the connector is not in the NT supported list or token requestor reference ID is absent"); + logger::info!("Falling back to fetch card details from locker"); fetch_card_details_from_locker( state, customer_id, @@ -5773,6 +5797,7 @@ pub async fn get_payment_method_details_from_payment_token( None, None, business_profile, + payment_attempt.connector.clone(), ) .await .map(|card| Some((card, enums::PaymentMethod::Card))), @@ -5791,6 +5816,7 @@ pub async fn get_payment_method_details_from_payment_token( None, None, business_profile, + payment_attempt.connector.clone(), ) .await .map(|card| Some((card, enums::PaymentMethod::Card))),