Bug: store `network_transaction_id` for `off_session` payments irrespective of the `is_connector_agnostic_mit_enabled` config



Currently, we store the `network_transaction_id` for the setup_mandate/off_session payments only if the `is_connector_agnostic_mit_enabled` config is enabled. During the MITs, we refer to this flag to decide whether to use the `connector_mandate_id` or the `network_transaction_id` for the MIT.

Instead of using the flag for multiple purposes, it should be used solely to determine whether to use the `connector_mandate_id` or the `network_transaction_id` for the MIT. Therefore, this change will ensure that the `network_transaction_id` is always stored for off-session payments if it is present in the connector response.
diff --git a/crates/router/src/core/payments/operations/payment_response.rs b/crates/router/src/core/payments/operations/payment_response.rs
index 9692b1ca8a5..1cc0975af47 100644
--- a/crates/router/src/core/payments/operations/payment_response.rs
+++ b/crates/router/src/core/payments/operations/payment_response.rs
@@ -576,7 +576,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsSyncData> for
         merchant_account: &domain::MerchantAccount,
         key_store: &domain::MerchantKeyStore,
         payment_data: &mut PaymentData<F>,
-        business_profile: &domain::Profile,
+        _business_profile: &domain::Profile,
     ) -> CustomResult<(), errors::ApiErrorResponse>
     where
         F: 'b + Clone + Send + Sync,
@@ -617,7 +617,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::PaymentsSyncData> for
             resp.status,
             resp.response.clone(),
             merchant_account.storage_scheme,
-            business_profile.is_connector_agnostic_mit_enabled,
         )
         .await?;
         Ok(())
@@ -1201,7 +1200,7 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::CompleteAuthorizeData
         merchant_account: &domain::MerchantAccount,
         key_store: &domain::MerchantKeyStore,
         payment_data: &mut PaymentData<F>,
-        business_profile: &domain::Profile,
+        _business_profile: &domain::Profile,
     ) -> CustomResult<(), errors::ApiErrorResponse>
     where
         F: 'b + Clone + Send + Sync,
@@ -1241,7 +1240,6 @@ impl<F: Clone> PostUpdateTracker<F, PaymentData<F>, types::CompleteAuthorizeData
             resp.status,
             resp.response.clone(),
             merchant_account.storage_scheme,
-            business_profile.is_connector_agnostic_mit_enabled,
         )
         .await?;
         Ok(())
@@ -2079,7 +2077,6 @@ async fn update_payment_method_status_and_ntid<F: Clone>(
     attempt_status: common_enums::AttemptStatus,
     payment_response: Result<types::PaymentsResponseData, ErrorResponse>,
     storage_scheme: enums::MerchantStorageScheme,
-    is_connector_agnostic_mit_enabled: Option<bool>,
 ) -> RouterResult<()> {
     todo!()
 }
@@ -2095,7 +2092,6 @@ async fn update_payment_method_status_and_ntid<F: Clone>(
     attempt_status: common_enums::AttemptStatus,
     payment_response: Result<types::PaymentsResponseData, ErrorResponse>,
     storage_scheme: enums::MerchantStorageScheme,
-    is_connector_agnostic_mit_enabled: Option<bool>,
 ) -> RouterResult<()> {
     // If the payment_method is deleted then ignore the error related to retrieving payment method
     // This should be handled when the payment method is soft deleted
@@ -2130,20 +2126,18 @@ async fn update_payment_method_status_and_ntid<F: Clone>(
     })
     .ok()
     .flatten();
-        let network_transaction_id =
-            if let Some(network_transaction_id) = pm_resp_network_transaction_id {
-                if is_connector_agnostic_mit_enabled == Some(true)
-                    && payment_data.payment_intent.setup_future_usage
-                        == Some(diesel_models::enums::FutureUsage::OffSession)
-                {
-                    Some(network_transaction_id)
-                } else {
-                    logger::info!("Skip storing network transaction id");
-                    None
-                }
+        let network_transaction_id = if payment_data.payment_intent.setup_future_usage
+            == Some(diesel_models::enums::FutureUsage::OffSession)
+        {
+            if pm_resp_network_transaction_id.is_some() {
+                pm_resp_network_transaction_id
             } else {
+                logger::info!("Skip storing network transaction id");
                 None
-            };
+            }
+        } else {
+            None
+        };
 
         let pm_update = if payment_method.status != common_enums::PaymentMethodStatus::Active
             && payment_method.status != attempt_status.into()
diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs
index 84f848ef0ab..6ca4fa2ee72 100644
--- a/crates/router/src/core/payments/tokenization.rs
+++ b/crates/router/src/core/payments/tokenization.rs
@@ -108,12 +108,11 @@ where
             };
 
             let network_transaction_id =
-                if let Some(network_transaction_id) = network_transaction_id {
-                    if business_profile.is_connector_agnostic_mit_enabled == Some(true)
-                        && save_payment_method_data.request.get_setup_future_usage()
-                            == Some(storage_enums::FutureUsage::OffSession)
-                    {
-                        Some(network_transaction_id)
+                if save_payment_method_data.request.get_setup_future_usage()
+                    == Some(storage_enums::FutureUsage::OffSession)
+                {
+                    if network_transaction_id.is_some() {
+                        network_transaction_id
                     } else {
                         logger::info!("Skip storing network transaction id");
                         None

## 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 -->
Currently, we store the `network_transaction_id` for the setup_mandate/off_session payments only if the `is_connector_agnostic_mit_enabled` config is enabled. During the MITs, we refer to this flag to decide whether to use the `connector_mandate_id` or the `network_transaction_id` for the MIT.

Instead of using the flag for multiple purposes, it should be used solely to determine whether to use the `connector_mandate_id` or the `network_transaction_id` for the MIT. Therefore, this change will ensure that the `network_transaction_id` is always stored for off-session payments if it is present in the connector response.

### 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).
-->
Instead of using the `is_connector_agnostic_mit_enabled` flag for multiple purposes, it should be used solely to determine whether to use the `connector_mandate_id` or the `network_transaction_id` for the MIT. And is the connector is returning the `network_transaction_id` for the `off_session` payment it should always be stored.

## 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 `is_connector_agnostic_mit_enabled` disabled.
#### Initial CIT
-> Make an off_session payment. Even though the `is_connector_agnostic_mit_enabled` is false `network_transaction_id` should be stored in the payment methods table.
```
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_1737523971",
    "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_WdSrWb2Xf2kDegvEULPM",
    "merchant_id": "merchant_1737523864",
    "status": "succeeded",
    "amount": 500,
    "net_amount": 500,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 500,
    "connector": "stripe",
    "client_secret": "pay_WdSrWb2Xf2kDegvEULPM_secret_VpuAJ51okhFJZG8TmQ0c",
    "created": "2025-01-22T05:32:47.192Z",
    "currency": "USD",
    "customer_id": "cu_1737523967",
    "customer": {
        "id": "cu_1737523967",
        "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_1737523967",
        "created_at": 1737523967,
        "expires": 1737527567,
        "secret": "epk_e06fef83ccd64ff8b38d5c9955b09a25"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi_3QjwYWEOqOywnAIx0lOiWYTn",
    "frm_message": null,
    "metadata": {},
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3QjwYWEOqOywnAIx0lOiWYTn",
    "payment_link": null,
    "profile_id": "pro_L5I6p61FJYPyguLsk4W7",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_OrorUGWr12wrEyKfTPBT",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-22T05:47:47.192Z",
    "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_MtvoUeVqyzRigXnRA3B8",
    "payment_method_status": "active",
    "updated": "2025-01-22T05:32:49.202Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "pm_1QjwYWEOqOywnAIx6kk4d3Cf"
}
```
-> Db screenshot shown `network_transaction_id` being stored in the payment methods table.
<img width="1259" alt="image" src="https://github.com/user-attachments/assets/a108e721-41ce-46e5-a0dc-0a327a812742" />

#### Recurring MIT
-> 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_1737523967"
}'
```
```
{
    "payment_id": "pay_i04r0cC5OTVNrNBbWHLk",
    "merchant_id": "merchant_1737523864",
    "status": "requires_payment_method",
    "amount": 10000,
    "net_amount": 10000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": null,
    "client_secret": "pay_i04r0cC5OTVNrNBbWHLk_secret_WsYRWkHY7vxbD2AOt1tL",
    "created": "2025-01-22T05:37:20.683Z",
    "currency": "USD",
    "customer_id": "cu_1737523967",
    "customer": {
        "id": "cu_1737523967",
        "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_1737523967",
        "created_at": 1737524240,
        "expires": 1737527840,
        "secret": "epk_5036d7ff60ff4b76a31e2a12bf758273"
    },
    "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_L5I6p61FJYPyguLsk4W7",
    "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-22T05:52:20.683Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-22T05:37:20.704Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```
-> List payment methods using the above client_secret
```
curl --location 'http://localhost:8080/customers/payment_methods?client_secret=pay_i04r0cC5OTVNrNBbWHLk_secret_WsYRWkHY7vxbD2AOt1tL' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_2075ddba1e634912bd68c04d912b9da4'
```
```
{
    "customer_payment_methods": [
        {
            "payment_token": "token_4LrYcGKdvscFoqp6OzWZ",
            "payment_method_id": "pm_MtvoUeVqyzRigXnRA3B8",
            "customer_id": "cu_1737523967",
            "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-22T05:32:49.170Z",
            "bank": null,
            "surcharge_details": null,
            "requires_cvv": true,
            "last_used_at": "2025-01-22T05:32:49.170Z",
            "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. Even though `network_transaction_id` is present, as the `is_connector_agnostic_mit_enabled` is false the MIT should be processed by using `connector_mandate_id`.
```
curl --location 'http://localhost:8080/payments/pay_i04r0cC5OTVNrNBbWHLk/confirm' \
--header 'api-key: pk_dev_2075ddba1e634912bd68c04d912b9da4' \
--header 'Content-Type: application/json' \
--data-raw '{
    "payment_token": "token_4LrYcGKdvscFoqp6OzWZ",
    "payment_method_type": "credit",
    "payment_method": "card",
    "setup_future_usage": "off_session",
    "client_secret": "pay_i04r0cC5OTVNrNBbWHLk_secret_WsYRWkHY7vxbD2AOt1tL",
    
    "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_i04r0cC5OTVNrNBbWHLk",
    "merchant_id": "merchant_1737523864",
    "status": "succeeded",
    "amount": 10000,
    "net_amount": 10000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 10000,
    "connector": "stripe",
    "client_secret": "pay_i04r0cC5OTVNrNBbWHLk_secret_WsYRWkHY7vxbD2AOt1tL",
    "created": "2025-01-22T05:37:20.683Z",
    "currency": "USD",
    "customer_id": "cu_1737523967",
    "customer": {
        "id": "cu_1737523967",
        "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_4LrYcGKdvscFoqp6OzWZ",
    "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_3QjwfBEOqOywnAIx0lXPFXLq",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3QjwfBEOqOywnAIx0lXPFXLq",
    "payment_link": null,
    "profile_id": "pro_L5I6p61FJYPyguLsk4W7",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_OrorUGWr12wrEyKfTPBT",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-22T05:52:20.683Z",
    "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_MtvoUeVqyzRigXnRA3B8",
    "payment_method_status": "active",
    "updated": "2025-01-22T05:39:42.150Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "pm_1QjwYWEOqOywnAIx6kk4d3Cf"
}
```
-> Logs showing `connector_mandate_id` is used for the MIT
<img width="1426" alt="image" src="https://github.com/user-attachments/assets/7ec05d70-a8a7-416f-9792-f875c0c689eb" />

#### Recurring MIT by passing different connector in the routing.
-> Create a `network_transaction_id` support connector (stripe, adyen or cybersource)
-> Create a payment for the same customer
```
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_1737523967"
}'
```
```
{
    "payment_id": "pay_Bi0rNupobukz2roRumXE",
    "merchant_id": "merchant_1737523864",
    "status": "requires_payment_method",
    "amount": 10000,
    "net_amount": 10000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": null,
    "client_secret": "pay_Bi0rNupobukz2roRumXE_secret_5p8bU6yvNJeims5isKKM",
    "created": "2025-01-22T05:43:24.656Z",
    "currency": "USD",
    "customer_id": "cu_1737523967",
    "customer": {
        "id": "cu_1737523967",
        "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_1737523967",
        "created_at": 1737524604,
        "expires": 1737528204,
        "secret": "epk_b8b07628bfa247d395517dbdc54c26b1"
    },
    "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_L5I6p61FJYPyguLsk4W7",
    "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-22T05:58:24.656Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-22T05:43:24.666Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```
-> List payment methods using the above client_secret
```
curl --location 'http://localhost:8080/customers/payment_methods?client_secret=pay_Bi0rNupobukz2roRumXE_secret_5p8bU6yvNJeims5isKKM' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_2075ddba1e634912bd68c04d912b9da4'
```
```
{
    "customer_payment_methods": [
        {
            "payment_token": "token_1nBgsEHUEWZbafeYF91S",
            "payment_method_id": "pm_MtvoUeVqyzRigXnRA3B8",
            "customer_id": "cu_1737523967",
            "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-22T05:32:49.170Z",
            "bank": null,
            "surcharge_details": null,
            "requires_cvv": true,
            "last_used_at": "2025-01-22T05:39:42.140Z",
            "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 by pass the newly configured connector (the connector that was not used in the initially CIT). Even though cybersource was sent in the routing input, the payment was processed with stripe as the `is_connector_agnostic_mit_enabled` is false and `connector_mandate_id` that is present is of stripe.

```
curl --location 'http://localhost:8080/payments/pay_Bi0rNupobukz2roRumXE/confirm' \
--header 'api-key: pk_dev_2075ddba1e634912bd68c04d912b9da4' \
--header 'Content-Type: application/json' \
--data-raw '{
    "payment_token": "token_1nBgsEHUEWZbafeYF91S",
    "payment_method_type": "credit",
    "payment_method": "card",
    "setup_future_usage": "off_session",
    "client_secret": "pay_Bi0rNupobukz2roRumXE_secret_5p8bU6yvNJeims5isKKM",
    "routing": {
        "type": "single",
        "data": {
            "connector": "cybersource",
            "merchant_connector_id": "mca_Z8Jdk0UIzjgZHVlOHjuX"
        }
    },
    "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_Bi0rNupobukz2roRumXE",
    "merchant_id": "merchant_1737523864",
    "status": "succeeded",
    "amount": 10000,
    "net_amount": 10000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 10000,
    "connector": "stripe",
    "client_secret": "pay_Bi0rNupobukz2roRumXE_secret_5p8bU6yvNJeims5isKKM",
    "created": "2025-01-22T05:43:24.656Z",
    "currency": "USD",
    "customer_id": "cu_1737523967",
    "customer": {
        "id": "cu_1737523967",
        "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_1nBgsEHUEWZbafeYF91S",
    "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_3QjwjAEOqOywnAIx1JaY1wKs",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3QjwjAEOqOywnAIx1JaY1wKs",
    "payment_link": null,
    "profile_id": "pro_L5I6p61FJYPyguLsk4W7",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_OrorUGWr12wrEyKfTPBT",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-22T05:58:24.656Z",
    "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_MtvoUeVqyzRigXnRA3B8",
    "payment_method_status": "active",
    "updated": "2025-01-22T05:43:49.519Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "pm_1QjwYWEOqOywnAIx6kk4d3Cf"
}
```
-> Log showing routing order is `[Cybersource, Stripe]` and `connector_mandate_id` was used to process the MIT
<img width="1427" alt="image" src="https://github.com/user-attachments/assets/e4fdde89-891c-4c15-83fd-d428e029bb29" />

NTID cypress test for stripe
<img width="1436" alt="image" src="https://github.com/user-attachments/assets/30ada514-d65a-4302-9c79-df0426e48622" />
<img width="816" alt="image" src="https://github.com/user-attachments/assets/ed17de24-643c-44d7-b6de-6e2ae6e09ed0" />

NTID cypress test for cybersource
<img width="1436" alt="image" src="https://github.com/user-attachments/assets/f36d444a-8123-4577-a0e8-df9dc7762c89" />
<img width="816" alt="image" src="https://github.com/user-attachments/assets/51568fcd-ccb3-424d-b11f-9d4db468bb39" />


## 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


-> Create a business profile and `is_connector_agnostic_mit_enabled` disabled.
#### Initial CIT
-> Make an off_session payment. Even though the `is_connector_agnostic_mit_enabled` is false `network_transaction_id` should be stored in the payment methods table.
```
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_1737523971",
    "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_WdSrWb2Xf2kDegvEULPM",
    "merchant_id": "merchant_1737523864",
    "status": "succeeded",
    "amount": 500,
    "net_amount": 500,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 500,
    "connector": "stripe",
    "client_secret": "pay_WdSrWb2Xf2kDegvEULPM_secret_VpuAJ51okhFJZG8TmQ0c",
    "created": "2025-01-22T05:32:47.192Z",
    "currency": "USD",
    "customer_id": "cu_1737523967",
    "customer": {
        "id": "cu_1737523967",
        "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_1737523967",
        "created_at": 1737523967,
        "expires": 1737527567,
        "secret": "epk_e06fef83ccd64ff8b38d5c9955b09a25"
    },
    "manual_retry_allowed": false,
    "connector_transaction_id": "pi_3QjwYWEOqOywnAIx0lOiWYTn",
    "frm_message": null,
    "metadata": {},
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3QjwYWEOqOywnAIx0lOiWYTn",
    "payment_link": null,
    "profile_id": "pro_L5I6p61FJYPyguLsk4W7",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_OrorUGWr12wrEyKfTPBT",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-22T05:47:47.192Z",
    "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_MtvoUeVqyzRigXnRA3B8",
    "payment_method_status": "active",
    "updated": "2025-01-22T05:32:49.202Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "pm_1QjwYWEOqOywnAIx6kk4d3Cf"
}
```
-> Db screenshot shown `network_transaction_id` being stored in the payment methods table.
<img width="1259" alt="image" src="https://github.com/user-attachments/assets/a108e721-41ce-46e5-a0dc-0a327a812742" />

#### Recurring MIT
-> 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_1737523967"
}'
```
```
{
    "payment_id": "pay_i04r0cC5OTVNrNBbWHLk",
    "merchant_id": "merchant_1737523864",
    "status": "requires_payment_method",
    "amount": 10000,
    "net_amount": 10000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": null,
    "client_secret": "pay_i04r0cC5OTVNrNBbWHLk_secret_WsYRWkHY7vxbD2AOt1tL",
    "created": "2025-01-22T05:37:20.683Z",
    "currency": "USD",
    "customer_id": "cu_1737523967",
    "customer": {
        "id": "cu_1737523967",
        "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_1737523967",
        "created_at": 1737524240,
        "expires": 1737527840,
        "secret": "epk_5036d7ff60ff4b76a31e2a12bf758273"
    },
    "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_L5I6p61FJYPyguLsk4W7",
    "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-22T05:52:20.683Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-22T05:37:20.704Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```
-> List payment methods using the above client_secret
```
curl --location 'http://localhost:8080/customers/payment_methods?client_secret=pay_i04r0cC5OTVNrNBbWHLk_secret_WsYRWkHY7vxbD2AOt1tL' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_2075ddba1e634912bd68c04d912b9da4'
```
```
{
    "customer_payment_methods": [
        {
            "payment_token": "token_4LrYcGKdvscFoqp6OzWZ",
            "payment_method_id": "pm_MtvoUeVqyzRigXnRA3B8",
            "customer_id": "cu_1737523967",
            "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-22T05:32:49.170Z",
            "bank": null,
            "surcharge_details": null,
            "requires_cvv": true,
            "last_used_at": "2025-01-22T05:32:49.170Z",
            "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. Even though `network_transaction_id` is present, as the `is_connector_agnostic_mit_enabled` is false the MIT should be processed by using `connector_mandate_id`.
```
curl --location 'http://localhost:8080/payments/pay_i04r0cC5OTVNrNBbWHLk/confirm' \
--header 'api-key: pk_dev_2075ddba1e634912bd68c04d912b9da4' \
--header 'Content-Type: application/json' \
--data-raw '{
    "payment_token": "token_4LrYcGKdvscFoqp6OzWZ",
    "payment_method_type": "credit",
    "payment_method": "card",
    "setup_future_usage": "off_session",
    "client_secret": "pay_i04r0cC5OTVNrNBbWHLk_secret_WsYRWkHY7vxbD2AOt1tL",
    
    "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_i04r0cC5OTVNrNBbWHLk",
    "merchant_id": "merchant_1737523864",
    "status": "succeeded",
    "amount": 10000,
    "net_amount": 10000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 10000,
    "connector": "stripe",
    "client_secret": "pay_i04r0cC5OTVNrNBbWHLk_secret_WsYRWkHY7vxbD2AOt1tL",
    "created": "2025-01-22T05:37:20.683Z",
    "currency": "USD",
    "customer_id": "cu_1737523967",
    "customer": {
        "id": "cu_1737523967",
        "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_4LrYcGKdvscFoqp6OzWZ",
    "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_3QjwfBEOqOywnAIx0lXPFXLq",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3QjwfBEOqOywnAIx0lXPFXLq",
    "payment_link": null,
    "profile_id": "pro_L5I6p61FJYPyguLsk4W7",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_OrorUGWr12wrEyKfTPBT",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-22T05:52:20.683Z",
    "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_MtvoUeVqyzRigXnRA3B8",
    "payment_method_status": "active",
    "updated": "2025-01-22T05:39:42.150Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "pm_1QjwYWEOqOywnAIx6kk4d3Cf"
}
```
-> Logs showing `connector_mandate_id` is used for the MIT
<img width="1426" alt="image" src="https://github.com/user-attachments/assets/7ec05d70-a8a7-416f-9792-f875c0c689eb" />

#### Recurring MIT by passing different connector in the routing.
-> Create a `network_transaction_id` support connector (stripe, adyen or cybersource)
-> Create a payment for the same customer
```
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_1737523967"
}'
```
```
{
    "payment_id": "pay_Bi0rNupobukz2roRumXE",
    "merchant_id": "merchant_1737523864",
    "status": "requires_payment_method",
    "amount": 10000,
    "net_amount": 10000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": null,
    "connector": null,
    "client_secret": "pay_Bi0rNupobukz2roRumXE_secret_5p8bU6yvNJeims5isKKM",
    "created": "2025-01-22T05:43:24.656Z",
    "currency": "USD",
    "customer_id": "cu_1737523967",
    "customer": {
        "id": "cu_1737523967",
        "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_1737523967",
        "created_at": 1737524604,
        "expires": 1737528204,
        "secret": "epk_b8b07628bfa247d395517dbdc54c26b1"
    },
    "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_L5I6p61FJYPyguLsk4W7",
    "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-22T05:58:24.656Z",
    "fingerprint": null,
    "browser_info": null,
    "payment_method_id": null,
    "payment_method_status": null,
    "updated": "2025-01-22T05:43:24.666Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": null
}
```
-> List payment methods using the above client_secret
```
curl --location 'http://localhost:8080/customers/payment_methods?client_secret=pay_Bi0rNupobukz2roRumXE_secret_5p8bU6yvNJeims5isKKM' \
--header 'Accept: application/json' \
--header 'api-key: pk_dev_2075ddba1e634912bd68c04d912b9da4'
```
```
{
    "customer_payment_methods": [
        {
            "payment_token": "token_1nBgsEHUEWZbafeYF91S",
            "payment_method_id": "pm_MtvoUeVqyzRigXnRA3B8",
            "customer_id": "cu_1737523967",
            "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-22T05:32:49.170Z",
            "bank": null,
            "surcharge_details": null,
            "requires_cvv": true,
            "last_used_at": "2025-01-22T05:39:42.140Z",
            "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 by pass the newly configured connector (the connector that was not used in the initially CIT). Even though cybersource was sent in the routing input, the payment was processed with stripe as the `is_connector_agnostic_mit_enabled` is false and `connector_mandate_id` that is present is of stripe.

```
curl --location 'http://localhost:8080/payments/pay_Bi0rNupobukz2roRumXE/confirm' \
--header 'api-key: pk_dev_2075ddba1e634912bd68c04d912b9da4' \
--header 'Content-Type: application/json' \
--data-raw '{
    "payment_token": "token_1nBgsEHUEWZbafeYF91S",
    "payment_method_type": "credit",
    "payment_method": "card",
    "setup_future_usage": "off_session",
    "client_secret": "pay_Bi0rNupobukz2roRumXE_secret_5p8bU6yvNJeims5isKKM",
    "routing": {
        "type": "single",
        "data": {
            "connector": "cybersource",
            "merchant_connector_id": "mca_Z8Jdk0UIzjgZHVlOHjuX"
        }
    },
    "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_Bi0rNupobukz2roRumXE",
    "merchant_id": "merchant_1737523864",
    "status": "succeeded",
    "amount": 10000,
    "net_amount": 10000,
    "shipping_cost": null,
    "amount_capturable": 0,
    "amount_received": 10000,
    "connector": "stripe",
    "client_secret": "pay_Bi0rNupobukz2roRumXE_secret_5p8bU6yvNJeims5isKKM",
    "created": "2025-01-22T05:43:24.656Z",
    "currency": "USD",
    "customer_id": "cu_1737523967",
    "customer": {
        "id": "cu_1737523967",
        "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_1nBgsEHUEWZbafeYF91S",
    "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_3QjwjAEOqOywnAIx1JaY1wKs",
    "frm_message": null,
    "metadata": null,
    "connector_metadata": null,
    "feature_metadata": null,
    "reference_id": "pi_3QjwjAEOqOywnAIx1JaY1wKs",
    "payment_link": null,
    "profile_id": "pro_L5I6p61FJYPyguLsk4W7",
    "surcharge_details": null,
    "attempt_count": 1,
    "merchant_decision": null,
    "merchant_connector_id": "mca_OrorUGWr12wrEyKfTPBT",
    "incremental_authorization_allowed": null,
    "authorization_count": null,
    "incremental_authorizations": null,
    "external_authentication_details": null,
    "external_3ds_authentication_attempted": false,
    "expires_on": "2025-01-22T05:58:24.656Z",
    "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_MtvoUeVqyzRigXnRA3B8",
    "payment_method_status": "active",
    "updated": "2025-01-22T05:43:49.519Z",
    "split_payments": null,
    "frm_metadata": null,
    "merchant_order_reference_id": null,
    "order_tax_amount": null,
    "connector_mandate_id": "pm_1QjwYWEOqOywnAIx6kk4d3Cf"
}
```
-> Log showing routing order is `[Cybersource, Stripe]` and `connector_mandate_id` was used to process the MIT
<img width="1427" alt="image" src="https://github.com/user-attachments/assets/e4fdde89-891c-4c15-83fd-d428e029bb29" />

NTID cypress test for stripe
<img width="1436" alt="image" src="https://github.com/user-attachments/assets/30ada514-d65a-4302-9c79-df0426e48622" />
<img width="816" alt="image" src="https://github.com/user-attachments/assets/ed17de24-643c-44d7-b6de-6e2ae6e09ed0" />

NTID cypress test for cybersource
<img width="1436" alt="image" src="https://github.com/user-attachments/assets/f36d444a-8123-4577-a0e8-df9dc7762c89" />
<img width="816" alt="image" src="https://github.com/user-attachments/assets/51568fcd-ccb3-424d-b11f-9d4db468bb39" />
