Bug: [REFACTOR]: [PAYU] Add amount conversion framework to Payu



### :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://docs.payu.in/reference/refund_transaction_api) 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?

- [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)

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

diff --git a/crates/hyperswitch_connectors/src/connectors/payu.rs b/crates/hyperswitch_connectors/src/connectors/payu.rs
index 05f983b8fbb..ad2479f19e4 100644
--- a/crates/hyperswitch_connectors/src/connectors/payu.rs
+++ b/crates/hyperswitch_connectors/src/connectors/payu.rs
@@ -6,6 +6,7 @@ use common_utils::{
     errors::CustomResult,
     ext_traits::ByteSliceExt,
     request::{Method, Request, RequestBuilder, RequestContent},
+    types::{AmountConvertor, MinorUnit, MinorUnitForConnector},
 };
 use error_stack::{report, ResultExt};
 use hyperswitch_domain_models::{
@@ -43,11 +44,22 @@ use transformers as payu;
 use crate::{
     constants::headers,
     types::{RefreshTokenRouterData, ResponseRouterData},
+    utils,
     utils::construct_not_supported_error_report,
 };
 
-#[derive(Debug, Clone)]
-pub struct Payu;
+#[derive(Clone)]
+pub struct Payu {
+    amount_converter: &'static (dyn AmountConvertor<Output = MinorUnit> + Sync),
+}
+
+impl Payu {
+    pub fn new() -> &'static Self {
+        &Self {
+            amount_converter: &MinorUnitForConnector,
+        }
+    }
+}
 
 impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Payu
 where
@@ -538,7 +550,15 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
         req: &PaymentsAuthorizeRouterData,
         _connectors: &Connectors,
     ) -> CustomResult<RequestContent, errors::ConnectorError> {
-        let connector_req = payu::PayuPaymentsRequest::try_from(req)?;
+        let amount = utils::convert_amount(
+            self.amount_converter,
+            req.request.minor_amount,
+            req.request.currency,
+        )?;
+
+        let connector_router_data = payu::PayuRouterData::try_from((amount, req))?;
+
+        let connector_req = payu::PayuPaymentsRequest::try_from(&connector_router_data)?;
         Ok(RequestContent::Json(Box::new(connector_req)))
     }
 
@@ -625,7 +645,14 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Payu {
         req: &RefundsRouterData<Execute>,
         _connectors: &Connectors,
     ) -> CustomResult<RequestContent, errors::ConnectorError> {
-        let connector_req = payu::PayuRefundRequest::try_from(req)?;
+        let amount = utils::convert_amount(
+            self.amount_converter,
+            req.request.minor_refund_amount,
+            req.request.currency,
+        )?;
+
+        let connector_router_data = payu::PayuRouterData::try_from((amount, req))?;
+        let connector_req = payu::PayuRefundRequest::try_from(&connector_router_data)?;
         Ok(RequestContent::Json(Box::new(connector_req)))
     }
 
diff --git a/crates/hyperswitch_connectors/src/connectors/payu/transformers.rs b/crates/hyperswitch_connectors/src/connectors/payu/transformers.rs
index 4ebc09a0023..9bdb52de4f0 100644
--- a/crates/hyperswitch_connectors/src/connectors/payu/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/payu/transformers.rs
@@ -3,6 +3,7 @@ use common_enums::enums;
 use common_utils::{
     consts::BASE64_ENGINE,
     pii::{Email, IpAddress},
+    types::MinorUnit,
 };
 use error_stack::ResultExt;
 use hyperswitch_domain_models::{
@@ -24,12 +25,28 @@ use crate::{
 
 const WALLET_IDENTIFIER: &str = "PBL";
 
-#[derive(Debug, Serialize, Eq, PartialEq)]
+#[derive(Debug, Serialize)]
+pub struct PayuRouterData<T> {
+    pub amount: MinorUnit,
+    pub router_data: T,
+}
+
+impl<T> TryFrom<(MinorUnit, T)> for PayuRouterData<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,
+        })
+    }
+}
+
+#[derive(Debug, Serialize)]
 #[serde(rename_all = "camelCase")]
 pub struct PayuPaymentsRequest {
     customer_ip: Secret<String, IpAddress>,
     merchant_pos_id: Secret<String>,
-    total_amount: i64,
+    total_amount: MinorUnit,
     currency_code: enums::Currency,
     description: String,
     pay_methods: PayuPaymentMethod,
@@ -77,11 +94,13 @@ pub enum PayuWalletCode {
     Jp,
 }
 
-impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest {
+impl TryFrom<&PayuRouterData<&types::PaymentsAuthorizeRouterData>> for PayuPaymentsRequest {
     type Error = error_stack::Report<errors::ConnectorError>;
-    fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
-        let auth_type = PayuAuthType::try_from(&item.connector_auth_type)?;
-        let payment_method = match item.request.payment_method_data.clone() {
+    fn try_from(
+        item: &PayuRouterData<&types::PaymentsAuthorizeRouterData>,
+    ) -> Result<Self, Self::Error> {
+        let auth_type = PayuAuthType::try_from(&item.router_data.connector_auth_type)?;
+        let payment_method = match item.router_data.request.payment_method_data.clone() {
             PaymentMethodData::Card(ccard) => Ok(PayuPaymentMethod {
                 pay_method: PayuPaymentMethodData::Card(PayuCard::Card {
                     number: ccard.card_number,
@@ -119,7 +138,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest {
                 "Unknown payment method".to_string(),
             )),
         }?;
-        let browser_info = item.request.browser_info.clone().ok_or(
+        let browser_info = item.router_data.request.browser_info.clone().ok_or(
             errors::ConnectorError::MissingRequiredField {
                 field_name: "browser_info",
             },
@@ -134,10 +153,10 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for PayuPaymentsRequest {
                     .to_string(),
             ),
             merchant_pos_id: auth_type.merchant_pos_id,
-            ext_order_id: Some(item.connector_request_reference_id.clone()),
-            total_amount: item.request.amount,
-            currency_code: item.request.currency,
-            description: item.description.clone().ok_or(
+            ext_order_id: Some(item.router_data.connector_request_reference_id.clone()),
+            total_amount: item.amount.to_owned(),
+            currency_code: item.router_data.request.currency,
+            description: item.router_data.description.clone().ok_or(
                 errors::ConnectorError::MissingRequiredField {
                     field_name: "item.description",
                 },
@@ -488,10 +507,10 @@ impl<F, T> TryFrom<ResponseRouterData<F, PayuPaymentsSyncResponse, T, PaymentsRe
     }
 }
 
-#[derive(Default, Debug, Eq, PartialEq, Serialize)]
+#[derive(Default, Debug, Serialize)]
 pub struct PayuRefundRequestData {
     description: String,
-    amount: Option<i64>,
+    amount: Option<MinorUnit>,
 }
 
 #[derive(Default, Debug, Serialize)]
@@ -499,12 +518,12 @@ pub struct PayuRefundRequest {
     refund: PayuRefundRequestData,
 }
 
-impl<F> TryFrom<&types::RefundsRouterData<F>> for PayuRefundRequest {
+impl<F> TryFrom<&PayuRouterData<&types::RefundsRouterData<F>>> for PayuRefundRequest {
     type Error = error_stack::Report<errors::ConnectorError>;
-    fn try_from(item: &types::RefundsRouterData<F>) -> Result<Self, Self::Error> {
+    fn try_from(item: &PayuRouterData<&types::RefundsRouterData<F>>) -> Result<Self, Self::Error> {
         Ok(Self {
             refund: PayuRefundRequestData {
-                description: item.request.reason.clone().ok_or(
+                description: item.router_data.request.reason.clone().ok_or(
                     errors::ConnectorError::MissingRequiredField {
                         field_name: "item.request.reason",
                     },
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index b85ae5bfab2..a3046213272 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -458,7 +458,7 @@ impl ConnectorData {
                 enums::Connector::Payone => {
                     Ok(ConnectorEnum::Old(Box::new(connector::Payone::new())))
                 }
-                enums::Connector::Payu => Ok(ConnectorEnum::Old(Box::new(&connector::Payu))),
+                enums::Connector::Payu => Ok(ConnectorEnum::Old(Box::new(connector::Payu::new()))),
                 enums::Connector::Placetopay => {
                     Ok(ConnectorEnum::Old(Box::new(connector::Placetopay::new())))
                 }
diff --git a/crates/router/tests/connectors/payu.rs b/crates/router/tests/connectors/payu.rs
index b0e5e9ec6a1..9bb3785bbd6 100644
--- a/crates/router/tests/connectors/payu.rs
+++ b/crates/router/tests/connectors/payu.rs
@@ -11,7 +11,7 @@ impl Connector for Payu {
     fn get_data(&self) -> types::api::ConnectorData {
         use router::connector::Payu;
         utils::construct_connector_data_old(
-            Box::new(&Payu),
+            Box::new(Payu::new()),
             types::Connector::Payu,
             types::api::GetToken::Connector,
             None,

## 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 payu, for sending to connector. 
fixes #5961 


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