

<?php $__env->startSection('hide_nav_bar', true); ?>

<?php $__env->startSection('content'); ?>
<main class="main-content">
    
    
    <header class="header mobile-header">
        <div class="user-greeting">
            <a href="<?php echo e(route('invoices.index')); ?>"><i class="fas fa-arrow-left"></i></a>
            <h3>
                <?php if($invoice->status == 'unpaid'): ?>
                    Detail Tagihan
                <?php else: ?>
                    Resi Pembayaran
                <?php endif; ?>
            </h3>
        </div>
    </header>

    
    <?php if($invoice->status == 'unpaid'): ?>
        
        
        
        <?php echo $__env->make('invoices._payment_form', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

    <?php else: ?>

        
        
        <?php echo $__env->make('invoices._receipt_view', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

    <?php endif; ?>

</main>


<?php if($invoice->status == 'unpaid'): ?>
    <?php $__env->startPush('scripts'); ?>
    
    <script src="https://app.sandbox.midtrans.com/snap/snap.js" data-client-key="<?php echo e(config('midtrans.client_key')); ?>"></script>
    
    <script type="text/javascript">
      document.getElementById('pay-button').addEventListener('click', function () {
        window.snap.pay('<?php echo e($snapToken); ?>', {
          onSuccess: function(result){
            // Sesuai alur Anda: Langsung refresh halaman ini untuk lihat resi
            window.location.href = '<?php echo e(route('invoices.show', $invoice->id)); ?>';
          },
          onPending: function(result){
            alert("Menunggu pembayaran Anda!");
          },
          onError: function(result){
            alert("Pembayaran gagal!");
          },
          onClose: function(){
            // Reset token jika pop-up ditutup
            window.location.href = '<?php echo e(route('invoices.show', ['invoice' => $invoice->id, 'reset' => 'true'])); ?>';
          }
        });
      });
    </script>
    <?php $__env->stopPush(); ?>
<?php endif; ?>

<?php $__env->stopSection(); ?>
<?php echo $__env->make('layouts.app', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\Users\UsEr\Documents\0 Mata Kuliah\Tugas Akhir\Project Pamsimas\PAMSIMAS_User\resources\views/invoices/show.blade.php ENDPATH**/ ?>