Bug: Creating a domain config (ENV) - `nrid_supported_connectors`



Create a application level config (`nrid_supported_connectors`) that contains the list of connectors that supports pg agnostic MITs,
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index 77040f79a4a..67dfddd0d55 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -129,6 +129,9 @@ bank_redirect.giropay.connector_list = "adyen,globalpay"
 card.credit ={connector_list ="cybersource"}
 card.debit = {connector_list ="cybersource"}
 
+[network_transaction_id_supported_connectors]
+connector_list = "stripe,adyen,cybersource"
+
 [multiple_api_version_supported_connectors]
 supported_connectors = "braintree"
 
diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml
index 8ae12dc54a6..03dc7825222 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -128,6 +128,9 @@ bank_redirect.giropay.connector_list = "adyen,globalpay"
 card.credit = { connector_list = "cybersource" }
 card.debit = { connector_list = "cybersource" }
 
+[network_transaction_id_supported_connectors]
+connector_list = "stripe,adyen,cybersource"
+
 [multiple_api_version_supported_connectors]
 supported_connectors = "braintree"
 
diff --git a/config/development.toml b/config/development.toml
index 8ba5c076071..5cdd5f0b9bf 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -511,6 +511,9 @@ bank_redirect.giropay = { connector_list = "adyen,globalpay" }
 card.credit = { connector_list = "cybersource" }
 card.debit = { connector_list = "cybersource" }
 
+[network_transaction_id_supported_connectors]
+connector_list = "stripe,adyen,cybersource"
+
 [connector_request_reference_id_config]
 merchant_ids_send_payment_id_as_connector_request_id = []
 
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index eb32b47e3b4..1077bf34c02 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -381,6 +381,9 @@ bank_redirect.giropay = { connector_list = "adyen,globalpay" }
 card.credit = { connector_list = "cybersource" }
 card.debit = { connector_list = "cybersource" }
 
+[network_transaction_id_supported_connectors]
+connector_list = "stripe,adyen,cybersource"
+
 [connector_customer]
 connector_list = "gocardless,stax,stripe"
 payout_connector_list = "wise"
diff --git a/crates/diesel_models/src/payment_method.rs b/crates/diesel_models/src/payment_method.rs
index ef153c23a7b..681a57bda87 100644
--- a/crates/diesel_models/src/payment_method.rs
+++ b/crates/diesel_models/src/payment_method.rs
@@ -38,6 +38,7 @@ pub struct PaymentMethod {
     pub connector_mandate_details: Option<serde_json::Value>,
     pub customer_acceptance: Option<pii::SecretSerdeValue>,
     pub status: storage_enums::PaymentMethodStatus,
+    pub network_transaction_id: Option<String>,
 }
 
 #[derive(Clone, Debug, Eq, PartialEq, Insertable, router_derive::DebugAsDisplay)]
@@ -69,6 +70,7 @@ pub struct PaymentMethodNew {
     pub connector_mandate_details: Option<serde_json::Value>,
     pub customer_acceptance: Option<pii::SecretSerdeValue>,
     pub status: storage_enums::PaymentMethodStatus,
+    pub network_transaction_id: Option<String>,
 }
 
 impl Default for PaymentMethodNew {
@@ -102,6 +104,7 @@ impl Default for PaymentMethodNew {
             connector_mandate_details: Option::default(),
             customer_acceptance: Option::default(),
             status: storage_enums::PaymentMethodStatus::Active,
+            network_transaction_id: Option::default(),
         }
     }
 }
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index 8e8bf48a538..ad30609a770 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -913,6 +913,8 @@ diesel::table! {
         customer_acceptance -> Nullable<Jsonb>,
         #[max_length = 64]
         status -> Varchar,
+        #[max_length = 255]
+        network_transaction_id -> Nullable<Varchar>,
     }
 }
 
diff --git a/crates/router/src/configs/secrets_transformers.rs b/crates/router/src/configs/secrets_transformers.rs
index 6906b5a3e7a..537f6666c5d 100644
--- a/crates/router/src/configs/secrets_transformers.rs
+++ b/crates/router/src/configs/secrets_transformers.rs
@@ -335,6 +335,8 @@ pub(crate) async fn fetch_raw_secrets(
         #[cfg(feature = "email")]
         email: conf.email,
         mandates: conf.mandates,
+        network_transaction_id_supported_connectors: conf
+            .network_transaction_id_supported_connectors,
         required_fields: conf.required_fields,
         delayed_session_response: conf.delayed_session_response,
         webhook_source_verification_call: conf.webhook_source_verification_call,
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index d92812cee40..a0dce991295 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -91,6 +91,7 @@ pub struct Settings<S: SecretState> {
     pub email: EmailSettings,
     pub cors: CorsSettings,
     pub mandates: Mandates,
+    pub network_transaction_id_supported_connectors: NetworkTransactionIdSupportedConnectors,
     pub required_fields: RequiredFields,
     pub delayed_session_response: DelayedSessionConfig,
     pub webhook_source_verification_call: WebhookSourceVerificationCall,
@@ -251,6 +252,12 @@ pub struct Mandates {
     pub update_mandate_supported: SupportedPaymentMethodsForMandate,
 }
 
+#[derive(Debug, Deserialize, Clone, Default)]
+pub struct NetworkTransactionIdSupportedConnectors {
+    #[serde(deserialize_with = "deserialize_hashset")]
+    pub connector_list: HashSet<api_models::enums::Connector>,
+}
+
 #[derive(Debug, Deserialize, Clone)]
 pub struct SupportedPaymentMethodsForMandate(
     pub HashMap<enums::PaymentMethod, SupportedPaymentMethodTypesForMandate>,
diff --git a/crates/router/src/db/payment_method.rs b/crates/router/src/db/payment_method.rs
index 14f650127dd..188eeeddc10 100644
--- a/crates/router/src/db/payment_method.rs
+++ b/crates/router/src/db/payment_method.rs
@@ -275,6 +275,7 @@ impl PaymentMethodInterface for MockDb {
             connector_mandate_details: payment_method_new.connector_mandate_details,
             customer_acceptance: payment_method_new.customer_acceptance,
             status: payment_method_new.status,
+            network_transaction_id: payment_method_new.network_transaction_id,
         };
         payment_methods.push(payment_method.clone());
         Ok(payment_method)
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index 72eb6f25559..a2d2648133b 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -277,6 +277,9 @@ wildcard_origin = false
 card.credit ={connector_list ="cybersource"}
 card.debit = {connector_list ="cybersource"}
 
+[network_transaction_id_supported_connectors]
+connector_list = "stripe,adyen,cybersource"
+
 [analytics]
 source = "sqlx"
 
diff --git a/migrations/2024-03-07-102620_add-network-transaction-id/down.sql b/migrations/2024-03-07-102620_add-network-transaction-id/down.sql
new file mode 100644
index 00000000000..4cf99815a9b
--- /dev/null
+++ b/migrations/2024-03-07-102620_add-network-transaction-id/down.sql
@@ -0,0 +1,3 @@
+-- This file should undo anything in `up.sql`
+
+ALTER TABLE payment_methods DROP COLUMN network_transaction_id;
\ No newline at end of file
diff --git a/migrations/2024-03-07-102620_add-network-transaction-id/up.sql b/migrations/2024-03-07-102620_add-network-transaction-id/up.sql
new file mode 100644
index 00000000000..06b199e6390
--- /dev/null
+++ b/migrations/2024-03-07-102620_add-network-transaction-id/up.sql
@@ -0,0 +1,3 @@
+-- Your SQL goes here
+
+ALTER TABLE payment_methods ADD COLUMN network_transaction_id VARCHAR(255) DEFAULT NULL;
\ No newline at end of file

## 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 -->
Add `network_transaction_id` column in the `payment_methods` table as it is required to store the NRID against the respective payment_method_id. This NRID will later be used processor agnostic MITs. This pr also adds application level config (`network_transactoin_id_supported_connectors`) that contains the list of connectors that support the `network_transaction_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).
-->


## 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)?
-->
columns in the `payment_methods` table 
![image](https://github.com/juspay/hyperswitch/assets/83439957/ee1f3540-7c55-4484-b841-9c85696a1a59)


## 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
- [ ] I added a [CHANGELOG](/CHANGELOG.md) entry if applicable
