<?php $__env->startSection('content'); ?>
<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-md-8">

            <div class="card shadow-sm border-0 rounded-3">
                <div class="card-header bg-white border-bottom">
                    <h4 class="fw-bold mb-0">🧾 Checkout Order #<?php echo e($order['uoid']); ?></h4>
                </div>

                <div class="card-body">
  
                    <?php if(!empty($order['final_image_path'])): ?>
                        <div class="text-center mb-4">
                            <img src="<?php echo e(asset($order['final_image_path'])); ?>" alt="Preview Gambar" class="img-fluid rounded"
                                style="max-width: 100%; max-height: 300px;">
                        </div>
                    <?php endif; ?>

                    <div class="mb-3">
                        <p class="mb-1"><strong>Nama:</strong> <?php echo e($order['nama']); ?></p>
                        <p class="mb-1"><strong>Alamat:</strong> <?php echo e($order['address']); ?></p>
                        <p class="mb-1"><strong>Kurir:</strong> <?php echo e($order['kurir']); ?> - <?php echo e($order['jenispengiriman']); ?></p>
                    </div>

                    <table class="table table-bordered">
                        <tbody>
                            <tr>
                                <th scope="row">Subtotal</th>
                                <td>Rp <?php echo e(number_format($order['sub_total'], 0, ',', '.')); ?></td>
                            </tr>
                            <tr>
                                <th scope="row">Ongkir</th>
                                <td>Rp <?php echo e(number_format($order['ongkir'], 0, ',', '.')); ?></td>
                            </tr>
                            <tr class="table-light">
                                <th scope="row" class="fs-5 text-dark">Total</th>
                                <td class="fs-5 fw-bold text-dark">Rp <?php echo e(number_format($order['total'], 0, ',', '.')); ?></td>
                            </tr>
                        </tbody>
                    </table>

                    <div class="d-grid mt-4">
                        <button id="pay-button" class="btn btn-success btn-lg fw-bold">
                            <i class="bi bi-wallet2 me-1"></i> Bayar Sekarang
                        </button>
                    </div>
                </div>
            </div>

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

<!-- Midtrans Script -->
<script type="text/javascript" src="https://app.midtrans.com/snap/snap.js"
    data-client-key="<?php echo e(env('MIDTRANS_CLIENT_KEY')); ?>"></script>
<script type="text/javascript">
    document.getElementById('pay-button').addEventListener('click', function() {
        snap.pay('<?php echo e($snapToken); ?>', {
            onSuccess: function(result) {
                alert("✅ Pembayaran berhasil!");
                window.location.href = '/success'; // Ganti jika perlu
            },
            onPending: function(result) {
                alert("⏳ Menunggu pembayaran...");
            },
            onError: function(result) {
                alert("❌ Pembayaran gagal.");
            },
            onClose: function() {
                alert("🚫 Pembayaran dibatalkan.");
            }
        });
    });
</script>
<?php $__env->stopSection(); ?>

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