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(core): add validation to check if routable connector supports network tokenization in CIT repeat flow #6749

Merged
merged 4 commits into from
Dec 10, 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
2 changes: 2 additions & 0 deletions crates/router/src/core/payment_methods.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)))?
Expand Down Expand Up @@ -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)))?
Expand Down
28 changes: 27 additions & 1 deletion crates/router/src/core/payments/helpers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1915,6 +1915,7 @@ pub async fn retrieve_card_with_permanent_token(
mandate_id: Option<api_models::payments::MandateIds>,
payment_method_info: Option<domain::PaymentMethod>,
business_profile: &domain::Profile,
connector: Option<String>,
) -> RouterResult<domain::PaymentMethodData> {
let customer_id = payment_intent
.customer_id
Expand Down Expand Up @@ -1985,7 +1986,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,
)
Expand Down Expand Up @@ -2015,6 +2037,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,
Expand Down Expand Up @@ -5776,6 +5800,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))),
Expand All @@ -5794,6 +5819,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))),
Expand Down
Loading