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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
fix(router): add validation for all the connector auth type (#1748)
Amisha Prabhat1cda7ad5fccb
diff --git a/connector-template/mod.rs b/connector-template/mod.rsindex 653c28962b..67745e8b4c 100644--- a/connector-template/mod.rs+++ b/connector-template/mod.rs@@ -77,6 +77,14 @@ impl ConnectorCommon for {{project-name | downcase | pascal_case}} {fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str {connectors.{{project-name}}.base_url.as_ref()}++ fn validate_auth_type(+ &self,+ val: &types::ConnectorAuthType,+ ) -> Result<(), error_stack::Report<errors::ConnectorError>> {+ {{project-name | downcase}}::{{project-name | downcase | pascal_case}}AuthType::try_from(val)?;+ Ok(())+ }fn get_auth_header(&self, auth_type:&types::ConnectorAuthType)-> CustomResult<Vec<(String,request::Maskable<String>)>,errors::ConnectorError> {let auth = {{project-name | downcase}}::{{project-name | downcase | pascal_case}}AuthType::try_from(auth_type)diff --git a/crates/router/src/connector/aci.rs b/crates/router/src/connector/aci.rsindex 5bed999903..6cc3f9e832 100644--- a/crates/router/src/connector/aci.rs+++ b/crates/router/src/connector/aci.rs@@ -34,6 +34,14 @@ 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.rsindex 3d5b4d9609..5dcc38e46c 100644--- a/crates/router/src/connector/adyen.rs+++ b/crates/router/src/connector/adyen.rs@@ -49,6 +49,14 @@ impl ConnectorCommon for Adyen {)])}+ 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.rsindex 7cd5eb7124..c8f253c410 100644--- a/crates/router/src/connector/airwallex.rs+++ b/crates/router/src/connector/airwallex.rs@@ -72,6 +72,14 @@ 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/airwallex/transformers.rs b/crates/router/src/connector/airwallex/transformers.rsindex 68b990951b..4e4dc6f823 100644--- a/crates/router/src/connector/airwallex/transformers.rs+++ b/crates/router/src/connector/airwallex/transformers.rs@@ -13,6 +13,25 @@ use crate::{types::{self, api, storage::enums},};+pub struct AirwallexAuthType {+ pub x_api_key: Secret<String>,+ pub x_client_id: Secret<String>,+}++impl TryFrom<&types::ConnectorAuthType> for AirwallexAuthType {+ type Error = error_stack::Report<errors::ConnectorError>;++ fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {+ if let types::ConnectorAuthType::BodyKey { api_key, key1 } = auth_type {+ Ok(Self {+ x_api_key: api_key.clone(),+ x_client_id: key1.clone(),+ })+ } else {+ Err(errors::ConnectorError::FailedToObtainAuthType)?+ }+ }+}#[derive(Default, Debug, Serialize, Eq, PartialEq)]pub struct AirwallexIntentRequest {// Unique ID to be sent for each transaction/operation request to the connectordiff --git a/crates/router/src/connector/authorizedotnet.rs b/crates/router/src/connector/authorizedotnet.rsindex 6b7ed503f9..ca7f793abd 100644--- a/crates/router/src/connector/authorizedotnet.rs+++ b/crates/router/src/connector/authorizedotnet.rs@@ -52,6 +52,14 @@ 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.rsindex aaaadd77ed..f1b1c3a452 100644--- a/crates/router/src/connector/authorizedotnet/transformers.rs+++ b/crates/router/src/connector/authorizedotnet/transformers.rs@@ -33,7 +33,7 @@ pub enum TransactionType {}#[derive(Debug, Serialize)]#[serde(rename_all = "camelCase")]-struct MerchantAuthentication {+pub struct MerchantAuthentication {name: Secret<String>,transaction_key: Secret<String>,}diff --git a/crates/router/src/connector/bambora.rs b/crates/router/src/connector/bambora.rsindex e6e6b2ae93..cd5e848403 100644--- a/crates/router/src/connector/bambora.rs+++ b/crates/router/src/connector/bambora.rs@@ -60,6 +60,14 @@ 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.rsindex eeb9802026..1e86764a42 100644--- a/crates/router/src/connector/bitpay.rs+++ b/crates/router/src/connector/bitpay.rs@@ -86,6 +86,14 @@ 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.rsindex 296b641e35..1b88ea8523 100644--- a/crates/router/src/connector/bluesnap.rs+++ b/crates/router/src/connector/bluesnap.rs@@ -67,7 +67,13 @@ 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.rsindex e0af2af95e..70aa46e99b 100644--- a/crates/router/src/connector/boku.rs+++ b/crates/router/src/connector/boku.rs@@ -78,6 +78,13 @@ impl ConnectorCommon for Boku {fn common_get_content_type(&self) -> &'static str {"application/json"}+ fn validate_auth_type(+ &self,+ val: &types::ConnectorAuthType,+ ) -> Result<(), error_stack::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.rsindex 717bf1747c..3c2838f74b 100644--- a/crates/router/src/connector/braintree.rs+++ b/crates/router/src/connector/braintree.rs@@ -34,6 +34,14 @@ 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.rsindex 249ca3fe61..c14c666a7a 100644--- a/crates/router/src/connector/cashtocode.rs+++ b/crates/router/src/connector/cashtocode.rs@@ -97,6 +97,14 @@ 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.rsindex c9d4edce7e..42b29d2483 100644--- a/crates/router/src/connector/checkout.rs+++ b/crates/router/src/connector/checkout.rs@@ -62,7 +62,13 @@ 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.rsindex 1d4d5764e2..a4bbf77ab4 100644--- a/crates/router/src/connector/coinbase.rs+++ b/crates/router/src/connector/coinbase.rs@@ -76,6 +76,14 @@ 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.rsindex 4fa8c4e8da..39bc441192 100644--- a/crates/router/src/connector/cryptopay.rs+++ b/crates/router/src/connector/cryptopay.rs@@ -133,6 +133,14 @@ 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.rsindex ba8b35964f..e9e51df5b5 100644--- a/crates/router/src/connector/cybersource.rs+++ b/crates/router/src/connector/cybersource.rs@@ -88,6 +88,13 @@ 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.rsindex be0855e435..02be442c75 100644--- a/crates/router/src/connector/dlocal.rs+++ b/crates/router/src/connector/dlocal.rs@@ -111,6 +111,14 @@ 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.rsindex 80787b35d1..3506e2ecb3 100644--- a/crates/router/src/connector/dummyconnector.rs+++ b/crates/router/src/connector/dummyconnector.rs@@ -90,6 +90,14 @@ impl<const T: u8> ConnectorCommon for DummyConnector<T> {"application/json"}+ fn validate_auth_type(+ &self,+ val: &types::ConnectorAuthType,+ ) -> Result<(), error_stack::Report<errors::ConnectorError>> {+ dummyconnector::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.rsindex 25a593f3ff..921cd1fc91 100644--- a/crates/router/src/connector/fiserv.rs+++ b/crates/router/src/connector/fiserv.rs@@ -105,6 +105,14 @@ 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.rsindex 5dde831071..b184a4364d 100644--- a/crates/router/src/connector/forte.rs+++ b/crates/router/src/connector/forte.rs@@ -79,6 +79,13 @@ 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.rsindex e15da504a8..a233da05a3 100644--- a/crates/router/src/connector/globalpay.rs+++ b/crates/router/src/connector/globalpay.rs@@ -15,6 +15,7 @@ use self::{GlobalpayPaymentsResponse, GlobalpayRefreshTokenErrorResponse,GlobalpayRefreshTokenResponse,},+ transformers::GlobalpayAuthType,};use super::utils::RefundsRequestData;use crate::{@@ -78,6 +79,14 @@ 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.rsindex bd3bfdb920..29e4eaa704 100644--- a/crates/router/src/connector/globepay.rs+++ b/crates/router/src/connector/globepay.rs@@ -103,6 +103,13 @@ 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.rsindex f3f5a4eb12..4b104cde73 100644--- a/crates/router/src/connector/iatapay.rs+++ b/crates/router/src/connector/iatapay.rs@@ -90,6 +90,14 @@ 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.rsindex 4f15fb77db..dbb1a93b4b 100644--- a/crates/router/src/connector/klarna.rs+++ b/crates/router/src/connector/klarna.rs@@ -35,6 +35,14 @@ 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.rsindex 46385e2ec6..042c593dcf 100644--- a/crates/router/src/connector/mollie.rs+++ b/crates/router/src/connector/mollie.rs@@ -65,6 +65,13 @@ 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.rsindex 07daef20e2..143fdf0474 100644--- a/crates/router/src/connector/multisafepay.rs+++ b/crates/router/src/connector/multisafepay.rs@@ -48,6 +48,14 @@ 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.rsindex 2d90c2c4c1..e9d8a06282 100644--- a/crates/router/src/connector/nexinets.rs+++ b/crates/router/src/connector/nexinets.rs@@ -76,6 +76,13 @@ 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.rsindex 37fc6e5cf8..c6b6241973 100644--- a/crates/router/src/connector/nmi.rs+++ b/crates/router/src/connector/nmi.rs@@ -59,6 +59,13 @@ 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.rsindex 22c778334e..fce88d86f9 100644--- a/crates/router/src/connector/noon.rs+++ b/crates/router/src/connector/noon.rs@@ -86,6 +86,13 @@ 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.rsindex 560eea6f09..6cbb44e587 100644--- a/crates/router/src/connector/nuvei.rs+++ b/crates/router/src/connector/nuvei.rs@@ -56,7 +56,13 @@ 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.rsindex 4203bd7152..2716796837 100644--- a/crates/router/src/connector/opayo.rs+++ b/crates/router/src/connector/opayo.rs@@ -76,6 +76,14 @@ impl ConnectorCommon for Opayo {"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.rsindex 36eba82093..c4f75d7fba 100644--- a/crates/router/src/connector/opennode.rs+++ b/crates/router/src/connector/opennode.rs@@ -75,6 +75,13 @@ 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.rsindex d210b04df2..04f5853842 100644--- a/crates/router/src/connector/payeezy.rs+++ b/crates/router/src/connector/payeezy.rs@@ -91,6 +91,13 @@ 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.rsindex b33b78ee5c..6d5bda6e2b 100644--- a/crates/router/src/connector/payme.rs+++ b/crates/router/src/connector/payme.rs@@ -73,6 +73,13 @@ 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.rsindex dc6a70431a..ec74a8f021 100644--- a/crates/router/src/connector/paypal.rs+++ b/crates/router/src/connector/paypal.rs@@ -150,6 +150,13 @@ 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.rsindex 1b5bc904bf..e6a2afbf99 100644--- a/crates/router/src/connector/payu.rs+++ b/crates/router/src/connector/payu.rs@@ -63,6 +63,14 @@ 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.rsindex 252f847988..f980b9d117 100644--- a/crates/router/src/connector/powertranz.rs+++ b/crates/router/src/connector/powertranz.rs@@ -84,6 +84,14 @@ 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.rsindex b1e814afb4..f6e8056505 100644--- a/crates/router/src/connector/rapyd.rs+++ b/crates/router/src/connector/rapyd.rs@@ -67,6 +67,14 @@ 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.rsindex ba0e655977..b66dff8510 100644--- a/crates/router/src/connector/shift4.rs+++ b/crates/router/src/connector/shift4.rs@@ -64,6 +64,14 @@ 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/stax.rs b/crates/router/src/connector/stax.rsindex 86a1e7196d..460539930b 100644--- a/crates/router/src/connector/stax.rs+++ b/crates/router/src/connector/stax.rs@@ -73,6 +73,13 @@ 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.rsindex a717022e78..6703e54293 100644--- a/crates/router/src/connector/stripe.rs+++ b/crates/router/src/connector/stripe.rs@@ -1,4 +1,4 @@-mod transformers;+pub mod transformers;use std::{collections::HashMap, fmt::Debug, ops::Deref};@@ -40,6 +40,14 @@ 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_urlconnectors.stripe.base_url.as_ref()diff --git a/crates/router/src/connector/trustpay.rs b/crates/router/src/connector/trustpay.rsindex e0a039e579..267ed06ab9 100644--- a/crates/router/src/connector/trustpay.rs+++ b/crates/router/src/connector/trustpay.rs@@ -81,6 +81,14 @@ 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.rsindex 222e20926d..5613cd439e 100644--- a/crates/router/src/connector/tsys.rs+++ b/crates/router/src/connector/tsys.rs@@ -73,6 +73,14 @@ 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.rsindex 7d1f4b2786..7519697e77 100644--- a/crates/router/src/connector/wise.rs+++ b/crates/router/src/connector/wise.rs@@ -59,6 +59,13 @@ 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.rsindex b356945fc6..cb07e7a1a5 100644--- a/crates/router/src/connector/worldline.rs+++ b/crates/router/src/connector/worldline.rs@@ -116,6 +116,14 @@ 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,diff --git a/crates/router/src/connector/worldpay.rs b/crates/router/src/connector/worldpay.rsindex 12f5abf6b3..ad6962e0fb 100644--- a/crates/router/src/connector/worldpay.rs+++ b/crates/router/src/connector/worldpay.rs@@ -59,6 +59,14 @@ 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.rsindex a583e0d834..43e392c2ad 100644--- a/crates/router/src/connector/zen.rs+++ b/crates/router/src/connector/zen.rs@@ -83,6 +83,13 @@ 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.rsindex c8efdf5397..320c59c84d 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -16,10 +16,11 @@ use crate::{payments::helpers,},db::StorageInterface,- routes::metrics,+ routes::{metrics, AppState},services::{self, api as service_api},types::{- self, api,+ self,+ api::{self, ConnectorData},domain::{self,types::{self as domain_types, AsyncLift},@@ -440,12 +441,16 @@ fn validate_certificate_in_mca_metadata(}pub async fn create_payment_connector(- store: &dyn StorageInterface,+ state: &AppState,req: api::MerchantConnectorCreate,merchant_id: &String,) -> RouterResponse<api_models::admin::MerchantConnectorResponse> {- let key_store = store- .get_merchant_key_store_by_merchant_id(merchant_id, &store.get_master_key().to_vec().into())+ let key_store = state+ .store+ .get_merchant_key_store_by_merchant_id(+ merchant_id,+ &state.store.get_master_key().to_vec().into(),+ ).await.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;@@ -454,7 +459,8 @@ pub async fn create_payment_connector(.map(validate_certificate_in_mca_metadata).transpose()?;- let merchant_account = store+ let merchant_account = state+ .store.find_merchant_account_by_merchant_id(merchant_id, &key_store).await.to_not_found_response(errors::ApiErrorResponse::MerchantAccountNotFound)?;@@ -485,7 +491,7 @@ pub async fn create_payment_connector(};// Validate Merchant api details and return error if not in correct format- let _: types::ConnectorAuthType = req+ let auth: types::ConnectorAuthType = req.connector_account_details.clone().parse_value("ConnectorAuthType")@@ -494,6 +500,14 @@ 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(),+ },+ )?;+let frm_configs = get_frm_config_as_secret(req.frm_configs);let merchant_connector_account = domain::MerchantConnectorAccount {@@ -538,7 +552,8 @@ pub async fn create_payment_connector(},};- let mca = store+ let mca = state+ .store.insert_merchant_connector_account(merchant_connector_account, &key_store).await.to_duplicate_response(diff --git a/crates/router/src/core/payments/operations/payment_session.rs b/crates/router/src/core/payments/operations/payment_session.rsindex ccfb3bfda1..7fa976b2d3 100644--- a/crates/router/src/core/payments/operations/payment_session.rs+++ b/crates/router/src/core/payments/operations/payment_session.rs@@ -310,7 +310,6 @@ wherepayment_intent: &storage::payment_intent::PaymentIntent,key_store: &domain::MerchantKeyStore,) -> RouterResult<api::ConnectorChoice> {- let connectors = &state.conf.connectors;let db = &state.store;let all_connector_accounts = db@@ -390,13 +389,15 @@ whereconnector_and_supporting_payment_method_type{let connector_type = api::GetToken::from(payment_method_type);- if let Ok(connector_data) =- api::ConnectorData::get_connector_by_name(connectors, &connector, connector_type)- .map_err(|err| {- logger::error!(session_token_error=?err);- err- })- {+ if let Ok(connector_data) = api::ConnectorData::get_connector_by_name(+ &state.conf.connectors,+ &connector,+ connector_type,+ )+ .map_err(|err| {+ logger::error!(session_token_error=?err);+ err+ }) {session_connector_data.push(api::SessionConnectorData {payment_method_type,connector: connector_data,diff --git a/crates/router/src/routes/admin.rs b/crates/router/src/routes/admin.rsindex dd8ca8d323..8695e17a1b 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.store, req, &merchant_id),+ |state, _, req| create_payment_connector(state, req, &merchant_id),&auth::AdminApiAuth,).awaitdiff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rsindex e8f4d497e6..44e14c949c 100644--- a/crates/router/src/types/api.rs+++ b/crates/router/src/types/api.rs@@ -65,6 +65,11 @@ 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)>;@@ -266,7 +271,7 @@ impl ConnectorData {})}- fn convert_connector(+ pub fn convert_connector(_connectors: &Connectors,connector_name: &str,) -> CustomResult<BoxedConnector, errors::ApiErrorResponse> {