// File: crates/hyperswitch_connectors/src/connectors/tsys/transformers.rs
// Module: hyperswitch_connectors
// Public structs: 17

use common_enums::enums;
use common_utils::types::StringMinorUnit;
use error_stack::ResultExt;
use hyperswitch_domain_models::{
    payment_method_data::PaymentMethodData,
    router_data::{self, ConnectorAuthType, RouterData},
    router_flow_types::refunds::{Execute, RSync},
    router_request_types::ResponseId,
    router_response_types::{PaymentsResponseData, RefundsResponseData},
    types::{
        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},
    utils::{self, CardData as _, PaymentsAuthorizeRequestData, RefundsRequestData as _},
};

#[derive(Debug, Serialize)]
pub enum TsysPaymentsRequest {
    Auth(TsysPaymentAuthSaleRequest),
    Sale(TsysPaymentAuthSaleRequest),
}

#[derive(Default, Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TsysPaymentAuthSaleRequest {
    #[serde(rename = "deviceID")]
    device_id: Secret<String>,
    transaction_key: Secret<String>,
    card_data_source: String,
    transaction_amount: StringMinorUnit,
    currency_code: enums::Currency,
    card_number: cards::CardNumber,
    expiration_date: Secret<String>,
    cvv2: Secret<String>,
    terminal_capability: String,
    terminal_operating_environment: String,
    cardholder_authentication_method: String,
    #[serde(rename = "developerID")]
    developer_id: Secret<String>,
    order_number: String,
}

impl TryFrom<&TsysRouterData<&types::PaymentsAuthorizeRouterData>> for TsysPaymentsRequest {
    type Error = error_stack::Report<errors::ConnectorError>;
    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 =
                    TsysAuthType::try_from(&item.connector_auth_type)?;
                let auth_data: TsysPaymentAuthSaleRequest = TsysPaymentAuthSaleRequest {
                    device_id: connector_auth.device_id,
                    transaction_key: connector_auth.transaction_key,
                    card_data_source: "INTERNET".to_string(),
                    transaction_amount: item_data.amount.clone(),
                    currency_code: item.request.currency,
                    card_number: ccard.card_number.clone(),
                    expiration_date: ccard
                        .get_card_expiry_month_year_2_digit_with_delimiter("/".to_owned())?,
                    cvv2: ccard.card_cvc,
                    terminal_capability: "ICC_CHIP_READ_ONLY".to_string(),
                    terminal_operating_environment: "ON_MERCHANT_PREMISES_ATTENDED".to_string(),
                    cardholder_authentication_method: "NOT_AUTHENTICATED".to_string(),
                    developer_id: connector_auth.developer_id,
                    order_number: item.connector_request_reference_id.clone(),
                };
                if item.request.is_auto_capture()? {
                    Ok(Self::Sale(auth_data))
                } else {
                    Ok(Self::Auth(auth_data))
                }
            }
            PaymentMethodData::CardRedirect(_)
            | PaymentMethodData::Wallet(_)
            | PaymentMethodData::PayLater(_)
            | PaymentMethodData::BankRedirect(_)
            | PaymentMethodData::BankDebit(_)
            | PaymentMethodData::BankTransfer(_)
            | PaymentMethodData::Crypto(_)
            | PaymentMethodData::MandatePayment
            | PaymentMethodData::Reward
            | PaymentMethodData::RealTimePayment(_)
            | PaymentMethodData::MobilePayment(_)
            | PaymentMethodData::Upi(_)
            | PaymentMethodData::Voucher(_)
            | PaymentMethodData::GiftCard(_)
            | PaymentMethodData::OpenBanking(_)
            | PaymentMethodData::CardToken(_)
            | PaymentMethodData::NetworkToken(_)
            | PaymentMethodData::CardDetailsForNetworkTransactionId(_) => {
                Err(errors::ConnectorError::NotImplemented(
                    utils::get_unimplemented_payment_method_error_message("tsys"),
                ))?
            }
        }
    }
}

// Auth Struct
pub struct TsysAuthType {
    pub(super) device_id: Secret<String>,
    pub(super) transaction_key: Secret<String>,
    pub(super) developer_id: Secret<String>,
}

impl TryFrom<&ConnectorAuthType> for TsysAuthType {
    type Error = error_stack::Report<errors::ConnectorError>;
    fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {
        match auth_type {
            ConnectorAuthType::SignatureKey {
                api_key,
                key1,
                api_secret,
            } => Ok(Self {
                device_id: api_key.to_owned(),
                transaction_key: key1.to_owned(),
                developer_id: api_secret.to_owned(),
            }),
            _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),
        }
    }
}

// PaymentsResponse
#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum TsysPaymentStatus {
    Pass,
    Fail,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "UPPERCASE")]
pub enum TsysTransactionStatus {
    Approved,
    Declined,
    Void,
}

impl From<TsysTransactionDetails> for enums::AttemptStatus {
    fn from(item: TsysTransactionDetails) -> Self {
        match item.transaction_status {
            TsysTransactionStatus::Approved => {
                if item.transaction_type.contains("Auth-Only") {
                    Self::Authorized
                } else {
                    Self::Charged
                }
            }
            TsysTransactionStatus::Void => Self::Voided,
            TsysTransactionStatus::Declined => Self::Failure,
        }
    }
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TsysErrorResponse {
    pub status: TsysPaymentStatus,
    pub response_code: String,
    pub response_message: String,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TsysTransactionDetails {
    #[serde(rename = "transactionID")]
    transaction_id: String,
    transaction_type: String,
    transaction_status: TsysTransactionStatus,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TsysPaymentsSyncResponse {
    pub status: TsysPaymentStatus,
    pub response_code: String,
    pub response_message: String,
    pub transaction_details: TsysTransactionDetails,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TsysResponse {
    pub status: TsysPaymentStatus,
    pub response_code: String,
    pub response_message: String,
    #[serde(rename = "transactionID")]
    pub transaction_id: String,
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[serde(untagged)]
pub enum TsysResponseTypes {
    SuccessResponse(TsysResponse),
    ErrorResponse(TsysErrorResponse),
}

#[derive(Debug, Clone, Deserialize, Serialize)]
#[allow(clippy::enum_variant_names)]
pub enum TsysPaymentsResponse {
    AuthResponse(TsysResponseTypes),
    SaleResponse(TsysResponseTypes),
    CaptureResponse(TsysResponseTypes),
    VoidResponse(TsysResponseTypes),
}

fn get_error_response(
    connector_response: TsysErrorResponse,
    status_code: u16,
) -> router_data::ErrorResponse {
    router_data::ErrorResponse {
        code: connector_response.response_code,
        message: connector_response.response_message.clone(),
        reason: Some(connector_response.response_message),
        status_code,
        attempt_status: None,
        connector_transaction_id: None,
        network_advice_code: None,
        network_decline_code: None,
        network_error_message: None,
        connector_metadata: None,
    }
}

fn get_payments_response(connector_response: TsysResponse) -> PaymentsResponseData {
    PaymentsResponseData::TransactionResponse {
        resource_id: ResponseId::ConnectorTransactionId(connector_response.transaction_id.clone()),
        redirection_data: Box::new(None),
        mandate_reference: Box::new(None),
        connector_metadata: None,
        network_txn_id: None,
        connector_response_reference_id: Some(connector_response.transaction_id),
        incremental_authorization_allowed: None,
        charges: None,
    }
}

fn get_payments_sync_response(
    connector_response: &TsysPaymentsSyncResponse,
) -> PaymentsResponseData {
    PaymentsResponseData::TransactionResponse {
        resource_id: ResponseId::ConnectorTransactionId(
            connector_response
                .transaction_details
                .transaction_id
                .clone(),
        ),
        redirection_data: Box::new(None),
        mandate_reference: Box::new(None),
        connector_metadata: None,
        network_txn_id: None,
        connector_response_reference_id: Some(
            connector_response
                .transaction_details
                .transaction_id
                .clone(),
        ),
        incremental_authorization_allowed: None,
        charges: None,
    }
}

impl<F, T> TryFrom<ResponseRouterData<F, TsysPaymentsResponse, T, PaymentsResponseData>>
    for RouterData<F, T, PaymentsResponseData>
{
    type Error = error_stack::Report<errors::ConnectorError>;
    fn try_from(
        item: ResponseRouterData<F, TsysPaymentsResponse, T, PaymentsResponseData>,
    ) -> Result<Self, Self::Error> {
        let (response, status) = match item.response {
            TsysPaymentsResponse::AuthResponse(resp) => match resp {
                TsysResponseTypes::SuccessResponse(auth_response) => (
                    Ok(get_payments_response(auth_response)),
                    enums::AttemptStatus::Authorized,
                ),
                TsysResponseTypes::ErrorResponse(connector_response) => (
                    Err(get_error_response(connector_response, item.http_code)),
                    enums::AttemptStatus::AuthorizationFailed,
                ),
            },
            TsysPaymentsResponse::SaleResponse(resp) => match resp {
                TsysResponseTypes::SuccessResponse(sale_response) => (
                    Ok(get_payments_response(sale_response)),
                    enums::AttemptStatus::Charged,
                ),
                TsysResponseTypes::ErrorResponse(connector_response) => (
                    Err(get_error_response(connector_response, item.http_code)),
                    enums::AttemptStatus::Failure,
                ),
            },
            TsysPaymentsResponse::CaptureResponse(resp) => match resp {
                TsysResponseTypes::SuccessResponse(capture_response) => (
                    Ok(get_payments_response(capture_response)),
                    enums::AttemptStatus::Charged,
                ),
                TsysResponseTypes::ErrorResponse(connector_response) => (
                    Err(get_error_response(connector_response, item.http_code)),
                    enums::AttemptStatus::CaptureFailed,
                ),
            },
            TsysPaymentsResponse::VoidResponse(resp) => match resp {
                TsysResponseTypes::SuccessResponse(void_response) => (
                    Ok(get_payments_response(void_response)),
                    enums::AttemptStatus::Voided,
                ),
                TsysResponseTypes::ErrorResponse(connector_response) => (
                    Err(get_error_response(connector_response, item.http_code)),
                    enums::AttemptStatus::VoidFailed,
                ),
            },
        };
        Ok(Self {
            status,
            response,
            ..item.data
        })
    }
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TsysSearchTransactionRequest {
    #[serde(rename = "deviceID")]
    device_id: Secret<String>,
    transaction_key: Secret<String>,
    #[serde(rename = "transactionID")]
    transaction_id: String,
    #[serde(rename = "developerID")]
    developer_id: Secret<String>,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct TsysSyncRequest {
    search_transaction: TsysSearchTransactionRequest,
}

impl TryFrom<&PaymentsSyncRouterData> for TsysSyncRequest {
    type Error = error_stack::Report<errors::ConnectorError>;
    fn try_from(item: &PaymentsSyncRouterData) -> Result<Self, Self::Error> {
        let connector_auth: TsysAuthType = TsysAuthType::try_from(&item.connector_auth_type)?;
        let search_transaction = TsysSearchTransactionRequest {
            device_id: connector_auth.device_id,
            transaction_key: connector_auth.transaction_key,
            transaction_id: item
                .request
                .connector_transaction_id
                .get_connector_transaction_id()
                .change_context(errors::ConnectorError::MissingConnectorTransactionID)?,
            developer_id: connector_auth.developer_id,
        };
        Ok(Self { search_transaction })
    }
}

#[derive(Debug, Deserialize, Serialize)]
#[serde(untagged)]
pub enum SearchResponseTypes {
    SuccessResponse(TsysPaymentsSyncResponse),
    ErrorResponse(TsysErrorResponse),
}

#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct TsysSyncResponse {
    search_transaction_response: SearchResponseTypes,
}

impl<F, T> TryFrom<ResponseRouterData<F, TsysSyncResponse, T, PaymentsResponseData>>
    for RouterData<F, T, PaymentsResponseData>
{
    type Error = error_stack::Report<errors::ConnectorError>;
    fn try_from(
        item: ResponseRouterData<F, TsysSyncResponse, T, PaymentsResponseData>,
    ) -> Result<Self, Self::Error> {
        let tsys_search_response = item.response.search_transaction_response;
        let (response, status) = match tsys_search_response {
            SearchResponseTypes::SuccessResponse(search_response) => (
                Ok(get_payments_sync_response(&search_response)),
                enums::AttemptStatus::from(search_response.transaction_details),
            ),
            SearchResponseTypes::ErrorResponse(connector_response) => (
                Err(get_error_response(connector_response, item.http_code)),
                item.data.status,
            ),
        };
        Ok(Self {
            status,
            response,
            ..item.data
        })
    }
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TsysCancelRequest {
    #[serde(rename = "deviceID")]
    device_id: Secret<String>,
    transaction_key: Secret<String>,
    #[serde(rename = "transactionID")]
    transaction_id: String,
    #[serde(rename = "developerID")]
    developer_id: Secret<String>,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct TsysPaymentsCancelRequest {
    void: TsysCancelRequest,
}
impl TryFrom<&PaymentsCancelRouterData> for TsysPaymentsCancelRequest {
    type Error = error_stack::Report<errors::ConnectorError>;
    fn try_from(item: &PaymentsCancelRouterData) -> Result<Self, Self::Error> {
        let connector_auth: TsysAuthType = TsysAuthType::try_from(&item.connector_auth_type)?;
        let void = TsysCancelRequest {
            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,
        };
        Ok(Self { void })
    }
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TsysCaptureRequest {
    #[serde(rename = "deviceID")]
    device_id: Secret<String>,
    transaction_key: Secret<String>,
    transaction_amount: StringMinorUnit,
    #[serde(rename = "transactionID")]
    transaction_id: String,
    #[serde(rename = "developerID")]
    developer_id: Secret<String>,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct TsysPaymentsCaptureRequest {
    capture: TsysCaptureRequest,
}

impl TryFrom<&TsysRouterData<&types::PaymentsCaptureRouterData>> for TsysPaymentsCaptureRequest {
    type Error = error_stack::Report<errors::ConnectorError>;
    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_data.amount.clone(),
        };
        Ok(Self { capture })
    }
}
// REFUND :
// Type definition for RefundRequest
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TsysReturnRequest {
    #[serde(rename = "deviceID")]
    device_id: Secret<String>,
    transaction_key: Secret<String>,
    transaction_amount: StringMinorUnit,
    #[serde(rename = "transactionID")]
    transaction_id: String,
}

#[derive(Debug, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct TsysRefundRequest {
    #[serde(rename = "Return")]
    return_request: TsysReturnRequest,
}

impl<F> TryFrom<&TsysRouterData<&RefundsRouterData<F>>> for TsysRefundRequest {
    type Error = error_stack::Report<errors::ConnectorError>;
    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_data.amount.clone(),
            transaction_id: item.request.connector_transaction_id.clone(),
        };
        Ok(Self { return_request })
    }
}

impl From<TsysPaymentStatus> for enums::RefundStatus {
    fn from(item: TsysPaymentStatus) -> Self {
        match item {
            TsysPaymentStatus::Pass => Self::Success,
            TsysPaymentStatus::Fail => Self::Failure,
        }
    }
}

impl From<TsysTransactionDetails> for enums::RefundStatus {
    fn from(item: TsysTransactionDetails) -> Self {
        match item.transaction_status {
            TsysTransactionStatus::Approved => Self::Pending,
            //Connector calls refunds as Void
            TsysTransactionStatus::Void => Self::Success,
            TsysTransactionStatus::Declined => Self::Failure,
        }
    }
}

#[derive(Debug, Deserialize, Serialize)]
#[serde(rename_all = "PascalCase")]
pub struct RefundResponse {
    return_response: TsysResponseTypes,
}

impl TryFrom<RefundsResponseRouterData<Execute, RefundResponse>> for RefundsRouterData<Execute> {
    type Error = error_stack::Report<errors::ConnectorError>;
    fn try_from(
        item: RefundsResponseRouterData<Execute, RefundResponse>,
    ) -> Result<Self, Self::Error> {
        let tsys_return_response = item.response.return_response;
        let response = match tsys_return_response {
            TsysResponseTypes::SuccessResponse(return_response) => Ok(RefundsResponseData {
                connector_refund_id: return_response.transaction_id,
                refund_status: enums::RefundStatus::from(return_response.status),
            }),
            TsysResponseTypes::ErrorResponse(connector_response) => {
                Err(get_error_response(connector_response, item.http_code))
            }
        };
        Ok(Self {
            response,
            ..item.data
        })
    }
}

impl TryFrom<&RefundSyncRouterData> for TsysSyncRequest {
    type Error = error_stack::Report<errors::ConnectorError>;
    fn try_from(item: &RefundSyncRouterData) -> Result<Self, Self::Error> {
        let connector_auth: TsysAuthType = TsysAuthType::try_from(&item.connector_auth_type)?;
        let search_transaction = TsysSearchTransactionRequest {
            device_id: connector_auth.device_id,
            transaction_key: connector_auth.transaction_key,
            transaction_id: item.request.get_connector_refund_id()?,
            developer_id: connector_auth.developer_id,
        };
        Ok(Self { search_transaction })
    }
}

impl TryFrom<RefundsResponseRouterData<RSync, TsysSyncResponse>> for RefundsRouterData<RSync> {
    type Error = error_stack::Report<errors::ConnectorError>;
    fn try_from(
        item: RefundsResponseRouterData<RSync, TsysSyncResponse>,
    ) -> Result<Self, Self::Error> {
        let tsys_search_response = item.response.search_transaction_response;
        let response = match tsys_search_response {
            SearchResponseTypes::SuccessResponse(search_response) => Ok(RefundsResponseData {
                connector_refund_id: search_response.transaction_details.transaction_id.clone(),
                refund_status: enums::RefundStatus::from(search_response.transaction_details),
            }),
            SearchResponseTypes::ErrorResponse(connector_response) => {
                Err(get_error_response(connector_response, item.http_code))
            }
        };
        Ok(Self {
            response,
            ..item.data
        })
    }
}


// Function: new
// File: crates/hyperswitch_connectors/src/connectors/adyenplatform.rs
// Module: hyperswitch_connectors

pub fn new() -> &'static Self


// Implementation: impl ConnectorValidation for for Redsys
// File: crates/hyperswitch_connectors/src/connectors/redsys.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)

impl ConnectorValidation for for Redsys


// File: crates/analytics/src/payments.rs
// Module: analytics

pub mod accumulator;
mod core;
pub mod distribution;
pub mod filters;
pub mod metrics;
pub mod types;
pub use accumulator::{
    PaymentDistributionAccumulator, PaymentMetricAccumulator, PaymentMetricsAccumulator,
};

pub trait PaymentAnalytics:
    metrics::PaymentMetricAnalytics + filters::PaymentFilterAnalytics
{
}

pub use self::core::{get_filters, get_metrics};


// File: crates/router/src/types/storage/dynamic_routing_stats.rs
// Module: router

pub use diesel_models::dynamic_routing_stats::{
    DynamicRoutingStats, DynamicRoutingStatsNew, DynamicRoutingStatsUpdate,
};


// Implementation: impl api::subscriptions::GetSubscriptionEstimateFlow for for Chargebee
// File: crates/hyperswitch_connectors/src/connectors/chargebee.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)

impl api::subscriptions::GetSubscriptionEstimateFlow for for Chargebee


// Implementation: impl api::Refund for for Braintree
// File: crates/hyperswitch_connectors/src/connectors/braintree.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)

impl api::Refund for for Braintree


// Struct: AvgTicketSize
// File: crates/api_models/src/analytics/payments.rs
// Module: api_models
// Implementations: 0

pub struct AvgTicketSize


// File: crates/router/src/core/payments/operations/payment_capture_v2.rs
// Module: router
// Public structs: 1

use api_models::{enums::FrmSuggestion, payments::PaymentsCaptureRequest};
use async_trait::async_trait;
use error_stack::ResultExt;
use hyperswitch_domain_models::payments::PaymentCaptureData;
use router_env::{instrument, tracing};

use super::{Domain, GetTracker, Operation, UpdateTracker, ValidateRequest};
use crate::{
    core::{
        errors::{self, CustomResult, RouterResult, StorageErrorExt},
        payments::{
            helpers,
            operations::{self, ValidateStatusForOperation},
        },
    },
    routes::{app::ReqState, SessionState},
    types::{
        api::{self, ConnectorCallType},
        domain::{self},
        storage::{self, enums as storage_enums},
    },
    utils::OptionExt,
};

#[derive(Debug, Clone, Copy)]
pub struct PaymentsCapture;

impl ValidateStatusForOperation for PaymentsCapture {
    /// Validate if the current operation can be performed on the current status of the payment intent
    fn validate_status_for_operation(
        &self,
        intent_status: common_enums::IntentStatus,
    ) -> Result<(), errors::ApiErrorResponse> {
        match intent_status {
            common_enums::IntentStatus::RequiresCapture
            | common_enums::IntentStatus::PartiallyAuthorizedAndRequiresCapture
            | common_enums::IntentStatus::PartiallyCapturedAndCapturable => Ok(()),
            common_enums::IntentStatus::Succeeded
            | common_enums::IntentStatus::Conflicted
            | common_enums::IntentStatus::Failed
            | common_enums::IntentStatus::Cancelled
            | common_enums::IntentStatus::CancelledPostCapture
            | common_enums::IntentStatus::Processing
            | common_enums::IntentStatus::RequiresCustomerAction
            | common_enums::IntentStatus::RequiresMerchantAction
            | common_enums::IntentStatus::RequiresPaymentMethod
            | common_enums::IntentStatus::PartiallyCaptured
            | common_enums::IntentStatus::RequiresConfirmation
            | common_enums::IntentStatus::Expired => {
                Err(errors::ApiErrorResponse::PaymentUnexpectedState {
                    current_flow: format!("{self:?}"),
                    field_name: "status".to_string(),
                    current_value: intent_status.to_string(),
                    states: [
                        common_enums::IntentStatus::RequiresCapture,
                        common_enums::IntentStatus::PartiallyCapturedAndCapturable,
                    ]
                    .map(|enum_value| enum_value.to_string())
                    .join(", "),
                })
            }
        }
    }
}

type BoxedConfirmOperation<'b, F> =
    super::BoxedOperation<'b, F, PaymentsCaptureRequest, PaymentCaptureData<F>>;

// TODO: change the macro to include changes for v2
// TODO: PaymentData in the macro should be an input
impl<F: Send + Clone> Operation<F, PaymentsCaptureRequest> for &PaymentsCapture {
    type Data = PaymentCaptureData<F>;
    fn to_validate_request(
        &self,
    ) -> RouterResult<&(dyn ValidateRequest<F, PaymentsCaptureRequest, Self::Data> + Send + Sync)>
    {
        Ok(*self)
    }
    fn to_get_tracker(
        &self,
    ) -> RouterResult<&(dyn GetTracker<F, Self::Data, PaymentsCaptureRequest> + Send + Sync)> {
        Ok(*self)
    }
    fn to_domain(&self) -> RouterResult<&(dyn Domain<F, PaymentsCaptureRequest, Self::Data>)> {
        Ok(*self)
    }
    fn to_update_tracker(
        &self,
    ) -> RouterResult<&(dyn UpdateTracker<F, Self::Data, PaymentsCaptureRequest> + Send + Sync)>
    {
        Ok(*self)
    }
}
#[automatically_derived]
impl<F: Send + Clone> Operation<F, PaymentsCaptureRequest> for PaymentsCapture {
    type Data = PaymentCaptureData<F>;
    fn to_validate_request(
        &self,
    ) -> RouterResult<&(dyn ValidateRequest<F, PaymentsCaptureRequest, Self::Data> + Send + Sync)>
    {
        Ok(self)
    }
    fn to_get_tracker(
        &self,
    ) -> RouterResult<&(dyn GetTracker<F, Self::Data, PaymentsCaptureRequest> + Send + Sync)> {
        Ok(self)
    }
    fn to_domain(&self) -> RouterResult<&dyn Domain<F, PaymentsCaptureRequest, Self::Data>> {
        Ok(self)
    }
    fn to_update_tracker(
        &self,
    ) -> RouterResult<&(dyn UpdateTracker<F, Self::Data, PaymentsCaptureRequest> + Send + Sync)>
    {
        Ok(self)
    }
}

impl<F: Send + Clone> ValidateRequest<F, PaymentsCaptureRequest, PaymentCaptureData<F>>
    for PaymentsCapture
{
    #[instrument(skip_all)]
    fn validate_request<'a, 'b>(
        &'b self,
        _request: &PaymentsCaptureRequest,
        merchant_context: &'a domain::MerchantContext,
    ) -> RouterResult<operations::ValidateResult> {
        let validate_result = operations::ValidateResult {
            merchant_id: merchant_context.get_merchant_account().get_id().to_owned(),
            storage_scheme: merchant_context.get_merchant_account().storage_scheme,
            requeue: false,
        };

        Ok(validate_result)
    }
}

#[async_trait]
impl<F: Send + Clone> GetTracker<F, PaymentCaptureData<F>, PaymentsCaptureRequest>
    for PaymentsCapture
{
    #[instrument(skip_all)]
    async fn get_trackers<'a>(
        &'a self,
        state: &'a SessionState,
        payment_id: &common_utils::id_type::GlobalPaymentId,
        request: &PaymentsCaptureRequest,
        merchant_context: &domain::MerchantContext,
        _profile: &domain::Profile,
        _header_payload: &hyperswitch_domain_models::payments::HeaderPayload,
    ) -> RouterResult<operations::GetTrackerResponse<PaymentCaptureData<F>>> {
        let db = &*state.store;
        let key_manager_state = &state.into();

        let storage_scheme = merchant_context.get_merchant_account().storage_scheme;

        let payment_intent = db
            .find_payment_intent_by_id(
                key_manager_state,
                payment_id,
                merchant_context.get_merchant_key_store(),
                storage_scheme,
            )
            .await
            .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;

        self.validate_status_for_operation(payment_intent.status)?;

        let active_attempt_id = payment_intent
            .active_attempt_id
            .as_ref()
            .get_required_value("active_attempt_id")
            .change_context(errors::ApiErrorResponse::InternalServerError)
            .attach_printable("Active attempt id is none when capturing the payment")?;

        let mut payment_attempt = db
            .find_payment_attempt_by_id(
                key_manager_state,
                merchant_context.get_merchant_key_store(),
                active_attempt_id,
                storage_scheme,
            )
            .await
            .change_context(errors::ApiErrorResponse::InternalServerError)
            .attach_printable("Could not find payment attempt given the attempt id")?;

        if let Some(amount_to_capture) = request.amount_to_capture {
            payment_attempt
                .amount_details
                .validate_amount_to_capture(amount_to_capture)
                .change_context(errors::ApiErrorResponse::PreconditionFailed {
                    message: format!(
                        "`amount_to_capture` is greater than the net amount {}",
                        payment_attempt.amount_details.get_net_amount()
                    ),
                })?;

            payment_attempt
                .amount_details
                .set_amount_to_capture(amount_to_capture);
        }

        let payment_data = PaymentCaptureData {
            flow: std::marker::PhantomData,
            payment_intent,
            payment_attempt,
        };

        let get_trackers_response = operations::GetTrackerResponse { payment_data };

        Ok(get_trackers_response)
    }
}

#[async_trait]
impl<F: Clone + Send> Domain<F, PaymentsCaptureRequest, PaymentCaptureData<F>> for PaymentsCapture {
    async fn get_customer_details<'a>(
        &'a self,
        state: &SessionState,
        payment_data: &mut PaymentCaptureData<F>,
        merchant_key_store: &domain::MerchantKeyStore,
        storage_scheme: storage_enums::MerchantStorageScheme,
    ) -> CustomResult<(BoxedConfirmOperation<'a, F>, Option<domain::Customer>), errors::StorageError>
    {
        match payment_data.payment_intent.customer_id.clone() {
            Some(id) => {
                let customer = state
                    .store
                    .find_customer_by_global_id(
                        &state.into(),
                        &id,
                        merchant_key_store,
                        storage_scheme,
                    )
                    .await?;

                Ok((Box::new(self), Some(customer)))
            }
            None => Ok((Box::new(self), None)),
        }
    }

    #[instrument(skip_all)]
    async fn make_pm_data<'a>(
        &'a self,
        _state: &'a SessionState,
        _payment_data: &mut PaymentCaptureData<F>,
        _storage_scheme: storage_enums::MerchantStorageScheme,
        _key_store: &domain::MerchantKeyStore,
        _customer: &Option<domain::Customer>,
        _business_profile: &domain::Profile,
        _should_retry_with_pan: bool,
    ) -> RouterResult<(
        BoxedConfirmOperation<'a, F>,
        Option<domain::PaymentMethodData>,
        Option<String>,
    )> {
        Ok((Box::new(self), None, None))
    }

    #[instrument(skip_all)]
    async fn perform_routing<'a>(
        &'a self,
        _merchant_context: &domain::MerchantContext,
        _business_profile: &domain::Profile,
        state: &SessionState,
        // TODO: do not take the whole payment data here
        payment_data: &mut PaymentCaptureData<F>,
    ) -> CustomResult<ConnectorCallType, errors::ApiErrorResponse> {
        let payment_attempt = &payment_data.payment_attempt;
        let connector = payment_attempt
            .connector
            .as_ref()
            .get_required_value("connector")
            .change_context(errors::ApiErrorResponse::InternalServerError)
            .attach_printable("Connector is none when constructing response")?;

        let merchant_connector_id = payment_attempt
            .merchant_connector_id
            .as_ref()
            .get_required_value("merchant_connector_id")
            .change_context(errors::ApiErrorResponse::InternalServerError)
            .attach_printable("Merchant connector id is none when constructing response")?;

        let connector_data = api::ConnectorData::get_connector_by_name(
            &state.conf.connectors,
            connector,
            api::GetToken::Connector,
            Some(merchant_connector_id.to_owned()),
        )
        .change_context(errors::ApiErrorResponse::InternalServerError)
        .attach_printable("Invalid connector name received")?;

        Ok(ConnectorCallType::PreDetermined(connector_data.into()))
    }
}

#[async_trait]
impl<F: Clone> UpdateTracker<F, PaymentCaptureData<F>, PaymentsCaptureRequest> for PaymentsCapture {
    #[instrument(skip_all)]
    async fn update_trackers<'b>(
        &'b self,
        state: &'b SessionState,
        _req_state: ReqState,
        mut payment_data: PaymentCaptureData<F>,
        _customer: Option<domain::Customer>,
        storage_scheme: storage_enums::MerchantStorageScheme,
        _updated_customer: Option<storage::CustomerUpdate>,
        key_store: &domain::MerchantKeyStore,
        _frm_suggestion: Option<FrmSuggestion>,
        _header_payload: hyperswitch_domain_models::payments::HeaderPayload,
    ) -> RouterResult<(BoxedConfirmOperation<'b, F>, PaymentCaptureData<F>)>
    where
        F: 'b + Send,
    {
        let payment_attempt_update = hyperswitch_domain_models::payments::payment_attempt::PaymentAttemptUpdate::PreCaptureUpdate { amount_to_capture: payment_data.payment_attempt.amount_details.get_amount_to_capture(), updated_by: storage_scheme.to_string() };

        let payment_attempt = state
            .store
            .update_payment_attempt(
                &state.into(),
                key_store,
                payment_data.payment_attempt.clone(),
                payment_attempt_update,
                storage_scheme,
            )
            .await
            .change_context(errors::ApiErrorResponse::InternalServerError)
            .attach_printable("Could not update payment attempt")?;

        payment_data.payment_attempt = payment_attempt;
        Ok((Box::new(self), payment_data))
    }
}


// Implementation: impl Responder
// File: crates/router/src/routes/cache.rs
// Module: router
// Methods: 0 total (0 public)

impl Responder


// Function: log_dispute_delete
// File: crates/router/src/services/kafka.rs
// Module: router

pub fn log_dispute_delete(
        &self,
        delete_old_dispute: &Dispute,
        tenant_id: TenantID,
    ) -> MQResult<()>


    #[strum(serialize = "11")]
    SamutPrakan,
    #[strum(serialize = "74")]
    SamutSakhon,
    #[strum(serialize = "75")]
    SamutSongkhram,
    #[strum(serialize = "19")]
    Saraburi,
    #[strum(serialize = "91")]
    Satun,
    #[strum(serialize = "33")]
    SiSaKet,
    #[strum(serialize = "17")]
    SingBuri,
    #[strum(serialize = "90")]
    Songkhla,
    #[strum(serialize = "64")]
    Sukhothai,
    #[strum(serialize = "72")]
    SuphanBuri,
    #[strum(serialize = "84")]
    SuratThani,
    #[strum(serialize = "32")]
    Surin,
    #[strum(serialize = "63")]
    Tak,
    #[strum(serialize = "92")]
    Trang,
    #[strum(serialize = "23")]
    Trat,
    #[strum(serialize = "34")]
    UbonRatchathani,
    #[strum(serialize = "41")]
    UdonThani,
    #[strum(serialize = "61")]
    UthaiThani,
    #[strum(serialize = "53")]
    Uttaradit,
    #[strum(serialize = "95")]
    Yala,
    #[strum(serialize = "35")]
    Yasothon,
}

#[derive(
    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
)]
pub enum PhilippinesStatesAbbreviation {
    #[strum(serialize = "ABR")]
    Abra,
    #[strum(serialize = "AGN")]
    AgusanDelNorte,
    #[strum(serialize = "AGS")]
    AgusanDelSur,
    #[strum(serialize = "AKL")]
    Aklan,
    #[strum(serialize = "ALB")]
    Albay,
    #[strum(serialize = "ANT")]
    Antique,
    #[strum(serialize = "APA")]
    Apayao,
    #[strum(serialize = "AUR")]
    Aurora,
    #[strum(serialize = "14")]
    AutonomousRegionInMuslimMindanao,
    #[strum(serialize = "BAS")]
    Basilan,
    #[strum(serialize = "BAN")]
    Bataan,
    #[strum(serialize = "BTN")]
    Batanes,
    #[strum(serialize = "BTG")]
    Batangas,
    #[strum(serialize = "BEN")]
    Benguet,
    #[strum(serialize = "05")]
    Bicol,
    #[strum(serialize = "BIL")]
    Biliran,
    #[strum(serialize = "BOH")]
    Bohol,
    #[strum(serialize = "BUK")]
    Bukidnon,
    #[strum(serialize = "BUL")]
    Bulacan,
    #[strum(serialize = "CAG")]
    Cagayan,
    #[strum(serialize = "02")]
    CagayanValley,
    #[strum(serialize = "40")]
    Calabarzon,
    #[strum(serialize = "CAN")]
    CamarinesNorte,
    #[strum(serialize = "CAS")]
    CamarinesSur,
    #[strum(serialize = "CAM")]
    Camiguin,
    #[strum(serialize = "CAP")]
    Capiz,
    #[strum(serialize = "13")]
    Caraga,
    #[strum(serialize = "CAT")]
    Catanduanes,
    #[strum(serialize = "CAV")]
    Cavite,
    #[strum(serialize = "CEB")]
    Cebu,
    #[strum(serialize = "03")]
    CentralLuzon,
    #[strum(serialize = "07")]
    CentralVisayas,
    #[strum(serialize = "15")]
    CordilleraAdministrativeRegion,
    #[strum(serialize = "NCO")]
    Cotabato,
    #[strum(serialize = "11")]
    Davao,
    #[strum(serialize = "DVO")]
    DavaoOccidental,
    #[strum(serialize = "DAO")]
    DavaoOriental,
    #[strum(serialize = "COM")]
    DavaoDeOro,
    #[strum(serialize = "DAV")]
    DavaoDelNorte,
    #[strum(serialize = "DAS")]
    DavaoDelSur,
    #[strum(serialize = "DIN")]
    DinagatIslands,
    #[strum(serialize = "EAS")]
    EasternSamar,
    #[strum(serialize = "08")]
    EasternVisayas,
    #[strum(serialize = "GUI")]
    Guimaras,
    #[strum(serialize = "ILN")]
    HilagangIloko,
    #[strum(serialize = "LAN")]
    HilagangLanaw,
    #[strum(serialize = "MGN")]
    HilagangMagindanaw,
    #[strum(serialize = "NSA")]
    HilagangSamar,
    #[strum(serialize = "ZAN")]
    HilagangSambuwangga,
    #[strum(serialize = "SUN")]
    HilagangSurigaw,
    #[strum(serialize = "IFU")]
    Ifugao,
    #[strum(serialize = "01")]
    Ilocos,
    #[strum(serialize = "ILS")]
    IlocosSur,
    #[strum(serialize = "ILI")]
    Iloilo,
    #[strum(serialize = "ISA")]
    Isabela,
    #[strum(serialize = "KAL")]
    Kalinga,
    #[strum(serialize = "MDC")]
    KanlurangMindoro,
    #[strum(serialize = "MSC")]
    KanlurangMisamis,
    #[strum(serialize = "NEC")]
    KanlurangNegros,
    #[strum(serialize = "SLE")]
    KatimogangLeyte,
    #[strum(serialize = "QUE")]
    Keson,
    #[strum(serialize = "QUI")]
    Kirino,
    #[strum(serialize = "LUN")]
    LaUnion,
    #[strum(serialize = "LAG")]
    Laguna,
    #[strum(serialize = "MOU")]
    LalawigangBulubundukin,
    #[strum(serialize = "LAS")]
    LanaoDelSur,
    #[strum(serialize = "LEY")]
    Leyte,
    #[strum(serialize = "MGS")]
    MaguindanaoDelSur,
    #[strum(serialize = "MAD")]
    Marinduque,
    #[strum(serialize = "MAS")]
    Masbate,
    #[strum(serialize = "41")]
    Mimaropa,
    #[strum(serialize = "MDR")]
    MindoroOriental,
    #[strum(serialize = "MSR")]
    MisamisOccidental,
    #[strum(serialize = "00")]
    NationalCapitalRegion,
    #[strum(serialize = "NER")]
    NegrosOriental,
    #[strum(serialize = "10")]
    NorthernMindanao,
    #[strum(serialize = "NUE")]
    NuevaEcija,
    #[strum(serialize = "NUV")]
    NuevaVizcaya,
    #[strum(serialize = "PLW")]
    Palawan,
    #[strum(serialize = "PAM")]
    Pampanga,
    #[strum(serialize = "PAN")]
    Pangasinan,
    #[strum(serialize = "06")]
    RehiyonNgKanlurangBisaya,
    #[strum(serialize = "12")]
    RehiyonNgSoccsksargen,
    #[strum(serialize = "09")]
    RehiyonNgTangwayNgSambuwangga,
    #[strum(serialize = "RIZ")]
    Risal,
    #[strum(serialize = "ROM")]
    Romblon,
    #[strum(serialize = "WSA")]
    Samar,
    #[strum(serialize = "ZMB")]
    Sambales,
    #[strum(serialize = "ZSI")]
    SambuwanggaSibugay,
    #[strum(serialize = "SAR")]
    Sarangani,
    #[strum(serialize = "SIG")]
    Sikihor,
    #[strum(serialize = "SOR")]
    Sorsogon,
    #[strum(serialize = "SCO")]
    SouthCotabato,
    #[strum(serialize = "SUK")]
    SultanKudarat,
    #[strum(serialize = "SLU")]
    Sulu,
    #[strum(serialize = "SUR")]
    SurigaoDelSur,
    #[strum(serialize = "TAR")]
    Tarlac,
    #[strum(serialize = "TAW")]
    TawiTawi,
    #[strum(serialize = "ZAS")]
    TimogSambuwangga,
}

#[derive(
    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
)]
pub enum IndiaStatesAbbreviation {
    #[strum(serialize = "AN")]
    AndamanAndNicobarIslands,
    #[strum(serialize = "AP")]
    AndhraPradesh,
    #[strum(serialize = "AR")]
    ArunachalPradesh,
    #[strum(serialize = "AS")]
    Assam,
    #[strum(serialize = "BR")]
    Bihar,
    #[strum(serialize = "CH")]
    Chandigarh,
    #[strum(serialize = "CG")]
    Chhattisgarh,
    #[strum(serialize = "DL")]
    Delhi,
    #[strum(serialize = "DH")]
    DadraAndNagarHaveliAndDamanAndDiu,
    #[strum(serialize = "GA")]
    Goa,
    #[strum(serialize = "GJ")]
    Gujarat,
    #[strum(serialize = "HR")]
    Haryana,
    #[strum(serialize = "HP")]
    HimachalPradesh,
    #[strum(serialize = "JK")]
    JammuAndKashmir,
    #[strum(serialize = "JH")]
    Jharkhand,
    #[strum(serialize = "KA")]
    Karnataka,
    #[strum(serialize = "KL")]
    Kerala,
    #[strum(serialize = "LA")]
    Ladakh,
    #[strum(serialize = "LD")]
    Lakshadweep,
    #[strum(serialize = "MP")]
    MadhyaPradesh,
    #[strum(serialize = "MH")]
    Maharashtra,
    #[strum(serialize = "MN")]
    Manipur,
    #[strum(serialize = "ML")]
    Meghalaya,
    #[strum(serialize = "MZ")]
    Mizoram,
    #[strum(serialize = "NL")]
    Nagaland,
    #[strum(serialize = "OD")]
    Odisha,
    #[strum(serialize = "PY")]
    Puducherry,
    #[strum(serialize = "PB")]
    Punjab,
    #[strum(serialize = "RJ")]
    Rajasthan,
    #[strum(serialize = "SK")]
    Sikkim,
    #[strum(serialize = "TN")]
    TamilNadu,
    #[strum(serialize = "TG")]
    Telangana,
    #[strum(serialize = "TR")]
    Tripura,
    #[strum(serialize = "UP")]
    UttarPradesh,
    #[strum(serialize = "UK")]
    Uttarakhand,
    #[strum(serialize = "WB")]
    WestBengal,
}

#[derive(
    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
)]
pub enum CanadaStatesAbbreviation {
    AB,
    BC,
    MB,
    NB,
    NL,
    NT,
    NS,
    NU,
    ON,
    PE,
    QC,
    SK,
    YT,
}

#[derive(
    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
)]
pub enum AlbaniaStatesAbbreviation {
    #[strum(serialize = "01")]
    Berat,
    #[strum(serialize = "09")]
    Diber,
    #[strum(serialize = "02")]
    Durres,
    #[strum(serialize = "03")]
    Elbasan,
    #[strum(serialize = "04")]
    Fier,
    #[strum(serialize = "05")]
    Gjirokaster,
    #[strum(serialize = "06")]
    Korce,
    #[strum(serialize = "07")]
    Kukes,
    #[strum(serialize = "08")]
    Lezhe,
    #[strum(serialize = "10")]
    Shkoder,
    #[strum(serialize = "11")]
    Tirane,
    #[strum(serialize = "12")]
    Vlore,
}

#[derive(
    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
)]
pub enum AndorraStatesAbbreviation {
    #[strum(serialize = "07")]
    AndorraLaVella,
    #[strum(serialize = "02")]
    Canillo,
    #[strum(serialize = "03")]
    Encamp,
    #[strum(serialize = "08")]
    EscaldesEngordany,
    #[strum(serialize = "04")]
    LaMassana,
    #[strum(serialize = "05")]
    Ordino,
    #[strum(serialize = "06")]
    SantJuliaDeLoria,
}

#[derive(
    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
)]
pub enum AustriaStatesAbbreviation {
    #[strum(serialize = "1")]
    Burgenland,
    #[strum(serialize = "2")]
    Carinthia,
    #[strum(serialize = "3")]
    LowerAustria,
    #[strum(serialize = "5")]
    Salzburg,
    #[strum(serialize = "6")]
    Styria,
    #[strum(serialize = "7")]
    Tyrol,
    #[strum(serialize = "4")]
    UpperAustria,
    #[strum(serialize = "9")]
    Vienna,
    #[strum(serialize = "8")]
    Vorarlberg,
}

#[derive(
    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
)]
pub enum BelarusStatesAbbreviation {
    #[strum(serialize = "BR")]
    BrestRegion,
    #[strum(serialize = "HO")]
    GomelRegion,
    #[strum(serialize = "HR")]
    GrodnoRegion,
    #[strum(serialize = "HM")]
    Minsk,
    #[strum(serialize = "MI")]
    MinskRegion,
    #[strum(serialize = "MA")]
    MogilevRegion,
    #[strum(serialize = "VI")]
    VitebskRegion,
}

#[derive(
    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
)]
pub enum BosniaAndHerzegovinaStatesAbbreviation {
    #[strum(serialize = "05")]
    BosnianPodrinjeCanton,
    #[strum(serialize = "BRC")]
    BrckoDistrict,
    #[strum(serialize = "10")]
    Canton10,
    #[strum(serialize = "06")]
    CentralBosniaCanton,
    #[strum(serialize = "BIH")]
    FederationOfBosniaAndHerzegovina,
    #[strum(serialize = "07")]
    HerzegovinaNeretvaCanton,
    #[strum(serialize = "02")]
    PosavinaCanton,
    #[strum(serialize = "SRP")]
    RepublikaSrpska,
    #[strum(serialize = "09")]
    SarajevoCanton,
    #[strum(serialize = "03")]
    TuzlaCanton,
    #[strum(serialize = "01")]
    UnaSanaCanton,
    #[strum(serialize = "08")]
    WestHerzegovinaCanton,
    #[strum(serialize = "04")]
    ZenicaDobojCanton,
}

#[derive(
    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
)]
pub enum BulgariaStatesAbbreviation {
    #[strum(serialize = "01")]
    BlagoevgradProvince,
    #[strum(serialize = "02")]
    BurgasProvince,
    #[strum(serialize = "08")]
    DobrichProvince,
    #[strum(serialize = "07")]
    GabrovoProvince,
    #[strum(serialize = "26")]
    HaskovoProvince,
    #[strum(serialize = "09")]
    KardzhaliProvince,
    #[strum(serialize = "10")]
    KyustendilProvince,
    #[strum(serialize = "11")]
    LovechProvince,
    #[strum(serialize = "12")]
    MontanaProvince,
    #[strum(serialize = "13")]
    PazardzhikProvince,
    #[strum(serialize = "14")]
    PernikProvince,
    #[strum(serialize = "15")]
    PlevenProvince,
    #[strum(serialize = "16")]
    PlovdivProvince,
    #[strum(serialize = "17")]
    RazgradProvince,
    #[strum(serialize = "18")]
    RuseProvince,
    #[strum(serialize = "27")]
    Shumen,
    #[strum(serialize = "19")]
    SilistraProvince,
    #[strum(serialize = "20")]
    SlivenProvince,
    #[strum(serialize = "21")]
    SmolyanProvince,
    #[strum(serialize = "22")]
    SofiaCityProvince,
    #[strum(serialize = "23")]
    SofiaProvince,
    #[strum(serialize = "24")]
    StaraZagoraProvince,
    #[strum(serialize = "25")]
    TargovishteProvince,
    #[strum(serialize = "03")]
    VarnaProvince,
    #[strum(serialize = "04")]
    VelikoTarnovoProvince,
    #[strum(serialize = "05")]
    VidinProvince,
    #[strum(serialize = "06")]
    VratsaProvince,
    #[strum(serialize = "28")]
    YambolProvince,
}

#[derive(
    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
)]
pub enum CroatiaStatesAbbreviation {
    #[strum(serialize = "07")]
    BjelovarBilogoraCounty,
    #[strum(serialize = "12")]
    BrodPosavinaCounty,
    #[strum(serialize = "19")]
    DubrovnikNeretvaCounty,
    #[strum(serialize = "18")]
    IstriaCounty,
    #[strum(serialize = "06")]
    KoprivnicaKrizevciCounty,
    #[strum(serialize = "02")]
    KrapinaZagorjeCounty,
    #[strum(serialize = "09")]
    LikaSenjCounty,
    #[strum(serialize = "20")]
    MedimurjeCounty,
    #[strum(serialize = "14")]
    OsijekBaranjaCounty,
    #[strum(serialize = "11")]
    PozegaSlavoniaCounty,
    #[strum(serialize = "08")]
    PrimorjeGorskiKotarCounty,
    #[strum(serialize = "03")]
    SisakMoslavinaCounty,
    #[strum(serialize = "17")]
    SplitDalmatiaCounty,
    #[strum(serialize = "05")]
    VarazdinCounty,
    #[strum(serialize = "10")]
    ViroviticaPodravinaCounty,
    #[strum(serialize = "16")]
    VukovarSyrmiaCounty,
    #[strum(serialize = "13")]
    ZadarCounty,
    #[strum(serialize = "21")]
    Zagreb,
    #[strum(serialize = "01")]
    ZagrebCounty,
    #[strum(serialize = "15")]
    SibenikKninCounty,
}

#[derive(
    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
)]
pub enum CzechRepublicStatesAbbreviation {
    #[strum(serialize = "201")]
    BenesovDistrict,
    #[strum(serialize = "202")]
    BerounDistrict,
    #[strum(serialize = "641")]
    BlanskoDistrict,
    #[strum(serialize = "642")]
    BrnoCityDistrict,
    #[strum(serialize = "643")]
    BrnoCountryDistrict,
    #[strum(serialize = "801")]
    BruntalDistrict,
    #[strum(serialize = "644")]
    BreclavDistrict,
    #[strum(serialize = "20")]
    CentralBohemianRegion,
    #[strum(serialize = "411")]
    ChebDistrict,
    #[strum(serialize = "422")]
    ChomutovDistrict,
    #[strum(serialize = "531")]
    ChrudimDistrict,
    #[strum(serialize = "321")]
    DomazliceDistrict,
    #[strum(serialize = "421")]
    DecinDistrict,
    #[strum(serialize = "802")]
    FrydekMistekDistrict,
    #[strum(serialize = "631")]
    HavlickuvBrodDistrict,
    #[strum(serialize = "645")]
    HodoninDistrict,
    #[strum(serialize = "120")]
    HorniPocernice,
    #[strum(serialize = "521")]
    HradecKraloveDistrict,
    #[strum(serialize = "52")]
    HradecKraloveRegion,
    #[strum(serialize = "512")]
    JablonecNadNisouDistrict,
    #[strum(serialize = "711")]
    JesenikDistrict,
    #[strum(serialize = "632")]
    JihlavaDistrict,
    #[strum(serialize = "313")]
    JindrichuvHradecDistrict,
    #[strum(serialize = "522")]
    JicinDistrict,
    #[strum(serialize = "412")]
    KarlovyVaryDistrict,
    #[strum(serialize = "41")]
    KarlovyVaryRegion,
    #[strum(serialize = "803")]
    KarvinaDistrict,
    #[strum(serialize = "203")]
    KladnoDistrict,
    #[strum(serialize = "322")]
    KlatovyDistrict,
    #[strum(serialize = "204")]
    KolinDistrict,
    #[strum(serialize = "721")]
    KromerizDistrict,
    #[strum(serialize = "513")]
    LiberecDistrict,
    #[strum(serialize = "51")]
    LiberecRegion,
    #[strum(serialize = "423")]
    LitomericeDistrict,
    #[strum(serialize = "424")]
    LounyDistrict,
    #[strum(serialize = "207")]
    MladaBoleslavDistrict,
    #[strum(serialize = "80")]
    MoravianSilesianRegion,
    #[strum(serialize = "425")]
    MostDistrict,
    #[strum(serialize = "206")]
    MelnikDistrict,
    #[strum(serialize = "804")]
    NovyJicinDistrict,
    #[strum(serialize = "208")]
    NymburkDistrict,
    #[strum(serialize = "523")]
    NachodDistrict,
    #[strum(serialize = "712")]
    OlomoucDistrict,
    #[strum(serialize = "71")]
    OlomoucRegion,
    #[strum(serialize = "805")]
    OpavaDistrict,
    #[strum(serialize = "806")]
    OstravaCityDistrict,
    #[strum(serialize = "532")]
    PardubiceDistrict,
    #[strum(serialize = "53")]
    PardubiceRegion,
    #[strum(serialize = "633")]
    PelhrimovDistrict,
    #[strum(serialize = "32")]
    PlzenRegion,
    #[strum(serialize = "323")]
    PlzenCityDistrict,
    #[strum(serialize = "325")]
    PlzenNorthDistrict,
    #[strum(serialize = "324")]
    PlzenSouthDistrict,
    #[strum(serialize = "315")]
    PrachaticeDistrict,
    #[strum(serialize = "10")]
    Prague,
    #[strum(serialize = "101")]
    Prague1,
    #[strum(serialize = "110")]
    Prague10,
    #[strum(serialize = "111")]
    Prague11,
    #[strum(serialize = "112")]
    Prague12,
    #[strum(serialize = "113")]
    Prague13,
    #[strum(serialize = "114")]
    Prague14,
    #[strum(serialize = "115")]
    Prague15,
    #[strum(serialize = "116")]
    Prague16,
    #[strum(serialize = "102")]
    Prague2,
    #[strum(serialize = "121")]
    Prague21,
    #[strum(serialize = "103")]
    Prague3,
    #[strum(serialize = "104")]
    Prague4,
    #[strum(serialize = "105")]
    Prague5,
    #[strum(serialize = "106")]
    Prague6,
    #[strum(serialize = "107")]
    Prague7,
    #[strum(serialize = "108")]
    Prague8,
    #[strum(serialize = "109")]
    Prague9,
    #[strum(serialize = "209")]
    PragueEastDistrict,
    #[strum(serialize = "20A")]
    PragueWestDistrict,
    #[strum(serialize = "713")]
    ProstejovDistrict,
    #[strum(serialize = "314")]
    PisekDistrict,
    #[strum(serialize = "714")]
    PrerovDistrict,
    #[strum(serialize = "20B")]
    PribramDistrict,
    #[strum(serialize = "20C")]
    RakovnikDistrict,
    #[strum(serialize = "326")]
    RokycanyDistrict,
    #[strum(serialize = "524")]
    RychnovNadKneznouDistrict,
    #[strum(serialize = "514")]
    SemilyDistrict,
    #[strum(serialize = "413")]
    SokolovDistrict,
    #[strum(serialize = "31")]
    SouthBohemianRegion,
    #[strum(serialize = "64")]
    SouthMoravianRegion,
    #[strum(serialize = "316")]
    StrakoniceDistrict,
    #[strum(serialize = "533")]
    SvitavyDistrict,
    #[strum(serialize = "327")]
    TachovDistrict,
    #[strum(serialize = "426")]
    TepliceDistrict,
    #[strum(serialize = "525")]
    TrutnovDistrict,
    #[strum(serialize = "317")]
    TaborDistrict,
    #[strum(serialize = "634")]
    TrebicDistrict,
    #[strum(serialize = "722")]
    UherskeHradisteDistrict,
    #[strum(serialize = "723")]
    VsetinDistrict,
    #[strum(serialize = "63")]
    VysocinaRegion,
    #[strum(serialize = "646")]
    VyskovDistrict,
    #[strum(serialize = "724")]
    ZlinDistrict,
    #[strum(serialize = "72")]
    ZlinRegion,
    #[strum(serialize = "647")]
    ZnojmoDistrict,
    #[strum(serialize = "427")]
    UstiNadLabemDistrict,
    #[strum(serialize = "42")]
    UstiNadLabemRegion,
    #[strum(serialize = "534")]
    UstiNadOrliciDistrict,
    #[strum(serialize = "511")]
    CeskaLipaDistrict,
    #[strum(serialize = "311")]
    CeskeBudejoviceDistrict,
    #[strum(serialize = "312")]
    CeskyKrumlovDistrict,
    #[strum(serialize = "715")]
    SumperkDistrict,
    #[strum(serialize = "635")]
    ZdarNadSazavouDistrict,
}

#[derive(
    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
)]
pub enum DenmarkStatesAbbreviation {
    #[strum(serialize = "84")]
    CapitalRegionOfDenmark,
    #[strum(serialize = "82")]
    CentralDenmarkRegion,
    #[strum(serialize = "81")]
    NorthDenmarkRegion,
    #[strum(serialize = "85")]
    RegionZealand,
    #[strum(serialize = "83")]
    RegionOfSouthernDenmark,
}

#[derive(
    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
)]
pub enum FinlandStatesAbbreviation {
    #[strum(serialize = "08")]
    CentralFinland,
    #[strum(serialize = "07")]
    CentralOstrobothnia,
    #[strum(serialize = "IS")]
    EasternFinlandProvince,
    #[strum(serialize = "19")]
    FinlandProper,
    #[strum(serialize = "05")]
    Kainuu,
    #[strum(serialize = "09")]
    Kymenlaakso,
    #[strum(serialize = "LL")]
    Lapland,
    #[strum(serialize = "13")]
    NorthKarelia,
    #[strum(serialize = "14")]
    NorthernOstrobothnia,
    #[strum(serialize = "15")]
    NorthernSavonia,
    #[strum(serialize = "12")]
    Ostrobothnia,
    #[strum(serialize = "OL")]
    OuluProvince,
    #[strum(serialize = "11")]
    Pirkanmaa,
    #[strum(serialize = "16")]
    PaijanneTavastia,
    #[strum(serialize = "17")]
    Satakunta,
    #[strum(serialize = "02")]
    SouthKarelia,
    #[strum(serialize = "03")]
    SouthernOstrobothnia,
    #[strum(serialize = "04")]
    SouthernSavonia,
    #[strum(serialize = "06")]
    TavastiaProper,
    #[strum(serialize = "18")]
    Uusimaa,
    #[strum(serialize = "01")]
    AlandIslands,
}

#[derive(
    Debug, Clone, PartialEq, Eq, Serialize, Deserialize, strum::Display, strum::EnumString,
)]
pub enum FranceStatesAbbreviation {
    #[strum(serialize = "01")]
    Ain,
    #[strum(serialize = "02")]
    Aisne,
    #[strum(serialize = "03")]
    Allier,
    #[strum(serialize = "04")]
    AlpesDeHauteProvence,
    #[strum(serialize = "06")]
    AlpesMaritimes,
    #[strum(serialize = "6AE")]
    Alsace,
    #[strum(serialize = "07")]
    Ardeche,
    #[strum(serialize = "08")]
    Ardennes,
    #[strum(serialize = "09")]
    Ariege,
    #[strum(serialize = "10")]
    Aube,
    #[strum(serialize = "11")]
    Aude,
    #[strum(serialize = "ARA")]
    AuvergneRhoneAlpes,
    #[strum(serialize = "12")]
    Aveyron,
    #[strum(serialize = "67")]
    BasRhin,
    #[strum(serialize = "13")]
    BouchesDuRhone,
    #[strum(serialize = "BFC")]
    BourgogneFrancheComte,
    #[strum(serialize = "BRE")]
    Bretagne,
    #[strum(serialize = "14")]
    Calvados,
    #[strum(serialize = "15")]
    Cantal,
    #[strum(serialize = "CVL")]
    CentreValDeLoire,
    #[strum(serialize = "16")]
    Charente,
    #[strum(serialize = "17")]
    CharenteMaritime,
    #[strum(serialize = "18")]
    Cher,
    #[strum(serialize = "CP")]
    Clipperton,
    #[strum(serialize = "19")]
    Correze,
    #[strum(serialize = "20R")]
    Corse,
    #[strum(serialize = "2A")]
    CorseDuSud,
    #[strum(serialize = "21")]
    CoteDor,
    #[strum(serialize = "22")]
    CotesDarmor,
    #[strum(serialize = "23")]
    Creuse,
    #[strum(serialize = "79")]
    DeuxSevres,
    #[strum(serialize = "24")]
    Dordogne,
    #[strum(serialize = "25")]
    Doubs,
    #[strum(serialize = "26")]
    Drome,
    #[strum(serialize = "91")]
    Essonne,
    #[strum(serialize = "27")]
    Eure,
    #[strum(serialize = "28")]
    EureEtLoir,
    #[strum(serialize = "29")]
    Finistere,
    #[strum(serialize = "973")]
    FrenchGuiana,
    #[strum(serialize = "PF")]
    FrenchPolynesia,
    #[strum(serialize = "TF")]
    FrenchSouthernAndAntarcticLands,
    #[strum(serialize = "30")]
    Gard,
    #[strum(serialize = "32")]
    Gers,
    #[strum(serialize = "33")]
    Gironde,
    #[strum(serialize = "GES")]
    GrandEst,
    #[strum(serialize = "971")]
    Guadeloupe,
    #[strum(serialize = "68")]
    HautRhin,
    #[strum(serialize = "2B")]
    HauteCorse,
    #[strum(serialize = "31")]
    HauteGaronne,
    #[strum(serialize = "43")]
    HauteLoire,
    #[strum(serialize = "52")]
    HauteMarne,
    #[strum(serialize = "70")]
    HauteSaone,
    #[strum(serialize = "74")]
    HauteSavoie,
    #[strum(serialize = "87")]
    HauteVienne,
    #[strum(serialize = "05")]
    HautesAlpes,
    #[strum(serialize = "65")]
    HautesPyrenees,
    #[strum(serialize = "HDF")]
    HautsDeFrance,
    #[strum(serialize = "92")]
    HautsDeSeine,
    #[strum(serialize = "34")]
    Herault,
    #[strum(serialize = "IDF")]
    IleDeFrance,
    #[strum(serialize = "35")]
    IlleEtVilaine,
    #[strum(serialize = "36")]
    Indre,


// Struct: ConnectorParamsWithKeys
// File: crates/hyperswitch_domain_models/src/connector_endpoints.rs
// Module: hyperswitch_domain_models
// Implementations: 0

pub struct ConnectorParamsWithKeys


// Function: update_by_merchant_id_authentication_id
// File: crates/diesel_models/src/query/authentication.rs
// Module: diesel_models

pub fn update_by_merchant_id_authentication_id(
        conn: &PgPooledConn,
        merchant_id: common_utils::id_type::MerchantId,
        authentication_id: common_utils::id_type::AuthenticationId,
        authorization_update: AuthenticationUpdate,
    ) -> StorageResult<Self>


// Function: new
// File: crates/hyperswitch_connectors/src/connectors/nomupay.rs
// Module: hyperswitch_connectors

pub fn new() -> &'static Self


// Implementation: impl api::PaymentVoid for for Hyperwallet
// File: crates/hyperswitch_connectors/src/connectors/hyperwallet.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)

impl api::PaymentVoid for for Hyperwallet


// Struct: BankOfAmericaRefundRequest
// File: crates/hyperswitch_connectors/src/connectors/bankofamerica/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0

pub struct BankOfAmericaRefundRequest


    /// Enable split payments, i.e., split the amount between multiple payment methods
    #[schema(value_type = Option<SplitTxnsEnabled>, default = "skip")]
    pub split_txns_enabled: Option<common_enums::SplitTxnsEnabled>,

    /// Merchant Connector id to be stored for billing_processor connector
    #[schema(value_type = Option<String>)]
    pub billing_processor_id: Option<id_type::MerchantConnectorAccountId>,
}

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct BusinessCollectLinkConfig {
    #[serde(flatten)]
    pub config: BusinessGenericLinkConfig,

    /// List of payment methods shown on collect UI
    #[schema(value_type = Vec<EnabledPaymentMethod>, example = r#"[{"payment_method": "bank_transfer", "payment_method_types": ["ach", "bacs", "sepa"]}]"#)]
    pub enabled_payment_methods: Vec<link_utils::EnabledPaymentMethod>,
}

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct BusinessPayoutLinkConfig {
    #[serde(flatten)]
    pub config: BusinessGenericLinkConfig,

    /// Form layout of the payout link
    #[schema(value_type = Option<UIWidgetFormLayout>, max_length = 255, example = "tabs")]
    pub form_layout: Option<api_enums::UIWidgetFormLayout>,

    /// Allows for removing any validations / pre-requisites which are necessary in a production environment
    #[schema(value_type = Option<bool>, default = false)]
    pub payout_test_mode: Option<bool>,
}

#[derive(Clone, Debug, serde::Serialize)]
pub struct MaskedHeaders(HashMap<String, String>);

impl MaskedHeaders {
    fn mask_value(value: &str) -> String {
        let value_len = value.len();

        let masked_value = if value_len <= 4 {
            "*".repeat(value_len)
        } else {
            value
                .char_indices()
                .map(|(index, ch)| {
                    if index < 2 || index >= value_len - 2 {
                        // Show the first two and last two characters, mask the rest with '*'
                        ch
                    } else {
                        // Mask the remaining characters
                        '*'
                    }
                })
                .collect::<String>()
        };

        masked_value
    }

    pub fn from_headers(headers: HashMap<String, Secret<String>>) -> Self {
        let masked_headers = headers
            .into_iter()
            .map(|(key, value)| (key, Self::mask_value(value.peek())))
            .collect();

        Self(masked_headers)
    }
}

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, ToSchema)]
pub struct BusinessGenericLinkConfig {
    /// Custom domain name to be used for hosting the link
    pub domain_name: Option<String>,

    /// A list of allowed domains (glob patterns) where this link can be embedded / opened from
    pub allowed_domains: HashSet<String>,

    #[serde(flatten)]
    #[schema(value_type = GenericLinkUiConfig)]
    pub ui_config: link_utils::GenericLinkUiConfig,
}

impl BusinessGenericLinkConfig {
    pub fn validate(&self) -> Result<(), &str> {
        // Validate host domain name
        let host_domain_valid = self
            .domain_name
            .clone()
            .map(|host_domain| link_utils::validate_strict_domain(&host_domain))
            .unwrap_or(true);
        if !host_domain_valid {
            return Err("Invalid host domain name received in payout_link_config");
        }

        let are_allowed_domains_valid = self
            .allowed_domains
            .clone()
            .iter()
            .all(|allowed_domain| link_utils::validate_wildcard_domain(allowed_domain));
        if !are_allowed_domains_valid {
            return Err("Invalid allowed domain names received in payout_link_config");
        }

        Ok(())
    }
}

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
pub struct BusinessPaymentLinkConfig {
    /// Custom domain name to be used for hosting the link in your own domain
    pub domain_name: Option<String>,
    /// Default payment link config for all future payment link
    #[serde(flatten)]
    #[schema(value_type = PaymentLinkConfigRequest)]
    pub default_config: Option<PaymentLinkConfigRequest>,
    /// list of configs for multi theme setup
    pub business_specific_configs: Option<HashMap<String, PaymentLinkConfigRequest>>,
    /// A list of allowed domains (glob patterns) where this link can be embedded / opened from
    #[schema(value_type = Option<HashSet<String>>)]
    pub allowed_domains: Option<HashSet<String>>,
    /// Toggle for HyperSwitch branding visibility
    pub branding_visibility: Option<bool>,
}

impl BusinessPaymentLinkConfig {
    pub fn validate(&self) -> Result<(), &str> {
        let host_domain_valid = self
            .domain_name
            .clone()
            .map(|host_domain| link_utils::validate_strict_domain(&host_domain))
            .unwrap_or(true);
        if !host_domain_valid {
            return Err("Invalid host domain name received in payment_link_config");
        }

        let are_allowed_domains_valid = self
            .allowed_domains
            .clone()
            .map(|allowed_domains| {
                allowed_domains
                    .iter()
                    .all(|allowed_domain| link_utils::validate_wildcard_domain(allowed_domain))
            })
            .unwrap_or(true);
        if !are_allowed_domains_valid {
            return Err("Invalid allowed domain names received in payment_link_config");
        }

        Ok(())
    }
}

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
pub struct PaymentLinkConfigRequest {
    /// custom theme for the payment link
    #[schema(value_type = Option<String>, max_length = 255, example = "#4E6ADD")]
    pub theme: Option<String>,
    /// merchant display logo
    #[schema(value_type = Option<String>, max_length = 255, example = "https://i.pinimg.com/736x/4d/83/5c/4d835ca8aafbbb15f84d07d926fda473.jpg")]
    pub logo: Option<String>,
    /// Custom merchant name for payment link
    #[schema(value_type = Option<String>, max_length = 255, example = "hyperswitch")]
    pub seller_name: Option<String>,
    /// Custom layout for sdk
    #[schema(value_type = Option<String>, max_length = 255, example = "accordion")]
    pub sdk_layout: Option<String>,
    /// Display only the sdk for payment link
    #[schema(default = false, example = true)]
    pub display_sdk_only: Option<bool>,
    /// Enable saved payment method option for payment link
    #[schema(default = false, example = true)]
    pub enabled_saved_payment_method: Option<bool>,
    /// Hide card nickname field option for payment link
    #[schema(default = false, example = true)]
    pub hide_card_nickname_field: Option<bool>,
    /// Show card form by default for payment link
    #[schema(default = true, example = true)]
    pub show_card_form_by_default: Option<bool>,
    /// Dynamic details related to merchant to be rendered in payment link
    pub transaction_details: Option<Vec<PaymentLinkTransactionDetails>>,
    /// Configurations for the background image for details section
    pub background_image: Option<PaymentLinkBackgroundImageConfig>,
    /// Custom layout for details section
    #[schema(value_type = Option<PaymentLinkDetailsLayout>, example = "layout1")]
    pub details_layout: Option<api_enums::PaymentLinkDetailsLayout>,
    /// Text for payment link's handle confirm button
    pub payment_button_text: Option<String>,
    /// Text for customizing message for card terms
    pub custom_message_for_card_terms: Option<String>,
    /// Custom background colour for payment link's handle confirm button
    pub payment_button_colour: Option<String>,
    /// Skip the status screen after payment completion
    pub skip_status_screen: Option<bool>,
    /// Custom text colour for payment link's handle confirm button
    pub payment_button_text_colour: Option<String>,
    /// Custom background colour for the payment link
    pub background_colour: Option<String>,
    /// SDK configuration rules
    pub sdk_ui_rules: Option<HashMap<String, HashMap<String, String>>>,
    /// Payment link configuration rules
    pub payment_link_ui_rules: Option<HashMap<String, HashMap<String, String>>>,
    /// Flag to enable the button only when the payment form is ready for submission
    pub enable_button_only_on_form_ready: Option<bool>,
    /// Optional header for the SDK's payment form
    pub payment_form_header_text: Option<String>,
    /// Label type in the SDK's payment form
    #[schema(value_type = Option<PaymentLinkSdkLabelType>, example = "floating")]
    pub payment_form_label_type: Option<api_enums::PaymentLinkSdkLabelType>,
    /// Boolean for controlling whether or not to show the explicit consent for storing cards
    #[schema(value_type = Option<PaymentLinkShowSdkTerms>, example = "always")]
    pub show_card_terms: Option<api_enums::PaymentLinkShowSdkTerms>,
    /// Boolean to control payment button text for setup mandate calls
    pub is_setup_mandate_flow: Option<bool>,
    /// Hex color for the CVC icon during error state
    pub color_icon_card_cvc_error: Option<String>,
}

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
pub struct PaymentLinkTransactionDetails {
    /// Key for the transaction details
    #[schema(value_type = String, max_length = 255, example = "Policy-Number")]
    pub key: String,
    /// Value for the transaction details
    #[schema(value_type = String, max_length = 255, example = "297472368473924")]
    pub value: String,
    /// UI configuration for the transaction details
    pub ui_configuration: Option<TransactionDetailsUiConfiguration>,
}

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
pub struct TransactionDetailsUiConfiguration {
    /// Position of the key-value pair in the UI
    #[schema(value_type = Option<i8>, example = 5)]
    pub position: Option<i8>,
    /// Whether the key should be bold
    #[schema(default = false, example = true)]
    pub is_key_bold: Option<bool>,
    /// Whether the value should be bold
    #[schema(default = false, example = true)]
    pub is_value_bold: Option<bool>,
}

#[derive(Clone, Debug, serde::Deserialize, serde::Serialize, PartialEq, ToSchema)]
pub struct PaymentLinkBackgroundImageConfig {
    /// URL of the image
    #[schema(value_type = String, example = "https://hyperswitch.io/favicon.ico")]
    pub url: common_utils::types::Url,
    /// Position of the image in the UI
    #[schema(value_type = Option<ElementPosition>, example = "top-left")]
    pub position: Option<api_enums::ElementPosition>,
    /// Size of the image in the UI
    #[schema(value_type = Option<ElementSize>, example = "contain")]
    pub size: Option<api_enums::ElementSize>,
}

#[derive(Clone, Debug, serde::Serialize, serde::Deserialize, PartialEq, ToSchema)]
pub struct PaymentLinkConfig {
    /// custom theme for the payment link
    pub theme: String,
    /// merchant display logo
    pub logo: String,
    /// Custom merchant name for payment link
    pub seller_name: String,
    /// Custom layout for sdk
    pub sdk_layout: String,
    /// Display only the sdk for payment link
    pub display_sdk_only: bool,
    /// Enable saved payment method option for payment link
    pub enabled_saved_payment_method: bool,
    /// Hide card nickname field option for payment link
    pub hide_card_nickname_field: bool,
    /// Show card form by default for payment link
    pub show_card_form_by_default: bool,
    /// A list of allowed domains (glob patterns) where this link can be embedded / opened from
    pub allowed_domains: Option<HashSet<String>>,
    /// Dynamic details related to merchant to be rendered in payment link
    pub transaction_details: Option<Vec<PaymentLinkTransactionDetails>>,
    /// Configurations for the background image for details section
    pub background_image: Option<PaymentLinkBackgroundImageConfig>,
    /// Custom layout for details section
    #[schema(value_type = Option<PaymentLinkDetailsLayout>, example = "layout1")]
    pub details_layout: Option<api_enums::PaymentLinkDetailsLayout>,
    /// Toggle for HyperSwitch branding visibility
    pub branding_visibility: Option<bool>,
    /// Text for payment link's handle confirm button
    pub payment_button_text: Option<String>,
    /// Text for customizing message for card terms
    pub custom_message_for_card_terms: Option<String>,
    /// Custom background colour for payment link's handle confirm button
    pub payment_button_colour: Option<String>,
    /// Skip the status screen after payment completion
    pub skip_status_screen: Option<bool>,
    /// Custom text colour for payment link's handle confirm button
    pub payment_button_text_colour: Option<String>,
    /// Custom background colour for the payment link
    pub background_colour: Option<String>,
    /// SDK configuration rules
    pub sdk_ui_rules: Option<HashMap<String, HashMap<String, String>>>,
    /// Payment link configuration rules
    pub payment_link_ui_rules: Option<HashMap<String, HashMap<String, String>>>,
    /// Flag to enable the button only when the payment form is ready for submission
    pub enable_button_only_on_form_ready: bool,
    /// Optional header for the SDK's payment form
    pub payment_form_header_text: Option<String>,
    /// Label type in the SDK's payment form
    #[schema(value_type = Option<PaymentLinkSdkLabelType>, example = "floating")]
    pub payment_form_label_type: Option<api_enums::PaymentLinkSdkLabelType>,
    /// Boolean for controlling whether or not to show the explicit consent for storing cards
    #[schema(value_type = Option<PaymentLinkShowSdkTerms>, example = "always")]
    pub show_card_terms: Option<api_enums::PaymentLinkShowSdkTerms>,
    /// Boolean to control payment button text for setup mandate calls
    pub is_setup_mandate_flow: Option<bool>,
    /// Hex color for the CVC icon during error state
    pub color_icon_card_cvc_error: Option<String>,
}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
pub struct ExtendedCardInfoChoice {
    pub enabled: bool,
}

impl common_utils::events::ApiEventMetric for ExtendedCardInfoChoice {}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, PartialEq, Eq)]
pub struct ConnectorAgnosticMitChoice {
    pub enabled: bool,
}

impl common_utils::events::ApiEventMetric for ConnectorAgnosticMitChoice {}

impl common_utils::events::ApiEventMetric for payment_methods::PaymentMethodMigrate {}

#[derive(Debug, Clone, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct ExtendedCardInfoConfig {
    /// Merchant public key
    #[schema(value_type = String)]
    pub public_key: Secret<String>,
    /// TTL for extended card info
    #[schema(default = 900, maximum = 7200, value_type = u16)]
    #[serde(default)]
    pub ttl_in_secs: TtlForExtendedCardInfo,
}

#[derive(Debug, serde::Serialize, Clone)]
pub struct TtlForExtendedCardInfo(u16);

impl Default for TtlForExtendedCardInfo {
    fn default() -> Self {
        Self(consts::DEFAULT_TTL_FOR_EXTENDED_CARD_INFO)
    }
}

impl<'de> Deserialize<'de> for TtlForExtendedCardInfo {
    fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
    where
        D: serde::Deserializer<'de>,
    {
        let value = u16::deserialize(deserializer)?;

        // Check if value exceeds the maximum allowed
        if value > consts::MAX_TTL_FOR_EXTENDED_CARD_INFO {
            Err(serde::de::Error::custom(
                "ttl_in_secs must be less than or equal to 7200 (2hrs)",
            ))
        } else {
            Ok(Self(value))
        }
    }
}

impl std::ops::Deref for TtlForExtendedCardInfo {
    type Target = u16;
    fn deref(&self) -> &Self::Target {
        &self.0
    }
}


// Implementation: impl GlobalStorageInterface for for KafkaStore
// File: crates/router/src/db/kafka_store.rs
// Module: router
// Methods: 1 total (0 public)

impl GlobalStorageInterface for for KafkaStore


// Implementation: impl RecoveryPaymentAttempt
// File: crates/hyperswitch_domain_models/src/revenue_recovery.rs
// Module: hyperswitch_domain_models
// Methods: 1 total (1 public)

impl RecoveryPaymentAttempt


// Function: list_user_roles_by_user_id_across_tenants
// File: crates/diesel_models/src/query/user_role.rs
// Module: diesel_models

pub fn list_user_roles_by_user_id_across_tenants(
        conn: &PgPooledConn,
        user_id: String,
        limit: Option<u32>,
    ) -> StorageResult<Vec<Self>>


// Implementation: impl api::PaymentAuthorize for for Cybersource
// File: crates/hyperswitch_connectors/src/connectors/cybersource.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)

impl api::PaymentAuthorize for for Cybersource


// File: crates/openapi/src/routes/blocklist.rs
// Module: openapi
// Public functions: 4

#[utoipa::path(
    post,
    path = "/blocklist/toggle",
    params (
        ("status" = bool, Query, description = "Boolean value to enable/disable blocklist"),
    ),
    responses(
        (status = 200, description = "Blocklist guard enabled/disabled", body = ToggleBlocklistResponse),
        (status = 400, description = "Invalid Data")
    ),
    tag = "Blocklist",
    operation_id = "Toggle blocklist guard for a particular merchant",
    security(("api_key" = []))
)]
pub async fn toggle_blocklist_guard() {}

#[utoipa::path(
    post,
    path = "/blocklist",
    request_body = BlocklistRequest,
    responses(
        (status = 200, description = "Fingerprint Blocked", body = BlocklistResponse),
        (status = 400, description = "Invalid Data")
    ),
    tag = "Blocklist",
    operation_id = "Block a Fingerprint",
    security(("api_key" = []))
)]
pub async fn add_entry_to_blocklist() {}

#[utoipa::path(
    delete,
    path = "/blocklist",
    request_body = BlocklistRequest,
    responses(
        (status = 200, description = "Fingerprint Unblocked", body = BlocklistResponse),
        (status = 400, description = "Invalid Data")
    ),
    tag = "Blocklist",
    operation_id = "Unblock a Fingerprint",
    security(("api_key" = []))
)]
pub async fn remove_entry_from_blocklist() {}

#[utoipa::path(
    get,
    path = "/blocklist",
    params (
        ("data_kind" = BlocklistDataKind, Query, description = "Kind of the fingerprint list requested"),
    ),
    responses(
        (status = 200, description = "Blocked Fingerprints", body = BlocklistResponse),
        (status = 400, description = "Invalid Data")
    ),
    tag = "Blocklist",
    operation_id = "List Blocked fingerprints of a particular kind",
    security(("api_key" = []))
)]
pub async fn list_blocked_payment_methods() {}


// Function: get_payment_method_surcharge_routing_id
// File: crates/common_utils/src/id_type/merchant.rs
// Module: common_utils

// Documentation: get_payment_method_surcharge_routing_id

pub fn get_payment_method_surcharge_routing_id(&self) -> String


// Function: get_gsm_decision
// File: crates/router/src/core/payments/retry.rs
// Module: router

pub fn get_gsm_decision(
    option_gsm: Option<hyperswitch_domain_models::gsm::GatewayStatusMap>,
) -> storage_enums::GsmDecision


// File: crates/external_services/src/grpc_client.rs
// Module: external_services
// Public functions: 3
// Public structs: 5

/// Dyanimc Routing Client interface implementation
#[cfg(feature = "dynamic_routing")]
pub mod dynamic_routing;
/// gRPC based Heath Check Client interface implementation
#[cfg(feature = "dynamic_routing")]
pub mod health_check_client;
/// gRPC based Recovery Trainer Client interface implementation
#[cfg(feature = "revenue_recovery")]
pub mod revenue_recovery;

/// gRPC based Unified Connector Service Client interface implementation
pub mod unified_connector_service;
use std::{fmt::Debug, sync::Arc};

#[cfg(feature = "dynamic_routing")]
use common_utils::consts;
use common_utils::{id_type, ucs_types};
#[cfg(feature = "dynamic_routing")]
use dynamic_routing::{DynamicRoutingClientConfig, RoutingStrategy};
#[cfg(feature = "dynamic_routing")]
use health_check_client::HealthCheckClient;
#[cfg(any(feature = "dynamic_routing", feature = "revenue_recovery"))]
use hyper_util::client::legacy::connect::HttpConnector;
#[cfg(any(feature = "dynamic_routing", feature = "revenue_recovery"))]
use router_env::logger;
use serde_urlencoded;
#[cfg(any(feature = "dynamic_routing", feature = "revenue_recovery"))]
use tonic::body::Body;
use typed_builder::TypedBuilder;

#[cfg(feature = "revenue_recovery")]
pub use self::revenue_recovery::{
    recovery_decider_client::{
        DeciderRequest, DeciderResponse, RecoveryDeciderClientConfig,
        RecoveryDeciderClientInterface, RecoveryDeciderError, RecoveryDeciderResult,
    },
    GrpcRecoveryHeaders,
};
use crate::grpc_client::unified_connector_service::{
    UnifiedConnectorServiceClient, UnifiedConnectorServiceClientConfig,
};

#[cfg(any(feature = "dynamic_routing", feature = "revenue_recovery"))]
/// Hyper based Client type for maintaining connection pool for all gRPC services
pub type Client = hyper_util::client::legacy::Client<HttpConnector, Body>;

/// Struct contains all the gRPC Clients
#[derive(Debug, Clone)]
pub struct GrpcClients {
    /// The routing client
    #[cfg(feature = "dynamic_routing")]
    pub dynamic_routing: Option<RoutingStrategy>,
    /// Health Check client for all gRPC services
    #[cfg(feature = "dynamic_routing")]
    pub health_client: HealthCheckClient,
    /// Recovery Decider Client
    #[cfg(feature = "revenue_recovery")]
    pub recovery_decider_client: Option<Box<dyn RecoveryDeciderClientInterface>>,
    /// Unified Connector Service client
    pub unified_connector_service_client: Option<UnifiedConnectorServiceClient>,
}

/// Type that contains the configs required to construct a  gRPC client with its respective services.
#[derive(Debug, Clone, serde::Deserialize, serde::Serialize, Default)]
pub struct GrpcClientSettings {
    #[cfg(feature = "dynamic_routing")]
    /// Configs for Dynamic Routing Client
    pub dynamic_routing_client: Option<DynamicRoutingClientConfig>,
    #[cfg(feature = "revenue_recovery")]
    /// Configs for Recovery Decider Client
    pub recovery_decider_client: Option<RecoveryDeciderClientConfig>,
    /// Configs for Unified Connector Service client
    pub unified_connector_service: Option<UnifiedConnectorServiceClientConfig>,
}

impl GrpcClientSettings {
    /// # Panics
    ///
    /// This function will panic if it fails to establish a connection with the gRPC server.
    /// This function will be called at service startup.
    #[allow(clippy::expect_used)]
    pub async fn get_grpc_client_interface(&self) -> Arc<GrpcClients> {
        #[cfg(any(feature = "dynamic_routing", feature = "revenue_recovery"))]
        let client =
            hyper_util::client::legacy::Client::builder(hyper_util::rt::TokioExecutor::new())
                .http2_only(true)
                .build_http();

        #[cfg(feature = "dynamic_routing")]
        let dynamic_routing_connection = self
            .dynamic_routing_client
            .clone()
            .map(|config| config.get_dynamic_routing_connection(client.clone()))
            .transpose()
            .expect("Failed to establish a connection with the Dynamic Routing Server")
            .flatten();

        #[cfg(feature = "dynamic_routing")]
        let health_client = HealthCheckClient::build_connections(self, client.clone())
            .await
            .expect("Failed to build gRPC connections");

        let unified_connector_service_client =
            UnifiedConnectorServiceClient::build_connections(self).await;

        #[cfg(feature = "revenue_recovery")]
        let recovery_decider_client = {
            match &self.recovery_decider_client {
                Some(config) => {
                    // Validate the config first
                    config
                        .validate()
                        .expect("Recovery Decider configuration validation failed");

                    // Create the client
                    let client = config
                        .get_recovery_decider_connection(client.clone())
                        .expect(
                            "Failed to establish a connection with the Recovery Decider Server",
                        );

                    logger::info!("Recovery Decider gRPC client successfully initialized");
                    let boxed_client: Box<dyn RecoveryDeciderClientInterface> = Box::new(client);
                    Some(boxed_client)
                }
                None => {
                    logger::debug!("Recovery Decider client configuration not provided, client will be disabled");
                    None
                }
            }
        };

        Arc::new(GrpcClients {
            #[cfg(feature = "dynamic_routing")]
            dynamic_routing: dynamic_routing_connection,
            #[cfg(feature = "dynamic_routing")]
            health_client,
            #[cfg(feature = "revenue_recovery")]
            recovery_decider_client,
            unified_connector_service_client,
        })
    }
}

/// Contains grpc headers
#[derive(Debug)]
pub struct GrpcHeaders {
    /// Tenant id
    pub tenant_id: String,
    /// Request id
    pub request_id: Option<String>,
}

/// Contains grpc headers for Ucs
#[derive(Debug, TypedBuilder)]
pub struct GrpcHeadersUcs {
    /// Tenant id
    tenant_id: String,
    /// Lineage ids
    lineage_ids: LineageIds,
    /// External vault proxy metadata
    external_vault_proxy_metadata: Option<String>,
    /// Merchant Reference Id
    merchant_reference_id: Option<ucs_types::UcsReferenceId>,
}

/// Type aliase for GrpcHeaders builder in initial stage
pub type GrpcHeadersUcsBuilderInitial = GrpcHeadersUcsBuilder<((String,), (), (), ())>;
/// Type aliase for GrpcHeaders builder in intermediate stage
pub type GrpcHeadersUcsBuilderFinal = GrpcHeadersUcsBuilder<(
    (String,),
    (LineageIds,),
    (Option<String>,),
    (Option<ucs_types::UcsReferenceId>,),
)>;

/// struct to represent set of Lineage ids
#[derive(Debug, serde::Serialize)]
pub struct LineageIds {
    merchant_id: id_type::MerchantId,
    profile_id: id_type::ProfileId,
}
impl LineageIds {
    /// constructor for LineageIds
    pub fn new(merchant_id: id_type::MerchantId, profile_id: id_type::ProfileId) -> Self {
        Self {
            merchant_id,
            profile_id,
        }
    }
    /// get url encoded string representation of LineageIds
    pub fn get_url_encoded_string(self) -> Result<String, serde_urlencoded::ser::Error> {
        serde_urlencoded::to_string(&self)
    }
}

#[cfg(feature = "dynamic_routing")]
/// Trait to add necessary headers to the tonic Request
pub(crate) trait AddHeaders {
    /// Add necessary header fields to the tonic Request
    fn add_headers_to_grpc_request(&mut self, headers: GrpcHeaders);
}

#[cfg(feature = "dynamic_routing")]
impl<T> AddHeaders for tonic::Request<T> {
    #[track_caller]
    fn add_headers_to_grpc_request(&mut self, headers: GrpcHeaders) {
        headers.tenant_id
            .parse()
            .map(|tenant_id| {
                self
                    .metadata_mut()
                    .append(consts::TENANT_HEADER, tenant_id)
            })
            .inspect_err(
                |err| logger::warn!(header_parse_error=?err,"invalid {} received",consts::TENANT_HEADER),
            )
            .ok();

        headers.request_id.map(|request_id| {
            request_id
                .parse()
                .map(|request_id| {
                    self
                        .metadata_mut()
                        .append(consts::X_REQUEST_ID, request_id)
                })
                .inspect_err(
                    |err| logger::warn!(header_parse_error=?err,"invalid {} received",consts::X_REQUEST_ID),
                )
                .ok();
        });
    }
}

#[cfg(feature = "dynamic_routing")]
pub(crate) fn create_grpc_request<T: Debug>(message: T, headers: GrpcHeaders) -> tonic::Request<T> {
    let mut request = tonic::Request::new(message);
    request.add_headers_to_grpc_request(headers);

    logger::info!(?request);

    request
}


// Struct: EbanxAuthType
// File: crates/hyperswitch_connectors/src/connectors/ebanx/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0

pub struct EbanxAuthType


// Implementation: impl Default for for SmithyGenerator
// File: crates/smithy-core/src/generator.rs
// Module: smithy-core
// Methods: 1 total (0 public)

impl Default for for SmithyGenerator


// Struct: CommonMandateReference
// File: crates/hyperswitch_domain_models/src/mandates.rs
// Module: hyperswitch_domain_models
// Implementations: 1

pub struct CommonMandateReference


// Struct: MandateMetaData
// File: crates/hyperswitch_connectors/src/connectors/gocardless/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0

pub struct MandateMetaData


// Implementation: impl FraudCheckTransaction for for Riskified
// File: crates/hyperswitch_connectors/src/connectors/riskified.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)

impl FraudCheckTransaction for for Riskified


// Implementation: impl api::PaymentToken for for Authipay
// File: crates/hyperswitch_connectors/src/connectors/authipay.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)

impl api::PaymentToken for for Authipay


// Implementation: impl Routing
// File: crates/router/src/routes/app.rs
// Module: router
// Methods: 1 total (1 public)

impl Routing


// Struct: Payouts
// File: crates/hyperswitch_domain_models/src/payouts/payouts.rs
// Module: hyperswitch_domain_models
// Implementations: 0

pub struct Payouts


// File: crates/analytics/src/payment_intents/metrics/sessionized_metrics.rs
// Module: analytics

mod payment_intent_count;
mod payment_processed_amount;
mod payments_distribution;
mod payments_success_rate;
mod smart_retried_amount;
mod successful_smart_retries;
mod total_smart_retries;

pub(super) use payment_intent_count::PaymentIntentCount;
pub(super) use payment_processed_amount::PaymentProcessedAmount;
pub(super) use payments_distribution::PaymentsDistribution;
pub(super) use payments_success_rate::PaymentsSuccessRate;
pub(super) use smart_retried_amount::SmartRetriedAmount;
pub(super) use successful_smart_retries::SuccessfulSmartRetries;
pub(super) use total_smart_retries::TotalSmartRetries;

pub use super::{PaymentIntentMetric, PaymentIntentMetricAnalytics, PaymentIntentMetricRow};


// Function: get_merchant_id_not_found
// File: crates/common_utils/src/id_type/merchant.rs
// Module: common_utils

// Documentation: Get a merchant id with the const value of `MERCHANT_ID_NOT_FOUND`

pub fn get_merchant_id_not_found() -> Self


// Function: get_connector_account_details
// File: crates/hyperswitch_domain_models/src/merchant_connector_account.rs
// Module: hyperswitch_domain_models

pub fn get_connector_account_details(
        &self,
    ) -> error_stack::Result<router_data::ConnectorAuthType, common_utils::errors::ParsingError>


// Trait: ToSql
// File: crates/analytics/src/query.rs
// Module: analytics

pub trait ToSql<T: AnalyticsDataSource>


// Struct: CalSuccessRateEventResponse
// File: crates/router/src/core/payments/routing/utils.rs
// Module: router
// Implementations: 0

pub struct CalSuccessRateEventResponse


// Struct: KafkaStore
// File: crates/router/src/db/kafka_store.rs
// Module: router
// Implementations: 60
// Traits: AddressInterface, ApiKeyInterface, CardsInfoInterface, ConfigInterface, CustomerInterface, DisputeInterface, EphemeralKeyInterface, ClientSecretInterface, EventInterface, LockerMockUpInterface, MandateInterface, PaymentLinkInterface, MerchantAccountInterface, ConnectorAccessToken, FileMetadataInterface, MerchantConnectorAccountInterface, QueueInterface, PaymentAttemptInterface, PaymentIntentInterface, PaymentMethodInterface, PayoutAttemptInterface, PayoutAttemptInterface, PayoutsInterface, PayoutsInterface, ProcessTrackerInterface, CaptureInterface, RefundInterface, MerchantKeyStoreInterface, ProfileInterface, ReverseLookupInterface, RoutingAlgorithmInterface, GsmInterface, UnifiedTranslationsInterface, StorageInterface, GlobalStorageInterface, AccountsStorageInterface, PaymentMethodsStorageInterface, CommonStorageInterface, SchedulerInterface, MasterKeyInterface, UserInterface, RedisConnInterface, UserRoleInterface, DashboardMetadataInterface, BatchSampleDataInterface, AuthorizationInterface, AuthenticationInterface, HealthCheckDbInterface, RoleInterface, GenericLinkInterface, UserKeyStoreInterface, UserAuthenticationMethodInterface, HyperswitchAiInteractionInterface, ThemeInterface, db::payment_method_session::PaymentMethodsSessionInterface, db::payment_method_session::PaymentMethodsSessionInterface, CallbackMapperInterface, TokenizationInterface, TokenizationInterface

pub struct KafkaStore


// Struct: TsysPaymentsCancelRequest
// File: crates/hyperswitch_connectors/src/connectors/tsys/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0

pub struct TsysPaymentsCancelRequest


// Struct: RefundData
// File: crates/hyperswitch_connectors/src/connectors/multisafepay/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0

pub struct RefundData


// Function: delete_refunds
// File: crates/diesel_models/src/query/user/sample_data.rs
// Module: diesel_models

pub fn delete_refunds(
    conn: &PgPooledConn,
    merchant_id: &common_utils::id_type::MerchantId,
) -> StorageResult<Vec<Refund>>


// Struct: UasFlowData
// File: crates/hyperswitch_domain_models/src/router_data_v2/flow_common_types.rs
// Module: hyperswitch_domain_models
// Implementations: 0

pub struct UasFlowData


// Struct: PaymentMethods
// File: crates/router/src/routes/app.rs
// Module: router
// Implementations: 2

pub struct PaymentMethods