@arnaudjnn/billing-tools 0.58.1 → 0.59.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/dist/index.d.ts CHANGED
@@ -5,6 +5,7 @@ export { getWorkOS } from "./workos.js";
5
5
  export { createWorkOSOrgMirror, ALL_MEMBERSHIP_STATUSES, type WorkOSOrgMirror, type WorkOSOrgMirrorOptions, } from "./org-mirror.js";
6
6
  export { getStripe, stripeConfigured, ensureStripeCustomer, getBillingCustomerId, getOrgSubscription, getTokenBalance, deductTokens, creditTokens, usageSince, createTokenCheckoutSession, createBillingPortalSession, getAutoReloadSettings, setAutoReloadSettings, tryAutoReload, listInvoices, listSubscriptionPrices, resolveSubscriptionPrice, type StripePrice, } from "./billing.js";
7
7
  export { ensurePlans, resolvePlanPrices, invalidatePlanPrices, migrateSubscriptions, planPriceId, planForPriceId, seatTypeForPriceId, seatLimit, seatTypeLimit, planSale, definePlans, isLegacyPlan, normalizePlan, normalizePlans, planModel, plansWhere, selfServePlans, defaultBasket, validateBasket, describeBasketProblem, grantFor, poolSizeOf, packSizeOf, exhaustedPolicy, cycleWindowFor, includedTokens, includedTokensByType, lookupKeyFor, DEFAULT_SEAT_TYPES, type PlanDef, type SeatTypeDef, type PlansConfig, type BillingInterval, type EnsuredPrice, type PlanPrices, type MigratedSubscription, type MigrateSubscriptionsResult, type PlanCatalog, type PlanSpec, type PlanModel, type PlanDisplay, type PlanLimits, type SeatTypeSpec, type SeatTypeDisplay, type NormalSeatType, type Sells, type Grant, type Cap, type Exhausted, type Replenish, type Sale, type Money, type IntervalPrice, type Quantities as PlanQuantities, type BasketProblem, type CycleWindow, } from "./plans.js";
8
+ export { changePlan, cancelPlan, planActions, planRank, PlanChangeError, type PlanChangeResult, type PlanChangeKind, type PlanChangeTiming, type PlanChangeErrorCode, type ProrationPolicy, type PlanActions, } from "./subscription.js";
8
9
  export { derivePlanViews, derivePlanView, renderPlansMarkdown, renderRateCardMarkdown, type PlanView, type PlanPriceView, type SeatRowView, type CtaView, type MoneyView, type DerivePlanViewsOptions, type MarkdownOptions, } from "./pricing.js";
9
10
  export { resolveAllowance, fundingFor, describeDenial, type AllowanceState, type AllowanceInput, type FundingDecision, type DenialReason, } from "./allowance.js";
10
11
  export { stripeBalanceUsageLedger, stripeMeterUsageLedger, ensureMeters, invalidateMeters, USAGE_METER_EVENT, type UsageLedger, type UsageEvent, type UsageQuery, type FundingSource, } from "./usage-ledger.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EACV,cAAc,EACd,WAAW,EACX,UAAU,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAGnE,OAAO,EACL,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,aAAa,GACd,MAAM,WAAW,CAAC;AAMnB,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAIxC,OAAO,EACL,qBAAqB,EACrB,uBAAuB,EACvB,KAAK,eAAe,EACpB,KAAK,sBAAsB,GAC5B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,sBAAsB,EACtB,wBAAwB,EACxB,KAAK,WAAW,GACjB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,oBAAoB,EACpB,oBAAoB,EACpB,WAAW,EACX,cAAc,EACd,kBAAkB,EAClB,SAAS,EACT,aAAa,EACb,QAAQ,EAIR,WAAW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,EACL,KAAK,UAAU,EACf,KAAK,SAAS,EACd,UAAU,EACV,UAAU,EACV,WAAW,EACX,cAAc,EACd,aAAa,GACd,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAKnD,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,YAAY,EACV,UAAU,EACV,qBAAqB,EACrB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACjE,YAAY,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChE,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,YAAY,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACpE,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
package/dist/index.js CHANGED
@@ -18,6 +18,10 @@ export { ensurePlans, resolvePlanPrices, invalidatePlanPrices, migrateSubscripti
18
18
  // it includes, how it's replenished, whether it can be bought) + presentation.
19
19
  // The legacy PlanDef keeps working — `normalizePlans` maps it.
20
20
  definePlans, isLegacyPlan, normalizePlan, normalizePlans, planModel, plansWhere, selfServePlans, defaultBasket, validateBasket, describeBasketProblem, grantFor, poolSizeOf, packSizeOf, exhaustedPolicy, cycleWindowFor, includedTokens, includedTokensByType, lookupKeyFor, DEFAULT_SEAT_TYPES, } from "./plans.js";
21
+ // The subscription lifecycle: one entry point for up, down and off. Before this,
22
+ // every plan or seat change opened a fresh Checkout Session and created a SECOND
23
+ // subscription, so the customer was billed twice.
24
+ export { changePlan, cancelPlan, planActions, planRank, PlanChangeError, } from "./subscription.js";
21
25
  // Pricing view models: the plan config turned into what a surface renders. Also
22
26
  // available as the leaf entry point `@arnaudjnn/billing-tools/pricing`, which
23
27
  // pulls in neither Stripe nor WorkOS — so a client component and a docs
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,mEAAmE;AAYnE,OAAO,EAAE,aAAa,EAAE,sBAAsB,EAAE,MAAM,YAAY,CAAC;AAEnE,cAAc;AACd,OAAO,EACL,WAAW,EACX,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,aAAa,GACd,MAAM,WAAW,CAAC;AAEnB,8EAA8E;AAC9E,6EAA6E;AAC7E,6EAA6E;AAC7E,gFAAgF;AAChF,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAExC,6EAA6E;AAC7E,6EAA6E;AAC7E,OAAO,EACL,qBAAqB,EACrB,uBAAuB,GAGxB,MAAM,iBAAiB,CAAC;AAEzB,+BAA+B;AAC/B,OAAO,EACL,SAAS,EACT,gBAAgB,EAChB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,eAAe,EACf,YAAY,EACZ,YAAY,EACZ,UAAU,EACV,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,EACrB,qBAAqB,EACrB,aAAa,EACb,YAAY,EACZ,sBAAsB,EACtB,wBAAwB,GAEzB,MAAM,cAAc,CAAC;AAEtB,wEAAwE;AACxE,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,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ClD,OAAO,EACL,qBAAqB,EACrB,sBAAsB,EACtB,qBAAqB,EACrB,qBAAqB,EACrB,kBAAkB,EAClB,kBAAkB,EAClB,kBAAkB,GACnB,MAAM,eAAe,CAAC;AAMvB,OAAO,EAAE,cAAc,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAGjE,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,uBAAuB,EACvB,mBAAmB,GACpB,MAAM,sBAAsB,CAAC;AAE9B,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,iBAAiB,EACjB,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAG9B,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,115 @@
1
+ import { type BillingInterval, type PlanCatalog, type PlanModel, type Quantities } from "./plans.js";
2
+ import type { BillingAdapter, ResolvedConfig } from "./types.js";
3
+ export type PlanChangeTiming = "auto" | "now" | "period_end";
4
+ export type ProrationPolicy = "next_invoice" | "invoice_now" | "none";
5
+ export type PlanChangeKind =
6
+ /** No live subscription: a Checkout Session was opened instead. */
7
+ "checkout"
8
+ /** Applied immediately. */
9
+ | "updated"
10
+ /** Takes effect at the end of the paid period. */
11
+ | "scheduled"
12
+ /** Ends at the end of the paid period (a downgrade to a free plan is this). */
13
+ | "canceling"
14
+ /** A pending cancellation was called off. */
15
+ | "resumed"
16
+ /** Already where it was asked to be. */
17
+ | "noop";
18
+ export interface PlanChangeResult {
19
+ kind: PlanChangeKind;
20
+ customerId: string | null;
21
+ subscriptionId: string | null;
22
+ /** The plan in force NOW (unchanged for `scheduled` / `canceling`). */
23
+ plan: string | null;
24
+ status: string | null;
25
+ /** ISO, for `scheduled` / `canceling` — when it takes effect. */
26
+ effectiveAt: string | null;
27
+ /** `checkout` only: mount these with BillingCheckoutSessionProvider. */
28
+ sessionId?: string;
29
+ clientSecret?: string | null;
30
+ }
31
+ export type PlanChangeErrorCode = "multiple_subscriptions" | "unknown_plan" | "not_purchasable" | "invalid_basket" | "needs_return_url" | "no_customer";
32
+ export declare class PlanChangeError extends Error {
33
+ readonly code: PlanChangeErrorCode;
34
+ readonly detail?: unknown | undefined;
35
+ constructor(code: PlanChangeErrorCode, message: string, detail?: unknown | undefined);
36
+ }
37
+ /** What a plan costs per month for its default basket — the ordering a UI means
38
+ * by "higher" and "lower". A quoted plan sorts above every priced one. */
39
+ export declare function planRank(model: PlanModel): number;
40
+ export interface PlanActions {
41
+ /** The next plan up, or null when already at the top. */
42
+ upgradeTo: string | null;
43
+ /** The next plan down, or null when already at the bottom. */
44
+ downgradeTo: string | null;
45
+ /** Whether there is a paid subscription to end. False on a free plan — there
46
+ * is nothing to cancel, so the action shouldn't be offered. */
47
+ canCancel: boolean;
48
+ /** The plan a cancellation lands on. */
49
+ cancelTo: string | null;
50
+ }
51
+ /**
52
+ * Which of upgrade / downgrade / cancel apply to an org on `currentPlan`.
53
+ *
54
+ * Pure, so a UI can hide what doesn't apply instead of offering an action that
55
+ * will be refused: no "upgrade" on the top plan, no "cancel" on a free one.
56
+ */
57
+ export declare function planActions(plans: PlanCatalog, currentPlan: string | null): PlanActions;
58
+ /**
59
+ * Move an org to `to.plan` — up, down, or off.
60
+ *
61
+ * The decision tree, which is why this is one function and not three:
62
+ *
63
+ * no live subscription, paid target → open a Checkout Session
64
+ * live subscription, FREE target → cancel at period end
65
+ * live subscription, same plan, pending cancel → resume
66
+ * live subscription, paid target → update the items; upgrades apply now,
67
+ * downgrades at the period end
68
+ *
69
+ * Proration defaults to `next_invoice` (`create_prorations`): nothing is charged
70
+ * today and the difference rides the next invoice. That is the safe default — no
71
+ * charge today means no SCA challenge, no pending update that expires in ~23h, and
72
+ * a mistake shows up as a wrong line on the next invoice rather than a wrong
73
+ * charge now.
74
+ */
75
+ export declare function changePlan(adapter: BillingAdapter, orgId: string, opts: {
76
+ plans: PlanCatalog;
77
+ to: {
78
+ plan: string;
79
+ interval?: BillingInterval;
80
+ seats?: Quantities;
81
+ };
82
+ config?: ResolvedConfig;
83
+ currency?: string;
84
+ timing?: PlanChangeTiming;
85
+ proration?: ProrationPolicy;
86
+ /**
87
+ * Manual TaxRate ids. Defaults to the rates already on the subscription's
88
+ * items — which is what stops a newly ADDED seat line being invoiced at 0%
89
+ * tax on an account that computes tax itself rather than with Stripe Tax.
90
+ */
91
+ taxRates?: string[];
92
+ /** Required for the no-subscription case, which opens a Checkout Session. */
93
+ returnUrl?: string;
94
+ email?: string;
95
+ metadata?: Record<string, string>;
96
+ /** Disambiguates when a customer somehow has more than one live subscription.
97
+ * Without it that case throws rather than guessing which one to change. */
98
+ subscriptionId?: string;
99
+ /** Write the outcome through the adapter as well as letting the sync engine
100
+ * mirror it, so the next render is already correct. Default true. */
101
+ record?: boolean;
102
+ }): Promise<PlanChangeResult>;
103
+ /**
104
+ * End the paid subscription at the end of the period it has been paid for.
105
+ *
106
+ * A named alias over `changePlan` to the free plan, because "cancel" is what the
107
+ * copy says and what the customer means. Reversible: calling `changePlan` back to
108
+ * the current plan resumes it.
109
+ */
110
+ export declare function cancelPlan(adapter: BillingAdapter, orgId: string, opts: {
111
+ plans: PlanCatalog;
112
+ currency?: string;
113
+ record?: boolean;
114
+ }): Promise<PlanChangeResult>;
115
+ //# sourceMappingURL=subscription.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.d.ts","sourceRoot":"","sources":["../src/subscription.ts"],"names":[],"mappings":"AAGA,OAAO,EAQL,KAAK,eAAe,EACpB,KAAK,WAAW,EAChB,KAAK,SAAS,EACd,KAAK,UAAU,EAChB,MAAM,YAAY,CAAC;AACpB,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAmBjE,MAAM,MAAM,gBAAgB,GAAG,MAAM,GAAG,KAAK,GAAG,YAAY,CAAC;AAC7D,MAAM,MAAM,eAAe,GAAG,cAAc,GAAG,aAAa,GAAG,MAAM,CAAC;AAEtE,MAAM,MAAM,cAAc;AACxB,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"./checkout.js";
3
+ import { defaultBasket, normalizePlans, planModel, resolvePlanPrices, validateBasket, describeBasketProblem, lookupKeyFor, } from "./plans.js";
4
+ export class PlanChangeError extends Error {
5
+ code;
6
+ detail;
7
+ constructor(code, message, detail) {
8
+ super(message);
9
+ this.code = code;
10
+ this.detail = detail;
11
+ this.name = "PlanChangeError";
12
+ }
13
+ }
14
+ /** Statuses that are still being billed, so still worth changing. A canceled or
15
+ * incomplete_expired subscription will never be invoiced again. */
16
+ const LIVE_STATUSES = new Set([
17
+ "active",
18
+ "trialing",
19
+ "past_due",
20
+ "unpaid",
21
+ "paused",
22
+ ]);
23
+ /**
24
+ * The subscription period, read off the ITEMS.
25
+ *
26
+ * `current_period_start/_end` moved off `Subscription` onto `SubscriptionItem` in
27
+ * the API version this SDK pins, so reading them from the subscription yields
28
+ * `undefined` — and this is the date a "cancels on …" or "changes on …" line has
29
+ * to show. Widest window, since items can differ.
30
+ */
31
+ function periodEndOf(sub) {
32
+ const ends = (sub.items?.data ?? [])
33
+ .map((i) => i.current_period_end)
34
+ .filter((v) => !!v);
35
+ return ends.length ? new Date(Math.max(...ends) * 1000).toISOString() : null;
36
+ }
37
+ /** What a plan costs per month for its default basket — the ordering a UI means
38
+ * by "higher" and "lower". A quoted plan sorts above every priced one. */
39
+ export function planRank(model) {
40
+ if (model.sale === "quote")
41
+ return Number.MAX_SAFE_INTEGER;
42
+ const basket = defaultBasket(model);
43
+ if (model.sells.kind === "flat")
44
+ return model.sells.price.monthly;
45
+ return model.seatTypes.reduce((sum, s) => sum + (basket[s.key] ?? 0) * s.price.monthly, 0);
46
+ }
47
+ /**
48
+ * Which of upgrade / downgrade / cancel apply to an org on `currentPlan`.
49
+ *
50
+ * Pure, so a UI can hide what doesn't apply instead of offering an action that
51
+ * will be refused: no "upgrade" on the top plan, no "cancel" on a free one.
52
+ */
53
+ export function planActions(plans, currentPlan) {
54
+ const models = normalizePlans(plans)
55
+ .filter((m) => m.sale !== "legacy" && !m.display?.hidden)
56
+ .sort((a, b) => planRank(a) - planRank(b));
57
+ const free = models.find((m) => m.sale === "free") ?? null;
58
+ const current = currentPlan ? models.find((m) => m.key === currentPlan) : null;
59
+ // No recorded plan behaves as the free tier: nothing is being billed.
60
+ const rank = current ? planRank(current) : (free ? planRank(free) : 0);
61
+ const above = models.filter((m) => planRank(m) > rank);
62
+ const below = models.filter((m) => planRank(m) < rank);
63
+ const isPaid = current ? current.sells.kind !== "nothing" && current.sale !== "free" : false;
64
+ return {
65
+ upgradeTo: above[0]?.key ?? null,
66
+ downgradeTo: below[below.length - 1]?.key ?? null,
67
+ canCancel: isPaid,
68
+ cancelTo: free?.key ?? null,
69
+ };
70
+ }
71
+ async function liveSubscriptions(customerId) {
72
+ const out = [];
73
+ for await (const sub of getStripe().subscriptions.list({
74
+ customer: customerId,
75
+ status: "all",
76
+ limit: 100,
77
+ })) {
78
+ if (LIVE_STATUSES.has(sub.status))
79
+ out.push(sub);
80
+ }
81
+ return out;
82
+ }
83
+ /**
84
+ * Move an org to `to.plan` — up, down, or off.
85
+ *
86
+ * The decision tree, which is why this is one function and not three:
87
+ *
88
+ * no live subscription, paid target → open a Checkout Session
89
+ * live subscription, FREE target → cancel at period end
90
+ * live subscription, same plan, pending cancel → resume
91
+ * live subscription, paid target → update the items; upgrades apply now,
92
+ * downgrades at the period end
93
+ *
94
+ * Proration defaults to `next_invoice` (`create_prorations`): nothing is charged
95
+ * today and the difference rides the next invoice. That is the safe default — no
96
+ * charge today means no SCA challenge, no pending update that expires in ~23h, and
97
+ * a mistake shows up as a wrong line on the next invoice rather than a wrong
98
+ * charge now.
99
+ */
100
+ export async function changePlan(adapter, orgId, opts) {
101
+ const stripe = getStripe();
102
+ const target = planModel(opts.plans, opts.to.plan);
103
+ if (!target)
104
+ throw new PlanChangeError("unknown_plan", `Unknown plan "${opts.to.plan}"`);
105
+ const interval = opts.to.interval ?? (target.intervals.includes("monthly") ? "monthly" : "yearly");
106
+ const targetIsFree = target.sells.kind === "nothing" || target.sale === "free";
107
+ const record = opts.record ?? true;
108
+ let customerId = await getBillingCustomerId(adapter, orgId);
109
+ if (!customerId && !targetIsFree) {
110
+ if (!opts.config)
111
+ throw new PlanChangeError("no_customer", "No Stripe customer, and no config to create one with");
112
+ customerId = await ensureStripeCustomer(adapter, orgId, opts.email, opts.config);
113
+ }
114
+ if (!customerId) {
115
+ // Nothing was ever billed and nothing is being asked for.
116
+ if (record)
117
+ await adapter.setSubscription?.(orgId, { plan: target.key, status: null, subscriptionId: null, periodEnd: null });
118
+ return { kind: "noop", customerId: null, subscriptionId: null, plan: target.key, status: null, effectiveAt: null };
119
+ }
120
+ const live = await liveSubscriptions(customerId);
121
+ const sub = opts.subscriptionId
122
+ ? live.find((s) => s.id === opts.subscriptionId)
123
+ : live.length > 1
124
+ ? undefined
125
+ : live[0];
126
+ if (!sub && live.length > 1) {
127
+ throw new PlanChangeError("multiple_subscriptions", `Customer ${customerId} has ${live.length} live subscriptions; pass subscriptionId to say which one to change`, live.map((s) => s.id));
128
+ }
129
+ // ── No live subscription: open a checkout ─────────────────────────────────
130
+ if (!sub) {
131
+ if (targetIsFree) {
132
+ if (record) {
133
+ await adapter.setSubscription?.(orgId, { plan: target.key, status: null, subscriptionId: null, periodEnd: null });
134
+ }
135
+ return { kind: "noop", customerId, subscriptionId: null, plan: target.key, status: null, effectiveAt: null };
136
+ }
137
+ const problems = validateBasket(opts.plans, { plan: target.key, interval, seats: opts.to.seats });
138
+ if (problems.length) {
139
+ throw new PlanChangeError("invalid_basket", problems.map(describeBasketProblem).join("; "), problems);
140
+ }
141
+ if (!opts.returnUrl) {
142
+ throw new PlanChangeError("needs_return_url", "No live subscription, so a Checkout Session is needed — pass returnUrl");
143
+ }
144
+ const session = await createCheckoutSession({
145
+ plans: opts.plans,
146
+ plan: target.key,
147
+ interval,
148
+ seats: opts.to.seats ?? defaultBasket(target),
149
+ returnUrl: opts.returnUrl,
150
+ customerId,
151
+ currency: opts.currency,
152
+ taxRates: opts.taxRates,
153
+ reuse: true,
154
+ // `org_id`, the key every sync handler reads. Without it the subscription
155
+ // this session creates is invisible to plan mirroring and to grants.
156
+ metadata: { ...opts.metadata, org_id: orgId, plan: target.key },
157
+ });
158
+ return {
159
+ kind: "checkout",
160
+ customerId,
161
+ subscriptionId: null,
162
+ plan: null,
163
+ status: null,
164
+ effectiveAt: null,
165
+ sessionId: session.sessionId,
166
+ clientSecret: session.clientSecret,
167
+ };
168
+ }
169
+ const effectiveAt = periodEndOf(sub);
170
+ const currentPlanKey = sub.metadata?.plan ?? null;
171
+ // ── A pending cancellation being called off ───────────────────────────────
172
+ if (sub.cancel_at_period_end && currentPlanKey && currentPlanKey === target.key) {
173
+ const resumed = await stripe.subscriptions.update(sub.id, { cancel_at_period_end: false });
174
+ if (record) {
175
+ await adapter.setSubscription?.(orgId, {
176
+ plan: target.key,
177
+ status: resumed.status,
178
+ subscriptionId: resumed.id,
179
+ periodEnd: periodEndOf(resumed),
180
+ });
181
+ }
182
+ return { kind: "resumed", customerId, subscriptionId: sub.id, plan: target.key, status: resumed.status, effectiveAt: periodEndOf(resumed) };
183
+ }
184
+ // ── Down to a free plan: cancel at the end of the paid period ─────────────
185
+ //
186
+ // The cheap primitive, not a schedule: it is one field, reversible with
187
+ // `false`, and the customer keeps what they paid for until it runs out.
188
+ if (targetIsFree) {
189
+ if (sub.cancel_at_period_end) {
190
+ return { kind: "canceling", customerId, subscriptionId: sub.id, plan: currentPlanKey, status: sub.status, effectiveAt };
191
+ }
192
+ const canceling = await stripe.subscriptions.update(sub.id, {
193
+ cancel_at_period_end: true,
194
+ metadata: { ...sub.metadata, org_id: orgId, pending_plan: target.key },
195
+ });
196
+ if (record) {
197
+ // The plan in force does NOT change yet — writing the downgraded plan now
198
+ // would remove the customer's access a month before they stop paying.
199
+ await adapter.setOrgMetadata?.(orgId, {
200
+ pendingPlan: target.key,
201
+ pendingPlanAt: periodEndOf(canceling),
202
+ });
203
+ }
204
+ return {
205
+ kind: "canceling",
206
+ customerId,
207
+ subscriptionId: sub.id,
208
+ plan: currentPlanKey,
209
+ status: canceling.status,
210
+ effectiveAt: periodEndOf(canceling),
211
+ };
212
+ }
213
+ // ── A paid target: diff the items ─────────────────────────────────────────
214
+ const seats = opts.to.seats ?? defaultBasket(target);
215
+ const problems = validateBasket(opts.plans, { plan: target.key, interval, seats });
216
+ if (problems.length) {
217
+ throw new PlanChangeError("invalid_basket", problems.map(describeBasketProblem).join("; "), problems);
218
+ }
219
+ const prices = await resolvePlanPrices(opts.plans, { currency: opts.currency });
220
+ const desired = new Map();
221
+ if (target.sells.kind === "flat") {
222
+ const key = lookupKeyFor(target.key, interval);
223
+ const id = prices.get(key);
224
+ if (!id)
225
+ throw new PlanChangeError("invalid_basket", `No Stripe price for ${key}`);
226
+ desired.set(id, 1);
227
+ }
228
+ else {
229
+ for (const [seatType, qty] of Object.entries(seats)) {
230
+ if (qty <= 0)
231
+ continue;
232
+ const key = lookupKeyFor(target.key, interval, seatType);
233
+ const id = prices.get(key);
234
+ if (!id)
235
+ throw new PlanChangeError("invalid_basket", `No Stripe price for ${key}`);
236
+ desired.set(id, qty);
237
+ }
238
+ }
239
+ // Tax rates already on the subscription carry onto ADDED lines. Without this, an
240
+ // account that computes its own tax (manual TaxRates rather than Stripe Tax)
241
+ // invoices a newly added line at 0%.
242
+ const carried = opts.taxRates ??
243
+ [...new Set(sub.items.data.flatMap((i) => (i.tax_rates ?? []).map((r) => r.id)))];
244
+ const items = [];
245
+ const seen = new Set();
246
+ for (const item of sub.items.data) {
247
+ const want = desired.get(item.price.id);
248
+ if (want != null) {
249
+ seen.add(item.price.id);
250
+ if ((item.quantity ?? 1) !== want)
251
+ items.push({ id: item.id, quantity: want });
252
+ }
253
+ else {
254
+ items.push({ id: item.id, deleted: true });
255
+ }
256
+ }
257
+ for (const [priceId, quantity] of desired) {
258
+ if (!seen.has(priceId)) {
259
+ items.push({ price: priceId, quantity, ...(carried.length ? { tax_rates: carried } : {}) });
260
+ }
261
+ }
262
+ if (items.length === 0) {
263
+ return { kind: "noop", customerId, subscriptionId: sub.id, plan: currentPlanKey ?? target.key, status: sub.status, effectiveAt };
264
+ }
265
+ const proration = opts.proration ?? "next_invoice";
266
+ const proration_behavior = proration === "invoice_now" ? "always_invoice" : proration === "none" ? "none" : "create_prorations";
267
+ // Direction decides the default timing: pay more now, pay less at the boundary.
268
+ const currentModel = currentPlanKey ? planModel(opts.plans, currentPlanKey) : null;
269
+ const isDowngrade = currentModel ? planRank(target) < planRank(currentModel) : false;
270
+ const timing = opts.timing ?? "auto";
271
+ const applyAtPeriodEnd = timing === "period_end" || (timing === "auto" && isDowngrade);
272
+ if (applyAtPeriodEnd) {
273
+ // A schedule, because a downgrade must not take effect before the paid period
274
+ // it replaces has run out.
275
+ const schedule = sub.schedule
276
+ ? await stripe.subscriptionSchedules.retrieve(sub.schedule)
277
+ : await stripe.subscriptionSchedules.create({ from_subscription: sub.id });
278
+ const currentPhase = schedule.phases[schedule.phases.length - 1];
279
+ await stripe.subscriptionSchedules.update(schedule.id, {
280
+ end_behavior: "release",
281
+ proration_behavior: "none",
282
+ phases: [
283
+ {
284
+ items: currentPhase.items.map((i) => ({
285
+ price: typeof i.price === "string" ? i.price : i.price.id,
286
+ quantity: i.quantity ?? 1,
287
+ })),
288
+ start_date: currentPhase.start_date,
289
+ end_date: currentPhase.end_date,
290
+ ...(carried.length ? { default_tax_rates: carried } : {}),
291
+ },
292
+ {
293
+ items: [...desired].map(([price, quantity]) => ({ price, quantity })),
294
+ ...(carried.length ? { default_tax_rates: carried } : {}),
295
+ },
296
+ ],
297
+ });
298
+ if (record) {
299
+ await adapter.setOrgMetadata?.(orgId, { pendingPlan: target.key, pendingPlanAt: effectiveAt });
300
+ }
301
+ return { kind: "scheduled", customerId, subscriptionId: sub.id, plan: currentPlanKey, status: sub.status, effectiveAt };
302
+ }
303
+ const updated = await stripe.subscriptions.update(sub.id, {
304
+ items,
305
+ proration_behavior,
306
+ // The live-subscription equivalent of `default_incomplete`: the change
307
+ // applies only once the invoice it generates is paid, and the original
308
+ // subscription is untouched if it never is.
309
+ ...(proration === "invoice_now" ? { payment_behavior: "pending_if_incomplete" } : {}),
310
+ metadata: { ...sub.metadata, org_id: orgId, plan: target.key },
311
+ },
312
+ // Keyed on the target, so a double-clicked Confirm inside Stripe's 24h window
313
+ // is a no-op rather than a second proration invoice.
314
+ { idempotencyKey: `plan:${sub.id}:${target.key}:${interval}:${JSON.stringify([...desired].sort())}:${timing}:${proration}` });
315
+ if (record) {
316
+ await adapter.setSubscription?.(orgId, {
317
+ plan: target.key,
318
+ status: updated.status,
319
+ subscriptionId: updated.id,
320
+ periodEnd: periodEndOf(updated),
321
+ });
322
+ await adapter.setOrgMetadata?.(orgId, { pendingPlan: null, pendingPlanAt: null });
323
+ }
324
+ return {
325
+ kind: "updated",
326
+ customerId,
327
+ subscriptionId: updated.id,
328
+ plan: target.key,
329
+ status: updated.status,
330
+ effectiveAt: periodEndOf(updated),
331
+ };
332
+ }
333
+ /**
334
+ * End the paid subscription at the end of the period it has been paid for.
335
+ *
336
+ * A named alias over `changePlan` to the free plan, because "cancel" is what the
337
+ * copy says and what the customer means. Reversible: calling `changePlan` back to
338
+ * the current plan resumes it.
339
+ */
340
+ export async function cancelPlan(adapter, orgId, opts) {
341
+ const free = normalizePlans(opts.plans).find((m) => m.sale === "free");
342
+ if (!free)
343
+ throw new PlanChangeError("unknown_plan", "No free plan to cancel down to");
344
+ return changePlan(adapter, orgId, { ...opts, to: { plan: free.key } });
345
+ }
346
+ //# sourceMappingURL=subscription.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"subscription.js","sourceRoot":"","sources":["../src/subscription.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,qBAAqB,EAAE,MAAM,eAAe,CAAC;AACtD,OAAO,EACL,aAAa,EACb,cAAc,EACd,SAAS,EACT,iBAAiB,EACjB,cAA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OAAuB,EACvB,KAAa,EACb,IAAiE;IAEjE,MAAM,IAAI,GAAG,cAAc,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAC;IACvE,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,eAAe,CAAC,cAAc,EAAE,gCAAgC,CAAC,CAAC;IACvF,OAAO,UAAU,CAAC,OAAO,EAAE,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE,EAAE,IAAI,EAAE,IAAI,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;AACzE,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arnaudjnn/billing-tools",
3
- "version": "0.58.1",
3
+ "version": "0.59.0",
4
4
  "description": "The get-paid engine for Stripe + WorkOS apps, for humans and AI agents. Drop-in API-key auth, token/credit + subscription billing, auth.md agent registration, and MPP machine payments, as MCP tools, a REST API, and a CLI. Framework-agnostic, storage-pluggable.",
5
5
  "license": "MIT",
6
6
  "author": "Arnaud Jeannin",