chore: add missing logs for surcharge flow (#5258)

This commit is contained in:
Hrithikesh
2024-07-22 13:59:04 +05:30
committed by GitHub
parent 06f1406cbc
commit bc19fca1f4
3 changed files with 23 additions and 4 deletions

View File

@ -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)?;

View File

@ -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 surcharge
let 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,

View File

@ -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
}
}