<!DOCTYPE html>
<html lang="en">
    <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><%- title %></title>

        <!-- CSS only -->
        <link
            rel="stylesheet"
            href="https://stackpath.bootstrapcdn.com/bootstrap/4.4.1/css/bootstrap.min.css"
        />
        <link
            href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.3/dist/css/bootstrap.min.css"
            rel="stylesheet"
            integrity="sha384-1BmE4kWBq78iYhFldvKuhfTAU6auU8tT94WrHftjDbrCEXSU1oBoqyl2QvZ6jIW3"
            crossorigin="anonymous"
        />
        <!-- font-awesome -->
        <link
            rel="stylesheet"
            href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css"
            referrerpolicy="no-referrer"
            integrity="sha512-9usAa10IRO0HhonpyAIVpjrylPvoDwiPUiKdWk5t3PyolY1cOd4DSE0Ga+ri4AuTroPR5aQvXU9xC6qOPnzFeg=="
            crossorigin="anonymous"
        />

        <style>
            /* body {
                padding-top: 70px;
            } */

            .bg {
                height: 100vh;
                width: 100vw;
                background: url("../images/xpecto_tempwall.png");
                /* background: url("https://user-images.githubusercontent.com/56690827/162190335-422b76d8-99a5-4fca-97e9-5a22d3154800.png"); */
                background-color: #171717;
                position: fixed;
                z-index: -1000;
                display: flex;
                justify-content: center;
                align-items: center;
                font-size: 5.5em;
                padding: 0;
            }
        </style>
    </head>
    <body>
        <div class="bg"></div>
        <!-- Navbar -->
        <nav class="navbar navbar-light mb-5" style="background-color: #22527b">
            <div class="container">
                <a class="navbar-brand mx-auto" href="#">
                    <img
                        src="https://user-images.githubusercontent.com/56690827/160768243-76239809-a9da-41f3-a270-ba9bdd205797.svg"
                        alt="logo"
                        class="d-inline-block align-top pull-left"
                    />
                </a>
            </div>
        </nav>

        <div class="row d-flex justify-content-center">
            <div class="col-sm-10 col-md-8 col-lg-5">
                <div class="card">
                    <h5 class="card-header">Confirm Order</h5>

                    <div class="card-body">
                        <p class="card-text">
                            Thank you for taking up this decision.
                        </p>

                        <dl class="row mt-2">
                            <dt class="col-sm-3">Order ID</dt>
                            <dd class="col-sm-9" id="orderId">
                                <%- paymentDetail.orderId %>
                            </dd>

                            <dt class="col-sm-3">Currency</dt>
                            <dd class="col-sm-9">
                                <%- paymentDetail.currency %>
                            </dd>

                            <dt class="col-sm-3">Amount</dt>
                            <dd class="col-sm-9">
                                <%- paymentDetail.amount/100 %> Rs.
                            </dd>
                        </dl>

                        <button
                            type="submit"
                            class="btn btn-primary"
                            onclick="checkout(event)"
                        >
                            Checkout
                        </button>
                    </div>
                </div>
                <form
                    id="paymentVerifyForm"
                    action="/payment/verify"
                    method="POST"
                >
                    <input
                        name="razorpay_payment_id"
                        type="hidden"
                        id="razorpay_payment_id"
                    />
                    <input
                        name="razorpay_order_id"
                        type="hidden"
                        id="razorpay_order_id"
                    />
                    <input
                        name="razorpay_signature"
                        type="hidden"
                        id="razorpay_signature"
                    />
                </form>
            </div>
        </div>

        <script src="https://checkout.razorpay.com/v1/checkout.js"></script>
        <script>
            function checkout(event) {
                const razorpayKeyId = "<%- razorpayKeyId %>";
                const orderId = "<%- paymentDetail.orderId %>";
                const options = {
                    key: razorpayKeyId,
                    currency: "INR",
                    name: "Razor Tutorial",
                    description: "Razor Test Transaction",
                    image: "https://previews.123rf.com/images/subhanbaghirov/subhanbaghirov1605/subhanbaghirov160500087/56875269-vector-light-bulb-icon-with-concept-of-idea-brainstorming-idea-illustration-.jpg",
                    order_id: JSON.parse(JSON.stringify(orderId)),
                    handler: function (response) {
                        document.getElementById("razorpay_payment_id").value =
                            response.razorpay_payment_id;
                        document.getElementById("razorpay_order_id").value =
                            response.razorpay_order_id;
                        document.getElementById("razorpay_signature").value =
                            response.razorpay_signature;
                        document.getElementById("paymentVerifyForm").submit();
                    },
                    modal: {
                        ondismiss: function () {
                            alert(`Payment Failed`);
                        },
                    },
                    theme: {
                        color: "#22527b",
                    },
                };
                const razorpay = new Razorpay(options);
                razorpay.open();
                event.preventDefault();
            }
        </script>
    </body>
</html>
