@extends('front.include.app')
@section('content')

        <section class="account-section bg_img" data-background="{{asset('website/images/account/account-bg.jpg')}}">
            <div class="container">
                <div class="padding-top padding-bottom">
                    <div class="row">
                        <div class="col-md-6 offset-3 col-md-offset-6">
    
                            @if($message = Session::get('error'))
                                <div class="alert alert-danger alert-dismissible fade in" role="alert">
                                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                        <span aria-hidden="true">×</span>
                                    </button>
                                    <strong>Error!</strong> {{ $message }}
                                </div>
                            @endif
    
                            @if($message = Session::get('success'))
                                <div class="alert alert-success alert-dismissible fade {{ Session::has('success') ? 'show' : 'in' }}" role="alert">
                                    <button type="button" class="close" data-dismiss="alert" aria-label="Close">
                                        <span aria-hidden="true">×</span>
                                    </button>
                                    <strong>Success!</strong> {{ $message }}
                                </div>
                            @endif
    
                            <div class="card card-default">
                                <!-- <div class="card-header">
                                    Razorpay Payment
                                </div> -->
                                @php 
                                    $name = "";
                                    $email = "";
                                    if(auth()->check() == true){
                                        $name = auth()->user()->name;
                                        $email = auth()->user()->email;
                                    }else{
                                        if(session()->has('reservation-user')){
                                            $name = session()->get('reservation-user')['name'];
                                            $email = session()->get('reservation-user')['email'];
                                        }
                                    }

                                @endphp
                                <div class="card-body text-center">
                                    <form id="prepay" action="{{ route('razorpay-payment.store') }}" method="POST" >
                                        @csrf
                                        <script src="https://checkout.razorpay.com/v1/checkout.js"
                                                data-key="{{ Config::get('razorpay.razor_key') }}"
                                                data-amount="{{(round((int)(session()->get('reservation')['bookin-ticket-payable-amount'])) * 100)}}"
                                                data-buttontext="Pay {{round((int)session()->get('reservation')['bookin-ticket-payable-amount'])}} INR"
                                                data-name="{{ config('app.name', 'Laravel') }}"
                                                data-description="Online ticket booking"
                                                data-image="{{asset('website/images/logo/tc-logo.png')}}"
                                                data-prefill.name="{{ $name }}"
                                                data-prefill.email="{{ $email }}"
                                                data-theme.color="#ff7529">
                                        </script>
                                    </form>
                                </div>
                            </div>
    
                        </div>
                    </div>
                </div>
            </div>
        </section>
@endsection
@section('script')
@if(Session::has('error') || Session::has('success'))
@else
<script>
    $("#prepay").submit();
</script>
@endif
@endsection