mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-27 11:24:45 +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,6 +2299,26 @@ pub fn filter_pm_based_on_update_mandate_support_for_connector(
|
|||||||
payment_method_type: &api_enums::PaymentMethodType,
|
payment_method_type: &api_enums::PaymentMethodType,
|
||||||
connector: api_enums::Connector,
|
connector: api_enums::Connector,
|
||||||
) -> bool {
|
) -> bool {
|
||||||
|
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
|
supported_payment_methods_for_mandate
|
||||||
.0
|
.0
|
||||||
.get(payment_method)
|
.get(payment_method)
|
||||||
@ -2306,6 +2326,7 @@ pub fn filter_pm_based_on_update_mandate_support_for_connector(
|
|||||||
.map(|supported_connectors| supported_connectors.connector_list.contains(&connector))
|
.map(|supported_connectors| supported_connectors.connector_list.contains(&connector))
|
||||||
.unwrap_or(false)
|
.unwrap_or(false)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn filter_pm_based_on_supported_payments_for_mandate(
|
fn filter_pm_based_on_supported_payments_for_mandate(
|
||||||
supported_payment_methods_for_mandate: &settings::SupportedPaymentMethodsForMandate,
|
supported_payment_methods_for_mandate: &settings::SupportedPaymentMethodsForMandate,
|
||||||
|
|||||||
@ -1,3 +1,4 @@
|
|||||||
|
use api_models::enums::{PaymentMethod, PaymentMethodType};
|
||||||
use async_trait::async_trait;
|
use async_trait::async_trait;
|
||||||
use error_stack::{IntoReport, ResultExt};
|
use error_stack::{IntoReport, ResultExt};
|
||||||
|
|
||||||
@ -275,17 +276,33 @@ impl types::SetupMandateRouterData {
|
|||||||
let payment_method_type = self.request.payment_method_type;
|
let payment_method_type = self.request.payment_method_type;
|
||||||
|
|
||||||
let payment_method = self.request.payment_method_data.get_payment_method();
|
let payment_method = self.request.payment_method_data.get_payment_method();
|
||||||
let supported_connectors_config =
|
let supported_connectors_config = payment_method.zip(payment_method_type).map_or_else(
|
||||||
payment_method
|
|| {
|
||||||
.zip(payment_method_type)
|
if payment_method == Some(PaymentMethod::Card) {
|
||||||
.map_or(false, |(pm, pmt)| {
|
cards::filter_pm_based_on_update_mandate_support_for_connector(
|
||||||
|
supported_connectors_for_update_mandate,
|
||||||
|
&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(
|
cards::filter_pm_based_on_update_mandate_support_for_connector(
|
||||||
supported_connectors_for_update_mandate,
|
supported_connectors_for_update_mandate,
|
||||||
&pm,
|
&pm,
|
||||||
&pmt,
|
&pmt,
|
||||||
connector.connector_name,
|
connector.connector_name,
|
||||||
)
|
)
|
||||||
});
|
},
|
||||||
|
);
|
||||||
if supported_connectors_config {
|
if supported_connectors_config {
|
||||||
let connector_integration: services::BoxedConnectorIntegration<
|
let connector_integration: services::BoxedConnectorIntegration<
|
||||||
'_,
|
'_,
|
||||||
@ -378,9 +395,13 @@ impl types::SetupMandateRouterData {
|
|||||||
Err(_) => Ok(resp),
|
Err(_) => Ok(resp),
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Err(errors::ApiErrorResponse::InternalServerError)
|
Err(errors::ApiErrorResponse::PreconditionFailed {
|
||||||
|
message: format!(
|
||||||
|
"Update Mandate flow not implemented for the connector {:?}",
|
||||||
|
connector.connector_name
|
||||||
|
),
|
||||||
|
})
|
||||||
.into_report()
|
.into_report()
|
||||||
.attach_printable("Update Mandate Flow not implemented for the connector ")?
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -256,9 +256,6 @@ bank_redirect.sofort = {connector_list = "stripe,adyen,globalpay"}
|
|||||||
card.credit ={connector_list ="cybersource"}
|
card.credit ={connector_list ="cybersource"}
|
||||||
card.debit = {connector_list ="cybersource"}
|
card.debit = {connector_list ="cybersource"}
|
||||||
|
|
||||||
[mandates.update_mandate_supported]
|
|
||||||
connector_list = "cybersource"
|
|
||||||
|
|
||||||
[analytics]
|
[analytics]
|
||||||
source = "sqlx"
|
source = "sqlx"
|
||||||
|
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
"description": "Its my first payment request",
|
"description": "Its my first payment request",
|
||||||
"authentication_type": "three_ds",
|
"authentication_type": "three_ds",
|
||||||
"return_url": "https://duck.com",
|
"return_url": "https://duck.com",
|
||||||
"setup_future_usage": "off_session",
|
"setup_future_usage": "on_session",
|
||||||
"billing": {
|
"billing": {
|
||||||
"address": {
|
"address": {
|
||||||
"line1": "1467",
|
"line1": "1467",
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
"description": "Its my first payment request",
|
"description": "Its my first payment request",
|
||||||
"authentication_type": "no_three_ds",
|
"authentication_type": "no_three_ds",
|
||||||
"return_url": "https://duck.com",
|
"return_url": "https://duck.com",
|
||||||
"setup_future_usage": "off_session",
|
"setup_future_usage": "on_session",
|
||||||
"billing": {
|
"billing": {
|
||||||
"address": {
|
"address": {
|
||||||
"line1": "1467",
|
"line1": "1467",
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
"description": "Its my first payment request",
|
"description": "Its my first payment request",
|
||||||
"authentication_type": "three_ds",
|
"authentication_type": "three_ds",
|
||||||
"return_url": "https://duck.com",
|
"return_url": "https://duck.com",
|
||||||
"setup_future_usage": "off_session",
|
"setup_future_usage": "on_session",
|
||||||
"billing": {
|
"billing": {
|
||||||
"address": {
|
"address": {
|
||||||
"line1": "1467",
|
"line1": "1467",
|
||||||
|
|||||||
@ -32,7 +32,7 @@
|
|||||||
"description": "Its my first payment request",
|
"description": "Its my first payment request",
|
||||||
"authentication_type": "three_ds",
|
"authentication_type": "three_ds",
|
||||||
"return_url": "https://duck.com",
|
"return_url": "https://duck.com",
|
||||||
"setup_future_usage": "off_session",
|
"setup_future_usage": "on_session",
|
||||||
"billing": {
|
"billing": {
|
||||||
"address": {
|
"address": {
|
||||||
"line1": "1467",
|
"line1": "1467",
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
"description": "Its my first payment request",
|
"description": "Its my first payment request",
|
||||||
"authentication_type": "no_three_ds",
|
"authentication_type": "no_three_ds",
|
||||||
"return_url": "https://duck.com",
|
"return_url": "https://duck.com",
|
||||||
"setup_future_usage": "off_session",
|
"setup_future_usage": "on_session",
|
||||||
"billing": {
|
"billing": {
|
||||||
"address": {
|
"address": {
|
||||||
"line1": "1467",
|
"line1": "1467",
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
"description": "Its my first payment request",
|
"description": "Its my first payment request",
|
||||||
"authentication_type": "no_three_ds",
|
"authentication_type": "no_three_ds",
|
||||||
"return_url": "https://duck.com",
|
"return_url": "https://duck.com",
|
||||||
"setup_future_usage": "off_session",
|
"setup_future_usage": "on_session",
|
||||||
"billing": {
|
"billing": {
|
||||||
"address": {
|
"address": {
|
||||||
"line1": "1467",
|
"line1": "1467",
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
"description": "Its my first payment request",
|
"description": "Its my first payment request",
|
||||||
"authentication_type": "no_three_ds",
|
"authentication_type": "no_three_ds",
|
||||||
"return_url": "https://duck.com",
|
"return_url": "https://duck.com",
|
||||||
"setup_future_usage": "off_session",
|
"setup_future_usage": "on_session",
|
||||||
"billing": {
|
"billing": {
|
||||||
"address": {
|
"address": {
|
||||||
"line1": "1467",
|
"line1": "1467",
|
||||||
|
|||||||
@ -31,7 +31,7 @@
|
|||||||
"description": "Its my first payment request",
|
"description": "Its my first payment request",
|
||||||
"authentication_type": "no_three_ds",
|
"authentication_type": "no_three_ds",
|
||||||
"return_url": "https://duck.com",
|
"return_url": "https://duck.com",
|
||||||
"setup_future_usage": "off_session",
|
"setup_future_usage": "on_session",
|
||||||
"billing": {
|
"billing": {
|
||||||
"address": {
|
"address": {
|
||||||
"line1": "1467",
|
"line1": "1467",
|
||||||
|
|||||||
Reference in New Issue
Block a user