Bug: [BUG] : [STAX] Incoming Amount is being processed as dollars instead of cents



### Bug Description

While creating a payment or a refund with connector Stax the incoming amount is being processed in it's higher decimal amount (e.g. Dollars) instead of processing it in it's lower units (e.g. Cents).

### Expected Behavior

The incoming amount to connector should be processed in lower units for connector Stax.

### Actual Behavior

The incoming amount to connector is being processed in higher decimal unit for connector Stax.

### Steps To Reproduce

The bug can be reproduced by attempting to create a payment or refund a payment with connector Stax.

### Context For The Bug

_No response_

### Environment

Are you using hyperswitch hosted version? Yes/No
If yes, please provide the value of the `x-request-id` response header to help us debug your issue.

If not (or if building/running locally), please provide the following details:
1. Operating System or Linux distribution:
2. Rust version (output of `rustc --version`): ``
3. App version (output of `cargo r --features vergen -- --version`): ``


### Have you spent some time checking if this bug has been raised before?

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

### Have you read the Contributing Guidelines?

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

### Are you willing to submit a PR?

Yes, I am willing to submit a PR!
diff --git a/crates/router/src/connector/stax/transformers.rs b/crates/router/src/connector/stax/transformers.rs
index d4a9aebeceb..e36f66abb71 100644
--- a/crates/router/src/connector/stax/transformers.rs
+++ b/crates/router/src/connector/stax/transformers.rs
@@ -1,10 +1,12 @@
 use common_utils::pii::Email;
-use error_stack::IntoReport;
+use error_stack::{IntoReport, ResultExt};
 use masking::{ExposeInterface, Secret};
 use serde::{Deserialize, Serialize};
 
 use crate::{
-    connector::utils::{missing_field_err, CardData, PaymentsAuthorizeRequestData, RouterData},
+    connector::utils::{
+        self, missing_field_err, CardData, PaymentsAuthorizeRequestData, RouterData,
+    },
     core::errors,
     types::{self, api, storage::enums},
 };
@@ -17,7 +19,7 @@ pub struct StaxPaymentsRequestMetaData {
 #[derive(Debug, Serialize)]
 pub struct StaxPaymentsRequest {
     payment_method_id: Secret<String>,
-    total: i64,
+    total: f64,
     is_refundable: bool,
     pre_auth: bool,
     meta: StaxPaymentsRequestMetaData,
@@ -32,12 +34,14 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for StaxPaymentsRequest {
                 connector: "Stax",
             })?
         }
+        let total = utils::to_currency_base_unit_asf64(item.request.amount, item.request.currency)?;
+
         match item.request.payment_method_data.clone() {
             api::PaymentMethodData::Card(_) => {
                 let pre_auth = !item.request.is_auto_capture()?;
                 Ok(Self {
                     meta: StaxPaymentsRequestMetaData { tax: 0 },
-                    total: item.request.amount,
+                    total,
                     is_refundable: true,
                     pre_auth,
                     payment_method_id: Secret::new(item.get_payment_method_token()?),
@@ -49,7 +53,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for StaxPaymentsRequest {
                 let pre_auth = !item.request.is_auto_capture()?;
                 Ok(Self {
                     meta: StaxPaymentsRequestMetaData { tax: 0 },
-                    total: item.request.amount,
+                    total,
                     is_refundable: true,
                     pre_auth,
                     payment_method_id: Secret::new(item.get_payment_method_token()?),
@@ -322,13 +326,16 @@ impl<F, T>
 #[derive(Debug, Serialize)]
 #[serde(rename_all = "camelCase")]
 pub struct StaxCaptureRequest {
-    total: Option<i64>,
+    total: Option<f64>,
 }
 
 impl TryFrom<&types::PaymentsCaptureRouterData> for StaxCaptureRequest {
     type Error = error_stack::Report<errors::ConnectorError>;
     fn try_from(item: &types::PaymentsCaptureRouterData) -> Result<Self, Self::Error> {
-        let total = item.request.amount_to_capture;
+        let total = utils::to_currency_base_unit_asf64(
+            item.request.amount_to_capture,
+            item.request.currency,
+        )?;
         Ok(Self { total: Some(total) })
     }
 }
@@ -337,14 +344,17 @@ impl TryFrom<&types::PaymentsCaptureRouterData> for StaxCaptureRequest {
 // Type definition for RefundRequest
 #[derive(Debug, Serialize)]
 pub struct StaxRefundRequest {
-    pub total: i64,
+    pub total: f64,
 }
 
 impl<F> TryFrom<&types::RefundsRouterData<F>> for StaxRefundRequest {
     type Error = error_stack::Report<errors::ConnectorError>;
     fn try_from(item: &types::RefundsRouterData<F>) -> Result<Self, Self::Error> {
         Ok(Self {
-            total: item.request.refund_amount,
+            total: utils::to_currency_base_unit_asf64(
+                item.request.refund_amount,
+                item.request.currency,
+            )?,
         })
     }
 }
@@ -354,7 +364,7 @@ pub struct ChildTransactionsInResponse {
     id: String,
     success: bool,
     created_at: String,
-    total: i64,
+    total: f64,
 }
 #[derive(Debug, Deserialize)]
 pub struct RefundResponse {
@@ -370,11 +380,16 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, RefundResponse>>
     fn try_from(
         item: types::RefundsResponseRouterData<api::Execute, RefundResponse>,
     ) -> Result<Self, Self::Error> {
+        let refund_amount = utils::to_currency_base_unit_asf64(
+            item.data.request.refund_amount,
+            item.data.request.currency,
+        )
+        .change_context(errors::ConnectorError::ResponseHandlingFailed)?;
         let filtered_txn: Vec<&ChildTransactionsInResponse> = item
             .response
             .child_transactions
             .iter()
-            .filter(|txn| txn.total == item.data.request.refund_amount)
+            .filter(|txn| txn.total == refund_amount)
             .collect();
 
         let mut refund_txn = filtered_txn
diff --git a/crates/router/tests/connectors/stax.rs b/crates/router/tests/connectors/stax.rs
index c4eb2c51321..72c1d89da09 100644
--- a/crates/router/tests/connectors/stax.rs
+++ b/crates/router/tests/connectors/stax.rs
@@ -625,7 +625,7 @@ async fn should_fail_for_refund_amount_higher_than_payment_amount() {
         .unwrap();
     assert_eq!(
         response.response.unwrap_err().reason,
-        Some(r#"{"total":["The total may not be greater than 100."]}"#.to_string()),
+        Some(r#"{"total":["The total may not be greater than 1."]}"#.to_string()),
     );
 }
 

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

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

## Description
<!-- Describe your changes in detail -->
While creating a payment or a refund with connector Stax the incoming amount is being processed in it's higher decimal amount (e.g. Dollars) instead of processing it in it's lower units (e.g. Cents).

### 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)?
-->
Unit testing was completed
<img width="1132" alt="Screenshot 2023-09-06 at 12 15 54 AM" src="https://github.com/juspay/hyperswitch/assets/41580413/df904983-a12a-488f-b6b1-1153276867c9">


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