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.

Enjoyed the article? Consider sharing it on Twitter so others can enjoy it too :)

Share on Twitter

Receive project updates, article drafts & thoughts on your inbox every saturday.

Subscribe →