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.

Discounts in Polar are reusable coupon codes that you can pin automatically to a checkout session or give to a customer to enter themselves. The LaravelPolar facade covers the full lifecycle: create, update, delete, list, and fetch. You can also apply or remove discounts on active subscriptions.
Four discount shapes: percentage or fixed amount, applied once/forever or repeated for N months. Each shape has its own create class — pick the one that matches your promotion.

Creating discounts

Use LaravelPolar::createDiscount() and pass one of four create variants that correspond to Polar’s discount types.

Percentage — applied once or forever

use Danestves\LaravelPolar\LaravelPolar;
use Polar\Models\Components;

$discount = LaravelPolar::createDiscount(
    new Components\DiscountPercentageOnceForeverDurationCreate(
        name: 'Black Friday 50%',
        type: Components\DiscountType::Percentage,
        duration: Components\DiscountDuration::Once,
        basisPoints: 5000, // 50 % expressed in basis points
        organizationId: 'your-org-id',
    )
);

Fixed amount — applied once or forever

$discount = LaravelPolar::createDiscount(
    new Components\DiscountFixedOnceForeverDurationCreate(
        name: '$10 off',
        type: Components\DiscountType::Fixed,
        duration: Components\DiscountDuration::Forever,
        amount: 1000, // amount in minor units (cents)
        currency: 'usd',
        organizationId: 'your-org-id',
    )
);

Fixed amount — repeated for N billing cycles

$discount = LaravelPolar::createDiscount(
    new Components\DiscountFixedRepeatDurationCreate(
        name: '3 months $5 off',
        type: Components\DiscountType::Fixed,
        duration: Components\DiscountDuration::Repeating,
        durationInMonths: 3,
        amount: 500,
        currency: 'usd',
        organizationId: 'your-org-id',
    )
);

Percentage — repeated for N billing cycles

$discount = LaravelPolar::createDiscount(
    new Components\DiscountPercentageRepeatDurationCreate(
        name: '20% off for 6 months',
        type: Components\DiscountType::Percentage,
        duration: Components\DiscountDuration::Repeating,
        durationInMonths: 6,
        basisPoints: 2000,
        organizationId: 'your-org-id',
    )
);

Managing discounts

// Update a discount
LaravelPolar::updateDiscount('disc_xxx', new Components\DiscountUpdate(
    name: 'Black Friday extended',
));

// Delete a discount
LaravelPolar::deleteDiscount('disc_xxx');

// List all discounts
$response = LaravelPolar::listDiscounts();

// Fetch a single discount
$discount = LaravelPolar::getDiscount('disc_xxx');
listDiscounts() also accepts an optional Operations\DiscountsListRequest if you need to filter or paginate results.

Applying a discount at checkout

Pin a discount to a checkout session with withDiscountId(). By default, customers can still type a different code in the checkout form — this just pre-fills a specific discount.
$user->checkout('product_id_123')
    ->withDiscountId('disc_xxx');
To force the discount and prevent the customer from entering or changing it, chain withoutDiscountCodes():
$user->checkout('product_id_123')
    ->withDiscountId('disc_xxx')
    ->withoutDiscountCodes();
When you call withDiscountId() without withoutDiscountCodes(), the discount code input remains visible in the checkout form and customers can override the pre-filled discount.

Applying a discount to an existing subscription

You can apply a discount on an active subscription. The change takes effect on the next billing cycle:
$user->subscription()->applyDiscount('disc_xxx');
To remove a discount from a subscription:
$user->subscription()->removeDiscount();