Encore is an open source TypeScript backend framework. You define your infrastructure (databases, queues, cron jobs, API endpoints) directly in your application code using the Encore SDK.
Encore understands your app's architecture and uses it to run your app locally, provision cloud infrastructure (in your AWS or GCP account), and give you observability like distributed tracing and service catalogs, all without config files or boilerplate.
Learn more about Encore →Polar is a payment platform that acts as your Merchant of Record. It handles subscriptions, one-time payments, license keys, and usage-based pricing with global tax compliance built in.
You create products in the Polar dashboard, send customers to a hosted checkout page, and receive webhooks when they subscribe or pay. Polar handles invoices, tax, and payouts.
Learn more about Polar →
The infrastructure you'd eventually build around payments (managed database, secrets per environment, preview environments, tracing) already done, in your AWS or GCP account.
Subscriptions, one-time payments, license keys, usage-based pricing. Global tax compliance as Merchant of Record.
Start free on Encore Cloud. When you're ready, connect your own AWS or GCP account and Encore deploys there instead. No code changes.
Every API call and webhook gets a visual timeline showing what happened, how long it took, and where it failed.
Every pull request gets a full copy of your backend with its own database and secrets. Test payments with Polar sandbox before merging.
Push to main and your app is live. No CI/CD pipelines to configure, no Dockerfiles to write.
Define a database in TypeScript and Encore creates PostgreSQL for you, locally and in the cloud. Migrations run automatically on deploy.
Store API tokens and webhook secrets in Encore instead of .env files. Each environment (local, preview, production) has its own values.
Write TypeScript. Encore handles the infrastructure. No DevOps expertise required.
Initialize the Polar client with your access token stored as an Encore secret. Secrets are encrypted per environment and injected at runtime.
import { Polar } from "@polar-sh/sdk";
import { secret } from "encore.dev/config";
const accessToken = secret("POLAR_ACCESS_TOKEN");
export const polar = new Polar({
accessToken: accessToken(),
// Use "sandbox" for development
server: "production",
});Define a type-safe API endpoint that creates Polar checkout sessions. Customers are sent to Polar's hosted payment page. Polar handles the entire payment flow.
import { api } from "encore.dev/api";
import { polar } from "./polar";
interface CheckoutRequest {
productId: string;
customerEmail: string;
}
interface CheckoutResponse {
checkoutUrl: string;
}
export const createCheckout = api(
{ expose: true, method: "POST", path: "/checkout" },
async (req: CheckoutRequest): Promise<CheckoutResponse> => {
const checkout = await polar.checkouts.custom.create({
productId: req.productId,
customerEmail: req.customerEmail,
successUrl: "https://yourapp.com/success",
});
return { checkoutUrl: checkout.url };
}
);Receive real-time events when customers subscribe, pay, or cancel using a raw endpoint. The SDK validates webhook signatures automatically. Every webhook is traced so you can see exactly what happened.
import { api } from "encore.dev/api";
import { secret } from "encore.dev/config";
import {
validateEvent,
WebhookVerificationError
} from "@polar-sh/sdk/webhooks";
const webhookSecret = secret("POLAR_WEBHOOK_SECRET");
export const webhook = api.raw(
{ expose: true, method: "POST", path: "/webhook/polar" },
async (req, res) => {
const body = await readBody(req);
try {
const event = validateEvent(
body,
req.headers,
webhookSecret()
);
switch (event.type) {
case "subscription.active":
await activateSubscription(event.data);
break;
case "subscription.canceled":
await cancelSubscription(event.data);
break;
case "order.paid":
await fulfillOrder(event.data);
break;
}
res.writeHead(200);
res.end();
} catch (err) {
if (err instanceof WebhookVerificationError) {
res.writeHead(403);
res.end("Invalid signature");
return;
}
throw err;
}
}
);Every webhook, checkout, and API call is automatically traced. See the full request flow from Polar's webhook to your database, locally and in production. No instrumentation code to write.
Learn more about tracing →The boring, error-prone work that Polar and Encore eliminate.
You focus on your product. That's it.
Because Encore defines infrastructure in code and provides built-in distributed tracing, AI coding assistants like Claude and Cursor can build and debug your entire Polar integration end-to-end.
They can read your Encore services to understand checkout flows and webhook handlers, then inspect traces to diagnose exactly what happened when a Polar checkout completes or a subscription webhook arrives.
Connect your AWS or GCP account and deploy. Encore provisions the infrastructure directly in your account: databases, load balancers, IAM roles, networking. Same code you've been running on Encore Cloud.
You can see it all in your console. Customer data stays in your infrastructure. Full control when you need it.
Learn how cloud deployment works →Declare what you need in TypeScript. Encore provisions it in your AWS or GCP account.
RDS or Cloud SQL for subscriptions, customers, and entitlements.
AWS Secrets Manager or GCP Secret Manager for API tokens.
SQS or GCP Pub/Sub for async webhook processing.
CloudWatch or Cloud Scheduler for subscription sync and reminders.
ALB or Cloud Load Balancing with automatic certificates.
S3 or Cloud Storage for invoices and downloadable content.
Proper IAM roles, VPCs, and security groups by default.
Distributed tracing, metrics, and logging out of the box.