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

refactor(payment_methods): add support for passing ttl to locker entries (#4690)

Chethan Rao7ca9c6e81313
diff --git a/config/config.example.toml b/config/config.example.toml
index d5bdfb5a6a..d10e8216e9 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -124,11 +124,12 @@ recon_admin_api_key = "recon_test_admin" # recon_admin API key for recon authent
# PCI Compliant storage entity which stores payment method information
# like card details
[locker]
-host = "" # Locker host
-host_rs = "" # Rust Locker host
-mock_locker = true # Emulate a locker locally using Postgres
-locker_signing_key_id = "1" # Key_id to sign basilisk hs locker
-locker_enabled = true # Boolean to enable or disable saving cards in locker
+host = "" # Locker host
+host_rs = "" # Rust Locker host
+mock_locker = true # Emulate a locker locally using Postgres
+locker_signing_key_id = "1" # Key_id to sign basilisk hs locker
+locker_enabled = true # Boolean to enable or disable saving cards in locker
+ttl_for_storage_in_secs = 220752000 # Time to live for storage entries in locker
[delayed_session_response]
connectors_with_delayed_session_response = "trustpay,payme" # List of connectors which has delayed session response
diff --git a/config/deployments/env_specific.toml b/config/deployments/env_specific.toml
index c725a8bd69..fc02335dcf 100644
--- a/config/deployments/env_specific.toml
+++ b/config/deployments/env_specific.toml
@@ -115,6 +115,8 @@ mock_locker = true # Emulate
locker_signing_key_id = "1" # Key_id to sign basilisk hs locker
locker_enabled = true # Boolean to enable or disable saving cards in locker
redis_temp_locker_encryption_key = "redis_temp_locker_encryption_key" # Encryption key for redis temp locker
+ttl_for_storage_in_secs = 220752000 # Time to live for storage entries in locker
+
[log.console]
enabled = true
diff --git a/config/development.toml b/config/development.toml
index a9f7f4d7b4..dfba91b514 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -71,6 +71,7 @@ host_rs = ""
mock_locker = true
basilisk_host = ""
locker_enabled = true
+ttl_for_storage_in_secs = 220752000
[forex_api]
call_delay = 21600
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index 6661d16403..d371d08148 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -61,6 +61,7 @@ host_rs = ""
mock_locker = true
basilisk_host = ""
locker_enabled = true
+ttl_for_storage_in_secs = 220752000
[jwekey]
vault_encryption_key = ""
diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs
index a582a00ee1..77f424d833 100644
--- a/crates/router/src/configs/defaults.rs
+++ b/crates/router/src/configs/defaults.rs
@@ -68,6 +68,8 @@ impl Default for super::settings::Locker {
locker_signing_key_id: "1".into(),
//true or false
locker_enabled: true,
+ //Time to live for storage entries in locker
+ ttl_for_storage_in_secs: 60 * 60 * 24 * 365 * 7,
}
}
}
diff --git a/crates/router/src/configs/settings.rs b/crates/router/src/configs/settings.rs
index b8a315f944..8ac27cce31 100644
--- a/crates/router/src/configs/settings.rs
+++ b/crates/router/src/configs/settings.rs
@@ -407,6 +407,7 @@ pub struct Locker {
pub basilisk_host: String,
pub locker_signing_key_id: String,
pub locker_enabled: bool,
+ pub ttl_for_storage_in_secs: i64,
}
#[derive(Debug, Deserialize, Clone)]
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 379050ba73..cd51face62 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -1070,6 +1070,7 @@ pub async fn add_bank_to_locker(
merchant_id: &merchant_account.merchant_id,
merchant_customer_id: customer_id.to_owned(),
enc_data,
+ ttl: state.conf.locker.ttl_for_storage_in_secs,
});
let store_resp = call_to_locker_hs(
state,
@@ -1229,6 +1230,7 @@ pub async fn add_card_hs(
card_isin: None,
nick_name: card.nick_name.as_ref().map(Secret::peek).cloned(),
},
+ ttl: state.conf.locker.ttl_for_storage_in_secs,
});
let store_card_payload =
diff --git a/crates/router/src/core/payment_methods/transformers.rs b/crates/router/src/core/payment_methods/transformers.rs
index 08e87b47f9..86b41d1d0f 100644
--- a/crates/router/src/core/payment_methods/transformers.rs
+++ b/crates/router/src/core/payment_methods/transformers.rs
@@ -43,6 +43,7 @@ pub struct StoreCardReq<'a> {
#[serde(skip_serializing_if = "Option::is_none")]
pub requestor_card_reference: Option<String>,
pub card: Card,
+ pub ttl: i64,
}
#[derive(Debug, Deserialize, Serialize)]
@@ -51,6 +52,7 @@ pub struct StoreGenericReq<'a> {
pub merchant_customer_id: String,
#[serde(rename = "enc_card_data")]
pub enc_data: String,
+ pub ttl: i64,
}
#[derive(Debug, Deserialize, Serialize)]
diff --git a/crates/router/src/core/payouts/helpers.rs b/crates/router/src/core/payouts/helpers.rs
index dad0739879..9c6cdbd888 100644
--- a/crates/router/src/core/payouts/helpers.rs
+++ b/crates/router/src/core/payouts/helpers.rs
@@ -220,6 +220,7 @@ pub async fn save_payout_data_to_locker(
nick_name: None,
},
requestor_card_reference: None,
+ ttl: state.conf.locker.ttl_for_storage_in_secs,
});
(
payload,
@@ -255,6 +256,7 @@ pub async fn save_payout_data_to_locker(
merchant_id: merchant_account.merchant_id.as_ref(),
merchant_customer_id: payout_attempt.customer_id.to_owned(),
enc_data,
+ ttl: state.conf.locker.ttl_for_storage_in_secs,
});
match payout_method_data {
payouts::PayoutMethodData::Bank(bank) => (
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index 2c3e83ad2b..878451080e 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -38,6 +38,7 @@ host_rs = ""
mock_locker = true
basilisk_host = ""
locker_enabled = true
+ttl_for_storage_in_secs = 220752000
[forex_api]
call_delay = 21600
@@ -320,4 +321,4 @@ client_secret = ""
partner_id = ""
[unmasked_headers]
-keys = "user-agent"
\ No newline at end of file
+keys = "user-agent"