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_1 (already cloned)
- Base commit: 33cd60e64288b2a6bb24cc27b9d319fdbeab46ef
- Task ID: juspay__hyperswitch-8190
- Version: v1.114.0
TASK DESCRIPTION: Bug: refactor(dynamic_routing): add logic for creating merchant account in decision engine
DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
Merchant account creation on decision-engine is pre-requisite for making success based routing calls to it. Since toggle SR endpoint on Hyperswitch is the place where rule creation API of DE is being called, we can check whether merchant_account exists in DE, if exists, toggle endpoint will go ahead with creating the rule. If not, it will first call DE to create a merchant_account and then create the rule. I have created the
is_merchant_created_in_decision_engineflag inside thedynamic_routing_algorithmcolumn which is of type JSON in profile table. I have added a#[serde(default)]attribute on top ofis_merchant_created_in_decision_engine. Hence it shouldn't break for older profiles which doesn't have this field itself.Additional Changes
- This PR modifies the API contract
- This PR modifies the database schema
- This PR modifies application configuration/environment variables
Motivation and Context
How did you test it?
- Create merchant_account and API key in Hyperswitch.
- Toggle SR for the default profile created above.
curl --location --request POST 'http://localhost:8080/account/merchant_1748681084/business_profile/pro_3gHXWoq1Xh3AKi6tNZV1/dynamic_routing/success_based/toggle?enable=dynamic_connector_selection' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: xyz' Assistant
I'll help you implement the dynamic routing refactor to add logic for creating merchant accounts in the decision engine. Let me start by understanding the current codebase structure and locating the relevant files.
Assistant
I'll work on implementing the dynamic routing refactor to add logic for creating merchant accounts in the decision engine. Let me start by exploring the codebase structure to understand where the relevant files are located.
Assistant
Let me search for files related to dynamic routing and decision engine integration:
Assistant
(no content)
Assistant
Let me search for the toggle endpoint and dynamic routing files more broadly:
Assistant
Let me examine the routing module to understand the structure better:
Assistant
Now let me look at the helper functions to understand how the dynamic routing is implemented:
Assistant
Let me search for the update_decision_engine_dynamic_routing_setup function mentioned in the code:
Assistant
Let me examine the routing helpers file to understand how dynamic routing works:
Assistant
Let me look at the business profile structure to understand how dynamic_routing_algorithm is defined:
Assistant
Let me look at the diesel models to understand the profile structure:
Assistant
Let me find the profile model:
Assistant
(no content)
Assistant
Now let me search for the DynamicRoutingAlgorithmRef to understand how it's structured:
Assistant
Let me check the routing API models to understand the structure:
Assistant
Now let me check how the helpers module implements the enable_dynamic_routing_algorithm function to understand where we need to add the merchant account creation logic:
Assistant
Let me continue reading the helpers file to find the enable_dynamic_routing_algorithm function:
Assistant
Let me search for the function definition:
Assistant
(no content)
Assistant
Let me search around the line numbers where this function is likely defined by looking for the function declaration:
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.