Bug: Fix Cypress v2 Core Flows Test Failures



The Cypress tests for v2 failed due to the recent authentication changes introduced in [PR #7487](https://github.com/juspay/hyperswitch/pull/7487) and payment method config changes.
diff --git a/cypress-tests-v2/cypress/e2e/configs/Payment/Commons.js b/cypress-tests-v2/cypress/e2e/configs/Payment/Commons.js
index 228dfd2cfdd..a645ec5c555 100644
--- a/cypress-tests-v2/cypress/e2e/configs/Payment/Commons.js
+++ b/cypress-tests-v2/cypress/e2e/configs/Payment/Commons.js
@@ -54,10 +54,10 @@ const multiUseMandateData = {
 
 export const payment_methods_enabled = [
   {
-    payment_method: "bank_debit",
-    payment_method_types: [
+    payment_method_type: "bank_debit",
+    payment_method_subtypes: [
       {
-        payment_method_type: "ach",
+        payment_method_subtype: "ach",
         payment_experience: null,
         card_networks: null,
         accepted_currencies: null,
@@ -68,7 +68,7 @@ export const payment_methods_enabled = [
         installment_payment_enabled: true,
       },
       {
-        payment_method_type: "bacs",
+        payment_method_subtype: "bacs",
         payment_experience: null,
         card_networks: null,
         accepted_currencies: null,
@@ -79,7 +79,7 @@ export const payment_methods_enabled = [
         installment_payment_enabled: true,
       },
       {
-        payment_method_type: "becs",
+        payment_method_subtype: "becs",
         payment_experience: null,
         card_networks: null,
         accepted_currencies: null,
@@ -90,7 +90,7 @@ export const payment_methods_enabled = [
         installment_payment_enabled: true,
       },
       {
-        payment_method_type: "sepa",
+        payment_method_subtype: "sepa",
         payment_experience: null,
         card_networks: null,
         accepted_currencies: null,
@@ -103,10 +103,10 @@ export const payment_methods_enabled = [
     ],
   },
   {
-    payment_method: "bank_redirect",
-    payment_method_types: [
+    payment_method_type: "bank_redirect",
+    payment_method_subtypes: [
       {
-        payment_method_type: "blik",
+        payment_method_subtype: "blik",
         payment_experience: null,
         card_networks: null,
         accepted_currencies: null,
@@ -117,7 +117,7 @@ export const payment_methods_enabled = [
         installment_payment_enabled: true,
       },
       {
-        payment_method_type: "eps",
+        payment_method_subtype: "eps",
         payment_experience: null,
         card_networks: null,
         accepted_currencies: null,
@@ -128,7 +128,7 @@ export const payment_methods_enabled = [
         installment_payment_enabled: true,
       },
       {
-        payment_method_type: "ideal",
+        payment_method_subtype: "ideal",
         payment_experience: null,
         card_networks: null,
         accepted_currencies: null,
@@ -139,7 +139,7 @@ export const payment_methods_enabled = [
         installment_payment_enabled: true,
       },
       {
-        payment_method_type: "giropay",
+        payment_method_subtype: "giropay",
         payment_experience: null,
         card_networks: null,
         accepted_currencies: null,
@@ -150,7 +150,7 @@ export const payment_methods_enabled = [
         installment_payment_enabled: true,
       },
       {
-        payment_method_type: "local_bank_redirect",
+        payment_method_subtype: "local_bank_redirect",
         payment_experience: null,
         card_networks: null,
         accepted_currencies: null,
@@ -161,7 +161,7 @@ export const payment_methods_enabled = [
         installment_payment_enabled: true,
       },
       {
-        payment_method_type: "przelewy24",
+        payment_method_subtype: "przelewy24",
         payment_experience: null,
         card_networks: null,
         accepted_currencies: null,
@@ -172,7 +172,7 @@ export const payment_methods_enabled = [
         installment_payment_enabled: true,
       },
       {
-        payment_method_type: "sofort",
+        payment_method_subtype: "sofort",
         payment_experience: null,
         card_networks: null,
         accepted_currencies: null,
@@ -185,10 +185,10 @@ export const payment_methods_enabled = [
     ],
   },
   {
-    payment_method: "bank_transfer",
-    payment_method_types: [
+    payment_method_type: "bank_transfer",
+    payment_method_subtypes: [
       {
-        payment_method_type: "ach",
+        payment_method_subtype: "ach",
         payment_experience: "redirect_to_url",
         card_networks: null,
         accepted_currencies: null,
@@ -199,7 +199,7 @@ export const payment_methods_enabled = [
         installment_payment_enabled: true,
       },
       {
-        payment_method_type: "bacs",
+        payment_method_subtype: "bacs",
         payment_experience: "redirect_to_url",
         card_networks: null,
         accepted_currencies: null,
@@ -210,14 +210,14 @@ export const payment_methods_enabled = [
         installment_payment_enabled: true,
       },
       {
-        payment_method_type: "pix",
+        payment_method_subtype: "pix",
         minimum_amount: -1,
         maximum_amount: 68607706,
         recurring_enabled: false,
         installment_payment_enabled: true,
       },
       {
-        payment_method_type: "sepa",
+        payment_method_subtype: "sepa",
         payment_experience: "redirect_to_url",
         card_networks: null,
         accepted_currencies: null,
@@ -230,10 +230,10 @@ export const payment_methods_enabled = [
     ],
   },
   {
-    payment_method: "card",
-    payment_method_types: [
+    payment_method_type: "card",
+    payment_method_subtypes: [
       {
-        payment_method_type: "credit",
+        payment_method_subtype: "credit",
         card_networks: [
           "AmericanExpress",
           "Discover",
@@ -251,7 +251,7 @@ export const payment_methods_enabled = [
         installment_payment_enabled: true,
       },
       {
-        payment_method_type: "debit",
+        payment_method_subtype: "debit",
         card_networks: [
           "AmericanExpress",
           "Discover",
@@ -271,10 +271,10 @@ export const payment_methods_enabled = [
     ],
   },
   {
-    payment_method: "card_redirect",
-    payment_method_types: [
+    payment_method_type: "card_redirect",
+    payment_method_subtypes: [
       {
-        payment_method_type: "card_redirect",
+        payment_method_subtype: "card_redirect",
         payment_experience: "redirect_to_url",
         card_networks: null,
         accepted_currencies: null,
@@ -287,10 +287,10 @@ export const payment_methods_enabled = [
     ],
   },
   {
-    payment_method: "real_time_payment",
-    payment_method_types: [
+    payment_method_type: "real_time_payment",
+    payment_method_subtypes: [
       {
-        payment_method_type: "duit_now",
+        payment_method_subtype: "duit_now",
         minimum_amount: 1,
         maximum_amount: 68607706,
         recurring_enabled: true,
@@ -298,7 +298,7 @@ export const payment_methods_enabled = [
         payment_experience: "redirect_to_url",
       },
       {
-        payment_method_type: "fps",
+        payment_method_subtype: "fps",
         minimum_amount: 1,
         maximum_amount: 68607706,
         recurring_enabled: true,
@@ -306,7 +306,7 @@ export const payment_methods_enabled = [
         payment_experience: "redirect_to_url",
       },
       {
-        payment_method_type: "prompt_pay",
+        payment_method_subtype: "prompt_pay",
         minimum_amount: 1,
         maximum_amount: 68607706,
         recurring_enabled: true,
@@ -314,7 +314,7 @@ export const payment_methods_enabled = [
         payment_experience: "redirect_to_url",
       },
       {
-        payment_method_type: "viet_qr",
+        payment_method_subtype: "viet_qr",
         minimum_amount: 1,
         maximum_amount: 68607706,
         recurring_enabled: true,
@@ -324,10 +324,10 @@ export const payment_methods_enabled = [
     ],
   },
   {
-    payment_method: "upi",
-    payment_method_types: [
+    payment_method_type: "upi",
+    payment_method_subtypes: [
       {
-        payment_method_type: "upi_collect",
+        payment_method_subtype: "upi_collect",
         minimum_amount: 1,
         maximum_amount: 68607706,
         recurring_enabled: true,
@@ -335,7 +335,7 @@ export const payment_methods_enabled = [
         payment_experience: "redirect_to_url",
       },
       {
-        payment_method_type: "upi_intent",
+        payment_method_subtype: "upi_intent",
         minimum_amount: 1,
         maximum_amount: 68607706,
         recurring_enabled: true,
diff --git a/cypress-tests-v2/cypress/support/commands.js b/cypress-tests-v2/cypress/support/commands.js
index 33f8907ce3f..54e52495d67 100644
--- a/cypress-tests-v2/cypress/support/commands.js
+++ b/cypress-tests-v2/cypress/support/commands.js
@@ -55,7 +55,7 @@ Cypress.Commands.add(
       url: url,
       headers: {
         "Content-Type": "application/json",
-        "api-key": api_key,
+        "Authorization": `admin-api-key=${api_key}`,
       },
       body: organizationCreateBody,
       failOnStatusCode: false,
@@ -91,7 +91,7 @@ Cypress.Commands.add("organizationRetrieveCall", (globalState) => {
     url: url,
     headers: {
       "Content-Type": "application/json",
-      "api-key": api_key,
+      "Authorization": `admin-api-key=${api_key}`,
     },
     failOnStatusCode: false,
   }).then((response) => {
@@ -135,7 +135,7 @@ Cypress.Commands.add(
       url: url,
       headers: {
         "Content-Type": "application/json",
-        "api-key": api_key,
+        "Authorization": `admin-api-key=${api_key}`,
       },
       body: organizationUpdateBody,
       failOnStatusCode: false,
@@ -185,7 +185,7 @@ Cypress.Commands.add(
       url: url,
       headers: {
         "Content-Type": "application/json",
-        "api-key": api_key,
+        "Authorization": `admin-api-key=${api_key}`,
         "X-Organization-Id": organization_id,
       },
       body: merchantAccountCreateBody,
@@ -230,7 +230,7 @@ Cypress.Commands.add("merchantAccountRetrieveCall", (globalState) => {
     url: url,
     headers: {
       "Content-Type": "application/json",
-      "api-key": api_key,
+      "Authorization": `admin-api-key=${api_key}`,
     },
     failOnStatusCode: false,
   }).then((response) => {
@@ -274,7 +274,7 @@ Cypress.Commands.add(
       url: url,
       headers: {
         "Content-Type": "application/json",
-        "api-key": api_key,
+        "Authorization": `admin-api-key=${api_key}`,
       },
       body: merchantAccountUpdateBody,
       failOnStatusCode: false,
@@ -310,7 +310,7 @@ Cypress.Commands.add(
   "businessProfileCreateCall",
   (businessProfileCreateBody, globalState) => {
     // Define the necessary variables and constants
-    const api_key = globalState.get("apiKey");
+    const api_key = globalState.get("adminApiKey");
     const base_url = globalState.get("baseUrl");
     const merchant_id = globalState.get("merchantId");
     const url = `${base_url}/v2/profiles`;
@@ -324,7 +324,8 @@ Cypress.Commands.add(
       url: url,
       headers: {
         "Content-Type": "application/json",
-        "api-key": api_key,
+        "Authorization": `admin-api-key=${api_key}`,
+        "x-merchant-id": merchant_id,
         ...customHeaders,
       },
       body: businessProfileCreateBody,
@@ -353,7 +354,7 @@ Cypress.Commands.add(
 );
 Cypress.Commands.add("businessProfileRetrieveCall", (globalState) => {
   // Define the necessary variables and constants
-  const api_key = globalState.get("apiKey");
+  const api_key = globalState.get("adminApiKey");
   const base_url = globalState.get("baseUrl");
   const merchant_id = globalState.get("merchantId");
   const profile_id = globalState.get("profileId");
@@ -368,7 +369,7 @@ Cypress.Commands.add("businessProfileRetrieveCall", (globalState) => {
     url: url,
     headers: {
       "Content-Type": "application/json",
-      "api-key": api_key,
+      "Authorization": `admin-api-key=${api_key}`,
       ...customHeaders,
     },
     failOnStatusCode: false,
@@ -395,7 +396,7 @@ Cypress.Commands.add(
   "businessProfileUpdateCall",
   (businessProfileUpdateBody, globalState) => {
     // Define the necessary variables and constants
-    const api_key = globalState.get("apiKey");
+    const api_key = globalState.get("adminApiKey");
     const base_url = globalState.get("baseUrl");
     const merchant_id = globalState.get("merchantId");
     const profile_id = globalState.get("profileId");
@@ -410,7 +411,7 @@ Cypress.Commands.add(
       url: url,
       headers: {
         "Content-Type": "application/json",
-        "api-key": api_key,
+        "Authorization": `admin-api-key=${api_key}`,
         ...customHeaders,
       },
       body: businessProfileUpdateBody,
@@ -460,6 +461,7 @@ Cypress.Commands.add(
 
     const customHeaders = {
       "x-merchant-id": merchant_id,
+      "x-profile-id": profile_id,
     };
 
     // Update request body
@@ -501,7 +503,7 @@ Cypress.Commands.add(
           url: url,
           headers: {
             "Content-Type": "application/json",
-            "api-key": api_key,
+            "Authorization": `admin-api-key=${api_key}`,
             ...customHeaders,
           },
           body: mcaCreateBody,
@@ -536,10 +538,12 @@ Cypress.Commands.add("mcaRetrieveCall", (globalState) => {
   const connector_name = globalState.get("connectorId");
   const merchant_connector_id = globalState.get("merchantConnectorId");
   const merchant_id = globalState.get("merchantId");
+  const profile_id = globalState.get("profileId");
   const url = `${base_url}/v2/connector-accounts/${merchant_connector_id}`;
 
   const customHeaders = {
     "x-merchant-id": merchant_id,
+    "x-profile-id": profile_id,
   };
 
   cy.request({
@@ -547,7 +551,7 @@ Cypress.Commands.add("mcaRetrieveCall", (globalState) => {
     url: url,
     headers: {
       "Content-Type": "application/json",
-      "api-key": api_key,
+      "Authorization": `admin-api-key=${api_key}`,
       ...customHeaders,
     },
     failOnStatusCode: false,
@@ -607,7 +611,7 @@ Cypress.Commands.add(
       url: url,
       headers: {
         "Content-Type": "application/json",
-        "api-key": api_key,
+        "Authorization": `admin-api-key=${api_key}`,
         ...customHeaders,
       },
       body: mcaUpdateBody,
@@ -667,7 +671,7 @@ Cypress.Commands.add("apiKeyCreateCall", (apiKeyCreateBody, globalState) => {
     url: url,
     headers: {
       "Content-Type": "application/json",
-      "api-key": api_key,
+      "Authorization": `admin-api-key=${api_key}`,
       ...customHeaders,
     },
     body: apiKeyCreateBody,
@@ -714,7 +718,7 @@ Cypress.Commands.add("apiKeyRetrieveCall", (globalState) => {
     url: url,
     headers: {
       "Content-Type": "application/json",
-      "api-key": api_key,
+      "Authorization": `admin-api-key=${api_key}`,
       ...customHeaders,
     },
     failOnStatusCode: false,
@@ -764,7 +768,7 @@ Cypress.Commands.add("apiKeyUpdateCall", (apiKeyUpdateBody, globalState) => {
     url: url,
     headers: {
       "Content-Type": "application/json",
-      "api-key": api_key,
+      "Authorization": `admin-api-key=${api_key}`,
       ...customHeaders,
     },
     body: apiKeyUpdateBody,
@@ -1172,7 +1176,7 @@ Cypress.Commands.add("merchantAccountsListCall", (globalState) => {
     method: "GET",
     url: url,
     headers: {
-      "api-key": api_key,
+      "Authorization": `admin-api-key=${api_key}`,
       "Content-Type": "application/json",
     },
     failOnStatusCode: false,
@@ -1214,7 +1218,7 @@ Cypress.Commands.add("businessProfilesListCall", (globalState) => {
     method: "GET",
     url: url,
     headers: {
-      "api-key": api_key,
+      "Authorization": `admin-api-key=${api_key}`,
       "Content-Type": "application/json",
       ...customHeaders,
     },
@@ -1250,13 +1254,14 @@ Cypress.Commands.add("mcaListCall", (globalState, service_type) => {
 
   const customHeaders = {
     "x-merchant-id": merchant_id,
+    "x-profile-id": profile_id,
   };
 
   cy.request({
     method: "GET",
     url: url,
     headers: {
-      "api-key": api_key,
+      "Authorization": `admin-api-key=${api_key}`,
       "Content-Type": "application/json",
       ...customHeaders,
     },
@@ -1318,7 +1323,7 @@ Cypress.Commands.add("apiKeysListCall", (globalState) => {
     method: "GET",
     url: url,
     headers: {
-      "api-key": api_key,
+      "Authorization": `admin-api-key=${api_key}`,
       "Content-Type": "application/json",
       ...customHeaders,
     },

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

- [ ] Bugfix
- [ ] New feature
- [ ] Enhancement
- [x] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [x] CI/CD

## Description
<!-- Describe your changes in detail -->
<details>
<summary>Changes</summary>

- Changed the Authorization in the `commands.js` because Authorization changes had been made recently.
- Changed field names in `payment_methods_enabled` accordingly as accepted by v2 endpoints.
</details>

### 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).
-->
The v2 Cypress Tests were failing due to the recent Authentication Changes in #7487.

## 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)?
-->
**_Before_**
<img width="715" alt="image" src="https://github.com/user-attachments/assets/70f6ccfe-8094-47f0-b70f-34cb66cccc86" />

**_After_**
<img width="714" alt="image" src="https://github.com/user-attachments/assets/3b1c6591-3667-468f-aa9d-01e8e01eb835" />


## Checklist
<!-- Put an `x` in the boxes that apply -->

- [ ] I formatted the code `cargo +nightly fmt --all`
- [ ] I addressed lints thrown by `cargo clippy`
- [ ] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
