// source --> https://slovenskyumeleckydvor.sk/wp-content/plugins/woo-comgate/public/assets/js/public.js?ver=4.7.9 
jQuery( document ).ready(function() {



    if(jQuery('#comgate_payment_loader').length > 0) {

        var refreshInterval = setInterval(get_comgate_status, 2000);

        function get_comgate_status() {
            var id = jQuery("#comgate_payment_loader").data('orderid');

            let data = {
                action: 'comgate_load_payment_status',
                orderid: id
            };

            jQuery.post(comgate_localize.ajaxurl, data, function (response) {
                if(response !== '') {
                    clearInterval(refreshInterval);
                    if(jQuery('#comgate_status_loader_wrap').length > 0) {
                        document.getElementById("comgate_status_loader_wrap").remove();
                    }
                    if (response === 'PAID') {
                        jQuery('.woocommerce-thankyou-order-received').html(comgate_localize.paidok)
                    } else if (response === 'CANCELLED') {
                        jQuery('.woocommerce-thankyou-order-received').html(comgate_localize.paidcancelled)
                        data = {
                            action: 'comgate_pay_url',
                            orderid: id
                        };
                        jQuery.post(comgate_localize.ajaxurl, data, function (response) {
                            window.top.location.replace(response);
                        });
                    } else if (response === 'AUTHORIZED') {
                        jQuery('.woocommerce-thankyou-order-received').html(comgate_localize.paidauthorized)
                    } else if (response === 'PENDING') {
                        jQuery('.woocommerce-thankyou-order-received').html(comgate_localize.paidpending)
                    }
                }
            })
        }

    }


});


(function ( $ ) {
	"use strict";

	$(function () {

   jQuery('body').on('click','.comgate_select',function(){
    
    jQuery(this).children('.comgate_select_input').prop('checked',true);
    
   });

   jQuery('body').on('click','.comgate_bank_select',function(){

    jQuery(this).children('.comgate_select_input').prop('checked',true);

   });
		
	});

}(jQuery));