Skip to content

EntitlementsBilling

Defined in: src/billing/contract.ts:141

The billing intake bound to an engine — what the panel’s POST /webhooks/:provider, /api/portal/checkout|manage and /api/customers/:id/reconcile routes call.

Property Modifier Type Description Defined in
canCheckout readonly boolean - src/billing/contract.ts:173
canManage readonly boolean - src/billing/contract.ts:174
providers readonly readonly string[] Configured provider ids. src/billing/contract.ts:143
apply(
provider,
events,
options?
): Promise<IntakeOutcome>;

Defined in: src/billing/contract.ts:150

Apply normalized events directly (tests, better-auth callbacks, custom intakes).

Parameter Type
provider string
events BillingEvent[]
options? { eventId?: string; }
options.eventId? string

Promise<IntakeOutcome>


createCheckout(customer, input): Promise<{
url: string;
}>;

Defined in: src/billing/contract.ts:158

Checkout link-out for a plan or add-on key from the catalog.

Parameter Type
customer string
input { cancelUrl?: string; plan: string; provider?: string; quantity?: number; successUrl?: string; }
input.cancelUrl? string
input.plan string
input.provider? string
input.quantity? number
input.successUrl? string

Promise<{ url: string; }>


createPortalSession(customer, input?): Promise<{
url: string;
}>;

Defined in: src/billing/contract.ts:169

Billing-portal link-out.

Parameter Type
customer string
input? { provider?: string; returnUrl?: string; }
input.provider? string
input.returnUrl? string

Promise<{ url: string; }>


handleWebhook(provider, request): Promise<{
events: number;
outcome: IntakeOutcome;
}>;

Defined in: src/billing/contract.ts:145

Verify + apply a webhook. Throws BillingVerificationError (400) or NotFoundError (404 unknown provider).

Parameter Type
provider string
request Request

Promise<{ events: number; outcome: IntakeOutcome; }>


reconcile(customer, provider?): Promise<ReconcileResult[]>;

Defined in: src/billing/contract.ts:156

Pull the provider’s current state for a customer and converge on it.

Parameter Type
customer string
provider? string

Promise<ReconcileResult[]>