Part · billing.subscriptionWhat's actually behind
What's actually behind billing.subscription
The part exactly as partkit add billing.subscription vendors it into your repo — verified, locked, every byte readable. Nothing here is mocked.
billing.subscriptionv1.2.0
✓ attested🔒 read-only↑ ctrlai upgradebilling.subscription@1
Lives at parts/billing.subscription/ in your repo — open, owned, readable. Not buried in node_modules. 746 lines of source you can audit.
content hash
09e6fa8b22…927443pinned in parts.lock — ctrlai guard fails CI if a single byte changestested against
node 25.3.0parts/billing.subscription/src/index.tstypescript · 1,546 bytes/**
* billing.subscription — public interface. The ONLY legal import surface.
* Contract: ../contract.json · What your app must provide: ../seams.md
*
* Subscription billing over a vendor-neutral contract: hosted checkout, a
* webhook-derived subscription mirror, cancel/reactivate/change-plan, and a
* derived `entitled` flag. The selected payment adapter (Stripe in v1) is the
* vendor seam; state lives in the app's Postgres via the SqlExecutor seam.
* Importing this module performs no I/O.
*/
import { adapter } from "../adapters/selected/adapter";
import { makeBilling, makeWebhookHandler } from "./internal/billing";
import type { Billing, SqlExecutor } from "./internal/types";
/** Bind the billing operations to the app's database seam + the selected adapter. */
export function billing(db: SqlExecutor): Billing {
return makeBilling(db, adapter);
}
/** The handler the app mounts at POST /api/webhooks/billing (raw body required). */
export function billingWebhookHandler(db: SqlExecutor): (request: Request) => Promise<Response> {
return makeWebhookHandler(db, adapter);
}
export { BillingError } from "./internal/errors";
export type { BillingErrorCode } from "./internal/errors";
export type {
Billing,
CancelInput,
ChangePlanInput,
CheckoutSession,
CreateCheckoutInput,
IngestResult,
IngestWebhookInput,
Plan,
PlanCatalog,
ProrationBehavior,
Subscription,
SubscriptionChangeEvent,
SubscriptionChangeHandler,
SubscriptionStatus,
SqlExecutor,
Unsubscribe,
} from "./internal/types";