Download the PHP package nandocdev/plinth-multitenant-billing without Composer
On this page you can find all versions of the php package nandocdev/plinth-multitenant-billing. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package plinth-multitenant-billing
Plinth: Multi-Tenant Billing & Payment Orchestration
Plinth is a high-performance billing engine for Laravel SaaS applications. It provides a provider-agnostic abstraction layer that handles multi-tenant subscriptions, one-time payments, atomic usage metering, and financial integrity via an internal ledger.
๐ Core Capabilities
- Dynamic Provider Switching: Support Stripe and dLocal (extendable) out of the box. Each tenant can configure their own credentials.
- Financial Integrity (Ledger): Append-only ledger for all transactions, preventing data corruption and enabling easy auditing.
- Atomic Metering (Redis): High-performance usage tracking with atomic counters to prevent over-consumption in distributed systems.
- SaaS First: Built-in support for Plans, Subscriptions, Invoices, Quotas, and Entitlements (Feature Flags).
- Store-First Webhooks: Robust, multi-tenant webhook handling with cryptographic verification and queued processing.
๐ฆ Installation
1. Register Service Provider
(Laravel auto-discovery usually handles this, but if not:)
Add Plinth\MultiTenantBilling\BillingServiceProvider::class to your config/app.php.
2. Configuration & Migrations
๐ API Functionality
1. Dynamic Payment Resolution
Each tenant can have their own provider. You configure this in the tenant_payment_providers table.
2. Payment Processing
Use the PaymentProcessor to handle direct charges (B2C context).
3. Hosted Checkout (Facade)
For redirect-based flows (Checkout sessions).
4. Usage Metering & Quotas
Manage resource consumption atomically using Redis.
5. Entitlements (Feature Flags)
Check plan-based feature access with $O(1)$ complexity via Redis Sets.
โ Webhook Integration
Plinth uses unique endpoints per tenant and provider to ensure maximum security and isolation.
Routes Configuration
Endpoints follow this pattern: /api/{provider}/webhooks/{tenant_id}.
Example Webhook Setup:
- Stripe:
https://your-api.com/api/stripe/webhooks/1 - dLocal:
https://your-api.com/api/dlocal/webhooks/1
The WebhookController handles:
- Signature Verification: Validates the payload cryptographically using the specific tenant's secret.
- Store-First Persistence: Saves the raw payload in
webhook_calls. - Async Processing: Dispatches
ProcessWebhookJobfor status normalization and ledger recording.
๐ Domain Models Reference
| Category | Models |
|---|---|
| Billing | Plan, Subscription, SubscriptionItem, Invoice, InvoiceLine, BillingAttempt |
| Payments | Customer, Order, Transaction, PaymentMethod, Refund, Dispute |
| Core | LedgerEntry, TenantPaymentProvider, WebhookCall, UsageSnapshot |
๐งช Testing
The package includes a full suite of Pest tests.
For package development, Plinth utilizes orchestra/testbench to simulate the Laravel environment and provides a pre-configured TestCase with in-memory SQLite migrations.
๐ License
The MIT License (MIT). Please see License File for more information.
Developed with โค๏ธ by Fernando Castillo (@nandocdev)