Monetize open-source and digital products with Polar — payment and billing platform for developers. Use when someone asks to "monetize open source", "Polar", "sell API access", "developer billing", "GitHub Sponsors alternative", "sell digital products as a developer", or "subscription billing for SaaS". Covers products, subscriptions, checkout, license keys, webhooks, and usage-based billing.
You are an expert in Polar, the monetization platform built for developers and open-source maintainers. You help developers add payments, subscriptions, product sales, license keys, and sponsorships to their projects with a developer-first API, webhooks, and embeddable components — replacing Stripe integration complexity with purpose-built tools for software monetization.
import { Polar } from "@polar-sh/sdk";
const polar = new Polar({ accessToken: process.env.POLAR_ACCESS_TOKEN });
// Create a product
const product = await polar.products.create({
name: "Pro Plan",
description: "Full access to all features",
prices: [{
type: "recurring",
recurringInterval: "month",
priceAmount: 2900, // $29.00
priceCurrency: "usd",
}],
benefits: [
{ type: "license_keys", description: "License key for desktop app" },
{ type: "discord", description: "Access to Pro Discord channel" },
{ type: "custom", description: "Priority support" },
],
});
// Create checkout session
const checkout = await polar.checkouts.create({
productId: product.id,
successUrl: "https://myapp.com/success?session={CHECKOUT_ID}",
customerEmail: "user@example.com",
metadata: { userId: "usr-42" },
});
// Redirect user to checkout.url
// Verify checkout
const session = await polar.checkouts.get(checkoutId);
if (session.status === "confirmed") {
await activateUserPro(session.metadata.userId);
}
// Handle Polar webhooks
import { validateEvent } from "@polar-sh/sdk/webhooks";
app.post("/api/webhooks/polar", async (req, res) => {
const event = validateEvent(req.body, req.headers, process.env.POLAR_WEBHOOK_SECRET!);
switch (event.type) {
case "subscription.created":
await db.users.update(event.data.customer.metadata.userId, { plan: "pro", polarSubId: event.data.id });
break;
case "subscription.canceled":
await db.users.update(event.data.customer.metadata.userId, { plan: "free", cancelAt: event.data.currentPeriodEnd });
break;
case "order.created":
await fulfillOrder(event.data);
break;
}
res.json({ received: true });
});
// Validate license key (in your desktop/CLI app)
const validation = await polar.licenseKeys.validate({
key: userProvidedKey,
organizationId: process.env.POLAR_ORG_ID!,
});
if (validation.valid) {
console.log(`License valid for: ${validation.customer.email}`);
console.log(`Activations: ${validation.activations}/${validation.limit}`);
// Activate features
} else {
console.log(`Invalid: ${validation.error}`);
}
// Activate (track device)
await polar.licenseKeys.activate({
key: userProvidedKey,
label: `${os.hostname()}-${os.platform()}`,
organizationId: process.env.POLAR_ORG_ID!,
});
// React component for checkout button
import { PolarCheckout } from "@polar-sh/react";
function PricingPage() {
return (
<div className="pricing-grid">
<div className="plan">
<h3>Pro</h3>
<p className="price">$29/mo</p>
<PolarCheckout
productId="prod_abc123"
successUrl="/success"
className="buy-button"
>
Get Pro
</PolarCheckout>
</div>
</div>
);
}
npm install @polar-sh/sdk
npm install @polar-sh/react # React components
userId in checkout metadata; link Polar customers to your user systemnpx skills add TerminalSkills/polar下载完整 Skill 目录,包含 SKILL.md 及所有相关文件
Search for places (restaurants, cafes, etc.) via Google Places API proxy on localhost.
Interact with GitHub using the `gh` CLI. Use `gh issue`, `gh pr`, `gh run`, and `gh api` for issues, PRs, CI runs, and advanced queries.
Create or update AgentSkills. Use when designing, structuring, or packaging skills with scripts, references, and assets.
Start voice calls via the OpenClaw voice-call plugin.
Notion API for creating and managing pages, databases, and blocks.
Gemini CLI for one-shot Q&A, summaries, and generation.
Category:developer