Bug: [FEATURE]: [IataPay] 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/iatapay.rs b/crates/router/src/connector/iatapay.rs
index 3a813c50cf6..4db2faa2d42 100644
--- a/crates/router/src/connector/iatapay.rs
+++ b/crates/router/src/connector/iatapay.rs
@@ -90,6 +90,10 @@ impl ConnectorCommon for Iatapay {
         "application/json"
     }
 
+    fn get_currency_unit(&self) -> api::CurrencyUnit {
+        api::CurrencyUnit::Base
+    }
+
     fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
         connectors.iatapay.base_url.as_ref()
     }
@@ -271,7 +275,13 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
         &self,
         req: &types::PaymentsAuthorizeRouterData,
     ) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
-        let req_obj = iatapay::IatapayPaymentsRequest::try_from(req)?;
+        let connector_router_data = iatapay::IatapayRouterData::try_from((
+            &self.get_currency_unit(),
+            req.request.currency,
+            req.request.amount,
+            req,
+        ))?;
+        let req_obj = iatapay::IatapayPaymentsRequest::try_from(&connector_router_data)?;
         let iatapay_req = types::RequestBody::log_and_get_request_body(
             &req_obj,
             Encode::<iatapay::IatapayPaymentsRequest>::encode_to_string_of_json,
@@ -451,7 +461,13 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
         &self,
         req: &types::RefundsRouterData<api::Execute>,
     ) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
-        let req_obj = iatapay::IatapayRefundRequest::try_from(req)?;
+        let connector_router_data = iatapay::IatapayRouterData::try_from((
+            &self.get_currency_unit(),
+            req.request.currency,
+            req.request.payment_amount,
+            req,
+        ))?;
+        let req_obj = iatapay::IatapayRefundRequest::try_from(&connector_router_data)?;
         let iatapay_req = types::RequestBody::log_and_get_request_body(
             &req_obj,
             Encode::<iatapay::IatapayRefundRequest>::encode_to_string_of_json,
diff --git a/crates/router/src/connector/iatapay/transformers.rs b/crates/router/src/connector/iatapay/transformers.rs
index d4731b024c8..7cdfafc858b 100644
--- a/crates/router/src/connector/iatapay/transformers.rs
+++ b/crates/router/src/connector/iatapay/transformers.rs
@@ -8,7 +8,7 @@ use crate::{
     connector::utils::{self, PaymentsAuthorizeRequestData, RefundsRequestData, RouterData},
     core::errors,
     services,
-    types::{self, api, storage::enums},
+    types::{self, api, storage::enums, PaymentsAuthorizeData},
 };
 
 // Every access token will be valid for 5 minutes. It contains grant_type and scope for different type of access, but for our usecases it should be only 'client_credentials' and 'payment' resp(as per doc) for all type of api call.
@@ -26,7 +26,34 @@ impl TryFrom<&types::RefreshTokenRouterData> for IatapayAuthUpdateRequest {
         })
     }
 }
-
+#[derive(Debug, Serialize)]
+pub struct IatapayRouterData<T> {
+    amount: f64,
+    router_data: T,
+}
+impl<T>
+    TryFrom<(
+        &types::api::CurrencyUnit,
+        types::storage::enums::Currency,
+        i64,
+        T,
+    )> for IatapayRouterData<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> {
+        Ok(Self {
+            amount: utils::to_currency_base_unit_asf64(_amount, _currency)?,
+            router_data: item,
+        })
+    }
+}
 #[derive(Debug, Deserialize)]
 pub struct IatapayAuthUpdateResponse {
     pub access_token: Secret<String>,
@@ -80,10 +107,29 @@ pub struct IatapayPaymentsRequest {
     payer_info: Option<PayerInfo>,
 }
 
-impl TryFrom<&types::PaymentsAuthorizeRouterData> for IatapayPaymentsRequest {
+impl
+    TryFrom<
+        &IatapayRouterData<
+            &types::RouterData<
+                types::api::payments::Authorize,
+                PaymentsAuthorizeData,
+                types::PaymentsResponseData,
+            >,
+        >,
+    > for IatapayPaymentsRequest
+{
     type Error = error_stack::Report<errors::ConnectorError>;
-    fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
-        let payment_method = item.payment_method;
+
+    fn try_from(
+        item: &IatapayRouterData<
+            &types::RouterData<
+                types::api::payments::Authorize,
+                PaymentsAuthorizeData,
+                types::PaymentsResponseData,
+            >,
+        >,
+    ) -> Result<Self, Self::Error> {
+        let payment_method = item.router_data.payment_method;
         let country = match payment_method {
             PaymentMethod::Upi => "IN".to_string(),
 
@@ -97,27 +143,26 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for IatapayPaymentsRequest {
             | PaymentMethod::BankDebit
             | PaymentMethod::Reward
             | PaymentMethod::Voucher
-            | PaymentMethod::GiftCard => item.get_billing_country()?.to_string(),
+            | PaymentMethod::GiftCard => item.router_data.get_billing_country()?.to_string(),
         };
-        let return_url = item.get_return_url()?;
-        let payer_info = match item.request.payment_method_data.clone() {
+        let return_url = item.router_data.get_return_url()?;
+        let payer_info = match item.router_data.request.payment_method_data.clone() {
             api::PaymentMethodData::Upi(upi_data) => upi_data.vpa_id.map(|id| PayerInfo {
                 token_id: id.switch_strategy(),
             }),
             _ => None,
         };
-        let amount =
-            utils::to_currency_base_unit_asf64(item.request.amount, item.request.currency)?;
         let payload = Self {
-            merchant_id: IatapayAuthType::try_from(&item.connector_auth_type)?.merchant_id,
-            merchant_payment_id: Some(item.connector_request_reference_id.clone()),
-            amount,
-            currency: item.request.currency.to_string(),
+            merchant_id: IatapayAuthType::try_from(&item.router_data.connector_auth_type)?
+                .merchant_id,
+            merchant_payment_id: Some(item.router_data.connector_request_reference_id.clone()),
+            amount: item.amount,
+            currency: item.router_data.request.currency.to_string(),
             country: country.clone(),
             locale: format!("en-{}", country),
             redirect_urls: get_redirect_url(return_url),
             payer_info,
-            notification_url: item.request.get_webhook_url()?,
+            notification_url: item.router_data.request.get_webhook_url()?,
         };
         Ok(payload)
     }
@@ -275,18 +320,19 @@ pub struct IatapayRefundRequest {
     pub notification_url: String,
 }
 
-impl<F> TryFrom<&types::RefundsRouterData<F>> for IatapayRefundRequest {
+impl<F> TryFrom<&IatapayRouterData<&types::RefundsRouterData<F>>> for IatapayRefundRequest {
     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_asf64(item.request.refund_amount, item.request.currency)?;
+    fn try_from(
+        item: &IatapayRouterData<&types::RefundsRouterData<F>>,
+    ) -> Result<Self, Self::Error> {
         Ok(Self {
-            amount,
-            merchant_id: IatapayAuthType::try_from(&item.connector_auth_type)?.merchant_id,
-            merchant_refund_id: Some(item.request.refund_id.clone()),
-            currency: item.request.currency.to_string(),
-            bank_transfer_description: item.request.reason.clone(),
-            notification_url: item.request.get_webhook_url()?,
+            amount: item.amount,
+            merchant_id: IatapayAuthType::try_from(&item.router_data.connector_auth_type)?
+                .merchant_id,
+            merchant_refund_id: Some(item.router_data.request.refund_id.clone()),
+            currency: item.router_data.request.currency.to_string(),
+            bank_transfer_description: item.router_data.request.reason.clone(),
+            notification_url: item.router_data.request.get_webhook_url()?,
         })
     }
 }

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

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

## Description
- Addresses issue #2229  
- Modified the files `hyperswitch/crates/router/src/connector/iatapay/transformers.rs` and `hyperswitch/crates/router/src/connector/iatapay.rs`
- Rebased with most recent changes


### 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)?
-->
We need to create a payment using Iatapay and test the currency unit from connector response and connector dashboard.

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