Skip to main content

Documentation Index

Fetch the complete documentation index at: https://danestvesllc-2b77d201.mintlify.app/llms.txt

Use this file to discover all available pages before exploring further.

Laravel Polar is a first-class Laravel package that connects your application to Polar.sh — the billing platform built for developers. With a single Billable trait you unlock checkout sessions, subscription management, webhooks, license keys, usage-based billing, and more, all with a fluent PHP API that feels right at home in Laravel.

Installation

Install the package and run the setup command to get your application connected to Polar.sh in minutes.

Configuration

Configure your access token, webhook secret, environment, and other options.

Billable Trait

Add the Billable trait to any Eloquent model to unlock the full billing API.

Webhooks

Handle real-time billing events from Polar.sh using typed Laravel events.

Get started in 4 steps

1

Install the package

Add Laravel Polar to your project via Composer and run the install command.
composer require danestves/laravel-polar
php artisan polar:install
2

Configure your credentials

Add your Polar.sh access token and webhook secret to your .env file.
POLAR_ACCESS_TOKEN="your_access_token"
POLAR_WEBHOOK_SECRET="your_webhook_secret"
POLAR_SERVER="sandbox"
3

Add the Billable trait

Apply the Billable trait to your User model (or any model that should be billed).
use Danestves\LaravelPolar\Billable;

class User extends Authenticatable
{
    use Billable;
}
4

Create your first checkout

Send customers to a Polar checkout with a single method call.
Route::get('/subscribe', function (Request $request) {
    return $request->user()->checkout(['your_product_id']);
});

Explore by feature

Checkout

One-time payments, multi-product checkouts, embedded checkout, and reusable checkout links.

Subscriptions

Create, cancel, resume, and swap subscription plans. Supports multiple subscription types per user.

Orders & Invoices

Retrieve order history, issue refunds, and generate downloadable PDF invoices.

License Keys

Issue, validate, and manage license keys as a product benefit.

Usage Billing

Track metered usage events and charge customers based on actual consumption.

Discounts

Create coupon codes and apply discounts to checkouts and subscriptions.