Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(router): add payment method type duplication check for `google_pay` (#5023)

Shankar Singh C7d46afd9852a
diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs
index 54a4e20c89..64fe526f0c 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)?;