Bug: fix(routing): update_gateway_score_condition




diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index 296f60f8d4a..b865110a1a6 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -9451,9 +9451,8 @@ impl RoutingApproach {
     pub fn from_decision_engine_approach(approach: &str) -> Self {
         match approach {
             "SR_SELECTION_V3_ROUTING" => Self::SuccessRateExploitation,
-            "SR_V3_HEDGING" => Self::SuccessRateExploration,
+            "SR_V3_HEDGING" | "DEFAULT" => Self::SuccessRateExploration,
             "NTW_BASED_ROUTING" => Self::DebitRouting,
-            "DEFAULT" => Self::StraightThroughRouting,
             _ => Self::DefaultFallback,
         }
     }
diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs
index 292a668a07c..7d7336cf794 100644
--- a/crates/router/src/core/payments/operations/payment_response.rs
+++ b/crates/router/src/core/payments/operations/payment_response.rs
@@ -2268,8 +2268,13 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
                 async move {
                     let should_route_to_open_router =
                         state.conf.open_router.dynamic_routing_enabled;
+                    let is_success_rate_based = matches!(
+                        payment_attempt.routing_approach,
+                        Some(enums::RoutingApproach::SuccessRateExploitation)
+                            | Some(enums::RoutingApproach::SuccessRateExploration)
+                    );
 
-                    if should_route_to_open_router {
+                    if should_route_to_open_router && is_success_rate_based {
                         routing_helpers::update_gateway_score_helper_with_open_router(
                             &state,
                             &payment_attempt,

## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [x] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description

This PR updates the dynamic routing logic to ensure that update_gateway_score_helper_with_open_router is invoked only when the payment_attempt.routing_approach is either:

SuccessRateExploitation or SuccessRateExploration.

This updates the routing logic and the payment response tracker to improve how routing approaches are interpreted and when gateway scores are updated. The main changes clarify the mapping of routing approaches and ensure that gateway score updates are only triggered for specific routing strategies.

Routing approach mapping improvements:
* Added support for `"DEFAULT"` to map to `SuccessRateExploration` in `RoutingApproach::from_decision_engine_approach`, making the handling of default approaches more consistent. (`crates/common_enums/src/enums.rs`)

Payment response update logic:
* Changed the gateway score update condition in `payment_response_update_tracker` to require both dynamic routing to be enabled and the routing approach to be success-rate based, preventing updates for approaches that do not use success rate logic. (`crates/router/src/core/payments/operations/payment_response.rs`)

This pull request updates routing logic to ensure that gateway score updates via Open Router only occur for success rate-based routing approaches. It also refines the mapping from decision engine approaches to routing approaches, making the behavior for the `"DEFAULT"` case more consistent.

Routing logic improvements:

* In `payment_response_update_tracker`, gateway score updates using Open Router are now restricted to cases where the routing approach is either `SuccessRateExploitation` or `SuccessRateExploration`, instead of being applied for all dynamic routing.

Routing approach mapping changes:

* In `RoutingApproach::from_decision_engine_approach`, the `"DEFAULT"` case is now mapped to `SuccessRateExploration` (alongside `"SR_V3_HEDGING"`), and is no longer mapped to `StraightThroughRouting`, improving consistency in approach selection.



<!--
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
2. `crates/router/src/configs`
3. `loadtest/config`
-->




## How did you test it?

sr_based

```
curl --location 'http://localhost:8080/account/merchant_1758275545/business_profile/pro_RiCX7Rsxbd4WReAR9TEh/dynamic_routing/success_based/create?enable=dynamic_connector_selection' \
--header 'Content-Type: application/json' \
--header 'api-key: *****' \
--data '{
    "decision_engine_configs": {
        "defaultBucketSize": 200,
        "defaultHedgingPercent": 5
    }
}'
```

```
{
    "id": "routing_S27CKCr6Mp8e3VmUnGf0",
    "profile_id": "pro_RiCX7Rsxbd4WReAR9TEh",
    "name": "Success rate based dynamic routing algorithm",
    "kind": "dynamic",
    "description": "",
    "created_at": 1758275557,
    "modified_at": 1758275557,
    "algorithm_for": "payment",
    "decision_engine_routing_id": null
}
```

activate

```
curl --location 'http://localhost:8080/routing/routing_S27CKCr6Mp8e3VmUnGf0/activate' \
--header 'Content-Type: application/json' \
--header 'api-key: *****' \
--data '{}'

```
```
{
    "id": "routing_S27CKCr6Mp8e3VmUnGf0",
    "profile_id": "pro_RiCX7Rsxbd4WReAR9TEh",
    "name": "Success rate based dynamic routing algorithm",
    "kind": "dynamic",
    "description": "",
    "created_at": 1758275557,
    "modified_at": 1758275557,
    "algorithm_for": "payment",
    "decision_engine_routing_id": null
}
```

volume split

```
curl --location --request POST 'http://localhost:8080/account/merchant_1758275545/business_profile/pro_RiCX7Rsxbd4WReAR9TEh/dynamic_routing/set_volume_split?split=20' \
--header 'api-key: *****'

```
```
{
    "routing_type": "dynamic",
    "split": 20
}

```
payment

```
curl --location 'http://localhost:8080/payments' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: *****' \
--data-raw '{
    "amount": 6540,
    "currency": "USD",
    "amount_to_capture": 6540,
    "confirm": true,
    "profile_id": "pro_RiCX7Rsxbd4WReAR9TEh",
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "authentication_type": "no_three_ds",
    "setup_future_usage": "on_session", 
    "customer": {
        "id": "customer123",
        "name": "John Doe",
        "email": "customer@gmail.com",
        "phone": "9999999999",
        "phone_country_code": "+1"
    },
    "customer_id": "customer123",
    
    
    
    "phone_country_code": "+1",
    
    
    
    
    "description": "Its my first payment request",
    "return_url": "https://google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": { 
        "card": {
            "card_number": "4242424242424242",
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "card_cvc": "123"
        }
    },
    
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "guest@example.com"
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "guest@example.com"
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 6540,
            "account_name": "transaction_processing"
        }
    ],
    "metadata": {
        "udf1": "value1",
        "new_customer": "true",
        "login_date": "2019-09-10T10:11:12Z"
    },
    "browser_info": {
        "user_agent": "Mozilla\/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit\/537.36 (KHTML, like Gecko) Chrome\/70.0.3538.110 Safari\/537.36",
        "accept_header": "text\/html,application\/xhtml+xml,application\/xml;q=0.9,image\/webp,image\/apng,*\/*;q=0.8",
        "language": "nl-NL",
        "color_depth": 24,
        "screen_height": 723,
        "screen_width": 1536,
        "time_zone": 0,
        "java_enabled": true,
        "java_script_enabled": true,
        "ip_address": "128.0.0.1"
    },
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "125.0.0.1",
            "user_agent": "amet irure esse"
        }
    },
    
    "connector_metadata": {
        "noon": {
            "order_category": "pay"
        }
    },
    "payment_link": false,
    "payment_link_config": {
        "theme": "",
        "logo": "",
        "seller_name": "",
        "sdk_layout": "",
        "display_sdk_only": false,
        "enabled_saved_payment_method": false
    },
    "payment_type": "normal", 
    "request_incremental_authorization": false,
    "merchant_order_reference_id": "test_ord",
    "session_expiry": 900 
}'
```

```
{
    "payment_id": "pay_QifEdH91f7xnl124ICdD",
    "merchant_id": "merchant_1758275545",
    "status": "succeeded",
    "amount": 6540,
    "net_amount": 6540,
    "shipping_cost": null,
    "amount_capturable": 6540,
    "amount_received": 6540,
    "connector": "stripe",
    "client_secret": "pay_QifEdH91f7xnl124ICdD",
    "created": "2025-09-19T10:16:18.704Z",
    "currency": "USD",
    "customer_id": "customer123",
    "customer": {
        "id": "customer123",
        "name": "John Doe",
        "email": "customer@gmail.com",
        "phone": "9999999999",
        "phone_country_code": "+1"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "on_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "4242",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "424242",
            "card_extended_bin": null,
            "card_exp_month": "10",
            "card_exp_year": "25",
            "card_holder_name": "joseph Doe",
            "payment_checks": {
                "cvc_check": "pass",
                "address_line1_check": "pass",
                "address_postal_code_check": "pass"
            },
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": null,
    "shipping": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "guest@example.com"
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "joseph",
            "last_name": "Doe",
            "origin_zip": null
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": "guest@example.com"
    },
    "order_details": [
        {
            "sku": null,
            "upc": null,
            "brand": null,
            "amount": 6540,
            "category": null,
            "quantity": 1,
            "tax_rate": null,
            "product_id": null,
            "description": null,
            "product_name": "Apple iphone 15",
            "product_type": null,
            "sub_category": null,
            "total_amount": null,
            "commodity_code": null,
            "unit_of_measure": null,
            "product_img_link": null,
            "product_tax_code": null,
            "total_tax_amount": null,
            "requires_shipping": null,
            "unit_discount_amount": null
        }
    ],
    "email": "customer@gmail.com",
    "name": "John Doe",
    "phone": "9999999999",
    "return_url": "https://google.com/",
    "authentication_type": "no_three_ds",
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": "credit",
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "customer123",
        "created_at": 1758276978,
        "expires": 1758280578,
        "secret": "epk_721a0329318e4cb4bc8075b73c371a07"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": "pi_3S91MVD5R7gDAGff06OHFTNL",
    "frm_message": null,
    "metadata": {
        "udf1": "value1",
        "login_date": "2019-09-10T10:11:12Z",
        "new_customer": "true"
    },
    "connector_metadata": {
        "apple_pay": null,
        "airwallex": null,
        "noon": {
            "order_category": "pay"
        },
        "braintree": null,
        "adyen": null
    },
    "feature_metadata": {
        "redirect_response": null,
        "search_tags": null,
        "apple_pay_recurring_details": null,
        "gateway_system": "direct"
    },
    "reference_id": "pi_3S91MVD5R7gDAGff06OHFTNL",
    "payment_link": null,
    "profile_id": "pro_RiCX7Rsxbd4WReAR9TEh",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_4NgqlrfFxugpnylD8XPF",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-09-19T10:31:18.704Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "128.0.0.1",
        "user_agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/70.0.3538.110 Safari/537.36",
        "color_depth": 24,
        "java_enabled": true,
        "screen_width": 1536,
        "accept_header": "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8",
        "screen_height": 723,
        "java_script_enabled": true
    },
    "payment_channel": null,
    "payment_method_id": null,
    "network_transaction_id": "104557651805572",
    "payment_method_status": null,
    "updated": "2025-09-19T10:16:20.099Z",
    "split_payments": null,
    "frm_metadata": null,
    "extended_authorization_applied": false,
    "capture_before": null,
    "merchant_order_reference_id": "test_ord",
    "order_tax_amount": null,
    "connector_mandate_id": null,
    "card_discovery": "manual",
    "force_3ds_challenge": false,
    "force_3ds_challenge_trigger": false,
    "issuer_error_code": null,
    "issuer_error_message": null,
    "is_iframe_redirection_enabled": null,
    "whole_connector_response": null,
    "enable_partial_authorization": null,
    "enable_overcapture": null,
    "is_overcapture_enabled": false,
    "network_details": null
}
```

## Screenshot


<img width="1319" height="326" alt="Screenshot 2025-09-19 at 7 09 13 PM" src="https://github.com/user-attachments/assets/d0c17cc5-f3cb-41bf-af65-212f9e36af41" />

<img width="1326" height="311" alt="Screenshot 2025-09-19 at 7 06 13 PM" src="https://github.com/user-attachments/assets/2ef8bd31-fd08-4441-9a80-2c201d008b35" />

