Bug: prioritise connector_mandate_id over network_transaction_id during MITs



During the MIT if the decided connector is same as the connector with which the mandate is created then the MIT should be processed with the connector mandate _id.
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index ceeb384ed21..c88cc161287 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -5799,26 +5799,7 @@ where
             .as_ref()
             .ok_or(errors::ApiErrorResponse::InternalServerError)
             .attach_printable("Failed to find the merchant connector id")?;
-        if is_network_transaction_id_flow(
-            state,
-            is_connector_agnostic_mit_enabled,
-            connector_data.connector_name,
-            payment_method_info,
-        ) {
-            logger::info!("using network_transaction_id for MIT flow");
-            let network_transaction_id = payment_method_info
-                .network_transaction_id
-                .as_ref()
-                .ok_or(errors::ApiErrorResponse::InternalServerError)
-                .attach_printable("Failed to fetch the network transaction id")?;
-
-            let mandate_reference_id = Some(payments_api::MandateReferenceId::NetworkMandateId(
-                network_transaction_id.to_string(),
-            ));
-
-            connector_choice = Some((connector_data, mandate_reference_id.clone()));
-            break;
-        } else if connector_mandate_details
+        if connector_mandate_details
             .clone()
             .map(|connector_mandate_details| {
                 connector_mandate_details.contains_key(merchant_connector_id)
@@ -5868,6 +5849,25 @@ where
                             break;
                         }
             }
+        } else if is_network_transaction_id_flow(
+            state,
+            is_connector_agnostic_mit_enabled,
+            connector_data.connector_name,
+            payment_method_info,
+        ) {
+            logger::info!("using network_transaction_id for MIT flow");
+            let network_transaction_id = payment_method_info
+                .network_transaction_id
+                .as_ref()
+                .ok_or(errors::ApiErrorResponse::InternalServerError)
+                .attach_printable("Failed to fetch the network transaction id")?;
+
+            let mandate_reference_id = Some(payments_api::MandateReferenceId::NetworkMandateId(
+                network_transaction_id.to_string(),
+            ));
+
+            connector_choice = Some((connector_data, mandate_reference_id.clone()));
+            break;
         } else {
             continue;
         }

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

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

## Description
<!-- Describe your changes in detail -->
During the MIT if the decided connector is same as the connector with which the mandate is created then the MIT should be processed with the connector mandate _id.

### Additional Changes

- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

<!--
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`
-->


## Motivation and Context
<!--
Why is this change required? What problem does it solve?
If it fixes an open issue, please link to the issue here.

If you don't have an issue, we'd recommend starting with one first so the PR
can focus on the implementation (unless it is an obvious bug or documentation fix
that will have little conversation).
-->
Connector mandate id based payments have better auth rates than the card details with network transaction id.

## How did you test it?
<!--
Did you write an integration/unit/API test to verify the code changes?
Or did you test this change manually (provide relevant screenshots)?
-->
-> Create a business profile and enable connector agnostic mandate feature
```
curl --location 'http://localhost:8080/account/merchant_1737444280/business_profile/pro_h1bdGYYiQic3IHdVU1Mm' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data '{
    "is_connector_agnostic_mit_enabled": true
}'
```
```
{
    "merchant_id": "merchant_1737444280",
    "profile_id": "pro_h1bdGYYiQic3IHdVU1Mm",
    "profile_name": "US_default",
    "return_url": "https://google.com/success",
    "enable_payment_response_hash": true,
    "payment_response_hash_key": "g9sOqQ4SnAvNAjupw2CYjfkOlasfwYVIILUieujxrvuklwkPFAUjaPR6k48uxLd0",
    "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": true,
    "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,
    "is_click_to_pay_enabled": false,
    "authentication_product_ids": null
}
```
#### Create a off session payment
```
curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'api-key: <api-key>' \
--header 'Content-Type: application/json' \
--data-raw '{
    "amount": 500,
    "currency": "USD",
    "confirm": true,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "customer_id": "cu_1737444547",
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "authentication_type": "no_three_ds",
    "return_url": "https://google.com",
    "payment_method": "card",
    "payment_method_type": "credit",
    "payment_method_data": {
        "card": {
            "card_number": "4111111111111111",
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "name name",
            "card_cvc": "737"
        }
    },
    "setup_future_usage": "off_session",
    "customer_acceptance": {
        "acceptance_type": "offline",
        "accepted_at": "1963-05-03T04:07:52.723Z",
        "online": {
            "ip_address": "in sit",
            "user_agent": "amet irure esse"
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "PiX",
            "last_name": "ss"
        }
    },
    "shipping": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "John",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "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": "125.0.0.1"
    },
    "statement_descriptor_name": "joseph",
    "statement_descriptor_suffix": "JS",
    "metadata": {},
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 0,
            "account_name": "transaction_processing"
        }
    ]
}'
```
```
{
    "payment_id": "pay_KqygCo0YGgtq5kwRg7ya",
    "merchant_id": "merchant_1737444280",
    "status": "succeeded",
    "amount": 500,
    "net_amount": 500,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 500,
    "connector": "stripe",
    "client_secret": "pay_KqygCo0YGgtq5kwRg7ya_secret_Dem5r9Q8FYZom1eRjrt0",
    "created": "2025-01-21T07:28:13.410Z",
    "currency": "USD",
    "customer_id": "cu_1737444493",
    "customer": {
        "id": "cu_1737444493",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": "Its my first payment request",
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1111",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "name name",
            "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": "John",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        },
        "email": null
    },
    "billing": {
        "address": {
            "city": "San Fransico",
            "country": "US",
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "zip": "94122",
            "state": "California",
            "first_name": "PiX",
            "last_name": "ss"
        },
        "phone": null,
        "email": null
    },
    "order_details": [
        {
            "brand": null,
            "amount": 0,
            "category": null,
            "quantity": 1,
            "tax_rate": null,
            "product_id": null,
            "product_name": "Apple iphone 15",
            "product_type": null,
            "sub_category": null,
            "product_img_link": null,
            "product_tax_code": null,
            "total_tax_amount": null,
            "requires_shipping": null
        }
    ],
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "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": "cu_1737444493",
        "created_at": 1737444493,
        "expires": 1737448093,
        "secret": "epk_5565c9134045451ab40c5712bfa952b2"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi_3QjbsgEOqOywnAIx1CT15pu2",
    "frm_message": null,
    "metadata": {},
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3QjbsgEOqOywnAIx1CT15pu2",
    "payment_link": null,
    "profile_id": "pro_h1bdGYYiQic3IHdVU1Mm",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_yzI9tnLJezjQey1LjoCo",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-21T07:43:13.410Z",
    "fingerprint": null,
    "browser_info": {
        "language": "nl-NL",
        "time_zone": 0,
        "ip_address": "125.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_method_id": "pm_LR6jCdVNR85W6L1jYIeX",
    "payment_method_status": "active",
    "updated": "2025-01-21T07:28:15.652Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "pm_1QjbsgEOqOywnAIxpfltM04Z"
}
```
-> Image showing `network_transaction_id` shored in db
![image](https://github.com/user-attachments/assets/b5aa3307-4ffd-4dcd-9f7a-023c6ebd17c6)

#### Recurring payment with same connector
-> Create a payment for the same customer with confirm false
```
curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'api-key: <api-key>' \
--header 'Content-Type: application/json' \
--data '{
    "amount": 10000,
    "currency": "USD",
    "capture_method": "automatic",
    "authentication_type": "three_ds",
    "confirm": false,
    "customer_id": "cu_1737444493"
}'
```
```
{
    "payment_id": "pay_pG0kiVb7LLFH8zL2MwFk",
    "merchant_id": "merchant_1737444280",
    "status": "requires_payment_method",
    "amount": 10000,
    "net_amount": 10000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": null,
    "client_secret": "pay_pG0kiVb7LLFH8zL2MwFk_secret_ArZFjbGaLgfS9Xz75hcM",
    "created": "2025-01-21T07:31:42.526Z",
    "currency": "USD",
    "customer_id": "cu_1737444493",
    "customer": {
        "id": "cu_1737444493",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": null,
    "payment_method_data": null,
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": null,
    "authentication_type": "three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": null,
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cu_1737444493",
        "created_at": 1737444702,
        "expires": 1737448302,
        "secret": "epk_eb66ffa2b7be44958a581a9774279fef"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_h1bdGYYiQic3IHdVU1Mm",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": null,
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-21T07:46:42.526Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-21T07:31:42.545Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```
-> List customer payment methods with the `client_secret`
```
curl --location 'http://localhost:8080/customers/payment_methods?client_secret=pay_pG0kiVb7LLFH8zL2MwFk_secret_ArZFjbGaLgfS9Xz75hcM' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_b40ef36c556f4da5b6d4682fe66bceeb'
```
```
{
    "customer_payment_methods": [
        {
            "payment_token": "token_sBwkrgItKqpd07yTPDVG",
            "payment_method_id": "pm_LR6jCdVNR85W6L1jYIeX",
            "customer_id": "cu_1737444493",
            "payment_method": "card",
            "payment_method_type": "credit",
            "payment_method_issuer": null,
            "payment_method_issuer_code": null,
            "recurring_enabled": true,
            "installment_payment_enabled": false,
            "payment_experience": [
                "redirect_to_url"
            ],
            "card": {
                "scheme": null,
                "issuer_country": null,
                "last4_digits": "1111",
                "expiry_month": "03",
                "expiry_year": "2030",
                "card_token": null,
                "card_holder_name": "name name",
                "card_fingerprint": null,
                "nick_name": null,
                "card_network": null,
                "card_isin": "411111",
                "card_issuer": null,
                "card_type": null,
                "saved_to_locker": true
            },
            "metadata": null,
            "created": "2025-01-21T07:28:15.607Z",
            "bank": null,
            "surcharge_details": null,
            "requires_cvv": true,
            "last_used_at": "2025-01-21T07:28:15.607Z",
            "default_payment_method_set": true,
            "billing": {
                "address": {
                    "city": "San Fransico",
                    "country": "US",
                    "line1": "1467",
                    "line2": "Harrison Street",
                    "line3": "Harrison Street",
                    "zip": "94122",
                    "state": "California",
                    "first_name": "name",
                    "last_name": "name"
                },
                "phone": null,
                "email": null
            }
        }
    ],
    "is_guest_customer": false
}
```
-> Confirm the payment with the above listed token and the `client_secret`
```
curl --location 'http://localhost:8080/payments/pay_pG0kiVb7LLFH8zL2MwFk/confirm' \
--header 'api-key: pk_dev_b40ef36c556f4da5b6d4682fe66bceeb' \
--header 'Content-Type: application/json' \
--data-raw '{
    "payment_token": "token_sBwkrgItKqpd07yTPDVG",
    "payment_method_type": "credit",
    "payment_method": "card",
    "setup_future_usage": "off_session",
    "client_secret": "pay_pG0kiVb7LLFH8zL2MwFk_secret_ArZFjbGaLgfS9Xz75hcM",
    "billing": {
        "address": {
            "city": "test",
            "country": "US",
            "line1": "here",
            "line2": "there",
            "line3": "anywhere",
            "zip": "560095",
            "state": "Washington",
            "first_name": "One",
            "last_name": "Two"
        },
        "phone": {
            "number": "1234567890",
            "country_code": "+1"
        },
        "email": "guest@example.com"
    }
}'
```
```
{
    "payment_id": "pay_pG0kiVb7LLFH8zL2MwFk",
    "merchant_id": "merchant_1737444280",
    "status": "succeeded",
    "amount": 10000,
    "net_amount": 10000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 10000,
    "connector": "stripe",
    "client_secret": "pay_pG0kiVb7LLFH8zL2MwFk_secret_ArZFjbGaLgfS9Xz75hcM",
    "created": "2025-01-21T07:31:42.526Z",
    "currency": "USD",
    "customer_id": "cu_1737444493",
    "customer": {
        "id": "cu_1737444493",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1111",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "name name",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "token_sBwkrgItKqpd07yTPDVG",
    "shipping": null,
    "billing": {
        "address": {
            "city": "test",
            "country": "US",
            "line1": "here",
            "line2": "there",
            "line3": "anywhere",
            "zip": "560095",
            "state": "Washington",
            "first_name": "One",
            "last_name": "Two"
        },
        "phone": {
            "number": "1234567890",
            "country_code": "+1"
        },
        "email": "guest@example.com"
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": null,
    "authentication_type": "three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "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": null,
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi_3Qjbx2EOqOywnAIx0fDT7TiV",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3Qjbx2EOqOywnAIx0fDT7TiV",
    "payment_link": null,
    "profile_id": "pro_h1bdGYYiQic3IHdVU1Mm",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_yzI9tnLJezjQey1LjoCo",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-21T07:46:42.526Z",
    "fingerprint": null,
    "browser_info": {
        "os_type": null,
        "language": null,
        "time_zone": null,
        "ip_address": "::1",
        "os_version": null,
        "user_agent": null,
        "color_depth": null,
        "device_model": null,
        "java_enabled": null,
        "screen_width": null,
        "accept_header": null,
        "screen_height": null,
        "java_script_enabled": null
    },
    "payment_method_id": "pm_LR6jCdVNR85W6L1jYIeX",
    "payment_method_status": "active",
    "updated": "2025-01-21T07:32:45.176Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "pm_1QjbsgEOqOywnAIxpfltM04Z"
}
```
-> Logs indicating `connector_mandate_id` was used to make MIT
![image](https://github.com/user-attachments/assets/49064be0-8548-4312-b95a-1f7ea04c0b24)

#### Recurring payment with different connector
Since the initial CIT was processed using the Stripe payment method, the table will only contain the connector mandate ID for Stripe. Now that Cybersource has been chosen for the MIT, the payment should be processed through Cybersource using the network_transaction_id, and it should succeed.

-> Configure another connector (stripe, adyen, or cybersource), other than the one used in CIT
-> Create a payment for same customer with confirm false
```
curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'api-key: <api-key>' \
--header 'Content-Type: application/json' \
--data '{
    "amount": 10000,
    "currency": "USD",
    "capture_method": "automatic",
    "authentication_type": "three_ds",
    "confirm": false,
    "customer_id": "cu_1737444493"
}'
```
```
{
    "payment_id": "pay_HEjhNaSLzmzi9i7hNQAf",
    "merchant_id": "merchant_1737444280",
    "status": "requires_payment_method",
    "amount": 10000,
    "net_amount": 10000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": null,
    "client_secret": "pay_HEjhNaSLzmzi9i7hNQAf_secret_HukTuQYWnuiDSV6cHmz9",
    "created": "2025-01-21T07:43:14.695Z",
    "currency": "USD",
    "customer_id": "cu_1737444493",
    "customer": {
        "id": "cu_1737444493",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": null,
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": null,
    "payment_method_data": null,
    "payment_token": null,
    "shipping": null,
    "billing": null,
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": null,
    "authentication_type": "three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "next_action": null,
    "cancellation_reason": null,
    "error_code": null,
    "error_message": null,
    "unified_code": null,
    "unified_message": null,
    "payment_experience": null,
    "payment_method_type": null,
    "connector_label": null,
    "business_country": null,
    "business_label": "default",
    "business_sub_label": null,
    "allowed_payment_method_types": null,
    "ephemeral_key": {
        "customer_id": "cu_1737444493",
        "created_at": 1737445394,
        "expires": 1737448994,
        "secret": "epk_e470828aef5346b78806253351aa5283"
    },
    "manual_retry_allowed": null,
    "connector_transaction_id": null,
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": null,
    "payment_link": null,
    "profile_id": "pro_h1bdGYYiQic3IHdVU1Mm",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": null,
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-21T07:58:14.695Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-21T07:43:14.712Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```
-> List customer payment methods using the `client_secret`
```
curl --location 'http://localhost:8080/customers/payment_methods?client_secret=pay_HEjhNaSLzmzi9i7hNQAf_secret_HukTuQYWnuiDSV6cHmz9' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_b40ef36c556f4da5b6d4682fe66bceeb'
```
```
{
    "customer_payment_methods": [
        {
            "payment_token": "token_NG5a2aePYBabkiDr0WTP",
            "payment_method_id": "pm_LR6jCdVNR85W6L1jYIeX",
            "customer_id": "cu_1737444493",
            "payment_method": "card",
            "payment_method_type": "credit",
            "payment_method_issuer": null,
            "payment_method_issuer_code": null,
            "recurring_enabled": true,
            "installment_payment_enabled": false,
            "payment_experience": [
                "redirect_to_url"
            ],
            "card": {
                "scheme": null,
                "issuer_country": null,
                "last4_digits": "1111",
                "expiry_month": "03",
                "expiry_year": "2030",
                "card_token": null,
                "card_holder_name": "name name",
                "card_fingerprint": null,
                "nick_name": null,
                "card_network": null,
                "card_isin": "411111",
                "card_issuer": null,
                "card_type": null,
                "saved_to_locker": true
            },
            "metadata": null,
            "created": "2025-01-21T07:28:15.607Z",
            "bank": null,
            "surcharge_details": null,
            "requires_cvv": true,
            "last_used_at": "2025-01-21T07:32:45.157Z",
            "default_payment_method_set": true,
            "billing": {
                "address": {
                    "city": "San Fransico",
                    "country": "US",
                    "line1": "1467",
                    "line2": "Harrison Street",
                    "line3": "Harrison Street",
                    "zip": "94122",
                    "state": "California",
                    "first_name": "name",
                    "last_name": "name"
                },
                "phone": null,
                "email": null
            }
        }
    ],
    "is_guest_customer": false
}
```
-> Since the initial CIT was processed using the Stripe payment method, the table will only contain the connector mandate ID for Stripe. Now that Cybersource has been chosen for the MIT, the payment should be processed through Cybersource using the network_transaction_id, and it should succeed.

```
curl --location 'http://localhost:8080/payments/pay_HEjhNaSLzmzi9i7hNQAf/confirm' \
--header 'api-key: pk_dev_b40ef36c556f4da5b6d4682fe66bceeb' \
--header 'Content-Type: application/json' \
--data-raw '{
    "payment_token": "token_NG5a2aePYBabkiDr0WTP",
    "payment_method_type": "credit",
    "payment_method": "card",
    "setup_future_usage": "off_session",
    "client_secret": "pay_HEjhNaSLzmzi9i7hNQAf_secret_HukTuQYWnuiDSV6cHmz9",
       "routing": {
        "type": "single",
        "data": {
            "connector": "cybersource",
            "merchant_connector_id": "mca_Nz1gr4IIjucxP22LHe1C"
        }
    },
    "billing": {
        "address": {
            "city": "test",
            "country": "US",
            "line1": "here",
            "line2": "there",
            "line3": "anywhere",
            "zip": "560095",
            "state": "Washington",
            "first_name": "One",
            "last_name": "Two"
        },
        "phone": {
            "number": "1234567890",
            "country_code": "+1"
        },
        "email": "guest@example.com"
    }
}'
```
```
{
    "payment_id": "pay_HEjhNaSLzmzi9i7hNQAf",
    "merchant_id": "merchant_1737444280",
    "status": "succeeded",
    "amount": 10000,
    "net_amount": 10000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 10000,
    "connector": "cybersource",
    "client_secret": "pay_HEjhNaSLzmzi9i7hNQAf_secret_HukTuQYWnuiDSV6cHmz9",
    "created": "2025-01-21T07:43:14.695Z",
    "currency": "USD",
    "customer_id": "cu_1737444493",
    "customer": {
        "id": "cu_1737444493",
        "name": "John Doe",
        "email": "guest@example.com",
        "phone": "999999999",
        "phone_country_code": "+65"
    },
    "description": null,
    "refunds": null,
    "disputes": null,
    "mandate_id": null,
    "mandate_data": null,
    "setup_future_usage": "off_session",
    "off_session": null,
    "capture_on": null,
    "capture_method": "automatic",
    "payment_method": "card",
    "payment_method_data": {
        "card": {
            "last4": "1111",
            "card_type": null,
            "card_network": null,
            "card_issuer": null,
            "card_issuing_country": null,
            "card_isin": "411111",
            "card_extended_bin": null,
            "card_exp_month": "03",
            "card_exp_year": "2030",
            "card_holder_name": "name name",
            "payment_checks": null,
            "authentication_data": null
        },
        "billing": null
    },
    "payment_token": "token_NG5a2aePYBabkiDr0WTP",
    "shipping": null,
    "billing": {
        "address": {
            "city": "test",
            "country": "US",
            "line1": "here",
            "line2": "there",
            "line3": "anywhere",
            "zip": "560095",
            "state": "Washington",
            "first_name": "One",
            "last_name": "Two"
        },
        "phone": {
            "number": "1234567890",
            "country_code": "+1"
        },
        "email": "guest@example.com"
    },
    "order_details": null,
    "email": "guest@example.com",
    "name": "John Doe",
    "phone": "999999999",
    "return_url": null,
    "authentication_type": "three_ds",
    "statement_descriptor_name": null,
    "statement_descriptor_suffix": null,
    "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": null,
    "manual_retry_allowed": false,
    "connector_transaction_id": "7374456386026828504805",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pay_HEjhNaSLzmzi9i7hNQAf_1",
    "payment_link": null,
    "profile_id": "pro_h1bdGYYiQic3IHdVU1Mm",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_Nz1gr4IIjucxP22LHe1C",
    "incremental_authorization_allowed": false,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-21T07:58:14.695Z",
    "fingerprint": null,
    "browser_info": {
        "os_type": null,
        "language": null,
        "time_zone": null,
        "ip_address": "::1",
        "os_version": null,
        "user_agent": null,
        "color_depth": null,
        "device_model": null,
        "java_enabled": null,
        "screen_width": null,
        "accept_header": null,
        "screen_height": null,
        "java_script_enabled": null
    },
    "payment_method_id": "pm_LR6jCdVNR85W6L1jYIeX",
    "payment_method_status": "active",
    "updated": "2025-01-21T07:47:19.698Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```
-> Logs indicating `network_transaction_id` was used to make MIT
![image](https://github.com/user-attachments/assets/59a70e78-5142-4a17-9837-350e8ea4c41b)

## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [x] I addressed lints thrown by `cargo clippy`
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible