Reservation

${__('Thank you')} ${parameters.customer?.name},
${__('Your booking details have been sent to your email.')}
${hasPaymentMethods() ? `
${__('You will be redirecting to checkout page to make a payment in')} 10 ${__('seconds')}.
${__('Please click the link below if you are not redirecting.')} ${__('Go to checkout page')}
`:''}
`); if (hasPaymentMethods()) { this.countdown(function(){ console.log(parameters); //redirect to checkout page Reservation.gateway.checkout(parameters); }); } }, gateway: { checkout: function(parameters = {}) { //if we are on same domain if (isIframeInSameDomain()) { CarRental.Transaction.gateway.checkout.goTo(parameters, false); } else { //we have to send a message to parent sendMessage({ redirect_url: CarRental.Transaction.gateway.checkout.url(parameters) }); } }, pokpay: function(parameters = {}) { //lets prepare parameters parameters = { gateway: 'Pokpay', object_type: 'ErmirShehaj\\CarRental\\Models\\CarRental\\CarRentalReservation', object_id: parameters.id, amount: parameters?.amount || 1 }; CarRental.Transaction.gateway.process(parameters, false); } }, countdown: function(callback, x = 10) { var count = x, timer = setInterval(function() { $("#countdown").html(count--); if(count < 1) { clearInterval(timer); if (typeof callback !== 'undefined') callback(); } }, 1000); }, redirect_url: '', webhook_url: '', }; function getBodyHeight() { return Math.max(document.querySelector('.k-content').offsetHeight, 840); var body = document.body, html = document.documentElement; var height = Math.max( body.scrollHeight, body.offsetHeight, html.clientHeight, html.scrollHeight, html.offsetHeight ); return height; } function notifyParentForIframeHeight(new_step = false, delay = 700) { sendMessage({ height: getBodyHeight(), new_step }, delay); } function notifyParentForNewStep(delay = 100) { sendMessage({ new_step: true }, delay); } function notifyParentForReservation(reservation = {}, delay = 10) { sendMessage({ reservation }, delay); } //this method will send a message to parent window function sendMessage(data, delay = 0) { setTimeout(function(){ //send height to parent page window.top.postMessage(data, '*') //inside the iframe }, delay); } function isIframeInSameDomain() { try{ return parent.document ? true:false; // accessible } catch(e){ // not accessible return false; } } function hasPaymentMethods() { let value = Cache.get('settings')?.find(x => x.name == "payment_gateways")?.value ?? ''; if (!empty(value)) { let list = JSON.parse(value); if (list.length == 1 && list[0] == 'Cash') { return false; } return true } return false; } -->