Skip to content

Commit

Permalink
add default implement for validate_if_surcharge_supported function in…
Browse files Browse the repository at this point in the history
… ConnectorValidation trait
  • Loading branch information
hrithikesh026 committed Oct 17, 2023
1 parent cff0ea7 commit f118742
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
4 changes: 4 additions & 0 deletions crates/router/src/connector/paypal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,6 +211,10 @@ impl ConnectorValidation for Paypal {
),
}
}

fn validate_if_surcharge_supported(&self) -> CustomResult<(), errors::ConnectorError> {
Ok(())
}
}

impl
Expand Down
6 changes: 5 additions & 1 deletion crates/router/src/connector/trustpay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {}

Expand Down
6 changes: 6 additions & 0 deletions crates/router/src/core/payments/flows/authorize_flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,12 @@ impl Feature<api::Authorize, types::PaymentsAuthorizeData> 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();
Expand Down
7 changes: 7 additions & 0 deletions crates/router/src/services/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down

0 comments on commit f118742

Please sign in to comment.