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.

The LaravelPolar facade is the primary entry point for calling Polar’s API from anywhere in your application. Every method is a thin, opinionated wrapper that:
  • Authenticates the request with your configured POLAR_ACCESS_TOKEN
  • Calls the underlying Polar PHP SDK
  • Throws a typed Polar\Models\Errors\APIException if the request fails
All methods are static and can be called from controllers, jobs, services, or anywhere else.
All Components\* and Operations\* types referenced below live in the Polar\Models\Components and Polar\Models\Operations namespaces respectively. Import them with use Polar\Models\Components; and use Polar\Models\Operations;.

Checkouts

createCheckoutSession

Create a hosted checkout session and redirect the customer to Polar’s checkout page.
use Danestves\LaravelPolar\LaravelPolar;
use Polar\Models\Components;

$checkout = LaravelPolar::createCheckoutSession(
    new Components\CheckoutCreate(
        productPriceId: 'price_xxx',
    )
);

return redirect($checkout->url);
ParameterTypeDescription
$requestComponents\CheckoutCreateCheckout creation payload.
Returns Components\Checkout — the created checkout object, including its hosted url. Throws Errors\APIException when the API returns a non-201 status.
Checkout links are reusable, shareable URLs that do not require a live session. Use them in marketing emails, landing pages, or “Buy now” buttons.
$link = LaravelPolar::createCheckoutLink(
    new Components\CheckoutLinkCreateProduct(
        productId: 'product_xxx',
        paymentProcessor: 'stripe',
    )
);

echo $link->url;
Three create variants are available:
ClassWhen to use
CheckoutLinkCreateProductSingle product, any price
CheckoutLinkCreateProductPriceSingle product pinned to a specific price
CheckoutLinkCreateProductsMultiple products — customer picks one
Returns Components\CheckoutLink.
LaravelPolar::updateCheckoutLink(
    'cl_xxx',
    new Components\CheckoutLinkUpdate(label: 'Black Friday')
);
ParameterTypeDescription
$checkoutLinkIdstringID of the checkout link to update.
$requestComponents\CheckoutLinkUpdateFields to update.
Returns Components\CheckoutLink.
LaravelPolar::deleteCheckoutLink('cl_xxx');
ParameterTypeDescription
$checkoutLinkIdstringID of the checkout link to delete.
Returns void. Throws on non-200/204 status.
$response = LaravelPolar::listCheckoutLinks();
// or with filters:
$response = LaravelPolar::listCheckoutLinks(
    new Operations\CheckoutLinksListRequest(page: 1, limit: 20)
);
ParameterTypeDescription
$request?Operations\CheckoutLinksListRequestOptional filters and pagination. Defaults to a blank request.
Returns Operations\CheckoutLinksListResponse.
$link = LaravelPolar::getCheckoutLink('cl_xxx');
ParameterTypeDescription
$checkoutLinkIdstringID of the checkout link to fetch.
Returns Components\CheckoutLink.

Subscriptions

updateSubscription

Modify an existing subscription — swap product, cancel, apply or remove a discount, adjust the trial, update seats, or revoke.
use Polar\Models\Components;

// Swap to a different product:
LaravelPolar::updateSubscription(
    'sub_xxx',
    new Components\SubscriptionUpdateProduct(productId: 'product_yyy')
);

// Cancel at period end:
LaravelPolar::updateSubscription(
    'sub_xxx',
    new Components\SubscriptionCancel()
);
ParameterTypeDescription
$subscriptionIdstringID of the subscription to update.
$request`SubscriptionUpdateProductSubscriptionCancelSubscriptionUpdateDiscountSubscriptionUpdateTrialSubscriptionUpdateSeatsSubscriptionRevoke`The specific update variant to apply.
Returns Components\Subscription.
For most use cases you should prefer the fluent helpers on the Subscription model ($subscription->swap(), $subscription->cancel(), $subscription->applyDiscount()) — they call this method under the hood.

Products

listProducts

Retrieve all products available in your Polar organization.
$response = LaravelPolar::listProducts();

foreach ($response->listResourceProduct?->items ?? [] as $product) {
    echo $product->name;
}
You can filter with a request object:
$response = LaravelPolar::listProducts(
    new Operations\ProductsListRequest(isArchived: false)
);
ParameterTypeDescription
$request?Operations\ProductsListRequestOptional filters. Defaults to a blank request when null.
Returns Operations\ProductsListResponse.

Customers

createCustomerSession

Mint a short-lived customer session token. The package uses this internally to authenticate customer-portal and payment-method calls without exposing your admin token.
$session = LaravelPolar::createCustomerSession(
    new Components\CustomerSessionCustomerIDCreate(customerId: 'cust_xxx')
);

// or by external ID:
$session = LaravelPolar::createCustomerSession(
    new Components\CustomerSessionCustomerExternalIDCreate(externalCustomerId: 'user_42')
);
ParameterTypeDescription
$request`CustomerSessionCustomerIDCreateCustomerSessionCustomerExternalIDCreate`Identifies the customer either by Polar ID or your own external ID.
Returns Components\CustomerSession.

Discounts

Discounts are reusable coupon codes. Four create variants cover fixed/percentage amounts and once/repeat durations.

createDiscount

$discount = LaravelPolar::createDiscount(
    new Components\DiscountPercentageOnceForeverDurationCreate(
        name: 'Black Friday 50%',
        type: Components\DiscountType::Percentage,
        duration: Components\DiscountDuration::Once,
        basisPoints: 5000,
        organizationId: 'your-org-id',
    )
);
ParameterType
$request`DiscountFixedOnceForeverDurationCreateDiscountFixedRepeatDurationCreateDiscountPercentageOnceForeverDurationCreateDiscountPercentageRepeatDurationCreate`
Returns the matching discount response union type.

updateDiscount

LaravelPolar::updateDiscount(
    'disc_xxx',
    new Components\DiscountUpdate(name: 'Black Friday extended')
);
ParameterType
$discountIdstring
$requestComponents\DiscountUpdate
Returns discount union type.

deleteDiscount

LaravelPolar::deleteDiscount('disc_xxx');
Returns void.

listDiscounts

$response = LaravelPolar::listDiscounts();
// or filtered:
$response = LaravelPolar::listDiscounts(new Operations\DiscountsListRequest());
ParameterType
$request?Operations\DiscountsListRequest
Returns Operations\DiscountsListResponse.

getDiscount

$discount = LaravelPolar::getDiscount('disc_xxx');
Returns discount union type.

Benefits

Benefits are features automatically granted to customers when they buy a product. Six create variants are supported: BenefitCustomCreate, BenefitDiscordCreate, BenefitGitHubRepositoryCreate, BenefitDownloadablesCreate, BenefitLicenseKeysCreate, BenefitMeterCreditCreate.

createBenefit

$benefit = LaravelPolar::createBenefit(
    new Components\BenefitCustomCreate(
        description: 'Premium Support',
        organizationId: 'your-org-id',
        properties: new Components\BenefitCustomCreateProperties(),
    )
);
Returns benefit union type.

updateBenefit

LaravelPolar::updateBenefit(
    'benefit_xxx',
    new Components\BenefitCustomUpdate(description: 'Updated Premium Support')
);
ParameterType
$benefitIdstring
$requestbenefit update union type
Returns benefit union type.

deleteBenefit

LaravelPolar::deleteBenefit('benefit_xxx');
Returns void.

listBenefits

$response = LaravelPolar::listBenefits(
    new Operations\BenefitsListRequest()
);
ParameterType
$requestOperations\BenefitsListRequest
Returns Operations\BenefitsListResponse.

getBenefit

$benefit = LaravelPolar::getBenefit('benefit_xxx');
Returns benefit union type.

listBenefitGrants

List all grants for a specific benefit — i.e. which customers have been given it.
$response = LaravelPolar::listBenefitGrants(
    new Operations\BenefitsGrantsRequest(benefitId: 'benefit_xxx')
);
ParameterType
$requestOperations\BenefitsGrantsRequest
Returns Operations\BenefitsGrantsResponse.

Custom fields

Custom fields let you collect arbitrary data at checkout — company name, VAT number, seat count, and so on. Five field types are supported: Text, Number, Date, Checkbox, Select.

createCustomField

$field = LaravelPolar::createCustomField(
    new Components\CustomFieldCreateText(
        slug: 'company',
        name: 'Company name',
        properties: new Components\CustomFieldTextProperties(),
    )
);
ParameterType
$request`CustomFieldCreateTextCustomFieldCreateNumberCustomFieldCreateDateCustomFieldCreateCheckboxCustomFieldCreateSelect`
Returns custom field union type.

updateCustomField

LaravelPolar::updateCustomField(
    'cf_xxx',
    new Components\CustomFieldUpdateText(name: 'Organization name')
);
ParameterType
$customFieldIdstring
$requestcustom field update union type
Returns custom field union type.

deleteCustomField

LaravelPolar::deleteCustomField('cf_xxx');
Returns void.

listCustomFields

$response = LaravelPolar::listCustomFields();
// or with filters:
$response = LaravelPolar::listCustomFields(
    new Operations\CustomFieldsListRequest()
);
ParameterType
$request?Operations\CustomFieldsListRequest
Returns Operations\CustomFieldsListResponse.

getCustomField

$field = LaravelPolar::getCustomField('cf_xxx');
Returns custom field union type.

License keys

License keys are a benefit type for desktop apps, CLIs, and SDKs. The facade exposes three distinct surfaces: admin management (org-scoped token), public verification (no admin token required), and listing keys per customer.
The public verification methods (validateLicenseKey, activateLicenseKey, deactivateLicenseKey) require an organization ID. Either pass it explicitly on each call, or set POLAR_ORGANIZATION_ID in your .env and the package resolves it automatically.

listLicenseKeys

Admin-scoped. Lists all license keys for your organization.
$response = LaravelPolar::listLicenseKeys();

// Filter by benefit or scope to a specific organization:
$response = LaravelPolar::listLicenseKeys(
    organizationId: 'org_xxx',
    benefitId: 'benefit_xxx',
    page: 1,
    limit: 50,
);
ParameterTypeDefault
$organizationId`stringarraynull`null
$benefitId`stringarraynull`null
$page?intnull
$limit?intnull
Returns Operations\LicenseKeysListResponse.

getLicenseKey

$key = LaravelPolar::getLicenseKey('lk_xxx');

echo $key->activations; // array of LicenseKeyActivationRead
Returns Components\LicenseKeyWithActivations.

updateLicenseKey

LaravelPolar::updateLicenseKey(
    'lk_xxx',
    new Components\LicenseKeyUpdate(limitActivations: 10)
);
ParameterType
$licenseKeyIdstring
$requestComponents\LicenseKeyUpdate
Returns Components\LicenseKeyRead.

validateLicenseKey

Public-facing. Validates a key and optionally increments a usage counter.
$validated = LaravelPolar::validateLicenseKey(
    key: 'LIC-XXXX-XXXX-XXXX',
    activationId: 'act_xxx',     // optional — bind to a specific activation
    incrementUsage: 1,           // optional — metered usage
);
ParameterTypeDefault
$keystring
$organizationId?stringreads polar.organization_id config
$activationId?stringnull
$conditions?array<string, mixed>null
$benefitId?stringnull
$customerId?stringnull
$incrementUsage?intnull
Returns Components\ValidatedLicenseKey.

activateLicenseKey

Register a new device/activation for a key.
$activation = LaravelPolar::activateLicenseKey(
    key: 'LIC-XXXX-XXXX-XXXX',
    label: 'My MacBook Pro',
    meta: ['hostname' => 'macbook-pro', 'os' => 'darwin'],
);
ParameterTypeDefault
$keystring
$labelstring
$organizationId?stringreads config
$conditions?array<string, mixed>null
$meta?array<string, mixed>null
Returns Components\LicenseKeyActivationRead.

deactivateLicenseKey

Remove a specific activation from a key.
LaravelPolar::deactivateLicenseKey(
    key: 'LIC-XXXX-XXXX-XXXX',
    activationId: 'act_xxx',
);
ParameterTypeDefault
$keystring
$activationIdstring
$organizationId?stringreads config
Returns void.

Refunds

createRefund

Issue a refund for an order.
LaravelPolar::createRefund(
    new Components\RefundCreate(
        orderId: 'ord_xxx',
        reason: Components\RefundReason::Duplicate,
        amount: 1000, // minor units (cents)
    )
);
Returns Components\Refund.
For refunding from an Order model instance, use the Cashier-style $order->refund() helper instead.

listRefunds

$response = LaravelPolar::listRefunds(
    new Operations\RefundsListRequest(orderId: 'ord_xxx')
);
ParameterType
$request?Operations\RefundsListRequest
Returns Operations\RefundsListResponse.

Team seats

Seat management for multi-user subscriptions. The facade methods operate cross-subscription; for subscription-scoped helpers see the Subscription model.

listSeats

$seatsList = LaravelPolar::listSeats(subscriptionId: 'sub_xxx');

$seatsList->seats;          // array<Components\CustomerSeat>
$seatsList->availableSeats; // int
$seatsList->totalSeats;     // int
ParameterTypeDefault
$subscriptionId?stringnull
$orderId?stringnull
Returns Components\SeatsList.

assignSeat

Assign a seat by email (sends an invitation) or by customer/external ID (assigns directly).
LaravelPolar::assignSeat(
    new Components\SeatAssign(
        subscriptionId: 'sub_xxx',
        email: 'alice@example.com',
    )
);
Returns Components\CustomerSeat.

revokeSeat

LaravelPolar::revokeSeat('seat_xxx');
Returns Components\CustomerSeat.

resendSeatInvitation

Resend the invitation email for a pending seat.
LaravelPolar::resendSeatInvitation('seat_xxx');
Returns Components\CustomerSeat.

Usage / events

Track metered usage for usage-based billing.

ingestEvents

Send one or more usage events in a single batch.
LaravelPolar::ingestEvents(
    new Components\EventsIngest(
        events: [
            new Components\Event(
                name: 'api_request',
                externalCustomerId: 'user_42',
                metadata: ['endpoint' => '/v1/data'],
            ),
        ]
    )
);
Returns void. Throws if Polar returns a non-202 response.
For a Cashier-style helper that automatically attaches the current customer, use $user->ingestUsageEvent() or $user->ingestUsageEvents() on your billable model.

listCustomerMeters

$response = LaravelPolar::listCustomerMeters(
    new Operations\CustomerMetersListRequest(externalCustomerId: 'user_42')
);
ParameterType
$requestOperations\CustomerMetersListRequest
Returns Operations\CustomerMetersListResponse.

getCustomerMeter

$meter = LaravelPolar::getCustomerMeter('meter_xxx');
Returns Components\CustomerMeter.

Analytics

getMetrics

Fetch aggregated revenue and usage metrics for a date range.
use Brick\DateTime\LocalDate;
use Polar\Models\Components;
use Polar\Models\Operations;

$metrics = LaravelPolar::getMetrics(
    new Operations\MetricsGetRequest(
        startDate: LocalDate::of(2026, 1, 1),
        endDate:   LocalDate::of(2026, 1, 31),
        interval:  Components\TimeInterval::Day,
    )
);

foreach ($metrics->periods as $period) {
    echo $period->startDatetime . ': ' . $period->revenue;
}
ParameterType
$requestOperations\MetricsGetRequest
Returns Components\MetricsResponse.

Files & organizations

listFiles

List downloadable assets, product media, and organization avatars.
$response = LaravelPolar::listFiles();

// Filter by organization or specific IDs:
$response = LaravelPolar::listFiles(
    organizationId: 'org_xxx',
    ids: ['file_aaa', 'file_bbb'],
    page: 1,
    limit: 20,
);

$items = $response->listResourceFileRead?->items ?? [];
ParameterTypeDefault
$organizationId`stringarraynull`null
$ids`stringarraynull`null
$page?intnull
$limit?intnull
Returns Operations\FilesListResponse.

listOrganizations

$response = LaravelPolar::listOrganizations(slug: 'my-org');
ParameterTypeDefault
$slug?stringnull
$page?intnull
$limit?intnull
Returns Operations\OrganizationsListResponse.

getOrganization

$org = LaravelPolar::getOrganization('org_xxx');
Returns Components\Organization.

Model customization

Override the Eloquent models the package resolves for customers, subscriptions, and orders. Call these methods in the boot method of a service provider.

useCustomerModel

use App\Models\PolarCustomer;
use Danestves\LaravelPolar\LaravelPolar;

LaravelPolar::useCustomerModel(PolarCustomer::class);

useSubscriptionModel

LaravelPolar::useSubscriptionModel(App\Models\PolarSubscription::class);

useOrderModel

LaravelPolar::useOrderModel(App\Models\PolarOrder::class);
All three methods accept a fully qualified class name string and return void. The custom class must extend the corresponding base model (Danestves\LaravelPolar\Customer, Subscription, or Order).

SDK access

sdk

Returns the underlying Polar\Polar SDK client. Use this to reach any Polar endpoint that the facade does not wrap directly.
$sdk = LaravelPolar::sdk();
Returns Polar\Polar — the underlying SDK client, built from your polar.access_token and polar.server config values. Throws Exception if the access token is not set. See Access the Polar SDK directly for examples of what you can do with the raw client.