@extends('layouts.admin') @section('title', __('Invoices')) @section('page-title', __('Invoices')) @section('content')
@if(($mode ?? 'events') !== 'stripe' && !empty($stripeError))
{{ __('Stripe invoice purchase history could not be loaded. Showing stored webhook entries instead.') }}
{{ $stripeError }}
@endif
{{ __('Filter') }} {{ __('Reset') }}
@if(($mode ?? 'events') === 'stripe') @forelse($invoices as $invoice) @php $invoiceId = data_get($invoice, 'id'); $stripeCustomerId = data_get($invoice, 'customer'); $stripeSubscriptionId = data_get($invoice, 'subscription'); $customer = $stripeCustomerId ? ($customersByStripeId[$stripeCustomerId] ?? null) : null; $subscription = $stripeSubscriptionId ? ($subscriptionsByStripeId[$stripeSubscriptionId] ?? null) : null; $amountPaid = data_get($invoice, 'amount_paid'); $amountDue = data_get($invoice, 'amount_due'); $amountTotal = data_get($invoice, 'total'); $currency = strtoupper((string) data_get($invoice, 'currency', '')); $statusText = (string) data_get($invoice, 'status', ''); $createdTs = data_get($invoice, 'created'); $amountCents = $amountPaid ?? $amountDue ?? $amountTotal; $amount = is_numeric($amountCents) ? ((float) $amountCents / 100) : null; @endphp @empty @endforelse @else @forelse($events as $event) @php $invoiceId = data_get($event->payload, 'id'); $stripeCustomerId = data_get($event->payload, 'customer'); $stripeSubscriptionId = data_get($event->payload, 'subscription'); $customer = $stripeCustomerId ? ($customersByStripeId[$stripeCustomerId] ?? null) : null; $subscription = $stripeSubscriptionId ? ($subscriptionsByStripeId[$stripeSubscriptionId] ?? null) : null; $amountPaid = data_get($event->payload, 'amount_paid'); $amountDue = data_get($event->payload, 'amount_due'); $currency = strtoupper((string) data_get($event->payload, 'currency', '')); $statusText = (string) data_get($event->payload, 'status', ''); $amountCents = $amountPaid ?? $amountDue; $amount = is_numeric($amountCents) ? ((float) $amountCents / 100) : null; @endphp @empty @endforelse @endif
{{ __('Invoice') }} {{ __('Customer') }} {{ __('Subscription') }} {{ __('Amount') }} {{ __('Status') }} {{ __('Event') }} {{ __('Processed') }}
@if($invoiceId) {{ $invoiceId }} @else — @endif @if($customer)
{{ $customer->full_name }}
{{ $customer->email }}
@else
@if($stripeCustomerId)
{{ $stripeCustomerId }}
@endif @endif
@if($subscription)
{{ $subscription->plan_name }}
{{ $subscription->stripe_subscription_id }}
@else
@if($stripeSubscriptionId)
{{ $stripeSubscriptionId }}
@endif @endif
@if($amount !== null) {{ $currency ? $currency . ' ' : '' }}{{ number_format($amount, 2) }} @else — @endif @php $badge = match ($statusText) { 'paid' => 'bg-green-100 text-green-800', 'open' => 'bg-yellow-100 text-yellow-800', 'void' => 'bg-gray-100 text-gray-800', 'uncollectible' => 'bg-red-100 text-red-800', 'draft' => 'bg-gray-100 text-gray-800', default => 'bg-gray-100 text-gray-800', }; @endphp {{ $statusText !== '' ? $statusText : '—' }}
{{ __('Stripe') }}
{{ __('API') }}
@if(is_numeric($createdTs)) {{ \Carbon\Carbon::createFromTimestamp((int) $createdTs)->diffForHumans() }} @else — @endif
{{ __('No invoices found.') }}
@if($invoiceId) {{ $invoiceId }} @else — @endif @if($customer)
{{ $customer->full_name }}
{{ $customer->email }}
@else
@if($stripeCustomerId)
{{ $stripeCustomerId }}
@endif @endif
@if($subscription)
{{ $subscription->plan_name }}
{{ $subscription->stripe_subscription_id }}
@else
@if($stripeSubscriptionId)
{{ $stripeSubscriptionId }}
@endif @endif
@if($amount !== null) {{ $currency ? $currency . ' ' : '' }}{{ number_format($amount, 2) }} @else — @endif @php $badge = match ($statusText) { 'paid' => 'bg-green-100 text-green-800', 'open' => 'bg-yellow-100 text-yellow-800', 'void' => 'bg-gray-100 text-gray-800', 'uncollectible' => 'bg-red-100 text-red-800', 'draft' => 'bg-gray-100 text-gray-800', default => 'bg-gray-100 text-gray-800', }; @endphp {{ $statusText !== '' ? $statusText : '—' }}
{{ $event->type }}
{{ $event->event_id }}
{{ $event->processed_at?->diffForHumans() ?? $event->created_at?->diffForHumans() ?? '—' }}
{{ __('No invoices found.') }}
@if(($mode ?? 'events') === 'stripe') @if($stripePagination)
@if(!empty($stripePagination['prev'])) {{ __('Prev') }} @endif
@if(!empty($stripePagination['next'])) {{ __('Next') }} @endif
@endif @else @if($events && $events->hasPages())
{{ $events->links() }}
@endif @endif
@endsection