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.
Properties
Section titled “Properties”| 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 |
Methods
Section titled “Methods”apply()
Section titled “apply()”apply( provider, events, options?): Promise<IntakeOutcome>;Defined in: src/billing/contract.ts:150
Apply normalized events directly (tests, better-auth callbacks, custom intakes).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
provider |
string |
events |
BillingEvent[] |
options? |
{ eventId?: string; } |
options.eventId? |
string |
Returns
Section titled “Returns”Promise<IntakeOutcome>
createCheckout()
Section titled “createCheckout()”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.
Parameters
Section titled “Parameters”| 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 |
Returns
Section titled “Returns”Promise<{
url: string;
}>
createPortalSession()
Section titled “createPortalSession()”createPortalSession(customer, input?): Promise<{ url: string;}>;Defined in: src/billing/contract.ts:169
Billing-portal link-out.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
customer |
string |
input? |
{ provider?: string; returnUrl?: string; } |
input.provider? |
string |
input.returnUrl? |
string |
Returns
Section titled “Returns”Promise<{
url: string;
}>
handleWebhook()
Section titled “handleWebhook()”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).
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
provider |
string |
request |
Request |
Returns
Section titled “Returns”Promise<{
events: number;
outcome: IntakeOutcome;
}>
reconcile()
Section titled “reconcile()”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.
Parameters
Section titled “Parameters”| Parameter | Type |
|---|---|
customer |
string |
provider? |
string |
Returns
Section titled “Returns”Promise<ReconcileResult[]>