<html>

<head>

    <script src="{{ Config::get('omnipay.bob.data')['script_api'] }}" data-error="errorCallback"
        data-cancel="cancelCallback" data-complete="completeCallback">
    </script>
    <script type="text/javascript">
        function errorCallback(error) {
            console.log(JSON.stringify(error));
        }
        function cancelCallback() {
            window.location= '{{ env('APP_URL') }}';
        }
        function completeCallback() {
            window.location = '{{ env('APP_URL') }}/omnipay/response/success/{{ $order_id }}/';
        }
        Checkout.configure({
            session: {
                id: "{{ $session_id  }}"
            },
            merchant: '{{ $merchant }}',
            order: {
                amount: '{{  $amount  }}',
                currency: '{{  $currency }}',
                description: '{{ $description }}',
                id: '{{  $order_id  }}',
                reference: '{{  $order_id  }}'
            },
            transaction:{
                reference: '{{  $order_id  }}'
            },
            interaction: {
                merchant: {
                    name: 'Samer Khouzami',
                    address: {
                        line1: 'test',
                        line2: 'test line 2'
                    },
                },
                displayControl: {
                    billingAddress: 'HIDE',
                    customerEmail: 'HIDE',
                    shipping: 'HIDE'
                }
            }
        });
    </script>
</head>

<body>
    <?php
if($amount == ''){
    echo '<h1>An error occured</h1>';
    exit();
}
?>
    <!DOCTYPE html>
    <html lang="en">

    <head>
        <title>Samer Khouzami</title>
    </head>

    <body>
        <div class="SizeHandler">
            redirecting, please be patient
            <?php if(isset($_SERVER['HTTP_REFERER']) && str_contains($_SERVER['HTTP_REFERER'],env('APP_URL'))){  ?>
            <script language="javascript">
                Checkout.showPaymentPage()
            </script>
            <?php } ?>
        </div>
    </body>

    </html>
