Issue:
Bug: [FEATURE]: Add support for merchant order reference id



### Feature Description

Add support for merchant order reference id

### Possible Implementation

Add support for merchant order reference id

### Have you spent some time checking if this feature request has been raised before?

- [X] I checked and didn't find a similar issue

### Have you read the Contributing Guidelines?

- [X] I have read the [Contributing Guidelines](https://github.com/juspay/hyperswitch/blob/main/docs/CONTRIBUTING.md)

### Are you willing to submit a PR?

Yes, I am willing to submit a PR!

Pull request description:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [x] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
Add support for accepting `merchant_order_reference_id` and subsequently pass it to the connector if connector supports accepting multiple reference.
This is being added for merchant to locate the payment using their id in the connector dashboard

### Additional Changes

- [X] This PR modifies the API contract
- [X] 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).
-->
#5198 

## 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)?
-->
### Do Payments Create and Update the `merchant_order_reference_id`, check this in DB
```
curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_JBNIuXN6ZUGXy4t5xk3btwzLBSxNJTfZHL6sYilDuqYUgMZulcithuwgj0UAYwCc' \
--data-raw '{
    "amount": 6100,
    "currency": "USD",
    "confirm": false,
    "business_country": "US",
    "business_label": "default",
    "amount_to_capture": 6100,
    
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    
    "return_url": "https://google.com",
    "email": "something@gmail.com",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "payment_method": "wallet",
    "payment_method_type": "paypal",
    "payment_method_data": {
        "wallet": {
            "paypal_redirect": {}
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "merchant_order_reference_id": "cust_order_id"
}'
```

```
curl --location 'http://localhost:8080/payments/pay_BCFeb1tpuJWad7PElBM1' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_JBNIuXN6ZUGXy4t5xk3btwzLBSxNJTfZHL6sYilDuqYUgMZulcithuwgj0UAYwCc' \
--data '{
  "amount": 6540,
  "confirm" :false,
  "amount_to_capture": 6540,
    "payment_method": "wallet",
    "payment_method_type": "paypal",
    "payment_method_data": {
        "wallet": {
            "paypal_redirect": {}
        }
    }
    ,
"merchant_order_reference_id": "true"
}'
```

### Create Paypal Payment

```
curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_JBNIuXN6ZUGXy4t5xk3btwzLBSxNJTfZHL6sYilDuqYUgMZulcithuwgj0UAYwCc' \
--data-raw '{
    "amount": 6100,
    "currency": "USD",
    "confirm": true,
    "business_country": "US",
    "business_label": "default",
    "amount_to_capture": 6100,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "return_url": "https://google.com",
    "email": "something@gmail.com",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "payment_method": "wallet",
    "payment_method_type": "paypal",
    "payment_method_data": {
        "wallet": {
            "paypal_redirect": {}
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "merchant_order_reference_id": "cust_order_id"
}' 
```
<img width="1441" alt="Screenshot 2024-07-04 at 2 57 04 PM" src="https://github.com/juspay/hyperswitch/assets/55536657/5213f556-a1c4-4d68-981f-5f2b559daca9">

### Create Adyen Payment
```
curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'api-key: dev_tRtH96ICztwLahErT89hnUwUjGNvNUSA6zZqpedyIruXledDUHfp5o0yQLRNCPB8' \
--header 'x-feature: router-custom' \
--header 'Content-Type: application/json' \
--data-raw '{
	"amount": 1337,
	"currency": "USD",
	"confirm": true,
	"capture_method": "manual",
	"capture_on": "2022-09-10T10:11:12Z",
	"amount_to_capture": 1337,
	"customer_id": "customerg12",
	"email": "customer@email.se",
	"name": "John Doe",
	"phone": "999999999",
	"phone_country_code": "+1",
	"description": "Its my first payment request",
	"authentication_type": "no_three_ds",
	"return_url": "https://duck.com",
	"payment_method": "card",
	"payment_method_type": "credit",
	"payment_method_data": {
		"card": {
			"card_number": "4111111145551142",
			"card_exp_month": "03",
			"card_exp_year": "2030",
			"card_holder_name": "joseph Doe",
			"card_cvc": "737"
		}
	},
	"billing": {
		"address": {
			"line1": "1",
			"line2": "Stargatan",
			
			"city": "Stockholm",
			
			"zip": "11 148",
			"country": "SE",
			"first_name": "Alice",
			"last_name": "Test"
		}
	},
	"shipping": {
		"address": {
			"line1": "1467",
			"line2": "Harrison Street",
			"line3": "Harrison Street",
			"city": "San Fransico",
			"state": "California",
			"zip": "94122",
			"country": "US",
			"first_name": "joseph",
			"last_name": "Doe"
		},
		"phone": {
			"number": "8056594427",
			"country_code": "+91"
		}
	},
    "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": "127.0.0.1"
    },
	"statement_descriptor_name": "joseph",
	"statement_descriptor_suffix": "JS",
    "metadata": {
        "test": "ket"
    },
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 10,
            "account_name": "transaction_processing"
        }
    ],
    "merchant_order_reference_id": "cust_order_adyen"
}'
```
<img width="593" alt="Screenshot 2024-07-04 at 3 08 44 PM" src="https://github.com/juspay/hyperswitch/assets/55536657/59036dcd-08bc-4618-a0c7-f666367a1a34">

### Create klarna Payment
```
Add merchant_order_reference_id in the request field from SDK
```
![image](https://github.com/juspay/hyperswitch/assets/55536657/6cc800b4-3c8a-4ed4-b6d7-6e156b485664)

### Test webhooks for Adyen and Paypal


## 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


Testing:

### Do Payments Create and Update the `merchant_order_reference_id`, check this in DB
```
curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_JBNIuXN6ZUGXy4t5xk3btwzLBSxNJTfZHL6sYilDuqYUgMZulcithuwgj0UAYwCc' \
--data-raw '{
    "amount": 6100,
    "currency": "USD",
    "confirm": false,
    "business_country": "US",
    "business_label": "default",
    "amount_to_capture": 6100,
    
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    
    "return_url": "https://google.com",
    "email": "something@gmail.com",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "payment_method": "wallet",
    "payment_method_type": "paypal",
    "payment_method_data": {
        "wallet": {
            "paypal_redirect": {}
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "merchant_order_reference_id": "cust_order_id"
}'
```

```
curl --location 'http://localhost:8080/payments/pay_BCFeb1tpuJWad7PElBM1' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: dev_JBNIuXN6ZUGXy4t5xk3btwzLBSxNJTfZHL6sYilDuqYUgMZulcithuwgj0UAYwCc' \
--data '{
  "amount": 6540,
  "confirm" :false,
  "amount_to_capture": 6540,
    "payment_method": "wallet",
    "payment_method_type": "paypal",
    "payment_method_data": {
        "wallet": {
            "paypal_redirect": {}
        }
    }
    ,
"merchant_order_reference_id": "true"
}'
```

### Create Paypal Payment

```
curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--header 'api-key: dev_JBNIuXN6ZUGXy4t5xk3btwzLBSxNJTfZHL6sYilDuqYUgMZulcithuwgj0UAYwCc' \
--data-raw '{
    "amount": 6100,
    "currency": "USD",
    "confirm": true,
    "business_country": "US",
    "business_label": "default",
    "amount_to_capture": 6100,
    "capture_method": "automatic",
    "capture_on": "2022-09-10T10:11:12Z",
    "return_url": "https://google.com",
    "email": "something@gmail.com",
    "name": "Joseph Doe",
    "phone": "999999999",
    "phone_country_code": "+65",
    "description": "Its my first payment request",
    "statement_descriptor_name": "Juspay",
    "statement_descriptor_suffix": "Router",
    "payment_method": "wallet",
    "payment_method_type": "paypal",
    "payment_method_data": {
        "wallet": {
            "paypal_redirect": {}
        }
    },
    "billing": {
        "address": {
            "line1": "1467",
            "line2": "Harrison Street",
            "line3": "Harrison Street",
            "city": "San Fransico",
            "state": "California",
            "zip": "94122",
            "country": "US",
            "first_name": "joseph",
            "last_name": "Doe"
        },
        "phone": {
            "number": "8056594427",
            "country_code": "+91"
        }
    },
    "merchant_order_reference_id": "cust_order_id"
}' 
```
<img width="1441" alt="Screenshot 2024-07-04 at 2 57 04 PM" src="https://github.com/juspay/hyperswitch/assets/55536657/5213f556-a1c4-4d68-981f-5f2b559daca9">

### Create Adyen Payment
```
curl --location 'http://localhost:8080/payments' \
--header 'Accept: application/json' \
--header 'api-key: dev_tRtH96ICztwLahErT89hnUwUjGNvNUSA6zZqpedyIruXledDUHfp5o0yQLRNCPB8' \
--header 'x-feature: router-custom' \
--header 'Content-Type: application/json' \
--data-raw '{
	"amount": 1337,
	"currency": "USD",
	"confirm": true,
	"capture_method": "manual",
	"capture_on": "2022-09-10T10:11:12Z",
	"amount_to_capture": 1337,
	"customer_id": "customerg12",
	"email": "customer@email.se",
	"name": "John Doe",
	"phone": "999999999",
	"phone_country_code": "+1",
	"description": "Its my first payment request",
	"authentication_type": "no_three_ds",
	"return_url": "https://duck.com",
	"payment_method": "card",
	"payment_method_type": "credit",
	"payment_method_data": {
		"card": {
			"card_number": "4111111145551142",
			"card_exp_month": "03",
			"card_exp_year": "2030",
			"card_holder_name": "joseph Doe",
			"card_cvc": "737"
		}
	},
	"billing": {
		"address": {
			"line1": "1",
			"line2": "Stargatan",
			
			"city": "Stockholm",
			
			"zip": "11 148",
			"country": "SE",
			"first_name": "Alice",
			"last_name": "Test"
		}
	},
	"shipping": {
		"address": {
			"line1": "1467",
			"line2": "Harrison Street",
			"line3": "Harrison Street",
			"city": "San Fransico",
			"state": "California",
			"zip": "94122",
			"country": "US",
			"first_name": "joseph",
			"last_name": "Doe"
		},
		"phone": {
			"number": "8056594427",
			"country_code": "+91"
		}
	},
    "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": "127.0.0.1"
    },
	"statement_descriptor_name": "joseph",
	"statement_descriptor_suffix": "JS",
    "metadata": {
        "test": "ket"
    },
    "order_details": [
        {
            "product_name": "Apple iphone 15",
            "quantity": 1,
            "amount": 10,
            "account_name": "transaction_processing"
        }
    ],
    "merchant_order_reference_id": "cust_order_adyen"
}'
```
<img width="593" alt="Screenshot 2024-07-04 at 3 08 44 PM" src="https://github.com/juspay/hyperswitch/assets/55536657/59036dcd-08bc-4618-a0c7-f666367a1a34">

### Create klarna Payment
```
Add merchant_order_reference_id in the request field from SDK
```
![image](https://github.com/juspay/hyperswitch/assets/55536657/6cc800b4-3c8a-4ed4-b6d7-6e156b485664)

### Test webhooks for Adyen and Paypal

Patch:
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index d8321524a1e..673a5cdae4f 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -506,6 +506,16 @@ pub struct PaymentsRequest {
 
     /// Fee information to be charged on the payment being collected
     pub charges: Option<PaymentChargeRequest>,
+
+    /// Merchant's identifier for the payment/invoice. This will be sent to the connector
+    /// if the connector provides support to accept multiple reference ids.
+    /// In case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference.
+    #[schema(
+        value_type = Option<String>,
+        max_length = 255,
+        example = "Custom_Order_id_123"
+    )]
+    pub merchant_order_reference_id: Option<String>,
 }
 
 /// Fee information to be charged on the payment being collected
@@ -3623,6 +3633,16 @@ pub struct PaymentsResponse {
     /// You can specify up to 50 keys, with key names up to 40 characters long and values up to 500 characters long. FRM Metadata is useful for storing additional, structured information on an object related to FRM.
     #[schema(value_type = Option<Object>, example = r#"{ "fulfillment_method" : "deliver", "coverage_request" : "fraud" }"#)]
     pub frm_metadata: Option<pii::SecretSerdeValue>,
+
+    /// Merchant's identifier for the payment/invoice. This will be sent to the connector
+    /// if the connector provides support to accept multiple reference ids.
+    /// In case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference.
+    #[schema(
+        value_type = Option<String>,
+        max_length = 255,
+        example = "Custom_Order_id_123"
+    )]
+    pub merchant_order_reference_id: Option<String>,
 }
 
 /// Fee information to be charged on the payment being collected
diff --git a/crates/diesel_models/src/payment_intent.rs b/crates/diesel_models/src/payment_intent.rs
index fa37eecdbfe..bc480c497ea 100644
--- a/crates/diesel_models/src/payment_intent.rs
+++ b/crates/diesel_models/src/payment_intent.rs
@@ -60,6 +60,7 @@ pub struct PaymentIntent {
     pub charges: Option<pii::SecretSerdeValue>,
     pub frm_metadata: Option<pii::SecretSerdeValue>,
     pub customer_details: Option<Encryption>,
+    pub merchant_order_reference_id: Option<String>,
 }
 
 #[derive(
@@ -116,6 +117,7 @@ pub struct PaymentIntentNew {
     pub charges: Option<pii::SecretSerdeValue>,
     pub frm_metadata: Option<pii::SecretSerdeValue>,
     pub customer_details: Option<Encryption>,
+    pub merchant_order_reference_id: Option<String>,
 }
 
 #[derive(Debug, Clone, Serialize, Deserialize)]
@@ -175,6 +177,7 @@ pub enum PaymentIntentUpdate {
         request_external_three_ds_authentication: Option<bool>,
         frm_metadata: Option<pii::SecretSerdeValue>,
         customer_details: Option<Encryption>,
+        merchant_order_reference_id: Option<String>,
     },
     PaymentAttemptAndAttemptCountUpdate {
         active_attempt_id: String,
@@ -251,6 +254,7 @@ pub struct PaymentIntentUpdateInternal {
     pub request_external_three_ds_authentication: Option<bool>,
     pub frm_metadata: Option<pii::SecretSerdeValue>,
     pub customer_details: Option<Encryption>,
+    pub merchant_order_reference_id: Option<String>,
 }
 
 impl PaymentIntentUpdate {
@@ -287,6 +291,7 @@ impl PaymentIntentUpdate {
             request_external_three_ds_authentication,
             frm_metadata,
             customer_details,
+            merchant_order_reference_id,
         } = self.into();
         PaymentIntent {
             amount: amount.unwrap_or(source.amount),
@@ -325,6 +330,8 @@ impl PaymentIntentUpdate {
                 .or(source.request_external_three_ds_authentication),
             frm_metadata: frm_metadata.or(source.frm_metadata),
             customer_details: customer_details.or(source.customer_details),
+            merchant_order_reference_id: merchant_order_reference_id
+                .or(source.merchant_order_reference_id),
             ..source
         }
     }
@@ -356,6 +363,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
                 request_external_three_ds_authentication,
                 frm_metadata,
                 customer_details,
+                merchant_order_reference_id,
             } => Self {
                 amount: Some(amount),
                 currency: Some(currency),
@@ -380,6 +388,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
                 request_external_three_ds_authentication,
                 frm_metadata,
                 customer_details,
+                merchant_order_reference_id,
                 ..Default::default()
             },
             PaymentIntentUpdate::MetadataUpdate {
diff --git a/crates/diesel_models/src/schema.rs b/crates/diesel_models/src/schema.rs
index 98f1b2fbbec..0b00e57a1c8 100644
--- a/crates/diesel_models/src/schema.rs
+++ b/crates/diesel_models/src/schema.rs
@@ -890,6 +890,8 @@ diesel::table! {
         charges -> Nullable<Jsonb>,
         frm_metadata -> Nullable<Jsonb>,
         customer_details -> Nullable<Bytea>,
+        #[max_length = 255]
+        merchant_order_reference_id -> Nullable<Varchar>,
     }
 }
 
diff --git a/crates/hyperswitch_domain_models/src/payments.rs b/crates/hyperswitch_domain_models/src/payments.rs
index f6e4f888790..0c22c70bc36 100644
--- a/crates/hyperswitch_domain_models/src/payments.rs
+++ b/crates/hyperswitch_domain_models/src/payments.rs
@@ -63,4 +63,5 @@ pub struct PaymentIntent {
     pub charges: Option<pii::SecretSerdeValue>,
     pub frm_metadata: Option<pii::SecretSerdeValue>,
     pub customer_details: Option<Encryptable<Secret<serde_json::Value>>>,
+    pub merchant_order_reference_id: Option<String>,
 }
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
index 1dca50e6482..01737076615 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_attempt.rs
@@ -530,6 +530,7 @@ impl behaviour::Conversion for PaymentIntent {
             charges: self.charges,
             frm_metadata: self.frm_metadata,
             customer_details: self.customer_details.map(Encryption::from),
+            merchant_order_reference_id: self.merchant_order_reference_id,
         })
     }
 
@@ -591,6 +592,7 @@ impl behaviour::Conversion for PaymentIntent {
                     .customer_details
                     .async_lift(inner_decrypt)
                     .await?,
+                merchant_order_reference_id: storage_model.merchant_order_reference_id,
             })
         }
         .await
@@ -645,6 +647,7 @@ impl behaviour::Conversion for PaymentIntent {
             charges: self.charges,
             frm_metadata: self.frm_metadata,
             customer_details: self.customer_details.map(Encryption::from),
+            merchant_order_reference_id: self.merchant_order_reference_id,
         })
     }
 }
diff --git a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
index 30fd1061c7f..fb824a80798 100644
--- a/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
+++ b/crates/hyperswitch_domain_models/src/payments/payment_intent.rs
@@ -193,6 +193,7 @@ pub enum PaymentIntentUpdate {
         session_expiry: Option<PrimitiveDateTime>,
         request_external_three_ds_authentication: Option<bool>,
         customer_details: Option<Encryptable<Secret<serde_json::Value>>>,
+        merchant_order_reference_id: Option<String>,
     },
     PaymentAttemptAndAttemptCountUpdate {
         active_attempt_id: String,
@@ -270,6 +271,7 @@ pub struct PaymentIntentUpdateInternal {
     pub request_external_three_ds_authentication: Option<bool>,
     pub frm_metadata: Option<pii::SecretSerdeValue>,
     pub customer_details: Option<Encryptable<Secret<serde_json::Value>>>,
+    pub merchant_order_reference_id: Option<String>,
 }
 
 impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
@@ -298,6 +300,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
                 request_external_three_ds_authentication,
                 frm_metadata,
                 customer_details,
+                merchant_order_reference_id,
             } => Self {
                 amount: Some(amount),
                 currency: Some(currency),
@@ -322,6 +325,7 @@ impl From<PaymentIntentUpdate> for PaymentIntentUpdateInternal {
                 request_external_three_ds_authentication,
                 frm_metadata,
                 customer_details,
+                merchant_order_reference_id,
                 ..Default::default()
             },
             PaymentIntentUpdate::MetadataUpdate {
@@ -562,6 +566,7 @@ impl From<PaymentIntentUpdate> for DieselPaymentIntentUpdate {
                 request_external_three_ds_authentication,
                 frm_metadata,
                 customer_details,
+                merchant_order_reference_id,
             } => Self::Update {
                 amount,
                 currency,
@@ -585,6 +590,7 @@ impl From<PaymentIntentUpdate> for DieselPaymentIntentUpdate {
                 request_external_three_ds_authentication,
                 frm_metadata,
                 customer_details: customer_details.map(Encryption::from),
+                merchant_order_reference_id,
             },
             PaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {
                 active_attempt_id,
@@ -687,6 +693,7 @@ impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInt
             request_external_three_ds_authentication,
             frm_metadata,
             customer_details,
+            merchant_order_reference_id,
         } = value;
 
         Self {
@@ -721,6 +728,7 @@ impl From<PaymentIntentUpdateInternal> for diesel_models::PaymentIntentUpdateInt
             request_external_three_ds_authentication,
             frm_metadata,
             customer_details: customer_details.map(Encryption::from),
+            merchant_order_reference_id,
         }
     }
 }
diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rs
index 8496827ff25..6d7e42eb1ae 100644
--- a/crates/hyperswitch_domain_models/src/router_request_types.rs
+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs
@@ -62,6 +62,11 @@ pub struct PaymentsAuthorizeData {
 
     // New amount for amount frame work
     pub minor_amount: MinorUnit,
+
+    /// Merchant's identifier for the payment/invoice. This will be sent to the connector
+    /// if the connector provides support to accept multiple reference ids.
+    /// In case the connector supports only one reference id, Hyperswitch's Payment ID will be sent as reference.
+    pub merchant_order_reference_id: Option<String>,
     pub integrity_object: Option<AuthoriseIntegrityObject>,
 }
 
diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs
index 9778d6d33a4..9a85522396d 100644
--- a/crates/router/src/connector/adyen/transformers.rs
+++ b/crates/router/src/connector/adyen/transformers.rs
@@ -179,6 +179,7 @@ pub struct AdyenPaymentRequest<'a> {
     line_items: Option<Vec<LineItem>>,
     channel: Option<Channel>,
     metadata: Option<pii::SecretSerdeValue>,
+    merchant_order_reference: Option<String>,
 }
 
 #[derive(Debug, Serialize)]
@@ -2610,6 +2611,7 @@ impl<'a>
             shopper_statement: item.router_data.request.statement_descriptor.clone(),
             shopper_ip: item.router_data.request.get_ip_address_as_optional(),
             metadata: item.router_data.request.metadata.clone(),
+            merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
         })
     }
 }
@@ -2672,6 +2674,7 @@ impl<'a>
             shopper_statement: item.router_data.request.statement_descriptor.clone(),
             shopper_ip: item.router_data.request.get_ip_address_as_optional(),
             metadata: item.router_data.request.metadata.clone(),
+            merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
         })
     }
 }
@@ -2725,6 +2728,7 @@ impl<'a>
             shopper_statement: item.router_data.request.statement_descriptor.clone(),
             shopper_ip: item.router_data.request.get_ip_address_as_optional(),
             metadata: item.router_data.request.metadata.clone(),
+            merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
         };
         Ok(request)
     }
@@ -2779,6 +2783,7 @@ impl<'a>
             shopper_statement: item.router_data.request.statement_descriptor.clone(),
             shopper_ip: item.router_data.request.get_ip_address_as_optional(),
             metadata: item.router_data.request.metadata.clone(),
+            merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
         };
         Ok(request)
     }
@@ -2829,6 +2834,7 @@ impl<'a>
             shopper_statement: item.router_data.request.statement_descriptor.clone(),
             shopper_ip: item.router_data.request.get_ip_address_as_optional(),
             metadata: item.router_data.request.metadata.clone(),
+            merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
         };
         Ok(request)
     }
@@ -2879,6 +2885,7 @@ impl<'a>
             shopper_statement: item.router_data.request.statement_descriptor.clone(),
             shopper_ip: item.router_data.request.get_ip_address_as_optional(),
             metadata: item.router_data.request.metadata.clone(),
+            merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
         };
         Ok(request)
     }
@@ -2939,6 +2946,7 @@ impl<'a>
             shopper_statement: item.router_data.request.statement_descriptor.clone(),
             shopper_ip: item.router_data.request.get_ip_address_as_optional(),
             metadata: item.router_data.request.metadata.clone(),
+            merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
         })
     }
 }
@@ -3034,6 +3042,7 @@ impl<'a>
             shopper_statement: item.router_data.request.statement_descriptor.clone(),
             shopper_ip: item.router_data.request.get_ip_address_as_optional(),
             metadata: item.router_data.request.metadata.clone(),
+            merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
         })
     }
 }
@@ -3109,6 +3118,7 @@ impl<'a>
             shopper_statement: item.router_data.request.statement_descriptor.clone(),
             shopper_ip: item.router_data.request.get_ip_address_as_optional(),
             metadata: item.router_data.request.metadata.clone(),
+            merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
         })
     }
 }
@@ -3167,6 +3177,7 @@ impl<'a>
             shopper_statement: item.router_data.request.statement_descriptor.clone(),
             shopper_ip: item.router_data.request.get_ip_address_as_optional(),
             metadata: item.router_data.request.metadata.clone(),
+            merchant_order_reference: item.router_data.request.merchant_order_reference_id.clone(),
         })
     }
 }
diff --git a/crates/router/src/connector/klarna/transformers.rs b/crates/router/src/connector/klarna/transformers.rs
index ab3463e3671..e6f0bab9c2c 100644
--- a/crates/router/src/connector/klarna/transformers.rs
+++ b/crates/router/src/connector/klarna/transformers.rs
@@ -78,6 +78,7 @@ pub struct KlarnaPaymentsRequest {
     purchase_country: enums::CountryAlpha2,
     purchase_currency: enums::Currency,
     merchant_reference1: Option<String>,
+    merchant_reference2: Option<String>,
     shipping_address: Option<KlarnaShippingAddress>,
 }
 
@@ -213,6 +214,7 @@ impl TryFrom<&KlarnaRouterData<&types::PaymentsAuthorizeRouterData>> for KlarnaP
                     })
                     .collect(),
                 merchant_reference1: Some(item.router_data.connector_request_reference_id.clone()),
+                merchant_reference2: item.router_data.request.merchant_order_reference_id.clone(),
                 auto_capture: request.is_auto_capture()?,
                 shipping_address: get_address_info(item.router_data.get_optional_shipping())
                     .transpose()?,
diff --git a/crates/router/src/connector/paypal/transformers.rs b/crates/router/src/connector/paypal/transformers.rs
index 39ea808d61f..7ec6b1c4af6 100644
--- a/crates/router/src/connector/paypal/transformers.rs
+++ b/crates/router/src/connector/paypal/transformers.rs
@@ -397,7 +397,7 @@ impl TryFrom<&PaypalRouterData<&types::PaymentsAuthorizeRouterData>> for PaypalP
 
         let purchase_units = vec![PurchaseUnitRequest {
             reference_id: Some(connector_request_reference_id.clone()),
-            custom_id: Some(connector_request_reference_id.clone()),
+            custom_id: item.router_data.request.merchant_order_reference_id.clone(),
             invoice_id: Some(connector_request_reference_id),
             amount,
             payee,
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 534da72a1d9..650ac1786ae 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -3133,6 +3133,7 @@ mod tests {
             charges: None,
             frm_metadata: None,
             customer_details: None,
+            merchant_order_reference_id: None,
         };
         let req_cs = Some("1".to_string());
         assert!(authenticate_client_secret(req_cs.as_ref(), &payment_intent).is_ok());
@@ -3193,6 +3194,7 @@ mod tests {
             charges: None,
             frm_metadata: None,
             customer_details: None,
+            merchant_order_reference_id: None,
         };
         let req_cs = Some("1".to_string());
         assert!(authenticate_client_secret(req_cs.as_ref(), &payment_intent,).is_err())
@@ -3252,6 +3254,7 @@ mod tests {
             charges: None,
             frm_metadata: None,
             customer_details: None,
+            merchant_order_reference_id: None,
         };
         let req_cs = Some("1".to_string());
         assert!(authenticate_client_secret(req_cs.as_ref(), &payment_intent).is_err())
diff --git a/crates/router/src/core/payments/operations/payment_confirm.rs b/crates/router/src/core/payments/operations/payment_confirm.rs
index 5e35b918a0f..e140a8e02df 100644
--- a/crates/router/src/core/payments/operations/payment_confirm.rs
+++ b/crates/router/src/core/payments/operations/payment_confirm.rs
@@ -1259,6 +1259,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
                         request_external_three_ds_authentication: None,
                         frm_metadata: m_frm_metadata,
                         customer_details,
+                        merchant_order_reference_id: None,
                     },
                     &m_key_store,
                     storage_scheme,
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index b8045487d9f..2414db55997 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -1116,6 +1116,7 @@ impl PaymentCreate {
             charges,
             frm_metadata: request.frm_metadata.clone(),
             customer_details,
+            merchant_order_reference_id: request.merchant_order_reference_id.clone(),
         })
     }
 
diff --git a/crates/router/src/core/payments/operations/payment_update.rs b/crates/router/src/core/payments/operations/payment_update.rs
index c34a40fd908..ca069c8bf6c 100644
--- a/crates/router/src/core/payments/operations/payment_update.rs
+++ b/crates/router/src/core/payments/operations/payment_update.rs
@@ -371,6 +371,11 @@ impl<F: Send + Clone> GetTracker<F, PaymentData<F>, api::PaymentsRequest> for Pa
             .request_external_three_ds_authentication
             .or(payment_intent.request_external_three_ds_authentication);
 
+        payment_intent.merchant_order_reference_id = request
+            .merchant_order_reference_id
+            .clone()
+            .or(payment_intent.merchant_order_reference_id);
+
         Self::populate_payment_attempt_with_request(&mut payment_attempt, request);
 
         let creds_identifier = request
@@ -706,6 +711,11 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
         let metadata = payment_data.payment_intent.metadata.clone();
         let frm_metadata = payment_data.payment_intent.frm_metadata.clone();
         let session_expiry = payment_data.payment_intent.session_expiry;
+        let merchant_order_reference_id = payment_data
+            .payment_intent
+            .merchant_order_reference_id
+            .clone();
+
         payment_data.payment_intent = state
             .store
             .update_payment_intent(
@@ -735,6 +745,7 @@ impl<F: Clone> UpdateTracker<F, PaymentData<F>, api::PaymentsRequest> for Paymen
                         .request_external_three_ds_authentication,
                     frm_metadata,
                     customer_details,
+                    merchant_order_reference_id,
                 },
                 key_store,
                 storage_scheme,
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index abcb4859710..aaf8e3b3a07 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -880,6 +880,7 @@ where
                 .set_updated(Some(payment_intent.modified_at))
                 .set_charges(charges_response)
                 .set_frm_metadata(payment_intent.frm_metadata)
+                .set_merchant_order_reference_id(payment_intent.merchant_order_reference_id)
                 .to_owned(),
             headers,
         ))
@@ -1305,6 +1306,11 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
             None => None,
         };
 
+        let merchant_order_reference_id = payment_data
+            .payment_intent
+            .merchant_order_reference_id
+            .clone();
+
         Ok(Self {
             payment_method_data: From::from(
                 payment_method_data.get_required_value("payment_method_data")?,
@@ -1350,6 +1356,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsAuthoriz
                 .transpose()?,
             customer_acceptance: payment_data.customer_acceptance,
             charges,
+            merchant_order_reference_id,
             integrity_object: None,
         })
     }
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index e6381e84b15..c457ca59df8 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -789,6 +789,7 @@ impl ForeignFrom<&SetupMandateRouterData> for PaymentsAuthorizeData {
             authentication_data: None,
             customer_acceptance: data.request.customer_acceptance.clone(),
             charges: None, // TODO: allow charges on mandates?
+            merchant_order_reference_id: None,
             integrity_object: None,
         }
     }
diff --git a/crates/router/src/types/api/verify_connector.rs b/crates/router/src/types/api/verify_connector.rs
index 60b40e78663..859f02d8fcc 100644
--- a/crates/router/src/types/api/verify_connector.rs
+++ b/crates/router/src/types/api/verify_connector.rs
@@ -55,6 +55,7 @@ impl VerifyConnectorData {
             authentication_data: None,
             customer_acceptance: None,
             charges: None,
+            merchant_order_reference_id: None,
             integrity_object: None,
         }
     }
diff --git a/crates/router/src/utils/user/sample_data.rs b/crates/router/src/utils/user/sample_data.rs
index 97c063eb3ae..28976236df9 100644
--- a/crates/router/src/utils/user/sample_data.rs
+++ b/crates/router/src/utils/user/sample_data.rs
@@ -226,6 +226,7 @@ pub async fn generate_sample_data(
             charges: None,
             frm_metadata: Default::default(),
             customer_details: None,
+            merchant_order_reference_id: Default::default(),
         };
         let payment_attempt = PaymentAttemptBatchNew {
             attempt_id: attempt_id.clone(),
diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rs
index 53bbea865c2..153134964be 100644
--- a/crates/router/tests/connectors/utils.rs
+++ b/crates/router/tests/connectors/utils.rs
@@ -937,6 +937,7 @@ impl Default for PaymentAuthorizeType {
             customer_acceptance: None,
             charges: None,
             integrity_object: None,
+            merchant_order_reference_id: None,
         };
         Self(data)
     }
diff --git a/migrations/2024-07-03-182616_add_merchant_order_reference_id/down.sql b/migrations/2024-07-03-182616_add_merchant_order_reference_id/down.sql
new file mode 100644
index 00000000000..bcfedcf6b4e
--- /dev/null
+++ b/migrations/2024-07-03-182616_add_merchant_order_reference_id/down.sql
@@ -0,0 +1,2 @@
+-- This file should undo anything in `up.sql`
+ALTER TABLE payment_intent DROP COLUMN IF EXISTS merchant_order_reference_id;
\ No newline at end of file
diff --git a/migrations/2024-07-03-182616_add_merchant_order_reference_id/up.sql b/migrations/2024-07-03-182616_add_merchant_order_reference_id/up.sql
new file mode 100644
index 00000000000..cd5d2359c59
--- /dev/null
+++ b/migrations/2024-07-03-182616_add_merchant_order_reference_id/up.sql
@@ -0,0 +1,2 @@
+-- Your SQL goes here
+ALTER TABLE payment_intent ADD COLUMN IF NOT EXISTS merchant_order_reference_id VARCHAR(255) DEFAULT NULL;
\ No newline at end of file