<!doctype html>
<html lang="en">
    <head>
        {block name='head'}
            {include file='_partials/head.tpl'}
        {/block}
        <link rel="canonical" href="/dashboard/authorization/">
    </head>
<body>

    <div class="form-container">
        <div id="payment-form">
            <div class="form-header">
                <h1 class="Header-companyName">{$site_title}</h1>
                <h2 class="Header-purchaseDescription">{$order.paperTypeTitle}</h2>
            </div>
            <div class="form-body">
                <div class="alert alert-info">
                    On a successful payment your order status will change to <b>"Looking For Writer"</b> in about a minute.
                </div>
                <button id="pay_btn" class="pay_btn" type="submit">Pay {$price_formatted}</button>
                <a class="back_to_order" href="/dashboard/order/{$order.id}">Back to Order</a>
            </div>
        </div> 
    </div>

    <script>window.jQuery || document.write('<script src="/static/common/libs/jquery/3.2.1/jquery.min.js"><\/script>')</script>

    <script src="https://js.dooglepay.com"></script>

    {block name='javascript_bottom'}
        {include file="_partials/javascript.tpl" javascript=$javascript.bottom}
    {/block}
    
    {block name="js"}
        <script type="text/javascript">
            const pay_btn = document.getElementById("pay_btn");
            pay_btn.onclick = function() {
                const payment = dooglepay({
                    key: "{$dooglepay_api_key}",
                    amount: {$price*100},
                    currency: "{$currency}",
                    methods: ["card"],
                    reference: '{$order.id}',
                    webhook: "{$dooglepay_hook}",
                    onCharge(transactionId) {
                        window.location = '{$successfulurlredirect}';
                    },
                    onError(e) {
                    },
                    onCancel() {
                        window.location = '{$redirectUri}';
                    }
                });
            };
        </script>
    {/block}

</body>
</html>