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

refactor(payment_link): Make performance optimisation for payment_link (#4092)

Sahkal Poddarfcfd567bfe55
diff --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.html
index f258b4fefd..732e331892 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
@@ -4,13 +4,12 @@
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Payments requested by HyperSwitch</title>
+ {{ preload_link_tags }}
+ <link rel="preconnect" href="https://fonts.gstatic.com">
+ <link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800">
<style>
{{rendered_css}}
</style>
- <link
- rel="stylesheet"
- href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800"
- />
</head>
<body class="hide-scrollbar">
<div id="payment-details-shimmer">
diff --git a/crates/router/src/core/payment_link/payment_link_initiate/payment_link.js b/crates/router/src/core/payment_link/payment_link_initiate/payment_link.js
index 3e262b45df..da6899923b 100644
--- a/crates/router/src/core/payment_link/payment_link_initiate/payment_link.js
+++ b/crates/router/src/core/payment_link/payment_link_initiate/payment_link.js
@@ -402,8 +402,8 @@ function initializeSDK() {
: paymentDetails.sdk_layout;
var unifiedCheckoutOptions = {
- displaySavedPaymentMethodsCheckbox: true,
- displaySavedPaymentMethods: true,
+ displaySavedPaymentMethodsCheckbox: false,
+ displaySavedPaymentMethods: false,
layout: {
type: type, //accordion , tabs, spaced accordion
spacedAccordionItems: paymentDetails.sdk_layout === "spaced_accordion",
@@ -623,6 +623,8 @@ function renderPaymentDetails(paymentDetails) {
// Create merchant logo's node
var merchantLogoNode = document.createElement("img");
merchantLogoNode.src = paymentDetails.merchant_logo;
+ merchantLogoNode.setAttribute("width", "48"); // Set width to 100 pixels
+ merchantLogoNode.setAttribute("height", "48");
// Create expiry node
var paymentExpiryNode = document.createElement("div");
@@ -755,6 +757,9 @@ function renderCartItem(
nameAndQuantityWrapperNode.className = "hyper-checkout-cart-product-details";
// Image
var productImageNode = document.createElement("img");
+ productImageNode.setAttribute("width", 56);
+ productImageNode.setAttribute("height", 56);
+
productImageNode.className = "hyper-checkout-cart-product-image";
productImageNode.src = item.product_img_link;
// Product title
diff --git a/crates/router/src/services/api.rs b/crates/router/src/services/api.rs
index a4c6bdd0a1..40a9713a8c 100644
--- a/crates/router/src/services/api.rs
+++ b/crates/router/src/services/api.rs
@@ -1994,6 +1994,11 @@ pub fn build_payment_link_html(
let _ = tera.add_raw_template("payment_link", &html_template);
+ context.insert(
+ "preload_link_tags",
+ &get_preload_link_html_template(&payment_link_data.sdk_url),
+ );
+
context.insert(
"hyperloader_sdk_link",
&get_hyper_loader_sdk(&payment_link_data.sdk_url),
@@ -2014,6 +2019,14 @@ fn get_hyper_loader_sdk(sdk_url: &str) -> String {
format!("<script src=\"{sdk_url}\" onload=\"initializeSDK()\"></script>")
}
+fn get_preload_link_html_template(sdk_url: &str) -> String {
+ format!(
+ r#"<link rel="preload" href="https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800" as="style">
+ <link rel="preload" href="{sdk_url}" as="script">"#,
+ sdk_url = sdk_url
+ )
+}
+
pub fn get_payment_link_status(
payment_link_data: PaymentLinkStatusData,
) -> CustomResult<String, errors::ApiErrorResponse> {