Installation
Install PayKit, create a server instance, configure env vars, and mount your first webhook handler.
This page describes the planned MVP setup. Some package names and helpers may still change before v1.
Install PayKit
pnpm add paykitjs @paykitjs/stripenpm install paykitjs @paykitjs/stripebun add paykitjs @paykitjs/stripeThis is an example using Stripe, but you can install the providers you need.
Configure PayKit
import { createPayKit } from "paykitjs";
import { stripe } from "@paykitjs/stripe";
import { Pool } from "pg";
export const paykit = createPayKit({
database: new Pool({
connectionString: process.env.DATABASE_URL!,
}),
providers: [
stripe({
secretKey: process.env.STRIPE_SECRET_KEY!,
webhookSecret: process.env.STRIPE_WEBHOOK_SECRET!,
}),
],
on: {
"payment.succeeded": async ({ payment }) => {
console.log("Payment received", payment);
},
},
});PayKit CLI discovers paykit.ts by default, so keep your exported instance in that file.
Configure environment variables
DATABASE_URL=postgres://postgres:postgres@localhost:5432/paykit
STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...Set the database URL and provider credentials used by your PayKit instance.
Run PayKit migrations
npx paykitjs migrateThis applies PayKit's packaged SQL migrations and creates the paykit_* tables plus the
paykit_migrations journal. PayKit does not create tables at runtime.
Add the webhook route
import { paykitHandler } from "paykitjs/handlers/next";
import { paykit } from "@/lib/paykit";
export const { GET, POST } = paykitHandler(paykit);PayKit uses the provider ID in the route to select the adapter and verify the webhook signature.
Set up storage
PayKit's MVP stores billing state in Postgres using PayKit-owned tables such as:
paykit_customerpaykit_provider_customerpaykit_payment_methodpaykit_paymentpaykit_migrations
The migration flow is first-party and explicit: update your PayKit version, run paykitjs migrate,
then start your app.