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

feat(router): change temp locker config as enable only (#2522)

Sai Harsha Vardhan7acf10101435
diff --git a/config/config.example.toml b/config/config.example.toml
index e827beff8c..56297fc20a 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -321,9 +321,11 @@ square = {long_lived_token = false, payment_method = "card"}
braintree = { long_lived_token = false, payment_method = "card" }
gocardless = {long_lived_token = true, payment_method = "bank_debit"}
-[temp_locker_disable_config]
-trustpay = {payment_method = "card,bank_redirect,wallet"}
-stripe = {payment_method = "card,bank_redirect,pay_later,wallet,bank_debit"}
+[temp_locker_enable_config]
+stripe = {payment_method = "bank_transfer"}
+nuvei = {payment_method = "card"}
+shift4 = {payment_method = "card"}
+bluesnap = {payment_method = "card"}
[dummy_connector]
enabled = true # Whether dummy connector is enabled or not
diff --git a/config/development.toml b/config/development.toml
index 91451a69c1..6d5d02c3bb 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -377,9 +377,11 @@ braintree = { long_lived_token = false, payment_method = "card" }
payme = {long_lived_token = false, payment_method = "card"}
gocardless = {long_lived_token = true, payment_method = "bank_debit"}
-[temp_locker_disable_config]
-trustpay = {payment_method = "card,bank_redirect,wallet"}
-stripe = {payment_method = "card,bank_redirect,pay_later,wallet,bank_debit"}
+[temp_locker_enable_config]
+stripe = {payment_method = "bank_transfer"}
+nuvei = {payment_method = "card"}
+shift4 = {payment_method = "card"}
+bluesnap = {payment_method = "card"}
[connector_customer]
connector_list = "gocardless,stax,stripe"
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index b8525e9b5f..983abd7cc3 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -208,9 +208,11 @@ square = {long_lived_token = false, payment_method = "card"}
braintree = { long_lived_token = false, payment_method = "card" }
gocardless = {long_lived_token = true, payment_method = "bank_debit"}
-[temp_locker_disable_config]
-trustpay = {payment_method = "card,bank_redirect,wallet"}
-stripe = {payment_method = "card,bank_redirect,pay_later,wallet,bank_debit"}
+[temp_locker_enable_config]
+stripe = {payment_method = "bank_transfer"}
+nuvei = {payment_method = "card"}
+shift4 = {payment_method = "card"}
+bluesnap = {payment_method = "card"}
[dummy_connector]
enabled = true
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index 70d05b79f9..a2feb55e86 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -99,7 +99,7 @@ pub struct Settings {
pub multiple_api_version_supported_connectors: MultipleApiVersionSupportedConnectors,
pub applepay_merchant_configs: ApplepayMerchantConfigs,
pub lock_settings: LockSettings,
- pub temp_locker_disable_config: TempLockerDisableConfig,
+ pub temp_locker_enable_config: TempLockerEnableConfig,
}
#[derive(Debug, Deserialize, Clone, Default)]
@@ -123,7 +123,7 @@ pub struct TokenizationConfig(pub HashMap<String, PaymentMethodTokenFilter>);
#[derive(Debug, Deserialize, Clone, Default)]
#[serde(transparent)]
-pub struct TempLockerDisableConfig(pub HashMap<String, TempLockerDisablePaymentMethodFilter>);
+pub struct TempLockerEnableConfig(pub HashMap<String, TempLockerEnablePaymentMethodFilter>);
#[derive(Debug, Deserialize, Clone, Default)]
pub struct ConnectorCustomer {
@@ -216,7 +216,7 @@ pub struct PaymentMethodTokenFilter {
}
#[derive(Debug, Deserialize, Clone, Default)]
-pub struct TempLockerDisablePaymentMethodFilter {
+pub struct TempLockerEnablePaymentMethodFilter {
#[serde(deserialize_with = "pm_deser")]
pub payment_method: HashSet<diesel_models::enums::PaymentMethod>,
}
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index a6e3b2f127..143b992395 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -31,7 +31,7 @@ use super::{
CustomerDetails, PaymentData,
};
use crate::{
- configs::settings::{ConnectorRequestReferenceIdConfig, Server, TempLockerDisableConfig},
+ configs::settings::{ConnectorRequestReferenceIdConfig, Server, TempLockerEnableConfig},
connector,
consts::{self, BASE64_ENGINE},
core::{
@@ -1480,7 +1480,7 @@ pub async fn store_payment_method_data_in_vault(
payment_method_data: &api::PaymentMethodData,
) -> RouterResult<Option<String>> {
if should_store_payment_method_data_in_vault(
- &state.conf.temp_locker_disable_config,
+ &state.conf.temp_locker_enable_config,
payment_attempt.connector.clone(),
payment_method,
) {
@@ -1499,18 +1499,17 @@ pub async fn store_payment_method_data_in_vault(
Ok(None)
}
pub fn should_store_payment_method_data_in_vault(
- temp_locker_disable_config: &TempLockerDisableConfig,
+ temp_locker_enable_config: &TempLockerEnableConfig,
option_connector: Option<String>,
payment_method: enums::PaymentMethod,
) -> bool {
option_connector
.map(|connector| {
- temp_locker_disable_config
+ temp_locker_enable_config
.0
.get(&connector)
- //should be true only if payment_method is not in the disable payment_method list for connector
- .map(|config| !config.payment_method.contains(&payment_method))
- .unwrap_or(true)
+ .map(|config| config.payment_method.contains(&payment_method))
+ .unwrap_or(false)
})
.unwrap_or(true)
}
diff --git a/crates/router/src/core/payments/operations/payment_complete_authorize.rs b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
index db2c9e27c9..506a9b4421 100644
--- a/crates/router/src/core/payments/operations/payment_complete_authorize.rs
+++ b/crates/router/src/core/payments/operations/payment_complete_authorize.rs
@@ -115,7 +115,7 @@ impl<F: Send + Clone, Ctx: PaymentMethodRetrieve>
let should_validate_pm_or_token_given =
//this validation should happen if data was stored in the vault
helpers::should_store_payment_method_data_in_vault(
- &state.conf.temp_locker_disable_config,
+ &state.conf.temp_locker_enable_config,
payment_attempt.connector.clone(),
payment_method,
);
@@ -300,11 +300,6 @@ impl<F: Clone + Send, Ctx: PaymentMethodRetrieve> Domain<F, api::PaymentsRequest
)> {
let (op, payment_method_data) =
helpers::make_pm_data(Box::new(self), state, payment_data).await?;
-
- utils::when(payment_method_data.is_none(), || {
- Err(errors::ApiErrorResponse::PaymentMethodNotFound)
- })?;
-
Ok((op, payment_method_data))
}