$('#checkout-confirm').on('submit', function(e) {
  e.preventDefault();
  var $this = $(this),
    dataInfo = $(this)
      .find('[data-info]')
      .data('info');

  var data = $('.container-payment-data').find('select, textarea, input').serialize();

  $.ajax({
    type: 'POST',
    url: dataInfo.url,
    data: data,
    dataType : 'json',
    beforeSend: function() {
      $this.find('.ftr-steps__button').prop('disabled', true);
      $('.ftr-loading-bar').removeClass('ftr-none');
    },
    complete: function() {
      $('.ftr-loading-bar').addClass('ftr-none');
      $this.find('.ftr-steps__button').prop('disabled', false);
    },
    success: function(json) {
      if (json['error']) {
        $('.ftr-field').removeClass('error');
        $('.ftr-field__error').remove();

        $.each(json['error'], function(index, value) {
          $('input[name=' + index + ']')
            .closest('.ftr-field')
            .addClass('error');
          $('input[name=' + index + ']  + .ftr-field__text').after(
            '<span class="ftr-field__error">' + value + '</span>'
          );
          notificationMsg(value, 'error');
          if (index == 't_e_limiter_ip' || index == 't_e_limiter'){
            setTimeout(function (e){
              location.href = ('index.php?route=account/logout');
            },5000)
          }
        });
      }else{
        window.location = dataInfo.location;
      }
    },
    error: function(xhr, ajaxOptions, thrownError) {
      console.log(thrownError + "\r\n" + xhr.statusText + "\r\n" + xhr.responseText);
    },
  });
});
