Laravel Cashier (Stripe)
Fluent Laravel interface to Stripe subscription billing, invoicing, and coupons
Repository Health
Technical Analysis
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
Billabletrait 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.
Used by 2 apps in this directory
Bagisto
Analytics · Ecommerce
Open-source Laravel eCommerce platform for building multi-vendor marketplaces, B2B stores, headless commerce, and AI-powered storefronts.
OpnForm
Forms Surveys · Marketing
Build unlimited, embeddable forms with no code — powered by AI, logic rules, and real-time analytics