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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(router): add payment_method check in `get_mandate_type` (#5828)
Sai Harsha Vardhan1929f56e2ab6
diff --git a/crates/router/src/core/mandate/helpers.rs b/crates/router/src/core/mandate/helpers.rsindex 96f00a0d20..52afa6e0e5 100644--- a/crates/router/src/core/mandate/helpers.rs+++ b/crates/router/src/core/mandate/helpers.rs@@ -51,6 +51,7 @@ pub fn get_mandate_type(setup_future_usage: Option<enums::FutureUsage>,customer_acceptance: Option<api_payments::CustomerAcceptance>,token: Option<String>,+ payment_method: Option<enums::PaymentMethod>,) -> CustomResult<Option<api::MandateTransactionType>, errors::ValidationError> {match (mandate_data.clone(),@@ -58,25 +59,28 @@ pub fn get_mandate_type(setup_future_usage,customer_acceptance.or(mandate_data.and_then(|m_data| m_data.customer_acceptance)),token,+ payment_method,) {- (Some(_), Some(_), Some(enums::FutureUsage::OffSession), Some(_), Some(_)) => {+ (Some(_), Some(_), Some(enums::FutureUsage::OffSession), Some(_), Some(_), _) => {Err(errors::ValidationError::InvalidValue {message: "Expected one out of recurring_details and mandate_data but got both".to_string(),}.into())}- (_, _, Some(enums::FutureUsage::OffSession), Some(_), Some(_))- | (_, _, Some(enums::FutureUsage::OffSession), Some(_), _)- | (Some(_), _, Some(enums::FutureUsage::OffSession), _, _) => {+ (_, _, Some(enums::FutureUsage::OffSession), Some(_), Some(_), _)+ | (_, _, Some(enums::FutureUsage::OffSession), Some(_), _, _)+ | (Some(_), _, Some(enums::FutureUsage::OffSession), _, _, _) => {Ok(Some(api::MandateTransactionType::NewMandateTransaction))}- (_, _, Some(enums::FutureUsage::OffSession), _, Some(_))- | (_, Some(_), _, _, _)- | (_, _, Some(enums::FutureUsage::OffSession), _, _) => Ok(Some(- api::MandateTransactionType::RecurringMandateTransaction,- )),+ (_, _, Some(enums::FutureUsage::OffSession), _, Some(_), _)+ | (_, Some(_), _, _, _, _)+ | (_, _, Some(enums::FutureUsage::OffSession), _, _, Some(enums::PaymentMethod::Wallet)) => {+ Ok(Some(+ api::MandateTransactionType::RecurringMandateTransaction,+ ))+ }_ => Ok(None),}diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rsindex 0f9459b552..00eb0a3bc3 100644--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs@@ -111,6 +111,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Copayment_intent.setup_future_usage,request.customer_acceptance.clone(),request.payment_token.clone(),+ payment_attempt.payment_method,).change_context(errors::ApiErrorResponse::MandateValidationFailed {reason: "Expected one out of recurring_details and mandate_data but got both".into(),diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rsindex df2f8746e1..c4abe7ff86 100644--- a/crates/router/src/core/payments/operations/payment_confirm.rs+++ b/crates/router/src/core/payments/operations/payment_confirm.rs@@ -524,6 +524,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Papayment_intent.setup_future_usage,request.customer_acceptance.clone(),request.payment_token.clone(),+ payment_attempt.payment_method.or(request.payment_method),).change_context(errors::ApiErrorResponse::MandateValidationFailed {reason: "Expected one out of recurring_details and mandate_data but got both".into(),diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rsindex f590f79781..88489f4a03 100644--- a/crates/router/src/core/payments/operations/payment_create.rs+++ b/crates/router/src/core/payments/operations/payment_create.rs@@ -150,6 +150,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Parequest.setup_future_usage,request.customer_acceptance.clone(),request.payment_token.clone(),+ request.payment_method,).change_context(errors::ApiErrorResponse::MandateValidationFailed {reason: "Expected one out of recurring_details and mandate_data but got both".into(),diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rsindex 6928b8f6f7..3b243e8613 100644--- a/crates/router/src/core/payments/operations/payment_update.rs+++ b/crates/router/src/core/payments/operations/payment_update.rs@@ -136,6 +136,7 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Papayment_intent.setup_future_usage,request.customer_acceptance.clone(),request.payment_token.clone(),+ payment_attempt.payment_method.or(request.payment_method),).change_context(errors::ApiErrorResponse::MandateValidationFailed {reason: "Expected one out of recurring_details and mandate_data but got both".into(),