You are working on the hyperswitch repository (Rust payment processing system).…
- User
You are working on the hyperswitch repository (Rust payment processing system).
REPOSITORY SETUP:
- Repository: juspay/hyperswitch
- Working directory: ./repos/hyperswitch_pool_3 (already cloned)
- Base commit: 0e957854372f1e6a81ce72234b8a4fda16cb4b8d
- Task ID: juspay__hyperswitch-8910
- Version: v1.116.0
TASK DESCRIPTION: Bug: refactor(euclid): transform enum types to include sub-variants of payment method types
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
This PR refactors the Euclid routing parameter transformation logic to include sub-variants of payment method types in the Decision Engine evaluation request.
Key updates:
- Added logic to convert
(payment_method_type, payment_method)pairs into aDirValuerepresentation. - Introduced
insert_dirvalue_param()to map eachDirValuevariant into a corresponding routing parameter key. - Enhanced
convert_backend_input_to_routing_evalto insert these sub-variant parameters alongside existing routing parameters. - This ensures richer context is sent to Euclid for more granular routing decisions.
Outcomes
- Enables finer-grained routing rules based on payment method sub-types (e.g.,
WalletType,CryptoType,GiftCardType). - Improves compatibility with dashboard-configured payment method rules in Euclid.
- Makes routing evaluation requests more descriptive and precise, improving match accuracy.
Diff Hunk Explanation
crates/router/src/core/payments/routing/utils.rs- Modified
convert_backend_input_to_routing_eval:
Assistant
I'll work on this refactoring task to transform enum types to include sub-variants of payment method types in the Euclid routing parameter transformation logic. Let me start by examining the relevant files to understand the current implementation.
First, let me look at the specific file mentioned in the task description -
crates/router/src/core/payments/routing/utils.rs:Assistant
Let me search for files related to payment method types and DirValue to understand the current implementation better:
Assistant
Now let me look at the enum types and DirValue to understand how payment methods are structured:
Assistant
Let me search for DirValue more broadly in the codebase to understand how it's defined:
Assistant
(no content)
Assistant
Let me also check what
BackendInputlooks like to understand how payment method types are passed in:Assistant
(no content)
Assistant
Now let me check the enums definitions to understand the different payment method types:
Assistant
Let me examine the common enums to understand PaymentMethodType:
Assistant
Let me search for the PaymentMethodType enum definition specifically:
Assistant
(no content)
Assistant
(no content)
Assistant
Now I understand the structure better. Let me check the existing routing utils file again and understand exactly what needs to be changed. I'll create a plan first with todos.
Assistant
Let me read the current
convert_backend_input_to_routing_evalfunction more closely and then implement the changes:Assistant
Now let me check the imports to understand what types are available:
Assistant
Let me also check how
DirValueis imported or used in the euclid module:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.