Polar Documentation

repository·main·Indexed 27 days ago

https://github.com/polarsource/polar

Polar is a billing platform for AI workloads that enables monetization of usage-based models such as token consumption, agent runs, and GPU compute. It serves as a Merchant of Record, managing global taxes, receipts, and customer accounts. The documentation covers the @polar-sh/checkout SDK for implementing payment methods via modals, inline embeds, or React components, as well as the @polar-sh/client API client and internal @polar-sh/ui library.

Tokens
209.5K
Snippets
410
Records
1.2K
Agent score
95%

What's inside polar

  1. Overview of the Customer Portal

    main

    The Customer Portal is a hosted, self-service destination where customers can manage their relationship with your business. It is designed to reduce support overhead by allowing customers to handle billing tasks independently.

    Key capabilities for customers:

    • Subscription & Purchase Management: View active subscriptions, past purchase history, and cancel subscriptions.
    • Financial Documents: Download and edit invoices (adding company names, VAT numbers, etc.) and download payment receipts.
    • Payment Recovery: Update default payment methods to recover from failed subscription renewals.
    • Benefit Access: Access entitled benefits such as license keys, file downloads, or Discord access.
    • Account Settings: Optionally change email addresses, switch subscription plans, manage seats, and view metered usage (configurable via Settings).
  2. Overview of Automated Benefits in Polar

    main

    Polar provides built-in benefit (entitlements) automation designed for developer and designer ecosystems. These benefits allow you to automate access to various resources based on customer purchases or subscriptions.

    Supported benefit types include:

    • Credits: Add balance to a customer's Usage Meter.
    • License Keys: Customizable software license keys.
    • Feature Flags: API-driven access flags with optional metadata.
    • File Downloads: Access to files up to 10GB each.
    • GitHub Repository Access: Automatic invitations to private GitHub repositories.
    • Discord Invite: Automated invitations and role granting.
    • Shared Slack Channel: Access via Slack Connect.
  3. Overview of Polar Core Features

    main

    Polar provides complete billing infrastructure as a Merchant of Record (MoR). Key capabilities include:

    • Flexible Product Management: Support for one-time purchases, recurring subscriptions, and flexible pricing (fixed, pay-what-you-want, or free).
    • Checkout Experience: Options for no-code Checkout Links, customizable Embedded Checkout, or a full Checkout API for dynamic sessions.
    • Global Merchant of Record: Handles international tax compliance (VAT, GST, sales tax), EU VAT (B2B reverse charge and B2C collection), and real-time tax calculation.
    • Automated Benefits: Instant delivery of license keys, files, GitHub access, and Discord roles.
  4. Overview of the Polar recruitment process

    main

    The Polar recruitment process is a multi-stage evaluation focused on practical assessment and values alignment. The stages are:

    1. Introduction Call (30 minutes): An initial call to discuss the candidate, Polar, and company culture.
    2. Technical Assignment: A practical task involving the review and analysis of a pull request (estimated 1-2 hours).
    3. Assignment Review & Technical Discussion (1 hour): A deep dive into the technical assignment to discuss decisions, trade-offs, and reasoning within a complex codebase.
    4. Team Conversations (30 min): 2-3 video calls to meet future team members.
    5. Offer: The formal offer stage.
    6. Reference Calls: Brief conversations with previous colleagues or managers.
  5. Understand Polar's payment processing infrastructure

    main

    Polar uses Stripe as its primary financial partner to process payments and settle funds. Stripe handles the secure transmission of transaction data, payment authorization, settlement, fraud prevention, and compliance with global card network standards.

    When a customer makes a purchase:

    1. Payment information is captured by Stripe at checkout.
    2. Stripe transmits the transaction to card networks and issuing banks.
    3. The issuing bank authorizes or declines the transaction.
    4. Approved funds are settled to the Polar account on Stripe. Payouts to merchants are managed via Stripe Connect.
  6. Understand Organization Roles and Permissions

    main

    Polar uses a Role-Based Access Control (RBAC) system with three primary roles assigned to users within an organization:

    • owner: The primary account holder. There is exactly one owner per organization. Ownership transfers are handled via specific administrative flows, not standard role updates.
    • admin: Users with administrative capabilities.
    • member: Standard users with base access.

    Authorization Logic: Permissions are determined by the intersection of a user's assigned scopes and the permissions implied by their role. An action is allowed if the required_perm is present in both the implied(scopes) and permissions(role) sets.

  7. Understand the Merchant Migration architecture

    main

    Polar uses a dedicated migration module to move billing data from source platforms (like Stripe) to Polar. The architecture is built around several key components:

    • MigrationJob: Represents a single migration run for an organization, tracking the source platform and current progress.
    • MigrationRecord: An idempotency layer that maps source_id to target_id for every imported entity (customers, products, subscriptions, etc.).
    • SourceAdapter: Responsible for reading the source provider's API and providing a generic CanonicalRecord (e.g., CanonicalProduct, CanonicalCustomer, CanonicalSubscription).
    • MigrationService: The main orchestrator of the migration process.
    • PanTransferStep: A checklist of steps (stored as JSONB) used to track the movement of payment cards (PAN copy or PAN import).
  8. Compare Polar Merchant of Record plans

    main

    Polar offers a free Starter plan and three paid tiers (Pro, Growth, and Scale) that reduce variable transaction rates and provide higher support priority. You can switch between plans at any time, and rates adjust immediately.

    PlanMonthly feePer transactionSupportIncluded
    StarterFree5% + 50¢Standard Support
    Pro$20 /mo3.8% + 40¢Prioritized Support
    Growth$100 /mo3.6% + 35¢Prioritized Support
    Scale$400 /mo3.4% + 30¢Slack + Prioritized SupportSingle Sign-On

    Paid plans replace the per-transaction Merchant of Record premium with a fixed monthly fee and a lower variable rate.

  9. Understand Seat-Based Pricing entities

    main

    Seat-based pricing separates the payer from the user through three distinct entities:

    • Customer: The billing entity (the payer). On their first seat-based purchase, they are upgraded to type: "team". They own subscriptions and payment methods.
    • Member: The end user (the consumer). Each member has an email, a role (owner, billing_manager, or member), and receives benefits independently. The purchaser is assigned the owner role.
    • CustomerSeat: The link between a product and a member. It tracks the assignment status (pending, claimed, or revoked) and holds the invitation token.

    Note: Always identify end users by their Member ID, as benefits are granted to members rather than the billing customer.