fix(connector): [JPMORGAN, PAYU, DIGITALVIRGO, BITPAY, HELCIM, PAYBOX] Replaced lazystatic macros with LazyLock (#7524)

Co-authored-by: Sayak Bhattacharya <sayak.b@Sayak-Bhattacharya-G092THXJ34.local>
This commit is contained in:
Sayak Bhattacharya
2025-04-02 18:33:25 +05:30
committed by GitHub
parent cfe226943d
commit fcbd863bc7
6 changed files with 249 additions and 267 deletions

View File

@ -1,4 +1,6 @@
pub mod transformers; pub mod transformers;
use std::sync::LazyLock;
use api_models::webhooks::IncomingWebhookEvent; use api_models::webhooks::IncomingWebhookEvent;
use common_enums::enums; use common_enums::enums;
use common_utils::{ use common_utils::{
@ -40,7 +42,6 @@ use hyperswitch_interfaces::{
types::{PaymentsAuthorizeType, PaymentsSyncType, Response}, types::{PaymentsAuthorizeType, PaymentsSyncType, Response},
webhooks, webhooks,
}; };
use lazy_static::lazy_static;
use masking::{Mask, PeekInterface}; use masking::{Mask, PeekInterface};
use transformers as bitpay; use transformers as bitpay;
@ -421,12 +422,8 @@ impl webhooks::IncomingWebhook for Bitpay {
Ok(Box::new(notif)) Ok(Box::new(notif))
} }
} }
static BITPAY_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| {
lazy_static! { let supported_capture_methods = vec![enums::CaptureMethod::Automatic];
static ref BITPAY_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = {
let supported_capture_methods = vec![
enums::CaptureMethod::Automatic,
];
let mut bitpay_supported_payment_methods = SupportedPaymentMethods::new(); let mut bitpay_supported_payment_methods = SupportedPaymentMethods::new();
@ -436,27 +433,26 @@ lazy_static! {
PaymentMethodDetails { PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported, mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported, refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods.clone(), supported_capture_methods,
specific_features: None, specific_features: None,
} },
); );
bitpay_supported_payment_methods bitpay_supported_payment_methods
}; });
static ref BITPAY_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { static BITPAY_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Bitpay", display_name: "Bitpay",
description: description:
"BitPay is a cryptocurrency payment processor that enables businesses to accept Bitcoin and other digital currencies ", "BitPay is a cryptocurrency payment processor that enables businesses to accept Bitcoin and other digital currencies ",
connector_type: enums::PaymentConnectorCategory::AlternativePaymentMethod, connector_type: enums::PaymentConnectorCategory::AlternativePaymentMethod,
}; };
static ref BITPAY_SUPPORTED_WEBHOOK_FLOWS: Vec<enums::EventClass> = vec![enums::EventClass::Payments]; static BITPAY_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 1] = [enums::EventClass::Payments];
}
impl ConnectorSpecifications for Bitpay { impl ConnectorSpecifications for Bitpay {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&*BITPAY_CONNECTOR_INFO) Some(&BITPAY_CONNECTOR_INFO)
} }
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
@ -464,6 +460,6 @@ impl ConnectorSpecifications for Bitpay {
} }
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&*BITPAY_SUPPORTED_WEBHOOK_FLOWS) Some(&BITPAY_SUPPORTED_WEBHOOK_FLOWS)
} }
} }

View File

@ -1,4 +1,6 @@
pub mod transformers; pub mod transformers;
use std::sync::LazyLock;
use base64::Engine; use base64::Engine;
use common_enums::enums; use common_enums::enums;
use common_utils::{ use common_utils::{
@ -45,7 +47,6 @@ use hyperswitch_interfaces::{
types::{self, Response}, types::{self, Response},
webhooks, webhooks,
}; };
use lazy_static::lazy_static;
use masking::{Mask, PeekInterface}; use masking::{Mask, PeekInterface};
use transformers as digitalvirgo; use transformers as digitalvirgo;
@ -526,9 +527,8 @@ impl webhooks::IncomingWebhook for Digitalvirgo {
Err(report!(errors::ConnectorError::WebhooksNotImplemented)) Err(report!(errors::ConnectorError::WebhooksNotImplemented))
} }
} }
static DIGITALVIRGO_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> =
lazy_static! { LazyLock::new(|| {
static ref DIGITALVIRGO_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = {
let supported_capture_methods = vec![ let supported_capture_methods = vec![
enums::CaptureMethod::Automatic, enums::CaptureMethod::Automatic,
enums::CaptureMethod::SequentialAutomatic, enums::CaptureMethod::SequentialAutomatic,
@ -542,28 +542,26 @@ lazy_static! {
PaymentMethodDetails { PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported, mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported, refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods.clone(), supported_capture_methods,
specific_features: None, specific_features: None,
} },
); );
digitalvirgo_supported_payment_methods digitalvirgo_supported_payment_methods
}; });
static ref DIGITALVIRGO_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { static DIGITALVIRGO_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Digital Virgo", display_name: "Digital Virgo",
description: description:
"Digital Virgo is an alternative payment provider specializing in carrier billing and mobile payments ", "Digital Virgo is an alternative payment provider specializing in carrier billing and mobile payments ",
connector_type: enums::PaymentConnectorCategory::AlternativePaymentMethod, connector_type: enums::PaymentConnectorCategory::AlternativePaymentMethod,
}; };
static ref DIGITALVIRGO_SUPPORTED_WEBHOOK_FLOWS: Vec<enums::EventClass> = Vec::new(); static DIGITALVIRGO_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
}
impl ConnectorSpecifications for Digitalvirgo { impl ConnectorSpecifications for Digitalvirgo {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&*DIGITALVIRGO_CONNECTOR_INFO) Some(&DIGITALVIRGO_CONNECTOR_INFO)
} }
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
@ -571,6 +569,6 @@ impl ConnectorSpecifications for Digitalvirgo {
} }
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&*DIGITALVIRGO_SUPPORTED_WEBHOOK_FLOWS) Some(&DIGITALVIRGO_SUPPORTED_WEBHOOK_FLOWS)
} }
} }

View File

@ -1,4 +1,5 @@
pub mod transformers; pub mod transformers;
use std::sync::LazyLock;
use api_models::webhooks::IncomingWebhookEvent; use api_models::webhooks::IncomingWebhookEvent;
use common_enums::enums; use common_enums::enums;
@ -44,7 +45,6 @@ use hyperswitch_interfaces::{
types::{self, Response}, types::{self, Response},
webhooks::{IncomingWebhook, IncomingWebhookRequestDetails}, webhooks::{IncomingWebhook, IncomingWebhookRequestDetails},
}; };
use lazy_static::lazy_static;
#[cfg(feature = "v2")] #[cfg(feature = "v2")]
use masking::PeekInterface; use masking::PeekInterface;
use masking::{ExposeInterface, Mask}; use masking::{ExposeInterface, Mask};
@ -834,8 +834,7 @@ impl IncomingWebhook for Helcim {
} }
} }
lazy_static! { static HELCIM_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| {
static ref HELCIM_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = {
let supported_capture_methods = vec![ let supported_capture_methods = vec![
enums::CaptureMethod::Automatic, enums::CaptureMethod::Automatic,
enums::CaptureMethod::Manual, enums::CaptureMethod::Manual,
@ -872,7 +871,7 @@ lazy_static! {
} }
}), }),
), ),
} },
); );
helcim_supported_payment_methods.add( helcim_supported_payment_methods.add(
@ -891,26 +890,24 @@ lazy_static! {
} }
}), }),
), ),
} },
); );
helcim_supported_payment_methods helcim_supported_payment_methods
}; });
static ref HELCIM_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { static HELCIM_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Helcim", display_name: "Helcim",
description: description:
"Helcim is a payment processing company that offers transparent, affordable merchant services for businesses of all sizes", "Helcim is a payment processing company that offers transparent, affordable merchant services for businesses of all sizes",
connector_type: enums::PaymentConnectorCategory::PaymentGateway, connector_type: enums::PaymentConnectorCategory::PaymentGateway,
}; };
static ref HELCIM_SUPPORTED_WEBHOOK_FLOWS: Vec<enums::EventClass> = Vec::new(); static HELCIM_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
}
impl ConnectorSpecifications for Helcim { impl ConnectorSpecifications for Helcim {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&*HELCIM_CONNECTOR_INFO) Some(&HELCIM_CONNECTOR_INFO)
} }
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
@ -918,7 +915,7 @@ impl ConnectorSpecifications for Helcim {
} }
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&*HELCIM_SUPPORTED_WEBHOOK_FLOWS) Some(&HELCIM_SUPPORTED_WEBHOOK_FLOWS)
} }
} }

View File

@ -1,4 +1,6 @@
pub mod transformers; pub mod transformers;
use std::sync::LazyLock;
use base64::Engine; use base64::Engine;
use common_enums::enums; use common_enums::enums;
use common_utils::{ use common_utils::{
@ -40,7 +42,6 @@ use hyperswitch_interfaces::{
types::{self, RefreshTokenType, Response}, types::{self, RefreshTokenType, Response},
webhooks, webhooks,
}; };
use lazy_static::lazy_static;
use masking::{Mask, Maskable, PeekInterface}; use masking::{Mask, Maskable, PeekInterface};
use transformers::{self as jpmorgan, JpmorganErrorResponse}; use transformers::{self as jpmorgan, JpmorganErrorResponse};
@ -811,9 +812,8 @@ impl webhooks::IncomingWebhook for Jpmorgan {
Err(report!(errors::ConnectorError::WebhooksNotImplemented)) Err(report!(errors::ConnectorError::WebhooksNotImplemented))
} }
} }
static JPMORGAN_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> =
lazy_static! { LazyLock::new(|| {
static ref JPMORGAN_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = {
let supported_capture_methods = vec![ let supported_capture_methods = vec![
enums::CaptureMethod::Automatic, enums::CaptureMethod::Automatic,
enums::CaptureMethod::Manual, enums::CaptureMethod::Manual,
@ -847,7 +847,6 @@ lazy_static! {
} }
}), }),
), ),
}, },
); );
@ -867,27 +866,24 @@ lazy_static! {
} }
}), }),
), ),
}, },
); );
jpmorgan_supported_payment_methods jpmorgan_supported_payment_methods
}; });
static ref JPMORGAN_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { static JPMORGAN_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Jpmorgan", display_name: "Jpmorgan",
description: description:
"J.P. Morgan is a global financial services firm and investment bank, offering banking, asset management, and payment processing solutions", "J.P. Morgan is a global financial services firm and investment bank, offering banking, asset management, and payment processing solutions",
connector_type: enums::PaymentConnectorCategory::BankAcquirer, connector_type: enums::PaymentConnectorCategory::BankAcquirer,
}; };
static ref JPMORGAN_SUPPORTED_WEBHOOK_FLOWS: Vec<enums::EventClass> = Vec::new(); static JPMORGAN_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
}
impl ConnectorSpecifications for Jpmorgan { impl ConnectorSpecifications for Jpmorgan {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&*JPMORGAN_CONNECTOR_INFO) Some(&JPMORGAN_CONNECTOR_INFO)
} }
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
@ -895,6 +891,6 @@ impl ConnectorSpecifications for Jpmorgan {
} }
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&*JPMORGAN_SUPPORTED_WEBHOOK_FLOWS) Some(&JPMORGAN_SUPPORTED_WEBHOOK_FLOWS)
} }
} }

View File

@ -1,4 +1,6 @@
pub mod transformers; pub mod transformers;
use std::sync::LazyLock;
use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId}; use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId};
use common_enums::{enums, CallConnectorAction, PaymentAction}; use common_enums::{enums, CallConnectorAction, PaymentAction};
use common_utils::{ use common_utils::{
@ -43,7 +45,6 @@ use hyperswitch_interfaces::{
types::{self, Response}, types::{self, Response},
webhooks::{IncomingWebhook, IncomingWebhookRequestDetails}, webhooks::{IncomingWebhook, IncomingWebhookRequestDetails},
}; };
use lazy_static::lazy_static;
use masking::{ExposeInterface, Mask}; use masking::{ExposeInterface, Mask};
use transformers as paybox; use transformers as paybox;
@ -691,9 +692,7 @@ impl ConnectorRedirectResponse for Paybox {
} }
} }
} }
static PAYBOX_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| {
lazy_static! {
static ref PAYBOX_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = {
let supported_capture_methods = vec![ let supported_capture_methods = vec![
enums::CaptureMethod::Automatic, enums::CaptureMethod::Automatic,
enums::CaptureMethod::Manual, enums::CaptureMethod::Manual,
@ -730,7 +729,7 @@ lazy_static! {
} }
}), }),
), ),
} },
); );
paybox_supported_payment_methods.add( paybox_supported_payment_methods.add(
@ -749,26 +748,24 @@ lazy_static! {
} }
}), }),
), ),
} },
); );
paybox_supported_payment_methods paybox_supported_payment_methods
}; });
static ref PAYBOX_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { static PAYBOX_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Paybox", display_name: "Paybox",
description: description:
"Paybox is a payment gateway that enables businesses to process online transactions securely ", "Paybox is a payment gateway that enables businesses to process online transactions securely ",
connector_type: enums::PaymentConnectorCategory::PaymentGateway, connector_type: enums::PaymentConnectorCategory::PaymentGateway,
}; };
static ref PAYBOX_SUPPORTED_WEBHOOK_FLOWS: Vec<enums::EventClass> = Vec::new(); static PAYBOX_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
}
impl ConnectorSpecifications for Paybox { impl ConnectorSpecifications for Paybox {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&*PAYBOX_CONNECTOR_INFO) Some(&PAYBOX_CONNECTOR_INFO)
} }
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
@ -776,6 +773,6 @@ impl ConnectorSpecifications for Paybox {
} }
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&*PAYBOX_SUPPORTED_WEBHOOK_FLOWS) Some(&PAYBOX_SUPPORTED_WEBHOOK_FLOWS)
} }
} }

View File

@ -1,4 +1,6 @@
pub mod transformers; pub mod transformers;
use std::sync::LazyLock;
use api_models::webhooks::IncomingWebhookEvent; use api_models::webhooks::IncomingWebhookEvent;
use common_enums::enums; use common_enums::enums;
use common_utils::{ use common_utils::{
@ -43,7 +45,6 @@ use hyperswitch_interfaces::{
}, },
webhooks::{IncomingWebhook, IncomingWebhookRequestDetails}, webhooks::{IncomingWebhook, IncomingWebhookRequestDetails},
}; };
use lazy_static::lazy_static;
use masking::{Mask, PeekInterface}; use masking::{Mask, PeekInterface};
use transformers as payu; use transformers as payu;
@ -790,8 +791,7 @@ impl IncomingWebhook for Payu {
} }
} }
lazy_static! { static PAYU_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> = LazyLock::new(|| {
static ref PAYU_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = {
let supported_capture_methods = vec![ let supported_capture_methods = vec![
enums::CaptureMethod::Automatic, enums::CaptureMethod::Automatic,
enums::CaptureMethod::Manual, enums::CaptureMethod::Manual,
@ -828,7 +828,7 @@ lazy_static! {
} }
}), }),
), ),
} },
); );
payu_supported_payment_methods.add( payu_supported_payment_methods.add(
@ -847,7 +847,7 @@ lazy_static! {
} }
}), }),
), ),
} },
); );
payu_supported_payment_methods.add( payu_supported_payment_methods.add(
@ -858,7 +858,7 @@ lazy_static! {
refunds: enums::FeatureStatus::Supported, refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods.clone(), supported_capture_methods: supported_capture_methods.clone(),
specific_features: None, specific_features: None,
} },
); );
payu_supported_payment_methods.add( payu_supported_payment_methods.add(
@ -869,26 +869,24 @@ lazy_static! {
refunds: enums::FeatureStatus::Supported, refunds: enums::FeatureStatus::Supported,
supported_capture_methods: supported_capture_methods.clone(), supported_capture_methods: supported_capture_methods.clone(),
specific_features: None, specific_features: None,
} },
); );
payu_supported_payment_methods payu_supported_payment_methods
}; });
static ref PAYU_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { static PAYU_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
display_name: "Payu", display_name: "Payu",
description: description:
"PayU is a global fintech company providing online payment solutions, including card processing, UPI, wallets, and BNPL services across multiple markets ", "PayU is a global fintech company providing online payment solutions, including card processing, UPI, wallets, and BNPL services across multiple markets ",
connector_type: enums::PaymentConnectorCategory::PaymentGateway, connector_type: enums::PaymentConnectorCategory::PaymentGateway,
}; };
static ref PAYU_SUPPORTED_WEBHOOK_FLOWS: Vec<enums::EventClass> = Vec::new(); static PAYU_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
}
impl ConnectorSpecifications for Payu { impl ConnectorSpecifications for Payu {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
Some(&*PAYU_CONNECTOR_INFO) Some(&PAYU_CONNECTOR_INFO)
} }
fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> {
@ -896,6 +894,6 @@ impl ConnectorSpecifications for Payu {
} }
fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> {
Some(&*PAYU_SUPPORTED_WEBHOOK_FLOWS) Some(&PAYU_SUPPORTED_WEBHOOK_FLOWS)
} }
} }