Laravel Billing is a composer-installable Laravel package that provides world-class, gateway-agnostic billing, plans, subscriptions, invoices, multi-currency support, usage metering and a Livewire-powered admin UI. The goal: a drop-in, extensible billing system any Laravel app can adopt — open source, modular, and future-proof.
⚡ This README is meant to be the public project landing page to attract contributors and users. It explains the vision, features, architecture, quickstart, API, how to help, roadmap, and governance.
- Vision & Goals
- Key Features
- Who should care / Why it exists
- Quickstart (for interested users)
- Installation & Setup (developer view)
- Core Concepts & Models
- Public PHP API examples
- Livewire Admin UI (out-of-the-box)
- Gateways & Extensibility
- Events, Jobs & Webhooks
- Security & Compliance notes
- Testing & CI expectations
- Roadmap & Release Plan
- How to contribute
- Governance, Code of Conduct & License
- Contact / Community
Vision: Build the world’s first widely-adopted, open-source, Laravel-first billing system that makes it trivial to add robust billing to any Laravel application: subscriptions, one-time charges, metered billing, invoices, reconciliation, multi-currency, and more — all with a developer-friendly, secure, and extensible architecture.
Primary goals
- Developer-first: easy installation, clear contracts, small API surface.
- Gateway-agnostic: adapter-based architecture for any payment provider.
- Composable: publishable Livewire admin UI and publishable views.
- Secure & compliant: minimize PCI scope and provide privacy controls.
- Maintainable & testable: strong test coverage, CI pipeline, clear docs.
Core
- Plans & Products: create plans with flexible billing intervals and per-currency pricing.
- Subscriptions: signups, trials, cancel/pause/resume, proration strategies.
- One-time payments: payments and invoices for single purchases.
- Invoicing: auto-generated invoices, status tracking, PDF generation.
- Transactions & Refunds: full transaction ledger and reconciliation utilities.
- Multi-currency: prices per currency + pluggable exchange-rate provider.
- Coupons & promotions: percent/flat/usage-limited discounts.
- Customer management: automatic linking to host
Usermodel, guest checkout support. - Livewire Admin UI: CRUD for plans, customers, subscriptions, invoices, gateways.
- Events & hooks:
SubscriptionCreated,PaymentSucceeded,InvoiceGenerated, etc. - CLI & scheduler: artisan commands and scheduled jobs to run recurring billing and retries.
Advanced / optional
- Metered billing & usage records.
- Hosted checkout widget + embeddable checkout components.
- Accounting integrations (Xero/QuickBooks).
- Multi-tenant support recipe.
- KPI dashboard (MRR, churn, LTV) and metrics emitting.
- SaaS founders & teams who want a Laravel-native billing solution that’s not tied to one gateway or vendor.
- Laravel package authors who need a drop-in billing system for their packages.
- Companies wanting full control over billing logic, invoicing, and data privacy.
- Developers who want an extensible, auditable, testable billing core they can customize.
This is intentionally short — if there's demand we’ll publish a fully detailed installation and configuration guide.
-
Create a new Laravel project (or use an existing).
-
Add the package after we publish:
composer require vendor/laravel-billing
-
Publish configuration, migrations, and views:
php artisan vendor:publish --provider="Vendor\Billing\BillingServiceProvider" -
Run migrations:
php artisan migrate
-
Configure
.env:BILLING_USER_MODEL="App\Models\User"- Configure gateway API keys in
config/billing.phpor env.
-
Seed example plans (optional):
php artisan billing:seed-plans
-
Schedule
php artisan schedule:runin cron and run queue workers for async jobs.
Full docs will be provided in the repository, this is the condensed dev installation.
-
Require the package
composer require vendor/laravel-billing
-
Register service provider (if not auto-discovered)
// config/app.php 'providers' => [ // ... Vendor\Billing\BillingServiceProvider::class, ];
-
Publish assets
php artisan vendor:publish --provider="Vendor\Billing\BillingServiceProvider" --tag="config" php artisan vendor:publish --provider="Vendor\Billing\BillingServiceProvider" --tag="migrations" php artisan vendor:publish --provider="Vendor\Billing\BillingServiceProvider" --tag="views"
-
Migrate
php artisan migrate
-
Environment variables (example)
BILLING_USER_MODEL=App\Models\User BILLING_DEFAULT_CURRENCY=USD STRIPE_KEY=pk_test_... STRIPE_SECRET=sk_test_... -- and per-gateway keys --
-
Scheduler & queue
-
Add
* * * * * php /path-to-project/artisan schedule:run >> /dev/null 2>&1to cron. -
Start queue workers for background jobs:
php artisan queue:work --tries=3
-
- Customer — wrapper around host app user (nullable for guest customers). Stores billing preferences and external IDs.
- Plan — subscription offering (slug, description, features JSON, interval).
- Price — plan price per currency (amount in cents).
- Subscription — active relationship between Customer and Plan/Price.
- Invoice — billing document with line items and status (draft, sent, paid, refunded).
- Transaction — gateway-level charge / refund tracking.
- PaymentMethod — stored payment instruments (tokenized).
- UsageRecord — for metered billing.
- Coupon — discounts and promotions.
The package exposes a service
Billing(or facade) and a set of helper classes.
Create subscription
use Vendor\Billing\Facades\Billing;
$subscription = Billing::createSubscription($user, 'pro-plan', [
'price' => 'pro-monthly-usd',
'payment_method' => $paymentMethodToken,
'trial_days' => 14,
]);Charge a one-time payment
$charge = Billing::chargeOneTime($user, [
'amount' => 4999, // cents
'currency' => 'USD',
'description' => 'E-book purchase',
'payment_method' => $cardToken,
]);Generate invoice PDF
$invoice = Billing::generateInvoicePdf($invoiceId); // returns path or streamRefund
Billing::refundTransaction($transactionId, $amountInCents = null);More detailed examples will be added in docs and the example/demo app.
The package ships a publishable Livewire admin UI covering:
- Plans & Prices CRUD
- Customers & Payment Methods
- Subscriptions (change plans, proration, cancel/resume)
- Invoices & PDFs
- Transactions & refunds
- Gateway settings (API keys)
- Audit trail & logs
Admin routes are prefixed (configurable) and protected by a billing.admin middleware group which the host app maps to its preferred auth/gate system (e.g., auth + can:manage-billing). Views are publishable for full customization.
Architecture: Adapter pattern — each gateway implements Contracts/PaymentGatewayInterface:
createCustomer(array $data)attachPaymentMethod($customer, $methodData)createPaymentIntent($params)capturePayment($params)refund($chargeId, $amount)createSubscription($customer, $priceOrPlan)cancelSubscription($subId, $atPeriodEnd)handleWebhook(Request $request)
Built-in adapters (initial):
- Stripe (primary)
- PayPal
- A sandbox/mock gateway for testing
How to add another gateway
- Create adapter class implementing the gateway contract.
- Register adapter in
config/billing.phpor a service provider. - Add webhook route/handler that points to adapter webhook processor.
Idempotency & webhooks
- The package ensures idempotency by storing
external_idfrom gateways and by using idempotency keys when calling gateway APIs. - All webhooks are signature-verified where the gateway supports it.
Events published
SubscriptionCreated,SubscriptionCancelled,SubscriptionResumed,InvoiceGenerated,PaymentSucceeded,PaymentFailed,RefundProcessed,WebhookReceived.
Jobs
ProcessRecurringCharge,RetryFailedPayment,GenerateInvoicePdf,SendInvoiceEmail,SyncGatewayData.
Webhooks
- Each gateway registers webhooks under
routes/vendor/billing/webhooks/{gateway}. - Webhooks pass through signature verification middleware, and all events are emitted into the app event bus so the host app can listen.
- PCI scope: The package favors tokenization and hosted payment pages to keep PCI burden minimal. Payment data is not stored in raw form.
- Secrets: Gateway API keys should be stored in environment variables. The package may optionally encrypt keys in the DB using Laravel’s encryption helpers.
- Webhooks: Signature verification is enabled for supported gateways.
- Privacy: Customer PII is minimized; data export and deletion tools will be provided (GDPR/CCPA).
- Access control: Admin UI and CLI actions restricted by middleware/gates.
- Unit tests for core billing logic and proration math.
- Integration tests that use a sandbox gateway adapter (mocked).
- Livewire component tests (Pest or PHPUnit).
- GitHub Actions pipeline: run tests, static analysis (PHPStan/Psalm), PHP-CS-Fixer, and publish docs.
- Aim for strong coverage of billing computations and webhook idempotency.
MVP (v0.x)
- Plan/price model, subscriptions, Stripe adapter, basic Livewire UI, invoices, transactions, docs.
v1.0
- Multiple gateways (PayPal), proration, trials, coupons, PDF invoices, webhooks, transactional emails.
v1.x
- Metered billing, reconciliation tools, hosted checkout widget, multi-currency improvements, accounting integrations.
v2.0
- Multi-tenant capabilities, enterprise audit logs, advanced analytics dashboard.
Contributors: we will publish milestones and label issues for good first issue, help wanted, and roadmap.
We welcome contributions of all kinds — code, documentation, tests, ideas, or translations.
Before you contribute
- Read [CONTRIBUTING.md] (will be present in repo).
- Open an issue to discuss larger features before writing code.
- Follow PSR coding style; code must include tests for new behavior.
Typical workflow
- Fork the repo, create a topic branch.
- Run tests locally.
- Open a PR with a clear description and link to any issue it addresses.
- Add tests and docs for new features.
Needed right now
- README polish & design feedback
- Simple Stripe adapter improvements and test coverage
- Livewire admin scaffolding & UX feedback
- Translations and docs writers
- CI pipeline setup (GitHub Actions) and PHPStan config
- License: MIT (default for open-source friendly adoption — can be adjusted if community prefers another).
- Code of Conduct: Contributor Covenant (we will add CODE_OF_CONDUCT.md).
- Maintainers: initially project creator + trusted collaborators. We will maintain a transparent decision log and release cadence.
- Star the repo — higher visibility helps attract contributors.
- Comment — tell us what gateway, feature, or region matters to you (eg. Razorpay, PayU, Mollie, Adyen, local/regional gateways).
- Contribute code — fork and make PRs. Small focused PRs are easiest to review.
- Write docs / tutorials / integrations — examples for Jetstream, Breeze, Inertia, Nova, Vapor, Forge.
- Sponsor — sponsorship helps pay for CI minutes, domain, docs hosting, and maintainers’ time.
- Add unit tests for proration calculation with edge cases.
- Implement mock gateway that simulates network latencies and failures.
- Livewire CRUD for Coupons with validation and edge-case tests.
- Add localization for two languages (English + one other).
- Create a simple demo Laravel app showcasing the package with Stripe in test mode.
return [
'user_model' => env('BILLING_USER_MODEL', App\Models\User::class),
'default_currency' => env('BILLING_DEFAULT_CURRENCY', 'USD'),
'gateways' => [
'stripe' => [
'driver' => 'stripe',
'key' => env('STRIPE_KEY'),
'secret' => env('STRIPE_SECRET'),
'webhook_secret' => env('STRIPE_WEBHOOK_SECRET'),
],
'paypal' => [
'driver' => 'paypal',
'client_id' => env('PAYPAL_CLIENT_ID'),
'secret' => env('PAYPAL_SECRET'),
],
],
'admin_route_prefix' => 'billing-admin',
'admin_middleware' => ['web', 'auth', 'can:manage-billing'],
];Q: Will this store credit cards? A: No raw card data — we rely on tokenization or hosted checkout flows. Full details in security docs.
Q: What Laravel versions will be supported?
A: We’ll target at least the current LTS and the latest minor — see composer.json for exact constraints. Backwards compatibility will be maintained where reasonable.
Q: Can this support monthly and daily billing? A: Yes — billing intervals include days, weeks, months, years and custom intervals.
If you care about this project, please:
- Star the repo (when published).
- Open an issue describing which features or gateways you care about most.
- Comment here (or in the repo) with your use-case — SaaS, marketplace, accounting integrations, or country-specific payment needs.
- Join as a contributor — even a small PR (typo fix, docs, unit test) is huge.