<?php echo $header; ?>

<?php
    if ($this->config->get('wg24_seo_fer_facebook_status')=='enable'){
      if (!$this->config->get('wg24_seo_fer_facebook_pixel')==''){
?>
<script>
  window.waitEvent('scripts_document', function() {
    fbq('track', 'Purchase', {currency : "BRL", value : <?php echo $order_total; ?>});

    var btnGetnetReload = document.querySelector('.js-reloadPayment');

    if(btnGetnetReload){
      btnGetnetReload.addEventListener('click', function(e){
        reloadPix()
      });
    }

    function reloadPix(){
      $.ajax({
        url: 'index.php?route=payment/getnet/reloadPix',
        type: 'get',
        dataType: 'json',
        timeout: 3000,
        contentType: 'application/json; charset=utf-8',
        error: function(xhr, ajaxOptions, thrownError) {
          console.log(thrownError + '\r\n' + xhr.statusText + '\r\n' + xhr.responseText);
        },
        success: function(json) {
          if(json.pay){
            var imgQR = document.querySelector('.js-imgQr');
            var spanQr = document.querySelector('.js-copy-content');
            imgQR.setAttribute('src','https://chart.googleapis.com/chart?chs=400x400&cht=qr&chl='+json.additional_data.qr_code);
            spanQr.textContent = json.additional_data.qr_code;
          }
        },
      });
    }

    setInterval( paymentStatus, 5000);

    function paymentStatus(){
      var imgQR = document.querySelector('.js-imgQr');
      if(imgQR && !(imgQR.getAttribute('src') == 'image/qrcode_pago.png')){
        $.ajax({
          url: 'index.php?route=checkout/success/verifyPaymentPix',
          type: 'get',
          dataType: 'json',
          timeout: 3000,
          contentType: 'application/json; charset=utf-8',
          error: function(xhr, ajaxOptions, thrownError) {
            console.log(thrownError + '\r\n' + xhr.statusText + '\r\n' + xhr.responseText);
          },
          success: function(json) {
            if(json){
              imgQR.setAttribute('src','image/qrcode_pago.png');
            }
          },
        });
      }
    }
  });

</script>;
<?php
      }
    }
?>

<section
  class="container-fluid"
  <?php if ($transaction && $transactionItens) { ?>
    data-transaction='{"details": <?php echo json_encode($transaction) ?>, "products": <?php echo json_encode($transactionItens) ?>, "googleTrackingCodes": <?php echo json_encode($googleAnalytics)?>}'
  <?php } ?>
>

  <div class="row">
    <div class="col-xs">
      <div class="content-box svn-teste-sucesso">

        <?php echo $breadcrumbs; ?>

        <?php if ($content_top) { ?>
          <?php echo $content_top; ?>
        <?php } ?>

        <h2 class="heading-1"><?php echo $heading_title; ?></h2>
        <p class="text-medium text-gray top-margin-x-small"><?php echo $text_message; ?></p>
        <div class="flex top-margin-small bottom-margin-x-large">
          <a href="<?php echo $order; ?>" class="btn-default btn-medium top-margin-small right-margin-small">
            <span>Ver pedido</span>
          </a>
          <a href="<?php echo $contact; ?>" class="btn-default btn-medium btn-outline top-margin-small">
            <span>Entrar em contato</span>
          </a>
        </div>

        <?php echo $payment_template; ?>

        <?php if (isset($checkout_success) && isset($certificate_ebit_status) && $certificate_ebit_status) { ?>
          <div>
            <a id="bannerEbit"></a>
            <param id="ebitParam"
                   value="email=<?php echo $certificate_ebit_info['email']; ?>&gender=<?php echo $certificate_ebit_info['gender']; ?>&birthDay=<?php echo $certificate_ebit_info['birthDay']; ?>&zipCode=<?php echo $certificate_ebit_info['zipCode']; ?>&mktSaleID=<?php echo $certificate_ebit_info['mktSaleID']; ?>&deliveryTax=<?php echo $certificate_ebit_info['deliveryTax']; ?>&totalSpent=<?php echo $certificate_ebit_info['totalSpent']; ?>&value=<?php echo $certificate_ebit_info['value']; ?>&quantity=<?php echo $certificate_ebit_info['quantity']; ?>&productName=<?php echo $certificate_ebit_info['productName']; ?>&transactionId=<?php echo $certificate_ebit_info['transactionId']; ?>&ean=<?php echo $certificate_ebit_info['eanCode']; ?>&sku=<?php echo $certificate_ebit_info['sku']; ?>&buscapeId=<?php echo $certificate_ebit_info['buscapeId']; ?>&storeId=<?php echo $certificate_ebit_info['storeId']; ?>&plataform=<?php echo $certificate_ebit_info['plataform']; ?>"
            />
          </div>
        <?php } ?>

      </div>
    </div>

    <?php if ($column_right) { ?>
      <div class="hidden-md-down col-md-3">
        <?php echo $column_right; ?>
      </div>
    <?php } ?>

    <?php if ($content_bottom) { ?>
      <div class="col-xs-12">
        <?php echo $content_bottom; ?>
      </div>
    <?php } ?>
  </div>
</section>

<?php echo $footer; ?>
