<?php $__env->startSection('title', 'Cart Page'); ?>
<?php $__env->startSection('content'); ?>
<section class="inner-banner">
    <img src="<?php echo e(asset('front/images/mainBanner.webp')); ?>" alt="image" class="img-fluid w-100 h-100">
    <div class="container">
        <div class="inner-banner__content">
            <h1>checkout</h1>
        </div>
    </div>
</section>

<section class="check-out-section chkot-pag">
    <div class="container">
        <div class="check-out-form">
            <h2 class="primary-heading">Billing Address</h2>
            <p>
                Fill the form below to complete your purchase
            </p>
            <p class="checkout-subheading">
                <a href="">Already Registered?</a> Click here to <a href="" class="text-uppercase">Login
                    now</a>
            </p>
            <form action="<?php echo e(route('checkout.order')); ?>" method="post">
                <?php echo csrf_field(); ?>
                <div class="row">
                    <div class="col-md-6">
                        <label for="">first NamE</label>
                        <input type="text" class="form-control" name="first_name"
                            value="<?php echo e(old('first_name') ?? ''); ?>" required>
                        <?php $__errorArgs = ['first_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <span class="text-danger"><?php echo e($message); ?></span>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                    <div class="col-md-6">
                        <label for="">Last NamE</label>
                        <input type="text" class="form-control" name="last_name" value="<?php echo e(old('last_name') ?? ''); ?>"
                            required>
                        <?php $__errorArgs = ['last_name'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <span class="text-danger"><?php echo e($message); ?></span>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                    <div class="col-md-6">
                        <label for="">email address</label>
                        <input type="email" class="form-control" name="email" value="<?php echo e(old('email') ?? ''); ?>"
                            required>
                        <?php $__errorArgs = ['email'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <span class="text-danger"><?php echo e($message); ?></span>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                    <div class="col-md-6">
                        <label for="">Phone</label>
                        <input type="text" class="form-control" name="phone_number"
                            value="<?php echo e(old('phone_number') ?? ''); ?>" pattern="\d{10}" maxlength="10" required
                            title="Please enter a valid 10-digit phone number.">
                        <?php $__errorArgs = ['phone_number'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <span class="text-danger"><?php echo e($message); ?></span>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                    <div class="col-md-12">
                        <label for="">address</label>
                        <input name="address" class="form-control"
                            value="<?php echo e(old('address') ?? ''); ?>">
                        <?php $__errorArgs = ['address'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <span class="text-danger"><?php echo e($message); ?></span>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                    <div class="col-md-12">
                        <label for="">Country</label>
                        <select name="country" class="form-control">
                            <option value="US">United States</option>
                        </select>
                        <?php $__errorArgs = ['country'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <span class="text-danger"><?php echo e($message); ?></span>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                    <div class="col-md-12">
                        <label for="">city</label>

                        <input type="text" class="form-control" name="city" required
                            value="<?php echo e(old('city') ?? ''); ?>">
                        <?php $__errorArgs = ['city'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <span class="text-danger"><?php echo e($message); ?></span>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                    <div class="col-md-6">
                        <label for="">ZIP/POSTAL CODE</label>
                        <input type="text" class="form-control" name="postal_code"
                            value="<?php echo e(old('postal_code') ?? ''); ?>" required>
                        <?php $__errorArgs = ['postal_code'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <span class="text-danger"><?php echo e($message); ?></span>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                    <div class="col-md-6">
                        <label for="">sTATE/pROVINCE</label>
                        <select name="state" id="country-select" class="form-control">
                            <?php $__empty_1 = true; $__currentLoopData = $get_states; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $state): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                            <option value="<?php echo e($state->code); ?>"
                                <?php echo e(isset($get_info['country']) && $get_info['country'] == $state->id ? 'selected' : ''); ?>>
                                <?php echo e($state->name); ?>

                            </option>
                            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                            <option>States Not Found</option>
                            <?php endif; ?>
                        </select>
                        <?php $__errorArgs = ['state'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                        <span class="text-danger"><?php echo e($message); ?></span>
                        <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                    </div>
                    <div class="col-md-12 checkbox">
                        <input type="checkbox" id="box-1">
                        <label for="box-1">Create an account for later use</label>
                    </div>
                    <div class="col-md-12 checkbox">
                        <input type="checkbox" id="box-2">
                        <label for="box-2">Ship to the same address mentioned above </label>
                    </div>
                </div>

                <hr>

                <div class="order-summery">

                    <h2 class="primary-heading text-center">Order Summary</h2>
                    <div class="row bb-1">
                        <div class="col-md-6">
                            <span>Subtotal (3 items)</span>
                        </div>
                        <div class="col-md-6 text-right">
                            USD <?php echo e(number_format($totalAmount, 2.0)); ?>

                        </div>
                    </div>
                    <div class="row bb-1">
                        <div class="col-md-6">
                            <span>Shipping fee</span>
                        </div>
                        <div class="col-md-6 text-right">
                            USD 12.00
                        </div>
                    </div>

                    <div class="row bb-1">
                        <div class="col-md-6">
                            <span>Total</span>
                        </div>
                        <div class="col-md-6 text-right">
                            USD <?php echo e(12 + number_format($totalAmount, 2.0)); ?>

                        </div>
                    </div>
                    <div class="col-md-12 mt-4 p-0">
                        <button class="btn d-btn w-100" type="submit">proceed to
                            checkout</button>

                    </div>

                </div>
            </form>
        </div>
    </div>
</section>


<?php $__env->stopSection(); ?>

<?php $__env->startSection('script'); ?>

<script type="text/javascript">
    $(function() {

        /*------------------------------------------
        --------------------------------------------
        Stripe Payment Code
        --------------------------------------------
        --------------------------------------------*/
        var $form = $(this);

        $('#payment-form').on('submit', function(e) {
            e.preventDefault();


            let cardNumber = $('.card-number').val();
            let cardCVC = $('.card-cvc').val();
            let cardExpMonth = $('.card-expiry-month').val();
            let cardExpYear = $('.card-expiry-year').val();




            var $form = $(this);
            var $errorMessage = $form.find('div.error');
            $errorMessage.addClass('hide');

            $('.has-error').removeClass('has-error');

            if (cardNumber === '' || cardCVC === '' || cardExpMonth === '' || cardExpYear === '') {
                return;
            }
            var $form = $(this),
                $errorMessage = $form.find('div.error'),
                valid = true;
            $errorMessage.addClass('hide');

            $('.has-error').removeClass('has-error');

            if (!$form.data('cc-on-file')) {
                e.preventDefault();

                let stripePublishableKey = $form.data('stripe-publishable-key');
                console.log('stripePublishableKey', stripePublishableKey);

                Stripe.setPublishableKey(stripePublishableKey);
                Stripe.card.createToken({
                    number: cardNumber,
                    cvc: cardCVC,
                    exp_month: cardExpMonth,
                    exp_year: cardExpYear,
                }, function(status, response) {
                    console.log('Tokenization response:', response);


                    if (response.error) {
                        console.log('Error', response);

                        $('.error')
                            .removeClass('hide')
                            .removeAttr('style')
                            .find('.alert')
                            .text(response.error.message);
                    } else {
                        console.log(response);


                        $form.append("<input type='hidden' name='payment_method_id' value='" +
                            response.id + "'/>");

                        $form.get(0).submit();


                    }
                });
            }


        });
    });
</script>
<?php $__env->stopSection(); ?>
<?php echo $__env->make('front.layout.app', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/servicedemoweb/public_html/luxury-candles/resources/views/front/checkout.blade.php ENDPATH**/ ?>