Snippet

Laravel Stripe Portal

php
public function portal(User $user)
{
    return with(\Stripe\BillingPortal\Session::create([
        'customer'   => $user->stripe_id,
        'return_url' => URL::previous(),
    ]), fn ($portal) => redirect($portal->url));
}

Context

Stripe recently introduced a new Billing Portal where users can update their payment information and their subscriptions. The following snippet allows you to implement said billing portal into your Laravel application, with no extra work on your part.