Skip to content

Commit

Permalink
feat(router): add payment method type duplication check for `google_p…
Browse files Browse the repository at this point in the history
…ay` (#5023)
  • Loading branch information
ShankarSinghC authored Jun 19, 2024
1 parent bec51a3 commit 7d46afd
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions crates/router/src/core/payments/tokenization.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) => {
Expand All @@ -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)?;
Expand Down

0 comments on commit 7d46afd

Please sign in to comment.