Bug: [REFACTOR]: [TSYS] Add amount conversion framework to Tsys



### :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://developers.tsys.com/api/product?key=Authentication+Platform) 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?

diff --git a/crates/hyperswitch_connectors/src/connectors/tsys.rs b/crates/hyperswitch_connectors/src/connectors/tsys.rs
index ec53a99316f..25b47981def 100644
--- a/crates/hyperswitch_connectors/src/connectors/tsys.rs
+++ b/crates/hyperswitch_connectors/src/connectors/tsys.rs
@@ -1,12 +1,11 @@
 pub mod transformers;
 
-use std::fmt::Debug;
-
 use common_enums::enums;
 use common_utils::{
     errors::CustomResult,
     ext_traits::BytesExt,
     request::{Method, Request, RequestBuilder, RequestContent},
+    types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector},
 };
 use error_stack::{report, ResultExt};
 use hyperswitch_domain_models::{
@@ -41,10 +40,18 @@ use hyperswitch_interfaces::{
 use transformers as tsys;
 
 use crate::{constants::headers, types::ResponseRouterData, utils};
+#[derive(Clone)]
+pub struct Tsys {
+    amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync),
+}
 
-#[derive(Debug, Clone)]
-pub struct Tsys;
-
+impl Tsys {
+    pub fn new() -> &'static Self {
+        &Self {
+            amount_converter: &StringMinorUnitForConnector,
+        }
+    }
+}
 impl api::Payment for Tsys {}
 impl api::PaymentSession for Tsys {}
 impl api::ConnectorAccessToken for Tsys {}
@@ -156,7 +163,14 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
         req: &PaymentsAuthorizeRouterData,
         _connectors: &Connectors,
     ) -> CustomResult<RequestContent, errors::ConnectorError> {
-        let connector_req = tsys::TsysPaymentsRequest::try_from(req)?;
+        let amount = utils::convert_amount(
+            self.amount_converter,
+            req.request.minor_amount,
+            req.request.currency,
+        )?;
+        let connector_router_data = tsys::TsysRouterData::from((amount, req));
+        let connector_req: transformers::TsysPaymentsRequest =
+            tsys::TsysPaymentsRequest::try_from(&connector_router_data)?;
         Ok(RequestContent::Json(Box::new(connector_req)))
     }
 
@@ -316,7 +330,13 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
         req: &PaymentsCaptureRouterData,
         _connectors: &Connectors,
     ) -> CustomResult<RequestContent, errors::ConnectorError> {
-        let connector_req = tsys::TsysPaymentsCaptureRequest::try_from(req)?;
+        let amount = utils::convert_amount(
+            self.amount_converter,
+            req.request.minor_amount_to_capture,
+            req.request.currency,
+        )?;
+        let connector_router_data = tsys::TsysRouterData::from((amount, req));
+        let connector_req = tsys::TsysPaymentsCaptureRequest::try_from(&connector_router_data)?;
         Ok(RequestContent::Json(Box::new(connector_req)))
     }
 
@@ -473,7 +493,14 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Tsys {
         req: &RefundsRouterData<Execute>,
         _connectors: &Connectors,
     ) -> CustomResult<RequestContent, errors::ConnectorError> {
-        let connector_req = tsys::TsysRefundRequest::try_from(req)?;
+        let amount = utils::convert_amount(
+            self.amount_converter,
+            req.request.minor_refund_amount,
+            req.request.currency,
+        )?;
+        let connector_router_data = tsys::TsysRouterData::from((amount, req));
+
+        let connector_req = tsys::TsysRefundRequest::try_from(&connector_router_data)?;
         Ok(RequestContent::Json(Box::new(connector_req)))
     }
 
diff --git a/crates/hyperswitch_connectors/src/connectors/tsys/transformers.rs b/crates/hyperswitch_connectors/src/connectors/tsys/transformers.rs
index e97cf228729..0e47edf294c 100644
--- a/crates/hyperswitch_connectors/src/connectors/tsys/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/tsys/transformers.rs
@@ -1,4 +1,5 @@
 use common_enums::enums;
+use common_utils::types::StringMinorUnit;
 use error_stack::ResultExt;
 use hyperswitch_domain_models::{
     payment_method_data::PaymentMethodData,
@@ -7,13 +8,26 @@ use hyperswitch_domain_models::{
     router_request_types::ResponseId,
     router_response_types::{PaymentsResponseData, RefundsResponseData},
     types::{
-        self, PaymentsCancelRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData,
-        RefundSyncRouterData, RefundsRouterData,
+        self, PaymentsCancelRouterData, PaymentsSyncRouterData, RefundSyncRouterData,
+        RefundsRouterData,
     },
 };
 use hyperswitch_interfaces::errors;
 use masking::Secret;
 use serde::{Deserialize, Serialize};
+pub struct TsysRouterData<T> {
+    pub amount: StringMinorUnit,
+    pub router_data: T,
+}
+
+impl<T> From<(StringMinorUnit, T)> for TsysRouterData<T> {
+    fn from((amount, router_data): (StringMinorUnit, T)) -> Self {
+        Self {
+            amount,
+            router_data,
+        }
+    }
+}
 
 use crate::{
     types::{RefundsResponseRouterData, ResponseRouterData},
@@ -33,7 +47,7 @@ pub struct TsysPaymentAuthSaleRequest {
     device_id: Secret<String>,
     transaction_key: Secret<String>,
     card_data_source: String,
-    transaction_amount: String,
+    transaction_amount: StringMinorUnit,
     currency_code: enums::Currency,
     card_number: cards::CardNumber,
     expiration_date: Secret<String>,
@@ -46,9 +60,12 @@ pub struct TsysPaymentAuthSaleRequest {
     order_number: String,
 }
 
-impl TryFrom<&types::PaymentsAuthorizeRouterData> for TsysPaymentsRequest {
+impl TryFrom<&TsysRouterData<&types::PaymentsAuthorizeRouterData>> for TsysPaymentsRequest {
     type Error = error_stack::Report<errors::ConnectorError>;
-    fn try_from(item: &types::PaymentsAuthorizeRouterData) -> Result<Self, Self::Error> {
+    fn try_from(
+        item_data: &TsysRouterData<&types::PaymentsAuthorizeRouterData>,
+    ) -> Result<Self, Self::Error> {
+        let item = item_data.router_data.clone();
         match item.request.payment_method_data.clone() {
             PaymentMethodData::Card(ccard) => {
                 let connector_auth: TsysAuthType =
@@ -57,7 +74,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for TsysPaymentsRequest {
                     device_id: connector_auth.device_id,
                     transaction_key: connector_auth.transaction_key,
                     card_data_source: "INTERNET".to_string(),
-                    transaction_amount: item.request.amount.to_string(),
+                    transaction_amount: item_data.amount.clone(),
                     currency_code: item.request.currency,
                     card_number: ccard.card_number.clone(),
                     expiration_date: ccard
@@ -430,7 +447,7 @@ pub struct TsysCaptureRequest {
     #[serde(rename = "deviceID")]
     device_id: Secret<String>,
     transaction_key: Secret<String>,
-    transaction_amount: String,
+    transaction_amount: StringMinorUnit,
     #[serde(rename = "transactionID")]
     transaction_id: String,
     #[serde(rename = "developerID")]
@@ -444,16 +461,19 @@ pub struct TsysPaymentsCaptureRequest {
     capture: TsysCaptureRequest,
 }
 
-impl TryFrom<&PaymentsCaptureRouterData> for TsysPaymentsCaptureRequest {
+impl TryFrom<&TsysRouterData<&types::PaymentsCaptureRouterData>> for TsysPaymentsCaptureRequest {
     type Error = error_stack::Report<errors::ConnectorError>;
-    fn try_from(item: &PaymentsCaptureRouterData) -> Result<Self, Self::Error> {
+    fn try_from(
+        item_data: &TsysRouterData<&types::PaymentsCaptureRouterData>,
+    ) -> Result<Self, Self::Error> {
+        let item = item_data.router_data.clone();
         let connector_auth: TsysAuthType = TsysAuthType::try_from(&item.connector_auth_type)?;
         let capture = TsysCaptureRequest {
             device_id: connector_auth.device_id,
             transaction_key: connector_auth.transaction_key,
             transaction_id: item.request.connector_transaction_id.clone(),
             developer_id: connector_auth.developer_id,
-            transaction_amount: item.request.amount_to_capture.to_string(),
+            transaction_amount: item_data.amount.clone(),
         };
         Ok(Self { capture })
     }
@@ -466,7 +486,7 @@ pub struct TsysReturnRequest {
     #[serde(rename = "deviceID")]
     device_id: Secret<String>,
     transaction_key: Secret<String>,
-    transaction_amount: String,
+    transaction_amount: StringMinorUnit,
     #[serde(rename = "transactionID")]
     transaction_id: String,
 }
@@ -478,14 +498,15 @@ pub struct TsysRefundRequest {
     return_request: TsysReturnRequest,
 }
 
-impl<F> TryFrom<&RefundsRouterData<F>> for TsysRefundRequest {
+impl<F> TryFrom<&TsysRouterData<&RefundsRouterData<F>>> for TsysRefundRequest {
     type Error = error_stack::Report<errors::ConnectorError>;
-    fn try_from(item: &RefundsRouterData<F>) -> Result<Self, Self::Error> {
+    fn try_from(item_data: &TsysRouterData<&RefundsRouterData<F>>) -> Result<Self, Self::Error> {
+        let item = item_data.router_data;
         let connector_auth: TsysAuthType = TsysAuthType::try_from(&item.connector_auth_type)?;
         let return_request = TsysReturnRequest {
             device_id: connector_auth.device_id,
             transaction_key: connector_auth.transaction_key,
-            transaction_amount: item.request.refund_amount.to_string(),
+            transaction_amount: item_data.amount.clone(),
             transaction_id: item.request.connector_transaction_id.clone(),
         };
         Ok(Self { return_request })
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index 5300e86afdb..8c953939831 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -508,7 +508,7 @@ impl ConnectorData {
                 enums::Connector::Trustpay => {
                     Ok(ConnectorEnum::Old(Box::new(connector::Trustpay::new())))
                 }
-                enums::Connector::Tsys => Ok(ConnectorEnum::Old(Box::new(&connector::Tsys))),
+                enums::Connector::Tsys => Ok(ConnectorEnum::Old(Box::new(connector::Tsys::new()))),
 
                 enums::Connector::Volt => Ok(ConnectorEnum::Old(Box::new(connector::Volt::new()))),
                 enums::Connector::Wellsfargo => {
diff --git a/crates/router/tests/connectors/tsys.rs b/crates/router/tests/connectors/tsys.rs
index 4cda0b479b2..6a4843ac2cd 100644
--- a/crates/router/tests/connectors/tsys.rs
+++ b/crates/router/tests/connectors/tsys.rs
@@ -16,7 +16,7 @@ impl utils::Connector for TsysTest {
     fn get_data(&self) -> types::api::ConnectorData {
         use router::connector::Tsys;
         utils::construct_connector_data_old(
-            Box::new(&Tsys),
+            Box::new(Tsys::new()),
             types::Connector::Tsys,
             types::api::GetToken::Connector,
             None,

## Type of Change


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

## Description
added `StringMajorUnit` for amount conversion

### 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).
-->
Fixes #6097 


## 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`
- [ ] I addressed lints thrown by `cargo clippy`
- [ ] I reviewed the submitted code
- [ ] I added unit tests for my changes where possible
