mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-28 04:04:55 +08:00
fix(postman): Fix failing postman tests and send a proper error message (#3601)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -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(
|
||||
|
||||
@ -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()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -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"
|
||||
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
@ -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",
|
||||
|
||||
Reference in New Issue
Block a user