diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs index a0a787269e37..52e5b118bf1c 100644 --- a/crates/router/src/connector/paypal.rs +++ b/crates/router/src/connector/paypal.rs @@ -211,6 +211,10 @@ impl ConnectorValidation for Paypal { ), } } + + fn validate_if_surcharge_supported(&self) -> CustomResult<(), errors::ConnectorError> { + Ok(()) + } } impl diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rs index fd2d369a7c55..b6cf673dbf7b 100644 --- a/crates/router/src/connector/trustpay.rs +++ b/crates/router/src/connector/trustpay.rs @@ -148,7 +148,11 @@ impl ConnectorCommon for Trustpay { } } -impl ConnectorValidation for Trustpay {} +impl ConnectorValidation for Trustpay { + fn validate_if_surcharge_supported(&self) -> CustomResult<(), errors::ConnectorError> { + Ok(()) + } +} impl api::Payment for Trustpay {} diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs index a72791475867..3eb1b124fc6a 100644 --- a/crates/router/src/core/payments/flows/authorize_flow.rs +++ b/crates/router/src/core/payments/flows/authorize_flow.rs @@ -73,6 +73,12 @@ impl Feature for types::PaymentsAu .connector .validate_capture_method(self.request.capture_method) .to_payment_failed_response()?; + if self.request.surcharge_details.is_some() { + connector + .connector + .validate_if_surcharge_supported() + .to_payment_failed_response()?; + } if self.should_proceed_with_authorize() { self.decide_authentication_type(); diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs index 6fe4c01cc26c..d843bbb1a188 100644 --- a/crates/router/src/services/api.rs +++ b/crates/router/src/services/api.rs @@ -92,6 +92,13 @@ pub trait ConnectorValidation: ConnectorCommon { fn is_webhook_source_verification_mandatory(&self) -> bool { false } + + fn validate_if_surcharge_supported(&self) -> CustomResult<(), errors::ConnectorError> { + Err(errors::ConnectorError::NotSupported { + message: "Surcharge", + connector: self.id(), + }) + } } #[async_trait::async_trait]