diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs index 418d58eb54ba..81c079d5d523 100644 --- a/crates/hyperswitch_connectors/src/default_implementations.rs +++ b/crates/hyperswitch_connectors/src/default_implementations.rs @@ -1049,6 +1049,56 @@ default_imp_for_file_upload!( connectors::Zsl ); +macro_rules! default_imp_for_payouts { + ($($path:ident::$connector:ident),*) => { + $( + impl api::Payouts for $path::$connector {} + )* + }; +} + +default_imp_for_payouts!( + connectors::Airwallex, + connectors::Amazonpay, + connectors::Bambora, + connectors::Billwerk, + connectors::Bitpay, + connectors::Cashtocode, + connectors::Cryptopay, + connectors::Coinbase, + connectors::Deutschebank, + connectors::Digitalvirgo, + connectors::Dlocal, + connectors::Elavon, + connectors::Fiserv, + connectors::Fiservemea, + connectors::Fiuu, + connectors::Forte, + connectors::Globepay, + connectors::Helcim, + connectors::Jpmorgan, + connectors::Mollie, + connectors::Multisafepay, + connectors::Nexinets, + connectors::Nexixpay, + connectors::Nomupay, + connectors::Novalnet, + connectors::Payeezy, + connectors::Payu, + connectors::Powertranz, + connectors::Razorpay, + connectors::Shift4, + connectors::Square, + connectors::Stax, + connectors::Taxjar, + connectors::Tsys, + connectors::Volt, + connectors::Worldline, + connectors::Worldpay, + connectors::Zen, + connectors::Zsl +); + #[cfg(feature = "payouts")] macro_rules! default_imp_for_payouts_create { ($($path:ident::$connector:ident),*) => { diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index 7205865f24ac..0ea8996cb4c3 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -38,6 +38,8 @@ use masking::Maskable; use router_env::metrics::add_attributes; use serde_json::json; +#[cfg(feature = "payouts")] +pub use self::payouts::*; pub use self::{payments::*, refunds::*}; use crate::{ configs::Connectors, connector_integration_v2::ConnectorIntegrationV2, consts, errors, @@ -410,3 +412,7 @@ pub trait ConnectorRedirectResponse { Ok(CallConnectorAction::Avoid) } } + +/// Empty trait for when payouts feature is disabled +#[cfg(not(feature = "payouts"))] +pub trait Payouts {} diff --git a/crates/hyperswitch_interfaces/src/api/payouts.rs b/crates/hyperswitch_interfaces/src/api/payouts.rs index 894f636707a4..5fc0280f19c0 100644 --- a/crates/hyperswitch_interfaces/src/api/payouts.rs +++ b/crates/hyperswitch_interfaces/src/api/payouts.rs @@ -1,13 +1,15 @@ //! Payouts interface -use hyperswitch_domain_models::router_flow_types::payouts::{ - PoCancel, PoCreate, PoEligibility, PoFulfill, PoQuote, PoRecipient, PoRecipientAccount, PoSync, -}; -#[cfg(feature = "payouts")] use hyperswitch_domain_models::{ - router_request_types::PayoutsData, router_response_types::PayoutsResponseData, + router_flow_types::payouts::{ + PoCancel, PoCreate, PoEligibility, PoFulfill, PoQuote, PoRecipient, PoRecipientAccount, + PoSync, + }, + router_request_types::PayoutsData, + router_response_types::PayoutsResponseData, }; +use super::ConnectorCommon; use crate::api::ConnectorIntegration; /// trait PayoutCancel @@ -42,3 +44,17 @@ pub trait PayoutRecipientAccount: /// trait PayoutSync pub trait PayoutSync: ConnectorIntegration {} + +/// trait Payouts +pub trait Payouts: + ConnectorCommon + + PayoutCancel + + PayoutCreate + + PayoutEligibility + + PayoutFulfill + + PayoutQuote + + PayoutRecipient + + PayoutRecipientAccount + + PayoutSync +{ +} diff --git a/crates/hyperswitch_interfaces/src/api/payouts_v2.rs b/crates/hyperswitch_interfaces/src/api/payouts_v2.rs index 40e0726ce80b..9027152f02d5 100644 --- a/crates/hyperswitch_interfaces/src/api/payouts_v2.rs +++ b/crates/hyperswitch_interfaces/src/api/payouts_v2.rs @@ -1,13 +1,15 @@ //! Payouts V2 interface -use hyperswitch_domain_models::router_flow_types::payouts::{ - PoCancel, PoCreate, PoEligibility, PoFulfill, PoQuote, PoRecipient, PoRecipientAccount, PoSync, -}; -#[cfg(feature = "payouts")] use hyperswitch_domain_models::{ - router_data_v2::flow_common_types::PayoutFlowData, router_request_types::PayoutsData, + router_data_v2::flow_common_types::PayoutFlowData, + router_flow_types::payouts::{ + PoCancel, PoCreate, PoEligibility, PoFulfill, PoQuote, PoRecipient, PoRecipientAccount, + PoSync, + }, + router_request_types::PayoutsData, router_response_types::PayoutsResponseData, }; +use super::ConnectorCommon; use crate::api::ConnectorIntegrationV2; /// trait PayoutCancelV2 @@ -57,3 +59,21 @@ pub trait PayoutSyncV2: ConnectorIntegrationV2 { } + +/// trait Payouts +pub trait PayoutsV2: + ConnectorCommon + + PayoutCancelV2 + + PayoutCreateV2 + + PayoutEligibilityV2 + + PayoutFulfillV2 + + PayoutQuoteV2 + + PayoutRecipientV2 + + PayoutRecipientAccountV2 + + PayoutSyncV2 +{ +} + +/// Empty trait for when payouts feature is disabled +#[cfg(not(feature = "payouts"))] +pub trait PayoutsV2 {} diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs index a68945029965..1358bcedba1d 100644 --- a/crates/router/src/core/payments/flows.rs +++ b/crates/router/src/core/payments/flows.rs @@ -12,6 +12,7 @@ pub mod session_update_flow; pub mod setup_mandate_flow; use async_trait::async_trait; +use hyperswitch_interfaces::api::payouts::Payouts; #[cfg(feature = "frm")] use crate::types::fraud_check as frm_types; @@ -969,88 +970,49 @@ default_imp_for_post_processing_steps!( macro_rules! default_imp_for_payouts { ($($path:ident::$connector:ident),*) => { $( - impl api::Payouts for $path::$connector {} + impl Payouts for $path::$connector {} )* }; } #[cfg(feature = "dummy_connector")] -impl api::Payouts for connector::DummyConnector {} +impl Payouts for connector::DummyConnector {} default_imp_for_payouts!( connector::Aci, - connector::Airwallex, - connector::Amazonpay, connector::Authorizedotnet, - connector::Bambora, connector::Bamboraapac, connector::Bankofamerica, - connector::Billwerk, - connector::Bitpay, connector::Bluesnap, connector::Boku, connector::Braintree, - connector::Cashtocode, connector::Checkout, - connector::Cryptopay, - connector::Coinbase, connector::Datatrans, - connector::Deutschebank, - connector::Digitalvirgo, - connector::Dlocal, - connector::Elavon, - connector::Fiserv, - connector::Fiservemea, - connector::Fiuu, - connector::Forte, connector::Globalpay, - connector::Globepay, connector::Gocardless, connector::Gpayments, - connector::Helcim, connector::Iatapay, connector::Itaubank, - connector::Jpmorgan, connector::Klarna, connector::Mifinity, - connector::Mollie, - connector::Multisafepay, connector::Netcetera, - connector::Nexinets, - connector::Nexixpay, connector::Nmi, - connector::Nomupay, connector::Noon, - connector::Novalnet, connector::Nuvei, connector::Opayo, connector::Opennode, connector::Paybox, - connector::Payeezy, connector::Payme, - connector::Payu, connector::Placetopay, connector::Plaid, - connector::Powertranz, connector::Prophetpay, connector::Rapyd, - connector::Razorpay, connector::Riskified, - connector::Shift4, connector::Signifyd, - connector::Square, - connector::Stax, - connector::Taxjar, connector::Threedsecureio, connector::Trustpay, - connector::Tsys, - connector::Volt, connector::Wellsfargo, - connector::Wellsfargopayout, - connector::Worldline, - connector::Worldpay, - connector::Zen, - connector::Zsl + connector::Wellsfargopayout ); #[cfg(feature = "payouts")] diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index 067a744cbeb8..eaff966daf05 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -571,25 +571,6 @@ pub trait FraudCheck {} #[cfg(not(feature = "frm"))] pub trait FraudCheckV2 {} -#[cfg(feature = "payouts")] -pub trait Payouts: - ConnectorCommon - + PayoutCancel - + PayoutCreate - + PayoutEligibility - + PayoutFulfill - + PayoutQuote - + PayoutRecipient - + PayoutRecipientAccount - + PayoutSync -{ -} -#[cfg(not(feature = "payouts"))] -pub trait Payouts {} - -#[cfg(not(feature = "payouts"))] -pub trait PayoutsV2 {} - #[cfg(test)] mod test { #![allow(clippy::unwrap_used)] diff --git a/crates/router/src/types/api/payouts.rs b/crates/router/src/types/api/payouts.rs index a9630beb25a4..b5a6ac24ca9e 100644 --- a/crates/router/src/types/api/payouts.rs +++ b/crates/router/src/types/api/payouts.rs @@ -11,7 +11,7 @@ pub use hyperswitch_domain_models::router_flow_types::payouts::{ }; pub use hyperswitch_interfaces::api::payouts::{ PayoutCancel, PayoutCreate, PayoutEligibility, PayoutFulfill, PayoutQuote, PayoutRecipient, - PayoutRecipientAccount, PayoutSync, + PayoutRecipientAccount, PayoutSync, Payouts, }; pub use super::payouts_v2::{