mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-01 11:06:50 +08:00
fix(router): add payment_method check in get_mandate_type (#5828)
This commit is contained in:
committed by
GitHub
parent
985761cfb3
commit
1929f56e2a
@ -51,6 +51,7 @@ pub fn get_mandate_type(
|
|||||||
setup_future_usage: Option<enums::FutureUsage>,
|
setup_future_usage: Option<enums::FutureUsage>,
|
||||||
customer_acceptance: Option<api_payments::CustomerAcceptance>,
|
customer_acceptance: Option<api_payments::CustomerAcceptance>,
|
||||||
token: Option<String>,
|
token: Option<String>,
|
||||||
|
payment_method: Option<enums::PaymentMethod>,
|
||||||
) -> CustomResult<Option<api::MandateTransactionType>, errors::ValidationError> {
|
) -> CustomResult<Option<api::MandateTransactionType>, errors::ValidationError> {
|
||||||
match (
|
match (
|
||||||
mandate_data.clone(),
|
mandate_data.clone(),
|
||||||
@ -58,25 +59,28 @@ pub fn get_mandate_type(
|
|||||||
setup_future_usage,
|
setup_future_usage,
|
||||||
customer_acceptance.or(mandate_data.and_then(|m_data| m_data.customer_acceptance)),
|
customer_acceptance.or(mandate_data.and_then(|m_data| m_data.customer_acceptance)),
|
||||||
token,
|
token,
|
||||||
|
payment_method,
|
||||||
) {
|
) {
|
||||||
(Some(_), Some(_), Some(enums::FutureUsage::OffSession), Some(_), Some(_)) => {
|
(Some(_), Some(_), Some(enums::FutureUsage::OffSession), Some(_), Some(_), _) => {
|
||||||
Err(errors::ValidationError::InvalidValue {
|
Err(errors::ValidationError::InvalidValue {
|
||||||
message: "Expected one out of recurring_details and mandate_data but got both"
|
message: "Expected one out of recurring_details and mandate_data but got both"
|
||||||
.to_string(),
|
.to_string(),
|
||||||
}
|
}
|
||||||
.into())
|
.into())
|
||||||
}
|
}
|
||||||
(_, _, Some(enums::FutureUsage::OffSession), Some(_), Some(_))
|
(_, _, Some(enums::FutureUsage::OffSession), Some(_), Some(_), _)
|
||||||
| (_, _, Some(enums::FutureUsage::OffSession), Some(_), _)
|
| (_, _, Some(enums::FutureUsage::OffSession), Some(_), _, _)
|
||||||
| (Some(_), _, Some(enums::FutureUsage::OffSession), _, _) => {
|
| (Some(_), _, Some(enums::FutureUsage::OffSession), _, _, _) => {
|
||||||
Ok(Some(api::MandateTransactionType::NewMandateTransaction))
|
Ok(Some(api::MandateTransactionType::NewMandateTransaction))
|
||||||
}
|
}
|
||||||
|
|
||||||
(_, _, Some(enums::FutureUsage::OffSession), _, Some(_))
|
(_, _, Some(enums::FutureUsage::OffSession), _, Some(_), _)
|
||||||
| (_, Some(_), _, _, _)
|
| (_, Some(_), _, _, _, _)
|
||||||
| (_, _, Some(enums::FutureUsage::OffSession), _, _) => Ok(Some(
|
| (_, _, Some(enums::FutureUsage::OffSession), _, _, Some(enums::PaymentMethod::Wallet)) => {
|
||||||
api::MandateTransactionType::RecurringMandateTransaction,
|
Ok(Some(
|
||||||
)),
|
api::MandateTransactionType::RecurringMandateTransaction,
|
||||||
|
))
|
||||||
|
}
|
||||||
|
|
||||||
_ => Ok(None),
|
_ => Ok(None),
|
||||||
}
|
}
|
||||||
|
|||||||
@ -111,6 +111,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Co
|
|||||||
payment_intent.setup_future_usage,
|
payment_intent.setup_future_usage,
|
||||||
request.customer_acceptance.clone(),
|
request.customer_acceptance.clone(),
|
||||||
request.payment_token.clone(),
|
request.payment_token.clone(),
|
||||||
|
payment_attempt.payment_method,
|
||||||
)
|
)
|
||||||
.change_context(errors::ApiErrorResponse::MandateValidationFailed {
|
.change_context(errors::ApiErrorResponse::MandateValidationFailed {
|
||||||
reason: "Expected one out of recurring_details and mandate_data but got both".into(),
|
reason: "Expected one out of recurring_details and mandate_data but got both".into(),
|
||||||
|
|||||||
@ -524,6 +524,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
|
|||||||
payment_intent.setup_future_usage,
|
payment_intent.setup_future_usage,
|
||||||
request.customer_acceptance.clone(),
|
request.customer_acceptance.clone(),
|
||||||
request.payment_token.clone(),
|
request.payment_token.clone(),
|
||||||
|
payment_attempt.payment_method.or(request.payment_method),
|
||||||
)
|
)
|
||||||
.change_context(errors::ApiErrorResponse::MandateValidationFailed {
|
.change_context(errors::ApiErrorResponse::MandateValidationFailed {
|
||||||
reason: "Expected one out of recurring_details and mandate_data but got both".into(),
|
reason: "Expected one out of recurring_details and mandate_data but got both".into(),
|
||||||
|
|||||||
@ -150,6 +150,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
|
|||||||
request.setup_future_usage,
|
request.setup_future_usage,
|
||||||
request.customer_acceptance.clone(),
|
request.customer_acceptance.clone(),
|
||||||
request.payment_token.clone(),
|
request.payment_token.clone(),
|
||||||
|
request.payment_method,
|
||||||
)
|
)
|
||||||
.change_context(errors::ApiErrorResponse::MandateValidationFailed {
|
.change_context(errors::ApiErrorResponse::MandateValidationFailed {
|
||||||
reason: "Expected one out of recurring_details and mandate_data but got both".into(),
|
reason: "Expected one out of recurring_details and mandate_data but got both".into(),
|
||||||
|
|||||||
@ -136,6 +136,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
|
|||||||
payment_intent.setup_future_usage,
|
payment_intent.setup_future_usage,
|
||||||
request.customer_acceptance.clone(),
|
request.customer_acceptance.clone(),
|
||||||
request.payment_token.clone(),
|
request.payment_token.clone(),
|
||||||
|
payment_attempt.payment_method.or(request.payment_method),
|
||||||
)
|
)
|
||||||
.change_context(errors::ApiErrorResponse::MandateValidationFailed {
|
.change_context(errors::ApiErrorResponse::MandateValidationFailed {
|
||||||
reason: "Expected one out of recurring_details and mandate_data but got both".into(),
|
reason: "Expected one out of recurring_details and mandate_data but got both".into(),
|
||||||
|
|||||||
Reference in New Issue
Block a user