PHPackages                             whilesmart/paywall - 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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. whilesmart/paywall

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

whilesmart/paywall
==================

Feature gates, quota checks, and usage tracking for Laravel applications

v1.0.0(1mo ago)037MITPHPPHP ^8.2CI passing

Since Mar 24Pushed 1mo agoCompare

[ Source](https://github.com/whilesmartphp/paywall)[ Packagist](https://packagist.org/packages/whilesmart/paywall)[ RSS](/packages/whilesmart-paywall/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (5)Versions (5)Used By (0)

Whilesmart Paywall
==================

[](#whilesmart-paywall)

Feature gates, quota checks, and usage tracking for Laravel applications via the subscriptions microservice.

[![Latest Version on Packagist](https://camo.githubusercontent.com/9870c76fcc593642e61e2477f28de1dea499be24b3d664c082b332eaacc69e8f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7768696c65736d6172742f70617977616c6c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/whilesmart/paywall)

Features
--------

[](#features)

- **Feature Gates**: Gate routes and actions behind subscription features
- **Quota Enforcement**: Check usage limits before allowing access, return quota details on denial
- **Usage Tracking**: Buffer usage locally, flush to the microservice in batches
- **Stripe Billing Proxy**: Get checkout and portal URLs from the microservice without needing `stripe/stripe-php`
- **Multiple Providers**: External (microservice API) or local (database) subscription providers
- **Grace Periods**: Configurable grace period for expired subscriptions
- **Role Bypass**: Admin roles can bypass feature gates
- **Laravel Auto-Discovery**: Automatically registers service provider

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

[](#installation)

```
composer require whilesmart/paywall
```

Publish the config and migrations:

```
php artisan vendor:publish --tag=paywall-config
php artisan vendor:publish --tag=paywall-migrations
php artisan migrate
```

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

[](#configuration)

Set your environment variables:

```
PAYWALL_PROVIDER=external
PAYWALL_EXTERNAL_URL=http://localhost:3000
PAYWALL_EXTERNAL_API_KEY=sk_your_api_key
PAYWALL_SUBSCRIBER_TYPE=user
```

Define features in `config/paywall.php`:

```
'features' => [
    'project_creation' => [
        'name' => 'Project Creation',
        'description' => 'Create and manage projects',
        'default_access' => false,
        'bypass_roles' => ['admin'],
    ],
],
```

Usage
-----

[](#usage)

### Middleware

[](#middleware)

```
// Boolean feature gate — returns 402 if denied
Route::middleware('paywall:project_creation')->group(function () {
    Route::post('/projects', [ProjectController::class, 'store']);
});

// Quota check — returns 402 with quota details if exhausted
Route::middleware('paywall.quota:projects')->group(function () {
    Route::post('/projects', [ProjectController::class, 'store']);
});

// Usage tracking — records usage after response is sent
Route::middleware('paywall.usage:api_calls')->group(function () {
    Route::get('/api/data', [DataController::class, 'index']);
});
```

### Facade

[](#facade)

```
use Whilesmart\Paywall\Facades\Paywall;

// Boolean check
if (Paywall::hasAccess($user, 'project_creation')) {
    // allowed
}

// Detailed check with limits and subscription info
$result = Paywall::checkAccess($user, 'projects');
$result->allowed;              // bool
$result->reason;               // "Quota exceeded" etc.
$result->limit->remaining;     // 3
$result->subscription->status; // "active"

// Record usage
Paywall::recordUsage($user, 'api_calls', 1, ['endpoint' => '/api/users']);

// Stripe checkout (proxied via microservice)
$url = Paywall::getCheckoutUrl($user, 'pro', $successUrl, $cancelUrl);
return redirect($url);

// Stripe billing portal
$url = Paywall::getPortalUrl($user, $returnUrl);
return redirect($url);
```

### HasSubscription Trait

[](#hassubscription-trait)

```
use Whilesmart\Paywall\Traits\HasSubscription;

class User extends Model
{
    use HasSubscription;
}
```

```
$user->subscribed();           // bool
$user->onTrial();              // bool
$user->canAccess('projects');  // bool
$user->checkAccess('projects'); // AccessResult
$user->featureUsage('projects'); // FeatureLimit
$user->subscription();         // array|null
```

### Usage Buffer

[](#usage-buffer)

Usage is buffered locally to avoid HTTP calls during requests. Flush via cron:

```
php artisan paywall:flush-usage
```

Add to your scheduler:

```
$schedule->command('paywall:flush-usage')->everyMinute();
```

Requirements
------------

[](#requirements)

- PHP ^8.2
- Laravel ^11.0|^12.0

License
-------

[](#license)

The MIT License (MIT).

###  Health Score

42

—

FairBetter than 89% of packages

Maintenance91

Actively maintained with recent releases

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% 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.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

41d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/a1ca6f6e01ecbfe6640ff410c4f0321054fb48d05a5f843c2b89887b90369bcd?d=identicon)[whilesmart](/maintainers/whilesmart)

---

Top Contributors

[![kofimokome](https://avatars.githubusercontent.com/u/21100923?v=4)](https://github.com/kofimokome "kofimokome (3 commits)")[![nfebe](https://avatars.githubusercontent.com/u/14317775?v=4)](https://github.com/nfebe "nfebe (3 commits)")

---

Tags

phplaravelpackagesubscriptionsquotapaywallfeature-gatesusage-tracking

###  Code Quality

TestsPHPUnit

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/whilesmart-paywall/health.svg)

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

###  Alternatives

[lab404/laravel-impersonate

Laravel Impersonate is a plugin that allows to you to authenticate as your users.

2.3k17.8M58](/packages/lab404-laravel-impersonate)[santigarcor/laratrust

This package provides a flexible way to add Role-based Permissions to Laravel

2.3k5.6M46](/packages/santigarcor-laratrust)[mominalzaraa/filament-localization

The first and only automatic Filament localization package with intelligent resource scanning, structured translation files, and comprehensive testing

101.6k](/packages/mominalzaraa-filament-localization)

PHPackages © 2026

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