2022-03-25 14:28:27 +01:00
|
|
|
window.addEventListener('load', function() {
|
2022-04-12 15:09:28 +02:00
|
|
|
|
2022-04-25 14:31:43 +02:00
|
|
|
function _loadBeaconJS(options) {
|
|
|
|
var script = document.createElement('script');
|
|
|
|
script.src = options.fnUrl;
|
|
|
|
document.body.appendChild(script);
|
|
|
|
}
|
2022-04-12 15:09:28 +02:00
|
|
|
|
2022-04-25 14:31:43 +02:00
|
|
|
function _injectConfig() {
|
|
|
|
var script = document.querySelector("[fncls='fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99']");
|
|
|
|
if (script) {
|
|
|
|
if (script.parentNode) {
|
|
|
|
script.parentNode.removeChild(script);
|
|
|
|
}
|
2022-04-21 16:51:17 +02:00
|
|
|
}
|
2022-03-24 16:27:03 +01:00
|
|
|
|
2022-04-25 14:31:43 +02:00
|
|
|
script = document.createElement('script');
|
|
|
|
script.id = 'fconfig';
|
|
|
|
script.type = 'application/json';
|
|
|
|
script.setAttribute('fncls', 'fnparams-dede7cc5-15fd-4c75-a9f4-36c430ee3a99');
|
2022-04-12 15:09:28 +02:00
|
|
|
|
2022-04-25 14:31:43 +02:00
|
|
|
var configuration = {
|
|
|
|
'f': FraudNetConfig.f,
|
|
|
|
's': FraudNetConfig.s
|
|
|
|
};
|
2022-04-25 15:58:30 +02:00
|
|
|
if(FraudNetConfig.sandbox === '1') {
|
|
|
|
configuration.sandbox = true;
|
|
|
|
}
|
2022-03-25 14:28:27 +01:00
|
|
|
|
2022-04-25 14:31:43 +02:00
|
|
|
script.text = JSON.stringify(configuration);
|
|
|
|
document.body.appendChild(script);
|
|
|
|
|
2022-05-11 16:11:05 +02:00
|
|
|
const payForOrderForm = document.forms.order_review;
|
|
|
|
if(payForOrderForm) {
|
|
|
|
const puiPayForOrderSessionId = document.createElement('input');
|
|
|
|
puiPayForOrderSessionId.setAttribute('type', 'hidden');
|
|
|
|
puiPayForOrderSessionId.setAttribute('name', 'pui_pay_for_order_session_id');
|
|
|
|
puiPayForOrderSessionId.setAttribute('value', FraudNetConfig.f);
|
|
|
|
payForOrderForm.appendChild(puiPayForOrderSessionId);
|
|
|
|
}
|
|
|
|
|
2022-04-25 14:31:43 +02:00
|
|
|
_loadBeaconJS({fnUrl: "https://c.paypal.com/da/r/fb.js"})
|
2022-04-12 15:09:28 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
document.addEventListener('hosted_fields_loaded', (event) => {
|
2022-04-25 14:31:43 +02:00
|
|
|
if (PAYPAL.asyncData && typeof PAYPAL.asyncData.initAndCollect === 'function') {
|
|
|
|
PAYPAL.asyncData.initAndCollect()
|
|
|
|
}
|
|
|
|
|
|
|
|
_injectConfig();
|
2022-04-12 15:09:28 +02:00
|
|
|
});
|
2022-03-25 14:28:27 +01:00
|
|
|
|
2022-04-25 14:31:43 +02:00
|
|
|
_injectConfig();
|
2022-03-25 14:28:27 +01:00
|
|
|
})
|
2022-03-24 16:27:03 +01:00
|
|
|
|