@hjam91/billing 0.0.0-stage → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +133 -2
- package/dist/admin.d.ts +186 -0
- package/dist/admin.js +88 -0
- package/dist/cache.d.ts +26 -0
- package/dist/cache.js +36 -0
- package/dist/cli.mjs +82 -0
- package/dist/config.d.ts +90 -0
- package/dist/config.js +31 -0
- package/dist/errors.d.ts +17 -0
- package/dist/errors.js +32 -0
- package/dist/hono.d.ts +85 -0
- package/dist/hono.js +208 -0
- package/dist/index.d.ts +332 -0
- package/dist/index.js +551 -0
- package/dist/kv.d.ts +25 -0
- package/dist/kv.js +29 -0
- package/dist/react.d.ts +119 -0
- package/dist/react.js +211 -0
- package/dist/types.d.ts +393 -0
- package/dist/types.js +5 -0
- package/dist/webhook.d.ts +52 -0
- package/dist/webhook.js +98 -0
- package/package.json +75 -4
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,332 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hjam91/billing — the app side of billing-kit. SERVER-SIDE ONLY: it holds
|
|
3
|
+
* the app's secret. (The browser uses `@hjam91/billing/react`, which talks to
|
|
4
|
+
* the app's own backend, never to the billing service.)
|
|
5
|
+
*
|
|
6
|
+
* const billing = createBilling({ baseUrl, appId, secret });
|
|
7
|
+
* const ent = await billing.getEntitlement(orgId);
|
|
8
|
+
* if (!ent.active) return paymentRequired();
|
|
9
|
+
*
|
|
10
|
+
* Entitlement checks are cached and FAIL OPEN on an OUTAGE: if the billing
|
|
11
|
+
* service is slow, down or answering 5xx, the last known answer is used; with
|
|
12
|
+
* no cached answer the account is allowed and the failure is logged. A billing
|
|
13
|
+
* outage must never lock out a paying customer.
|
|
14
|
+
*
|
|
15
|
+
* A 401/403/404 is NOT an outage: it means this app's configuration is wrong
|
|
16
|
+
* (secret, app id, rotated key, disabled app). Since 0.2.0 those DENY
|
|
17
|
+
* (reason 'unverified', source 'error'), log at ERROR and call `onError`, so a
|
|
18
|
+
* misconfiguration or a disabled tenant can never mean free access forever.
|
|
19
|
+
* Set `failOpenOnAuthError: true` to restore the 0.1 behaviour.
|
|
20
|
+
*
|
|
21
|
+
* Actions (checkout, portal, auto-renew, trial, delete) never fail open —
|
|
22
|
+
* they throw BillingError, because there is nothing safe to pretend.
|
|
23
|
+
*
|
|
24
|
+
* WHO MAY ACT FOR AN ACCOUNT IS THE APP'S DECISION. The service checks that
|
|
25
|
+
* the app is who it says it is and that an account only manages what it owns;
|
|
26
|
+
* it cannot know whether the signed-in user is an admin of `accountId`. Check
|
|
27
|
+
* that in the app before calling checkout/portal/setAutoRenew.
|
|
28
|
+
*/
|
|
29
|
+
import { type CacheStore } from './cache.js';
|
|
30
|
+
import type { AccountInput, AccountStatus, Balances, ChangePreview, CheckResult, EntitlementResult, Lock, PlanChange, PublicPlan, TrackResult, UpsertResult, UsageSettingsInput } from './types.js';
|
|
31
|
+
export * from './types.js';
|
|
32
|
+
export { BillingError, isOutage, killSignal } from './errors.js';
|
|
33
|
+
export { type BillingConfig, type ConfigChange, type ConfigPushResult, type PlanSpec, type PriceSpec, defineConfig, formatChanges } from './config.js';
|
|
34
|
+
export { type AppHealth, type BillingAdmin, type BillingAdminOptions, type InvoiceView, type RefundParams, type RefundResult, createBillingAdmin } from './admin.js';
|
|
35
|
+
export { type CacheEntry, type CacheStore, memoryStore } from './cache.js';
|
|
36
|
+
export { BillingWebhookError, type BillingWebhookErrorCode, type VerifyOptions, verifyBillingEvent, verifyBillingWebhook } from './webhook.js';
|
|
37
|
+
/** What `onError` receives for every failed entitlement check. */
|
|
38
|
+
export interface EntitlementFailure {
|
|
39
|
+
accountId: string;
|
|
40
|
+
status: number;
|
|
41
|
+
code: string;
|
|
42
|
+
/**
|
|
43
|
+
* 'outage' (network / timeout / 5xx: failed open), 'misconfigured' (401/403/404: denied) or, since 0.7, 'killed'
|
|
44
|
+
* (403 app_disabled / 503 service_locked_down: the owner's kill switch; served per `onKill`).
|
|
45
|
+
*/
|
|
46
|
+
kind: 'outage' | 'misconfigured' | 'killed';
|
|
47
|
+
served: 'stale' | 'fail_open' | 'deny';
|
|
48
|
+
}
|
|
49
|
+
export interface Logger {
|
|
50
|
+
warn(...args: unknown[]): void;
|
|
51
|
+
error(...args: unknown[]): void;
|
|
52
|
+
}
|
|
53
|
+
export interface BillingOptions {
|
|
54
|
+
/** The billing service, e.g. https://billing.example.com (no trailing path). */
|
|
55
|
+
baseUrl: string;
|
|
56
|
+
appId: string;
|
|
57
|
+
/** The app's server secret (bk_...). Never ship it to a browser. */
|
|
58
|
+
secret: string;
|
|
59
|
+
/** Where entitlements are cached. Default: in-memory, per process/isolate. */
|
|
60
|
+
cache?: CacheStore;
|
|
61
|
+
/** How long a cached entitlement counts as fresh. Default 60. */
|
|
62
|
+
ttlSeconds?: number;
|
|
63
|
+
/** Allow access when the service is unreachable (network, timeout, 5xx) and nothing is cached. Default true. */
|
|
64
|
+
failOpen?: boolean;
|
|
65
|
+
/**
|
|
66
|
+
* Also fail open on 401/403/404 (wrong secret/app id, disabled app). Default
|
|
67
|
+
* FALSE since 0.2.0: those deny, because they are configuration errors.
|
|
68
|
+
*/
|
|
69
|
+
failOpenOnAuthError?: boolean;
|
|
70
|
+
/**
|
|
71
|
+
* A cached answer older than this is not served during an outage (the
|
|
72
|
+
* failOpen rule applies instead). Default 7 days.
|
|
73
|
+
*/
|
|
74
|
+
maxStaleSeconds?: number;
|
|
75
|
+
/** Called for every failed entitlement check (metrics / alerting). Must not throw. */
|
|
76
|
+
onError?: (failure: EntitlementFailure) => void;
|
|
77
|
+
/**
|
|
78
|
+
* What checks answer while the owner's KILL SWITCH is on for this app — 403 app_disabled (the app was disabled,
|
|
79
|
+
* e.g. because its secret was stolen) or 503 service_locked_down (the whole service is locked down). Since 0.7.
|
|
80
|
+
* - 'fail_open' (default): your customers keep access — the last known (cached / stale) answer; an account with
|
|
81
|
+
* nothing cached follows `failOpen` (allowed by default, denied with failOpen: false) — and every such check
|
|
82
|
+
* logs at ERROR, loudly. The kill exists to stop a THIEF using your credentials; it must
|
|
83
|
+
* not also lock out your paying customers while you rotate.
|
|
84
|
+
* - 'deny': checks deny (reason 'unverified', source 'error') and the cache is dropped.
|
|
85
|
+
* A 401 (revoked / wrong secret) still DENIES as before (`failOpenOnAuthError`), whatever this says.
|
|
86
|
+
* There is no client-side "self-destruct": an SDK is code a thief can copy and edit, so all enforcement is in the
|
|
87
|
+
* service (see the README, "Failure behaviour").
|
|
88
|
+
*/
|
|
89
|
+
onKill?: 'fail_open' | 'deny';
|
|
90
|
+
/** fetch implementation (tests, or a service binding's fetch). Default: global fetch. */
|
|
91
|
+
fetch?: typeof fetch;
|
|
92
|
+
/** Per-request timeout. Default 3000 ms. */
|
|
93
|
+
timeoutMs?: number;
|
|
94
|
+
logger?: Logger;
|
|
95
|
+
/**
|
|
96
|
+
* Keeps background refreshes alive after the response in Workers
|
|
97
|
+
* (`ctx.waitUntil.bind(ctx)`). Can also be passed per call.
|
|
98
|
+
*/
|
|
99
|
+
waitUntil?: (p: Promise<unknown>) => void;
|
|
100
|
+
/** Clock override, epoch ms (tests). */
|
|
101
|
+
now?: () => number;
|
|
102
|
+
/** Tracks that could not reach the service wait in memory for a retry; at most this many (oldest dropped). Default 1000. Since 0.5.0. */
|
|
103
|
+
usageBufferSize?: number;
|
|
104
|
+
/** A buffered track is dropped (and logged) after this many failed sends. Default 5. Since 0.5.0. */
|
|
105
|
+
usageMaxAttempts?: number;
|
|
106
|
+
}
|
|
107
|
+
/** Options of `track()` (since 0.5.0). */
|
|
108
|
+
export interface TrackOptions {
|
|
109
|
+
/**
|
|
110
|
+
* Unique per app (90 days): a retry with the same key never counts twice. Default: a random key per
|
|
111
|
+
* call, so the SDK's own retries are safe — pass your own (e.g. the message id) to dedupe yours.
|
|
112
|
+
*/
|
|
113
|
+
idempotencyKey?: string;
|
|
114
|
+
eventName?: string;
|
|
115
|
+
properties?: Record<string, unknown>;
|
|
116
|
+
/** Answer the check for `value` and deduct only when allowed, in one atomic step. */
|
|
117
|
+
checkAndTrack?: boolean;
|
|
118
|
+
waitUntil?: (p: Promise<unknown>) => void;
|
|
119
|
+
}
|
|
120
|
+
export interface DeleteAccountResult {
|
|
121
|
+
deleted: boolean;
|
|
122
|
+
account_id: string;
|
|
123
|
+
canceled: string[];
|
|
124
|
+
cancel_mode?: 'immediately' | 'period_end';
|
|
125
|
+
customer_deleted?: boolean;
|
|
126
|
+
/** What the service keeps after deletion (hashed trial marks, one audit entry). */
|
|
127
|
+
retained?: string[];
|
|
128
|
+
}
|
|
129
|
+
export interface CheckoutParams {
|
|
130
|
+
accountId: string;
|
|
131
|
+
plan: string;
|
|
132
|
+
quantity?: number;
|
|
133
|
+
successUrl: string;
|
|
134
|
+
cancelUrl: string;
|
|
135
|
+
/** Used for the Stripe customer (receipts) if the account has none yet. */
|
|
136
|
+
email?: string;
|
|
137
|
+
/**
|
|
138
|
+
* The OTHER accounts `accountId` pays for (since 0.4.0): one subscription per covered
|
|
139
|
+
* account, all owned by `accountId`. One id: a subscription Checkout; several: one
|
|
140
|
+
* card-only setup Checkout, then a subscription per account, each with its own trial.
|
|
141
|
+
*/
|
|
142
|
+
covers?: string | string[];
|
|
143
|
+
/** A Stripe promotion code id (promo_…) to apply (since 0.4.0). */
|
|
144
|
+
promotionCode?: string;
|
|
145
|
+
/** The name on the payer's Stripe customer, shown on invoices and receipts (since 0.4.0). */
|
|
146
|
+
customerName?: string;
|
|
147
|
+
}
|
|
148
|
+
export interface CheckoutResult {
|
|
149
|
+
url: string;
|
|
150
|
+
sessionId: string;
|
|
151
|
+
/** Since 0.6.0, mode 'payment' (a pack or a lifetime plan): the purchase this Checkout pays for. */
|
|
152
|
+
purchaseId?: string;
|
|
153
|
+
trialEnd: string | null;
|
|
154
|
+
reused: boolean;
|
|
155
|
+
/** 'setup' for a multi-account Checkout (since 0.4.0); 'payment' for a one_time product (since 0.6.0). */
|
|
156
|
+
mode: 'subscription' | 'setup' | 'payment';
|
|
157
|
+
/** The accounts it pays for ([] = the payer itself). */
|
|
158
|
+
covers: string[];
|
|
159
|
+
/** The Stripe-side trial end per covered account (null = charged on completion). */
|
|
160
|
+
trialEnds: Record<string, string | null>;
|
|
161
|
+
}
|
|
162
|
+
/** Which of an account's OWN subscriptions an action targets (since 0.4.0). Default: its own current one. */
|
|
163
|
+
export interface SubscriptionSelector {
|
|
164
|
+
/** One subscription by the service's id (sub_row_…). */
|
|
165
|
+
subscriptionId?: string;
|
|
166
|
+
/** The live subscription that covers this other account. */
|
|
167
|
+
coversAccountId?: string;
|
|
168
|
+
/** Every live subscription it owns (a payer's bulk switch); see `results`. */
|
|
169
|
+
all?: boolean;
|
|
170
|
+
}
|
|
171
|
+
/** The wire form of an AccountInput (snake_case; left-out fields stay out). */
|
|
172
|
+
export declare function accountInputBody(input: AccountInput): Record<string, unknown>;
|
|
173
|
+
/** The service's batch limit (POST /v1/accounts/batch and /upsert). */
|
|
174
|
+
export declare const BATCH_LIMIT = 200;
|
|
175
|
+
export interface Billing {
|
|
176
|
+
/** Cached, fail-open entitlement for an account. Never throws. */
|
|
177
|
+
getEntitlement(accountId: string, opts?: {
|
|
178
|
+
waitUntil?: (p: Promise<unknown>) => void;
|
|
179
|
+
fresh?: boolean;
|
|
180
|
+
}): Promise<EntitlementResult>;
|
|
181
|
+
/** Drops the cached entitlement (verifyBillingWebhook calls this). */
|
|
182
|
+
invalidate(accountId: string): Promise<void>;
|
|
183
|
+
/**
|
|
184
|
+
* Starts Stripe Checkout; redirect the user to `url`. A repeated identical
|
|
185
|
+
* call returns the same open session (`reused: true`). An account that
|
|
186
|
+
* already subscribes gets BillingError 409 `already_subscribed` with
|
|
187
|
+
* `details.portal_url`.
|
|
188
|
+
*/
|
|
189
|
+
checkout(params: CheckoutParams): Promise<CheckoutResult>;
|
|
190
|
+
/** Starts the free trial (apps in 'explicit' trial mode): once per account, email and card. 409 trial_used. */
|
|
191
|
+
startTrial(accountId: string, opts?: {
|
|
192
|
+
email?: string;
|
|
193
|
+
}): Promise<AccountStatus>;
|
|
194
|
+
/**
|
|
195
|
+
* Deletes the account's billing data (GDPR/COPPA): cancels its live
|
|
196
|
+
* subscriptions (immediately, or at period end), deletes what the service
|
|
197
|
+
* stores. Throws 502 cancel_failed (and deletes nothing) if Stripe refuses.
|
|
198
|
+
*/
|
|
199
|
+
deleteAccount(accountId: string, opts?: {
|
|
200
|
+
cancel?: 'immediately' | 'period_end';
|
|
201
|
+
deleteCustomer?: boolean;
|
|
202
|
+
}): Promise<DeleteAccountResult>;
|
|
203
|
+
/** Everything the service stores about the account (data export). */
|
|
204
|
+
exportAccount(accountId: string): Promise<Record<string, unknown>>;
|
|
205
|
+
/** The owner summary for this app: counts by state, MRR estimate, flags, recent subscriptions, webhook health. */
|
|
206
|
+
summary(): Promise<Record<string, unknown>>;
|
|
207
|
+
/** Opens the Stripe customer portal for the account's OWN subscription(s); `subscriptionId` must be one it owns. */
|
|
208
|
+
portal(params: {
|
|
209
|
+
accountId: string;
|
|
210
|
+
returnUrl: string;
|
|
211
|
+
subscriptionId?: string;
|
|
212
|
+
}): Promise<{
|
|
213
|
+
url: string;
|
|
214
|
+
}>;
|
|
215
|
+
/**
|
|
216
|
+
* Turns auto-renew on/off for subscriptions the account OWNS: its own current one by default,
|
|
217
|
+
* or (since 0.4.0) one by id, the one covering an account, or all of them (`results` per subscription).
|
|
218
|
+
*/
|
|
219
|
+
setAutoRenew(accountId: string, on: boolean, select?: SubscriptionSelector): Promise<AccountStatus>;
|
|
220
|
+
/**
|
|
221
|
+
* Entitlements of many accounts (since 0.4.0): cached ones are served from the cache, the misses
|
|
222
|
+
* are fetched in ONE request per 200 ids, and every id fails open on its own (an outage serves the
|
|
223
|
+
* last known value, or allows). Ids the service has never seen are null unless `create: true`
|
|
224
|
+
* (reading must not start trials) — upsert them first, or pass create.
|
|
225
|
+
*/
|
|
226
|
+
getEntitlements(accountIds: string[], opts?: {
|
|
227
|
+
waitUntil?: (p: Promise<unknown>) => void;
|
|
228
|
+
fresh?: boolean;
|
|
229
|
+
create?: boolean;
|
|
230
|
+
}): Promise<Record<string, EntitlementResult | null>>;
|
|
231
|
+
/** Full status of many accounts in one request per 200 ids (refreshes their cache); unknown ids are null. Since 0.4.0. */
|
|
232
|
+
statuses(accountIds: string[], opts?: {
|
|
233
|
+
create?: boolean;
|
|
234
|
+
}): Promise<Record<string, AccountStatus | null>>;
|
|
235
|
+
/** Creates or updates one account: createdAt (trial anchor), parentAccountId, role, email. Since 0.4.0. */
|
|
236
|
+
upsertAccount(accountId: string, input: AccountInput): Promise<AccountStatus>;
|
|
237
|
+
/** The same for many (≤ 200 per request; larger lists are sent in chunks). Refused ones are in `errors`. Since 0.4.0. */
|
|
238
|
+
upsertAccounts(accounts: Array<AccountInput & {
|
|
239
|
+
accountId: string;
|
|
240
|
+
}>): Promise<UpsertResult>;
|
|
241
|
+
/**
|
|
242
|
+
* Full status for a billing page. Also refreshes the entitlement cache.
|
|
243
|
+
* Pass the user's email to have `trial_available` honour once-per-email trials.
|
|
244
|
+
*/
|
|
245
|
+
status(accountId: string, opts?: {
|
|
246
|
+
email?: string;
|
|
247
|
+
}): Promise<AccountStatus>;
|
|
248
|
+
/** Declares that `coveredBy` pays for `accountId` (null removes it). */
|
|
249
|
+
setCoverage(accountId: string, coveredBy: string | null): Promise<AccountStatus>;
|
|
250
|
+
/**
|
|
251
|
+
* May the account use the feature (since 0.5.0)? NEVER throws. A boolean feature is answered from a
|
|
252
|
+
* fresh cached entitlement when there is one; otherwise POST /v1/check. When the service is down:
|
|
253
|
+
* the last known value (within maxStaleSeconds), else allowed with reason 'unverified' (failOpen).
|
|
254
|
+
* A 401/403/404 (wrong secret, disabled app, unknown feature) DENIES, as for entitlements.
|
|
255
|
+
*/
|
|
256
|
+
check(accountId: string, featureId: string, opts?: {
|
|
257
|
+
requiredBalance?: number;
|
|
258
|
+
fresh?: boolean;
|
|
259
|
+
}): Promise<CheckResult>;
|
|
260
|
+
/**
|
|
261
|
+
* Records usage (since 0.5.0): deducts `value` (default 1) atomically; refused (allowed:false, nothing
|
|
262
|
+
* recorded) without room. NEVER throws: when the service is unreachable the event waits in a small
|
|
263
|
+
* in-memory buffer (retried on later calls or flushUsage(), dropped and logged after usageMaxAttempts)
|
|
264
|
+
* and the answer is allowed with reason 'unverified' and queued: true. Usage is never fatal to the app.
|
|
265
|
+
*/
|
|
266
|
+
track(accountId: string, featureId: string, value?: number, opts?: TrackOptions): Promise<TrackResult>;
|
|
267
|
+
/** Sets the account's usage of a feature to `value` (a static feature's real count). Throws BillingError. Since 0.5.0. */
|
|
268
|
+
setUsage(accountId: string, featureId: string, value: number): Promise<TrackResult>;
|
|
269
|
+
/** Sends the buffered tracks now (POST /v1/track/batch). Never throws. Since 0.5.0. */
|
|
270
|
+
flushUsage(): Promise<{
|
|
271
|
+
sent: number;
|
|
272
|
+
dropped: number;
|
|
273
|
+
pending: number;
|
|
274
|
+
}>;
|
|
275
|
+
/** Every balance of the account, its grants, held locks, auto top-ups and spend cap. Throws BillingError. Since 0.6.0. */
|
|
276
|
+
balances(accountId: string): Promise<Balances>;
|
|
277
|
+
/**
|
|
278
|
+
* Reserves `amount` of a feature's balance (since 0.6.0); `allowed: false` and `lock_id: null` when
|
|
279
|
+
* there is no room. Finalize with what was used; an unfinalized lock lapses after ttlSeconds and
|
|
280
|
+
* gives everything back. Throws BillingError (a lock is an action, not a check).
|
|
281
|
+
*/
|
|
282
|
+
lock(accountId: string, featureId: string, amount: number, opts?: {
|
|
283
|
+
ttlSeconds?: number;
|
|
284
|
+
idempotencyKey?: string;
|
|
285
|
+
}): Promise<Lock>;
|
|
286
|
+
/** Confirms what a lock used (0..amount) and gives the rest back. 409 lock_not_held once finalized or lapsed. Since 0.6.0. */
|
|
287
|
+
finalize(lockId: string, used: number): Promise<Lock>;
|
|
288
|
+
/** Checkout for a prepaid pack (a `mode: "one_time"` plan): a manual top-up. Same rules as checkout(). Since 0.6.0. */
|
|
289
|
+
topUp(params: {
|
|
290
|
+
accountId: string;
|
|
291
|
+
product: string;
|
|
292
|
+
quantity?: number;
|
|
293
|
+
successUrl: string;
|
|
294
|
+
cancelUrl: string;
|
|
295
|
+
email?: string;
|
|
296
|
+
}): Promise<CheckoutResult>;
|
|
297
|
+
/** The account's spend cap and low-balance / automatic top-up rules (its own choices; the app decides who may set them). Since 0.6.0. */
|
|
298
|
+
setUsageSettings(accountId: string, settings: UsageSettingsInput): Promise<Record<string, unknown>>;
|
|
299
|
+
/**
|
|
300
|
+
* Changes the plan of a subscription the account OWNS (since 0.7.0). Defaults: an upgrade now, prorated and
|
|
301
|
+
* charged at once; a downgrade at period end; an interval switch now. `change.status` is applied | scheduled |
|
|
302
|
+
* requires_action (send the user to `change.action_url`). Pass `prorationDate` from previewChange to be
|
|
303
|
+
* charged exactly what it showed. Throws BillingError. The app decides who may do this (canManage).
|
|
304
|
+
*/
|
|
305
|
+
changePlan(accountId: string, plan: string, opts?: PlanChangeOptions): Promise<AccountStatus & {
|
|
306
|
+
change: PlanChange;
|
|
307
|
+
}>;
|
|
308
|
+
/** What changePlan would cost: amount due now, the next invoice, the lines. Since 0.7.0. */
|
|
309
|
+
previewChange(accountId: string, plan: string, opts?: PlanChangeOptions): Promise<ChangePreview>;
|
|
310
|
+
/** Attaches an add-on plan (or sets its quantity) on the account's own subscription. Since 0.7.0. */
|
|
311
|
+
attachAddOn(accountId: string, plan: string, opts?: {
|
|
312
|
+
quantity?: number;
|
|
313
|
+
subscriptionId?: string;
|
|
314
|
+
}): Promise<AccountStatus>;
|
|
315
|
+
/** Removes an add-on. Since 0.7.0. */
|
|
316
|
+
detachAddOn(accountId: string, plan: string): Promise<AccountStatus>;
|
|
317
|
+
/** The app's public plans (a pricing page); never custom or hidden plans. Since 0.7.0. */
|
|
318
|
+
plans(): Promise<{
|
|
319
|
+
plans: PublicPlan[];
|
|
320
|
+
default_plan: string | null;
|
|
321
|
+
}>;
|
|
322
|
+
}
|
|
323
|
+
/** Options of changePlan / previewChange (since 0.7.0). */
|
|
324
|
+
export interface PlanChangeOptions {
|
|
325
|
+
when?: 'now' | 'period_end';
|
|
326
|
+
proration?: 'create_prorations' | 'always_invoice' | 'none';
|
|
327
|
+
/** From previewChange: be charged exactly what the preview showed. */
|
|
328
|
+
prorationDate?: number;
|
|
329
|
+
subscriptionId?: string;
|
|
330
|
+
coversAccountId?: string;
|
|
331
|
+
}
|
|
332
|
+
export declare function createBilling(opts: BillingOptions): Billing;
|