
<?php
// Capture form data from POST or GET (for redirects after payment)
$salutation = isset($_POST['jform-salutation']) ? htmlspecialchars($_POST['jform-salutation'], ENT_QUOTES, 'UTF-8') : (isset($_GET['salutation']) ? htmlspecialchars($_GET['salutation'], ENT_QUOTES, 'UTF-8') : '');
$firstname = isset($_POST['jform-firstname']) ? htmlspecialchars($_POST['jform-firstname'], ENT_QUOTES, 'UTF-8') : (isset($_GET['firstname']) ? htmlspecialchars($_GET['firstname'], ENT_QUOTES, 'UTF-8') : '');
$lastname = isset($_POST['jform-lastname']) ? htmlspecialchars($_POST['jform-lastname'], ENT_QUOTES, 'UTF-8') : (isset($_GET['lastname']) ? htmlspecialchars($_GET['lastname'], ENT_QUOTES, 'UTF-8') : '');
$email = isset($_POST['jform-email']) ? htmlspecialchars($_POST['jform-email'], ENT_QUOTES, 'UTF-8') : (isset($_GET['email']) ? htmlspecialchars($_GET['email'], ENT_QUOTES, 'UTF-8') : '');
$phone = isset($_POST['jform-phone']) ? htmlspecialchars($_POST['jform-phone'], ENT_QUOTES, 'UTF-8') : (isset($_GET['phone']) ? htmlspecialchars($_GET['phone'], ENT_QUOTES, 'UTF-8') : '');
$currency = isset($_POST['jform-currency']) ? htmlspecialchars($_POST['jform-currency'], ENT_QUOTES, 'UTF-8') : (isset($_GET['currency']) ? htmlspecialchars($_GET['currency'], ENT_QUOTES, 'UTF-8') : 'KES');
$amount = isset($_POST['jform-amount']) ? htmlspecialchars($_POST['jform-amount'], ENT_QUOTES, 'UTF-8') : (isset($_GET['amount']) ? $_GET['amount'] : '0.00');
$description = isset($_POST['jform-description']) ? htmlspecialchars($_POST['jform-description'], ENT_QUOTES, 'UTF-8') : (isset($_GET['description']) ? htmlspecialchars($_GET['description'], ENT_QUOTES, 'UTF-8') : '');
$usdEquivalent = isset($_GET['usdEquivalent']) ? $_GET['usdEquivalent'] : '0.00';

// Format customer full name
$customername = trim($salutation . ' ' . $firstname . ' ' . $lastname);

// Calculate USD equivalent for USDT value if not provided
if ($usdEquivalent === '0.00' && is_numeric($amount)) {
    $exchangeRates = [
        'GBP' => 1.35,
        'EUR' => 1.18,
        'USD' => 1.0,
        'KES' => 1 / 129.10
    ];
    $cleanAmount = str_replace(',', '', $amount);
    $numericAmount = is_numeric($cleanAmount) ? floatval($cleanAmount) : 0.0;
    $usdEquivalent = $numericAmount * ($exchangeRates[$currency] ?? 1.0);
}

// Format amounts
$cleanAmount = str_replace(',', '', $amount);
$numericAmount = is_numeric($cleanAmount) ? floatval($cleanAmount) : 0.0;
$formattedAmount = number_format($numericAmount, 2);
$formattedUsdEquivalent = number_format(floatval($usdEquivalent), 2);
?>
<!DOCTYPE html>
<html lang="en" class="dark-theme">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Coin2pay - Crypto Payment</title>
    <link rel="icon" type="image/png" sizes="32x32" href="https://hostedpage.coin2pay.io/assets/img/logo/logo-coin2pay_icon-light.png">
    <link href="assets/style_payments.css" rel="stylesheet" type="text/css">
<link href="assets/style_forms_validation.css" rel="stylesheet" type="text/css">
<link href="assets/bootstrap.min.css" rel="stylesheet" type="text/css">
    <link rel="stylesheet" href="https://hostedpage.coin2pay.io/assets/css/app.css?1234" type="text/css">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.0.0-beta1/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-giJF6kkoqNQ00vy+HMDP7azOuL0xtbfIcaT9wjKHr8RbDVddVHyTfAAsrekwKmP1" crossorigin="anonymous">
    <link href="https://cdn.prod.website-files.com/69808992a33f77fee53fbf3f/css/digitrust1.webflow.shared.9575ce27f.css"
        rel="stylesheet" type="text/css" integrity="sha384-lXXOJ/xWjpRlqAVWS9n8iQqOyxNuSj/cfBZfjSy7m+Q7p7ghH75skhtvnitWqvam"
        crossorigin="anonymous" />
        <style>
            /* Local overrides to ensure these rules override the CDN stylesheet */
            .main-conatiner.w-container, .main-conatiner, .w-container { max-width: 1500px !important; }
            .hero-left { background: rgba(0,0,0,0) !important; backdrop-filter: none !important; box-shadow: none !important; }
        </style>
    <link href="https://fonts.googleapis.com" rel="preconnect" />
    <link href="https://fonts.gstatic.com" rel="preconnect" crossorigin="anonymous" />
    <script src="https://ajax.googleapis.com/ajax/libs/webfont/1.6.26/webfont.js" type="text/javascript"></script>
    <script
        type="text/javascript">
        WebFont.load({
            google: {
                families: ["Montserrat:100,100italic,200,200italic,300,300italic,400,400italic,500,500italic,600,600italic,700,700italic,800,800italic,900,900italic"]
            }
        });
    </script>
    <script
        type="text/javascript">
        ! function(o, c) {
            var n = c.documentElement,
                t = " w-mod-";
            n.className += t + "js", ("ontouchstart" in o || o.DocumentTouch && c instanceof DocumentTouch) && (n.className += t + "touch")
        }(window, document);
    </script>
    <link href="https://cdn.prod.website-files.com/69808992a33f77fee53fbf3f/69808995a33f77fee53fc01f_favicon.png"
        rel="shortcut icon" type="image/x-icon" />
    <link href="https://cdn.prod.website-files.com/69808992a33f77fee53fbf3f/69808995a33f77fee53fc020_webclip-ss.png"
        rel="apple-touch-icon" />
    <link href="https://unpkg.com/aos@2.3.1/dist/aos.css" rel="stylesheet">
    <style></style>
    <link rel="stylesheet" href="assets/theme-blend.css" type="text/css">
    <style>
        body {
            font-family: 'Arial', sans-serif;
            background-color: #e9ecef;
            padding: 0px;
        }

        h1 {
            text-align: center;
            margin-bottom: 30px;
            color: #333;
        }

        .copy-btn,
        .submit-btn {
            padding: 10px;
            cursor: pointer;
            background-color: #f4f4f4;
            border: 1px solid #ccc;
            border-radius: 4px;
        }

        .copy-btn:hover,
        submit-btn:hover {
            background-color: #e2e2e2;
        }
    </style>
</head>

<body class="main-body">


    <div class="container card card-border-color card-border-color-primary" style="margin-top: 100px !important; max-width: 860px !important">

        <div class="form-group remarks">
            <label class="control-label font-weight-bold"><b>Payment Steps:</b></label>
            <span id="Label3"><br>
                <!-- 1. Enter your amount <b>(Minimum: <font color='red'>$100</font>)</b>. <br>  -->
                1. Select the Digital Identity package you wish to order.<br>
                2. Select the cryptocurrency gateway you want to use.<br>
                3. Copy the wallet address provided or generate QRScan the QR code to make the payment. <br>
                4. Send the exact amount of <?php echo htmlspecialchars($currency); ?> <?php echo htmlspecialchars($formattedAmount); ?> (equivalent to USD <?php echo htmlspecialchars($formattedUsdEquivalent); ?>) to the address provided. <br>
                5. After completing the transaction, fill on "Payment Details" to finalize the process. <br>
                6. Make sure your payment has been sent before clicking "Submit Payment" to avoid fake payment.<br>
            </span>
        </div>



        <div class="info-card" id="content">
            <div class="info-card" id="content" style="display: block;">
                <form action="<?php echo htmlspecialchars($_SERVER['PHP_SELF']); ?>" method="post">
               

             
             
            
      
                
                <hr>
                <div class="form-group card-body">
                    <label class="control-label" style>Bitcoin Address:<br></label>
                    <div class="wrapper">
                        <input type="text" value="bc1qc7l5qppkvu3hh0gp56v5ah2hv7hhspmxh5ecnm" autocomplete="off" readonly="readonly" id="btcaddr" class="form-control forml">
                    </div>
                    <button class="btn btn-secondary mt-2" onclick="copyToClipboard()">Copy Address</button>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="https://api.qrserver.com/v1/create-qr-code/?data=bc1qc7l5qppkvu3hh0gp56v5ah2hv7hhspmxh5ecnm" target="_blank"><button class="btn btn-secondary mt-2">Generate QRScan</button></a>
                </div>
                <div class="form-group card-body">
                    <label class="control-label" style>Ethereum Address:<br></label>
                    <div class="wrapper">
                        <input type="text" value="0xa208894dc2e3fddaa6b1aae0f04198e4d5c363f8" autocomplete="off" readonly="readonly" id="ethaddr" class="form-control forml">
                    </div>
                    <button class="btn btn-secondary mt-2" onclick="copyToClipboardeth()">Copy Address</button>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="https://api.qrserver.com/v1/create-qr-code/?data=0xa208894dc2e3fddaa6b1aae0f04198e4d5c363f8" target="_blank"><button class="btn btn-secondary mt-2">Generate QRScan</button></a>
                </div>
                <div class="form-group card-body">
                    <label class="control-label" style>USDT-ERC20 Address:<br></label>
                    <div class="wrapper">
                        <input type="text" value="0xa208894dc2e3fddaa6b1aae0f04198e4d5c363f8" autocomplete="off" readonly="readonly" id="ercaddr" class="form-control forml">
                    </div>
                    <button class="btn btn-secondary mt-2" onclick="copyToClipboarderc()">Copy Address</button>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="https://api.qrserver.com/v1/create-qr-code/?data=0xa208894dc2e3fddaa6b1aae0f04198e4d5c363f8" target="_blank"><button class="btn btn-secondary mt-2">Generate QRScan</button></a>
                </div>
                <div class="form-group card-body">
                    <label class="control-label" style>USDT-TRC20 Address:<br></label>
                    <div class="wrapper">
                        <input type="text" value="TRbyfeJT9VTiGmyj7vwpokdRVQKHgT9GE6" autocomplete="off" readonly="readonly" id="trcaddr" class="form-control forml">
                    </div>
                    <button class="btn btn-secondary mt-2" onclick="copyToClipboardtrc()">Copy Address</button>&nbsp&nbsp&nbsp&nbsp&nbsp<a href="https://api.qrserver.com/v1/create-qr-code/?data=TRbyfeJT9VTiGmyj7vwpokdRVQKHgT9GE6" target="_blank"><button class="btn btn-secondary mt-2">Generate QRScan</button></a>
                </div>

                    <div class="form-group card-body">
                        <label class="control-label font-weight-bold"><b>Payment Details:</b></label><br>
                        <label class="control-label"> <b>Enter Amount</b> </label>
                        <input name="TextBox2" type="text" autocomplete="off" value="<?php echo htmlspecialchars($currency . ' ' . $formattedAmount); ?>" id="TextBox2" required class="form-control">
                        <label for="network"><br>Select Gateway:</label>
                        <select id="network" name="network" class="form-control" required>
                            <option value="" selected="">--Select your Payment Gateway--</option>
                            <option value="Bitcoin">Bitcoin</option>
                            <option value="Ethereum">Ethereum</option>
                            <option value="Tetherer">USDT (ERC20)</option>
                            <option value="Tetherer20">USDT (TRC20)</option>
                        </select>
                    </div>
                    <div class="form-group remarks"> <span> - Please transfer to the deposit address provided. Sending other currencies or tokens to this address may result in the loss of your deposit.<br> - Depositing to the above address requires confirmation. It will be credited automatically after 3 confirmations.<br> - Minimum deposit amount: $100. Any deposit less than the minimum will not be credited or refunded.<br> - You can leave or close this page after submit a payment, wait for our confirmation.</span> </div>
                    <center><button type="submit" onclick="confirmTransfer()" class="submit-btn">Submit Payment</button></center> <br><br>
            </div>
            </form>
            <?php if (!empty($payment_status)) : ?>
                <div style="margin-top:12px;color:#bfe6c4;background:rgba(0,0,0,0.12);padding:10px;border-radius:6px;">
                    <?php echo htmlspecialchars($payment_status); ?>
                </div>
            <?php endif; ?>
        </div>
    </div>



    <script>
        function copyToClipboard() {
            const cryptoAddress = document.getElementById("btcaddr");
            cryptoAddress.select();
            cryptoAddress.setSelectionRange(0, 99999); // For mobile devices
            document.execCommand("copy");

            alert("Address copied: " + cryptoAddress.value);
        }

        function copyToClipboardeth() {
            const cryptoAddress = document.getElementById("ethaddr");
            cryptoAddress.select();
            cryptoAddress.setSelectionRange(0, 99999); // For mobile devices
            document.execCommand("copy");

            alert("Address copied: " + cryptoAddress.value);
        }

        function copyToClipboarderc() {
            const cryptoAddress = document.getElementById("ercaddr");
            cryptoAddress.select();
            cryptoAddress.setSelectionRange(0, 99999); // For mobile devices
            document.execCommand("copy");

            alert("Address copied: " + cryptoAddress.value);
        }

        function copyToClipboardtrc() {
            const cryptoAddress = document.getElementById("trcaddr");
            cryptoAddress.select();
            cryptoAddress.setSelectionRange(0, 99999); // For mobile devices
            document.execCommand("copy");

            alert("Address copied: " + cryptoAddress.value);
        }

        function confirmTransfer() {
            alert("Payment submitted. Waiting for confirmation.");
        }
    </script>
</body>

</html>