Laravel Cashier (Stripe)

Fluent Laravel interface to Stripe subscription billing, invoicing, and coupons

SDK
Composer
vv16.7.0
2,541stars
MIT License

Repository Health

Pre-computed score based on development activity, maintenance, community, maturity, and trend momentum.How we score it →
89/100Excellent
Development Activity84
Maintenance84
Community88
Maturity60
Momentum40

Technical Analysis

AI-assessed by reading the actual repository — architecture, code quality, innovation, and documentation.How we score it →
78/100Good
Architecture82
Code Quality84
Innovation70
Learning Curve74

Laravel Cashier is the official Laravel package for integrating Stripe’s subscription billing services into a Laravel application. It wraps Stripe’s customer, subscription, invoice, and payment-method APIs behind a Billable trait that any Eloquent model can use, turning multi-step Stripe API calls into simple, fluent method chains for creating subscriptions, applying coupons, swapping plans, and generating invoice PDFs.

Beyond basic recurring billing, Cashier handles the operational details teams tend to reimplement themselves: subscription quantities, cancellation grace periods, trial periods, Stripe webhook handling for keeping local subscription state in sync, and Strong Customer Authentication (SCA) support for regulated payment flows. Being an official Laravel package, it is maintained alongside the framework itself and is the default choice for Laravel applications billing customers through Stripe.

What You Get

  • A Billable trait for Eloquent models that adds subscription, payment-method, and invoice methods directly on the model
  • Fluent subscription builders for creating, swapping, and canceling Stripe subscriptions, including trials and grace periods
  • Coupon, promotion code, and tax-rate support applied directly through the subscription builder API
  • Built-in Stripe webhook controller and event dispatching to keep local subscription/invoice state synced with Stripe
  • Invoice PDF generation and a customer-balance/transaction API for account credits and one-off charges

Common Use Cases

  • Adding SaaS subscription billing (monthly/annual plans, trials, upgrades/downgrades) to a Laravel application via Stripe
  • Generating and emailing customer invoices with PDF attachments for a subscription-based product
  • Handling Stripe webhook events (payment failures, subscription updates, disputes) to keep a Laravel app’s billing state accurate
  • Applying coupons, promotion codes, or one-off customer balance credits to Stripe subscriptions from application code

Under The Hood

Architecture CashierServiceProvider.php registers Cashier’s routes (for Stripe webhooks), views (invoice templates), and console commands with the host Laravel application, while the Billable trait is the primary integration point — mixed into a User or Team Eloquent model, it delegates to SubscriptionBuilder.php/CheckoutBuilder.php for creating subscriptions and Stripe Checkout sessions. Subscription.php and SubscriptionItem.php model local database records that mirror Stripe subscription state, kept in sync via Http/Controllers webhook handlers that translate incoming Stripe events into Events/ classes and Jobs/ for asynchronous processing. Invoice.php/InvoiceLineItem.php/Invoices/ handle invoice retrieval and PDF rendering, and all Stripe API calls are ultimately delegated to the official stripe/stripe-php SDK dependency rather than Cashier reimplementing HTTP transport. Tech Stack Built for PHP 8.1+ and Laravel 10-13 (illuminate/database, illuminate/notifications, illuminate/routing, etc.), depending on stripe/stripe-php for the underlying Stripe API client, moneyphp/money for currency-safe monetary calculations, and nesbot/carbon for date handling around trial/grace periods. Code Quality Tests are split into Unit and Feature suites with a dedicated TestCase.php base and a workbench/ directory (Laravel’s package-testing skeleton) for exercising the package against a full Laravel app instance; PHPStan is configured via phpstan.neon.dist for static analysis. API Design The Billable trait keeps the day-to-day API surface small and idiomatic to Laravel ($user->newSubscription(...)->trialDays(14)->create($paymentMethod)), which minimizes boilerplate for common billing flows, though correctly handling webhooks, SCA, and edge cases in subscription lifecycle still requires reading Cashier’s documentation closely.

Join founders buildingwith open source

Opinionated takes, migration guides, cost-saving tips, and insights from the open source ecosystem.

Subscribe on Substack
Join 750+ subscribers

Search