Bug: [CYPRESS]: Verify Search in "Payment operations" page.



---

### **Title**: Verify Search in "Payment operations" page.

---

### **Description**:

This task is to write and execute automated test cases for various UI elements and functionalities on the "Payment Operations" page. The tests should validate that key UI elements are present and that core functionalities operate as expected.

### **Objective**:

Ensure that the "Payment Operations" page displays all key elements and that interactions like searching, filtering, and report generation work as intended. The task will include multiple test cases covering these areas.

### **Pre-requisites:**

[Create a dummy connector](https://github.com/juspay/hyperswitch/issues/6125)
[Use the SDK to process a payment](https://github.com/juspay/hyperswitch/issues/6124)

---

### **Test Cases**:


#### **Test Case 1: Search for Payment Using Existing Payment ID**

- **Pre-requisites**: Make a payment.
- **Steps**:
  1. Login to the application.
  2. Navigate to the "Payment Operations" page.
  3. Enter an existing payment ID into the search bar.
- **Test Data**: {{payment_id}}
- **Expected Results**:
  - Payments table should contain one row with valid payment details.

#### **Test Case 2: Search for Payment Using Invalid Payment ID**

- **Pre-requisites**: User is logged in.
- **Steps**:
  1. Navigate to the "Payment Operations" page.
  2. Enter an invalid payment ID or string into the search bar.
- **Test Data**: "abacd," "something," "createdAt"
- **Expected Results**:
  - "There are no payments as of now" text should be displayed.
  - "Customize columns" button should not be present.

---

### **Acceptance Criteria**:

1. All test cases should pass with the expected results.
2. Each test case must verify the required functionality or UI element.
3. The tests should be included in the regression suite and executed in the CI/CD pipeline.

---

### **Submission Process**:
- Ask the maintainers for assignment of the issue, you can request for assignment by commenting on the issue itself.
- Once assigned, submit a pull request (PR).
- Maintainers will review and provide feedback, if any. 
- Maintainers can unassign issues due to inactivity, [read more here](https://github.com/juspay/hyperswitch/wiki/Hacktoberfest-Contribution-Rules).
- For this issue, please submit a PR on juspay/hyperswitch-control-center repo, and link it to the issue.

Refer [here](https://github.com/juspay/hyperswitch/blob/main/docs/TERMS_OF_CONTEST.md) for Terms and conditions for the contest.

---
diff --git a/crates/api_models/Cargo.toml b/crates/api_models/Cargo.toml
index 4e8710e031c..f1c7e8396da 100644
--- a/crates/api_models/Cargo.toml
+++ b/crates/api_models/Cargo.toml
@@ -10,7 +10,6 @@ license.workspace = true
 [features]
 default = ["payouts"]
 errors = ["dep:actix-web", "dep:reqwest"]
-multiple_mca = []
 dummy_connector = ["common_enums/dummy_connector"]
 detailed_errors = []
 payouts = []
diff --git a/crates/api_models/src/admin.rs b/crates/api_models/src/admin.rs
index ec68111dd0e..a3a6643056b 100644
--- a/crates/api_models/src/admin.rs
+++ b/crates/api_models/src/admin.rs
@@ -76,11 +76,6 @@ pub struct MerchantAccountCreate {
     pub locker_id: Option<String>,
 
     ///Default business details for connector routing
-    #[cfg(feature = "multiple_mca")]
-    #[schema(value_type = PrimaryBusinessDetails)]
-    pub primary_business_details: Vec<PrimaryBusinessDetails>,
-
-    #[cfg(not(feature = "multiple_mca"))]
     #[schema(value_type = Option<PrimaryBusinessDetails>)]
     pub primary_business_details: Option<Vec<PrimaryBusinessDetails>>,
 
@@ -603,21 +598,10 @@ pub struct MerchantConnectorCreate {
     ]))]
     pub frm_configs: Option<FrmConfigs>,
 
-    /// Business Country of the connector
-    #[cfg(feature = "multiple_mca")]
     #[schema(value_type = CountryAlpha2, example = "US")]
     pub business_country: api_enums::CountryAlpha2,
 
-    #[cfg(not(feature = "multiple_mca"))]
-    #[schema(value_type = Option<CountryAlpha2>, example = "US")]
-    pub business_country: Option<api_enums::CountryAlpha2>,
-
-    ///Business Type of the merchant
-    #[schema(example = "travel")]
-    #[cfg(feature = "multiple_mca")]
     pub business_label: String,
-    #[cfg(not(feature = "multiple_mca"))]
-    pub business_label: Option<String>,
 
     /// Business Sub label of the merchant
     #[schema(example = "chase")]
diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml
index cccaaca5cb6..45091f0f61f 100644
--- a/crates/router/Cargo.toml
+++ b/crates/router/Cargo.toml
@@ -22,7 +22,6 @@ kv_store = []
 accounts_cache = []
 openapi = ["olap", "oltp", "payouts"]
 vergen = ["router_env/vergen"]
-multiple_mca = ["api_models/multiple_mca"]
 dummy_connector = ["api_models/dummy_connector"]
 external_access_dc = ["dummy_connector"]
 detailed_errors = ["api_models/detailed_errors", "error-stack/serde"]
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index 6db72e93f45..ebe22a49da0 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -38,31 +38,6 @@ pub fn create_merchant_publishable_key() -> String {
     )
 }
 
-fn get_primary_business_details(
-    request: &api::MerchantAccountCreate,
-) -> Vec<PrimaryBusinessDetails> {
-    // In this case, business details is not optional, it will always be passed
-    #[cfg(feature = "multiple_mca")]
-    {
-        request.primary_business_details.to_owned()
-    }
-
-    // In this case, business details will be optional, if it is not passed, then create the
-    // default value
-    #[cfg(not(feature = "multiple_mca"))]
-    {
-        request
-            .primary_business_details
-            .to_owned()
-            .unwrap_or_else(|| {
-                vec![PrimaryBusinessDetails {
-                    country: enums::CountryAlpha2::US,
-                    business: "default".to_string(),
-                }]
-            })
-    }
-}
-
 pub async fn create_merchant_account(
     db: &dyn StorageInterface,
     req: api::MerchantAccountCreate,
@@ -76,7 +51,7 @@ pub async fn create_merchant_account(
     let publishable_key = Some(create_merchant_publishable_key());
 
     let primary_business_details = utils::Encode::<Vec<PrimaryBusinessDetails>>::encode_to_value(
-        &get_primary_business_details(&req),
+        &req.primary_business_details.unwrap_or_default(),
     )
     .change_context(errors::ApiErrorResponse::InvalidDataValue {
         field_name: "primary_business_details",
@@ -383,27 +358,6 @@ async fn validate_merchant_id<S: Into<String>>(
         .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)
 }
 
-fn get_business_details_wrapper(
-    request: &api::MerchantConnectorCreate,
-    _merchant_account: &domain::MerchantAccount,
-) -> RouterResult<(enums::CountryAlpha2, String)> {
-    #[cfg(feature = "multiple_mca")]
-    {
-        // The fields are mandatory
-        Ok((request.business_country, request.business_label.to_owned()))
-    }
-
-    #[cfg(not(feature = "multiple_mca"))]
-    {
-        // If the value is not passed, then take it from Merchant account
-        helpers::get_business_details(
-            request.business_country,
-            request.business_label.as_ref(),
-            _merchant_account,
-        )
-    }
-}
-
 fn validate_certificate_in_mca_metadata(
     connector_metadata: Secret<serde_json::Value>,
 ) -> RouterResult<()> {
@@ -459,11 +413,15 @@ pub async fn create_payment_connector(
         .await
         .to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
 
-    let (business_country, business_label) = get_business_details_wrapper(&req, &merchant_account)?;
+    helpers::validate_business_details(
+        req.business_country,
+        &req.business_label,
+        &merchant_account,
+    )?;
 
     let connector_label = helpers::get_connector_label(
-        business_country,
-        &business_label,
+        req.business_country,
+        &req.business_label,
         req.business_sub_label.as_ref(),
         &req.connector_name.to_string(),
     );
@@ -526,8 +484,8 @@ pub async fn create_payment_connector(
         metadata: req.metadata,
         frm_configs,
         connector_label: connector_label.clone(),
-        business_country,
-        business_label,
+        business_country: req.business_country,
+        business_label: req.business_label.clone(),
         business_sub_label: req.business_sub_label,
         created_at: common_utils::date_time::now(),
         modified_at: common_utils::date_time::now(),
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 66e9a305708..05a0f88ca0f 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -1830,6 +1830,32 @@ pub fn get_connector_label(
     connector_label
 }
 
+/// Check whether the business details are configured in the merchant account
+pub fn validate_business_details(
+    business_country: api_enums::CountryAlpha2,
+    business_label: &String,
+    merchant_account: &domain::MerchantAccount,
+) -> RouterResult<()> {
+    let primary_business_details = merchant_account
+        .primary_business_details
+        .clone()
+        .parse_value::<Vec<api_models::admin::PrimaryBusinessDetails>>("PrimaryBusinessDetails")
+        .change_context(errors::ApiErrorResponse::InternalServerError)
+        .attach_printable("failed to parse primary business details")?;
+
+    primary_business_details
+        .iter()
+        .find(|business_details| {
+            &business_details.business == business_label
+                && business_details.country == business_country
+        })
+        .ok_or(errors::ApiErrorResponse::PreconditionFailed {
+            message: "business_details are not configured in the merchant account".to_string(),
+        })?;
+
+    Ok(())
+}
+
 /// Do lazy parsing of primary business details
 /// If both country and label are passed, no need to parse business details from merchant_account
 /// If any one is missing, get it from merchant_account
@@ -1840,42 +1866,29 @@ pub fn get_business_details(
     business_label: Option<&String>,
     merchant_account: &domain::MerchantAccount,
 ) -> RouterResult<(api_enums::CountryAlpha2, String)> {
-    let (business_country, business_label) = match business_country.zip(business_label) {
-        Some((business_country, business_label)) => {
-            (business_country.to_owned(), business_label.to_owned())
-        }
-        None => {
-            // Parse the primary business details from merchant account
-            let primary_business_details: Vec<api_models::admin::PrimaryBusinessDetails> =
-                merchant_account
-                    .primary_business_details
-                    .clone()
-                    .parse_value("PrimaryBusinessDetails")
-                    .change_context(errors::ApiErrorResponse::InternalServerError)
-                    .attach_printable("failed to parse primary business details")?;
+    let primary_business_details = merchant_account
+        .primary_business_details
+        .clone()
+        .parse_value::<Vec<api_models::admin::PrimaryBusinessDetails>>("PrimaryBusinessDetails")
+        .change_context(errors::ApiErrorResponse::InternalServerError)
+        .attach_printable("failed to parse primary business details")?;
 
-            if primary_business_details.len() == 1 {
-                let primary_business_details = primary_business_details.first().ok_or(
-                    errors::ApiErrorResponse::MissingRequiredField {
-                        field_name: "primary_business_details",
-                    },
-                )?;
-                (
-                    business_country.unwrap_or_else(|| primary_business_details.country.to_owned()),
-                    business_label
-                        .map(ToString::to_string)
-                        .unwrap_or_else(|| primary_business_details.business.to_owned()),
-                )
-            } else {
-                // If primary business details are not present or more than one
-                Err(report!(errors::ApiErrorResponse::MissingRequiredField {
-                    field_name: "business_country, business_label"
-                }))?
-            }
+    match business_country.zip(business_label) {
+        Some((business_country, business_label)) => {
+            Ok((business_country.to_owned(), business_label.to_owned()))
         }
-    };
-
-    Ok((business_country, business_label))
+        _ => match primary_business_details.first() {
+            Some(business_details) if primary_business_details.len() == 1 => Ok((
+                business_country.unwrap_or_else(|| business_details.country.to_owned()),
+                business_label
+                    .map(ToString::to_string)
+                    .unwrap_or_else(|| business_details.business.to_owned()),
+            )),
+            _ => Err(report!(errors::ApiErrorResponse::MissingRequiredField {
+                field_name: "business_country, business_label"
+            })),
+        },
+    }
 }
 
 #[inline]
diff --git a/crates/router/src/core/payments/operations/payment_create.rs b/crates/router/src/core/payments/operations/payment_create.rs
index e456f58a0e1..c3c2bae9896 100644
--- a/crates/router/src/core/payments/operations/payment_create.rs
+++ b/crates/router/src/core/payments/operations/payment_create.rs
@@ -586,11 +586,29 @@ impl PaymentCreate {
             .change_context(errors::ApiErrorResponse::InternalServerError)
             .attach_printable("Failed to convert order details to value")?;
 
-        let (business_country, business_label) = helpers::get_business_details(
-            request.business_country,
-            request.business_label.as_ref(),
-            merchant_account,
-        )?;
+        let (business_country, business_label) =
+            match (request.business_country, request.business_label.as_ref()) {
+                (Some(business_country), Some(business_label)) => {
+                    helpers::validate_business_details(
+                        business_country,
+                        business_label,
+                        merchant_account,
+                    )?;
+
+                    Ok((business_country, business_label.clone()))
+                }
+                (None, Some(_)) => Err(errors::ApiErrorResponse::MissingRequiredField {
+                    field_name: "business_country",
+                }),
+                (Some(_), None) => Err(errors::ApiErrorResponse::MissingRequiredField {
+                    field_name: "business_label",
+                }),
+                (None, None) => Ok(helpers::get_business_details(
+                    request.business_country,
+                    request.business_label.as_ref(),
+                    merchant_account,
+                )?),
+            }?;
 
         let allowed_payment_method_types = request
             .get_allowed_payment_method_types_as_value()
diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json
index 11ef305ffa3..2ba0b4a41c9 100644
--- a/openapi/openapi_spec.json
+++ b/openapi/openapi_spec.json
@@ -5634,7 +5634,9 @@
         "required": [
           "connector_type",
           "connector_name",
-          "connector_label"
+          "connector_label",
+          "business_country",
+          "business_label"
         ],
         "properties": {
           "connector_type": {
@@ -5730,16 +5732,10 @@
             "nullable": true
           },
           "business_country": {
-            "allOf": [
-              {
-                "$ref": "#/components/schemas/CountryAlpha2"
-              }
-            ],
-            "nullable": true
+            "$ref": "#/components/schemas/CountryAlpha2"
           },
           "business_label": {
-            "type": "string",
-            "nullable": true
+            "type": "string"
           },
           "business_sub_label": {
             "type": "string",

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

- [x] Refactoring

## Description
<!-- Describe your changes in detail -->
This PR will remove the multiple mca feature. No fields will have default values in primary business details.
- When creating merchant connector account, `business_label` and `business_country` are mandatory. A validation is added to ensure that the business details passed when creating connector account, are configured in the merchant account.
- When creating the payment, if no business details (`business_country` and `business_label`) are passed then take it from the merchant account. If more than one business details are configured in the merchant account, then raise an error mentioning that business details are mandatory. 


## 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 its 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)?
-->
- Create a merchant account, without primary business details
  - Create connector account without business details -> Error
  
    <img width="829" alt="Screenshot 2023-07-11 at 3 48 23 PM" src="https://github.com/juspay/hyperswitch/assets/48803246/f5ac8294-b38b-48de-ab44-be5f7854aedc">

  - Create connector account with business details -> Error
     <img width="785" alt="Screenshot 2023-07-11 at 3 47 56 PM" src="https://github.com/juspay/hyperswitch/assets/48803246/76b8a6b3-f7cc-4148-9667-d5ed675a82c4">

  - Create a payment without business data.
     
    <img width="718" alt="Screenshot 2023-07-11 at 3 50 58 PM" src="https://github.com/juspay/hyperswitch/assets/48803246/977002fb-6f16-4a5e-903e-b25c4fabad6e">

  - Create a payment with business data.
    <img width="829" alt="Screenshot 2023-07-11 at 3 51 43 PM" src="https://github.com/juspay/hyperswitch/assets/48803246/ac3e03d2-5ee7-441a-994d-60c120cc7dcb">

- Create a merchant account with business data ( only one business detail ).
  - Create a payment without business data -> Take business data from merchant account.
- Create a merchant account with business data ( two business details ).
  - Create a payment without business data. -> Error
    <img width="720" alt="Screenshot 2023-07-11 at 3 55 04 PM" src="https://github.com/juspay/hyperswitch/assets/48803246/7a864518-5dd0-4397-8557-194993999c4b">

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