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
refactor(open-api): api-refs for routing (#11283)
Prajjwal Kumar30e8b688acba
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.jsonindex 5100140377..87fd002062 100644--- a/api-reference/v1/openapi_spec_v1.json+++ b/api-reference/v1/openapi_spec_v1.json@@ -17523,7 +17523,7 @@},"DeRoutableConnectorChoice": {"type": "object",- "description": "Routable Connector chosen for a payment",+ "description": "Connector representation used in API request/response.\n\nRepresents a Merchant Connector Account.","required": ["gateway_name","gateway_id"@@ -17533,7 +17533,9 @@"$ref": "#/components/schemas/RoutableConnectors"},"gateway_id": {- "type": "string"+ "type": "string",+ "description": "Merchant Connector Account ID.\n\nExample:\n```json\n\"mca_ExbsYfO1xFErhNtwY1PX\"\n```",+ "example": "authipay_1705"}}},@@ -17542,24 +17544,43 @@"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": {@@ -17572,25 +17593,37 @@},"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}}@@ -17603,7 +17636,9 @@"properties": {"threshold": {"type": "number",- "format": "double"+ "format": "double",+ "description": "Threshold for elimination logic in gateway selection",+ "example": 0.3}}},@@ -17625,38 +17660,53 @@},"DecisionEngineSRSubLevelInputConfig": {"type": "object",+ "description": "Payment method level configuration for success rate based routing","properties": {"paymentMethodType": {"type": "string",+ "description": "Payment method type (e.g., \"card\", \"wallet\")",+ "example": "card","nullable": true},"paymentMethod": {"type": "string",+ "description": "Specific payment method (e.g., \"credit\", \"debit\")",+ "example": "credit","nullable": true},"latencyThreshold": {"type": "number","format": "double",+ "description": "Latency threshold in percentile for this payment method",+ "example": 90.0,"nullable": true},"bucketSize": {"type": "integer","format": "int32",+ "description": "Number of transactions to consider for this payment method",+ "example": 100,"nullable": true},"hedgingPercent": {"type": "number","format": "double",+ "description": "Percentage of traffic to route for exploration for this payment method",+ "example": 5.0,"nullable": true},"lowerResetFactor": {"type": "number","format": "double",+ "description": "Lower reset factor for this payment method",+ "example": 0.5,"nullable": true},"upperResetFactor": {"type": "number","format": "double",+ "description": "Upper reset factor for this payment method",+ "example": 1.5,"nullable": true},"gatewayExtraScore": {@@ -17664,36 +17714,48 @@"items": {"$ref": "#/components/schemas/DecisionEngineGatewayWiseExtraScore"},+ "description": "Gateway-specific extra scoring factors for this payment method","nullable": true}}},"DecisionEngineSuccessRateData": {"type": "object",+ "description": "Configuration for Decision Engine success rate based routing","properties": {"defaultLatencyThreshold": {"type": "number","format": "double",+ "description": "Default latency threshold in percentile for gateway selection",+ "example": 90.0,"nullable": true},"defaultBucketSize": {"type": "integer","format": "int32",+ "description": "Default number of transactions to consider for success rate calculation",+ "example": 100,"nullable": true},"defaultHedgingPercent": {"type": "number","format": "double",+ "description": "Default percentage of traffic to route for exploration/hedging",+ "example": 5.0,"nullable": true},"defaultLowerResetFactor": {"type": "number","format": "double",+ "description": "Lower reset factor for adjusting gateway scores",+ "example": 0.5,"nullable": true},"defaultUpperResetFactor": {"type": "number","format": "double",+ "description": "Upper reset factor for adjusting gateway scores",+ "example": 1.5,"nullable": true},"defaultGatewayExtraScore": {@@ -17701,6 +17763,7 @@"items": {"$ref": "#/components/schemas/DecisionEngineGatewayWiseExtraScore"},+ "description": "Gateway-specific extra scoring factors","nullable": true},"subLevelInputConfig": {@@ -17708,6 +17771,7 @@"items": {"$ref": "#/components/schemas/DecisionEngineSRSubLevelInputConfig"},+ "description": "Payment method level specific configurations","nullable": true}}@@ -18192,6 +18256,7 @@"items": {"$ref": "#/components/schemas/DynamicRoutingConfigParams"},+ "deprecated": true,"nullable": true},"elimination_analyser_config": {@@ -22987,7 +23052,7 @@},"MerchantRoutingAlgorithm": {"type": "object",- "description": "Routing Algorithm specific to merchants",+ "description": "Routing algorithm configuration created for a merchant.\n\nRepresents a fully defined routing strategy scoped to a profile\nand transaction type.","required": ["id","profile_id",@@ -23000,27 +23065,39 @@],"properties": {"id": {- "type": "string"+ "type": "string",+ "description": "Unique identifier of the routing configuration.\n\nExample:\n```json\n\"routing_abc123\"\n```",+ "example": "routing_abc123"},"profile_id": {- "type": "string"+ "type": "string",+ "description": "Profile ID to which this routing configuration belongs.\n\nExample:\n```json\n\"profile_123\"\n```",+ "example": "profile_123"},"name": {- "type": "string"+ "type": "string",+ "description": "Human-readable name of the routing configuration.\n\nExample:\n```json\n\"default_card_routing\"\n```",+ "example": "default_card_routing"},"description": {- "type": "string"+ "type": "string",+ "description": "Description explaining the purpose of this routing configuration.\n\nExample:\n```json\n\"Primary routing strategy for card payments\"\n```",+ "example": "Primary routing strategy for card payments"},"algorithm": {"$ref": "#/components/schemas/RoutingAlgorithmWrapper"},"created_at": {"type": "integer",- "format": "int64"+ "format": "int64",+ "description": "Timestamp (in milliseconds since epoch) when the routing\nconfiguration was created.\n\nExample:\n```json\n1718000000000\n```",+ "example": 1718000000000},"modified_at": {"type": "integer",- "format": "int64"+ "format": "int64",+ "description": "Timestamp (in milliseconds since epoch) when the routing\nconfiguration was last modified.\n\nExample:\n```json\n1718050000000\n```",+ "example": 1718050000000},"algorithm_for": {"$ref": "#/components/schemas/TransactionType"@@ -24139,6 +24216,7 @@},"OpenRouterDecideGatewayRequest": {"type": "object",+ "description": "Request to decide the optimal gateway for routing a payment","required": ["paymentInfo","merchantId"@@ -24148,13 +24226,17 @@"$ref": "#/components/schemas/PaymentInfo"},"merchantId": {- "type": "string"+ "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": {@@ -24167,6 +24249,8 @@},"eliminationEnabled": {"type": "boolean",+ "description": "Whether elimination logic is enabled for filtering gateways",+ "example": true,"nullable": true}}@@ -25384,40 +25468,58 @@},"PaymentInfo": {"type": "object",+ "description": "Payment information used for routing decision-making","required": ["paymentId","amount","currency","paymentType",+ "metadata","paymentMethodType",- "paymentMethod"+ "paymentMethod",+ "cardIsin"],"properties": {"paymentId": {- "type": "string"+ "type": "string",+ "description": "Unique identifier for the payment transaction",+ "example": "pay_12345"},"amount": {- "$ref": "#/components/schemas/MinorUnit"+ "type": "integer",+ "format": "int64",+ "description": "Payment amount in minor units",+ "example": "100"},"currency": {- "$ref": "#/components/schemas/Currency"+ "type": "string",+ "description": "Currency code for the payment",+ "example": "USD"},"paymentType": {- "type": "string"+ "type": "string",+ "description": "Type of payment transaction being processed",+ "example": "ORDER_PAYMENT"},"metadata": {"type": "string",- "nullable": true+ "description": "Optional metadata associated with the payment",+ "example": "metadata"},"paymentMethodType": {- "type": "string"+ "type": "string",+ "description": "Specific payment method type being used",+ "example": "upi"},"paymentMethod": {- "$ref": "#/components/schemas/PaymentMethod"+ "type": "string",+ "description": "General payment method category",+ "example": "upi"},"cardIsin": {"type": "string",- "nullable": true+ "description": "Card Issuer Identification Number (first 6 digits of card)",+ "example": "424242"}}},@@ -33788,14 +33890,20 @@"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}}@@ -33805,6 +33913,8 @@"properties": {"isEnforcement": {"type": "boolean",+ "description": "Whether enforcement mode is enabled",+ "example": false,"nullable": true},"gws": {@@ -33812,17 +33922,21 @@"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",- "additionalProperties": {- "type": "string"- },+ "description": "Map of gateway reference IDs","nullable": true},"primaryLogic": {@@ -34315,19 +34429,23 @@},"ProfileDefaultRoutingConfig": {"type": "object",+ "description": "Default routing configuration associated with a business profile.\n\nThis represents the fallback routing connectors configured\nat the profile level.","required": ["profile_id","connectors"],"properties": {"profile_id": {- "type": "string"+ "type": "string",+ "description": "Unique identifier of the business profile.\n\nExample:\n```json\n\"profile_123\"\n```",+ "example": "profile_123"},"connectors": {"type": "array","items": {"$ref": "#/components/schemas/RoutableConnectorChoice"- }+ },+ "description": "List of connectors configured as default for this profile.\n\nExample:\n```json\n[\n{\n\"connector\": \"stripe\",\n\"merchant_connector_id\": \"mca_ExbsYfO1xFErhNtwY1PX\"\n}\n]\n```"}}},@@ -36350,10 +36468,14 @@"properties": {"name": {"type": "string",+ "description": "Unique name of the routing configuration.\n\nThis identifier is used to reference the routing config internally.\n\nExample:\n```json\n\"default_card_routing\"\n```",+ "example": "default_card_routing","nullable": true},"description": {"type": "string",+ "description": "Optional human-readable description of the routing configuration.\n\nExample:\n```json\n\"Primary routing strategy for card payments in India\"\n```",+ "example": "Primary routing strategy for card payments in Middle east","nullable": true},"algorithm": {@@ -36366,6 +36488,8 @@},"profile_id": {"type": "string",+ "description": "Profile ID associated with this routing configuration.\n\nRouting configs can be scoped per business profile.\n\nExample:\n```json\n\"profile_123\"\n```",+ "example": "profile_123","nullable": true},"transaction_type": {@@ -36380,28 +36504,35 @@},"RoutingDictionary": {"type": "object",+ "description": "Routing dictionary for a merchant.\n\nContains all routing configurations created by the merchant,\nalong with the currently active routing configuration.","required": ["merchant_id","records"],"properties": {"merchant_id": {- "type": "string"+ "type": "string",+ "description": "Unique merchant identifier.\n\nExample:\n```json\n\"merchant_789\"\n```",+ "example": "merchant_789"},"active_id": {"type": "string",+ "description": "Currently active routing configuration ID.\n\nExample:\n```json\n\"routing_abc123\"\n```",+ "example": "routing_abc123","nullable": true},"records": {"type": "array","items": {"$ref": "#/components/schemas/RoutingDictionaryRecord"- }+ },+ "description": "List of all routing configuration records\nassociated with this merchant."}}},"RoutingDictionaryRecord": {"type": "object",+ "description": "Metadata record representing a stored routing configuration.\n\nUsed in routing dictionary listings.","required": ["id","profile_id",@@ -36413,27 +36544,39 @@],"properties": {"id": {- "type": "string"+ "type": "string",+ "description": "Unique identifier of the routing configuration.\n\nExample:\n```json\n\"routing_abc123\"\n```",+ "example": "routing_abc123"},"profile_id": {- "type": "string"+ "type": "string",+ "description": "Profile ID associated with this routing configuration.\n\nExample:\n```json\n\"profile_123\"\n```",+ "example": "profile_123"},"name": {- "type": "string"+ "type": "string",+ "description": "Name of the routing configuration.\n\nExample:\n```json\n\"india_card_routing\"\n```",+ "example": "india_card_routing"},"kind": {"$ref": "#/components/schemas/RoutingAlgorithmKind"},"description": {- "type": "string"+ "type": "string",+ "description": "Description of this routing configuration.\n\nExample:\n```json\n\"Volume split routing for domestic transactions\"\n```",+ "example": "Volume split routing for domestic transactions"},"created_at": {"type": "integer",- "format": "int64"+ "format": "int64",+ "description": "Creation timestamp (milliseconds since epoch).",+ "example": 1718000000000},"modified_at": {"type": "integer",- "format": "int64"+ "format": "int64",+ "description": "Last modification timestamp (milliseconds since epoch).",+ "example": 1718050000000},"algorithm_for": {"allOf": [@@ -36445,12 +36588,15 @@},"decision_engine_routing_id": {"type": "string",+ "description": "Associated Decision Engine routing identifier (if applicable).\n\nPresent when routing is linked to an external decision engine.\n\nExample:\n```json\n\"de_route_456\"\n```",+ "example": "de_route_456","nullable": true}}},"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",@@ -36458,22 +36604,26 @@],"properties": {"created_by": {- "type": "string"+ "type": "string",+ "description": "Identifier of the user/system triggering routing evaluation.\n\nExample:\n```json\n\"created_by\": \"some_id\"\n```",+ "example": "profile_123"},"parameters": {"type": "object",- "description": "Parameters that can be used in the routing evaluate request.\neg: {\"parameters\": {\n\"payment_method\": {\"type\": \"enum_variant\", \"value\": \"card\"},\n\"payment_method_type\": {\"type\": \"enum_variant\", \"value\": \"credit\"},\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\"capture_method\": {\"type\": \"enum_variant\", \"value\": \"scheduled\"},\n\"business_country\": {\"type\": \"str_value\", \"value\": \"IN\"},\n\"billing_country\": {\"type\": \"str_value\", \"value\": \"IN\"},\n\"business_label\": {\"type\": \"str_value\", \"value\": \"business_label\"},\n\"setup_future_usage\": {\"type\": \"enum_variant\", \"value\": \"off_session\"},\n\"card_network\": {\"type\": \"enum_variant\", \"value\": \"visa\"},\n\"payment_type\": {\"type\": \"enum_variant\", \"value\": \"recurring_mandate\"},\n\"mandate_type\": {\"type\": \"enum_variant\", \"value\": \"single_use\"},\n\"mandate_acceptance_type\": {\"type\": \"enum_variant\", \"value\": \"online\"},\n\"metadata\":{\"type\": \"metadata_variant\", \"value\": {\"key\": \"key1\", \"value\": \"value1\"}}\n}}"+ "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```"}}},"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",@@ -36482,14 +36632,19 @@],"properties": {"status": {- "type": "string"+ "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```"},- "output": {},"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",@@ -36514,7 +36669,7 @@},"RoutingRetrieveResponse": {"type": "object",- "description": "Response of the retrieved routing configs for a merchant account",+ "description": "Response returned when retrieving routing configuration\nfor a merchant account.","properties": {"algorithm": {"allOf": [@@ -37992,6 +38147,7 @@"items": {"$ref": "#/components/schemas/DynamicRoutingConfigParams"},+ "deprecated": true,"nullable": true},"config": {@@ -38814,6 +38970,7 @@},"UpdateScorePayload": {"type": "object",+ "description": "Request payload to update gateway performance score based on transaction outcome","required": ["merchantId","gateway",@@ -38822,27 +38979,36 @@],"properties": {"merchantId": {- "type": "string"+ "type": "string",+ "description": "Profile ID of the merchant",+ "example": "pro_aMoPnEkgCVnh2WVsFe32"},"gateway": {- "type": "string"+ "type": "string",+ "description": "Payment Gateway identifier",+ "example": "stripe:mca1"},"status": {"$ref": "#/components/schemas/TxnStatus"},"paymentId": {- "type": "string"+ "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"+ "type": "string",+ "description": "Status message indicating the result of the score update",+ "example": "Gateway score updated successfully"}}},diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.jsonindex e3cf85d5ad..a79b562c66 100644--- a/api-reference/v2/openapi_spec_v2.json+++ b/api-reference/v2/openapi_spec_v2.json@@ -12433,7 +12433,9 @@"properties": {"threshold": {"type": "number",- "format": "double"+ "format": "double",+ "description": "Threshold for elimination logic in gateway selection",+ "example": 0.3}}},@@ -12455,38 +12457,53 @@},"DecisionEngineSRSubLevelInputConfig": {"type": "object",+ "description": "Payment method level configuration for success rate based routing","properties": {"paymentMethodType": {"type": "string",+ "description": "Payment method type (e.g., \"card\", \"wallet\")",+ "example": "card","nullable": true},"paymentMethod": {"type": "string",+ "description": "Specific payment method (e.g., \"credit\", \"debit\")",+ "example": "credit","nullable": true},"latencyThreshold": {"type": "number","format": "double",+ "description": "Latency threshold in percentile for this payment method",+ "example": 90.0,"nullable": true},"bucketSize": {"type": "integer","format": "int32",+ "description": "Number of transactions to consider for this payment method",+ "example": 100,"nullable": true},"hedgingPercent": {"type": "number","format": "double",+ "description": "Percentage of traffic to route for exploration for this payment method",+ "example": 5.0,"nullable": true},"lowerResetFactor": {"type": "number","format": "double",+ "description": "Lower reset factor for this payment method",+ "example": 0.5,"nullable": true},"upperResetFactor": {"type": "number","format": "double",+ "description": "Upper reset factor for this payment method",+ "example": 1.5,"nullable": true},"gatewayExtraScore": {@@ -12494,36 +12511,48 @@"items": {"$ref": "#/components/schemas/DecisionEngineGatewayWiseExtraScore"},+ "description": "Gateway-specific extra scoring factors for this payment method","nullable": true}}},"DecisionEngineSuccessRateData": {"type": "object",+ "description": "Configuration for Decision Engine success rate based routing","properties": {"defaultLatencyThreshold": {"type": "number","format": "double",+ "description": "Default latency threshold in percentile for gateway selection",+ "example": 90.0,"nullable": true},"defaultBucketSize": {"type": "integer","format": "int32",+ "description": "Default number of transactions to consider for success rate calculation",+ "example": 100,"nullable": true},"defaultHedgingPercent": {"type": "number","format": "double",+ "description": "Default percentage of traffic to route for exploration/hedging",+ "example": 5.0,"nullable": true},"defaultLowerResetFactor": {"type": "number","format": "double",+ "description": "Lower reset factor for adjusting gateway scores",+ "example": 0.5,"nullable": true},"defaultUpperResetFactor": {"type": "number","format": "double",+ "description": "Upper reset factor for adjusting gateway scores",+ "example": 1.5,"nullable": true},"defaultGatewayExtraScore": {@@ -12531,6 +12560,7 @@"items": {"$ref": "#/components/schemas/DecisionEngineGatewayWiseExtraScore"},+ "description": "Gateway-specific extra scoring factors","nullable": true},"subLevelInputConfig": {@@ -12538,6 +12568,7 @@"items": {"$ref": "#/components/schemas/DecisionEngineSRSubLevelInputConfig"},+ "description": "Payment method level specific configurations","nullable": true}}@@ -13028,6 +13059,7 @@"items": {"$ref": "#/components/schemas/DynamicRoutingConfigParams"},+ "deprecated": true,"nullable": true},"elimination_analyser_config": {@@ -17160,7 +17192,7 @@},"MerchantRoutingAlgorithm": {"type": "object",- "description": "Routing Algorithm specific to merchants",+ "description": "Routing algorithm configuration created for a merchant.\n\nRepresents a fully defined routing strategy scoped to a profile\nand transaction type.","required": ["id","profile_id",@@ -17173,27 +17205,39 @@],"properties": {"id": {- "type": "string"+ "type": "string",+ "description": "Unique identifier of the routing configuration.\n\nExample:\n```json\n\"routing_abc123\"\n```",+ "example": "routing_abc123"},"profile_id": {- "type": "string"+ "type": "string",+ "description": "Profile ID to which this routing configuration belongs.\n\nExample:\n```json\n\"profile_123\"\n```",+ "example": "profile_123"},"name": {- "type": "string"+ "type": "string",+ "description": "Human-readable name of the routing configuration.\n\nExample:\n```json\n\"default_card_routing\"\n```",+ "example": "default_card_routing"},"description": {- "type": "string"+ "type": "string",+ "description": "Description explaining the purpose of this routing configuration.\n\nExample:\n```json\n\"Primary routing strategy for card payments\"\n```",+ "example": "Primary routing strategy for card payments"},"algorithm": {"$ref": "#/components/schemas/RoutingAlgorithmWrapper"},"created_at": {"type": "integer",- "format": "int64"+ "format": "int64",+ "description": "Timestamp (in milliseconds since epoch) when the routing\nconfiguration was created.\n\nExample:\n```json\n1718000000000\n```",+ "example": 1718000000000},"modified_at": {"type": "integer",- "format": "int64"+ "format": "int64",+ "description": "Timestamp (in milliseconds since epoch) when the routing\nconfiguration was last modified.\n\nExample:\n```json\n1718050000000\n```",+ "example": 1718050000000},"algorithm_for": {"$ref": "#/components/schemas/TransactionType"@@ -25677,19 +25721,23 @@},"ProfileDefaultRoutingConfig": {"type": "object",+ "description": "Default routing configuration associated with a business profile.\n\nThis represents the fallback routing connectors configured\nat the profile level.","required": ["profile_id","connectors"],"properties": {"profile_id": {- "type": "string"+ "type": "string",+ "description": "Unique identifier of the business profile.\n\nExample:\n```json\n\"profile_123\"\n```",+ "example": "profile_123"},"connectors": {"type": "array","items": {"$ref": "#/components/schemas/RoutableConnectorChoice"- }+ },+ "description": "List of connectors configured as default for this profile.\n\nExample:\n```json\n[\n{\n\"connector\": \"stripe\",\n\"merchant_connector_id\": \"mca_ExbsYfO1xFErhNtwY1PX\"\n}\n]\n```"}}},@@ -27560,28 +27608,35 @@},"RoutingDictionary": {"type": "object",+ "description": "Routing dictionary for a merchant.\n\nContains all routing configurations created by the merchant,\nalong with the currently active routing configuration.","required": ["merchant_id","records"],"properties": {"merchant_id": {- "type": "string"+ "type": "string",+ "description": "Unique merchant identifier.\n\nExample:\n```json\n\"merchant_789\"\n```",+ "example": "merchant_789"},"active_id": {"type": "string",+ "description": "Currently active routing configuration ID.\n\nExample:\n```json\n\"routing_abc123\"\n```",+ "example": "routing_abc123","nullable": true},"records": {"type": "array","items": {"$ref": "#/components/schemas/RoutingDictionaryRecord"- }+ },+ "description": "List of all routing configuration records\nassociated with this merchant."}}},"RoutingDictionaryRecord": {"type": "object",+ "description": "Metadata record representing a stored routing configuration.\n\nUsed in routing dictionary listings.","required": ["id","profile_id",@@ -27593,27 +27648,39 @@],"properties": {"id": {- "type": "string"+ "type": "string",+ "description": "Unique identifier of the routing configuration.\n\nExample:\n```json\n\"routing_abc123\"\n```",+ "example": "routing_abc123"},"profile_id": {- "type": "string"+ "type": "string",+ "description": "Profile ID associated with this routing configuration.\n\nExample:\n```json\n\"profile_123\"\n```",+ "example": "profile_123"},"name": {- "type": "string"+ "type": "string",+ "description": "Name of the routing configuration.\n\nExample:\n```json\n\"india_card_routing\"\n```",+ "example": "india_card_routing"},"kind": {"$ref": "#/components/schemas/RoutingAlgorithmKind"},"description": {- "type": "string"+ "type": "string",+ "description": "Description of this routing configuration.\n\nExample:\n```json\n\"Volume split routing for domestic transactions\"\n```",+ "example": "Volume split routing for domestic transactions"},"created_at": {"type": "integer",- "format": "int64"+ "format": "int64",+ "description": "Creation timestamp (milliseconds since epoch).",+ "example": 1718000000000},"modified_at": {"type": "integer",- "format": "int64"+ "format": "int64",+ "description": "Last modification timestamp (milliseconds since epoch).",+ "example": 1718050000000},"algorithm_for": {"allOf": [@@ -27625,6 +27692,8 @@},"decision_engine_routing_id": {"type": "string",+ "description": "Associated Decision Engine routing identifier (if applicable).\n\nPresent when routing is linked to an external decision engine.\n\nExample:\n```json\n\"de_route_456\"\n```",+ "example": "de_route_456","nullable": true}}@@ -27644,7 +27713,7 @@},"RoutingRetrieveResponse": {"type": "object",- "description": "Response of the retrieved routing configs for a merchant account",+ "description": "Response returned when retrieving routing configuration\nfor a merchant account.","properties": {"algorithm": {"allOf": [@@ -28979,6 +29048,7 @@"items": {"$ref": "#/components/schemas/DynamicRoutingConfigParams"},+ "deprecated": true,"nullable": true},"config": {diff --git a/crates/api_models/src/open_router.rs b/crates/api_models/src/open_router.rsindex 7cd2844547..7cc8d47fca 100644--- a/crates/api_models/src/open_router.rs+++ b/crates/api_models/src/open_router.rs@@ -16,49 +16,125 @@ use crate::{payment_methods,};+/// Request to decide the optimal gateway for routing a payment#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]#[serde(rename_all = "camelCase")]pub struct OpenRouterDecideGatewayRequest {+ /// Payment information for routing decisionpub payment_info: PaymentInfo,- #[schema(value_type = String)]++ /// Profile ID of the merchant+ #[schema(value_type = String, example = "pro_aMoPnEkgCVnh2WVsFe32")]pub merchant_id: id_type::ProfileId,++ /// List of eligible gateways for routing consideration+ #[schema(value_type = Option<Vec<String>>, example = "[\"stripe:mca_123\", \"adyen:mca_456\"]")]pub eligible_gateway_list: Option<Vec<String>>,++ /// Algorithm to use for ranking and selecting gateways+ #[schema(value_type = Option<RankingAlgorithm>, example = "SR_BASED_ROUTING")]pub ranking_algorithm: Option<RankingAlgorithm>,++ /// Whether elimination logic is enabled for filtering gateways+ #[schema(value_type = Option<bool>, example = true)]pub elimination_enabled: Option<bool>,}#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]pub struct DecideGatewayResponse {+ /// The gateway decided by the routing engine+ #[schema(value_type = Option<String>, example = "stripe:mca1")]pub decided_gateway: Option<String>,++ /// Map of gateways with their priority scores+ #[schema(value_type = Option<HashMap<String, f64>>, example = json!({"stripe:mca1": 1.0, "adyen:mca2": 1.0}))]pub gateway_priority_map: Option<serde_json::Value>,++ /// Gateways organized by filter criteria+ #[schema(value_type = Option<Object>)]pub filter_wise_gateways: Option<serde_json::Value>,++ /// Tag identifying the priority logic used+ #[schema(value_type = Option<String>)]pub priority_logic_tag: Option<String>,++ /// The routing approach used for decision making+ #[schema(value_type = Option<String>, example = "SR_SELECTION_V3_ROUTING")]pub routing_approach: Option<String>,++ /// The gateway that was evaluated before the final decision+ #[schema(value_type = Option<String>, example = "adyen:mca2")]pub gateway_before_evaluation: Option<String>,++ /// Detailed output from the priority logic evaluation+ #[schema(value_type = Option<PriorityLogicOutput>)]pub priority_logic_output: Option<PriorityLogicOutput>,++ /// The reset approach applied during routing+ #[schema(value_type = Option<String>, example = "NO_RESET")]pub reset_approach: Option<String>,++ /// Dimensions used for routing decision (payment type, method, etc.)+ #[schema(value_type = Option<String>, example = "ORDER_PAYMENT, UPI, upi")]pub routing_dimension: Option<String>,++ /// Level at which routing dimension is evaluated+ #[schema(value_type = Option<String>, example = "PM_LEVEL")]pub routing_dimension_level: Option<String>,++ /// Indicates if routing decision was affected by scheduled outage+ #[schema(value_type = Option<bool>, example = false)]pub is_scheduled_outage: Option<bool>,++ /// Indicates if dynamic merchant gateway account is enabled+ #[schema(value_type = Option<bool>, example = false)]pub is_dynamic_mga_enabled: Option<bool>,++ /// Map of gateways to their MGA IDs+ #[schema(value_type = Option<Object>)]pub gateway_mga_id_map: Option<serde_json::Value>,}#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]#[serde(rename_all = "camelCase")]pub struct PriorityLogicOutput {+ /// Whether enforcement mode is enabled+ #[schema(value_type = Option<bool>, example = false)]pub is_enforcement: Option<bool>,++ /// List of gateways returned by the priority logic+ #[schema(value_type = Option<Vec<String>>, example = json!(["stripe:mca1", "adyen:mca2"]))]pub gws: Option<Vec<String>>,++ /// Tag identifying the priority logic used+ #[schema(value_type = Option<String>)]pub priority_logic_tag: Option<String>,++ /// Map of gateway reference IDs+ #[schema(value_type = Option<Object>, example = json!({}))]pub gateway_reference_ids: Option<HashMap<String, String>>,++ /// Primary logic details+ #[schema(value_type = Option<PriorityLogicData>)]pub primary_logic: Option<PriorityLogicData>,++ /// Fallback logic details+ #[schema(value_type = Option<PriorityLogicData>)]pub fallback_logic: Option<PriorityLogicData>,}#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]pub struct PriorityLogicData {+ /// Name of the logic+ #[schema(value_type = Option<String>, example = "success_rate_logic")]pub name: Option<String>,++ /// Status of the logic execution+ #[schema(value_type = Option<String>, example = "success")]pub status: Option<String>,++ /// Reason for failure if the logic failed+ #[schema(value_type = Option<String>, example = "insufficient_data")]pub failure_reason: Option<String>,}@@ -70,26 +146,42 @@ pub enum RankingAlgorithm {NtwBasedRouting,}+/// Payment information used for routing decision-making#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]#[serde(rename_all = "camelCase")]pub struct PaymentInfo {- #[schema(value_type = String)]+ /// Unique identifier for the payment transaction+ #[schema(value_type = String, example = "pay_12345")]pub payment_id: id_type::PaymentId,+ /// Payment amount in minor units+ #[schema(value_type = i64, example = "100")]pub amount: MinorUnit,+ /// Currency code for the payment+ #[schema(value_type = String, example = "USD")]pub currency: Currency,// customerId: Option<ETCu::CustomerId>,// preferredGateway: Option<ETG::Gateway>,+ /// Type of payment transaction being processed+ #[schema(value_type = String, example = "ORDER_PAYMENT")]pub payment_type: String,+ /// Optional metadata associated with the payment+ #[schema(value_type = String, example = "metadata")]pub metadata: Option<String>,// internalMetadata: Option<String>,// isEmi: Option<bool>,// emiBank: Option<String>,// emiTenure: Option<i32>,+ /// Specific payment method type being used+ #[schema(value_type = String, example = "upi")]pub payment_method_type: String,+ /// General payment method category+ #[schema(value_type = String, example = "upi")]pub payment_method: PaymentMethod,// paymentSource: Option<String>,// authType: Option<ETCa::txn_card_info::AuthType>,// cardIssuerBankName: Option<String>,+ /// Card Issuer Identification Number (first 6 digits of card)+ #[schema(value_type = String, example = "424242")]pub card_isin: Option<String>,// cardType: Option<ETCa::card_type::CardType>,// cardSwitchProvider: Option<Secret<String>>,@@ -198,19 +290,32 @@ pub struct UnifiedError {pub developer_message: String,}+/// Request payload to update gateway performance score based on transaction outcome#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, ToSchema)]#[serde(rename_all = "camelCase")]pub struct UpdateScorePayload {- #[schema(value_type = String)]+ /// Profile ID of the merchant+ #[schema(value_type = String, example = "pro_aMoPnEkgCVnh2WVsFe32")]pub merchant_id: id_type::ProfileId,++ /// Payment Gateway identifier+ #[schema(value_type = String, example = "stripe:mca1")]pub gateway: String,++ /// Transaction status for feedback scoring+ #[schema(value_type = TxnStatus, example = "CHARGED")]pub status: TxnStatus,- #[schema(value_type = String)]++ /// Payment ID associated with the transaction+ #[schema(value_type = String, example = "pay_1234")]pub payment_id: id_type::PaymentId,}+/// Response after updating gateway score#[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]pub struct UpdateScoreResponse {+ /// Status message indicating the result of the score update+ #[schema(value_type = String, example = "Gateway score updated successfully")]pub message: String,}@@ -269,15 +374,36 @@ pub enum DecisionEngineConfigVariant {Elimination(DecisionEngineEliminationData),}+/// Configuration for Decision Engine success rate based routing#[derive(Debug, Clone, Serialize, Deserialize, ToSchema)]#[serde(rename_all = "camelCase")]pub struct DecisionEngineSuccessRateData {+ /// Default latency threshold in percentile for gateway selection+ #[schema(value_type = Option<f64>, example = 90.0)]pub default_latency_threshold: Option<f64>,++ /// Default number of transactions to consider for success rate calculation+ #[schema(value_type = Option<i32>, example = 100)]pub default_bucket_size: Option<i32>,++ /// Default percentage of traffic to route for exploration/hedging+ #[schema(value_type = Option<f64>, example = 5.0)]pub default_hedging_percent: Option<f64>,++ /// Lower reset factor for adjusting gateway scores+ #[schema(value_type = Option<f64>, example = 0.5)]pub default_lower_reset_factor: Option<f64>,++ /// Upper reset factor for adjusting gateway scores+ #[schema(value_type = Option<f64>, example = 1.5)]pub default_upper_reset_factor: Option<f64>,++ /// Gateway-specific extra scoring factors+ #[schema(value_type = Option<Vec<DecisionEngineGatewayWiseExtraScore>>)]pub default_gateway_extra_score: Option<Vec<DecisionEngineGatewayWiseExtraScore>>,++ /// Payment method level specific configurations+ #[schema(value_type = Option<Vec<DecisionEngineSRSubLevelInputConfig>>)]pub sub_level_input_config: Option<Vec<DecisionEngineSRSubLevelInputConfig>>,}@@ -310,16 +436,41 @@ impl DecisionEngineSuccessRateData {}}}++/// Payment method level configuration for success rate based routing#[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]#[serde(rename_all = "camelCase")]pub struct DecisionEngineSRSubLevelInputConfig {+ /// Payment method type (e.g., "card", "wallet")+ #[schema(value_type = Option<String>, example = "card")]pub payment_method_type: Option<String>,++ /// Specific payment method (e.g., "credit", "debit")+ #[schema(value_type = Option<String>, example = "credit")]pub payment_method: Option<String>,++ /// Latency threshold in percentile for this payment method+ #[schema(value_type = Option<f64>, example = 90.0)]pub latency_threshold: Option<f64>,++ /// Number of transactions to consider for this payment method+ #[schema(value_type = Option<i32>, example = 100)]pub bucket_size: Option<i32>,++ /// Percentage of traffic to route for exploration for this payment method+ #[schema(value_type = Option<f64>, example = 5.0)]pub hedging_percent: Option<f64>,++ /// Lower reset factor for this payment method+ #[schema(value_type = Option<f64>, example = 0.5)]pub lower_reset_factor: Option<f64>,++ /// Upper reset factor for this payment method+ #[schema(value_type = Option<f64>, example = 1.5)]pub upper_reset_factor: Option<f64>,++ /// Gateway-specific extra scoring factors for this payment method+ #[schema(value_type = Option<Vec<DecisionEngineGatewayWiseExtraScore>>)]pub gateway_extra_score: Option<Vec<DecisionEngineGatewayWiseExtraScore>>,}@@ -371,6 +522,8 @@ impl DecisionEngineGatewayWiseExtraScore {#[derive(Debug, Serialize, Deserialize, Clone, ToSchema)]#[serde(rename_all = "camelCase")]pub struct DecisionEngineEliminationData {+ /// Threshold for elimination logic in gateway selection+ #[schema(value_type = f64, example = 0.3)]pub threshold: f64,}diff --git a/crates/api_models/src/routing.rs b/crates/api_models/src/routing.rsindex ca7fbd83d8..9454ddbb59 100644--- a/crates/api_models/src/routing.rs+++ b/crates/api_models/src/routing.rs@@ -58,12 +58,71 @@ pub struct RoutingConfigRequest {#[cfg(feature = "v1")]#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]pub struct RoutingConfigRequest {- #[schema(value_type = Option<String>)]+ /// Unique name of the routing configuration.+ ///+ /// This identifier is used to reference the routing config internally.+ ///+ /// Example:+ /// ```json+ /// "default_card_routing"+ /// ```+ #[schema(value_type = Option<String>, example = "default_card_routing")]pub name: Option<RoutingConfigName>,++ /// Optional human-readable description of the routing configuration.+ ///+ /// Example:+ /// ```json+ /// "Primary routing strategy for card payments in India"+ /// ```+ #[schema(example = "Primary routing strategy for card payments in Middle east")]pub description: Option<String>,++ /// Static routing algorithm configuration.+ ///+ /// Defines how connectors should be selected.+ ///+ /// Possible structures:+ /// - Priority routing+ /// - Volume split routing+ /// - Advanced routing+ ///+ /// Example (Priority):+ /// ```json+ /// {+ /// "type": "priority",+ /// "connectors": [+ /// {+ /// "connector": "stripe",+ /// "mca_id": "mca_ExbsYfO1xFErhNtwY1PX"+ /// }+ /// ]+ /// }+ /// ```pub algorithm: Option<StaticRoutingAlgorithm>,- #[schema(value_type = Option<String>)]++ /// Profile ID associated with this routing configuration.+ ///+ /// Routing configs can be scoped per business profile.+ ///+ /// Example:+ /// ```json+ /// "profile_123"+ /// ```+ #[schema(value_type = Option<String>, example = "profile_123")]pub profile_id: Option<common_utils::id_type::ProfileId>,++ /// Transaction type for which this routing config applies.+ ///+ /// Example values:+ /// - `payment`+ /// - `payout`+ ///+ /// Example:+ /// ```json+ /// "payment"+ /// ```+ #[schema(example = "payment")]pub transaction_type: Option<TransactionType>,}@@ -104,39 +163,148 @@ impl Deref for RoutingConfigName {}}+/// Default routing configuration associated with a business profile.+///+/// This represents the fallback routing connectors configured+/// at the profile level.#[derive(Debug, serde::Serialize, ToSchema)]pub struct ProfileDefaultRoutingConfig {- #[schema(value_type = String)]+ /// Unique identifier of the business profile.+ ///+ /// Example:+ /// ```json+ /// "profile_123"+ /// ```+ #[schema(value_type = String, example = "profile_123")]pub profile_id: common_utils::id_type::ProfileId,++ /// List of connectors configured as default for this profile.+ ///+ /// Example:+ /// ```json+ /// [+ /// {+ /// "connector": "stripe",+ /// "merchant_connector_id": "mca_ExbsYfO1xFErhNtwY1PX"+ /// }+ /// ]+ /// ```pub connectors: Vec<RoutableConnectorChoice>,}-#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]+/// Query parameters used to retrieve routing configurations.+///+/// Supports pagination and transaction-type filtering.+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]pub struct RoutingRetrieveQuery {+ /// Maximum number of routing configs to return.+ ///+ /// Example:+ /// ```json+ /// 10+ /// ```+ #[schema(example = 10)]pub limit: Option<u16>,++ /// Offset for pagination.+ ///+ /// Example:+ /// ```json+ /// 0+ /// ```+ #[schema(example = 0)]pub offset: Option<u8>,++ /// Filter routing configs by transaction type.+ ///+ /// Example:+ /// ```json+ /// "payment"+ /// ```+ #[schema(example = "payment")]pub transaction_type: Option<TransactionType>,}-#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]+/// Payload used to activate a routing configuration.+///+/// Activation can be scoped by transaction type.+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]pub struct RoutingActivatePayload {+ /// Transaction type for which the routing config should be activated.+ ///+ /// Example:+ /// ```json+ /// "payment"+ /// ```+ #[schema(example = "payment")]pub transaction_type: Option<TransactionType>,}-#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]+/// Query parameters used to retrieve routing configuration+/// linked to a specific profile.+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]pub struct RoutingRetrieveLinkQuery {+ /// Profile ID for which routing config should be retrieved.+ ///+ /// Example:+ /// ```json+ /// "profile_123"+ /// ```+ #[schema(value_type = String, example = "profile_123")]pub profile_id: Option<common_utils::id_type::ProfileId>,++ /// Filter by transaction type.+ ///+ /// Example:+ /// ```json+ /// "payment"+ /// ```+ #[schema(example = "payment")]pub transaction_type: Option<TransactionType>,}-#[derive(Clone, Debug, serde::Deserialize, serde::Serialize)]+/// Wrapper structure combining routing query parameters+/// with a mandatory profile identifier.+///+/// Used internally for link-based routing retrieval.+#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]pub struct RoutingRetrieveLinkQueryWrapper {+ /// Pagination and filtering parameters.pub routing_query: RoutingRetrieveQuery,++ /// Mandatory profile ID.+ ///+ /// Example:+ /// ```json+ /// "profile_123"+ /// ```+ #[schema(value_type = String, example = "profile_123")]pub profile_id: common_utils::id_type::ProfileId,}++/// Response returned when retrieving routing configuration+/// for a merchant account.#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]-/// Response of the retrieved routing configs for a merchant accountpub struct RoutingRetrieveResponse {+ /// Merchant routing algorithm configuration.+ ///+ /// This may contain:+ /// - Priority routing+ /// - Volume split routing+ /// - Other merchant-level routing strategies+ ///+ /// Example:+ /// ```json+ /// {+ /// "type": "priority",+ /// "connectors": [+ /// {+ /// "connector": "stripe",+ /// "mca_id": "mca_ExbsYfO1xFErhNtwY1PX"+ /// }+ /// ]+ /// }+ /// ```pub algorithm: Option<MerchantRoutingAlgorithm>,}@@ -147,18 +315,83 @@ pub enum LinkedRoutingConfigRetrieveResponse {ProfileBased(Vec<RoutingDictionaryRecord>),}+/// Routing algorithm configuration created for a merchant.+///+/// Represents a fully defined routing strategy scoped to a profile+/// and transaction type.#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]-/// Routing Algorithm specific to merchantspub struct MerchantRoutingAlgorithm {- #[schema(value_type = String)]+ /// Unique identifier of the routing configuration.+ ///+ /// Example:+ /// ```json+ /// "routing_abc123"+ /// ```+ #[schema(value_type = String, example = "routing_abc123")]pub id: common_utils::id_type::RoutingId,- #[schema(value_type = String)]++ /// Profile ID to which this routing configuration belongs.+ ///+ /// Example:+ /// ```json+ /// "profile_123"+ /// ```+ #[schema(value_type = String, example = "profile_123")]pub profile_id: common_utils::id_type::ProfileId,++ /// Human-readable name of the routing configuration.+ ///+ /// Example:+ /// ```json+ /// "default_card_routing"+ /// ```+ #[schema(example = "default_card_routing")]pub name: String,++ /// Description explaining the purpose of this routing configuration.+ ///+ /// Example:+ /// ```json+ /// "Primary routing strategy for card payments"+ /// ```+ #[schema(example = "Primary routing strategy for card payments")]pub description: String,++ /// Actual routing algorithm definition.+ ///+ /// Can represent:+ /// - Priority routing+ /// - Volume split routing+ /// - Other supported algorithm typespub algorithm: RoutingAlgorithmWrapper,++ /// Timestamp (in milliseconds since epoch) when the routing+ /// configuration was created.+ ///+ /// Example:+ /// ```json+ /// 1718000000000+ /// ```+ #[schema(example = 1718000000000i64)]pub created_at: i64,++ /// Timestamp (in milliseconds since epoch) when the routing+ /// configuration was last modified.+ ///+ /// Example:+ /// ```json+ /// 1718050000000+ /// ```+ #[schema(example = 1718050000000i64)]pub modified_at: i64,++ /// Transaction type for which this routing algorithm applies.+ ///+ /// Example:+ /// ```json+ /// "payment"+ /// ```+ #[schema(example = "payment")]pub algorithm_for: TransactionType,}@@ -586,26 +819,113 @@ impl RoutingAlgorithmRef {}}+/// Metadata record representing a stored routing configuration.+///+/// Used in routing dictionary listings.#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]pub struct RoutingDictionaryRecord {- #[schema(value_type = String)]+ /// Unique identifier of the routing configuration.+ ///+ /// Example:+ /// ```json+ /// "routing_abc123"+ /// ```+ #[schema(value_type = String, example = "routing_abc123")]pub id: common_utils::id_type::RoutingId,- #[schema(value_type = String)]++ /// Profile ID associated with this routing configuration.+ ///+ /// Example:+ /// ```json+ /// "profile_123"+ /// ```+ #[schema(value_type = String, example = "profile_123")]pub profile_id: common_utils::id_type::ProfileId,++ /// Name of the routing configuration.+ ///+ /// Example:+ /// ```json+ /// "india_card_routing"+ /// ```+ #[schema(example = "india_card_routing")]pub name: String,++ /// Type/kind of routing algorithm.+ ///+ /// Example:+ /// ```json+ /// "static"+ /// ```+ #[schema(example = "static")]pub kind: RoutingAlgorithmKind,++ /// Description of this routing configuration.+ ///+ /// Example:+ /// ```json+ /// "Volume split routing for domestic transactions"+ /// ```+ #[schema(example = "Volume split routing for domestic transactions")]pub description: String,++ /// Creation timestamp (milliseconds since epoch).+ #[schema(example = 1718000000000i64)]pub created_at: i64,++ /// Last modification timestamp (milliseconds since epoch).+ #[schema(example = 1718050000000i64)]pub modified_at: i64,++ /// Transaction type for which this routing applies.+ ///+ /// May be `null` if not scoped.+ ///+ /// Example:+ /// ```json+ /// "payment"+ /// ```+ #[schema(example = "payment")]pub algorithm_for: Option<TransactionType>,++ /// Associated Decision Engine routing identifier (if applicable).+ ///+ /// Present when routing is linked to an external decision engine.+ ///+ /// Example:+ /// ```json+ /// "de_route_456"+ /// ```+ #[schema(example = "de_route_456")]pub decision_engine_routing_id: Option<String>,}+/// Routing dictionary for a merchant.+///+/// Contains all routing configurations created by the merchant,+/// along with the currently active routing configuration.#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]pub struct RoutingDictionary {- #[schema(value_type = String)]+ /// Unique merchant identifier.+ ///+ /// Example:+ /// ```json+ /// "merchant_789"+ /// ```+ #[schema(value_type = String, example = "merchant_789")]pub merchant_id: common_utils::id_type::MerchantId,++ /// Currently active routing configuration ID.+ ///+ /// Example:+ /// ```json+ /// "routing_abc123"+ /// ```+ #[schema(example = "routing_abc123")]pub active_id: Option<String>,++ /// List of all routing configuration records+ /// associated with this merchant.pub records: Vec<RoutingDictionaryRecord>,}@@ -1014,7 +1334,9 @@ pub struct RoutingVolumeSplitResponse {#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, ToSchema)]#[serde(deny_unknown_fields)]pub struct EliminationRoutingConfig {+ #[schema(deprecated)]pub params: Option<Vec<DynamicRoutingConfigParams>>,+ #[schema(deprecated)]pub elimination_analyser_config: Option<EliminationAnalyserConfig>,#[schema(value_type = DecisionEngineEliminationData)]pub decision_engine_configs: Option<open_router::DecisionEngineEliminationData>,@@ -1109,7 +1431,9 @@ impl EliminationRoutingConfig {#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, ToSchema)]#[serde(deny_unknown_fields)]pub struct SuccessBasedRoutingConfig {+ #[schema(deprecated)]pub params: Option<Vec<DynamicRoutingConfigParams>>,+ #[schema(deprecated)]pub config: Option<SuccessBasedRoutingConfigBody>,#[schema(value_type = DecisionEngineSuccessRateData)]pub decision_engine_configs: Option<open_router::DecisionEngineSuccessRateData>,@@ -1563,6 +1887,11 @@ impl RuleMigrationResponse {}}+/// Source from which the routing result was generated.+///+/// Possible values:+/// - `decision_engine` → External Decision Engine evaluated the rule+/// - `hyperswitch_routing` → Internal Hyperswitch routing logic was used#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, strum::Display, strum::EnumString)]#[serde(rename_all = "snake_case")]#[strum(serialize_all = "snake_case")]@@ -1572,39 +1901,148 @@ pub enum RoutingResultSource {/// Inbuilt Hyperswitch Routing EngineHyperswitchRouting,}+//TODO: temporary change will be refactored afterwards+/// Request body used to evaluate routing rules.+///+/// This API evaluates routing logic based on dynamic parameters+/// like payment method, amount, country, card_bin, etc.#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, ToSchema)]pub struct RoutingEvaluateRequest {+ /// Identifier of the user/system triggering routing evaluation.+ ///+ /// Example:+ /// ```json+ /// "created_by": "some_id"+ /// ```+ #[schema(example = "profile_123")]pub created_by: String,+ /// Dynamic parameters used during routing evaluation.+ ///+ /// Each key represents a routing attribute.+ ///+ /// Example fields:+ ///+ /// - `payment_method`+ /// - `payment_method_type`+ /// - `amount`+ /// - `currency`+ /// - `authentication_type`+ /// - `card_bin`+ /// - `capture_method`+ /// - `business_country`+ /// - `billing_country`+ /// - `business_label`+ /// - `setup_future_usage`+ /// - `card_network`+ /// - `payment_type`+ /// - `mandate_type`+ /// - `mandate_acceptance_type`+ /// - `metadata`+ ///+ /// Example:+ /// ```json+ /// {+ /// "payment_method": { "type": "enum_variant", "value": "card" },+ /// "amount": { "type": "number", "value": 10 },+ /// "currency": { "type": "str_value", "value": "INR" },+ /// "authentication_type": { "type": "enum_variant", "value": "three_ds" },+ /// "card_bin": { "type": "str_value", "value": "424242" },+ /// "business_country": { "type": "str_value", "value": "IN" },+ /// "setup_future_usage": { "type": "enum_variant", "value": "off_session" },+ /// "card_network": { "type": "enum_variant", "value": "visa" },+ /// "metadata": {+ /// "type": "metadata_variant",+ /// "value": { "key": "key1", "value": "value1" }+ /// }+ /// }+ /// ```+ ///+ /// For the complete superset of supported routing keys,+ /// refer to `routing_configs.keys` in:+ /// https://github.com/juspay/decision-engine/blob/main/config/development.toml#[schema(value_type = Object)]- ///Parameters that can be used in the routing evaluate request.- ///eg: {"parameters": {- /// "payment_method": {"type": "enum_variant", "value": "card"},- /// "payment_method_type": {"type": "enum_variant", "value": "credit"},- /// "amount": {"type": "number", "value": 10},- /// "currency": {"type": "str_value", "value": "INR"},- /// "authentication_type": {"type": "enum_variant", "value": "three_ds"},- /// "card_bin": {"type": "str_value", "value": "424242"},- /// "capture_method": {"type": "enum_variant", "value": "scheduled"},- /// "business_country": {"type": "str_value", "value": "IN"},- /// "billing_country": {"type": "str_value", "value": "IN"},- /// "business_label": {"type": "str_value", "value": "business_label"},- /// "setup_future_usage": {"type": "enum_variant", "value": "off_session"},- /// "card_network": {"type": "enum_variant", "value": "visa"},- /// "payment_type": {"type": "enum_variant", "value": "recurring_mandate"},- /// "mandate_type": {"type": "enum_variant", "value": "single_use"},- /// "mandate_acceptance_type": {"type": "enum_variant", "value": "online"},- /// "metadata":{"type": "metadata_variant", "value": {"key": "key1", "value": "value1"}}- /// }}pub parameters: std::collections::HashMap<String, Option<ValueType>>,++ /// Fallback connectors used if routing rule evaluation fails.+ ///+ /// These connectors will be returned if no rule matches.+ ///+ /// Example:+ /// ```json+ /// [+ /// {+ /// "gateway_name": "stripe",+ /// "gateway_id": "mca_123"+ /// }+ /// ]+ /// ```pub fallback_output: Vec<DeRoutableConnectorChoice>,}impl common_utils::events::ApiEventMetric for RoutingEvaluateRequest {}+/// Response returned after routing evaluation.+///+/// Contains:+/// - Routing status+/// - Raw output structure (priority / volume_split)+/// - Final evaluated connectors+/// - Eligible connectors list#[derive(Debug, serde::Serialize, serde::Deserialize, Clone, ToSchema)]pub struct RoutingEvaluateResponse {+ /// Status of routing evaluation.+ ///+ /// Example:+ /// ```json+ /// "success"+ /// ```+ #[schema(example = "success")]pub status: String,++ /// Raw routing output returned by routing engine.+ ///+ /// Possible structures:+ ///+ /// 1. Volume Split:+ /// ```json+ /// {+ /// "type": "volume_split",+ /// "splits": [+ /// {+ /// "connector": { "gateway_name": "adyen", "gateway_id": "mca_124" },+ /// "split": 60+ /// },+ /// {+ /// "connector": { "gateway_name": "stripe", "gateway_id": "mca_123" },+ /// "split": 40+ /// }+ /// ]+ /// }+ /// ```+ ///+ /// 2. Priority:+ /// ```json+ /// {+ /// "type": "priority",+ /// "connectors": [+ /// { "gateway_name": "stripe", "gateway_id": "mca_123" },+ /// { "gateway_name": "adyen", "gateway_id": "mca_124" }+ /// ]+ /// }+ /// ```pub output: serde_json::Value,++ /// Final connector(s) selected after evaluation.+ ///+ /// Example:+ /// ```json+ /// [+ /// {+ /// "connector": "stripe",+ /// "merchant_connector_id": "mca_123"+ /// }+ /// ]+ /// ```#[serde(deserialize_with = "deserialize_connector_choices")]pub evaluated_output: Vec<RoutableConnectorChoice>,#[serde(deserialize_with = "deserialize_connector_choices")]@@ -1634,14 +2072,29 @@ impl From<DeRoutableConnectorChoice> for RoutableConnectorChoice {}}}--/// Routable Connector chosen for a payment+/// Connector representation used in API request/response.+///+/// Represents a Merchant Connector Account.#[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]pub struct DeRoutableConnectorChoice {+ /// Connector name (e.g., stripe, adyen).+ ///+ /// Example:+ /// ```json+ /// "stripe"+ /// ```pub gateway_name: RoutableConnectors,- #[schema(value_type = String)]++ /// Merchant Connector Account ID.+ ///+ /// Example:+ /// ```json+ /// "mca_ExbsYfO1xFErhNtwY1PX"+ /// ```+ #[schema(value_type = String,example = "authipay_1705")]pub gateway_id: Option<common_utils::id_type::MerchantConnectorAccountId>,}+/// Represents a value in the DSL#[derive(Clone, Debug, PartialEq, Eq, Hash, Serialize, Deserialize, ToSchema)]#[serde(tag = "type", content = "value", rename_all = "snake_case")]