@peable.to/contracts 6.1.0 → 6.3.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/cjs/resources/billingEngine/index.js +4 -1
- package/dist/cjs/resources/billingEngine/quotes.js +342 -0
- package/dist/cjs/resources/connect/reporting.js +250 -2
- package/dist/cjs/resources/events/events.js +4 -0
- package/dist/cjs/vocabulary/errors.js +4 -0
- package/dist/cjs/vocabulary/events.js +4 -0
- package/dist/cjs/vocabulary/index.js +1 -0
- package/dist/cjs/vocabulary/invoices.js +3 -0
- package/dist/cjs/vocabulary/quotes.js +31 -0
- package/dist/cjs/vocabulary/reporting.js +28 -1
- package/dist/esm/resources/billingEngine/index.js +4 -1
- package/dist/esm/resources/billingEngine/quotes.js +339 -0
- package/dist/esm/resources/connect/reporting.js +251 -3
- package/dist/esm/resources/events/events.js +4 -0
- package/dist/esm/vocabulary/errors.js +4 -0
- package/dist/esm/vocabulary/events.js +4 -0
- package/dist/esm/vocabulary/index.js +1 -0
- package/dist/esm/vocabulary/invoices.js +3 -0
- package/dist/esm/vocabulary/quotes.js +28 -0
- package/dist/esm/vocabulary/reporting.js +27 -0
- package/dist/types/resources/billingEngine/index.d.ts +839 -1
- package/dist/types/resources/billingEngine/invoices.d.ts +12 -0
- package/dist/types/resources/billingEngine/quotes.d.ts +1032 -0
- package/dist/types/resources/connect/index.d.ts +671 -0
- package/dist/types/resources/connect/reporting.d.ts +894 -0
- package/dist/types/resources/events/events.d.ts +16 -0
- package/dist/types/resources/events/index.d.ts +54 -2
- package/dist/types/resources/events/webhookDeliveries.d.ts +12 -0
- package/dist/types/resources/events/webhookEndpoints.d.ts +52 -4
- package/dist/types/resources/payments/disputes.d.ts +10 -10
- package/dist/types/resources/payments/index.d.ts +6 -6
- package/dist/types/vocabulary/errors.d.ts +4 -0
- package/dist/types/vocabulary/events.d.ts +4 -0
- package/dist/types/vocabulary/index.d.ts +1 -0
- package/dist/types/vocabulary/invoices.d.ts +1 -1
- package/dist/types/vocabulary/quotes.d.ts +27 -0
- package/dist/types/vocabulary/reporting.d.ts +23 -0
- 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
|
+
];
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.reportingRoutes = exports.downloadReportQuery = exports.listReportRunsQuery = exports.createReportRunParams = exports.reportRunSchema = exports.reportRunParametersSchema = exports.reportTypeSchema = void 0;
|
|
3
|
+
exports.reportingRoutes = exports.downloadReportQuery = exports.listReportSchedulesQuery = exports.reportScheduleActionParams = exports.updateReportScheduleParams = exports.createReportScheduleParams = exports.listReportRunsQuery = exports.createReportRunParams = exports.reportScheduleSchema = exports.reportScheduleCadenceSchema = exports.reportRunSchema = exports.reportRunParametersSchema = exports.reportTypeSchema = void 0;
|
|
4
4
|
const zod_1 = require("zod");
|
|
5
5
|
const objects_1 = require("../../common/objects");
|
|
6
6
|
const envelopes_1 = require("../../common/envelopes");
|
|
@@ -88,6 +88,7 @@ exports.reportRunSchema = (0, objects_2.defineObject)('reporting.report_run', 'R
|
|
|
88
88
|
.nullable()
|
|
89
89
|
.describe('The CSV once `succeeded` — a File of purpose `finance_report_run` (`GET /v1/files/{id}/contents` reads it).'),
|
|
90
90
|
succeeded_at: primitives_1.unixSeconds.nullable(),
|
|
91
|
+
report_schedule: (0, objects_1.expandable)('reporting.report_schedule', 'The schedule that fired this run (`frs_…`); `null` for a run asked for directly.').nullable(),
|
|
91
92
|
})
|
|
92
93
|
.strict(), {
|
|
93
94
|
examples: [
|
|
@@ -102,6 +103,78 @@ exports.reportRunSchema = (0, objects_2.defineObject)('reporting.report_run', 'R
|
|
|
102
103
|
error: null,
|
|
103
104
|
result: null,
|
|
104
105
|
succeeded_at: null,
|
|
106
|
+
report_schedule: null,
|
|
107
|
+
},
|
|
108
|
+
],
|
|
109
|
+
});
|
|
110
|
+
/** When a schedule fires (Stripe's payout-schedule spelling). */
|
|
111
|
+
exports.reportScheduleCadenceSchema = (0, objects_2.defineComponent)('ReportScheduleCadence', zod_1.z
|
|
112
|
+
.object({
|
|
113
|
+
interval: zod_1.z.enum(reporting_1.REPORT_SCHEDULE_INTERVALS),
|
|
114
|
+
weekly_anchor: zod_1.z
|
|
115
|
+
.enum(reporting_1.REPORT_SCHEDULE_WEEKDAYS)
|
|
116
|
+
.nullable()
|
|
117
|
+
.describe('The day a `weekly` schedule fires; `null` otherwise.'),
|
|
118
|
+
monthly_anchor: zod_1.z
|
|
119
|
+
.number()
|
|
120
|
+
.int()
|
|
121
|
+
.nullable()
|
|
122
|
+
.describe('The day of the month a `monthly` schedule fires (1–31; a shorter month fires on its last day); `null` otherwise.'),
|
|
123
|
+
})
|
|
124
|
+
.strict());
|
|
125
|
+
/**
|
|
126
|
+
* `reporting.report_schedule` (`frs_…`): a report run on a cadence. Each
|
|
127
|
+
* occurrence is local midnight in `timezone`; it creates an ordinary report
|
|
128
|
+
* run over the time since the previous occurrence, and emails `recipients` a
|
|
129
|
+
* link to it in Orbit once it succeeded (or failed). The CSV is never attached
|
|
130
|
+
* and never public: a recipient signs in to Orbit to download it.
|
|
131
|
+
*/
|
|
132
|
+
exports.reportScheduleSchema = (0, objects_2.defineObject)('reporting.report_schedule', 'ReportSchedule', zod_1.z
|
|
133
|
+
.object({
|
|
134
|
+
id: zod_1.z.string(),
|
|
135
|
+
object: zod_1.z.literal('reporting.report_schedule'),
|
|
136
|
+
livemode: primitives_1.livemode,
|
|
137
|
+
created: primitives_1.unixSeconds,
|
|
138
|
+
report_type: reportTypeId,
|
|
139
|
+
parameters: zod_1.z
|
|
140
|
+
.object({
|
|
141
|
+
columns: zod_1.z.array(zod_1.z.string()).optional(),
|
|
142
|
+
currency: primitives_1.currency.optional(),
|
|
143
|
+
})
|
|
144
|
+
.strict()
|
|
145
|
+
.describe("Every run's `parameters` but the interval, which each occurrence sets: the time since the previous occurrence."),
|
|
146
|
+
schedule: exports.reportScheduleCadenceSchema,
|
|
147
|
+
timezone: zod_1.z
|
|
148
|
+
.string()
|
|
149
|
+
.describe('The IANA time zone whose midnight each occurrence is (`Europe/Madrid`).'),
|
|
150
|
+
recipients: zod_1.z
|
|
151
|
+
.array(zod_1.z.string())
|
|
152
|
+
.describe('Who is emailed when a run of this schedule succeeds or fails.'),
|
|
153
|
+
locale: zod_1.z.enum(reporting_1.REPORT_SCHEDULE_LOCALES).describe('The language of those emails.'),
|
|
154
|
+
status: zod_1.z.enum(reporting_1.REPORT_SCHEDULE_STATUSES),
|
|
155
|
+
next_run_at: primitives_1.unixSeconds
|
|
156
|
+
.nullable()
|
|
157
|
+
.describe('The next occurrence while `active`; `null` while paused or canceled.'),
|
|
158
|
+
last_run: (0, objects_1.expandable)('reporting.report_run', 'The newest run this schedule fired.').nullable(),
|
|
159
|
+
canceled_at: primitives_1.unixSeconds.nullable(),
|
|
160
|
+
})
|
|
161
|
+
.strict(), {
|
|
162
|
+
examples: [
|
|
163
|
+
{
|
|
164
|
+
id: 'frs_0193b8f34d1e4a6b8c27',
|
|
165
|
+
object: 'reporting.report_schedule',
|
|
166
|
+
livemode: false,
|
|
167
|
+
created: 1793750400,
|
|
168
|
+
report_type: 'balance.summary.1',
|
|
169
|
+
parameters: {},
|
|
170
|
+
schedule: { interval: 'monthly', weekly_anchor: null, monthly_anchor: 1 },
|
|
171
|
+
timezone: 'Europe/Madrid',
|
|
172
|
+
recipients: ['finance@example.com'],
|
|
173
|
+
locale: 'en',
|
|
174
|
+
status: 'active',
|
|
175
|
+
next_run_at: 1796079600,
|
|
176
|
+
last_run: null,
|
|
177
|
+
canceled_at: null,
|
|
105
178
|
},
|
|
106
179
|
],
|
|
107
180
|
});
|
|
@@ -125,7 +198,79 @@ exports.createReportRunParams = zod_1.z
|
|
|
125
198
|
.strict(),
|
|
126
199
|
})
|
|
127
200
|
.strict();
|
|
128
|
-
exports.listReportRunsQuery = (0, params_1.listQuery)({
|
|
201
|
+
exports.listReportRunsQuery = (0, params_1.listQuery)({
|
|
202
|
+
report_type: reportTypeId.optional(),
|
|
203
|
+
report_schedule: zod_1.z
|
|
204
|
+
.string()
|
|
205
|
+
.min(1)
|
|
206
|
+
.max(64)
|
|
207
|
+
.optional()
|
|
208
|
+
.describe('Only the runs this schedule (`frs_…`) fired.'),
|
|
209
|
+
});
|
|
210
|
+
/** A schedule's run template: a run's `parameters` without the interval. */
|
|
211
|
+
const scheduleParameters = zod_1.z
|
|
212
|
+
.object({
|
|
213
|
+
columns: zod_1.z
|
|
214
|
+
.array(column)
|
|
215
|
+
.min(1)
|
|
216
|
+
.max(64)
|
|
217
|
+
.optional()
|
|
218
|
+
.describe("Columns of the report type's layout, each once."),
|
|
219
|
+
currency: zod_1.z.enum(money_1.CURRENCY_CODES).optional(),
|
|
220
|
+
})
|
|
221
|
+
.strict();
|
|
222
|
+
const cadenceParams = zod_1.z
|
|
223
|
+
.object({
|
|
224
|
+
interval: zod_1.z.enum(reporting_1.REPORT_SCHEDULE_INTERVALS),
|
|
225
|
+
weekly_anchor: zod_1.z
|
|
226
|
+
.enum(reporting_1.REPORT_SCHEDULE_WEEKDAYS)
|
|
227
|
+
.optional()
|
|
228
|
+
.describe('Required for `weekly`, refused otherwise.'),
|
|
229
|
+
monthly_anchor: zod_1.z
|
|
230
|
+
.number()
|
|
231
|
+
.int()
|
|
232
|
+
.min(1)
|
|
233
|
+
.max(31)
|
|
234
|
+
.optional()
|
|
235
|
+
.describe('Required for `monthly`, refused otherwise; a shorter month fires on its last day.'),
|
|
236
|
+
})
|
|
237
|
+
.strict();
|
|
238
|
+
const recipientsParam = zod_1.z
|
|
239
|
+
.array(zod_1.z.email().max(254))
|
|
240
|
+
.max(reporting_1.REPORT_SCHEDULE_MAX_RECIPIENTS)
|
|
241
|
+
.describe(`At most ${String(reporting_1.REPORT_SCHEDULE_MAX_RECIPIENTS)} addresses, each once. They receive a link to the run in Orbit, never the file.`);
|
|
242
|
+
const timezoneParam = zod_1.z
|
|
243
|
+
.string()
|
|
244
|
+
.min(1)
|
|
245
|
+
.max(64)
|
|
246
|
+
.describe('An IANA time zone (`Europe/Madrid`); `UTC` when absent.');
|
|
247
|
+
/** `POST /v1/reporting/report_schedules`. */
|
|
248
|
+
exports.createReportScheduleParams = zod_1.z
|
|
249
|
+
.object({
|
|
250
|
+
report_type: reportTypeId,
|
|
251
|
+
parameters: scheduleParameters.optional(),
|
|
252
|
+
schedule: cadenceParams,
|
|
253
|
+
timezone: timezoneParam.optional(),
|
|
254
|
+
recipients: recipientsParam.optional(),
|
|
255
|
+
locale: zod_1.z.enum(reporting_1.REPORT_SCHEDULE_LOCALES).optional().describe('`en` when absent.'),
|
|
256
|
+
})
|
|
257
|
+
.strict();
|
|
258
|
+
/** `POST /v1/reporting/report_schedules/{id}`: each field sent replaces the stored one. */
|
|
259
|
+
exports.updateReportScheduleParams = zod_1.z
|
|
260
|
+
.object({
|
|
261
|
+
report_type: reportTypeId.optional(),
|
|
262
|
+
parameters: scheduleParameters.optional(),
|
|
263
|
+
schedule: cadenceParams.optional(),
|
|
264
|
+
timezone: timezoneParam.optional(),
|
|
265
|
+
recipients: recipientsParam.optional(),
|
|
266
|
+
locale: zod_1.z.enum(reporting_1.REPORT_SCHEDULE_LOCALES).optional(),
|
|
267
|
+
})
|
|
268
|
+
.strict();
|
|
269
|
+
/** Pause, resume and cancel take no parameters. */
|
|
270
|
+
exports.reportScheduleActionParams = zod_1.z.object({}).strict();
|
|
271
|
+
exports.listReportSchedulesQuery = (0, params_1.listQuery)({
|
|
272
|
+
status: zod_1.z.enum(reporting_1.REPORT_SCHEDULE_STATUSES).optional(),
|
|
273
|
+
});
|
|
129
274
|
/**
|
|
130
275
|
* A download's query: a run's `parameters`, spelled as a query string
|
|
131
276
|
* (`columns[]=a&columns[]=b`, or one `columns=a`).
|
|
@@ -150,6 +295,7 @@ exports.downloadReportQuery = zod_1.z
|
|
|
150
295
|
})
|
|
151
296
|
.strict();
|
|
152
297
|
const reportTypeIdParam = { id: 'The report type (`payments.itemized.1`, …).' };
|
|
298
|
+
const reportScheduleIdParam = { id: 'The report schedule (`frs_…`).' };
|
|
153
299
|
exports.reportingRoutes = [
|
|
154
300
|
(0, route_1.defineRoute)({
|
|
155
301
|
operationId: 'listReportTypes',
|
|
@@ -232,4 +378,106 @@ exports.reportingRoutes = [
|
|
|
232
378
|
sdk: 'reporting.reportRuns.retrieve',
|
|
233
379
|
expandable: 'reporting.report_run',
|
|
234
380
|
}),
|
|
381
|
+
(0, route_1.defineRoute)({
|
|
382
|
+
operationId: 'createReportSchedule',
|
|
383
|
+
method: 'post',
|
|
384
|
+
path: '/v1/reporting/report_schedules',
|
|
385
|
+
tag: 'Reporting',
|
|
386
|
+
summary: 'Create a report schedule',
|
|
387
|
+
description: 'A report run at local midnight in `timezone` every day, week or month, each over the time since the previous occurrence. `next_run_at` is the first occurrence after now; nothing is backfilled.',
|
|
388
|
+
auth: 'service',
|
|
389
|
+
scope: 'payments:write',
|
|
390
|
+
idempotent: true,
|
|
391
|
+
body: exports.createReportScheduleParams,
|
|
392
|
+
response: exports.reportScheduleSchema,
|
|
393
|
+
sdk: 'reporting.reportSchedules.create',
|
|
394
|
+
}),
|
|
395
|
+
(0, route_1.defineRoute)({
|
|
396
|
+
operationId: 'listReportSchedules',
|
|
397
|
+
method: 'get',
|
|
398
|
+
path: '/v1/reporting/report_schedules',
|
|
399
|
+
tag: 'Reporting',
|
|
400
|
+
summary: 'List report schedules',
|
|
401
|
+
description: 'Newest first; a canceled schedule is listed too.',
|
|
402
|
+
auth: 'service',
|
|
403
|
+
scope: 'payments:read',
|
|
404
|
+
query: exports.listReportSchedulesQuery,
|
|
405
|
+
response: (0, envelopes_1.listOf)(exports.reportScheduleSchema),
|
|
406
|
+
sdk: 'reporting.reportSchedules.list',
|
|
407
|
+
expandable: 'reporting.report_schedule',
|
|
408
|
+
}),
|
|
409
|
+
(0, route_1.defineRoute)({
|
|
410
|
+
operationId: 'retrieveReportSchedule',
|
|
411
|
+
method: 'get',
|
|
412
|
+
path: '/v1/reporting/report_schedules/{id}',
|
|
413
|
+
tag: 'Reporting',
|
|
414
|
+
summary: 'Retrieve a report schedule',
|
|
415
|
+
auth: 'service',
|
|
416
|
+
scope: 'payments:read',
|
|
417
|
+
params: reportScheduleIdParam,
|
|
418
|
+
query: params_1.expandOnlyQuery,
|
|
419
|
+
response: exports.reportScheduleSchema,
|
|
420
|
+
sdk: 'reporting.reportSchedules.retrieve',
|
|
421
|
+
expandable: 'reporting.report_schedule',
|
|
422
|
+
}),
|
|
423
|
+
(0, route_1.defineRoute)({
|
|
424
|
+
operationId: 'updateReportSchedule',
|
|
425
|
+
method: 'post',
|
|
426
|
+
path: '/v1/reporting/report_schedules/{id}',
|
|
427
|
+
tag: 'Reporting',
|
|
428
|
+
summary: 'Update a report schedule',
|
|
429
|
+
description: 'A new `schedule` or `timezone` moves an active schedule to its first occurrence after now. A canceled schedule cannot change (409 `report_schedule_unexpected_state`).',
|
|
430
|
+
auth: 'service',
|
|
431
|
+
scope: 'payments:write',
|
|
432
|
+
idempotent: true,
|
|
433
|
+
params: reportScheduleIdParam,
|
|
434
|
+
body: exports.updateReportScheduleParams,
|
|
435
|
+
response: exports.reportScheduleSchema,
|
|
436
|
+
sdk: 'reporting.reportSchedules.update',
|
|
437
|
+
}),
|
|
438
|
+
(0, route_1.defineRoute)({
|
|
439
|
+
operationId: 'pauseReportSchedule',
|
|
440
|
+
method: 'post',
|
|
441
|
+
path: '/v1/reporting/report_schedules/{id}/pause',
|
|
442
|
+
tag: 'Reporting',
|
|
443
|
+
summary: 'Pause a report schedule',
|
|
444
|
+
description: 'Nothing fires until it is resumed. Pausing a paused schedule answers it as it is.',
|
|
445
|
+
auth: 'service',
|
|
446
|
+
scope: 'payments:write',
|
|
447
|
+
idempotent: true,
|
|
448
|
+
params: reportScheduleIdParam,
|
|
449
|
+
body: exports.reportScheduleActionParams,
|
|
450
|
+
response: exports.reportScheduleSchema,
|
|
451
|
+
sdk: 'reporting.reportSchedules.pause',
|
|
452
|
+
}),
|
|
453
|
+
(0, route_1.defineRoute)({
|
|
454
|
+
operationId: 'resumeReportSchedule',
|
|
455
|
+
method: 'post',
|
|
456
|
+
path: '/v1/reporting/report_schedules/{id}/resume',
|
|
457
|
+
tag: 'Reporting',
|
|
458
|
+
summary: 'Resume a paused report schedule',
|
|
459
|
+
description: 'It fires again from its first occurrence after now; the occurrences it missed while paused are not run.',
|
|
460
|
+
auth: 'service',
|
|
461
|
+
scope: 'payments:write',
|
|
462
|
+
idempotent: true,
|
|
463
|
+
params: reportScheduleIdParam,
|
|
464
|
+
body: exports.reportScheduleActionParams,
|
|
465
|
+
response: exports.reportScheduleSchema,
|
|
466
|
+
sdk: 'reporting.reportSchedules.resume',
|
|
467
|
+
}),
|
|
468
|
+
(0, route_1.defineRoute)({
|
|
469
|
+
operationId: 'cancelReportSchedule',
|
|
470
|
+
method: 'post',
|
|
471
|
+
path: '/v1/reporting/report_schedules/{id}/cancel',
|
|
472
|
+
tag: 'Reporting',
|
|
473
|
+
summary: 'Cancel a report schedule',
|
|
474
|
+
description: 'For good: it never fires again, and a run it fires no longer emails anyone. Its runs and their files stay.',
|
|
475
|
+
auth: 'service',
|
|
476
|
+
scope: 'payments:write',
|
|
477
|
+
idempotent: true,
|
|
478
|
+
params: reportScheduleIdParam,
|
|
479
|
+
body: exports.reportScheduleActionParams,
|
|
480
|
+
response: exports.reportScheduleSchema,
|
|
481
|
+
sdk: 'reporting.reportSchedules.cancel',
|
|
482
|
+
}),
|
|
235
483
|
];
|
|
@@ -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.',
|
|
@@ -117,8 +117,12 @@ 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.',
|
|
125
|
+
report_schedule_unexpected_state: 'A canceled report schedule never changes.',
|
|
122
126
|
customer_currency_mismatch: "The currency differs from the customer's billing currency.",
|
|
123
127
|
customer_test_clock_mismatch: 'The objects live on different test clocks.',
|
|
124
128
|
coupon_invalid: 'The coupon does not exist or is no longer valid.',
|