Discounts & Promotions
Relevant source files
The following files were used as context for generating this wiki page:
- clients/apps/web/src/components/Landing/features/DiscountsPage.tsx
- AGENTS.md
- clients/apps/web/src/app/(main)/(website)/(landing)/features/discounts/page.tsx
- clients/apps/web/src/components/Landing/comparison/PolarStripePage.tsx
- clients/apps/web/src/components/Landing/comparison/PolarLemonSqueezyPage.tsx
- server/polar/organization_review/analyzer.py
Discounts and Promotions in Polar provide a flexible primitive for reducing prices across orders and subscriptions. The system supports various formats including public promo codes, private partner deals, and programmatic offers. These discounts are designed to handle complex logic such as fixed amount or percentage reductions, specific durations for recurring products, and various delivery methods like manual code entry or automatic application via Checkout Links.
The feature is integrated directly into the checkout flow, ensuring that reductions are calculated server-side, itemized on invoices, and surfaced in the Customer Portal for transparency.
Sources: clients/apps/web/src/components/Landing/features/DiscountsPage.tsx:30-40, clients/apps/web/src/app/(main)/(website)/(landing)/features/discounts/page.tsx:6-10
Core Configuration: The Three Knobs
Every discount in Polar is defined by three primary configuration decisions: Shape, Duration, and Delivery.
1. Shape
The "Shape" of a discount determines how the price reduction is calculated.
- Percentage Off: A percentage reduction applied to the total order.
- Fixed Amount: A specific monetary value deducted in the customer's currency.
2. Duration
Duration settings are critical for recurring products and subscriptions.
- Once: Applies only to the first or next charge; subsequent renewals are at full price.
- Several Months: Applies for a fixed number of billing cycles (e.g., 3 months) before expiring.
- Forever: Persists for the entire life of the subscription as long as it remains active.
3. Delivery
Delivery determines the access control and application method for the discount.
- Promo Code: A string that customers manually enter at checkout.
- Programmatic/Private: No code is exposed; the discount is applied via API or pinned to a specific Checkout Link.
Sources: clients/apps/web/src/components/Landing/features/DiscountsPage.tsx:44-65, clients/apps/web/src/components/Landing/features/DiscountsPage.tsx:104-123
Technical Architecture & Implementation
The discount system is a core part of the Polar backend, which is built using FastAPI and PostgreSQL. Authentication for discount operations is managed through a specific AuthSubject and scoped permissions.
Application Logic Flow
Discounts can be applied through three distinct mechanics as illustrated in the flow below:
The diagram shows how different entry points lead to a centralized validation logic before server-side calculation and invoice generation.
Sources: clients/apps/web/src/components/Landing/features/DiscountsPage.tsx:77-96, AGENTS.md:144-150
Feature Capabilities
The following table summarizes the operational constraints available for discounts:
| Feature | Description |
|---|---|
| Product Scoping | Restrict discounts to specific products or groups of products. |
| Time Windows | Define start and end dates for automatic activation and expiration. |
| Redemption Limits | Cap the total number of times a discount can be used globally. |
| Checkout Pinning | Automatically apply a discount when a specific link is visited. |
| Tax Integration | Discounts apply before tax to ensure accurate totals and trails. |
Sources: clients/apps/web/src/components/Landing/features/DiscountsPage.tsx:67-96, clients/apps/web/src/components/Landing/features/DiscountsPage.tsx:125-135
Security and Authentication
Access to creating and managing discounts is governed by the Polar authentication system. Specifically, write operations require specific OAuth scopes and authorized subjects.
# Illustrative authentication structure for discounts
_DiscountWrite = Authenticator(
required_scopes={Scope.web_default, Scope.discounts_write},
allowed_subjects={User, Organization},
)
DiscountWrite = Annotated[AuthSubject[User | Organization], Depends(_DiscountWrite)]
Sources: AGENTS.md:144-150
Comparison with Other Platforms
Polar's discount system is often compared to other Merchant of Record (MoR) or payment processing providers.
| Feature | Polar | Stripe | Lemon Squeezy |
|---|---|---|---|
| Merchant of Record | Yes (Handles Tax/VAT) | No (User handles tax) | Yes |
| Discount Engine | Built-in | Separate (Stripe Tax/Billing) | Built-in |
| Framework Adapters | Next.js, Laravel, etc. | Limited/Third-party | Limited |
| Open Source | Yes | No | No |
Sources: clients/apps/web/src/components/Landing/comparison/PolarStripePage.tsx:30-60, clients/apps/web/src/components/Landing/comparison/PolarLemonSqueezyPage.tsx:30-65
Operational Monitoring & Risk
Discounts and pricing models are monitored by automated risk analyzers. High-risk pricing patterns, such as "Ad-hoc prices" (overriding catalog prices via API), are flagged for human review to prevent abuse.
The review analyzer ensures that promotional features like ad-hoc pricing are used for legitimate business cases and not for circumventing policy.
Sources: server/polar/organization_review/analyzer.py:115-130, server/polar/organization_review/analyzer.py:460-470
Polar's "Discounts & Promotions" module is a robust toolset for developers to manage pricing flexibility while maintaining strict financial and compliance standards. By combining shape, duration, and delivery options, it supports everything from simple Black Friday sales to complex, programmatic partner incentives.