Building Laravel SaaS Application for Subscription Services

Mirza Waleed

Mirza Waleed


The business landscape is evolving at a rapid pace. Where eCommerce once ruled, a new model has emerged – the subscription economy. By 2025 the subscription economy will reach a market size of $1.5 trillion in global spending annually.

For SaaS and software companies, recurring revenue streams provide financial stability in volatile times. It allows for predictive cash flows, better retention, and the opportunity to upsell existing customers over time.

However, maximizing the potential of subscription services requires navigating complex technical and operational challenges. From billing and collections to revenue recognition, it is an intricate process requiring strategic expertise.

This guide covers best practices used by leading subscription businesses to optimize recurring revenue. We’ll discuss proven approaches for setup, payments, customer lifecycles, and more. Our goal is to arm you with actionable insights that can help scale your organization efficiently in today’s demanding digital marketplace.

Whether you are launching your first subscription product or expanding an existing business, we hope you find value in the perspectives and strategies shared. Our aim is to support your efforts to deliver innovative solutions to customers while achieving sustainable business success.

Setting Up the Project

When embarking on a subscription service, the initial setup lays the groundwork for future success. Proper planning and structuring at the onset help build a scalable foundation.

Initialize the Project Scaffolding

The first step is to configure a Laravel development environment. We’ll use Laravel Sail for quick Docker setup:

curl -s "" | bash

This clones the starter project and installs Sail.

Add Authentication

Members need to sign up and login to access features. We’ll install Laravel Breeze for authentication, along with Fortify for additional security:

composer require laravel/breeze --dev

php artisan breeze:install


Construct the Database

Subscriptions have interrelated components. We define schema through migrations:

php artisan make:migration create_users_table

php artisan make:migration create_plans_table

php artisan make:migration create_subscriptions_table


Model the Subscription Elements

ORM models represent database tables:


class User extends Authenticatable {


public function subscriptions() {

return $this->hasMany(Subscription::class);



Proper modeling facilitates querying relationships between users, plans, and subscriptions.

Prepare for Payments

Payment handling requires additional packages. We’ll install Cashier for its subscription payment capabilities:

composer require laravel/cashier

php artisan vendor:publish --tag="cashier-migrations"

This lays the foundation for processing recurring billing.

Plans and Subscriptions

A fundamental part of any subscription service is having structured plans for users to choose from. Cashier makes it straightforward to configure and manage plans within Laravel.

Configuring Plans in Cashier

Plans are defined in a configuration file. We’ll add some sample plans:

// cashier.php

'plans' => [

'starter' => [

'name' => 'Starter', 

'price' => 4.99,

'interval' => 'monthly'


'professional' => [

'name' => 'Professional',

'price' => 14.99,

'interval' => 'monthly'


'enterprise' => [

'name' => 'Enterprise',

'price' => 24.99,

'interval' => 'yearly'




Subscribing Users and Assigning Plans

Users can subscribe during registration or on their profile. We’ll expose a subscribe method:

// UsersController.php

public function subscribe(Request $request) 


$user = auth()->user();

$user->newSubscription('starter', $request->stripe_token)


return redirect('/')->with('success', 'Thanks for subscribing!');



Methods for Updating/Cancelling Subscriptions

We provide methods to allow users to change or cancel plans:



Cashier handles updating payment details and status changes behind the scenes.

Handling Payments

To initiate billing, a payment gateway integration is required. Stripe is fully supported through Cashier.

Setting Up Stripe/Payment Gateway

Generate Stripe API keys and add to the .env file:



Cashier will automatically connect to Stripe.

Processing Subscriptions and Payments

When a user subscribes, Cashier queues a background job to process the payment:

$user->newSubscription('plan', $token)->create();

This confirms payment and saves the subscription in Stripe and the local database.

Webhooks for Handling Events

Stripe notifies of changes via webhooks. We register a webhook handler:

Cashier::webhook($request, $response);

This updates the status based on Stripe events. For example, if payment fails it will cancel the subscription.

Webhooks ensure the application state remains in sync with Stripe as operations occur outside our control (e.g. expired cards).

We now have a fully integrated Stripe payment flow to reliably charge subscribers each billing cycle.

Recurring Billing

Cashier automates recurring charges through Laravel jobs. Here are some key aspects:

Managing Trial Periods

Trials allow users to test a subscription before committing long-term:


Once the trial expires, the regular billing will automatically begin.

Scheduling Renewal Billings

Cashier schedules a recurring “” job to process upcoming bills:

// Creates job that runs at subscription renewal/billing date


This applies to the latest card on file from Stripe.

Handling Expired Cards/Failed Payments

Webhooks notify of payment failures from expired cards. We gracefully handle this:

// Received webhook 

if ($event->type == 'payment_failed') {

// Retry in a week


'billing_date' => now()->addDays(7)



This ensures robust recurring income by keeping subscriptions active even if cards need updating.

With these features, Cashier takes care of recurring billing logistics so we can focus on the product.

Customer Lifecycle

How customers experience a product impacts retention. Some best practices:

Onboarding Funnel

Guiding new users through signup, payment, and getting set up ensures a positive first impression.

Engagement Features

Offering premium content, personalized recommendations, and profiles incentivizes continued use of the platform.

Retention Strategies

Regular email communications and prompt support responses build familiarity and trust over time. Rewarding long-term subscribers also boosts retention.

cancellation handling

Rather than abrupt cancellation, provide a multi-step process to cancel:

  1. Request cancellation
  2. Send reminders of features
  3. Offer alternative plans/discounts
  4. Final cancellation notice
  5. Cancel after grace period

This reduces regret and encourages users to stay if issues are addressed.

We also analyze canceled accounts to surface common reasons through:

// Cancellation reason 


Insights help refine the product and messaging over time to better satisfy users throughout their journey. Combined with the above best practices, this full lifecycle approach strengthens customer relationships and increases subscription longevity.

Admin Interface

A powerful admin area allows robust oversight and control of subscriptions.

Building Dashboard for Analytics

The dashboard displays key metrics like new/canceling users, revenues over time, top plans, etc. This helps optimize business decisions.

Subscription Management Views

We build CRUD interfaces to view and edit subscriptions. Features include:

  • List of all subscriptions with status, value, user, etc
  • Filtering and sorting
  • Subscription details display
  • Plan change/cancel actions

Triggering Workflows from Admin

Additional controls allow managing customer state:

// Resume cancelled subscription


// Admin-initiated plan swap


// Update payment source


Combined with robust analytics, the admin empowers operatives to have full visibility and control over the subscription business from a single dashboard. This closes the loop to streamline operations at scale.

Additional Features

Laravel and Cashier allow extending functionality through additional packages.

Invoice Downloads

Users can view/download invoices. We’ll use the Cashier Invoice package:

composer require mews/cashier-invoicing

Then in the user profile:

// Download PDF 

$invoice = Invoice::find($id);

return $invoice->download();


Offer coupon codes for promotions. Using Cashier Coupons:

composer require crocodic/laravel-cashier-coupons

Apply coupon on checkout:



Sell extra features/services. We define additional plans:

'plans' => [


'pro-plus' => [

'name' => 'Pro Plus', 

'price' => 24.99,



Users can then upgrade:



Usage Tracking/Metering

Track usage-based plans/tiers. With Cashier Metering:

composer require cashier-meter/meter

Record usage and bill appropriately each period.

These packages extend Laravel functionalities seamlessly to offer a full-featured subscription experience.


Laravel and packages like Cashier provide powerful capabilities for building robust subscription businesses. With the fundamental groundwork covered here, you now have the foundations to:

  • Craft subscription plans and signup flows
  • Reliably process recurring payments through Stripe integration
  • Manage customer lifecycles with engagement, and retention strategies
  • Gain insights from detailed analytics and admin controls
  • Extend functionality through additional premium features

While this covers common patterns, the flexibility of Laravel allows customization of every aspect to your unique needs.

Starting a subscription service requires navigating technical and operational complexities. But by leveraging Laravel’s features out of the box, along with complementary packages, you can develop sophisticated recurring models with far less effort than building from scratch.

This allows focusing energy on crafting outstanding user experiences rather than infrastructure plumbing. Combined with best practices for the subscription business model, you are well-equipped to confidently launch and scale your recurring offering.

Thank you for learning about leveraging Laravel for subscription services. Feel encouraged to start building your own solution using the code snippets and insights provided. Wishing you the best in powering your business through strong recurring income streams.

Ready To Start Your Project