first commit

This commit is contained in:
2026-03-05 13:07:40 +01:00
commit 64ba0721ee
25709 changed files with 4691006 additions and 0 deletions

View File

@@ -0,0 +1,104 @@
(function ($) {
$.loadScript = function (url, callback) {
$.ajax({
url: url,
dataType: 'script',
success: callback,
async: false
});
}
function setupBanksForm() {
var str = '',
i,
str2 = '',
tile,
others = [157, 106, 109, 148, 104],
group,
id,
groupName,
logoSrc;
if (isSmallList === 0) {
for (i in tr_groups) {
group = tr_groups[i];
id = group[0];
groupName = group[1];
logoSrc = group[3];
if (show_installments == 0 && id == 109) {
continue;
}
tile = getBankTile(id, groupName, logoSrc);
if (inArray(id, others) === false) {
str += tile;
} else {
str2 += tile;
}
}
var $wrapper = $('#bank-selection-form');
$wrapper.html(str + str2);
$wrapper.find('.tpay-group-holder.tpay-with-logo').click(function () {
var bankId = $(this).attr('data-groupId'),
input = document.getElementById('tpay-channel-input'),
bank_block = document.getElementById('bank-' + bankId),
active_bank_blocks = document.getElementsByClassName('tpay-active');
input.value = bankId;
if (active_bank_blocks.length > 0) {
active_bank_blocks[0].className = active_bank_blocks[0].className.replace('tpay-active', '');
}
if (bank_block !== null) {
bank_block.className = bank_block.className + ' tpay-active';
}
})
} else {
for (i in tr_groups) {
group = tr_groups[i];
id = group[0];
groupName = group[1];
if (show_installments == 0 && id == 109) {
continue;
}
str += getBankOption(id, groupName);
}
document.getElementById('tpay-bank-list').innerHTML = str;
var $wrapper = $('#tpay-bank-list');
$wrapper.change(function () {
document.getElementById('tpay-channel-input').value = document.getElementById('tpay-bank-list').value;
});
}
var regulation_checkbox = document.getElementById('tpay-accept-regulations-checkbox'),
regulations_input = document.getElementById('tpay-regulations-input');
regulation_checkbox.onchange = function () {
regulations_input.value = (this.checked) ? 1 : 0;
};
}
function getBankTile(groupId, groupName, logoSrc) {
return '<div class="tpay-group-holder tpay-with-logo" id="bank-' + groupId + '" data-groupId="' + groupId + '">' +
'<div class="tpay-group-name">' + groupName + '</div>' +
'<div class="tpay-group-logo-holder">' +
'<img src="' + logoSrc + '" class="tpay-group-logo" alt="' + groupName + '"/>' +
'</div></div>';
}
function getBankOption(groupId, groupName) {
return '<option value="' + groupId + '" >' + groupName + '</option>';
}
function inArray(needle, haystack) {
var length = haystack.length;
for (var i = 0; i < length; i++) {
if (haystack[i] == needle) return true;
}
return false;
}
$(document).ready(function () {
var tpayBanksLink = link;
$.loadScript(tpayBanksLink, setupBanksForm);
$(document.body).on('updated_checkout', function () {
$.loadScript(tpayBanksLink, setupBanksForm);
});
});
})(jQuery);

View File

@@ -0,0 +1,18 @@
(function ($) {
$(document).ready(function () {
setupBlikForm();
$(document.body).on('updated_checkout', function () {
setupBlikForm();
});
});
setupBlikForm = function () {
$('#blik_code').on('input change blur', function () {
var that = $(this);
if (that.val().length > 0) {
$('#tpay-transfers-form').css('display', 'none');
} else {
$('#tpay-transfers-form').css('display', 'block');
}
});
}
})(jQuery);

View File

@@ -0,0 +1,162 @@
(function ($) {
function CardPayment(url, pubkey) {
this.url = url;
this.pubkey = pubkey;
$("#card_payment_form").attr("action", url);
var numberInput = $('#card_number'),
expiryInput = $('#expiry_date'),
cvcInput = $('#cvc');
const TRIGGER_EVENTS = 'input change blur';
function SubmitPayment() {
var cardNumber = numberInput.val().replace(/\s/g, ''),
cd = cardNumber + '|' + expiryInput.val().replace(/\s/g, '') + '|' + cvcInput.val().replace(/\s/g, '') + '|' + document.location.origin,
encrypt = new JSEncrypt(),
decoded = Base64.decode(pubkey),
encrypted;
encrypt.setPublicKey(decoded);
encrypted = encrypt.encrypt(cd);
$("#card_data").val(encrypted);
$("#card_vendor").val($.payment.cardType(cardNumber));
}
function setWrong($elem) {
$elem.addClass('wrong').removeClass('valid');
}
function setValid($elem) {
$elem.addClass('valid').removeClass('wrong');
}
function validateCcNumber($elem) {
var isValid = false,
ccNumber = $.payment.formatCardNumber($elem.val()),
supported = ['mastercard', 'maestro', 'visa'],
type = $.payment.cardType(ccNumber),
notValidNote = $('#info_msg_not_valid'),
cardTypeHolder = $('.tpay-card-icon'),
notSupportedNote = $('#info_msg_not_supported');
$elem.val($.payment.formatCardNumber($elem.val()));
cardTypeHolder.attr('class', 'tpay-card-icon');
if (supported.indexOf(type) < 0 && type !== null && ccNumber.length > 1) {
showElem(notSupportedNote);
hideElem(notValidNote);
setWrong($elem);
} else if (supported.indexOf(type) > -1 && $.payment.validateCardNumber(ccNumber)) {
setValid($elem);
hideElem(notSupportedNote);
hideElem(notValidNote);
isValid = true;
SubmitPayment();
} else if (ccNumber.length < 4) {
hideElem(notSupportedNote);
hideElem(notValidNote);
setWrong($elem);
} else {
setWrong($elem);
showElem(notValidNote);
hideElem(notSupportedNote);
}
if (type !== '') {
cardTypeHolder.addClass('tpay-' + type + '-icon');
}
return isValid;
}
function hideElem($elem) {
$elem.css('display', 'none');
}
function showElem($elem) {
$elem.css('display', 'block');
}
function validateExpiryDate($elem) {
var isValid = false, expiration;
$elem.val($.payment.formatExpiry($elem.val()));
expiration = $elem.payment('cardExpiryVal');
if (!$.payment.validateCardExpiry(expiration.month, expiration.year)) {
setWrong($elem);
} else {
setValid($elem);
isValid = true;
SubmitPayment();
}
return isValid;
}
function validateCvc($elem) {
var isValid = false;
if (!$.payment.validateCardCVC($elem.val(), $.payment.cardType(numberInput.val().replace(/\s/g, '')))) {
setWrong($elem);
} else {
setValid($elem);
isValid = true;
SubmitPayment();
}
return isValid;
}
numberInput.on(TRIGGER_EVENTS, function () {
validateCcNumber($(this));
});
expiryInput.on(TRIGGER_EVENTS, function () {
validateExpiryDate($(this));
});
cvcInput.on(TRIGGER_EVENTS, function () {
validateCvc($(this));
});
$(".payment_box.payment_method_tpaycards").visibilityChanged({
callback: function (element, visible) {
SubmitPayment();
},
runOnLoad: false,
frequency: 1000
});
}
function handleTpayForm() {
$('input[name=savedId]').each(function () {
$(this).click(function () {
if ($(this).is(":checked")) {
if ($(this).val() !== 'new') {
$('#card_form').css({opacity: 1.0}).animate({opacity: 0.0}, 500);
setTimeout(
function () {
$('#card_form').css({display: "none"})
}, 500
);
}
}
});
});
$('#newCard').click(function () {
if ($(this).is(":checked")) {
$('#card_form').css({opacity: 0.0, display: "block"}).animate({opacity: 1.0}, 500);
}
});
}
$(document).ready(function ($) {
setupCardForm();
$(document.body).on('updated_checkout', function () {
setupCardForm();
});
function setupCardForm() {
var RSA = document.getElementById("tpayRSA").textContent;
$('input[name=savedId]').first().prop('checked', "checked");
handleTpayForm();
var cards_regulation_checkbox = document.getElementById('tpay-cards-accept-regulations-checkbox'),
cards_regulations_input = document.getElementById('tpay-cards-regulations-input');
cards_regulation_checkbox.onchange = function () {
cards_regulations_input.value = (this.checked) ? 1 : 0;
};
new CardPayment("", RSA);
}
});
})(jQuery);

View File

@@ -0,0 +1,35 @@
(function ($) {
var defaults = {
callback: function () { },
runOnLoad: true,
frequency: 100,
previousVisibility : null
};
var methods = {};
methods.checkVisibility = function (element, options) {
if ($.contains(document, element[0])) {
var previousVisibility = options.previousVisibility;
var isVisible = element.css('display') != 'none';
options.previousVisibility = isVisible;
if (previousVisibility == null) {
if (options.runOnLoad) {
options.callback(element, isVisible);
}
} else if (previousVisibility !== isVisible) {
options.callback(element, isVisible);
}
setTimeout(function() {
methods.checkVisibility(element, options);
}, options.frequency);
}
};
$.fn.visibilityChanged = function (options) {
var settings = $.extend({}, defaults, options);
return this.each(function () {
methods.checkVisibility($(this), settings);
});
};
})(jQuery);