Bug: [FEATURE]: [ACI] Currency Unit Conversion



### :memo: Feature Description

- Each currency can be described in terms of base or minor units. 
- For instance, when dealing with USD currency, the Cent is considered as the minor unit, while the Dollar is considered the base unit. 
- In Hyperswitch, the amount value is expected to be always provided in minor units. 
- For example: In USD, If the amount is 1 in base unit (Dollar), then it will be equivalent to 100 in minor units (Cent)
- Some of the connectors integrated require the amount to be converted to a desirable unit before being passed to them. 
- We have functions `to_currency_base_unit` and `to_currency_lower_unit` in place to convert the minor unit amount to its decimal equivalent and vice versa. These conversions are handled explicitly based on the connector.


### :hammer: Possible Implementation

- ConnectorCommon trait have been implemented for the connector. 
- This trait contains `get_currency_unit` method. This method needs to be implemented. 
- It will define what type of conversion needs to be done during `connector_router_data` creation. Concurrently handle the creation of `connector_router_data` to be passed for the connector request body creation.
- You can check this PR for further reference https://github.com/juspay/hyperswitch/pull/2196

:bookmark: Note: All the changes needed should be contained within `hyperswitch/crates/router/src/connector/`

### :package: Have you spent some time checking if this feature request has been raised before?

- [X] I checked and didn't find a similar issue

### :package: Have you read the Contributing Guidelines?

- [X] I have read the [Contributing Guidelines](https://github.com/juspay/hyperswitch/blob/main/docs/CONTRIBUTING.md)

### :sparkles: Are you willing to submit a PR?

diff --git a/crates/router/src/connector/aci.rs b/crates/router/src/connector/aci.rs
index 0a6e0d8a609..0e325a04ddb 100644
--- a/crates/router/src/connector/aci.rs
+++ b/crates/router/src/connector/aci.rs
@@ -30,7 +30,9 @@ impl ConnectorCommon for Aci {
     fn id(&self) -> &'static str {
         "aci"
     }
-
+    fn get_currency_unit(&self) -> api::CurrencyUnit {
+        api::CurrencyUnit::Base
+    }
     fn common_get_content_type(&self) -> &'static str {
         "application/x-www-form-urlencoded"
     }
@@ -279,7 +281,13 @@ impl
         req: &types::PaymentsAuthorizeRouterData,
     ) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
         // encode only for for urlencoded things.
-        let connector_req = aci::AciPaymentsRequest::try_from(req)?;
+        let connector_router_data = aci::AciRouterData::try_from((
+            &self.get_currency_unit(),
+            req.request.currency,
+            req.request.amount,
+            req,
+        ))?;
+        let connector_req = aci::AciPaymentsRequest::try_from(&connector_router_data)?;
         let aci_req = types::RequestBody::log_and_get_request_body(
             &connector_req,
             utils::Encode::<aci::AciPaymentsRequest>::url_encode,
@@ -471,7 +479,13 @@ impl services::ConnectorIntegration<api::Execute, types::RefundsData, types::Ref
         &self,
         req: &types::RefundsRouterData<api::Execute>,
     ) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
-        let connector_req = aci::AciRefundRequest::try_from(req)?;
+        let connector_router_data = aci::AciRouterData::try_from((
+            &self.get_currency_unit(),
+            req.request.currency,
+            req.request.refund_amount,
+            req,
+        ))?;
+        let connector_req = aci::AciRefundRequest::try_from(&connector_router_data)?;
         let body = types::RequestBody::log_and_get_request_body(
             &connector_req,
             utils::Encode::<aci::AciRefundRequest>::url_encode,
diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rs
index f6c1daffe4d..f56369ed31a 100644
--- a/crates/router/src/connector/aci/transformers.rs
+++ b/crates/router/src/connector/aci/transformers.rs
@@ -17,6 +17,38 @@ use crate::{
 
 type Error = error_stack::Report<errors::ConnectorError>;
 
+#[derive(Debug, Serialize)]
+pub struct AciRouterData<T> {
+    amount: String,
+    router_data: T,
+}
+
+impl<T>
+    TryFrom<(
+        &types::api::CurrencyUnit,
+        types::storage::enums::Currency,
+        i64,
+        T,
+    )> for AciRouterData<T>
+{
+    type Error = error_stack::Report<errors::ConnectorError>;
+
+    fn try_from(
+        (currency_unit, currency, amount, item): (
+            &types::api::CurrencyUnit,
+            types::storage::enums::Currency,
+            i64,
+            T,
+        ),
+    ) -> Result<Self, Self::Error> {
+        let amount = utils::get_amount_as_string(currency_unit, amount, currency)?;
+        Ok(Self {
+            amount,
+            router_data: item,
+        })
+    }
+}
+
 pub struct AciAuthType {
     pub api_key: Secret<String>,
     pub entity_id: Secret<String>,
@@ -101,14 +133,14 @@ impl TryFrom<&api_models::payments::WalletData> for PaymentDetails {
 
 impl
     TryFrom<(
-        &types::PaymentsAuthorizeRouterData,
+        &AciRouterData<&types::PaymentsAuthorizeRouterData>,
         &api_models::payments::BankRedirectData,
     )> for PaymentDetails
 {
     type Error = Error;
     fn try_from(
         value: (
-            &types::PaymentsAuthorizeRouterData,
+            &AciRouterData<&types::PaymentsAuthorizeRouterData>,
             &api_models::payments::BankRedirectData,
         ),
     ) -> Result<Self, Self::Error> {
@@ -202,9 +234,9 @@ impl
                     bank_account_bic: None,
                     bank_account_iban: None,
                     billing_country: Some(country.to_owned()),
-                    merchant_customer_id: Some(Secret::new(item.get_customer_id()?)),
+                    merchant_customer_id: Some(Secret::new(item.router_data.get_customer_id()?)),
                     merchant_transaction_id: Some(Secret::new(
-                        item.connector_request_reference_id.clone(),
+                        item.router_data.connector_request_reference_id.clone(),
                     )),
                     customer_email: None,
                 }))
@@ -348,10 +380,12 @@ pub enum AciPaymentType {
     Refund,
 }
 
-impl TryFrom<&types::PaymentsAuthorizeRouterData> for AciPaymentsRequest {
+impl TryFrom<&AciRouterData<&types::PaymentsAuthorizeRouterData>> for AciPaymentsRequest {
     type Error = error_stack::Report<errors::ConnectorError>;
-    fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
-        match item.request.payment_method_data.clone() {
+    fn try_from(
+        item: &AciRouterData<&types::PaymentsAuthorizeRouterData>,
+    ) -> Result<Self, Self::Error> {
+        match item.router_data.request.payment_method_data.clone() {
             api::PaymentMethodData::Card(ref card_data) => Self::try_from((item, card_data)),
             api::PaymentMethodData::Wallet(ref wallet_data) => Self::try_from((item, wallet_data)),
             api::PaymentMethodData::PayLater(ref pay_later_data) => {
@@ -361,7 +395,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AciPaymentsRequest {
                 Self::try_from((item, bank_redirect_data))
             }
             api::PaymentMethodData::MandatePayment => {
-                let mandate_id = item.request.mandate_id.clone().ok_or(
+                let mandate_id = item.router_data.request.mandate_id.clone().ok_or(
                     errors::ConnectorError::MissingRequiredField {
                         field_name: "mandate_id",
                     },
@@ -376,7 +410,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AciPaymentsRequest {
             | api::PaymentMethodData::CardRedirect(_)
             | api::PaymentMethodData::Upi(_)
             | api::PaymentMethodData::Voucher(_) => Err(errors::ConnectorError::NotSupported {
-                message: format!("{:?}", item.payment_method),
+                message: format!("{:?}", item.router_data.payment_method),
                 connector: "Aci",
             })?,
         }
@@ -385,14 +419,14 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AciPaymentsRequest {
 
 impl
     TryFrom<(
-        &types::PaymentsAuthorizeRouterData,
+        &AciRouterData<&types::PaymentsAuthorizeRouterData>,
         &api_models::payments::WalletData,
     )> for AciPaymentsRequest
 {
     type Error = Error;
     fn try_from(
         value: (
-            &types::PaymentsAuthorizeRouterData,
+            &AciRouterData<&types::PaymentsAuthorizeRouterData>,
             &api_models::payments::WalletData,
         ),
     ) -> Result<Self, Self::Error> {
@@ -404,21 +438,21 @@ impl
             txn_details,
             payment_method,
             instruction: None,
-            shopper_result_url: item.request.router_return_url.clone(),
+            shopper_result_url: item.router_data.request.router_return_url.clone(),
         })
     }
 }
 
 impl
     TryFrom<(
-        &types::PaymentsAuthorizeRouterData,
+        &AciRouterData<&types::PaymentsAuthorizeRouterData>,
         &api_models::payments::BankRedirectData,
     )> for AciPaymentsRequest
 {
     type Error = Error;
     fn try_from(
         value: (
-            &types::PaymentsAuthorizeRouterData,
+            &AciRouterData<&types::PaymentsAuthorizeRouterData>,
             &api_models::payments::BankRedirectData,
         ),
     ) -> Result<Self, Self::Error> {
@@ -430,21 +464,21 @@ impl
             txn_details,
             payment_method,
             instruction: None,
-            shopper_result_url: item.request.router_return_url.clone(),
+            shopper_result_url: item.router_data.request.router_return_url.clone(),
         })
     }
 }
 
 impl
     TryFrom<(
-        &types::PaymentsAuthorizeRouterData,
+        &AciRouterData<&types::PaymentsAuthorizeRouterData>,
         &api_models::payments::PayLaterData,
     )> for AciPaymentsRequest
 {
     type Error = Error;
     fn try_from(
         value: (
-            &types::PaymentsAuthorizeRouterData,
+            &AciRouterData<&types::PaymentsAuthorizeRouterData>,
             &api_models::payments::PayLaterData,
         ),
     ) -> Result<Self, Self::Error> {
@@ -456,15 +490,23 @@ impl
             txn_details,
             payment_method,
             instruction: None,
-            shopper_result_url: item.request.router_return_url.clone(),
+            shopper_result_url: item.router_data.request.router_return_url.clone(),
         })
     }
 }
 
-impl TryFrom<(&types::PaymentsAuthorizeRouterData, &api::Card)> for AciPaymentsRequest {
+impl
+    TryFrom<(
+        &AciRouterData<&types::PaymentsAuthorizeRouterData>,
+        &api::Card,
+    )> for AciPaymentsRequest
+{
     type Error = Error;
     fn try_from(
-        value: (&types::PaymentsAuthorizeRouterData, &api::Card),
+        value: (
+            &AciRouterData<&types::PaymentsAuthorizeRouterData>,
+            &api::Card,
+        ),
     ) -> Result<Self, Self::Error> {
         let (item, card_data) = value;
         let txn_details = get_transaction_details(item)?;
@@ -482,14 +524,14 @@ impl TryFrom<(&types::PaymentsAuthorizeRouterData, &api::Card)> for AciPaymentsR
 
 impl
     TryFrom<(
-        &types::PaymentsAuthorizeRouterData,
+        &AciRouterData<&types::PaymentsAuthorizeRouterData>,
         api_models::payments::MandateIds,
     )> for AciPaymentsRequest
 {
     type Error = Error;
     fn try_from(
         value: (
-            &types::PaymentsAuthorizeRouterData,
+            &AciRouterData<&types::PaymentsAuthorizeRouterData>,
             api_models::payments::MandateIds,
         ),
     ) -> Result<Self, Self::Error> {
@@ -501,32 +543,34 @@ impl
             txn_details,
             payment_method: PaymentDetails::Mandate,
             instruction,
-            shopper_result_url: item.request.router_return_url.clone(),
+            shopper_result_url: item.router_data.request.router_return_url.clone(),
         })
     }
 }
 
 fn get_transaction_details(
-    item: &types::PaymentsAuthorizeRouterData,
+    item: &AciRouterData<&types::PaymentsAuthorizeRouterData>,
 ) -> Result<TransactionDetails, error_stack::Report<errors::ConnectorError>> {
-    let auth = AciAuthType::try_from(&item.connector_auth_type)?;
+    let auth = AciAuthType::try_from(&item.router_data.connector_auth_type)?;
     Ok(TransactionDetails {
         entity_id: auth.entity_id,
-        amount: utils::to_currency_base_unit(item.request.amount, item.request.currency)?,
-        currency: item.request.currency.to_string(),
+        amount: item.amount.to_owned(),
+        currency: item.router_data.request.currency.to_string(),
         payment_type: AciPaymentType::Debit,
     })
 }
 
-fn get_instruction_details(item: &types::PaymentsAuthorizeRouterData) -> Option<Instruction> {
-    if item.request.setup_mandate_details.is_some() {
+fn get_instruction_details(
+    item: &AciRouterData<&types::PaymentsAuthorizeRouterData>,
+) -> Option<Instruction> {
+    if item.router_data.request.setup_mandate_details.is_some() {
         return Some(Instruction {
             mode: InstructionMode::Initial,
             transaction_type: InstructionType::Unscheduled,
             source: InstructionSource::CardholderInitiatedTransaction,
             create_registration: Some(true),
         });
-    } else if item.request.mandate_id.is_some() {
+    } else if item.router_data.request.mandate_id.is_some() {
         return Some(Instruction {
             mode: InstructionMode::Repeated,
             transaction_type: InstructionType::Unscheduled,
@@ -703,14 +747,13 @@ pub struct AciRefundRequest {
     pub entity_id: Secret<String>,
 }
 
-impl<F> TryFrom<&types::RefundsRouterData<F>> for AciRefundRequest {
+impl<F> TryFrom<&AciRouterData<&types::RefundsRouterData<F>>> for AciRefundRequest {
     type Error = error_stack::Report<errors::ConnectorError>;
-    fn try_from(item: &types::RefundsRouterData<F>) -> Result<Self, Self::Error> {
-        let amount =
-            utils::to_currency_base_unit(item.request.refund_amount, item.request.currency)?;
-        let currency = item.request.currency;
+    fn try_from(item: &AciRouterData<&types::RefundsRouterData<F>>) -> Result<Self, Self::Error> {
+        let amount = item.amount.to_owned();
+        let currency = item.router_data.request.currency;
         let payment_type = AciPaymentType::Refund;
-        let auth = AciAuthType::try_from(&item.connector_auth_type)?;
+        let auth = AciAuthType::try_from(&item.router_data.connector_auth_type)?;
 
         Ok(Self {
             amount,

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

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

## Description
<!-- Describe your changes in detail -->


### 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`
- [x] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
- [ ] I added a [CHANGELOG](/CHANGELOG.md) entry if applicable
