#statusMessageContainer { text-align: center; } #statusMessageContainer p { text-align: left; } /* Loader */ .loading { position: relative; width: 100%; height: 70px; } .loading:after { font-family: Sans-Serif !important; box-sizing: border-box; content: ''; position: absolute; z-index: 100; left: 50%; top: 50%; width: 40px; height: 40px; font-size: 40px; border-right: 3px solid #9e191d; border-bottom: 1px solid #ebebeb; border-top: 2px solid #9e191d; border-radius: 100px; margin: -30px 0 0 -20px; animation: spin .75s infinite linear; -webkit-animation: spin .75s infinite linear; -moz-animation: spin .75s infinite linear; -o-animation: spin .75s infinite linear; } .spin { -webkit-animation: spin 1000ms infinite linear; animation: spin 1000ms infinite linear; } @keyframes spin { from { transform:rotate(0deg); } to { transform:rotate(360deg); } } @-webkit-keyframes spin { from { -webkit-transform: rotate(0deg); } to { -webkit-transform: rotate(360deg); } } .return-to-my-account { display: none; } .dotpay-alert { width: 100%; margin: 10px 2px; } .dotpay-alert h3,p { margin: 10px; padding-top: 3px; } .dotpay-alert.error { border: 1px solid #ec4d51; color: #9e191d; background-color: #ffe9e9; } .dotpay-alert.info { border: 1px solid #4dcaec; color: #194e9e; background-color: #e9ffff; } .dotpay-alert.success { border: 1px solid #39da4c; color: #0d9347; background-color: #e9ffeb; } .alertDot { text-align: center !important; margin: 24px 0 24px !important; padding: 10px; } .gicons { font-size: 36px; } #dp_countdown{ color: #97191d; font-size: 0.8em; } // Create an element in the DOM for testing if Material Icons are present let $span = document.createElement("span"); $span.className = "material-icons"; $span.style.display = "none"; document.body.insertBefore($span, document.body.firstChild); // See if the computed font-family value is material icons const needToLoadMaterialIcons = window.getComputedStyle($span, null).getPropertyValue("font-family") !== "Material Icons"; // If it's not, load the resource if (needToLoadMaterialIcons) { console.log('Need to load Material Icon...'); let $link = document.createElement("link"); $link.href = "https://fonts.googleapis.com/icon?family=Material+Icons"; $link.rel = "stylesheet"; document.head.appendChild($link); } // Cleanup the original document.body.removeChild($span); var dotpayCheckStatusTimeout = 2;//in minutes function dotpayCheckStatus(interval) { jQuery.ajax({ "url":"https://print-druk.pl/?wc-api=dotpay_status", "method":"POST", "success":function(r){ switch(r) { case '1': clearAlerts(); createAlert('success', 'Status transakcji: wykonana', 'Płatność została potwierdzona.'); jQuery( "div.dotpay-alert > H3" ).prepend( "thumb_up_alt " ); setTimeout(function(){location.href = "https://print-druk.pl/checkout/order-received/?key";}, 3000); break; case '-1': clearAlerts(); createAlert('error', 'Płatność została odrzucona.', 'Błąd płatności'); jQuery('.return-to-my-account').show(); jQuery( "div.dotpay-alert > H3" ).prepend( "thumb_down " ); jQuery( "div.dotpay-alert > p.alertDot" ).append( " ponów płatność dla tego zamówienia" ); break; case '0': break; default: clearAlerts(); createAlert('error', 'Nie znaleziono zamówienia', 'Błąd pobierania informacji o statusie płatności'); jQuery('.return-to-my-account').show(); jQuery( "div.dotpay-alert > H3" ).prepend( "gps_off " ); } if(r!='0') stopWaiting(interval); } }); } function createAlert(type, message, header) { var types = ['error', 'info', 'success']; if(types.indexOf(type)==-1) type = 'info'; var div = document.createElement('div'); div.className = "dotpay-alert "+type; if(header!=undefined) { var h3 = document.createElement('h3'); h3.appendChild(document.createTextNode(header)); div.appendChild(h3); } var p = document.createElement('p'); p.className = 'alertDot'; p.appendChild(document.createTextNode(message)); div.appendChild(p); document.getElementById('dotpay-alert-container').appendChild(div); } function clearAlerts() { var elems = document.getElementById('dotpay-alert-container').children; while(elems.length>0) elems[0].remove(); } function stopWaiting(interval) { jQuery('.loading').remove(); clearInterval(interval); } jQueryDotpayCheckStatus = function(){ if (typeof jQuery != 'undefined') { var dotpayCheckStatusInterval = 5000; var dotpayCheckStatusLimit = dotpayCheckStatusTimeout*60000/dotpayCheckStatusInterval; jQuery(document).ready(function(){ var blocked = false; var counter = 0; console.log('%cpending payment status...','background: #cfcfcf; color: darkviolet;'); console.log('pending'); createAlert('info', 'Płatność oczekuje potwierdzenia w Dotpay... proces ten może potrwać do 2 minut.'); jQuery( "p.alertDot" ).prepend( "help_outline" ); var now1 = new Date().getTime(); var countDownDate = new Date(now1 + 1000*120).getTime(); // Update the count down every 1 second var x = setInterval(function() { var now = new Date().getTime(); var distance = countDownDate - now; var minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); var seconds = Math.floor((distance % (1000 * 60)) / 1000); var dp_countdownEl = document.getElementById("dp_countdown"); // Output the result if(dp_countdownEl){ dp_countdownEl.innerHTML = minutes + "m " + seconds + "s "; // If the count down is over, write some text if (distance < 0) { clearInterval(x); dp_countdownEl.innerHTML = 'Upłynął przewidziany czas na potwierdzenie tej płatności.'; } } }, 1000); var interval = setInterval(function(){ if(blocked) return true; dotpayCheckStatus(interval); ++counter; if(counter>dotpayCheckStatusLimit) { blocked = true; stopWaiting(interval); clearAlerts(); createAlert('error', 'Został przekroczony czas oczekiwania na potwierdzenie płatności', 'Problem z potwierdzeniem Twojej płatności'); jQuery('.return-to-my-account').show(); jQuery( "div.dotpay-alert > H3" ).prepend( "timer_off " ); jQuery( "div.dotpay-alert > p.alertDot" ).append( "Kiedy transakcja zostanie potwierdzona, wówczas na Twój adres e-mail wyślemy wiadomość z potwierdzeniem. Jeżeli płatność nie zostanie potwierdzona, skontaktuj się ze sprzedawcą." ); } }, 5000); }); } else{ console.log("\n -------------------------------------------------------------------------------------\n"); console.log("%cWarning!","color:red;font-family:system-ui;font-size:3rem;-webkit-text-stroke: 1px black;font-weight:bold;"); console.log("\n%cLoad jQuery first in your template! Then Dotpay plugin.", "background: red; color: yellow; font-size: 1.2rem"); console.log("%cOtherwise the Dotpay plugin may not work properly!", "color: red; font-size: 1rem;font-weight: bold;"); console.log("\n -------------------------------------------------------------------------------------\n"); } } Możesz przejść do swojego panelu konta użytkownika if(window.jQuery){ jQueryDotpayCheckStatus(); } else{ var script = document.createElement('script'); document.head.appendChild(script); script.type = 'text/javascript'; script.src = "//ajax.googleapis.com/ajax/libs/jquery/3.5.0/jquery.min.js"; script.onload = jQueryDotpayCheckStatus; }