{{-- Filter & Actions Panel --}}

{{ __('Payments') }}

{{ __('Track payments, refunds, and transaction history.') }}

{{ __('Download Template') }}
{{ __('Reset') }}
{{-- Payments Table Panel --}}

{{ __('Payment Directory') }}

{{ __('Showing') }} {{ $payments->firstItem() ?? 0 }}-{{ $payments->lastItem() ?? 0 }} {{ __('of') }} {{ $payments->total() }} {{ __('transactions.') }}

{{ __('Export') }}
{{-- List View --}}
@forelse($payments as $payment) {{-- Approve confirmation modal — separate from refund modal --}} @if($payment->status === 'pending' && in_array($payment->gateway_slug, ['bank_transfer', 'offline'], true))
@csrf

{{ __('Approve payment') }} #{{ $payment->id }}?

{{ __('Confirm you have received') }} {{ \App\Helpers\CurrencyHelper::formatWith((float) $payment->amount, $payment->currency) }} {{ __('via') }} {{ str_replace('_', ' ', $payment->gateway_slug) }} {{ __('from') }} {{ $payment->workspace?->name ?? __('this customer') }}.

{{ __("This will mark the payment as Succeeded, activate the customer's subscription, generate the invoice, and write an audit log entry.") }}

@endif {{-- Refund confirmation modal --}} @if($payment->status === 'succeeded' && !$payment->refund_amount)
@csrf

{{ __('Refund') }} {{ \App\Helpers\CurrencyHelper::formatWith((float) $payment->amount, $payment->currency) }}?

{{ __('This will issue a') }} {{ __('full refund') }} {{ __('of') }} {{ \App\Helpers\CurrencyHelper::formatWith((float) $payment->amount, $payment->currency) }} {{ __('to') }} {{ $payment->workspace?->name ?? __('this customer') }}. {{ __('This action cannot be undone.') }}

@endif @empty @endforelse
{{ __('Invoice') }} {{ __('User') }} {{ __('Amount') }} {{ __('Status') }} {{ __('Date') }} {{ __('Actions') }}
{{-- Show the invoice number as primary identifier (what's printed on the customer's PDF) — falls back to gateway transaction id when no invoice has been generated yet (e.g. legacy payments from before invoicing shipped). --}} @if($payment->invoice_number) {{ $payment->invoice_number }} @else {{ $payment->stripe_payment_id ?? $payment->gateway_transaction_id ?? '#' . $payment->id }} @endif {{ $payment->workspace?->name ?? __('N/A') }} {{ \App\Helpers\CurrencyHelper::formatWith((float) $payment->amount, $payment->currency) }} {{ ucfirst($payment->status) }} {{ $payment->created_at->format('M j, Y') }}
{{-- Invoice actions — succeeded payments get a View (iframe modal preview, no new tab) + Download. InvoiceController allows admins through unconditionally so admin can pull any customer's invoice for support. --}} @if($payment->status === 'succeeded') {{-- Open the themed HTML preview in a new tab so the user keeps the payments list open behind it. The preview page has its own Download / Print / Close buttons in the top action bar. --}} {{ __('View') }} {{ __('PDF') }} @endif @if($payment->status === 'succeeded' && !$payment->refund_amount) @endif {{-- Manual Approve — only for Bank Transfer / Offline pending rows. Online gateways must NOT show this because their state belongs to the gateway's webhook flow; flipping their status here would skip the gateway's idempotency guarantees and risk double-activating a subscription. --}} @if($payment->status === 'pending' && in_array($payment->gateway_slug, ['bank_transfer', 'offline'], true)) @endif
{{ __('No payments found.') }}
{{-- Grid View --}}
@forelse($payments as $payment)
{{ $payment->workspace?->name ?? __('N/A') }} {{ \App\Helpers\CurrencyHelper::formatWith((float) $payment->amount, $payment->currency) }}
{{ ucfirst($payment->status) }} {{ $payment->created_at->format('M j, Y') }}
@if($payment->invoice_number) {{ $payment->invoice_number }} @else {{ $payment->stripe_payment_id ?? $payment->gateway_transaction_id ?? '#' . $payment->id }} @endif @if($payment->status === 'succeeded')
{{ __('View') }} {{ __('PDF') }} @if(!$payment->refund_amount) @endif
@endif {{-- Grid-view Approve button — parity with the table view so admins switching between Table/Grid don't lose the action. Same gating: pending + manual gateway only. --}} @if($payment->status === 'pending' && in_array($payment->gateway_slug, ['bank_transfer', 'offline'], true))
@endif
@empty
{{ __('No payments found.') }}
@endforelse
@if($payments->hasPages())
{{ $payments->withQueryString()->links() }}
@endif
{{-- Import Modal --}}
@csrf

{{ __('Import Payments') }}

{{ __('Upload a CSV file that matches the provided template.') }}