mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-30 17:47:54 +08:00
fix(payment_link): remove dynamic section if no fields are present (#5579)
This commit is contained in:
@ -617,29 +617,37 @@ function renderDynamicMerchantDetails(paymentDetails) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function appendMerchantDetails(paymentDetails, merchantDynamicDetails) {
|
function appendMerchantDetails(paymentDetails, merchantDynamicDetails) {
|
||||||
if (Object.keys(paymentDetails.transaction_details).length === 0) {
|
if (!(typeof paymentDetails.transaction_details === "string" && paymentDetails.transaction_details.length > 0)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// render a horizontal line above dynamic merchant details
|
try {
|
||||||
let horizontalLineContainer = document.getElementById("hyper-checkout-payment-horizontal-line-container");
|
let merchantDetailsObject = JSON.parse(paymentDetails.transaction_details);
|
||||||
let horizontalLine = document.createElement("hr");
|
|
||||||
horizontalLine.className = "hyper-checkout-payment-horizontal-line";
|
|
||||||
horizontalLineContainer.append(horizontalLine);
|
|
||||||
|
|
||||||
// max number of items to show in the merchant details
|
if (Object.keys(merchantDetailsObject).length > 0) {
|
||||||
let maxItemsInDetails = 5;
|
// render a horizontal line above dynamic merchant details
|
||||||
let merchantDetailsObject = JSON.parse(paymentDetails.transaction_details);
|
var horizontalLineContainer = document.getElementById("hyper-checkout-payment-horizontal-line-container");
|
||||||
for(const key in merchantDetailsObject) {
|
var horizontalLine = document.createElement("hr");
|
||||||
var merchantData = document.createElement("div");
|
horizontalLine.className = "hyper-checkout-payment-horizontal-line";
|
||||||
merchantData.className = "hyper-checkout-payment-merchant-dynamic-data";
|
horizontalLineContainer.append(horizontalLine);
|
||||||
merchantData.innerHTML = key+": "+merchantDetailsObject[key].bold();
|
|
||||||
|
|
||||||
merchantDynamicDetails.append(merchantData);
|
// max number of items to show in the merchant details
|
||||||
if(--maxItemsInDetails === 0) {
|
let maxItemsInDetails = 5;
|
||||||
break;
|
for (var key in merchantDetailsObject) {
|
||||||
|
var merchantData = document.createElement("div");
|
||||||
|
merchantData.className = "hyper-checkout-payment-merchant-dynamic-data";
|
||||||
|
merchantData.innerHTML = key+": "+merchantDetailsObject[key].bold();
|
||||||
|
|
||||||
|
merchantDynamicDetails.append(merchantData);
|
||||||
|
if (--maxItemsInDetails === 0) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (error) {
|
||||||
|
console.error("Error parsing merchant details", error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user