@fantastic.dev/better-stripe 0.79.1 → 0.81.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.
Files changed (58) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +1 -1
  3. package/dist/client/billing/renewalPriceReplacement.d.ts +133 -0
  4. package/dist/client/billing/renewalPriceReplacement.d.ts.map +1 -0
  5. package/dist/client/billing/renewalPriceReplacement.js +90 -0
  6. package/dist/client/billing/renewalPriceReplacement.js.map +1 -0
  7. package/dist/client/billing/renewalProjection/discounts.d.ts +20 -0
  8. package/dist/client/billing/renewalProjection/discounts.d.ts.map +1 -0
  9. package/dist/client/billing/renewalProjection/discounts.js +121 -0
  10. package/dist/client/billing/renewalProjection/discounts.js.map +1 -0
  11. package/dist/client/billing/renewalProjection/itemSettings.d.ts +14 -0
  12. package/dist/client/billing/renewalProjection/itemSettings.d.ts.map +1 -0
  13. package/dist/client/billing/renewalProjection/itemSettings.js +41 -0
  14. package/dist/client/billing/renewalProjection/itemSettings.js.map +1 -0
  15. package/dist/client/billing/renewalProjection/settings.d.ts +18 -0
  16. package/dist/client/billing/renewalProjection/settings.d.ts.map +1 -0
  17. package/dist/client/billing/renewalProjection/settings.js +132 -0
  18. package/dist/client/billing/renewalProjection/settings.js.map +1 -0
  19. package/dist/client/billing/renewalProjection/settingsSchema.d.ts +200 -0
  20. package/dist/client/billing/renewalProjection/settingsSchema.d.ts.map +1 -0
  21. package/dist/client/billing/renewalProjection/settingsSchema.js +150 -0
  22. package/dist/client/billing/renewalProjection/settingsSchema.js.map +1 -0
  23. package/dist/client/billing/renewalReplacementSchema.d.ts +126 -0
  24. package/dist/client/billing/renewalReplacementSchema.d.ts.map +1 -0
  25. package/dist/client/billing/renewalReplacementSchema.js +127 -0
  26. package/dist/client/billing/renewalReplacementSchema.js.map +1 -0
  27. package/dist/client/billing/renewalReplacementSnapshot.d.ts +3 -0
  28. package/dist/client/billing/renewalReplacementSnapshot.d.ts.map +1 -0
  29. package/dist/client/billing/renewalReplacementSnapshot.js +69 -0
  30. package/dist/client/billing/renewalReplacementSnapshot.js.map +1 -0
  31. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +32 -32
  32. package/dist/client/connect/payoutSyncTestHelpers.d.ts +16 -16
  33. package/dist/client/index.d.ts +3 -0
  34. package/dist/client/index.d.ts.map +1 -1
  35. package/dist/client/index.js +1 -0
  36. package/dist/client/index.js.map +1 -1
  37. package/dist/client/usage/observationClient.d.ts +2 -2
  38. package/dist/client/usage/observationClient.d.ts.map +1 -1
  39. package/dist/component/balanceFunding/mutations.d.ts +16 -16
  40. package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
  41. package/dist/component/balanceFunding/stateHandlers.d.ts +8 -8
  42. package/dist/component/earnings/triggers.d.ts +16 -16
  43. package/docs/client-api.md +5 -0
  44. package/docs/renewal-preservation-mappings.md +94 -0
  45. package/docs/renewal-price-replacements.md +191 -0
  46. package/package.json +1 -1
  47. package/src/client/billing/renewal-discount-projection.test.ts +207 -0
  48. package/src/client/billing/renewal-item-settings-projection.test.ts +79 -0
  49. package/src/client/billing/renewal-price-replacement.test.ts +503 -0
  50. package/src/client/billing/renewal-settings-projection.test.ts +300 -0
  51. package/src/client/billing/renewalPriceReplacement.ts +127 -0
  52. package/src/client/billing/renewalProjection/discounts.ts +152 -0
  53. package/src/client/billing/renewalProjection/itemSettings.ts +55 -0
  54. package/src/client/billing/renewalProjection/settings.ts +163 -0
  55. package/src/client/billing/renewalProjection/settingsSchema.ts +154 -0
  56. package/src/client/billing/renewalReplacementSchema.ts +135 -0
  57. package/src/client/billing/renewalReplacementSnapshot.ts +85 -0
  58. package/src/client/index.ts +6 -0
@@ -0,0 +1,163 @@
1
+ import type Stripe from "stripe";
2
+ import type { z } from "zod";
3
+ import { renewalSnapshot } from "../renewalReplacementSnapshot.js";
4
+ import { settingsInput, type reference } from "./settingsSchema.js";
5
+
6
+ type Settings = Pick<
7
+ Stripe.SubscriptionScheduleUpdateParams.Phase,
8
+ | "collection_method"
9
+ | "default_payment_method"
10
+ | "on_behalf_of"
11
+ | "transfer_data"
12
+ | "automatic_tax"
13
+ | "default_tax_rates"
14
+ | "invoice_settings"
15
+ | "description"
16
+ | "metadata"
17
+ >;
18
+ type Result =
19
+ | { status: "unsupported"; reason: string }
20
+ | {
21
+ status: "projected";
22
+ settings: Settings;
23
+ requiresProviderQualification: true;
24
+ };
25
+ type Reference = z.infer<ReturnType<typeof reference>>;
26
+ const identity = (ref: Reference) => (typeof ref === "string" ? ref : ref.id);
27
+
28
+ /**
29
+ * Map only the named fields of a provider phase. The aggregate assembler must
30
+ * correlate context with its full acknowledged schedule and unchanged defaults.
31
+ * A projection is neither a complete phase nor evidence of provider retention.
32
+ */
33
+ export function projectRenewalPhaseSettings(input: unknown): Result {
34
+ let args: z.infer<typeof settingsInput>;
35
+ try {
36
+ args = settingsInput.parse(renewalSnapshot(input));
37
+ } catch {
38
+ return { status: "unsupported", reason: "unsupported_phase_settings" };
39
+ }
40
+ const { settings: source, context } = args;
41
+ const failure = (reason: string): Result => ({
42
+ status: "unsupported",
43
+ reason,
44
+ });
45
+ const referenceMatches = (ref: Reference | null | undefined) => {
46
+ if (ref == null || typeof ref === "string") return true;
47
+ const customer = ref.customer;
48
+ if (
49
+ typeof customer === "object" &&
50
+ customer !== null &&
51
+ ((customer.livemode !== undefined &&
52
+ customer.livemode !== context.livemode) ||
53
+ (customer.customer_account !== undefined &&
54
+ customer.customer_account !== context.customerAccountId))
55
+ )
56
+ return false;
57
+ return (
58
+ (ref.livemode === undefined || ref.livemode === context.livemode) &&
59
+ (ref.customer_account == null ||
60
+ ref.customer_account === context.customerAccountId) &&
61
+ (customer == null || identity(customer) === context.customerId)
62
+ );
63
+ };
64
+ const references = [
65
+ source.default_payment_method,
66
+ source.on_behalf_of,
67
+ source.transfer_data?.destination,
68
+ ...(source.invoice_settings?.account_tax_ids ?? []),
69
+ ...(source.default_tax_rates ?? []),
70
+ source.automatic_tax?.liability?.account,
71
+ source.invoice_settings?.issuer?.account,
72
+ ];
73
+ if (!references.every(referenceMatches))
74
+ return failure("foreign_setting_reference");
75
+ const issuerIdentity = (issuer: typeof context.effectiveInvoiceIssuer) =>
76
+ issuer.type === "self" ? "self" : identity(issuer.account);
77
+ if (
78
+ source.invoice_settings?.issuer != null &&
79
+ issuerIdentity(source.invoice_settings.issuer) !==
80
+ issuerIdentity(context.effectiveInvoiceIssuer)
81
+ )
82
+ return failure("invoice_issuer_mismatch");
83
+ for (const taxId of source.invoice_settings?.account_tax_ids ?? []) {
84
+ if (typeof taxId === "string") continue;
85
+ const owner = taxId.owner;
86
+ if (
87
+ issuerIdentity(owner) !==
88
+ issuerIdentity(context.effectiveInvoiceIssuer) ||
89
+ (owner.type === "account" && !referenceMatches(owner.account))
90
+ )
91
+ return failure("foreign_invoice_tax_owner");
92
+ }
93
+ if (
94
+ source.collection_method != null &&
95
+ source.collection_method !== context.effectiveCollectionMethod
96
+ )
97
+ return failure("collection_method_mismatch");
98
+ if (
99
+ source.automatic_tax !== undefined &&
100
+ source.automatic_tax.enabled !== context.effectiveAutomaticTax
101
+ )
102
+ return failure("automatic_tax_mismatch");
103
+ if (context.effectiveAutomaticTax && source.default_tax_rates?.length)
104
+ return failure("automatic_and_manual_tax");
105
+ const out: Settings = {};
106
+ if (source.collection_method !== null)
107
+ out.collection_method = source.collection_method;
108
+ if (source.default_payment_method !== null)
109
+ out.default_payment_method = identity(source.default_payment_method);
110
+ if (source.on_behalf_of !== null)
111
+ out.on_behalf_of = identity(source.on_behalf_of);
112
+ if (source.transfer_data !== null) {
113
+ out.transfer_data = {
114
+ destination: identity(source.transfer_data.destination),
115
+ };
116
+ if (source.transfer_data.amount_percent !== null)
117
+ out.transfer_data.amount_percent = source.transfer_data.amount_percent;
118
+ }
119
+ const mapIssuer = (
120
+ issuer: NonNullable<typeof source.automatic_tax>["liability"],
121
+ ) =>
122
+ issuer?.type === "account"
123
+ ? { type: "account" as const, account: identity(issuer.account) }
124
+ : { type: "self" as const };
125
+ if (source.automatic_tax !== undefined) {
126
+ out.automatic_tax = { enabled: source.automatic_tax.enabled };
127
+ if (source.automatic_tax.liability != null)
128
+ out.automatic_tax.liability = mapIssuer(source.automatic_tax.liability);
129
+ }
130
+ if (source.default_tax_rates != null)
131
+ out.default_tax_rates = source.default_tax_rates.length
132
+ ? source.default_tax_rates.map(identity)
133
+ : "";
134
+ const invoice = source.invoice_settings;
135
+ if (invoice !== null) {
136
+ const mapped: NonNullable<Settings["invoice_settings"]> = {};
137
+ if (invoice.account_tax_ids !== null)
138
+ mapped.account_tax_ids = invoice.account_tax_ids.length
139
+ ? invoice.account_tax_ids.map(identity)
140
+ : "";
141
+ if (invoice.custom_fields !== null)
142
+ mapped.custom_fields = invoice.custom_fields.length
143
+ ? invoice.custom_fields.map(({ name, value }) => ({ name, value }))
144
+ : "";
145
+ if (invoice.issuer !== null) mapped.issuer = mapIssuer(invoice.issuer);
146
+ if (invoice.days_until_due !== null) {
147
+ if (context.effectiveCollectionMethod !== "send_invoice")
148
+ return failure("incompatible_invoice_due_days");
149
+ mapped.days_until_due = invoice.days_until_due;
150
+ }
151
+ if (invoice.description !== null) mapped.description = invoice.description;
152
+ if (invoice.footer !== null) mapped.footer = invoice.footer;
153
+ if (Object.keys(mapped).length) out.invoice_settings = mapped;
154
+ }
155
+ if (source.description !== null) out.description = source.description;
156
+ if (source.metadata !== null && Object.keys(source.metadata).length)
157
+ out.metadata = source.metadata;
158
+ return {
159
+ status: "projected",
160
+ settings: out,
161
+ requiresProviderQualification: true,
162
+ };
163
+ }
@@ -0,0 +1,154 @@
1
+ import { z } from "zod";
2
+
3
+ const id = (prefix: string) =>
4
+ z
5
+ .string()
6
+ .max(255)
7
+ .regex(new RegExp(`^${prefix}_[A-Za-z0-9_]+$`));
8
+ export const reference = (prefix: string, object: string) =>
9
+ z.union([
10
+ id(prefix),
11
+ z
12
+ .object({
13
+ id: id(prefix),
14
+ object: z.literal(object),
15
+ deleted: z.literal(false).optional(),
16
+ livemode: z.boolean().optional(),
17
+ customer: z
18
+ .union([
19
+ id("cus"),
20
+ z
21
+ .object({
22
+ id: id("cus"),
23
+ object: z.literal("customer"),
24
+ deleted: z.literal(false).optional(),
25
+ livemode: z.boolean().optional(),
26
+ customer_account: id("acct").nullable().optional(),
27
+ })
28
+ .passthrough(),
29
+ ])
30
+ .nullable()
31
+ .optional(),
32
+ customer_account: id("acct").nullable().optional(),
33
+ })
34
+ .passthrough(),
35
+ ]);
36
+ const account = reference("acct", "account");
37
+ const issuer = z.discriminatedUnion("type", [
38
+ z.object({ type: z.literal("self"), account: z.null().optional() }).strict(),
39
+ z.object({ type: z.literal("account"), account }).strict(),
40
+ ]);
41
+ const invoiceTaxId = z.union([
42
+ id("txi"),
43
+ z
44
+ .object({
45
+ id: id("txi"),
46
+ object: z.literal("tax_id"),
47
+ deleted: z.literal(false).optional(),
48
+ livemode: z.boolean(),
49
+ customer: z.null().optional(),
50
+ customer_account: z.null().optional(),
51
+ owner: z.discriminatedUnion("type", [
52
+ z
53
+ .object({
54
+ type: z.literal("self"),
55
+ customer_account: z.null(),
56
+ account: z.null().optional(),
57
+ customer: z.null().optional(),
58
+ })
59
+ .strict(),
60
+ z
61
+ .object({
62
+ type: z.literal("account"),
63
+ account,
64
+ customer_account: z.null(),
65
+ customer: z.null().optional(),
66
+ })
67
+ .strict(),
68
+ ]),
69
+ })
70
+ .passthrough(),
71
+ ]);
72
+ export const taxRate = z
73
+ .object({
74
+ id: id("txr"),
75
+ object: z.literal("tax_rate"),
76
+ deleted: z.literal(false).optional(),
77
+ livemode: z.boolean(),
78
+ })
79
+ .passthrough();
80
+ const string = z.string().max(5000);
81
+ export const settingsInput = z
82
+ .object({
83
+ context: z
84
+ .object({
85
+ customerAccountId: id("acct"),
86
+ customerId: id("cus"),
87
+ livemode: z.boolean(),
88
+ effectiveCollectionMethod: z.enum([
89
+ "charge_automatically",
90
+ "send_invoice",
91
+ ]),
92
+ effectiveAutomaticTax: z.boolean(),
93
+ effectiveInvoiceIssuer: issuer,
94
+ })
95
+ .strict(),
96
+ settings: z
97
+ .object({
98
+ application_fee_percent: z.null(),
99
+ billing_thresholds: z.null(),
100
+ collection_method: z
101
+ .enum(["charge_automatically", "send_invoice"])
102
+ .nullable(),
103
+ default_payment_method: reference("pm", "payment_method").nullable(),
104
+ on_behalf_of: account.nullable(),
105
+ transfer_data: z
106
+ .object({
107
+ destination: account,
108
+ amount_percent: z
109
+ .number()
110
+ .min(0)
111
+ .max(100)
112
+ .multipleOf(0.01)
113
+ .nullable(),
114
+ })
115
+ .strict()
116
+ .nullable(),
117
+ automatic_tax: z
118
+ .object({
119
+ enabled: z.boolean(),
120
+ liability: issuer.nullable().optional(),
121
+ disabled_reason: z.null().optional(),
122
+ })
123
+ .strict()
124
+ .optional(),
125
+ default_tax_rates: z.array(taxRate).max(20).nullable().optional(),
126
+ invoice_settings: z
127
+ .object({
128
+ account_tax_ids: z.array(invoiceTaxId).max(20).nullable(),
129
+ custom_fields: z
130
+ .array(
131
+ z
132
+ .object({
133
+ name: z.string().max(40),
134
+ value: z.string().max(140),
135
+ })
136
+ .strict(),
137
+ )
138
+ .max(4)
139
+ .nullable(),
140
+ days_until_due: z.number().int().nonnegative().max(3650).nullable(),
141
+ description: string.nullable(),
142
+ footer: string.nullable(),
143
+ issuer: issuer.nullable(),
144
+ })
145
+ .strict()
146
+ .nullable(),
147
+ description: string.nullable(),
148
+ metadata: z
149
+ .record(z.string().max(40), z.string().min(1).max(500))
150
+ .nullable(),
151
+ })
152
+ .strict(),
153
+ })
154
+ .strict();
@@ -0,0 +1,135 @@
1
+ import { z } from "zod";
2
+
3
+ const id = (prefix: string) =>
4
+ z
5
+ .string()
6
+ .max(255)
7
+ .regex(new RegExp(`^${prefix}_[A-Za-z0-9_]+$`));
8
+ const integer = z.number().int().positive().max(Number.MAX_SAFE_INTEGER);
9
+ // Stripe allows caller-supplied product IDs, including IDs without prod_.
10
+ const productId = z.string().min(1).max(255).regex(/\S/);
11
+ const product = z.union([
12
+ productId,
13
+ z
14
+ .object({
15
+ id: productId,
16
+ object: z.literal("product"),
17
+ deleted: z.literal(false).optional(),
18
+ })
19
+ .passthrough(),
20
+ ]);
21
+ export const renewalPrice = z
22
+ .object({
23
+ id: id("price"),
24
+ object: z.literal("price"),
25
+ product,
26
+ active: z.boolean(),
27
+ livemode: z.boolean(),
28
+ type: z.literal("recurring"),
29
+ currency: z.string().regex(/^[a-z]{3}$/),
30
+ billing_scheme: z.literal("per_unit"),
31
+ recurring: z
32
+ .object({
33
+ interval: z.enum(["day", "week", "month", "year"]),
34
+ interval_count: integer,
35
+ usage_type: z.literal("licensed"),
36
+ })
37
+ .passthrough(),
38
+ })
39
+ .passthrough();
40
+
41
+ export const renewalExpected = z
42
+ .object({
43
+ customerAccountId: id("acct"),
44
+ subscriptionId: id("sub"),
45
+ itemId: id("si"),
46
+ currentPriceId: id("price"),
47
+ currentProductId: productId,
48
+ targetPriceId: id("price"),
49
+ targetProductId: productId,
50
+ periodStart: integer,
51
+ periodEnd: integer,
52
+ livemode: z.boolean(),
53
+ })
54
+ .strict()
55
+ .refine((v) => v.periodEnd > v.periodStart, "Invalid original period.");
56
+
57
+ export const renewalSubscription = z
58
+ .object({
59
+ id: id("sub"),
60
+ object: z.literal("subscription"),
61
+ customer_account: id("acct"),
62
+ status: z.literal("active"),
63
+ currency: z.string().regex(/^[a-z]{3}$/),
64
+ livemode: z.boolean(),
65
+ schedule: z.null(),
66
+ cancel_at: z.null(),
67
+ cancel_at_period_end: z.literal(false),
68
+ pause_collection: z.null(),
69
+ pending_update: z.null(),
70
+ default_source: z.null(),
71
+ application_fee_percent: z.null(),
72
+ payment_settings: z.union([
73
+ z.null(),
74
+ z
75
+ .object({
76
+ payment_method_options: z.null(),
77
+ payment_method_types: z.null(),
78
+ save_default_payment_method: z.literal("off").nullable(),
79
+ })
80
+ .strict(),
81
+ ]),
82
+ billing_schedules: z.array(z.unknown()).length(0).optional(),
83
+ items: z
84
+ .object({
85
+ has_more: z.literal(false),
86
+ data: z.tuple([
87
+ z
88
+ .object({
89
+ id: id("si"),
90
+ object: z.literal("subscription_item"),
91
+ subscription: id("sub"),
92
+ current_period_start: integer,
93
+ current_period_end: integer,
94
+ quantity: integer,
95
+ price: renewalPrice,
96
+ })
97
+ .passthrough(),
98
+ ]),
99
+ })
100
+ .passthrough(),
101
+ })
102
+ .passthrough();
103
+
104
+ /** Trusted host selectors from the original authorized operation, not browser claims. */
105
+ export type RenewalPriceReplacementExpected = z.infer<typeof renewalExpected>;
106
+
107
+ export const renewalBillingCustomer = z
108
+ .object({
109
+ id: id("cus"),
110
+ object: z.literal("customer"),
111
+ customer_account: id("acct"),
112
+ livemode: z.boolean(),
113
+ deleted: z.literal(false).optional(),
114
+ discount: z.union([
115
+ z.null(),
116
+ z
117
+ .object({
118
+ id: id("di"),
119
+ object: z.literal("discount"),
120
+ deleted: z.literal(false).optional(),
121
+ })
122
+ .passthrough(),
123
+ ]),
124
+ })
125
+ .passthrough();
126
+
127
+ export const renewalPreparationInput = z
128
+ .object({
129
+ subscription: z.unknown(),
130
+ targetPrice: z.unknown(),
131
+ billingCustomer: z.unknown().optional(),
132
+ expected: renewalExpected,
133
+ key: z.string(),
134
+ })
135
+ .strict();
@@ -0,0 +1,85 @@
1
+ /** A bounded JSON copy. Reject non-JSON values rather than silently dropping them. */
2
+ export function renewalSnapshot<T>(value: T): T {
3
+ const seen = new Set<object>();
4
+ let nodes = 0;
5
+ let characters = 500_000;
6
+ function charge(size: number) {
7
+ characters -= size;
8
+ if (characters < 0)
9
+ throw new Error("Renewal snapshot exceeds its JSON size budget.");
10
+ }
11
+ function copy(item: unknown, depth: number): unknown {
12
+ if (++nodes > 10_000 || depth > 40)
13
+ throw new Error("Renewal snapshot exceeds its JSON traversal budget.");
14
+ if (typeof item === "string") {
15
+ charge(item.length);
16
+ return item;
17
+ }
18
+ if (item === null || typeof item === "boolean") return item;
19
+ if (typeof item === "number" && Number.isFinite(item)) return item;
20
+ if (typeof item !== "object" || item === null || seen.has(item))
21
+ throw new Error("Renewal snapshot must contain finite JSON values.");
22
+ if (
23
+ !Array.isArray(item) &&
24
+ ![Object.prototype, null].includes(Object.getPrototypeOf(item))
25
+ )
26
+ throw new Error("Renewal snapshot must contain plain JSON objects.");
27
+ if (Array.isArray(item) && item.length > 10_000)
28
+ throw new Error(
29
+ "Renewal snapshot array is too large for its JSON budget.",
30
+ );
31
+ seen.add(item);
32
+ const entries: [string, unknown][] = [];
33
+ for (const key in item) {
34
+ const entry = Object.getOwnPropertyDescriptor(item, key);
35
+ if (!entry) continue;
36
+ if (!("value" in entry))
37
+ throw new Error("Renewal snapshot must contain JSON data properties.");
38
+ if (entries.length >= 10_000)
39
+ throw new Error(
40
+ "Renewal snapshot object exceeds its JSON traversal budget.",
41
+ );
42
+ charge(key.length);
43
+ entries.push([key, entry.value]);
44
+ }
45
+ if (
46
+ Object.getOwnPropertySymbols(item).some(
47
+ (key) => Object.getOwnPropertyDescriptor(item, key)?.enumerable,
48
+ )
49
+ )
50
+ throw new Error("Renewal snapshot must contain JSON data properties.");
51
+ let result: unknown;
52
+ if (Array.isArray(item)) {
53
+ if (
54
+ entries.some(
55
+ ([key]) =>
56
+ !/^(0|[1-9][0-9]*)$/.test(key) || Number(key) >= item.length,
57
+ )
58
+ )
59
+ throw new Error(
60
+ "Renewal snapshot arrays must contain only JSON elements.",
61
+ );
62
+ result = Array.from({ length: item.length }, (_, index) => {
63
+ const entry = Object.getOwnPropertyDescriptor(item, String(index));
64
+ if (!entry || !("value" in entry))
65
+ throw new Error(
66
+ "Renewal snapshot must not contain sparse JSON arrays.",
67
+ );
68
+ return copy(entry.value, depth + 1);
69
+ });
70
+ } else {
71
+ result = Object.fromEntries(
72
+ entries
73
+ .sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))
74
+ .map(([key, entry]) => [key, copy(entry, depth + 1)]),
75
+ );
76
+ }
77
+ seen.delete(item);
78
+ return result;
79
+ }
80
+ const normalized = copy(value, 0);
81
+ const serialized = JSON.stringify(normalized);
82
+ if (serialized.length > 500_000)
83
+ throw new Error("Renewal snapshot is too large.");
84
+ return JSON.parse(serialized) as T;
85
+ }
@@ -1,3 +1,9 @@
1
+ export { prepareRenewalPriceReplacement } from "./billing/renewalPriceReplacement.js";
2
+ export type {
3
+ PrepareRenewalPriceReplacementOptions,
4
+ PreparedRenewalPriceReplacement,
5
+ } from "./billing/renewalPriceReplacement.js";
6
+ export type { RenewalPriceReplacementExpected } from "./billing/renewalReplacementSchema.js";
1
7
  export { qualifyCapturedCheckoutPayment } from "./billing/capturedCheckoutPayment.js";
2
8
  export type {
3
9
  CapturedCheckoutPaymentExpected,