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(core): add intent_fulfillment_time configuration to temp locker (#10877)

Sakil Mostakc87e82a24447
diff --git a/crates/router/src/core/authentication/utils.rs b/crates/router/src/core/authentication/utils.rs
index c22a381ebd..fa62f9247f 100644
--- a/crates/router/src/core/authentication/utils.rs
+++ b/crates/router/src/core/authentication/utils.rs
@@ -220,7 +220,7 @@ pub async fn update_trackers<F: Clone, Req>(
} => {
authentication_value
.async_map(|auth_val| {
- crate::core::payment_methods::vault::create_tokenize(
+ crate::core::payment_methods::vault::create_tokenize_without_configurable_expiry(
state,
auth_val.expose(),
None,
@@ -281,7 +281,7 @@ pub async fn update_trackers<F: Clone, Req>(
} => {
authentication_value
.async_map(|auth_val| {
- crate::core::payment_methods::vault::create_tokenize(
+ crate::core::payment_methods::vault::create_tokenize_without_configurable_expiry(
state,
auth_val.expose(),
None,
diff --git a/crates/router/src/core/payment_methods/cards.rs b/crates/router/src/core/payment_methods/cards.rs
index 9bae249c73..116f1f3935 100644
--- a/crates/router/src/core/payment_methods/cards.rs
+++ b/crates/router/src/core/payment_methods/cards.rs
@@ -4893,6 +4893,7 @@ pub async fn get_bank_from_vault(
&pm_parsed,
Some(customer_id.to_owned()),
key_store,
+ None,
)
.await
.change_context(errors::ApiErrorResponse::InternalServerError)
@@ -4988,7 +4989,7 @@ impl TempLockerCardSupport {
.change_context(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Wrapped value2 construction failed when saving card to locker")?;
- let lookup_key = vault::create_tokenize(
+ let lookup_key = vault::create_tokenize_without_configurable_expiry(
state,
value1,
Some(value2),
diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rs
index 2d23f30b85..21eb1ec82c 100644
--- a/crates/router/src/core/payment_methods/vault.rs
+++ b/crates/router/src/core/payment_methods/vault.rs
@@ -1166,7 +1166,7 @@ impl Vault {
let lookup_key = token_id.unwrap_or_else(|| generate_id_with_default_len("token"));
- let lookup_key = create_tokenize(
+ let lookup_key = create_tokenize_without_configurable_expiry(
state,
value1,
Some(value2),
@@ -1210,6 +1210,7 @@ impl Vault {
payout_method: &api::PayoutMethodData,
customer_id: Option<id_type::CustomerId>,
merchant_key_store: &domain::MerchantKeyStore,
+ intent_fulfillment_time: Option<i64>,
) -> RouterResult<String> {
let value1 = payout_method
.get_value1(customer_id.clone())
@@ -1224,12 +1225,13 @@ impl Vault {
let lookup_key =
token_id.unwrap_or_else(|| generate_id_with_default_len("temporary_token"));
- let lookup_key = create_tokenize(
+ let lookup_key = create_tokenize_with_configurable_expiry(
state,
value1,
Some(value2),
lookup_key,
merchant_key_store.key.get_inner(),
+ intent_fulfillment_time,
)
.await?;
// add_delete_tokenized_data_task(&*state.store, &lookup_key, pm).await?;
@@ -1260,12 +1262,44 @@ fn get_redis_locker_key(lookup_key: &str) -> String {
}
#[instrument(skip(state, value1, value2))]
-pub async fn create_tokenize(
+pub async fn create_tokenize_without_configurable_expiry(
state: &routes::SessionState,
value1: String,
value2: Option<String>,
lookup_key: String,
encryption_key: &masking::Secret<Vec<u8>>,
+) -> RouterResult<String> {
+ create_tokenize(state, value1, value2, lookup_key, encryption_key, None).await
+}
+
+#[instrument(skip(state, value1, value2))]
+pub async fn create_tokenize_with_configurable_expiry(
+ state: &routes::SessionState,
+ value1: String,
+ value2: Option<String>,
+ lookup_key: String,
+ encryption_key: &masking::Secret<Vec<u8>>,
+ expiry_time: Option<i64>,
+) -> RouterResult<String> {
+ create_tokenize(
+ state,
+ value1,
+ value2,
+ lookup_key,
+ encryption_key,
+ expiry_time,
+ )
+ .await
+}
+
+#[instrument(skip(state, value1, value2))]
+async fn create_tokenize(
+ state: &routes::SessionState,
+ value1: String,
+ value2: Option<String>,
+ lookup_key: String,
+ encryption_key: &masking::Secret<Vec<u8>>,
+ expiry_time: Option<i64>,
) -> RouterResult<String> {
let redis_key = get_redis_locker_key(lookup_key.as_str());
let func = || async {
@@ -1297,7 +1331,7 @@ pub async fn create_tokenize(
.set_key_if_not_exists_with_expiry(
&redis_key.as_str().into(),
bytes::Bytes::from(encrypted_payload),
- Some(i64::from(consts::LOCKER_REDIS_EXPIRY_SECONDS)),
+ expiry_time.or(Some(i64::from(consts::LOCKER_REDIS_EXPIRY_SECONDS))),
)
.await
.map(|_| lookup_key.clone())
diff --git a/crates/router/src/core/payouts/helpers.rs b/crates/router/src/core/payouts/helpers.rs
index 2755809793..d1c8995f28 100644
--- a/crates/router/src/core/payouts/helpers.rs
+++ b/crates/router/src/core/payouts/helpers.rs
@@ -162,12 +162,17 @@ pub async fn make_payout_method_data(
// Create / Update operation
(Some(payout_method), payout_token, Some(payout_data)) => {
+ #[cfg(feature = "v1")]
+ let intent_fulfillment_time = payout_data.business_profile.intent_fulfillment_time;
+ #[cfg(not(feature = "v1"))]
+ let intent_fulfillment_time = None;
let lookup_key = vault::Vault::store_payout_method_data_in_locker(
state,
payout_token.to_owned(),
payout_method,
Some(customer_id.to_owned()),
merchant_key_store,
+ intent_fulfillment_time,
)
.await?;
diff --git a/crates/router/src/core/unified_authentication_service/utils.rs b/crates/router/src/core/unified_authentication_service/utils.rs
index 485c142e64..1d1270c869 100644
--- a/crates/router/src/core/unified_authentication_service/utils.rs
+++ b/crates/router/src/core/unified_authentication_service/utils.rs
@@ -315,7 +315,7 @@ pub async fn external_authentication_update_trackers<F: Clone, Req>(
authentication_details
.authentication_value
.async_map(|auth_val| {
- payment_methods::vault::create_tokenize(
+ payment_methods::vault::create_tokenize_without_configurable_expiry(
state,
auth_val.expose(),
None,
@@ -384,7 +384,7 @@ pub async fn external_authentication_update_trackers<F: Clone, Req>(
.and_then(|details| details.dynamic_data_value)
.map(ExposeInterface::expose)
.async_map(|auth_val| {
- payment_methods::vault::create_tokenize(
+ payment_methods::vault::create_tokenize_without_configurable_expiry(
state,
auth_val,
None,
diff --git a/crates/router/src/core/webhooks/incoming.rs b/crates/router/src/core/webhooks/incoming.rs
index b4ad24865b..15c759c7a2 100644
--- a/crates/router/src/core/webhooks/incoming.rs
+++ b/crates/router/src/core/webhooks/incoming.rs
@@ -2236,7 +2236,7 @@ async fn external_authentication_incoming_webhook_flow(
authentication_details
.authentication_value
.async_map(|auth_val| {
- payment_methods::vault::create_tokenize(
+ payment_methods::vault::create_tokenize_without_configurable_expiry(
&state,
auth_val.expose(),
None,