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_6 (already cloned)
- Base commit: 713c85d25d29259672da6efbfed0862e843ec542
- Task ID: juspay__hyperswitch-8295
- Version: v1.114.0
TASK DESCRIPTION: Bug: add
merchant_category_codein business profileAdd support to accept
merchant_category_codeas input in the business profile. This is the four-digit code assigned based on business type to determine processing fees and risk level. This code can be used to make various decision during a payment flow. One such use case is network interchange fee calculation in debit routing.DETAILED CONTEXT & HINTS:
Type of Change
- Bugfix
- New feature
- Enhancement
- Refactoring
- Dependency updates
- Documentation
- CI/CD
Description
This pull request introduces
merchant_category_codefield in the business profile. This is the four-digit code assigned based on business type to determine processing fees and risk level. This code can be used to make various decision during a payment flow. One such use case is network interchange fee calculation in debit routing.- Enum Enhancements: Introduced two new enums,
MerchantCategoryandMerchantCategoryCode, to represent MCCs and their corresponding human-readable names. Implemented a mapping functionto_merchant_category_nameto convert MCCs to their names.
WASM Functionality
- Frontend Integration: Added a new WASM function
getMerchantCategoryCodeWithNameto retrieve all MCCs along with their names for frontend use. This function iterates over theMerchantCategoryCodeenum and constructs a list of MCCs and their human-readable names.
Code Refactoring
- Enum Renaming: Renamed
MerchantCategoryCodetoDecisionEngineMerchantCategoryCodein specific contexts to clarify usage in decision engine logic. This is struct will be removed once the new struct is introduced in decision engine.
-> Supported Merchant Category Codes
- 5411
- 7011
- 0763
- 8111
- 5021
- 4816
- 5661
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?
-> Update a business profile by passing merchant category code
curl --location 'http://localhost:8080/account/merchant_1749476401/business_profile/pro_1RkvEPVmDc3K9FSyjOOS' \ --header 'Content-Type: application/json' \ --header 'Accept: application/json' \ --header 'api-key: ' \ --data '{ "merchant_category_code": "5411" }'{ "merchant_id": "merchant_1749476401", "profile_id": "pro_1RkvEPVmDc3K9FSyjOOS", "profile_name": "US_default", "return_url": "https://google.com/success", "enable_payment_response_hash": true, "payment_response_hash_key": "IfRVqwhR9vFVlA7sYWqPZvy6xNbM6wToe8N0WCEGykmFkTc7hYyycIbOCbGw3Hxo", "redirect_to_merchant_with_http_post": false, "webhook_details": { "webhook_version": "1.0.1", "webhook_username": "ekart_retail", "webhook_password": "password_ekart@123", "webhook_url": null, "payment_created_enabled": true, "payment_succeeded_enabled": true, "payment_failed_enabled": true }, "metadata": null, "routing_algorithm": null, "intent_fulfillment_time": 900, "frm_routing_algorithm": null, "payout_routing_algorithm": null, "applepay_verified_domains": null, "session_expiry": 900, "payment_link_config": null, "authentication_connector_details": null, "use_billing_as_payment_method_billing": true, "extended_card_info_config": null, "collect_shipping_details_from_wallet_connector": false, "collect_billing_details_from_wallet_connector": false, "always_collect_shipping_details_from_wallet_connector": false, "always_collect_billing_details_from_wallet_connector": false, "is_connector_agnostic_mit_enabled": false, "payout_link_config": null, "outgoing_webhook_custom_http_headers": null, "tax_connector_id": null, "is_tax_connector_enabled": false, "is_network_tokenization_enabled": false, "is_auto_retries_enabled": false, "max_auto_retries_enabled": null, "always_request_extended_authorization": null, "is_click_to_pay_enabled": false, "authentication_product_ids": null, "card_testing_guard_config": { "card_ip_blocking_status": "disabled", "card_ip_blocking_threshold": 3, "guest_user_card_blocking_status": "disabled", "guest_user_card_blocking_threshold": 10, "customer_id_blocking_status": "disabled", "customer_id_blocking_threshold": 5, "card_testing_guard_expiry": 3600 }, "is_clear_pan_retries_enabled": false, "force_3ds_challenge": false, "is_debit_routing_enabled": true, "merchant_business_country": null, "is_pre_network_tokenization_enabled": false, "merchant_category_code": "5411" }-> Db entry [image: image] open
-> Wasm testing
Checklist
- I formatted the code
cargo +nightly fmt --all - I addressed lints thrown by
cargo clippy - I reviewed the submitted code
- I added unit tests for my changes where possible
Summary by CodeRabbit
- New Features
- Introduced support for merchant category codes across payment and profile APIs, enabling optional inclusion of standardized merchant category codes in payment intent requests and merchant profiles.
- Added a public function to retrieve merchant category codes with their descriptive names via WebAssembly.
- Database
- Added a new nullable column for merchant category codes to the business profile table.
- API Documentation
- Updated API schemas and documentation to include merchant category code fields and enumerations.
- Refactor
- Standardized and extended merchant category code enums for improved mapping and integration.
CRITICAL INSTRUCTIONS - WORK FAST AND EFFICIENTLY:
-
Create DENSE, ACTION-FOCUSED todos IMMEDIATELY
- Make todos specific and actionable
- Focus on HIGH-IMPACT actions only
- 5-8 todos maximum - be surgical, not exhaustive
-
Execute aggressively:
- Use bash commands to search efficiently
- Read multiple related files in quick succession
- Make ALL related changes in one edit
- Skip unnecessary exploration
-
File operations:
- All repo files: './repos/hyperswitch_pool_6/'
- Use targeted edits over whole file rewrites
-
NO TESTING UNLESS CRITICAL:
- Focus on making the actual code changes
- Only test if explicitly required
-
Maximize information density:
- Each turn should accomplish significant work
- Batch file reads when examining related code
- Use search commands to locate code quickly
EFFICIENCY IS CRITICAL. Make substantial progress every turn.
Assistant
I'll help you implement the merchant_category_code feature in the business profile. Let me start by creating a plan and exploring the relevant files.
Assistant
Let me first explore the business profile structure to understand where to add the merchant_category_code field.
Assistant
(no content)
Assistant
Let me examine the business profile structures to understand the current implementation:
Assistant
Let me look at the diesel models and storage models to understand the structure better:
Assistant
Now let me check the router storage models:
Assistant
Let me check for any existing merchant category code related code or enums:
Assistant
Let me check the common enums to see if there are any existing merchant category related enums:
Assistant
(no content)
Assistant
Let me search for any reference to the specific merchant category codes mentioned in the task:
Assistant
Let me check the API models to understand how business profiles are handled in the API layer:
Assistant
(no content)
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
Identical first prompt
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →
claude-sonnet-4-5-20250929Compare side by side →