Bug: [BUG] Validate payment method type in payments request against given payment method data for non-card flows



### Bug Description

The payments flow currently does not validate the payment method type given in the payments request against the given payment method data for non-card flows.

### Expected Behavior

The payments flow should include a validation check that ensures that
- The payment method type is present for non-card flows
- The payment method type matches with the details in the payment method data

### Actual Behavior

Said validation is absent which can cause problems down the line

### Steps To Reproduce

Make a payment with a non-card payment method without providing the `"payment_method_type"` in the payments request

### Context For The Bug

_No response_

### Environment

Hyperswitch hosted version

### Have you spent some time to check if this bug has been raised before?

- [X] I checked and didn't find 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?

No, I don't have time to work on this right now
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 25450aaf22c..74e1791b051 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -37,6 +37,7 @@ use crate::{
             types::{self, AsyncLift},
         },
         storage::{self, enums as storage_enums, ephemeral_key, CustomerUpdate::Update},
+        transformers::ForeignInto,
         ErrorResponse, RouterData,
     },
     utils::{
@@ -1370,6 +1371,18 @@ pub(crate) fn validate_payment_method_fields_present(
         },
     )?;
 
+    utils::when(
+        !matches!(
+            req.payment_method,
+            Some(api_enums::PaymentMethod::Card) | None
+        ) && (req.payment_method_type.is_none()),
+        || {
+            Err(errors::ApiErrorResponse::MissingRequiredField {
+                field_name: "payment_method_type",
+            })
+        },
+    )?;
+
     utils::when(
         req.payment_method.is_some()
             && req.payment_method_data.is_none()
@@ -1381,6 +1394,56 @@ pub(crate) fn validate_payment_method_fields_present(
         },
     )?;
 
+    let payment_method: Option<api_enums::PaymentMethod> =
+        (req.payment_method_type).map(ForeignInto::foreign_into);
+
+    utils::when(
+        req.payment_method.is_some()
+            && req.payment_method_type.is_some()
+            && (req.payment_method != payment_method),
+        || {
+            Err(errors::ApiErrorResponse::InvalidRequestData {
+                message: ("payment_method_type doesn't correspond to the specified payment_method"
+                    .to_string()),
+            })
+        },
+    )?;
+
+    utils::when(
+        !matches!(
+            req.payment_method
+                .as_ref()
+                .zip(req.payment_method_data.as_ref()),
+            Some(
+                (
+                    api_enums::PaymentMethod::Card,
+                    api::PaymentMethodData::Card(..)
+                ) | (
+                    api_enums::PaymentMethod::Wallet,
+                    api::PaymentMethodData::Wallet(..)
+                ) | (
+                    api_enums::PaymentMethod::PayLater,
+                    api::PaymentMethodData::PayLater(..)
+                ) | (
+                    api_enums::PaymentMethod::BankRedirect,
+                    api::PaymentMethodData::BankRedirect(..)
+                ) | (
+                    api_enums::PaymentMethod::BankDebit,
+                    api::PaymentMethodData::BankDebit(..)
+                ) | (
+                    api_enums::PaymentMethod::Crypto,
+                    api::PaymentMethodData::Crypto(..)
+                )
+            ) | None
+        ),
+        || {
+            Err(errors::ApiErrorResponse::InvalidRequestData {
+                message: "payment_method_data doesn't correspond to the specified payment_method"
+                    .to_string(),
+            })
+        },
+    )?;
+
     Ok(())
 }
 

## Type of Change

- [x] Bugfix
- [x] New feature

## Description

Added the following checks for non-card flows :

1. Check if `payment_method_type` is specified.
2. Check if the specified `payment_method_type` corresponds to the parent `payment_method`.
3. Check if the specified `payment_method_data` corresponds to the parent `payment_method`.

<!-- 
Provide links to the files with corresponding changes.

Following are the paths where you can find config files:
1. `config`
5. `crates/router/src/configs`
6. `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 its an obvious bug or documentation fix
that will have little conversation).
-->

This PR resolves [this](https://github.com/juspay/hyperswitch/issues/1102) issue.

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