<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

/* ================================
   SESSION & CONFIG
================================ */
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/session.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/includes/config.php';

/* ================================
   HEADER
================================ */
require_once $_SERVER['DOCUMENT_ROOT'] . '/template/tngweb/header.php';

/* ================================
   API DETAILS
================================ */
$price = 1299;
$upi_id = "departmentspace@ibl";
$upi_name = "Suman Kumar";
$purpose = "API Service Purchase";
$showQR = false;

if (isset($_POST['buyapi'])) {
    $showQR = true;

    $upi_url = "upi://pay?pa={$upi_id}&pn=".urlencode($upi_name).
               "&am={$price}&cu=INR&tn=".urlencode($purpose);

    $qr_url = "https://api.qrserver.com/v1/create-qr-code/?size=260x260&data=" . urlencode($upi_url);
}
?>

<style>
.api-card {
    max-width: 700px;
    margin: 60px auto;
    border-radius: 15px;
}
.api-header {
    background: #6f42c1;
    color: #fff;
    padding: 18px;
    font-size: 22px;
    border-radius: 15px 15px 0 0;
    text-align: center;
}
.price-box {
    font-size: 22px;
    font-weight: bold;
    color: #198754;
}
.service-list {
    text-align: left;
    margin-top: 20px;
}
.service-list li {
    padding: 6px 0;
    font-weight: 600;
}
.other-service {
    margin-top: 20px;
    font-weight: bold;
    color: #FF5722;
    text-align: center;
}
</style>

<div class="container">
    <div class="card shadow api-card">

        <div class="api-header">
            🚀 API SERVICE
        </div>

        <div class="card-body text-center p-4">

<h5 class="fw-bold mb-2">All Working Only 2 Minutes</h5>
<p class="text-muted mb-3">
    You have the card. The card text will appear here and you can use this section to print it.
</p>


            <div class="price-box my-3">
                💰 Price: ₹ <?= $price ?>
            </div>

            <?php if (!$showQR) { ?>
                <form method="POST">
                    <button name="buyapi" class="btn btn-primary btn-lg px-5">
                        🛒 BUY API
                    </button>
                </form>
            <?php } else { ?>

                <div class="my-3">
                    <img src="<?= $qr_url ?>" alt="UPI QR Code">
                </div>

                <div class="alert alert-info">
                    <strong>UPI ID:</strong> <?= $upi_id ?><br>
                    <strong>Amount:</strong> ₹ <?= $price ?>
                </div>

                <div class="alert alert-success">
                    <strong>Banking Name:</strong><br>
                    <span style="font-size:22px;font-weight:bold;">
                        <?= $upi_name ?>
                    </span>
                </div>

                <p class="text-danger fw-bold">
                    ⚠️ Payment करने के बाद Admin को Screenshot भेजें
                </p>

            <?php } ?>

            <div class="other-service">
                ANY OTHER SERVICE AVAILABLE
            </div>

        </div>
    </div>
</div>

<?php
require_once $_SERVER['DOCUMENT_ROOT'] . '/template/tngweb/footer.php';
?>
