Skip to content

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

fix(routing): Added routing validation for payments req (#4762)

Sarthak Soni21a3a2ea8ada
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index aa2cf09cb6..edda62d79f 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -1336,6 +1336,16 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for PaymentConfir
.clone()
.ok_or(report!(errors::ApiErrorResponse::PaymentNotFound))?;
+ let _request_straight_through: Option<api::routing::StraightThroughAlgorithm> = request
+ .routing
+ .clone()
+ .map(|val| val.parse_value("RoutingAlgorithm"))
+ .transpose()
+ .change_context(errors::ApiErrorResponse::InvalidRequestData {
+ message: "Invalid straight through routing rules format".to_string(),
+ })
+ .attach_printable("Invalid straight through routing rules format")?;
+
Ok((
Box::new(self),
operations::ValidateResult {
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index 4d4444a280..9a4e878905 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -735,6 +735,16 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for PaymentCreate
)?;
}
+ let _request_straight_through: Option<api::routing::StraightThroughAlgorithm> = request
+ .routing
+ .clone()
+ .map(|val| val.parse_value("RoutingAlgorithm"))
+ .transpose()
+ .change_context(errors::ApiErrorResponse::InvalidRequestData {
+ message: "Invalid straight through routing rules format".to_string(),
+ })
+ .attach_printable("Invalid straight through routing rules format")?;
+
Ok((
Box::new(self),
operations::ValidateResult {
diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs
index 494ab0f2ee..e44dc0c1f2 100644
--- a/crates/router/src/core/payments/operations/payment_update.rs
+++ b/crates/router/src/core/payments/operations/payment_update.rs
@@ -782,6 +782,16 @@ impl<F: Send + Clone> ValidateRequest<F, api::PaymentsRequest> for PaymentUpdate
&request.mandate_id,
)?;
+ let _request_straight_through: Option<api::routing::StraightThroughAlgorithm> = request
+ .routing
+ .clone()
+ .map(|val| val.parse_value("RoutingAlgorithm"))
+ .transpose()
+ .change_context(errors::ApiErrorResponse::InvalidRequestData {
+ message: "Invalid straight through routing rules format".to_string(),
+ })
+ .attach_printable("Invalid straight through routing rules format")?;
+
Ok((
Box::new(self),
operations::ValidateResult {