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

refactor(routing): Remove de evaluate, feedback and rule evaluate api handlers (#15123)

Gaurav Rawata519d6b8eead
diff --git a/api-reference/docs.json b/api-reference/docs.json
index 3c81467e29..b0c8562438 100644
--- a/api-reference/docs.json
+++ b/api-reference/docs.json
@@ -307,10 +307,7 @@
"v1/routing/routing--retrieve-default-for-profile",
"v1/routing/routing--update-default-for-profile",
"v1/routing/routing--retrieve",
- "v1/routing/routing--activate-config",
- "v1/routing/routing--evaluate",
- "v1/routing/routing--feedback",
- "v1/routing/routing--rule-evaluate"
+ "v1/routing/routing--activate-config"
]
},
{
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index d5de8f75b9..a92c9562aa 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -7117,201 +7117,6 @@
]
}
},
- "/routing/evaluate": {
- "post": {
- "tags": [
- "Routing"
- ],
- "summary": "Routing - Evaluate",
- "description": "Evaluate routing rules",
- "operationId": "Evaluate routing rules",
- "parameters": [
- {
- "name": "X-Connected-Merchant-Id",
- "in": "header",
- "description": "Merchant ID of the connected merchant on whose behalf the operation is performed. Required when authenticating with a platform merchant's API key. Standard and connected merchants must not send it.",
- "required": false,
- "schema": {
- "type": "string",
- "nullable": true
- },
- "example": "merchant_abc"
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/OpenRouterDecideGatewayRequest"
- }
- }
- },
- "required": true
- },
- "responses": {
- "200": {
- "description": "Routing rules evaluated successfully",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/DecideGatewayResponse"
- }
- }
- }
- },
- "400": {
- "description": "Request body is malformed"
- },
- "403": {
- "description": "Forbidden"
- },
- "404": {
- "description": "Resource missing"
- },
- "422": {
- "description": "Unprocessable request"
- },
- "500": {
- "description": "Internal server error"
- }
- },
- "security": [
- {
- "api_key": []
- }
- ]
- }
- },
- "/routing/feedback": {
- "post": {
- "tags": [
- "Routing"
- ],
- "summary": "Routing - Feedback",
- "description": "Update gateway scores for dynamic routing",
- "operationId": "Update gateway scores",
- "parameters": [
- {
- "name": "X-Connected-Merchant-Id",
- "in": "header",
- "description": "Merchant ID of the connected merchant on whose behalf the operation is performed. Required when authenticating with a platform merchant's API key. Standard and connected merchants must not send it.",
- "required": false,
- "schema": {
- "type": "string",
- "nullable": true
- },
- "example": "merchant_abc"
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/UpdateScorePayload"
- }
- }
- },
- "required": true
- },
- "responses": {
- "200": {
- "description": "Gateway score updated successfully",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/UpdateScoreResponse"
- }
- }
- }
- },
- "400": {
- "description": "Request body is malformed"
- },
- "403": {
- "description": "Forbidden"
- },
- "404": {
- "description": "Resource missing"
- },
- "422": {
- "description": "Unprocessable request"
- },
- "500": {
- "description": "Internal server error"
- }
- },
- "security": [
- {
- "api_key": []
- }
- ]
- }
- },
- "/routing/rule/evaluate": {
- "post": {
- "tags": [
- "Routing"
- ],
- "summary": "Routing - Rule Evaluate",
- "description": "Evaluate routing rules",
- "operationId": "Evaluate routing rules (alternative)",
- "parameters": [
- {
- "name": "X-Connected-Merchant-Id",
- "in": "header",
- "description": "Merchant ID of the connected merchant on whose behalf the operation is performed. Required when authenticating with a platform merchant's API key. Standard and connected merchants must not send it.",
- "required": false,
- "schema": {
- "type": "string",
- "nullable": true
- },
- "example": "merchant_abc"
- }
- ],
- "requestBody": {
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/RoutingEvaluateRequest"
- }
- }
- },
- "required": true
- },
- "responses": {
- "200": {
- "description": "Routing rules evaluated successfully",
- "content": {
- "application/json": {
- "schema": {
- "$ref": "#/components/schemas/RoutingEvaluateResponse"
- }
- }
- }
- },
- "400": {
- "description": "Request body is malformed"
- },
- "403": {
- "description": "Forbidden"
- },
- "404": {
- "description": "Resource missing"
- },
- "422": {
- "description": "Unprocessable request"
- },
- "500": {
- "description": "Internal server error"
- }
- },
- "security": [
- {
- "api_key": []
- }
- ]
- }
- },
"/offer_engine/offers/list": {
"post": {
"tags": [
@@ -22912,95 +22717,6 @@
}
}
},
- "DecideGatewayResponse": {
- "type": "object",
- "properties": {
- "decided_gateway": {
- "type": "string",
- "description": "The gateway decided by the routing engine",
- "example": "stripe:mca1",
- "nullable": true
- },
- "gateway_priority_map": {
- "type": "object",
- "description": "Map of gateways with their priority scores",
- "additionalProperties": {
- "type": "number",
- "format": "double"
- },
- "example": {
- "adyen:mca2": 1.0,
- "stripe:mca1": 1.0
- },
- "nullable": true
- },
- "filter_wise_gateways": {
- "type": "object",
- "description": "Gateways organized by filter criteria",
- "nullable": true
- },
- "priority_logic_tag": {
- "type": "string",
- "description": "Tag identifying the priority logic used",
- "nullable": true
- },
- "routing_approach": {
- "type": "string",
- "description": "The routing approach used for decision making",
- "example": "SR_SELECTION_V3_ROUTING",
- "nullable": true
- },
- "gateway_before_evaluation": {
- "type": "string",
- "description": "The gateway that was evaluated before the final decision",
- "example": "adyen:mca2",
- "nullable": true
- },
- "priority_logic_output": {
- "allOf": [
- {
- "$ref": "#/components/schemas/PriorityLogicOutput"
- }
- ],
- "nullable": true
- },
- "reset_approach": {
- "type": "string",
- "description": "The reset approach applied during routing",
- "example": "NO_RESET",
- "nullable": true
- },
- "routing_dimension": {
- "type": "string",
- "description": "Dimensions used for routing decision (payment type, method, etc.)",
- "example": "ORDER_PAYMENT, UPI, upi",
- "nullable": true
- },
- "routing_dimension_level": {
- "type": "string",
- "description": "Level at which routing dimension is evaluated",
- "example": "PM_LEVEL",
- "nullable": true
- },
- "is_scheduled_outage": {
- "type": "boolean",
- "description": "Indicates if routing decision was affected by scheduled outage",
- "example": false,
- "nullable": true
- },
- "is_dynamic_mga_enabled": {
- "type": "boolean",
- "description": "Indicates if dynamic merchant gateway account is enabled",
- "example": false,
- "nullable": true
- },
- "gateway_mga_id_map": {
- "type": "object",
- "description": "Map of gateways to their MGA IDs",
- "nullable": true
- }
- }
- },
"DecisionEngineEliminationData": {
"type": "object",
"required": [
@@ -31507,41 +31223,6 @@
}
}
},
- "OpenRouterDecideGatewayRequest": {
- "type": "object",
- "description": "Request to decide the optimal gateway for routing a payment",
- "required": [
- "paymentInfo",
- "merchantId"
- ],
- "properties": {
- "paymentInfo": {
- "$ref": "#/components/schemas/PaymentInfo"
- },
- "merchantId": {
- "type": "string",
- "description": "Profile ID of the merchant",
- "example": "pro_aMoPnEkgCVnh2WVsFe32"
- },
- "eligibleGatewayList": {
- "type": "array",
- "items": {
- "type": "string"
- },
- "description": "List of eligible gateways for routing consideration",
- "example": "[\"stripe:mca_123\", \"adyen:mca_456\"]",
- "nullable": true
- },
- "rankingAlgorithm": {
- "allOf": [
- {
- "$ref": "#/components/schemas/RankingAlgorithm"
- }
- ],
- "nullable": true
- }
- }
- },
"OrderDetailsWithAmount": {
"type": "object",
"required": [
@@ -32837,74 +32518,6 @@
"type": "string",
"description": "A type for payment_id that can be used for payment ids"
},
- "PaymentInfo": {
- "type": "object",
- "description": "Payment information used for routing decision-making",
- "required": [
- "paymentId",
- "amount",
- "currency",
- "paymentType",
- "metadata",
- "paymentMethodType",
- "paymentMethod",
- "cardIsin"
- ],
- "properties": {
- "paymentId": {
- "type": "string",
- "description": "Unique identifier for the payment transaction",
- "example": "pay_12345"
- },
- "amount": {
- "type": "integer",
- "format": "int64",
- "description": "Payment amount in minor units",
- "example": "100"
- },
- "currency": {
- "type": "string",
- "description": "Currency code for the payment",
- "example": "USD"
- },
- "preferredConnectors": {
- "type": "array",
- "items": {
- "type": "string"
- },
- "description": "Ordered preferred connector account identities in `connector:mca_id` format.",
- "example": [
- "adyen:mca_5678"
- ],
- "nullable": true
- },
- "paymentType": {
- "type": "string",
- "description": "Type of payment transaction being processed",
- "example": "ORDER_PAYMENT"
- },
- "metadata": {
- "type": "string",
- "description": "Optional metadata associated with the payment",
- "example": "metadata"
- },
- "paymentMethodType": {
- "type": "string",
- "description": "Specific payment method type being used",
- "example": "upi"
- },
- "paymentMethod": {
- "type": "string",
- "description": "General payment method category",
- "example": "upi"
- },
- "cardIsin": {
- "type": "string",
- "description": "Card Issuer Identification Number (first 6 digits of card)",
- "example": "424242"
- }
- }
- },
"PaymentIntentStateMetadata": {
"type": "object",
"description": "Additional metadata for payment intent state containing refunded and disputed amounts",
@@ -43256,78 +42869,6 @@
},
"additionalProperties": false
},
- "PriorityLogicData": {
- "type": "object",
- "properties": {
- "name": {
- "type": "string",
- "description": "Name of the logic",
- "example": "success_rate_logic",
- "nullable": true
- },
- "status": {
- "type": "string",
- "description": "Status of the logic execution",
- "example": "success",
- "nullable": true
- },
- "failure_reason": {
- "type": "string",
- "description": "Reason for failure if the logic failed",
- "example": "insufficient_data",
- "nullable": true
- }
- }
- },
- "PriorityLogicOutput": {
- "type": "object",
- "properties": {
- "isEnforcement": {
- "type": "boolean",
- "description": "Whether enforcement mode is enabled",
- "example": false,
- "nullable": true
- },
- "gws": {
- "type": "array",
- "items": {
- "type": "string"
- },
- "description": "List of gateways returned by the priority logic",
- "example": [
- "stripe:mca1",
- "adyen:mca2"
- ],
- "nullable": true
- },
- "priorityLogicTag": {
- "type": "string",
- "description": "Tag identifying the priority logic used",
- "nullable": true
- },
- "gatewayReferenceIds": {
- "type": "object",
- "description": "Map of gateway reference IDs",
- "nullable": true
- },
- "primaryLogic": {
- "allOf": [
- {
- "$ref": "#/components/schemas/PriorityLogicData"
- }
- ],
- "nullable": true
- },
- "fallbackLogic": {
- "allOf": [
- {
- "$ref": "#/components/schemas/PriorityLogicData"
- }
- ],
- "nullable": true
- }
- }
- },
"ProcessorPaymentToken": {
"type": "object",
"description": "Processor payment token for MIT payments where payment_method_data is not available",
@@ -44496,14 +44037,6 @@
}
}
},
- "RankingAlgorithm": {
- "type": "string",
- "enum": [
- "SR_BASED_ROUTING",
- "PL_BASED_ROUTING",
- "NTW_BASED_ROUTING"
- ]
- },
"RapidDisputeResolution": {
"type": "object",
"description": "Visa Rapid Dispute Resolution details",
@@ -46898,80 +46431,6 @@
}
}
},
- "RoutingEvaluateRequest": {
- "type": "object",
- "description": "Request body used to evaluate routing rules.\n\nThis API evaluates routing logic based on dynamic parameters\nlike payment method, amount, country, card_bin, etc.",
- "required": [
- "created_by",
- "parameters",
- "fallback_output"
- ],
- "properties": {
- "created_by": {
- "type": "string",
- "description": "Identifier of the user/system triggering routing evaluation.\n\nExample:\n```json\n\"created_by\": \"some_id\"\n```",
- "example": "profile_123"
- },
- "payment_id": {
- "type": "string",
- "description": "Payment ID for debugging and tracing routing decisions.\n\nExample:\n```json\n\"payment_id\": \"pay_abc123\"\n```",
- "example": "pay_abc123",
- "nullable": true
- },
- "parameters": {
- "type": "object",
- "description": "Dynamic parameters used during routing evaluation.\n\nEach key represents a routing attribute.\n\nExample fields:\n\n- `payment_method`\n- `payment_method_type`\n- `amount`\n- `currency`\n- `authentication_type`\n- `card_bin`\n- `capture_method`\n- `business_country`\n- `billing_country`\n- `business_label`\n- `setup_future_usage`\n- `card_network`\n- `payment_type`\n- `mandate_type`\n- `mandate_acceptance_type`\n- `metadata`\n\nExample:\n```json\n{\n\"payment_method\": { \"type\": \"enum_variant\", \"value\": \"card\" },\n\"amount\": { \"type\": \"number\", \"value\": 10 },\n\"currency\": { \"type\": \"str_value\", \"value\": \"INR\" },\n\"authentication_type\": { \"type\": \"enum_variant\", \"value\": \"three_ds\" },\n\"card_bin\": { \"type\": \"str_value\", \"value\": \"424242\" },\n\"business_country\": { \"type\": \"str_value\", \"value\": \"IN\" },\n\"setup_future_usage\": { \"type\": \"enum_variant\", \"value\": \"off_session\" },\n\"card_network\": { \"type\": \"enum_variant\", \"value\": \"visa\" },\n\"metadata\": {\n\"type\": \"metadata_variant\",\n\"value\": { \"key\": \"key1\", \"value\": \"value1\" }\n}\n}\n```\n\nFor the complete superset of supported routing keys,\nrefer to `routing_configs.keys` in:\nhttps://github.com/juspay/decision-engine/blob/main/config/development.toml"
- },
- "fallback_output": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/DeRoutableConnectorChoice"
- },
- "description": "Fallback connectors used if routing rule evaluation fails.\n\nThese connectors will be returned if no rule matches.\n\nExample:\n```json\n[\n{\n\"gateway_name\": \"stripe\",\n\"gateway_id\": \"mca_123\"\n}\n]\n```"
- },
- "algorithm_for": {
- "allOf": [
- {
- "$ref": "#/components/schemas/TransactionType"
- }
- ],
- "nullable": true
- }
- }
- },
- "RoutingEvaluateResponse": {
- "type": "object",
- "description": "Response returned after routing evaluation.\n\nContains:\n- Routing status\n- Raw output structure (priority / volume_split)\n- Final evaluated connectors\n- Eligible connectors list",
- "required": [
- "status",
- "output",
- "evaluated_output",
- "eligible_connectors"
- ],
- "properties": {
- "status": {
- "type": "string",
- "description": "Status of routing evaluation.\n\nExample:\n```json\n\"success\"\n```",
- "example": "success"
- },
- "output": {
- "description": "Raw routing output returned by routing engine.\n\nPossible structures:\n\n1. Volume Split:\n```json\n{\n\"type\": \"volume_split\",\n\"splits\": [\n{\n\"connector\": { \"gateway_name\": \"adyen\", \"gateway_id\": \"mca_124\" },\n\"split\": 60\n},\n{\n\"connector\": { \"gateway_name\": \"stripe\", \"gateway_id\": \"mca_123\" },\n\"split\": 40\n}\n]\n}\n```\n\n2. Priority:\n```json\n{\n\"type\": \"priority\",\n\"connectors\": [\n{ \"gateway_name\": \"stripe\", \"gateway_id\": \"mca_123\" },\n{ \"gateway_name\": \"adyen\", \"gateway_id\": \"mca_124\" }\n]\n}\n```"
- },
- "evaluated_output": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/RoutableConnectorChoice"
- },
- "description": "Final connector(s) selected after evaluation.\n\nExample:\n```json\n[\n{\n\"connector\": \"stripe\",\n\"merchant_connector_id\": \"mca_123\"\n}\n]\n```"
- },
- "eligible_connectors": {
- "type": "array",
- "items": {
- "$ref": "#/components/schemas/RoutableConnectorChoice"
- }
- }
- }
- },
"RoutingKind": {
"oneOf": [
{
@@ -50130,34 +49589,6 @@
"tokenize"
]
},
- "TxnStatus": {
- "type": "string",
- "enum": [
- "STARTED",
- "AUTHENTICATION_FAILED",
- "JUSPAY_DECLINED",
- "PENDING_VBV",
- "V_B_V_SUCCESSFUL",
- "AUTHORIZED",
- "AUTHORIZATION_FAILED",
- "CHARGED",
- "AUTHORIZING",
- "C_O_D_INITIATED",
- "VOIDED",
- "VOIDED_POST_CHARGE",
- "VOID_INITIATED",
- "NOP",
- "CAPTURE_INITIATED",
- "CAPTURE_FAILED",
- "VOID_FAILED",
- "AUTO_REFUNDED",
- "PARTIAL_CHARGED",
- "TO_BE_CHARGED",
- "PENDING",
- "FAILURE",
- "DECLINED"
- ]
- },
"UIWidgetFormLayout": {
"type": "string",
"enum": [
@@ -50218,50 +49649,6 @@
},
"additionalProperties": false
},
- "UpdateScorePayload": {
- "type": "object",
- "description": "Request payload to update gateway performance score based on transaction outcome",
- "required": [
- "merchantId",
- "gateway",
- "status",
- "paymentId"
- ],
- "properties": {
- "merchantId": {
- "type": "string",
- "description": "Profile ID of the merchant",
- "example": "pro_aMoPnEkgCVnh2WVsFe32"
- },
- "gateway": {
- "type": "string",
- "description": "Payment Gateway identifier",
- "example": "stripe:mca1"
- },
- "status": {
- "$ref": "#/components/schemas/TxnStatus"
- },
- "paymentId": {
- "type": "string",
- "description": "Payment ID associated with the transaction",
- "example": "pay_1234"
- }
- }
- },
- "UpdateScoreResponse": {
- "type": "object",
- "description": "Response after updating gateway score",
- "required": [
- "message"
- ],
- "properties": {
- "message": {
- "type": "string",
- "description": "Status message indicating the result of the score update",
- "example": "Gateway score updated successfully"
- }
- }
- },
"UpdateSubscriptionRequest": {
"type": "object",
"required": [
diff --git a/api-reference/v1/routing/routing--evaluate.mdx b/api-reference/v1/routing/routing--evaluate.mdx
deleted file mode 100644
index d4fe104628..0000000000
--- a/api-reference/v1/routing/routing--evaluate.mdx
+++ /dev/null
@@ -1,3 +0,0 @@
----
-openapi: post /routing/evaluate
----
diff --git a/api-reference/v1/routing/routing--feedback.mdx b/api-reference/v1/routing/routing--feedback.mdx
deleted file mode 100644
index 60fb7cde6d..0000000000
--- a/api-reference/v1/routing/routing--feedback.mdx
+++ /dev/null
@@ -1,3 +0,0 @@
----
-openapi: post /routing/feedback
----
diff --git a/api-reference/v1/routing/routing--rule-evaluate.mdx b/api-reference/v1/routing/routing--rule-evaluate.mdx
deleted file mode 100644
index 8715b56d5c..0000000000
--- a/api-reference/v1/routing/routing--rule-evaluate.mdx
+++ /dev/null
@@ -1,3 +0,0 @@
----
-openapi: post /routing/rule/evaluate
----
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index 69a5e35f47..9894a20c30 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -195,9 +195,6 @@ Never share your secret api keys. Keep them guarded and secure.
routes::routing::create_success_based_routing,
routes::routing::create_elimination_routing,
routes::routing::contract_based_routing_setup_config,
- routes::routing::call_decide_gateway_open_router,
- routes::routing::call_update_gateway_score_open_router,
- routes::routing::evaluate_routing_rule,
// Routes for offers
routes::offer_engine::offer_engine_browse_offers,
@@ -1206,24 +1203,13 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::authentication::AuthenticationPaymentMethodDataResponse,
api_models::authentication::AuthenticationDetails,
api_models::authentication::ExternalThreeDsData,
- api_models::open_router::OpenRouterDecideGatewayRequest,
- api_models::open_router::DecideGatewayResponse,
- api_models::open_router::UpdateScorePayload,
- api_models::open_router::UpdateScoreResponse,
- api_models::routing::RoutingEvaluateRequest,
- api_models::routing::RoutingEvaluateResponse,
api_models::routing::ValueType,
api_models::routing::DeRoutableConnectorChoice,
api_models::routing::RoutableConnectorChoice,
- api_models::open_router::PaymentInfo,
common_utils::id_type::PaymentId,
common_utils::id_type::ProfileId,
common_utils::id_type::AuthenticationId,
common_utils::id_type::ProfileAcquirerId,
- api_models::open_router::RankingAlgorithm,
- api_models::open_router::TxnStatus,
- api_models::open_router::PriorityLogicOutput,
- api_models::open_router::PriorityLogicData,
api_models::user::PlatformAccountCreateRequest,
api_models::user::PlatformAccountCreateResponse,
api_models::platform::Initiator,
diff --git a/crates/openapi/src/routes/routing.rs b/crates/openapi/src/routes/routing.rs
index b7a38b2ae6..4ca72acc53 100644
--- a/crates/openapi/src/routes/routing.rs
+++ b/crates/openapi/src/routes/routing.rs
@@ -487,96 +487,3 @@ pub async fn create_elimination_routing() {}
security(("api_key" = []), ("jwt_key" = []))
)]
pub async fn contract_based_routing_setup_config() {}
-
-#[cfg(feature = "v1")]
-/// Routing - Evaluate
-///
-/// Evaluate routing rules
-#[utoipa::path(
- post,
- path = "/routing/evaluate",
- request_body = OpenRouterDecideGatewayRequest,
- responses(
- (status = 200, description = "Routing rules evaluated successfully", body = DecideGatewayResponse),
- (status = 400, description = "Request body is malformed"),
- (status = 500, description = "Internal server error"),
- (status = 404, description = "Resource missing"),
- (status = 422, description = "Unprocessable request"),
- (status = 403, description = "Forbidden"),
- ),
- params(
- (
- "X-Connected-Merchant-Id" = Option<String>, Header,
- description = "Merchant ID of the connected merchant on whose behalf the operation is performed. \
- Required when authenticating with a platform merchant's API key. \
- Standard and connected merchants must not send it.",
- example = "merchant_abc"
- )
- ),
- tag = "Routing",
- operation_id = "Evaluate routing rules",
- security(("api_key" = []))
-)]
-pub async fn call_decide_gateway_open_router() {}
-
-#[cfg(feature = "v1")]
-/// Routing - Feedback
-///
-/// Update gateway scores for dynamic routing
-#[utoipa::path(
- post,
- path = "/routing/feedback",
- request_body = UpdateScorePayload,
- responses(
- (status = 200, description = "Gateway score updated successfully", body = UpdateScoreResponse),
- (status = 400, description = "Request body is malformed"),
- (status = 500, description = "Internal server error"),
- (status = 404, description = "Resource missing"),
- (status = 422, description = "Unprocessable request"),
- (status = 403, description = "Forbidden"),
- ),
- params(
- (
- "X-Connected-Merchant-Id" = Option<String>, Header,
- description = "Merchant ID of the connected merchant on whose behalf the operation is performed. \
- Required when authenticating with a platform merchant's API key. \
- Standard and connected merchants must not send it.",
- example = "merchant_abc"
- )
- ),
- tag = "Routing",
- operation_id = "Update gateway scores",
- security(("api_key" = []))
-)]
-pub async fn call_update_gateway_score_open_router() {}
-
-#[cfg(feature = "v1")]
-/// Routing - Rule Evaluate
-///
-/// Evaluate routing rules
-#[utoipa::path(
- post,
- path = "/routing/rule/evaluate",
- request_body = RoutingEvaluateRequest,
- responses(
- (status = 200, description = "Routing rules evaluated successfully", body = RoutingEvaluateResponse),
- (status = 400, description = "Request body is malformed"),
- (status = 500, description = "Internal server error"),
- (status = 404, description = "Resource missing"),
- (status = 422, description = "Unprocessable request"),
- (status = 403, description = "Forbidden"),
- ),
- params(
- (
- "X-Connected-Merchant-Id" = Option<String>, Header,
- description = "Merchant ID of the connected merchant on whose behalf the operation is performed. \
- Required when authenticating with a platform merchant's API key. \
- Standard and connected merchants must not send it.",
- example = "merchant_abc"
- )
- ),
- tag = "Routing",
- operation_id = "Evaluate routing rules (alternative)",
- security(("api_key" = []))
-)]
-pub async fn evaluate_routing_rule() {}
diff --git a/crates/router/src/core/payments/routing.rs b/crates/router/src/core/payments/routing.rs
index 9c995e87c0..534a279a5d 100644
--- a/crates/router/src/core/payments/routing.rs
+++ b/crates/router/src/core/payments/routing.rs
@@ -3592,77 +3592,6 @@ pub fn make_dsl_input_for_surcharge(
Ok(backend_input)
}
-#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
-pub async fn perform_dynamic_routing_with_open_router(
- state: &SessionState,
- routable_connectors: Vec<api_routing::RoutableConnectorChoice>,
- profile: &domain::Profile,
- payment_data: oss_storage::PaymentAttempt,
-) -> RoutingResult<Option<RoutingConnectorOutcomeWithApproach>> {
- let dynamic_routing_algo_ref: api_routing::DynamicRoutingAlgorithmRef = profile
- .dynamic_routing_algorithm
- .clone()
- .map(|val| val.parse_value("DynamicRoutingAlgorithmRef"))
- .transpose()
- .change_context(errors::RoutingError::DeserializationError {
- from: "JSON".to_string(),
- to: "DynamicRoutingAlgorithmRef".to_string(),
- })
- .attach_printable("unable to deserialize DynamicRoutingAlgorithmRef from JSON")?
- .ok_or(errors::RoutingError::GenericNotFoundError {
- field: "dynamic_routing_algorithm".to_string(),
- })?;
-
- logger::debug!(
- "performing dynamic_routing with open_router for profile {}",
- profile.get_id().get_string_repr()
- );
-
- let is_success_rate_routing_enabled =
- dynamic_routing_algo_ref.is_success_rate_routing_enabled();
- let is_elimination_enabled = dynamic_routing_algo_ref.is_elimination_enabled();
-
- // Since success_based and elimination routing is being done in 1 api call, we call decide_gateway when either of it enabled
- let connectors = if is_success_rate_routing_enabled || is_elimination_enabled {
- let connectors = perform_decide_gateway_call_with_open_router(
- state,
- routable_connectors.clone(),
- profile.get_id(),
- &payment_data,
- )
- .await?;
-
- if is_elimination_enabled {
- // This will initiate the elimination process for the connector.
- // Penalize the elimination score of the connector before making a payment.
- // Once the payment is made, we will update the score based on the payment status
- if let Some(connector) = connectors.connectors.first() {
- logger::debug!(
- "penalizing the elimination score of the gateway with id {} in open_router for profile {}",
- routing::format_connector_for_logging(
- connector.connector,
- connector.merchant_connector_id.as_ref(),
- ),
- profile.get_id().get_string_repr()
- );
- update_gateway_score_with_open_router(
- state,
- connector.clone(),
- profile.get_id(),
- &payment_data.merchant_id,
- &payment_data.payment_id,
- common_enums::AttemptStatus::AuthenticationPending,
- )
- .await?
- }
- }
- Some(connectors)
- } else {
- None
- };
- Ok(connectors)
-}
-
#[cfg(feature = "v1")]
pub async fn perform_open_routing_for_debit_routing<F, D>(
state: &SessionState,
@@ -3859,115 +3788,6 @@ where
Ok(connector_list)
}
-#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
-#[instrument(skip_all)]
-pub async fn perform_decide_gateway_call_with_open_router(
- state: &SessionState,
- mut routable_connectors: Vec<api_routing::RoutableConnectorChoice>,
- profile_id: &common_utils::id_type::ProfileId,
- payment_attempt: &oss_storage::PaymentAttempt,
-) -> RoutingResult<RoutingConnectorOutcomeWithApproach> {
- logger::debug!(
- "performing decide_gateway call with open_router for profile {}",
- profile_id.get_string_repr()
- );
-
- let open_router_req_body = OpenRouterDecideGatewayRequest::construct_sr_request(
- payment_attempt,
- routable_connectors.clone(),
- Some(or_types::RankingAlgorithm::SrBasedRouting),
- // Legacy routing does not send preferred connectors.
- None,
- );
-
- let routing_events_wrapper = utils::RoutingEventsWrapper::new(
- state.tenant.tenant_id.clone(),
- state.request_id.clone(),
- payment_attempt.payment_id.get_string_repr().to_string(),
- payment_attempt.profile_id.to_owned(),
- payment_attempt.merchant_id.to_owned(),
- "DecisionEngine: SuccessRate decide_gateway".to_string(),
- Some(open_router_req_body.clone()),
- true,
- false,
- );
-
- let response: RoutingResult<utils::RoutingEventsResponse<DecidedGateway>> =
- utils::SRApiClient::send_decision_engine_request(
- state,
- services::Method::Post,
- "decide-gateway",
- Some(open_router_req_body),
- None,
- Some(routing_events_wrapper),
- )
- .await;
-
- let sr_sorted_connectors = match response {
- Ok(resp) => {
- let decided_gateway: DecidedGateway =
- resp.response.ok_or(errors::RoutingError::OpenRouterError(
- "Empty response received from open_router".into(),
- ))?;
-
- let mut routing_event = resp.event.ok_or(errors::RoutingError::RoutingEventsError {
- message: "Decision-Engine: RoutingEvent not found in RoutingEventsResponse"
- .to_string(),
- status_code: 500,
- })?;
-
- routing_event.set_response_body(&decided_gateway);
- routing_event.set_routing_approach(
- utils::RoutingApproach::from_decision_engine_approach(
- &decided_gateway.routing_approach,
- )
- .to_string(),
- );
-
- let routing_approach = common_enums::RoutingApproach::from_decision_engine_approach(
- &decided_gateway.routing_approach,
- );
-
- if let Some(gateway_priority_map) = decided_gateway.gateway_priority_map {
- logger::debug!(gateway_priority_map=?gateway_priority_map, routing_approach=decided_gateway.routing_approach, "open_router decide_gateway call response");
- routable_connectors.sort_by(|connector_choice_a, connector_choice_b| {
- let connector_choice_a_score = gateway_priority_map
- .get(&connector_choice_a.to_string())
- .copied()
- .unwrap_or(0.0);
- let connector_choice_b_score = gateway_priority_map
- .get(&connector_choice_b.to_string())
- .copied()
- .unwrap_or(0.0);
- connector_choice_b_score
- .partial_cmp(&connector_choice_a_score)
- .unwrap_or(std::cmp::Ordering::Equal)
- });
- }
-
- routing_event.set_routable_connectors(routable_connectors.clone());
- state.event_handler().log_event(&routing_event);
-
- Ok(RoutingConnectorOutcomeWithApproach {
- connectors: routable_connectors,
- routing_approach,
- })
- }
- Err(err) => {
- logger::error!("open_router_error_response: {:?}", err);
-
- Err(errors::RoutingError::OpenRouterError(
- "Failed to perform decide_gateway call in open_router".into(),
- ))
- }
- }?;
-
- Ok(RoutingConnectorOutcomeWithApproach {
- connectors: sr_sorted_connectors.connectors,
- routing_approach: sr_sorted_connectors.routing_approach,
- })
-}
-
#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
#[instrument(skip_all)]
pub async fn update_gateway_score_with_open_router(
diff --git a/crates/router/src/core/routing.rs b/crates/router/src/core/routing.rs
index 61757d48b9..6e91849b61 100644
--- a/crates/router/src/core/routing.rs
+++ b/crates/router/src/core/routing.rs
@@ -5,18 +5,13 @@ use std::collections::{HashMap, HashSet};
#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
use api_models::routing::DynamicRoutingAlgoAccessor;
use api_models::{
- enums, mandates as mandates_api,
- open_router::{
- DecideGatewayResponse, OpenRouterDecideGatewayRequest, UpdateScorePayload,
- UpdateScoreResponse,
- },
- routing,
+ enums, mandates as mandates_api, routing,
routing::{
self as routing_types, RoutingRetrieveQuery, RuleMigrationError, RuleMigrationResponse,
},
};
use async_trait::async_trait;
-use common_utils::{ext_traits::Encode, request::Method};
+use common_utils::ext_traits::Encode;
use diesel_models::routing_algorithm::RoutingAlgorithm;
use error_stack::ResultExt;
#[cfg(all(feature = "v1", feature = "dynamic_routing"))]
@@ -3594,62 +3589,6 @@ pub async fn routing_migration_status(
})
}
-pub async fn decide_gateway_open_router(
- state: SessionState,
- req_body: OpenRouterDecideGatewayRequest,
-) -> RouterResponse<DecideGatewayResponse> {
- let response = if state.conf.open_router.dynamic_routing_enabled {
- SRApiClient::send_decision_engine_request(
- &state,
- Method::Post,
- "decide-gateway",
- Some(req_body),
- None,
- None,
- )
- .await
- .change_context(errors::ApiErrorResponse::InternalServerError)?
- .response
- .ok_or(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to perform decide gateway call with open router")?
- } else {
- Err(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Dynamic routing is not enabled")?
- };
-
- Ok(hyperswitch_domain_models::api::ApplicationResponse::Json(
- response,
- ))
-}
-
-pub async fn update_gateway_score_open_router(
- state: SessionState,
- req_body: UpdateScorePayload,
-) -> RouterResponse<UpdateScoreResponse> {
- let response = if state.conf.open_router.dynamic_routing_enabled {
- SRApiClient::send_decision_engine_request(
- &state,
- Method::Post,
- "update-gateway-score",
- Some(req_body),
- None,
- None,
- )
- .await
- .change_context(errors::ApiErrorResponse::InternalServerError)?
- .response
- .ok_or(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to perform update gateway score call with open router")?
- } else {
- Err(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Dynamic routing is not enabled")?
- };
-
- Ok(hyperswitch_domain_models::api::ApplicationResponse::Json(
- response,
- ))
-}
-
pub fn transaction_type_from_payments_dsl(input: &PaymentsDslInput<'_>) -> enums::TransactionType {
let txn_data = TransactionData::Payment(input.clone());
enums::TransactionType::from(&txn_data)
diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs
index 927e3f8308..1551e07bd7 100644
--- a/crates/router/src/routes/app.rs
+++ b/crates/router/src/routes/app.rs
@@ -1316,19 +1316,6 @@ impl Routing {
})),
);
- #[cfg(feature = "dynamic_routing")]
- {
- route = route
- .service(
- web::resource("/evaluate")
- .route(web::post().to(routing::call_decide_gateway_open_router)),
- )
- .service(
- web::resource("/feedback")
- .route(web::post().to(routing::call_update_gateway_score_open_router)),
- )
- }
-
#[cfg(feature = "payouts")]
{
route = route
@@ -1449,10 +1436,6 @@ impl Routing {
routing::routing_link_config(state, req, path, payload, None)
},
)),
- )
- .service(
- web::resource("/rule/evaluate")
- .route(web::post().to(routing::evaluate_routing_rule)),
);
route
}
diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rs
index f85faa3f59..c146b97b99 100644
--- a/crates/router/src/routes/lock_utils.rs
+++ b/crates/router/src/routes/lock_utils.rs
@@ -92,12 +92,9 @@ impl From<Flow> for ApiIdentifier {
| Flow::CreateDynamicRoutingConfig
| Flow::UpdateDynamicRoutingConfigs
| Flow::DecisionManagerUpsertConfig
- | Flow::RoutingEvaluateRule
| Flow::DecisionEngineRuleMigration
| Flow::DecisionEngineMigrationStatus
- | Flow::VolumeSplitOnRoutingType
- | Flow::DecisionEngineDecideGatewayCall
- | Flow::DecisionEngineGatewayFeedbackCall => Self::Routing,
+ | Flow::VolumeSplitOnRoutingType => Self::Routing,
Flow::CreateSubscription
| Flow::ConfirmSubscription
| Flow::CreateAndConfirmSubscription
diff --git a/crates/router/src/routes/routing.rs b/crates/router/src/routes/routing.rs
index 803061031e..b857d9e9a8 100644
--- a/crates/router/src/routes/routing.rs
+++ b/crates/router/src/routes/routing.rs
@@ -3,29 +3,18 @@
//! Functions that are used to perform the api level configuration, retrieval, updation
//! of Routing configs.
-use std::str::FromStr;
-
use actix_web::{web, HttpRequest, Responder};
use api_models::{
enums,
- routing::{
- self as routing_types, RoutingEvaluateRequest, RoutingEvaluateResponse,
- RoutingRetrieveQuery,
- },
+ routing::{self as routing_types, RoutingRetrieveQuery},
};
-use error_stack::ResultExt;
-use payment_methods::core::errors::ApiErrorResponse;
use router_env::{
tracing::{self, instrument},
Flow,
};
use crate::{
- core::{
- api_locking, conditional_config,
- payments::routing::utils::{DecisionEngineApiHandler, EuclidApiClient},
- routing, surcharge_decision_config,
- },
+ core::{api_locking, conditional_config, routing, surcharge_decision_config},
routes::AppState,
services,
services::{api as oss_api, authentication as auth, authorization::permissions::Permission},
@@ -1525,65 +1514,6 @@ pub async fn get_dynamic_routing_volume_split(
))
.await
}
-const EUCLID_API_TIMEOUT: u64 = 5;
-#[cfg(all(feature = "olap", feature = "v1"))]
-#[instrument(skip_all)]
-pub async fn evaluate_routing_rule(
- state: web::Data<AppState>,
- req: HttpRequest,
- json_payload: web::Json<RoutingEvaluateRequest>,
-) -> impl Responder {
- let json_payload = json_payload.into_inner();
- let flow = Flow::RoutingEvaluateRule;
- Box::pin(oss_api::server_wrap(
- flow,
- state,
- &req,
- json_payload.clone(),
- |state, auth: auth::AuthenticationData, payload, _| async move {
- // `created_by` is a DE profile id; restrict it to the caller's merchant.
- let profile_id = common_utils::id_type::ProfileId::from_str(&payload.created_by)
- .change_context(ApiErrorResponse::InvalidRequestData {
- message: "created_by is not a valid profile id".to_string(),
- })?;
- // A profile outside the caller's merchant surfaces as ProfileNotFound; report it
- // as the ownership failure it is rather than leaking a lookup error.
- crate::core::utils::validate_and_get_business_profile(
- state.store.as_ref(),
- auth.platform.get_processor(),
- Some(&profile_id),
- )
- .await
- .change_context(ApiErrorResponse::InvalidRequestData {
- message: "created_by does not belong to the authenticated merchant".to_string(),
- })?;
-
- let euclid_response: RoutingEvaluateResponse =
- EuclidApiClient::send_decision_engine_request(
- &state,
- services::Method::Post,
- "routing/evaluate",
- Some(payload),
- Some(EUCLID_API_TIMEOUT),
- None,
- )
- .await
- .change_context(ApiErrorResponse::InternalServerError)?
- .response
- .ok_or(ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to evaluate routing rule")?;
-
- Ok(services::ApplicationResponse::Json(euclid_response))
- },
- &auth::ApiKeyAuth {
- allow_connected_scope_operation: true,
- allow_platform_self_operation: false,
- },
- api_locking::LockAction::NotApplicable,
- ))
- .await
-}
-
use actix_web::HttpResponse;
/// Where every profile holding a routing rule stands in the migration, a page at a time.
@@ -1632,53 +1562,3 @@ pub async fn migrate_routing_rules(
))
.await
}
-
-#[cfg(all(feature = "olap", feature = "v1", feature = "dynamic_routing"))]
-#[instrument(skip_all)]
-pub async fn call_decide_gateway_open_router(
- state: web::Data<AppState>,
- req: HttpRequest,
- payload: web::Json<api_models::open_router::OpenRouterDecideGatewayRequest>,
-) -> impl Responder {
- let flow = Flow::DecisionEngineDecideGatewayCall;
- Box::pin(oss_api::server_wrap(
- flow,
- state,
- &req,
- payload.clone(),
- |state, _auth: auth::AuthenticationData, payload, _| {
- routing::decide_gateway_open_router(state.clone(), payload)
- },
- &auth::ApiKeyAuth {
- allow_connected_scope_operation: true,
- allow_platform_self_operation: false,
- },
- api_locking::LockAction::NotApplicable,
- ))
- .await
-}
-
-#[cfg(all(feature = "olap", feature = "v1", feature = "dynamic_routing"))]
-#[instrument(skip_all)]
-pub async fn call_update_gateway_score_open_router(
- state: web::Data<AppState>,
- req: HttpRequest,
- payload: web::Json<api_models::open_router::UpdateScorePayload>,
-) -> impl Responder {
- let flow = Flow::DecisionEngineGatewayFeedbackCall;
- Box::pin(oss_api::server_wrap(
- flow,
- state,
- &req,
- payload.clone(),
- |state, _auth: auth::AuthenticationData, payload, _| {
- routing::update_gateway_score_open_router(state.clone(), payload)
- },
- &auth::ApiKeyAuth {
- allow_connected_scope_operation: true,
- allow_platform_self_operation: false,
- },
- api_locking::LockAction::NotApplicable,
- ))
- .await
-}
diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rs
index c5d3382cbd..2055ae40c8 100644
--- a/crates/router_env/src/logger/types.rs
+++ b/crates/router_env/src/logger/types.rs
@@ -692,8 +692,6 @@ pub enum Flow {
PaymentStartRedirection,
/// Volume split on the routing type
VolumeSplitOnRoutingType,
- /// Routing evaluate rule flow
- RoutingEvaluateRule,
/// Report whether the Unified Connector Service kill switch has tripped a scope
UnifiedConnectorServiceKillSwitchStatus,
/// Clear a Unified Connector Service kill switch cutover
@@ -778,10 +776,6 @@ pub enum Flow {
ThreeDsDecisionRuleExecute,
/// Incoming Network Token Webhook Receive
IncomingNetworkTokenWebhookReceive,
- /// Decision Engine Decide Gateway Call
- DecisionEngineDecideGatewayCall,
- /// Decision Engine Gateway Feedback Call
- DecisionEngineGatewayFeedbackCall,
/// Recovery payments create flow.
RecoveryPaymentsCreate,
/// Tokenization delete flow