Bug: [FEATURE]: [Worldpay] 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/worldpay.rs b/crates/router/src/connector/worldpay.rs
index 0c69cd981bb..60a5fc83045 100644
--- a/crates/router/src/connector/worldpay.rs
+++ b/crates/router/src/connector/worldpay.rs
@@ -56,6 +56,10 @@ impl ConnectorCommon for Worldpay {
         "worldpay"
     }
 
+    fn get_currency_unit(&self) -> api::CurrencyUnit {
+        api::CurrencyUnit::Minor
+    }
+
     fn common_get_content_type(&self) -> &'static str {
         "application/vnd.worldpay.payments-v6+json"
     }
@@ -428,7 +432,13 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
         &self,
         req: &types::PaymentsAuthorizeRouterData,
     ) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
-        let connector_request = WorldpayPaymentsRequest::try_from(req)?;
+        let connector_router_data = worldpay::WorldpayRouterData::try_from((
+            &self.get_currency_unit(),
+            req.request.currency,
+            req.request.amount,
+            req,
+        ))?;
+        let connector_request = WorldpayPaymentsRequest::try_from(&connector_router_data)?;
         let worldpay_payment_request = types::RequestBody::log_and_get_request_body(
             &connector_request,
             ext_traits::Encode::<WorldpayPaymentsRequest>::encode_to_string_of_json,
diff --git a/crates/router/src/connector/worldpay/transformers.rs b/crates/router/src/connector/worldpay/transformers.rs
index 3d467f4198f..aabe27fc4eb 100644
--- a/crates/router/src/connector/worldpay/transformers.rs
+++ b/crates/router/src/connector/worldpay/transformers.rs
@@ -3,15 +3,44 @@ use common_utils::errors::CustomResult;
 use diesel_models::enums;
 use error_stack::{IntoReport, ResultExt};
 use masking::{PeekInterface, Secret};
+use serde::Serialize;
 
 use super::{requests::*, response::*};
 use crate::{
     connector::utils,
     consts,
     core::errors,
-    types::{self, api},
+    types::{self, api, PaymentsAuthorizeData, PaymentsResponseData},
 };
 
+#[derive(Debug, Serialize)]
+pub struct WorldpayRouterData<T> {
+    amount: i64,
+    router_data: T,
+}
+impl<T>
+    TryFrom<(
+        &types::api::CurrencyUnit,
+        types::storage::enums::Currency,
+        i64,
+        T,
+    )> for WorldpayRouterData<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,
+            router_data: item,
+        })
+    }
+}
 fn fetch_payment_instrument(
     payment_method: api::PaymentMethodData,
 ) -> CustomResult<PaymentInstrument, errors::ConnectorError> {
@@ -100,29 +129,48 @@ fn fetch_payment_instrument(
     }
 }
 
-impl TryFrom<&types::PaymentsAuthorizeRouterData> for WorldpayPaymentsRequest {
+impl
+    TryFrom<
+        &WorldpayRouterData<
+            &types::RouterData<
+                types::api::payments::Authorize,
+                PaymentsAuthorizeData,
+                PaymentsResponseData,
+            >,
+        >,
+    > for WorldpayPaymentsRequest
+{
     type Error = error_stack::Report<errors::ConnectorError>;
-    fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
+
+    fn try_from(
+        item: &WorldpayRouterData<
+            &types::RouterData<
+                types::api::payments::Authorize,
+                PaymentsAuthorizeData,
+                PaymentsResponseData,
+            >,
+        >,
+    ) -> Result<Self, Self::Error> {
         Ok(Self {
             instruction: Instruction {
                 value: PaymentValue {
-                    amount: item.request.amount,
-                    currency: item.request.currency.to_string(),
+                    amount: item.amount,
+                    currency: item.router_data.request.currency.to_string(),
                 },
                 narrative: InstructionNarrative {
-                    line1: item.merchant_id.clone().replace('_', "-"),
+                    line1: item.router_data.merchant_id.clone().replace('_', "-"),
                     ..Default::default()
                 },
                 payment_instrument: fetch_payment_instrument(
-                    item.request.payment_method_data.clone(),
+                    item.router_data.request.payment_method_data.clone(),
                 )?,
                 debt_repayment: None,
             },
             merchant: Merchant {
-                entity: item.attempt_id.clone().replace('_', "-"),
+                entity: item.router_data.attempt_id.clone().replace('_', "-"),
                 ..Default::default()
             },
-            transaction_reference: item.attempt_id.clone(),
+            transaction_reference: item.router_data.attempt_id.clone(),
             channel: None,
             customer: None,
         })
diff --git a/package.json b/package.json
index 0766efdcc17..45d2be3153b 100644
--- a/package.json
+++ b/package.json
@@ -6,4 +6,4 @@
   "devDependencies": {
     "newman": "git+ssh://git@github.com:knutties/newman.git#7106e194c15d49d066fa09d9a2f18b2238f3dba8"
   }
-}
+}
\ No newline at end of file

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

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

## Description
<!-- Describe your changes in detail -->
This pull request implements the get_currency_unit from the ConnectorCommon trait for the Worldpay connector. This function allows connectors to declare their accepted currency unit as either Base or Minor. For Worldpay it accepts currency as Minor units.

### Additional Changes

- [ ] This PR modifies the API contract
- [ ] This PR modifies the database schema
- [ ] This PR modifies application configuration/environment variables

### Links to the files with corresponding changes.

1. crates\router\src\connector\worldpay.rs
2. crates\router\src\connector\worldpay\transformers.rs


## 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).
-->
Closes #2250.

## How did you test it?
I tried setting up and testing using VS code and codesandbox but was not able to do it.
So kindly review the changes and do let me know if any further issues.


## Checklist
<!-- Put an `x` in the boxes that apply -->

- [x] I formatted the code `cargo +nightly fmt --all`
- [ ] I addressed lints thrown by `cargo clippy`
- [ ] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
- [ ] I added a [CHANGELOG](/CHANGELOG.md) entry if applicable
