<?php $__env->startSection('title', 'Transaction #'.$transaction->id); ?>

<?php $__env->startSection('content'); ?>
<div class="admin-top">
    <div>
        <h1>Transaction #<?php echo e($transaction->id); ?></h1>
        <p class="sub"><?php echo e($transaction->gateway); ?> · <?php echo e($transaction->status); ?></p>
    </div>
    <a href="<?php echo e(route('admin.transactions.index')); ?>" class="btn btn-ghost">Back</a>
</div>

<div class="card">
    <p><strong>User:</strong> <?php echo e($transaction->user?->email ?? 'Guest'); ?></p>
    <p><strong>Provider ID:</strong> <?php echo e($transaction->transaction_id ?? '—'); ?></p>
    <p><strong>Amount:</strong> <?php echo e($transaction->currency); ?> <?php echo e(number_format($transaction->amount, 2)); ?></p>
    <p><strong>Payment method:</strong> <?php echo e($transaction->payment_method ?? '—'); ?></p>
    <p><strong>Created:</strong> <?php echo e($transaction->created_at); ?></p>
</div>

<?php if($transaction->response_json): ?>
    <div class="card">
        <h2 style="font-size:1rem; margin-top:0;">API response</h2>
        <pre style="overflow:auto; max-height:320px; font-size:0.78rem; background:#0c0a08; padding:1rem; border-radius:10px; border:1px solid var(--admin-border);"><?php echo e(json_encode($transaction->response_json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES)); ?></pre>
    </div>
<?php endif; ?>

<?php if($transaction->refunds->isNotEmpty()): ?>
    <div class="card">
        <h2 style="font-size:1rem; margin-top:0;">Refunds</h2>
        <table class="admin-table">
            <thead><tr><th>Refund ID</th><th>Amount</th><th>Status</th></tr></thead>
            <tbody>
                <?php $__currentLoopData = $transaction->refunds; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $r): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); ?>
                    <tr>
                        <td><?php echo e($r->refund_id); ?></td>
                        <td><?php echo e(number_format($r->amount, 2)); ?></td>
                        <td><?php echo e($r->status); ?></td>
                    </tr>
                <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); ?>
            </tbody>
        </table>
    </div>
<?php endif; ?>

<?php if(auth()->user()->can('refund', $transaction)): ?>
    <div class="card">
        <h2 style="font-size:1rem; margin-top:0;">Refund (Stripe)</h2>
        <form method="POST" action="<?php echo e(route('admin.transactions.refund', $transaction)); ?>">
            <?php echo csrf_field(); ?>
            <div class="form-row">
                <label>Partial amount (leave empty for full)</label>
                <input type="number" step="0.01" name="amount" max="<?php echo e($transaction->amount); ?>" placeholder="<?php echo e($transaction->amount); ?>">
            </div>
            <button type="submit" class="btn btn-danger" onclick="return confirm('Refund this payment?');">Refund</button>
        </form>
    </div>
<?php endif; ?>

<div class="card">
    <h2 style="font-size:1rem; margin-top:0;">Recent gateway logs</h2>
    <table class="admin-table">
        <thead><tr><th>Type</th><th>When</th><th>Preview</th></tr></thead>
        <tbody>
            <?php $__empty_1 = true; $__currentLoopData = $logs; $__env->addLoop($__currentLoopData); foreach($__currentLoopData as $log): $__env->incrementLoopIndices(); $loop = $__env->getLastLoop(); $__empty_1 = false; ?>
                <tr>
                    <td><?php echo e($log->log_type); ?></td>
                    <td><?php echo e($log->created_at?->format('Y-m-d H:i:s')); ?></td>
                    <td style="max-width:420px; overflow:hidden; text-overflow:ellipsis;"><?php echo e(\Illuminate\Support\Str::limit($log->payload, 120)); ?></td>
                </tr>
            <?php endforeach; $__env->popLoop(); $loop = $__env->getLastLoop(); if ($__empty_1): ?>
                <tr><td colspan="3">No logs.</td></tr>
            <?php endif; ?>
        </tbody>
    </table>
</div>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.admin', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH C:\projects\honey b\backend\resources\views\admin\transactions\show.blade.php ENDPATH**/ ?>