laravel/cashier
Laravel Cashier adds a fluent Stripe subscription billing layer to Laravel. Manage plans, trials, coupons, quantities, swaps, cancellations with grace periods, and invoicing, including PDF invoice generation, with minimal boilerplate.
Laravel Cashier is a highly specialized package designed to abstract Stripe’s subscription billing logic into a Laravel-friendly, Eloquent-based interface. It aligns perfectly with:
Key strengths:
user->newSubscription('default', $plan)->create($paymentMethod)).HandleWebhook middleware).dompdf).Potential misfit:
Prerequisites:
.env.subscriptions, subscription_items, and invoices tables./stripe/webhooks) with VerifyWebhookSignature middleware.Integration Path:
composer require laravel/cashier stripe/stripe-php
php artisan vendor:publish --provider="Laravel\Cashier\CashierServiceProvider"
php artisan migrate
.env:
STRIPE_KEY=your_test_key
STRIPE_SECRET=your_test_secret
HasSubscriptions):
use Laravel\Cashier\Billable;
class User extends Authenticatable {
use Billable;
}
Feasibility Score: 9/10 (minimal friction for Laravel apps; Stripe dependency is the only constraint).
| Risk Area | Severity | Mitigation |
|---|---|---|
| Stripe API Changes | High | Cashier abstracts most changes, but breaking updates (e.g., Stripe SDK v16+) require testing. Monitor Stripe API changelog. |
| Webhook Reliability | Medium | Use VerifyWebhookSignature middleware and test locally with Stripe CLI. |
| Tax/Invoice Complexity | Medium | Cashier handles most tax logic, but custom tax rules may need overrides. |
| Legacy Laravel Support | Low | Drop support for Laravel <9.x (v15.x) or <10.x (v16.x) if using newer versions. |
| Performance | Low | Webhooks and invoice generation are async-friendly; cache Stripe API responses if needed. |
Critical Questions for TPM:
invoice.paid) be tested in CI?Best For:
Less Ideal For:
stripe/stripe-php directly for OTPs.| Phase | Tasks | Tools/Dependencies |
|---|---|---|
| Pre-Migration | Audit existing billing logic; identify Stripe API calls to replace. | Postman (API testing), Laravel Telescope (logs). |
| Setup | Install Cashier, publish config/migrations, configure Stripe keys. | Composer, Artisan. |
| Core Integration | Extend User model, set up webhooks, test subscription flows. | Stripe CLI, Laravel Dusk. |
| Feature Parity | Replace custom billing logic with Cashier methods (e.g., createSubscription()). |
Changelog review, feature flags. |
| Webhook Validation | Test all Stripe events locally; deploy with monitoring. | Stripe CLI, Sentry. |
| Go-Live | Enable Stripe webhooks, monitor for failures, roll back if needed. | Feature flags, canary releases. |
Sequencing:
| Component | Compatibility | Notes |
|---|---|---|
| Laravel | 10.x (v16.x), 9.x (v15.x), 8.x (v14.x) | Drop older versions if using latest Cashier. |
| PHP | 8.1+ (v15.x), 8.5+ (v16.x) | Align with Laravel’s PHP requirements. |
| Stripe SDK | v16+ (v16.x Cashier) | Breaking changes may require updates. |
| Database | MySQL, PostgreSQL, SQLite (with caveats) | SQLite may need adjustments for migrations. |
| Frontend | Blade, Inertia, Livewire (Checkout integration) | Use Checkout::newSession() for embedded forms. |
| Third-Party | dompdf (invoices), Guzzle (HTTP), Symfony (components) | Dependencies are well-maintained. |
Key Compatibility Risks:
createAsStripeCustomer()).Pros:
Cons:
Maintenance Tasks:
Support Channels:
Common Support Needs:
stripe listen --forward-to localhost:3000/stripe/webhooks for local testing.How can I help you explore Laravel packages today?