<?php
require ($_SERVER['DOCUMENT_ROOT'].'/core/sys.php');
$title = 'Проверка платежа';
require ($_SERVER['DOCUMENT_ROOT'].'/core/head.php');
$id = abs(intval($_SESSION['payment']));
$pay = $db->prepare('SELECT * FROM `pay` WHERE `id` = ?');
$pay -> execute([$id]);
$pay = $pay -> fetch(PDO :: FETCH_ASSOC);
$client = $db->prepare('SELECT * FROM `platform` WHERE `id` = ?');
$client -> execute([$pay['platform']]);
$client = $client -> fetch(PDO :: FETCH_ASSOC);
$amount = number_format($pay['summa']+$pay['summa']*0.05, 2, '.', '');
/*Проверки*/
?>
<div class="card">
    <div class="card-body">
    <b>Счет:</b> <?=$id;?><br/>
     <b>Сумма к оплате:</b> <?=$pay['summa']+$pay['summa']*0.05;?>руб.    <br/>
        <b>Товар:</b> <?=trim(htmlspecialchars(base64_decode($pay['com']), ENT_QUOTES, 'UTF-8'))?><br/>
      <b>Продавец:</b> <?=$client['url'];?><br/>
    </div>



<?
if($pay['status'] != 'yes'){
?>
<div id="info" class="message">
                Идет проверка платежа...<br/>
                Обновление через: <span id="timer_inp">5</span> сек.
</div>
 <div class="card-body">
    <div style="text-align:center;"><a href="<?=$client['error']?>"><button class="btn btn-success my-2 my-sm-0">Вернуться на сайт</button></a></div>
    </div> </div> 

<script type="text/javascript">
            function timer() {
                var obj = document.getElementById('timer_inp');
                obj.innerHTML--;
                if (obj.innerHTML == 0) {
                    location.reload();
                    setTimeout(function () {
                    }, 1000);
                } else {
                    setTimeout(timer, 1000);
                }
            }

            setTimeout(timer, 1000);
        </script>
<?
}else{
?>
<div id="success" class="message"> Платеж был успешно произведен</div>
 <div class="card-body">
    <div style="text-align:center;"><a href="<?=$client['result']?>"><button class="btn btn-success my-2 my-sm-0">Вернуться на сайт</button></a></div>
    </div> </div> 
<?
}
/*END*/
require ($_SERVER['DOCUMENT_ROOT'].'/core/foot.php');