PHPackages                             mhmadahmd/filasaas - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. mhmadahmd/filasaas

ActiveLibrary

mhmadahmd/filasaas
==================

This is my package filasaas

110PHP

Since Dec 16Pushed 4mo agoCompare

[ Source](https://github.com/mhmadahmd/FilaSAAS)[ Packagist](https://packagist.org/packages/mhmadahmd/filasaas)[ RSS](/packages/mhmadahmd-filasaas/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

Filasaas - Multi-Gateway Billing and Subscription System
========================================================

[](#filasaas---multi-gateway-billing-and-subscription-system)

[![Latest Version on Packagist](https://camo.githubusercontent.com/cc4c6a74bbfeb0827742c529487c17ea3987909e0a163649282eece987397012/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d686d616461686d642f66696c61736161732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mhmadahmd/filasaas)[![GitHub Tests Action Status](https://camo.githubusercontent.com/ec41a283dfa2a95f50a8c9fa1800c963704ef325f4a64f72a6baee359190315e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d686d616461686d642f66696c61736161732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/mhmadahmd/filasaas/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/13621da5b925361d8d16ebb74a5a07aa44643b03bab1e0f612d2d0d720292abd/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d686d616461686d642f66696c61736161732f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/mhmadahmd/filasaas/actions?query=workflow%3A%22Fix+PHP+code+styling%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/46a6edae7ecdad32d083200f1bfb0866469b80d7c8e812c1ff68781847701c34/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d686d616461686d642f66696c61736161732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mhmadahmd/filasaas)

A comprehensive Filament plugin for billing and subscription management with multi-gateway support. Supports Cash payments (with configurable approval workflow), Stripe (via Laravel Cashier), PayPal (via Laravel package), and extensible custom local gateways.

Features
--------

[](#features)

- **Multi-Gateway Support**: Cash, Stripe, PayPal, and extensible custom gateways
- **Configurable Cash Approval**: Plans can auto-approve or require manual admin approval
- **Unified Gateway Interface**: All payment methods use the same interface
- **Plan-Based Gateway Restrictions**: Plans can limit which payment methods are available
- **Admin Approval Workflow**: Manual approval system for cash payments with audit trail
- **Webhook Support**: Handle payment status updates from all gateways
- **Subscription Management**: Full lifecycle management (create, cancel, switch, renew)
- **Feature-Based Plans**: Plans with features and usage tracking
- **Trial &amp; Grace Periods**: Support for trial periods and grace periods
- **Filament Integration**: Complete Filament 4 resources, pages, and actions

Installation
------------

[](#installation)

```
composer require mhmadahmd/filasaas
```

Publish and run the migrations:

```
php artisan vendor:publish --tag="filasaas-migrations"
php artisan migrate
```

Publish the config file:

```
php artisan vendor:publish --tag="filasaas-config"
```

Configuration
-------------

[](#configuration)

After publishing the config file, configure your payment gateways in `config/filasaas.php`:

```
'gateways' => [
    'cash' => [
        'enabled' => true,
        'default_approval_mode' => 'manual', // 'auto' or 'manual'
    ],
    'stripe' => [
        'enabled' => true,
        'key' => env('STRIPE_KEY'),
        'secret' => env('STRIPE_SECRET'),
        'webhook_secret' => env('STRIPE_WEBHOOK_SECRET'),
    ],
    'paypal' => [
        'enabled' => true,
        'mode' => env('PAYPAL_MODE', 'sandbox'),
        'client_id' => env('PAYPAL_CLIENT_ID'),
        'client_secret' => env('PAYPAL_CLIENT_SECRET'),
    ],
],
```

Quick Start
-----------

[](#quick-start)

### 1. Add Trait to Billable Model

[](#1-add-trait-to-billable-model)

Add the `HasPlanSubscriptions` trait to your User model (or any billable model):

```
use Mhmadahmd\Filasaas\Traits\HasPlanSubscriptions;

class User extends Authenticatable
{
    use HasPlanSubscriptions;
    // ...
}
```

### 2. Register the Plugin

[](#2-register-the-plugin)

Register the plugin in your Filament panel provider (e.g., `app/Providers/Filament/AdminPanelProvider.php`):

```
use Mhmadahmd\Filasaas\FilasaasPlugin;

public function panel(Panel $panel): Panel
{
    return $panel
        // ... other panel configuration
        ->plugin(FilasaasPlugin::make());
}
```

**Important:** Use `->plugin()` (singular) and pass the plugin instance directly, not an array.

### 3. Create a Plan

[](#3-create-a-plan)

Use the Plan resource in Filament to create subscription plans with features.

### 4. Subscribe Users

[](#4-subscribe-users)

Users can subscribe through the Billing page or programmatically:

```
use Mhmadahmd\Filasaas\Services\TenantBillingProvider;

$billingProvider = app(TenantBillingProvider::class);
$subscription = $billingProvider->subscribeToPlan($planId, 'cash');
```

Usage Examples
--------------

[](#usage-examples)

### Check if User is Subscribed

[](#check-if-user-is-subscribed)

```
$user = User::find(1);
$billingProvider = app(TenantBillingProvider::class);

if ($billingProvider->isSubscribedTo($planId, $user)) {
    // User is subscribed
}
```

### Cancel Subscription

[](#cancel-subscription)

```
$billingProvider = app(TenantBillingProvider::class);
$billingProvider->cancelSubscription($subscriptionId, $immediately = false);
```

### Record Feature Usage

[](#record-feature-usage)

```
$subscription = Subscription::find(1);
$subscription->recordFeatureUsage($featureId, $uses = 1);
```

### Check Feature Access

[](#check-feature-access)

```
if ($subscription->canUseFeature($featureId)) {
    // User can use this feature
}
```

Gateway Setup
-------------

[](#gateway-setup)

### Cash Gateway

[](#cash-gateway)

The cash gateway is enabled by default. Configure auto-approval per plan:

```
$plan->cash_auto_approve = true; // Auto-approve
$plan->cash_auto_approve = false; // Require manual approval
```

### Stripe Gateway

[](#stripe-gateway)

1. Install Laravel Cashier (optional but recommended):

```
composer require laravel/cashier-stripe
```

2. Configure Stripe credentials in `.env`:

```
STRIPE_KEY=your_stripe_key
STRIPE_SECRET=your_stripe_secret
STRIPE_WEBHOOK_SECRET=your_webhook_secret

```

3. Enable Stripe in config:

```
'stripe' => [
    'enabled' => true,
    // ...
],
```

### PayPal Gateway

[](#paypal-gateway)

1. Configure PayPal credentials in `.env`:

```
PAYPAL_MODE=sandbox
PAYPAL_CLIENT_ID=your_client_id
PAYPAL_CLIENT_SECRET=your_client_secret

```

2. Enable PayPal in config:

```
'paypal' => [
    'enabled' => true,
    // ...
],
```

3. Set up PayPal webhook URL: `https://yourdomain.com/webhooks/billing/paypal`

### Custom Gateways

[](#custom-gateways)

See [CUSTOM\_GATEWAYS.md](docs/CUSTOM_GATEWAYS.md) for detailed instructions on implementing custom local gateways.

API Documentation
-----------------

[](#api-documentation)

### TenantBillingProvider

[](#tenantbillingprovider)

Main service for subscription management:

- `subscribeToPlan(int $planId, string $gateway, array $options = []): Subscription`
- `cancelSubscription(int $subscriptionId, bool $immediately = false): Subscription`
- `switchPlan(int $subscriptionId, int $newPlanId, array $options = []): Subscription`
- `getCurrentSubscriptions(): Collection`
- `getActiveSubscriptions(): Collection`
- `getAvailablePlans(): Collection`
- `getPaymentHistory(?int $limit = 10): Collection`
- `hasActiveSubscription(): bool`
- `isSubscribedTo(int $planId): bool`

### PaymentGatewayManager

[](#paymentgatewaymanager)

Service for managing payment gateways:

- `register(string $identifier, PaymentGatewayInterface $gateway): void`
- `get(string $identifier): ?PaymentGatewayInterface`
- `getAll(): array`
- `getAvailableForPlan(Plan $plan): array`
- `processPayment(SubscriptionPayment $payment): mixed`
- `isGatewayAvailable(string $gateway, Plan $plan): bool`

Middleware
----------

[](#middleware)

Use the `VerifyBillableIsSubscribed` middleware to protect routes:

```
Route::middleware([\Mhmadahmd\Filasaas\Middleware\VerifyBillableIsSubscribed::class])
    ->group(function () {
        // Protected routes
    });
```

Webhooks
--------

[](#webhooks)

Webhook routes are automatically registered:

- PayPal: `POST /webhooks/billing/paypal`
- Custom Gateways: `POST /webhooks/billing/{gateway}`

Testing
-------

[](#testing)

```
composer test
```

Documentation
-------------

[](#documentation)

- [Installation Guide](docs/INSTALLATION.md)
- [Custom Gateways Guide](docs/CUSTOM_GATEWAYS.md)

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](.github/CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Mohammad Ahmad](https://github.com/mhmadahmd)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

19

—

LowBetter than 10% of packages

Maintenance50

Moderate activity, may be stable

Popularity7

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity12

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://www.gravatar.com/avatar/3dbc6e6a4390cfa1c7e41826b7a99a1b990e30629ce01997f96ace20241459fa?d=identicon)[mhmadahmd](/maintainers/mhmadahmd)

---

Top Contributors

[![mhmadahmd](https://avatars.githubusercontent.com/u/16565669?v=4)](https://github.com/mhmadahmd "mhmadahmd (13 commits)")

### Embed Badge

![Health badge](/badges/mhmadahmd-filasaas/health.svg)

```
[![Health](https://phpackages.com/badges/mhmadahmd-filasaas/health.svg)](https://phpackages.com/packages/mhmadahmd-filasaas)
```

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
