/**
* NOTICE OF LICENSE
*
* This source file is subject to the MIT License (MIT)
* that is bundled with this package in the file LICENSE.md.
*
* @author mElements S.A.
* @copyright mElements S.A.
* @license MIT License
**/
// jQuery Mask Plugin v1.14.16
// github.com/igorescobar/jQuery-Mask-Plugin
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.findInternal=function(a,n,f){a instanceof String&&(a=String(a));for(var p=a.length,k=0;k
g?h=10*d:e>=h&&e!==g?c.maskDigitPosMapOld[h]||(e=h,h=h-(k-l)-a,c.maskDigitPosMap[h]&&(h=e)):h>e&&(h=h+(l-k)+f)}return h},behaviour:function(d){d=
d||window.event;c.invalid=[];var e=b.data("mask-keycode");if(-1===a.inArray(e,l.byPassKeys)){e=c.getMasked();var h=c.getCaret(),g=b.data("mask-previus-value")||"";setTimeout(function(){c.setCaret(c.calculateCaretPosition(g))},a.jMaskGlobals.keyStrokeCompensation);c.val(e);c.setCaret(h);return c.callbacks(d)}},getMasked:function(a,b){var h=[],f=void 0===b?c.val():b+"",g=0,k=d.length,n=0,p=f.length,m=1,r="push",u=-1,w=0;b=[];if(e.reverse){r="unshift";m=-1;var x=0;g=k-1;n=p-1;var A=function(){return-1<
g&&-1 0) {
paynow.paymentButton.enable();
return true
} else {
paynow.paymentButton.disable();
return false
}
},
isOnePageCheckout: function () {
// support for: Supercheckout by Knownband
if ($('#velsof_supercheckout_form').length) {
return true
}
return false
},
closeMiniMenu: function (e) {
if (!$(e.target).is(paynow.selectors.cardMethodRemove) && !$(e.target).is(paynow.selectors.cardMethodMiniMenuOpen)) {
$(paynow.selectors.cardMethodRemove).addClass('--hidden')
}
},
toggleCardMiniMenu: function (e) {
$(e.currentTarget).siblings().toggleClass('--hidden')
},
isTermsChecked: function () {
if (paynow.config.allTermsHaveToBeChecked) {
return !$(paynow.selectors.terms).is(':not(:checked)')
} else {
return $(paynow.selectors.terms).is(':checked')
}
},
triggerOnePageCheckoutPlaceOrder: function () {
// support for: Supercheckout by Knownband
if ($('#velsof_supercheckout_form').length) {
$("#supercheckout_confirm_order").trigger('click')
}
},
chargeBlik: function (onSuccess, onFail, onError) {
$.ajax($(paynow.selectors.form).data('action'), {
method: 'POST', type: 'POST',
data: {
'blikCode': $(paynow.selectors.blikCode).val().replace(/\s/g, ""),
'token': $(paynow.selectors.form).data('token')
},
}).success(function (data, textStatus, jqXHR) {
if (data.success === true) {
if (typeof onSuccess == 'function') {
onSuccess(data, textStatus, jqXHR)
}
} else {
if (typeof onFail == 'function') {
onFail(data, textStatus, jqXHR)
}
}
}).error(function (jqXHR, textStatus, errorThrown) {
if (typeof onError == 'function') {
onError(jqXHR, textStatus, errorThrown)
}
});
},
addApplePayEnabledToCookie: function () {
let applePayEnabled = false;
if (window.ApplePaySession) {
applePayEnabled = window.ApplePaySession.canMakePayments();
}
document.cookie = 'applePayEnabled=' + (applePayEnabled ? '1' : '0');
},
addFingerprintToCardPayment: function () {
const input = $('#payment-method-fingerprint');
if (!input.length) {
return;
}
try {
const fpPromise = import('https://static.paynow.pl/scripts/PyG5QjFDUI.min.js')
.then(FingerprintJS => FingerprintJS.load())
fpPromise
.then(fp => fp.get())
.then(result => {
input.val(result.visitorId);
})
} catch (e) {
console.error('Cannot get fingerprint');
}
},
removeSavedInstrument: function (e) {
const target = $(e.currentTarget);
const savedInstrument = target.data('removeSavedInstrument');
const errorMessage = target.data('errorMessage');
const cardMethodOption = $('#wrapper-' + savedInstrument);
cardMethodOption.addClass('loading');
$.ajax(target.data('action'), {
method: 'POST', type: 'POST',
data: {
'savedInstrumentToken': savedInstrument,
'token': target.data('token'),
},
}).success(function (data, textStatus, jqXHR) {
if (data.success === true) {
cardMethodOption.remove();
} else {
cardMethodOption.removeClass('loading');
paynow.showRemoveSavedInstrumentErrorMessage(savedInstrument, errorMessage);
}
}).error(function (jqXHR, textStatus, errorThrown) {
cardMethodOption.removeClass('loading');
paynow.showRemoveSavedInstrumentErrorMessage(savedInstrument, errorMessage);
});
},
showRemoveSavedInstrumentErrorMessage: function (savedInstrument, errorMessage) {
const errorMessageWrapper = jQuery('#wrapper-' + savedInstrument + ' .paynow-payment-card-error');
errorMessageWrapper.text(errorMessage);
setTimeout(() => {
errorMessageWrapper.text('');
}, 5000)
},
paymentButton: {
show: function () {
$(paynow.selectors.paymentButton).show();
},
hide: function () {
$(paynow.selectors.paymentButton).hide();
},
disable: function () {
$(paynow.selectors.paymentButton).prop('disabled', true);
if (paynow.config.useCssClassDisabled) {
$(paynow.selectors.paymentButton).addClass('disabled');
}
},
enable: function () {
$(paynow.selectors.paymentButton).prop('disabled', false);
if (paynow.config.useCssClassDisabled) {
$(paynow.selectors.paymentButton).removeClass('disabled');
}
}
},
blikButton: {
disable: function () {
$(paynow.selectors.blikButton).prop('disabled', true);
if (paynow.config.useCssClassDisabled) {
$(paynow.selectors.blikButton).addClass('disabled');
}
},
enable: function () {
$(paynow.selectors.blikButton).prop('disabled', false);
if (paynow.config.useCssClassDisabled) {
$(paynow.selectors.blikButton).removeClass('disabled');
}
},
show: function () {
$(paynow.selectors.blikButton).show();
},
hide: function () {
$(paynow.selectors.blikButton).hide();
}
}
};
$(document).ready(paynow.init);
// backward compatibility; in case someone is using old functions in own code
function enableBlikSupport() { paynow.blikFormPrepare() }
function paynowPblPaymentBtnCheck() { paynow.pblValidate() }
function enablePblSupport() {}