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(config): add config support to pt_mapping along with redis (#1861)

Nishant Joshib03dd2445616
diff --git a/crates/router/src/scheduler/workflows/payment_sync.rs b/crates/router/src/scheduler/workflows/payment_sync.rs
index 805aeef316..4dc2b29908 100644
--- a/crates/router/src/scheduler/workflows/payment_sync.rs
+++ b/crates/router/src/scheduler/workflows/payment_sync.rs
@@ -1,9 +1,11 @@
+use common_utils::ext_traits::StringExt;
+use error_stack::ResultExt;
use router_env::logger;
use super::{PaymentsSyncWorkflow, ProcessTrackerWorkflow};
use crate::{
core::payments::{self as payment_flows, operations},
- db::{get_and_deserialize_key, StorageInterface},
+ db::StorageInterface,
errors,
routes::AppState,
scheduler::{consumer, process_data, utils},
@@ -109,9 +111,19 @@ pub async fn get_sync_process_schedule_time(
merchant_id: &str,
retry_count: i32,
) -> Result<Option<time::PrimitiveDateTime>, errors::ProcessTrackerError> {
- let redis_mapping: errors::CustomResult<process_data::ConnectorPTMapping, errors::RedisError> =
- get_and_deserialize_key(db, &format!("pt_mapping_{connector}"), "ConnectorPTMapping").await;
- let mapping = match redis_mapping {
+ let mapping: common_utils::errors::CustomResult<
+ process_data::ConnectorPTMapping,
+ errors::StorageError,
+ > = db
+ .find_config_by_key_cached(&format!("pt_mapping_{connector}"))
+ .await
+ .map(|value| value.config)
+ .and_then(|config| {
+ config
+ .parse_struct("ConnectorPTMapping")
+ .change_context(errors::StorageError::DeserializationFailed)
+ });
+ let mapping = match mapping {
Ok(x) => x,
Err(err) => {
logger::info!("Redis Mapping Error: {}", err);