From 7d46afd9852a793befa5321835ae9413fafb3fd9 Mon Sep 17 00:00:00 2001 From: Shankar Singh C <83439957+ShankarSinghC@users.noreply.github.com> Date: Wed, 19 Jun 2024 18:02:30 +0530 Subject: [PATCH] feat(router): add payment method type duplication check for `google_pay` (#5023) --- crates/router/src/core/payments/tokenization.rs | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs index 54a4e20c89c5..64fe526f0c03 100644 --- a/crates/router/src/core/payments/tokenization.rs +++ b/crates/router/src/core/payments/tokenization.rs @@ -515,8 +515,10 @@ where } }, None => { - let customer_apple_pay_saved_pm_id_option = if payment_method_type + let customer_saved_pm_id_option = if payment_method_type == Some(api_models::enums::PaymentMethodType::ApplePay) + || payment_method_type + == Some(api_models::enums::PaymentMethodType::GooglePay) { match state .store @@ -530,8 +532,7 @@ where Ok(customer_payment_methods) => Ok(customer_payment_methods .iter() .find(|payment_method| { - payment_method.payment_method_type - == Some(api_models::enums::PaymentMethodType::ApplePay) + payment_method.payment_method_type == payment_method_type }) .map(|pm| pm.payment_method_id.clone())), Err(error) => { @@ -552,10 +553,8 @@ where Ok(None) }?; - if let Some(customer_apple_pay_saved_pm_id) = - customer_apple_pay_saved_pm_id_option - { - resp.payment_method_id = customer_apple_pay_saved_pm_id; + if let Some(customer_saved_pm_id) = customer_saved_pm_id_option { + resp.payment_method_id = customer_saved_pm_id; } else { let pm_metadata = create_payment_method_metadata(None, connector_token)?;