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
chore: add missing logs for surcharge flow (#5258)
Hrithikeshbc19fca1f4e7
diff --git a/crates/router/src/core/payment_methods/surcharge_decision_configs.rs b/crates/router/src/core/payment_methods/surcharge_decision_configs.rsindex d708019fe1..fd209e78da 100644--- a/crates/router/src/core/payment_methods/surcharge_decision_configs.rs+++ b/crates/router/src/core/payment_methods/surcharge_decision_configs.rs@@ -9,7 +9,7 @@ use euclid::{backend,backend::{inputs as dsl_inputs, EuclidBackend},};-use router_env::{instrument, tracing};+use router_env::{instrument, logger, tracing};use serde::{Deserialize, Serialize};use storage_impl::redis::cache::{self, SURCHARGE_CACHE};@@ -135,6 +135,11 @@ pub async fn perform_surcharge_decision_management_for_payment_method_list())}};+ let surcharge_source_log_message = match &surcharge_source {+ SurchargeSource::Generate(_) => "Surcharge was calculated through surcharge rules",+ SurchargeSource::Predetermined(_) => "Surcharge was sent in payment create request",+ };+ logger::debug!(payment_method_list_surcharge_source = surcharge_source_log_message);let mut backend_input =make_dsl_input_for_surcharge(payment_attempt, payment_intent, billing_address)@@ -289,6 +294,11 @@ pub async fn perform_surcharge_decision_management_for_saved_cards(}(None, None) => return Ok(surcharge_metadata),};+ let surcharge_source_log_message = match &surcharge_source {+ SurchargeSource::Generate(_) => "Surcharge was calculated through surcharge rules",+ SurchargeSource::Predetermined(_) => "Surcharge was sent in payment create request",+ };+ logger::debug!(customer_saved_card_list_surcharge_source = surcharge_source_log_message);let mut backend_input = make_dsl_input_for_surcharge(payment_attempt, payment_intent, None).change_context(ConfigError::InputConstructionError)?;diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rsindex 9c420c1e44..8d83cfb803 100644--- a/crates/router/src/core/payments.rs+++ b/crates/router/src/core/payments.rs@@ -660,6 +660,7 @@ where.surcharge_applicable.unwrap_or(false){+ logger::debug!("payment_intent.surcharge_applicable = true");if let Some(surcharge_details) = payment_data.payment_attempt.get_surcharge_details() {// if retry payment, surcharge would have been populated from the previous attempt. Use the same surchargelet surcharge_details =@@ -707,6 +708,7 @@ where.payment_attempt.get_surcharge_details().map(|surcharge_details| {+ logger::debug!("surcharge sent in payments create request");types::SurchargeDetails::from((&surcharge_details,&payment_data.payment_attempt,diff --git a/crates/router/src/core/payments/types.rs b/crates/router/src/core/payments/types.rsindex 1f16c4d667..71460a1119 100644--- a/crates/router/src/core/payments/types.rs+++ b/crates/router/src/core/payments/types.rs@@ -13,7 +13,7 @@ pub use hyperswitch_domain_models::router_request_types::{AuthenticationData, PaymentCharges, SurchargeDetails,};use redis_interface::errors::RedisError;-use router_env::{instrument, tracing};+use router_env::{instrument, logger, tracing};use crate::{consts as router_consts,@@ -319,6 +319,7 @@ impl SurchargeMetadata {.await.change_context(errors::ApiErrorResponse::InternalServerError).attach_printable("Failed to write to redis")?;+ logger::debug!("Surcharge results stored in redis with key = {}", redis_key);}Ok(())}@@ -335,9 +336,15 @@ impl SurchargeMetadata {.attach_printable("Failed to get redis connection")?;let redis_key = Self::get_surcharge_metadata_redis_key(payment_attempt_id);let value_key = Self::get_surcharge_details_redis_hashset_key(&surcharge_key);- redis_conn+ let result = redis_conn.get_hash_field_and_deserialize(&redis_key, &value_key, "SurchargeDetails")- .await+ .await;+ logger::debug!(+ "Surcharge result fetched from redis with key = {} and {}",+ redis_key,+ value_key+ );+ result}}