Billing overview
What a workspace pays for and what it has paid: the plan and its price, what has been used of each limit, the card on file, who the invoices are made out to, and every invoice to download. It is the billing page of the settings, in the nav the settings page block draws, and it covers a trial, a failed payment and a plan cancelled at the end of its period as well as the plain monthly case.


A block, not a component: copy the view below into your app. It is a page in the sidebar shell, beside the settings nav from the settings page block. It takes no card details. The card form is your payment provider's own hosted fields, mounted where the dialog holds a place for them, so the number never reaches your app.
What it shows
-
The plan in a panel: its name, a badge for its state, the monthly price worked out from the seats and written by
Support\Money(the formatting money input uses), and when it renews. Change plan goes to your plans page; Cancel plan asks first, in a modal. -
Usage against each limit as a usage meter: seats, file storage and API calls. At 80% a meter turns amber; at 90% or more it becomes an upgrade prompt that says what stops working at the limit (each limit's
full) and what the next plan adds. -
The payment method, as words: "Card ending 4242" and its expiry, with Update card. No brand's logo: the last four digits and the date are what a reader checks.
-
Billing details: the name and address on the invoices, where they are sent, the VAT number, and an Edit link.
-
Invoices, newest first, in a table: the number, the date, the amount, a status badge and a download link each, paged by the package's pagination view, and an empty state before the first one.
-
Update card opens a dialog with the price it will be charged and a skeleton where the provider's card fields load:

-
On a trial: a trial banner card counting the days down, the plan marked Trial with no Cancel, "No card yet", and no invoices:

-
A failed payment: an alert that says what failed and by when to fix it, with its own Update card, and the invoice marked "Payment failed":

-
Cancelled at the end of the period: a warning that says when the plan ends and what changes then, with a way to keep it:

Built from
- Page header: the title and its line
- Panel: Plan, Usage, Payment method and Billing details
- Badge: the plan's state and each invoice's
- Button: Change plan, Cancel plan, Update card, the downloads
- Usage meter and Upgrade prompt: each limit, and the way past one that is nearly used up
- Trial banner: the days left of a trial
- Alert: a failed payment, a plan that is ending
- Icon: the card
- Table and Empty state: the invoices
- Modal and Skeleton: cancelling, and the card dialog with the provider's fields loading
The markup
resources/views/settings/billing.blade.php
{{--
What the workspace pays for and what it has paid: the plan, what it has
used of it, the card, who the invoices are made out to, and the
invoices. The controller passes $subscription, $usage (label, used,
limit, unit, and full: what happens at the limit), $card (last4 and expires, or null), $details and
$invoices (a paginator). Amounts are in minor units, as the payment
provider keeps them.
--}}
@php
$money = fn (int $minor) => \Shipbytes\BladeUi\Support\Money::format($minor, $subscription['currency'], 'en-GB', minor: true, symbol: 'symbol');
$date = fn (?string $day) => $day ? \Illuminate\Support\Carbon::parse($day)->format('j F Y') : null;
$status = $subscription['status'];
$trialing = $status === 'trialing';
$ending = $subscription['ends'] !== null;
$total = $subscription['price'] * $subscription['seats'];
$invoiceStatus = [
'paid' => ['Paid', 'success'],
'open' => ['Due', 'warning'],
'failed' => ['Payment failed', 'danger'],
'void' => ['Void', 'neutral'],
];
@endphp
<x-layouts.app title="Billing">
<div class="flex flex-col gap-6 lg:flex-row lg:gap-10">
<x-settings.nav />
<div x-data="{ cancelOpen: false, cardOpen: false }" class="flex min-w-0 flex-1 flex-col gap-6">
<x-ds::page-header title="Billing" description="The plan Tidewater Ferries is on, what it has used, and every invoice." />
@if ($status === 'past_due')
<x-ds::alert tone="danger" title="The last payment did not go through">
<p>The bank declined {{ $money($total) }} for December. Update the card by {{ $date($subscription['retryBy']) }} to keep the Team plan; we will try again then.</p>
<x-slot:actions>
<x-ds::button variant="secondary" size="sm" :href="route('billing.portal')" x-on:click.prevent="cardOpen = true" aria-haspopup="dialog">Update card</x-ds::button>
</x-slot:actions>
</x-ds::alert>
@elseif ($ending)
<x-ds::alert tone="warning" title="The Team plan ends on {{ $date($subscription['ends']) }}">
<p>Until then nothing changes. After it, the workspace moves to the Free plan: 5 seats and 2 GB of files, and members past the fifth can only read.</p>
<x-slot:actions>
<form method="POST" action="{{ route('billing.subscription.resume') }}">
@csrf
<x-ds::button type="submit" variant="secondary" size="sm">Keep the Team plan</x-ds::button>
</form>
</x-slot:actions>
</x-ds::alert>
@endif
@if ($trialing)
<x-ds::trial-banner
variant="card"
:daysLeft="$subscription['trialDaysLeft']"
:total="14"
:href="route('billing.plans')"
actionLabel="Choose a plan"
/>
@endif
<x-ds::panel title="Plan" body="plain">
<div class="flex flex-col gap-4 sm:flex-row sm:items-start sm:justify-between">
<div class="min-w-0">
<p class="flex flex-wrap items-center gap-2">
<span class="text-title text-fg">{{ $subscription['plan'] }}</span>
@if ($trialing)
<x-ds::badge tone="accent">Trial</x-ds::badge>
@elseif ($status === 'past_due')
<x-ds::badge tone="danger" :dot="true">Payment overdue</x-ds::badge>
@elseif ($ending)
<x-ds::badge tone="warning">Cancelled</x-ds::badge>
@else
<x-ds::badge tone="success" :dot="true">Active</x-ds::badge>
@endif
</p>
<p class="mt-1 text-body text-fg-body">
<span class="font-medium text-fg tabular-nums">{{ $money($total) }}</span> a month:
{{ $subscription['seats'] }} seats at {{ $money($subscription['price']) }}
</p>
<p class="mt-1 text-meta text-fg-muted">
@if ($trialing)
Free until {{ $date($subscription['trialEnds']) }}. Add a card to stay on Team after that.
@elseif ($ending)
Ends on {{ $date($subscription['ends']) }}, with no further charge.
@else
Renews on {{ $date($subscription['renews']) }}. Seats added before then are charged pro rata.
@endif
</p>
</div>
<div class="flex shrink-0 flex-wrap gap-2">
<x-ds::button variant="secondary" :href="route('billing.plans')">Change plan</x-ds::button>
@unless ($trialing || $ending)
{{-- A link to the host's own confirmation page, which the dialog takes over when the script is there. --}}
<x-ds::button variant="ghost" tone="danger" :href="route('billing.cancel')" x-on:click.prevent="cancelOpen = true" aria-haspopup="dialog">Cancel plan</x-ds::button>
@endunless
</div>
</div>
</x-ds::panel>
<x-ds::panel title="Usage" body="plain">
<div class="flex flex-col gap-5">
@foreach ($usage as $limit)
{{-- Nine tenths used, the meter becomes the way to more; at eight it only turns amber. --}}
@if ($limit['used'] / $limit['limit'] >= 0.9)
<x-ds::upgrade-prompt
variant="inline"
:label="$limit['label']"
:used="$limit['used']"
:limit="$limit['limit']"
:unit="$limit['unit']"
plan="Business"
:href="route('billing.plans')"
:benefits="['500,000 API calls a month', '100 seats', '1 TB of files']"
>
{{ $limit['full'] }}
</x-ds::upgrade-prompt>
@else
<x-ds::usage-meter :label="$limit['label']" :used="$limit['used']" :limit="$limit['limit']" :unit="$limit['unit']" />
@endif
@endforeach
</div>
</x-ds::panel>
<div class="grid gap-6 md:grid-cols-2">
<x-ds::panel title="Payment method" body="plain">
{{-- Words, not a brand's mark: the card's last four digits and when it expires are what a reader checks. --}}
<div class="flex flex-wrap items-center justify-between gap-3">
<div class="flex min-w-0 items-center gap-3">
<x-ds::icon name="credit-card" class="shrink-0 text-fg-muted" />
@if ($card)
<div class="min-w-0">
<p class="font-medium text-fg">Card ending {{ $card['last4'] }}</p>
<p class="text-meta text-fg-muted">Expires {{ $card['expires'] }}</p>
</div>
@else
<p class="text-fg-muted">No card yet</p>
@endif
</div>
<x-ds::button variant="secondary" size="sm" :href="route('billing.portal')" x-on:click.prevent="cardOpen = true" aria-haspopup="dialog">{{ $card ? 'Update card' : 'Add a card' }}</x-ds::button>
</div>
</x-ds::panel>
<x-ds::panel title="Billing details" action="Edit" :actionHref="route('billing.details.edit')" body="plain">
<address class="text-body not-italic text-fg-body">
<span class="font-medium text-fg">{{ $details['name'] }}</span><br>
@foreach ($details['address'] as $line)
{{ $line }}<br>
@endforeach
</address>
<p class="mt-2 text-meta text-fg-muted">Invoices go to {{ $details['email'] }} · VAT {{ $details['tax'] }}</p>
</x-ds::panel>
</div>
<section aria-labelledby="invoices-heading" class="flex flex-col gap-4">
<h2 id="invoices-heading" class="text-section text-fg">Invoices</h2>
<x-ds::table label="Invoices" :columns="['Invoice', 'Date', ['label' => 'Amount', 'align' => 'right'], 'Status', ['label' => '', 'width' => 'w-14']]">
@forelse ($invoices as $invoice)
@php [$word, $tone] = $invoiceStatus[$invoice['status']]; @endphp
<x-ds::table-row>
<x-ds::table-cell :rowHeader="true" :nowrap="true" class="tabular-nums">{{ $invoice['number'] }}</x-ds::table-cell>
<x-ds::table-cell :nowrap="true">{{ $date($invoice['date']) }}</x-ds::table-cell>
<x-ds::table-cell align="right" :nowrap="true" class="tabular-nums">{{ $money($invoice['total']) }}</x-ds::table-cell>
<x-ds::table-cell :nowrap="true"><x-ds::badge :tone="$tone">{{ $word }}</x-ds::badge></x-ds::table-cell>
<x-ds::table-cell align="right">
<x-ds::button
variant="ghost"
size="sm"
icon="arrow-down-tray"
:iconOnly="true"
:href="route('billing.invoices.show', $invoice['id'])"
:aria-label="'Download invoice '.$invoice['number'].' (PDF)'"
/>
</x-ds::table-cell>
</x-ds::table-row>
@empty
<tr>
<td colspan="5">
<x-ds::empty-state
icon="document-text"
title="No invoices yet"
:description="$trialing ? 'The first one comes when the trial ends and the plan starts.' : 'Each month’s invoice shows up here once it is issued.'"
:bare="true"
/>
</td>
</tr>
@endforelse
</x-ds::table>
{{ $invoices->links('ds::pagination') }}
</section>
@unless ($trialing || $ending)
<x-ds::modal open="cancelOpen" title="Cancel the Team plan?" size="sm">
<p class="text-body text-fg-body">
Tidewater Ferries keeps Team until {{ $date($subscription['renews']) }} and is not charged again. After that it moves to the Free plan. You can change your mind until then.
</p>
<form id="cancel-plan" method="POST" action="{{ route('billing.subscription.destroy') }}">
@csrf
@method('DELETE')
</form>
<x-slot:footer>
<x-ds::button variant="ghost" size="sm" x-on:click="cancelOpen = false">Keep the plan</x-ds::button>
<x-ds::button type="submit" form="cancel-plan" variant="danger" size="sm">Cancel plan</x-ds::button>
</x-slot:footer>
</x-ds::modal>
@endunless
{{--
No card fields here: the payment provider's own hosted fields
mount in #payment-element, so the number never reaches this
app. The skeleton holds their place until they load.
--}}
<x-ds::modal open="cardOpen" :title="$card ? 'Update the card' : 'Add a card'" size="sm">
<form id="card-form" method="POST" action="{{ route('billing.card.update') }}" class="flex flex-col gap-3">
@csrf
@method('PUT')
<p class="text-body text-fg-body">The card is charged {{ $money($total) }} a month from the next renewal. Card details go straight to our payment provider.</p>
<div id="payment-element">
<x-ds::skeleton variant="block" size="lg" />
</div>
<input type="hidden" name="payment_method">
</form>
<x-slot:footer>
<x-ds::button variant="ghost" size="sm" x-on:click="cardOpen = false">Cancel</x-ds::button>
<x-ds::button type="submit" form="card-form" size="sm">Save card</x-ds::button>
</x-slot:footer>
</x-ds::modal>
</div>
</div>
</x-layouts.app>
Wire it up
The routes
use App\Http\Controllers\BillingController;
Route::middleware(['auth', 'can:manage-billing'])->prefix('settings/billing')->name('billing.')->group(function () {
Route::get('plans', [BillingController::class, 'plans'])->name('plans');
Route::get('cancel', [BillingController::class, 'confirmCancel'])->name('cancel');
Route::delete('subscription', [BillingController::class, 'cancel'])->name('subscription.destroy');
Route::post('subscription/resume', [BillingController::class, 'resume'])->name('subscription.resume');
Route::get('portal', [BillingController::class, 'portal'])->name('portal');
Route::put('card', [BillingController::class, 'updateCard'])->name('card.update');
Route::get('details', [BillingController::class, 'editDetails'])->name('details.edit');
Route::get('invoices/{invoice}', [BillingController::class, 'invoice'])->name('invoices.show');
});
Route::get('settings/billing', [BillingController::class, 'show'])->middleware('auth')->name('settings.billing');
billing.cancel is the no-script way to cancel: a page of your own with
the modal's words and its DELETE form. billing.portal is the no-script
way to change the card: a redirect to your provider's hosted billing page.
With the script, both are taken over by the dialogs on this page.
The page
The view takes plain arrays, so it does not care which provider is behind them. With Laravel Cashier on the workspace (the billable model), the controller is about this; check the method names against the Cashier version you run:
namespace App\Http\Controllers;
use Illuminate\Http\Request;
use Illuminate\Pagination\LengthAwarePaginator;
class BillingController
{
public function show(Request $request)
{
$workspace = $request->user()->currentWorkspace;
$subscription = $workspace->subscription('default');
$card = $workspace->defaultPaymentMethod();
$all = $workspace->invoicesIncludingPending();
$page = LengthAwarePaginator::resolveCurrentPage();
return view('settings.billing', [
'subscription' => [
'plan' => config("plans.{$subscription->stripe_price}.name"),
'status' => $subscription->onTrial() ? 'trialing' : ($subscription->pastDue() ? 'past_due' : 'active'),
'price' => config("plans.{$subscription->stripe_price}.price"), // minor units, per seat
'currency' => 'GBP',
'seats' => $subscription->quantity,
'renews' => $subscription->ended() || $subscription->onGracePeriod() ? null : $subscription->asStripeSubscription()->current_period_end,
'ends' => $subscription->onGracePeriod() ? $subscription->ends_at->toDateString() : null,
'trialDaysLeft' => $subscription->onTrial() ? (int) now()->diffInDays($subscription->trial_ends_at) : null,
'trialEnds' => $subscription->trial_ends_at?->toDateString(),
'retryBy' => $workspace->nextPaymentRetry(), // your own: from the provider's dunning settings
],
'usage' => $workspace->usageAgainstLimits(), // your own: label, used, limit, unit, full
'card' => $card ? ['last4' => $card->card->last4, 'expires' => sprintf('%02d/%d', $card->card->exp_month, $card->card->exp_year)] : null,
'details' => $workspace->billingDetails(), // name, address lines, email, tax
'invoices' => new LengthAwarePaginator(
$all->forPage($page, 10)->map(fn ($invoice) => [
'id' => $invoice->id,
'number' => $invoice->number,
'date' => $invoice->date()->toDateString(),
'total' => $invoice->rawTotal(),
'status' => $invoice->status === 'open' && $invoice->attempt_count > 0 ? 'failed' : $invoice->status,
])->values(),
$all->count(), 10, $page, ['path' => $request->url()],
),
]);
}
public function cancel(Request $request)
{
$request->user()->currentWorkspace->subscription('default')->cancel();
return to_route('settings.billing')->with('status', 'The Team plan ends at the end of this period.');
}
public function resume(Request $request)
{
$request->user()->currentWorkspace->subscription('default')->resume();
return to_route('settings.billing')->with('status', 'The Team plan carries on.');
}
public function portal(Request $request)
{
return $request->user()->currentWorkspace->redirectToBillingPortal(route('settings.billing'));
}
public function updateCard(Request $request)
{
$request->validate(['payment_method' => ['required', 'string']]);
$request->user()->currentWorkspace->updateDefaultPaymentMethod($request->input('payment_method'));
return to_route('settings.billing')->with('status', 'Card saved.');
}
public function invoice(Request $request, string $invoice)
{
return $request->user()->currentWorkspace->downloadInvoice($invoice);
}
}
Cashier's invoices are not a query, so the paginator is built by hand from the collection; past a few dozen invoices, page through the provider's list instead. The mapping of a provider's invoice states onto the four the view knows (paid, open, failed, void) is yours to decide.
The card dialog
The dialog's form holds an empty #payment-element with a skeleton and a
hidden payment_method. Your provider's script mounts its card fields
there when the dialog first opens, and on submit swaps the card for a
payment method id, sets the hidden field and lets the form post:
document.getElementById('card-form').addEventListener('submit', async (event) => {
event.preventDefault();
const id = await provider.confirmCardSetup(/* your provider's call */);
event.target.elements.payment_method.value = id;
event.target.submit();
});
Nothing of the package's runs here; the provider's own script loads only on this page.
Phone, keyboard, no script
- Phone: one column. Plan's buttons go under its price, Payment method and Billing details stack, and the invoices table keeps its five columns in a box that scrolls sideways (the number and date come first). The dialogs fill the width.
- Keyboard: the settings nav, then each panel's actions in reading order: Change plan, Cancel plan, the upgrade prompts' links, Update card, Edit, then each invoice's download, then the pages. Cancel plan and Update card open their dialogs with focus inside; Escape closes them and gives focus back to the button.
- No script: Cancel plan is a link to your own confirmation page and Update card a link to the provider's billing portal; the dialogs only take them over when the script runs. Keep the plan, the downloads, Change plan, Edit and the pages are plain forms and links. The card fields are the provider's own and need its script, which is why Update card falls back to the portal.
From the package repo: edit this page on GitHub.