From 8feab2f59899ca0e20eba88c64193496db043ab1 Mon Sep 17 00:00:00 2001 From: Sayak Bhattacharya Date: Thu, 13 Mar 2025 21:13:05 +0530 Subject: [PATCH 1/2] fix(connector): [JPMORGAN, PAYU, DIGITALVIRGO, HELCIM, PAYBOX, PAYU] replaced lazystatic macros with LazyLock fix(connector): [JPMORGAN, PAYU, DIGITALVIRGO, HELCIM, PAYBOX, PAYU] Replaced lazystatic macros with LazyLock fix(connector): [JPMORGAN, PAYU, DIGITALVIRGO, HELCIM, PAYBOX, PAYU] Replaced lazystatic macros with LazyLock fix(connector): [JPMORGAN, PAYU, DIGITALVIRGO, HELCIM, PAYBOX, PAYU] Replaced lazystatic macros with LazyLock fix(connector): [JPMORGAN, PAYU, DIGITALVIRGO, HELCIM, PAYBOX, PAYU] Replaced lazystatic macros with LazyLock fix(connector): [JPMORGAN, PAYU, DIGITALVIRGO, HELCIM, PAYBOX, PAYU] Replaced lazystatic macros with LazyLock fix(connector): [JPMORGAN, PAYU, DIGITALVIRGO, HELCIM, PAYBOX, PAYU] Replaced lazystatic macros with LazyLock --- .../src/connectors/bitpay.rs | 53 +++--- .../src/connectors/digitalvirgo.rs | 23 ++- .../src/connectors/helcim.rs | 133 +++++++------ .../src/connectors/jpmorgan.rs | 24 +-- .../src/connectors/paybox.rs | 137 +++++++------ .../src/connectors/payu.rs | 180 +++++++++--------- 6 files changed, 267 insertions(+), 283 deletions(-) diff --git a/crates/hyperswitch_connectors/src/connectors/bitpay.rs b/crates/hyperswitch_connectors/src/connectors/bitpay.rs index 4de2f422b94..14174219075 100644 --- a/crates/hyperswitch_connectors/src/connectors/bitpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/bitpay.rs @@ -1,4 +1,6 @@ pub mod transformers; +use std::sync::LazyLock; + use api_models::webhooks::IncomingWebhookEvent; use common_enums::enums; use common_utils::{ @@ -40,7 +42,6 @@ use hyperswitch_interfaces::{ types::{PaymentsAuthorizeType, PaymentsSyncType, Response}, webhooks, }; -use lazy_static::lazy_static; use masking::{Mask, PeekInterface}; use transformers as bitpay; @@ -419,42 +420,38 @@ impl webhooks::IncomingWebhook for Bitpay { Ok(Box::new(notif)) } } - -lazy_static! { - static ref BITPAY_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = { - let supported_capture_methods = vec![ - enums::CaptureMethod::Automatic, - ]; - - let mut bitpay_supported_payment_methods = SupportedPaymentMethods::new(); - - bitpay_supported_payment_methods.add( - enums::PaymentMethod::Crypto, - enums::PaymentMethodType::CryptoCurrency, - PaymentMethodDetails{ - mandates: enums::FeatureStatus::NotSupported, - refunds: enums::FeatureStatus::Supported, - supported_capture_methods: supported_capture_methods.clone(), - specific_features: None, - } - ); - - bitpay_supported_payment_methods - }; - - static ref BITPAY_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { +static BITPAY_SUPPORTED_PAYMENT_METHODS: LazyLock = LazyLock::new(|| { + let supported_capture_methods = vec![enums::CaptureMethod::Automatic]; + + let mut bitpay_supported_payment_methods = SupportedPaymentMethods::new(); + + bitpay_supported_payment_methods.add( + enums::PaymentMethod::Crypto, + enums::PaymentMethodType::CryptoCurrency, + PaymentMethodDetails { + mandates: enums::FeatureStatus::NotSupported, + refunds: enums::FeatureStatus::Supported, + supported_capture_methods: supported_capture_methods.clone(), + specific_features: None, + }, + ); + + bitpay_supported_payment_methods +}); + +static BITPAY_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { display_name: "Bitpay", description: "BitPay is a cryptocurrency payment processor that enables businesses to accept Bitcoin and other digital currencies ", connector_type: enums::PaymentConnectorCategory::AlternativePaymentMethod, }; - static ref BITPAY_SUPPORTED_WEBHOOK_FLOWS: Vec = vec![enums::EventClass::Payments]; -} +static BITPAY_SUPPORTED_WEBHOOK_FLOWS: LazyLock<[enums::EventClass; 1]> = + LazyLock::new(|| [enums::EventClass::Payments]); impl ConnectorSpecifications for Bitpay { 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> { diff --git a/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs b/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs index a58a086f5e7..add51fbc704 100644 --- a/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs +++ b/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs @@ -1,4 +1,6 @@ pub mod transformers; +use std::sync::LazyLock; + use base64::Engine; use common_enums::enums; use common_utils::{ @@ -45,7 +47,6 @@ use hyperswitch_interfaces::{ types::{self, Response}, webhooks, }; -use lazy_static::lazy_static; use masking::{Mask, PeekInterface}; use transformers as digitalvirgo; @@ -524,9 +525,8 @@ impl webhooks::IncomingWebhook for Digitalvirgo { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } - -lazy_static! { - static ref DIGITALVIRGO_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = { +static DIGITALVIRGO_SUPPORTED_PAYMENT_METHODS: LazyLock = + LazyLock::new(|| { let supported_capture_methods = vec![ enums::CaptureMethod::Automatic, enums::CaptureMethod::SequentialAutomatic, @@ -537,31 +537,30 @@ lazy_static! { digitalvirgo_supported_payment_methods.add( enums::PaymentMethod::MobilePayment, enums::PaymentMethodType::DirectCarrierBilling, - PaymentMethodDetails{ + PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, supported_capture_methods: supported_capture_methods.clone(), specific_features: None, - } + }, ); digitalvirgo_supported_payment_methods - }; + }); - static ref DIGITALVIRGO_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { +static DIGITALVIRGO_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { display_name: "Digital Virgo", description: "Digital Virgo is an alternative payment provider specializing in carrier billing and mobile payments ", connector_type: enums::PaymentConnectorCategory::AlternativePaymentMethod, }; - static ref DIGITALVIRGO_SUPPORTED_WEBHOOK_FLOWS: Vec = Vec::new(); - -} +static DIGITALVIRGO_SUPPORTED_WEBHOOK_FLOWS: LazyLock<[enums::EventClass; 0]> = + LazyLock::new(|| []); impl ConnectorSpecifications for Digitalvirgo { 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> { diff --git a/crates/hyperswitch_connectors/src/connectors/helcim.rs b/crates/hyperswitch_connectors/src/connectors/helcim.rs index 79b950063c3..df001decf84 100644 --- a/crates/hyperswitch_connectors/src/connectors/helcim.rs +++ b/crates/hyperswitch_connectors/src/connectors/helcim.rs @@ -1,4 +1,5 @@ pub mod transformers; +use std::sync::LazyLock; use api_models::webhooks::IncomingWebhookEvent; use common_enums::enums; @@ -42,7 +43,6 @@ use hyperswitch_interfaces::{ types::{self, Response}, webhooks::{IncomingWebhook, IncomingWebhookRequestDetails}, }; -use lazy_static::lazy_static; use masking::{ExposeInterface, Mask}; use transformers as helcim; @@ -828,83 +828,80 @@ impl IncomingWebhook for Helcim { } } -lazy_static! { - static ref HELCIM_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::Visa, - common_enums::CardNetwork::Mastercard, - common_enums::CardNetwork::Interac, - common_enums::CardNetwork::AmericanExpress, - common_enums::CardNetwork::JCB, - common_enums::CardNetwork::DinersClub, - common_enums::CardNetwork::Discover, - common_enums::CardNetwork::CartesBancaires, - common_enums::CardNetwork::UnionPay, - ]; - - let mut helcim_supported_payment_methods = SupportedPaymentMethods::new(); - - helcim_supported_payment_methods.add( - enums::PaymentMethod::Card, - enums::PaymentMethodType::Credit, - PaymentMethodDetails{ - mandates: enums::FeatureStatus::Supported, - 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(), - } - }), - ), - } - ); - - helcim_supported_payment_methods.add( - enums::PaymentMethod::Card, - enums::PaymentMethodType::Debit, - PaymentMethodDetails{ - mandates: enums::FeatureStatus::Supported, - 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(), - } - }), - ), - } - ); - - helcim_supported_payment_methods - }; +static HELCIM_SUPPORTED_PAYMENT_METHODS: LazyLock = LazyLock::new(|| { + let supported_capture_methods = vec![ + enums::CaptureMethod::Automatic, + enums::CaptureMethod::Manual, + enums::CaptureMethod::SequentialAutomatic, + ]; + + let supported_card_network = vec![ + common_enums::CardNetwork::Visa, + common_enums::CardNetwork::Mastercard, + common_enums::CardNetwork::Interac, + common_enums::CardNetwork::AmericanExpress, + common_enums::CardNetwork::JCB, + common_enums::CardNetwork::DinersClub, + common_enums::CardNetwork::Discover, + common_enums::CardNetwork::CartesBancaires, + common_enums::CardNetwork::UnionPay, + ]; + + let mut helcim_supported_payment_methods = SupportedPaymentMethods::new(); + + helcim_supported_payment_methods.add( + enums::PaymentMethod::Card, + enums::PaymentMethodType::Credit, + PaymentMethodDetails { + mandates: enums::FeatureStatus::Supported, + 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(), + } + }), + ), + }, + ); + + helcim_supported_payment_methods.add( + enums::PaymentMethod::Card, + enums::PaymentMethodType::Debit, + PaymentMethodDetails { + mandates: enums::FeatureStatus::Supported, + 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(), + } + }), + ), + }, + ); - static ref HELCIM_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { + helcim_supported_payment_methods +}); + +static HELCIM_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { display_name: "Helcim", description: "Helcim is a payment processing company that offers transparent, affordable merchant services for businesses of all sizes", connector_type: enums::PaymentConnectorCategory::PaymentGateway, }; - static ref HELCIM_SUPPORTED_WEBHOOK_FLOWS: Vec = Vec::new(); - -} +static HELCIM_SUPPORTED_WEBHOOK_FLOWS: LazyLock<[enums::EventClass; 0]> = LazyLock::new(|| []); impl ConnectorSpecifications for Helcim { 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> { diff --git a/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs b/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs index 9d6037877f2..ff290d99866 100644 --- a/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs +++ b/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs @@ -1,4 +1,6 @@ pub mod transformers; +use std::sync::LazyLock; + use base64::Engine; use common_enums::enums; use common_utils::{ @@ -40,7 +42,6 @@ use hyperswitch_interfaces::{ types::{self, RefreshTokenType, Response}, webhooks, }; -use lazy_static::lazy_static; use masking::{Mask, Maskable, PeekInterface}; use transformers::{self as jpmorgan, JpmorganErrorResponse}; @@ -809,9 +810,8 @@ impl webhooks::IncomingWebhook for Jpmorgan { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } - -lazy_static! { - static ref JPMORGAN_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = { +static JPMORGAN_SUPPORTED_PAYMENT_METHODS: LazyLock = + LazyLock::new(|| { let supported_capture_methods = vec![ enums::CaptureMethod::Automatic, enums::CaptureMethod::Manual, @@ -832,7 +832,7 @@ lazy_static! { jpmorgan_supported_payment_methods.add( enums::PaymentMethod::Card, enums::PaymentMethodType::Debit, - PaymentMethodDetails{ + PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::NotSupported, supported_capture_methods: supported_capture_methods.clone(), @@ -845,14 +845,13 @@ lazy_static! { } }), ), - }, ); jpmorgan_supported_payment_methods.add( enums::PaymentMethod::Card, enums::PaymentMethodType::Credit, - PaymentMethodDetails{ + PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::NotSupported, supported_capture_methods: supported_capture_methods.clone(), @@ -865,27 +864,24 @@ lazy_static! { } }), ), - }, ); jpmorgan_supported_payment_methods - }; + }); - static ref JPMORGAN_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { +static JPMORGAN_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { display_name: "Jpmorgan", description: "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, }; - static ref JPMORGAN_SUPPORTED_WEBHOOK_FLOWS: Vec = Vec::new(); - -} +static JPMORGAN_SUPPORTED_WEBHOOK_FLOWS: LazyLock<[enums::EventClass; 0]> = LazyLock::new(|| []); impl ConnectorSpecifications for Jpmorgan { 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> { diff --git a/crates/hyperswitch_connectors/src/connectors/paybox.rs b/crates/hyperswitch_connectors/src/connectors/paybox.rs index 395fc73808c..6163adeef0a 100644 --- a/crates/hyperswitch_connectors/src/connectors/paybox.rs +++ b/crates/hyperswitch_connectors/src/connectors/paybox.rs @@ -1,4 +1,6 @@ pub mod transformers; +use std::sync::LazyLock; + use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId}; use common_enums::{enums, CallConnectorAction, PaymentAction}; use common_utils::{ @@ -43,7 +45,6 @@ use hyperswitch_interfaces::{ types::{self, Response}, webhooks::{IncomingWebhook, IncomingWebhookRequestDetails}, }; -use lazy_static::lazy_static; use masking::{ExposeInterface, Mask}; use transformers as paybox; @@ -689,84 +690,80 @@ impl ConnectorRedirectResponse for Paybox { } } } - -lazy_static! { - static ref PAYBOX_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::Visa, - common_enums::CardNetwork::Mastercard, - common_enums::CardNetwork::Interac, - common_enums::CardNetwork::AmericanExpress, - common_enums::CardNetwork::JCB, - common_enums::CardNetwork::DinersClub, - common_enums::CardNetwork::Discover, - common_enums::CardNetwork::CartesBancaires, - common_enums::CardNetwork::UnionPay, - ]; - - let mut paybox_supported_payment_methods = SupportedPaymentMethods::new(); - - paybox_supported_payment_methods.add( - enums::PaymentMethod::Card, - enums::PaymentMethodType::Debit, - PaymentMethodDetails{ - mandates: enums::FeatureStatus::Supported, - 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::Supported, - no_three_ds: common_enums::FeatureStatus::Supported, - supported_card_networks: supported_card_network.clone(), - } - }), - ), - } - ); - - paybox_supported_payment_methods.add( - enums::PaymentMethod::Card, - enums::PaymentMethodType::Credit, - PaymentMethodDetails{ - mandates: enums::FeatureStatus::Supported, - 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::Supported, - no_three_ds: common_enums::FeatureStatus::Supported, - supported_card_networks: supported_card_network.clone(), - } - }), - ), - } - ); - - paybox_supported_payment_methods - }; - - static ref PAYBOX_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { +static PAYBOX_SUPPORTED_PAYMENT_METHODS: LazyLock = LazyLock::new(|| { + let supported_capture_methods = vec![ + enums::CaptureMethod::Automatic, + enums::CaptureMethod::Manual, + enums::CaptureMethod::SequentialAutomatic, + ]; + + let supported_card_network = vec![ + common_enums::CardNetwork::Visa, + common_enums::CardNetwork::Mastercard, + common_enums::CardNetwork::Interac, + common_enums::CardNetwork::AmericanExpress, + common_enums::CardNetwork::JCB, + common_enums::CardNetwork::DinersClub, + common_enums::CardNetwork::Discover, + common_enums::CardNetwork::CartesBancaires, + common_enums::CardNetwork::UnionPay, + ]; + + let mut paybox_supported_payment_methods = SupportedPaymentMethods::new(); + + paybox_supported_payment_methods.add( + enums::PaymentMethod::Card, + enums::PaymentMethodType::Debit, + PaymentMethodDetails { + mandates: enums::FeatureStatus::Supported, + 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::Supported, + no_three_ds: common_enums::FeatureStatus::Supported, + supported_card_networks: supported_card_network.clone(), + } + }), + ), + }, + ); + + paybox_supported_payment_methods.add( + enums::PaymentMethod::Card, + enums::PaymentMethodType::Credit, + PaymentMethodDetails { + mandates: enums::FeatureStatus::Supported, + 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::Supported, + no_three_ds: common_enums::FeatureStatus::Supported, + supported_card_networks: supported_card_network.clone(), + } + }), + ), + }, + ); + + paybox_supported_payment_methods +}); + +static PAYBOX_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { display_name: "Paybox", description: "Paybox is a payment gateway that enables businesses to process online transactions securely ", connector_type: enums::PaymentConnectorCategory::PaymentGateway, }; - static ref PAYBOX_SUPPORTED_WEBHOOK_FLOWS: Vec = Vec::new(); - -} +static PAYBOX_SUPPORTED_WEBHOOK_FLOWS: LazyLock<[enums::EventClass; 0]> = LazyLock::new(|| []); impl ConnectorSpecifications for Paybox { 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> { diff --git a/crates/hyperswitch_connectors/src/connectors/payu.rs b/crates/hyperswitch_connectors/src/connectors/payu.rs index cd8c99b6151..0ebdb16b955 100644 --- a/crates/hyperswitch_connectors/src/connectors/payu.rs +++ b/crates/hyperswitch_connectors/src/connectors/payu.rs @@ -1,4 +1,6 @@ pub mod transformers; +use std::sync::LazyLock; + use api_models::webhooks::IncomingWebhookEvent; use common_enums::enums; use common_utils::{ @@ -43,7 +45,6 @@ use hyperswitch_interfaces::{ }, webhooks::{IncomingWebhook, IncomingWebhookRequestDetails}, }; -use lazy_static::lazy_static; use masking::{Mask, PeekInterface}; use transformers as payu; @@ -786,105 +787,102 @@ impl IncomingWebhook for Payu { } } -lazy_static! { - static ref PAYU_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::Visa, - common_enums::CardNetwork::Mastercard, - common_enums::CardNetwork::Interac, - common_enums::CardNetwork::AmericanExpress, - common_enums::CardNetwork::JCB, - common_enums::CardNetwork::DinersClub, - common_enums::CardNetwork::Discover, - common_enums::CardNetwork::CartesBancaires, - common_enums::CardNetwork::UnionPay, - ]; - - let mut payu_supported_payment_methods = SupportedPaymentMethods::new(); - - payu_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::Supported, - no_three_ds: common_enums::FeatureStatus::NotSupported, - supported_card_networks: supported_card_network.clone(), - } - }), - ), - } - ); - - payu_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::Supported, - no_three_ds: common_enums::FeatureStatus::NotSupported, - supported_card_networks: supported_card_network.clone(), - } - }), - ), - } - ); - - payu_supported_payment_methods.add( - enums::PaymentMethod::Wallet, - enums::PaymentMethodType::GooglePay, - PaymentMethodDetails{ - mandates: enums::FeatureStatus::NotSupported, - refunds: enums::FeatureStatus::Supported, - supported_capture_methods: supported_capture_methods.clone(), - specific_features: None, - } - ); - - payu_supported_payment_methods.add( - enums::PaymentMethod::Wallet, - enums::PaymentMethodType::ApplePay, - PaymentMethodDetails{ - mandates: enums::FeatureStatus::NotSupported, - refunds: enums::FeatureStatus::Supported, - supported_capture_methods: supported_capture_methods.clone(), - specific_features: None, - } - ); - - payu_supported_payment_methods - }; - - static ref PAYU_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { +static PAYU_SUPPORTED_PAYMENT_METHODS: LazyLock = LazyLock::new(|| { + let supported_capture_methods = vec![ + enums::CaptureMethod::Automatic, + enums::CaptureMethod::Manual, + enums::CaptureMethod::SequentialAutomatic, + ]; + + let supported_card_network = vec![ + common_enums::CardNetwork::Visa, + common_enums::CardNetwork::Mastercard, + common_enums::CardNetwork::Interac, + common_enums::CardNetwork::AmericanExpress, + common_enums::CardNetwork::JCB, + common_enums::CardNetwork::DinersClub, + common_enums::CardNetwork::Discover, + common_enums::CardNetwork::CartesBancaires, + common_enums::CardNetwork::UnionPay, + ]; + + let mut payu_supported_payment_methods = SupportedPaymentMethods::new(); + + payu_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::Supported, + no_three_ds: common_enums::FeatureStatus::NotSupported, + supported_card_networks: supported_card_network.clone(), + } + }), + ), + }, + ); + + payu_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::Supported, + no_three_ds: common_enums::FeatureStatus::NotSupported, + supported_card_networks: supported_card_network.clone(), + } + }), + ), + }, + ); + + payu_supported_payment_methods.add( + enums::PaymentMethod::Wallet, + enums::PaymentMethodType::GooglePay, + PaymentMethodDetails { + mandates: enums::FeatureStatus::NotSupported, + refunds: enums::FeatureStatus::Supported, + supported_capture_methods: supported_capture_methods.clone(), + specific_features: None, + }, + ); + + payu_supported_payment_methods.add( + enums::PaymentMethod::Wallet, + enums::PaymentMethodType::ApplePay, + PaymentMethodDetails { + mandates: enums::FeatureStatus::NotSupported, + refunds: enums::FeatureStatus::Supported, + supported_capture_methods: supported_capture_methods.clone(), + specific_features: None, + }, + ); + + payu_supported_payment_methods +}); + +static PAYU_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { display_name: "Payu", description: "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, }; - static ref PAYU_SUPPORTED_WEBHOOK_FLOWS: Vec = Vec::new(); - -} +static PAYU_SUPPORTED_WEBHOOK_FLOWS: LazyLock<[enums::EventClass; 0]> = LazyLock::new(|| []); impl ConnectorSpecifications for Payu { 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> { From d0668e269954256f6c8bf0aa246e3719c463fd3e Mon Sep 17 00:00:00 2001 From: Sayak Bhattacharya Date: Thu, 27 Mar 2025 16:36:42 +0530 Subject: [PATCH 2/2] fix(connector): [JPMORGAN, PAYU, DIGITALVIRGO, BITPAY, HELCIM, PAYBOX] Replaced lazystatic macros with LazyLock --- crates/hyperswitch_connectors/src/connectors/bitpay.rs | 7 +++---- .../hyperswitch_connectors/src/connectors/digitalvirgo.rs | 7 +++---- crates/hyperswitch_connectors/src/connectors/helcim.rs | 4 ++-- crates/hyperswitch_connectors/src/connectors/jpmorgan.rs | 4 ++-- crates/hyperswitch_connectors/src/connectors/paybox.rs | 4 ++-- crates/hyperswitch_connectors/src/connectors/payu.rs | 4 ++-- 6 files changed, 14 insertions(+), 16 deletions(-) diff --git a/crates/hyperswitch_connectors/src/connectors/bitpay.rs b/crates/hyperswitch_connectors/src/connectors/bitpay.rs index 14174219075..0766def5048 100644 --- a/crates/hyperswitch_connectors/src/connectors/bitpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/bitpay.rs @@ -431,7 +431,7 @@ static BITPAY_SUPPORTED_PAYMENT_METHODS: LazyLock = Laz PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, - supported_capture_methods: supported_capture_methods.clone(), + supported_capture_methods, specific_features: None, }, ); @@ -446,8 +446,7 @@ static BITPAY_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { connector_type: enums::PaymentConnectorCategory::AlternativePaymentMethod, }; -static BITPAY_SUPPORTED_WEBHOOK_FLOWS: LazyLock<[enums::EventClass; 1]> = - LazyLock::new(|| [enums::EventClass::Payments]); +static BITPAY_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 1] = [enums::EventClass::Payments]; impl ConnectorSpecifications for Bitpay { fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { @@ -459,6 +458,6 @@ impl ConnectorSpecifications for Bitpay { } fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { - Some(&*BITPAY_SUPPORTED_WEBHOOK_FLOWS) + Some(&BITPAY_SUPPORTED_WEBHOOK_FLOWS) } } diff --git a/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs b/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs index add51fbc704..9b771924fc3 100644 --- a/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs +++ b/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs @@ -540,7 +540,7 @@ static DIGITALVIRGO_SUPPORTED_PAYMENT_METHODS: LazyLock PaymentMethodDetails { mandates: enums::FeatureStatus::NotSupported, refunds: enums::FeatureStatus::Supported, - supported_capture_methods: supported_capture_methods.clone(), + supported_capture_methods, specific_features: None, }, ); @@ -555,8 +555,7 @@ static DIGITALVIRGO_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { connector_type: enums::PaymentConnectorCategory::AlternativePaymentMethod, }; -static DIGITALVIRGO_SUPPORTED_WEBHOOK_FLOWS: LazyLock<[enums::EventClass; 0]> = - LazyLock::new(|| []); +static DIGITALVIRGO_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = []; impl ConnectorSpecifications for Digitalvirgo { fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { @@ -568,6 +567,6 @@ impl ConnectorSpecifications for Digitalvirgo { } fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { - Some(&*DIGITALVIRGO_SUPPORTED_WEBHOOK_FLOWS) + Some(&DIGITALVIRGO_SUPPORTED_WEBHOOK_FLOWS) } } diff --git a/crates/hyperswitch_connectors/src/connectors/helcim.rs b/crates/hyperswitch_connectors/src/connectors/helcim.rs index df001decf84..cf8d6279a51 100644 --- a/crates/hyperswitch_connectors/src/connectors/helcim.rs +++ b/crates/hyperswitch_connectors/src/connectors/helcim.rs @@ -897,7 +897,7 @@ static HELCIM_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { connector_type: enums::PaymentConnectorCategory::PaymentGateway, }; -static HELCIM_SUPPORTED_WEBHOOK_FLOWS: LazyLock<[enums::EventClass; 0]> = LazyLock::new(|| []); +static HELCIM_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = []; impl ConnectorSpecifications for Helcim { fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { @@ -909,6 +909,6 @@ impl ConnectorSpecifications for Helcim { } fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { - Some(&*HELCIM_SUPPORTED_WEBHOOK_FLOWS) + Some(&HELCIM_SUPPORTED_WEBHOOK_FLOWS) } } diff --git a/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs b/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs index ff290d99866..fa463f1bd79 100644 --- a/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs +++ b/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs @@ -877,7 +877,7 @@ static JPMORGAN_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { connector_type: enums::PaymentConnectorCategory::BankAcquirer, }; -static JPMORGAN_SUPPORTED_WEBHOOK_FLOWS: LazyLock<[enums::EventClass; 0]> = LazyLock::new(|| []); +static JPMORGAN_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = []; impl ConnectorSpecifications for Jpmorgan { fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { @@ -889,6 +889,6 @@ impl ConnectorSpecifications for Jpmorgan { } fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { - Some(&*JPMORGAN_SUPPORTED_WEBHOOK_FLOWS) + Some(&JPMORGAN_SUPPORTED_WEBHOOK_FLOWS) } } diff --git a/crates/hyperswitch_connectors/src/connectors/paybox.rs b/crates/hyperswitch_connectors/src/connectors/paybox.rs index 6163adeef0a..699dd97abfb 100644 --- a/crates/hyperswitch_connectors/src/connectors/paybox.rs +++ b/crates/hyperswitch_connectors/src/connectors/paybox.rs @@ -759,7 +759,7 @@ static PAYBOX_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { connector_type: enums::PaymentConnectorCategory::PaymentGateway, }; -static PAYBOX_SUPPORTED_WEBHOOK_FLOWS: LazyLock<[enums::EventClass; 0]> = LazyLock::new(|| []); +static PAYBOX_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = []; impl ConnectorSpecifications for Paybox { fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { @@ -771,6 +771,6 @@ impl ConnectorSpecifications for Paybox { } fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { - Some(&*PAYBOX_SUPPORTED_WEBHOOK_FLOWS) + Some(&PAYBOX_SUPPORTED_WEBHOOK_FLOWS) } } diff --git a/crates/hyperswitch_connectors/src/connectors/payu.rs b/crates/hyperswitch_connectors/src/connectors/payu.rs index 0ebdb16b955..8085d484858 100644 --- a/crates/hyperswitch_connectors/src/connectors/payu.rs +++ b/crates/hyperswitch_connectors/src/connectors/payu.rs @@ -878,7 +878,7 @@ static PAYU_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { connector_type: enums::PaymentConnectorCategory::PaymentGateway, }; -static PAYU_SUPPORTED_WEBHOOK_FLOWS: LazyLock<[enums::EventClass; 0]> = LazyLock::new(|| []); +static PAYU_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = []; impl ConnectorSpecifications for Payu { fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { @@ -890,6 +890,6 @@ impl ConnectorSpecifications for Payu { } fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { - Some(&*PAYU_SUPPORTED_WEBHOOK_FLOWS) + Some(&PAYU_SUPPORTED_WEBHOOK_FLOWS) } }