Issue:
Bug: [REFACTOR]: [SHIFT4] Add amount conversion framework to Shift4



### :memo: Feature Description

Currently, amounts are represented as `i64` values throughout the application. We want to introduce a `Unit` struct that explicitly states the denomination. A new type, `MinorUnit`, has been added to standardize the flow of amounts across the application. This type will now be used by all the connector flows.

Rather than handling conversions in each connector, we will centralize the conversion logic in one place within the core of the application.

### :hammer: Possible Implementation

- For each connector, we need to create an amount conversion function. Connectors will specify the format they require, and the core framework will handle the conversion accordingly.
- Connectors should invoke the `convert` function to receive the amount in their required format.
- Refer to the [connector documentation](https://dev.shift4.com/docs/api#cards) to determine the required amount format for each connector.
- You can refer [this PR](https://github.com/juspay/hyperswitch/pull/4825) for more context.


🔖 Note: All the changes needed should be contained within `hyperswitch/crates/router/src/connector/` , `crates/router/src/types/api.rs` , `crates/router/tests/connectors/`


### :package: Have you spent some time checking if this feature request has been raised before?

- [ ] I checked and didn't find a similar issue

### :package: Have you read the Contributing Guidelines?

- [ ] I have read the [Contributing Guidelines](https://github.com/juspay/hyperswitch/blob/main/docs/CONTRIBUTING.md)

### :package: 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).

Refer [here](https://github.com/juspay/hyperswitch/blob/main/docs/TERMS_OF_CONTEST.md) for Terms and conditions for the contest.

###  :sparkles: Are you willing to submit a PR?


Pull request description:
## Type of Change
<!-- Put an `x` in the boxes that apply -->

- [ ] Bugfix
- [ ] New feature
- [ ] Enhancement
- [X] Refactoring
- [ ] Dependency updates
- [ ] Documentation
- [ ] CI/CD

## Description
This PR adds amount conversion framework to Shift4, for sending to connector.
Resolves #6122 

### 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).
-->


## 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)?
-->


## 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`
- [ ] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible


Testing:

Patch:
diff --git a/crates/router/src/connector/shift4.rs b/crates/router/src/connector/shift4.rs
index 895487db3ba..08c23bc5710 100644
--- a/crates/router/src/connector/shift4.rs
+++ b/crates/router/src/connector/shift4.rs
@@ -1,8 +1,10 @@
 pub mod transformers;
 
-use std::fmt::Debug;
-
-use common_utils::{ext_traits::ByteSliceExt, request::RequestContent};
+use common_utils::{
+    ext_traits::ByteSliceExt,
+    request::RequestContent,
+    types::{AmountConvertor, MinorUnit, MinorUnitForConnector},
+};
 use diesel_models::enums;
 use error_stack::{report, ResultExt};
 use transformers as shift4;
@@ -27,8 +29,18 @@ use crate::{
     utils::BytesExt,
 };
 
-#[derive(Debug, Clone)]
-pub struct Shift4;
+#[derive(Clone)]
+pub struct Shift4 {
+    amount_converter: &'static (dyn AmountConvertor<Output = MinorUnit> + Sync),
+}
+
+impl Shift4 {
+    pub fn new() -> &'static Self {
+        &Self {
+            amount_converter: &MinorUnitForConnector,
+        }
+    }
+}
 
 impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Shift4
 where
@@ -206,7 +218,13 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
         req: &types::PaymentsAuthorizeRouterData,
         _connectors: &settings::Connectors,
     ) -> CustomResult<RequestContent, errors::ConnectorError> {
-        let connector_req = shift4::Shift4PaymentsRequest::try_from(req)?;
+        let amount = connector_utils::convert_amount(
+            self.amount_converter,
+            req.request.minor_amount,
+            req.request.currency,
+        )?;
+        let connector_router_data = shift4::Shift4RouterData::try_from((amount, req))?;
+        let connector_req = shift4::Shift4PaymentsRequest::try_from(&connector_router_data)?;
         Ok(RequestContent::Json(Box::new(connector_req)))
     }
 
@@ -470,7 +488,21 @@ impl
         req: &types::PaymentsPreProcessingRouterData,
         _connectors: &settings::Connectors,
     ) -> CustomResult<RequestContent, errors::ConnectorError> {
-        let connector_req = shift4::Shift4PaymentsRequest::try_from(req)?;
+        let amount = connector_utils::convert_amount(
+            self.amount_converter,
+            req.request.minor_amount.ok_or_else(|| {
+                errors::ConnectorError::MissingRequiredField {
+                    field_name: "minor_amount",
+                }
+            })?,
+            req.request
+                .currency
+                .ok_or_else(|| errors::ConnectorError::MissingRequiredField {
+                    field_name: "currency",
+                })?,
+        )?;
+        let connector_router_data = shift4::Shift4RouterData::try_from((amount, req))?;
+        let connector_req = shift4::Shift4PaymentsRequest::try_from(&connector_router_data)?;
         Ok(RequestContent::Json(Box::new(connector_req)))
     }
 
@@ -559,7 +591,13 @@ impl
         req: &types::PaymentsCompleteAuthorizeRouterData,
         _connectors: &settings::Connectors,
     ) -> CustomResult<RequestContent, errors::ConnectorError> {
-        let connector_req = shift4::Shift4PaymentsRequest::try_from(req)?;
+        let amount = connector_utils::convert_amount(
+            self.amount_converter,
+            req.request.minor_amount,
+            req.request.currency,
+        )?;
+        let connector_router_data = shift4::Shift4RouterData::try_from((amount, req))?;
+        let connector_req = shift4::Shift4PaymentsRequest::try_from(&connector_router_data)?;
         Ok(RequestContent::Json(Box::new(connector_req)))
     }
 
@@ -641,7 +679,13 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
         req: &types::RefundsRouterData<api::Execute>,
         _connectors: &settings::Connectors,
     ) -> CustomResult<RequestContent, errors::ConnectorError> {
-        let connector_req = shift4::Shift4RefundRequest::try_from(req)?;
+        let amount = connector_utils::convert_amount(
+            self.amount_converter,
+            req.request.minor_refund_amount,
+            req.request.currency,
+        )?;
+        let connector_router_data = shift4::Shift4RouterData::try_from((amount, req))?;
+        let connector_req = shift4::Shift4RefundRequest::try_from(&connector_router_data)?;
         Ok(RequestContent::Json(Box::new(connector_req)))
     }
 
diff --git a/crates/router/src/connector/shift4/transformers.rs b/crates/router/src/connector/shift4/transformers.rs
index 2210ab0a361..3b768151115 100644
--- a/crates/router/src/connector/shift4/transformers.rs
+++ b/crates/router/src/connector/shift4/transformers.rs
@@ -1,6 +1,6 @@
 use api_models::payments;
 use cards::CardNumber;
-use common_utils::pii::SecretSerdeValue;
+use common_utils::{pii::SecretSerdeValue, types::MinorUnit};
 use error_stack::ResultExt;
 use masking::Secret;
 use serde::{Deserialize, Serialize};
@@ -23,11 +23,25 @@ trait Shift4AuthorizePreprocessingCommon {
     fn get_router_return_url(&self) -> Option<String>;
     fn get_email_optional(&self) -> Option<pii::Email>;
     fn get_complete_authorize_url(&self) -> Option<String>;
-    fn get_amount_required(&self) -> Result<i64, Error>;
     fn get_currency_required(&self) -> Result<diesel_models::enums::Currency, Error>;
     fn get_payment_method_data_required(&self) -> Result<domain::PaymentMethodData, Error>;
 }
 
+pub struct Shift4RouterData<T> {
+    pub amount: MinorUnit,
+    pub router_data: T,
+}
+
+impl<T> TryFrom<(MinorUnit, T)> for Shift4RouterData<T> {
+    type Error = error_stack::Report<errors::ConnectorError>;
+    fn try_from((amount, item): (MinorUnit, T)) -> Result<Self, Self::Error> {
+        Ok(Self {
+            amount,
+            router_data: item,
+        })
+    }
+}
+
 impl Shift4AuthorizePreprocessingCommon for types::PaymentsAuthorizeData {
     fn get_email_optional(&self) -> Option<pii::Email> {
         self.email.clone()
@@ -37,10 +51,6 @@ impl Shift4AuthorizePreprocessingCommon for types::PaymentsAuthorizeData {
         self.complete_authorize_url.clone()
     }
 
-    fn get_amount_required(&self) -> Result<i64, error_stack::Report<errors::ConnectorError>> {
-        Ok(self.amount)
-    }
-
     fn get_currency_required(
         &self,
     ) -> Result<diesel_models::enums::Currency, error_stack::Report<errors::ConnectorError>> {
@@ -70,10 +80,6 @@ impl Shift4AuthorizePreprocessingCommon for types::PaymentsPreProcessingData {
         self.complete_authorize_url.clone()
     }
 
-    fn get_amount_required(&self) -> Result<i64, Error> {
-        self.get_amount()
-    }
-
     fn get_currency_required(&self) -> Result<diesel_models::enums::Currency, Error> {
         self.get_currency()
     }
@@ -95,7 +101,7 @@ impl Shift4AuthorizePreprocessingCommon for types::PaymentsPreProcessingData {
 }
 #[derive(Debug, Serialize)]
 pub struct Shift4PaymentsRequest {
-    amount: String,
+    amount: MinorUnit,
     currency: enums::Currency,
     captured: bool,
     #[serde(flatten)]
@@ -195,19 +201,19 @@ pub enum CardPayment {
     CardToken(Secret<String>),
 }
 
-impl<T, Req> TryFrom<&types::RouterData<T, Req, types::PaymentsResponseData>>
+impl<T, Req> TryFrom<&Shift4RouterData<&types::RouterData<T, Req, types::PaymentsResponseData>>>
     for Shift4PaymentsRequest
 where
     Req: Shift4AuthorizePreprocessingCommon,
 {
     type Error = Error;
     fn try_from(
-        item: &types::RouterData<T, Req, types::PaymentsResponseData>,
+        item: &Shift4RouterData<&types::RouterData<T, Req, types::PaymentsResponseData>>,
     ) -> Result<Self, Self::Error> {
-        let submit_for_settlement = item.request.is_automatic_capture()?;
-        let amount = item.request.get_amount_required()?.to_string();
-        let currency = item.request.get_currency_required()?;
-        let payment_method = Shift4PaymentMethod::try_from(item)?;
+        let submit_for_settlement = item.router_data.request.is_automatic_capture()?;
+        let amount = item.amount.to_owned();
+        let currency = item.router_data.request.get_currency_required()?;
+        let payment_method = Shift4PaymentMethod::try_from(item.router_data)?;
         Ok(Self {
             amount,
             currency,
@@ -437,27 +443,33 @@ where
     }
 }
 
-impl<T> TryFrom<&types::RouterData<T, types::CompleteAuthorizeData, types::PaymentsResponseData>>
-    for Shift4PaymentsRequest
+impl<T>
+    TryFrom<
+        &Shift4RouterData<
+            &types::RouterData<T, types::CompleteAuthorizeData, types::PaymentsResponseData>,
+        >,
+    > for Shift4PaymentsRequest
 {
     type Error = Error;
     fn try_from(
-        item: &types::RouterData<T, types::CompleteAuthorizeData, types::PaymentsResponseData>,
+        item: &Shift4RouterData<
+            &types::RouterData<T, types::CompleteAuthorizeData, types::PaymentsResponseData>,
+        >,
     ) -> Result<Self, Self::Error> {
-        match &item.request.payment_method_data {
+        match &item.router_data.request.payment_method_data {
             Some(domain::PaymentMethodData::Card(_)) => {
                 let card_token: Shift4CardToken =
-                    to_connector_meta(item.request.connector_meta.clone())?;
+                    to_connector_meta(item.router_data.request.connector_meta.clone())?;
                 Ok(Self {
-                    amount: item.request.amount.to_string(),
-                    currency: item.request.currency,
+                    amount: item.amount.to_owned(),
+                    currency: item.router_data.request.currency,
                     payment_method: Shift4PaymentMethod::CardsNon3DSRequest(Box::new(
                         CardsNon3DSRequest {
                             card: CardPayment::CardToken(card_token.id),
-                            description: item.description.clone(),
+                            description: item.router_data.description.clone(),
                         },
                     )),
-                    captured: item.request.is_auto_capture()?,
+                    captured: item.router_data.request.is_auto_capture()?,
                 })
             }
             Some(domain::PaymentMethodData::Wallet(_))
@@ -687,7 +699,7 @@ pub struct Token {
 
 #[derive(Default, Debug, Deserialize, Serialize)]
 pub struct ThreeDSecureInfo {
-    pub amount: i64,
+    pub amount: MinorUnit,
     pub currency: String,
     pub enrolled: bool,
     #[serde(rename = "liabilityShift")]
@@ -814,15 +826,17 @@ impl<T, F>
 #[serde(rename_all = "camelCase")]
 pub struct Shift4RefundRequest {
     charge_id: String,
-    amount: i64,
+    amount: MinorUnit,
 }
 
-impl<F> TryFrom<&types::RefundsRouterData<F>> for Shift4RefundRequest {
+impl<F> TryFrom<&Shift4RouterData<&types::RefundsRouterData<F>>> for Shift4RefundRequest {
     type Error = Error;
-    fn try_from(item: &types::RefundsRouterData<F>) -> Result<Self, Self::Error> {
+    fn try_from(
+        item: &Shift4RouterData<&types::RefundsRouterData<F>>,
+    ) -> Result<Self, Self::Error> {
         Ok(Self {
-            charge_id: item.request.connector_transaction_id.clone(),
-            amount: item.request.refund_amount,
+            charge_id: item.router_data.request.connector_transaction_id.clone(),
+            amount: item.amount.to_owned(),
         })
     }
 }
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index 5300e86afdb..18283834cf0 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -473,7 +473,9 @@ impl ConnectorData {
                     Ok(ConnectorEnum::Old(Box::new(connector::Razorpay::new())))
                 }
                 enums::Connector::Rapyd => Ok(ConnectorEnum::Old(Box::new(&connector::Rapyd))),
-                enums::Connector::Shift4 => Ok(ConnectorEnum::Old(Box::new(&connector::Shift4))),
+                enums::Connector::Shift4 => {
+                    Ok(ConnectorEnum::Old(Box::new(connector::Shift4::new())))
+                }
                 enums::Connector::Square => Ok(ConnectorEnum::Old(Box::new(&connector::Square))),
                 enums::Connector::Stax => Ok(ConnectorEnum::Old(Box::new(&connector::Stax))),
                 enums::Connector::Stripe => {
diff --git a/crates/router/tests/connectors/shift4.rs b/crates/router/tests/connectors/shift4.rs
index fdaa1ebedef..ce10c9dad1a 100644
--- a/crates/router/tests/connectors/shift4.rs
+++ b/crates/router/tests/connectors/shift4.rs
@@ -15,7 +15,7 @@ impl utils::Connector for Shift4Test {
     fn get_data(&self) -> types::api::ConnectorData {
         use router::connector::Shift4;
         utils::construct_connector_data_old(
-            Box::new(&Shift4),
+            Box::new(Shift4::new()),
             types::Connector::Shift4,
             types::api::GetToken::Connector,
             None,