mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 21:07:58 +08:00
refactor(payment_link): logs payment links logs coverage (#4918)
Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
@ -10,6 +10,7 @@ use common_utils::{
|
|||||||
use error_stack::ResultExt;
|
use error_stack::ResultExt;
|
||||||
use futures::future;
|
use futures::future;
|
||||||
use masking::{PeekInterface, Secret};
|
use masking::{PeekInterface, Secret};
|
||||||
|
use router_env::logger;
|
||||||
use time::PrimitiveDateTime;
|
use time::PrimitiveDateTime;
|
||||||
|
|
||||||
use super::errors::{self, RouterResult, StorageErrorExt};
|
use super::errors::{self, RouterResult, StorageErrorExt};
|
||||||
@ -161,12 +162,17 @@ pub async fn initiate_payment_link_flow(
|
|||||||
{
|
{
|
||||||
let status = match payment_link_status {
|
let status = match payment_link_status {
|
||||||
api_models::payments::PaymentLinkStatus::Active => {
|
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)
|
PaymentLinkStatusWrap::IntentStatus(payment_intent.status)
|
||||||
}
|
}
|
||||||
api_models::payments::PaymentLinkStatus::Expired => {
|
api_models::payments::PaymentLinkStatus::Expired => {
|
||||||
if is_terminal_state {
|
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)
|
PaymentLinkStatusWrap::IntentStatus(payment_intent.status)
|
||||||
} else {
|
} else {
|
||||||
|
logger::info!(
|
||||||
|
"displaying status page as the requested payment link has expired"
|
||||||
|
);
|
||||||
PaymentLinkStatusWrap::PaymentLinkStatus(
|
PaymentLinkStatusWrap::PaymentLinkStatus(
|
||||||
api_models::payments::PaymentLinkStatus::Expired,
|
api_models::payments::PaymentLinkStatus::Expired,
|
||||||
)
|
)
|
||||||
@ -198,6 +204,11 @@ pub async fn initiate_payment_link_flow(
|
|||||||
theme: payment_link_config.theme.clone(),
|
theme: payment_link_config.theme.clone(),
|
||||||
return_url: return_url.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(
|
let js_script = get_js_script(
|
||||||
&api_models::payments::PaymentLinkData::PaymentLinkStatusDetails(payment_details),
|
&api_models::payments::PaymentLinkData::PaymentLinkStatusDetails(payment_details),
|
||||||
)?;
|
)?;
|
||||||
@ -241,6 +252,11 @@ pub async fn initiate_payment_link_flow(
|
|||||||
css_script,
|
css_script,
|
||||||
html_meta_tags,
|
html_meta_tags,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
logger::info!(
|
||||||
|
"payment link data, for building payment link {:?}",
|
||||||
|
payment_link_data
|
||||||
|
);
|
||||||
Ok(services::ApplicationResponse::PaymentLinkForm(Box::new(
|
Ok(services::ApplicationResponse::PaymentLinkForm(Box::new(
|
||||||
services::api::PaymentLinkAction::PaymentLinkFormData(payment_link_data),
|
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",
|
field_name: "payment_link_config",
|
||||||
})
|
})
|
||||||
.attach_printable("Invalid payment_link_config given in business 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_value
|
extracted_value
|
||||||
|
|||||||
@ -324,6 +324,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
{{rendered_js}}
|
{{rendered_js}}
|
||||||
|
{{logging_template}}
|
||||||
</script>
|
</script>
|
||||||
{{ hyperloader_sdk_link }}
|
{{ hyperloader_sdk_link }}
|
||||||
</body>
|
</body>
|
||||||
|
|||||||
@ -12,6 +12,7 @@
|
|||||||
/>
|
/>
|
||||||
<script>
|
<script>
|
||||||
{{ rendered_js }}
|
{{ rendered_js }}
|
||||||
|
{{logging_template}}
|
||||||
</script>
|
</script>
|
||||||
</head>
|
</head>
|
||||||
<body onload="boot()">
|
<body onload="boot()">
|
||||||
|
|||||||
@ -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 files
|
// Modify Html template with rendered js and rendered css files
|
||||||
let html_template =
|
let html_template =
|
||||||
include_str!("../core/payment_link/payment_link_initiate/payment_link.html").to_string();
|
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_css", &rendered_css);
|
||||||
context.insert("rendered_js", &rendered_js);
|
context.insert("rendered_js", &rendered_js);
|
||||||
|
|
||||||
|
context.insert("logging_template", &logging_template);
|
||||||
|
|
||||||
match tera.render("payment_link", &context) {
|
match tera.render("payment_link", &context) {
|
||||||
Ok(rendered_html) => Ok(rendered_html),
|
Ok(rendered_html) => Ok(rendered_html),
|
||||||
Err(tera_error) => {
|
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 data
|
// Add modification to js template with dynamic data
|
||||||
let js_template =
|
let js_template =
|
||||||
include_str!("../core/payment_link/payment_link_status/status.js").to_string();
|
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_css", &rendered_css);
|
||||||
|
|
||||||
context.insert("rendered_js", &rendered_js);
|
context.insert("rendered_js", &rendered_js);
|
||||||
|
context.insert("logging_template", &logging_template);
|
||||||
|
|
||||||
match tera.render("payment_link_status", &context) {
|
match tera.render("payment_link_status", &context) {
|
||||||
Ok(rendered_html) => Ok(rendered_html),
|
Ok(rendered_html) => Ok(rendered_html),
|
||||||
|
|||||||
Reference in New Issue
Block a user