Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Cashier Laravel Package

laravel/cashier

Laravel Cashier (Stripe) adds a fluent, expressive API for subscription billing in Laravel. Manage subscriptions, coupons, plan swaps, quantities, cancellation grace periods, and invoice PDF generation—without writing boilerplate billing code.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

Architecture Fit

Laravel Cashier (Stripe integration) is a highly aligned solution for any Laravel-based SaaS or subscription-driven application requiring Stripe billing. Its event-driven architecture (via webhooks) and model integration (e.g., User model traits) make it a seamless fit for:

  • Subscription management (plans, trials, cancellations, prorations).
  • Payment flows (Checkout, invoices, dunning).
  • Tax and coupon handling (multi-currency, regional compliance).
  • Usage-based billing (Stripe’s metered pricing).

The package abstracts Stripe’s complexity behind Laravel’s eloquent models, reducing boilerplate while maintaining type safety (PHP 8.5+ support) and Stripe API parity.

Integration Feasibility

  • Low friction: Designed for Laravel’s ecosystem (Lumen, Octane, Livewire/Inertia compatibility).
  • Database agnostic: Works with MySQL, PostgreSQL, SQLite (with minor caveats like SQLite migrations).
  • Webhook-first: Requires Stripe webhook endpoints (Laravel’s VerifyWebhookSignature middleware included).
  • Testing support: Built-in test helpers (e.g., fake() for Stripe mocking).

Key dependencies:

  • Stripe PHP SDK (v16+).
  • Laravel 10.x–13.x (v16.x branch) or 12.x (v15.x branch).
  • PHP 8.1+ (8.5+ for v16.x).

Technical Risk

Risk Area Assessment Mitigation Strategy
Stripe API Changes Stripe’s API evolves rapidly (e.g., v16 SDK breaking changes). Monitor Stripe API changelog and Cashier’s releases.
Webhook Reliability Critical for syncing subscriptions/payments. Implement idempotency, retries, and dead-letter queues (e.g., Laravel Horizon).
Tax/Compliance Regional tax rules (e.g., VAT, GST) require careful configuration. Use Stripe’s tax_rates and validate with local experts.
Downtime Impact Stripe outages or API throttling can disrupt billing. Cache subscription states locally; use Stripe’s backup payments.
Migration Complexity Upgrading between major versions (e.g., v15→v16) may require schema changes. Test upgrades in staging; use Laravel’s migrate:fresh for rollback safety.

Key Questions for TPM

  1. Business Model:

    • Are subscriptions time-based (fixed plans), usage-based, or hybrid? Cashier supports all but may need custom logic for edge cases (e.g., tiered pricing).
    • Do you need multi-currency or multi-region support? Stripe’s prices API handles this, but tax rules must be configured per region.
  2. Payment Flows:

    • Will you use Stripe Checkout, direct payment methods (SEPA, cards), or embedded elements? Cashier supports all but may require UI customization.
    • Are off-session payments (e.g., manual invoices) needed? Cashier’s Invoice model covers this.
  3. Compliance:

    • Are there PCI DSS or data residency requirements? Stripe handles PCI compliance, but ensure your Laravel app’s storage (e.g., payment method tokens) aligns with policies.
    • Do you need audit logs for subscriptions/payments? Extend Cashier’s webhooks or use Laravel’s log() middleware.
  4. Scaling:

    • What’s the expected transaction volume? Stripe’s usage limits may require tier upgrades.
    • Will you use Laravel Queues for async webhook processing? Recommended for high-volume setups.
  5. Customization:

    • Are there non-Stripe payment gateways (e.g., PayPal) needed? Cashier is Stripe-only; consider a wrapper layer for multi-gateway support.
    • Do you need custom invoice PDFs? Cashier uses dompdf; extend via Invoice::render() or replace the driver.
  6. Monitoring:

    • How will you track failed payments or subscription churn? Integrate with:
      • Stripe’s Dashboard.
      • Laravel’s failed_jobs table (for webhook retries).
      • Third-party tools (e.g., Mixpanel, PostHog) via Cashier’s events.

Integration Approach

Stack Fit

Cashier is optimized for Laravel’s stack and integrates natively with:

  • Eloquent Models: Add HasPaymentMethods and HasSubscriptions traits to User or custom models.
  • Laravel Queues: Webhooks and async jobs (e.g., HandleWebhook).
  • Laravel Horizon: For processing high-volume webhooks.
  • Laravel Nova/Panel: Pre-built Cashier widgets for admin dashboards.
  • Livewire/Inertia: For real-time subscription management UIs.

Non-Laravel Considerations:

  • If using Lumen, ensure illuminate/support and illuminate/database are installed.
  • For Octane, Cashier’s async operations (e.g., webhooks) will work but may need Swoole tuning.

Migration Path

Scenario Steps
New Laravel Project 1. Install via Composer: composer require laravel/cashier. 2. Publish config: php artisan vendor:publish --provider="Laravel\Cashier\CashierServiceProvider". 3. Set up Stripe keys in .env. 4. Add traits to User model.
Existing Stripe Integration 1. Audit custom Stripe logic (e.g., subscription creation). 2. Replace with Cashier methods (e.g., createSubscription()). 3. Migrate webhooks to Cashier’s HandleWebhook. 4. Test in staging.
Legacy Billing System 1. Backfill Stripe customers/subscriptions via API. 2. Sync historical data (e.g., invoices) to Laravel. 3. Gradually migrate users to Cashier.
Multi-Tenant SaaS 1. Extend User model to include tenant_id. 2. Use Stripe’s customer metadata for tenant tracking. 3. Customize webhooks to route events per tenant.

Compatibility

Component Compatibility Notes
Laravel Versions v16.x: Laravel 13.x; v15.x: Laravel 12.x. Avoid mixing major versions (e.g., v15 Cashier on Laravel 14).
PHP Versions v16.x: PHP 8.5+; v15.x: PHP 8.1+. Use php -v to check compatibility.
Stripe SDK v16.x: Stripe PHP SDK v16+; v15.x: SDK v15+. Pin versions in composer.json to avoid surprises.
Databases All supported, but SQLite may need adjustments for migrations (e.g., Schema::disableForeignKeyConstraints()).
Payment Methods Supports cards, SEPA, iDEAL, etc. Custom methods require Stripe’s payment links or direct API calls.
Webhooks Requires HTTPS endpoint. Use Laravel’s VerifyWebhookSignature middleware. For high traffic, consider a load-balanced setup with retries.

Sequencing

  1. Phase 1: Setup & Configuration

    • Install Cashier and configure Stripe keys.
    • Set up webhook endpoints (test with Stripe CLI: stripe listen --forward-to localhost:8000/stripe/webhook).
    • Publish config and migrate database tables.
  2. Phase 2: Core Subscription Flows

    • Implement createSubscription(), cancelSubscription(), and swap() methods.
    • Test trial periods, prorations, and coupon redemptions.
  3. Phase 3: Payment & Billing

    • Configure Invoice generation and PDFs.
    • Set up dunning (failed payment retries) via Stripe’s invoice_settings.default_payment_method.
    • Implement HandleWebhook for real-time events (e.g., invoice.paid).
  4. **Phase 4:

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle