From 35a61282696c9500356674051eacfa9f47ad17eb Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Sun, 17 Nov 2024 15:37:40 +0530 Subject: [PATCH 01/40] add payment method validation --- crates/common_enums/src/enums.rs | 11 +++ .../src/connectors/bambora.rs | 26 ++++++- crates/hyperswitch_interfaces/src/api.rs | 77 ++++++++++++++++++- crates/hyperswitch_interfaces/src/types.rs | 19 +++++ .../src/core/payments/flows/authorize_flow.rs | 16 +++- .../connector_integration_interface.rs | 23 ++++++ 6 files changed, 165 insertions(+), 7 deletions(-) diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 4d2e117a8809..fd563f95931e 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -3308,3 +3308,14 @@ pub enum ConnectorMandateStatus { /// Indicates that the connector mandate is not active and hence cannot be used for payments. Inactive, } + +#[derive(Debug, PartialEq, Eq, Default, Clone)] +pub enum PaymentMethodStage { + /// Payment Method available in production + #[default] + Live, + /// Payment Method available in sandbox + Beta, + /// Payment Method not available + Upcoming, +} diff --git a/crates/hyperswitch_connectors/src/connectors/bambora.rs b/crates/hyperswitch_connectors/src/connectors/bambora.rs index 4731546b3d33..26abc7b3eda4 100644 --- a/crates/hyperswitch_connectors/src/connectors/bambora.rs +++ b/crates/hyperswitch_connectors/src/connectors/bambora.rs @@ -38,8 +38,9 @@ use hyperswitch_interfaces::{ errors, events::connector_api_logs::ConnectorEvent, types::{ - self, PaymentsAuthorizeType, PaymentsCaptureType, PaymentsCompleteAuthorizeType, - PaymentsSyncType, PaymentsVoidType, Response, + self, PaymentMethodDetails, PaymentMethodTypeMetada, PaymentsAuthorizeType, + PaymentsCaptureType, PaymentsCompleteAuthorizeType, PaymentsSyncType, PaymentsVoidType, + Response, SupportedPaymentMethods, }, webhooks, }; @@ -119,6 +120,27 @@ impl ConnectorCommon for Bambora { )]) } + fn get_supported_payment_methods(&self) -> Option { + let mut supported_payment_methods = SupportedPaymentMethods::new(); + let mut card_payment_method = PaymentMethodTypeMetada::new(); + card_payment_method.insert( + enums::PaymentMethodType::Credit, + PaymentMethodDetails { + availability_status: enums::PaymentMethodStage::Live, + supports_mandates: false, + }, + ); + card_payment_method.insert( + enums::PaymentMethodType::Debit, + PaymentMethodDetails { + availability_status: enums::PaymentMethodStage::Live, + supports_mandates: false, + }, + ); + supported_payment_methods.insert(enums::PaymentMethod::Card, card_payment_method); + Some(supported_payment_methods) + } + fn build_error_response( &self, res: Response, diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index 7205865f24ac..1f7482fbfdae 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -16,7 +16,11 @@ pub mod payouts; pub mod payouts_v2; pub mod refunds; pub mod refunds_v2; -use common_enums::enums::{CallConnectorAction, CaptureMethod, PaymentAction, PaymentMethodType}; + +use common_enums::{ + enums::{CallConnectorAction, CaptureMethod, PaymentAction, PaymentMethodType}, + PaymentMethod, PaymentMethodStage, +}; use common_utils::{ errors::CustomResult, request::{Method, Request, RequestContent}, @@ -40,8 +44,12 @@ use serde_json::json; pub use self::{payments::*, refunds::*}; use crate::{ - configs::Connectors, connector_integration_v2::ConnectorIntegrationV2, consts, errors, - events::connector_api_logs::ConnectorEvent, metrics, types, + configs::Connectors, + connector_integration_v2::ConnectorIntegrationV2, + consts, errors, + events::connector_api_logs::ConnectorEvent, + metrics, + types::{self, SupportedPaymentMethods}, }; /// type BoxedConnectorIntegration @@ -255,6 +263,11 @@ pub trait ConnectorCommon { /// The base URL for interacting with the connector's API. fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str; + /// Details related to payment method supported by the connector + fn get_supported_payment_methods(&self) -> Option { + None + } + /// common error response for a connector if it is same in all case fn build_error_response( &self, @@ -338,6 +351,64 @@ pub trait ConnectorVerifyWebhookSourceV2: /// trait ConnectorValidation pub trait ConnectorValidation: ConnectorCommon { + /// fn validate_payment_method + fn validate_payment_method( + &self, + payment_method_type: &Option, + payment_method: &PaymentMethod, + is_mandate_payment: bool, + test_mode: bool, + ) -> CustomResult<(), errors::ConnectorError> { + match self.get_supported_payment_methods() { + Some(supported_payment_methods) => { + // Check if the payment method exists + let payment_method_information = supported_payment_methods + .get(payment_method) + .ok_or_else(|| errors::ConnectorError::NotSupported { + message: payment_method.to_string(), + connector: self.id(), + })?; + + match payment_method_type { + Some(pmt) => { + // Check if the payment method type exists + let payment_method_type_information = payment_method_information + .get(pmt) + .ok_or_else(|| { + errors::ConnectorError::NotSupported { + message: format!("{:?}, {:?}", pmt, payment_method), + connector: self.id(), + } + })?; + // Validate the payment method type based on its availability and mandate support + match ( + test_mode, + is_mandate_payment, + payment_method_type_information.availability_status.clone(), + payment_method_type_information.supports_mandates, + ) { + // Test mode mandate payment + (true, true, PaymentMethodStage::Live | PaymentMethodStage::Beta, true) | + // Test mode payment + (true, false, PaymentMethodStage::Live | PaymentMethodStage::Beta, _) | + // Live mode mandate payment + (false, true, PaymentMethodStage::Live, true) | + // Live mode payment + (false, false, PaymentMethodStage::Live, _) => Ok(()), + // If none of the cases match, return an unsupported error + _ => Err(errors::ConnectorError::NotSupported { + message: format!("{:?}, {:?}", payment_method_type, payment_method), + connector: self.id(), + }.into()), + } + } + None => Ok(()), + } + } + None => Ok(()), + } + } + /// fn validate_capture_method fn validate_capture_method( &self, diff --git a/crates/hyperswitch_interfaces/src/types.rs b/crates/hyperswitch_interfaces/src/types.rs index 41a1b1ba83c9..288e4dbdef7e 100644 --- a/crates/hyperswitch_interfaces/src/types.rs +++ b/crates/hyperswitch_interfaces/src/types.rs @@ -1,4 +1,7 @@ //! Types interface +use std::collections::HashMap; + +use common_enums::{PaymentMethod, PaymentMethodStage, PaymentMethodType}; use hyperswitch_domain_models::{ router_data::AccessToken, router_flow_types::{ @@ -185,3 +188,19 @@ pub type RetrieveFileType = /// Type alias for `ConnectorIntegration` pub type DefendDisputeType = dyn ConnectorIntegration; + +/// Represents details of a payment method. +#[derive(Debug, Clone)] +pub struct PaymentMethodDetails { + /// The availability status of the payment method based on the environment (e.g., live, beta, upcoming). + pub availability_status: PaymentMethodStage, + + /// Indicates whether mandates are supported by this payment method. + pub supports_mandates: bool, +} + +/// list of payment method types and metadata related to them +pub type PaymentMethodTypeMetada = HashMap; + +/// list of payment methods, payment method types and metadata related to them +pub type SupportedPaymentMethods = HashMap; diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs index 09a6fb519248..1a99f1ee550d 100644 --- a/crates/router/src/core/payments/flows/authorize_flow.rs +++ b/crates/router/src/core/payments/flows/authorize_flow.rs @@ -317,9 +317,21 @@ impl Feature for types::PaymentsAu ) .to_payment_failed_response()?; - if crate::connector::utils::PaymentsAuthorizeRequestData::is_customer_initiated_mandate_payment( + let is_customer_initiated_mandate_payment = crate::connector::utils::PaymentsAuthorizeRequestData::is_customer_initiated_mandate_payment( &self.request, - ) { + ); + + connector + .connector + .validate_payment_method( + &self.request.payment_method_type, + &self.payment_method, + is_customer_initiated_mandate_payment, + self.test_mode.unwrap_or(false), + ) + .to_payment_failed_response()?; + + if is_customer_initiated_mandate_payment { connector .connector .validate_mandate_payment( diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs index a597ddfe1540..edba7a312906 100644 --- a/crates/router/src/services/connector_integration_interface.rs +++ b/crates/router/src/services/connector_integration_interface.rs @@ -335,6 +335,29 @@ impl ConnectorRedirectResponse for ConnectorEnum { } impl ConnectorValidation for ConnectorEnum { + fn validate_payment_method( + &self, + payment_method_type: &Option, + payment_method: &common_enums::PaymentMethod, + is_mandate_payment: bool, + test_mode: bool, + ) -> CustomResult<(), errors::ConnectorError> { + match self { + Self::Old(connector) => connector.validate_payment_method( + payment_method_type, + payment_method, + is_mandate_payment, + test_mode, + ), + Self::New(connector) => connector.validate_payment_method( + payment_method_type, + payment_method, + is_mandate_payment, + test_mode, + ), + } + } + fn validate_capture_method( &self, capture_method: Option, From 0e82f4395a371d02ade614990294b61b4ed6edf0 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Tue, 19 Nov 2024 17:24:48 +0530 Subject: [PATCH 02/40] add /feature_matrix endpoint --- crates/api_models/src/feature_matrix.rs | 43 +++++++++ crates/api_models/src/lib.rs | 1 + crates/common_enums/src/enums.rs | 39 +++++--- .../src/connectors/bambora.rs | 4 +- crates/hyperswitch_interfaces/src/types.rs | 4 +- .../src/core/payments/flows/authorize_flow.rs | 3 +- crates/router/src/lib.rs | 3 +- crates/router/src/routes.rs | 3 +- crates/router/src/routes/app.rs | 17 ++++ crates/router/src/routes/feature_matrix.rs | 95 +++++++++++++++++++ crates/router/src/routes/lock_utils.rs | 3 + .../connector_integration_interface.rs | 8 ++ crates/router/src/types/api.rs | 9 +- crates/router/src/types/api/payments.rs | 3 +- .../src/utils/connector_onboarding/paypal.rs | 1 - crates/router_env/src/logger/types.rs | 2 + 16 files changed, 212 insertions(+), 26 deletions(-) create mode 100644 crates/api_models/src/feature_matrix.rs create mode 100644 crates/router/src/routes/feature_matrix.rs diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs new file mode 100644 index 000000000000..b990eebb0789 --- /dev/null +++ b/crates/api_models/src/feature_matrix.rs @@ -0,0 +1,43 @@ +use serde::{Serialize, Deserialize} ; +use utoipa::ToSchema; + +use crate::enums; + +#[derive(Default, Debug, Deserialize, Serialize, Clone, ToSchema)] +pub struct FeatureMatrixRequest { + // List of connectors for which the feature matrix is requested + pub connectors: Option>, +} + +#[cfg(feature = "v1")] +#[derive(Clone, Debug, Serialize)] +pub struct SupportedPaymentMethod { + pub payment_method: enums::PaymentMethodType, + pub availability_status: enums::PaymentMethodStage, + pub supports_mandates: bool, +} + +#[cfg(feature = "v1")] +#[derive(Clone, Debug, ToSchema, Serialize)] +pub struct SupportedPaymentMethodTypes { + pub payment_method_type: enums::PaymentMethod, + pub payment_methods: Vec +} + +#[cfg(feature = "v1")] +#[derive(Clone, Debug, ToSchema, Serialize)] +pub struct FeatureMatrixResponse { + pub connector: enums::Connector, + pub payment_method_types: Vec +} + +#[derive(Clone, Debug, serde::Serialize, ToSchema)] +pub struct FeatureMatrixListResponse { + /// The number of connectors included in the list + pub size: usize, + // The list of payments response objects + pub data: Vec, +} + +impl common_utils::events::ApiEventMetric for FeatureMatrixListResponse {} +impl common_utils::events::ApiEventMetric for FeatureMatrixRequest {} \ No newline at end of file diff --git a/crates/api_models/src/lib.rs b/crates/api_models/src/lib.rs index a28332e7fea0..eae31db2eb52 100644 --- a/crates/api_models/src/lib.rs +++ b/crates/api_models/src/lib.rs @@ -17,6 +17,7 @@ pub mod ephemeral_key; pub mod errors; pub mod events; pub mod files; +pub mod feature_matrix; pub mod gsm; pub mod health_check; pub mod locker_migration; diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index fd563f95931e..f644581ab429 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -1617,6 +1617,34 @@ pub enum PaymentMethod { OpenBanking, } +#[derive( + Clone, + Copy, + Debug, + Default, + Eq, + Hash, + PartialEq, + serde::Deserialize, + serde::Serialize, + strum::Display, + strum::VariantNames, + strum::EnumIter, + strum::EnumString, + ToSchema, +)] +#[strum(serialize_all = "snake_case")] +pub enum PaymentMethodStage { + /// Payment Method available in production + #[default] + Live, + /// Payment Method available in sandbox + Beta, + /// Payment Method not available + Upcoming, +} + + /// The type of the payment that differentiates between normal and various types of mandate payments. Use 'setup_mandate' in case of zero auth flow. #[derive( Clone, @@ -3308,14 +3336,3 @@ pub enum ConnectorMandateStatus { /// Indicates that the connector mandate is not active and hence cannot be used for payments. Inactive, } - -#[derive(Debug, PartialEq, Eq, Default, Clone)] -pub enum PaymentMethodStage { - /// Payment Method available in production - #[default] - Live, - /// Payment Method available in sandbox - Beta, - /// Payment Method not available - Upcoming, -} diff --git a/crates/hyperswitch_connectors/src/connectors/bambora.rs b/crates/hyperswitch_connectors/src/connectors/bambora.rs index 26abc7b3eda4..1deb4b01aa1a 100644 --- a/crates/hyperswitch_connectors/src/connectors/bambora.rs +++ b/crates/hyperswitch_connectors/src/connectors/bambora.rs @@ -38,7 +38,7 @@ use hyperswitch_interfaces::{ errors, events::connector_api_logs::ConnectorEvent, types::{ - self, PaymentMethodDetails, PaymentMethodTypeMetada, PaymentsAuthorizeType, + self, PaymentMethodDetails, PaymentMethodTypeMetadata, PaymentsAuthorizeType, PaymentsCaptureType, PaymentsCompleteAuthorizeType, PaymentsSyncType, PaymentsVoidType, Response, SupportedPaymentMethods, }, @@ -122,7 +122,7 @@ impl ConnectorCommon for Bambora { fn get_supported_payment_methods(&self) -> Option { let mut supported_payment_methods = SupportedPaymentMethods::new(); - let mut card_payment_method = PaymentMethodTypeMetada::new(); + let mut card_payment_method = PaymentMethodTypeMetadata::new(); card_payment_method.insert( enums::PaymentMethodType::Credit, PaymentMethodDetails { diff --git a/crates/hyperswitch_interfaces/src/types.rs b/crates/hyperswitch_interfaces/src/types.rs index 288e4dbdef7e..516f6be764f7 100644 --- a/crates/hyperswitch_interfaces/src/types.rs +++ b/crates/hyperswitch_interfaces/src/types.rs @@ -200,7 +200,7 @@ pub struct PaymentMethodDetails { } /// list of payment method types and metadata related to them -pub type PaymentMethodTypeMetada = HashMap; +pub type PaymentMethodTypeMetadata = HashMap; /// list of payment methods, payment method types and metadata related to them -pub type SupportedPaymentMethods = HashMap; +pub type SupportedPaymentMethods = HashMap; diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs index 1a99f1ee550d..3f587ae3ec45 100644 --- a/crates/router/src/core/payments/flows/authorize_flow.rs +++ b/crates/router/src/core/payments/flows/authorize_flow.rs @@ -328,8 +328,7 @@ impl Feature for types::PaymentsAu &self.payment_method, is_customer_initiated_mandate_payment, self.test_mode.unwrap_or(false), - ) - .to_payment_failed_response()?; + ).to_payment_failed_response()?; if is_customer_initiated_mandate_payment { connector diff --git a/crates/router/src/lib.rs b/crates/router/src/lib.rs index 215a8b209cf0..da8fe1144f9a 100644 --- a/crates/router/src/lib.rs +++ b/crates/router/src/lib.rs @@ -178,7 +178,8 @@ pub fn mk_app( .service(routes::User::server(state.clone())) .service(routes::ConnectorOnboarding::server(state.clone())) .service(routes::Verify::server(state.clone())) - .service(routes::WebhookEvents::server(state.clone())); + .service(routes::WebhookEvents::server(state.clone())) + .service(routes::FeatureMatrix::server(state.clone())); } } diff --git a/crates/router/src/routes.rs b/crates/router/src/routes.rs index 8baed5089e81..868a084c85df 100644 --- a/crates/router/src/routes.rs +++ b/crates/router/src/routes.rs @@ -8,6 +8,7 @@ pub mod blocklist; pub mod cache; pub mod cards_info; pub mod configs; +pub mod feature_matrix; #[cfg(feature = "olap")] pub mod connector_onboarding; #[cfg(any(feature = "olap", feature = "oltp"))] @@ -69,7 +70,7 @@ pub use self::app::{ ApiKeys, AppState, ApplePayCertificatesMigration, Cache, Cards, Configs, ConnectorOnboarding, Customers, Disputes, EphemeralKey, Files, Gsm, Health, Mandates, MerchantAccount, MerchantConnectorAccount, PaymentLink, PaymentMethods, Payments, Poll, Profile, ProfileNew, - Refunds, SessionState, User, Webhooks, + Refunds, SessionState, User, Webhooks, FeatureMatrix, }; #[cfg(feature = "olap")] pub use self::app::{Blocklist, Organization, Routing, Verify, WebhookEvents}; diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index 9f0a83a053f6..8fe4dcb21748 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -72,6 +72,9 @@ use crate::routes::cards_info::card_iin_info; use crate::routes::fraud_check as frm_routes; #[cfg(all(feature = "recon", feature = "olap"))] use crate::routes::recon as recon_routes; +#[cfg(all(feature = "olap", feature = "v1"))] +use crate::routes::feature_matrix; + pub use crate::{ configs::settings, db::{CommonStorageInterface, GlobalStorageInterface, StorageImpl, StorageInterface}, @@ -2147,3 +2150,17 @@ impl WebhookEvents { ) } } + +#[cfg(feature = "olap")] +pub struct FeatureMatrix; + +#[cfg(all(feature = "olap", feature = "v1"))] +impl FeatureMatrix { + pub fn server(state: AppState) -> Scope { + web::scope("/feature_matrix").app_data(web::Data::new(state)) + .service( + web::resource("").route(web::get().to(feature_matrix::fetch_connector_feature_matrix))) + } +} + + diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs new file mode 100644 index 000000000000..0bcbc3eed564 --- /dev/null +++ b/crates/router/src/routes/feature_matrix.rs @@ -0,0 +1,95 @@ +use api_models::feature_matrix; +use hyperswitch_domain_models::api::ApplicationResponse; +use hyperswitch_interfaces::api::ConnectorCommon; +use actix_web::{web, HttpRequest, Responder}; +use router_env::{instrument, tracing, Flow}; +use api_models::connector_enums::Connector; +use strum::IntoEnumIterator; +use crate::{ + self as app, + core::{ + errors::RouterResponse, + api_locking::LockAction + }, + services::{api, authentication as auth}, + types::api::{ + self as api_types, + payments as payment_types, + } + +}; + + +#[cfg(all(feature = "olap", feature = "v1"))] +#[instrument(skip_all)] +pub async fn fetch_connector_feature_matrix( + state: web::Data, + req: HttpRequest, + json_payload: web::Json, +) -> impl Responder { + let flow: Flow = Flow::FeatureMatrix; + let payload = json_payload.into_inner(); + Box::pin(api::server_wrap( + flow, + state, + &req, + payload, + |state, (), req , _| { + connector_feature_matrix( + state, + req + ) + }, + &auth::NoAuth, + LockAction::NotApplicable, + )).await + +} + + +#[cfg(feature = "v1")] +pub async fn connector_feature_matrix( + _state: app::SessionState, + req: payment_types::FeatureMatrixRequest, +) -> RouterResponse { + let connector_list = req.connectors.unwrap_or_else(|| Connector::iter().collect()); + let feature_matrix_response: Vec = connector_list + .into_iter() + .filter_map(|connector_name| { + api_types::ConnectorData::convert_connector(&connector_name.to_string()).ok().and_then(|connector| { + connector.get_supported_payment_methods().map(|supported_methods| { + let payment_method_types = supported_methods + .into_iter() + .map(|(payment_method, supported_payment_method_types)| { + let payment_methods = supported_payment_method_types + .into_iter() + .map(|(payment_method_type, feature_metadata)| { + feature_matrix::SupportedPaymentMethod { + payment_method: payment_method_type, + availability_status: feature_metadata.availability_status, + supports_mandates: feature_metadata.supports_mandates, + } + }) + .collect(); + + feature_matrix::SupportedPaymentMethodTypes { + payment_method_type: payment_method, + payment_methods, + } + }) + .collect(); + + payment_types::FeatureMatrixResponse { + connector: connector_name, + payment_method_types, + } + }) + }) + }) + .collect(); + + Ok(ApplicationResponse::Json(payment_types::FeatureMatrixListResponse { + size: feature_matrix_response.len(), + data: feature_matrix_response, + })) +} \ No newline at end of file diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rs index 4d3718b967dd..ead913bd45e1 100644 --- a/crates/router/src/routes/lock_utils.rs +++ b/crates/router/src/routes/lock_utils.rs @@ -37,6 +37,7 @@ pub enum ApiIdentifier { Recon, Poll, ApplePayCertificatesMigration, + Documentation } impl From for ApiIdentifier { @@ -290,6 +291,8 @@ impl From for ApiIdentifier { | Flow::ReconVerifyToken => Self::Recon, Flow::RetrievePollStatus => Self::Poll, + + Flow::FeatureMatrix => Self::Documentation, } } } diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs index edba7a312906..cfb95b862c51 100644 --- a/crates/router/src/services/connector_integration_interface.rs +++ b/crates/router/src/services/connector_integration_interface.rs @@ -2,6 +2,7 @@ use common_utils::{crypto, errors::CustomResult, request::Request}; use hyperswitch_domain_models::{router_data::RouterData, router_data_v2::RouterDataV2}; use hyperswitch_interfaces::{ authentication::ExternalAuthenticationPayload, connector_integration_v2::ConnectorIntegrationV2, + types::SupportedPaymentMethods, }; use super::{BoxedConnectorIntegrationV2, ConnectorValidation}; @@ -426,6 +427,13 @@ impl api::ConnectorCommon for ConnectorEnum { } } + fn get_supported_payment_methods(&self) -> Option { + match self { + Self::Old(connector) => connector.get_supported_payment_methods(), + Self::New(connector) => connector.get_supported_payment_methods(), + } + } + fn get_auth_header( &self, auth_type: &types::ConnectorAuthType, diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs index 6db9d29daabd..3e5bb6550575 100644 --- a/crates/router/src/types/api.rs +++ b/crates/router/src/types/api.rs @@ -271,12 +271,12 @@ pub enum ConnectorChoice { impl ConnectorData { pub fn get_connector_by_name( - connectors: &Connectors, + _connectors: &Connectors, name: &str, connector_type: GetToken, connector_id: Option, ) -> CustomResult { - let connector = Self::convert_connector(connectors, name)?; + let connector = Self::convert_connector(name)?; let connector_name = api_enums::Connector::from_str(name) .change_context(errors::ConnectorError::InvalidConnectorName) .change_context(errors::ApiErrorResponse::InternalServerError) @@ -291,12 +291,12 @@ impl ConnectorData { #[cfg(feature = "payouts")] pub fn get_payout_connector_by_name( - connectors: &Connectors, + _connectors: &Connectors, name: &str, connector_type: GetToken, connector_id: Option, ) -> CustomResult { - let connector = Self::convert_connector(connectors, name)?; + let connector = Self::convert_connector(name)?; let payout_connector_name = api_enums::PayoutConnectors::from_str(name) .change_context(errors::ConnectorError::InvalidConnectorName) .change_context(errors::ApiErrorResponse::InternalServerError) @@ -311,7 +311,6 @@ impl ConnectorData { } pub fn convert_connector( - _connectors: &Connectors, connector_name: &str, ) -> CustomResult { match enums::Connector::from_str(connector_name) { diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs index 57ef1d3336f5..7709d7b33adb 100644 --- a/crates/router/src/types/api/payments.rs +++ b/crates/router/src/types/api/payments.rs @@ -16,8 +16,9 @@ pub use api_models::payments::{ PaymentsRedirectionResponse, PaymentsRejectRequest, PaymentsResponse, PaymentsResponseForm, PaymentsRetrieveRequest, PaymentsSessionRequest, PaymentsSessionResponse, PaymentsStartRequest, PgRedirectResponse, PhoneDetails, RedirectionResponse, SessionToken, UrlDetails, VerifyRequest, - VerifyResponse, WalletData, + VerifyResponse, WalletData }; +pub use api_models::feature_matrix::{FeatureMatrixRequest, FeatureMatrixListResponse, FeatureMatrixResponse}; #[cfg(feature = "v2")] pub use api_models::payments::{PaymentsCreateIntentRequest, PaymentsIntentResponse}; use error_stack::ResultExt; diff --git a/crates/router/src/utils/connector_onboarding/paypal.rs b/crates/router/src/utils/connector_onboarding/paypal.rs index ebd40fb11dd2..8feec1a3a820 100644 --- a/crates/router/src/utils/connector_onboarding/paypal.rs +++ b/crates/router/src/utils/connector_onboarding/paypal.rs @@ -17,7 +17,6 @@ use crate::{ pub async fn generate_access_token(state: SessionState) -> RouterResult { let connector = enums::Connector::Paypal; let boxed_connector = types::api::ConnectorData::convert_connector( - &state.conf.connectors, connector.to_string().as_str(), )?; let connector_auth = diff --git a/crates/router_env/src/logger/types.rs b/crates/router_env/src/logger/types.rs index 5d59e7ddbac4..fef0afac9572 100644 --- a/crates/router_env/src/logger/types.rs +++ b/crates/router_env/src/logger/types.rs @@ -354,6 +354,8 @@ pub enum Flow { DecisionManagerRetrieveConfig, /// Manual payment fulfillment acknowledgement FrmFulfillment, + /// Get connectors feature matrix + FeatureMatrix, /// Change password flow ChangePassword, /// Signout flow From 81082ec7a0bf7d03ae06d4ab7ba0630febf7749e Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Tue, 19 Nov 2024 12:53:02 +0000 Subject: [PATCH 03/40] chore: run formatter --- crates/api_models/src/feature_matrix.rs | 10 +- crates/api_models/src/lib.rs | 2 +- crates/common_enums/src/enums.rs | 1 - crates/hyperswitch_interfaces/src/api.rs | 15 ++- .../src/core/payments/flows/authorize_flow.rs | 3 +- crates/router/src/routes.rs | 8 +- crates/router/src/routes/app.rs | 18 ++-- crates/router/src/routes/feature_matrix.rs | 94 +++++++++---------- crates/router/src/routes/lock_utils.rs | 4 +- .../connector_integration_interface.rs | 4 +- crates/router/src/types/api/payments.rs | 41 ++++---- .../src/utils/connector_onboarding/paypal.rs | 5 +- 12 files changed, 101 insertions(+), 104 deletions(-) diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index b990eebb0789..b7a407f78f12 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -1,4 +1,4 @@ -use serde::{Serialize, Deserialize} ; +use serde::{Deserialize, Serialize}; use utoipa::ToSchema; use crate::enums; @@ -13,7 +13,7 @@ pub struct FeatureMatrixRequest { #[derive(Clone, Debug, Serialize)] pub struct SupportedPaymentMethod { pub payment_method: enums::PaymentMethodType, - pub availability_status: enums::PaymentMethodStage, + pub availability_status: enums::PaymentMethodStage, pub supports_mandates: bool, } @@ -21,14 +21,14 @@ pub struct SupportedPaymentMethod { #[derive(Clone, Debug, ToSchema, Serialize)] pub struct SupportedPaymentMethodTypes { pub payment_method_type: enums::PaymentMethod, - pub payment_methods: Vec + pub payment_methods: Vec, } #[cfg(feature = "v1")] #[derive(Clone, Debug, ToSchema, Serialize)] pub struct FeatureMatrixResponse { pub connector: enums::Connector, - pub payment_method_types: Vec + pub payment_method_types: Vec, } #[derive(Clone, Debug, serde::Serialize, ToSchema)] @@ -40,4 +40,4 @@ pub struct FeatureMatrixListResponse { } impl common_utils::events::ApiEventMetric for FeatureMatrixListResponse {} -impl common_utils::events::ApiEventMetric for FeatureMatrixRequest {} \ No newline at end of file +impl common_utils::events::ApiEventMetric for FeatureMatrixRequest {} diff --git a/crates/api_models/src/lib.rs b/crates/api_models/src/lib.rs index eae31db2eb52..1cbade5554c4 100644 --- a/crates/api_models/src/lib.rs +++ b/crates/api_models/src/lib.rs @@ -16,8 +16,8 @@ pub mod ephemeral_key; #[cfg(feature = "errors")] pub mod errors; pub mod events; -pub mod files; pub mod feature_matrix; +pub mod files; pub mod gsm; pub mod health_check; pub mod locker_migration; diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 7a834c1ce070..8096fbaaa810 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -1670,7 +1670,6 @@ pub enum PaymentMethodStage { Upcoming, } - /// The type of the payment that differentiates between normal and various types of mandate payments. Use 'setup_mandate' in case of zero auth flow. #[derive( Clone, diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index 538138d21664..8238d744c699 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -374,14 +374,13 @@ pub trait ConnectorValidation: ConnectorCommon { match payment_method_type { Some(pmt) => { // Check if the payment method type exists - let payment_method_type_information = payment_method_information - .get(pmt) - .ok_or_else(|| { - errors::ConnectorError::NotSupported { - message: format!("{:?}, {:?}", pmt, payment_method), - connector: self.id(), - } - })?; + let payment_method_type_information = + payment_method_information.get(pmt).ok_or_else(|| { + errors::ConnectorError::NotSupported { + message: format!("{:?}, {:?}", pmt, payment_method), + connector: self.id(), + } + })?; // Validate the payment method type based on its availability and mandate support match ( test_mode, diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs index 90be7d441c2e..8831b5d19333 100644 --- a/crates/router/src/core/payments/flows/authorize_flow.rs +++ b/crates/router/src/core/payments/flows/authorize_flow.rs @@ -328,7 +328,8 @@ impl Feature for types::PaymentsAu &self.payment_method, is_customer_initiated_mandate_payment, self.test_mode.unwrap_or(false), - ).to_payment_failed_response()?; + ) + .to_payment_failed_response()?; if is_customer_initiated_mandate_payment { connector diff --git a/crates/router/src/routes.rs b/crates/router/src/routes.rs index 3ecedb910435..6d1406c78ed4 100644 --- a/crates/router/src/routes.rs +++ b/crates/router/src/routes.rs @@ -8,7 +8,6 @@ pub mod blocklist; pub mod cache; pub mod cards_info; pub mod configs; -pub mod feature_matrix; #[cfg(feature = "olap")] pub mod connector_onboarding; #[cfg(any(feature = "olap", feature = "oltp"))] @@ -18,6 +17,7 @@ pub mod disputes; #[cfg(feature = "dummy_connector")] pub mod dummy_connector; pub mod ephemeral_key; +pub mod feature_matrix; pub mod files; #[cfg(feature = "frm")] pub mod fraud_check; @@ -65,9 +65,9 @@ pub use self::app::DummyConnector; pub use self::app::Recon; pub use self::app::{ ApiKeys, AppState, ApplePayCertificatesMigration, Cache, Cards, Configs, ConnectorOnboarding, - Customers, Disputes, EphemeralKey, Files, Forex, Gsm, Health, Mandates, MerchantAccount, - MerchantConnectorAccount, PaymentLink, PaymentMethods, Payments, Poll, Profile, ProfileNew, - Refunds, SessionState, User, Webhooks, FeatureMatrix, + Customers, Disputes, EphemeralKey, FeatureMatrix, Files, Forex, Gsm, Health, Mandates, + MerchantAccount, MerchantConnectorAccount, PaymentLink, PaymentMethods, Payments, Poll, + Profile, ProfileNew, Refunds, SessionState, User, Webhooks, }; #[cfg(feature = "olap")] pub use self::app::{Blocklist, Organization, Routing, Verify, WebhookEvents}; diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index 05e9e2886822..32c900ad810f 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -68,13 +68,12 @@ use crate::analytics::AnalyticsProvider; use crate::errors::RouterResult; #[cfg(feature = "v1")] use crate::routes::cards_info::card_iin_info; +#[cfg(all(feature = "olap", feature = "v1"))] +use crate::routes::feature_matrix; #[cfg(all(feature = "frm", feature = "oltp"))] use crate::routes::fraud_check as frm_routes; #[cfg(all(feature = "recon", feature = "olap"))] use crate::routes::recon as recon_routes; -#[cfg(all(feature = "olap", feature = "v1"))] -use crate::routes::feature_matrix; - pub use crate::{ configs::settings, db::{CommonStorageInterface, GlobalStorageInterface, StorageImpl, StorageInterface}, @@ -2149,15 +2148,16 @@ impl WebhookEvents { } #[cfg(feature = "olap")] -pub struct FeatureMatrix; +pub struct FeatureMatrix; #[cfg(all(feature = "olap", feature = "v1"))] impl FeatureMatrix { pub fn server(state: AppState) -> Scope { - web::scope("/feature_matrix").app_data(web::Data::new(state)) - .service( - web::resource("").route(web::get().to(feature_matrix::fetch_connector_feature_matrix))) + web::scope("/feature_matrix") + .app_data(web::Data::new(state)) + .service( + web::resource("") + .route(web::get().to(feature_matrix::fetch_connector_feature_matrix)), + ) } } - - diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index 0bcbc3eed564..eb95a6ca683c 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -1,25 +1,17 @@ -use api_models::feature_matrix; +use actix_web::{web, HttpRequest, Responder}; +use api_models::{connector_enums::Connector, feature_matrix}; use hyperswitch_domain_models::api::ApplicationResponse; use hyperswitch_interfaces::api::ConnectorCommon; -use actix_web::{web, HttpRequest, Responder}; use router_env::{instrument, tracing, Flow}; -use api_models::connector_enums::Connector; use strum::IntoEnumIterator; + use crate::{ self as app, - core::{ - errors::RouterResponse, - api_locking::LockAction - }, + core::{api_locking::LockAction, errors::RouterResponse}, services::{api, authentication as auth}, - types::api::{ - self as api_types, - payments as payment_types, - } - + types::api::{self as api_types, payments as payment_types}, }; - #[cfg(all(feature = "olap", feature = "v1"))] #[instrument(skip_all)] pub async fn fetch_connector_feature_matrix( @@ -34,62 +26,66 @@ pub async fn fetch_connector_feature_matrix( state, &req, payload, - |state, (), req , _| { - connector_feature_matrix( - state, - req - ) - }, + |state, (), req, _| connector_feature_matrix(state, req), &auth::NoAuth, LockAction::NotApplicable, - )).await - + )) + .await } - #[cfg(feature = "v1")] pub async fn connector_feature_matrix( _state: app::SessionState, req: payment_types::FeatureMatrixRequest, ) -> RouterResponse { - let connector_list = req.connectors.unwrap_or_else(|| Connector::iter().collect()); + let connector_list = req + .connectors + .unwrap_or_else(|| Connector::iter().collect()); let feature_matrix_response: Vec = connector_list .into_iter() .filter_map(|connector_name| { - api_types::ConnectorData::convert_connector(&connector_name.to_string()).ok().and_then(|connector| { - connector.get_supported_payment_methods().map(|supported_methods| { - let payment_method_types = supported_methods - .into_iter() - .map(|(payment_method, supported_payment_method_types)| { - let payment_methods = supported_payment_method_types + api_types::ConnectorData::convert_connector(&connector_name.to_string()) + .ok() + .and_then(|connector| { + connector + .get_supported_payment_methods() + .map(|supported_methods| { + let payment_method_types = supported_methods .into_iter() - .map(|(payment_method_type, feature_metadata)| { - feature_matrix::SupportedPaymentMethod { - payment_method: payment_method_type, - availability_status: feature_metadata.availability_status, - supports_mandates: feature_metadata.supports_mandates, + .map(|(payment_method, supported_payment_method_types)| { + let payment_methods = supported_payment_method_types + .into_iter() + .map(|(payment_method_type, feature_metadata)| { + feature_matrix::SupportedPaymentMethod { + payment_method: payment_method_type, + availability_status: feature_metadata + .availability_status, + supports_mandates: feature_metadata + .supports_mandates, + } + }) + .collect(); + + feature_matrix::SupportedPaymentMethodTypes { + payment_method_type: payment_method, + payment_methods, } }) .collect(); - feature_matrix::SupportedPaymentMethodTypes { - payment_method_type: payment_method, - payment_methods, + payment_types::FeatureMatrixResponse { + connector: connector_name, + payment_method_types, } }) - .collect(); - - payment_types::FeatureMatrixResponse { - connector: connector_name, - payment_method_types, - } }) - }) }) .collect(); - Ok(ApplicationResponse::Json(payment_types::FeatureMatrixListResponse { - size: feature_matrix_response.len(), - data: feature_matrix_response, - })) -} \ No newline at end of file + Ok(ApplicationResponse::Json( + payment_types::FeatureMatrixListResponse { + size: feature_matrix_response.len(), + data: feature_matrix_response, + }, + )) +} diff --git a/crates/router/src/routes/lock_utils.rs b/crates/router/src/routes/lock_utils.rs index ead913bd45e1..6fcfa10c87b2 100644 --- a/crates/router/src/routes/lock_utils.rs +++ b/crates/router/src/routes/lock_utils.rs @@ -37,7 +37,7 @@ pub enum ApiIdentifier { Recon, Poll, ApplePayCertificatesMigration, - Documentation + Documentation, } impl From for ApiIdentifier { @@ -291,7 +291,7 @@ impl From for ApiIdentifier { | Flow::ReconVerifyToken => Self::Recon, Flow::RetrievePollStatus => Self::Poll, - + Flow::FeatureMatrix => Self::Documentation, } } diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs index 2129738342e9..d0863dd4dcc7 100644 --- a/crates/router/src/services/connector_integration_interface.rs +++ b/crates/router/src/services/connector_integration_interface.rs @@ -1,8 +1,8 @@ use common_utils::{crypto, errors::CustomResult, request::Request}; use hyperswitch_domain_models::{router_data::RouterData, router_data_v2::RouterDataV2}; use hyperswitch_interfaces::{ - authentication::ExternalAuthenticationPayload, connector_integration_v2::ConnectorIntegrationV2, - types::SupportedPaymentMethods, + authentication::ExternalAuthenticationPayload, + connector_integration_v2::ConnectorIntegrationV2, types::SupportedPaymentMethods, }; use super::{BoxedConnectorIntegrationV2, ConnectorValidation}; diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs index e752f67d102d..62519b1f58ec 100644 --- a/crates/router/src/types/api/payments.rs +++ b/crates/router/src/types/api/payments.rs @@ -1,26 +1,29 @@ #[cfg(feature = "v1")] pub use api_models::payments::PaymentsRequest; -pub use api_models::payments::{ - AcceptanceType, Address, AddressDetails, Amount, AuthenticationForStartResponse, Card, - CryptoData, CustomerAcceptance, CustomerDetailsResponse, MandateAmountData, MandateData, - MandateTransactionType, MandateType, MandateValidationFields, NextActionType, OnlineMandate, - OpenBankingSessionToken, PayLaterData, PaymentIdType, PaymentListConstraints, - PaymentListFilterConstraints, PaymentListFilters, PaymentListFiltersV2, PaymentListResponse, - PaymentListResponseV2, PaymentMethodData, PaymentMethodDataRequest, PaymentMethodDataResponse, - PaymentOp, PaymentRetrieveBody, PaymentRetrieveBodyWithCredentials, PaymentsAggregateResponse, - PaymentsApproveRequest, PaymentsCancelRequest, PaymentsCaptureRequest, - PaymentsCompleteAuthorizeRequest, PaymentsDynamicTaxCalculationRequest, - PaymentsDynamicTaxCalculationResponse, PaymentsExternalAuthenticationRequest, - PaymentsIncrementalAuthorizationRequest, PaymentsManualUpdateRequest, - PaymentsPostSessionTokensRequest, PaymentsPostSessionTokensResponse, PaymentsRedirectRequest, - PaymentsRedirectionResponse, PaymentsRejectRequest, PaymentsResponse, PaymentsResponseForm, - PaymentsRetrieveRequest, PaymentsSessionRequest, PaymentsSessionResponse, PaymentsStartRequest, - PgRedirectResponse, PhoneDetails, RedirectionResponse, SessionToken, UrlDetails, VerifyRequest, - VerifyResponse, WalletData -}; -pub use api_models::feature_matrix::{FeatureMatrixRequest, FeatureMatrixListResponse, FeatureMatrixResponse}; #[cfg(feature = "v2")] pub use api_models::payments::{PaymentsCreateIntentRequest, PaymentsIntentResponse}; +pub use api_models::{ + feature_matrix::{FeatureMatrixListResponse, FeatureMatrixRequest, FeatureMatrixResponse}, + payments::{ + AcceptanceType, Address, AddressDetails, Amount, AuthenticationForStartResponse, Card, + CryptoData, CustomerAcceptance, CustomerDetailsResponse, MandateAmountData, MandateData, + MandateTransactionType, MandateType, MandateValidationFields, NextActionType, + OnlineMandate, OpenBankingSessionToken, PayLaterData, PaymentIdType, + PaymentListConstraints, PaymentListFilterConstraints, PaymentListFilters, + PaymentListFiltersV2, PaymentListResponse, PaymentListResponseV2, PaymentMethodData, + PaymentMethodDataRequest, PaymentMethodDataResponse, PaymentOp, PaymentRetrieveBody, + PaymentRetrieveBodyWithCredentials, PaymentsAggregateResponse, PaymentsApproveRequest, + PaymentsCancelRequest, PaymentsCaptureRequest, PaymentsCompleteAuthorizeRequest, + PaymentsDynamicTaxCalculationRequest, PaymentsDynamicTaxCalculationResponse, + PaymentsExternalAuthenticationRequest, PaymentsIncrementalAuthorizationRequest, + PaymentsManualUpdateRequest, PaymentsPostSessionTokensRequest, + PaymentsPostSessionTokensResponse, PaymentsRedirectRequest, PaymentsRedirectionResponse, + PaymentsRejectRequest, PaymentsResponse, PaymentsResponseForm, PaymentsRetrieveRequest, + PaymentsSessionRequest, PaymentsSessionResponse, PaymentsStartRequest, PgRedirectResponse, + PhoneDetails, RedirectionResponse, SessionToken, UrlDetails, VerifyRequest, VerifyResponse, + WalletData, + }, +}; use error_stack::ResultExt; pub use hyperswitch_domain_models::router_flow_types::payments::{ Approve, Authorize, AuthorizeSessionToken, Balance, CalculateTax, Capture, CompleteAuthorize, diff --git a/crates/router/src/utils/connector_onboarding/paypal.rs b/crates/router/src/utils/connector_onboarding/paypal.rs index 8feec1a3a820..33b85587b430 100644 --- a/crates/router/src/utils/connector_onboarding/paypal.rs +++ b/crates/router/src/utils/connector_onboarding/paypal.rs @@ -16,9 +16,8 @@ use crate::{ pub async fn generate_access_token(state: SessionState) -> RouterResult { let connector = enums::Connector::Paypal; - let boxed_connector = types::api::ConnectorData::convert_connector( - connector.to_string().as_str(), - )?; + let boxed_connector = + types::api::ConnectorData::convert_connector(connector.to_string().as_str())?; let connector_auth = super::get_connector_auth(connector, state.conf.connector_onboarding.get_inner())?; From fc46d917cb41b0170b8cb2007d0087bf71901754 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Wed, 20 Nov 2024 13:16:42 +0530 Subject: [PATCH 04/40] add support for deutshebank --- .../src/connectors/deutschebank.rs | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs index a861155afb3a..01ce11ff08f8 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs @@ -39,7 +39,7 @@ use hyperswitch_interfaces::{ configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, - types::{self, Response}, + types::{self, Response, PaymentMethodDetails, SupportedPaymentMethods, PaymentMethodTypeMetadata}, webhooks, }; use masking::{ExposeInterface, Mask, Secret}; @@ -135,6 +135,20 @@ impl ConnectorCommon for Deutschebank { connectors.deutschebank.base_url.as_ref() } + fn get_supported_payment_methods(&self) -> Option { + let mut supported_payment_methods = SupportedPaymentMethods::new(); + let mut bank_debit_payment_method = PaymentMethodTypeMetadata::new(); + bank_debit_payment_method.insert( + enums::PaymentMethodType::Sepa, + PaymentMethodDetails { + availability_status: enums::PaymentMethodStage::Live, + supports_mandates: true, + }, + ); + supported_payment_methods.insert(enums::PaymentMethod::BankDebit, bank_debit_payment_method); + Some(supported_payment_methods) + } + fn get_auth_header( &self, auth_type: &ConnectorAuthType, From 9f1e4fe0d0ceabc065eb11bdcd196a3093ac8d25 Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Wed, 20 Nov 2024 07:47:34 +0000 Subject: [PATCH 05/40] chore: run formatter --- .../hyperswitch_connectors/src/connectors/deutschebank.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs index 01ce11ff08f8..4a71ba5cc5c5 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs @@ -39,7 +39,9 @@ use hyperswitch_interfaces::{ configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, - types::{self, Response, PaymentMethodDetails, SupportedPaymentMethods, PaymentMethodTypeMetadata}, + types::{ + self, PaymentMethodDetails, PaymentMethodTypeMetadata, Response, SupportedPaymentMethods, + }, webhooks, }; use masking::{ExposeInterface, Mask, Secret}; @@ -145,7 +147,8 @@ impl ConnectorCommon for Deutschebank { supports_mandates: true, }, ); - supported_payment_methods.insert(enums::PaymentMethod::BankDebit, bank_debit_payment_method); + supported_payment_methods + .insert(enums::PaymentMethod::BankDebit, bank_debit_payment_method); Some(supported_payment_methods) } From 05a35be3a265152fa2cb6a86140f6c47546e4afb Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Mon, 2 Dec 2024 12:13:48 +0530 Subject: [PATCH 06/40] add country and currency in pm details --- crates/api_models/src/feature_matrix.rs | 5 +++- crates/common_enums/src/enums.rs | 27 ------------------- .../src/connectors/bambora.rs | 2 -- .../src/connectors/deutschebank.rs | 1 - .../src/connectors/zsl.rs | 16 ++++++++++- crates/hyperswitch_interfaces/src/api.rs | 16 +++-------- crates/hyperswitch_interfaces/src/types.rs | 5 +--- .../src/core/payments/flows/authorize_flow.rs | 1 - crates/router/src/routes/feature_matrix.rs | 26 +++++++++++++++--- .../connector_integration_interface.rs | 5 +--- 10 files changed, 48 insertions(+), 56 deletions(-) diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index b7a407f78f12..eb2a011acda0 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -1,3 +1,5 @@ +use std::collections::HashSet; + use serde::{Deserialize, Serialize}; use utoipa::ToSchema; @@ -13,8 +15,9 @@ pub struct FeatureMatrixRequest { #[derive(Clone, Debug, Serialize)] pub struct SupportedPaymentMethod { pub payment_method: enums::PaymentMethodType, - pub availability_status: enums::PaymentMethodStage, pub supports_mandates: bool, + pub supported_countries: Option>, + pub supported_currencies: Option> } #[cfg(feature = "v1")] diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 8096fbaaa810..23dbab778256 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -1643,33 +1643,6 @@ pub enum PaymentMethod { MobilePayment, } -#[derive( - Clone, - Copy, - Debug, - Default, - Eq, - Hash, - PartialEq, - serde::Deserialize, - serde::Serialize, - strum::Display, - strum::VariantNames, - strum::EnumIter, - strum::EnumString, - ToSchema, -)] -#[strum(serialize_all = "snake_case")] -pub enum PaymentMethodStage { - /// Payment Method available in production - #[default] - Live, - /// Payment Method available in sandbox - Beta, - /// Payment Method not available - Upcoming, -} - /// The type of the payment that differentiates between normal and various types of mandate payments. Use 'setup_mandate' in case of zero auth flow. #[derive( Clone, diff --git a/crates/hyperswitch_connectors/src/connectors/bambora.rs b/crates/hyperswitch_connectors/src/connectors/bambora.rs index 1deb4b01aa1a..f547a6821b78 100644 --- a/crates/hyperswitch_connectors/src/connectors/bambora.rs +++ b/crates/hyperswitch_connectors/src/connectors/bambora.rs @@ -126,14 +126,12 @@ impl ConnectorCommon for Bambora { card_payment_method.insert( enums::PaymentMethodType::Credit, PaymentMethodDetails { - availability_status: enums::PaymentMethodStage::Live, supports_mandates: false, }, ); card_payment_method.insert( enums::PaymentMethodType::Debit, PaymentMethodDetails { - availability_status: enums::PaymentMethodStage::Live, supports_mandates: false, }, ); diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs index 4a71ba5cc5c5..d199c69eb64f 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs @@ -143,7 +143,6 @@ impl ConnectorCommon for Deutschebank { bank_debit_payment_method.insert( enums::PaymentMethodType::Sepa, PaymentMethodDetails { - availability_status: enums::PaymentMethodStage::Live, supports_mandates: true, }, ); diff --git a/crates/hyperswitch_connectors/src/connectors/zsl.rs b/crates/hyperswitch_connectors/src/connectors/zsl.rs index 0a833a1f84ad..7fcb77b92c1b 100644 --- a/crates/hyperswitch_connectors/src/connectors/zsl.rs +++ b/crates/hyperswitch_connectors/src/connectors/zsl.rs @@ -35,7 +35,7 @@ use hyperswitch_interfaces::{ configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, - types::{self, Response}, + types::{self, PaymentMethodDetails, PaymentMethodTypeMetadata, Response, SupportedPaymentMethods}, webhooks::{IncomingWebhook, IncomingWebhookRequestDetails}, }; use masking::{ExposeInterface, Secret}; @@ -97,6 +97,20 @@ impl ConnectorCommon for Zsl { connectors.zsl.base_url.as_ref() } + fn get_supported_payment_methods(&self) -> Option { + let mut supported_payment_methods = SupportedPaymentMethods::new(); + let mut bank_transfer_payment_method = PaymentMethodTypeMetadata::new(); + bank_transfer_payment_method.insert( + enums::PaymentMethodType::LocalBankTransfer, + PaymentMethodDetails { + supports_mandates: false, + }, + ); + supported_payment_methods.insert(enums::PaymentMethod::BankTransfer, + bank_transfer_payment_method); + Some(supported_payment_methods) + } + fn build_error_response( &self, res: Response, diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index 8238d744c699..7f260d649d3d 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -19,7 +19,7 @@ pub mod refunds_v2; use common_enums::{ enums::{CallConnectorAction, CaptureMethod, PaymentAction, PaymentMethodType}, - PaymentMethod, PaymentMethodStage, + PaymentMethod, }; use common_utils::{ errors::CustomResult, @@ -358,8 +358,7 @@ pub trait ConnectorValidation: ConnectorCommon { &self, payment_method_type: &Option, payment_method: &PaymentMethod, - is_mandate_payment: bool, - test_mode: bool, + is_mandate_payment: bool ) -> CustomResult<(), errors::ConnectorError> { match self.get_supported_payment_methods() { Some(supported_payment_methods) => { @@ -383,19 +382,12 @@ pub trait ConnectorValidation: ConnectorCommon { })?; // Validate the payment method type based on its availability and mandate support match ( - test_mode, is_mandate_payment, - payment_method_type_information.availability_status.clone(), payment_method_type_information.supports_mandates, ) { - // Test mode mandate payment - (true, true, PaymentMethodStage::Live | PaymentMethodStage::Beta, true) | + (true, true) | // Test mode payment - (true, false, PaymentMethodStage::Live | PaymentMethodStage::Beta, _) | - // Live mode mandate payment - (false, true, PaymentMethodStage::Live, true) | - // Live mode payment - (false, false, PaymentMethodStage::Live, _) => Ok(()), + (false, _) => Ok(()), // If none of the cases match, return an unsupported error _ => Err(errors::ConnectorError::NotSupported { message: format!("{:?}, {:?}", payment_method_type, payment_method), diff --git a/crates/hyperswitch_interfaces/src/types.rs b/crates/hyperswitch_interfaces/src/types.rs index 516f6be764f7..c0160fedd47f 100644 --- a/crates/hyperswitch_interfaces/src/types.rs +++ b/crates/hyperswitch_interfaces/src/types.rs @@ -1,7 +1,7 @@ //! Types interface use std::collections::HashMap; -use common_enums::{PaymentMethod, PaymentMethodStage, PaymentMethodType}; +use common_enums::{PaymentMethod, PaymentMethodType}; use hyperswitch_domain_models::{ router_data::AccessToken, router_flow_types::{ @@ -192,9 +192,6 @@ pub type DefendDisputeType = /// Represents details of a payment method. #[derive(Debug, Clone)] pub struct PaymentMethodDetails { - /// The availability status of the payment method based on the environment (e.g., live, beta, upcoming). - pub availability_status: PaymentMethodStage, - /// Indicates whether mandates are supported by this payment method. pub supports_mandates: bool, } diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs index 8831b5d19333..975fc06741cb 100644 --- a/crates/router/src/core/payments/flows/authorize_flow.rs +++ b/crates/router/src/core/payments/flows/authorize_flow.rs @@ -327,7 +327,6 @@ impl Feature for types::PaymentsAu &self.request.payment_method_type, &self.payment_method, is_customer_initiated_mandate_payment, - self.test_mode.unwrap_or(false), ) .to_payment_failed_response()?; diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index eb95a6ca683c..581a41f58ac0 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -3,6 +3,7 @@ use api_models::{connector_enums::Connector, feature_matrix}; use hyperswitch_domain_models::api::ApplicationResponse; use hyperswitch_interfaces::api::ConnectorCommon; use router_env::{instrument, tracing, Flow}; +use crate::settings; use strum::IntoEnumIterator; use crate::{ @@ -35,9 +36,11 @@ pub async fn fetch_connector_feature_matrix( #[cfg(feature = "v1")] pub async fn connector_feature_matrix( - _state: app::SessionState, + state: app::SessionState, req: payment_types::FeatureMatrixRequest, ) -> RouterResponse { + + let connector_list = req .connectors .unwrap_or_else(|| Connector::iter().collect()); @@ -56,12 +59,29 @@ pub async fn connector_feature_matrix( let payment_methods = supported_payment_method_types .into_iter() .map(|(payment_method_type, feature_metadata)| { + + let payment_method_type_config = + state.conf.pm_filters.0.get(&connector_name.to_string()) + .and_then(|selected_connector| + selected_connector.0 + .get(&settings::PaymentMethodFilterKey::PaymentMethodType( + payment_method_type, + ))); + + let supported_countries = payment_method_type_config.and_then(|config| { + config.country.clone() + }); + + let supported_currencies = payment_method_type_config.and_then(|config| { + config.currency.clone() + }); + feature_matrix::SupportedPaymentMethod { payment_method: payment_method_type, - availability_status: feature_metadata - .availability_status, supports_mandates: feature_metadata .supports_mandates, + supported_countries, + supported_currencies, } }) .collect(); diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs index d0863dd4dcc7..62217c05a607 100644 --- a/crates/router/src/services/connector_integration_interface.rs +++ b/crates/router/src/services/connector_integration_interface.rs @@ -354,20 +354,17 @@ impl ConnectorValidation for ConnectorEnum { payment_method_type: &Option, payment_method: &common_enums::PaymentMethod, is_mandate_payment: bool, - test_mode: bool, ) -> CustomResult<(), errors::ConnectorError> { match self { Self::Old(connector) => connector.validate_payment_method( payment_method_type, payment_method, - is_mandate_payment, - test_mode, + is_mandate_payment ), Self::New(connector) => connector.validate_payment_method( payment_method_type, payment_method, is_mandate_payment, - test_mode, ), } } From 87aae3862d27bc0937d607224222ac16ebf27b89 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 5 Dec 2024 14:15:01 +0530 Subject: [PATCH 07/40] refactor(router): add paymentMethod to validate_capture and resolve comments --- crates/api_models/src/feature_matrix.rs | 6 +- .../src/connectors/airwallex.rs | 1 + .../src/connectors/bambora.rs | 29 ++--- .../src/connectors/billwerk.rs | 1 + .../src/connectors/cashtocode.rs | 1 + .../src/connectors/coinbase.rs | 1 + .../src/connectors/deutschebank.rs | 22 ++-- .../src/connectors/digitalvirgo.rs | 1 + .../src/connectors/dlocal.rs | 1 + .../src/connectors/fiserv.rs | 1 + .../src/connectors/fiservemea.rs | 1 + .../src/connectors/fiuu.rs | 3 +- .../src/connectors/forte.rs | 1 + .../src/connectors/helcim.rs | 1 + .../src/connectors/multisafepay.rs | 1 + .../src/connectors/nexinets.rs | 1 + .../src/connectors/nexixpay.rs | 1 + .../src/connectors/novalnet.rs | 1 + .../src/connectors/payeezy.rs | 3 +- .../src/connectors/payu.rs | 1 + .../src/connectors/powertranz.rs | 1 + .../src/connectors/shift4.rs | 1 + .../src/connectors/square.rs | 1 + .../src/connectors/stax.rs | 1 + .../src/connectors/tsys.rs | 1 + .../src/connectors/worldline.rs | 1 + .../src/connectors/worldpay.rs | 1 + .../src/connectors/zsl.rs | 16 ++- crates/hyperswitch_interfaces/src/api.rs | 110 +++++++++++------- crates/hyperswitch_interfaces/src/types.rs | 8 +- crates/router/src/connector/adyen.rs | 1 + .../router/src/connector/authorizedotnet.rs | 1 + crates/router/src/connector/bamboraapac.rs | 1 + crates/router/src/connector/bankofamerica.rs | 1 + crates/router/src/connector/bluesnap.rs | 1 + crates/router/src/connector/boku.rs | 1 + crates/router/src/connector/braintree.rs | 1 + crates/router/src/connector/checkout.rs | 1 + crates/router/src/connector/cybersource.rs | 1 + crates/router/src/connector/datatrans.rs | 3 +- crates/router/src/connector/dummyconnector.rs | 1 + crates/router/src/connector/globalpay.rs | 1 + crates/router/src/connector/gocardless.rs | 1 + crates/router/src/connector/klarna.rs | 1 + crates/router/src/connector/nmi.rs | 1 + crates/router/src/connector/noon.rs | 1 + crates/router/src/connector/nuvei.rs | 1 + crates/router/src/connector/opayo.rs | 1 + crates/router/src/connector/paybox.rs | 1 + crates/router/src/connector/payme.rs | 1 + crates/router/src/connector/paypal.rs | 1 + crates/router/src/connector/placetopay.rs | 1 + crates/router/src/connector/rapyd.rs | 1 + crates/router/src/connector/stripe.rs | 1 + crates/router/src/connector/wellsfargo.rs | 1 + .../src/core/payments/flows/authorize_flow.rs | 10 +- crates/router/src/routes/feature_matrix.rs | 29 ++--- .../connector_integration_interface.rs | 26 ++--- 58 files changed, 184 insertions(+), 127 deletions(-) diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index eb2a011acda0..6011d3d5c65a 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -15,9 +15,11 @@ pub struct FeatureMatrixRequest { #[derive(Clone, Debug, Serialize)] pub struct SupportedPaymentMethod { pub payment_method: enums::PaymentMethodType, - pub supports_mandates: bool, + pub supports_mandate: bool, + pub supports_refund: bool, + pub supported_capture_methods: Vec, pub supported_countries: Option>, - pub supported_currencies: Option> + pub supported_currencies: Option>, } #[cfg(feature = "v1")] diff --git a/crates/hyperswitch_connectors/src/connectors/airwallex.rs b/crates/hyperswitch_connectors/src/connectors/airwallex.rs index 26bfcd1e07e3..1ea08c516b01 100644 --- a/crates/hyperswitch_connectors/src/connectors/airwallex.rs +++ b/crates/hyperswitch_connectors/src/connectors/airwallex.rs @@ -130,6 +130,7 @@ impl ConnectorValidation for Airwallex { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/bambora.rs b/crates/hyperswitch_connectors/src/connectors/bambora.rs index f547a6821b78..3f945a3da854 100644 --- a/crates/hyperswitch_connectors/src/connectors/bambora.rs +++ b/crates/hyperswitch_connectors/src/connectors/bambora.rs @@ -123,16 +123,25 @@ impl ConnectorCommon for Bambora { fn get_supported_payment_methods(&self) -> Option { let mut supported_payment_methods = SupportedPaymentMethods::new(); let mut card_payment_method = PaymentMethodTypeMetadata::new(); + let bambora_default_capture_methods = vec![ + enums::CaptureMethod::Automatic, + enums::CaptureMethod::Manual, + ]; + card_payment_method.insert( enums::PaymentMethodType::Credit, PaymentMethodDetails { - supports_mandates: false, + supports_mandate: false, + supports_refund: true, + supported_capture_methods: bambora_default_capture_methods.clone(), }, ); card_payment_method.insert( enums::PaymentMethodType::Debit, PaymentMethodDetails { - supports_mandates: false, + supports_mandate: false, + supports_refund: true, + supported_capture_methods: bambora_default_capture_methods.clone(), }, ); supported_payment_methods.insert(enums::PaymentMethod::Card, card_payment_method); @@ -164,21 +173,7 @@ impl ConnectorCommon for Bambora { } } -impl ConnectorValidation for Bambora { - fn validate_capture_method( - &self, - capture_method: Option, - _pmt: Option, - ) -> CustomResult<(), errors::ConnectorError> { - let capture_method = capture_method.unwrap_or_default(); - match capture_method { - enums::CaptureMethod::Automatic | enums::CaptureMethod::Manual => Ok(()), - enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err( - utils::construct_not_implemented_error_report(capture_method, self.id()), - ), - } - } -} +impl ConnectorValidation for Bambora {} impl ConnectorIntegration for Bambora diff --git a/crates/hyperswitch_connectors/src/connectors/billwerk.rs b/crates/hyperswitch_connectors/src/connectors/billwerk.rs index 251d2355f250..f398d1568688 100644 --- a/crates/hyperswitch_connectors/src/connectors/billwerk.rs +++ b/crates/hyperswitch_connectors/src/connectors/billwerk.rs @@ -154,6 +154,7 @@ impl ConnectorValidation for Billwerk { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &common_enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/cashtocode.rs b/crates/hyperswitch_connectors/src/connectors/cashtocode.rs index c72b63aebc05..cd70fdae153b 100644 --- a/crates/hyperswitch_connectors/src/connectors/cashtocode.rs +++ b/crates/hyperswitch_connectors/src/connectors/cashtocode.rs @@ -151,6 +151,7 @@ impl ConnectorValidation for Cashtocode { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/coinbase.rs b/crates/hyperswitch_connectors/src/connectors/coinbase.rs index 7b149952ca8d..9600bf1bd99c 100644 --- a/crates/hyperswitch_connectors/src/connectors/coinbase.rs +++ b/crates/hyperswitch_connectors/src/connectors/coinbase.rs @@ -136,6 +136,7 @@ impl ConnectorValidation for Coinbase { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs index d199c69eb64f..8d2b700b68b2 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs @@ -140,10 +140,16 @@ impl ConnectorCommon for Deutschebank { fn get_supported_payment_methods(&self) -> Option { let mut supported_payment_methods = SupportedPaymentMethods::new(); let mut bank_debit_payment_method = PaymentMethodTypeMetadata::new(); + let deutschebank_default_capture_methods = vec![ + enums::CaptureMethod::Automatic, + enums::CaptureMethod::Manual, + ]; bank_debit_payment_method.insert( enums::PaymentMethodType::Sepa, PaymentMethodDetails { - supports_mandates: true, + supports_mandate: true, + supports_refund: true, + supported_capture_methods: deutschebank_default_capture_methods.clone(), }, ); supported_payment_methods @@ -188,20 +194,6 @@ impl ConnectorCommon for Deutschebank { } impl ConnectorValidation for Deutschebank { - fn validate_capture_method( - &self, - capture_method: Option, - _pmt: Option, - ) -> CustomResult<(), errors::ConnectorError> { - let capture_method = capture_method.unwrap_or_default(); - match capture_method { - enums::CaptureMethod::Automatic | enums::CaptureMethod::Manual => Ok(()), - enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err( - utils::construct_not_implemented_error_report(capture_method, self.id()), - ), - } - } - fn validate_mandate_payment( &self, pm_type: Option, diff --git a/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs b/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs index af6486f008e8..bd88126c4c7c 100644 --- a/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs +++ b/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs @@ -166,6 +166,7 @@ impl ConnectorValidation for Digitalvirgo { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/dlocal.rs b/crates/hyperswitch_connectors/src/connectors/dlocal.rs index 78d3ad4f63e9..736e6752cb39 100644 --- a/crates/hyperswitch_connectors/src/connectors/dlocal.rs +++ b/crates/hyperswitch_connectors/src/connectors/dlocal.rs @@ -157,6 +157,7 @@ impl ConnectorValidation for Dlocal { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/fiserv.rs b/crates/hyperswitch_connectors/src/connectors/fiserv.rs index fc67cd2fde78..8b10e434e46a 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiserv.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiserv.rs @@ -182,6 +182,7 @@ impl ConnectorValidation for Fiserv { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/fiservemea.rs b/crates/hyperswitch_connectors/src/connectors/fiservemea.rs index a7eed07d30c4..808c1103559b 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiservemea.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiservemea.rs @@ -250,6 +250,7 @@ impl ConnectorValidation for Fiservemea { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/fiuu.rs b/crates/hyperswitch_connectors/src/connectors/fiuu.rs index 774a0ba75850..d6cb09d529bf 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiuu.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiuu.rs @@ -2,7 +2,7 @@ pub mod transformers; use std::collections::{HashMap, HashSet}; -use common_enums::{CaptureMethod, PaymentMethodType}; +use common_enums::{CaptureMethod, PaymentMethodType, PaymentMethod}; use common_utils::{ crypto::{self, GenerateDigest}, errors::{self as common_errors, CustomResult}, @@ -205,6 +205,7 @@ impl ConnectorValidation for Fiuu { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/forte.rs b/crates/hyperswitch_connectors/src/connectors/forte.rs index fd5c7792887c..a9798e0847cc 100644 --- a/crates/hyperswitch_connectors/src/connectors/forte.rs +++ b/crates/hyperswitch_connectors/src/connectors/forte.rs @@ -170,6 +170,7 @@ impl ConnectorValidation for Forte { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/helcim.rs b/crates/hyperswitch_connectors/src/connectors/helcim.rs index fcb9c77e104d..5d186f28307f 100644 --- a/crates/hyperswitch_connectors/src/connectors/helcim.rs +++ b/crates/hyperswitch_connectors/src/connectors/helcim.rs @@ -173,6 +173,7 @@ impl ConnectorValidation for Helcim { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/multisafepay.rs b/crates/hyperswitch_connectors/src/connectors/multisafepay.rs index 7d212bd1f9d6..5dc0c74d750c 100644 --- a/crates/hyperswitch_connectors/src/connectors/multisafepay.rs +++ b/crates/hyperswitch_connectors/src/connectors/multisafepay.rs @@ -130,6 +130,7 @@ impl ConnectorValidation for Multisafepay { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/nexinets.rs b/crates/hyperswitch_connectors/src/connectors/nexinets.rs index 94b24bbe867b..41ab75f7a3b9 100644 --- a/crates/hyperswitch_connectors/src/connectors/nexinets.rs +++ b/crates/hyperswitch_connectors/src/connectors/nexinets.rs @@ -167,6 +167,7 @@ impl ConnectorValidation for Nexinets { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/nexixpay.rs b/crates/hyperswitch_connectors/src/connectors/nexixpay.rs index 76085324167e..23179760605f 100644 --- a/crates/hyperswitch_connectors/src/connectors/nexixpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/nexixpay.rs @@ -202,6 +202,7 @@ impl ConnectorValidation for Nexixpay { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/novalnet.rs b/crates/hyperswitch_connectors/src/connectors/novalnet.rs index 8331e229acb9..5cb479bd0e87 100644 --- a/crates/hyperswitch_connectors/src/connectors/novalnet.rs +++ b/crates/hyperswitch_connectors/src/connectors/novalnet.rs @@ -161,6 +161,7 @@ impl ConnectorValidation for Novalnet { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/payeezy.rs b/crates/hyperswitch_connectors/src/connectors/payeezy.rs index cb22d0cb7b03..63e3f561a948 100644 --- a/crates/hyperswitch_connectors/src/connectors/payeezy.rs +++ b/crates/hyperswitch_connectors/src/connectors/payeezy.rs @@ -2,7 +2,7 @@ pub mod transformers; use api_models::webhooks::IncomingWebhookEvent; use base64::Engine; -use common_enums::{CaptureMethod, PaymentMethodType}; +use common_enums::{CaptureMethod, PaymentMethodType, PaymentMethod}; use common_utils::{ errors::CustomResult, ext_traits::ByteSliceExt, @@ -154,6 +154,7 @@ impl ConnectorValidation for Payeezy { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/payu.rs b/crates/hyperswitch_connectors/src/connectors/payu.rs index ad2479f19e4c..9cf17cd99b16 100644 --- a/crates/hyperswitch_connectors/src/connectors/payu.rs +++ b/crates/hyperswitch_connectors/src/connectors/payu.rs @@ -142,6 +142,7 @@ impl ConnectorValidation for Payu { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/powertranz.rs b/crates/hyperswitch_connectors/src/connectors/powertranz.rs index a437d419bc83..7262ca87bff6 100644 --- a/crates/hyperswitch_connectors/src/connectors/powertranz.rs +++ b/crates/hyperswitch_connectors/src/connectors/powertranz.rs @@ -148,6 +148,7 @@ impl ConnectorValidation for Powertranz { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/shift4.rs b/crates/hyperswitch_connectors/src/connectors/shift4.rs index 283709798d00..5d554ab6f6eb 100644 --- a/crates/hyperswitch_connectors/src/connectors/shift4.rs +++ b/crates/hyperswitch_connectors/src/connectors/shift4.rs @@ -141,6 +141,7 @@ impl ConnectorValidation for Shift4 { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/square.rs b/crates/hyperswitch_connectors/src/connectors/square.rs index bf2cd4e1aceb..0dc691393a04 100644 --- a/crates/hyperswitch_connectors/src/connectors/square.rs +++ b/crates/hyperswitch_connectors/src/connectors/square.rs @@ -159,6 +159,7 @@ impl ConnectorValidation for Square { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/stax.rs b/crates/hyperswitch_connectors/src/connectors/stax.rs index 8ca847327a41..1ef5ab0bab66 100644 --- a/crates/hyperswitch_connectors/src/connectors/stax.rs +++ b/crates/hyperswitch_connectors/src/connectors/stax.rs @@ -140,6 +140,7 @@ impl ConnectorValidation for Stax { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/tsys.rs b/crates/hyperswitch_connectors/src/connectors/tsys.rs index 25b47981def6..d621100bdf6d 100644 --- a/crates/hyperswitch_connectors/src/connectors/tsys.rs +++ b/crates/hyperswitch_connectors/src/connectors/tsys.rs @@ -105,6 +105,7 @@ impl ConnectorValidation for Tsys { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/worldline.rs b/crates/hyperswitch_connectors/src/connectors/worldline.rs index c5a8466175c1..19fb8654ba7b 100644 --- a/crates/hyperswitch_connectors/src/connectors/worldline.rs +++ b/crates/hyperswitch_connectors/src/connectors/worldline.rs @@ -173,6 +173,7 @@ impl ConnectorValidation for Worldline { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/worldpay.rs b/crates/hyperswitch_connectors/src/connectors/worldpay.rs index fd67bb60128a..011f3d4939c6 100644 --- a/crates/hyperswitch_connectors/src/connectors/worldpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/worldpay.rs @@ -164,6 +164,7 @@ impl ConnectorValidation for Worldpay { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/zsl.rs b/crates/hyperswitch_connectors/src/connectors/zsl.rs index 7fcb77b92c1b..96d20962d504 100644 --- a/crates/hyperswitch_connectors/src/connectors/zsl.rs +++ b/crates/hyperswitch_connectors/src/connectors/zsl.rs @@ -35,7 +35,9 @@ use hyperswitch_interfaces::{ configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, - types::{self, PaymentMethodDetails, PaymentMethodTypeMetadata, Response, SupportedPaymentMethods}, + types::{ + self, PaymentMethodDetails, PaymentMethodTypeMetadata, Response, SupportedPaymentMethods, + }, webhooks::{IncomingWebhook, IncomingWebhookRequestDetails}, }; use masking::{ExposeInterface, Secret}; @@ -100,14 +102,19 @@ impl ConnectorCommon for Zsl { fn get_supported_payment_methods(&self) -> Option { let mut supported_payment_methods = SupportedPaymentMethods::new(); let mut bank_transfer_payment_method = PaymentMethodTypeMetadata::new(); + let zsl_default_capture_methods = vec![enums::CaptureMethod::Automatic]; bank_transfer_payment_method.insert( enums::PaymentMethodType::LocalBankTransfer, PaymentMethodDetails { - supports_mandates: false, + supports_mandate: false, + supports_refund: false, + supported_capture_methods: zsl_default_capture_methods.clone(), }, ); - supported_payment_methods.insert(enums::PaymentMethod::BankTransfer, - bank_transfer_payment_method); + supported_payment_methods.insert( + enums::PaymentMethod::BankTransfer, + bank_transfer_payment_method, + ); Some(supported_payment_methods) } @@ -139,6 +146,7 @@ impl ConnectorValidation for Zsl { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index 7f260d649d3d..e75a325444d9 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -358,66 +358,62 @@ pub trait ConnectorValidation: ConnectorCommon { &self, payment_method_type: &Option, payment_method: &PaymentMethod, - is_mandate_payment: bool ) -> CustomResult<(), errors::ConnectorError> { - match self.get_supported_payment_methods() { - Some(supported_payment_methods) => { - // Check if the payment method exists - let payment_method_information = supported_payment_methods - .get(payment_method) - .ok_or_else(|| errors::ConnectorError::NotSupported { - message: payment_method.to_string(), - connector: self.id(), - })?; - - match payment_method_type { - Some(pmt) => { - // Check if the payment method type exists - let payment_method_type_information = - payment_method_information.get(pmt).ok_or_else(|| { - errors::ConnectorError::NotSupported { - message: format!("{:?}, {:?}", pmt, payment_method), - connector: self.id(), - } - })?; - // Validate the payment method type based on its availability and mandate support - match ( - is_mandate_payment, - payment_method_type_information.supports_mandates, - ) { - (true, true) | - // Test mode payment - (false, _) => Ok(()), - // If none of the cases match, return an unsupported error - _ => Err(errors::ConnectorError::NotSupported { - message: format!("{:?}, {:?}", payment_method_type, payment_method), - connector: self.id(), - }.into()), - } - } - None => Ok(()), - } - } - None => Ok(()), + if let Some(supported_payment_methods) = self.get_supported_payment_methods() { + get_connector_payment_method_type_info( + supported_payment_methods, + payment_method, + payment_method_type, + self.id(), + )?; } + Ok(()) } /// fn validate_capture_method fn validate_capture_method( &self, capture_method: Option, - _pmt: Option, + payment_method: &PaymentMethod, + pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); - match capture_method { - CaptureMethod::Automatic => Ok(()), - CaptureMethod::Manual | CaptureMethod::ManualMultiple | CaptureMethod::Scheduled => { + if let Some(supported_payment_methods) = self.get_supported_payment_methods() { + let connector_payment_method_type_info = get_connector_payment_method_type_info( + supported_payment_methods, + payment_method, + &pmt, + self.id(), + )?; + + if connector_payment_method_type_info + .map(|payment_method_type_info| { + payment_method_type_info + .supported_capture_methods + .contains(&capture_method) + }) + .unwrap_or(true) + // when payment method type is None + { + Ok(()) + } else { Err(errors::ConnectorError::NotSupported { message: capture_method.to_string(), connector: self.id(), } .into()) } + } else { + match capture_method { + CaptureMethod::Automatic => Ok(()), + CaptureMethod::Manual + | CaptureMethod::ManualMultiple + | CaptureMethod::Scheduled => Err(errors::ConnectorError::NotSupported { + message: capture_method.to_string(), + connector: self.id(), + } + .into()), + } } } @@ -478,3 +474,29 @@ pub trait ConnectorRedirectResponse { /// Empty trait for when payouts feature is disabled #[cfg(not(feature = "payouts"))] pub trait Payouts {} + +fn get_connector_payment_method_type_info( + supported_payment_method: SupportedPaymentMethods, + payment_method: &PaymentMethod, + payment_method_type: &Option, + connector: &'static str, +) -> CustomResult, errors::ConnectorError> { + let payment_method_details = supported_payment_method + .get(payment_method) + .ok_or_else(|| errors::ConnectorError::NotSupported { + message: payment_method.to_string(), + connector: connector, + })?; + + payment_method_type + .map(|pmt| { + payment_method_details.get(&pmt).cloned().ok_or_else(|| { + errors::ConnectorError::NotSupported { + message: format!("{} {}", payment_method.to_string(), pmt), + connector: connector, + } + .into() + }) + }) + .transpose() +} diff --git a/crates/hyperswitch_interfaces/src/types.rs b/crates/hyperswitch_interfaces/src/types.rs index c0160fedd47f..a50f1b53133f 100644 --- a/crates/hyperswitch_interfaces/src/types.rs +++ b/crates/hyperswitch_interfaces/src/types.rs @@ -1,7 +1,7 @@ //! Types interface use std::collections::HashMap; -use common_enums::{PaymentMethod, PaymentMethodType}; +use common_enums::{CaptureMethod, PaymentMethod, PaymentMethodType}; use hyperswitch_domain_models::{ router_data::AccessToken, router_flow_types::{ @@ -193,7 +193,11 @@ pub type DefendDisputeType = #[derive(Debug, Clone)] pub struct PaymentMethodDetails { /// Indicates whether mandates are supported by this payment method. - pub supports_mandates: bool, + pub supports_mandate: bool, + /// Indicates whether refund is supported by this payment method. + pub supports_refund: bool, + /// Indicates whether manual capture supported is supported by this payment method. + pub supported_capture_methods: Vec, } /// list of payment method types and metadata related to them diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs index 7b491674e92a..4a52568a6dc0 100644 --- a/crates/router/src/connector/adyen.rs +++ b/crates/router/src/connector/adyen.rs @@ -100,6 +100,7 @@ impl ConnectorValidation for Adyen { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/authorizedotnet.rs b/crates/router/src/connector/authorizedotnet.rs index b48643e76e88..b9d1a5fcd700 100644 --- a/crates/router/src/connector/authorizedotnet.rs +++ b/crates/router/src/connector/authorizedotnet.rs @@ -69,6 +69,7 @@ impl ConnectorValidation for Authorizedotnet { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/bamboraapac.rs b/crates/router/src/connector/bamboraapac.rs index 82ed134a9756..2e2ec22c396b 100644 --- a/crates/router/src/connector/bamboraapac.rs +++ b/crates/router/src/connector/bamboraapac.rs @@ -82,6 +82,7 @@ impl ConnectorValidation for Bamboraapac { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/bankofamerica.rs b/crates/router/src/connector/bankofamerica.rs index daec033f6f36..38b6783596ef 100644 --- a/crates/router/src/connector/bankofamerica.rs +++ b/crates/router/src/connector/bankofamerica.rs @@ -281,6 +281,7 @@ impl ConnectorValidation for Bankofamerica { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rs index 468f68dc340c..dfb7581795fd 100644 --- a/crates/router/src/connector/bluesnap.rs +++ b/crates/router/src/connector/bluesnap.rs @@ -183,6 +183,7 @@ impl ConnectorValidation for Bluesnap { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/boku.rs b/crates/router/src/connector/boku.rs index a132094693a1..d18705da9d82 100644 --- a/crates/router/src/connector/boku.rs +++ b/crates/router/src/connector/boku.rs @@ -161,6 +161,7 @@ impl ConnectorValidation for Boku { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/braintree.rs b/crates/router/src/connector/braintree.rs index 85b310397b26..fd8a2318d7a4 100644 --- a/crates/router/src/connector/braintree.rs +++ b/crates/router/src/connector/braintree.rs @@ -176,6 +176,7 @@ impl ConnectorValidation for Braintree { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/checkout.rs b/crates/router/src/connector/checkout.rs index 3fca0b86aeba..f27d19f8f64a 100644 --- a/crates/router/src/connector/checkout.rs +++ b/crates/router/src/connector/checkout.rs @@ -157,6 +157,7 @@ impl ConnectorValidation for Checkout { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/cybersource.rs b/crates/router/src/connector/cybersource.rs index 806cf67b2da2..31571002302a 100644 --- a/crates/router/src/connector/cybersource.rs +++ b/crates/router/src/connector/cybersource.rs @@ -239,6 +239,7 @@ impl ConnectorValidation for Cybersource { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/datatrans.rs b/crates/router/src/connector/datatrans.rs index 9c7772c5b3ef..c6c150446b61 100644 --- a/crates/router/src/connector/datatrans.rs +++ b/crates/router/src/connector/datatrans.rs @@ -1,5 +1,5 @@ pub mod transformers; -use api_models::enums::{CaptureMethod, PaymentMethodType}; +use api_models::enums::{CaptureMethod, PaymentMethodType, PaymentMethod}; use base64::Engine; use common_utils::types::{AmountConvertor, MinorUnit, MinorUnitForConnector}; use error_stack::{report, ResultExt}; @@ -140,6 +140,7 @@ impl ConnectorValidation for Datatrans { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/dummyconnector.rs b/crates/router/src/connector/dummyconnector.rs index 13a05578238b..60e1e057b575 100644 --- a/crates/router/src/connector/dummyconnector.rs +++ b/crates/router/src/connector/dummyconnector.rs @@ -127,6 +127,7 @@ impl ConnectorValidation for DummyConnector { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/globalpay.rs b/crates/router/src/connector/globalpay.rs index 2707ef4b6f2e..74d85b2cc901 100644 --- a/crates/router/src/connector/globalpay.rs +++ b/crates/router/src/connector/globalpay.rs @@ -130,6 +130,7 @@ impl ConnectorValidation for Globalpay { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/gocardless.rs b/crates/router/src/connector/gocardless.rs index 281a1ea5c9b8..379669c8be01 100644 --- a/crates/router/src/connector/gocardless.rs +++ b/crates/router/src/connector/gocardless.rs @@ -331,6 +331,7 @@ impl ConnectorValidation for Gocardless { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/klarna.rs b/crates/router/src/connector/klarna.rs index 6aa9b62ed6ad..f81246dbe211 100644 --- a/crates/router/src/connector/klarna.rs +++ b/crates/router/src/connector/klarna.rs @@ -113,6 +113,7 @@ impl ConnectorValidation for Klarna { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/nmi.rs b/crates/router/src/connector/nmi.rs index 76665c2700c2..b32b5ed22274 100644 --- a/crates/router/src/connector/nmi.rs +++ b/crates/router/src/connector/nmi.rs @@ -111,6 +111,7 @@ impl ConnectorValidation for Nmi { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rs index b2b47e5fd3a3..daf2004f5f0c 100644 --- a/crates/router/src/connector/noon.rs +++ b/crates/router/src/connector/noon.rs @@ -179,6 +179,7 @@ impl ConnectorValidation for Noon { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/nuvei.rs b/crates/router/src/connector/nuvei.rs index 8108413b4eea..97eb7b6dcee9 100644 --- a/crates/router/src/connector/nuvei.rs +++ b/crates/router/src/connector/nuvei.rs @@ -76,6 +76,7 @@ impl ConnectorValidation for Nuvei { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/opayo.rs b/crates/router/src/connector/opayo.rs index 3e7edba2128d..ee498507d98a 100644 --- a/crates/router/src/connector/opayo.rs +++ b/crates/router/src/connector/opayo.rs @@ -134,6 +134,7 @@ impl ConnectorValidation for Opayo { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/paybox.rs b/crates/router/src/connector/paybox.rs index dd54e185dac3..06ed70da7b94 100644 --- a/crates/router/src/connector/paybox.rs +++ b/crates/router/src/connector/paybox.rs @@ -148,6 +148,7 @@ impl ConnectorValidation for Paybox { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/payme.rs b/crates/router/src/connector/payme.rs index 6bf26b4f60bd..f391a7f6bb7f 100644 --- a/crates/router/src/connector/payme.rs +++ b/crates/router/src/connector/payme.rs @@ -141,6 +141,7 @@ impl ConnectorValidation for Payme { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs index 48a35c78cc25..3efbb3d587a0 100644 --- a/crates/router/src/connector/paypal.rs +++ b/crates/router/src/connector/paypal.rs @@ -323,6 +323,7 @@ impl ConnectorValidation for Paypal { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/placetopay.rs b/crates/router/src/connector/placetopay.rs index 5eb93e6d5318..f2df1b511863 100644 --- a/crates/router/src/connector/placetopay.rs +++ b/crates/router/src/connector/placetopay.rs @@ -126,6 +126,7 @@ impl ConnectorValidation for Placetopay { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/rapyd.rs b/crates/router/src/connector/rapyd.rs index 196eb4ce73dd..951575d7fcaf 100644 --- a/crates/router/src/connector/rapyd.rs +++ b/crates/router/src/connector/rapyd.rs @@ -133,6 +133,7 @@ impl ConnectorValidation for Rapyd { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rs index 1125c0af6dc8..ce971998f557 100644 --- a/crates/router/src/connector/stripe.rs +++ b/crates/router/src/connector/stripe.rs @@ -136,6 +136,7 @@ impl ConnectorValidation for Stripe { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/wellsfargo.rs b/crates/router/src/connector/wellsfargo.rs index a63007f0a273..02500685e5b8 100644 --- a/crates/router/src/connector/wellsfargo.rs +++ b/crates/router/src/connector/wellsfargo.rs @@ -248,6 +248,7 @@ impl ConnectorValidation for Wellsfargo { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs index 975fc06741cb..32ac93dc071f 100644 --- a/crates/router/src/core/payments/flows/authorize_flow.rs +++ b/crates/router/src/core/payments/flows/authorize_flow.rs @@ -313,24 +313,22 @@ impl Feature for types::PaymentsAu .connector .validate_capture_method( self.request.capture_method, + &self.payment_method, self.request.payment_method_type, ) .to_payment_failed_response()?; - let is_customer_initiated_mandate_payment = crate::connector::utils::PaymentsAuthorizeRequestData::is_customer_initiated_mandate_payment( - &self.request, - ); - connector .connector .validate_payment_method( &self.request.payment_method_type, &self.payment_method, - is_customer_initiated_mandate_payment, ) .to_payment_failed_response()?; - if is_customer_initiated_mandate_payment { + if crate::connector::utils::PaymentsAuthorizeRequestData::is_customer_initiated_mandate_payment( + &self.request, + ) { connector .connector .validate_mandate_payment( diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index 581a41f58ac0..a19fb160fc15 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -3,13 +3,13 @@ use api_models::{connector_enums::Connector, feature_matrix}; use hyperswitch_domain_models::api::ApplicationResponse; use hyperswitch_interfaces::api::ConnectorCommon; use router_env::{instrument, tracing, Flow}; -use crate::settings; use strum::IntoEnumIterator; use crate::{ self as app, core::{api_locking::LockAction, errors::RouterResponse}, services::{api, authentication as auth}, + settings, types::api::{self as api_types, payments as payment_types}, }; @@ -39,8 +39,6 @@ pub async fn connector_feature_matrix( state: app::SessionState, req: payment_types::FeatureMatrixRequest, ) -> RouterResponse { - - let connector_list = req .connectors .unwrap_or_else(|| Connector::iter().collect()); @@ -60,26 +58,15 @@ pub async fn connector_feature_matrix( .into_iter() .map(|(payment_method_type, feature_metadata)| { - let payment_method_type_config = - state.conf.pm_filters.0.get(&connector_name.to_string()) - .and_then(|selected_connector| - selected_connector.0 - .get(&settings::PaymentMethodFilterKey::PaymentMethodType( - payment_method_type, - ))); - - let supported_countries = payment_method_type_config.and_then(|config| { - config.country.clone() - }); - - let supported_currencies = payment_method_type_config.and_then(|config| { - config.currency.clone() - }); - + let payment_method_type_config = state.conf.pm_filters.0.get(&connector_name.to_string()) + .and_then(|selected_connector|selected_connector.0.get(&settings::PaymentMethodFilterKey::PaymentMethodType(payment_method_type))); + let supported_countries = payment_method_type_config.and_then(|config| {config.country.clone()}); + let supported_currencies = payment_method_type_config.and_then(|config| { config.currency.clone()}); feature_matrix::SupportedPaymentMethod { payment_method: payment_method_type, - supports_mandates: feature_metadata - .supports_mandates, + supports_mandate: feature_metadata.supports_mandate, + supports_refund: feature_metadata.supports_refund, + supported_capture_methods: feature_metadata.supported_capture_methods, supported_countries, supported_currencies, } diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs index 62217c05a607..a323cce17b89 100644 --- a/crates/router/src/services/connector_integration_interface.rs +++ b/crates/router/src/services/connector_integration_interface.rs @@ -353,30 +353,30 @@ impl ConnectorValidation for ConnectorEnum { &self, payment_method_type: &Option, payment_method: &common_enums::PaymentMethod, - is_mandate_payment: bool, ) -> CustomResult<(), errors::ConnectorError> { match self { - Self::Old(connector) => connector.validate_payment_method( - payment_method_type, - payment_method, - is_mandate_payment - ), - Self::New(connector) => connector.validate_payment_method( - payment_method_type, - payment_method, - is_mandate_payment, - ), + Self::Old(connector) => { + connector.validate_payment_method(payment_method_type, payment_method) + } + Self::New(connector) => { + connector.validate_payment_method(payment_method_type, payment_method) + } } } fn validate_capture_method( &self, capture_method: Option, + payment_method: &common_enums::PaymentMethod, pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { match self { - Self::Old(connector) => connector.validate_capture_method(capture_method, pmt), - Self::New(connector) => connector.validate_capture_method(capture_method, pmt), + Self::Old(connector) => { + connector.validate_capture_method(capture_method, payment_method, pmt) + } + Self::New(connector) => { + connector.validate_capture_method(capture_method, payment_method, pmt) + } } } From 169285da9203823b9e73c2cc5031eaf112f56ec3 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 5 Dec 2024 14:31:25 +0530 Subject: [PATCH 08/40] feat(configs): add bambora country and currency --- config/config.example.toml | 4 ++++ config/deployments/integration_test.toml | 4 ++++ config/deployments/production.toml | 4 ++++ config/deployments/sandbox.toml | 4 ++++ config/development.toml | 4 ++++ config/docker_compose.toml | 3 +++ loadtest/config/development.toml | 4 ++++ 7 files changed, 27 insertions(+) diff --git a/config/config.example.toml b/config/config.example.toml index 289087f4a333..01a5fcb58289 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -509,6 +509,10 @@ seicomart = { country = "JP", currency = "JPY" } pay_easy = { country = "JP", currency = "JPY" } boleto = { country = "BR", currency = "BRL" } +[pm_filters.bambora] +credit = { country = "US,CA", currency = "USD,CAD" } +debit = { country = "US,CA", currency = "USD,CAD" } + [pm_filters.volt] open_banking_uk = { country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL" } diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml index 1c7a40ea5398..d69f94f30d0d 100644 --- a/config/deployments/integration_test.toml +++ b/config/deployments/integration_test.toml @@ -261,6 +261,10 @@ we_chat_pay = { country = "AU,NZ,CN,JP,HK,SG,ES,GB,SE,NO,AT,NL,DE,CY,CH,BE,FR,DK google_pay.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" paypal.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" +[pm_filters.bambora] +credit = { country = "US,CA", currency = "USD,CAD" } +debit = { country = "US,CA", currency = "USD,CAD" } + [pm_filters.bankofamerica] credit = { currency = "USD" } debit = { currency = "USD" } diff --git a/config/deployments/production.toml b/config/deployments/production.toml index 73e5794f0420..9737364b136f 100644 --- a/config/deployments/production.toml +++ b/config/deployments/production.toml @@ -273,6 +273,10 @@ we_chat_pay = { country = "AU,NZ,CN,JP,HK,SG,ES,GB,SE,NO,AT,NL,DE,CY,CH,BE,FR,DK google_pay.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" paypal.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" +[pm_filters.bambora] +credit = { country = "US,CA", currency = "USD,CAD" } +debit = { country = "US,CA", currency = "USD,CAD" } + [pm_filters.bankofamerica] credit = { currency = "USD" } debit = { currency = "USD" } diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml index 98e1e7e00d9c..f3fa084bb465 100644 --- a/config/deployments/sandbox.toml +++ b/config/deployments/sandbox.toml @@ -277,6 +277,10 @@ pix = { country = "BR", currency = "BRL" } google_pay.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" paypal.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" +[pm_filters.bambora] +credit = { country = "US,CA", currency = "USD,CAD" } +debit = { country = "US,CA", currency = "USD,CAD" } + [pm_filters.bankofamerica] credit = { currency = "USD" } debit = { currency = "USD" } diff --git a/config/development.toml b/config/development.toml index b6638fe1d476..be6d358867da 100644 --- a/config/development.toml +++ b/config/development.toml @@ -449,6 +449,10 @@ pay_easy = { country = "JP", currency = "JPY" } pix = { country = "BR", currency = "BRL" } boleto = { country = "BR", currency = "BRL" } +[pm_filters.bambora] +credit = { country = "US,CA", currency = "USD,CAD" } +debit = { country = "US,CA", currency = "USD,CAD" } + [pm_filters.bankofamerica] credit = { currency = "USD" } debit = { currency = "USD" } diff --git a/config/docker_compose.toml b/config/docker_compose.toml index 7adeee8a3763..fdcf78a4d34c 100644 --- a/config/docker_compose.toml +++ b/config/docker_compose.toml @@ -420,6 +420,9 @@ vipps = { country = "NO", currency = "NOK" } walley = { country = "SE,NO,DK,FI", currency = "DKK,EUR,NOK,SEK" } we_chat_pay = { country = "AU,NZ,CN,JP,HK,SG,ES,GB,SE,NO,AT,NL,DE,CY,CH,BE,FR,DK,LI,MT,SI,GR,PT,IT,CA,US", currency = "AUD,CAD,CNY,EUR,GBP,HKD,JPY,NZD,SGD,USD,CNY" } +[pm_filters.bambora] +credit = { country = "US,CA", currency = "USD,CAD" } +debit = { country = "US,CA", currency = "USD,CAD" } [pm_filters.volt] open_banking_uk = { country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL" } diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml index 934b072f14a3..845e81dfceb7 100644 --- a/loadtest/config/development.toml +++ b/loadtest/config/development.toml @@ -270,6 +270,10 @@ paypal = { country = "AU,NZ,CN,JP,HK,MY,TH,KR,PH,ID,AE,KW,BR,ES,GB,SE,NO,SK,AT,N klarna = { country = "AU,AT,BE,CA,CZ,DK,FI,FR,DE,GR,IE,IT,NO,PL,PT,RO,ES,SE,CH,NL,GB,US", currency = "AUD,EUR,CAD,CZK,DKK,NOK,PLN,RON,SEK,CHF,GBP,USD"} ideal = { country = "NL", currency = "EUR" } +[pm_filters.bambora] +credit = { country = "US,CA", currency = "USD,CAD" } +debit = { country = "US,CA", currency = "USD,CAD" } + [pm_filters.zen] credit = { not_available_flows = { capture_method = "manual" } } debit = { not_available_flows = { capture_method = "manual" } } From 9ba4b17422b832a7c63ffa3f0dab94b6f293e56d Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 5 Dec 2024 16:57:55 +0530 Subject: [PATCH 09/40] feat(cypress): add a test case --- crates/api_models/src/feature_matrix.rs | 4 +--- crates/router/src/routes/feature_matrix.rs | 7 +++++-- .../e2e/PaymentTest/00000-CoreFlows.cy.js | 17 +++++++++++++++++ cypress-tests/cypress/support/commands.js | 15 +++++++++++++++ 4 files changed, 38 insertions(+), 5 deletions(-) diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index 6011d3d5c65a..14d78839f460 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -1,8 +1,6 @@ use std::collections::HashSet; - use serde::{Deserialize, Serialize}; use utoipa::ToSchema; - use crate::enums; #[derive(Default, Debug, Deserialize, Serialize, Clone, ToSchema)] @@ -36,7 +34,7 @@ pub struct FeatureMatrixResponse { pub payment_method_types: Vec, } -#[derive(Clone, Debug, serde::Serialize, ToSchema)] +#[derive(Clone, Debug, Serialize, ToSchema)] pub struct FeatureMatrixListResponse { /// The number of connectors included in the list pub size: usize, diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index a19fb160fc15..72bf77cc4a5c 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -18,10 +18,13 @@ use crate::{ pub async fn fetch_connector_feature_matrix( state: web::Data, req: HttpRequest, - json_payload: web::Json, + json_payload: Option>, ) -> impl Responder { let flow: Flow = Flow::FeatureMatrix; - let payload = json_payload.into_inner(); + let payload = json_payload.map(|json_request| + json_request.into_inner() + ).unwrap_or(payment_types::FeatureMatrixRequest{connectors: None}); + Box::pin(api::server_wrap( flow, state, diff --git a/cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js index c785c1e68273..79e1c88f4e08 100644 --- a/cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js +++ b/cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js @@ -184,4 +184,21 @@ describe("Core flows", () => { cy.merchantDeleteCall(globalState); }); }); + + context("List Connector Feature Matrix", () => { + before("seed global state", () => { + cy.task("getGlobalState").then((state) => { + globalState = new State(state); + }); + }); + + after("flush global state", () => { + cy.task("setGlobalState", globalState.data); + }); + + it("List connector feature matrix call", () => { + cy.ListConnectorsFeatureMatrixCall(globalState); + }); + + }); }); diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index 6204c86f44a0..64eb0570d263 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -110,6 +110,21 @@ Cypress.Commands.add("merchantDeleteCall", (globalState) => { }); }); + +Cypress.Commands.add("ListConnectorsFeatureMatrixCall", (globalState) => { + cy.request({ + method: "GET", + url: `${globalState.get("baseUrl")}/feature_matrix`, + headers: { + Accept: "application/json", + } + }).then((response) => { + logRequestId(response.headers["x-request-id"]); + + expect(response.body).to.have.property("data").and.not.empty; + }); +}); + Cypress.Commands.add("merchantListCall", (globalState) => { const organization_id = globalState.get("organizationId"); From 3298399f7af88b58b3076cd72faa22139532c1b3 Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 12:13:14 +0000 Subject: [PATCH 10/40] chore(cypress): run formatter and address lints --- cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js | 1 - cypress-tests/cypress/support/commands.js | 3 +-- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js b/cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js index 79e1c88f4e08..a0e2ad643e89 100644 --- a/cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js +++ b/cypress-tests/cypress/e2e/PaymentTest/00000-CoreFlows.cy.js @@ -199,6 +199,5 @@ describe("Core flows", () => { it("List connector feature matrix call", () => { cy.ListConnectorsFeatureMatrixCall(globalState); }); - }); }); diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index 4213aaa5584e..8aea12133bc1 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -111,14 +111,13 @@ Cypress.Commands.add("merchantDeleteCall", (globalState) => { }); }); - Cypress.Commands.add("ListConnectorsFeatureMatrixCall", (globalState) => { cy.request({ method: "GET", url: `${globalState.get("baseUrl")}/feature_matrix`, headers: { Accept: "application/json", - } + }, }).then((response) => { logRequestId(response.headers["x-request-id"]); From f66bfb3400d38fbbbb41747abc100069a478746c Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Thu, 5 Dec 2024 12:38:17 +0000 Subject: [PATCH 11/40] chore: run formatter --- crates/api_models/src/feature_matrix.rs | 2 ++ crates/hyperswitch_connectors/src/connectors/fiuu.rs | 2 +- crates/hyperswitch_connectors/src/connectors/payeezy.rs | 2 +- crates/router/src/connector/datatrans.rs | 2 +- crates/router/src/routes/feature_matrix.rs | 6 +++--- .../router/src/services/connector_integration_interface.rs | 3 ++- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index 14d78839f460..03e544d16548 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -1,6 +1,8 @@ use std::collections::HashSet; + use serde::{Deserialize, Serialize}; use utoipa::ToSchema; + use crate::enums; #[derive(Default, Debug, Deserialize, Serialize, Clone, ToSchema)] diff --git a/crates/hyperswitch_connectors/src/connectors/fiuu.rs b/crates/hyperswitch_connectors/src/connectors/fiuu.rs index d6cb09d529bf..1dd7bf3511b0 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiuu.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiuu.rs @@ -2,7 +2,7 @@ pub mod transformers; use std::collections::{HashMap, HashSet}; -use common_enums::{CaptureMethod, PaymentMethodType, PaymentMethod}; +use common_enums::{CaptureMethod, PaymentMethod, PaymentMethodType}; use common_utils::{ crypto::{self, GenerateDigest}, errors::{self as common_errors, CustomResult}, diff --git a/crates/hyperswitch_connectors/src/connectors/payeezy.rs b/crates/hyperswitch_connectors/src/connectors/payeezy.rs index 63e3f561a948..c3cef40f5001 100644 --- a/crates/hyperswitch_connectors/src/connectors/payeezy.rs +++ b/crates/hyperswitch_connectors/src/connectors/payeezy.rs @@ -2,7 +2,7 @@ pub mod transformers; use api_models::webhooks::IncomingWebhookEvent; use base64::Engine; -use common_enums::{CaptureMethod, PaymentMethodType, PaymentMethod}; +use common_enums::{CaptureMethod, PaymentMethod, PaymentMethodType}; use common_utils::{ errors::CustomResult, ext_traits::ByteSliceExt, diff --git a/crates/router/src/connector/datatrans.rs b/crates/router/src/connector/datatrans.rs index fc5eb876646f..2a88be06cdeb 100644 --- a/crates/router/src/connector/datatrans.rs +++ b/crates/router/src/connector/datatrans.rs @@ -1,5 +1,5 @@ pub mod transformers; -use api_models::enums::{CaptureMethod, PaymentMethodType, PaymentMethod}; +use api_models::enums::{CaptureMethod, PaymentMethod, PaymentMethodType}; use base64::Engine; use common_utils::types::{AmountConvertor, MinorUnit, MinorUnitForConnector}; use error_stack::{report, ResultExt}; diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index 72bf77cc4a5c..aeb4b89c6889 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -21,9 +21,9 @@ pub async fn fetch_connector_feature_matrix( json_payload: Option>, ) -> impl Responder { let flow: Flow = Flow::FeatureMatrix; - let payload = json_payload.map(|json_request| - json_request.into_inner() - ).unwrap_or(payment_types::FeatureMatrixRequest{connectors: None}); + let payload = json_payload + .map(|json_request| json_request.into_inner()) + .unwrap_or(payment_types::FeatureMatrixRequest { connectors: None }); Box::pin(api::server_wrap( flow, diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs index 424094a80f39..6d7453c1cb66 100644 --- a/crates/router/src/services/connector_integration_interface.rs +++ b/crates/router/src/services/connector_integration_interface.rs @@ -2,7 +2,8 @@ use common_utils::{crypto, errors::CustomResult, request::Request}; use hyperswitch_domain_models::{router_data::RouterData, router_data_v2::RouterDataV2}; use hyperswitch_interfaces::{ authentication::ExternalAuthenticationPayload, - connector_integration_v2::ConnectorIntegrationV2, webhooks::IncomingWebhookFlowError,types::SupportedPaymentMethods + connector_integration_v2::ConnectorIntegrationV2, types::SupportedPaymentMethods, + webhooks::IncomingWebhookFlowError, }; use super::{BoxedConnectorIntegrationV2, ConnectorValidation}; From 2c9663fadc52640692fd7a55607a1ad4cad32ef9 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 6 Dec 2024 12:54:35 +0530 Subject: [PATCH 12/40] fix(router): resolve merge conflict --- crates/hyperswitch_connectors/src/connectors/bambora.rs | 1 + crates/hyperswitch_connectors/src/connectors/deutschebank.rs | 1 + crates/hyperswitch_interfaces/src/api.rs | 3 ++- 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/crates/hyperswitch_connectors/src/connectors/bambora.rs b/crates/hyperswitch_connectors/src/connectors/bambora.rs index 3f945a3da854..800a7bcb2f68 100644 --- a/crates/hyperswitch_connectors/src/connectors/bambora.rs +++ b/crates/hyperswitch_connectors/src/connectors/bambora.rs @@ -126,6 +126,7 @@ impl ConnectorCommon for Bambora { let bambora_default_capture_methods = vec![ enums::CaptureMethod::Automatic, enums::CaptureMethod::Manual, + enums::CaptureMethod::SequentialAutomatic, ]; card_payment_method.insert( diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs index 8d2b700b68b2..d8e2ec37c5b5 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs @@ -143,6 +143,7 @@ impl ConnectorCommon for Deutschebank { let deutschebank_default_capture_methods = vec![ enums::CaptureMethod::Automatic, enums::CaptureMethod::Manual, + enums::CaptureMethod::SequentialAutomatic, ]; bank_debit_payment_method.insert( enums::PaymentMethodType::Sepa, diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index e75a325444d9..97ef80d1daec 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -405,7 +405,8 @@ pub trait ConnectorValidation: ConnectorCommon { } } else { match capture_method { - CaptureMethod::Automatic => Ok(()), + CaptureMethod::Automatic + | enums::CaptureMethod::SequentialAutomatic => Ok(()), CaptureMethod::Manual | CaptureMethod::ManualMultiple | CaptureMethod::Scheduled => Err(errors::ConnectorError::NotSupported { From f1ffeb817ac32b5ac7b9c46637f54fa05db66d69 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 6 Dec 2024 12:55:25 +0530 Subject: [PATCH 13/40] fix(router): remove unnecessary qualification for enum --- crates/hyperswitch_interfaces/src/api.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index 97ef80d1daec..8206cde9d561 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -406,7 +406,7 @@ pub trait ConnectorValidation: ConnectorCommon { } else { match capture_method { CaptureMethod::Automatic - | enums::CaptureMethod::SequentialAutomatic => Ok(()), + | CaptureMethod::SequentialAutomatic => Ok(()), CaptureMethod::Manual | CaptureMethod::ManualMultiple | CaptureMethod::Scheduled => Err(errors::ConnectorError::NotSupported { From a21d1c046a360d16b70a7888708275957161ed8e Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Fri, 6 Dec 2024 07:42:11 +0000 Subject: [PATCH 14/40] chore: run formatter --- crates/hyperswitch_interfaces/src/api.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index 8206cde9d561..12f0ef5b51e9 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -405,8 +405,7 @@ pub trait ConnectorValidation: ConnectorCommon { } } else { match capture_method { - CaptureMethod::Automatic - | CaptureMethod::SequentialAutomatic => Ok(()), + CaptureMethod::Automatic | CaptureMethod::SequentialAutomatic => Ok(()), CaptureMethod::Manual | CaptureMethod::ManualMultiple | CaptureMethod::Scheduled => Err(errors::ConnectorError::NotSupported { From d8e001a0125164d49558003abec2d910d0fba29f Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Mon, 9 Dec 2024 02:12:25 +0530 Subject: [PATCH 15/40] feat(router): add ConnectorSpecifications trait --- connector-template/mod.rs | 27 +++- crates/api_models/src/feature_matrix.rs | 21 +-- crates/api_models/src/webhooks.rs | 1 + crates/common_enums/src/enums.rs | 12 ++ .../src/connectors/airwallex.rs | 4 +- .../src/connectors/amazonpay.rs | 7 +- .../src/connectors/bambora.rs | 83 ++++++----- .../src/connectors/bamboraapac.rs | 7 +- .../src/connectors/billwerk.rs | 7 +- .../src/connectors/bitpay.rs | 7 +- .../src/connectors/boku.rs | 7 +- .../src/connectors/cashtocode.rs | 7 +- .../src/connectors/coinbase.rs | 7 +- .../src/connectors/cryptopay.rs | 7 +- .../src/connectors/deutschebank.rs | 71 ++++++---- .../src/connectors/digitalvirgo.rs | 4 +- .../src/connectors/dlocal.rs | 7 +- .../src/connectors/elavon.rs | 10 +- .../src/connectors/fiserv.rs | 7 +- .../src/connectors/fiservemea.rs | 7 +- .../src/connectors/fiuu.rs | 7 +- .../src/connectors/forte.rs | 7 +- .../src/connectors/globepay.rs | 7 +- .../src/connectors/gocardless.rs | 7 +- .../src/connectors/helcim.rs | 7 +- .../src/connectors/inespay.rs | 7 +- .../src/connectors/jpmorgan.rs | 7 +- .../src/connectors/mollie.rs | 4 +- .../src/connectors/multisafepay.rs | 7 +- .../src/connectors/nexinets.rs | 7 +- .../src/connectors/nexixpay.rs | 7 +- .../src/connectors/nomupay.rs | 7 +- .../src/connectors/novalnet.rs | 4 +- .../src/connectors/payeezy.rs | 7 +- .../src/connectors/payu.rs | 7 +- .../src/connectors/powertranz.rs | 7 +- .../src/connectors/prophetpay.rs | 7 +- .../src/connectors/rapyd.rs | 6 +- .../src/connectors/razorpay.rs | 7 +- .../src/connectors/redsys.rs | 7 +- .../src/connectors/shift4.rs | 7 +- .../src/connectors/square.rs | 7 +- .../src/connectors/stax.rs | 7 +- .../src/connectors/taxjar.rs | 7 +- .../src/connectors/thunes.rs | 7 +- .../src/connectors/tsys.rs | 7 +- .../src/connectors/volt.rs | 7 +- .../src/connectors/worldline.rs | 6 +- .../src/connectors/worldpay.rs | 4 +- .../src/connectors/xendit.rs | 7 +- .../src/connectors/zen.rs | 4 +- .../src/connectors/zsl.rs | 67 +++++---- .../src/router_response_types.rs | 74 ++++++++++ crates/hyperswitch_interfaces/src/api.rs | 44 ++++-- .../src/api/payments.rs | 1 + .../src/api/payments_v2.rs | 5 +- crates/hyperswitch_interfaces/src/types.rs | 19 --- crates/router/src/connector/aci.rs | 3 + crates/router/src/connector/adyen.rs | 4 +- crates/router/src/connector/adyenplatform.rs | 4 +- .../router/src/connector/authorizedotnet.rs | 4 +- crates/router/src/connector/bankofamerica.rs | 4 +- crates/router/src/connector/bluesnap.rs | 4 +- crates/router/src/connector/braintree.rs | 4 +- crates/router/src/connector/checkout.rs | 4 +- crates/router/src/connector/cybersource.rs | 4 +- crates/router/src/connector/datatrans.rs | 4 +- crates/router/src/connector/dummyconnector.rs | 4 +- crates/router/src/connector/ebanx.rs | 4 +- crates/router/src/connector/globalpay.rs | 4 +- crates/router/src/connector/gpayments.rs | 4 +- crates/router/src/connector/iatapay.rs | 4 +- crates/router/src/connector/itaubank.rs | 4 +- crates/router/src/connector/klarna.rs | 4 +- crates/router/src/connector/mifinity.rs | 4 +- crates/router/src/connector/netcetera.rs | 4 +- crates/router/src/connector/nmi.rs | 4 +- crates/router/src/connector/noon.rs | 4 +- crates/router/src/connector/nuvei.rs | 4 +- crates/router/src/connector/opayo.rs | 4 +- crates/router/src/connector/opennode.rs | 4 +- crates/router/src/connector/paybox.rs | 4 +- crates/router/src/connector/payme.rs | 4 +- crates/router/src/connector/payone.rs | 4 +- crates/router/src/connector/paypal.rs | 4 +- crates/router/src/connector/placetopay.rs | 4 +- crates/router/src/connector/plaid.rs | 4 +- crates/router/src/connector/riskified.rs | 4 +- crates/router/src/connector/signifyd.rs | 4 +- crates/router/src/connector/stripe.rs | 4 +- crates/router/src/connector/threedsecureio.rs | 4 +- crates/router/src/connector/trustpay.rs | 4 +- crates/router/src/connector/wellsfargo.rs | 4 +- .../router/src/connector/wellsfargopayout.rs | 4 +- crates/router/src/connector/wise.rs | 4 +- crates/router/src/routes/feature_matrix.rs | 132 +++++++++++------- crates/router/src/services/api.rs | 3 +- .../connector_integration_interface.rs | 43 ++++-- crates/router/src/types/api/payments.rs | 4 +- 99 files changed, 776 insertions(+), 280 deletions(-) diff --git a/connector-template/mod.rs b/connector-template/mod.rs index ae450aecf20b..08b7bc4306e3 100644 --- a/connector-template/mod.rs +++ b/connector-template/mod.rs @@ -3,6 +3,7 @@ pub mod transformers; use error_stack::{report, ResultExt}; use masking::{ExposeInterface, Mask}; +use common_enums::enums::PaymentsConnectorType; use common_utils::{ errors::CustomResult, ext_traits::BytesExt, @@ -10,6 +11,7 @@ use common_utils::{ request::{Method, Request, RequestBuilder, RequestContent}, }; +use api_models::webhooks::WebhookFlow; use hyperswitch_domain_models::{ router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData}, router_flow_types::{ @@ -25,14 +27,14 @@ use hyperswitch_domain_models::{ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData, }, - router_response_types::{PaymentsResponseData, RefundsResponseData}, + router_response_types::{ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods, SupportedPaymentMethodsExt}, types::{ PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData, }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation, ConnectorSpecifications}, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -551,3 +553,24 @@ impl webhooks::IncomingWebhook for {{project-name | downcase | pascal_case}} { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for {{project-name | downcase | pascal_case}} { + fn get_connector_data(&self) -> Option { + Some(ConnectorInfo { + description: + "Connector About" + .to_string(), + connector_type: PaymentsConnectorType::PaymentGateway, + }) + } + + fn get_supported_payment_methods(&self) -> Option { + let mut bambora_supported_payment_methods = SupportedPaymentMethods::new(); + Some(bambora_supported_payment_methods) + } + + fn get_supported_webhook_flows(&self) -> Option> { + Some(Vec::new()) + } +} + diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index 03e544d16548..df5a185469b4 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -3,7 +3,7 @@ use std::collections::HashSet; use serde::{Deserialize, Serialize}; use utoipa::ToSchema; -use crate::enums; +use crate::{enums, webhooks::WebhookFlow}; #[derive(Default, Debug, Deserialize, Serialize, Clone, ToSchema)] pub struct FeatureMatrixRequest { @@ -12,7 +12,7 @@ pub struct FeatureMatrixRequest { } #[cfg(feature = "v1")] -#[derive(Clone, Debug, Serialize)] +#[derive(Debug, Serialize)] pub struct SupportedPaymentMethod { pub payment_method: enums::PaymentMethodType, pub supports_mandate: bool, @@ -23,25 +23,28 @@ pub struct SupportedPaymentMethod { } #[cfg(feature = "v1")] -#[derive(Clone, Debug, ToSchema, Serialize)] +#[derive(Debug, ToSchema, Serialize)] pub struct SupportedPaymentMethodTypes { pub payment_method_type: enums::PaymentMethod, pub payment_methods: Vec, } #[cfg(feature = "v1")] -#[derive(Clone, Debug, ToSchema, Serialize)] -pub struct FeatureMatrixResponse { - pub connector: enums::Connector, +#[derive(Debug, ToSchema, Serialize)] +pub struct ConnectorFeatureMatrixResponse { + pub connector: String, + pub description: Option, + pub connector_type: Option, pub payment_method_types: Vec, + pub supported_webhook_flows: Option>, } -#[derive(Clone, Debug, Serialize, ToSchema)] +#[derive(Debug, Serialize, ToSchema)] pub struct FeatureMatrixListResponse { - /// The number of connectors included in the list + /// The number of connectors included in the response pub size: usize, // The list of payments response objects - pub data: Vec, + pub data: Vec, } impl common_utils::events::ApiEventMetric for FeatureMatrixListResponse {} diff --git a/crates/api_models/src/webhooks.rs b/crates/api_models/src/webhooks.rs index e6f4065eb7a9..308a3d4bb589 100644 --- a/crates/api_models/src/webhooks.rs +++ b/crates/api_models/src/webhooks.rs @@ -59,6 +59,7 @@ pub enum IncomingWebhookEvent { PayoutReversed, } +#[derive(Clone, Debug, Serialize)] pub enum WebhookFlow { Payment, #[cfg(feature = "payouts")] diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 1e05e7ec883a..239684267916 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -3399,3 +3399,15 @@ pub enum ErrorCategory { IssueWithPaymentMethod, ProcessorDeclineIncorrectData, } + +/// Connector Access Method +#[derive( + Clone, Copy, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, strum::Display, +)] +#[strum(serialize_all = "snake_case")] +#[serde(rename_all = "snake_case")] +pub enum PaymentsConnectorType { + PaymentGateway, + AlternativePaymentMethod, + BankAcquirer, +} diff --git a/crates/hyperswitch_connectors/src/connectors/airwallex.rs b/crates/hyperswitch_connectors/src/connectors/airwallex.rs index 95e3cfaee844..0a9cc4fbd144 100644 --- a/crates/hyperswitch_connectors/src/connectors/airwallex.rs +++ b/crates/hyperswitch_connectors/src/connectors/airwallex.rs @@ -34,7 +34,7 @@ use hyperswitch_domain_models::{ use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, disputes::DisputePayload, @@ -1106,3 +1106,5 @@ impl ConnectorRedirectResponse for Airwallex { } } } + +impl ConnectorSpecifications for Airwallex {} diff --git a/crates/hyperswitch_connectors/src/connectors/amazonpay.rs b/crates/hyperswitch_connectors/src/connectors/amazonpay.rs index da4d3d79bbcf..f89595415748 100644 --- a/crates/hyperswitch_connectors/src/connectors/amazonpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/amazonpay.rs @@ -26,7 +26,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -565,3 +568,5 @@ impl webhooks::IncomingWebhook for Amazonpay { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Amazonpay {} diff --git a/crates/hyperswitch_connectors/src/connectors/bambora.rs b/crates/hyperswitch_connectors/src/connectors/bambora.rs index 800a7bcb2f68..62413f0ca8c2 100644 --- a/crates/hyperswitch_connectors/src/connectors/bambora.rs +++ b/crates/hyperswitch_connectors/src/connectors/bambora.rs @@ -2,6 +2,7 @@ pub mod transformers; use std::fmt::Debug; +use api_models::webhooks::WebhookFlow; use common_enums::enums; use common_utils::{ errors::CustomResult, @@ -22,7 +23,10 @@ use hyperswitch_domain_models::{ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData, }, - router_response_types::{PaymentsResponseData, RefundsResponseData}, + router_response_types::{ + ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods, + SupportedPaymentMethodsExt, + }, types::{ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData, PaymentsCompleteAuthorizeRouterData, PaymentsSyncRouterData, RefundSyncRouterData, @@ -32,15 +36,14 @@ use hyperswitch_domain_models::{ use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, types::{ - self, PaymentMethodDetails, PaymentMethodTypeMetadata, PaymentsAuthorizeType, - PaymentsCaptureType, PaymentsCompleteAuthorizeType, PaymentsSyncType, PaymentsVoidType, - Response, SupportedPaymentMethods, + self, PaymentsAuthorizeType, PaymentsCaptureType, PaymentsCompleteAuthorizeType, + PaymentsSyncType, PaymentsVoidType, Response, }, webhooks, }; @@ -120,35 +123,6 @@ impl ConnectorCommon for Bambora { )]) } - fn get_supported_payment_methods(&self) -> Option { - let mut supported_payment_methods = SupportedPaymentMethods::new(); - let mut card_payment_method = PaymentMethodTypeMetadata::new(); - let bambora_default_capture_methods = vec![ - enums::CaptureMethod::Automatic, - enums::CaptureMethod::Manual, - enums::CaptureMethod::SequentialAutomatic, - ]; - - card_payment_method.insert( - enums::PaymentMethodType::Credit, - PaymentMethodDetails { - supports_mandate: false, - supports_refund: true, - supported_capture_methods: bambora_default_capture_methods.clone(), - }, - ); - card_payment_method.insert( - enums::PaymentMethodType::Debit, - PaymentMethodDetails { - supports_mandate: false, - supports_refund: true, - supported_capture_methods: bambora_default_capture_methods.clone(), - }, - ); - supported_payment_methods.insert(enums::PaymentMethod::Card, card_payment_method); - Some(supported_payment_methods) - } - fn build_error_response( &self, res: Response, @@ -842,3 +816,44 @@ impl webhooks::IncomingWebhook for Bambora { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Bambora { + fn get_connector_data(&self) -> Option { + Some(ConnectorInfo { + description: + "Bambora is a leading online payment provider in Canada and United States." + .to_string(), + connector_type: enums::PaymentsConnectorType::PaymentGateway, + }) + } + + fn get_supported_payment_methods(&self) -> Option { + let bambora_default_capture_methods = vec![ + enums::CaptureMethod::Automatic, + enums::CaptureMethod::Manual, + enums::CaptureMethod::SequentialAutomatic, + ]; + + let mut bambora_supported_payment_methods = SupportedPaymentMethods::new(); + bambora_supported_payment_methods.add( + enums::PaymentMethod::Card, + enums::PaymentMethodType::Credit, + false, + true, + bambora_default_capture_methods.clone(), + ); + bambora_supported_payment_methods.add( + enums::PaymentMethod::Card, + enums::PaymentMethodType::Debit, + false, + true, + bambora_default_capture_methods.clone(), + ); + + Some(bambora_supported_payment_methods) + } + + fn get_supported_webhook_flows(&self) -> Option> { + Some(Vec::new()) + } +} diff --git a/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs b/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs index df363b92ba92..67cd53522bcf 100644 --- a/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs +++ b/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs @@ -29,7 +29,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE}, errors, @@ -743,3 +746,5 @@ impl IncomingWebhook for Bamboraapac { fn html_to_xml_string_conversion(res: String) -> String { res.replace("<", "<").replace(">", ">") } + +impl ConnectorSpecifications for Bamboraapac {} diff --git a/crates/hyperswitch_connectors/src/connectors/billwerk.rs b/crates/hyperswitch_connectors/src/connectors/billwerk.rs index 36874e534f83..db7da9e03f33 100644 --- a/crates/hyperswitch_connectors/src/connectors/billwerk.rs +++ b/crates/hyperswitch_connectors/src/connectors/billwerk.rs @@ -29,7 +29,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE}, errors, @@ -814,3 +817,5 @@ impl IncomingWebhook for Billwerk { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Billwerk {} diff --git a/crates/hyperswitch_connectors/src/connectors/bitpay.rs b/crates/hyperswitch_connectors/src/connectors/bitpay.rs index 032b8cf051fa..c2a2c7b76a17 100644 --- a/crates/hyperswitch_connectors/src/connectors/bitpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/bitpay.rs @@ -27,7 +27,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts, errors, events::connector_api_logs::ConnectorEvent, @@ -412,3 +415,5 @@ impl webhooks::IncomingWebhook for Bitpay { Ok(Box::new(notif)) } } + +impl ConnectorSpecifications for Bitpay {} diff --git a/crates/hyperswitch_connectors/src/connectors/boku.rs b/crates/hyperswitch_connectors/src/connectors/boku.rs index e0615b8e9bea..c85db2be8b71 100644 --- a/crates/hyperswitch_connectors/src/connectors/boku.rs +++ b/crates/hyperswitch_connectors/src/connectors/boku.rs @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts::NO_ERROR_CODE, errors, @@ -709,3 +712,5 @@ fn get_xml_deserialized( } } } + +impl ConnectorSpecifications for Boku {} diff --git a/crates/hyperswitch_connectors/src/connectors/cashtocode.rs b/crates/hyperswitch_connectors/src/connectors/cashtocode.rs index 1b3e731f7a2d..4dc4b58acbe7 100644 --- a/crates/hyperswitch_connectors/src/connectors/cashtocode.rs +++ b/crates/hyperswitch_connectors/src/connectors/cashtocode.rs @@ -25,7 +25,10 @@ use hyperswitch_domain_models::{ types::{PaymentsAuthorizeRouterData, PaymentsSyncRouterData}, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -453,3 +456,5 @@ impl ConnectorIntegration for Cashtoc impl ConnectorIntegration for Cashtocode { // default implementation of build_request method will be executed } + +impl ConnectorSpecifications for Cashtocode {} diff --git a/crates/hyperswitch_connectors/src/connectors/coinbase.rs b/crates/hyperswitch_connectors/src/connectors/coinbase.rs index dad517aae18a..8c86418e9641 100644 --- a/crates/hyperswitch_connectors/src/connectors/coinbase.rs +++ b/crates/hyperswitch_connectors/src/connectors/coinbase.rs @@ -29,7 +29,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -441,3 +444,5 @@ impl webhooks::IncomingWebhook for Coinbase { Ok(Box::new(notif.event)) } } + +impl ConnectorSpecifications for Coinbase {} diff --git a/crates/hyperswitch_connectors/src/connectors/cryptopay.rs b/crates/hyperswitch_connectors/src/connectors/cryptopay.rs index dcd629f4336b..2650d8f1e91b 100644 --- a/crates/hyperswitch_connectors/src/connectors/cryptopay.rs +++ b/crates/hyperswitch_connectors/src/connectors/cryptopay.rs @@ -27,7 +27,10 @@ use hyperswitch_domain_models::{ types::{PaymentsAuthorizeRouterData, PaymentsSyncRouterData}, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -496,3 +499,5 @@ impl webhooks::IncomingWebhook for Cryptopay { Ok(Box::new(notif)) } } + +impl ConnectorSpecifications for Cryptopay {} diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs index d8e2ec37c5b5..91ba3fa57960 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs @@ -3,8 +3,9 @@ pub mod transformers; use std::time::SystemTime; use actix_web::http::header::Date; +use api_models::webhooks::WebhookFlow; use base64::Engine; -use common_enums::enums; +use common_enums::{enums, PaymentsConnectorType}; use common_utils::{ errors::CustomResult, ext_traits::BytesExt, @@ -27,7 +28,10 @@ use hyperswitch_domain_models::{ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData, }, - router_response_types::{PaymentsResponseData, RefundsResponseData}, + router_response_types::{ + ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods, + SupportedPaymentMethodsExt, + }, types::{ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData, PaymentsCompleteAuthorizeRouterData, PaymentsSyncRouterData, RefreshTokenRouterData, @@ -35,13 +39,14 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, - types::{ - self, PaymentMethodDetails, PaymentMethodTypeMetadata, Response, SupportedPaymentMethods, - }, + types::{self, Response}, webhooks, }; use masking::{ExposeInterface, Mask, Secret}; @@ -137,27 +142,6 @@ impl ConnectorCommon for Deutschebank { connectors.deutschebank.base_url.as_ref() } - fn get_supported_payment_methods(&self) -> Option { - let mut supported_payment_methods = SupportedPaymentMethods::new(); - let mut bank_debit_payment_method = PaymentMethodTypeMetadata::new(); - let deutschebank_default_capture_methods = vec![ - enums::CaptureMethod::Automatic, - enums::CaptureMethod::Manual, - enums::CaptureMethod::SequentialAutomatic, - ]; - bank_debit_payment_method.insert( - enums::PaymentMethodType::Sepa, - PaymentMethodDetails { - supports_mandate: true, - supports_refund: true, - supported_capture_methods: deutschebank_default_capture_methods.clone(), - }, - ); - supported_payment_methods - .insert(enums::PaymentMethod::BankDebit, bank_debit_payment_method); - Some(supported_payment_methods) - } - fn get_auth_header( &self, auth_type: &ConnectorAuthType, @@ -955,3 +939,36 @@ impl webhooks::IncomingWebhook for Deutschebank { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Deutschebank { + fn get_connector_data(&self) -> Option { + Some(ConnectorInfo { + description: + "Deutsche Bank is a German multinational investment bank and financial services company " + .to_string(), + connector_type: PaymentsConnectorType::BankAcquirer, + }) + } + + fn get_supported_payment_methods(&self) -> Option { + let deutschebank_default_capture_methods = vec![ + enums::CaptureMethod::Automatic, + enums::CaptureMethod::Manual, + enums::CaptureMethod::SequentialAutomatic, + ]; + let mut deutschebank_supported_payment_methods = SupportedPaymentMethods::new(); + deutschebank_supported_payment_methods.add( + enums::PaymentMethod::BankDebit, + enums::PaymentMethodType::Sepa, + true, + true, + deutschebank_default_capture_methods.clone(), + ); + + Some(deutschebank_supported_payment_methods) + } + + fn get_supported_webhook_flows(&self) -> Option> { + Some(Vec::new()) + } +} diff --git a/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs b/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs index a190b98d3d4d..abc01f998ff8 100644 --- a/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs +++ b/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs @@ -35,7 +35,7 @@ use hyperswitch_domain_models::{ use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, errors, @@ -539,3 +539,5 @@ impl webhooks::IncomingWebhook for Digitalvirgo { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Digitalvirgo {} diff --git a/crates/hyperswitch_connectors/src/connectors/dlocal.rs b/crates/hyperswitch_connectors/src/connectors/dlocal.rs index 1adba7241752..d3c8a015b9ea 100644 --- a/crates/hyperswitch_connectors/src/connectors/dlocal.rs +++ b/crates/hyperswitch_connectors/src/connectors/dlocal.rs @@ -32,7 +32,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -689,3 +692,5 @@ impl webhooks::IncomingWebhook for Dlocal { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Dlocal {} diff --git a/crates/hyperswitch_connectors/src/connectors/elavon.rs b/crates/hyperswitch_connectors/src/connectors/elavon.rs index 4fcc75296f57..ee8d576f8e88 100644 --- a/crates/hyperswitch_connectors/src/connectors/elavon.rs +++ b/crates/hyperswitch_connectors/src/connectors/elavon.rs @@ -1,7 +1,7 @@ pub mod transformers; use std::{collections::HashMap, str}; -use common_enums::{CaptureMethod, PaymentMethodType}; +use common_enums::{CaptureMethod, PaymentMethod, PaymentMethodType}; use common_utils::{ errors::CustomResult, request::{Method, Request, RequestBuilder, RequestContent}, @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -582,6 +585,7 @@ impl ConnectorValidation for Elavon { fn validate_capture_method( &self, capture_method: Option, + _payment_method: &PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -603,3 +607,5 @@ impl ConnectorValidation for Elavon { utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id()) } } + +impl ConnectorSpecifications for Elavon {} diff --git a/crates/hyperswitch_connectors/src/connectors/fiserv.rs b/crates/hyperswitch_connectors/src/connectors/fiserv.rs index 964779a70721..0bd81276e949 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiserv.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiserv.rs @@ -29,7 +29,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts, errors, events::connector_api_logs::ConnectorEvent, @@ -785,3 +788,5 @@ impl webhooks::IncomingWebhook for Fiserv { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Fiserv {} diff --git a/crates/hyperswitch_connectors/src/connectors/fiservemea.rs b/crates/hyperswitch_connectors/src/connectors/fiservemea.rs index 7560b6271e43..8c041b171475 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiservemea.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiservemea.rs @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts, errors, events::connector_api_logs::ConnectorEvent, @@ -787,3 +790,5 @@ impl webhooks::IncomingWebhook for Fiservemea { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Fiservemea {} diff --git a/crates/hyperswitch_connectors/src/connectors/fiuu.rs b/crates/hyperswitch_connectors/src/connectors/fiuu.rs index 5b742700290e..1acd282ce340 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiuu.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiuu.rs @@ -31,7 +31,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -926,3 +929,5 @@ impl webhooks::IncomingWebhook for Fiuu { Ok(mandate_reference) } } + +impl ConnectorSpecifications for Fiuu {} diff --git a/crates/hyperswitch_connectors/src/connectors/forte.rs b/crates/hyperswitch_connectors/src/connectors/forte.rs index a053246b420f..a192098ad260 100644 --- a/crates/hyperswitch_connectors/src/connectors/forte.rs +++ b/crates/hyperswitch_connectors/src/connectors/forte.rs @@ -30,7 +30,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts::NO_ERROR_CODE, errors, @@ -728,3 +731,5 @@ impl IncomingWebhook for Forte { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Forte {} diff --git a/crates/hyperswitch_connectors/src/connectors/globepay.rs b/crates/hyperswitch_connectors/src/connectors/globepay.rs index c9e316707c1e..f11b7b5977f2 100644 --- a/crates/hyperswitch_connectors/src/connectors/globepay.rs +++ b/crates/hyperswitch_connectors/src/connectors/globepay.rs @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts, errors, events::connector_api_logs::ConnectorEvent, @@ -553,3 +556,5 @@ impl webhooks::IncomingWebhook for Globepay { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Globepay {} diff --git a/crates/hyperswitch_connectors/src/connectors/gocardless.rs b/crates/hyperswitch_connectors/src/connectors/gocardless.rs index 06853b51a937..151b6f8e1c5a 100644 --- a/crates/hyperswitch_connectors/src/connectors/gocardless.rs +++ b/crates/hyperswitch_connectors/src/connectors/gocardless.rs @@ -32,7 +32,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -869,3 +872,5 @@ impl IncomingWebhook for Gocardless { } } } + +impl ConnectorSpecifications for Gocardless {} diff --git a/crates/hyperswitch_connectors/src/connectors/helcim.rs b/crates/hyperswitch_connectors/src/connectors/helcim.rs index 4ffa5cd9e074..27c106a510db 100644 --- a/crates/hyperswitch_connectors/src/connectors/helcim.rs +++ b/crates/hyperswitch_connectors/src/connectors/helcim.rs @@ -29,7 +29,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, consts::NO_ERROR_CODE, errors, @@ -811,3 +814,5 @@ impl IncomingWebhook for Helcim { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Helcim {} diff --git a/crates/hyperswitch_connectors/src/connectors/inespay.rs b/crates/hyperswitch_connectors/src/connectors/inespay.rs index 89bf50c60ca9..3d3ea346b78a 100644 --- a/crates/hyperswitch_connectors/src/connectors/inespay.rs +++ b/crates/hyperswitch_connectors/src/connectors/inespay.rs @@ -26,7 +26,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -561,3 +564,5 @@ impl webhooks::IncomingWebhook for Inespay { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Inespay {} diff --git a/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs b/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs index 6095a53ad00b..9039a7e22189 100644 --- a/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs +++ b/crates/hyperswitch_connectors/src/connectors/jpmorgan.rs @@ -27,7 +27,10 @@ use hyperswitch_domain_models::{ }; // use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -566,3 +569,5 @@ impl webhooks::IncomingWebhook for Jpmorgan { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Jpmorgan {} diff --git a/crates/hyperswitch_connectors/src/connectors/mollie.rs b/crates/hyperswitch_connectors/src/connectors/mollie.rs index 010ae90c56f1..8cdf4f03a703 100644 --- a/crates/hyperswitch_connectors/src/connectors/mollie.rs +++ b/crates/hyperswitch_connectors/src/connectors/mollie.rs @@ -30,7 +30,7 @@ use hyperswitch_domain_models::{ use hyperswitch_interfaces::{ api::{ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, consts, errors, @@ -634,3 +634,5 @@ impl ConnectorRedirectResponse for Mollie { } } } + +impl ConnectorSpecifications for Mollie {} diff --git a/crates/hyperswitch_connectors/src/connectors/multisafepay.rs b/crates/hyperswitch_connectors/src/connectors/multisafepay.rs index 0a34e413fde9..a80f339cd9d9 100644 --- a/crates/hyperswitch_connectors/src/connectors/multisafepay.rs +++ b/crates/hyperswitch_connectors/src/connectors/multisafepay.rs @@ -29,7 +29,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -566,3 +569,5 @@ impl IncomingWebhook for Multisafepay { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Multisafepay {} diff --git a/crates/hyperswitch_connectors/src/connectors/nexinets.rs b/crates/hyperswitch_connectors/src/connectors/nexinets.rs index 578e1e6a7adc..9c5fdcae5ca6 100644 --- a/crates/hyperswitch_connectors/src/connectors/nexinets.rs +++ b/crates/hyperswitch_connectors/src/connectors/nexinets.rs @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -739,3 +742,5 @@ impl ConnectorIntegration Option { - let mut supported_payment_methods = SupportedPaymentMethods::new(); - let mut bank_transfer_payment_method = PaymentMethodTypeMetadata::new(); - let zsl_default_capture_methods = vec![enums::CaptureMethod::Automatic]; - bank_transfer_payment_method.insert( - enums::PaymentMethodType::LocalBankTransfer, - PaymentMethodDetails { - supports_mandate: false, - supports_refund: false, - supported_capture_methods: zsl_default_capture_methods.clone(), - }, - ); - supported_payment_methods.insert( - enums::PaymentMethod::BankTransfer, - bank_transfer_payment_method, - ); - Some(supported_payment_methods) - } - fn build_error_response( &self, res: Response, @@ -478,3 +463,33 @@ fn get_webhook_object_from_body( .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; Ok(response) } + +impl ConnectorSpecifications for Zsl { + fn get_connector_data(&self) -> Option { + Some(ConnectorInfo { + description: + "Zsl is a payment gateway operating in China, specializing in facilitating local bank transfers" + .to_string(), + connector_type: PaymentsConnectorType::PaymentGateway, + }) + } + + fn get_supported_payment_methods(&self) -> Option { + let zsl_default_capture_methods = vec![enums::CaptureMethod::Automatic]; + + let mut zsl_supported_payment_methods = SupportedPaymentMethods::new(); + zsl_supported_payment_methods.add( + enums::PaymentMethod::BankTransfer, + enums::PaymentMethodType::LocalBankTransfer, + false, + false, + zsl_default_capture_methods.clone(), + ); + + Some(zsl_supported_payment_methods) + } + + fn get_supported_webhook_flows(&self) -> Option> { + Some(Vec::new()) + } +} diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs index 89eb7f9b3cdb..f25282485846 100644 --- a/crates/hyperswitch_domain_models/src/router_response_types.rs +++ b/crates/hyperswitch_domain_models/src/router_response_types.rs @@ -2,6 +2,7 @@ pub mod disputes; pub mod fraud_check; use std::collections::HashMap; +use common_enums::{CaptureMethod, PaymentMethod, PaymentMethodType, PaymentsConnectorType}; use common_utils::{request::Method, types as common_types, types::MinorUnit}; pub use disputes::{AcceptDisputeResponse, DefendDisputeResponse, SubmitEvidenceResponse}; @@ -511,3 +512,76 @@ pub struct CompleteAuthorizeRedirectResponse { pub params: Option>, pub payload: Option, } + +/// Represents details of a payment method. +#[derive(Debug, Clone)] +pub struct PaymentMethodDetails { + /// Indicates whether mandates are supported by this payment method. + pub supports_mandate: bool, + /// Indicates whether refund is supported by this payment method. + pub supports_refund: bool, + /// Indicates whether manual capture supported is supported by this payment method. + pub supported_capture_methods: Vec, +} + +/// list of payment method types and metadata related to them +pub type PaymentMethodTypeMetadata = HashMap; + +/// list of payment methods, payment method types and metadata related to them +pub type SupportedPaymentMethods = HashMap; + +#[derive(Debug, Clone)] +pub struct ConnectorInfo { + /// Description of the connector. + pub description: String, + + /// Connector Type + pub connector_type: PaymentsConnectorType, +} + +pub trait SupportedPaymentMethodsExt { + fn add( + &mut self, + payment_method: PaymentMethod, + payment_method_type: PaymentMethodType, + supports_mandate: bool, + supports_refund: bool, + supported_capture_methods: Vec, + ); +} + +impl SupportedPaymentMethodsExt for SupportedPaymentMethods { + fn add( + &mut self, + payment_method: PaymentMethod, + payment_method_type: PaymentMethodType, + supports_mandate: bool, + supports_refund: bool, + supported_capture_methods: Vec, + ) { + // Check if `payment_method` exists in the map + if let Some(payment_method_data) = self.get_mut(&payment_method) { + // If it exists, insert or update the data for `payment_method_type` + payment_method_data.insert( + payment_method_type, + PaymentMethodDetails { + supports_mandate, + supports_refund, + supported_capture_methods, + }, + ); + } else { + // If it doesn't exist, create a new entry + let payment_method_details = PaymentMethodDetails { + supports_mandate, + supports_refund, + supported_capture_methods, + }; + + let mut payment_method_type_metadata = PaymentMethodTypeMetadata::new(); + payment_method_type_metadata.insert(payment_method_type, payment_method_details); + + self.insert(payment_method, payment_method_type_metadata); + } + } +} diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index 12f0ef5b51e9..c4361e5dc624 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -36,7 +36,10 @@ use hyperswitch_domain_models::{ router_request_types::{ AccessTokenRequestData, MandateRevokeRequestData, VerifyWebhookSourceRequestData, }, - router_response_types::{MandateRevokeResponseData, VerifyWebhookSourceResponseData}, + router_response_types::{ + ConnectorInfo, MandateRevokeResponseData, PaymentMethodDetails, SupportedPaymentMethods, + VerifyWebhookSourceResponseData, + }, }; use masking::Maskable; use router_env::metrics::add_attributes; @@ -46,12 +49,8 @@ use serde_json::json; pub use self::payouts::*; pub use self::{payments::*, refunds::*}; use crate::{ - configs::Connectors, - connector_integration_v2::ConnectorIntegrationV2, - consts, errors, - events::connector_api_logs::ConnectorEvent, - metrics, - types::{self, SupportedPaymentMethods}, + configs::Connectors, connector_integration_v2::ConnectorIntegrationV2, consts, errors, + events::connector_api_logs::ConnectorEvent, metrics, types, }; /// type BoxedConnectorIntegration @@ -265,11 +264,6 @@ pub trait ConnectorCommon { /// The base URL for interacting with the connector's API. fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str; - /// Details related to payment method supported by the connector - fn get_supported_payment_methods(&self) -> Option { - None - } - /// common error response for a connector if it is same in all case fn build_error_response( &self, @@ -287,6 +281,24 @@ pub trait ConnectorCommon { } } +/// The trait that provides specifications about the connector +pub trait ConnectorSpecifications { + /// Details related to payment method supported by the connector + fn get_supported_payment_methods(&self) -> Option { + None + } + + /// Supported webhooks flows + fn get_supported_webhook_flows(&self) -> Option> { + None + } + + /// Details related to connector + fn get_connector_data(&self) -> Option { + None + } +} + /// Extended trait for connector common to allow functions with generic type pub trait ConnectorCommonExt: ConnectorCommon + ConnectorIntegration @@ -352,7 +364,7 @@ pub trait ConnectorVerifyWebhookSourceV2: } /// trait ConnectorValidation -pub trait ConnectorValidation: ConnectorCommon { +pub trait ConnectorValidation: ConnectorCommon + ConnectorSpecifications { /// fn validate_payment_method fn validate_payment_method( &self, @@ -366,8 +378,10 @@ pub trait ConnectorValidation: ConnectorCommon { payment_method_type, self.id(), )?; + Ok(()) + } else { + Ok(()) } - Ok(()) } /// fn validate_capture_method @@ -480,7 +494,7 @@ fn get_connector_payment_method_type_info( payment_method: &PaymentMethod, payment_method_type: &Option, connector: &'static str, -) -> CustomResult, errors::ConnectorError> { +) -> CustomResult, errors::ConnectorError> { let payment_method_details = supported_payment_method .get(payment_method) .ok_or_else(|| errors::ConnectorError::NotSupported { diff --git a/crates/hyperswitch_interfaces/src/api/payments.rs b/crates/hyperswitch_interfaces/src/api/payments.rs index b3ac7e0fa906..ab327d0629a6 100644 --- a/crates/hyperswitch_interfaces/src/api/payments.rs +++ b/crates/hyperswitch_interfaces/src/api/payments.rs @@ -23,6 +23,7 @@ use crate::api; /// trait Payment pub trait Payment: api::ConnectorCommon + + api::ConnectorSpecifications + api::ConnectorValidation + PaymentAuthorize + PaymentAuthorizeSessionToken diff --git a/crates/hyperswitch_interfaces/src/api/payments_v2.rs b/crates/hyperswitch_interfaces/src/api/payments_v2.rs index e2ddf49e0cd0..366024f7da6e 100644 --- a/crates/hyperswitch_interfaces/src/api/payments_v2.rs +++ b/crates/hyperswitch_interfaces/src/api/payments_v2.rs @@ -19,7 +19,9 @@ use hyperswitch_domain_models::{ router_response_types::{PaymentsResponseData, TaxCalculationResponseData}, }; -use crate::api::{ConnectorCommon, ConnectorIntegrationV2, ConnectorValidation}; +use crate::api::{ + ConnectorCommon, ConnectorIntegrationV2, ConnectorSpecifications, ConnectorValidation, +}; /// trait PaymentAuthorizeV2 pub trait PaymentAuthorizeV2: @@ -182,6 +184,7 @@ pub trait PaymentsPostProcessingV2: /// trait PaymentV2 pub trait PaymentV2: ConnectorCommon + + ConnectorSpecifications + ConnectorValidation + PaymentAuthorizeV2 + PaymentAuthorizeSessionTokenV2 diff --git a/crates/hyperswitch_interfaces/src/types.rs b/crates/hyperswitch_interfaces/src/types.rs index a50f1b53133f..334d1aedad08 100644 --- a/crates/hyperswitch_interfaces/src/types.rs +++ b/crates/hyperswitch_interfaces/src/types.rs @@ -1,7 +1,5 @@ //! Types interface -use std::collections::HashMap; -use common_enums::{CaptureMethod, PaymentMethod, PaymentMethodType}; use hyperswitch_domain_models::{ router_data::AccessToken, router_flow_types::{ @@ -188,20 +186,3 @@ pub type RetrieveFileType = /// Type alias for `ConnectorIntegration` pub type DefendDisputeType = dyn ConnectorIntegration; - -/// Represents details of a payment method. -#[derive(Debug, Clone)] -pub struct PaymentMethodDetails { - /// Indicates whether mandates are supported by this payment method. - pub supports_mandate: bool, - /// Indicates whether refund is supported by this payment method. - pub supports_refund: bool, - /// Indicates whether manual capture supported is supported by this payment method. - pub supported_capture_methods: Vec, -} - -/// list of payment method types and metadata related to them -pub type PaymentMethodTypeMetadata = HashMap; - -/// list of payment methods, payment method types and metadata related to them -pub type SupportedPaymentMethods = HashMap; diff --git a/crates/router/src/connector/aci.rs b/crates/router/src/connector/aci.rs index 6f800194a476..c59c0ce07556 100644 --- a/crates/router/src/connector/aci.rs +++ b/crates/router/src/connector/aci.rs @@ -6,6 +6,7 @@ use common_utils::{ types::{AmountConvertor, StringMajorUnit, StringMajorUnitForConnector}, }; use error_stack::{report, ResultExt}; +use hyperswitch_interfaces::api::ConnectorSpecifications; use masking::PeekInterface; use transformers as aci; @@ -616,3 +617,5 @@ impl api::IncomingWebhook for Aci { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Aci {} diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs index 7f5c204e1bdf..733cdca92f94 100644 --- a/crates/router/src/connector/adyen.rs +++ b/crates/router/src/connector/adyen.rs @@ -27,7 +27,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -2292,3 +2292,5 @@ impl api::FileUpload for Adyen { Ok(()) } } + +impl ConnectorSpecifications for Adyen {} diff --git a/crates/router/src/connector/adyenplatform.rs b/crates/router/src/connector/adyenplatform.rs index 2ee80699a5a0..f95e9cd4d649 100644 --- a/crates/router/src/connector/adyenplatform.rs +++ b/crates/router/src/connector/adyenplatform.rs @@ -29,7 +29,7 @@ use crate::{ configs::settings, core::errors::{self, CustomResult}, headers, - services::{self, request::Mask, ConnectorValidation}, + services::{self, request::Mask, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon}, @@ -461,3 +461,5 @@ impl api::IncomingWebhook for Adyenplatform { } } } + +impl ConnectorSpecifications for Adyenplatform {} diff --git a/crates/router/src/connector/authorizedotnet.rs b/crates/router/src/connector/authorizedotnet.rs index 944070adc334..728722c2d11a 100644 --- a/crates/router/src/connector/authorizedotnet.rs +++ b/crates/router/src/connector/authorizedotnet.rs @@ -19,7 +19,7 @@ use crate::{ }, events::connector_api_logs::ConnectorEvent, headers, - services::{self, request, ConnectorIntegration, ConnectorValidation}, + services::{self, request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt, PaymentsCompleteAuthorize}, @@ -1058,3 +1058,5 @@ impl services::ConnectorRedirectResponse for Authorizedotnet { } } } + +impl ConnectorSpecifications for Authorizedotnet {} diff --git a/crates/router/src/connector/bankofamerica.rs b/crates/router/src/connector/bankofamerica.rs index 7d6128b4f085..9f5dc716a61f 100644 --- a/crates/router/src/connector/bankofamerica.rs +++ b/crates/router/src/connector/bankofamerica.rs @@ -25,7 +25,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -1066,3 +1066,5 @@ impl api::IncomingWebhook for Bankofamerica { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Bankofamerica {} diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rs index f6d43d61314f..8dc8b401850d 100644 --- a/crates/router/src/connector/bluesnap.rs +++ b/crates/router/src/connector/bluesnap.rs @@ -28,7 +28,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -1381,3 +1381,5 @@ fn get_rsync_url_with_connector_refund_id( req.request.get_connector_refund_id()? )) } + +impl ConnectorSpecifications for Bluesnap {} diff --git a/crates/router/src/connector/braintree.rs b/crates/router/src/connector/braintree.rs index a20df8123e60..a9ecd5429f2a 100644 --- a/crates/router/src/connector/braintree.rs +++ b/crates/router/src/connector/braintree.rs @@ -30,7 +30,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -1210,3 +1210,5 @@ impl self.build_error_response(res, event_builder) } } + +impl ConnectorSpecifications for Braintree {} diff --git a/crates/router/src/connector/checkout.rs b/crates/router/src/connector/checkout.rs index bd3feac3ce76..948924d52a1d 100644 --- a/crates/router/src/connector/checkout.rs +++ b/crates/router/src/connector/checkout.rs @@ -27,7 +27,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -1490,3 +1490,5 @@ impl ConnectorErrorTypeMapping for Checkout { } } } + +impl ConnectorSpecifications for Checkout {} diff --git a/crates/router/src/connector/cybersource.rs b/crates/router/src/connector/cybersource.rs index 83bea8dd560f..a0e8f2c3a431 100644 --- a/crates/router/src/connector/cybersource.rs +++ b/crates/router/src/connector/cybersource.rs @@ -27,7 +27,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -1719,3 +1719,5 @@ impl api::IncomingWebhook for Cybersource { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Cybersource {} diff --git a/crates/router/src/connector/datatrans.rs b/crates/router/src/connector/datatrans.rs index 3737a8830713..9b0b7aac90da 100644 --- a/crates/router/src/connector/datatrans.rs +++ b/crates/router/src/connector/datatrans.rs @@ -16,7 +16,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -688,3 +688,5 @@ impl api::IncomingWebhook for Datatrans { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Datatrans {} diff --git a/crates/router/src/connector/dummyconnector.rs b/crates/router/src/connector/dummyconnector.rs index a8f48d41654d..b5ba0e252cb2 100644 --- a/crates/router/src/connector/dummyconnector.rs +++ b/crates/router/src/connector/dummyconnector.rs @@ -16,7 +16,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -614,3 +614,5 @@ impl api::IncomingWebhook for DummyConnector { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for DummyConnector {} diff --git a/crates/router/src/connector/ebanx.rs b/crates/router/src/connector/ebanx.rs index e5e7f2e259aa..01db54c1f67e 100644 --- a/crates/router/src/connector/ebanx.rs +++ b/crates/router/src/connector/ebanx.rs @@ -15,7 +15,7 @@ use crate::{ configs::settings, core::errors::{self, CustomResult}, events::connector_api_logs::ConnectorEvent, - services::{ConnectorIntegration, ConnectorValidation}, + services::{ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -466,3 +466,5 @@ impl api::IncomingWebhook for Ebanx { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Ebanx {} diff --git a/crates/router/src/connector/globalpay.rs b/crates/router/src/connector/globalpay.rs index 5a7d9dee05a3..2f9559a46d06 100644 --- a/crates/router/src/connector/globalpay.rs +++ b/crates/router/src/connector/globalpay.rs @@ -28,7 +28,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -1044,3 +1044,5 @@ impl services::ConnectorRedirectResponse for Globalpay { } } } + +impl ConnectorSpecifications for Globalpay {} diff --git a/crates/router/src/connector/gpayments.rs b/crates/router/src/connector/gpayments.rs index 9f88e215138f..1febbfa7885d 100644 --- a/crates/router/src/connector/gpayments.rs +++ b/crates/router/src/connector/gpayments.rs @@ -14,7 +14,7 @@ use crate::{ core::errors::{self, CustomResult}, events::connector_api_logs::ConnectorEvent, headers, services, - services::{request, ConnectorIntegration, ConnectorValidation}, + services::{request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -613,3 +613,5 @@ impl self.build_error_response(res, event_builder) } } + +impl ConnectorSpecifications for Gpayments {} diff --git a/crates/router/src/connector/iatapay.rs b/crates/router/src/connector/iatapay.rs index cf4a1d6e16bc..e694968ee04b 100644 --- a/crates/router/src/connector/iatapay.rs +++ b/crates/router/src/connector/iatapay.rs @@ -22,7 +22,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -757,3 +757,5 @@ impl api::IncomingWebhook for Iatapay { } } } + +impl ConnectorSpecifications for Iatapay {} diff --git a/crates/router/src/connector/itaubank.rs b/crates/router/src/connector/itaubank.rs index 0c99a95e0e51..2087c72ba859 100644 --- a/crates/router/src/connector/itaubank.rs +++ b/crates/router/src/connector/itaubank.rs @@ -14,7 +14,7 @@ use crate::{ core::errors::{self, CustomResult}, events::connector_api_logs::ConnectorEvent, headers, - services::{self, request, ConnectorIntegration, ConnectorValidation}, + services::{self, request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -785,3 +785,5 @@ impl api::IncomingWebhook for Itaubank { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Itaubank {} diff --git a/crates/router/src/connector/klarna.rs b/crates/router/src/connector/klarna.rs index ead89ab0dcaf..713cf8a8a279 100644 --- a/crates/router/src/connector/klarna.rs +++ b/crates/router/src/connector/klarna.rs @@ -21,7 +21,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -1026,3 +1026,5 @@ impl api::IncomingWebhook for Klarna { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Klarna {} diff --git a/crates/router/src/connector/mifinity.rs b/crates/router/src/connector/mifinity.rs index d8ac2d101297..dcf95a576e3f 100644 --- a/crates/router/src/connector/mifinity.rs +++ b/crates/router/src/connector/mifinity.rs @@ -16,7 +16,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -501,3 +501,5 @@ impl api::IncomingWebhook for Mifinity { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Mifinity {} diff --git a/crates/router/src/connector/netcetera.rs b/crates/router/src/connector/netcetera.rs index edf56365f4ef..459ac93e0680 100644 --- a/crates/router/src/connector/netcetera.rs +++ b/crates/router/src/connector/netcetera.rs @@ -13,7 +13,7 @@ use crate::{ core::errors::{self, CustomResult}, events::connector_api_logs::ConnectorEvent, headers, - services::{self, request, ConnectorIntegration, ConnectorValidation}, + services::{self, request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -462,3 +462,5 @@ impl > for Netcetera { } + +impl ConnectorSpecifications for Netcetera {} diff --git a/crates/router/src/connector/nmi.rs b/crates/router/src/connector/nmi.rs index 478f1ebe65c4..bb02130171ff 100644 --- a/crates/router/src/connector/nmi.rs +++ b/crates/router/src/connector/nmi.rs @@ -19,7 +19,7 @@ use crate::{ payments, }, events::connector_api_logs::ConnectorEvent, - services::{self, request, ConnectorIntegration, ConnectorValidation}, + services::{self, request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -1034,3 +1034,5 @@ impl services::ConnectorRedirectResponse for Nmi { } } } + +impl ConnectorSpecifications for Nmi {} diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rs index 60e32a43a475..d309fe72c75d 100644 --- a/crates/router/src/connector/noon.rs +++ b/crates/router/src/connector/noon.rs @@ -27,7 +27,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -946,3 +946,5 @@ impl api::IncomingWebhook for Noon { Ok(Box::new(noon::NoonPaymentsResponse::from(resource))) } } + +impl ConnectorSpecifications for Noon {} diff --git a/crates/router/src/connector/nuvei.rs b/crates/router/src/connector/nuvei.rs index 8773119f275d..9e759e9efbfe 100644 --- a/crates/router/src/connector/nuvei.rs +++ b/crates/router/src/connector/nuvei.rs @@ -21,7 +21,7 @@ use crate::{ }, events::connector_api_logs::ConnectorEvent, headers, - services::{self, request, ConnectorIntegration, ConnectorValidation}, + services::{self, request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -981,3 +981,5 @@ impl services::ConnectorRedirectResponse for Nuvei { } } } + +impl ConnectorSpecifications for Nuvei {} diff --git a/crates/router/src/connector/opayo.rs b/crates/router/src/connector/opayo.rs index 495217abf085..fa94380d822a 100644 --- a/crates/router/src/connector/opayo.rs +++ b/crates/router/src/connector/opayo.rs @@ -18,7 +18,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -602,3 +602,5 @@ impl api::IncomingWebhook for Opayo { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Opayo {} diff --git a/crates/router/src/connector/opennode.rs b/crates/router/src/connector/opennode.rs index 0a1de1fdde2a..1c11da057122 100644 --- a/crates/router/src/connector/opennode.rs +++ b/crates/router/src/connector/opennode.rs @@ -16,7 +16,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -449,3 +449,5 @@ impl api::IncomingWebhook for Opennode { Ok(Box::new(notif.status)) } } + +impl ConnectorSpecifications for Opennode {} diff --git a/crates/router/src/connector/paybox.rs b/crates/router/src/connector/paybox.rs index 21db611fa872..4cd3dee924a3 100644 --- a/crates/router/src/connector/paybox.rs +++ b/crates/router/src/connector/paybox.rs @@ -21,7 +21,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -712,3 +712,5 @@ impl services::ConnectorRedirectResponse for Paybox { } } } + +impl ConnectorSpecifications for Paybox {} diff --git a/crates/router/src/connector/payme.rs b/crates/router/src/connector/payme.rs index 82679439d53e..3d8dd04882a4 100644 --- a/crates/router/src/connector/payme.rs +++ b/crates/router/src/connector/payme.rs @@ -23,7 +23,7 @@ use crate::{ }, events::connector_api_logs::ConnectorEvent, headers, - services::{self, request, ConnectorIntegration, ConnectorValidation}, + services::{self, request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -1295,3 +1295,5 @@ impl api::IncomingWebhook for Payme { }) } } + +impl ConnectorSpecifications for Payme {} diff --git a/crates/router/src/connector/payone.rs b/crates/router/src/connector/payone.rs index 6bc04ed79c5f..58b179e57992 100644 --- a/crates/router/src/connector/payone.rs +++ b/crates/router/src/connector/payone.rs @@ -30,7 +30,7 @@ use crate::{ headers, services::{ request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -429,3 +429,5 @@ impl ConnectorErrorTypeMapping for Payone { } } } + +impl ConnectorSpecifications for Payone {} diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs index 7bb0ecd21b14..567f54b42429 100644 --- a/crates/router/src/connector/paypal.rs +++ b/crates/router/src/connector/paypal.rs @@ -36,7 +36,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, PaymentAction, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, PaymentAction, }, types::{ self, @@ -2207,3 +2207,5 @@ impl ConnectorErrorTypeMapping for Paypal { } } } + +impl ConnectorSpecifications for Paypal {} diff --git a/crates/router/src/connector/placetopay.rs b/crates/router/src/connector/placetopay.rs index 82d6d3feeab5..bbec580e6a68 100644 --- a/crates/router/src/connector/placetopay.rs +++ b/crates/router/src/connector/placetopay.rs @@ -16,7 +16,7 @@ use crate::{ services::{ self, request::{self}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -690,3 +690,5 @@ impl api::IncomingWebhook for Placetopay { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Placetopay {} diff --git a/crates/router/src/connector/plaid.rs b/crates/router/src/connector/plaid.rs index 5bfd42994262..f24d7bd8d6d5 100644 --- a/crates/router/src/connector/plaid.rs +++ b/crates/router/src/connector/plaid.rs @@ -13,7 +13,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -456,3 +456,5 @@ impl api::IncomingWebhook for Plaid { Err((errors::ConnectorError::WebhooksNotImplemented).into()) } } + +impl ConnectorSpecifications for Plaid {} diff --git a/crates/router/src/connector/riskified.rs b/crates/router/src/connector/riskified.rs index 7d9feec717a5..1268e041603d 100644 --- a/crates/router/src/connector/riskified.rs +++ b/crates/router/src/connector/riskified.rs @@ -22,7 +22,7 @@ use super::utils::{self as connector_utils, FrmTransactionRouterDataRequest}; use crate::{ configs::settings, core::errors::{self, CustomResult}, - services::{self, ConnectorIntegration, ConnectorValidation}, + services::{self, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -677,3 +677,5 @@ impl api::IncomingWebhook for Riskified { Ok(Box::new(resource)) } } + +impl ConnectorSpecifications for Riskified {} diff --git a/crates/router/src/connector/signifyd.rs b/crates/router/src/connector/signifyd.rs index 4ee36d8966ba..21452819c39a 100644 --- a/crates/router/src/connector/signifyd.rs +++ b/crates/router/src/connector/signifyd.rs @@ -20,7 +20,7 @@ use crate::{ configs::settings, core::errors::{self, CustomResult}, headers, - services::{self, request, ConnectorIntegration, ConnectorValidation}, + services::{self, request, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, types::{ self, api::{self, ConnectorCommon, ConnectorCommonExt}, @@ -754,3 +754,5 @@ impl api::IncomingWebhook for Signifyd { Ok(Box::new(resource)) } } + +impl ConnectorSpecifications for Signifyd {} diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rs index 5e00c1e2ede7..1c7e8cd9801a 100644 --- a/crates/router/src/connector/stripe.rs +++ b/crates/router/src/connector/stripe.rs @@ -29,7 +29,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -2904,3 +2904,5 @@ impl self.build_error_response(res, event_builder) } } + +impl ConnectorSpecifications for Stripe {} diff --git a/crates/router/src/connector/threedsecureio.rs b/crates/router/src/connector/threedsecureio.rs index a051cf471f19..aec8f7804512 100644 --- a/crates/router/src/connector/threedsecureio.rs +++ b/crates/router/src/connector/threedsecureio.rs @@ -15,7 +15,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -530,3 +530,5 @@ impl > for Threedsecureio { } + +impl ConnectorSpecifications for Threedsecureio {} diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rs index 6562ba319760..10c71a5d3754 100644 --- a/crates/router/src/connector/trustpay.rs +++ b/crates/router/src/connector/trustpay.rs @@ -29,7 +29,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -1077,3 +1077,5 @@ impl ConnectorErrorTypeMapping for Trustpay { } } } + +impl ConnectorSpecifications for Trustpay {} diff --git a/crates/router/src/connector/wellsfargo.rs b/crates/router/src/connector/wellsfargo.rs index 36ec7cffb6bf..59ca7af6d8c0 100644 --- a/crates/router/src/connector/wellsfargo.rs +++ b/crates/router/src/connector/wellsfargo.rs @@ -27,7 +27,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -1317,3 +1317,5 @@ impl api::IncomingWebhook for Wellsfargo { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Wellsfargo {} diff --git a/crates/router/src/connector/wellsfargopayout.rs b/crates/router/src/connector/wellsfargopayout.rs index fe8f5dda25fe..33111ee7be05 100644 --- a/crates/router/src/connector/wellsfargopayout.rs +++ b/crates/router/src/connector/wellsfargopayout.rs @@ -14,7 +14,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, + ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -581,3 +581,5 @@ impl api::IncomingWebhook for Wellsfargopayout { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Wellsfargopayout {} diff --git a/crates/router/src/connector/wise.rs b/crates/router/src/connector/wise.rs index 9f41651b2f92..e4493f5016f8 100644 --- a/crates/router/src/connector/wise.rs +++ b/crates/router/src/connector/wise.rs @@ -19,7 +19,7 @@ use crate::{ services::{ self, request::{self, Mask}, - ConnectorValidation, + ConnectorSpecifications, ConnectorValidation, }, types::{ self, @@ -748,3 +748,5 @@ impl api::IncomingWebhook for Wise { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Wise {} diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index aeb4b89c6889..587a025efd26 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -1,14 +1,14 @@ use actix_web::{web, HttpRequest, Responder}; use api_models::{connector_enums::Connector, feature_matrix}; use hyperswitch_domain_models::api::ApplicationResponse; -use hyperswitch_interfaces::api::ConnectorCommon; +use hyperswitch_interfaces::api::ConnectorSpecifications; use router_env::{instrument, tracing, Flow}; use strum::IntoEnumIterator; use crate::{ self as app, core::{api_locking::LockAction, errors::RouterResponse}, - services::{api, authentication as auth}, + services::{api, authentication as auth, connector_integration_interface::ConnectorEnum}, settings, types::api::{self as api_types, payments as payment_types}, }; @@ -23,14 +23,14 @@ pub async fn fetch_connector_feature_matrix( let flow: Flow = Flow::FeatureMatrix; let payload = json_payload .map(|json_request| json_request.into_inner()) - .unwrap_or(payment_types::FeatureMatrixRequest { connectors: None }); + .unwrap_or_else(|| payment_types::FeatureMatrixRequest { connectors: None }); Box::pin(api::server_wrap( flow, state, &req, payload, - |state, (), req, _| connector_feature_matrix(state, req), + |state, (), req, _| generate_connector_feature_matrix(state, req), &auth::NoAuth, LockAction::NotApplicable, )) @@ -38,59 +38,29 @@ pub async fn fetch_connector_feature_matrix( } #[cfg(feature = "v1")] -pub async fn connector_feature_matrix( +pub async fn generate_connector_feature_matrix( state: app::SessionState, req: payment_types::FeatureMatrixRequest, ) -> RouterResponse { let connector_list = req .connectors .unwrap_or_else(|| Connector::iter().collect()); - let feature_matrix_response: Vec = connector_list - .into_iter() - .filter_map(|connector_name| { - api_types::ConnectorData::convert_connector(&connector_name.to_string()) - .ok() - .and_then(|connector| { - connector - .get_supported_payment_methods() - .map(|supported_methods| { - let payment_method_types = supported_methods - .into_iter() - .map(|(payment_method, supported_payment_method_types)| { - let payment_methods = supported_payment_method_types - .into_iter() - .map(|(payment_method_type, feature_metadata)| { - let payment_method_type_config = state.conf.pm_filters.0.get(&connector_name.to_string()) - .and_then(|selected_connector|selected_connector.0.get(&settings::PaymentMethodFilterKey::PaymentMethodType(payment_method_type))); - let supported_countries = payment_method_type_config.and_then(|config| {config.country.clone()}); - let supported_currencies = payment_method_type_config.and_then(|config| { config.currency.clone()}); - feature_matrix::SupportedPaymentMethod { - payment_method: payment_method_type, - supports_mandate: feature_metadata.supports_mandate, - supports_refund: feature_metadata.supports_refund, - supported_capture_methods: feature_metadata.supported_capture_methods, - supported_countries, - supported_currencies, - } - }) - .collect(); - - feature_matrix::SupportedPaymentMethodTypes { - payment_method_type: payment_method, - payment_methods, - } - }) - .collect(); - - payment_types::FeatureMatrixResponse { - connector: connector_name, - payment_method_types, - } - }) - }) - }) - .collect(); + let feature_matrix_response: Vec = + connector_list + .into_iter() + .filter_map(|connector_name| { + api_types::ConnectorData::convert_connector(&connector_name.to_string()) + .ok() + .and_then(|connector| { + build_connector_feature_details( + &state, + connector, + connector_name.to_string(), + ) + }) + }) + .collect(); Ok(ApplicationResponse::Json( payment_types::FeatureMatrixListResponse { @@ -99,3 +69,65 @@ pub async fn connector_feature_matrix( }, )) } + +fn build_connector_feature_details( + state: &app::SessionState, + connector: ConnectorEnum, + connector_name: String, +) -> Option { + connector + .get_supported_payment_methods() + .map(|supported_methods| { + let payment_method_types = supported_methods + .into_iter() + .map(|(payment_method, supported_payment_method_types)| { + let payment_methods = supported_payment_method_types + .into_iter() + .map(|(payment_method_type, feature_metadata)| { + let payment_method_type_config = + state.conf.pm_filters.0.get(&connector_name).and_then( + |selected_connector| { + selected_connector.0.get( + &settings::PaymentMethodFilterKey::PaymentMethodType( + payment_method_type, + ), + ) + }, + ); + + let supported_countries = payment_method_type_config + .and_then(|config| config.country.clone()); + + let supported_currencies = payment_method_type_config + .and_then(|config| config.currency.clone()); + + feature_matrix::SupportedPaymentMethod { + payment_method: payment_method_type, + supports_mandate: feature_metadata.supports_mandate, + supports_refund: feature_metadata.supports_refund, + supported_capture_methods: feature_metadata + .supported_capture_methods, + supported_countries, + supported_currencies, + } + }) + .collect(); + + feature_matrix::SupportedPaymentMethodTypes { + payment_method_type: payment_method, + payment_methods, + } + }) + .collect(); + + let connector_about = connector.get_connector_data(); + + payment_types::ConnectorFeatureMatrixResponse { + connector: connector_name, + description: connector_about.clone().map(|about| about.description), + connector_type: connector_about.clone().map(|about| about.connector_type), + supported_webhook_flows: connector.get_supported_webhook_flows(), + payment_method_types, + } + }) +} diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs index 9416ff175a85..052d7ca858ee 100644 --- a/crates/router/src/services/api.rs +++ b/crates/router/src/services/api.rs @@ -39,7 +39,8 @@ pub use hyperswitch_domain_models::{ pub use hyperswitch_interfaces::{ api::{ BoxedConnectorIntegration, CaptureSyncMethod, ConnectorIntegration, - ConnectorIntegrationAny, ConnectorRedirectResponse, ConnectorValidation, + ConnectorIntegrationAny, ConnectorRedirectResponse, ConnectorSpecifications, + ConnectorValidation, }, connector_integration_v2::{ BoxedConnectorIntegrationV2, ConnectorIntegrationAnyV2, ConnectorIntegrationV2, diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs index f36cff4d12e8..a59ae5fbf7ff 100644 --- a/crates/router/src/services/connector_integration_interface.rs +++ b/crates/router/src/services/connector_integration_interface.rs @@ -1,12 +1,15 @@ use common_utils::{crypto, errors::CustomResult, request::Request}; -use hyperswitch_domain_models::{router_data::RouterData, router_data_v2::RouterDataV2}; +use hyperswitch_domain_models::{ + router_data::RouterData, + router_data_v2::RouterDataV2, + router_response_types::{ConnectorInfo, SupportedPaymentMethods}, +}; use hyperswitch_interfaces::{ authentication::ExternalAuthenticationPayload, - connector_integration_v2::ConnectorIntegrationV2, types::SupportedPaymentMethods, - webhooks::IncomingWebhookFlowError, + connector_integration_v2::ConnectorIntegrationV2, webhooks::IncomingWebhookFlowError, }; -use super::{BoxedConnectorIntegrationV2, ConnectorValidation}; +use super::{BoxedConnectorIntegrationV2, ConnectorSpecifications, ConnectorValidation}; use crate::{ core::payments, errors, @@ -437,6 +440,31 @@ impl ConnectorValidation for ConnectorEnum { } } +impl ConnectorSpecifications for ConnectorEnum { + fn get_supported_payment_methods(&self) -> Option { + match self { + Self::Old(connector) => connector.get_supported_payment_methods(), + Self::New(connector) => connector.get_supported_payment_methods(), + } + } + + /// Supported webhooks flows + fn get_supported_webhook_flows(&self) -> Option> { + match self { + Self::Old(connector) => connector.get_supported_webhook_flows(), + Self::New(connector) => connector.get_supported_webhook_flows(), + } + } + + /// Details related to connector + fn get_connector_data(&self) -> Option { + match self { + Self::Old(connector) => connector.get_connector_data(), + Self::New(connector) => connector.get_connector_data(), + } + } +} + impl api::ConnectorCommon for ConnectorEnum { fn id(&self) -> &'static str { match self { @@ -452,13 +480,6 @@ impl api::ConnectorCommon for ConnectorEnum { } } - fn get_supported_payment_methods(&self) -> Option { - match self { - Self::Old(connector) => connector.get_supported_payment_methods(), - Self::New(connector) => connector.get_supported_payment_methods(), - } - } - fn get_auth_header( &self, auth_type: &types::ConnectorAuthType, diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs index 62519b1f58ec..3aec3aaa8a28 100644 --- a/crates/router/src/types/api/payments.rs +++ b/crates/router/src/types/api/payments.rs @@ -3,7 +3,9 @@ pub use api_models::payments::PaymentsRequest; #[cfg(feature = "v2")] pub use api_models::payments::{PaymentsCreateIntentRequest, PaymentsIntentResponse}; pub use api_models::{ - feature_matrix::{FeatureMatrixListResponse, FeatureMatrixRequest, FeatureMatrixResponse}, + feature_matrix::{ + ConnectorFeatureMatrixResponse, FeatureMatrixListResponse, FeatureMatrixRequest, + }, payments::{ AcceptanceType, Address, AddressDetails, Amount, AuthenticationForStartResponse, Card, CryptoData, CustomerAcceptance, CustomerDetailsResponse, MandateAmountData, MandateData, From c598713ca37436da5eeb26eee68b10eb59bd9244 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Mon, 9 Dec 2024 12:08:50 +0530 Subject: [PATCH 16/40] refactor(cypress): resolve comment --- cypress-tests/cypress/support/commands.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index 8aea12133bc1..bd61b2f55ed3 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -122,6 +122,12 @@ Cypress.Commands.add("ListConnectorsFeatureMatrixCall", (globalState) => { logRequestId(response.headers["x-request-id"]); expect(response.body).to.have.property("data").and.not.empty; + expect(response.body.data).to.be.an("array").and.not.empty; + response.body.data.forEach((item) => { + expect(item).to.have.property("description").and.not.empty; + expect(item).to.have.property("connector_type").and.not.empty; + expect(item).to.have.property("payment_method_types").and.not.empty; + }); }); }); From f075052419f75400ceeab6f896d32739a5f6601f Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Mon, 9 Dec 2024 13:28:06 +0530 Subject: [PATCH 17/40] feat(openapi): add request and response struct to openapi --- api-reference/openapi_spec.json | 153 ++++++++++++++++++++++++ crates/api_models/src/feature_matrix.rs | 18 +-- crates/api_models/src/webhooks.rs | 2 +- crates/common_enums/src/enums.rs | 2 +- crates/openapi/src/openapi.rs | 7 ++ 5 files changed, 171 insertions(+), 11 deletions(-) diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index 3f3ffc17a183..dfa784d3bf8c 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -8796,6 +8796,43 @@ "zsl" ] }, + "ConnectorFeatureMatrixResponse": { + "type": "object", + "required": [ + "connector", + "payment_method_types" + ], + "properties": { + "connector": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "connector_type": { + "allOf": [ + { + "$ref": "#/components/schemas/PaymentsConnectorType" + } + ], + "nullable": true + }, + "payment_method_types": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SupportedPaymentMethodTypes" + } + }, + "supported_webhook_flows": { + "type": "array", + "items": { + "$ref": "#/components/schemas/WebhookFlow" + }, + "nullable": true + } + } + }, "ConnectorMetadata": { "type": "object", "description": "Some connectors like Apple Pay, Airwallex and Noon might require some additional information, find specific details in the child attributes below.", @@ -10583,6 +10620,38 @@ } } }, + "FeatureMatrixListResponse": { + "type": "object", + "required": [ + "size", + "data" + ], + "properties": { + "size": { + "type": "integer", + "description": "The number of connectors included in the response", + "minimum": 0 + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ConnectorFeatureMatrixResponse" + } + } + } + }, + "FeatureMatrixRequest": { + "type": "object", + "properties": { + "connectors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Connector" + }, + "nullable": true + } + } + }, "FeatureMetadata": { "type": "object", "description": "additional data that might be required by hyperswitch", @@ -17094,6 +17163,15 @@ } } }, + "PaymentsConnectorType": { + "type": "string", + "description": "Connector Access Method", + "enum": [ + "payment_gateway", + "alternative_payment_method", + "bank_acquirer" + ] + }, "PaymentsCreateRequest": { "type": "object", "required": [ @@ -23926,6 +24004,66 @@ "destination" ] }, + "SupportedPaymentMethod": { + "type": "object", + "required": [ + "payment_method", + "supports_mandate", + "supports_refund", + "supported_capture_methods" + ], + "properties": { + "payment_method": { + "$ref": "#/components/schemas/PaymentMethodType" + }, + "supports_mandate": { + "type": "boolean" + }, + "supports_refund": { + "type": "boolean" + }, + "supported_capture_methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CaptureMethod" + } + }, + "supported_countries": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CountryAlpha2" + }, + "uniqueItems": true, + "nullable": true + }, + "supported_currencies": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Currency" + }, + "uniqueItems": true, + "nullable": true + } + } + }, + "SupportedPaymentMethodTypes": { + "type": "object", + "required": [ + "payment_method_type", + "payment_methods" + ], + "properties": { + "payment_method_type": { + "$ref": "#/components/schemas/PaymentMethod" + }, + "payment_methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SupportedPaymentMethod" + } + } + } + }, "SurchargeDetailsResponse": { "type": "object", "required": [ @@ -25178,6 +25316,21 @@ } }, "additionalProperties": false + }, + "WebhookFlow": { + "type": "string", + "enum": [ + "Payment", + "Payout", + "Refund", + "Dispute", + "Subscription", + "ReturnResponse", + "BankTransfer", + "Mandate", + "ExternalAuthentication", + "FraudCheck" + ] } }, "securitySchemes": { diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index df5a185469b4..65f0462db76b 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -3,29 +3,29 @@ use std::collections::HashSet; use serde::{Deserialize, Serialize}; use utoipa::ToSchema; -use crate::{enums, webhooks::WebhookFlow}; +use crate::{enums::{PaymentMethodType, CaptureMethod, CountryAlpha2, Currency, Connector, PaymentMethod, PaymentsConnectorType}, webhooks::WebhookFlow}; #[derive(Default, Debug, Deserialize, Serialize, Clone, ToSchema)] pub struct FeatureMatrixRequest { // List of connectors for which the feature matrix is requested - pub connectors: Option>, + pub connectors: Option>, } #[cfg(feature = "v1")] -#[derive(Debug, Serialize)] +#[derive(Debug, ToSchema, Serialize)] pub struct SupportedPaymentMethod { - pub payment_method: enums::PaymentMethodType, + pub payment_method: PaymentMethodType, pub supports_mandate: bool, pub supports_refund: bool, - pub supported_capture_methods: Vec, - pub supported_countries: Option>, - pub supported_currencies: Option>, + pub supported_capture_methods: Vec, + pub supported_countries: Option>, + pub supported_currencies: Option>, } #[cfg(feature = "v1")] #[derive(Debug, ToSchema, Serialize)] pub struct SupportedPaymentMethodTypes { - pub payment_method_type: enums::PaymentMethod, + pub payment_method_type: PaymentMethod, pub payment_methods: Vec, } @@ -34,7 +34,7 @@ pub struct SupportedPaymentMethodTypes { pub struct ConnectorFeatureMatrixResponse { pub connector: String, pub description: Option, - pub connector_type: Option, + pub connector_type: Option, pub payment_method_types: Vec, pub supported_webhook_flows: Option>, } diff --git a/crates/api_models/src/webhooks.rs b/crates/api_models/src/webhooks.rs index 308a3d4bb589..4700a4cc40ef 100644 --- a/crates/api_models/src/webhooks.rs +++ b/crates/api_models/src/webhooks.rs @@ -59,7 +59,7 @@ pub enum IncomingWebhookEvent { PayoutReversed, } -#[derive(Clone, Debug, Serialize)] +#[derive(Clone, Debug, Serialize, ToSchema)] pub enum WebhookFlow { Payment, #[cfg(feature = "payouts")] diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 239684267916..7ddd259623db 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -3402,7 +3402,7 @@ pub enum ErrorCategory { /// Connector Access Method #[derive( - Clone, Copy, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, strum::Display, + Clone, Copy, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, strum::Display, ToSchema, )] #[strum(serialize_all = "snake_case")] #[serde(rename_all = "snake_case")] diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index c7fa29a1b20e..b3d0629efc0c 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -288,6 +288,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::enums::AuthorizationStatus, api_models::enums::PaymentMethodStatus, api_models::enums::UIWidgetFormLayout, + api_models::enums::PaymentsConnectorType, api_models::admin::MerchantConnectorCreate, api_models::admin::AdditionalMerchantData, api_models::admin::ConnectorWalletDetails, @@ -548,6 +549,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::FrmMessage, api_models::webhooks::OutgoingWebhook, api_models::webhooks::OutgoingWebhookContent, + api_models::webhooks::WebhookFlow, api_models::enums::EventClass, api_models::enums::EventType, api_models::enums::DecoupledAuthenticationType, @@ -655,6 +657,11 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::DisplayAmountOnSdk, api_models::payments::PaymentsPostSessionTokensRequest, api_models::payments::PaymentsPostSessionTokensResponse, + api_models::feature_matrix::FeatureMatrixListResponse, + api_models::feature_matrix::FeatureMatrixRequest, + api_models::feature_matrix::ConnectorFeatureMatrixResponse, + api_models::feature_matrix::SupportedPaymentMethodTypes, + api_models::feature_matrix::SupportedPaymentMethod, )), modifiers(&SecurityAddon) )] From 454110fe71f0b4d6f5e78b0086e47f17d05f8e1f Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Mon, 9 Dec 2024 13:59:16 +0530 Subject: [PATCH 18/40] refactor(router): change the type of supported_webhook_flows field --- api-reference-v2/openapi_spec.json | 138 ++++++++++++++++++ api-reference/openapi_spec.json | 17 +-- crates/api_models/src/feature_matrix.rs | 10 +- crates/api_models/src/webhooks.rs | 1 - .../src/connectors/bambora.rs | 3 +- .../src/connectors/deutschebank.rs | 3 +- .../src/connectors/zsl.rs | 4 +- .../src/router_response_types.rs | 2 +- crates/hyperswitch_interfaces/src/api.rs | 4 +- crates/openapi/src/openapi.rs | 1 - crates/openapi/src/openapi_v2.rs | 6 + crates/router/src/routes/feature_matrix.rs | 4 +- .../connector_integration_interface.rs | 3 +- 13 files changed, 161 insertions(+), 35 deletions(-) diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 778e89ab30b6..ac1cd0b81c1b 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -6292,6 +6292,43 @@ "zsl" ] }, + "ConnectorFeatureMatrixResponse": { + "type": "object", + "required": [ + "connector", + "payment_method_types" + ], + "properties": { + "connector": { + "type": "string" + }, + "description": { + "type": "string", + "nullable": true + }, + "connector_type": { + "allOf": [ + { + "$ref": "#/components/schemas/PaymentsConnectorType" + } + ], + "nullable": true + }, + "payment_method_types": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SupportedPaymentMethodTypes" + } + }, + "supported_webhook_flows": { + "type": "array", + "items": { + "$ref": "#/components/schemas/EventClass" + }, + "nullable": true + } + } + }, "ConnectorMetadata": { "type": "object", "description": "Some connectors like Apple Pay, Airwallex and Noon might require some additional information, find specific details in the child attributes below.", @@ -8099,6 +8136,38 @@ } } }, + "FeatureMatrixListResponse": { + "type": "object", + "required": [ + "size", + "data" + ], + "properties": { + "size": { + "type": "integer", + "description": "The number of connectors included in the response", + "minimum": 0 + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/ConnectorFeatureMatrixResponse" + } + } + } + }, + "FeatureMatrixRequest": { + "type": "object", + "properties": { + "connectors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Connector" + }, + "nullable": true + } + } + }, "FeatureMetadata": { "type": "object", "description": "additional data that might be required by hyperswitch", @@ -14114,6 +14183,15 @@ } } }, + "PaymentsConnectorType": { + "type": "string", + "description": "Connector Access Method", + "enum": [ + "payment_gateway", + "alternative_payment_method", + "bank_acquirer" + ] + }, "PaymentsCreateIntentRequest": { "type": "object", "required": [ @@ -19728,6 +19806,66 @@ "destination" ] }, + "SupportedPaymentMethod": { + "type": "object", + "required": [ + "payment_method", + "supports_mandate", + "supports_refund", + "supported_capture_methods" + ], + "properties": { + "payment_method": { + "$ref": "#/components/schemas/PaymentMethodType" + }, + "supports_mandate": { + "type": "boolean" + }, + "supports_refund": { + "type": "boolean" + }, + "supported_capture_methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CaptureMethod" + } + }, + "supported_countries": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CountryAlpha2" + }, + "uniqueItems": true, + "nullable": true + }, + "supported_currencies": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Currency" + }, + "uniqueItems": true, + "nullable": true + } + } + }, + "SupportedPaymentMethodTypes": { + "type": "object", + "required": [ + "payment_method_type", + "payment_methods" + ], + "properties": { + "payment_method_type": { + "$ref": "#/components/schemas/PaymentMethod" + }, + "payment_methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/SupportedPaymentMethod" + } + } + } + }, "SurchargeCalculationOverride": { "type": "string", "enum": [ diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index dfa784d3bf8c..a10ecddf68a4 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -8827,7 +8827,7 @@ "supported_webhook_flows": { "type": "array", "items": { - "$ref": "#/components/schemas/WebhookFlow" + "$ref": "#/components/schemas/EventClass" }, "nullable": true } @@ -25316,21 +25316,6 @@ } }, "additionalProperties": false - }, - "WebhookFlow": { - "type": "string", - "enum": [ - "Payment", - "Payout", - "Refund", - "Dispute", - "Subscription", - "ReturnResponse", - "BankTransfer", - "Mandate", - "ExternalAuthentication", - "FraudCheck" - ] } }, "securitySchemes": { diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index 65f0462db76b..dd3758ca3893 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -3,7 +3,7 @@ use std::collections::HashSet; use serde::{Deserialize, Serialize}; use utoipa::ToSchema; -use crate::{enums::{PaymentMethodType, CaptureMethod, CountryAlpha2, Currency, Connector, PaymentMethod, PaymentsConnectorType}, webhooks::WebhookFlow}; +use crate::enums::{PaymentMethodType, CaptureMethod, CountryAlpha2, Currency, Connector, PaymentMethod, PaymentsConnectorType, EventClass}; #[derive(Default, Debug, Deserialize, Serialize, Clone, ToSchema)] pub struct FeatureMatrixRequest { @@ -11,7 +11,7 @@ pub struct FeatureMatrixRequest { pub connectors: Option>, } -#[cfg(feature = "v1")] + #[derive(Debug, ToSchema, Serialize)] pub struct SupportedPaymentMethod { pub payment_method: PaymentMethodType, @@ -22,21 +22,21 @@ pub struct SupportedPaymentMethod { pub supported_currencies: Option>, } -#[cfg(feature = "v1")] + #[derive(Debug, ToSchema, Serialize)] pub struct SupportedPaymentMethodTypes { pub payment_method_type: PaymentMethod, pub payment_methods: Vec, } -#[cfg(feature = "v1")] + #[derive(Debug, ToSchema, Serialize)] pub struct ConnectorFeatureMatrixResponse { pub connector: String, pub description: Option, pub connector_type: Option, pub payment_method_types: Vec, - pub supported_webhook_flows: Option>, + pub supported_webhook_flows: Option>, } #[derive(Debug, Serialize, ToSchema)] diff --git a/crates/api_models/src/webhooks.rs b/crates/api_models/src/webhooks.rs index 4700a4cc40ef..e6f4065eb7a9 100644 --- a/crates/api_models/src/webhooks.rs +++ b/crates/api_models/src/webhooks.rs @@ -59,7 +59,6 @@ pub enum IncomingWebhookEvent { PayoutReversed, } -#[derive(Clone, Debug, Serialize, ToSchema)] pub enum WebhookFlow { Payment, #[cfg(feature = "payouts")] diff --git a/crates/hyperswitch_connectors/src/connectors/bambora.rs b/crates/hyperswitch_connectors/src/connectors/bambora.rs index 62413f0ca8c2..f96941bfc864 100644 --- a/crates/hyperswitch_connectors/src/connectors/bambora.rs +++ b/crates/hyperswitch_connectors/src/connectors/bambora.rs @@ -2,7 +2,6 @@ pub mod transformers; use std::fmt::Debug; -use api_models::webhooks::WebhookFlow; use common_enums::enums; use common_utils::{ errors::CustomResult, @@ -853,7 +852,7 @@ impl ConnectorSpecifications for Bambora { Some(bambora_supported_payment_methods) } - fn get_supported_webhook_flows(&self) -> Option> { + fn get_supported_webhook_flows(&self) -> Option> { Some(Vec::new()) } } diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs index 91ba3fa57960..5a66d9a4cffd 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs @@ -3,7 +3,6 @@ pub mod transformers; use std::time::SystemTime; use actix_web::http::header::Date; -use api_models::webhooks::WebhookFlow; use base64::Engine; use common_enums::{enums, PaymentsConnectorType}; use common_utils::{ @@ -968,7 +967,7 @@ impl ConnectorSpecifications for Deutschebank { Some(deutschebank_supported_payment_methods) } - fn get_supported_webhook_flows(&self) -> Option> { + fn get_supported_webhook_flows(&self) -> Option> { Some(Vec::new()) } } diff --git a/crates/hyperswitch_connectors/src/connectors/zsl.rs b/crates/hyperswitch_connectors/src/connectors/zsl.rs index d0e108079464..76ce52794315 100644 --- a/crates/hyperswitch_connectors/src/connectors/zsl.rs +++ b/crates/hyperswitch_connectors/src/connectors/zsl.rs @@ -2,7 +2,7 @@ pub mod transformers; use std::fmt::Debug; -use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId, WebhookFlow}; +use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId}; use common_enums::{enums, PaymentsConnectorType}; use common_utils::{ errors::CustomResult, @@ -489,7 +489,7 @@ impl ConnectorSpecifications for Zsl { Some(zsl_supported_payment_methods) } - fn get_supported_webhook_flows(&self) -> Option> { + fn get_supported_webhook_flows(&self) -> Option> { Some(Vec::new()) } } diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs index f25282485846..963432ed12c7 100644 --- a/crates/hyperswitch_domain_models/src/router_response_types.rs +++ b/crates/hyperswitch_domain_models/src/router_response_types.rs @@ -520,7 +520,7 @@ pub struct PaymentMethodDetails { pub supports_mandate: bool, /// Indicates whether refund is supported by this payment method. pub supports_refund: bool, - /// Indicates whether manual capture supported is supported by this payment method. + /// List of supported capture methods pub supported_capture_methods: Vec, } diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index c4361e5dc624..89d7e9521331 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -18,7 +18,7 @@ pub mod refunds; pub mod refunds_v2; use common_enums::{ - enums::{CallConnectorAction, CaptureMethod, PaymentAction, PaymentMethodType}, + enums::{CallConnectorAction, CaptureMethod, PaymentAction, PaymentMethodType, EventClass}, PaymentMethod, }; use common_utils::{ @@ -289,7 +289,7 @@ pub trait ConnectorSpecifications { } /// Supported webhooks flows - fn get_supported_webhook_flows(&self) -> Option> { + fn get_supported_webhook_flows(&self) -> Option> { None } diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index b3d0629efc0c..4f04a5765331 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -549,7 +549,6 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::FrmMessage, api_models::webhooks::OutgoingWebhook, api_models::webhooks::OutgoingWebhookContent, - api_models::webhooks::WebhookFlow, api_models::enums::EventClass, api_models::enums::EventType, api_models::enums::DecoupledAuthenticationType, diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs index 2221055be5ab..47811487eb47 100644 --- a/crates/openapi/src/openapi_v2.rs +++ b/crates/openapi/src/openapi_v2.rs @@ -247,6 +247,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::enums::ConnectorStatus, api_models::enums::AuthorizationStatus, api_models::enums::PaymentMethodStatus, + api_models::enums::PaymentsConnectorType, api_models::enums::OrderFulfillmentTimeOrigin, api_models::enums::UIWidgetFormLayout, api_models::admin::MerchantConnectorCreate, @@ -618,6 +619,11 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::PaymentsDynamicTaxCalculationResponse, api_models::payments::DisplayAmountOnSdk, api_models::payments::ErrorDetails, + api_models::feature_matrix::FeatureMatrixListResponse, + api_models::feature_matrix::FeatureMatrixRequest, + api_models::feature_matrix::ConnectorFeatureMatrixResponse, + api_models::feature_matrix::SupportedPaymentMethodTypes, + api_models::feature_matrix::SupportedPaymentMethod, common_utils::types::BrowserInformation, api_models::payments::ConfirmIntentAmountDetailsResponse, routes::payments::ForceSync, diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index 587a025efd26..d58d33a178a2 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -13,7 +13,7 @@ use crate::{ types::api::{self as api_types, payments as payment_types}, }; -#[cfg(all(feature = "olap", feature = "v1"))] + #[instrument(skip_all)] pub async fn fetch_connector_feature_matrix( state: web::Data, @@ -37,7 +37,7 @@ pub async fn fetch_connector_feature_matrix( .await } -#[cfg(feature = "v1")] + pub async fn generate_connector_feature_matrix( state: app::SessionState, req: payment_types::FeatureMatrixRequest, diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs index a59ae5fbf7ff..82d875e7d0a7 100644 --- a/crates/router/src/services/connector_integration_interface.rs +++ b/crates/router/src/services/connector_integration_interface.rs @@ -1,3 +1,4 @@ +use common_enums::EventClass; use common_utils::{crypto, errors::CustomResult, request::Request}; use hyperswitch_domain_models::{ router_data::RouterData, @@ -449,7 +450,7 @@ impl ConnectorSpecifications for ConnectorEnum { } /// Supported webhooks flows - fn get_supported_webhook_flows(&self) -> Option> { + fn get_supported_webhook_flows(&self) -> Option> { match self { Self::Old(connector) => connector.get_supported_webhook_flows(), Self::New(connector) => connector.get_supported_webhook_flows(), From ca4e8d5009ac1716cec598201918c89ed0e119c3 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Mon, 9 Dec 2024 14:19:58 +0530 Subject: [PATCH 19/40] fix(router): merge conflicts --- crates/router/src/types/api/payments.rs | 27 +++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs index e44db9f114f2..c599999ec64b 100644 --- a/crates/router/src/types/api/payments.rs +++ b/crates/router/src/types/api/payments.rs @@ -1,5 +1,23 @@ #[cfg(feature = "v1")] pub use api_models::payments::PaymentsRequest; +pub use api_models::payments::{ + AcceptanceType, Address, AddressDetails, Amount, AuthenticationForStartResponse, Card, + CryptoData, CustomerAcceptance, CustomerDetailsResponse, MandateAmountData, MandateData, + MandateTransactionType, MandateType, MandateValidationFields, NextActionType, OnlineMandate, + OpenBankingSessionToken, PayLaterData, PaymentIdType, PaymentListConstraints, + PaymentListFilterConstraints, PaymentListFilters, PaymentListFiltersV2, PaymentListResponse, + PaymentListResponseV2, PaymentMethodData, PaymentMethodDataRequest, PaymentMethodDataResponse, + PaymentOp, PaymentRetrieveBody, PaymentRetrieveBodyWithCredentials, PaymentsAggregateResponse, + PaymentsApproveRequest, PaymentsCancelRequest, PaymentsCaptureRequest, + PaymentsCompleteAuthorizeRequest, PaymentsDynamicTaxCalculationRequest, + PaymentsDynamicTaxCalculationResponse, PaymentsExternalAuthenticationRequest, + PaymentsIncrementalAuthorizationRequest, PaymentsManualUpdateRequest, + PaymentsPostSessionTokensRequest, PaymentsPostSessionTokensResponse, PaymentsRedirectRequest, + PaymentsRedirectionResponse, PaymentsRejectRequest, PaymentsResponse, PaymentsResponseForm, + PaymentsRetrieveRequest, PaymentsSessionRequest, PaymentsSessionResponse, PaymentsStartRequest, + PgRedirectResponse, PhoneDetails, RedirectionResponse, SessionToken, UrlDetails, VerifyRequest, + VerifyResponse, WalletData, +}; #[cfg(feature = "v2")] pub use api_models::payments::{ PaymentsCreateIntentRequest, PaymentsIntentResponse, PaymentsUpdateIntentRequest, @@ -18,9 +36,6 @@ pub use hyperswitch_interfaces::api::payments::{ PaymentToken, PaymentVoid, PaymentsCompleteAuthorize, PaymentsPostProcessing, PaymentsPreProcessing, TaxCalculation, }; -feature_matrix::{ - ConnectorFeatureMatrixResponse, FeatureMatrixListResponse, FeatureMatrixRequest, -}, pub use super::payments_v2::{ ConnectorCustomerV2, MandateSetupV2, PaymentApproveV2, PaymentAuthorizeSessionTokenV2, @@ -29,6 +44,10 @@ pub use super::payments_v2::{ PaymentSyncV2, PaymentTokenV2, PaymentV2, PaymentVoidV2, PaymentsCompleteAuthorizeV2, PaymentsPostProcessingV2, PaymentsPreProcessingV2, TaxCalculationV2, }; + +pub use api_models::feature_matrix::{ + ConnectorFeatureMatrixResponse, FeatureMatrixListResponse, FeatureMatrixRequest, +}; use crate::core::errors; pub trait PaymentIdTypeExt { @@ -158,4 +177,4 @@ mod payments_test { let ds_sample_1 = serde_json::from_str::(&s_sample_1).unwrap(); assert_eq!(ds_sample_1, sample_1) } -} +} \ No newline at end of file From bb26e3c98a04c58c067546b2ef9250c4d13a2bda Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Mon, 9 Dec 2024 14:20:46 +0530 Subject: [PATCH 20/40] fix(router): fix formatting --- crates/api_models/src/feature_matrix.rs | 8 ++-- crates/common_enums/src/enums.rs | 10 ++++- crates/hyperswitch_interfaces/src/api.rs | 2 +- crates/router/src/routes/feature_matrix.rs | 2 - crates/router/src/types/api/payments.rs | 48 +++++++++++----------- 5 files changed, 39 insertions(+), 31 deletions(-) diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index dd3758ca3893..c3c436cad1e3 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -3,7 +3,10 @@ use std::collections::HashSet; use serde::{Deserialize, Serialize}; use utoipa::ToSchema; -use crate::enums::{PaymentMethodType, CaptureMethod, CountryAlpha2, Currency, Connector, PaymentMethod, PaymentsConnectorType, EventClass}; +use crate::enums::{ + CaptureMethod, Connector, CountryAlpha2, Currency, EventClass, PaymentMethod, + PaymentMethodType, PaymentsConnectorType, +}; #[derive(Default, Debug, Deserialize, Serialize, Clone, ToSchema)] pub struct FeatureMatrixRequest { @@ -11,7 +14,6 @@ pub struct FeatureMatrixRequest { pub connectors: Option>, } - #[derive(Debug, ToSchema, Serialize)] pub struct SupportedPaymentMethod { pub payment_method: PaymentMethodType, @@ -22,14 +24,12 @@ pub struct SupportedPaymentMethod { pub supported_currencies: Option>, } - #[derive(Debug, ToSchema, Serialize)] pub struct SupportedPaymentMethodTypes { pub payment_method_type: PaymentMethod, pub payment_methods: Vec, } - #[derive(Debug, ToSchema, Serialize)] pub struct ConnectorFeatureMatrixResponse { pub connector: String, diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 6cb4542cf493..6ebc0725ca4d 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -3466,7 +3466,15 @@ pub enum ErrorCategory { /// Connector Access Method #[derive( - Clone, Copy, Debug, Eq, PartialEq, serde::Deserialize, serde::Serialize, strum::Display, ToSchema, + Clone, + Copy, + Debug, + Eq, + PartialEq, + serde::Deserialize, + serde::Serialize, + strum::Display, + ToSchema, )] #[strum(serialize_all = "snake_case")] #[serde(rename_all = "snake_case")] diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index 89d7e9521331..9ee4bf1d32cf 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -18,7 +18,7 @@ pub mod refunds; pub mod refunds_v2; use common_enums::{ - enums::{CallConnectorAction, CaptureMethod, PaymentAction, PaymentMethodType, EventClass}, + enums::{CallConnectorAction, CaptureMethod, EventClass, PaymentAction, PaymentMethodType}, PaymentMethod, }; use common_utils::{ diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index d58d33a178a2..d237f3dea398 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -13,7 +13,6 @@ use crate::{ types::api::{self as api_types, payments as payment_types}, }; - #[instrument(skip_all)] pub async fn fetch_connector_feature_matrix( state: web::Data, @@ -37,7 +36,6 @@ pub async fn fetch_connector_feature_matrix( .await } - pub async fn generate_connector_feature_matrix( state: app::SessionState, req: payment_types::FeatureMatrixRequest, diff --git a/crates/router/src/types/api/payments.rs b/crates/router/src/types/api/payments.rs index c599999ec64b..6ec0fe701e9c 100644 --- a/crates/router/src/types/api/payments.rs +++ b/crates/router/src/types/api/payments.rs @@ -1,27 +1,33 @@ #[cfg(feature = "v1")] pub use api_models::payments::PaymentsRequest; -pub use api_models::payments::{ - AcceptanceType, Address, AddressDetails, Amount, AuthenticationForStartResponse, Card, - CryptoData, CustomerAcceptance, CustomerDetailsResponse, MandateAmountData, MandateData, - MandateTransactionType, MandateType, MandateValidationFields, NextActionType, OnlineMandate, - OpenBankingSessionToken, PayLaterData, PaymentIdType, PaymentListConstraints, - PaymentListFilterConstraints, PaymentListFilters, PaymentListFiltersV2, PaymentListResponse, - PaymentListResponseV2, PaymentMethodData, PaymentMethodDataRequest, PaymentMethodDataResponse, - PaymentOp, PaymentRetrieveBody, PaymentRetrieveBodyWithCredentials, PaymentsAggregateResponse, - PaymentsApproveRequest, PaymentsCancelRequest, PaymentsCaptureRequest, - PaymentsCompleteAuthorizeRequest, PaymentsDynamicTaxCalculationRequest, - PaymentsDynamicTaxCalculationResponse, PaymentsExternalAuthenticationRequest, - PaymentsIncrementalAuthorizationRequest, PaymentsManualUpdateRequest, - PaymentsPostSessionTokensRequest, PaymentsPostSessionTokensResponse, PaymentsRedirectRequest, - PaymentsRedirectionResponse, PaymentsRejectRequest, PaymentsResponse, PaymentsResponseForm, - PaymentsRetrieveRequest, PaymentsSessionRequest, PaymentsSessionResponse, PaymentsStartRequest, - PgRedirectResponse, PhoneDetails, RedirectionResponse, SessionToken, UrlDetails, VerifyRequest, - VerifyResponse, WalletData, -}; #[cfg(feature = "v2")] pub use api_models::payments::{ PaymentsCreateIntentRequest, PaymentsIntentResponse, PaymentsUpdateIntentRequest, }; +pub use api_models::{ + feature_matrix::{ + ConnectorFeatureMatrixResponse, FeatureMatrixListResponse, FeatureMatrixRequest, + }, + payments::{ + AcceptanceType, Address, AddressDetails, Amount, AuthenticationForStartResponse, Card, + CryptoData, CustomerAcceptance, CustomerDetailsResponse, MandateAmountData, MandateData, + MandateTransactionType, MandateType, MandateValidationFields, NextActionType, + OnlineMandate, OpenBankingSessionToken, PayLaterData, PaymentIdType, + PaymentListConstraints, PaymentListFilterConstraints, PaymentListFilters, + PaymentListFiltersV2, PaymentListResponse, PaymentListResponseV2, PaymentMethodData, + PaymentMethodDataRequest, PaymentMethodDataResponse, PaymentOp, PaymentRetrieveBody, + PaymentRetrieveBodyWithCredentials, PaymentsAggregateResponse, PaymentsApproveRequest, + PaymentsCancelRequest, PaymentsCaptureRequest, PaymentsCompleteAuthorizeRequest, + PaymentsDynamicTaxCalculationRequest, PaymentsDynamicTaxCalculationResponse, + PaymentsExternalAuthenticationRequest, PaymentsIncrementalAuthorizationRequest, + PaymentsManualUpdateRequest, PaymentsPostSessionTokensRequest, + PaymentsPostSessionTokensResponse, PaymentsRedirectRequest, PaymentsRedirectionResponse, + PaymentsRejectRequest, PaymentsResponse, PaymentsResponseForm, PaymentsRetrieveRequest, + PaymentsSessionRequest, PaymentsSessionResponse, PaymentsStartRequest, PgRedirectResponse, + PhoneDetails, RedirectionResponse, SessionToken, UrlDetails, VerifyRequest, VerifyResponse, + WalletData, + }, +}; use error_stack::ResultExt; pub use hyperswitch_domain_models::router_flow_types::payments::{ Approve, Authorize, AuthorizeSessionToken, Balance, CalculateTax, Capture, CompleteAuthorize, @@ -44,10 +50,6 @@ pub use super::payments_v2::{ PaymentSyncV2, PaymentTokenV2, PaymentV2, PaymentVoidV2, PaymentsCompleteAuthorizeV2, PaymentsPostProcessingV2, PaymentsPreProcessingV2, TaxCalculationV2, }; - -pub use api_models::feature_matrix::{ - ConnectorFeatureMatrixResponse, FeatureMatrixListResponse, FeatureMatrixRequest, -}; use crate::core::errors; pub trait PaymentIdTypeExt { @@ -177,4 +179,4 @@ mod payments_test { let ds_sample_1 = serde_json::from_str::(&s_sample_1).unwrap(); assert_eq!(ds_sample_1, sample_1) } -} \ No newline at end of file +} From 9cf45c7f212d0ce376941f51ec69a8089bdda299 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Tue, 10 Dec 2024 13:41:03 +0530 Subject: [PATCH 21/40] fix(clippy): remove ref from validation functions --- api-reference-v2/openapi_spec.json | 24 ++-- api-reference/openapi_spec.json | 24 ++-- connector-template/mod.rs | 12 +- crates/api_models/src/feature_matrix.rs | 8 +- crates/common_enums/src/enums.rs | 2 +- .../src/connectors/airwallex.rs | 2 +- .../src/connectors/bambora.rs | 4 +- .../src/connectors/bamboraapac.rs | 2 +- .../src/connectors/billwerk.rs | 2 +- .../src/connectors/boku.rs | 2 +- .../src/connectors/cashtocode.rs | 2 +- .../src/connectors/coinbase.rs | 2 +- .../src/connectors/deutschebank.rs | 6 +- .../src/connectors/digitalvirgo.rs | 2 +- .../src/connectors/dlocal.rs | 2 +- .../src/connectors/elavon.rs | 2 +- .../src/connectors/fiserv.rs | 2 +- .../src/connectors/fiservemea.rs | 2 +- .../src/connectors/fiuu.rs | 2 +- .../src/connectors/forte.rs | 2 +- .../src/connectors/gocardless.rs | 2 +- .../src/connectors/helcim.rs | 2 +- .../src/connectors/multisafepay.rs | 2 +- .../src/connectors/nexinets.rs | 2 +- .../src/connectors/nexixpay.rs | 2 +- .../src/connectors/novalnet.rs | 2 +- .../src/connectors/payeezy.rs | 2 +- .../src/connectors/payu.rs | 2 +- .../src/connectors/powertranz.rs | 2 +- .../src/connectors/rapyd.rs | 2 +- .../src/connectors/shift4.rs | 2 +- .../src/connectors/square.rs | 2 +- .../src/connectors/stax.rs | 2 +- .../src/connectors/tsys.rs | 2 +- .../src/connectors/worldline.rs | 2 +- .../src/connectors/worldpay.rs | 2 +- .../src/connectors/zsl.rs | 8 +- .../src/router_response_types.rs | 7 +- crates/hyperswitch_interfaces/src/api.rs | 31 ++--- crates/openapi/src/openapi.rs | 2 +- crates/openapi/src/openapi_v2.rs | 2 +- crates/router/src/connector/adyen.rs | 2 +- .../router/src/connector/authorizedotnet.rs | 2 +- crates/router/src/connector/bankofamerica.rs | 2 +- crates/router/src/connector/bluesnap.rs | 2 +- crates/router/src/connector/braintree.rs | 2 +- crates/router/src/connector/checkout.rs | 2 +- crates/router/src/connector/cybersource.rs | 2 +- crates/router/src/connector/datatrans.rs | 2 +- crates/router/src/connector/dummyconnector.rs | 2 +- crates/router/src/connector/globalpay.rs | 2 +- crates/router/src/connector/klarna.rs | 2 +- crates/router/src/connector/nmi.rs | 2 +- crates/router/src/connector/noon.rs | 2 +- crates/router/src/connector/nuvei.rs | 2 +- crates/router/src/connector/opayo.rs | 2 +- crates/router/src/connector/paybox.rs | 2 +- crates/router/src/connector/payme.rs | 2 +- crates/router/src/connector/paypal.rs | 2 +- crates/router/src/connector/placetopay.rs | 2 +- crates/router/src/connector/stripe.rs | 2 +- crates/router/src/connector/wellsfargo.rs | 2 +- .../src/core/payments/flows/authorize_flow.rs | 7 +- crates/router/src/routes/app.rs | 2 +- crates/router/src/routes/feature_matrix.rs | 117 ++++++++++-------- .../connector_integration_interface.rs | 12 +- 66 files changed, 188 insertions(+), 180 deletions(-) diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 173651cfb970..3a617f5dee3a 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -6438,7 +6438,7 @@ "type": "object", "required": [ "connector", - "payment_method_types" + "supported_payment_methods" ], "properties": { "connector": { @@ -6451,12 +6451,12 @@ "connector_type": { "allOf": [ { - "$ref": "#/components/schemas/PaymentsConnectorType" + "$ref": "#/components/schemas/PaymentConnectorCategory" } ], "nullable": true }, - "payment_method_types": { + "supported_payment_methods": { "type": "array", "items": { "$ref": "#/components/schemas/SupportedPaymentMethodTypes" @@ -12509,6 +12509,15 @@ } ] }, + "PaymentConnectorCategory": { + "type": "string", + "description": "Connector Access Method", + "enum": [ + "payment_gateway", + "alternative_payment_method", + "bank_acquirer" + ] + }, "PaymentCreatePaymentLinkConfig": { "allOf": [ { @@ -14325,15 +14334,6 @@ } } }, - "PaymentsConnectorType": { - "type": "string", - "description": "Connector Access Method", - "enum": [ - "payment_gateway", - "alternative_payment_method", - "bank_acquirer" - ] - }, "PaymentsCreateIntentRequest": { "type": "object", "required": [ diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index a10ecddf68a4..520c977dcb07 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -8800,7 +8800,7 @@ "type": "object", "required": [ "connector", - "payment_method_types" + "supported_payment_methods" ], "properties": { "connector": { @@ -8813,12 +8813,12 @@ "connector_type": { "allOf": [ { - "$ref": "#/components/schemas/PaymentsConnectorType" + "$ref": "#/components/schemas/PaymentConnectorCategory" } ], "nullable": true }, - "payment_method_types": { + "supported_payment_methods": { "type": "array", "items": { "$ref": "#/components/schemas/SupportedPaymentMethodTypes" @@ -15224,6 +15224,15 @@ } ] }, + "PaymentConnectorCategory": { + "type": "string", + "description": "Connector Access Method", + "enum": [ + "payment_gateway", + "alternative_payment_method", + "bank_acquirer" + ] + }, "PaymentCreatePaymentLinkConfig": { "allOf": [ { @@ -17163,15 +17172,6 @@ } } }, - "PaymentsConnectorType": { - "type": "string", - "description": "Connector Access Method", - "enum": [ - "payment_gateway", - "alternative_payment_method", - "bank_acquirer" - ] - }, "PaymentsCreateRequest": { "type": "object", "required": [ diff --git a/connector-template/mod.rs b/connector-template/mod.rs index 08b7bc4306e3..d4b8ed16b4d8 100644 --- a/connector-template/mod.rs +++ b/connector-template/mod.rs @@ -3,7 +3,7 @@ pub mod transformers; use error_stack::{report, ResultExt}; use masking::{ExposeInterface, Mask}; -use common_enums::enums::PaymentsConnectorType; +use common_enums::enums::PaymentConnectorCategory; use common_utils::{ errors::CustomResult, ext_traits::BytesExt, @@ -27,7 +27,7 @@ use hyperswitch_domain_models::{ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData, }, - router_response_types::{ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods, SupportedPaymentMethodsExt}, + router_response_types::{ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods}, types::{ PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData, @@ -555,18 +555,18 @@ impl webhooks::IncomingWebhook for {{project-name | downcase | pascal_case}} { } impl ConnectorSpecifications for {{project-name | downcase | pascal_case}} { - fn get_connector_data(&self) -> Option { + fn get_connector_about(&self) -> Option { Some(ConnectorInfo { description: "Connector About" .to_string(), - connector_type: PaymentsConnectorType::PaymentGateway, + connector_type: PaymentConnectorCategory::PaymentGateway, }) } fn get_supported_payment_methods(&self) -> Option { - let mut bambora_supported_payment_methods = SupportedPaymentMethods::new(); - Some(bambora_supported_payment_methods) + let mut supported_payment_methods = SupportedPaymentMethods::new(); + Some(supported_payment_methods) } fn get_supported_webhook_flows(&self) -> Option> { diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index c3c436cad1e3..132772688931 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -4,8 +4,8 @@ use serde::{Deserialize, Serialize}; use utoipa::ToSchema; use crate::enums::{ - CaptureMethod, Connector, CountryAlpha2, Currency, EventClass, PaymentMethod, - PaymentMethodType, PaymentsConnectorType, + CaptureMethod, Connector, CountryAlpha2, Currency, EventClass, PaymentConnectorCategory, + PaymentMethod, PaymentMethodType, }; #[derive(Default, Debug, Deserialize, Serialize, Clone, ToSchema)] @@ -34,8 +34,8 @@ pub struct SupportedPaymentMethodTypes { pub struct ConnectorFeatureMatrixResponse { pub connector: String, pub description: Option, - pub connector_type: Option, - pub payment_method_types: Vec, + pub connector_type: Option, + pub supported_payment_methods: Vec, pub supported_webhook_flows: Option>, } diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 6ebc0725ca4d..d902151fa388 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -3478,7 +3478,7 @@ pub enum ErrorCategory { )] #[strum(serialize_all = "snake_case")] #[serde(rename_all = "snake_case")] -pub enum PaymentsConnectorType { +pub enum PaymentConnectorCategory { PaymentGateway, AlternativePaymentMethod, BankAcquirer, diff --git a/crates/hyperswitch_connectors/src/connectors/airwallex.rs b/crates/hyperswitch_connectors/src/connectors/airwallex.rs index 0a9cc4fbd144..862aac4ad377 100644 --- a/crates/hyperswitch_connectors/src/connectors/airwallex.rs +++ b/crates/hyperswitch_connectors/src/connectors/airwallex.rs @@ -130,7 +130,7 @@ impl ConnectorValidation for Airwallex { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/bambora.rs b/crates/hyperswitch_connectors/src/connectors/bambora.rs index f96941bfc864..f5ff984c387b 100644 --- a/crates/hyperswitch_connectors/src/connectors/bambora.rs +++ b/crates/hyperswitch_connectors/src/connectors/bambora.rs @@ -817,12 +817,12 @@ impl webhooks::IncomingWebhook for Bambora { } impl ConnectorSpecifications for Bambora { - fn get_connector_data(&self) -> Option { + fn get_connector_about(&self) -> Option { Some(ConnectorInfo { description: "Bambora is a leading online payment provider in Canada and United States." .to_string(), - connector_type: enums::PaymentsConnectorType::PaymentGateway, + connector_type: enums::PaymentConnectorCategory::PaymentGateway, }) } diff --git a/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs b/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs index 67cd53522bcf..9f05cd9b4114 100644 --- a/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs +++ b/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs @@ -101,7 +101,7 @@ impl ConnectorValidation for Bamboraapac { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/billwerk.rs b/crates/hyperswitch_connectors/src/connectors/billwerk.rs index db7da9e03f33..06fbd695bcec 100644 --- a/crates/hyperswitch_connectors/src/connectors/billwerk.rs +++ b/crates/hyperswitch_connectors/src/connectors/billwerk.rs @@ -157,7 +157,7 @@ impl ConnectorValidation for Billwerk { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &common_enums::PaymentMethod, + _payment_method: common_enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/boku.rs b/crates/hyperswitch_connectors/src/connectors/boku.rs index c85db2be8b71..d179544cd4ba 100644 --- a/crates/hyperswitch_connectors/src/connectors/boku.rs +++ b/crates/hyperswitch_connectors/src/connectors/boku.rs @@ -174,7 +174,7 @@ impl ConnectorValidation for Boku { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/cashtocode.rs b/crates/hyperswitch_connectors/src/connectors/cashtocode.rs index 4dc4b58acbe7..40f5b7bfe725 100644 --- a/crates/hyperswitch_connectors/src/connectors/cashtocode.rs +++ b/crates/hyperswitch_connectors/src/connectors/cashtocode.rs @@ -154,7 +154,7 @@ impl ConnectorValidation for Cashtocode { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/coinbase.rs b/crates/hyperswitch_connectors/src/connectors/coinbase.rs index 8c86418e9641..db50932fdea2 100644 --- a/crates/hyperswitch_connectors/src/connectors/coinbase.rs +++ b/crates/hyperswitch_connectors/src/connectors/coinbase.rs @@ -139,7 +139,7 @@ impl ConnectorValidation for Coinbase { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs index 5a66d9a4cffd..cebc9f2228cf 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs @@ -4,7 +4,7 @@ use std::time::SystemTime; use actix_web::http::header::Date; use base64::Engine; -use common_enums::{enums, PaymentsConnectorType}; +use common_enums::{enums, PaymentConnectorCategory}; use common_utils::{ errors::CustomResult, ext_traits::BytesExt, @@ -940,12 +940,12 @@ impl webhooks::IncomingWebhook for Deutschebank { } impl ConnectorSpecifications for Deutschebank { - fn get_connector_data(&self) -> Option { + fn get_connector_about(&self) -> Option { Some(ConnectorInfo { description: "Deutsche Bank is a German multinational investment bank and financial services company " .to_string(), - connector_type: PaymentsConnectorType::BankAcquirer, + connector_type: PaymentConnectorCategory::BankAcquirer, }) } diff --git a/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs b/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs index abc01f998ff8..5e03e780b0e8 100644 --- a/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs +++ b/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs @@ -166,7 +166,7 @@ impl ConnectorValidation for Digitalvirgo { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/dlocal.rs b/crates/hyperswitch_connectors/src/connectors/dlocal.rs index d3c8a015b9ea..fefe21714cd4 100644 --- a/crates/hyperswitch_connectors/src/connectors/dlocal.rs +++ b/crates/hyperswitch_connectors/src/connectors/dlocal.rs @@ -160,7 +160,7 @@ impl ConnectorValidation for Dlocal { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/elavon.rs b/crates/hyperswitch_connectors/src/connectors/elavon.rs index ee8d576f8e88..452b5e1e9799 100644 --- a/crates/hyperswitch_connectors/src/connectors/elavon.rs +++ b/crates/hyperswitch_connectors/src/connectors/elavon.rs @@ -585,7 +585,7 @@ impl ConnectorValidation for Elavon { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &PaymentMethod, + _payment_method: PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/fiserv.rs b/crates/hyperswitch_connectors/src/connectors/fiserv.rs index 0bd81276e949..88f43b1256bc 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiserv.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiserv.rs @@ -185,7 +185,7 @@ impl ConnectorValidation for Fiserv { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/fiservemea.rs b/crates/hyperswitch_connectors/src/connectors/fiservemea.rs index 8c041b171475..01271140086b 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiservemea.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiservemea.rs @@ -253,7 +253,7 @@ impl ConnectorValidation for Fiservemea { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/fiuu.rs b/crates/hyperswitch_connectors/src/connectors/fiuu.rs index 1acd282ce340..45f2261ffd7e 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiuu.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiuu.rs @@ -208,7 +208,7 @@ impl ConnectorValidation for Fiuu { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &PaymentMethod, + _payment_method: PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/forte.rs b/crates/hyperswitch_connectors/src/connectors/forte.rs index a192098ad260..fd40d0ac0779 100644 --- a/crates/hyperswitch_connectors/src/connectors/forte.rs +++ b/crates/hyperswitch_connectors/src/connectors/forte.rs @@ -173,7 +173,7 @@ impl ConnectorValidation for Forte { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/gocardless.rs b/crates/hyperswitch_connectors/src/connectors/gocardless.rs index 151b6f8e1c5a..1661769374cd 100644 --- a/crates/hyperswitch_connectors/src/connectors/gocardless.rs +++ b/crates/hyperswitch_connectors/src/connectors/gocardless.rs @@ -339,7 +339,7 @@ impl ConnectorValidation for Gocardless { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/helcim.rs b/crates/hyperswitch_connectors/src/connectors/helcim.rs index 27c106a510db..c859225c6b01 100644 --- a/crates/hyperswitch_connectors/src/connectors/helcim.rs +++ b/crates/hyperswitch_connectors/src/connectors/helcim.rs @@ -176,7 +176,7 @@ impl ConnectorValidation for Helcim { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/multisafepay.rs b/crates/hyperswitch_connectors/src/connectors/multisafepay.rs index a80f339cd9d9..8f334bea8441 100644 --- a/crates/hyperswitch_connectors/src/connectors/multisafepay.rs +++ b/crates/hyperswitch_connectors/src/connectors/multisafepay.rs @@ -133,7 +133,7 @@ impl ConnectorValidation for Multisafepay { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/nexinets.rs b/crates/hyperswitch_connectors/src/connectors/nexinets.rs index 9c5fdcae5ca6..668e0c03c19e 100644 --- a/crates/hyperswitch_connectors/src/connectors/nexinets.rs +++ b/crates/hyperswitch_connectors/src/connectors/nexinets.rs @@ -170,7 +170,7 @@ impl ConnectorValidation for Nexinets { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/nexixpay.rs b/crates/hyperswitch_connectors/src/connectors/nexixpay.rs index d5165771b110..3bdf8dfe3d42 100644 --- a/crates/hyperswitch_connectors/src/connectors/nexixpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/nexixpay.rs @@ -207,7 +207,7 @@ impl ConnectorValidation for Nexixpay { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/novalnet.rs b/crates/hyperswitch_connectors/src/connectors/novalnet.rs index c441bdb7a446..365199ac93df 100644 --- a/crates/hyperswitch_connectors/src/connectors/novalnet.rs +++ b/crates/hyperswitch_connectors/src/connectors/novalnet.rs @@ -161,7 +161,7 @@ impl ConnectorValidation for Novalnet { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/payeezy.rs b/crates/hyperswitch_connectors/src/connectors/payeezy.rs index ae3d137d2515..246d01f62154 100644 --- a/crates/hyperswitch_connectors/src/connectors/payeezy.rs +++ b/crates/hyperswitch_connectors/src/connectors/payeezy.rs @@ -157,7 +157,7 @@ impl ConnectorValidation for Payeezy { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &PaymentMethod, + _payment_method: PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/payu.rs b/crates/hyperswitch_connectors/src/connectors/payu.rs index 3d7131d6ceb3..b9aed329f2ee 100644 --- a/crates/hyperswitch_connectors/src/connectors/payu.rs +++ b/crates/hyperswitch_connectors/src/connectors/payu.rs @@ -145,7 +145,7 @@ impl ConnectorValidation for Payu { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/powertranz.rs b/crates/hyperswitch_connectors/src/connectors/powertranz.rs index ab1600db599b..c73bdead2287 100644 --- a/crates/hyperswitch_connectors/src/connectors/powertranz.rs +++ b/crates/hyperswitch_connectors/src/connectors/powertranz.rs @@ -151,7 +151,7 @@ impl ConnectorValidation for Powertranz { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/rapyd.rs b/crates/hyperswitch_connectors/src/connectors/rapyd.rs index 5f6b01983c43..62405f51c553 100644 --- a/crates/hyperswitch_connectors/src/connectors/rapyd.rs +++ b/crates/hyperswitch_connectors/src/connectors/rapyd.rs @@ -151,7 +151,7 @@ impl ConnectorValidation for Rapyd { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/shift4.rs b/crates/hyperswitch_connectors/src/connectors/shift4.rs index 1445645c7609..456627b8fb2d 100644 --- a/crates/hyperswitch_connectors/src/connectors/shift4.rs +++ b/crates/hyperswitch_connectors/src/connectors/shift4.rs @@ -144,7 +144,7 @@ impl ConnectorValidation for Shift4 { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/square.rs b/crates/hyperswitch_connectors/src/connectors/square.rs index c20f18cdbee6..76df62ff652c 100644 --- a/crates/hyperswitch_connectors/src/connectors/square.rs +++ b/crates/hyperswitch_connectors/src/connectors/square.rs @@ -162,7 +162,7 @@ impl ConnectorValidation for Square { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/stax.rs b/crates/hyperswitch_connectors/src/connectors/stax.rs index 0167b3822aee..53e9231462e3 100644 --- a/crates/hyperswitch_connectors/src/connectors/stax.rs +++ b/crates/hyperswitch_connectors/src/connectors/stax.rs @@ -143,7 +143,7 @@ impl ConnectorValidation for Stax { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/tsys.rs b/crates/hyperswitch_connectors/src/connectors/tsys.rs index 80f20d5d9f1b..1f634adacdc9 100644 --- a/crates/hyperswitch_connectors/src/connectors/tsys.rs +++ b/crates/hyperswitch_connectors/src/connectors/tsys.rs @@ -108,7 +108,7 @@ impl ConnectorValidation for Tsys { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/worldline.rs b/crates/hyperswitch_connectors/src/connectors/worldline.rs index 0c1c94c79d2f..131f48effb57 100644 --- a/crates/hyperswitch_connectors/src/connectors/worldline.rs +++ b/crates/hyperswitch_connectors/src/connectors/worldline.rs @@ -173,7 +173,7 @@ impl ConnectorValidation for Worldline { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/worldpay.rs b/crates/hyperswitch_connectors/src/connectors/worldpay.rs index 5da600655ae5..93a13c78a84b 100644 --- a/crates/hyperswitch_connectors/src/connectors/worldpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/worldpay.rs @@ -164,7 +164,7 @@ impl ConnectorValidation for Worldpay { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/hyperswitch_connectors/src/connectors/zsl.rs b/crates/hyperswitch_connectors/src/connectors/zsl.rs index 76ce52794315..9ce4f683aab7 100644 --- a/crates/hyperswitch_connectors/src/connectors/zsl.rs +++ b/crates/hyperswitch_connectors/src/connectors/zsl.rs @@ -3,7 +3,7 @@ pub mod transformers; use std::fmt::Debug; use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId}; -use common_enums::{enums, PaymentsConnectorType}; +use common_enums::{enums, PaymentConnectorCategory}; use common_utils::{ errors::CustomResult, ext_traits::{BytesExt, ValueExt}, @@ -131,7 +131,7 @@ impl ConnectorValidation for Zsl { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -465,12 +465,12 @@ fn get_webhook_object_from_body( } impl ConnectorSpecifications for Zsl { - fn get_connector_data(&self) -> Option { + fn get_connector_about(&self) -> Option { Some(ConnectorInfo { description: "Zsl is a payment gateway operating in China, specializing in facilitating local bank transfers" .to_string(), - connector_type: PaymentsConnectorType::PaymentGateway, + connector_type: PaymentConnectorCategory::PaymentGateway, }) } diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs index 963432ed12c7..5827d6e31cf0 100644 --- a/crates/hyperswitch_domain_models/src/router_response_types.rs +++ b/crates/hyperswitch_domain_models/src/router_response_types.rs @@ -2,7 +2,7 @@ pub mod disputes; pub mod fraud_check; use std::collections::HashMap; -use common_enums::{CaptureMethod, PaymentMethod, PaymentMethodType, PaymentsConnectorType}; +use common_enums::{CaptureMethod, PaymentConnectorCategory, PaymentMethod, PaymentMethodType}; use common_utils::{request::Method, types as common_types, types::MinorUnit}; pub use disputes::{AcceptDisputeResponse, DefendDisputeResponse, SubmitEvidenceResponse}; @@ -536,7 +536,7 @@ pub struct ConnectorInfo { pub description: String, /// Connector Type - pub connector_type: PaymentsConnectorType, + pub connector_type: PaymentConnectorCategory, } pub trait SupportedPaymentMethodsExt { @@ -559,9 +559,7 @@ impl SupportedPaymentMethodsExt for SupportedPaymentMethods { supports_refund: bool, supported_capture_methods: Vec, ) { - // Check if `payment_method` exists in the map if let Some(payment_method_data) = self.get_mut(&payment_method) { - // If it exists, insert or update the data for `payment_method_type` payment_method_data.insert( payment_method_type, PaymentMethodDetails { @@ -571,7 +569,6 @@ impl SupportedPaymentMethodsExt for SupportedPaymentMethods { }, ); } else { - // If it doesn't exist, create a new entry let payment_method_details = PaymentMethodDetails { supports_mandate, supports_refund, diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index 9ee4bf1d32cf..c8bc2c392d28 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -294,7 +294,7 @@ pub trait ConnectorSpecifications { } /// Details related to connector - fn get_connector_data(&self) -> Option { + fn get_connector_about(&self) -> Option { None } } @@ -368,8 +368,8 @@ pub trait ConnectorValidation: ConnectorCommon + ConnectorSpecifications { /// fn validate_payment_method fn validate_payment_method( &self, - payment_method_type: &Option, - payment_method: &PaymentMethod, + payment_method_type: Option, + payment_method: PaymentMethod, ) -> CustomResult<(), errors::ConnectorError> { if let Some(supported_payment_methods) = self.get_supported_payment_methods() { get_connector_payment_method_type_info( @@ -388,7 +388,7 @@ pub trait ConnectorValidation: ConnectorCommon + ConnectorSpecifications { fn validate_capture_method( &self, capture_method: Option, - payment_method: &PaymentMethod, + payment_method: PaymentMethod, pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -396,7 +396,7 @@ pub trait ConnectorValidation: ConnectorCommon + ConnectorSpecifications { let connector_payment_method_type_info = get_connector_payment_method_type_info( supported_payment_methods, payment_method, - &pmt, + pmt, self.id(), )?; @@ -491,23 +491,24 @@ pub trait Payouts {} fn get_connector_payment_method_type_info( supported_payment_method: SupportedPaymentMethods, - payment_method: &PaymentMethod, - payment_method_type: &Option, + payment_method: PaymentMethod, + payment_method_type: Option, connector: &'static str, ) -> CustomResult, errors::ConnectorError> { - let payment_method_details = supported_payment_method - .get(payment_method) - .ok_or_else(|| errors::ConnectorError::NotSupported { - message: payment_method.to_string(), - connector: connector, - })?; + let payment_method_details = + supported_payment_method + .get(&payment_method) + .ok_or_else(|| errors::ConnectorError::NotSupported { + message: payment_method.to_string(), + connector, + })?; payment_method_type .map(|pmt| { payment_method_details.get(&pmt).cloned().ok_or_else(|| { errors::ConnectorError::NotSupported { - message: format!("{} {}", payment_method.to_string(), pmt), - connector: connector, + message: format!("{} {}", payment_method, pmt), + connector, } .into() }) diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index 4f04a5765331..03ff91bbafa2 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -288,7 +288,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::enums::AuthorizationStatus, api_models::enums::PaymentMethodStatus, api_models::enums::UIWidgetFormLayout, - api_models::enums::PaymentsConnectorType, + api_models::enums::PaymentConnectorCategory, api_models::admin::MerchantConnectorCreate, api_models::admin::AdditionalMerchantData, api_models::admin::ConnectorWalletDetails, diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs index 53bd956eca9a..872fcfe87c15 100644 --- a/crates/openapi/src/openapi_v2.rs +++ b/crates/openapi/src/openapi_v2.rs @@ -248,7 +248,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::enums::ConnectorStatus, api_models::enums::AuthorizationStatus, api_models::enums::PaymentMethodStatus, - api_models::enums::PaymentsConnectorType, + api_models::enums::PaymentConnectorCategory, api_models::enums::OrderFulfillmentTimeOrigin, api_models::enums::UIWidgetFormLayout, api_models::admin::MerchantConnectorCreate, diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs index 733cdca92f94..400017878d82 100644 --- a/crates/router/src/connector/adyen.rs +++ b/crates/router/src/connector/adyen.rs @@ -101,7 +101,7 @@ impl ConnectorValidation for Adyen { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/authorizedotnet.rs b/crates/router/src/connector/authorizedotnet.rs index 728722c2d11a..b468a1b86dcc 100644 --- a/crates/router/src/connector/authorizedotnet.rs +++ b/crates/router/src/connector/authorizedotnet.rs @@ -69,7 +69,7 @@ impl ConnectorValidation for Authorizedotnet { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/bankofamerica.rs b/crates/router/src/connector/bankofamerica.rs index 9f5dc716a61f..38f94cb05bf2 100644 --- a/crates/router/src/connector/bankofamerica.rs +++ b/crates/router/src/connector/bankofamerica.rs @@ -281,7 +281,7 @@ impl ConnectorValidation for Bankofamerica { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rs index 8dc8b401850d..06525137ccd2 100644 --- a/crates/router/src/connector/bluesnap.rs +++ b/crates/router/src/connector/bluesnap.rs @@ -183,7 +183,7 @@ impl ConnectorValidation for Bluesnap { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/braintree.rs b/crates/router/src/connector/braintree.rs index a9ecd5429f2a..d899c049eb9d 100644 --- a/crates/router/src/connector/braintree.rs +++ b/crates/router/src/connector/braintree.rs @@ -176,7 +176,7 @@ impl ConnectorValidation for Braintree { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/checkout.rs b/crates/router/src/connector/checkout.rs index 948924d52a1d..5e96c9dc2ed0 100644 --- a/crates/router/src/connector/checkout.rs +++ b/crates/router/src/connector/checkout.rs @@ -157,7 +157,7 @@ impl ConnectorValidation for Checkout { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/cybersource.rs b/crates/router/src/connector/cybersource.rs index a0e8f2c3a431..bbd72274310e 100644 --- a/crates/router/src/connector/cybersource.rs +++ b/crates/router/src/connector/cybersource.rs @@ -249,7 +249,7 @@ impl ConnectorValidation for Cybersource { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/datatrans.rs b/crates/router/src/connector/datatrans.rs index 9b0b7aac90da..4ade020dfd45 100644 --- a/crates/router/src/connector/datatrans.rs +++ b/crates/router/src/connector/datatrans.rs @@ -140,7 +140,7 @@ impl ConnectorValidation for Datatrans { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &PaymentMethod, + _payment_method: PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/dummyconnector.rs b/crates/router/src/connector/dummyconnector.rs index b5ba0e252cb2..d1efe9153e30 100644 --- a/crates/router/src/connector/dummyconnector.rs +++ b/crates/router/src/connector/dummyconnector.rs @@ -127,7 +127,7 @@ impl ConnectorValidation for DummyConnector { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/globalpay.rs b/crates/router/src/connector/globalpay.rs index 2f9559a46d06..272251962eca 100644 --- a/crates/router/src/connector/globalpay.rs +++ b/crates/router/src/connector/globalpay.rs @@ -130,7 +130,7 @@ impl ConnectorValidation for Globalpay { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/klarna.rs b/crates/router/src/connector/klarna.rs index 713cf8a8a279..357c626a6f26 100644 --- a/crates/router/src/connector/klarna.rs +++ b/crates/router/src/connector/klarna.rs @@ -113,7 +113,7 @@ impl ConnectorValidation for Klarna { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/nmi.rs b/crates/router/src/connector/nmi.rs index bb02130171ff..ca0162bc0bb1 100644 --- a/crates/router/src/connector/nmi.rs +++ b/crates/router/src/connector/nmi.rs @@ -111,7 +111,7 @@ impl ConnectorValidation for Nmi { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rs index d309fe72c75d..6c1d2a7d691d 100644 --- a/crates/router/src/connector/noon.rs +++ b/crates/router/src/connector/noon.rs @@ -179,7 +179,7 @@ impl ConnectorValidation for Noon { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/nuvei.rs b/crates/router/src/connector/nuvei.rs index 9e759e9efbfe..0e76c3405b69 100644 --- a/crates/router/src/connector/nuvei.rs +++ b/crates/router/src/connector/nuvei.rs @@ -76,7 +76,7 @@ impl ConnectorValidation for Nuvei { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/opayo.rs b/crates/router/src/connector/opayo.rs index fa94380d822a..55f320ab8d92 100644 --- a/crates/router/src/connector/opayo.rs +++ b/crates/router/src/connector/opayo.rs @@ -134,7 +134,7 @@ impl ConnectorValidation for Opayo { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/paybox.rs b/crates/router/src/connector/paybox.rs index 4cd3dee924a3..24f2851dfcd1 100644 --- a/crates/router/src/connector/paybox.rs +++ b/crates/router/src/connector/paybox.rs @@ -148,7 +148,7 @@ impl ConnectorValidation for Paybox { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/payme.rs b/crates/router/src/connector/payme.rs index 3d8dd04882a4..0632754164f7 100644 --- a/crates/router/src/connector/payme.rs +++ b/crates/router/src/connector/payme.rs @@ -141,7 +141,7 @@ impl ConnectorValidation for Payme { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs index 567f54b42429..14b41edd391b 100644 --- a/crates/router/src/connector/paypal.rs +++ b/crates/router/src/connector/paypal.rs @@ -323,7 +323,7 @@ impl ConnectorValidation for Paypal { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/placetopay.rs b/crates/router/src/connector/placetopay.rs index bbec580e6a68..4ff4889203a6 100644 --- a/crates/router/src/connector/placetopay.rs +++ b/crates/router/src/connector/placetopay.rs @@ -126,7 +126,7 @@ impl ConnectorValidation for Placetopay { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rs index 1c7e8cd9801a..e30c906c5a79 100644 --- a/crates/router/src/connector/stripe.rs +++ b/crates/router/src/connector/stripe.rs @@ -136,7 +136,7 @@ impl ConnectorValidation for Stripe { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/connector/wellsfargo.rs b/crates/router/src/connector/wellsfargo.rs index 59ca7af6d8c0..56a90e9650bd 100644 --- a/crates/router/src/connector/wellsfargo.rs +++ b/crates/router/src/connector/wellsfargo.rs @@ -248,7 +248,7 @@ impl ConnectorValidation for Wellsfargo { fn validate_capture_method( &self, capture_method: Option, - _payment_method: &enums::PaymentMethod, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs index fe8ac7171d2e..64363f1319af 100644 --- a/crates/router/src/core/payments/flows/authorize_flow.rs +++ b/crates/router/src/core/payments/flows/authorize_flow.rs @@ -340,17 +340,14 @@ impl Feature for types::PaymentsAu .connector .validate_capture_method( self.request.capture_method, - &self.payment_method, + self.payment_method, self.request.payment_method_type, ) .to_payment_failed_response()?; connector .connector - .validate_payment_method( - &self.request.payment_method_type, - &self.payment_method, - ) + .validate_payment_method(self.request.payment_method_type, self.payment_method) .to_payment_failed_response()?; if crate::connector::utils::PaymentsAuthorizeRequestData::is_customer_initiated_mandate_payment( diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index 0132ac5566f0..68e8d6c6df16 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -2228,7 +2228,7 @@ impl FeatureMatrix { .app_data(web::Data::new(state)) .service( web::resource("") - .route(web::get().to(feature_matrix::fetch_connector_feature_matrix)), + .route(web::get().to(feature_matrix::fetch_feature_matrix)), ) } } diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index d237f3dea398..49872469c732 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -1,6 +1,7 @@ use actix_web::{web, HttpRequest, Responder}; use api_models::{connector_enums::Connector, feature_matrix}; -use hyperswitch_domain_models::api::ApplicationResponse; +use common_enums::enums; +use hyperswitch_domain_models::{api::ApplicationResponse, router_response_types::PaymentMethodTypeMetadata}; use hyperswitch_interfaces::api::ConnectorSpecifications; use router_env::{instrument, tracing, Flow}; use strum::IntoEnumIterator; @@ -14,7 +15,7 @@ use crate::{ }; #[instrument(skip_all)] -pub async fn fetch_connector_feature_matrix( +pub async fn fetch_feature_matrix( state: web::Data, req: HttpRequest, json_payload: Option>, @@ -29,14 +30,14 @@ pub async fn fetch_connector_feature_matrix( state, &req, payload, - |state, (), req, _| generate_connector_feature_matrix(state, req), + |state, (), req, _| generate_feature_matrix(state, req), &auth::NoAuth, LockAction::NotApplicable, )) .await } -pub async fn generate_connector_feature_matrix( +pub async fn generate_feature_matrix( state: app::SessionState, req: payment_types::FeatureMatrixRequest, ) -> RouterResponse { @@ -73,59 +74,71 @@ fn build_connector_feature_details( connector: ConnectorEnum, connector_name: String, ) -> Option { - connector - .get_supported_payment_methods() - .map(|supported_methods| { - let payment_method_types = supported_methods - .into_iter() - .map(|(payment_method, supported_payment_method_types)| { - let payment_methods = supported_payment_method_types - .into_iter() - .map(|(payment_method_type, feature_metadata)| { - let payment_method_type_config = - state.conf.pm_filters.0.get(&connector_name).and_then( - |selected_connector| { - selected_connector.0.get( - &settings::PaymentMethodFilterKey::PaymentMethodType( - payment_method_type, - ), - ) - }, - ); + let connector_integration_features = connector.get_supported_payment_methods(); - let supported_countries = payment_method_type_config - .and_then(|config| config.country.clone()); + connector_integration_features.map(|connector_integration_feature_data| { + let supported_payment_methods = connector_integration_feature_data + .into_iter() + .map(|(payment_method, supported_payment_method_types)| { + build_connector_payment_method_data( + state, + &connector_name, + payment_method, + supported_payment_method_types, + ) + }) + .collect(); - let supported_currencies = payment_method_type_config - .and_then(|config| config.currency.clone()); + let connector_about = connector.get_connector_about(); + feature_matrix::ConnectorFeatureMatrixResponse { + connector: connector_name, + description: connector_about.clone().map(|about| about.description), + connector_type: connector_about.clone().map(|about| about.connector_type), + supported_webhook_flows: connector.get_supported_webhook_flows(), + supported_payment_methods, + } + }) +} - feature_matrix::SupportedPaymentMethod { - payment_method: payment_method_type, - supports_mandate: feature_metadata.supports_mandate, - supports_refund: feature_metadata.supports_refund, - supported_capture_methods: feature_metadata - .supported_capture_methods, - supported_countries, - supported_currencies, - } - }) - .collect(); +fn build_connector_payment_method_data( + state: &app::SessionState, + connector_name: &str, + payment_method: enums::PaymentMethod, + supported_payment_method_types: PaymentMethodTypeMetadata, +) -> feature_matrix::SupportedPaymentMethodTypes { + let payment_methods = supported_payment_method_types + .into_iter() + .map(|(payment_method_type, feature_metadata)| { + let payment_method_type_config = state + .conf + .pm_filters + .0 + .get(connector_name) + .and_then(|selected_connector| { + selected_connector.0.get( + &settings::PaymentMethodFilterKey::PaymentMethodType(payment_method_type), + ) + }); - feature_matrix::SupportedPaymentMethodTypes { - payment_method_type: payment_method, - payment_methods, - } - }) - .collect(); + let supported_countries = payment_method_type_config + .and_then(|config| config.country.clone()); - let connector_about = connector.get_connector_data(); + let supported_currencies = payment_method_type_config + .and_then(|config| config.currency.clone()); - payment_types::ConnectorFeatureMatrixResponse { - connector: connector_name, - description: connector_about.clone().map(|about| about.description), - connector_type: connector_about.clone().map(|about| about.connector_type), - supported_webhook_flows: connector.get_supported_webhook_flows(), - payment_method_types, + feature_matrix::SupportedPaymentMethod { + payment_method: payment_method_type, + supports_mandate: feature_metadata.supports_mandate, + supports_refund: feature_metadata.supports_refund, + supported_capture_methods: feature_metadata.supported_capture_methods, + supported_countries, + supported_currencies, } }) -} + .collect(); + + feature_matrix::SupportedPaymentMethodTypes { + payment_method_type: payment_method, + payment_methods, + } +} \ No newline at end of file diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs index 82d875e7d0a7..f2300a68c003 100644 --- a/crates/router/src/services/connector_integration_interface.rs +++ b/crates/router/src/services/connector_integration_interface.rs @@ -370,8 +370,8 @@ impl ConnectorRedirectResponse for ConnectorEnum { impl ConnectorValidation for ConnectorEnum { fn validate_payment_method( &self, - payment_method_type: &Option, - payment_method: &common_enums::PaymentMethod, + payment_method_type: Option, + payment_method: common_enums::PaymentMethod, ) -> CustomResult<(), errors::ConnectorError> { match self { Self::Old(connector) => { @@ -386,7 +386,7 @@ impl ConnectorValidation for ConnectorEnum { fn validate_capture_method( &self, capture_method: Option, - payment_method: &common_enums::PaymentMethod, + payment_method: common_enums::PaymentMethod, pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { match self { @@ -458,10 +458,10 @@ impl ConnectorSpecifications for ConnectorEnum { } /// Details related to connector - fn get_connector_data(&self) -> Option { + fn get_connector_about(&self) -> Option { match self { - Self::Old(connector) => connector.get_connector_data(), - Self::New(connector) => connector.get_connector_data(), + Self::Old(connector) => connector.get_connector_about(), + Self::New(connector) => connector.get_connector_about(), } } } From 6ebe4c2a10c37c916af1e6b249838a073853537f Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Tue, 10 Dec 2024 08:12:01 +0000 Subject: [PATCH 22/40] chore: run formatter --- crates/router/src/routes/app.rs | 5 +-- crates/router/src/routes/feature_matrix.rs | 37 ++++++++++++---------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/crates/router/src/routes/app.rs b/crates/router/src/routes/app.rs index 68e8d6c6df16..016e0b238964 100644 --- a/crates/router/src/routes/app.rs +++ b/crates/router/src/routes/app.rs @@ -2226,9 +2226,6 @@ impl FeatureMatrix { pub fn server(state: AppState) -> Scope { web::scope("/feature_matrix") .app_data(web::Data::new(state)) - .service( - web::resource("") - .route(web::get().to(feature_matrix::fetch_feature_matrix)), - ) + .service(web::resource("").route(web::get().to(feature_matrix::fetch_feature_matrix))) } } diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index 49872469c732..6f4b64ad198e 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -1,7 +1,9 @@ use actix_web::{web, HttpRequest, Responder}; use api_models::{connector_enums::Connector, feature_matrix}; use common_enums::enums; -use hyperswitch_domain_models::{api::ApplicationResponse, router_response_types::PaymentMethodTypeMetadata}; +use hyperswitch_domain_models::{ + api::ApplicationResponse, router_response_types::PaymentMethodTypeMetadata, +}; use hyperswitch_interfaces::api::ConnectorSpecifications; use router_env::{instrument, tracing, Flow}; use strum::IntoEnumIterator; @@ -109,22 +111,25 @@ fn build_connector_payment_method_data( let payment_methods = supported_payment_method_types .into_iter() .map(|(payment_method_type, feature_metadata)| { - let payment_method_type_config = state - .conf - .pm_filters - .0 - .get(connector_name) - .and_then(|selected_connector| { - selected_connector.0.get( - &settings::PaymentMethodFilterKey::PaymentMethodType(payment_method_type), - ) - }); + let payment_method_type_config = + state + .conf + .pm_filters + .0 + .get(connector_name) + .and_then(|selected_connector| { + selected_connector.0.get( + &settings::PaymentMethodFilterKey::PaymentMethodType( + payment_method_type, + ), + ) + }); - let supported_countries = payment_method_type_config - .and_then(|config| config.country.clone()); + let supported_countries = + payment_method_type_config.and_then(|config| config.country.clone()); - let supported_currencies = payment_method_type_config - .and_then(|config| config.currency.clone()); + let supported_currencies = + payment_method_type_config.and_then(|config| config.currency.clone()); feature_matrix::SupportedPaymentMethod { payment_method: payment_method_type, @@ -141,4 +146,4 @@ fn build_connector_payment_method_data( payment_method_type: payment_method, payment_methods, } -} \ No newline at end of file +} From 8562f9036f5d244031d28c85a194c55b05f1f0e9 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Tue, 10 Dec 2024 14:04:16 +0530 Subject: [PATCH 23/40] refactor(feature_matrix): rename fields and generate openapi_spec --- api-reference-v2/openapi_spec.json | 14 +++++++------- api-reference/openapi_spec.json | 14 +++++++------- crates/api_models/src/feature_matrix.rs | 8 ++++---- crates/router/src/routes/feature_matrix.rs | 8 ++++---- 4 files changed, 22 insertions(+), 22 deletions(-) diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 3a617f5dee3a..7f2c9067d995 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -6437,18 +6437,18 @@ "ConnectorFeatureMatrixResponse": { "type": "object", "required": [ - "connector", + "name", "supported_payment_methods" ], "properties": { - "connector": { + "name": { "type": "string" }, "description": { "type": "string", "nullable": true }, - "connector_type": { + "category": { "allOf": [ { "$ref": "#/components/schemas/PaymentConnectorCategory" @@ -8281,16 +8281,16 @@ "FeatureMatrixListResponse": { "type": "object", "required": [ - "size", - "data" + "connector_count", + "connectors" ], "properties": { - "size": { + "connector_count": { "type": "integer", "description": "The number of connectors included in the response", "minimum": 0 }, - "data": { + "connectors": { "type": "array", "items": { "$ref": "#/components/schemas/ConnectorFeatureMatrixResponse" diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index 520c977dcb07..31a4faecd0f5 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -8799,18 +8799,18 @@ "ConnectorFeatureMatrixResponse": { "type": "object", "required": [ - "connector", + "name", "supported_payment_methods" ], "properties": { - "connector": { + "name": { "type": "string" }, "description": { "type": "string", "nullable": true }, - "connector_type": { + "category": { "allOf": [ { "$ref": "#/components/schemas/PaymentConnectorCategory" @@ -10623,16 +10623,16 @@ "FeatureMatrixListResponse": { "type": "object", "required": [ - "size", - "data" + "connector_count", + "connectors" ], "properties": { - "size": { + "connector_count": { "type": "integer", "description": "The number of connectors included in the response", "minimum": 0 }, - "data": { + "connectors": { "type": "array", "items": { "$ref": "#/components/schemas/ConnectorFeatureMatrixResponse" diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index 132772688931..db823d278897 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -32,9 +32,9 @@ pub struct SupportedPaymentMethodTypes { #[derive(Debug, ToSchema, Serialize)] pub struct ConnectorFeatureMatrixResponse { - pub connector: String, + pub name: String, pub description: Option, - pub connector_type: Option, + pub category: Option, pub supported_payment_methods: Vec, pub supported_webhook_flows: Option>, } @@ -42,9 +42,9 @@ pub struct ConnectorFeatureMatrixResponse { #[derive(Debug, Serialize, ToSchema)] pub struct FeatureMatrixListResponse { /// The number of connectors included in the response - pub size: usize, + pub connector_count: usize, // The list of payments response objects - pub data: Vec, + pub connectors: Vec, } impl common_utils::events::ApiEventMetric for FeatureMatrixListResponse {} diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index 6f4b64ad198e..68e8d7382fa6 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -65,8 +65,8 @@ pub async fn generate_feature_matrix( Ok(ApplicationResponse::Json( payment_types::FeatureMatrixListResponse { - size: feature_matrix_response.len(), - data: feature_matrix_response, + connector_count: feature_matrix_response.len(), + connectors: feature_matrix_response, }, )) } @@ -93,9 +93,9 @@ fn build_connector_feature_details( let connector_about = connector.get_connector_about(); feature_matrix::ConnectorFeatureMatrixResponse { - connector: connector_name, + name: connector_name, description: connector_about.clone().map(|about| about.description), - connector_type: connector_about.clone().map(|about| about.connector_type), + category: connector_about.clone().map(|about| about.connector_type), supported_webhook_flows: connector.get_supported_webhook_flows(), supported_payment_methods, } From 0c8421a30bb5f86dc8be1281a115be959fcfa1e8 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Tue, 10 Dec 2024 14:59:01 +0530 Subject: [PATCH 24/40] refactor(router): remove validate_capture_method from zsl --- .../src/connectors/zsl.rs | 18 ------------------ 1 file changed, 18 deletions(-) diff --git a/crates/hyperswitch_connectors/src/connectors/zsl.rs b/crates/hyperswitch_connectors/src/connectors/zsl.rs index 9ce4f683aab7..79c4164daaa0 100644 --- a/crates/hyperswitch_connectors/src/connectors/zsl.rs +++ b/crates/hyperswitch_connectors/src/connectors/zsl.rs @@ -128,24 +128,6 @@ impl ConnectorCommon for Zsl { } impl ConnectorValidation for Zsl { - fn validate_capture_method( - &self, - capture_method: Option, - _payment_method: enums::PaymentMethod, - _pmt: Option, - ) -> CustomResult<(), errors::ConnectorError> { - let capture_method = capture_method.unwrap_or_default(); - match capture_method { - enums::CaptureMethod::Automatic | enums::CaptureMethod::SequentialAutomatic => Ok(()), - enums::CaptureMethod::Manual - | enums::CaptureMethod::ManualMultiple - | enums::CaptureMethod::Scheduled => Err(construct_not_supported_error_report( - capture_method, - self.id(), - )), - } - } - fn is_webhook_source_verification_mandatory(&self) -> bool { true } From 76417509bc9275409cd4e50a3edbfa7c86ce4fa3 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Tue, 10 Dec 2024 15:06:53 +0530 Subject: [PATCH 25/40] fix(configs): remove CAD from pm_filters.bambora --- config/config.example.toml | 4 ++-- config/deployments/integration_test.toml | 4 ++-- config/deployments/production.toml | 4 ++-- config/deployments/sandbox.toml | 4 ++-- config/development.toml | 4 ++-- config/docker_compose.toml | 4 ++-- loadtest/config/development.toml | 4 ++-- 7 files changed, 14 insertions(+), 14 deletions(-) diff --git a/config/config.example.toml b/config/config.example.toml index 1124a2b8523d..2f35af25f0c6 100644 --- a/config/config.example.toml +++ b/config/config.example.toml @@ -515,8 +515,8 @@ pay_easy = { country = "JP", currency = "JPY" } boleto = { country = "BR", currency = "BRL" } [pm_filters.bambora] -credit = { country = "US,CA", currency = "USD,CAD" } -debit = { country = "US,CA", currency = "USD,CAD" } +credit = { country = "US,CA", currency = "USD" } +debit = { country = "US,CA", currency = "USD" } [pm_filters.volt] open_banking_uk = { country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL" } diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml index fe2d288fe094..cb25c7850df0 100644 --- a/config/deployments/integration_test.toml +++ b/config/deployments/integration_test.toml @@ -266,8 +266,8 @@ google_pay.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" paypal.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" [pm_filters.bambora] -credit = { country = "US,CA", currency = "USD,CAD" } -debit = { country = "US,CA", currency = "USD,CAD" } +credit = { country = "US,CA", currency = "USD" } +debit = { country = "US,CA", currency = "USD" } [pm_filters.bankofamerica] credit = { currency = "USD" } diff --git a/config/deployments/production.toml b/config/deployments/production.toml index 097af4e215af..39454737555f 100644 --- a/config/deployments/production.toml +++ b/config/deployments/production.toml @@ -280,8 +280,8 @@ google_pay.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" paypal.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" [pm_filters.bambora] -credit = { country = "US,CA", currency = "USD,CAD" } -debit = { country = "US,CA", currency = "USD,CAD" } +credit = { country = "US,CA", currency = "USD" } +debit = { country = "US,CA", currency = "USD" } [pm_filters.bankofamerica] credit = { currency = "USD" } diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml index 5f18975dba6a..2f2d427287a1 100644 --- a/config/deployments/sandbox.toml +++ b/config/deployments/sandbox.toml @@ -282,8 +282,8 @@ google_pay.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" paypal.currency = "CHF,DKK,EUR,GBP,NOK,PLN,SEK,USD,AUD,NZD,CAD" [pm_filters.bambora] -credit = { country = "US,CA", currency = "USD,CAD" } -debit = { country = "US,CA", currency = "USD,CAD" } +credit = { country = "US,CA", currency = "USD" } +debit = { country = "US,CA", currency = "USD" } [pm_filters.bankofamerica] credit = { currency = "USD" } diff --git a/config/development.toml b/config/development.toml index f4e07378471b..3bebf6753b9d 100644 --- a/config/development.toml +++ b/config/development.toml @@ -457,8 +457,8 @@ pix = { country = "BR", currency = "BRL" } boleto = { country = "BR", currency = "BRL" } [pm_filters.bambora] -credit = { country = "US,CA", currency = "USD,CAD" } -debit = { country = "US,CA", currency = "USD,CAD" } +credit = { country = "US,CA", currency = "USD" } +debit = { country = "US,CA", currency = "USD" } [pm_filters.bankofamerica] credit = { currency = "USD" } diff --git a/config/docker_compose.toml b/config/docker_compose.toml index bd6fd8b35e7b..b2c34b28ce48 100644 --- a/config/docker_compose.toml +++ b/config/docker_compose.toml @@ -428,8 +428,8 @@ walley = { country = "SE,NO,DK,FI", currency = "DKK,EUR,NOK,SEK" } we_chat_pay = { country = "AU,NZ,CN,JP,HK,SG,ES,GB,SE,NO,AT,NL,DE,CY,CH,BE,FR,DK,LI,MT,SI,GR,PT,IT,CA,US", currency = "AUD,CAD,CNY,EUR,GBP,HKD,JPY,NZD,SGD,USD,CNY" } [pm_filters.bambora] -credit = { country = "US,CA", currency = "USD,CAD" } -debit = { country = "US,CA", currency = "USD,CAD" } +credit = { country = "US,CA", currency = "USD" } +debit = { country = "US,CA", currency = "USD" } [pm_filters.volt] open_banking_uk = { country = "DE,GB,AT,BE,CY,EE,ES,FI,FR,GR,HR,IE,IT,LT,LU,LV,MT,NL,PT,SI,SK,BG,CZ,DK,HU,NO,PL,RO,SE,AU,BR", currency = "EUR,GBP,DKK,NOK,PLN,SEK,AUD,BRL" } diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml index 7ca327b59bbf..795ec0c96001 100644 --- a/loadtest/config/development.toml +++ b/loadtest/config/development.toml @@ -277,8 +277,8 @@ klarna = { country = "AU,AT,BE,CA,CZ,DK,FI,FR,DE,GR,IE,IT,NO,PL,PT,RO,ES,SE,CH,N ideal = { country = "NL", currency = "EUR" } [pm_filters.bambora] -credit = { country = "US,CA", currency = "USD,CAD" } -debit = { country = "US,CA", currency = "USD,CAD" } +credit = { country = "US,CA", currency = "USD" } +debit = { country = "US,CA", currency = "USD" } [pm_filters.zen] credit = { not_available_flows = { capture_method = "manual" } } From 0f30c991d835a7e15748729fe73a1fafa4a12cdf Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 12 Dec 2024 15:16:19 +0530 Subject: [PATCH 26/40] chore: fix clippy error --- crates/hyperswitch_connectors/src/connectors/zsl.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/hyperswitch_connectors/src/connectors/zsl.rs b/crates/hyperswitch_connectors/src/connectors/zsl.rs index 79c4164daaa0..24391c4d356f 100644 --- a/crates/hyperswitch_connectors/src/connectors/zsl.rs +++ b/crates/hyperswitch_connectors/src/connectors/zsl.rs @@ -49,8 +49,7 @@ use transformers::{self as zsl, get_status}; use crate::{ constants::headers, - types::{RefreshTokenRouterData, ResponseRouterData}, - utils::construct_not_supported_error_report, + types::{RefreshTokenRouterData, ResponseRouterData} }; #[derive(Debug, Clone)] From b84ef1b7ac4b0f01b829162a2fcbd95079451544 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 12 Dec 2024 15:41:02 +0530 Subject: [PATCH 27/40] fix(router): resolve merge conflicts --- .../src/connectors/bluesnap.rs | 6 +++-- .../src/connectors/datatrans.rs | 7 ++++-- .../src/connectors/paybox.rs | 6 +++-- .../src/connectors/placetopay.rs | 23 ++----------------- .../unified_authentication_service.rs | 4 +++- 5 files changed, 18 insertions(+), 28 deletions(-) diff --git a/crates/hyperswitch_connectors/src/connectors/bluesnap.rs b/crates/hyperswitch_connectors/src/connectors/bluesnap.rs index 3267637b09a7..402c5cd99312 100644 --- a/crates/hyperswitch_connectors/src/connectors/bluesnap.rs +++ b/crates/hyperswitch_connectors/src/connectors/bluesnap.rs @@ -34,8 +34,7 @@ use hyperswitch_domain_models::{ }; use hyperswitch_interfaces::{ api::{ - self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, ConnectorSpecifications, ConnectorValidation }, configs::Connectors, consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE}, @@ -207,6 +206,7 @@ impl ConnectorValidation for Bluesnap { fn validate_capture_method( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -1369,3 +1369,5 @@ fn get_rsync_url_with_connector_refund_id( req.request.get_connector_refund_id()? )) } + +impl ConnectorSpecifications for Bluesnap {} \ No newline at end of file diff --git a/crates/hyperswitch_connectors/src/connectors/datatrans.rs b/crates/hyperswitch_connectors/src/connectors/datatrans.rs index 081fedc6a36f..ec88d60aacf8 100644 --- a/crates/hyperswitch_connectors/src/connectors/datatrans.rs +++ b/crates/hyperswitch_connectors/src/connectors/datatrans.rs @@ -2,7 +2,7 @@ pub mod transformers; use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId}; use base64::Engine; -use common_enums::{CaptureMethod, PaymentMethodType}; +use common_enums::{CaptureMethod, PaymentMethodType, PaymentMethod}; use common_utils::{ consts::BASE64_ENGINE, errors::CustomResult, @@ -30,7 +30,7 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -156,6 +156,7 @@ impl ConnectorValidation for Datatrans { fn validate_capture_method( &self, capture_method: Option, + _payment_method: PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -682,3 +683,5 @@ impl IncomingWebhook for Datatrans { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for Datatrans {} \ No newline at end of file diff --git a/crates/hyperswitch_connectors/src/connectors/paybox.rs b/crates/hyperswitch_connectors/src/connectors/paybox.rs index 4f85f31c698e..2f69da571fa8 100644 --- a/crates/hyperswitch_connectors/src/connectors/paybox.rs +++ b/crates/hyperswitch_connectors/src/connectors/paybox.rs @@ -32,8 +32,7 @@ use hyperswitch_domain_models::{ }; use hyperswitch_interfaces::{ api::{ - self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, - ConnectorValidation, + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, ConnectorSpecifications, ConnectorValidation }, configs::Connectors, errors, @@ -161,6 +160,7 @@ impl ConnectorValidation for Paybox { fn validate_capture_method( &self, capture_method: Option, + _payment_method: enums::PaymentMethod, _pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); @@ -701,3 +701,5 @@ impl ConnectorRedirectResponse for Paybox { } } } + +impl ConnectorSpecifications for Paybox {} \ No newline at end of file diff --git a/crates/hyperswitch_connectors/src/connectors/placetopay.rs b/crates/hyperswitch_connectors/src/connectors/placetopay.rs index 2c946d603190..0c152d9a4c48 100644 --- a/crates/hyperswitch_connectors/src/connectors/placetopay.rs +++ b/crates/hyperswitch_connectors/src/connectors/placetopay.rs @@ -28,7 +28,7 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -38,28 +38,9 @@ use hyperswitch_interfaces::{ use transformers as placetopay; use crate::{ -<<<<<<< HEAD:crates/router/src/connector/placetopay.rs - configs::settings, - connector::utils as connector_utils, - core::errors::{self, CustomResult}, - events::connector_api_logs::ConnectorEvent, - headers, - services::{ - self, - request::{self}, - ConnectorIntegration, ConnectorSpecifications, ConnectorValidation, - }, - types::{ - self, - api::{self, enums, ConnectorCommon, ConnectorCommonExt}, - ErrorResponse, Response, - }, - utils::BytesExt, -======= constants::headers, types::ResponseRouterData, utils::{construct_not_supported_error_report, convert_amount}, ->>>>>>> main:crates/hyperswitch_connectors/src/connectors/placetopay.rs }; #[derive(Clone)] @@ -698,4 +679,4 @@ impl IncomingWebhook for Placetopay { } } -impl ConnectorSpecifications for Placetopay {} +impl ConnectorSpecifications for Placetopay {} \ No newline at end of file diff --git a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs index e85fe5dd7de7..301f957016e5 100644 --- a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs +++ b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs @@ -26,7 +26,7 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -598,3 +598,5 @@ impl webhooks::IncomingWebhook for UnifiedAuthenticationService { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for UnifiedAuthenticationService{} \ No newline at end of file From 27a302c796e8141f136307ddde7ac6aee0d3b897 Mon Sep 17 00:00:00 2001 From: "hyperswitch-bot[bot]" <148525504+hyperswitch-bot[bot]@users.noreply.github.com> Date: Thu, 12 Dec 2024 10:15:06 +0000 Subject: [PATCH 28/40] chore: run formatter --- crates/hyperswitch_connectors/src/connectors/bluesnap.rs | 5 +++-- .../hyperswitch_connectors/src/connectors/datatrans.rs | 9 ++++++--- crates/hyperswitch_connectors/src/connectors/paybox.rs | 5 +++-- .../hyperswitch_connectors/src/connectors/placetopay.rs | 7 +++++-- .../src/connectors/unified_authentication_service.rs | 7 +++++-- crates/hyperswitch_connectors/src/connectors/zsl.rs | 2 +- 6 files changed, 23 insertions(+), 12 deletions(-) diff --git a/crates/hyperswitch_connectors/src/connectors/bluesnap.rs b/crates/hyperswitch_connectors/src/connectors/bluesnap.rs index 402c5cd99312..b99b8454f5d5 100644 --- a/crates/hyperswitch_connectors/src/connectors/bluesnap.rs +++ b/crates/hyperswitch_connectors/src/connectors/bluesnap.rs @@ -34,7 +34,8 @@ use hyperswitch_domain_models::{ }; use hyperswitch_interfaces::{ api::{ - self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, ConnectorSpecifications, ConnectorValidation + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE}, @@ -1370,4 +1371,4 @@ fn get_rsync_url_with_connector_refund_id( )) } -impl ConnectorSpecifications for Bluesnap {} \ No newline at end of file +impl ConnectorSpecifications for Bluesnap {} diff --git a/crates/hyperswitch_connectors/src/connectors/datatrans.rs b/crates/hyperswitch_connectors/src/connectors/datatrans.rs index ec88d60aacf8..1a4dc346a0ee 100644 --- a/crates/hyperswitch_connectors/src/connectors/datatrans.rs +++ b/crates/hyperswitch_connectors/src/connectors/datatrans.rs @@ -2,7 +2,7 @@ pub mod transformers; use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId}; use base64::Engine; -use common_enums::{CaptureMethod, PaymentMethodType, PaymentMethod}; +use common_enums::{CaptureMethod, PaymentMethod, PaymentMethodType}; use common_utils::{ consts::BASE64_ENGINE, errors::CustomResult, @@ -30,7 +30,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -684,4 +687,4 @@ impl IncomingWebhook for Datatrans { } } -impl ConnectorSpecifications for Datatrans {} \ No newline at end of file +impl ConnectorSpecifications for Datatrans {} diff --git a/crates/hyperswitch_connectors/src/connectors/paybox.rs b/crates/hyperswitch_connectors/src/connectors/paybox.rs index 2f69da571fa8..fc37c801287e 100644 --- a/crates/hyperswitch_connectors/src/connectors/paybox.rs +++ b/crates/hyperswitch_connectors/src/connectors/paybox.rs @@ -32,7 +32,8 @@ use hyperswitch_domain_models::{ }; use hyperswitch_interfaces::{ api::{ - self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, ConnectorSpecifications, ConnectorValidation + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorRedirectResponse, + ConnectorSpecifications, ConnectorValidation, }, configs::Connectors, errors, @@ -702,4 +703,4 @@ impl ConnectorRedirectResponse for Paybox { } } -impl ConnectorSpecifications for Paybox {} \ No newline at end of file +impl ConnectorSpecifications for Paybox {} diff --git a/crates/hyperswitch_connectors/src/connectors/placetopay.rs b/crates/hyperswitch_connectors/src/connectors/placetopay.rs index 0c152d9a4c48..f65d9e837a25 100644 --- a/crates/hyperswitch_connectors/src/connectors/placetopay.rs +++ b/crates/hyperswitch_connectors/src/connectors/placetopay.rs @@ -28,7 +28,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -679,4 +682,4 @@ impl IncomingWebhook for Placetopay { } } -impl ConnectorSpecifications for Placetopay {} \ No newline at end of file +impl ConnectorSpecifications for Placetopay {} diff --git a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs index 301f957016e5..bbdc384518f3 100644 --- a/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs +++ b/crates/hyperswitch_connectors/src/connectors/unified_authentication_service.rs @@ -26,7 +26,10 @@ use hyperswitch_domain_models::{ }, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, @@ -599,4 +602,4 @@ impl webhooks::IncomingWebhook for UnifiedAuthenticationService { } } -impl ConnectorSpecifications for UnifiedAuthenticationService{} \ No newline at end of file +impl ConnectorSpecifications for UnifiedAuthenticationService {} diff --git a/crates/hyperswitch_connectors/src/connectors/zsl.rs b/crates/hyperswitch_connectors/src/connectors/zsl.rs index 24391c4d356f..cfee931680d8 100644 --- a/crates/hyperswitch_connectors/src/connectors/zsl.rs +++ b/crates/hyperswitch_connectors/src/connectors/zsl.rs @@ -49,7 +49,7 @@ use transformers::{self as zsl, get_status}; use crate::{ constants::headers, - types::{RefreshTokenRouterData, ResponseRouterData} + types::{RefreshTokenRouterData, ResponseRouterData}, }; #[derive(Debug, Clone)] From c1f050d6f058e95f1de4a9ecdecff77f1ecf39f2 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 13 Dec 2024 12:57:08 +0530 Subject: [PATCH 29/40] chore: fix open_sepc error --- crates/openapi/src/openapi.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index 15cba979bf72..643a5488b8e5 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -661,7 +661,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::payments::DisplayAmountOnSdk, api_models::payments::PaymentsPostSessionTokensRequest, api_models::payments::PaymentsPostSessionTokensResponse, - api_models::payments::CtpServiceDetails + api_models::payments::CtpServiceDetails, api_models::feature_matrix::FeatureMatrixListResponse, api_models::feature_matrix::FeatureMatrixRequest, api_models::feature_matrix::ConnectorFeatureMatrixResponse, From db5377589445133cd26de41f79bb0cfa7408b54d Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Mon, 16 Dec 2024 14:54:21 +0530 Subject: [PATCH 30/40] fix(cypress): change assertion field name --- cypress-tests/cypress/support/commands.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index e7dea1cc746c..16fe0c9a437b 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -121,12 +121,12 @@ Cypress.Commands.add("ListConnectorsFeatureMatrixCall", (globalState) => { }).then((response) => { logRequestId(response.headers["x-request-id"]); - expect(response.body).to.have.property("data").and.not.empty; - expect(response.body.data).to.be.an("array").and.not.empty; - response.body.data.forEach((item) => { + expect(response.body).to.have.property("connectors").and.not.empty; + expect(response.body.connectors).to.be.an("array").and.not.empty; + response.body.connectors.forEach((item) => { expect(item).to.have.property("description").and.not.empty; - expect(item).to.have.property("connector_type").and.not.empty; - expect(item).to.have.property("payment_method_types").and.not.empty; + expect(item).to.have.property("category").and.not.empty; + expect(item).to.have.property("supported_payment_methods").and.not.empty; }); }); }); From e33acec4715cf434ab79e550a579d4c8080aa39b Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Tue, 17 Dec 2024 15:44:51 +0530 Subject: [PATCH 31/40] refactor(router): remove type import --- connector-template/mod.rs | 6 ++---- .../hyperswitch_connectors/src/connectors/deutschebank.rs | 4 ++-- crates/hyperswitch_connectors/src/connectors/zsl.rs | 4 ++-- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/connector-template/mod.rs b/connector-template/mod.rs index d4b8ed16b4d8..873082b3125e 100644 --- a/connector-template/mod.rs +++ b/connector-template/mod.rs @@ -3,7 +3,6 @@ pub mod transformers; use error_stack::{report, ResultExt}; use masking::{ExposeInterface, Mask}; -use common_enums::enums::PaymentConnectorCategory; use common_utils::{ errors::CustomResult, ext_traits::BytesExt, @@ -11,7 +10,6 @@ use common_utils::{ request::{Method, Request, RequestBuilder, RequestContent}, }; -use api_models::webhooks::WebhookFlow; use hyperswitch_domain_models::{ router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData}, router_flow_types::{ @@ -560,7 +558,7 @@ impl ConnectorSpecifications for {{project-name | downcase | pascal_case}} { description: "Connector About" .to_string(), - connector_type: PaymentConnectorCategory::PaymentGateway, + connector_type: common_enums::enums::PaymentConnectorCategory::PaymentGateway, }) } @@ -569,7 +567,7 @@ impl ConnectorSpecifications for {{project-name | downcase | pascal_case}} { Some(supported_payment_methods) } - fn get_supported_webhook_flows(&self) -> Option> { + fn get_supported_webhook_flows(&self) -> Option> { Some(Vec::new()) } } diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs index cebc9f2228cf..852ecfd67507 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs @@ -4,7 +4,7 @@ use std::time::SystemTime; use actix_web::http::header::Date; use base64::Engine; -use common_enums::{enums, PaymentConnectorCategory}; +use common_enums::enums; use common_utils::{ errors::CustomResult, ext_traits::BytesExt, @@ -945,7 +945,7 @@ impl ConnectorSpecifications for Deutschebank { description: "Deutsche Bank is a German multinational investment bank and financial services company " .to_string(), - connector_type: PaymentConnectorCategory::BankAcquirer, + connector_type: enums::PaymentConnectorCategory::BankAcquirer, }) } diff --git a/crates/hyperswitch_connectors/src/connectors/zsl.rs b/crates/hyperswitch_connectors/src/connectors/zsl.rs index cfee931680d8..f306ef7ac797 100644 --- a/crates/hyperswitch_connectors/src/connectors/zsl.rs +++ b/crates/hyperswitch_connectors/src/connectors/zsl.rs @@ -3,7 +3,7 @@ pub mod transformers; use std::fmt::Debug; use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId}; -use common_enums::{enums, PaymentConnectorCategory}; +use common_enums::enums; use common_utils::{ errors::CustomResult, ext_traits::{BytesExt, ValueExt}, @@ -451,7 +451,7 @@ impl ConnectorSpecifications for Zsl { description: "Zsl is a payment gateway operating in China, specializing in facilitating local bank transfers" .to_string(), - connector_type: PaymentConnectorCategory::PaymentGateway, + connector_type: enums::PaymentConnectorCategory::PaymentGateway, }) } From 0e0dde80d5f9432612371f3ba4967b842682ce87 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Tue, 17 Dec 2024 18:04:05 +0530 Subject: [PATCH 32/40] refactor(router): merge validate_capture_method() and validate_payment_method() --- .../src/connectors/airwallex.rs | 2 +- .../src/connectors/bamboraapac.rs | 2 +- .../src/connectors/billwerk.rs | 2 +- .../src/connectors/bluesnap.rs | 2 +- .../src/connectors/boku.rs | 2 +- .../src/connectors/cashtocode.rs | 2 +- .../src/connectors/coinbase.rs | 2 +- .../src/connectors/datatrans.rs | 2 +- .../src/connectors/digitalvirgo.rs | 2 +- .../src/connectors/dlocal.rs | 2 +- .../src/connectors/elavon.rs | 2 +- .../src/connectors/fiserv.rs | 2 +- .../src/connectors/fiservemea.rs | 2 +- .../src/connectors/fiuu.rs | 2 +- .../src/connectors/forte.rs | 2 +- .../src/connectors/gocardless.rs | 2 +- .../src/connectors/helcim.rs | 2 +- .../src/connectors/multisafepay.rs | 2 +- .../src/connectors/nexinets.rs | 2 +- .../src/connectors/nexixpay.rs | 2 +- .../src/connectors/novalnet.rs | 2 +- .../src/connectors/paybox.rs | 2 +- .../src/connectors/payeezy.rs | 2 +- .../src/connectors/payu.rs | 2 +- .../src/connectors/placetopay.rs | 2 +- .../src/connectors/powertranz.rs | 2 +- .../src/connectors/rapyd.rs | 2 +- .../src/connectors/shift4.rs | 2 +- .../src/connectors/square.rs | 2 +- .../src/connectors/stax.rs | 2 +- .../src/connectors/tsys.rs | 2 +- .../src/connectors/worldline.rs | 2 +- .../src/connectors/worldpay.rs | 2 +- crates/hyperswitch_interfaces/src/api.rs | 83 +++++++------------ crates/router/src/connector/adyen.rs | 2 +- .../router/src/connector/authorizedotnet.rs | 2 +- crates/router/src/connector/bankofamerica.rs | 2 +- crates/router/src/connector/braintree.rs | 2 +- crates/router/src/connector/checkout.rs | 2 +- crates/router/src/connector/cybersource.rs | 2 +- crates/router/src/connector/dummyconnector.rs | 2 +- crates/router/src/connector/globalpay.rs | 2 +- crates/router/src/connector/klarna.rs | 2 +- crates/router/src/connector/nmi.rs | 2 +- crates/router/src/connector/noon.rs | 2 +- crates/router/src/connector/nuvei.rs | 2 +- crates/router/src/connector/opayo.rs | 2 +- crates/router/src/connector/payme.rs | 2 +- crates/router/src/connector/paypal.rs | 2 +- crates/router/src/connector/stripe.rs | 2 +- crates/router/src/connector/wellsfargo.rs | 2 +- .../src/core/payments/flows/authorize_flow.rs | 7 +- .../connector_integration_interface.rs | 33 +++----- 53 files changed, 91 insertions(+), 132 deletions(-) diff --git a/crates/hyperswitch_connectors/src/connectors/airwallex.rs b/crates/hyperswitch_connectors/src/connectors/airwallex.rs index 862aac4ad377..f37bef830269 100644 --- a/crates/hyperswitch_connectors/src/connectors/airwallex.rs +++ b/crates/hyperswitch_connectors/src/connectors/airwallex.rs @@ -127,7 +127,7 @@ impl ConnectorCommon for Airwallex { } impl ConnectorValidation for Airwallex { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs b/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs index 9f05cd9b4114..cdfacbf3ecb1 100644 --- a/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs +++ b/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs @@ -98,7 +98,7 @@ where } impl ConnectorValidation for Bamboraapac { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/billwerk.rs b/crates/hyperswitch_connectors/src/connectors/billwerk.rs index 06fbd695bcec..3987039de974 100644 --- a/crates/hyperswitch_connectors/src/connectors/billwerk.rs +++ b/crates/hyperswitch_connectors/src/connectors/billwerk.rs @@ -154,7 +154,7 @@ impl ConnectorCommon for Billwerk { } impl ConnectorValidation for Billwerk { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: common_enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/bluesnap.rs b/crates/hyperswitch_connectors/src/connectors/bluesnap.rs index b99b8454f5d5..8fac36424e23 100644 --- a/crates/hyperswitch_connectors/src/connectors/bluesnap.rs +++ b/crates/hyperswitch_connectors/src/connectors/bluesnap.rs @@ -204,7 +204,7 @@ impl ConnectorCommon for Bluesnap { } impl ConnectorValidation for Bluesnap { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/boku.rs b/crates/hyperswitch_connectors/src/connectors/boku.rs index 688310968ada..68195979874b 100644 --- a/crates/hyperswitch_connectors/src/connectors/boku.rs +++ b/crates/hyperswitch_connectors/src/connectors/boku.rs @@ -171,7 +171,7 @@ impl ConnectorCommon for Boku { } impl ConnectorValidation for Boku { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/cashtocode.rs b/crates/hyperswitch_connectors/src/connectors/cashtocode.rs index 40f5b7bfe725..cc7ac3812374 100644 --- a/crates/hyperswitch_connectors/src/connectors/cashtocode.rs +++ b/crates/hyperswitch_connectors/src/connectors/cashtocode.rs @@ -151,7 +151,7 @@ impl ConnectorCommon for Cashtocode { } impl ConnectorValidation for Cashtocode { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/coinbase.rs b/crates/hyperswitch_connectors/src/connectors/coinbase.rs index db50932fdea2..f58437ff0793 100644 --- a/crates/hyperswitch_connectors/src/connectors/coinbase.rs +++ b/crates/hyperswitch_connectors/src/connectors/coinbase.rs @@ -136,7 +136,7 @@ impl ConnectorCommon for Coinbase { } impl ConnectorValidation for Coinbase { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/datatrans.rs b/crates/hyperswitch_connectors/src/connectors/datatrans.rs index 1a4dc346a0ee..2a19a99c0fad 100644 --- a/crates/hyperswitch_connectors/src/connectors/datatrans.rs +++ b/crates/hyperswitch_connectors/src/connectors/datatrans.rs @@ -156,7 +156,7 @@ impl ConnectorCommon for Datatrans { impl ConnectorValidation for Datatrans { //TODO: implement functions when support enabled - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs b/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs index 5e03e780b0e8..74d76c4754ff 100644 --- a/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs +++ b/crates/hyperswitch_connectors/src/connectors/digitalvirgo.rs @@ -163,7 +163,7 @@ impl ConnectorCommon for Digitalvirgo { } impl ConnectorValidation for Digitalvirgo { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/dlocal.rs b/crates/hyperswitch_connectors/src/connectors/dlocal.rs index fefe21714cd4..0aefd65e4a0f 100644 --- a/crates/hyperswitch_connectors/src/connectors/dlocal.rs +++ b/crates/hyperswitch_connectors/src/connectors/dlocal.rs @@ -157,7 +157,7 @@ impl ConnectorCommon for Dlocal { } impl ConnectorValidation for Dlocal { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/elavon.rs b/crates/hyperswitch_connectors/src/connectors/elavon.rs index 452b5e1e9799..28ffecff7315 100644 --- a/crates/hyperswitch_connectors/src/connectors/elavon.rs +++ b/crates/hyperswitch_connectors/src/connectors/elavon.rs @@ -582,7 +582,7 @@ impl webhooks::IncomingWebhook for Elavon { } impl ConnectorValidation for Elavon { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/fiserv.rs b/crates/hyperswitch_connectors/src/connectors/fiserv.rs index 88f43b1256bc..e80c57454a09 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiserv.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiserv.rs @@ -182,7 +182,7 @@ impl ConnectorCommon for Fiserv { } impl ConnectorValidation for Fiserv { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/fiservemea.rs b/crates/hyperswitch_connectors/src/connectors/fiservemea.rs index 01271140086b..13ec1870e04c 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiservemea.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiservemea.rs @@ -250,7 +250,7 @@ impl ConnectorCommon for Fiservemea { } impl ConnectorValidation for Fiservemea { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/fiuu.rs b/crates/hyperswitch_connectors/src/connectors/fiuu.rs index 45f2261ffd7e..7805281c4be0 100644 --- a/crates/hyperswitch_connectors/src/connectors/fiuu.rs +++ b/crates/hyperswitch_connectors/src/connectors/fiuu.rs @@ -205,7 +205,7 @@ pub fn build_form_from_struct(data: T) -> Result, _payment_method: PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/forte.rs b/crates/hyperswitch_connectors/src/connectors/forte.rs index fd40d0ac0779..1068922faa7a 100644 --- a/crates/hyperswitch_connectors/src/connectors/forte.rs +++ b/crates/hyperswitch_connectors/src/connectors/forte.rs @@ -170,7 +170,7 @@ impl ConnectorCommon for Forte { } impl ConnectorValidation for Forte { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/gocardless.rs b/crates/hyperswitch_connectors/src/connectors/gocardless.rs index 1661769374cd..0ecf8bac4a21 100644 --- a/crates/hyperswitch_connectors/src/connectors/gocardless.rs +++ b/crates/hyperswitch_connectors/src/connectors/gocardless.rs @@ -336,7 +336,7 @@ impl ConnectorIntegration, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/helcim.rs b/crates/hyperswitch_connectors/src/connectors/helcim.rs index c859225c6b01..5f0e49d84e15 100644 --- a/crates/hyperswitch_connectors/src/connectors/helcim.rs +++ b/crates/hyperswitch_connectors/src/connectors/helcim.rs @@ -173,7 +173,7 @@ impl ConnectorCommon for Helcim { } impl ConnectorValidation for Helcim { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/multisafepay.rs b/crates/hyperswitch_connectors/src/connectors/multisafepay.rs index 8f334bea8441..3403f2213d26 100644 --- a/crates/hyperswitch_connectors/src/connectors/multisafepay.rs +++ b/crates/hyperswitch_connectors/src/connectors/multisafepay.rs @@ -130,7 +130,7 @@ impl ConnectorCommon for Multisafepay { } impl ConnectorValidation for Multisafepay { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/nexinets.rs b/crates/hyperswitch_connectors/src/connectors/nexinets.rs index 668e0c03c19e..f93eef657245 100644 --- a/crates/hyperswitch_connectors/src/connectors/nexinets.rs +++ b/crates/hyperswitch_connectors/src/connectors/nexinets.rs @@ -167,7 +167,7 @@ impl ConnectorCommon for Nexinets { } impl ConnectorValidation for Nexinets { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/nexixpay.rs b/crates/hyperswitch_connectors/src/connectors/nexixpay.rs index 3bdf8dfe3d42..9ec2ac73903b 100644 --- a/crates/hyperswitch_connectors/src/connectors/nexixpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/nexixpay.rs @@ -204,7 +204,7 @@ impl ConnectorCommon for Nexixpay { } impl ConnectorValidation for Nexixpay { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/novalnet.rs b/crates/hyperswitch_connectors/src/connectors/novalnet.rs index 365199ac93df..99da9c5caced 100644 --- a/crates/hyperswitch_connectors/src/connectors/novalnet.rs +++ b/crates/hyperswitch_connectors/src/connectors/novalnet.rs @@ -158,7 +158,7 @@ impl ConnectorCommon for Novalnet { } impl ConnectorValidation for Novalnet { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/paybox.rs b/crates/hyperswitch_connectors/src/connectors/paybox.rs index fc37c801287e..89453364d875 100644 --- a/crates/hyperswitch_connectors/src/connectors/paybox.rs +++ b/crates/hyperswitch_connectors/src/connectors/paybox.rs @@ -158,7 +158,7 @@ impl ConnectorCommon for Paybox { } impl ConnectorValidation for Paybox { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/payeezy.rs b/crates/hyperswitch_connectors/src/connectors/payeezy.rs index 246d01f62154..5621b9d1230e 100644 --- a/crates/hyperswitch_connectors/src/connectors/payeezy.rs +++ b/crates/hyperswitch_connectors/src/connectors/payeezy.rs @@ -154,7 +154,7 @@ impl ConnectorCommon for Payeezy { } impl ConnectorValidation for Payeezy { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/payu.rs b/crates/hyperswitch_connectors/src/connectors/payu.rs index b9aed329f2ee..5ceb759df8cc 100644 --- a/crates/hyperswitch_connectors/src/connectors/payu.rs +++ b/crates/hyperswitch_connectors/src/connectors/payu.rs @@ -142,7 +142,7 @@ impl ConnectorCommon for Payu { } impl ConnectorValidation for Payu { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/placetopay.rs b/crates/hyperswitch_connectors/src/connectors/placetopay.rs index f65d9e837a25..6e593c53e16d 100644 --- a/crates/hyperswitch_connectors/src/connectors/placetopay.rs +++ b/crates/hyperswitch_connectors/src/connectors/placetopay.rs @@ -139,7 +139,7 @@ impl ConnectorCommon for Placetopay { } impl ConnectorValidation for Placetopay { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/powertranz.rs b/crates/hyperswitch_connectors/src/connectors/powertranz.rs index c73bdead2287..80a35590520c 100644 --- a/crates/hyperswitch_connectors/src/connectors/powertranz.rs +++ b/crates/hyperswitch_connectors/src/connectors/powertranz.rs @@ -148,7 +148,7 @@ impl ConnectorCommon for Powertranz { } impl ConnectorValidation for Powertranz { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/rapyd.rs b/crates/hyperswitch_connectors/src/connectors/rapyd.rs index 62405f51c553..63659c6aadbe 100644 --- a/crates/hyperswitch_connectors/src/connectors/rapyd.rs +++ b/crates/hyperswitch_connectors/src/connectors/rapyd.rs @@ -148,7 +148,7 @@ impl ConnectorCommon for Rapyd { } impl ConnectorValidation for Rapyd { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/shift4.rs b/crates/hyperswitch_connectors/src/connectors/shift4.rs index 456627b8fb2d..019f681ec5f5 100644 --- a/crates/hyperswitch_connectors/src/connectors/shift4.rs +++ b/crates/hyperswitch_connectors/src/connectors/shift4.rs @@ -141,7 +141,7 @@ impl ConnectorCommon for Shift4 { } impl ConnectorValidation for Shift4 { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/square.rs b/crates/hyperswitch_connectors/src/connectors/square.rs index 76df62ff652c..e07d85800ffd 100644 --- a/crates/hyperswitch_connectors/src/connectors/square.rs +++ b/crates/hyperswitch_connectors/src/connectors/square.rs @@ -159,7 +159,7 @@ impl ConnectorCommon for Square { } impl ConnectorValidation for Square { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/stax.rs b/crates/hyperswitch_connectors/src/connectors/stax.rs index 53e9231462e3..27be4d309dc5 100644 --- a/crates/hyperswitch_connectors/src/connectors/stax.rs +++ b/crates/hyperswitch_connectors/src/connectors/stax.rs @@ -140,7 +140,7 @@ impl ConnectorCommon for Stax { } impl ConnectorValidation for Stax { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/tsys.rs b/crates/hyperswitch_connectors/src/connectors/tsys.rs index 1f634adacdc9..39c8f9186993 100644 --- a/crates/hyperswitch_connectors/src/connectors/tsys.rs +++ b/crates/hyperswitch_connectors/src/connectors/tsys.rs @@ -105,7 +105,7 @@ impl ConnectorCommon for Tsys { } impl ConnectorValidation for Tsys { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/worldline.rs b/crates/hyperswitch_connectors/src/connectors/worldline.rs index 131f48effb57..1bfef7b752aa 100644 --- a/crates/hyperswitch_connectors/src/connectors/worldline.rs +++ b/crates/hyperswitch_connectors/src/connectors/worldline.rs @@ -170,7 +170,7 @@ impl ConnectorCommon for Worldline { } impl ConnectorValidation for Worldline { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_connectors/src/connectors/worldpay.rs b/crates/hyperswitch_connectors/src/connectors/worldpay.rs index 93a13c78a84b..07e4c178f9b8 100644 --- a/crates/hyperswitch_connectors/src/connectors/worldpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/worldpay.rs @@ -161,7 +161,7 @@ impl ConnectorCommon for Worldpay { } impl ConnectorValidation for Worldpay { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index 3520e9f272e2..8d29b212b33a 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -363,69 +363,44 @@ pub trait ConnectorVerifyWebhookSourceV2: /// trait ConnectorValidation pub trait ConnectorValidation: ConnectorCommon + ConnectorSpecifications { - /// fn validate_payment_method - fn validate_payment_method( - &self, - payment_method_type: Option, - payment_method: PaymentMethod, - ) -> CustomResult<(), errors::ConnectorError> { - if let Some(supported_payment_methods) = self.get_supported_payment_methods() { - get_connector_payment_method_type_info( - supported_payment_methods, - payment_method, - payment_method_type, - self.id(), - )?; - Ok(()) - } else { - Ok(()) - } - } - - /// fn validate_capture_method - fn validate_capture_method( + /// Validate, the payment request against the connector supported features + fn validate_connector_against_payment_request( &self, capture_method: Option, payment_method: PaymentMethod, pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); - if let Some(supported_payment_methods) = self.get_supported_payment_methods() { - let connector_payment_method_type_info = get_connector_payment_method_type_info( - supported_payment_methods, - payment_method, - pmt, - self.id(), - )?; - - if connector_payment_method_type_info - .map(|payment_method_type_info| { - payment_method_type_info - .supported_capture_methods - .contains(&capture_method) - }) - .unwrap_or(true) - // when payment method type is None - { - Ok(()) - } else { - Err(errors::ConnectorError::NotSupported { - message: capture_method.to_string(), - connector: self.id(), - } - .into()) + let default_capture_method = + vec![CaptureMethod::Automatic, CaptureMethod::SequentialAutomatic]; + let is_feature_supported = match self.get_supported_payment_methods() { + Some(supported_payment_methods) => { + let connector_payment_method_type_info = get_connector_payment_method_type_info( + supported_payment_methods, + payment_method, + pmt, + self.id(), + )?; + + connector_payment_method_type_info + .map(|payment_method_type_info| { + payment_method_type_info + .supported_capture_methods + .contains(&capture_method) + }) + .unwrap_or_else(|| default_capture_method.contains(&capture_method)) } + None => default_capture_method.contains(&capture_method), + }; + + if is_feature_supported { + Ok(()) } else { - match capture_method { - CaptureMethod::Automatic | CaptureMethod::SequentialAutomatic => Ok(()), - CaptureMethod::Manual - | CaptureMethod::ManualMultiple - | CaptureMethod::Scheduled => Err(errors::ConnectorError::NotSupported { - message: capture_method.to_string(), - connector: self.id(), - } - .into()), + Err(errors::ConnectorError::NotSupported { + message: capture_method.to_string(), + connector: self.id(), } + .into()) } } diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs index 400017878d82..b9ab7ea87e0f 100644 --- a/crates/router/src/connector/adyen.rs +++ b/crates/router/src/connector/adyen.rs @@ -98,7 +98,7 @@ impl ConnectorCommon for Adyen { } impl ConnectorValidation for Adyen { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/authorizedotnet.rs b/crates/router/src/connector/authorizedotnet.rs index b468a1b86dcc..afc8f063e4eb 100644 --- a/crates/router/src/connector/authorizedotnet.rs +++ b/crates/router/src/connector/authorizedotnet.rs @@ -66,7 +66,7 @@ impl ConnectorCommon for Authorizedotnet { } impl ConnectorValidation for Authorizedotnet { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/bankofamerica.rs b/crates/router/src/connector/bankofamerica.rs index 38f94cb05bf2..95ceee555895 100644 --- a/crates/router/src/connector/bankofamerica.rs +++ b/crates/router/src/connector/bankofamerica.rs @@ -278,7 +278,7 @@ impl ConnectorCommon for Bankofamerica { } impl ConnectorValidation for Bankofamerica { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/braintree.rs b/crates/router/src/connector/braintree.rs index d899c049eb9d..7a88180c64d2 100644 --- a/crates/router/src/connector/braintree.rs +++ b/crates/router/src/connector/braintree.rs @@ -173,7 +173,7 @@ impl ConnectorCommon for Braintree { } impl ConnectorValidation for Braintree { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/checkout.rs b/crates/router/src/connector/checkout.rs index 5e96c9dc2ed0..96b30dc80f93 100644 --- a/crates/router/src/connector/checkout.rs +++ b/crates/router/src/connector/checkout.rs @@ -154,7 +154,7 @@ impl ConnectorCommon for Checkout { } impl ConnectorValidation for Checkout { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/cybersource.rs b/crates/router/src/connector/cybersource.rs index bbd72274310e..078f66335f5c 100644 --- a/crates/router/src/connector/cybersource.rs +++ b/crates/router/src/connector/cybersource.rs @@ -246,7 +246,7 @@ impl ConnectorCommon for Cybersource { } impl ConnectorValidation for Cybersource { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/dummyconnector.rs b/crates/router/src/connector/dummyconnector.rs index d1efe9153e30..15a2ff690366 100644 --- a/crates/router/src/connector/dummyconnector.rs +++ b/crates/router/src/connector/dummyconnector.rs @@ -124,7 +124,7 @@ impl ConnectorCommon for DummyConnector { } impl ConnectorValidation for DummyConnector { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/globalpay.rs b/crates/router/src/connector/globalpay.rs index 272251962eca..2e971f8034a1 100644 --- a/crates/router/src/connector/globalpay.rs +++ b/crates/router/src/connector/globalpay.rs @@ -127,7 +127,7 @@ impl ConnectorCommon for Globalpay { } impl ConnectorValidation for Globalpay { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/klarna.rs b/crates/router/src/connector/klarna.rs index 357c626a6f26..90113fd6f5a9 100644 --- a/crates/router/src/connector/klarna.rs +++ b/crates/router/src/connector/klarna.rs @@ -110,7 +110,7 @@ impl ConnectorCommon for Klarna { } impl ConnectorValidation for Klarna { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/nmi.rs b/crates/router/src/connector/nmi.rs index ca0162bc0bb1..73aaec55e574 100644 --- a/crates/router/src/connector/nmi.rs +++ b/crates/router/src/connector/nmi.rs @@ -108,7 +108,7 @@ impl ConnectorCommon for Nmi { } impl ConnectorValidation for Nmi { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rs index 6c1d2a7d691d..c8780af3ce50 100644 --- a/crates/router/src/connector/noon.rs +++ b/crates/router/src/connector/noon.rs @@ -176,7 +176,7 @@ impl ConnectorCommon for Noon { } impl ConnectorValidation for Noon { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/nuvei.rs b/crates/router/src/connector/nuvei.rs index 0e76c3405b69..c72bee24fa28 100644 --- a/crates/router/src/connector/nuvei.rs +++ b/crates/router/src/connector/nuvei.rs @@ -73,7 +73,7 @@ impl ConnectorCommon for Nuvei { } impl ConnectorValidation for Nuvei { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/opayo.rs b/crates/router/src/connector/opayo.rs index 55f320ab8d92..a9fc439e54ce 100644 --- a/crates/router/src/connector/opayo.rs +++ b/crates/router/src/connector/opayo.rs @@ -131,7 +131,7 @@ impl ConnectorCommon for Opayo { } impl ConnectorValidation for Opayo { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/payme.rs b/crates/router/src/connector/payme.rs index 0632754164f7..10a0fe675621 100644 --- a/crates/router/src/connector/payme.rs +++ b/crates/router/src/connector/payme.rs @@ -138,7 +138,7 @@ impl ConnectorCommon for Payme { } impl ConnectorValidation for Payme { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs index 14b41edd391b..fb635708c23e 100644 --- a/crates/router/src/connector/paypal.rs +++ b/crates/router/src/connector/paypal.rs @@ -320,7 +320,7 @@ impl ConnectorCommon for Paypal { } impl ConnectorValidation for Paypal { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rs index c717215cc11a..6d377171121c 100644 --- a/crates/router/src/connector/stripe.rs +++ b/crates/router/src/connector/stripe.rs @@ -134,7 +134,7 @@ impl ConnectorCommon for Stripe { } impl ConnectorValidation for Stripe { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/connector/wellsfargo.rs b/crates/router/src/connector/wellsfargo.rs index 56a90e9650bd..b47b3662253e 100644 --- a/crates/router/src/connector/wellsfargo.rs +++ b/crates/router/src/connector/wellsfargo.rs @@ -245,7 +245,7 @@ impl ConnectorCommon for Wellsfargo { } impl ConnectorValidation for Wellsfargo { - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, _payment_method: enums::PaymentMethod, diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs index 53bd65c45515..7efa9a5e1809 100644 --- a/crates/router/src/core/payments/flows/authorize_flow.rs +++ b/crates/router/src/core/payments/flows/authorize_flow.rs @@ -337,18 +337,13 @@ impl Feature for types::PaymentsAu payments::CallConnectorAction::Trigger => { connector .connector - .validate_capture_method( + .validate_connector_against_payment_request( self.request.capture_method, self.payment_method, self.request.payment_method_type, ) .to_payment_failed_response()?; - connector - .connector - .validate_payment_method(self.request.payment_method_type, self.payment_method) - .to_payment_failed_response()?; - if crate::connector::utils::PaymentsAuthorizeRequestData::is_customer_initiated_mandate_payment( &self.request, ) { diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs index f2300a68c003..ce9e410a3b4b 100644 --- a/crates/router/src/services/connector_integration_interface.rs +++ b/crates/router/src/services/connector_integration_interface.rs @@ -368,34 +368,23 @@ impl ConnectorRedirectResponse for ConnectorEnum { } impl ConnectorValidation for ConnectorEnum { - fn validate_payment_method( - &self, - payment_method_type: Option, - payment_method: common_enums::PaymentMethod, - ) -> CustomResult<(), errors::ConnectorError> { - match self { - Self::Old(connector) => { - connector.validate_payment_method(payment_method_type, payment_method) - } - Self::New(connector) => { - connector.validate_payment_method(payment_method_type, payment_method) - } - } - } - - fn validate_capture_method( + fn validate_connector_against_payment_request( &self, capture_method: Option, payment_method: common_enums::PaymentMethod, pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { match self { - Self::Old(connector) => { - connector.validate_capture_method(capture_method, payment_method, pmt) - } - Self::New(connector) => { - connector.validate_capture_method(capture_method, payment_method, pmt) - } + Self::Old(connector) => connector.validate_connector_against_payment_request( + capture_method, + payment_method, + pmt, + ), + Self::New(connector) => connector.validate_connector_against_payment_request( + capture_method, + payment_method, + pmt, + ), } } From ab161b088b01a680a1317251413f26a9cac2d675 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Wed, 18 Dec 2024 12:35:24 +0530 Subject: [PATCH 33/40] refactor(feature_matrix): remove payment method wise nesting --- crates/api_models/src/feature_matrix.rs | 10 +++---- crates/openapi/src/openapi.rs | 1 - crates/router/src/routes/feature_matrix.rs | 31 +++++++++------------- 3 files changed, 16 insertions(+), 26 deletions(-) diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index db823d278897..4a4652e9aad8 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -16,7 +16,8 @@ pub struct FeatureMatrixRequest { #[derive(Debug, ToSchema, Serialize)] pub struct SupportedPaymentMethod { - pub payment_method: PaymentMethodType, + pub payment_method: PaymentMethod, + pub payment_method_type: PaymentMethodType, pub supports_mandate: bool, pub supports_refund: bool, pub supported_capture_methods: Vec, @@ -24,18 +25,13 @@ pub struct SupportedPaymentMethod { pub supported_currencies: Option>, } -#[derive(Debug, ToSchema, Serialize)] -pub struct SupportedPaymentMethodTypes { - pub payment_method_type: PaymentMethod, - pub payment_methods: Vec, -} #[derive(Debug, ToSchema, Serialize)] pub struct ConnectorFeatureMatrixResponse { pub name: String, pub description: Option, pub category: Option, - pub supported_payment_methods: Vec, + pub supported_payment_methods: Vec, pub supported_webhook_flows: Option>, } diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index e93e1a0fc3fc..e29b31463906 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -670,7 +670,6 @@ Never share your secret api keys. Keep them guarded and secure. api_models::feature_matrix::FeatureMatrixListResponse, api_models::feature_matrix::FeatureMatrixRequest, api_models::feature_matrix::ConnectorFeatureMatrixResponse, - api_models::feature_matrix::SupportedPaymentMethodTypes, api_models::feature_matrix::SupportedPaymentMethod, )), modifiers(&SecurityAddon) diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index 68e8d7382fa6..52a4539b8f19 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -77,38 +77,37 @@ fn build_connector_feature_details( connector_name: String, ) -> Option { let connector_integration_features = connector.get_supported_payment_methods(); - connector_integration_features.map(|connector_integration_feature_data| { - let supported_payment_methods = connector_integration_feature_data + let supported_payment_methods = + connector_integration_feature_data .into_iter() - .map(|(payment_method, supported_payment_method_types)| { - build_connector_payment_method_data( + .flat_map(|(payment_method, supported_payment_method_types)| { + build_payment_method_wise_feature_details( state, &connector_name, payment_method, supported_payment_method_types, ) - }) - .collect(); + }).collect::>(); let connector_about = connector.get_connector_about(); feature_matrix::ConnectorFeatureMatrixResponse { name: connector_name, - description: connector_about.clone().map(|about| about.description), - category: connector_about.clone().map(|about| about.connector_type), + description: connector_about.as_ref().map(|about| about.description.clone()), + category: connector_about.as_ref().map(|about| about.connector_type.clone()), supported_webhook_flows: connector.get_supported_webhook_flows(), supported_payment_methods, } }) } -fn build_connector_payment_method_data( +fn build_payment_method_wise_feature_details( state: &app::SessionState, connector_name: &str, payment_method: enums::PaymentMethod, supported_payment_method_types: PaymentMethodTypeMetadata, -) -> feature_matrix::SupportedPaymentMethodTypes { - let payment_methods = supported_payment_method_types +) -> Vec { + supported_payment_method_types .into_iter() .map(|(payment_method_type, feature_metadata)| { let payment_method_type_config = @@ -132,7 +131,8 @@ fn build_connector_payment_method_data( payment_method_type_config.and_then(|config| config.currency.clone()); feature_matrix::SupportedPaymentMethod { - payment_method: payment_method_type, + payment_method, + payment_method_type, supports_mandate: feature_metadata.supports_mandate, supports_refund: feature_metadata.supports_refund, supported_capture_methods: feature_metadata.supported_capture_methods, @@ -140,10 +140,5 @@ fn build_connector_payment_method_data( supported_currencies, } }) - .collect(); - - feature_matrix::SupportedPaymentMethodTypes { - payment_method_type: payment_method, - payment_methods, - } + .collect() } From f2d97d9fec79dd8a9def5f85c9fe6f41b10d595a Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Thu, 19 Dec 2024 16:32:48 +0530 Subject: [PATCH 34/40] refactor(router): change the return type of ConnectorSpecifications functions --- Cargo.lock | 1 + connector-template/mod.rs | 24 +------- crates/api_models/src/feature_matrix.rs | 26 ++++----- crates/common_enums/src/enums.rs | 20 +++++++ crates/hyperswitch_connectors/Cargo.toml | 1 + .../src/connectors/bambora.rs | 58 ++++++++++++------- .../src/connectors/deutschebank.rs | 53 +++++++++++------ .../src/connectors/zsl.rs | 53 +++++++++++------ .../src/router_response_types.rs | 40 +++++-------- crates/hyperswitch_interfaces/src/api.rs | 10 ++-- crates/router/src/routes/feature_matrix.rs | 23 ++++---- .../connector_integration_interface.rs | 7 +-- 12 files changed, 174 insertions(+), 142 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 581480f43553..d4cce14c1c4d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4003,6 +4003,7 @@ dependencies = [ "hyperswitch_domain_models", "hyperswitch_interfaces", "image", + "lazy_static", "masking", "mime", "once_cell", diff --git a/connector-template/mod.rs b/connector-template/mod.rs index 873082b3125e..ee5f4872d6eb 100644 --- a/connector-template/mod.rs +++ b/connector-template/mod.rs @@ -25,7 +25,7 @@ use hyperswitch_domain_models::{ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData, }, - router_response_types::{ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods}, + router_response_types::{PaymentsResponseData, RefundsResponseData}, types::{ PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData, @@ -552,23 +552,5 @@ impl webhooks::IncomingWebhook for {{project-name | downcase | pascal_case}} { } } -impl ConnectorSpecifications for {{project-name | downcase | pascal_case}} { - fn get_connector_about(&self) -> Option { - Some(ConnectorInfo { - description: - "Connector About" - .to_string(), - connector_type: common_enums::enums::PaymentConnectorCategory::PaymentGateway, - }) - } - - fn get_supported_payment_methods(&self) -> Option { - let mut supported_payment_methods = SupportedPaymentMethods::new(); - Some(supported_payment_methods) - } - - fn get_supported_webhook_flows(&self) -> Option> { - Some(Vec::new()) - } -} - +impl ConnectorSpecifications for {{project-name | downcase | pascal_case}} {} + diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index 4a4652e9aad8..e7b3bf125000 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -2,27 +2,23 @@ use std::collections::HashSet; use serde::{Deserialize, Serialize}; use utoipa::ToSchema; - -use crate::enums::{ - CaptureMethod, Connector, CountryAlpha2, Currency, EventClass, PaymentConnectorCategory, - PaymentMethod, PaymentMethodType, -}; +use crate::enums; #[derive(Default, Debug, Deserialize, Serialize, Clone, ToSchema)] pub struct FeatureMatrixRequest { // List of connectors for which the feature matrix is requested - pub connectors: Option>, + pub connectors: Option>, } #[derive(Debug, ToSchema, Serialize)] pub struct SupportedPaymentMethod { - pub payment_method: PaymentMethod, - pub payment_method_type: PaymentMethodType, - pub supports_mandate: bool, - pub supports_refund: bool, - pub supported_capture_methods: Vec, - pub supported_countries: Option>, - pub supported_currencies: Option>, + pub payment_method: enums::PaymentMethod, + pub payment_method_type: enums::PaymentMethodType, + pub mandates: enums::FeatureStatus, + pub refunds: enums::FeatureStatus, + pub supported_capture_methods: Vec, + pub supported_countries: Option>, + pub supported_currencies: Option>, } @@ -30,9 +26,9 @@ pub struct SupportedPaymentMethod { pub struct ConnectorFeatureMatrixResponse { pub name: String, pub description: Option, - pub category: Option, + pub category: Option, pub supported_payment_methods: Vec, - pub supported_webhook_flows: Option>, + pub supported_webhook_flows: Option>, } #[derive(Debug, Serialize, ToSchema)] diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 6827c5b1de13..e911aeaff701 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -3522,3 +3522,23 @@ pub enum PaymentConnectorCategory { AlternativePaymentMethod, BankAcquirer, } + +/// The status of the feature +#[derive( + Clone, + Copy, + Debug, + Eq, + PartialEq, + serde::Deserialize, + serde::Serialize, + strum::Display, + ToSchema, +)] +#[strum(serialize_all = "snake_case")] +#[serde(rename_all = "snake_case")] +pub enum FeatureStatus { + NotSupported, + Supported, +} + diff --git a/crates/hyperswitch_connectors/Cargo.toml b/crates/hyperswitch_connectors/Cargo.toml index 6405ac8ae84f..ca9e77283cda 100644 --- a/crates/hyperswitch_connectors/Cargo.toml +++ b/crates/hyperswitch_connectors/Cargo.toml @@ -40,6 +40,7 @@ time = "0.3.35" url = "2.5.0" urlencoding = "2.1.3" uuid = { version = "1.8.0", features = ["v4"] } +lazy_static = "1.4.0" # First party crates api_models = { version = "0.1.0", path = "../api_models", features = ["errors"], default-features = false } diff --git a/crates/hyperswitch_connectors/src/connectors/bambora.rs b/crates/hyperswitch_connectors/src/connectors/bambora.rs index f5ff984c387b..52a38ff3b40a 100644 --- a/crates/hyperswitch_connectors/src/connectors/bambora.rs +++ b/crates/hyperswitch_connectors/src/connectors/bambora.rs @@ -8,6 +8,7 @@ use common_utils::{ ext_traits::BytesExt, request::{Method, Request, RequestBuilder, RequestContent}, }; +use lazy_static::lazy_static; use error_stack::{report, ResultExt}; use hyperswitch_domain_models::{ router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData}, @@ -24,7 +25,7 @@ use hyperswitch_domain_models::{ }, router_response_types::{ ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods, - SupportedPaymentMethodsExt, + SupportedPaymentMethodsExt, PaymentMethodDetails, }, types::{ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData, @@ -816,43 +817,56 @@ impl webhooks::IncomingWebhook for Bambora { } } -impl ConnectorSpecifications for Bambora { - fn get_connector_about(&self) -> Option { - Some(ConnectorInfo { - description: - "Bambora is a leading online payment provider in Canada and United States." - .to_string(), - connector_type: enums::PaymentConnectorCategory::PaymentGateway, - }) - } - - fn get_supported_payment_methods(&self) -> Option { - let bambora_default_capture_methods = vec![ +lazy_static! { + static ref BAMBORA_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = { + let default_capture_methods = vec![ enums::CaptureMethod::Automatic, enums::CaptureMethod::Manual, enums::CaptureMethod::SequentialAutomatic, ]; let mut bambora_supported_payment_methods = SupportedPaymentMethods::new(); + bambora_supported_payment_methods.add( enums::PaymentMethod::Card, enums::PaymentMethodType::Credit, - false, - true, - bambora_default_capture_methods.clone(), + PaymentMethodDetails { + mandates: common_enums::FeatureStatus::NotSupported, + refunds: common_enums::FeatureStatus::Supported, + supported_capture_methods: default_capture_methods.clone(), + }, ); bambora_supported_payment_methods.add( enums::PaymentMethod::Card, enums::PaymentMethodType::Debit, - false, - true, - bambora_default_capture_methods.clone(), + PaymentMethodDetails { + mandates: common_enums::FeatureStatus::NotSupported, + refunds: common_enums::FeatureStatus::Supported, + supported_capture_methods: default_capture_methods.clone(), + }, ); - Some(bambora_supported_payment_methods) + bambora_supported_payment_methods + }; + static ref BAMBORA_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { + description: "Bambora is a leading online payment provider in Canada and United States.".to_string(), + connector_type: enums::PaymentConnectorCategory::PaymentGateway, + }; + + static ref BAMBORA_SUPPORTED_WEBHOOK_FLOWS: Vec = Vec::new(); + +} + +impl ConnectorSpecifications for Bambora { + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { + Some(&*BAMBORA_CONNECTOR_INFO) + } + + fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { + Some(&*BAMBORA_SUPPORTED_PAYMENT_METHODS) } - fn get_supported_webhook_flows(&self) -> Option> { - Some(Vec::new()) + fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { + Some(&*BAMBORA_SUPPORTED_WEBHOOK_FLOWS) } } diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs index 852ecfd67507..75d81ede3c92 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs @@ -11,6 +11,7 @@ use common_utils::{ request::{Method, Request, RequestBuilder, RequestContent}, types::{AmountConvertor, MinorUnit, MinorUnitForConnector}, }; +use lazy_static::lazy_static; use error_stack::{report, ResultExt}; use hyperswitch_domain_models::{ router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData}, @@ -29,7 +30,7 @@ use hyperswitch_domain_models::{ }, router_response_types::{ ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods, - SupportedPaymentMethodsExt, + SupportedPaymentMethodsExt, PaymentMethodDetails }, types::{ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData, @@ -939,35 +940,49 @@ impl webhooks::IncomingWebhook for Deutschebank { } } -impl ConnectorSpecifications for Deutschebank { - fn get_connector_about(&self) -> Option { - Some(ConnectorInfo { - description: - "Deutsche Bank is a German multinational investment bank and financial services company " - .to_string(), - connector_type: enums::PaymentConnectorCategory::BankAcquirer, - }) - } - - fn get_supported_payment_methods(&self) -> Option { - let deutschebank_default_capture_methods = vec![ +lazy_static! { + static ref DEUTSCHEBANK_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = { + let supported_capture_methods = vec![ enums::CaptureMethod::Automatic, enums::CaptureMethod::Manual, enums::CaptureMethod::SequentialAutomatic, ]; let mut deutschebank_supported_payment_methods = SupportedPaymentMethods::new(); + deutschebank_supported_payment_methods.add( enums::PaymentMethod::BankDebit, enums::PaymentMethodType::Sepa, - true, - true, - deutschebank_default_capture_methods.clone(), + PaymentMethodDetails{ + mandates: enums::FeatureStatus::NotSupported, + refunds: enums::FeatureStatus::NotSupported, + supported_capture_methods, + } ); - Some(deutschebank_supported_payment_methods) + deutschebank_supported_payment_methods + }; + + static ref DEUTSCHEBANK_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { + description: + "Deutsche Bank is a German multinational investment bank and financial services company " + .to_string(), + connector_type: enums::PaymentConnectorCategory::BankAcquirer, + }; + + static ref DEUTSCHEBANK_SUPPORTED_WEBHOOK_FLOWS: Vec = Vec::new(); + +} + +impl ConnectorSpecifications for Deutschebank { + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { + Some(&*DEUTSCHEBANK_CONNECTOR_INFO) + } + + fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { + Some(&*DEUTSCHEBANK_SUPPORTED_PAYMENT_METHODS) } - fn get_supported_webhook_flows(&self) -> Option> { - Some(Vec::new()) + fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { + Some(&*DEUTSCHEBANK_SUPPORTED_WEBHOOK_FLOWS) } } diff --git a/crates/hyperswitch_connectors/src/connectors/zsl.rs b/crates/hyperswitch_connectors/src/connectors/zsl.rs index f306ef7ac797..dc5584a040fa 100644 --- a/crates/hyperswitch_connectors/src/connectors/zsl.rs +++ b/crates/hyperswitch_connectors/src/connectors/zsl.rs @@ -9,6 +9,7 @@ use common_utils::{ ext_traits::{BytesExt, ValueExt}, request::{Method, Request, RequestBuilder, RequestContent}, }; +use lazy_static::lazy_static; use error_stack::ResultExt; use hyperswitch_domain_models::{ api::ApplicationResponse, @@ -25,7 +26,7 @@ use hyperswitch_domain_models::{ }, router_response_types::{ ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods, - SupportedPaymentMethodsExt, + SupportedPaymentMethodsExt, PaymentMethodDetails, }, types::{ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData, @@ -445,32 +446,48 @@ fn get_webhook_object_from_body( Ok(response) } -impl ConnectorSpecifications for Zsl { - fn get_connector_about(&self) -> Option { - Some(ConnectorInfo { - description: - "Zsl is a payment gateway operating in China, specializing in facilitating local bank transfers" - .to_string(), - connector_type: enums::PaymentConnectorCategory::PaymentGateway, - }) - } - fn get_supported_payment_methods(&self) -> Option { - let zsl_default_capture_methods = vec![enums::CaptureMethod::Automatic]; +lazy_static! { + static ref ZSL_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = { + let supported_capture_methods = vec![enums::CaptureMethod::Automatic]; let mut zsl_supported_payment_methods = SupportedPaymentMethods::new(); + + zsl_supported_payment_methods.add( enums::PaymentMethod::BankTransfer, enums::PaymentMethodType::LocalBankTransfer, - false, - false, - zsl_default_capture_methods.clone(), + PaymentMethodDetails{ + mandates: common_enums::FeatureStatus::NotSupported, + refunds: common_enums::FeatureStatus::NotSupported, + supported_capture_methods, + }, ); - Some(zsl_supported_payment_methods) + zsl_supported_payment_methods + }; + + static ref ZSL_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { + description: + "Zsl is a payment gateway operating in China, specializing in facilitating local bank transfers" + .to_string(), + connector_type: enums::PaymentConnectorCategory::PaymentGateway, + }; + + static ref ZSL_SUPPORTED_WEBHOOK_FLOWS: Vec = Vec::new(); + +} + +impl ConnectorSpecifications for Zsl { + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { + Some(&*ZSL_CONNECTOR_INFO) + } + + fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { + Some(&*ZSL_SUPPORTED_PAYMENT_METHODS) } - fn get_supported_webhook_flows(&self) -> Option> { - Some(Vec::new()) + fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { + Some(&*ZSL_SUPPORTED_WEBHOOK_FLOWS) } } diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs index 5827d6e31cf0..383db115987b 100644 --- a/crates/hyperswitch_domain_models/src/router_response_types.rs +++ b/crates/hyperswitch_domain_models/src/router_response_types.rs @@ -2,7 +2,6 @@ pub mod disputes; pub mod fraud_check; use std::collections::HashMap; -use common_enums::{CaptureMethod, PaymentConnectorCategory, PaymentMethod, PaymentMethodType}; use common_utils::{request::Method, types as common_types, types::MinorUnit}; pub use disputes::{AcceptDisputeResponse, DefendDisputeResponse, SubmitEvidenceResponse}; @@ -517,18 +516,18 @@ pub struct CompleteAuthorizeRedirectResponse { #[derive(Debug, Clone)] pub struct PaymentMethodDetails { /// Indicates whether mandates are supported by this payment method. - pub supports_mandate: bool, + pub mandates: common_enums::FeatureStatus, /// Indicates whether refund is supported by this payment method. - pub supports_refund: bool, + pub refunds: common_enums::FeatureStatus, /// List of supported capture methods - pub supported_capture_methods: Vec, + pub supported_capture_methods: Vec, } /// list of payment method types and metadata related to them -pub type PaymentMethodTypeMetadata = HashMap; +pub type PaymentMethodTypeMetadata = HashMap; /// list of payment methods, payment method types and metadata related to them -pub type SupportedPaymentMethods = HashMap; +pub type SupportedPaymentMethods = HashMap; #[derive(Debug, Clone)] pub struct ConnectorInfo { @@ -536,44 +535,31 @@ pub struct ConnectorInfo { pub description: String, /// Connector Type - pub connector_type: PaymentConnectorCategory, + pub connector_type: common_enums::PaymentConnectorCategory, } pub trait SupportedPaymentMethodsExt { fn add( &mut self, - payment_method: PaymentMethod, - payment_method_type: PaymentMethodType, - supports_mandate: bool, - supports_refund: bool, - supported_capture_methods: Vec, + payment_method: common_enums::PaymentMethod, + payment_method_type: common_enums::PaymentMethodType, + payment_method_details: PaymentMethodDetails, ); } impl SupportedPaymentMethodsExt for SupportedPaymentMethods { fn add( &mut self, - payment_method: PaymentMethod, - payment_method_type: PaymentMethodType, - supports_mandate: bool, - supports_refund: bool, - supported_capture_methods: Vec, + payment_method: common_enums::PaymentMethod, + payment_method_type: common_enums::PaymentMethodType, + payment_method_details: PaymentMethodDetails, ) { if let Some(payment_method_data) = self.get_mut(&payment_method) { payment_method_data.insert( payment_method_type, - PaymentMethodDetails { - supports_mandate, - supports_refund, - supported_capture_methods, - }, + payment_method_details, ); } else { - let payment_method_details = PaymentMethodDetails { - supports_mandate, - supports_refund, - supported_capture_methods, - }; let mut payment_method_type_metadata = PaymentMethodTypeMetadata::new(); payment_method_type_metadata.insert(payment_method_type, payment_method_details); diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index 8d29b212b33a..f84137ffffaa 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -282,17 +282,17 @@ pub trait ConnectorCommon { /// The trait that provides specifications about the connector pub trait ConnectorSpecifications { /// Details related to payment method supported by the connector - fn get_supported_payment_methods(&self) -> Option { + fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { None } /// Supported webhooks flows - fn get_supported_webhook_flows(&self) -> Option> { + fn get_supported_webhook_flows(&self) -> Option<&'static [EventClass]> { None } - /// Details related to connector - fn get_connector_about(&self) -> Option { + /// About the connector + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { None } } @@ -463,7 +463,7 @@ pub trait ConnectorRedirectResponse { pub trait Payouts {} fn get_connector_payment_method_type_info( - supported_payment_method: SupportedPaymentMethods, + supported_payment_method: &SupportedPaymentMethods, payment_method: PaymentMethod, payment_method_type: Option, connector: &'static str, diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index 52a4539b8f19..65d9b23f4c5e 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -91,11 +91,12 @@ fn build_connector_feature_details( }).collect::>(); let connector_about = connector.get_connector_about(); + let supported_webhook_flows = connector.get_supported_webhook_flows().map(|webhook_flows| webhook_flows.to_vec()); feature_matrix::ConnectorFeatureMatrixResponse { name: connector_name, - description: connector_about.as_ref().map(|about| about.description.clone()), - category: connector_about.as_ref().map(|about| about.connector_type.clone()), - supported_webhook_flows: connector.get_supported_webhook_flows(), + description: connector_about.map(|about| about.description.clone()), + category: connector_about.map(|about| about.connector_type.clone()), + supported_webhook_flows, supported_payment_methods, } }) @@ -104,8 +105,8 @@ fn build_connector_feature_details( fn build_payment_method_wise_feature_details( state: &app::SessionState, connector_name: &str, - payment_method: enums::PaymentMethod, - supported_payment_method_types: PaymentMethodTypeMetadata, + payment_method: &enums::PaymentMethod, + supported_payment_method_types: &PaymentMethodTypeMetadata, ) -> Vec { supported_payment_method_types .into_iter() @@ -119,7 +120,7 @@ fn build_payment_method_wise_feature_details( .and_then(|selected_connector| { selected_connector.0.get( &settings::PaymentMethodFilterKey::PaymentMethodType( - payment_method_type, + *payment_method_type, ), ) }); @@ -131,11 +132,11 @@ fn build_payment_method_wise_feature_details( payment_method_type_config.and_then(|config| config.currency.clone()); feature_matrix::SupportedPaymentMethod { - payment_method, - payment_method_type, - supports_mandate: feature_metadata.supports_mandate, - supports_refund: feature_metadata.supports_refund, - supported_capture_methods: feature_metadata.supported_capture_methods, + payment_method: *payment_method, + payment_method_type: *payment_method_type, + mandates: feature_metadata.mandates, + refunds: feature_metadata.refunds, + supported_capture_methods: feature_metadata.supported_capture_methods.clone(), supported_countries, supported_currencies, } diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs index ce9e410a3b4b..81477718ae28 100644 --- a/crates/router/src/services/connector_integration_interface.rs +++ b/crates/router/src/services/connector_integration_interface.rs @@ -1,4 +1,3 @@ -use common_enums::EventClass; use common_utils::{crypto, errors::CustomResult, request::Request}; use hyperswitch_domain_models::{ router_data::RouterData, @@ -431,7 +430,7 @@ impl ConnectorValidation for ConnectorEnum { } impl ConnectorSpecifications for ConnectorEnum { - fn get_supported_payment_methods(&self) -> Option { + fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { match self { Self::Old(connector) => connector.get_supported_payment_methods(), Self::New(connector) => connector.get_supported_payment_methods(), @@ -439,7 +438,7 @@ impl ConnectorSpecifications for ConnectorEnum { } /// Supported webhooks flows - fn get_supported_webhook_flows(&self) -> Option> { + fn get_supported_webhook_flows(&self) -> Option<&'static [common_enums::EventClass]> { match self { Self::Old(connector) => connector.get_supported_webhook_flows(), Self::New(connector) => connector.get_supported_webhook_flows(), @@ -447,7 +446,7 @@ impl ConnectorSpecifications for ConnectorEnum { } /// Details related to connector - fn get_connector_about(&self) -> Option { + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { match self { Self::Old(connector) => connector.get_connector_about(), Self::New(connector) => connector.get_connector_about(), From e13885190b482008757b0c0407377fe3bb09870c Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 20 Dec 2024 01:04:17 +0530 Subject: [PATCH 35/40] chore: fix merge conflicts --- api-reference-v2/openapi_spec.json | 36 +++---- api-reference/openapi_spec.json | 98 ++++++++++++++++++- crates/api_models/src/feature_matrix.rs | 23 ++--- .../src/connectors/ctp_mastercard.rs | 4 +- crates/openapi/src/openapi_v2.rs | 1 - 5 files changed, 123 insertions(+), 39 deletions(-) diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index d65809fb12ce..1d16d8bb2e7a 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -6691,7 +6691,7 @@ "supported_payment_methods": { "type": "array", "items": { - "$ref": "#/components/schemas/SupportedPaymentMethodTypes" + "$ref": "#/components/schemas/SupportedPaymentMethod" } }, "supported_webhook_flows": { @@ -20709,19 +20709,23 @@ "type": "object", "required": [ "payment_method", - "supports_mandate", - "supports_refund", + "payment_method_type", + "mandates", + "refunds", "supported_capture_methods" ], "properties": { "payment_method": { + "$ref": "#/components/schemas/PaymentMethod" + }, + "payment_method_type": { "$ref": "#/components/schemas/PaymentMethodType" }, - "supports_mandate": { - "type": "boolean" + "mandates": { + "$ref": "#/components/schemas/FeatureStatus" }, - "supports_refund": { - "type": "boolean" + "refunds": { + "$ref": "#/components/schemas/FeatureStatus" }, "supported_capture_methods": { "type": "array", @@ -20747,24 +20751,6 @@ } } }, - "SupportedPaymentMethodTypes": { - "type": "object", - "required": [ - "payment_method_type", - "payment_methods" - ], - "properties": { - "payment_method_type": { - "$ref": "#/components/schemas/PaymentMethod" - }, - "payment_methods": { - "type": "array", - "items": { - "$ref": "#/components/schemas/SupportedPaymentMethod" - } - } - } - }, "SurchargeCalculationOverride": { "type": "string", "enum": [ diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index 7b4c7688c7f1..02f92d5e51aa 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -9211,7 +9211,7 @@ "supported_payment_methods": { "type": "array", "items": { - "$ref": "#/components/schemas/SupportedPaymentMethodTypes" + "$ref": "#/components/schemas/SupportedPaymentMethod" } }, "supported_webhook_flows": { @@ -24807,6 +24807,102 @@ }, "additionalProperties": false }, + "SuccessBasedRoutingConfig": { + "type": "object", + "properties": { + "params": { + "type": "array", + "items": { + "$ref": "#/components/schemas/DynamicRoutingConfigParams" + }, + "nullable": true + }, + "config": { + "allOf": [ + { + "$ref": "#/components/schemas/SuccessBasedRoutingConfigBody" + } + ], + "nullable": true + } + } + }, + "SuccessBasedRoutingConfigBody": { + "type": "object", + "properties": { + "min_aggregates_size": { + "type": "integer", + "format": "int32", + "nullable": true, + "minimum": 0 + }, + "default_success_rate": { + "type": "number", + "format": "double", + "nullable": true + }, + "max_aggregates_size": { + "type": "integer", + "format": "int32", + "nullable": true, + "minimum": 0 + }, + "current_block_threshold": { + "allOf": [ + { + "$ref": "#/components/schemas/CurrentBlockThreshold" + } + ], + "nullable": true + } + } + }, + "SupportedPaymentMethod": { + "type": "object", + "required": [ + "payment_method", + "payment_method_type", + "mandates", + "refunds", + "supported_capture_methods" + ], + "properties": { + "payment_method": { + "$ref": "#/components/schemas/PaymentMethod" + }, + "payment_method_type": { + "$ref": "#/components/schemas/PaymentMethodType" + }, + "mandates": { + "$ref": "#/components/schemas/FeatureStatus" + }, + "refunds": { + "$ref": "#/components/schemas/FeatureStatus" + }, + "supported_capture_methods": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CaptureMethod" + } + }, + "supported_countries": { + "type": "array", + "items": { + "$ref": "#/components/schemas/CountryAlpha2" + }, + "uniqueItems": true, + "nullable": true + }, + "supported_currencies": { + "type": "array", + "items": { + "$ref": "#/components/schemas/Currency" + }, + "uniqueItems": true, + "nullable": true + } + } + }, "SurchargeDetailsResponse": { "type": "object", "required": [ diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index e7b3bf125000..a879433dc3e4 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -2,23 +2,24 @@ use std::collections::HashSet; use serde::{Deserialize, Serialize}; use utoipa::ToSchema; -use crate::enums; + +use crate::enums::{Connector, PaymentMethod, PaymentMethodType, FeatureStatus, CaptureMethod, CountryAlpha2, Currency, EventClass, PaymentConnectorCategory}; #[derive(Default, Debug, Deserialize, Serialize, Clone, ToSchema)] pub struct FeatureMatrixRequest { // List of connectors for which the feature matrix is requested - pub connectors: Option>, + pub connectors: Option>, } #[derive(Debug, ToSchema, Serialize)] pub struct SupportedPaymentMethod { - pub payment_method: enums::PaymentMethod, - pub payment_method_type: enums::PaymentMethodType, - pub mandates: enums::FeatureStatus, - pub refunds: enums::FeatureStatus, - pub supported_capture_methods: Vec, - pub supported_countries: Option>, - pub supported_currencies: Option>, + pub payment_method: PaymentMethod, + pub payment_method_type: PaymentMethodType, + pub mandates: FeatureStatus, + pub refunds: FeatureStatus, + pub supported_capture_methods: Vec, + pub supported_countries: Option>, + pub supported_currencies: Option>, } @@ -26,9 +27,9 @@ pub struct SupportedPaymentMethod { pub struct ConnectorFeatureMatrixResponse { pub name: String, pub description: Option, - pub category: Option, + pub category: Option, pub supported_payment_methods: Vec, - pub supported_webhook_flows: Option>, + pub supported_webhook_flows: Option>, } #[derive(Debug, Serialize, ToSchema)] diff --git a/crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs b/crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs index 1d82b98af8af..d8cbe36d5a3f 100644 --- a/crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs +++ b/crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs @@ -15,7 +15,7 @@ use hyperswitch_domain_models::{ router_response_types::{PaymentsResponseData, RefundsResponseData}, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, configs::Connectors, errors, webhooks, }; @@ -122,3 +122,5 @@ impl webhooks::IncomingWebhook for CtpMastercard { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } } + +impl ConnectorSpecifications for CtpMastercard {} \ No newline at end of file diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs index d47db7acee63..92054b7288af 100644 --- a/crates/openapi/src/openapi_v2.rs +++ b/crates/openapi/src/openapi_v2.rs @@ -642,7 +642,6 @@ Never share your secret api keys. Keep them guarded and secure. api_models::feature_matrix::FeatureMatrixListResponse, api_models::feature_matrix::FeatureMatrixRequest, api_models::feature_matrix::ConnectorFeatureMatrixResponse, - api_models::feature_matrix::SupportedPaymentMethodTypes, api_models::feature_matrix::SupportedPaymentMethod, common_utils::types::BrowserInformation, api_models::payments::ConfirmIntentAmountDetailsResponse, From 6e0c329319eb31dd6dbf34918c035eb0936ef562 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 20 Dec 2024 13:53:52 +0530 Subject: [PATCH 36/40] chore: fix formatting error --- crates/api_models/src/feature_matrix.rs | 6 ++++-- crates/common_enums/src/enums.rs | 1 - .../src/connectors/bambora.rs | 15 +++++++-------- .../src/connectors/ctp_mastercard.rs | 7 +++++-- .../src/connectors/deutschebank.rs | 6 +++--- .../hyperswitch_connectors/src/connectors/zsl.rs | 11 +++++------ .../src/router_response_types.rs | 6 +----- crates/hyperswitch_interfaces/src/api.rs | 4 ++-- crates/router/src/routes/feature_matrix.rs | 10 ++++++---- .../services/connector_integration_interface.rs | 2 +- 10 files changed, 34 insertions(+), 34 deletions(-) diff --git a/crates/api_models/src/feature_matrix.rs b/crates/api_models/src/feature_matrix.rs index a879433dc3e4..2eaade1b61e8 100644 --- a/crates/api_models/src/feature_matrix.rs +++ b/crates/api_models/src/feature_matrix.rs @@ -3,7 +3,10 @@ use std::collections::HashSet; use serde::{Deserialize, Serialize}; use utoipa::ToSchema; -use crate::enums::{Connector, PaymentMethod, PaymentMethodType, FeatureStatus, CaptureMethod, CountryAlpha2, Currency, EventClass, PaymentConnectorCategory}; +use crate::enums::{ + CaptureMethod, Connector, CountryAlpha2, Currency, EventClass, FeatureStatus, + PaymentConnectorCategory, PaymentMethod, PaymentMethodType, +}; #[derive(Default, Debug, Deserialize, Serialize, Clone, ToSchema)] pub struct FeatureMatrixRequest { @@ -22,7 +25,6 @@ pub struct SupportedPaymentMethod { pub supported_currencies: Option>, } - #[derive(Debug, ToSchema, Serialize)] pub struct ConnectorFeatureMatrixResponse { pub name: String, diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs index 1ccd6808b7d2..fcd757d31aa1 100644 --- a/crates/common_enums/src/enums.rs +++ b/crates/common_enums/src/enums.rs @@ -3546,4 +3546,3 @@ pub enum FeatureStatus { NotSupported, Supported, } - diff --git a/crates/hyperswitch_connectors/src/connectors/bambora.rs b/crates/hyperswitch_connectors/src/connectors/bambora.rs index 52a38ff3b40a..193a16df0b19 100644 --- a/crates/hyperswitch_connectors/src/connectors/bambora.rs +++ b/crates/hyperswitch_connectors/src/connectors/bambora.rs @@ -8,7 +8,6 @@ use common_utils::{ ext_traits::BytesExt, request::{Method, Request, RequestBuilder, RequestContent}, }; -use lazy_static::lazy_static; use error_stack::{report, ResultExt}; use hyperswitch_domain_models::{ router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData}, @@ -24,8 +23,8 @@ use hyperswitch_domain_models::{ PaymentsSyncData, RefundsData, SetupMandateRequestData, }, router_response_types::{ - ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods, - SupportedPaymentMethodsExt, PaymentMethodDetails, + ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData, + SupportedPaymentMethods, SupportedPaymentMethodsExt, }, types::{ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData, @@ -47,6 +46,7 @@ use hyperswitch_interfaces::{ }, webhooks, }; +use lazy_static::lazy_static; use masking::Mask; use transformers as bambora; @@ -826,7 +826,7 @@ lazy_static! { ]; let mut bambora_supported_payment_methods = SupportedPaymentMethods::new(); - + bambora_supported_payment_methods.add( enums::PaymentMethod::Card, enums::PaymentMethodType::Credit, @@ -849,16 +849,15 @@ lazy_static! { bambora_supported_payment_methods }; static ref BAMBORA_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo { - description: "Bambora is a leading online payment provider in Canada and United States.".to_string(), + description: "Bambora is a leading online payment provider in Canada and United States." + .to_string(), connector_type: enums::PaymentConnectorCategory::PaymentGateway, }; - static ref BAMBORA_SUPPORTED_WEBHOOK_FLOWS: Vec = Vec::new(); - } impl ConnectorSpecifications for Bambora { - fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { Some(&*BAMBORA_CONNECTOR_INFO) } diff --git a/crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs b/crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs index d8cbe36d5a3f..6a1c7e08815a 100644 --- a/crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs +++ b/crates/hyperswitch_connectors/src/connectors/ctp_mastercard.rs @@ -15,7 +15,10 @@ use hyperswitch_domain_models::{ router_response_types::{PaymentsResponseData, RefundsResponseData}, }; use hyperswitch_interfaces::{ - api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, ConnectorValidation}, + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications, + ConnectorValidation, + }, configs::Connectors, errors, webhooks, }; @@ -123,4 +126,4 @@ impl webhooks::IncomingWebhook for CtpMastercard { } } -impl ConnectorSpecifications for CtpMastercard {} \ No newline at end of file +impl ConnectorSpecifications for CtpMastercard {} diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs index 75d81ede3c92..3098d27e7ecb 100644 --- a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs +++ b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs @@ -11,7 +11,6 @@ use common_utils::{ request::{Method, Request, RequestBuilder, RequestContent}, types::{AmountConvertor, MinorUnit, MinorUnitForConnector}, }; -use lazy_static::lazy_static; use error_stack::{report, ResultExt}; use hyperswitch_domain_models::{ router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData}, @@ -29,8 +28,8 @@ use hyperswitch_domain_models::{ PaymentsSyncData, RefundsData, SetupMandateRequestData, }, router_response_types::{ - ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods, - SupportedPaymentMethodsExt, PaymentMethodDetails + ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData, + SupportedPaymentMethods, SupportedPaymentMethodsExt, }, types::{ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData, @@ -49,6 +48,7 @@ use hyperswitch_interfaces::{ types::{self, Response}, webhooks, }; +use lazy_static::lazy_static; use masking::{ExposeInterface, Mask, Secret}; use rand::distributions::{Alphanumeric, DistString}; use ring::hmac; diff --git a/crates/hyperswitch_connectors/src/connectors/zsl.rs b/crates/hyperswitch_connectors/src/connectors/zsl.rs index dc5584a040fa..4287e289fd1a 100644 --- a/crates/hyperswitch_connectors/src/connectors/zsl.rs +++ b/crates/hyperswitch_connectors/src/connectors/zsl.rs @@ -9,7 +9,6 @@ use common_utils::{ ext_traits::{BytesExt, ValueExt}, request::{Method, Request, RequestBuilder, RequestContent}, }; -use lazy_static::lazy_static; use error_stack::ResultExt; use hyperswitch_domain_models::{ api::ApplicationResponse, @@ -25,8 +24,8 @@ use hyperswitch_domain_models::{ RefundsData, SetupMandateRequestData, }, router_response_types::{ - ConnectorInfo, PaymentsResponseData, RefundsResponseData, SupportedPaymentMethods, - SupportedPaymentMethodsExt, PaymentMethodDetails, + ConnectorInfo, PaymentMethodDetails, PaymentsResponseData, RefundsResponseData, + SupportedPaymentMethods, SupportedPaymentMethodsExt, }, types::{ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData, @@ -45,6 +44,7 @@ use hyperswitch_interfaces::{ types::{self, Response}, webhooks::{IncomingWebhook, IncomingWebhookFlowError, IncomingWebhookRequestDetails}, }; +use lazy_static::lazy_static; use masking::{ExposeInterface, Secret}; use transformers::{self as zsl, get_status}; @@ -446,7 +446,6 @@ fn get_webhook_object_from_body( Ok(response) } - lazy_static! { static ref ZSL_SUPPORTED_PAYMENT_METHODS: SupportedPaymentMethods = { let supported_capture_methods = vec![enums::CaptureMethod::Automatic]; @@ -479,12 +478,12 @@ lazy_static! { } impl ConnectorSpecifications for Zsl { - fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { Some(&*ZSL_CONNECTOR_INFO) } fn get_supported_payment_methods(&self) -> Option<&'static SupportedPaymentMethods> { - Some(&*ZSL_SUPPORTED_PAYMENT_METHODS) + Some(&*ZSL_SUPPORTED_PAYMENT_METHODS) } fn get_supported_webhook_flows(&self) -> Option<&'static [enums::EventClass]> { diff --git a/crates/hyperswitch_domain_models/src/router_response_types.rs b/crates/hyperswitch_domain_models/src/router_response_types.rs index 383db115987b..61453f36b84e 100644 --- a/crates/hyperswitch_domain_models/src/router_response_types.rs +++ b/crates/hyperswitch_domain_models/src/router_response_types.rs @@ -555,12 +555,8 @@ impl SupportedPaymentMethodsExt for SupportedPaymentMethods { payment_method_details: PaymentMethodDetails, ) { if let Some(payment_method_data) = self.get_mut(&payment_method) { - payment_method_data.insert( - payment_method_type, - payment_method_details, - ); + payment_method_data.insert(payment_method_type, payment_method_details); } else { - let mut payment_method_type_metadata = PaymentMethodTypeMetadata::new(); payment_method_type_metadata.insert(payment_method_type, payment_method_details); diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index 822ebecac2d8..c7956c871244 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -295,12 +295,12 @@ pub trait ConnectorSpecifications { } /// Supported webhooks flows - fn get_supported_webhook_flows(&self) -> Option<&'static [EventClass]> { + fn get_supported_webhook_flows(&self) -> Option<&'static [EventClass]> { None } /// About the connector - fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { None } } diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index 65d9b23f4c5e..a157439322f2 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -78,8 +78,7 @@ fn build_connector_feature_details( ) -> Option { let connector_integration_features = connector.get_supported_payment_methods(); connector_integration_features.map(|connector_integration_feature_data| { - let supported_payment_methods = - connector_integration_feature_data + let supported_payment_methods = connector_integration_feature_data .into_iter() .flat_map(|(payment_method, supported_payment_method_types)| { build_payment_method_wise_feature_details( @@ -88,10 +87,13 @@ fn build_connector_feature_details( payment_method, supported_payment_method_types, ) - }).collect::>(); + }) + .collect::>(); let connector_about = connector.get_connector_about(); - let supported_webhook_flows = connector.get_supported_webhook_flows().map(|webhook_flows| webhook_flows.to_vec()); + let supported_webhook_flows = connector + .get_supported_webhook_flows() + .map(|webhook_flows| webhook_flows.to_vec()); feature_matrix::ConnectorFeatureMatrixResponse { name: connector_name, description: connector_about.map(|about| about.description.clone()), diff --git a/crates/router/src/services/connector_integration_interface.rs b/crates/router/src/services/connector_integration_interface.rs index 81477718ae28..5903c8e9cc0d 100644 --- a/crates/router/src/services/connector_integration_interface.rs +++ b/crates/router/src/services/connector_integration_interface.rs @@ -446,7 +446,7 @@ impl ConnectorSpecifications for ConnectorEnum { } /// Details related to connector - fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { + fn get_connector_about(&self) -> Option<&'static ConnectorInfo> { match self { Self::Old(connector) => connector.get_connector_about(), Self::New(connector) => connector.get_connector_about(), From 71f623b91864163bc82a234573ada98fcce054b7 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 20 Dec 2024 14:33:07 +0530 Subject: [PATCH 37/40] chore: fix formatiing --- crates/hyperswitch_connectors/src/connectors/zsl.rs | 2 -- 1 file changed, 2 deletions(-) diff --git a/crates/hyperswitch_connectors/src/connectors/zsl.rs b/crates/hyperswitch_connectors/src/connectors/zsl.rs index 4287e289fd1a..434cfbc3435a 100644 --- a/crates/hyperswitch_connectors/src/connectors/zsl.rs +++ b/crates/hyperswitch_connectors/src/connectors/zsl.rs @@ -451,8 +451,6 @@ lazy_static! { let supported_capture_methods = vec![enums::CaptureMethod::Automatic]; let mut zsl_supported_payment_methods = SupportedPaymentMethods::new(); - - zsl_supported_payment_methods.add( enums::PaymentMethod::BankTransfer, enums::PaymentMethodType::LocalBankTransfer, From f956a628994f2b8164210c0ed34f6144ef5c86af Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 20 Dec 2024 15:08:38 +0530 Subject: [PATCH 38/40] chore: fix clippy error --- crates/hyperswitch_interfaces/src/api.rs | 9 +++++---- crates/router/src/routes/feature_matrix.rs | 15 +++++++++------ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/crates/hyperswitch_interfaces/src/api.rs b/crates/hyperswitch_interfaces/src/api.rs index c7956c871244..ca2d806762ad 100644 --- a/crates/hyperswitch_interfaces/src/api.rs +++ b/crates/hyperswitch_interfaces/src/api.rs @@ -433,8 +433,9 @@ pub trait ConnectorValidation: ConnectorCommon + ConnectorSpecifications { pmt: Option, ) -> CustomResult<(), errors::ConnectorError> { let capture_method = capture_method.unwrap_or_default(); - let default_capture_method = - vec![CaptureMethod::Automatic, CaptureMethod::SequentialAutomatic]; + let is_default_capture_method = + [CaptureMethod::Automatic, CaptureMethod::SequentialAutomatic] + .contains(&capture_method); let is_feature_supported = match self.get_supported_payment_methods() { Some(supported_payment_methods) => { let connector_payment_method_type_info = get_connector_payment_method_type_info( @@ -450,9 +451,9 @@ pub trait ConnectorValidation: ConnectorCommon + ConnectorSpecifications { .supported_capture_methods .contains(&capture_method) }) - .unwrap_or_else(|| default_capture_method.contains(&capture_method)) + .unwrap_or_else(|| is_default_capture_method) } - None => default_capture_method.contains(&capture_method), + None => is_default_capture_method, }; if is_feature_supported { diff --git a/crates/router/src/routes/feature_matrix.rs b/crates/router/src/routes/feature_matrix.rs index a157439322f2..08dd7d0d7b2b 100644 --- a/crates/router/src/routes/feature_matrix.rs +++ b/crates/router/src/routes/feature_matrix.rs @@ -52,6 +52,9 @@ pub async fn generate_feature_matrix( .into_iter() .filter_map(|connector_name| { api_types::ConnectorData::convert_connector(&connector_name.to_string()) + .inspect_err(|_| { + router_env::logger::warn!("Failed to fetch {:?} details", connector_name) + }) .ok() .and_then(|connector| { build_connector_feature_details( @@ -79,12 +82,12 @@ fn build_connector_feature_details( let connector_integration_features = connector.get_supported_payment_methods(); connector_integration_features.map(|connector_integration_feature_data| { let supported_payment_methods = connector_integration_feature_data - .into_iter() + .iter() .flat_map(|(payment_method, supported_payment_method_types)| { build_payment_method_wise_feature_details( state, &connector_name, - payment_method, + *payment_method, supported_payment_method_types, ) }) @@ -97,7 +100,7 @@ fn build_connector_feature_details( feature_matrix::ConnectorFeatureMatrixResponse { name: connector_name, description: connector_about.map(|about| about.description.clone()), - category: connector_about.map(|about| about.connector_type.clone()), + category: connector_about.map(|about| about.connector_type), supported_webhook_flows, supported_payment_methods, } @@ -107,11 +110,11 @@ fn build_connector_feature_details( fn build_payment_method_wise_feature_details( state: &app::SessionState, connector_name: &str, - payment_method: &enums::PaymentMethod, + payment_method: enums::PaymentMethod, supported_payment_method_types: &PaymentMethodTypeMetadata, ) -> Vec { supported_payment_method_types - .into_iter() + .iter() .map(|(payment_method_type, feature_metadata)| { let payment_method_type_config = state @@ -134,7 +137,7 @@ fn build_payment_method_wise_feature_details( payment_method_type_config.and_then(|config| config.currency.clone()); feature_matrix::SupportedPaymentMethod { - payment_method: *payment_method, + payment_method, payment_method_type: *payment_method_type, mandates: feature_metadata.mandates, refunds: feature_metadata.refunds, From 9fa021bbe514b924b4600c9d3d6f30c216cee2d7 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger Date: Fri, 20 Dec 2024 15:21:05 +0530 Subject: [PATCH 39/40] chore: fix openapi_spec --- api-reference-v2/openapi_spec.json | 8 ++++++++ api-reference/openapi_spec.json | 8 ++++++++ crates/openapi/src/openapi.rs | 1 + crates/openapi/src/openapi_v2.rs | 1 + 4 files changed, 18 insertions(+) diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json index 1d16d8bb2e7a..4cb32d7e3b7a 100644 --- a/api-reference-v2/openapi_spec.json +++ b/api-reference-v2/openapi_spec.json @@ -8737,6 +8737,14 @@ } } }, + "FeatureStatus": { + "type": "string", + "description": "The status of the feature", + "enum": [ + "not_supported", + "supported" + ] + }, "FieldType": { "oneOf": [ { diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json index 02f92d5e51aa..8e212e26b6ec 100644 --- a/api-reference/openapi_spec.json +++ b/api-reference/openapi_spec.json @@ -11235,6 +11235,14 @@ } } }, + "FeatureStatus": { + "type": "string", + "description": "The status of the feature", + "enum": [ + "not_supported", + "supported" + ] + }, "FieldType": { "oneOf": [ { diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs index caa1b8f1acd7..c9e30c72c08e 100644 --- a/crates/openapi/src/openapi.rs +++ b/crates/openapi/src/openapi.rs @@ -303,6 +303,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::enums::PaymentMethodStatus, api_models::enums::UIWidgetFormLayout, api_models::enums::PaymentConnectorCategory, + api_models::enums::FeatureStatus, api_models::admin::MerchantConnectorCreate, api_models::admin::AdditionalMerchantData, api_models::admin::ConnectorWalletDetails, diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs index 92054b7288af..75c5ba3bfac2 100644 --- a/crates/openapi/src/openapi_v2.rs +++ b/crates/openapi/src/openapi_v2.rs @@ -261,6 +261,7 @@ Never share your secret api keys. Keep them guarded and secure. api_models::enums::PaymentLinkDetailsLayout, api_models::enums::PaymentMethodStatus, api_models::enums::PaymentConnectorCategory, + api_models::enums::FeatureStatus, api_models::enums::OrderFulfillmentTimeOrigin, api_models::enums::UIWidgetFormLayout, api_models::admin::MerchantConnectorCreate, From 11bf49797c56d31be554aa67255e23e194db8570 Mon Sep 17 00:00:00 2001 From: AkshayaFoiger <131388445+AkshayaFoiger@users.noreply.github.com> Date: Fri, 20 Dec 2024 16:58:44 +0530 Subject: [PATCH 40/40] Update cypress-tests/cypress/support/commands.js Co-authored-by: Pa1NarK <69745008+pixincreate@users.noreply.github.com> --- cypress-tests/cypress/support/commands.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.js index 16fe0c9a437b..0577d50e68d8 100644 --- a/cypress-tests/cypress/support/commands.js +++ b/cypress-tests/cypress/support/commands.js @@ -112,9 +112,12 @@ Cypress.Commands.add("merchantDeleteCall", (globalState) => { }); Cypress.Commands.add("ListConnectorsFeatureMatrixCall", (globalState) => { + const baseUrl = globalState.get("baseUrl"); + const url = `${baseUrl}/feature_matrix`; + cy.request({ method: "GET", - url: `${globalState.get("baseUrl")}/feature_matrix`, + url: url, headers: { Accept: "application/json", },