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
feat(core): add runtime flag to disable dummy connector (#2100)
Apoorv Dixitd52fe7f1403b
diff --git a/config/config.example.toml b/config/config.example.tomlindex 2a280f320f..604be8f091 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -316,6 +316,7 @@ trustpay = {payment_method = "card,bank_redirect,wallet"}stripe = {payment_method = "card,bank_redirect,pay_later,wallet,bank_debit"}[dummy_connector]+enabled = true # Whether dummy connector is enabled or notpayment_ttl = 172800 # Time to live for dummy connector payment in redispayment_duration = 1000 # Fake delay duration for dummy connector paymentpayment_tolerance = 100 # Fake delay tolerance for dummy connector paymentdiff --git a/config/development.toml b/config/development.tomlindex 9fc9dae8a2..1d6ed43980 100644--- a/config/development.toml+++ b/config/development.toml@@ -382,6 +382,7 @@ connector_list = "bluesnap,stax,stripe"payout_connector_list = "wise"[dummy_connector]+enabled = truepayment_ttl = 172800payment_duration = 1000payment_tolerance = 100diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex d2152cbb47..625f6a6f1e 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -207,6 +207,7 @@ trustpay = {payment_method = "card,bank_redirect,wallet"}stripe = {payment_method = "card,bank_redirect,pay_later,wallet,bank_debit"}[dummy_connector]+enabled = truepayment_ttl = 172800payment_duration = 1000payment_tolerance = 100diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rsindex 640f692d55..1d0ebf5070 100644--- a/crates/router/src/configs/settings.rs+++ b/crates/router/src/configs/settings.rs@@ -164,6 +164,7 @@ where#[cfg(feature = "dummy_connector")]#[derive(Debug, Deserialize, Clone, Default)]pub struct DummyConnector {+ pub enabled: bool,pub payment_ttl: i64,pub payment_duration: u64,pub payment_tolerance: u64,diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rsindex 7a3a6055f7..8e64c63dd7 100644--- a/crates/router/src/core/admin.rs+++ b/crates/router/src/core/admin.rs@@ -17,7 +17,7 @@ use crate::{utils as core_utils,},db::StorageInterface,- routes::metrics,+ routes::{metrics, AppState},services::{self, api as service_api},types::{self, api,@@ -547,12 +547,18 @@ 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())+ #[cfg(feature = "dummy_connector")]+ validate_dummy_connector_enabled(state, &req.connector_name).await?;+ 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)?;@@ -561,7 +567,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)?;@@ -624,7 +631,7 @@ pub async fn create_payment_connector(req.business_label.as_ref(),&merchant_account,req.profile_id.as_ref(),- store,+ &*state.store,).await?;@@ -671,7 +678,8 @@ pub async fn create_payment_connector(profile_id: Some(profile_id.clone()),};- let mca = store+ let mca = state+ .store.insert_merchant_connector_account(merchant_connector_account, &key_store).await.to_duplicate_response(@@ -1379,3 +1387,28 @@ pub(crate) fn validate_auth_type(}}}++#[cfg(feature = "dummy_connector")]+pub async fn validate_dummy_connector_enabled(+ state: &AppState,+ connector_name: &api_enums::Connector,+) -> Result<(), errors::ApiErrorResponse> {+ if !state.conf.dummy_connector.enabled+ && matches!(+ connector_name,+ 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+ )+ {+ Err(errors::ApiErrorResponse::InvalidRequestData {+ message: "Invalid connector name".to_string(),+ })+ } else {+ Ok(())+ }+}diff --git a/crates/router/src/routes/admin.rs b/crates/router/src/routes/admin.rsindex 225b9bad82..bfafb8fd19 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/loadtest/config/development.toml b/loadtest/config/development.tomlindex 32a602d4ff..9dda369474 100644--- a/loadtest/config/development.toml+++ b/loadtest/config/development.toml@@ -187,6 +187,7 @@ mollie = {long_lived_token = false, payment_method = "card"}braintree = { long_lived_token = false, payment_method = "card" }[dummy_connector]+enabled = truepayment_ttl = 172800payment_duration = 1000payment_tolerance = 100