laravel-polar
A package to easily integrate your Laravel application with Polar.sh
composer require danestves/laravel-polar Introduction
Laravel Polar brings Polar.sh subscriptions and payments to a Laravel app. It handles subscriptions, recurring payments and Polar’s API, with webhooks and subscription management built in.
Background
Laravel developers need a dependable way to take subscriptions and payments. Laravel Polar connects a Laravel app to Polar.sh, in the conventions and patterns Laravel developers already use.
Features
Subscription Management
- Complete subscription lifecycle handling
- Multiple subscription types support
- Flexible plan switching
- Grace period management
- Cancellation and resumption capabilities
Order Management
- Order tracking and management
- Refund handling
- Product and price verification
- Purchase history tracking
Webhook Integration
Built-in support for various webhook events:
- Subscription events (created, updated, canceled, etc.)
- Order events (created, refunded)
- Benefit grant events (created, updated, revoked)
Billable Models
- Easy integration with your existing User model
- Flexible subscription queries
- Purchase verification methods
- Subscription status checks
Implementation
Basic Setup
- Installation
composer require danestves/laravel-polar
- Model Configuration
use Danestves\LaravelPolar\Billable;
class User extends Authenticatable
{
use Billable;
}
Subscription Management
Creating Subscriptions
Route::get('/subscribe', function (Request $request) {
return $request->user()->subscribe('product_id_123');
});
Checking Subscription Status
if ($user->subscribed()) {
// User has an active subscription
}
if ($user->subscription()->hasProduct('product_id_123')) {
// User is subscribed to specific product
}
Advanced Features
Multiple Subscriptions
// Subscribe to different types
$user->subscribe('product_id_123', 'swimming');
$user->subscribe('product_id_456', 'gym');
// Access specific subscriptions
$swimmingSub = $user->subscription('swimming');
$gymSub = $user->subscription('gym');
Plan Switching
// Simple plan swap
$user->subscription()->swap('new_product_id');
// Immediate billing
$user->subscription()->swapAndInvoice('new_product_id');
Webhook Handling
namespace App\Listeners;
use Danestves\LaravelPolar\Events\WebhookHandled;
class PolarEventListener
{
public function handle(WebhookHandled $event): void
{
if ($event->payload['type'] === 'subscription.updated') {
// Handle subscription update
}
}
}
Impact
Laravel Polar has become an essential tool for Laravel developers integrating with Polar.sh:
- 84 stars and 14 forks on GitHub, as of October 2026
- Active development and maintenance
- Growing community adoption
- Comprehensive documentation
- Regular feature updates and bug fixes
Technical Details
The project is built with:
- PHP 99.8% / Blade 0.2%
- PHPStan for static analysis
- PHPUnit for testing
- Laravel-specific best practices
- MIT licensed for maximum flexibility
Roadmap
Future development plans include:
- Trial period support
- Enhanced subscription management features
- Additional webhook event handlers
- Expanded documentation and examples
Conclusion
Laravel Polar gives a Laravel app Polar.sh subscriptions and payments in the conventions it already uses, and it is still maintained.
Package: laravel-polar
- Since
- 2025
- What
- An open source package by Daniel Esteves