Issue:
Bug: [Bug] metadata validation for update payment connector



Metadata validation in update payment connector happens even if we don't pass metadata in the request. Instead, if metadata is not present we should consider MCA metadata in update_payment_connector function .

Pull request description:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [x] Bugfix
- [ ] New feature
- [ ] Enhancement
- [ ] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
<!-- Describe your changes in detail -->
Metadata validation in update payment connector happens even if we don't pass metadata in the request. This pr fixes metadata validation in update payment connector function. If metadata is not present we consider mca metadata.

### 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).
-->
Metadata validation in update payment connector happens even if we don't pass metadata in the request. This pr fixes metadata validation in update payment connector function. If metadata is not present we consider mca metadata.

## 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)?
-->
**Test case 1 :**
step 1 : Create merchant connector account for Fiserv.
```
curl --location --request POST 'https://sandbox.hyperswitch.io/account/<merchant_Id>/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "connector_type": "fiz_operations",
    "connector_name": "fiserv",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_key": "API_KEY",
        "key1": "KEY1",
        "api_secret": "API_SECRET"
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "payment_method_type": "klarna",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "affirm",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "afterpay_clearpay",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "bank_redirect",
            "payment_method_types": [
                {
                    "payment_method_type": "eps",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "sofort",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "metadata": {
        "terminal_id":"TERMINAL_ID"
    }
}'
```
step 2 : Update merchant connector account without updating metadata, It should not throw 422. 
here below curl is updating connector webhook details.
```
curl --location --request POST 'https://sandbox.hyperswitch.io/account/<merchant_id>/connectors/<mca_id>' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "connector_type": "fiz_operations",
    "connector_webhook_details": {
        "merchant_secret": "MERCHANT_SECRET",
        "additional_secret": null
    }
}'
```
**Test case 2 :** 
step 1 : Pass metadata in create payment connector for fiserv. curl is same as test case 1 -> step1

step 2 : Pass valid metadata in update payment connector, This should update metadata.
where valid metadata for fiserv  is `{"terminal_id": "TERMINAL_ID"}`
```
curl --location --request POST 'https://sandbox.hyperswitch.io/account/<merchant_id>/connectors/<mca_id>' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "connector_type": "fiz_operations",
    "metadata": {"terminal_id": "DIFFERENT_TERMINAL_ID"}
}'
```
**Test case 3 :**
step 1 : Pass metadata in create payment connector for fiserv. curl is same as test case 1 -> step1
step 2 : Pass Invalid metadata or empty metadata in update payment connector, This should throw error.
```
curl --location --request POST 'https://sandbox.hyperswitch.io/account/<merchant_id>/connectors/<mca_id>' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "connector_type": "fiz_operations",
    "metadata": {}
}'
```

This can be done for any other connector which have metadata validation while creating merchant connector account(Braintree, Coinbase ).

## 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


Testing:

**Test case 1 :**
step 1 : Create merchant connector account for Fiserv.
```
curl --location --request POST 'https://sandbox.hyperswitch.io/account/<merchant_Id>/connectors' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "connector_type": "fiz_operations",
    "connector_name": "fiserv",
    "connector_account_details": {
        "auth_type": "SignatureKey",
        "api_key": "API_KEY",
        "key1": "KEY1",
        "api_secret": "API_SECRET"
    },
    "test_mode": true,
    "disabled": false,
    "payment_methods_enabled": [
        {
            "payment_method": "card",
            "payment_method_types": [
                {
                    "payment_method_type": "credit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "debit",
                    "card_networks": [
                        "Visa",
                        "Mastercard"
                    ],
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "pay_later",
            "payment_method_types": [
                {
                    "payment_method_type": "klarna",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "affirm",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "afterpay_clearpay",
                    "payment_experience": "redirect_to_url",
                    "minimum_amount": 1,
                    "maximum_amount": 68607706,
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        },
        {
            "payment_method": "bank_redirect",
            "payment_method_types": [
                {
                    "payment_method_type": "eps",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                },
                {
                    "payment_method_type": "sofort",
                    "recurring_enabled": true,
                    "installment_payment_enabled": true
                }
            ]
        }
    ],
    "metadata": {
        "terminal_id":"TERMINAL_ID"
    }
}'
```
step 2 : Update merchant connector account without updating metadata, It should not throw 422. 
here below curl is updating connector webhook details.
```
curl --location --request POST 'https://sandbox.hyperswitch.io/account/<merchant_id>/connectors/<mca_id>' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "connector_type": "fiz_operations",
    "connector_webhook_details": {
        "merchant_secret": "MERCHANT_SECRET",
        "additional_secret": null
    }
}'
```
**Test case 2 :** 
step 1 : Pass metadata in create payment connector for fiserv. curl is same as test case 1 -> step1

step 2 : Pass valid metadata in update payment connector, This should update metadata.
where valid metadata for fiserv  is `{"terminal_id": "TERMINAL_ID"}`
```
curl --location --request POST 'https://sandbox.hyperswitch.io/account/<merchant_id>/connectors/<mca_id>' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "connector_type": "fiz_operations",
    "metadata": {"terminal_id": "DIFFERENT_TERMINAL_ID"}
}'
```
**Test case 3 :**
step 1 : Pass metadata in create payment connector for fiserv. curl is same as test case 1 -> step1
step 2 : Pass Invalid metadata or empty metadata in update payment connector, This should throw error.
```
curl --location --request POST 'https://sandbox.hyperswitch.io/account/<merchant_id>/connectors/<mca_id>' \
--header 'Content-Type: application/json' \
--header 'Accept: application/json' \
--header 'api-key: test_admin' \
--data-raw '{
    "connector_type": "fiz_operations",
    "metadata": {}
}'
```

This can be done for any other connector which have metadata validation while creating merchant connector account(Braintree, Coinbase ).

Patch:
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index 2b87d64c6ac..14c88448125 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -1185,6 +1185,7 @@ pub async fn update_payment_connector(
             field_name: "connector_account_details".to_string(),
             expected_format: "auth_type and api_key".to_string(),
         })?;
+    let metadata = req.metadata.clone().or(mca.metadata.clone());
     let connector_name = mca.connector_name.as_ref();
     let connector_enum = api_models::enums::Connector::from_str(connector_name)
         .into_report()
@@ -1192,27 +1193,27 @@ pub async fn update_payment_connector(
             field_name: "connector",
         })
         .attach_printable_lazy(|| format!("unable to parse connector name {connector_name:?}"))?;
-    validate_auth_and_metadata_type(connector_enum, &auth, &req.metadata).map_err(
-        |err| match *err.current_context() {
-            errors::ConnectorError::InvalidConnectorName => {
-                err.change_context(errors::ApiErrorResponse::InvalidRequestData {
-                    message: "The connector name is invalid".to_string(),
-                })
-            }
-            errors::ConnectorError::InvalidConnectorConfig { config: field_name } => err
-                .change_context(errors::ApiErrorResponse::InvalidRequestData {
-                    message: format!("The {} is invalid", field_name),
-                }),
-            errors::ConnectorError::FailedToObtainAuthType => {
-                err.change_context(errors::ApiErrorResponse::InvalidRequestData {
-                    message: "The auth type is invalid for the connector".to_string(),
-                })
-            }
-            _ => err.change_context(errors::ApiErrorResponse::InvalidRequestData {
-                message: "The request body is invalid".to_string(),
+    validate_auth_and_metadata_type(connector_enum, &auth, &metadata).map_err(|err| match *err
+        .current_context()
+    {
+        errors::ConnectorError::InvalidConnectorName => {
+            err.change_context(errors::ApiErrorResponse::InvalidRequestData {
+                message: "The connector name is invalid".to_string(),
+            })
+        }
+        errors::ConnectorError::InvalidConnectorConfig { config: field_name } => err
+            .change_context(errors::ApiErrorResponse::InvalidRequestData {
+                message: format!("The {} is invalid", field_name),
             }),
-        },
-    )?;
+        errors::ConnectorError::FailedToObtainAuthType => {
+            err.change_context(errors::ApiErrorResponse::InvalidRequestData {
+                message: "The auth type is invalid for the connector".to_string(),
+            })
+        }
+        _ => err.change_context(errors::ApiErrorResponse::InvalidRequestData {
+            message: "The request body is invalid".to_string(),
+        }),
+    })?;
 
     let (connector_status, disabled) =
         validate_status_and_disabled(req.status, req.disabled, auth, mca.status)?;