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
refactor(payment_link): logs payment links logs coverage (#4918)
Sahkal Poddar618ec41aff04
diff --git a/crates/router/src/core/payment_link.rs b/crates/router/src/core/payment_link.rsindex 566f9d86aa..e9f9a6b401 100644--- a/crates/router/src/core/payment_link.rs+++ b/crates/router/src/core/payment_link.rs@@ -10,6 +10,7 @@ use common_utils::{use error_stack::ResultExt;use futures::future;use masking::{PeekInterface, Secret};+use router_env::logger;use time::PrimitiveDateTime;use super::errors::{self, RouterResult, StorageErrorExt};@@ -161,12 +162,17 @@ pub async fn initiate_payment_link_flow({let status = match payment_link_status {api_models::payments::PaymentLinkStatus::Active => {+ logger::info!("displaying status page as the requested payment link has reached terminal state with payment status as {:?}", payment_intent.status);PaymentLinkStatusWrap::IntentStatus(payment_intent.status)}api_models::payments::PaymentLinkStatus::Expired => {if is_terminal_state {+ logger::info!("displaying status page as the requested payment link has reached terminal state with payment status as {:?}", payment_intent.status);PaymentLinkStatusWrap::IntentStatus(payment_intent.status)} else {+ logger::info!(+ "displaying status page as the requested payment link has expired"+ );PaymentLinkStatusWrap::PaymentLinkStatus(api_models::payments::PaymentLinkStatus::Expired,)@@ -198,6 +204,11 @@ pub async fn initiate_payment_link_flow(theme: payment_link_config.theme.clone(),return_url: return_url.clone(),};++ logger::info!(+ "payment link data, for building payment link status page {:?}",+ payment_details+ );let js_script = get_js_script(&api_models::payments::PaymentLinkData::PaymentLinkStatusDetails(payment_details),)?;@@ -241,6 +252,11 @@ pub async fn initiate_payment_link_flow(css_script,html_meta_tags,};++ logger::info!(+ "payment link data, for building payment link {:?}",+ payment_link_data+ );Ok(services::ApplicationResponse::PaymentLinkForm(Box::new(services::api::PaymentLinkAction::PaymentLinkFormData(payment_link_data),)))@@ -407,6 +423,10 @@ pub fn get_payment_link_config_based_on_priority(field_name: "payment_link_config",}).attach_printable("Invalid payment_link_config given in business config")?;+ logger::info!(+ "domain name set to custom domain https://{:?}",+ extracted_value.domain_name+ );(extracted_valuediff --git a/crates/router/src/core/payment_link/payment_link_initiate/payment_link.html b/crates/router/src/core/payment_link/payment_link_initiate/payment_link.htmlindex fc8121c505..1e6723201c 100644--- a/crates/router/src/core/payment_link/payment_link_initiate/payment_link.html+++ b/crates/router/src/core/payment_link/payment_link_initiate/payment_link.html@@ -324,6 +324,7 @@</div><script>{{rendered_js}}+ {{logging_template}}</script>{{ hyperloader_sdk_link }}</body>diff --git a/crates/router/src/core/payment_link/payment_link_status/status.html b/crates/router/src/core/payment_link/payment_link_status/status.htmlindex 00f1efe38c..0670a92674 100644--- a/crates/router/src/core/payment_link/payment_link_status/status.html+++ b/crates/router/src/core/payment_link/payment_link_status/status.html@@ -12,6 +12,7 @@/><script>{{ rendered_js }}+ {{logging_template}}</script></head><body onload="boot()">diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rsindex a7198e74c4..9f9dffec58 100644--- a/crates/router/src/services/api.rs+++ b/crates/router/src/services/api.rs@@ -1936,6 +1936,10 @@ pub fn build_payment_link_html(}};+ // Logging template+ let logging_template =+ include_str!("redirection/assets/redirect_error_logs_push.js").to_string();+// Modify Html template with rendered js and rendered css fileslet html_template =include_str!("../core/payment_link/payment_link_initiate/payment_link.html").to_string();@@ -1961,6 +1965,8 @@ pub fn build_payment_link_html(context.insert("rendered_css", &rendered_css);context.insert("rendered_js", &rendered_js);+ context.insert("logging_template", &logging_template);+match tera.render("payment_link", &context) {Ok(rendered_html) => Ok(rendered_html),Err(tera_error) => {@@ -2002,6 +2008,10 @@ pub fn get_payment_link_status(}};+ // Logging template+ let logging_template =+ include_str!("redirection/assets/redirect_error_logs_push.js").to_string();+// Add modification to js template with dynamic datalet js_template =include_str!("../core/payment_link/payment_link_status/status.js").to_string();@@ -2024,6 +2034,7 @@ pub fn get_payment_link_status(context.insert("rendered_css", &rendered_css);context.insert("rendered_js", &rendered_js);+ context.insert("logging_template", &logging_template);match tera.render("payment_link_status", &context) {Ok(rendered_html) => Ok(rendered_html),