| Server IP : 85.158.181.41 / Your IP : 216.73.217.12 Web Server : Apache System : Linux cloud9-vm129 6.1.178+1-ph #ph SMP PREEMPT_DYNAMIC Wed Jul 29 09:00:54 UTC 2026 x86_64 User : moncbefd ( 1024) PHP Version : 7.3.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : OFF | Pkexec : OFF Directory : /home/moncbefd/www.moneta.at/GXModules/Gambio/Hub/Shop/Javascript/ |
Upload File : |
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = Array.prototype.forEach;
}
let payPalButtonSettings = {};
let payPalText = {};
let currentScript = document.currentScript;
let initDisplayModeECS_ButtonReplace = function() {
let paypalButtonContainer = document.querySelector('#paypal-button-container'),
footerTotalRow = document.querySelector('table.order-total tr.footer.total'),
newTotalRow = document.createElement('tr'),
newTotalRowCell = document.createElement('td');
newTotalRowCell.colSpan = '2';
newTotalRowCell.style.width = '100%';
newTotalRowCell.style.borderTop = 'none';
newTotalRowCell.appendChild(paypalButtonContainer);
newTotalRow.appendChild(newTotalRowCell);
footerTotalRow.parentNode.appendChild(newTotalRow);
footerTotalRow.querySelectorAll('td').forEach(function(td) {
td.style.paddingBottom = '15px';
});
};
let initDisplayModeECS = function() {
if(window.location.search.match(/(\?|&)display_mode=ecs($|&)/)) {
let checkoutButtons = document.querySelector('div.checkout-buttons');
if(checkoutButtons) {
checkoutButtons.style.display = 'none';
}
let checkoutSubmitButton = document.querySelector('div.shopping-cart-button a.button-submit');
if(checkoutSubmitButton === null) {
checkoutSubmitButton = document.querySelector('tr.checkout-button');
}
if(checkoutSubmitButton) {
checkoutSubmitButton.style.display = 'none';
}
let shoppingCartButton = document.querySelector('div.shopping-cart-button');
if(shoppingCartButton) {
shoppingCartButton.classList.add('paypal-ecs-mode');
}
let ppiContainer = document.querySelector('div.paypalinstallmentcontainer');
if(ppiContainer) {
ppiContainer.style.display = 'none';
}
initDisplayModeECS_ButtonReplace();
}
}
let initJSSDKPayPalButton = function() {
initDisplayModeECS();
paypal.Buttons({
style: payPalButtonSettings.style,
createOrder: function(data, actions) {
return $.ajax({
url: payPalButtonSettings.createPaymentUrl,
dataType: 'json'
}).then(function(data) {
let token;
if (data.payment) {
for (let link in data.payment.links) {
if (data.payment.links[link].rel === 'approval_url') {
token = data.payment.links[link].href.match(/EC-\w+/)[0];
}
}
} else {
//throw new Error(payPalText.paypalUnavailable);
return false;
}
return token;
});
},
onApprove: function(data, actions) {
$.ajax({
url: payPalButtonSettings.authorizedPaymentUrl,
method: 'post',
headers: {
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
},
data: 'paymentID=' + data.paymentID + '&payerID=' + data.payerID
}).then(function (res) {
console.debug(res);
document.location = payPalButtonSettings.checkoutUrl;
});
},
onError: function(err) {
let ppButtonContainer = document.querySelector('#paypal-button-container');
let ecsIntro = document.querySelector('div.ecs_intro');
if(ppButtonContainer) {
let errorMessage = document.querySelector('div.paypal-error');
if(!errorMessage) {
errorMessage = document.createElement('div');
errorMessage.classList.add('paypal-error');
errorMessage.classList.add('alert');
errorMessage.classList.add('alert-warning');
errorMessage.style.textAlign = 'left';
errorMessage.style.color = '#555';
}
errorMessage.innerText = payPalText.paypalUnavailable + ' ';
let shoppingCartButton = document.querySelector('div.shopping-cart-button');
if(shoppingCartButton && shoppingCartButton.classList.contains('paypal-ecs-mode')) {
let linkUrl = window.location.toString().replace('display_mode=ecs', 'display_mode=normal');
let continueLink = document.createElement('a');
continueLink.setAttribute('href', linkUrl);
continueLink.innerText = payPalText.errorContinue;
errorMessage.append(continueLink);
}
ppButtonContainer.parentNode.append(errorMessage);
ppButtonContainer.style.display = 'none';
}
if(ecsIntro) {
ecsIntro.style.display = 'none';
}
}
}).render('#paypal-button-container');
let observerTarget = document.querySelector('#paypal-button-container');
let observer = new MutationObserver(function(mutations, observer) {
mutations.forEach(function(mutation) {
// console.debug(mutation);
if(mutation.removedNodes.length > 0) {
console.info('re-init PayPal buttons');
initJSSDKPayPalButton();
}
});
});
observer.observe(observerTarget, {childList: true});
};
document.addEventListener('DOMContentLoaded', function() {
let jssdk = document.createElement('script');
jssdk.src = payPalButtonSettings.jssrc;
jssdk.onload = initJSSDKPayPalButton;
if(currentScript) {
currentScript.parentNode.insertBefore(jssdk, currentScript);
} else {
document.querySelector('script:last-of-type').parentNode.appendChild(jssdk);
}
});