@peable.to/contracts 6.0.0 → 6.2.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 (38) hide show
  1. package/dist/cjs/resources/billingEngine/index.js +4 -1
  2. package/dist/cjs/resources/billingEngine/quotes.js +342 -0
  3. package/dist/cjs/resources/checkout/checkoutSessions.js +8 -0
  4. package/dist/cjs/resources/events/events.js +4 -0
  5. package/dist/cjs/vocabulary/checkout.js +3 -1
  6. package/dist/cjs/vocabulary/errors.js +3 -0
  7. package/dist/cjs/vocabulary/events.js +4 -0
  8. package/dist/cjs/vocabulary/index.js +1 -0
  9. package/dist/cjs/vocabulary/invoices.js +3 -0
  10. package/dist/cjs/vocabulary/quotes.js +31 -0
  11. package/dist/esm/resources/billingEngine/index.js +4 -1
  12. package/dist/esm/resources/billingEngine/quotes.js +339 -0
  13. package/dist/esm/resources/checkout/checkoutSessions.js +9 -1
  14. package/dist/esm/resources/events/events.js +4 -0
  15. package/dist/esm/vocabulary/checkout.js +2 -0
  16. package/dist/esm/vocabulary/errors.js +3 -0
  17. package/dist/esm/vocabulary/events.js +4 -0
  18. package/dist/esm/vocabulary/index.js +1 -0
  19. package/dist/esm/vocabulary/invoices.js +3 -0
  20. package/dist/esm/vocabulary/quotes.js +28 -0
  21. package/dist/types/resources/billingEngine/index.d.ts +839 -1
  22. package/dist/types/resources/billingEngine/invoices.d.ts +12 -0
  23. package/dist/types/resources/billingEngine/quotes.d.ts +1032 -0
  24. package/dist/types/resources/checkout/checkoutSessions.d.ts +52 -0
  25. package/dist/types/resources/checkout/index.d.ts +40 -0
  26. package/dist/types/resources/events/events.d.ts +16 -0
  27. package/dist/types/resources/events/index.d.ts +54 -2
  28. package/dist/types/resources/events/webhookDeliveries.d.ts +12 -0
  29. package/dist/types/resources/events/webhookEndpoints.d.ts +52 -4
  30. package/dist/types/resources/payments/disputes.d.ts +10 -10
  31. package/dist/types/resources/payments/index.d.ts +6 -6
  32. package/dist/types/vocabulary/checkout.d.ts +3 -0
  33. package/dist/types/vocabulary/errors.d.ts +3 -0
  34. package/dist/types/vocabulary/events.d.ts +4 -0
  35. package/dist/types/vocabulary/index.d.ts +1 -0
  36. package/dist/types/vocabulary/invoices.d.ts +1 -1
  37. package/dist/types/vocabulary/quotes.d.ts +27 -0
  38. package/package.json +1 -1
@@ -23,6 +23,7 @@ const customerBalanceTransactions_1 = require("./customerBalanceTransactions");
23
23
  const invoiceItems_1 = require("./invoiceItems");
24
24
  const invoices_1 = require("./invoices");
25
25
  const public_1 = require("./public");
26
+ const quotes_1 = require("./quotes");
26
27
  const subscriptions_1 = require("./subscriptions");
27
28
  __exportStar(require("./billingPortal"), exports);
28
29
  __exportStar(require("./creditNotes"), exports);
@@ -30,13 +31,15 @@ __exportStar(require("./customerBalanceTransactions"), exports);
30
31
  __exportStar(require("./invoiceItems"), exports);
31
32
  __exportStar(require("./invoices"), exports);
32
33
  __exportStar(require("./public"), exports);
34
+ __exportStar(require("./quotes"), exports);
33
35
  __exportStar(require("./subscriptions"), exports);
34
- /** Orbit's native billing engine (ADR 0018): subscriptions, invoices, credit notes, the balance ledger and the customer portal. */
36
+ /** Orbit's native billing engine (ADR 0018): subscriptions, invoices, credit notes, quotes, the balance ledger and the customer portal. */
35
37
  exports.billingEngineRoutes = [
36
38
  ...subscriptions_1.subscriptionRoutes,
37
39
  ...invoices_1.invoiceRoutes,
38
40
  ...invoiceItems_1.invoiceItemRoutes,
39
41
  ...creditNotes_1.creditNoteRoutes,
42
+ ...quotes_1.quoteRoutes,
40
43
  ...customerBalanceTransactions_1.customerBalanceTransactionRoutes,
41
44
  ...billingPortal_1.billingPortalRoutes,
42
45
  ...public_1.publicBillingRoutes,
@@ -0,0 +1,342 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.quoteRoutes = exports.listQuoteLineItemsQuery = exports.listQuotesQuery = exports.quoteActionParams = exports.finalizeQuoteParams = exports.updateQuoteParams = exports.createQuoteParams = exports.quoteSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const envelopes_1 = require("../../common/envelopes");
6
+ const objects_1 = require("../../common/objects");
7
+ const params_1 = require("../../common/params");
8
+ const primitives_1 = require("../../common/primitives");
9
+ const route_1 = require("../../route");
10
+ const invoices_1 = require("../../vocabulary/invoices");
11
+ const quotes_1 = require("../../vocabulary/quotes");
12
+ const subscriptions_1 = require("../../vocabulary/subscriptions");
13
+ const shared_1 = require("../checkout/shared");
14
+ const params_2 = require("./params");
15
+ const subscriptions_2 = require("./subscriptions");
16
+ /**
17
+ * Quotes (`qt_…`) — Stripe's Quotes on Orbit's native billing engine (ADR 0018
18
+ * §5). A quote prices catalog Prices for one customer: a `draft` is edited,
19
+ * `finalize` numbers it and fixes its discount and Peable Tax (failing closed,
20
+ * never zero), and `accept` turns it into native billing objects — an invoice
21
+ * for one-time lines, a subscription with its first invoice for recurring ones
22
+ * (one-time lines then ride on that first invoice). Its lines are Stripe's
23
+ * `item`, the same object a Checkout Session's lines are.
24
+ */
25
+ const totalDetailsSchema = zod_1.z
26
+ .object({
27
+ amount_discount: primitives_1.amount,
28
+ amount_shipping: primitives_1.amount.describe('Always `0`: a quote ships nothing.'),
29
+ amount_tax: primitives_1.amount
30
+ .nullable()
31
+ .describe('Every tax, inclusive and exclusive; `null` on a draft whose tax is not known yet.'),
32
+ })
33
+ .strict();
34
+ exports.quoteSchema = (0, objects_1.defineObject)('quote', 'Quote', zod_1.z
35
+ .object({
36
+ id: zod_1.z.string(),
37
+ object: zod_1.z.literal('quote'),
38
+ livemode: primitives_1.livemode,
39
+ number: zod_1.z
40
+ .string()
41
+ .nullable()
42
+ .describe('`null` while a draft; `QT-PREFIX-0001` once finalized — per merchant.'),
43
+ status: zod_1.z.enum(quotes_1.QUOTE_STATUSES),
44
+ customer: (0, objects_1.expandable)('customer', '`cus_…`, or the Customer with `expand[]=customer`.'),
45
+ currency: primitives_1.currency,
46
+ collection_method: zod_1.z.enum(subscriptions_1.COLLECTION_METHODS),
47
+ invoice_settings: zod_1.z
48
+ .object({
49
+ days_until_due: zod_1.z
50
+ .number()
51
+ .int()
52
+ .nullable()
53
+ .describe("`send_invoice` only; the billing settings' default when `null`."),
54
+ })
55
+ .strict(),
56
+ subscription_data: zod_1.z
57
+ .object({
58
+ description: zod_1.z.string().nullable(),
59
+ trial_period_days: zod_1.z.number().int().nullable(),
60
+ metadata: primitives_1.metadata,
61
+ })
62
+ .strict()
63
+ .describe('What the subscription an accepted quote with recurring lines starts with.'),
64
+ discount: subscriptions_2.discountSchema.nullable(),
65
+ automatic_tax: zod_1.z
66
+ .object({
67
+ enabled: zod_1.z.boolean(),
68
+ status: zod_1.z.enum(invoices_1.AUTOMATIC_TAX_STATUSES).nullable(),
69
+ tax_calculation: zod_1.z
70
+ .string()
71
+ .nullable()
72
+ .describe('The Peable Tax calculation (`taxcalc_…`) the quote finalized with.'),
73
+ })
74
+ .strict(),
75
+ amount_subtotal: primitives_1.amount.describe('Every line before discount and tax (one period of a recurring line).'),
76
+ amount_total: primitives_1.amount.describe('`amount_subtotal - amount_discount + exclusive tax`.'),
77
+ total_details: totalDetailsSchema,
78
+ expires_at: primitives_1.unixSeconds.describe('An open quote is cancelled at this instant.'),
79
+ header: zod_1.z.string().nullable(),
80
+ description: zod_1.z.string().nullable(),
81
+ footer: zod_1.z.string().nullable(),
82
+ invoice: (0, objects_1.expandable)('invoice', "The invoice accepting made (`in_…`, expandable): the one-time invoice, or the subscription's first.").nullable(),
83
+ subscription: (0, objects_1.expandable)('subscription', 'The subscription accepting made (`sub_…`, expandable); `null` without recurring lines.').nullable(),
84
+ status_transitions: zod_1.z
85
+ .object({
86
+ finalized_at: primitives_1.unixSeconds.nullable(),
87
+ accepted_at: primitives_1.unixSeconds.nullable(),
88
+ canceled_at: primitives_1.unixSeconds.nullable(),
89
+ })
90
+ .strict(),
91
+ test_clock: zod_1.z.string().nullable(),
92
+ metadata: primitives_1.metadata,
93
+ created: primitives_1.unixSeconds,
94
+ })
95
+ .strict(), {
96
+ examples: [
97
+ {
98
+ id: 'qt_0193b8f2c1a87d3e9f4a',
99
+ object: 'quote',
100
+ livemode: false,
101
+ number: 'QT-ACME-0001',
102
+ status: 'open',
103
+ customer: 'cus_0193b8f2c1a87d3e9f4a',
104
+ currency: 'EUR',
105
+ collection_method: 'send_invoice',
106
+ invoice_settings: { days_until_due: 30 },
107
+ subscription_data: { description: null, trial_period_days: null, metadata: {} },
108
+ discount: null,
109
+ automatic_tax: { enabled: false, status: null, tax_calculation: null },
110
+ amount_subtotal: '120000',
111
+ amount_total: '120000',
112
+ total_details: { amount_discount: '0', amount_shipping: '0', amount_tax: '0' },
113
+ expires_at: 1796342400,
114
+ header: 'Annual support',
115
+ description: null,
116
+ footer: null,
117
+ invoice: null,
118
+ subscription: null,
119
+ status_transitions: { finalized_at: 1793750400, accepted_at: null, canceled_at: null },
120
+ test_clock: null,
121
+ metadata: {},
122
+ created: 1793750400,
123
+ },
124
+ ],
125
+ });
126
+ // ---- Requests ------------------------------------------------------------------------
127
+ const quoteLineItemParams = zod_1.z
128
+ .object({
129
+ price: params_1.idParam.describe('An active, licensed catalog Price (`price_…`), one-time or recurring.'),
130
+ quantity: zod_1.z
131
+ .number()
132
+ .int()
133
+ .min(1)
134
+ .max(quotes_1.QUOTE_LIMITS.quantityMax)
135
+ .optional()
136
+ .describe('Default 1.'),
137
+ })
138
+ .strict();
139
+ const lineItemsParam = zod_1.z
140
+ .array(quoteLineItemParams)
141
+ .min(1)
142
+ .max(quotes_1.QUOTE_LIMITS.lineItemsMax)
143
+ .describe('Each price once, in one currency; every recurring price on one interval. Replaces every line on an update.');
144
+ const invoiceSettingsParam = zod_1.z.object({ days_until_due: params_2.daysUntilDueParam.optional() }).strict();
145
+ const subscriptionDataParam = zod_1.z
146
+ .object({
147
+ description: (0, params_2.shortText)(500).optional(),
148
+ trial_period_days: zod_1.z.number().int().min(1).max(quotes_1.QUOTE_LIMITS.trialPeriodDaysMax).optional(),
149
+ metadata: params_1.metadataCreateParam.optional(),
150
+ })
151
+ .strict();
152
+ exports.createQuoteParams = zod_1.z
153
+ .object({
154
+ customer: params_1.idParam,
155
+ line_items: lineItemsParam,
156
+ collection_method: zod_1.z
157
+ .enum(subscriptions_1.COLLECTION_METHODS)
158
+ .optional()
159
+ .describe('Default `charge_automatically`; a FairCoin (`FAIR`) quote is always `send_invoice`.'),
160
+ invoice_settings: invoiceSettingsParam.optional(),
161
+ subscription_data: subscriptionDataParam.optional(),
162
+ discounts: params_2.discountsParam.optional().describe('At most one: a coupon or a promotion code.'),
163
+ automatic_tax: params_2.automaticTaxParam.optional(),
164
+ expires_at: params_1.unixSecondsParam
165
+ .optional()
166
+ .describe("Default: 30 days from now (the customer's test clock time when it has one)."),
167
+ header: (0, params_2.shortText)(quotes_1.QUOTE_LIMITS.headerMax).optional(),
168
+ description: (0, params_2.shortText)(quotes_1.QUOTE_LIMITS.descriptionMax).optional(),
169
+ footer: (0, params_2.shortText)(quotes_1.QUOTE_LIMITS.footerMax).optional(),
170
+ metadata: params_1.metadataCreateParam.optional(),
171
+ expand: params_1.expandParam.optional(),
172
+ })
173
+ .strict();
174
+ /** Drafts only, except `metadata`. A field sent as `""` is cleared. */
175
+ exports.updateQuoteParams = zod_1.z
176
+ .object({
177
+ line_items: lineItemsParam.optional(),
178
+ collection_method: zod_1.z.enum(subscriptions_1.COLLECTION_METHODS).optional(),
179
+ invoice_settings: invoiceSettingsParam.optional(),
180
+ subscription_data: subscriptionDataParam.optional(),
181
+ discounts: zod_1.z.union([params_2.discountsParam, zod_1.z.literal('')]).optional(),
182
+ automatic_tax: params_2.automaticTaxParam.optional(),
183
+ expires_at: params_1.unixSecondsParam.optional(),
184
+ header: zod_1.z.union([(0, params_2.shortText)(quotes_1.QUOTE_LIMITS.headerMax), zod_1.z.literal('')]).optional(),
185
+ description: zod_1.z.union([(0, params_2.shortText)(quotes_1.QUOTE_LIMITS.descriptionMax), zod_1.z.literal('')]).optional(),
186
+ footer: zod_1.z.union([(0, params_2.shortText)(quotes_1.QUOTE_LIMITS.footerMax), zod_1.z.literal('')]).optional(),
187
+ metadata: params_1.metadataUpdateParam.optional(),
188
+ expand: params_1.expandParam.optional(),
189
+ })
190
+ .strict();
191
+ exports.finalizeQuoteParams = zod_1.z
192
+ .object({
193
+ expires_at: params_1.unixSecondsParam.optional().describe('A new expiry, set as it finalizes.'),
194
+ expand: params_1.expandParam.optional(),
195
+ })
196
+ .strict();
197
+ /** The body of `accept` and `cancel`: nothing but `expand[]`. */
198
+ exports.quoteActionParams = zod_1.z.object({ expand: params_1.expandParam.optional() }).strict();
199
+ exports.listQuotesQuery = (0, params_1.listQuery)({
200
+ customer: params_1.idParam.optional(),
201
+ status: zod_1.z.enum(quotes_1.QUOTE_STATUSES).optional(),
202
+ });
203
+ /** A quote's lines, in their order; `created` does not apply to them. */
204
+ exports.listQuoteLineItemsQuery = (0, params_1.listQuery)({});
205
+ // ---- Routes --------------------------------------------------------------------------
206
+ const quoteId = { id: 'The quote (`qt_…`).' };
207
+ exports.quoteRoutes = [
208
+ (0, route_1.defineRoute)({
209
+ operationId: 'createQuote',
210
+ method: 'post',
211
+ path: '/v1/quotes',
212
+ tag: 'Quotes',
213
+ summary: 'Create a quote',
214
+ description: "A draft for one customer, priced from catalog Prices with the catalog's own pricing. Its tax is computed when it finalizes.",
215
+ auth: 'service',
216
+ scope: 'payments:write',
217
+ idempotent: true,
218
+ body: exports.createQuoteParams,
219
+ response: exports.quoteSchema,
220
+ sdk: 'quotes.create',
221
+ expandable: 'quote',
222
+ }),
223
+ (0, route_1.defineRoute)({
224
+ operationId: 'listQuotes',
225
+ method: 'get',
226
+ path: '/v1/quotes',
227
+ tag: 'Quotes',
228
+ summary: 'List quotes',
229
+ auth: 'service',
230
+ scope: 'payments:read',
231
+ query: exports.listQuotesQuery,
232
+ response: (0, envelopes_1.listOf)(exports.quoteSchema),
233
+ sdk: 'quotes.list',
234
+ expandable: 'quote',
235
+ }),
236
+ (0, route_1.defineRoute)({
237
+ operationId: 'retrieveQuote',
238
+ method: 'get',
239
+ path: '/v1/quotes/{id}',
240
+ tag: 'Quotes',
241
+ summary: 'Retrieve a quote',
242
+ auth: 'service',
243
+ scope: 'payments:read',
244
+ params: quoteId,
245
+ query: params_1.expandOnlyQuery,
246
+ response: exports.quoteSchema,
247
+ sdk: 'quotes.retrieve',
248
+ expandable: 'quote',
249
+ }),
250
+ (0, route_1.defineRoute)({
251
+ operationId: 'updateQuote',
252
+ method: 'post',
253
+ path: '/v1/quotes/{id}',
254
+ tag: 'Quotes',
255
+ summary: 'Update a quote',
256
+ description: 'Drafts only, except `metadata`. `line_items` replaces every line; a field sent as `""` is cleared; `metadata` is a patch.',
257
+ auth: 'service',
258
+ scope: 'payments:write',
259
+ idempotent: true,
260
+ params: quoteId,
261
+ body: exports.updateQuoteParams,
262
+ response: exports.quoteSchema,
263
+ sdk: 'quotes.update',
264
+ expandable: 'quote',
265
+ }),
266
+ (0, route_1.defineRoute)({
267
+ operationId: 'finalizeQuote',
268
+ method: 'post',
269
+ path: '/v1/quotes/{id}/finalize',
270
+ tag: 'Quotes',
271
+ summary: 'Finalize a draft quote',
272
+ description: 'It gets its number, its discount and its Peable Tax. Tax fails closed: a quote whose tax cannot be computed stays a draft (`automatic_tax.status` says why).',
273
+ auth: 'service',
274
+ scope: 'payments:write',
275
+ idempotent: true,
276
+ params: quoteId,
277
+ body: exports.finalizeQuoteParams,
278
+ response: exports.quoteSchema,
279
+ sdk: 'quotes.finalizeQuote',
280
+ expandable: 'quote',
281
+ }),
282
+ (0, route_1.defineRoute)({
283
+ operationId: 'acceptQuote',
284
+ method: 'post',
285
+ path: '/v1/quotes/{id}/accept',
286
+ tag: 'Quotes',
287
+ summary: 'Accept an open quote',
288
+ description: 'The customer said yes. One-time lines become an invoice; recurring lines a subscription whose first invoice also carries the one-time lines. The invoice is finalized (tax before finalize) and collected as the engine collects any other: charged when `charge_automatically` and the customer has a card, otherwise paid on its hosted page — where FairCoin is always offered.',
289
+ auth: 'service',
290
+ scope: 'payments:write',
291
+ idempotent: true,
292
+ params: quoteId,
293
+ body: exports.quoteActionParams,
294
+ response: exports.quoteSchema,
295
+ sdk: 'quotes.accept',
296
+ expandable: 'quote',
297
+ }),
298
+ (0, route_1.defineRoute)({
299
+ operationId: 'cancelQuote',
300
+ method: 'post',
301
+ path: '/v1/quotes/{id}/cancel',
302
+ tag: 'Quotes',
303
+ summary: 'Cancel a quote',
304
+ description: 'A draft or an open quote; an accepted one cannot be cancelled.',
305
+ auth: 'service',
306
+ scope: 'payments:write',
307
+ idempotent: true,
308
+ params: quoteId,
309
+ body: exports.quoteActionParams,
310
+ response: exports.quoteSchema,
311
+ sdk: 'quotes.cancel',
312
+ expandable: 'quote',
313
+ }),
314
+ (0, route_1.defineRoute)({
315
+ operationId: 'listQuoteLineItems',
316
+ method: 'get',
317
+ path: '/v1/quotes/{id}/line_items',
318
+ tag: 'Quotes',
319
+ summary: "List a quote's line items",
320
+ description: "In their order (at most twenty); the cursor is a line's own `li_…`.",
321
+ auth: 'service',
322
+ scope: 'payments:read',
323
+ params: quoteId,
324
+ query: exports.listQuoteLineItemsQuery,
325
+ response: (0, envelopes_1.listOf)(shared_1.checkoutLineItemSchema),
326
+ sdk: 'quotes.listLineItems',
327
+ expandable: 'item',
328
+ }),
329
+ (0, route_1.defineRoute)({
330
+ operationId: 'retrieveQuotePdf',
331
+ method: 'get',
332
+ path: '/v1/quotes/{id}/pdf',
333
+ tag: 'Quotes',
334
+ summary: "Download a quote's PDF",
335
+ description: 'A draft renders marked as a draft, without a number.',
336
+ auth: 'service',
337
+ scope: 'payments:read',
338
+ params: quoteId,
339
+ response: { kind: 'binary', contentType: 'application/pdf' },
340
+ sdk: 'quotes.pdf',
341
+ }),
342
+ ];
@@ -22,6 +22,10 @@ const shared_1 = require("./shared");
22
22
  const sessionFields = {
23
23
  id: zod_1.z.string(),
24
24
  object: zod_1.z.literal('checkout_session'),
25
+ contact_collection: zod_1.z
26
+ .enum(checkout_1.CHECKOUT_CONTACT_COLLECTIONS)
27
+ .optional()
28
+ .describe('Contact policy fixed by the merchant at creation. Absent means email. merchant_account delegates contact and notifications to the merchant account channel; it does not assert a Peable-verified identity.'),
25
29
  livemode: primitives_1.livemode,
26
30
  mode: zod_1.z.enum(checkout_1.CHECKOUT_SESSION_MODES),
27
31
  status: zod_1.z.enum(checkout_1.CHECKOUT_SESSION_STATUSES),
@@ -291,6 +295,10 @@ exports.createCheckoutSessionParams = zod_1.z
291
295
  .optional()
292
296
  .describe('`cus_…`; mutually exclusive with `customer_email`.'),
293
297
  customer_email: shared_1.checkoutEmailParam.optional(),
298
+ contact_collection: zod_1.z
299
+ .enum(checkout_1.CHECKOUT_CONTACT_COLLECTIONS)
300
+ .optional()
301
+ .describe('Defaults to email. merchant_account delegates contact and payment notifications to the merchant, which must have its own authenticated account channel. This is not identity verification by Peable. Payers cannot change this policy.'),
294
302
  customer_creation: zod_1.z
295
303
  .enum(checkout_1.CHECKOUT_CUSTOMER_CREATIONS)
296
304
  .optional()
@@ -274,6 +274,10 @@ exports.WEBHOOK_EVENT_DESCRIPTIONS = {
274
274
  'billing_portal.configuration.created': 'A customer portal configuration was created.',
275
275
  'billing_portal.configuration.updated': 'A customer portal configuration was updated.',
276
276
  'billing_portal.session.created': 'A customer portal session was created.',
277
+ 'quote.created': 'A draft Quote was created.',
278
+ 'quote.finalized': 'A Quote was finalized: numbered, priced and taxed, waiting for its customer.',
279
+ 'quote.accepted': 'A Quote was accepted: its `invoice` (and, for recurring lines, its `subscription`) exists.',
280
+ 'quote.canceled': 'A Quote was cancelled, or expired while open.',
277
281
  'tax.assessment.created': 'A tax compliance assessment was run. Nothing was registered, filed or collected.',
278
282
  'tax.review_item.created': 'A tax assessment finding opened a review item.',
279
283
  'tax.review_item.updated': 'A tax review item was decided, or found again.',
@@ -4,7 +4,7 @@
4
4
  // the wallet import them without the schemas (`@peable.to/contracts/vocabulary`,
5
5
  // re-exported by `@peable.to/shared-types`).
6
6
  Object.defineProperty(exports, "__esModule", { value: true });
7
- exports.PAYMENT_LINK_LIMITS = exports.CHECKOUT_SESSION_ID_TEMPLATE = exports.CHECKOUT_LIMITS = exports.CHECKOUT_TAX_ID_TYPES = exports.CHECKOUT_CUSTOM_FIELD_TYPES = exports.CHECKOUT_BILLING_ADDRESS_COLLECTIONS = exports.CHECKOUT_CUSTOMER_CREATIONS = exports.CHECKOUT_SUBMIT_TYPES = exports.CHECKOUT_RTL_LOCALES = exports.CHECKOUT_LOCALES = exports.CHECKOUT_UI_MODES = exports.CHECKOUT_PAYMENT_STATUSES = exports.CHECKOUT_SESSION_STATUSES = exports.CHECKOUT_SESSION_MODES = exports.FAIRCOIN_UNAVAILABLE_REASONS = void 0;
7
+ exports.CHECKOUT_CONTACT_COLLECTIONS = exports.PAYMENT_LINK_LIMITS = exports.CHECKOUT_SESSION_ID_TEMPLATE = exports.CHECKOUT_LIMITS = exports.CHECKOUT_TAX_ID_TYPES = exports.CHECKOUT_CUSTOM_FIELD_TYPES = exports.CHECKOUT_BILLING_ADDRESS_COLLECTIONS = exports.CHECKOUT_CUSTOMER_CREATIONS = exports.CHECKOUT_SUBMIT_TYPES = exports.CHECKOUT_RTL_LOCALES = exports.CHECKOUT_LOCALES = exports.CHECKOUT_UI_MODES = exports.CHECKOUT_PAYMENT_STATUSES = exports.CHECKOUT_SESSION_STATUSES = exports.CHECKOUT_SESSION_MODES = exports.FAIRCOIN_UNAVAILABLE_REASONS = void 0;
8
8
  exports.checkoutLocaleDirection = checkoutLocaleDirection;
9
9
  /**
10
10
  * Why FairCoin cannot be paid with on an order right now (ADR 0021). It is
@@ -102,3 +102,5 @@ exports.PAYMENT_LINK_LIMITS = Object.freeze({
102
102
  lineItemsMax: 20,
103
103
  customMessageMax: 500,
104
104
  });
105
+ /** Who owns contact collection for a service-created checkout session. */
106
+ exports.CHECKOUT_CONTACT_COLLECTIONS = ['email', 'merchant_account'];
@@ -117,6 +117,9 @@ exports.ERROR_CODE_DESCRIPTIONS = {
117
117
  invoice_not_editable: 'The invoice is finalized and can no longer be edited.',
118
118
  invoice_unexpected_state: 'The invoice is in a status that does not allow this operation.',
119
119
  invoice_no_customer_line_items: 'The invoice has no line items to finalize.',
120
+ quote_not_editable: 'Only a draft quote can be edited.',
121
+ quote_unexpected_state: "The quote's status does not allow this.",
122
+ quote_expired: 'The quote expired.',
120
123
  invoice_payment_intent_requires_action: "The invoice's payment needs the customer to act (a card challenge).",
121
124
  subscription_unexpected_state: 'The subscription is in a status that does not allow this operation.',
122
125
  customer_currency_mismatch: "The currency differs from the customer's billing currency.",
@@ -123,6 +123,10 @@ exports.WEBHOOK_EVENT_OBJECTS = {
123
123
  'billing_portal.configuration.created': 'billing_portal.configuration',
124
124
  'billing_portal.configuration.updated': 'billing_portal.configuration',
125
125
  'billing_portal.session.created': 'billing_portal.session',
126
+ 'quote.created': 'quote',
127
+ 'quote.finalized': 'quote',
128
+ 'quote.accepted': 'quote',
129
+ 'quote.canceled': 'quote',
126
130
  'tax.assessment.created': 'tax.assessment',
127
131
  'tax.review_item.created': 'tax.review_item',
128
132
  'tax.review_item.updated': 'tax.review_item',
@@ -29,6 +29,7 @@ __exportStar(require("./lists"), exports);
29
29
  __exportStar(require("./money"), exports);
30
30
  __exportStar(require("./tax"), exports);
31
31
  __exportStar(require("./subscriptions"), exports);
32
+ __exportStar(require("./quotes"), exports);
32
33
  __exportStar(require("./reporting"), exports);
33
34
  __exportStar(require("./payments"), exports);
34
35
  __exportStar(require("./version"), exports);
@@ -13,6 +13,9 @@ exports.INVOICE_BILLING_REASONS = [
13
13
  'subscription_update',
14
14
  'subscription_cancel',
15
15
  'upcoming',
16
+ // A one-time quote's invoice (Stripe's name); a recurring quote's first
17
+ // invoice is its subscription's `subscription_create`.
18
+ 'quote_accept',
16
19
  ];
17
20
  /**
18
21
  * `automatic_tax.status` — Peable Tax (ADR 0011) is computed before an invoice
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ // Quotes (`qt_…`, ADR 0018 §5) — the closed value sets their schemas are built
3
+ // from. Zod-free: `@peable.to/shared-types` re-exports them at runtime.
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.QUOTE_LIMITS = exports.QUOTE_STATUSES = void 0;
6
+ /**
7
+ * Where a quote stands — Stripe's four.
8
+ *
9
+ * - `draft` — being written; the only status a quote can be edited in.
10
+ * - `open` — finalized: numbered, priced and taxed, waiting for the
11
+ * customer's answer until `expires_at`.
12
+ * - `accepted` — terminal: the native billing engine made its invoice (one-time
13
+ * lines) or its subscription and first invoice (recurring lines).
14
+ * - `canceled` — terminal: cancelled by the merchant, or expired while open.
15
+ */
16
+ exports.QUOTE_STATUSES = ['draft', 'open', 'accepted', 'canceled'];
17
+ /** Bounds a quote is checked against. */
18
+ exports.QUOTE_LIMITS = {
19
+ /** Lines on one quote — a subscription's item limit. */
20
+ lineItemsMax: 20,
21
+ quantityMax: 1000000,
22
+ /** `header` and `footer`; `description` is 1500 like an invoice's. */
23
+ headerMax: 50,
24
+ footerMax: 500,
25
+ descriptionMax: 1500,
26
+ /** A quote expires 30 days after it is created unless `expires_at` says otherwise (Stripe's default). */
27
+ defaultExpiryDays: 30,
28
+ /** `expires_at` at most this far ahead. */
29
+ expiryMaxDays: 365,
30
+ trialPeriodDaysMax: 730,
31
+ };
@@ -6,6 +6,7 @@ import { customerBalanceTransactionRoutes } from './customerBalanceTransactions.
6
6
  import { invoiceItemRoutes } from './invoiceItems.js';
7
7
  import { invoiceRoutes } from './invoices.js';
8
8
  import { publicBillingRoutes } from './public.js';
9
+ import { quoteRoutes } from './quotes.js';
9
10
  import { subscriptionRoutes } from './subscriptions.js';
10
11
  export * from './billingPortal.js';
11
12
  export * from './creditNotes.js';
@@ -13,13 +14,15 @@ export * from './customerBalanceTransactions.js';
13
14
  export * from './invoiceItems.js';
14
15
  export * from './invoices.js';
15
16
  export * from './public.js';
17
+ export * from './quotes.js';
16
18
  export * from './subscriptions.js';
17
- /** Orbit's native billing engine (ADR 0018): subscriptions, invoices, credit notes, the balance ledger and the customer portal. */
19
+ /** Orbit's native billing engine (ADR 0018): subscriptions, invoices, credit notes, quotes, the balance ledger and the customer portal. */
18
20
  export const billingEngineRoutes = [
19
21
  ...subscriptionRoutes,
20
22
  ...invoiceRoutes,
21
23
  ...invoiceItemRoutes,
22
24
  ...creditNoteRoutes,
25
+ ...quoteRoutes,
23
26
  ...customerBalanceTransactionRoutes,
24
27
  ...billingPortalRoutes,
25
28
  ...publicBillingRoutes,