Laravel Cashier
Laravel Cashier Chargebee provides an expressive, fluent interface to Chargebee's subscription billing services. It handles almost all of the boilerplate subscription billing code you are dreading writing, including subscription management, checkout, invoices, payment methods, and more.
Prerequisites
- PHP 8.1 or later
- Laravel 10, 11, or 12
- Chargebee PHP SDK v4.8.0 or later (installed automatically)
Installation
Publish and run the migrations:
Optionally publish the configuration file:
Configuration
Add your Chargebee credentials to .env:
Billable Model
Add the Billable trait to your user model:
Features
- Customers — Create, retrieve, update, and sync Chargebee customers
- Subscriptions — Full lifecycle management (create, update, cancel, resume, pause)
- Checkout — Product, subscription, and single-charge checkouts via Hosted Pages
- Payment Methods — Add, list, update default, and delete payment sources
- Invoices — Retrieve, preview upcoming, and generate PDF invoices
- Billing Portal — Redirect customers to a self-service portal
- Webhooks — Automatic handling with Basic Auth verification
- Trials — With or without payment method, check/end/extend
- Entitlements — Configure and check feature entitlements
Customers
Subscriptions
Creating a Subscription
Checking Status
Cancelling
Checkout
Product Checkout
Subscription Checkout
Single Charge Checkout
Billing Portal
Redirect users to the self-service billing portal:
Webhooks
Setup
Create a webhook via Artisan:
This registers a webhook at https://your-domain.com/chargebee/webhook. Configure Basic Auth credentials in your config/cashier.php:
Handling Events
Cashier automatically handles subscription state changes from webhooks. To handle additional events, listen to Cashier's events in your EventServiceProvider:
Invoices
Entitlements
Entitlements require enabling in config and adding the HasEntitlements trait to your model:
Generate the feature enum:
Then check access using the generated enum: