// Struct: ClientAuthSetupInfoResponse
// File: crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0

pub struct ClientAuthSetupInfoResponse


// Struct: Proxy
// File: crates/router/src/routes/app.rs
// Module: router
// Implementations: 1

pub struct Proxy


// Struct: PayerInfo
// File: crates/hyperswitch_connectors/src/connectors/iatapay/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0

pub struct PayerInfo


// File: crates/test_utils/tests/connectors/stripe_wh_ui.rs
// Module: test_utils

use thirtyfour::{prelude::*, WebDriver};

use crate::{selenium::*, tester};

struct StripeSeleniumTest;

impl SeleniumTest for StripeSeleniumTest {
    fn get_connector_name(&self) -> String {
        "stripe".to_string()
    }
}

async fn should_make_webhook(web_driver: WebDriver) -> Result<(), WebDriverError> {
    let conn = StripeSeleniumTest {};
    conn.make_webhook_test(
        web_driver,
        &format!("{CHECKOUT_BASE_URL}/saved/16"),
        vec![
            Event::Trigger(Trigger::Click(By::Id("card-submit-btn"))),
            Event::Assert(Assert::IsPresent("status")),
            Event::Assert(Assert::IsPresent("succeeded")),
        ],
        10,
        "succeeded",
    )
    .await?;
    Ok(())
}

#[test]
fn should_make_webhook_test() {
    tester!(should_make_webhook);
}


// Function: get_authorize_page
// File: crates/router/src/routes/dummy_connector/utils.rs
// Module: router

pub fn get_authorize_page(
    payment_data: types::DummyConnectorPaymentData,
    return_url: String,
    dummy_connector_conf: &settings::DummyConnector,
) -> String


// Struct: Storage
// File: crates/router_env/src/logger/storage.rs
// Module: router_env
// Implementations: 3
// Traits: Default, Visit

pub struct Storage<'a>


// Struct: CreateOrderResult
// File: crates/router/src/types.rs
// Module: router
// Implementations: 0

pub struct CreateOrderResult


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

impl Cards


// Function: get_api_event
// File: crates/analytics/src/api_event/events.rs
// Module: analytics

pub fn get_api_event<T>(
    merchant_id: &common_utils::id_type::MerchantId,
    query_param: ApiLogsRequest,
    pool: &T,
) -> FiltersResult<Vec<ApiLogsResult>>
where
    T: AnalyticsDataSource + ApiLogsFilterAnalytics,
    PrimitiveDateTime: ToSql<T>,
    AnalyticsCollection: ToSql<T>,
    Granularity: GroupByClause<T>,
    Aggregate<&'static str>: ToSql<T>,
    Window<&'static str>: ToSql<T>,


// File: crates/router/src/routes/three_ds_decision_rule.rs
// Module: router
// Public functions: 1

use actix_web::{web, Responder};
use hyperswitch_domain_models::merchant_context::{Context, MerchantContext};
use router_env::{instrument, tracing, Flow};

use crate::{
    self as app,
    core::{api_locking, three_ds_decision_rule as three_ds_decision_rule_core},
    services::{api, authentication as auth},
};

#[instrument(skip_all, fields(flow = ?Flow::ThreeDsDecisionRuleExecute))]
#[cfg(feature = "oltp")]
pub async fn execute_decision_rule(
    state: web::Data<app::AppState>,
    req: actix_web::HttpRequest,
    payload: web::Json<api_models::three_ds_decision_rule::ThreeDsDecisionRuleExecuteRequest>,
) -> impl Responder {
    let flow = Flow::ThreeDsDecisionRuleExecute;
    let payload = payload.into_inner();
    Box::pin(api::server_wrap(
        flow,
        state,
        &req,
        payload,
        |state, auth: auth::AuthenticationData, req, _| {
            let merchant_context = MerchantContext::NormalMerchant(Box::new(Context(
                auth.merchant_account,
                auth.key_store,
            )));
            three_ds_decision_rule_core::execute_three_ds_decision_rule(
                state,
                merchant_context,
                req,
            )
        },
        &auth::HeaderAuth(auth::ApiKeyAuth {
            is_connected_allowed: false,
            is_platform_allowed: false,
        }),
        api_locking::LockAction::NotApplicable,
    ))
    .await
}


// Implementation: impl PaymentMethodsEnabled
// File: crates/api_models/src/admin.rs
// Module: api_models
// Methods: 2 total (2 public)

impl PaymentMethodsEnabled


// Struct: GiftCardDetails
// File: crates/hyperswitch_domain_models/src/payment_method_data.rs
// Module: hyperswitch_domain_models
// Implementations: 0

pub struct GiftCardDetails


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

mod core;
pub mod events;
pub mod filters;
pub mod metrics;
pub mod types;

pub trait APIEventAnalytics: events::ApiLogsFilterAnalytics {}

pub use self::core::{api_events_core, get_api_event_metrics, get_filters};


// Struct: Tax
// File: crates/hyperswitch_connectors/src/connectors/taxjar/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0

pub struct Tax


// Struct: GetCardToken
// File: crates/router/src/types/payment_methods.rs
// Module: router
// Implementations: 0

pub struct GetCardToken


// Function: payouts_list_core
// File: crates/router/src/core/payouts.rs
// Module: router

pub fn payouts_list_core(
    _state: SessionState,
    _merchant_context: domain::MerchantContext,
    _profile_id_list: Option<Vec<id_type::ProfileId>>,
    _constraints: payouts::PayoutListConstraints,
) -> RouterResponse<payouts::PayoutListResponse>


// Implementation: impl CardInfoBuilder
// File: crates/router/src/core/cards_info.rs
// Module: router
// Methods: 1 total (0 public)

impl CardInfoBuilder


// Implementation: impl AddressConstructor for for ShippingAddress
// File: crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs
// Module: hyperswitch_connectors
// Methods: 1 total (0 public)

impl AddressConstructor for for ShippingAddress


// File: crates/router/src/core/authentication/transformers.rs
// Module: router
// Public functions: 4

use std::marker::PhantomData;

use api_models::payments;
use common_enums::PaymentMethod;
use common_utils::ext_traits::ValueExt;
use error_stack::ResultExt;

use crate::{
    core::{
        errors::{self, RouterResult},
        payments::helpers as payments_helpers,
    },
    types::{
        self, domain, storage,
        transformers::{ForeignFrom, ForeignTryFrom},
    },
    utils::ext_traits::OptionExt,
    SessionState,
};

const IRRELEVANT_ATTEMPT_ID_IN_AUTHENTICATION_FLOW: &str =
    "irrelevant_attempt_id_in_AUTHENTICATION_flow";
const IRRELEVANT_CONNECTOR_REQUEST_REFERENCE_ID_IN_AUTHENTICATION_FLOW: &str =
    "irrelevant_connector_request_reference_id_in_AUTHENTICATION_flow";

#[allow(clippy::too_many_arguments)]
pub fn construct_authentication_router_data(
    state: &SessionState,
    merchant_id: common_utils::id_type::MerchantId,
    authentication_connector: String,
    payment_method_data: domain::PaymentMethodData,
    payment_method: PaymentMethod,
    billing_address: hyperswitch_domain_models::address::Address,
    shipping_address: Option<hyperswitch_domain_models::address::Address>,
    browser_details: Option<types::BrowserInformation>,
    amount: Option<common_utils::types::MinorUnit>,
    currency: Option<common_enums::Currency>,
    message_category: types::api::authentication::MessageCategory,
    device_channel: payments::DeviceChannel,
    merchant_connector_account: payments_helpers::MerchantConnectorAccountType,
    authentication_data: storage::Authentication,
    return_url: Option<String>,
    sdk_information: Option<payments::SdkInformation>,
    threeds_method_comp_ind: payments::ThreeDsCompletionIndicator,
    email: Option<common_utils::pii::Email>,
    webhook_url: String,
    three_ds_requestor_url: String,
    psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>,
    payment_id: common_utils::id_type::PaymentId,
    force_3ds_challenge: bool,
) -> RouterResult<types::authentication::ConnectorAuthenticationRouterData> {
    let router_request = types::authentication::ConnectorAuthenticationRequestData {
        payment_method_data,
        billing_address,
        shipping_address,
        browser_details,
        amount: amount.map(|amt| amt.get_amount_as_i64()),
        currency,
        message_category,
        device_channel,
        pre_authentication_data: super::types::PreAuthenticationData::foreign_try_from(
            &authentication_data,
        )?,
        return_url,
        sdk_information,
        email,
        three_ds_requestor_url,
        threeds_method_comp_ind,
        webhook_url,
        force_3ds_challenge,
    };
    construct_router_data(
        state,
        authentication_connector,
        payment_method,
        merchant_id.clone(),
        types::PaymentAddress::default(),
        router_request,
        &merchant_connector_account,
        psd2_sca_exemption_type,
        payment_id,
    )
}

pub fn construct_post_authentication_router_data(
    state: &SessionState,
    authentication_connector: String,
    business_profile: domain::Profile,
    merchant_connector_account: payments_helpers::MerchantConnectorAccountType,
    authentication_data: &storage::Authentication,
    payment_id: &common_utils::id_type::PaymentId,
) -> RouterResult<types::authentication::ConnectorPostAuthenticationRouterData> {
    let threeds_server_transaction_id = authentication_data
        .threeds_server_transaction_id
        .clone()
        .get_required_value("threeds_server_transaction_id")
        .change_context(errors::ApiErrorResponse::InternalServerError)?;
    let router_request = types::authentication::ConnectorPostAuthenticationRequestData {
        threeds_server_transaction_id,
    };
    construct_router_data(
        state,
        authentication_connector,
        PaymentMethod::default(),
        business_profile.merchant_id.clone(),
        types::PaymentAddress::default(),
        router_request,
        &merchant_connector_account,
        None,
        payment_id.clone(),
    )
}

pub fn construct_pre_authentication_router_data<F: Clone>(
    state: &SessionState,
    authentication_connector: String,
    card: hyperswitch_domain_models::payment_method_data::Card,
    merchant_connector_account: &payments_helpers::MerchantConnectorAccountType,
    merchant_id: common_utils::id_type::MerchantId,
    payment_id: common_utils::id_type::PaymentId,
) -> RouterResult<
    types::RouterData<
        F,
        types::authentication::PreAuthNRequestData,
        types::authentication::AuthenticationResponseData,
    >,
> {
    let router_request = types::authentication::PreAuthNRequestData { card };
    construct_router_data(
        state,
        authentication_connector,
        PaymentMethod::default(),
        merchant_id,
        types::PaymentAddress::default(),
        router_request,
        merchant_connector_account,
        None,
        payment_id,
    )
}

#[allow(clippy::too_many_arguments)]
pub fn construct_router_data<F: Clone, Req, Res>(
    state: &SessionState,
    authentication_connector_name: String,
    payment_method: PaymentMethod,
    merchant_id: common_utils::id_type::MerchantId,
    address: types::PaymentAddress,
    request_data: Req,
    merchant_connector_account: &payments_helpers::MerchantConnectorAccountType,
    psd2_sca_exemption_type: Option<common_enums::ScaExemptionType>,
    payment_id: common_utils::id_type::PaymentId,
) -> RouterResult<types::RouterData<F, Req, Res>> {
    let test_mode: Option<bool> = merchant_connector_account.is_test_mode_on();
    let auth_type: types::ConnectorAuthType = merchant_connector_account
        .get_connector_account_details()
        .parse_value("ConnectorAuthType")
        .change_context(errors::ApiErrorResponse::InternalServerError)?;
    Ok(types::RouterData {
        flow: PhantomData,
        merchant_id,
        customer_id: None,
        tenant_id: state.tenant.tenant_id.clone(),
        connector_customer: None,
        connector: authentication_connector_name,
        payment_id: payment_id.get_string_repr().to_owned(),
        attempt_id: IRRELEVANT_ATTEMPT_ID_IN_AUTHENTICATION_FLOW.to_owned(),
        status: common_enums::AttemptStatus::default(),
        payment_method,
        connector_auth_type: auth_type,
        description: None,
        address,
        auth_type: common_enums::AuthenticationType::NoThreeDs,
        connector_meta_data: merchant_connector_account.get_metadata(),
        connector_wallets_details: merchant_connector_account.get_connector_wallets_details(),
        amount_captured: None,
        minor_amount_captured: None,
        access_token: None,
        session_token: None,
        reference_id: None,
        payment_method_token: None,
        recurring_mandate_payment_data: None,
        preprocessing_id: None,
        payment_method_balance: None,
        connector_api_version: None,
        request: request_data,
        response: Err(types::ErrorResponse::default()),
        connector_request_reference_id:
            IRRELEVANT_CONNECTOR_REQUEST_REFERENCE_ID_IN_AUTHENTICATION_FLOW.to_owned(),
        #[cfg(feature = "payouts")]
        payout_method_data: None,
        #[cfg(feature = "payouts")]
        quote_id: None,
        test_mode,
        connector_http_status_code: None,
        external_latency: None,
        apple_pay_flow: None,
        frm_metadata: None,
        dispute_id: None,
        refund_id: None,
        payment_method_status: None,
        connector_response: None,
        integrity_check: Ok(()),
        additional_merchant_data: None,
        header_payload: None,
        connector_mandate_request_reference_id: None,
        authentication_id: None,
        psd2_sca_exemption_type,
        raw_connector_response: None,
        is_payment_id_from_merchant: None,
        l2_l3_data: None,
        minor_amount_capturable: None,
    })
}

impl ForeignFrom<common_enums::TransactionStatus> for common_enums::AuthenticationStatus {
    fn foreign_from(trans_status: common_enums::TransactionStatus) -> Self {
        match trans_status {
            common_enums::TransactionStatus::Success => Self::Success,
            common_enums::TransactionStatus::Failure
            | common_enums::TransactionStatus::Rejected
            | common_enums::TransactionStatus::VerificationNotPerformed
            | common_enums::TransactionStatus::NotVerified => Self::Failed,
            common_enums::TransactionStatus::ChallengeRequired
            | common_enums::TransactionStatus::ChallengeRequiredDecoupledAuthentication
            | common_enums::TransactionStatus::InformationOnly => Self::Pending,
        }
    }
}


// File: crates/common_enums/src/transformers.rs
// Module: common_enums
// Public functions: 10
// Public structs: 1

use std::fmt::{Display, Formatter};

use serde::{Deserialize, Serialize};

#[cfg(feature = "payouts")]
use crate::enums::PayoutStatus;
use crate::enums::{
    AttemptStatus, Country, CountryAlpha2, CountryAlpha3, DisputeStatus, EventType, IntentStatus,
    MandateStatus, PaymentMethod, PaymentMethodType, RefundStatus,
};

impl Display for NumericCountryCodeParseError {
    fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
        write!(f, "Invalid Country Code")
    }
}

impl CountryAlpha2 {
    pub const fn from_alpha2_to_alpha3(code: Self) -> CountryAlpha3 {
        match code {
            Self::AF => CountryAlpha3::AFG,
            Self::AX => CountryAlpha3::ALA,
            Self::AL => CountryAlpha3::ALB,
            Self::DZ => CountryAlpha3::DZA,
            Self::AS => CountryAlpha3::ASM,
            Self::AD => CountryAlpha3::AND,
            Self::AO => CountryAlpha3::AGO,
            Self::AI => CountryAlpha3::AIA,
            Self::AQ => CountryAlpha3::ATA,
            Self::AG => CountryAlpha3::ATG,
            Self::AR => CountryAlpha3::ARG,
            Self::AM => CountryAlpha3::ARM,
            Self::AW => CountryAlpha3::ABW,
            Self::AU => CountryAlpha3::AUS,
            Self::AT => CountryAlpha3::AUT,
            Self::AZ => CountryAlpha3::AZE,
            Self::BS => CountryAlpha3::BHS,
            Self::BH => CountryAlpha3::BHR,
            Self::BD => CountryAlpha3::BGD,
            Self::BB => CountryAlpha3::BRB,
            Self::BY => CountryAlpha3::BLR,
            Self::BE => CountryAlpha3::BEL,
            Self::BZ => CountryAlpha3::BLZ,
            Self::BJ => CountryAlpha3::BEN,
            Self::BM => CountryAlpha3::BMU,
            Self::BT => CountryAlpha3::BTN,
            Self::BO => CountryAlpha3::BOL,
            Self::BQ => CountryAlpha3::BES,
            Self::BA => CountryAlpha3::BIH,
            Self::BW => CountryAlpha3::BWA,
            Self::BV => CountryAlpha3::BVT,
            Self::BR => CountryAlpha3::BRA,
            Self::IO => CountryAlpha3::IOT,
            Self::BN => CountryAlpha3::BRN,
            Self::BG => CountryAlpha3::BGR,
            Self::BF => CountryAlpha3::BFA,
            Self::BI => CountryAlpha3::BDI,
            Self::CV => CountryAlpha3::CPV,
            Self::KH => CountryAlpha3::KHM,
            Self::CM => CountryAlpha3::CMR,
            Self::CA => CountryAlpha3::CAN,
            Self::KY => CountryAlpha3::CYM,
            Self::CF => CountryAlpha3::CAF,
            Self::TD => CountryAlpha3::TCD,
            Self::CL => CountryAlpha3::CHL,
            Self::CN => CountryAlpha3::CHN,
            Self::CX => CountryAlpha3::CXR,
            Self::CC => CountryAlpha3::CCK,
            Self::CO => CountryAlpha3::COL,
            Self::KM => CountryAlpha3::COM,
            Self::CG => CountryAlpha3::COG,
            Self::CD => CountryAlpha3::COD,
            Self::CK => CountryAlpha3::COK,
            Self::CR => CountryAlpha3::CRI,
            Self::CI => CountryAlpha3::CIV,
            Self::HR => CountryAlpha3::HRV,
            Self::CU => CountryAlpha3::CUB,
            Self::CW => CountryAlpha3::CUW,
            Self::CY => CountryAlpha3::CYP,
            Self::CZ => CountryAlpha3::CZE,
            Self::DK => CountryAlpha3::DNK,
            Self::DJ => CountryAlpha3::DJI,
            Self::DM => CountryAlpha3::DMA,
            Self::DO => CountryAlpha3::DOM,
            Self::EC => CountryAlpha3::ECU,
            Self::EG => CountryAlpha3::EGY,
            Self::SV => CountryAlpha3::SLV,
            Self::GQ => CountryAlpha3::GNQ,
            Self::ER => CountryAlpha3::ERI,
            Self::EE => CountryAlpha3::EST,
            Self::ET => CountryAlpha3::ETH,
            Self::FK => CountryAlpha3::FLK,
            Self::FO => CountryAlpha3::FRO,
            Self::FJ => CountryAlpha3::FJI,
            Self::FI => CountryAlpha3::FIN,
            Self::FR => CountryAlpha3::FRA,
            Self::GF => CountryAlpha3::GUF,
            Self::PF => CountryAlpha3::PYF,
            Self::TF => CountryAlpha3::ATF,
            Self::GA => CountryAlpha3::GAB,
            Self::GM => CountryAlpha3::GMB,
            Self::GE => CountryAlpha3::GEO,
            Self::DE => CountryAlpha3::DEU,
            Self::GH => CountryAlpha3::GHA,
            Self::GI => CountryAlpha3::GIB,
            Self::GR => CountryAlpha3::GRC,
            Self::GL => CountryAlpha3::GRL,
            Self::GD => CountryAlpha3::GRD,
            Self::GP => CountryAlpha3::GLP,
            Self::GU => CountryAlpha3::GUM,
            Self::GT => CountryAlpha3::GTM,
            Self::GG => CountryAlpha3::GGY,
            Self::GN => CountryAlpha3::GIN,
            Self::GW => CountryAlpha3::GNB,
            Self::GY => CountryAlpha3::GUY,
            Self::HT => CountryAlpha3::HTI,
            Self::HM => CountryAlpha3::HMD,
            Self::VA => CountryAlpha3::VAT,
            Self::HN => CountryAlpha3::HND,
            Self::HK => CountryAlpha3::HKG,
            Self::HU => CountryAlpha3::HUN,
            Self::IS => CountryAlpha3::ISL,
            Self::IN => CountryAlpha3::IND,
            Self::ID => CountryAlpha3::IDN,
            Self::IR => CountryAlpha3::IRN,
            Self::IQ => CountryAlpha3::IRQ,
            Self::IE => CountryAlpha3::IRL,
            Self::IM => CountryAlpha3::IMN,
            Self::IL => CountryAlpha3::ISR,
            Self::IT => CountryAlpha3::ITA,
            Self::JM => CountryAlpha3::JAM,
            Self::JP => CountryAlpha3::JPN,
            Self::JE => CountryAlpha3::JEY,
            Self::JO => CountryAlpha3::JOR,
            Self::KZ => CountryAlpha3::KAZ,
            Self::KE => CountryAlpha3::KEN,
            Self::KI => CountryAlpha3::KIR,
            Self::KP => CountryAlpha3::PRK,
            Self::KR => CountryAlpha3::KOR,
            Self::KW => CountryAlpha3::KWT,
            Self::KG => CountryAlpha3::KGZ,
            Self::LA => CountryAlpha3::LAO,
            Self::LV => CountryAlpha3::LVA,
            Self::LB => CountryAlpha3::LBN,
            Self::LS => CountryAlpha3::LSO,
            Self::LR => CountryAlpha3::LBR,
            Self::LY => CountryAlpha3::LBY,
            Self::LI => CountryAlpha3::LIE,
            Self::LT => CountryAlpha3::LTU,
            Self::LU => CountryAlpha3::LUX,
            Self::MO => CountryAlpha3::MAC,
            Self::MK => CountryAlpha3::MKD,
            Self::MG => CountryAlpha3::MDG,
            Self::MW => CountryAlpha3::MWI,
            Self::MY => CountryAlpha3::MYS,
            Self::MV => CountryAlpha3::MDV,
            Self::ML => CountryAlpha3::MLI,
            Self::MT => CountryAlpha3::MLT,
            Self::MH => CountryAlpha3::MHL,
            Self::MQ => CountryAlpha3::MTQ,
            Self::MR => CountryAlpha3::MRT,
            Self::MU => CountryAlpha3::MUS,
            Self::YT => CountryAlpha3::MYT,
            Self::MX => CountryAlpha3::MEX,
            Self::FM => CountryAlpha3::FSM,
            Self::MD => CountryAlpha3::MDA,
            Self::MC => CountryAlpha3::MCO,
            Self::MN => CountryAlpha3::MNG,
            Self::ME => CountryAlpha3::MNE,
            Self::MS => CountryAlpha3::MSR,
            Self::MA => CountryAlpha3::MAR,
            Self::MZ => CountryAlpha3::MOZ,
            Self::MM => CountryAlpha3::MMR,
            Self::NA => CountryAlpha3::NAM,
            Self::NR => CountryAlpha3::NRU,
            Self::NP => CountryAlpha3::NPL,
            Self::NL => CountryAlpha3::NLD,
            Self::NC => CountryAlpha3::NCL,
            Self::NZ => CountryAlpha3::NZL,
            Self::NI => CountryAlpha3::NIC,
            Self::NE => CountryAlpha3::NER,
            Self::NG => CountryAlpha3::NGA,
            Self::NU => CountryAlpha3::NIU,
            Self::NF => CountryAlpha3::NFK,
            Self::MP => CountryAlpha3::MNP,
            Self::NO => CountryAlpha3::NOR,
            Self::OM => CountryAlpha3::OMN,
            Self::PK => CountryAlpha3::PAK,
            Self::PW => CountryAlpha3::PLW,
            Self::PS => CountryAlpha3::PSE,
            Self::PA => CountryAlpha3::PAN,
            Self::PG => CountryAlpha3::PNG,
            Self::PY => CountryAlpha3::PRY,
            Self::PE => CountryAlpha3::PER,
            Self::PH => CountryAlpha3::PHL,
            Self::PN => CountryAlpha3::PCN,
            Self::PL => CountryAlpha3::POL,
            Self::PT => CountryAlpha3::PRT,
            Self::PR => CountryAlpha3::PRI,
            Self::QA => CountryAlpha3::QAT,
            Self::RE => CountryAlpha3::REU,
            Self::RO => CountryAlpha3::ROU,
            Self::RU => CountryAlpha3::RUS,
            Self::RW => CountryAlpha3::RWA,
            Self::BL => CountryAlpha3::BLM,
            Self::SH => CountryAlpha3::SHN,
            Self::KN => CountryAlpha3::KNA,
            Self::LC => CountryAlpha3::LCA,
            Self::MF => CountryAlpha3::MAF,
            Self::PM => CountryAlpha3::SPM,
            Self::VC => CountryAlpha3::VCT,
            Self::WS => CountryAlpha3::WSM,
            Self::SM => CountryAlpha3::SMR,
            Self::ST => CountryAlpha3::STP,
            Self::SA => CountryAlpha3::SAU,
            Self::SN => CountryAlpha3::SEN,
            Self::RS => CountryAlpha3::SRB,
            Self::SC => CountryAlpha3::SYC,
            Self::SL => CountryAlpha3::SLE,
            Self::SG => CountryAlpha3::SGP,
            Self::SX => CountryAlpha3::SXM,
            Self::SK => CountryAlpha3::SVK,
            Self::SI => CountryAlpha3::SVN,
            Self::SB => CountryAlpha3::SLB,
            Self::SO => CountryAlpha3::SOM,
            Self::ZA => CountryAlpha3::ZAF,
            Self::GS => CountryAlpha3::SGS,
            Self::SS => CountryAlpha3::SSD,
            Self::ES => CountryAlpha3::ESP,
            Self::LK => CountryAlpha3::LKA,
            Self::SD => CountryAlpha3::SDN,
            Self::SR => CountryAlpha3::SUR,
            Self::SJ => CountryAlpha3::SJM,
            Self::SZ => CountryAlpha3::SWZ,
            Self::SE => CountryAlpha3::SWE,
            Self::CH => CountryAlpha3::CHE,
            Self::SY => CountryAlpha3::SYR,
            Self::TW => CountryAlpha3::TWN,
            Self::TJ => CountryAlpha3::TJK,
            Self::TZ => CountryAlpha3::TZA,
            Self::TH => CountryAlpha3::THA,
            Self::TL => CountryAlpha3::TLS,
            Self::TG => CountryAlpha3::TGO,
            Self::TK => CountryAlpha3::TKL,
            Self::TO => CountryAlpha3::TON,
            Self::TT => CountryAlpha3::TTO,
            Self::TN => CountryAlpha3::TUN,
            Self::TR => CountryAlpha3::TUR,
            Self::TM => CountryAlpha3::TKM,
            Self::TC => CountryAlpha3::TCA,
            Self::TV => CountryAlpha3::TUV,
            Self::UG => CountryAlpha3::UGA,
            Self::UA => CountryAlpha3::UKR,
            Self::AE => CountryAlpha3::ARE,
            Self::GB => CountryAlpha3::GBR,
            Self::US => CountryAlpha3::USA,
            Self::UM => CountryAlpha3::UMI,
            Self::UY => CountryAlpha3::URY,
            Self::UZ => CountryAlpha3::UZB,
            Self::VU => CountryAlpha3::VUT,
            Self::VE => CountryAlpha3::VEN,
            Self::VN => CountryAlpha3::VNM,
            Self::VG => CountryAlpha3::VGB,
            Self::VI => CountryAlpha3::VIR,
            Self::WF => CountryAlpha3::WLF,
            Self::EH => CountryAlpha3::ESH,
            Self::YE => CountryAlpha3::YEM,
            Self::ZM => CountryAlpha3::ZMB,
            Self::ZW => CountryAlpha3::ZWE,
        }
    }
}
impl Country {
    pub const fn from_alpha2(code: CountryAlpha2) -> Self {
        match code {
            CountryAlpha2::AF => Self::Afghanistan,
            CountryAlpha2::AX => Self::AlandIslands,
            CountryAlpha2::AL => Self::Albania,
            CountryAlpha2::DZ => Self::Algeria,
            CountryAlpha2::AS => Self::AmericanSamoa,
            CountryAlpha2::AD => Self::Andorra,
            CountryAlpha2::AO => Self::Angola,
            CountryAlpha2::AI => Self::Anguilla,
            CountryAlpha2::AQ => Self::Antarctica,
            CountryAlpha2::AG => Self::AntiguaAndBarbuda,
            CountryAlpha2::AR => Self::Argentina,
            CountryAlpha2::AM => Self::Armenia,
            CountryAlpha2::AW => Self::Aruba,
            CountryAlpha2::AU => Self::Australia,
            CountryAlpha2::AT => Self::Austria,
            CountryAlpha2::AZ => Self::Azerbaijan,
            CountryAlpha2::BS => Self::Bahamas,
            CountryAlpha2::BH => Self::Bahrain,
            CountryAlpha2::BD => Self::Bangladesh,
            CountryAlpha2::BB => Self::Barbados,
            CountryAlpha2::BY => Self::Belarus,
            CountryAlpha2::BE => Self::Belgium,
            CountryAlpha2::BZ => Self::Belize,
            CountryAlpha2::BJ => Self::Benin,
            CountryAlpha2::BM => Self::Bermuda,
            CountryAlpha2::BT => Self::Bhutan,
            CountryAlpha2::BO => Self::BoliviaPlurinationalState,
            CountryAlpha2::BQ => Self::BonaireSintEustatiusAndSaba,
            CountryAlpha2::BA => Self::BosniaAndHerzegovina,
            CountryAlpha2::BW => Self::Botswana,
            CountryAlpha2::BV => Self::BouvetIsland,
            CountryAlpha2::BR => Self::Brazil,
            CountryAlpha2::IO => Self::BritishIndianOceanTerritory,
            CountryAlpha2::BN => Self::BruneiDarussalam,
            CountryAlpha2::BG => Self::Bulgaria,
            CountryAlpha2::BF => Self::BurkinaFaso,
            CountryAlpha2::BI => Self::Burundi,
            CountryAlpha2::CV => Self::CaboVerde,
            CountryAlpha2::KH => Self::Cambodia,
            CountryAlpha2::CM => Self::Cameroon,
            CountryAlpha2::CA => Self::Canada,
            CountryAlpha2::KY => Self::CaymanIslands,
            CountryAlpha2::CF => Self::CentralAfricanRepublic,
            CountryAlpha2::TD => Self::Chad,
            CountryAlpha2::CL => Self::Chile,
            CountryAlpha2::CN => Self::China,
            CountryAlpha2::CX => Self::ChristmasIsland,
            CountryAlpha2::CC => Self::CocosKeelingIslands,
            CountryAlpha2::CO => Self::Colombia,
            CountryAlpha2::KM => Self::Comoros,
            CountryAlpha2::CG => Self::Congo,
            CountryAlpha2::CD => Self::CongoDemocraticRepublic,
            CountryAlpha2::CK => Self::CookIslands,
            CountryAlpha2::CR => Self::CostaRica,
            CountryAlpha2::CI => Self::CotedIvoire,
            CountryAlpha2::HR => Self::Croatia,
            CountryAlpha2::CU => Self::Cuba,
            CountryAlpha2::CW => Self::Curacao,
            CountryAlpha2::CY => Self::Cyprus,
            CountryAlpha2::CZ => Self::Czechia,
            CountryAlpha2::DK => Self::Denmark,
            CountryAlpha2::DJ => Self::Djibouti,
            CountryAlpha2::DM => Self::Dominica,
            CountryAlpha2::DO => Self::DominicanRepublic,
            CountryAlpha2::EC => Self::Ecuador,
            CountryAlpha2::EG => Self::Egypt,
            CountryAlpha2::SV => Self::ElSalvador,
            CountryAlpha2::GQ => Self::EquatorialGuinea,
            CountryAlpha2::ER => Self::Eritrea,
            CountryAlpha2::EE => Self::Estonia,
            CountryAlpha2::ET => Self::Ethiopia,
            CountryAlpha2::FK => Self::FalklandIslandsMalvinas,
            CountryAlpha2::FO => Self::FaroeIslands,
            CountryAlpha2::FJ => Self::Fiji,
            CountryAlpha2::FI => Self::Finland,
            CountryAlpha2::FR => Self::France,
            CountryAlpha2::GF => Self::FrenchGuiana,
            CountryAlpha2::PF => Self::FrenchPolynesia,
            CountryAlpha2::TF => Self::FrenchSouthernTerritories,
            CountryAlpha2::GA => Self::Gabon,
            CountryAlpha2::GM => Self::Gambia,
            CountryAlpha2::GE => Self::Georgia,
            CountryAlpha2::DE => Self::Germany,
            CountryAlpha2::GH => Self::Ghana,
            CountryAlpha2::GI => Self::Gibraltar,
            CountryAlpha2::GR => Self::Greece,
            CountryAlpha2::GL => Self::Greenland,
            CountryAlpha2::GD => Self::Grenada,
            CountryAlpha2::GP => Self::Guadeloupe,
            CountryAlpha2::GU => Self::Guam,
            CountryAlpha2::GT => Self::Guatemala,
            CountryAlpha2::GG => Self::Guernsey,
            CountryAlpha2::GN => Self::Guinea,
            CountryAlpha2::GW => Self::GuineaBissau,
            CountryAlpha2::GY => Self::Guyana,
            CountryAlpha2::HT => Self::Haiti,
            CountryAlpha2::HM => Self::HeardIslandAndMcDonaldIslands,
            CountryAlpha2::VA => Self::HolySee,
            CountryAlpha2::HN => Self::Honduras,
            CountryAlpha2::HK => Self::HongKong,
            CountryAlpha2::HU => Self::Hungary,
            CountryAlpha2::IS => Self::Iceland,
            CountryAlpha2::IN => Self::India,
            CountryAlpha2::ID => Self::Indonesia,
            CountryAlpha2::IR => Self::IranIslamicRepublic,
            CountryAlpha2::IQ => Self::Iraq,
            CountryAlpha2::IE => Self::Ireland,
            CountryAlpha2::IM => Self::IsleOfMan,
            CountryAlpha2::IL => Self::Israel,
            CountryAlpha2::IT => Self::Italy,
            CountryAlpha2::JM => Self::Jamaica,
            CountryAlpha2::JP => Self::Japan,
            CountryAlpha2::JE => Self::Jersey,
            CountryAlpha2::JO => Self::Jordan,
            CountryAlpha2::KZ => Self::Kazakhstan,
            CountryAlpha2::KE => Self::Kenya,
            CountryAlpha2::KI => Self::Kiribati,
            CountryAlpha2::KP => Self::KoreaDemocraticPeoplesRepublic,
            CountryAlpha2::KR => Self::KoreaRepublic,
            CountryAlpha2::KW => Self::Kuwait,
            CountryAlpha2::KG => Self::Kyrgyzstan,
            CountryAlpha2::LA => Self::LaoPeoplesDemocraticRepublic,
            CountryAlpha2::LV => Self::Latvia,
            CountryAlpha2::LB => Self::Lebanon,
            CountryAlpha2::LS => Self::Lesotho,
            CountryAlpha2::LR => Self::Liberia,
            CountryAlpha2::LY => Self::Libya,
            CountryAlpha2::LI => Self::Liechtenstein,
            CountryAlpha2::LT => Self::Lithuania,
            CountryAlpha2::LU => Self::Luxembourg,
            CountryAlpha2::MO => Self::Macao,
            CountryAlpha2::MK => Self::MacedoniaTheFormerYugoslavRepublic,
            CountryAlpha2::MG => Self::Madagascar,
            CountryAlpha2::MW => Self::Malawi,
            CountryAlpha2::MY => Self::Malaysia,
            CountryAlpha2::MV => Self::Maldives,
            CountryAlpha2::ML => Self::Mali,
            CountryAlpha2::MT => Self::Malta,
            CountryAlpha2::MH => Self::MarshallIslands,
            CountryAlpha2::MQ => Self::Martinique,
            CountryAlpha2::MR => Self::Mauritania,
            CountryAlpha2::MU => Self::Mauritius,
            CountryAlpha2::YT => Self::Mayotte,
            CountryAlpha2::MX => Self::Mexico,
            CountryAlpha2::FM => Self::MicronesiaFederatedStates,
            CountryAlpha2::MD => Self::MoldovaRepublic,
            CountryAlpha2::MC => Self::Monaco,
            CountryAlpha2::MN => Self::Mongolia,
            CountryAlpha2::ME => Self::Montenegro,
            CountryAlpha2::MS => Self::Montserrat,
            CountryAlpha2::MA => Self::Morocco,
            CountryAlpha2::MZ => Self::Mozambique,
            CountryAlpha2::MM => Self::Myanmar,
            CountryAlpha2::NA => Self::Namibia,
            CountryAlpha2::NR => Self::Nauru,
            CountryAlpha2::NP => Self::Nepal,
            CountryAlpha2::NL => Self::Netherlands,
            CountryAlpha2::NC => Self::NewCaledonia,
            CountryAlpha2::NZ => Self::NewZealand,
            CountryAlpha2::NI => Self::Nicaragua,
            CountryAlpha2::NE => Self::Niger,
            CountryAlpha2::NG => Self::Nigeria,
            CountryAlpha2::NU => Self::Niue,
            CountryAlpha2::NF => Self::NorfolkIsland,
            CountryAlpha2::MP => Self::NorthernMarianaIslands,
            CountryAlpha2::NO => Self::Norway,
            CountryAlpha2::OM => Self::Oman,
            CountryAlpha2::PK => Self::Pakistan,
            CountryAlpha2::PW => Self::Palau,
            CountryAlpha2::PS => Self::PalestineState,
            CountryAlpha2::PA => Self::Panama,
            CountryAlpha2::PG => Self::PapuaNewGuinea,
            CountryAlpha2::PY => Self::Paraguay,
            CountryAlpha2::PE => Self::Peru,
            CountryAlpha2::PH => Self::Philippines,
            CountryAlpha2::PN => Self::Pitcairn,
            CountryAlpha2::PL => Self::Poland,
            CountryAlpha2::PT => Self::Portugal,
            CountryAlpha2::PR => Self::PuertoRico,
            CountryAlpha2::QA => Self::Qatar,
            CountryAlpha2::RE => Self::Reunion,
            CountryAlpha2::RO => Self::Romania,
            CountryAlpha2::RU => Self::RussianFederation,
            CountryAlpha2::RW => Self::Rwanda,
            CountryAlpha2::BL => Self::SaintBarthelemy,
            CountryAlpha2::SH => Self::SaintHelenaAscensionAndTristandaCunha,
            CountryAlpha2::KN => Self::SaintKittsAndNevis,
            CountryAlpha2::LC => Self::SaintLucia,
            CountryAlpha2::MF => Self::SaintMartinFrenchpart,
            CountryAlpha2::PM => Self::SaintPierreAndMiquelon,
            CountryAlpha2::VC => Self::SaintVincentAndTheGrenadines,
            CountryAlpha2::WS => Self::Samoa,
            CountryAlpha2::SM => Self::SanMarino,
            CountryAlpha2::ST => Self::SaoTomeAndPrincipe,
            CountryAlpha2::SA => Self::SaudiArabia,
            CountryAlpha2::SN => Self::Senegal,
            CountryAlpha2::RS => Self::Serbia,
            CountryAlpha2::SC => Self::Seychelles,
            CountryAlpha2::SL => Self::SierraLeone,
            CountryAlpha2::SG => Self::Singapore,
            CountryAlpha2::SX => Self::SintMaartenDutchpart,
            CountryAlpha2::SK => Self::Slovakia,
            CountryAlpha2::SI => Self::Slovenia,
            CountryAlpha2::SB => Self::SolomonIslands,
            CountryAlpha2::SO => Self::Somalia,
            CountryAlpha2::ZA => Self::SouthAfrica,
            CountryAlpha2::GS => Self::SouthGeorgiaAndTheSouthSandwichIslands,
            CountryAlpha2::SS => Self::SouthSudan,
            CountryAlpha2::ES => Self::Spain,
            CountryAlpha2::LK => Self::SriLanka,
            CountryAlpha2::SD => Self::Sudan,
            CountryAlpha2::SR => Self::Suriname,
            CountryAlpha2::SJ => Self::SvalbardAndJanMayen,
            CountryAlpha2::SZ => Self::Swaziland,
            CountryAlpha2::SE => Self::Sweden,
            CountryAlpha2::CH => Self::Switzerland,
            CountryAlpha2::SY => Self::SyrianArabRepublic,
            CountryAlpha2::TW => Self::TaiwanProvinceOfChina,
            CountryAlpha2::TJ => Self::Tajikistan,
            CountryAlpha2::TZ => Self::TanzaniaUnitedRepublic,
            CountryAlpha2::TH => Self::Thailand,
            CountryAlpha2::TL => Self::TimorLeste,
            CountryAlpha2::TG => Self::Togo,
            CountryAlpha2::TK => Self::Tokelau,
            CountryAlpha2::TO => Self::Tonga,
            CountryAlpha2::TT => Self::TrinidadAndTobago,
            CountryAlpha2::TN => Self::Tunisia,
            CountryAlpha2::TR => Self::Turkey,
            CountryAlpha2::TM => Self::Turkmenistan,
            CountryAlpha2::TC => Self::TurksAndCaicosIslands,
            CountryAlpha2::TV => Self::Tuvalu,
            CountryAlpha2::UG => Self::Uganda,
            CountryAlpha2::UA => Self::Ukraine,
            CountryAlpha2::AE => Self::UnitedArabEmirates,
            CountryAlpha2::GB => Self::UnitedKingdomOfGreatBritainAndNorthernIreland,
            CountryAlpha2::US => Self::UnitedStatesOfAmerica,
            CountryAlpha2::UM => Self::UnitedStatesMinorOutlyingIslands,
            CountryAlpha2::UY => Self::Uruguay,
            CountryAlpha2::UZ => Self::Uzbekistan,
            CountryAlpha2::VU => Self::Vanuatu,
            CountryAlpha2::VE => Self::VenezuelaBolivarianRepublic,
            CountryAlpha2::VN => Self::Vietnam,
            CountryAlpha2::VG => Self::VirginIslandsBritish,
            CountryAlpha2::VI => Self::VirginIslandsUS,
            CountryAlpha2::WF => Self::WallisAndFutuna,
            CountryAlpha2::EH => Self::WesternSahara,
            CountryAlpha2::YE => Self::Yemen,
            CountryAlpha2::ZM => Self::Zambia,
            CountryAlpha2::ZW => Self::Zimbabwe,
        }
    }
    pub const fn to_alpha2(self) -> CountryAlpha2 {
        match self {
            Self::Afghanistan => CountryAlpha2::AF,
            Self::AlandIslands => CountryAlpha2::AX,
            Self::Albania => CountryAlpha2::AL,
            Self::Algeria => CountryAlpha2::DZ,
            Self::AmericanSamoa => CountryAlpha2::AS,
            Self::Andorra => CountryAlpha2::AD,
            Self::Angola => CountryAlpha2::AO,
            Self::Anguilla => CountryAlpha2::AI,
            Self::Antarctica => CountryAlpha2::AQ,
            Self::AntiguaAndBarbuda => CountryAlpha2::AG,
            Self::Argentina => CountryAlpha2::AR,
            Self::Armenia => CountryAlpha2::AM,
            Self::Aruba => CountryAlpha2::AW,
            Self::Australia => CountryAlpha2::AU,
            Self::Austria => CountryAlpha2::AT,
            Self::Azerbaijan => CountryAlpha2::AZ,
            Self::Bahamas => CountryAlpha2::BS,
            Self::Bahrain => CountryAlpha2::BH,
            Self::Bangladesh => CountryAlpha2::BD,
            Self::Barbados => CountryAlpha2::BB,
            Self::Belarus => CountryAlpha2::BY,
            Self::Belgium => CountryAlpha2::BE,
            Self::Belize => CountryAlpha2::BZ,
            Self::Benin => CountryAlpha2::BJ,
            Self::Bermuda => CountryAlpha2::BM,
            Self::Bhutan => CountryAlpha2::BT,
            Self::BoliviaPlurinationalState => CountryAlpha2::BO,
            Self::BonaireSintEustatiusAndSaba => CountryAlpha2::BQ,
            Self::BosniaAndHerzegovina => CountryAlpha2::BA,
            Self::Botswana => CountryAlpha2::BW,
            Self::BouvetIsland => CountryAlpha2::BV,
            Self::Brazil => CountryAlpha2::BR,
            Self::BritishIndianOceanTerritory => CountryAlpha2::IO,
            Self::BruneiDarussalam => CountryAlpha2::BN,
            Self::Bulgaria => CountryAlpha2::BG,
            Self::BurkinaFaso => CountryAlpha2::BF,
            Self::Burundi => CountryAlpha2::BI,
            Self::CaboVerde => CountryAlpha2::CV,
            Self::Cambodia => CountryAlpha2::KH,
            Self::Cameroon => CountryAlpha2::CM,
            Self::Canada => CountryAlpha2::CA,
            Self::CaymanIslands => CountryAlpha2::KY,
            Self::CentralAfricanRepublic => CountryAlpha2::CF,
            Self::Chad => CountryAlpha2::TD,
            Self::Chile => CountryAlpha2::CL,
            Self::China => CountryAlpha2::CN,
            Self::ChristmasIsland => CountryAlpha2::CX,
            Self::CocosKeelingIslands => CountryAlpha2::CC,
            Self::Colombia => CountryAlpha2::CO,
            Self::Comoros => CountryAlpha2::KM,
            Self::Congo => CountryAlpha2::CG,
            Self::CongoDemocraticRepublic => CountryAlpha2::CD,
            Self::CookIslands => CountryAlpha2::CK,
            Self::CostaRica => CountryAlpha2::CR,
            Self::CotedIvoire => CountryAlpha2::CI,
            Self::Croatia => CountryAlpha2::HR,
            Self::Cuba => CountryAlpha2::CU,
            Self::Curacao => CountryAlpha2::CW,
            Self::Cyprus => CountryAlpha2::CY,
            Self::Czechia => CountryAlpha2::CZ,
            Self::Denmark => CountryAlpha2::DK,
            Self::Djibouti => CountryAlpha2::DJ,
            Self::Dominica => CountryAlpha2::DM,
            Self::DominicanRepublic => CountryAlpha2::DO,
            Self::Ecuador => CountryAlpha2::EC,
            Self::Egypt => CountryAlpha2::EG,
            Self::ElSalvador => CountryAlpha2::SV,
            Self::EquatorialGuinea => CountryAlpha2::GQ,
            Self::Eritrea => CountryAlpha2::ER,
            Self::Estonia => CountryAlpha2::EE,
            Self::Ethiopia => CountryAlpha2::ET,
            Self::FalklandIslandsMalvinas => CountryAlpha2::FK,
            Self::FaroeIslands => CountryAlpha2::FO,
            Self::Fiji => CountryAlpha2::FJ,
            Self::Finland => CountryAlpha2::FI,
            Self::France => CountryAlpha2::FR,
            Self::FrenchGuiana => CountryAlpha2::GF,
            Self::FrenchPolynesia => CountryAlpha2::PF,
            Self::FrenchSouthernTerritories => CountryAlpha2::TF,
            Self::Gabon => CountryAlpha2::GA,
            Self::Gambia => CountryAlpha2::GM,
            Self::Georgia => CountryAlpha2::GE,
            Self::Germany => CountryAlpha2::DE,
            Self::Ghana => CountryAlpha2::GH,
            Self::Gibraltar => CountryAlpha2::GI,
            Self::Greece => CountryAlpha2::GR,
            Self::Greenland => CountryAlpha2::GL,
            Self::Grenada => CountryAlpha2::GD,
            Self::Guadeloupe => CountryAlpha2::GP,
            Self::Guam => CountryAlpha2::GU,
            Self::Guatemala => CountryAlpha2::GT,
            Self::Guernsey => CountryAlpha2::GG,
            Self::Guinea => CountryAlpha2::GN,
            Self::GuineaBissau => CountryAlpha2::GW,
            Self::Guyana => CountryAlpha2::GY,
            Self::Haiti => CountryAlpha2::HT,
            Self::HeardIslandAndMcDonaldIslands => CountryAlpha2::HM,
            Self::HolySee => CountryAlpha2::VA,
            Self::Honduras => CountryAlpha2::HN,
            Self::HongKong => CountryAlpha2::HK,
            Self::Hungary => CountryAlpha2::HU,
            Self::Iceland => CountryAlpha2::IS,
            Self::India => CountryAlpha2::IN,
            Self::Indonesia => CountryAlpha2::ID,
            Self::IranIslamicRepublic => CountryAlpha2::IR,
            Self::Iraq => CountryAlpha2::IQ,
            Self::Ireland => CountryAlpha2::IE,
            Self::IsleOfMan => CountryAlpha2::IM,
            Self::Israel => CountryAlpha2::IL,
            Self::Italy => CountryAlpha2::IT,
            Self::Jamaica => CountryAlpha2::JM,
            Self::Japan => CountryAlpha2::JP,
            Self::Jersey => CountryAlpha2::JE,
            Self::Jordan => CountryAlpha2::JO,
            Self::Kazakhstan => CountryAlpha2::KZ,
            Self::Kenya => CountryAlpha2::KE,
            Self::Kiribati => CountryAlpha2::KI,
            Self::KoreaDemocraticPeoplesRepublic => CountryAlpha2::KP,
            Self::KoreaRepublic => CountryAlpha2::KR,
            Self::Kuwait => CountryAlpha2::KW,
            Self::Kyrgyzstan => CountryAlpha2::KG,
            Self::LaoPeoplesDemocraticRepublic => CountryAlpha2::LA,
            Self::Latvia => CountryAlpha2::LV,
            Self::Lebanon => CountryAlpha2::LB,
            Self::Lesotho => CountryAlpha2::LS,
            Self::Liberia => CountryAlpha2::LR,
            Self::Libya => CountryAlpha2::LY,
            Self::Liechtenstein => CountryAlpha2::LI,
            Self::Lithuania => CountryAlpha2::LT,
            Self::Luxembourg => CountryAlpha2::LU,


// Function: get_decision_engine_configs
// File: crates/api_models/src/routing.rs
// Module: api_models

pub fn get_decision_engine_configs(
        &self,
    ) -> Result<open_router::DecisionEngineEliminationData, error_stack::Report<ValidationError>>


// Struct: RecurlyAuthType
// File: crates/hyperswitch_connectors/src/connectors/recurly/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0

pub struct RecurlyAuthType


// Struct: PaymentAttemptUpdateMems
// File: crates/diesel_models/src/kv.rs
// Module: diesel_models
// Implementations: 0

pub struct PaymentAttemptUpdateMems


// Struct: ConditionalConfigs
// File: crates/common_types/src/payments.rs
// Module: common_types
// Implementations: 1
// Traits: EuclidDirFilter

// Documentation: ConditionalConfigs

pub struct ConditionalConfigs


// Struct: PaymentMethodCollectLinkData
// File: crates/diesel_models/src/generic_link.rs
// Module: diesel_models
// Implementations: 0

pub struct PaymentMethodCollectLinkData


// File: crates/router/src/core/payments/retry.rs
// Module: router
// Public functions: 13

use std::vec::IntoIter;

use common_utils::{ext_traits::Encode, types::MinorUnit};
use diesel_models::enums as storage_enums;
use error_stack::ResultExt;
use hyperswitch_domain_models::ext_traits::OptionExt;
use router_env::{
    logger,
    tracing::{self, instrument},
};

use crate::{
    core::{
        errors::{self, RouterResult, StorageErrorExt},
        payments::{
            self,
            flows::{ConstructFlowSpecificData, Feature},
            operations,
        },
        routing::helpers as routing_helpers,
    },
    db::StorageInterface,
    routes::{
        self,
        app::{self, ReqState},
        metrics,
    },
    services,
    types::{self, api, domain, storage, transformers::ForeignFrom},
};

#[instrument(skip_all)]
#[allow(clippy::too_many_arguments)]
#[cfg(feature = "v1")]
pub async fn do_gsm_actions<F, ApiRequest, FData, D>(
    state: &app::SessionState,
    req_state: ReqState,
    payment_data: &mut D,
    mut connector_routing_data: IntoIter<api::ConnectorRoutingData>,
    original_connector_data: &api::ConnectorData,
    mut router_data: types::RouterData<F, FData, types::PaymentsResponseData>,
    merchant_context: &domain::MerchantContext,
    operation: &operations::BoxedOperation<'_, F, ApiRequest, D>,
    customer: &Option<domain::Customer>,
    validate_result: &operations::ValidateResult,
    schedule_time: Option<time::PrimitiveDateTime>,
    frm_suggestion: Option<storage_enums::FrmSuggestion>,
    business_profile: &domain::Profile,
) -> RouterResult<types::RouterData<F, FData, types::PaymentsResponseData>>
where
    F: Clone + Send + Sync,
    FData: Send + Sync + types::Capturable,
    payments::PaymentResponse: operations::Operation<F, FData>,
    D: payments::OperationSessionGetters<F>
        + payments::OperationSessionSetters<F>
        + Send
        + Sync
        + Clone,
    D: ConstructFlowSpecificData<F, FData, types::PaymentsResponseData>,
    types::RouterData<F, FData, types::PaymentsResponseData>: Feature<F, FData>,
    dyn api::Connector: services::api::ConnectorIntegration<F, FData, types::PaymentsResponseData>,
{
    let mut retries = None;

    metrics::AUTO_RETRY_ELIGIBLE_REQUEST_COUNT.add(1, &[]);

    let mut initial_gsm = get_gsm(state, &router_data).await?;

    let step_up_possible = initial_gsm
        .as_ref()
        .and_then(|data| data.feature_data.get_retry_feature_data())
        .map(|data| data.is_step_up_possible())
        .unwrap_or(false);

    #[cfg(feature = "v1")]
    let is_no_three_ds_payment = matches!(
        payment_data.get_payment_attempt().authentication_type,
        Some(storage_enums::AuthenticationType::NoThreeDs)
    );

    #[cfg(feature = "v2")]
    let is_no_three_ds_payment = matches!(
        payment_data.get_payment_attempt().authentication_type,
        storage_enums::AuthenticationType::NoThreeDs
    );

    let should_step_up = if step_up_possible && is_no_three_ds_payment {
        is_step_up_enabled_for_merchant_connector(
            state,
            merchant_context.get_merchant_account().get_id(),
            original_connector_data.connector_name,
        )
        .await
    } else {
        false
    };

    if should_step_up {
        router_data = do_retry(
            &state.clone(),
            req_state.clone(),
            original_connector_data,
            operation,
            customer,
            merchant_context,
            payment_data,
            router_data,
            validate_result,
            schedule_time,
            true,
            frm_suggestion,
            business_profile,
            false, //should_retry_with_pan is not applicable for step-up
            None,
        )
        .await?;
    }
    // Step up is not applicable so proceed with auto retries flow
    else {
        loop {
            // Use initial_gsm for first time alone
            let gsm = match initial_gsm.as_ref() {
                Some(gsm) => Some(gsm.clone()),
                None => get_gsm(state, &router_data).await?,
            };

            match get_gsm_decision(gsm) {
                storage_enums::GsmDecision::Retry => {
                    retries = get_retries(
                        state,
                        retries,
                        merchant_context.get_merchant_account().get_id(),
                        business_profile,
                    )
                    .await;

                    if retries.is_none() || retries == Some(0) {
                        metrics::AUTO_RETRY_EXHAUSTED_COUNT.add(1, &[]);
                        logger::info!("retries exhausted for auto_retry payment");
                        break;
                    }

                    if connector_routing_data.len() == 0 {
                        logger::info!("connectors exhausted for auto_retry payment");
                        metrics::AUTO_RETRY_EXHAUSTED_COUNT.add(1, &[]);
                        break;
                    }

                    let is_network_token = payment_data
                        .get_payment_method_data()
                        .map(|pmd| pmd.is_network_token_payment_method_data())
                        .unwrap_or(false);

                    let clear_pan_possible = initial_gsm
                        .and_then(|data| data.feature_data.get_retry_feature_data())
                        .map(|data| data.is_clear_pan_possible())
                        .unwrap_or(false);

                    let should_retry_with_pan = is_network_token
                        && clear_pan_possible
                        && business_profile.is_clear_pan_retries_enabled;

                    // Currently we are taking off_session as a source of truth to identify MIT payments.
                    let is_mit_payment = payment_data
                        .get_payment_intent()
                        .off_session
                        .unwrap_or(false);

                    let (connector, routing_decision) = if is_mit_payment {
                        let connector_routing_data =
                            super::get_connector_data(&mut connector_routing_data)?;
                        let payment_method_info = payment_data
                            .get_payment_method_info()
                            .get_required_value("payment_method_info")?
                            .clone();
                        let mandate_reference_id = payments::get_mandate_reference_id(
                            connector_routing_data.action_type.clone(),
                            connector_routing_data.clone(),
                            payment_data,
                            &payment_method_info,
                        )?;
                        payment_data.set_mandate_id(api_models::payments::MandateIds {
                            mandate_id: None,
                            mandate_reference_id, //mandate_ref_id
                        });
                        (connector_routing_data.connector_data, None)
                    } else if should_retry_with_pan {
                        // If should_retry_with_pan is true, it indicates that we are retrying with PAN using the same connector.
                        (original_connector_data.clone(), None)
                    } else {
                        let connector_routing_data =
                            super::get_connector_data(&mut connector_routing_data)?;
                        let routing_decision = connector_routing_data.network.map(|card_network| {
                            routing_helpers::RoutingDecisionData::get_debit_routing_decision_data(
                                card_network,
                                None,
                            )
                        });

                        (connector_routing_data.connector_data, routing_decision)
                    };

                    router_data = do_retry(
                        &state.clone(),
                        req_state.clone(),
                        &connector,
                        operation,
                        customer,
                        merchant_context,
                        payment_data,
                        router_data,
                        validate_result,
                        schedule_time,
                        //this is an auto retry payment, but not step-up
                        false,
                        frm_suggestion,
                        business_profile,
                        should_retry_with_pan,
                        routing_decision,
                    )
                    .await?;

                    retries = retries.map(|i| i - 1);
                }
                storage_enums::GsmDecision::DoDefault => break,
            }
            initial_gsm = None;
        }
    }
    Ok(router_data)
}

#[instrument(skip_all)]
pub async fn is_step_up_enabled_for_merchant_connector(
    state: &app::SessionState,
    merchant_id: &common_utils::id_type::MerchantId,
    connector_name: types::Connector,
) -> bool {
    let key = merchant_id.get_step_up_enabled_key();
    let db = &*state.store;
    db.find_config_by_key_unwrap_or(key.as_str(), Some("[]".to_string()))
        .await
        .change_context(errors::ApiErrorResponse::InternalServerError)
        .and_then(|step_up_config| {
            serde_json::from_str::<Vec<types::Connector>>(&step_up_config.config)
                .change_context(errors::ApiErrorResponse::InternalServerError)
                .attach_printable("Step-up config parsing failed")
        })
        .map_err(|err| {
            logger::error!(step_up_config_error=?err);
        })
        .ok()
        .map(|connectors_enabled| connectors_enabled.contains(&connector_name))
        .unwrap_or(false)
}

#[cfg(feature = "v1")]
pub async fn get_merchant_max_auto_retries_enabled(
    db: &dyn StorageInterface,
    merchant_id: &common_utils::id_type::MerchantId,
) -> Option<i32> {
    let key = merchant_id.get_max_auto_retries_enabled();

    db.find_config_by_key(key.as_str())
        .await
        .change_context(errors::ApiErrorResponse::InternalServerError)
        .and_then(|retries_config| {
            retries_config
                .config
                .parse::<i32>()
                .change_context(errors::ApiErrorResponse::InternalServerError)
                .attach_printable("Retries config parsing failed")
        })
        .map_err(|err| {
            logger::error!(retries_error=?err);
            None::<i32>
        })
        .ok()
}

#[cfg(feature = "v1")]
#[instrument(skip_all)]
pub async fn get_retries(
    state: &app::SessionState,
    retries: Option<i32>,
    merchant_id: &common_utils::id_type::MerchantId,
    profile: &domain::Profile,
) -> Option<i32> {
    match retries {
        Some(retries) => Some(retries),
        None => get_merchant_max_auto_retries_enabled(state.store.as_ref(), merchant_id)
            .await
            .or(profile.max_auto_retries_enabled.map(i32::from)),
    }
}

#[instrument(skip_all)]
pub async fn get_gsm<F, FData>(
    state: &app::SessionState,
    router_data: &types::RouterData<F, FData, types::PaymentsResponseData>,
) -> RouterResult<Option<hyperswitch_domain_models::gsm::GatewayStatusMap>> {
    let error_response = router_data.response.as_ref().err();
    let error_code = error_response.map(|err| err.code.to_owned());
    let error_message = error_response.map(|err| err.message.to_owned());
    let connector_name = router_data.connector.to_string();
    let flow = get_flow_name::<F>()?;
    Ok(
        payments::helpers::get_gsm_record(state, error_code, error_message, connector_name, flow)
            .await,
    )
}

#[instrument(skip_all)]
pub fn get_gsm_decision(
    option_gsm: Option<hyperswitch_domain_models::gsm::GatewayStatusMap>,
) -> storage_enums::GsmDecision {
    let option_gsm_decision = option_gsm
        .as_ref()
        .map(|gsm| gsm.feature_data.get_decision());

    if option_gsm_decision.is_some() {
        metrics::AUTO_RETRY_GSM_MATCH_COUNT.add(1, &[]);
    }
    option_gsm_decision.unwrap_or_default()
}

#[inline]
fn get_flow_name<F>() -> RouterResult<String> {
    Ok(std::any::type_name::<F>()
        .to_string()
        .rsplit("::")
        .next()
        .ok_or(errors::ApiErrorResponse::InternalServerError)
        .attach_printable("Flow stringify failed")?
        .to_string())
}

#[cfg(feature = "v1")]
#[allow(clippy::too_many_arguments)]
#[instrument(skip_all)]
pub async fn do_retry<F, ApiRequest, FData, D>(
    state: &routes::SessionState,
    req_state: ReqState,
    connector: &api::ConnectorData,
    operation: &operations::BoxedOperation<'_, F, ApiRequest, D>,
    customer: &Option<domain::Customer>,
    merchant_context: &domain::MerchantContext,
    payment_data: &mut D,
    router_data: types::RouterData<F, FData, types::PaymentsResponseData>,
    validate_result: &operations::ValidateResult,
    schedule_time: Option<time::PrimitiveDateTime>,
    is_step_up: bool,
    frm_suggestion: Option<storage_enums::FrmSuggestion>,
    business_profile: &domain::Profile,
    should_retry_with_pan: bool,
    routing_decision: Option<routing_helpers::RoutingDecisionData>,
) -> RouterResult<types::RouterData<F, FData, types::PaymentsResponseData>>
where
    F: Clone + Send + Sync,
    FData: Send + Sync + types::Capturable,
    payments::PaymentResponse: operations::Operation<F, FData>,
    D: payments::OperationSessionGetters<F>
        + payments::OperationSessionSetters<F>
        + Send
        + Sync
        + Clone,
    D: ConstructFlowSpecificData<F, FData, types::PaymentsResponseData>,
    types::RouterData<F, FData, types::PaymentsResponseData>: Feature<F, FData>,
    dyn api::Connector: services::api::ConnectorIntegration<F, FData, types::PaymentsResponseData>,
{
    metrics::AUTO_RETRY_PAYMENT_COUNT.add(1, &[]);

    modify_trackers(
        state,
        connector.connector_name.to_string(),
        payment_data,
        merchant_context.get_merchant_key_store(),
        merchant_context.get_merchant_account().storage_scheme,
        router_data,
        is_step_up,
    )
    .await?;

    let (merchant_connector_account, router_data, tokenization_action) =
        payments::call_connector_service_prerequisites(
            state,
            merchant_context,
            connector.clone(),
            operation,
            payment_data,
            customer,
            validate_result,
            business_profile,
            should_retry_with_pan,
            routing_decision,
        )
        .await?;

    let (router_data, _mca) = payments::decide_unified_connector_service_call(
        state,
        req_state,
        merchant_context,
        connector.clone(),
        operation,
        payment_data,
        customer,
        payments::CallConnectorAction::Trigger,
        validate_result,
        schedule_time,
        hyperswitch_domain_models::payments::HeaderPayload::default(),
        frm_suggestion,
        business_profile,
        true,
        None,
        merchant_connector_account,
        router_data,
        tokenization_action,
    )
    .await?;

    Ok(router_data)
}

#[cfg(feature = "v2")]
#[instrument(skip_all)]
pub async fn modify_trackers<F, FData, D>(
    state: &routes::SessionState,
    connector: String,
    payment_data: &mut D,
    key_store: &domain::MerchantKeyStore,
    storage_scheme: storage_enums::MerchantStorageScheme,
    router_data: types::RouterData<F, FData, types::PaymentsResponseData>,
    is_step_up: bool,
) -> RouterResult<()>
where
    F: Clone + Send,
    FData: Send,
    D: payments::OperationSessionGetters<F> + payments::OperationSessionSetters<F> + Send + Sync,
{
    todo!()
}

#[cfg(feature = "v1")]
#[instrument(skip_all)]
pub async fn modify_trackers<F, FData, D>(
    state: &routes::SessionState,
    connector: String,
    payment_data: &mut D,
    key_store: &domain::MerchantKeyStore,
    storage_scheme: storage_enums::MerchantStorageScheme,
    router_data: types::RouterData<F, FData, types::PaymentsResponseData>,
    is_step_up: bool,
) -> RouterResult<()>
where
    F: Clone + Send,
    FData: Send + types::Capturable,
    D: payments::OperationSessionGetters<F> + payments::OperationSessionSetters<F> + Send + Sync,
{
    let new_attempt_count = payment_data.get_payment_intent().attempt_count + 1;
    let new_payment_attempt = make_new_payment_attempt(
        connector,
        payment_data.get_payment_attempt().clone(),
        new_attempt_count,
        is_step_up,
        payment_data.get_payment_intent().setup_future_usage,
    );

    let db = &*state.store;
    let key_manager_state = &state.into();
    let additional_payment_method_data =
        payments::helpers::update_additional_payment_data_with_connector_response_pm_data(
            payment_data
                .get_payment_attempt()
                .payment_method_data
                .clone(),
            router_data
                .connector_response
                .clone()
                .and_then(|connector_response| connector_response.additional_payment_method_data),
        )?;

    let debit_routing_savings = payment_data.get_payment_method_data().and_then(|data| {
        payments::helpers::get_debit_routing_savings_amount(
            data,
            payment_data.get_payment_attempt(),
        )
    });

    match router_data.response {
        Ok(types::PaymentsResponseData::TransactionResponse {
            resource_id,
            connector_metadata,
            redirection_data,
            charges,
            ..
        }) => {
            let encoded_data = payment_data.get_payment_attempt().encoded_data.clone();

            let authentication_data = (*redirection_data)
                .as_ref()
                .map(Encode::encode_to_value)
                .transpose()
                .change_context(errors::ApiErrorResponse::InternalServerError)
                .attach_printable("Could not parse the connector response")?;

            let payment_attempt_update = storage::PaymentAttemptUpdate::ResponseUpdate {
                status: router_data.status,
                connector: None,
                connector_transaction_id: match resource_id {
                    types::ResponseId::NoResponseId => None,
                    types::ResponseId::ConnectorTransactionId(id)
                    | types::ResponseId::EncodedData(id) => Some(id),
                },
                connector_response_reference_id: payment_data
                    .get_payment_attempt()
                    .connector_response_reference_id
                    .clone(),
                authentication_type: None,
                payment_method_id: payment_data.get_payment_attempt().payment_method_id.clone(),
                mandate_id: payment_data
                    .get_mandate_id()
                    .and_then(|mandate| mandate.mandate_id.clone()),
                connector_metadata,
                payment_token: None,
                error_code: None,
                error_message: None,
                error_reason: None,
                amount_capturable: if router_data.status.is_terminal_status() {
                    Some(MinorUnit::new(0))
                } else {
                    None
                },
                updated_by: storage_scheme.to_string(),
                authentication_data,
                encoded_data,
                unified_code: None,
                unified_message: None,
                capture_before: None,
                extended_authorization_applied: None,
                payment_method_data: additional_payment_method_data,
                connector_mandate_detail: None,
                charges,
                setup_future_usage_applied: None,
                debit_routing_savings,
                network_transaction_id: payment_data
                    .get_payment_attempt()
                    .network_transaction_id
                    .clone(),
                is_overcapture_enabled: None,
            };

            #[cfg(feature = "v1")]
            db.update_payment_attempt_with_attempt_id(
                payment_data.get_payment_attempt().clone(),
                payment_attempt_update,
                storage_scheme,
            )
            .await
            .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;

            #[cfg(feature = "v2")]
            db.update_payment_attempt_with_attempt_id(
                key_manager_state,
                key_store,
                payment_data.get_payment_attempt().clone(),
                payment_attempt_update,
                storage_scheme,
            )
            .await
            .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
        }
        Ok(_) => {
            logger::error!("unexpected response: this response was not expected in Retry flow");
            return Ok(());
        }
        Err(ref error_response) => {
            let option_gsm = get_gsm(state, &router_data).await?;
            let auth_update = if Some(router_data.auth_type)
                != payment_data.get_payment_attempt().authentication_type
            {
                Some(router_data.auth_type)
            } else {
                None
            };

            let payment_attempt_update = storage::PaymentAttemptUpdate::ErrorUpdate {
                connector: None,
                error_code: Some(Some(error_response.code.clone())),
                error_message: Some(Some(error_response.message.clone())),
                status: storage_enums::AttemptStatus::Failure,
                error_reason: Some(error_response.reason.clone()),
                amount_capturable: Some(MinorUnit::new(0)),
                updated_by: storage_scheme.to_string(),
                unified_code: option_gsm.clone().map(|gsm| gsm.unified_code),
                unified_message: option_gsm.map(|gsm| gsm.unified_message),
                connector_transaction_id: error_response.connector_transaction_id.clone(),
                payment_method_data: additional_payment_method_data,
                authentication_type: auth_update,
                issuer_error_code: error_response.network_decline_code.clone(),
                issuer_error_message: error_response.network_error_message.clone(),
                network_details: Some(ForeignFrom::foreign_from(error_response)),
            };

            #[cfg(feature = "v1")]
            db.update_payment_attempt_with_attempt_id(
                payment_data.get_payment_attempt().clone(),
                payment_attempt_update,
                storage_scheme,
            )
            .await
            .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;

            #[cfg(feature = "v2")]
            db.update_payment_attempt_with_attempt_id(
                key_manager_state,
                key_store,
                payment_data.get_payment_attempt().clone(),
                payment_attempt_update,
                storage_scheme,
            )
            .await
            .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;
        }
    }

    #[cfg(feature = "v1")]
    let payment_attempt = db
        .insert_payment_attempt(new_payment_attempt, storage_scheme)
        .await
        .change_context(errors::ApiErrorResponse::InternalServerError)
        .attach_printable("Error inserting payment attempt")?;

    #[cfg(feature = "v2")]
    let payment_attempt = db
        .insert_payment_attempt(
            key_manager_state,
            key_store,
            new_payment_attempt,
            storage_scheme,
        )
        .await
        .change_context(errors::ApiErrorResponse::InternalServerError)
        .attach_printable("Error inserting payment attempt")?;

    // update payment_attempt, connector_response and payment_intent in payment_data
    payment_data.set_payment_attempt(payment_attempt);

    let payment_intent = db
        .update_payment_intent(
            key_manager_state,
            payment_data.get_payment_intent().clone(),
            storage::PaymentIntentUpdate::PaymentAttemptAndAttemptCountUpdate {
                active_attempt_id: payment_data.get_payment_attempt().get_id().to_owned(),
                attempt_count: new_attempt_count,
                updated_by: storage_scheme.to_string(),
            },
            key_store,
            storage_scheme,
        )
        .await
        .to_not_found_response(errors::ApiErrorResponse::PaymentNotFound)?;

    payment_data.set_payment_intent(payment_intent);

    Ok(())
}

#[cfg(feature = "v1")]
#[instrument(skip_all)]
pub fn make_new_payment_attempt(
    connector: String,
    old_payment_attempt: storage::PaymentAttempt,
    new_attempt_count: i16,
    is_step_up: bool,
    setup_future_usage_intent: Option<storage_enums::FutureUsage>,
) -> storage::PaymentAttemptNew {
    let created_at @ modified_at @ last_synced = Some(common_utils::date_time::now());
    storage::PaymentAttemptNew {
        connector: Some(connector),
        attempt_id: old_payment_attempt
            .payment_id
            .get_attempt_id(new_attempt_count),
        payment_id: old_payment_attempt.payment_id,
        merchant_id: old_payment_attempt.merchant_id,
        status: old_payment_attempt.status,
        currency: old_payment_attempt.currency,
        save_to_locker: old_payment_attempt.save_to_locker,
        offer_amount: old_payment_attempt.offer_amount,
        payment_method_id: old_payment_attempt.payment_method_id,
        payment_method: old_payment_attempt.payment_method,
        payment_method_type: old_payment_attempt.payment_method_type,
        capture_method: old_payment_attempt.capture_method,
        capture_on: old_payment_attempt.capture_on,
        confirm: old_payment_attempt.confirm,
        authentication_type: if is_step_up {
            Some(storage_enums::AuthenticationType::ThreeDs)
        } else {
            old_payment_attempt.authentication_type
        },
        amount_to_capture: old_payment_attempt.amount_to_capture,
        mandate_id: old_payment_attempt.mandate_id,
        browser_info: old_payment_attempt.browser_info,
        payment_token: old_payment_attempt.payment_token,
        client_source: old_payment_attempt.client_source,
        client_version: old_payment_attempt.client_version,
        created_at,
        modified_at,
        last_synced,
        profile_id: old_payment_attempt.profile_id,
        organization_id: old_payment_attempt.organization_id,
        net_amount: old_payment_attempt.net_amount,
        error_message: Default::default(),
        cancellation_reason: Default::default(),
        error_code: Default::default(),
        connector_metadata: Default::default(),
        payment_experience: Default::default(),
        payment_method_data: Default::default(),
        business_sub_label: Default::default(),
        straight_through_algorithm: Default::default(),
        preprocessing_step_id: Default::default(),
        mandate_details: Default::default(),
        error_reason: Default::default(),
        connector_response_reference_id: Default::default(),
        multiple_capture_count: Default::default(),
        amount_capturable: Default::default(),
        updated_by: Default::default(),
        authentication_data: Default::default(),
        encoded_data: Default::default(),
        merchant_connector_id: Default::default(),
        unified_code: Default::default(),
        unified_message: Default::default(),
        external_three_ds_authentication_attempted: Default::default(),
        authentication_connector: Default::default(),
        authentication_id: Default::default(),
        mandate_data: Default::default(),
        payment_method_billing_address_id: Default::default(),
        fingerprint_id: Default::default(),
        customer_acceptance: Default::default(),
        connector_mandate_detail: Default::default(),
        request_extended_authorization: Default::default(),
        extended_authorization_applied: Default::default(),
        capture_before: Default::default(),
        card_discovery: old_payment_attempt.card_discovery,
        processor_merchant_id: old_payment_attempt.processor_merchant_id,
        created_by: old_payment_attempt.created_by,
        setup_future_usage_applied: setup_future_usage_intent, // setup future usage is picked from intent for new payment attempt
        routing_approach: old_payment_attempt.routing_approach,
        connector_request_reference_id: Default::default(),
        network_transaction_id: old_payment_attempt.network_transaction_id,
        network_details: Default::default(),
        is_stored_credential: old_payment_attempt.is_stored_credential,
    }
}

#[cfg(feature = "v2")]
#[instrument(skip_all)]
pub fn make_new_payment_attempt(
    _connector: String,
    _old_payment_attempt: storage::PaymentAttempt,
    _new_attempt_count: i16,
    _is_step_up: bool,
) -> storage::PaymentAttempt {
    todo!()
}

pub async fn get_merchant_config_for_gsm(
    db: &dyn StorageInterface,
    merchant_id: &common_utils::id_type::MerchantId,
) -> bool {
    let config = db
        .find_config_by_key_unwrap_or(
            &merchant_id.get_should_call_gsm_key(),
            Some("false".to_string()),
        )
        .await;
    match config {
        Ok(conf) => conf.config == "true",
        Err(error) => {
            logger::error!(?error);
            false
        }
    }
}

#[cfg(feature = "v1")]
pub async fn config_should_call_gsm(
    db: &dyn StorageInterface,
    merchant_id: &common_utils::id_type::MerchantId,
    profile: &domain::Profile,
) -> bool {
    let merchant_config_gsm = get_merchant_config_for_gsm(db, merchant_id).await;
    let profile_config_gsm = profile.is_auto_retries_enabled;
    merchant_config_gsm || profile_config_gsm
}

pub trait GsmValidation<F: Send + Clone + Sync, FData: Send + Sync, Resp> {
    // TODO : move this function to appropriate place later.
    fn should_call_gsm(&self) -> bool;
}

impl<F: Send + Clone + Sync, FData: Send + Sync>
    GsmValidation<F, FData, types::PaymentsResponseData>
    for types::RouterData<F, FData, types::PaymentsResponseData>
{
    #[inline(always)]
    fn should_call_gsm(&self) -> bool {
        if self.response.is_err() {
            true
        } else {
            match self.status {
                storage_enums::AttemptStatus::Started
                | storage_enums::AttemptStatus::AuthenticationPending
                | storage_enums::AttemptStatus::AuthenticationSuccessful
                | storage_enums::AttemptStatus::Authorized
                | storage_enums::AttemptStatus::Charged
                | storage_enums::AttemptStatus::Authorizing
                | storage_enums::AttemptStatus::CodInitiated
                | storage_enums::AttemptStatus::Voided
                | storage_enums::AttemptStatus::VoidedPostCharge
                | storage_enums::AttemptStatus::VoidInitiated
                | storage_enums::AttemptStatus::CaptureInitiated
                | storage_enums::AttemptStatus::RouterDeclined
                | storage_enums::AttemptStatus::VoidFailed
                | storage_enums::AttemptStatus::AutoRefunded
                | storage_enums::AttemptStatus::CaptureFailed
                | storage_enums::AttemptStatus::PartialCharged
                | storage_enums::AttemptStatus::PartialChargedAndChargeable
                | storage_enums::AttemptStatus::Pending
                | storage_enums::AttemptStatus::PaymentMethodAwaited
                | storage_enums::AttemptStatus::ConfirmationAwaited
                | storage_enums::AttemptStatus::Unresolved
                | storage_enums::AttemptStatus::DeviceDataCollectionPending
                | storage_enums::AttemptStatus::IntegrityFailure
                | storage_enums::AttemptStatus::Expired
                | storage_enums::AttemptStatus::PartiallyAuthorized => false,

                storage_enums::AttemptStatus::AuthenticationFailed
                | storage_enums::AttemptStatus::AuthorizationFailed
                | storage_enums::AttemptStatus::Failure => true,
            }
        }
    }
}


// Implementation: impl api::PaymentSession for for Paybox
// File: crates/hyperswitch_connectors/src/connectors/paybox.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)

impl api::PaymentSession for for Paybox


// Function: disable_dynamic_routing_algorithm
// File: crates/router/src/core/routing/helpers.rs
// Module: router

pub fn disable_dynamic_routing_algorithm(
    state: &SessionState,
    key_store: domain::MerchantKeyStore,
    business_profile: domain::Profile,
    dynamic_routing_algo_ref: routing_types::DynamicRoutingAlgorithmRef,
    dynamic_routing_type: routing_types::DynamicRoutingType,
) -> RouterResult<ApplicationResponse<routing_types::RoutingDictionaryRecord>>


// Function: get_string_repr
// File: crates/common_utils/src/ucs_types.rs
// Module: common_utils

// Documentation: A string slice (`&str`) representing the reference ID.

pub fn get_string_repr(&self) -> &str


// File: crates/router/src/types/api/disputes_v2.rs
// Module: router

pub use hyperswitch_interfaces::api::disputes_v2::{
    AcceptDisputeV2, DefendDisputeV2, DisputeSyncV2, DisputeV2, FetchDisputesV2, SubmitEvidenceV2,
};


// Struct: IatapayPaymentsResponse
// File: crates/hyperswitch_connectors/src/connectors/iatapay/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0

pub struct IatapayPaymentsResponse


// Struct: UserKeyTransferRequest
// File: crates/api_models/src/user.rs
// Module: api_models
// Implementations: 0

pub struct UserKeyTransferRequest


// Function: get_merchant_details
// File: crates/hyperswitch_domain_models/src/merchant_account.rs
// Module: hyperswitch_domain_models

// Documentation: Get the merchant_details from MerchantAccount

pub fn get_merchant_details(&self) -> &OptionalEncryptableValue


// Struct: GetSearchResponse
// File: crates/api_models/src/analytics/search.rs
// Module: api_models
// Implementations: 0

pub struct GetSearchResponse


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

pub struct PaymentInsightsInformation


// Struct: PaymentExperienceTypes
// File: crates/api_models/src/payment_methods.rs
// Module: api_models
// Implementations: 0

pub struct PaymentExperienceTypes


// Function: get_variant_values
// File: crates/euclid_wasm/src/lib.rs
// Module: euclid_wasm

pub fn get_variant_values(key: &str) -> Result<JsValue, JsValue>


// Struct: WellsfargopayoutAuthType
// File: crates/hyperswitch_connectors/src/connectors/wellsfargopayout/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0

pub struct WellsfargopayoutAuthType


// Struct: ErrorResponse
// File: crates/hyperswitch_connectors/src/connectors/wise/transformers.rs
// Module: hyperswitch_connectors
// Implementations: 0

pub struct ErrorResponse


// Implementation: impl api::PaymentSession for for Nexinets
// File: crates/hyperswitch_connectors/src/connectors/nexinets.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)

impl api::PaymentSession for for Nexinets


// Implementation: impl api::PaymentSync for for Payload
// File: crates/hyperswitch_connectors/src/connectors/payload.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)

impl api::PaymentSync for for Payload


// Implementation: impl api::MandateSetup for for Bambora
// File: crates/hyperswitch_connectors/src/connectors/bambora.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)

impl api::MandateSetup for for Bambora


// Implementation: impl api::RefundSync for for Opennode
// File: crates/hyperswitch_connectors/src/connectors/opennode.rs
// Module: hyperswitch_connectors
// Methods: 0 total (0 public)

impl api::RefundSync for for Opennode


// Struct: CardAndNetworkTokenDataForVault
// File: crates/hyperswitch_domain_models/src/payments.rs
// Module: hyperswitch_domain_models
// Implementations: 0

pub struct CardAndNetworkTokenDataForVault


// Trait: Event
// File: crates/events/src/lib.rs
// Module: events

// Documentation: An event that can be published.

pub trait Event: EventInfo