

<?php $__env->startSection('title', 'Checkout'); ?>

<?php $__env->startSection('content'); ?>
<div class="page-header">
    <div>
        <h4 class="page-title">Checkout</h4>
        <p class="text-muted mb-0">Complete your subscription purchase</p>
    </div>
    <a href="<?php echo e(route('seller.subscription.index')); ?>" class="btn btn-light border shadow-sm">
        <i class="bi bi-arrow-left me-1"></i> Back to Plans
    </a>
</div>

<div class="alert alert-warning border-0 shadow-sm mb-4">
    <div class="d-flex align-items-center">
        <i class="bi bi-exclamation-triangle-fill fs-4 me-3 text-warning"></i>
        <div>
            <h6 class="fw-bold mb-1">Important Note</h6>
            <p class="mb-0 small">Once the subscription plan is purchased, it cannot be cancelled or refunded. Thank you for understanding.</p>
        </div>
    </div>
</div>

<div class="row justify-content-center">
    <div class="col-lg-6 col-md-8">
        <div class="card border-0 shadow-lg rounded-4 overflow-hidden">
            <div class="card-header bg-primary text-white py-4 text-center">
                <h5 class="mb-1 fw-bold text-white">Order Summary</h5>
                <p class="mb-0 opacity-75 small">Review your plan details before payment</p>
            </div>
            <div class="card-body p-5">
                <div class="d-flex justify-content-between align-items-center mb-4 pb-4 border-bottom border-dashed">
                    <div>
                        <h4 class="fw-bold mb-1 text-dark"><?php echo e($plan->name); ?> Plan</h4>
                        <span class="badge bg-info bg-opacity-10 text-info border border-info px-3 py-2 rounded-pill">
                            <i class="bi bi-clock me-1"></i> <?php echo e($plan->duration_days); ?> Days Validity
                        </span>
                    </div>
                    <div class="text-end">
                        <?php if(isset($gstAmount) && $gstAmount > 0): ?>
                             <small class="text-muted d-block mb-1">Base: <?php echo e($currency == 'INR' ? '₹' : '$'); ?><?php echo e(number_format($amount, 2)); ?></small>
                             <small class="text-muted d-block mb-1">GST (18%): <?php echo e($currency == 'INR' ? '₹' : '$'); ?><?php echo e(number_format($gstAmount, 2)); ?></small>
                        <?php endif; ?>
                        <small class="text-muted d-block mb-1">Total Amount</small>
                        <h2 class="text-primary fw-bold mb-0">
                            <?php echo e($currency == 'INR' ? '₹' : '$'); ?><?php echo e(number_format($totalAmount, 2)); ?>

                        </h2>
                    </div>
                </div>

                <h6 class="fw-bold mb-4 text-uppercase text-muted small letter-spacing-1">Select Payment Method</h6>

                <div class="d-grid gap-3">
                    <?php if($gateways['razorpay'] && $currency == 'INR'): ?>
                        <!-- Razorpay Button -->
                        <?php if(isset($razorpayOrder) && isset($razorpayOrder['id'])): ?>
                            <button id="rzp-button1" class="btn btn-primary-gradient py-3 fw-bold shadow-sm">
                                <i class="bi bi-credit-card-2-front me-2"></i> Pay with Razorpay
                            </button>
                            <form action="<?php echo e(route('seller.subscription.success')); ?>" method="POST" id="razorpay-form">
                                <?php echo csrf_field(); ?>
                                <input type="hidden" name="plan_id" value="<?php echo e($plan->id); ?>">
                                <input type="hidden" name="payment_method" value="razorpay">
                                <input type="hidden" name="payment_id" id="razorpay_payment_id">
                                <input type="hidden" name="transaction_id" value="<?php echo e($transaction->id); ?>">
                            </form>
                            <?php if(isset($razorpayOrder['key'])): ?>
                                <script src="https://checkout.razorpay.com/v1/checkout.js"></script>
                                <script>
                                    var options = {
                                        "key": "<?php echo e($razorpayOrder['key']); ?>",
                                        "amount": "<?php echo e($razorpayOrder['amount']); ?>",
                                        "currency": "INR",
                                        "name": "The Mini Port",
                                        "description": "<?php echo e($plan->name); ?> Subscription",
                                        "order_id": "<?php echo e($razorpayOrder['order_id']); ?>",
                                        "handler": function (response){
                                            document.getElementById('razorpay_payment_id').value = response.razorpay_payment_id;
                                            document.getElementById('razorpay-form').submit();
                                        },
                                        "prefill": {
                                            "name": "<?php echo e(auth()->user()->name); ?>",
                                            "email": "<?php echo e(auth()->user()->email); ?>",
                                            "contact": ""
                                        },
                                        "theme": {
                                            "color": "#0d6efd"
                                        }
                                    };
                                    var rzp1 = new Razorpay(options);
                                    document.getElementById('rzp-button1').onclick = function(e){
                                        rzp1.open();
                                        e.preventDefault();
                                    }
                                </script>
                            <?php endif; ?>
                        <?php else: ?>
                            <div class="alert alert-danger mb-0">
                                <small><i class="bi bi-exclamation-circle me-1"></i> Razorpay initialization failed. Please check credentials.</small>
                            </div>
                        <?php endif; ?>
                    <?php endif; ?>

                    <?php if($gateways['paypal'] && $currency == 'USD'): ?>
                        <!-- PayPal Button -->
                        <form action="<?php echo e(route('seller.subscription.paypal.initiate')); ?>" method="POST">
                            <?php echo csrf_field(); ?>
                            <input type="hidden" name="plan_id" value="<?php echo e($plan->id); ?>">
                            <button type="submit" class="btn btn-warning w-100 py-3 fw-bold shadow-sm text-dark">
                                <i class="bi bi-paypal me-2"></i> Pay with PayPal (USD $<?php echo e(number_format($plan->price_usd, 2)); ?>)
                            </button>
                        </form>
                    <?php endif; ?>

                    <?php if($gateways['manual']): ?>
                        <!-- Manual Payment -->
                        <button class="btn btn-outline-secondary w-100 py-3 fw-bold" type="button" data-bs-toggle="collapse" data-bs-target="#manualPaymentDetails">
                            <i class="bi bi-bank me-2"></i> Manual Payment / Bank Transfer
                        </button>
                        <div class="collapse" id="manualPaymentDetails">
                            <div class="card card-body bg-light border-0 rounded-3 mt-2">
                                <h6 class="fw-bold mb-2">Bank Details:</h6>
                                <p class="mb-3 small text-muted" style="white-space: pre-line;"><?php echo e(\App\Models\Setting::getValue('manual_payment_instructions')); ?></p>
                                
                                <form action="<?php echo e(route('seller.subscription.success')); ?>" method="POST">
                                    <?php echo csrf_field(); ?>
                                    <input type="hidden" name="plan_id" value="<?php echo e($plan->id); ?>">
                                    <input type="hidden" name="payment_method" value="manual">
                                    <input type="hidden" name="transaction_id" value="<?php echo e($transaction->id); ?>">
                                    
                                    <div class="mb-3">
                                        <label class="form-label small fw-bold">Transaction ID / Reference No.</label>
                                        <input type="text" name="payment_id" class="form-control" required placeholder="Enter bank reference number">
                                    </div>
                                    
                                    <button type="submit" class="btn btn-success w-100 fw-bold">
                                        Submit for Approval
                                    </button>
                                </form>
                            </div>
                        </div>
                    <?php endif; ?>

                    <!-- TEST / DEMO PAYMENT (Visible for testing) -->
                    <?php if(\App\Models\Setting::getValue('demo_mode_enabled', false)): ?>
                        <div class="border-top pt-3 mt-3">
                            <div class="d-flex align-items-center mb-3">
                                <span class="badge bg-dark me-2">DEMO MODE</span>
                                <small class="text-muted">Use this to simulate payment if gateways are not configured.</small>
                            </div>
                            <form action="<?php echo e(route('seller.subscription.mock')); ?>" method="POST">
                                <?php echo csrf_field(); ?>
                                <input type="hidden" name="plan_id" value="<?php echo e($plan->id); ?>">
                                <input type="hidden" name="currency" value="<?php echo e($currency); ?>">
                                <button type="submit" class="btn btn-outline-dark w-100 py-2 fw-bold shadow-sm dashed-border">
                                    <i class="bi bi-magic me-2"></i> Simulate Successful Payment
                                </button>
                            </form>
                        </div>
                    <?php endif; ?>
                </div>
                
                <div class="text-center mt-4">
                    <small class="text-muted"><i class="bi bi-lock-fill me-1"></i> Secure Payment Processing</small>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
    .letter-spacing-1 { letter-spacing: 1px; }
</style>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.seller', \Illuminate\Support\Arr::except(get_defined_vars(), ['__data', '__path']))->render(); ?><?php /**PATH /home/u281583269/domains/theminiport.com/public_html/resources/views/seller/subscription/checkout.blade.php ENDPATH**/ ?>