polar-billing

Documents Polar's billing architecture covering Stripe integration, subscriptions, orders, and benefit provisioning.

1.1k|107|Updated Jul 9, 2025
One-click install
npx skills add https://github.com/fcakyon/claude-codex-settings --skill polar-billing
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: polar-billing
Source: https://github.com/fcakyon/claude-codex-settings/tree/main/plugins/polar-skills/skills/polar-billing
Command: npx skills add https://github.com/fcakyon/claude-codex-settings --skill polar-billing

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Working on Polar's billing codebase requires understanding a complex web of entities, services, background tasks, and Stripe webhooks; this Skill provides a complete reference so you can navigate and modify the billing system without reverse-engineering it from scratch.

Core Features & Use Cases

  • Entity & Relationship Reference: Documents Checkout, Order, Subscription, Transaction, Payment, Refund, Customer, and Product models with their fields and relationships.
  • Flow Documentation: Maps subscription creation, renewal cycles, cancellation, trials, proration, dunning retries, and payout flows end to end.
  • Stripe Integration Guide: Lists webhook endpoints, event handlers, and the async Dramatiq task processing pipeline.
  • Use Case: When debugging why a subscription failed to renew, consult the dunning section to trace order.process_dunning tasks, Payment decline reasons, and next_payment_attempt_at scheduling.

Quick Start

Ask the AI to explain how Polar handles subscription proration when a customer upgrades their plan mid-cycle.

Frequently Asked Questions about polar-billing

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How does Polar handle subscription renewal billing?

Polar renews subscriptions via an APScheduler-triggered subscription.cycle task at period end. It advances period dates, creates a BillingEntry, enqueues order creation with billing_reason=subscription_cycle, then triggers Stripe payment and ledger entries on success.

How does Polar integrate with Stripe webhooks?

Polar receives Stripe events at /v1/integrations/stripe/webhook endpoints, verifies signatures, stores them in an external_events table, and processes them asynchronously via Dramatiq tasks for charges, refunds, disputes, and payouts.

How does proration work when changing subscription plans?

Polar calculates proration by crediting unused time on the old price and debiting the remaining time on the new price. Depending on the proration behavior, the net amount is added to the next invoice or billed immediately, recorded as BillingEntry rows.

Why did a Polar subscription payment fail and what happens next?

Failed payments set the subscription to past_due and schedule retries via the hourly order.process_dunning task based on next_payment_attempt_at. If retries exhaust, the subscription becomes unpaid and benefits are revoked, unless a grace period applies.

How are benefits granted and revoked in Polar?

Benefits are granted after order or subscription creation through enqueue_benefits_grants, which queues per-benefit tasks like GitHub access, Discord roles, or meter credits. Cancellation or refunds enqueue revocation tasks that call each benefit type's revoke strategy.