diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs index dfbd9211df..82427709ec 100644 --- a/crates/router/src/core/payment_methods/cards.rs +++ b/crates/router/src/core/payment_methods/cards.rs @@ -2299,12 +2299,33 @@ pub fn filter_pm_based_on_update_mandate_support_for_connector( payment_method_type: &api_enums::PaymentMethodType, connector: api_enums::Connector, ) -> bool { - supported_payment_methods_for_mandate - .0 - .get(payment_method) - .and_then(|payment_method_type_hm| payment_method_type_hm.0.get(payment_method_type)) - .map(|supported_connectors| supported_connectors.connector_list.contains(&connector)) - .unwrap_or(false) + if payment_method == &api_enums::PaymentMethod::Card { + supported_payment_methods_for_mandate + .0 + .get(payment_method) + .map(|payment_method_type_hm| { + let pm_credit = payment_method_type_hm + .0 + .get(&api_enums::PaymentMethodType::Credit) + .map(|conn| conn.connector_list.clone()) + .unwrap_or_default(); + let pm_debit = payment_method_type_hm + .0 + .get(&api_enums::PaymentMethodType::Debit) + .map(|conn| conn.connector_list.clone()) + .unwrap_or_default(); + &pm_credit | &pm_debit + }) + .map(|supported_connectors| supported_connectors.contains(&connector)) + .unwrap_or(false) + } else { + supported_payment_methods_for_mandate + .0 + .get(payment_method) + .and_then(|payment_method_type_hm| payment_method_type_hm.0.get(payment_method_type)) + .map(|supported_connectors| supported_connectors.connector_list.contains(&connector)) + .unwrap_or(false) + } } fn filter_pm_based_on_supported_payments_for_mandate( diff --git a/crates/router/src/core/payments/flows/setup_mandate_flow.rs b/crates/router/src/core/payments/flows/setup_mandate_flow.rs index a81f97851d..30918b2fe4 100644 --- a/crates/router/src/core/payments/flows/setup_mandate_flow.rs +++ b/crates/router/src/core/payments/flows/setup_mandate_flow.rs @@ -1,3 +1,4 @@ +use api_models::enums::{PaymentMethod, PaymentMethodType}; use async_trait::async_trait; use error_stack::{IntoReport, ResultExt}; @@ -275,17 +276,33 @@ impl types::SetupMandateRouterData { let payment_method_type = self.request.payment_method_type; let payment_method = self.request.payment_method_data.get_payment_method(); - let supported_connectors_config = - payment_method - .zip(payment_method_type) - .map_or(false, |(pm, pmt)| { + let supported_connectors_config = payment_method.zip(payment_method_type).map_or_else( + || { + if payment_method == Some(PaymentMethod::Card) { cards::filter_pm_based_on_update_mandate_support_for_connector( supported_connectors_for_update_mandate, - &pm, - &pmt, + &PaymentMethod::Card, + &PaymentMethodType::Credit, + connector.connector_name, + ) && cards::filter_pm_based_on_update_mandate_support_for_connector( + supported_connectors_for_update_mandate, + &PaymentMethod::Card, + &PaymentMethodType::Debit, connector.connector_name, ) - }); + } else { + false + } + }, + |(pm, pmt)| { + cards::filter_pm_based_on_update_mandate_support_for_connector( + supported_connectors_for_update_mandate, + &pm, + &pmt, + connector.connector_name, + ) + }, + ); if supported_connectors_config { let connector_integration: services::BoxedConnectorIntegration< '_, @@ -378,9 +395,13 @@ impl types::SetupMandateRouterData { Err(_) => Ok(resp), } } else { - Err(errors::ApiErrorResponse::InternalServerError) - .into_report() - .attach_printable("Update Mandate Flow not implemented for the connector ")? + Err(errors::ApiErrorResponse::PreconditionFailed { + message: format!( + "Update Mandate flow not implemented for the connector {:?}", + connector.connector_name + ), + }) + .into_report() } } } diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml index 14d119768d..c523237861 100644 --- a/loadtest/config/development.toml +++ b/loadtest/config/development.toml @@ -256,9 +256,6 @@ bank_redirect.sofort = {connector_list = "stripe,adyen,globalpay"} card.credit ={connector_list ="cybersource"} card.debit = {connector_list ="cybersource"} -[mandates.update_mandate_supported] -connector_list = "cybersource" - [analytics] source = "sqlx" diff --git a/postman/collection-dir/adyen_uk/Flow Testcases/Happy Cases/Scenario16-Bank debit-ach/Payments - Create/request.json b/postman/collection-dir/adyen_uk/Flow Testcases/Happy Cases/Scenario16-Bank debit-ach/Payments - Create/request.json index bc160467bf..21c079e0ad 100644 --- a/postman/collection-dir/adyen_uk/Flow Testcases/Happy Cases/Scenario16-Bank debit-ach/Payments - Create/request.json +++ b/postman/collection-dir/adyen_uk/Flow Testcases/Happy Cases/Scenario16-Bank debit-ach/Payments - Create/request.json @@ -31,7 +31,7 @@ "description": "Its my first payment request", "authentication_type": "three_ds", "return_url": "https://duck.com", - "setup_future_usage": "off_session", + "setup_future_usage": "on_session", "billing": { "address": { "line1": "1467", diff --git a/postman/collection-dir/adyen_uk/Flow Testcases/Happy Cases/Scenario17-Bank debit-Bacs/Payments - Create/request.json b/postman/collection-dir/adyen_uk/Flow Testcases/Happy Cases/Scenario17-Bank debit-Bacs/Payments - Create/request.json index 9340a49352..1ec9a829a4 100644 --- a/postman/collection-dir/adyen_uk/Flow Testcases/Happy Cases/Scenario17-Bank debit-Bacs/Payments - Create/request.json +++ b/postman/collection-dir/adyen_uk/Flow Testcases/Happy Cases/Scenario17-Bank debit-Bacs/Payments - Create/request.json @@ -31,7 +31,7 @@ "description": "Its my first payment request", "authentication_type": "no_three_ds", "return_url": "https://duck.com", - "setup_future_usage": "off_session", + "setup_future_usage": "on_session", "billing": { "address": { "line1": "1467", diff --git a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario6-Create Wallet - Paypal/Payments - Create/request.json b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario6-Create Wallet - Paypal/Payments - Create/request.json index f0066e67bb..824bfb4923 100644 --- a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario6-Create Wallet - Paypal/Payments - Create/request.json +++ b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario6-Create Wallet - Paypal/Payments - Create/request.json @@ -32,7 +32,7 @@ "description": "Its my first payment request", "authentication_type": "three_ds", "return_url": "https://duck.com", - "setup_future_usage": "off_session", + "setup_future_usage": "on_session", "billing": { "address": { "line1": "1467", diff --git a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario7-Create Wallet - Paypal with confrm false/Payments - Create/request.json b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario7-Create Wallet - Paypal with confrm false/Payments - Create/request.json index 792e7c399f..9778d0ee32 100644 --- a/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario7-Create Wallet - Paypal with confrm false/Payments - Create/request.json +++ b/postman/collection-dir/paypal/Flow Testcases/Happy Cases/Scenario7-Create Wallet - Paypal with confrm false/Payments - Create/request.json @@ -32,7 +32,7 @@ "description": "Its my first payment request", "authentication_type": "three_ds", "return_url": "https://duck.com", - "setup_future_usage": "off_session", + "setup_future_usage": "on_session", "billing": { "address": { "line1": "1467", diff --git a/postman/collection-dir/zen/Flow Testcases/Happy Cases/Scenario1-Create payment with confirm true/Payments - Create/request.json b/postman/collection-dir/zen/Flow Testcases/Happy Cases/Scenario1-Create payment with confirm true/Payments - Create/request.json index 0bf606d869..7afc6d61c4 100644 --- a/postman/collection-dir/zen/Flow Testcases/Happy Cases/Scenario1-Create payment with confirm true/Payments - Create/request.json +++ b/postman/collection-dir/zen/Flow Testcases/Happy Cases/Scenario1-Create payment with confirm true/Payments - Create/request.json @@ -31,7 +31,7 @@ "description": "Its my first payment request", "authentication_type": "no_three_ds", "return_url": "https://duck.com", - "setup_future_usage": "off_session", + "setup_future_usage": "on_session", "billing": { "address": { "line1": "1467", diff --git a/postman/collection-dir/zen/Flow Testcases/Happy Cases/Scenario3-Create payment without PMD/Payments - Create/request.json b/postman/collection-dir/zen/Flow Testcases/Happy Cases/Scenario3-Create payment without PMD/Payments - Create/request.json index c2d7c7bf9c..a6aef6ecb7 100644 --- a/postman/collection-dir/zen/Flow Testcases/Happy Cases/Scenario3-Create payment without PMD/Payments - Create/request.json +++ b/postman/collection-dir/zen/Flow Testcases/Happy Cases/Scenario3-Create payment without PMD/Payments - Create/request.json @@ -31,7 +31,7 @@ "description": "Its my first payment request", "authentication_type": "no_three_ds", "return_url": "https://duck.com", - "setup_future_usage": "off_session", + "setup_future_usage": "on_session", "billing": { "address": { "line1": "1467", diff --git a/postman/collection-dir/zen/Flow Testcases/Happy Cases/Scenario5-Create 3DS payment with confrm false/Payments - Create/request.json b/postman/collection-dir/zen/Flow Testcases/Happy Cases/Scenario5-Create 3DS payment with confrm false/Payments - Create/request.json index caa19cc5c6..01fa401365 100644 --- a/postman/collection-dir/zen/Flow Testcases/Happy Cases/Scenario5-Create 3DS payment with confrm false/Payments - Create/request.json +++ b/postman/collection-dir/zen/Flow Testcases/Happy Cases/Scenario5-Create 3DS payment with confrm false/Payments - Create/request.json @@ -31,7 +31,7 @@ "description": "Its my first payment request", "authentication_type": "no_three_ds", "return_url": "https://duck.com", - "setup_future_usage": "off_session", + "setup_future_usage": "on_session", "billing": { "address": { "line1": "1467", diff --git a/postman/collection-dir/zen/Flow Testcases/Variation Cases/Scenario2-Confirming the payment without PMD/Payments - Create/request.json b/postman/collection-dir/zen/Flow Testcases/Variation Cases/Scenario2-Confirming the payment without PMD/Payments - Create/request.json index c2d7c7bf9c..a6aef6ecb7 100644 --- a/postman/collection-dir/zen/Flow Testcases/Variation Cases/Scenario2-Confirming the payment without PMD/Payments - Create/request.json +++ b/postman/collection-dir/zen/Flow Testcases/Variation Cases/Scenario2-Confirming the payment without PMD/Payments - Create/request.json @@ -31,7 +31,7 @@ "description": "Its my first payment request", "authentication_type": "no_three_ds", "return_url": "https://duck.com", - "setup_future_usage": "off_session", + "setup_future_usage": "on_session", "billing": { "address": { "line1": "1467",