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

fix(samsung_pay): add payment_method_type duplication check (#7337)

Shankar Singh C11ff437456f9
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index 54514f6e05..c286ae04d5 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -1651,6 +1651,12 @@ pub enum PaymentMethodType {
DirectCarrierBilling,
}
+impl PaymentMethodType {
+ pub fn should_check_for_customer_saved_payment_method_type(self) -> bool {
+ matches!(self, Self::ApplePay | Self::GooglePay | Self::SamsungPay)
+ }
+}
+
impl masking::SerializableSecret for PaymentMethodType {}
/// Indicates the type of payment method. Eg: 'card', 'wallet', etc.
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index c995b646ff..032262b30a 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -591,10 +591,13 @@ pub async fn get_token_pm_type_mandate_details(
mandate_generic_data.mandate_connector,
mandate_generic_data.payment_method_info,
)
- } else if request.payment_method_type
- == Some(api_models::enums::PaymentMethodType::ApplePay)
- || request.payment_method_type
- == Some(api_models::enums::PaymentMethodType::GooglePay)
+ } else if request
+ .payment_method_type
+ .map(|payment_method_type_value| {
+ payment_method_type_value
+ .should_check_for_customer_saved_payment_method_type()
+ })
+ .unwrap_or(false)
{
let payment_request_customer_id = request.get_customer_id();
if let Some(customer_id) =
diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs
index d46977d8c9..b4e4db3d16 100644
--- a/crates/router/src/core/payments/tokenization.rs
+++ b/crates/router/src/core/payments/tokenization.rs
@@ -655,9 +655,11 @@ where
},
None => {
let customer_saved_pm_option = if payment_method_type
- == Some(api_models::enums::PaymentMethodType::ApplePay)
- || payment_method_type
- == Some(api_models::enums::PaymentMethodType::GooglePay)
+ .map(|payment_method_type_value| {
+ payment_method_type_value
+ .should_check_for_customer_saved_payment_method_type()
+ })
+ .unwrap_or(false)
{
match state
.store