Bug: [BUG] `payment_method_type` not saved when creating a record in the `payment_method` table



### Bug Description

When saving the payment method record to the `payment_method` table after a payment, only the `PaymentMethod` is saved but not the `PaymentMethodType` even if it is present in the request.

### Expected Behavior

the payment method type should also get saved in the payment method record.

### Actual Behavior

the payment method type is not saved. It is hardcoded to `None` in the code

https://github.com/juspay/hyperswitch/blob/1322aa757902662a1bd90cc3f09e887a7fdbf841/crates/router/src/core/payments/helpers.rs#L722

### Steps To Reproduce

1. Create a Merchant Account
2. Create a connector account
3. Make a payment with any payment method

### Context For The Bug

_No response_

### Environment

Are you using hyperswitch hosted version? No
If yes, please provide the value of the `x-request-id` response header for helping us debug your issue.

If not (or if building/running locally), please provide the following details:
1. Operating System or Linux distribution: 
2. Rust version (output of `rustc --version`): ``
3. App version (output of `cargo r -- --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, but I'm happy to collaborate on a PR with someone else
diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs
index 49d30f6e87e..36d40d7480e 100644
--- a/crates/router/src/core/payments/flows/authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/authorize_flow.rs
@@ -84,6 +84,7 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> for types::PaymentsAu
                 resp.to_owned(),
                 maybe_customer,
                 merchant_account,
+                self.request.payment_method_type.clone(),
             )
             .await?;
 
diff --git a/crates/router/src/core/payments/flows/verify_flow.rs b/crates/router/src/core/payments/flows/verify_flow.rs
index 274ad4fcdc0..a70e4419b33 100644
--- a/crates/router/src/core/payments/flows/verify_flow.rs
+++ b/crates/router/src/core/payments/flows/verify_flow.rs
@@ -67,6 +67,7 @@ impl Feature<api::Verify, types::VerifyRequestData> for types::VerifyRouterData
             resp.to_owned(),
             maybe_customer,
             merchant_account,
+            self.request.payment_method_type.clone(),
         )
         .await?;
 
@@ -177,12 +178,14 @@ impl types::VerifyRouterData {
                 .await
                 .to_verify_failed_response()?;
 
+                let payment_method_type = self.request.payment_method_type.clone();
                 let pm_id = tokenization::save_payment_method(
                     state,
                     connector,
                     resp.to_owned(),
                     maybe_customer,
                     merchant_account,
+                    payment_method_type,
                 )
                 .await?;
 
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 6d6017f6f81..b29d89a3811 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -729,13 +729,14 @@ where
 
 #[instrument(skip_all)]
 pub(crate) async fn get_payment_method_create_request(
-    payment_method: Option<&api::PaymentMethodData>,
-    payment_method_type: Option<storage_enums::PaymentMethod>,
+    payment_method_data: Option<&api::PaymentMethodData>,
+    payment_method: Option<storage_enums::PaymentMethod>,
+    payment_method_type: Option<storage_enums::PaymentMethodType>,
     customer: &domain::Customer,
 ) -> RouterResult<api::PaymentMethodCreate> {
-    match payment_method {
-        Some(pm_data) => match payment_method_type {
-            Some(payment_method_type) => match pm_data {
+    match payment_method_data {
+        Some(pm_data) => match payment_method {
+            Some(payment_method) => match pm_data {
                 api::PaymentMethodData::Card(card) => {
                     let card_detail = api::CardDetail {
                         card_number: card.card_number.clone(),
@@ -745,8 +746,8 @@ pub(crate) async fn get_payment_method_create_request(
                     };
                     let customer_id = customer.customer_id.clone();
                     let payment_method_request = api::PaymentMethodCreate {
-                        payment_method: payment_method_type.foreign_into(),
-                        payment_method_type: None,
+                        payment_method: payment_method.foreign_into(),
+                        payment_method_type: payment_method_type.map(ForeignInto::foreign_into),
                         payment_method_issuer: card.card_issuer.clone(),
                         payment_method_issuer_code: None,
                         card: Some(card_detail),
@@ -761,8 +762,8 @@ pub(crate) async fn get_payment_method_create_request(
                 }
                 _ => {
                     let payment_method_request = api::PaymentMethodCreate {
-                        payment_method: payment_method_type.foreign_into(),
-                        payment_method_type: None,
+                        payment_method: payment_method.foreign_into(),
+                        payment_method_type: payment_method_type.map(ForeignInto::foreign_into),
                         payment_method_issuer: None,
                         payment_method_issuer_code: None,
                         card: None,
diff --git a/crates/router/src/core/payments/tokenization.rs b/crates/router/src/core/payments/tokenization.rs
index b60d9a68aa4..6cf6cbb28bb 100644
--- a/crates/router/src/core/payments/tokenization.rs
+++ b/crates/router/src/core/payments/tokenization.rs
@@ -15,6 +15,7 @@ use crate::{
         self,
         api::{self, PaymentMethodCreateExt},
         domain,
+        storage::enums as storage_enums,
     },
     utils::OptionExt,
 };
@@ -25,6 +26,7 @@ pub async fn save_payment_method<F: Clone, FData>(
     resp: types::RouterData<F, FData, types::PaymentsResponseData>,
     maybe_customer: &Option<domain::Customer>,
     merchant_account: &domain::MerchantAccount,
+    payment_method_type: Option<storage_enums::PaymentMethodType>,
 ) -> RouterResult<Option<String>>
 where
     FData: mandate::MandateBehaviour,
@@ -53,6 +55,7 @@ where
         let payment_method_create_request = helpers::get_payment_method_create_request(
             Some(&resp.request.get_payment_method_data()),
             Some(resp.payment_method),
+            payment_method_type,
             &customer,
         )
         .await?;
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 320896b34d1..c8cf6405a73 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -885,6 +885,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::VerifyRequestDat
             router_return_url,
             email: payment_data.email,
             return_url: payment_data.payment_intent.return_url,
+            payment_method_type: attempt.payment_method_type.clone(),
         })
     }
 }
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index a694e878aa6..881d4e7a2b2 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -339,6 +339,7 @@ pub struct VerifyRequestData {
     pub router_return_url: Option<String>,
     pub email: Option<Email>,
     pub return_url: Option<String>,
+    pub payment_method_type: Option<storage_enums::PaymentMethodType>,
 }
 
 #[derive(Debug, Clone)]

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

- [x] Bugfix

## Description
<!-- Describe your changes in detail -->
When saving the payment method record to the payment_method table after a payment, only the PaymentMethod is saved but not the PaymentMethodType even if it is present in the request.
This PR fixes that.

<!--
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 its an obvious bug or documentation fix
that will have little conversation).
-->
I fixed a bug! 

## 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)?
-->
Manually
<img width="1300" alt="Screenshot 2023-06-07 at 15 41 13" src="https://github.com/juspay/hyperswitch/assets/69745008/ef39a227-3db8-46dc-addd-0206ccc91b79">
<img width="1300" alt="Screenshot 2023-06-07 at 15 41 32" src="https://github.com/juspay/hyperswitch/assets/69745008/a32db4d9-be1f-45ce-add1-c42719097159">
<img width="1300" alt="Screenshot 2023-06-07 at 15 41 53" src="https://github.com/juspay/hyperswitch/assets/69745008/0cfe24ef-fd17-4113-8fa5-662b766bb5ea">
<img width="731" alt="image" src="https://github.com/juspay/hyperswitch/assets/69745008/797e6478-0c56-4eb7-a871-daf579db7d8e">

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