PHPackages                             akyroslabs/laravel-polar - 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. [Payment Processing](/categories/payments)
4. /
5. akyroslabs/laravel-polar

ActiveLibrary[Payment Processing](/categories/payments)

akyroslabs/laravel-polar
========================

Polar.sh integration for Laravel — subscriptions, checkout, customer portal, webhooks, plan limits, usage billing, and benefits. Polar as Merchant of Record.

v2.0.0(yesterday)00MITPHPPHP ^8.2

Since Apr 4Pushed yesterdayCompare

[ Source](https://github.com/akyroslabs/laravel-polar)[ Packagist](https://packagist.org/packages/akyroslabs/laravel-polar)[ RSS](/packages/akyroslabs-laravel-polar/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (3)Versions (3)Used By (0)

Laravel Polar
=============

[](#laravel-polar)

Polar.sh integration for Laravel — subscriptions, checkout, customer portal, webhooks, plan limits, usage billing, benefits, and more. Polar as Merchant of Record.

No tax headaches. No invoice logic. Polar handles it all.

---

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

[](#installation)

```
composer require akyroslabs/laravel-polar
```

Publish config and migrations:

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

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

[](#configuration)

Add to your `.env`:

```
POLAR_API_KEY=polar_key_...
POLAR_WEBHOOK_SECRET=whsec_...
POLAR_SANDBOX=false
POLAR_BILLABLE_MODEL=App\Models\Tenant
```

Configure plans in `config/polar.php`:

```
'plans' => [
    'free' => [
        'product_id' => null,
        'limits' => ['servers' => 2, 'users' => 1],
        'features' => ['basic_monitoring'],
    ],
    'starter' => [
        'product_id' => 'polar-product-id',
        'limits' => ['servers' => 10, 'users' => 3],
        'features' => ['*'],
    ],
    'pro' => [
        'product_id' => 'polar-product-id',
        'limits' => ['servers' => 50, 'users' => 10],
        'features' => ['*'],
    ],
],
```

Setup
-----

[](#setup)

Add the `Billable` trait to your model:

```
use AkyrosLabs\Polar\Billable;

class Tenant extends Model
{
    use Billable;
}
```

Register the webhook URL in your Polar dashboard:

```
https://your-app.com/polar/webhook

```

Checkout
--------

[](#checkout)

```
// Redirect to Polar checkout
return $tenant->checkout('price_id')
    ->successUrl('/dashboard?upgraded=1')
    ->redirect();

// Subscribe to a plan
return $tenant->subscribe('price_id')
    ->successUrl('/dashboard')
    ->redirect();

// One-time charge
return $tenant->charge(4999, 'product_id')
    ->redirect();

// Just get the URL
$url = $tenant->checkout('price_id')->url();
```

Subscription Management
-----------------------

[](#subscription-management)

```
// Check status
$tenant->subscribed();              // Has active subscription?
$tenant->subscribed('default', $productId);  // On specific product?
$tenant->onTrial();                 // In trial?
$tenant->onGracePeriod();           // Canceled but still active?

// Get subscription
$sub = $tenant->subscription();
$sub->active();                     // Active?
$sub->canceled();                   // Canceled?
$sub->valid();                      // Active, trial, or grace period?
$sub->ended();                      // Fully ended?
$sub->pastDue();                    // Payment past due?

// Actions
$sub->swap('new_price_id');         // Change plan
$sub->cancel();                     // Cancel at period end
$sub->resume();                     // Resume during grace period
```

Customer Portal
---------------

[](#customer-portal)

```
return redirect($tenant->customerPortalUrl());

// Or shorthand
return $tenant->redirectToCustomerPortal();
```

Plan Limits &amp; Features
--------------------------

[](#plan-limits--features)

```
$tenant->planName();                    // "pro"
$tenant->planLimit('servers');          // 50
$tenant->planLimit('users');            // 10
$tenant->hasFeature('attack_mode');     // true
$tenant->onFreePlan();                  // false
$tenant->exceedsLimit('servers', 48);   // false
$tenant->exceedsLimit('servers', 50);   // true
$tenant->planLimits();                  // ['servers' => 50, 'users' => 10]
$tenant->planFeatures();               // ['*']
```

Usage-Based Billing
-------------------

[](#usage-based-billing)

```
// Track single event
$tenant->ingestUsageEvent('api_call', ['endpoint' => '/servers']);

// Batch events
$tenant->ingestUsageEvents([
    ['name' => 'api_call', 'metadata' => ['endpoint' => '/alerts']],
    ['name' => 'api_call', 'metadata' => ['endpoint' => '/servers']],
]);

// Get meters
$tenant->listCustomerMeters();
```

Benefits
--------

[](#benefits)

```
$tenant->listBenefits();
$tenant->getBenefit('benefit_id');
$tenant->listBenefitGrants('benefit_id');
```

Orders
------

[](#orders)

```
$tenant->orders;                          // All orders
$tenant->hasPurchasedProduct('product_id'); // Check purchase
```

Webhooks
--------

[](#webhooks)

The package automatically processes these Polar events:

EventAction`subscription.created`Creates subscription + customer record`subscription.updated`Syncs status, product, period end`subscription.active`Sets status to active`subscription.canceled`Sets status to canceled`subscription.revoked`Sets status to revoked`order.created`Creates order record`order.updated`Syncs order data`customer.created/updated/deleted`Syncs customer records`checkout.created/updated`Fires events`benefit_grant.created/updated/revoked`Fires events### Custom Event Listeners

[](#custom-event-listeners)

```
use AkyrosLabs\Polar\Events\SubscriptionCreated;

class HandleNewSubscription
{
    public function handle(SubscriptionCreated $event): void
    {
        $tenant = $event->billable;
        // Send welcome email, provision resources, etc.
    }
}
```

**17 events available:** WebhookReceived, WebhookHandled, SubscriptionCreated, SubscriptionUpdated, SubscriptionActive, SubscriptionCanceled, SubscriptionRevoked, OrderCreated, OrderUpdated, CustomerCreated, CustomerUpdated, CustomerDeleted, CheckoutCreated, CheckoutUpdated, BenefitGrantCreated, BenefitGrantUpdated, BenefitGrantRevoked

Middleware
----------

[](#middleware)

```
// In bootstrap/app.php — auto-registered as 'subscribed'
Route::middleware('subscribed')->group(function () {
    // Requires any active subscription
});

Route::middleware('subscribed:pro')->group(function () {
    // Requires specific plan
});
```

Blade Directives
----------------

[](#blade-directives)

```
@subscribed
    You have an active subscription.
@endsubscribed

@onPlan('pro')
    Pro features here.
@endonPlan

@onTrial
    Your trial ends soon.
@endonTrial

@feature('attack_mode')
    Activate Attack Mode
@endfeature
```

Artisan Commands
----------------

[](#artisan-commands)

```
# Sync all subscriptions with Polar
php artisan polar:sync

# List all products
php artisan polar:products
```

Facade
------

[](#facade)

```
use AkyrosLabs\Polar\Facades\Polar;

$products = Polar::listProducts();
$subscription = Polar::getSubscription($id);
$session = Polar::createCustomerSession($customerId);
```

Database Tables
---------------

[](#database-tables)

TablePurpose`polar_customers`Billable ↔ Polar customer mapping, generic trial`polar_subscriptions`Active subscriptions with status, product, period`polar_orders`Orders with amounts, tax, refund trackingAll tables use polymorphic `billable` relationships — works with any model.

Sandbox Mode
------------

[](#sandbox-mode)

Set `POLAR_SANDBOX=true` to use `sandbox-api.polar.sh` for testing.

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

[](#requirements)

- PHP 8.2+
- Laravel 11 or 12

License
-------

[](#license)

MIT License

---

Built by [Akyros Labs LLC](https://akyroslabs.com) —

###  Health Score

40

—

FairBetter than 87% of packages

Maintenance100

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity47

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1d ago

Major Versions

v1.0.0 → v2.0.02026-04-04

### Community

Maintainers

![](https://www.gravatar.com/avatar/2a92905b10878a7760ef1c7e23d505308880336d99c2b247fe4759c4d31185ca?d=identicon)[AkyrosLabs](/maintainers/AkyrosLabs)

---

Top Contributors

[![akyroslabs](https://avatars.githubusercontent.com/u/257565678?v=4)](https://github.com/akyroslabs "akyroslabs (2 commits)")

---

Tags

laravelbillingsubscriptionssaasmerchant-of-recordpolarusage billing

### Embed Badge

![Health badge](/badges/akyroslabs-laravel-polar/health.svg)

```
[![Health](https://phpackages.com/badges/akyroslabs-laravel-polar/health.svg)](https://phpackages.com/packages/akyroslabs-laravel-polar)
```

###  Alternatives

[mollie/laravel-cashier-mollie

Laravel Cashier provides an expressive, fluent interface to Mollie's subscription billing services.

172155.4k1](/packages/mollie-laravel-cashier-mollie)[chargebee/cashier

Laravel Cashier for Chargebee provides an expressive, fluent interface to Chargebee's subscription billing services.

627.4k1](/packages/chargebee-cashier)

PHPackages © 2026

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