<html>
<head>
    @if(\Illuminate\Support\Facades\Cache::store('file')->get('custom_url_'.$id) !=null)
        @php

            $custom_url=\Illuminate\Support\Facades\Cache::store('file')->get('custom_url_'.$id);
        @endphp
    @endif
    <script src="https://epayment.areeba.com/static/checkout/checkout.min.js"
            data-error="errorCallback"
            data-cancel="cancelCallback"
            data-complete="@if(isset($custom_url)) {{$custom_url}} @else {{ env('APP_URL') }}/omnipay/response/success/{{ $id }} @endif "></script>
    <script type="text/javascript">
        function errorCallback(error) {
            console.log(JSON.stringify(error));
        }
        function cancelCallback() {
            window.location= '{{ env('APP_URL') }}';
        }
        function completeCallback() {
            window.location = '@if(isset($custom_url)) {{$custom_url}} @else {{ env('APP_URL') }}/omnipay/response/success/{{ $id }}/ @endif';
        }



        Checkout.configure({
            session: {
                id: "{{ $session }}"
            }
        });


    </script>
</head>
<body>

<?php

if($amount == ''){
    echo '<h1>An error occured</h1>';
    exit();
}


?>

<!DOCTYPE html>
<html lang="en">
<head>
    <title>Redirecting to the payment gateway</title>
</head>
<body>
<div class="SizeHandler">
    redirecting, please be patient

</div>


</body>
</html>
<pre>
</pre>
@if(\Illuminate\Support\Facades\Cache::store('file')->get($id) == 1)
    @php \Illuminate\Support\Facades\Cache::store('file')->delete($id); @endphp
    <script language="javascript">Checkout.showPaymentPage()</script>
@else

        <?php
        if(isset($_SERVER['HTTP_REFERER'])){
            $referer = str_replace('//www.', '//', $_SERVER['HTTP_REFERER']);
        }else{
            $referer = false;
        }
    if(($referer && str_contains($referer,env('APP_URL'))) || request()->input('proceed')){ ?>
    <script language="javascript">Checkout.showPaymentPage()</script>
    <?php }else{ ?>
    <button class="btn" onclick="Checkout.showPaymentPage()">Proceed</button>
<?php

    \Illuminate\Support\Facades\Cache::store('file')->delete('custom_url_'.$id);
    } ?>

@endif



