Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

refactor(connector): [BILLWERK, FISERVEMEA, TSYS] use LazyLock instead of lazy_static (#7494)

Anurag413a7eee8aaf
diff --git a/crates/hyperswitch_connectors/src/connectors/billwerk.rs b/crates/hyperswitch_connectors/src/connectors/billwerk.rs
index 4d76dcd570..4d5e324b39 100644
--- a/crates/hyperswitch_connectors/src/connectors/billwerk.rs
+++ b/crates/hyperswitch_connectors/src/connectors/billwerk.rs
@@ -1,5 +1,7 @@
pub mod transformers;
+use std::sync::LazyLock;
+
use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId};
use base64::Engine;
use common_enums::enums;
@@ -44,7 +46,6 @@ use hyperswitch_interfaces::{
types::{self, Response},
webhooks::{IncomingWebhook, IncomingWebhookRequestDetails},
};
-use lazy_static::lazy_static;
use masking::{Mask, PeekInterface};
use transformers::{
self as billwerk, BillwerkAuthType, BillwerkCaptureRequest, BillwerkErrorResponse,
@@ -808,8 +809,8 @@ impl IncomingWebhook for Billwerk {
}
}
-lazy_static! {
- static ref BILLWERK_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = {
+static BILLWERK_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> =
+ LazyLock::new(|| {
let supported_capture_methods = vec![
enums::CaptureMethod::Automatic,
enums::CaptureMethod::Manual,
@@ -833,7 +834,7 @@ lazy_static! {
billwerk_supported_payment_methods.add(
enums::PaymentMethod::Card,
enums::PaymentMethodType::Credit,
- PaymentMethodDetails{
+ PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods.clone(),
@@ -846,13 +847,13 @@ lazy_static! {
}
}),
),
- }
+ },
);
billwerk_supported_payment_methods.add(
enums::PaymentMethod::Card,
enums::PaymentMethodType::Debit,
- PaymentMethodDetails{
+ PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods.clone(),
@@ -865,24 +866,23 @@ lazy_static! {
}
}),
),
- }
+ },
);
billwerk_supported_payment_methods
- };
+ });
- static ref BILLWERK_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
- display_name: "Billwerk",
- description: "Billwerk+ Pay is an acquirer independent payment gateway that's easy to setup with more than 50 recurring and non-recurring payment methods.",
- connector_type: enums::PaymentConnectorCategory::PaymentGateway,
- };
+static BILLWERK_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
+ display_name: "Billwerk",
+ description: "Billwerk+ Pay is an acquirer independent payment gateway that's easy to setup with more than 50 recurring and non-recurring payment methods.",
+ connector_type: enums::PaymentConnectorCategory::PaymentGateway,
+};
- static ref BILLWERK_SUPPORTED_WEBHOOK_FLOWS: Vec<enums::EventClass> = Vec::new();
-}
+static BILLWERK_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
impl ConnectorSpecifications for Billwerk {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
- Some(&*BILLWERK_CONNECTOR_INFO)
+ Some(&BILLWERK_CONNECTOR_INFO)
}
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
@@ -890,6 +890,6 @@ impl ConnectorSpecifications for Billwerk {
}
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
- Some(&*BILLWERK_SUPPORTED_WEBHOOK_FLOWS)
+ Some(&BILLWERK_SUPPORTED_WEBHOOK_FLOWS)
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/fiservemea.rs b/crates/hyperswitch_connectors/src/connectors/fiservemea.rs
index cb00c66a4f..95c252cb68 100644
--- a/crates/hyperswitch_connectors/src/connectors/fiservemea.rs
+++ b/crates/hyperswitch_connectors/src/connectors/fiservemea.rs
@@ -1,5 +1,7 @@
pub mod transformers;
+use std::sync::LazyLock;
+
use base64::Engine;
use common_enums::enums;
use common_utils::{
@@ -41,7 +43,6 @@ use hyperswitch_interfaces::{
types::{self, Response},
webhooks,
};
-use lazy_static::lazy_static;
use masking::{ExposeInterface, Mask, PeekInterface};
use ring::hmac;
use time::OffsetDateTime;
@@ -784,8 +785,8 @@ impl webhooks::IncomingWebhook for Fiservemea {
}
}
-lazy_static! {
- static ref FISERVEMEA_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = {
+static FISERVEMEA_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> =
+ LazyLock::new(|| {
let supported_capture_methods = vec![
enums::CaptureMethod::Automatic,
enums::CaptureMethod::Manual,
@@ -809,7 +810,7 @@ lazy_static! {
fiservemea_supported_payment_methods.add(
enums::PaymentMethod::Card,
enums::PaymentMethodType::Credit,
- PaymentMethodDetails{
+ PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods.clone(),
@@ -822,13 +823,13 @@ lazy_static! {
}
}),
),
- }
+ },
);
fiservemea_supported_payment_methods.add(
enums::PaymentMethod::Card,
enums::PaymentMethodType::Debit,
- PaymentMethodDetails{
+ PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods.clone(),
@@ -841,24 +842,23 @@ lazy_static! {
}
}),
),
- }
+ },
);
fiservemea_supported_payment_methods
- };
+ });
- static ref FISERVEMEA_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
- display_name: "Fiservemea",
- description: "Fiserv powers over 6+ million merchants and 10,000+ financial institutions enabling them to accept billions of payments a year.",
- connector_type: enums::PaymentConnectorCategory::BankAcquirer,
- };
+static FISERVEMEA_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
+ display_name: "Fiservemea",
+ description: "Fiserv powers over 6+ million merchants and 10,000+ financial institutions enabling them to accept billions of payments a year.",
+ connector_type: enums::PaymentConnectorCategory::BankAcquirer,
+};
- static ref FISERVEMEA_SUPPORTED_WEBHOOK_FLOWS: Vec<enums::EventClass> = Vec::new();
-}
+static FISERVEMEA_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
impl ConnectorSpecifications for Fiservemea {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
- Some(&*FISERVEMEA_CONNECTOR_INFO)
+ Some(&FISERVEMEA_CONNECTOR_INFO)
}
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
@@ -866,6 +866,6 @@ impl ConnectorSpecifications for Fiservemea {
}
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
- Some(&*FISERVEMEA_SUPPORTED_WEBHOOK_FLOWS)
+ Some(&FISERVEMEA_SUPPORTED_WEBHOOK_FLOWS)
}
}
diff --git a/crates/hyperswitch_connectors/src/connectors/tsys.rs b/crates/hyperswitch_connectors/src/connectors/tsys.rs
index 7a0fe0bdc9..d5a6fd834e 100644
--- a/crates/hyperswitch_connectors/src/connectors/tsys.rs
+++ b/crates/hyperswitch_connectors/src/connectors/tsys.rs
@@ -1,5 +1,7 @@
pub mod transformers;
+use std::sync::LazyLock;
+
use common_enums::enums;
use common_utils::{
errors::CustomResult,
@@ -43,7 +45,6 @@ use hyperswitch_interfaces::{
},
webhooks,
};
-use lazy_static::lazy_static;
use transformers as tsys;
use crate::{constants::headers, types::ResponseRouterData, utils};
@@ -645,78 +646,76 @@ impl webhooks::IncomingWebhook for Tsys {
}
}
-lazy_static! {
- static ref TSYS_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = {
- let supported_capture_methods = vec![
- enums::CaptureMethod::Automatic,
- enums::CaptureMethod::Manual,
- enums::CaptureMethod::SequentialAutomatic,
- ];
-
- let supported_card_network = vec![
- common_enums::CardNetwork::Mastercard,
- common_enums::CardNetwork::Visa,
- common_enums::CardNetwork::AmericanExpress,
- common_enums::CardNetwork::Discover,
- common_enums::CardNetwork::JCB,
- common_enums::CardNetwork::UnionPay,
- ];
-
- let mut tsys_supported_payment_methods = SupportedPaymentMethods::new();
-
- tsys_supported_payment_methods.add(
- enums::PaymentMethod::Card,
- enums::PaymentMethodType::Credit,
- PaymentMethodDetails{
- mandates: enums::FeatureStatus::NotSupported,
- refunds: enums::FeatureStatus::Supported,
- supported_capture_methods: supported_capture_methods.clone(),
- specific_features: Some(
- api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
- api_models::feature_matrix::CardSpecificFeatures {
- three_ds: common_enums::FeatureStatus::NotSupported,
- no_three_ds: common_enums::FeatureStatus::Supported,
- supported_card_networks: supported_card_network.clone(),
- }
- }),
- ),
- }
- );
-
- tsys_supported_payment_methods.add(
- enums::PaymentMethod::Card,
- enums::PaymentMethodType::Debit,
- PaymentMethodDetails{
- mandates: enums::FeatureStatus::NotSupported,
- refunds: enums::FeatureStatus::Supported,
- supported_capture_methods: supported_capture_methods.clone(),
- specific_features: Some(
- api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
- api_models::feature_matrix::CardSpecificFeatures {
- three_ds: common_enums::FeatureStatus::NotSupported,
- no_three_ds: common_enums::FeatureStatus::Supported,
- supported_card_networks: supported_card_network.clone(),
- }
- }),
- ),
- }
- );
-
- tsys_supported_payment_methods
- };
-
- static ref TSYS_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
- display_name: "Tsys",
- description: "TSYS, a Global Payments company, is the payment stack for the future, powered by unmatched expertise.",
- connector_type: enums::PaymentConnectorCategory::BankAcquirer,
- };
-
- static ref TSYS_SUPPORTED_WEBHOOK_FLOWS: Vec<enums::EventClass> = Vec::new();
-}
+static TSYS_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| {
+ let supported_capture_methods = vec![
+ enums::CaptureMethod::Automatic,
+ enums::CaptureMethod::Manual,
+ enums::CaptureMethod::SequentialAutomatic,
+ ];
+
+ let supported_card_network = vec![
+ common_enums::CardNetwork::Mastercard,
+ common_enums::CardNetwork::Visa,
+ common_enums::CardNetwork::AmericanExpress,
+ common_enums::CardNetwork::Discover,
+ common_enums::CardNetwork::JCB,
+ common_enums::CardNetwork::UnionPay,
+ ];
+
+ let mut tsys_supported_payment_methods = SupportedPaymentMethods::new();
+
+ tsys_supported_payment_methods.add(
+ enums::PaymentMethod::Card,
+ enums::PaymentMethodType::Credit,
+ PaymentMethodDetails {
+ mandates: enums::FeatureStatus::NotSupported,
+ refunds: enums::FeatureStatus::Supported,
+ supported_capture_methods: supported_capture_methods.clone(),
+ specific_features: Some(
+ api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
+ api_models::feature_matrix::CardSpecificFeatures {
+ three_ds: common_enums::FeatureStatus::NotSupported,
+ no_three_ds: common_enums::FeatureStatus::Supported,
+ supported_card_networks: supported_card_network.clone(),
+ }
+ }),
+ ),
+ },
+ );
+
+ tsys_supported_payment_methods.add(
+ enums::PaymentMethod::Card,
+ enums::PaymentMethodType::Debit,
+ PaymentMethodDetails {
+ mandates: enums::FeatureStatus::NotSupported,
+ refunds: enums::FeatureStatus::Supported,
+ supported_capture_methods: supported_capture_methods.clone(),
+ specific_features: Some(
+ api_models::feature_matrix::PaymentMethodSpecificFeatures::Card({
+ api_models::feature_matrix::CardSpecificFeatures {
+ three_ds: common_enums::FeatureStatus::NotSupported,
+ no_three_ds: common_enums::FeatureStatus::Supported,
+ supported_card_networks: supported_card_network.clone(),
+ }
+ }),
+ ),
+ },
+ );
+
+ tsys_supported_payment_methods
+});
+
+static TSYS_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
+ display_name: "Tsys",
+ description: "TSYS, a Global Payments company, is the payment stack for the future, powered by unmatched expertise.",
+ connector_type: enums::PaymentConnectorCategory::BankAcquirer,
+};
+
+static TSYS_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
impl ConnectorSpecifications for Tsys {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
- Some(&*TSYS_CONNECTOR_INFO)
+ Some(&TSYS_CONNECTOR_INFO)
}
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
@@ -724,6 +723,6 @@ impl ConnectorSpecifications for Tsys {
}
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
- Some(&*TSYS_SUPPORTED_WEBHOOK_FLOWS)
+ Some(&TSYS_SUPPORTED_WEBHOOK_FLOWS)
}
}