Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

revert: fix(core): add validation for all the connector auth_type (#1833)

Amisha Prabhatae3d25e6899a
diff --git a/crates/router/src/connector/aci.rs b/crates/router/src/connector/aci.rs
index 6cc3f9e832..80255985c2 100644
--- a/crates/router/src/connector/aci.rs
+++ b/crates/router/src/connector/aci.rs
@@ -1,5 +1,5 @@
mod result_codes;
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
use error_stack::{IntoReport, ResultExt};
@@ -34,14 +34,6 @@ impl ConnectorCommon for Aci {
"application/x-www-form-urlencoded"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- aci::AciAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.aci.base_url.as_ref()
}
diff --git a/crates/router/src/connector/adyen.rs b/crates/router/src/connector/adyen.rs
index f37c9ca88b..2471beba32 100644
--- a/crates/router/src/connector/adyen.rs
+++ b/crates/router/src/connector/adyen.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -51,15 +51,6 @@ impl ConnectorCommon for Adyen {
auth.api_key.into_masked(),
)])
}
-
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- adyen::AdyenAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.adyen.base_url.as_ref()
}
diff --git a/crates/router/src/connector/airwallex.rs b/crates/router/src/connector/airwallex.rs
index 81667fec82..2fb171eb9f 100644
--- a/crates/router/src/connector/airwallex.rs
+++ b/crates/router/src/connector/airwallex.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -72,14 +72,6 @@ impl ConnectorCommon for Airwallex {
connectors.airwallex.base_url.as_ref()
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- airwallex::AirwallexAuthType::try_from(val)?;
- Ok(())
- }
-
fn build_error_response(
&self,
res: Response,
diff --git a/crates/router/src/connector/authorizedotnet.rs b/crates/router/src/connector/authorizedotnet.rs
index ca7f793abd..5669c7843d 100644
--- a/crates/router/src/connector/authorizedotnet.rs
+++ b/crates/router/src/connector/authorizedotnet.rs
@@ -1,5 +1,4 @@
-#![allow(dead_code)]
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -52,14 +51,6 @@ impl ConnectorCommon for Authorizedotnet {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- authorizedotnet::MerchantAuthentication::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.authorizedotnet.base_url.as_ref()
}
diff --git a/crates/router/src/connector/authorizedotnet/transformers.rs b/crates/router/src/connector/authorizedotnet/transformers.rs
index f1b1c3a452..e6b79c5690 100644
--- a/crates/router/src/connector/authorizedotnet/transformers.rs
+++ b/crates/router/src/connector/authorizedotnet/transformers.rs
@@ -33,12 +33,12 @@ pub enum TransactionType {
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
-pub struct MerchantAuthentication {
+pub struct AuthorizedotnetAuthType {
name: Secret<String>,
transaction_key: Secret<String>,
}
-impl TryFrom<&types::ConnectorAuthType> for MerchantAuthentication {
+impl TryFrom<&types::ConnectorAuthType> for AuthorizedotnetAuthType {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {
@@ -226,14 +226,14 @@ struct TransactionVoidOrCaptureRequest {
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AuthorizedotnetPaymentsRequest {
- merchant_authentication: MerchantAuthentication,
+ merchant_authentication: AuthorizedotnetAuthType,
transaction_request: TransactionRequest,
}
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AuthorizedotnetPaymentCancelOrCaptureRequest {
- merchant_authentication: MerchantAuthentication,
+ merchant_authentication: AuthorizedotnetAuthType,
transaction_request: TransactionVoidOrCaptureRequest,
}
@@ -285,7 +285,7 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for CreateTransactionRequest {
authorization_indicator_type,
};
- let merchant_authentication = MerchantAuthentication::try_from(&item.connector_auth_type)?;
+ let merchant_authentication = AuthorizedotnetAuthType::try_from(&item.connector_auth_type)?;
Ok(Self {
create_transaction_request: AuthorizedotnetPaymentsRequest {
@@ -305,7 +305,7 @@ impl TryFrom<&types::PaymentsCancelRouterData> for CancelOrCaptureTransactionReq
ref_trans_id: item.request.connector_transaction_id.to_string(),
};
- let merchant_authentication = MerchantAuthentication::try_from(&item.connector_auth_type)?;
+ let merchant_authentication = AuthorizedotnetAuthType::try_from(&item.connector_auth_type)?;
Ok(Self {
create_transaction_request: AuthorizedotnetPaymentCancelOrCaptureRequest {
@@ -328,7 +328,7 @@ impl TryFrom<&types::PaymentsCaptureRouterData> for CancelOrCaptureTransactionRe
ref_trans_id: item.request.connector_transaction_id.to_string(),
};
- let merchant_authentication = MerchantAuthentication::try_from(&item.connector_auth_type)?;
+ let merchant_authentication = AuthorizedotnetAuthType::try_from(&item.connector_auth_type)?;
Ok(Self {
create_transaction_request: AuthorizedotnetPaymentCancelOrCaptureRequest {
@@ -424,6 +424,7 @@ pub struct RefundResponse {
response_code: AuthorizedotnetRefundStatus,
#[serde(rename = "transId")]
transaction_id: String,
+ #[allow(dead_code)]
network_trans_id: Option<String>,
pub account_number: Option<String>,
pub errors: Option<Vec<ErrorMessage>>,
@@ -635,7 +636,7 @@ struct RefundTransactionRequest {
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct AuthorizedotnetRefundRequest {
- merchant_authentication: MerchantAuthentication,
+ merchant_authentication: AuthorizedotnetAuthType,
transaction_request: RefundTransactionRequest,
}
@@ -659,7 +660,7 @@ impl<F> TryFrom<&types::RefundsRouterData<F>> for CreateRefundRequest {
})?
.clone();
- let merchant_authentication = MerchantAuthentication::try_from(&item.connector_auth_type)?;
+ let merchant_authentication = AuthorizedotnetAuthType::try_from(&item.connector_auth_type)?;
let transaction_request = RefundTransactionRequest {
transaction_type: TransactionType::Refund,
@@ -738,7 +739,7 @@ impl<F> TryFrom<types::RefundsResponseRouterData<F, AuthorizedotnetRefundRespons
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct TransactionDetails {
- merchant_authentication: MerchantAuthentication,
+ merchant_authentication: AuthorizedotnetAuthType,
#[serde(rename = "transId")]
transaction_id: Option<String>,
}
@@ -753,7 +754,7 @@ impl<F> TryFrom<&types::RefundsRouterData<F>> for AuthorizedotnetCreateSyncReque
fn try_from(item: &types::RefundsRouterData<F>) -> Result<Self, Self::Error> {
let transaction_id = item.request.get_connector_refund_id()?;
- let merchant_authentication = MerchantAuthentication::try_from(&item.connector_auth_type)?;
+ let merchant_authentication = AuthorizedotnetAuthType::try_from(&item.connector_auth_type)?;
let payload = Self {
get_transaction_details_request: TransactionDetails {
@@ -775,7 +776,7 @@ impl TryFrom<&types::PaymentsSyncRouterData> for AuthorizedotnetCreateSyncReques
.change_context(errors::ConnectorError::MissingConnectorTransactionID)?,
);
- let merchant_authentication = MerchantAuthentication::try_from(&item.connector_auth_type)?;
+ let merchant_authentication = AuthorizedotnetAuthType::try_from(&item.connector_auth_type)?;
let payload = Self {
get_transaction_details_request: TransactionDetails {
@@ -1099,7 +1100,7 @@ pub struct PaypalConfirmRequest {
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
pub struct PaypalConfirmTransactionRequest {
- merchant_authentication: MerchantAuthentication,
+ merchant_authentication: AuthorizedotnetAuthType,
transaction_request: TransactionConfirmRequest,
}
@@ -1156,7 +1157,7 @@ impl TryFrom<&types::PaymentsCompleteAuthorizeRouterData> for PaypalConfirmReque
ref_trans_id: item.request.connector_transaction_id.clone(),
};
- let merchant_authentication = MerchantAuthentication::try_from(&item.connector_auth_type)?;
+ let merchant_authentication = AuthorizedotnetAuthType::try_from(&item.connector_auth_type)?;
Ok(Self {
create_transaction_request: PaypalConfirmTransactionRequest {
diff --git a/crates/router/src/connector/bambora.rs b/crates/router/src/connector/bambora.rs
index cd5e848403..19c3acaf42 100644
--- a/crates/router/src/connector/bambora.rs
+++ b/crates/router/src/connector/bambora.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -60,14 +60,6 @@ impl ConnectorCommon for Bambora {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- bambora::BamboraAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.bambora.base_url.as_ref()
}
diff --git a/crates/router/src/connector/bitpay.rs b/crates/router/src/connector/bitpay.rs
index 2aa6903b1a..50873f8811 100644
--- a/crates/router/src/connector/bitpay.rs
+++ b/crates/router/src/connector/bitpay.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -86,14 +86,6 @@ impl ConnectorCommon for Bitpay {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- bitpay::BitpayAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.bitpay.base_url.as_ref()
}
diff --git a/crates/router/src/connector/bluesnap.rs b/crates/router/src/connector/bluesnap.rs
index 1b88ea8523..436abbb67f 100644
--- a/crates/router/src/connector/bluesnap.rs
+++ b/crates/router/src/connector/bluesnap.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -67,13 +67,7 @@ impl ConnectorCommon for Bluesnap {
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- bluesnap::BluesnapAuthType::try_from(val)?;
- Ok(())
- }
+
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.bluesnap.base_url.as_ref()
}
diff --git a/crates/router/src/connector/boku.rs b/crates/router/src/connector/boku.rs
index 628417f487..f9dec8a7e2 100644
--- a/crates/router/src/connector/boku.rs
+++ b/crates/router/src/connector/boku.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -108,13 +108,6 @@ impl ConnectorCommon for Boku {
fn common_get_content_type(&self) -> &'static str {
"text/xml;charset=utf-8"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), Report<errors::ConnectorError>> {
- boku::BokuAuthType::try_from(val)?;
- Ok(())
- }
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.boku.base_url.as_ref()
diff --git a/crates/router/src/connector/braintree.rs b/crates/router/src/connector/braintree.rs
index 36813e39c4..745fc4fbc5 100644
--- a/crates/router/src/connector/braintree.rs
+++ b/crates/router/src/connector/braintree.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -34,14 +34,6 @@ impl ConnectorCommon for Braintree {
connectors.braintree.base_url.as_ref()
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- braintree::BraintreeAuthType::try_from(val)?;
- Ok(())
- }
-
fn get_auth_header(
&self,
auth_type: &types::ConnectorAuthType,
diff --git a/crates/router/src/connector/cashtocode.rs b/crates/router/src/connector/cashtocode.rs
index 687b1d2db4..0e322fdec6 100644
--- a/crates/router/src/connector/cashtocode.rs
+++ b/crates/router/src/connector/cashtocode.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -97,14 +97,6 @@ impl ConnectorCommon for Cashtocode {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- cashtocode::CashtocodeAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.cashtocode.base_url.as_ref()
}
diff --git a/crates/router/src/connector/checkout.rs b/crates/router/src/connector/checkout.rs
index 42b29d2483..c7df563fe4 100644
--- a/crates/router/src/connector/checkout.rs
+++ b/crates/router/src/connector/checkout.rs
@@ -1,6 +1,4 @@
-#![allow(dead_code)]
-
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -62,13 +60,7 @@ impl ConnectorCommon for Checkout {
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- checkout::CheckoutAuthType::try_from(val)?;
- Ok(())
- }
+
fn get_auth_header(
&self,
auth_type: &types::ConnectorAuthType,
diff --git a/crates/router/src/connector/coinbase.rs b/crates/router/src/connector/coinbase.rs
index 5c190dac81..2d6411ccfd 100644
--- a/crates/router/src/connector/coinbase.rs
+++ b/crates/router/src/connector/coinbase.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -76,14 +76,6 @@ impl ConnectorCommon for Coinbase {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- coinbase::CoinbaseAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.coinbase.base_url.as_ref()
}
diff --git a/crates/router/src/connector/cryptopay.rs b/crates/router/src/connector/cryptopay.rs
index 39bc441192..cbc33d7cee 100644
--- a/crates/router/src/connector/cryptopay.rs
+++ b/crates/router/src/connector/cryptopay.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -133,14 +133,6 @@ impl ConnectorCommon for Cryptopay {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- cryptopay::CryptopayAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.cryptopay.base_url.as_ref()
}
diff --git a/crates/router/src/connector/cybersource.rs b/crates/router/src/connector/cybersource.rs
index e9e51df5b5..ac19553fdf 100644
--- a/crates/router/src/connector/cybersource.rs
+++ b/crates/router/src/connector/cybersource.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -88,13 +88,6 @@ impl ConnectorCommon for Cybersource {
"application/json;charset=utf-8"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- cybersource::CybersourceAuthType::try_from(val)?;
- Ok(())
- }
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.cybersource.base_url.as_ref()
}
diff --git a/crates/router/src/connector/dlocal.rs b/crates/router/src/connector/dlocal.rs
index 02be442c75..c773316179 100644
--- a/crates/router/src/connector/dlocal.rs
+++ b/crates/router/src/connector/dlocal.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -111,14 +111,6 @@ impl ConnectorCommon for Dlocal {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- dlocal::DlocalAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.dlocal.base_url.as_ref()
}
diff --git a/crates/router/src/connector/dummyconnector.rs b/crates/router/src/connector/dummyconnector.rs
index e9f52dbaba..cc82946547 100644
--- a/crates/router/src/connector/dummyconnector.rs
+++ b/crates/router/src/connector/dummyconnector.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -80,14 +80,6 @@ impl<const T: u8> ConnectorCommon for DummyConnector<T> {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- transformers::DummyConnectorAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.dummyconnector.base_url.as_ref()
}
diff --git a/crates/router/src/connector/fiserv.rs b/crates/router/src/connector/fiserv.rs
index 921cd1fc91..95e3238dd9 100644
--- a/crates/router/src/connector/fiserv.rs
+++ b/crates/router/src/connector/fiserv.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -105,14 +105,6 @@ impl ConnectorCommon for Fiserv {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- fiserv::FiservAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.fiserv.base_url.as_ref()
}
diff --git a/crates/router/src/connector/forte.rs b/crates/router/src/connector/forte.rs
index b184a4364d..2984dce72a 100644
--- a/crates/router/src/connector/forte.rs
+++ b/crates/router/src/connector/forte.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -79,13 +79,6 @@ impl ConnectorCommon for Forte {
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- forte::ForteAuthType::try_from(val)?;
- Ok(())
- }
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.forte.base_url.as_ref()
diff --git a/crates/router/src/connector/globalpay.rs b/crates/router/src/connector/globalpay.rs
index a233da05a3..e045c4b373 100644
--- a/crates/router/src/connector/globalpay.rs
+++ b/crates/router/src/connector/globalpay.rs
@@ -1,6 +1,6 @@
mod requests;
mod response;
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -15,7 +15,6 @@ use self::{
GlobalpayPaymentsResponse, GlobalpayRefreshTokenErrorResponse,
GlobalpayRefreshTokenResponse,
},
- transformers::GlobalpayAuthType,
};
use super::utils::RefundsRequestData;
use crate::{
@@ -79,14 +78,6 @@ impl ConnectorCommon for Globalpay {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- GlobalpayAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.globalpay.base_url.as_ref()
}
diff --git a/crates/router/src/connector/globepay.rs b/crates/router/src/connector/globepay.rs
index 29e4eaa704..002d06fa0c 100644
--- a/crates/router/src/connector/globepay.rs
+++ b/crates/router/src/connector/globepay.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -103,13 +103,6 @@ impl ConnectorCommon for Globepay {
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- globepay::GlobepayAuthType::try_from(val)?;
- Ok(())
- }
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.globepay.base_url.as_ref()
diff --git a/crates/router/src/connector/iatapay.rs b/crates/router/src/connector/iatapay.rs
index e56d4881e5..b3025363dc 100644
--- a/crates/router/src/connector/iatapay.rs
+++ b/crates/router/src/connector/iatapay.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -90,14 +90,6 @@ impl ConnectorCommon for Iatapay {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- iatapay::IatapayAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.iatapay.base_url.as_ref()
}
diff --git a/crates/router/src/connector/klarna.rs b/crates/router/src/connector/klarna.rs
index dbb1a93b4b..41d8c4e7b6 100644
--- a/crates/router/src/connector/klarna.rs
+++ b/crates/router/src/connector/klarna.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
use api_models::payments as api_payments;
@@ -35,14 +35,6 @@ impl ConnectorCommon for Klarna {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- klarna::KlarnaAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.klarna.base_url.as_ref()
}
diff --git a/crates/router/src/connector/mollie.rs b/crates/router/src/connector/mollie.rs
index 042c593dcf..e49b6deeda 100644
--- a/crates/router/src/connector/mollie.rs
+++ b/crates/router/src/connector/mollie.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -65,13 +65,6 @@ impl ConnectorCommon for Mollie {
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.mollie.base_url.as_ref()
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- mollie::MollieAuthType::try_from(val)?;
- Ok(())
- }
fn get_auth_header(
&self,
diff --git a/crates/router/src/connector/multisafepay.rs b/crates/router/src/connector/multisafepay.rs
index 143fdf0474..cf3e83d590 100644
--- a/crates/router/src/connector/multisafepay.rs
+++ b/crates/router/src/connector/multisafepay.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -48,14 +48,6 @@ impl ConnectorCommon for Multisafepay {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- multisafepay::MultisafepayAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.multisafepay.base_url.as_ref()
}
diff --git a/crates/router/src/connector/nexinets.rs b/crates/router/src/connector/nexinets.rs
index e9d8a06282..c62a8dae44 100644
--- a/crates/router/src/connector/nexinets.rs
+++ b/crates/router/src/connector/nexinets.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -76,13 +76,6 @@ impl ConnectorCommon for Nexinets {
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- nexinets::NexinetsAuthType::try_from(val)?;
- Ok(())
- }
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.nexinets.base_url.as_ref()
diff --git a/crates/router/src/connector/nmi.rs b/crates/router/src/connector/nmi.rs
index c6b6241973..c7b34d9ff2 100644
--- a/crates/router/src/connector/nmi.rs
+++ b/crates/router/src/connector/nmi.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -59,13 +59,6 @@ impl ConnectorCommon for Nmi {
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.nmi.base_url.as_ref()
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- nmi::NmiAuthType::try_from(val)?;
- Ok(())
- }
fn build_error_response(
&self,
diff --git a/crates/router/src/connector/noon.rs b/crates/router/src/connector/noon.rs
index fce88d86f9..2fe526a6bd 100644
--- a/crates/router/src/connector/noon.rs
+++ b/crates/router/src/connector/noon.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -86,13 +86,6 @@ impl ConnectorCommon for Noon {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- noon::NoonAuthType::try_from(val)?;
- Ok(())
- }
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.noon.base_url.as_ref()
}
diff --git a/crates/router/src/connector/nuvei.rs b/crates/router/src/connector/nuvei.rs
index 6cbb44e587..2c90077f09 100644
--- a/crates/router/src/connector/nuvei.rs
+++ b/crates/router/src/connector/nuvei.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -56,13 +56,7 @@ impl ConnectorCommon for Nuvei {
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- nuvei::NuveiAuthType::try_from(val)?;
- Ok(())
- }
+
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.nuvei.base_url.as_ref()
}
diff --git a/crates/router/src/connector/opayo.rs b/crates/router/src/connector/opayo.rs
index 2716796837..fd28cebf67 100644
--- a/crates/router/src/connector/opayo.rs
+++ b/crates/router/src/connector/opayo.rs
@@ -75,15 +75,6 @@ impl ConnectorCommon for Opayo {
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
-
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- opayo::OpayoAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.opayo.base_url.as_ref()
}
diff --git a/crates/router/src/connector/opennode.rs b/crates/router/src/connector/opennode.rs
index 01f8cbbe0f..96e1b8654b 100644
--- a/crates/router/src/connector/opennode.rs
+++ b/crates/router/src/connector/opennode.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -75,13 +75,6 @@ impl ConnectorCommon for Opennode {
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- opennode::OpennodeAuthType::try_from(val)?;
- Ok(())
- }
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.opennode.base_url.as_ref()
diff --git a/crates/router/src/connector/payeezy.rs b/crates/router/src/connector/payeezy.rs
index 77add3a82a..823bd60c15 100644
--- a/crates/router/src/connector/payeezy.rs
+++ b/crates/router/src/connector/payeezy.rs
@@ -91,13 +91,6 @@ impl ConnectorCommon for Payeezy {
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- payeezy::PayeezyAuthType::try_from(val)?;
- Ok(())
- }
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.payeezy.base_url.as_ref()
diff --git a/crates/router/src/connector/payme.rs b/crates/router/src/connector/payme.rs
index 1c70aa0d43..26c7c1eb95 100644
--- a/crates/router/src/connector/payme.rs
+++ b/crates/router/src/connector/payme.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -73,13 +73,6 @@ impl ConnectorCommon for Payme {
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- payme::PaymeAuthType::try_from(val)?;
- Ok(())
- }
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.payme.base_url.as_ref()
diff --git a/crates/router/src/connector/paypal.rs b/crates/router/src/connector/paypal.rs
index 4c11529f16..ae1777279c 100644
--- a/crates/router/src/connector/paypal.rs
+++ b/crates/router/src/connector/paypal.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
use base64::Engine;
@@ -151,13 +151,6 @@ impl ConnectorCommon for Paypal {
fn common_get_content_type(&self) -> &'static str {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- paypal::PaypalAuthType::try_from(val)?;
- Ok(())
- }
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.paypal.base_url.as_ref()
diff --git a/crates/router/src/connector/payu.rs b/crates/router/src/connector/payu.rs
index e6a2afbf99..dd04262eb3 100644
--- a/crates/router/src/connector/payu.rs
+++ b/crates/router/src/connector/payu.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -63,14 +63,6 @@ impl ConnectorCommon for Payu {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- payu::PayuAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.payu.base_url.as_ref()
}
diff --git a/crates/router/src/connector/powertranz.rs b/crates/router/src/connector/powertranz.rs
index f980b9d117..91392a27c3 100644
--- a/crates/router/src/connector/powertranz.rs
+++ b/crates/router/src/connector/powertranz.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -84,14 +84,6 @@ impl ConnectorCommon for Powertranz {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- powertranz::PowertranzAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.powertranz.base_url.as_ref()
}
diff --git a/crates/router/src/connector/rapyd.rs b/crates/router/src/connector/rapyd.rs
index edffaa19a1..02cc153da4 100644
--- a/crates/router/src/connector/rapyd.rs
+++ b/crates/router/src/connector/rapyd.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
use base64::Engine;
@@ -67,14 +67,6 @@ impl ConnectorCommon for Rapyd {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- rapyd::RapydAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.rapyd.base_url.as_ref()
}
diff --git a/crates/router/src/connector/shift4.rs b/crates/router/src/connector/shift4.rs
index b66dff8510..8d6e8d0fd0 100644
--- a/crates/router/src/connector/shift4.rs
+++ b/crates/router/src/connector/shift4.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -64,14 +64,6 @@ impl ConnectorCommon for Shift4 {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- shift4::Shift4AuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.shift4.base_url.as_ref()
}
diff --git a/crates/router/src/connector/square.rs b/crates/router/src/connector/square.rs
index 0bc41decc0..1cb4a2aee6 100644
--- a/crates/router/src/connector/square.rs
+++ b/crates/router/src/connector/square.rs
@@ -83,14 +83,6 @@ impl ConnectorCommon for Square {
connectors.square.base_url.as_ref()
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- square::SquareAuthType::try_from(val)?;
- Ok(())
- }
-
fn get_auth_header(
&self,
auth_type: &types::ConnectorAuthType,
diff --git a/crates/router/src/connector/stax.rs b/crates/router/src/connector/stax.rs
index 002058bb8e..2795a0bf92 100644
--- a/crates/router/src/connector/stax.rs
+++ b/crates/router/src/connector/stax.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -66,13 +66,6 @@ impl ConnectorCommon for Stax {
fn id(&self) -> &'static str {
"stax"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- stax::StaxAuthType::try_from(val)?;
- Ok(())
- }
fn common_get_content_type(&self) -> &'static str {
"application/json"
diff --git a/crates/router/src/connector/stripe.rs b/crates/router/src/connector/stripe.rs
index b8a258a28d..eb96e166f1 100644
--- a/crates/router/src/connector/stripe.rs
+++ b/crates/router/src/connector/stripe.rs
@@ -40,14 +40,6 @@ impl ConnectorCommon for Stripe {
"application/x-www-form-urlencoded"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- stripe::StripeAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
// &self.base_url
connectors.stripe.base_url.as_ref()
diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rs
index a339bc449e..14155065a6 100644
--- a/crates/router/src/connector/trustpay.rs
+++ b/crates/router/src/connector/trustpay.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -84,14 +84,6 @@ impl ConnectorCommon for Trustpay {
"application/x-www-form-urlencoded"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- trustpay::TrustpayAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.trustpay.base_url.as_ref()
}
diff --git a/crates/router/src/connector/tsys.rs b/crates/router/src/connector/tsys.rs
index 5613cd439e..e0f6e592c3 100644
--- a/crates/router/src/connector/tsys.rs
+++ b/crates/router/src/connector/tsys.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -73,14 +73,6 @@ impl ConnectorCommon for Tsys {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- tsys::TsysAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.tsys.base_url.as_ref()
}
diff --git a/crates/router/src/connector/wise.rs b/crates/router/src/connector/wise.rs
index 7519697e77..b0eee83484 100644
--- a/crates/router/src/connector/wise.rs
+++ b/crates/router/src/connector/wise.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
use error_stack::{IntoReport, ResultExt};
@@ -59,13 +59,6 @@ impl ConnectorCommon for Wise {
fn id(&self) -> &'static str {
"wise"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- wise::WiseAuthType::try_from(val)?;
- Ok(())
- }
fn get_auth_header(
&self,
diff --git a/crates/router/src/connector/worldline.rs b/crates/router/src/connector/worldline.rs
index cb07e7a1a5..b258cd98d6 100644
--- a/crates/router/src/connector/worldline.rs
+++ b/crates/router/src/connector/worldline.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -37,7 +37,7 @@ pub struct Worldline;
impl Worldline {
pub fn generate_authorization_token(
&self,
- auth: worldline::AuthType,
+ auth: worldline::WorldlineAuthType,
http_method: &services::Method,
content_type: &str,
date: &str,
@@ -50,7 +50,7 @@ impl Worldline {
date.trim(),
endpoint.trim()
);
- let worldline::AuthType {
+ let worldline::WorldlineAuthType {
api_key,
api_secret,
..
@@ -87,7 +87,7 @@ where
let url = Self::get_url(self, req, connectors)?;
let endpoint = url.replace(base_url, "");
let http_method = Self::get_http_method(self);
- let auth = worldline::AuthType::try_from(&req.connector_auth_type)?;
+ let auth = worldline::WorldlineAuthType::try_from(&req.connector_auth_type)?;
let date = Self::get_current_date_time()?;
let content_type = Self::get_content_type(self);
let signed_data: String =
@@ -116,14 +116,6 @@ impl ConnectorCommon for Worldline {
connectors.worldline.base_url.as_ref()
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- worldline::AuthType::try_from(val)?;
- Ok(())
- }
-
fn build_error_response(
&self,
res: types::Response,
@@ -192,7 +184,8 @@ impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsR
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
let base_url = self.base_url(connectors);
- let auth: worldline::AuthType = worldline::AuthType::try_from(&req.connector_auth_type)?;
+ let auth: worldline::WorldlineAuthType =
+ worldline::WorldlineAuthType::try_from(&req.connector_auth_type)?;
let merchant_account_id = auth.merchant_account_id.expose();
let payment_id: &str = req.request.connector_transaction_id.as_ref();
Ok(format!(
@@ -272,7 +265,7 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
.get_connector_transaction_id()
.change_context(errors::ConnectorError::MissingConnectorTransactionID)?;
let base_url = self.base_url(connectors);
- let auth = worldline::AuthType::try_from(&req.connector_auth_type)?;
+ let auth = worldline::WorldlineAuthType::try_from(&req.connector_auth_type)?;
let merchant_account_id = auth.merchant_account_id.expose();
Ok(format!(
"{base_url}v1/{merchant_account_id}/payments/{payment_id}"
@@ -348,7 +341,7 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Payme
) -> CustomResult<String, errors::ConnectorError> {
let payment_id = req.request.connector_transaction_id.clone();
let base_url = self.base_url(connectors);
- let auth = worldline::AuthType::try_from(&req.connector_auth_type)?;
+ let auth = worldline::WorldlineAuthType::try_from(&req.connector_auth_type)?;
let merchant_account_id = auth.merchant_account_id.expose();
Ok(format!(
"{base_url}v1/{merchant_account_id}/payments/{payment_id}/approve"
@@ -465,7 +458,7 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
let base_url = self.base_url(connectors);
- let auth = worldline::AuthType::try_from(&req.connector_auth_type)?;
+ let auth = worldline::WorldlineAuthType::try_from(&req.connector_auth_type)?;
let merchant_account_id = auth.merchant_account_id.expose();
Ok(format!("{base_url}v1/{merchant_account_id}/payments"))
}
@@ -556,7 +549,7 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
) -> CustomResult<String, errors::ConnectorError> {
let payment_id = req.request.connector_transaction_id.clone();
let base_url = self.base_url(connectors);
- let auth = worldline::AuthType::try_from(&req.connector_auth_type)?;
+ let auth = worldline::WorldlineAuthType::try_from(&req.connector_auth_type)?;
let merchant_account_id = auth.merchant_account_id.expose();
Ok(format!(
"{base_url}v1/{merchant_account_id}/payments/{payment_id}/refund"
@@ -646,7 +639,8 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse
) -> CustomResult<String, errors::ConnectorError> {
let refund_id = req.request.get_connector_refund_id()?;
let base_url = self.base_url(connectors);
- let auth: worldline::AuthType = worldline::AuthType::try_from(&req.connector_auth_type)?;
+ let auth: worldline::WorldlineAuthType =
+ worldline::WorldlineAuthType::try_from(&req.connector_auth_type)?;
let merchant_account_id = auth.merchant_account_id.expose();
Ok(format!(
"{base_url}v1/{merchant_account_id}/refunds/{refund_id}/"
diff --git a/crates/router/src/connector/worldline/transformers.rs b/crates/router/src/connector/worldline/transformers.rs
index 6dbdd9bb22..72c8e06249 100644
--- a/crates/router/src/connector/worldline/transformers.rs
+++ b/crates/router/src/connector/worldline/transformers.rs
@@ -409,13 +409,13 @@ impl From<payments::AddressDetails> for Shipping {
}
}
-pub struct AuthType {
+pub struct WorldlineAuthType {
pub api_key: Secret<String>,
pub api_secret: Secret<String>,
pub merchant_account_id: Secret<String>,
}
-impl TryFrom<&types::ConnectorAuthType> for AuthType {
+impl TryFrom<&types::ConnectorAuthType> for WorldlineAuthType {
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {
if let types::ConnectorAuthType::SignatureKey {
diff --git a/crates/router/src/connector/worldpay.rs b/crates/router/src/connector/worldpay.rs
index ad6962e0fb..a1943c7805 100644
--- a/crates/router/src/connector/worldpay.rs
+++ b/crates/router/src/connector/worldpay.rs
@@ -1,6 +1,6 @@
mod requests;
mod response;
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -59,14 +59,6 @@ impl ConnectorCommon for Worldpay {
"application/vnd.worldpay.payments-v6+json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- worldpay::WorldpayAuthType::try_from(val)?;
- Ok(())
- }
-
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.worldpay.base_url.as_ref()
}
diff --git a/crates/router/src/connector/zen.rs b/crates/router/src/connector/zen.rs
index 43e392c2ad..3a201eb44b 100644
--- a/crates/router/src/connector/zen.rs
+++ b/crates/router/src/connector/zen.rs
@@ -1,4 +1,4 @@
-mod transformers;
+pub mod transformers;
use std::fmt::Debug;
@@ -83,13 +83,6 @@ impl ConnectorCommon for Zen {
fn common_get_content_type(&self) -> &'static str {
mime::APPLICATION_JSON.essence_str()
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>> {
- zen::ZenAuthType::try_from(val)?;
- Ok(())
- }
fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {
connectors.zen.base_url.as_ref()
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index f762bd6588..b8a51dc51a 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -1,4 +1,4 @@
-use api_models::admin::PrimaryBusinessDetails;
+use api_models::{admin::PrimaryBusinessDetails, enums as api_enums};
use common_utils::{
crypto::{generate_cryptographically_secure_random_string, OptionalSecretValue},
date_time,
@@ -16,11 +16,10 @@ use crate::{
payments::helpers,
},
db::StorageInterface,
- routes::{metrics, AppState},
+ routes::metrics,
services::{self, api as service_api},
types::{
- self,
- api::{self, ConnectorData},
+ self, api,
domain::{
self,
types::{self as domain_types, AsyncLift},
@@ -395,16 +394,12 @@ fn validate_certificate_in_mca_metadata(
}
pub async fn create_payment_connector(
- state: &AppState,
+ store: &dyn StorageInterface,
req: api::MerchantConnectorCreate,
merchant_id: &String,
) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {
- let key_store = state
- .store
- .get_merchant_key_store_by_merchant_id(
- merchant_id,
- &state.store.get_master_key().to_vec().into(),
- )
+ let key_store = store
+ .get_merchant_key_store_by_merchant_id(merchant_id, &store.get_master_key().to_vec().into())
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
@@ -413,8 +408,7 @@ pub async fn create_payment_connector(
.map(validate_certificate_in_mca_metadata)
.transpose()?;
- let merchant_account = state
- .store
+ let merchant_account = store
.find_merchant_account_by_merchant_id(merchant_id, &key_store)
.await
.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;
@@ -458,13 +452,17 @@ pub async fn create_payment_connector(
expected_format: "auth_type and api_key".to_string(),
})?;
- let conn_name =
- ConnectorData::convert_connector(&state.conf.connectors, &req.connector_name.to_string())?;
- conn_name.validate_auth_type(&auth).change_context(
- errors::ApiErrorResponse::InvalidRequestData {
- message: "The auth type is not supported for connector".to_string(),
- },
- )?;
+ validate_auth_type(req.connector_name, &auth).map_err(|err| {
+ if err.current_context() == &errors::ConnectorError::InvalidConnectorName {
+ err.change_context(errors::ApiErrorResponse::InvalidRequestData {
+ message: "The connector name is invalid".to_string(),
+ })
+ } else {
+ err.change_context(errors::ApiErrorResponse::InvalidRequestData {
+ message: "The auth type is invalid for the connector".to_string(),
+ })
+ }
+ })?;
let frm_configs = get_frm_config_as_secret(req.frm_configs);
@@ -510,8 +508,7 @@ pub async fn create_payment_connector(
},
};
- let mca = state
- .store
+ let mca = store
.insert_merchant_connector_account(merchant_connector_account, &key_store)
.await
.to_duplicate_response(
@@ -832,3 +829,197 @@ pub fn get_frm_config_as_secret(
None => None,
}
}
+
+pub(crate) fn validate_auth_type(
+ connector_name: api_models::enums::Connector,
+ val: &types::ConnectorAuthType,
+) -> Result<(), error_stack::Report<errors::ConnectorError>> {
+ use crate::connector::*;
+
+ match connector_name {
+ #[cfg(feature = "dummy_connector")]
+ api_enums::Connector::DummyConnector1
+ | api_enums::Connector::DummyConnector2
+ | api_enums::Connector::DummyConnector3
+ | api_enums::Connector::DummyConnector4
+ | api_enums::Connector::DummyConnector5
+ | api_enums::Connector::DummyConnector6
+ | api_enums::Connector::DummyConnector7 => {
+ dummyconnector::transformers::DummyConnectorAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Aci => {
+ aci::transformers::AciAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Adyen => {
+ adyen::transformers::AdyenAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Airwallex => {
+ airwallex::transformers::AirwallexAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Authorizedotnet => {
+ authorizedotnet::transformers::AuthorizedotnetAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Bitpay => {
+ bitpay::transformers::BitpayAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Bambora => {
+ bambora::transformers::BamboraAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Boku => {
+ boku::transformers::BokuAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Bluesnap => {
+ bluesnap::transformers::BluesnapAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Braintree => {
+ braintree::transformers::BraintreeAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Cashtocode => {
+ cashtocode::transformers::CashtocodeAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Checkout => {
+ checkout::transformers::CheckoutAuthType::try_from(val)?;
+ Ok(())
+ }
+
+ api_enums::Connector::Coinbase => {
+ coinbase::transformers::CoinbaseAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Cryptopay => {
+ cryptopay::transformers::CryptopayAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Cybersource => {
+ cybersource::transformers::CybersourceAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Dlocal => {
+ dlocal::transformers::DlocalAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Fiserv => {
+ fiserv::transformers::FiservAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Forte => {
+ forte::transformers::ForteAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Globalpay => {
+ globalpay::transformers::GlobalpayAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Globepay => {
+ globepay::transformers::GlobepayAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Iatapay => {
+ iatapay::transformers::IatapayAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Klarna => {
+ klarna::transformers::KlarnaAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Mollie => {
+ mollie::transformers::MollieAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Multisafepay => {
+ multisafepay::transformers::MultisafepayAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Nexinets => {
+ nexinets::transformers::NexinetsAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Nmi => {
+ nmi::transformers::NmiAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Noon => {
+ noon::transformers::NoonAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Nuvei => {
+ nuvei::transformers::NuveiAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Opennode => {
+ opennode::transformers::OpennodeAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Payme => {
+ payme::transformers::PaymeAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Paypal => {
+ paypal::transformers::PaypalAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Payu => {
+ payu::transformers::PayuAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Powertranz => {
+ powertranz::transformers::PowertranzAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Rapyd => {
+ rapyd::transformers::RapydAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Shift4 => {
+ shift4::transformers::Shift4AuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Stax => {
+ stax::transformers::StaxAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Stripe => {
+ stripe::transformers::StripeAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Trustpay => {
+ trustpay::transformers::TrustpayAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Tsys => {
+ tsys::transformers::TsysAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Wise => {
+ wise::transformers::WiseAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Worldline => {
+ worldline::transformers::WorldlineAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Worldpay => {
+ worldpay::transformers::WorldpayAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Zen => {
+ zen::transformers::ZenAuthType::try_from(val)?;
+ Ok(())
+ }
+ api_enums::Connector::Signifyd => {
+ Err(report!(errors::ConnectorError::InvalidConnectorName)
+ .attach_printable(format!("invalid connector name: {connector_name}")))
+ }
+ }
+}
diff --git a/crates/router/src/routes/admin.rs b/crates/router/src/routes/admin.rs
index 8695e17a1b..dd8ca8d323 100644
--- a/crates/router/src/routes/admin.rs
+++ b/crates/router/src/routes/admin.rs
@@ -180,7 +180,7 @@ pub async fn payment_connector_create(
state.get_ref(),
&req,
json_payload.into_inner(),
- |state, _, req| create_payment_connector(state, req, &merchant_id),
+ |state, _, req| create_payment_connector(&*state.store, req, &merchant_id),
&auth::AdminApiAuth,
)
.await
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index 4882d7a129..283aae9835 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -65,11 +65,6 @@ pub trait ConnectorCommon {
"application/json"
}
- fn validate_auth_type(
- &self,
- val: &types::ConnectorAuthType,
- ) -> Result<(), error_stack::Report<errors::ConnectorError>>;
-
// FIXME write doc - think about this
// fn headers(&self) -> Vec<(&str, &str)>;