Bug: refactor(routers,connectors) : Remove unused functions in `crates/router/src/connector/utils.rs`



 ## Analyze and Remove Unused Functions from `crates/router/src/connector/utils.rs`

### Description:

There are functions in the crates/router/src/connector/utils.rs file that appear to be unused across the router crate. For 

example:
•	validate_currency is defined in utils.rs but is not used anywhere in the codebase. This function can be safely removed.

###  Task:
•	Perform a comprehensive analysis of all the functions present in crates/router/src/connector/utils.rs.
•	Identify any functions that are not referenced anywhere in the router crate which are in utils.
•	Remove such unused functions to reduce dead code and improve maintainability.
diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs
index e0034a63335..addb7dd7c8c 100644
--- a/crates/router/src/connector/utils.rs
+++ b/crates/router/src/connector/utils.rs
@@ -21,7 +21,6 @@ use common_utils::{
 use diesel_models::{enums, types::OrderDetailsWithAmount};
 use error_stack::{report, ResultExt};
 use hyperswitch_domain_models::{
-    mandates,
     network_tokenization::NetworkTokenNumber,
     payments::payment_attempt::PaymentAttempt,
     router_request_types::{
@@ -32,8 +31,6 @@ use hyperswitch_domain_models::{
 use masking::{Deserialize, ExposeInterface, Secret};
 use once_cell::sync::Lazy;
 use regex::Regex;
-use serde::Serializer;
-use time::PrimitiveDateTime;
 
 #[cfg(feature = "frm")]
 use crate::types::fraud_check;
@@ -1932,13 +1929,6 @@ pub fn get_header_key_value<'a>(
     get_header_field(headers.get(key))
 }
 
-pub fn get_http_header<'a>(
-    key: &str,
-    headers: &'a http::HeaderMap,
-) -> CustomResult<&'a str, errors::ConnectorError> {
-    get_header_field(headers.get(key))
-}
-
 fn get_header_field(
     field: Option<&http::HeaderValue>,
 ) -> CustomResult<&str, errors::ConnectorError> {
@@ -1953,23 +1943,6 @@ fn get_header_field(
         ))?
 }
 
-pub fn to_boolean(string: String) -> bool {
-    let str = string.as_str();
-    match str {
-        "true" => true,
-        "false" => false,
-        "yes" => true,
-        "no" => false,
-        _ => false,
-    }
-}
-
-pub fn get_connector_meta(
-    connector_meta: Option<serde_json::Value>,
-) -> Result<serde_json::Value, Error> {
-    connector_meta.ok_or_else(missing_field_err("connector_meta_data"))
-}
-
 pub fn to_connector_meta<T>(connector_meta: Option<serde_json::Value>) -> Result<T, Error>
 where
     T: serde::de::DeserializeOwned,
@@ -1990,77 +1963,6 @@ where
     json.parse_value(std::any::type_name::<T>()).switch()
 }
 
-pub fn base64_decode(data: String) -> Result<Vec<u8>, Error> {
-    consts::BASE64_ENGINE
-        .decode(data)
-        .change_context(errors::ConnectorError::ResponseDeserializationFailed)
-}
-
-pub fn to_currency_base_unit_from_optional_amount(
-    amount: Option<i64>,
-    currency: enums::Currency,
-) -> Result<String, error_stack::Report<errors::ConnectorError>> {
-    match amount {
-        Some(a) => to_currency_base_unit(a, currency),
-        _ => Err(errors::ConnectorError::MissingRequiredField {
-            field_name: "amount",
-        }
-        .into()),
-    }
-}
-
-pub fn get_amount_as_string(
-    currency_unit: &api::CurrencyUnit,
-    amount: i64,
-    currency: enums::Currency,
-) -> Result<String, error_stack::Report<errors::ConnectorError>> {
-    let amount = match currency_unit {
-        api::CurrencyUnit::Minor => amount.to_string(),
-        api::CurrencyUnit::Base => to_currency_base_unit(amount, currency)?,
-    };
-    Ok(amount)
-}
-
-pub fn get_amount_as_f64(
-    currency_unit: &api::CurrencyUnit,
-    amount: i64,
-    currency: enums::Currency,
-) -> Result<f64, error_stack::Report<errors::ConnectorError>> {
-    let amount = match currency_unit {
-        api::CurrencyUnit::Base => to_currency_base_unit_asf64(amount, currency)?,
-        api::CurrencyUnit::Minor => u32::try_from(amount)
-            .change_context(errors::ConnectorError::ParsingFailed)?
-            .into(),
-    };
-    Ok(amount)
-}
-
-pub fn to_currency_base_unit(
-    amount: i64,
-    currency: enums::Currency,
-) -> Result<String, error_stack::Report<errors::ConnectorError>> {
-    currency
-        .to_currency_base_unit(amount)
-        .change_context(errors::ConnectorError::ParsingFailed)
-}
-
-pub fn to_currency_lower_unit(
-    amount: String,
-    currency: enums::Currency,
-) -> Result<String, error_stack::Report<errors::ConnectorError>> {
-    currency
-        .to_currency_lower_unit(amount)
-        .change_context(errors::ConnectorError::ResponseHandlingFailed)
-}
-
-pub fn construct_not_implemented_error_report(
-    capture_method: enums::CaptureMethod,
-    connector_name: &str,
-) -> error_stack::Report<errors::ConnectorError> {
-    errors::ConnectorError::NotImplemented(format!("{} for {}", capture_method, connector_name))
-        .into()
-}
-
 pub fn construct_not_supported_error_report(
     capture_method: enums::CaptureMethod,
     connector_name: &'static str,
@@ -2072,77 +1974,6 @@ pub fn construct_not_supported_error_report(
     .into()
 }
 
-pub fn to_currency_base_unit_with_zero_decimal_check(
-    amount: i64,
-    currency: enums::Currency,
-) -> Result<String, error_stack::Report<errors::ConnectorError>> {
-    currency
-        .to_currency_base_unit_with_zero_decimal_check(amount)
-        .change_context(errors::ConnectorError::RequestEncodingFailed)
-}
-
-pub fn to_currency_base_unit_asf64(
-    amount: i64,
-    currency: enums::Currency,
-) -> Result<f64, error_stack::Report<errors::ConnectorError>> {
-    currency
-        .to_currency_base_unit_asf64(amount)
-        .change_context(errors::ConnectorError::ParsingFailed)
-}
-
-pub fn str_to_f32<S>(value: &str, serializer: S) -> Result<S::Ok, S::Error>
-where
-    S: Serializer,
-{
-    let float_value = value.parse::<f64>().map_err(|_| {
-        serde::ser::Error::custom("Invalid string, cannot be converted to float value")
-    })?;
-    serializer.serialize_f64(float_value)
-}
-
-pub fn collect_values_by_removing_signature(
-    value: &serde_json::Value,
-    signature: &String,
-) -> Vec<String> {
-    match value {
-        serde_json::Value::Null => vec!["null".to_owned()],
-        serde_json::Value::Bool(b) => vec![b.to_string()],
-        serde_json::Value::Number(n) => match n.as_f64() {
-            Some(f) => vec![format!("{f:.2}")],
-            None => vec![n.to_string()],
-        },
-        serde_json::Value::String(s) => {
-            if signature == s {
-                vec![]
-            } else {
-                vec![s.clone()]
-            }
-        }
-        serde_json::Value::Array(arr) => arr
-            .iter()
-            .flat_map(|v| collect_values_by_removing_signature(v, signature))
-            .collect(),
-        serde_json::Value::Object(obj) => obj
-            .values()
-            .flat_map(|v| collect_values_by_removing_signature(v, signature))
-            .collect(),
-    }
-}
-
-pub fn collect_and_sort_values_by_removing_signature(
-    value: &serde_json::Value,
-    signature: &String,
-) -> Vec<String> {
-    let mut values = collect_values_by_removing_signature(value, signature);
-    values.sort();
-    values
-}
-
-#[inline]
-pub fn get_webhook_merchant_secret_key(connector_label: &str, merchant_id: &str) -> String {
-    format!("whsec_verification_{connector_label}_{merchant_id}")
-}
-
 impl ForeignTryFrom<String> for UsStatesAbbreviation {
     type Error = error_stack::Report<errors::ConnectorError>;
     fn foreign_try_from(value: String) -> Result<Self, Self::Error> {
@@ -2317,71 +2148,6 @@ pub trait MultipleCaptureSyncResponse {
     fn get_amount_captured(&self) -> Result<Option<MinorUnit>, error_stack::Report<ParsingError>>;
 }
 
-pub fn construct_captures_response_hashmap<T>(
-    capture_sync_response_list: Vec<T>,
-) -> CustomResult<HashMap<String, types::CaptureSyncResponse>, errors::ConnectorError>
-where
-    T: MultipleCaptureSyncResponse,
-{
-    let mut hashmap = HashMap::new();
-    for capture_sync_response in capture_sync_response_list {
-        let connector_capture_id = capture_sync_response.get_connector_capture_id();
-        if capture_sync_response.is_capture_response() {
-            hashmap.insert(
-                connector_capture_id.clone(),
-                types::CaptureSyncResponse::Success {
-                    resource_id: ResponseId::ConnectorTransactionId(connector_capture_id),
-                    status: capture_sync_response.get_capture_attempt_status(),
-                    connector_response_reference_id: capture_sync_response
-                        .get_connector_reference_id(),
-                    amount: capture_sync_response
-                        .get_amount_captured()
-                        .change_context(errors::ConnectorError::AmountConversionFailed)
-                        .attach_printable(
-                            "failed to convert back captured response amount to minor unit",
-                        )?,
-                },
-            );
-        }
-    }
-
-    Ok(hashmap)
-}
-
-pub fn is_manual_capture(capture_method: Option<enums::CaptureMethod>) -> bool {
-    capture_method == Some(enums::CaptureMethod::Manual)
-        || capture_method == Some(enums::CaptureMethod::ManualMultiple)
-}
-
-pub fn generate_random_bytes(length: usize) -> Vec<u8> {
-    // returns random bytes of length n
-    let mut rng = rand::thread_rng();
-    (0..length).map(|_| rand::Rng::gen(&mut rng)).collect()
-}
-
-pub fn validate_currency(
-    request_currency: types::storage::enums::Currency,
-    merchant_config_currency: Option<types::storage::enums::Currency>,
-) -> Result<(), errors::ConnectorError> {
-    let merchant_config_currency =
-        merchant_config_currency.ok_or(errors::ConnectorError::NoConnectorMetaData)?;
-    if request_currency != merchant_config_currency {
-        Err(errors::ConnectorError::NotSupported {
-            message: format!(
-                "currency {} is not supported for this merchant account",
-                request_currency
-            ),
-            connector: "Braintree",
-        })?
-    }
-    Ok(())
-}
-
-pub fn get_timestamp_in_milliseconds(datetime: &PrimitiveDateTime) -> i64 {
-    let utc_datetime = datetime.assume_utc();
-    utc_datetime.unix_timestamp() * 1000
-}
-
 #[cfg(feature = "frm")]
 pub trait FraudCheckSaleRequest {
     fn get_order_details(&self) -> Result<Vec<OrderDetailsWithAmount>, Error>;
@@ -2993,27 +2759,6 @@ impl From<domain::payments::PaymentMethodData> for PaymentMethodDataType {
     }
 }
 
-pub fn get_mandate_details(
-    setup_mandate_details: Option<&mandates::MandateData>,
-) -> Result<Option<&mandates::MandateAmountData>, error_stack::Report<errors::ConnectorError>> {
-    setup_mandate_details
-        .map(|mandate_data| match &mandate_data.mandate_type {
-            Some(mandates::MandateDataType::SingleUse(mandate))
-            | Some(mandates::MandateDataType::MultiUse(Some(mandate))) => Ok(mandate),
-            Some(mandates::MandateDataType::MultiUse(None)) => {
-                Err(errors::ConnectorError::MissingRequiredField {
-                    field_name: "setup_future_usage.mandate_data.mandate_type.multi_use.amount",
-                }
-                .into())
-            }
-            None => Err(errors::ConnectorError::MissingRequiredField {
-                field_name: "setup_future_usage.mandate_data.mandate_type",
-            }
-            .into()),
-        })
-        .transpose()
-}
-
 pub fn convert_amount<T>(
     amount_convertor: &dyn AmountConvertor<Output = T>,
     amount: MinorUnit,

crates/router/src/connector/utils.rs

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

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

## Description
<!-- Describe your changes in detail -->
Removed functions that are not used in other files and removed imports that are only referenced by the unused functions.
[crates/router/src/connector/utils.rs](https://github.com/juspay/hyperswitch/blob/3cdb9e174ca384704781a4c56e826c3a5e39d295/crates/router/src/connector/utils.rs)

### 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
fix: #7928
<!--
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)?
-->
Only removed unused util functions hence no testing required.

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