@peable.to/contracts 0.3.0 → 1.0.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/common/address.js +81 -0
- package/dist/cjs/common/envelopes.js +101 -0
- package/dist/cjs/common/objects.js +85 -0
- package/dist/cjs/common/params.js +211 -0
- package/dist/cjs/common/primitives.js +39 -0
- package/dist/cjs/contributions.js +22 -0
- package/dist/cjs/index.js +40 -97
- package/dist/cjs/openapi/document.js +297 -0
- package/dist/cjs/openapi/index.js +7 -0
- package/dist/cjs/openapi/webhooks.js +17 -0
- package/dist/cjs/resources/billingEngine/billingPortal.js +237 -0
- package/dist/cjs/resources/billingEngine/creditNotes.js +189 -0
- package/dist/cjs/resources/billingEngine/customerBalanceTransactions.js +90 -0
- package/dist/cjs/resources/billingEngine/index.js +43 -0
- package/dist/cjs/resources/billingEngine/invoiceItems.js +155 -0
- package/dist/cjs/resources/billingEngine/invoices.js +509 -0
- package/dist/cjs/resources/billingEngine/params.js +43 -0
- package/dist/cjs/resources/billingEngine/public.js +326 -0
- package/dist/cjs/resources/billingEngine/subscriptions.js +476 -0
- package/dist/cjs/resources/catalog/billing.js +755 -0
- package/dist/cjs/resources/catalog/billingSettings.js +131 -0
- package/dist/cjs/resources/catalog/coupons.js +222 -0
- package/dist/cjs/resources/catalog/entitlements.js +257 -0
- package/dist/cjs/resources/catalog/index.js +58 -0
- package/dist/cjs/resources/catalog/meters.js +279 -0
- package/dist/cjs/resources/catalog/prices.js +423 -0
- package/dist/cjs/resources/catalog/products.js +228 -0
- package/dist/cjs/resources/catalog/promotionCodes.js +174 -0
- package/dist/cjs/resources/catalog/shared.js +75 -0
- package/dist/cjs/resources/catalog/testClocks.js +127 -0
- package/dist/cjs/resources/checkout/checkoutSessions.js +582 -0
- package/dist/cjs/resources/checkout/contributions.js +172 -0
- package/dist/cjs/resources/checkout/files.js +133 -0
- package/dist/cjs/resources/checkout/index.js +57 -0
- package/dist/cjs/resources/checkout/merchants.js +290 -0
- package/dist/cjs/resources/checkout/paymentLinks.js +330 -0
- package/dist/cjs/resources/checkout/paymentMethodConfigurations.js +262 -0
- package/dist/cjs/resources/checkout/shared.js +368 -0
- package/dist/cjs/resources/connect/account.js +332 -0
- package/dist/cjs/resources/connect/applicationFees.js +113 -0
- package/dist/cjs/resources/connect/balance.js +212 -0
- package/dist/cjs/resources/connect/connectedAccounts.js +260 -0
- package/dist/cjs/resources/connect/index.js +51 -0
- package/dist/cjs/resources/connect/onboarding.js +82 -0
- package/dist/cjs/resources/connect/payouts.js +196 -0
- package/dist/cjs/resources/connect/reporting.js +235 -0
- package/dist/cjs/resources/connect/requestLogs.js +110 -0
- package/dist/cjs/resources/connect/transfers.js +227 -0
- package/dist/cjs/resources/core/customers.js +194 -0
- package/dist/cjs/resources/core/index.js +23 -0
- package/dist/cjs/resources/core/paymentMethods.js +134 -0
- package/dist/cjs/resources/events/events.js +357 -0
- package/dist/cjs/resources/events/index.js +29 -0
- package/dist/cjs/resources/events/webhookDeliveries.js +93 -0
- package/dist/cjs/resources/events/webhookEndpoints.js +215 -0
- package/dist/cjs/resources/payments/charges.js +157 -0
- package/dist/cjs/resources/payments/disputes.js +204 -0
- package/dist/cjs/resources/payments/index.js +41 -0
- package/dist/cjs/resources/payments/paymentIntents.js +529 -0
- package/dist/cjs/resources/payments/refunds.js +245 -0
- package/dist/cjs/resources/payments/setupIntents.js +158 -0
- package/dist/cjs/resources/payments/social.js +182 -0
- package/dist/cjs/resources/payments/testHelpers.js +39 -0
- package/dist/cjs/resources/tax/assessments.js +217 -0
- package/dist/cjs/resources/tax/businessProfile.js +99 -0
- package/dist/cjs/resources/tax/calculations.js +176 -0
- package/dist/cjs/resources/tax/capabilities.js +42 -0
- package/dist/cjs/resources/tax/codes.js +37 -0
- package/dist/cjs/resources/tax/complianceActions.js +56 -0
- package/dist/cjs/resources/tax/deadlines.js +59 -0
- package/dist/cjs/resources/tax/documents.js +128 -0
- package/dist/cjs/resources/tax/index.js +80 -0
- package/dist/cjs/resources/tax/locationEvidence.js +131 -0
- package/dist/cjs/resources/tax/operatingLocations.js +98 -0
- package/dist/cjs/resources/tax/products.js +67 -0
- package/dist/cjs/resources/tax/registrationDeclarations.js +124 -0
- package/dist/cjs/resources/tax/registrations.js +82 -0
- package/dist/cjs/resources/tax/reports.js +92 -0
- package/dist/cjs/resources/tax/reviewItems.js +116 -0
- package/dist/cjs/resources/tax/ruleSet.js +68 -0
- package/dist/cjs/resources/tax/salesDestinations.js +94 -0
- package/dist/cjs/resources/tax/settings.js +104 -0
- package/dist/cjs/resources/tax/shared.js +62 -0
- package/dist/cjs/resources/tax/transactions.js +102 -0
- package/dist/cjs/route.js +22 -0
- package/dist/cjs/routes.js +31 -0
- package/dist/cjs/vocabulary/billingPortal.js +15 -0
- package/dist/cjs/vocabulary/catalog.js +110 -0
- package/dist/cjs/vocabulary/checkout.js +53 -0
- package/dist/cjs/vocabulary/connect.js +95 -0
- package/dist/cjs/vocabulary/errors.js +174 -0
- package/dist/cjs/vocabulary/events.js +176 -0
- package/dist/cjs/vocabulary/files.js +44 -0
- package/dist/cjs/vocabulary/index.js +37 -0
- package/dist/cjs/vocabulary/invoices.js +52 -0
- package/dist/cjs/vocabulary/lists.js +22 -0
- package/dist/cjs/vocabulary/merchants.js +23 -0
- package/dist/cjs/vocabulary/money.js +104 -0
- package/dist/cjs/vocabulary/paymentMethodConfigurations.js +36 -0
- package/dist/cjs/vocabulary/payments.js +195 -0
- package/dist/cjs/vocabulary/reporting.js +27 -0
- package/dist/cjs/vocabulary/subscriptions.js +60 -0
- package/dist/cjs/vocabulary/tax.js +237 -0
- package/dist/cjs/vocabulary/version.js +12 -0
- package/dist/esm/common/address.js +76 -0
- package/dist/esm/common/envelopes.js +95 -0
- package/dist/esm/common/objects.js +74 -0
- package/dist/esm/common/params.js +203 -0
- package/dist/esm/common/primitives.js +35 -0
- package/dist/esm/contributions.js +5 -0
- package/dist/esm/index.js +26 -94
- package/dist/esm/openapi/document.js +294 -0
- package/dist/esm/openapi/index.js +2 -0
- package/dist/esm/openapi/webhooks.js +14 -0
- package/dist/esm/resources/billingEngine/billingPortal.js +234 -0
- package/dist/esm/resources/billingEngine/creditNotes.js +186 -0
- package/dist/esm/resources/billingEngine/customerBalanceTransactions.js +87 -0
- package/dist/esm/resources/billingEngine/index.js +26 -0
- package/dist/esm/resources/billingEngine/invoiceItems.js +152 -0
- package/dist/esm/resources/billingEngine/invoices.js +506 -0
- package/dist/esm/resources/billingEngine/params.js +39 -0
- package/dist/esm/resources/billingEngine/public.js +323 -0
- package/dist/esm/resources/billingEngine/subscriptions.js +473 -0
- package/dist/esm/resources/catalog/billing.js +752 -0
- package/dist/esm/resources/catalog/billingSettings.js +128 -0
- package/dist/esm/resources/catalog/coupons.js +219 -0
- package/dist/esm/resources/catalog/entitlements.js +254 -0
- package/dist/esm/resources/catalog/index.js +38 -0
- package/dist/esm/resources/catalog/meters.js +276 -0
- package/dist/esm/resources/catalog/prices.js +419 -0
- package/dist/esm/resources/catalog/products.js +225 -0
- package/dist/esm/resources/catalog/promotionCodes.js +171 -0
- package/dist/esm/resources/catalog/shared.js +67 -0
- package/dist/esm/resources/catalog/testClocks.js +124 -0
- package/dist/esm/resources/checkout/checkoutSessions.js +579 -0
- package/dist/esm/resources/checkout/contributions.js +167 -0
- package/dist/esm/resources/checkout/files.js +130 -0
- package/dist/esm/resources/checkout/index.js +25 -0
- package/dist/esm/resources/checkout/merchants.js +287 -0
- package/dist/esm/resources/checkout/paymentLinks.js +327 -0
- package/dist/esm/resources/checkout/paymentMethodConfigurations.js +259 -0
- package/dist/esm/resources/checkout/shared.js +363 -0
- package/dist/esm/resources/connect/account.js +329 -0
- package/dist/esm/resources/connect/applicationFees.js +110 -0
- package/dist/esm/resources/connect/balance.js +209 -0
- package/dist/esm/resources/connect/connectedAccounts.js +257 -0
- package/dist/esm/resources/connect/index.js +34 -0
- package/dist/esm/resources/connect/onboarding.js +79 -0
- package/dist/esm/resources/connect/payouts.js +193 -0
- package/dist/esm/resources/connect/reporting.js +232 -0
- package/dist/esm/resources/connect/requestLogs.js +107 -0
- package/dist/esm/resources/connect/transfers.js +224 -0
- package/dist/esm/resources/core/customers.js +191 -0
- package/dist/esm/resources/core/index.js +6 -0
- package/dist/esm/resources/core/paymentMethods.js +131 -0
- package/dist/esm/resources/events/events.js +353 -0
- package/dist/esm/resources/events/index.js +12 -0
- package/dist/esm/resources/events/webhookDeliveries.js +90 -0
- package/dist/esm/resources/events/webhookEndpoints.js +212 -0
- package/dist/esm/resources/payments/charges.js +154 -0
- package/dist/esm/resources/payments/disputes.js +201 -0
- package/dist/esm/resources/payments/index.js +24 -0
- package/dist/esm/resources/payments/paymentIntents.js +526 -0
- package/dist/esm/resources/payments/refunds.js +242 -0
- package/dist/esm/resources/payments/setupIntents.js +155 -0
- package/dist/esm/resources/payments/social.js +179 -0
- package/dist/esm/resources/payments/testHelpers.js +36 -0
- package/dist/esm/resources/tax/assessments.js +214 -0
- package/dist/esm/resources/tax/businessProfile.js +96 -0
- package/dist/esm/resources/tax/calculations.js +173 -0
- package/dist/esm/resources/tax/capabilities.js +39 -0
- package/dist/esm/resources/tax/codes.js +34 -0
- package/dist/esm/resources/tax/complianceActions.js +53 -0
- package/dist/esm/resources/tax/deadlines.js +56 -0
- package/dist/esm/resources/tax/documents.js +125 -0
- package/dist/esm/resources/tax/index.js +63 -0
- package/dist/esm/resources/tax/locationEvidence.js +128 -0
- package/dist/esm/resources/tax/operatingLocations.js +95 -0
- package/dist/esm/resources/tax/products.js +64 -0
- package/dist/esm/resources/tax/registrationDeclarations.js +121 -0
- package/dist/esm/resources/tax/registrations.js +79 -0
- package/dist/esm/resources/tax/reports.js +89 -0
- package/dist/esm/resources/tax/reviewItems.js +113 -0
- package/dist/esm/resources/tax/ruleSet.js +65 -0
- package/dist/esm/resources/tax/salesDestinations.js +91 -0
- package/dist/esm/resources/tax/settings.js +101 -0
- package/dist/esm/resources/tax/shared.js +58 -0
- package/dist/esm/resources/tax/transactions.js +99 -0
- package/dist/esm/route.js +16 -0
- package/dist/esm/routes.js +27 -0
- package/dist/esm/vocabulary/billingPortal.js +12 -0
- package/dist/esm/vocabulary/catalog.js +106 -0
- package/dist/esm/vocabulary/checkout.js +50 -0
- package/dist/esm/vocabulary/connect.js +92 -0
- package/dist/esm/vocabulary/errors.js +169 -0
- package/dist/esm/vocabulary/events.js +173 -0
- package/dist/esm/vocabulary/files.js +41 -0
- package/dist/esm/vocabulary/index.js +21 -0
- package/dist/esm/vocabulary/invoices.js +49 -0
- package/dist/esm/vocabulary/lists.js +19 -0
- package/dist/esm/vocabulary/merchants.js +20 -0
- package/dist/esm/vocabulary/money.js +98 -0
- package/dist/esm/vocabulary/paymentMethodConfigurations.js +33 -0
- package/dist/esm/vocabulary/payments.js +192 -0
- package/dist/esm/vocabulary/reporting.js +24 -0
- package/dist/esm/vocabulary/subscriptions.js +57 -0
- package/dist/esm/vocabulary/tax.js +233 -0
- package/dist/esm/vocabulary/version.js +9 -0
- package/dist/types/common/address.d.ts +62 -0
- package/dist/types/common/envelopes.d.ts +88 -0
- package/dist/types/common/objects.d.ts +107 -0
- package/dist/types/common/params.d.ts +156 -0
- package/dist/types/common/primitives.d.ts +56 -0
- package/dist/types/contributions.d.ts +1 -0
- package/dist/types/index.d.ts +16 -134
- package/dist/types/openapi/document.d.ts +16 -0
- package/dist/types/openapi/index.d.ts +2 -0
- package/dist/types/openapi/webhooks.d.ts +15 -0
- package/dist/types/resources/billingEngine/billingPortal.d.ts +742 -0
- package/dist/types/resources/billingEngine/creditNotes.d.ts +655 -0
- package/dist/types/resources/billingEngine/customerBalanceTransactions.d.ts +282 -0
- package/dist/types/resources/billingEngine/index.d.ts +6071 -0
- package/dist/types/resources/billingEngine/invoiceItems.d.ts +502 -0
- package/dist/types/resources/billingEngine/invoices.d.ts +2547 -0
- package/dist/types/resources/billingEngine/params.d.ts +51 -0
- package/dist/types/resources/billingEngine/public.d.ts +1860 -0
- package/dist/types/resources/billingEngine/subscriptions.d.ts +1519 -0
- package/dist/types/resources/catalog/billing.d.ts +1723 -0
- package/dist/types/resources/catalog/billingSettings.d.ts +160 -0
- package/dist/types/resources/catalog/coupons.d.ts +403 -0
- package/dist/types/resources/catalog/entitlements.d.ts +422 -0
- package/dist/types/resources/catalog/index.d.ts +3155 -0
- package/dist/types/resources/catalog/meters.d.ts +474 -0
- package/dist/types/resources/catalog/prices.d.ts +1091 -0
- package/dist/types/resources/catalog/products.d.ts +430 -0
- package/dist/types/resources/catalog/promotionCodes.d.ts +369 -0
- package/dist/types/resources/catalog/shared.d.ts +34 -0
- package/dist/types/resources/catalog/testClocks.d.ts +220 -0
- package/dist/types/resources/checkout/checkoutSessions.d.ts +3207 -0
- package/dist/types/resources/checkout/contributions.d.ts +375 -0
- package/dist/types/resources/checkout/files.d.ts +280 -0
- package/dist/types/resources/checkout/index.d.ts +5678 -0
- package/dist/types/resources/checkout/merchants.d.ts +395 -0
- package/dist/types/resources/checkout/paymentLinks.d.ts +1728 -0
- package/dist/types/resources/checkout/paymentMethodConfigurations.d.ts +2104 -0
- package/dist/types/resources/checkout/shared.d.ts +419 -0
- package/dist/types/resources/connect/account.d.ts +483 -0
- package/dist/types/resources/connect/applicationFees.d.ts +198 -0
- package/dist/types/resources/connect/balance.d.ts +399 -0
- package/dist/types/resources/connect/connectedAccounts.d.ts +494 -0
- package/dist/types/resources/connect/index.d.ts +2094 -0
- package/dist/types/resources/connect/onboarding.d.ts +95 -0
- package/dist/types/resources/connect/payouts.d.ts +527 -0
- package/dist/types/resources/connect/reporting.d.ts +506 -0
- package/dist/types/resources/connect/requestLogs.d.ts +236 -0
- package/dist/types/resources/connect/transfers.d.ts +436 -0
- package/dist/types/resources/core/customers.d.ts +619 -0
- package/dist/types/resources/core/index.d.ts +679 -0
- package/dist/types/resources/core/paymentMethods.d.ts +336 -0
- package/dist/types/resources/events/events.d.ts +731 -0
- package/dist/types/resources/events/index.d.ts +1727 -0
- package/dist/types/resources/events/webhookDeliveries.d.ts +436 -0
- package/dist/types/resources/events/webhookEndpoints.d.ts +1502 -0
- package/dist/types/resources/payments/charges.d.ts +390 -0
- package/dist/types/resources/payments/disputes.d.ts +822 -0
- package/dist/types/resources/payments/index.d.ts +3517 -0
- package/dist/types/resources/payments/paymentIntents.d.ts +2080 -0
- package/dist/types/resources/payments/refunds.d.ts +684 -0
- package/dist/types/resources/payments/setupIntents.d.ts +391 -0
- package/dist/types/resources/payments/social.d.ts +266 -0
- package/dist/types/resources/payments/testHelpers.d.ts +178 -0
- package/dist/types/resources/tax/assessments.d.ts +787 -0
- package/dist/types/resources/tax/businessProfile.d.ts +134 -0
- package/dist/types/resources/tax/calculations.d.ts +261 -0
- package/dist/types/resources/tax/capabilities.d.ts +81 -0
- package/dist/types/resources/tax/codes.d.ts +29 -0
- package/dist/types/resources/tax/complianceActions.d.ts +97 -0
- package/dist/types/resources/tax/deadlines.d.ts +133 -0
- package/dist/types/resources/tax/documents.d.ts +257 -0
- package/dist/types/resources/tax/index.d.ts +1946 -0
- package/dist/types/resources/tax/locationEvidence.d.ts +246 -0
- package/dist/types/resources/tax/operatingLocations.d.ts +170 -0
- package/dist/types/resources/tax/products.d.ts +68 -0
- package/dist/types/resources/tax/registrationDeclarations.d.ts +270 -0
- package/dist/types/resources/tax/registrations.d.ts +103 -0
- package/dist/types/resources/tax/reports.d.ts +129 -0
- package/dist/types/resources/tax/reviewItems.d.ts +226 -0
- package/dist/types/resources/tax/ruleSet.d.ts +219 -0
- package/dist/types/resources/tax/salesDestinations.d.ts +158 -0
- package/dist/types/resources/tax/settings.d.ts +122 -0
- package/dist/types/resources/tax/shared.d.ts +43 -0
- package/dist/types/resources/tax/transactions.d.ts +404 -0
- package/dist/types/route.d.ts +86 -0
- package/dist/types/routes.d.ts +23 -0
- package/dist/types/vocabulary/billingPortal.d.ts +15 -0
- package/dist/types/vocabulary/catalog.d.ts +97 -0
- package/dist/types/vocabulary/checkout.d.ts +49 -0
- package/dist/types/vocabulary/connect.d.ts +62 -0
- package/dist/types/vocabulary/errors.d.ts +145 -0
- package/dist/types/vocabulary/events.d.ts +171 -0
- package/dist/types/vocabulary/files.d.ts +30 -0
- package/dist/types/vocabulary/index.d.ts +17 -0
- package/dist/types/vocabulary/invoices.d.ts +39 -0
- package/dist/types/vocabulary/lists.d.ts +9 -0
- package/dist/types/vocabulary/merchants.d.ts +9 -0
- package/dist/types/vocabulary/money.d.ts +59 -0
- package/dist/types/vocabulary/paymentMethodConfigurations.d.ts +22 -0
- package/dist/types/vocabulary/payments.d.ts +117 -0
- package/dist/types/vocabulary/reporting.d.ts +18 -0
- package/dist/types/vocabulary/subscriptions.d.ts +45 -0
- package/dist/types/vocabulary/tax.d.ts +163 -0
- package/dist/types/vocabulary/version.d.ts +10 -0
- package/package.json +51 -11
- package/dist/cjs/openapi.js +0 -138
- package/dist/esm/openapi.js +0 -134
- package/dist/types/openapi.d.ts +0 -145
|
@@ -0,0 +1,506 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { embedded } from '../../common/objects.js';
|
|
3
|
+
import { deletedOf, listOf, searchResultOf } from '../../common/envelopes.js';
|
|
4
|
+
import { defineComponent, defineObject, expandable } from '../../common/objects.js';
|
|
5
|
+
import { expandOnlyQuery, expandParam, idParam, listQuery, metadataCreateParam, metadataUpdateParam, queryBoolean, queryInteger, queryUnixSeconds, rangeParam, searchQuery, unixSecondsParam, } from '../../common/params.js';
|
|
6
|
+
import { amount, currency, livemode, metadata, signedAmount, unixSeconds, } from '../../common/primitives.js';
|
|
7
|
+
import { defineRoute } from '../../route.js';
|
|
8
|
+
import { AUTOMATIC_TAX_STATUSES, INVOICE_BILLING_REASONS, INVOICE_LINE_TYPES, INVOICE_STATUSES, PENDING_INVOICE_ITEMS_BEHAVIORS, } from '../../vocabulary/invoices.js';
|
|
9
|
+
import { COLLECTION_METHODS, PRORATION_BEHAVIORS } from '../../vocabulary/subscriptions.js';
|
|
10
|
+
import { automaticTaxParam, currencyParam, daysUntilDueParam, discountsParam, shortText, } from './params.js';
|
|
11
|
+
import { discountSchema } from './subscriptions.js';
|
|
12
|
+
/**
|
|
13
|
+
* Invoices (`in_…`) and their lines (`il_…`) — Orbit's native billing engine
|
|
14
|
+
* (ADR 0018 §2).
|
|
15
|
+
*
|
|
16
|
+
* ## Signed amounts
|
|
17
|
+
*
|
|
18
|
+
* Every amount is a base-unit STRING (ADR 0014 D1). Most are never negative;
|
|
19
|
+
* the ones documented as SIGNED may start with `-`: a proration credit line,
|
|
20
|
+
* an invoice whose credits exceed its charges, and a customer balance (where
|
|
21
|
+
* negative is credit the customer holds, Stripe's convention). A signed amount
|
|
22
|
+
* still has exactly one spelling: no `+`, no `-0`, no leading zeros.
|
|
23
|
+
*/
|
|
24
|
+
/** One tax amount on a line. */
|
|
25
|
+
export const invoiceTaxAmountSchema = defineComponent('InvoiceTaxAmount', z
|
|
26
|
+
.object({
|
|
27
|
+
amount: signedAmount.describe('SIGNED: a credit line carries negative tax.'),
|
|
28
|
+
inclusive: z.boolean(),
|
|
29
|
+
tax_calculation: z
|
|
30
|
+
.string()
|
|
31
|
+
.nullable()
|
|
32
|
+
.describe('The Peable Tax calculation (`taxcalc_…`) it came from; `null` for a derived credit.'),
|
|
33
|
+
taxability_reason: z.string().nullable(),
|
|
34
|
+
})
|
|
35
|
+
.strict());
|
|
36
|
+
/** The amount a discount took off a line, or off the whole invoice. */
|
|
37
|
+
const discountAmountSchema = z
|
|
38
|
+
.object({
|
|
39
|
+
amount: signedAmount.describe('SIGNED: a discount on a credit line is negative.'),
|
|
40
|
+
discount: z.string().describe('The discount it comes from.'),
|
|
41
|
+
})
|
|
42
|
+
.strict();
|
|
43
|
+
const periodSchema = z.object({ start: unixSeconds, end: unixSeconds }).strict();
|
|
44
|
+
export const invoiceLineItemSchema = defineObject('line_item', 'InvoiceLineItem', z
|
|
45
|
+
.object({
|
|
46
|
+
id: z.string(),
|
|
47
|
+
object: z.literal('line_item'),
|
|
48
|
+
livemode,
|
|
49
|
+
invoice: z.string().describe('The invoice (`in_…`) it is on.'),
|
|
50
|
+
type: z.enum(INVOICE_LINE_TYPES),
|
|
51
|
+
amount: signedAmount.describe('SIGNED: before discounts; tax-inclusive when the price is.'),
|
|
52
|
+
currency,
|
|
53
|
+
description: z.string().nullable(),
|
|
54
|
+
discount_amounts: z.array(discountAmountSchema),
|
|
55
|
+
discountable: z.boolean(),
|
|
56
|
+
period: periodSchema,
|
|
57
|
+
price: embedded('price', 'The Price, embedded; `null` for a fixed-amount item.').nullable(),
|
|
58
|
+
quantity: z.number().int().nullable(),
|
|
59
|
+
proration: z.boolean(),
|
|
60
|
+
subscription: z.string().nullable(),
|
|
61
|
+
subscription_item: z.string().nullable(),
|
|
62
|
+
invoice_item: z.string().nullable(),
|
|
63
|
+
tax_amounts: z.array(invoiceTaxAmountSchema),
|
|
64
|
+
metadata,
|
|
65
|
+
})
|
|
66
|
+
.strict());
|
|
67
|
+
export const invoiceSchema = defineObject('invoice', 'Invoice', z
|
|
68
|
+
.object({
|
|
69
|
+
id: z.string(),
|
|
70
|
+
object: z.literal('invoice'),
|
|
71
|
+
livemode,
|
|
72
|
+
number: z
|
|
73
|
+
.string()
|
|
74
|
+
.nullable()
|
|
75
|
+
.describe('`null` while a draft; `PREFIX-0001` once finalized — gapless per merchant.'),
|
|
76
|
+
customer: expandable('customer', '`cus_…`, or the Customer with `expand[]=customer`.'),
|
|
77
|
+
customer_email: z.string().nullable(),
|
|
78
|
+
customer_name: z.string().nullable(),
|
|
79
|
+
subscription: expandable('subscription', '`sub_…`, or the Subscription with `expand[]=subscription`.').nullable(),
|
|
80
|
+
status: z.enum(INVOICE_STATUSES),
|
|
81
|
+
billing_reason: z.enum(INVOICE_BILLING_REASONS),
|
|
82
|
+
collection_method: z.enum(COLLECTION_METHODS),
|
|
83
|
+
currency,
|
|
84
|
+
description: z.string().nullable(),
|
|
85
|
+
auto_advance: z.boolean(),
|
|
86
|
+
automatically_finalizes_at: unixSeconds
|
|
87
|
+
.nullable()
|
|
88
|
+
.describe('When a draft with `auto_advance` will finalize.'),
|
|
89
|
+
lines: listOf(invoiceLineItemSchema).describe('Every line, on one page.'),
|
|
90
|
+
subtotal: signedAmount.describe('SIGNED. Sum of the lines before discounts.'),
|
|
91
|
+
subtotal_excluding_tax: signedAmount.describe('SIGNED. `subtotal` less the tax included in it (inclusive prices).'),
|
|
92
|
+
total_discount_amounts: z.array(discountAmountSchema),
|
|
93
|
+
discount: discountSchema.nullable(),
|
|
94
|
+
tax: signedAmount
|
|
95
|
+
.nullable()
|
|
96
|
+
.describe('SIGNED; `null` on a draft whose tax is not calculated yet.'),
|
|
97
|
+
total: signedAmount.describe('SIGNED.'),
|
|
98
|
+
total_excluding_tax: signedAmount.describe('SIGNED.'),
|
|
99
|
+
starting_balance: signedAmount.describe("SIGNED: the customer's balance applied when it finalized."),
|
|
100
|
+
ending_balance: signedAmount
|
|
101
|
+
.nullable()
|
|
102
|
+
.describe("SIGNED: what the customer's balance became; `null` until finalized."),
|
|
103
|
+
amount_due: amount,
|
|
104
|
+
amount_paid: amount,
|
|
105
|
+
amount_remaining: amount,
|
|
106
|
+
pre_payment_credit_notes_amount: amount,
|
|
107
|
+
post_payment_credit_notes_amount: amount,
|
|
108
|
+
attempt_count: z.number().int().nonnegative(),
|
|
109
|
+
attempted: z.boolean(),
|
|
110
|
+
next_payment_attempt: unixSeconds.nullable(),
|
|
111
|
+
due_date: unixSeconds.nullable(),
|
|
112
|
+
days_until_due: z.number().int().nullable(),
|
|
113
|
+
period_start: unixSeconds,
|
|
114
|
+
period_end: unixSeconds,
|
|
115
|
+
payment_intent: expandable('payment_intent', '`pi_…`, or the PaymentIntent with `expand[]=payment_intent`.').nullable(),
|
|
116
|
+
default_payment_method: expandable('payment_method', '`pm_…`, or the PaymentMethod with `expand[]=default_payment_method`.').nullable(),
|
|
117
|
+
automatic_tax: z
|
|
118
|
+
.object({
|
|
119
|
+
enabled: z.boolean(),
|
|
120
|
+
status: z.enum(AUTOMATIC_TAX_STATUSES).nullable(),
|
|
121
|
+
tax_calculation: z
|
|
122
|
+
.string()
|
|
123
|
+
.nullable()
|
|
124
|
+
.describe('The Peable Tax calculation (`taxcalc_…`) the invoice finalized with.'),
|
|
125
|
+
})
|
|
126
|
+
.strict(),
|
|
127
|
+
hosted_invoice_url: z
|
|
128
|
+
.string()
|
|
129
|
+
.nullable()
|
|
130
|
+
.describe('The payer-facing page (anonymous, an unguessable token); `null` while a draft.'),
|
|
131
|
+
invoice_pdf: z.string().nullable().describe('The PDF of the same; `null` while a draft.'),
|
|
132
|
+
last_finalization_error: z
|
|
133
|
+
.object({ code: z.string(), message: z.string() })
|
|
134
|
+
.strict()
|
|
135
|
+
.nullable(),
|
|
136
|
+
status_transitions: z
|
|
137
|
+
.object({
|
|
138
|
+
finalized_at: unixSeconds.nullable(),
|
|
139
|
+
paid_at: unixSeconds.nullable(),
|
|
140
|
+
voided_at: unixSeconds.nullable(),
|
|
141
|
+
marked_uncollectible_at: unixSeconds.nullable(),
|
|
142
|
+
})
|
|
143
|
+
.strict(),
|
|
144
|
+
paid_out_of_band: z.boolean(),
|
|
145
|
+
test_clock: z.string().nullable(),
|
|
146
|
+
metadata,
|
|
147
|
+
created: unixSeconds,
|
|
148
|
+
effective_at: unixSeconds.nullable(),
|
|
149
|
+
})
|
|
150
|
+
.strict(), {
|
|
151
|
+
examples: [
|
|
152
|
+
{
|
|
153
|
+
id: 'in_0193b8f2c1a87d3e9f4a',
|
|
154
|
+
object: 'invoice',
|
|
155
|
+
livemode: false,
|
|
156
|
+
number: 'ACME-0001',
|
|
157
|
+
customer: 'cus_0193b8f2c1a87d3e9f4a',
|
|
158
|
+
customer_email: 'jenny@example.com',
|
|
159
|
+
customer_name: 'Jenny Rosen',
|
|
160
|
+
subscription: 'sub_0193b8f2c1a87d3e9f4a',
|
|
161
|
+
status: 'paid',
|
|
162
|
+
billing_reason: 'subscription_create',
|
|
163
|
+
collection_method: 'charge_automatically',
|
|
164
|
+
currency: 'EUR',
|
|
165
|
+
description: null,
|
|
166
|
+
auto_advance: true,
|
|
167
|
+
automatically_finalizes_at: null,
|
|
168
|
+
lines: {
|
|
169
|
+
object: 'list',
|
|
170
|
+
data: [],
|
|
171
|
+
has_more: false,
|
|
172
|
+
url: '/v1/invoices/in_0193b8f2c1a87d3e9f4a/lines',
|
|
173
|
+
},
|
|
174
|
+
subtotal: '1999',
|
|
175
|
+
subtotal_excluding_tax: '1999',
|
|
176
|
+
total_discount_amounts: [],
|
|
177
|
+
discount: null,
|
|
178
|
+
tax: '0',
|
|
179
|
+
total: '1999',
|
|
180
|
+
total_excluding_tax: '1999',
|
|
181
|
+
starting_balance: '0',
|
|
182
|
+
ending_balance: '0',
|
|
183
|
+
amount_due: '1999',
|
|
184
|
+
amount_paid: '1999',
|
|
185
|
+
amount_remaining: '0',
|
|
186
|
+
pre_payment_credit_notes_amount: '0',
|
|
187
|
+
post_payment_credit_notes_amount: '0',
|
|
188
|
+
attempt_count: 1,
|
|
189
|
+
attempted: true,
|
|
190
|
+
next_payment_attempt: null,
|
|
191
|
+
due_date: null,
|
|
192
|
+
days_until_due: null,
|
|
193
|
+
period_start: 1793750400,
|
|
194
|
+
period_end: 1793750400,
|
|
195
|
+
payment_intent: 'pi_0193b8f2c1a87d3e9f4a',
|
|
196
|
+
default_payment_method: null,
|
|
197
|
+
automatic_tax: { enabled: false, status: null, tax_calculation: null },
|
|
198
|
+
hosted_invoice_url: 'https://checkout.peable.to/invoice/inv_tok_…',
|
|
199
|
+
invoice_pdf: 'https://api.peable.to/v1/invoices/public/inv_tok_…/pdf',
|
|
200
|
+
last_finalization_error: null,
|
|
201
|
+
status_transitions: {
|
|
202
|
+
finalized_at: 1793750400,
|
|
203
|
+
paid_at: 1793750401,
|
|
204
|
+
voided_at: null,
|
|
205
|
+
marked_uncollectible_at: null,
|
|
206
|
+
},
|
|
207
|
+
paid_out_of_band: false,
|
|
208
|
+
test_clock: null,
|
|
209
|
+
metadata: {},
|
|
210
|
+
created: 1793750400,
|
|
211
|
+
effective_at: 1793750400,
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
});
|
|
215
|
+
/** What `DELETE /v1/invoices/:id` (a draft) answers. */
|
|
216
|
+
export const deletedInvoiceSchema = defineComponent('DeletedInvoice', deletedOf('invoice'));
|
|
217
|
+
// ---- Requests ------------------------------------------------------------------------
|
|
218
|
+
export const createInvoiceParams = z
|
|
219
|
+
.object({
|
|
220
|
+
customer: idParam,
|
|
221
|
+
currency: currencyParam
|
|
222
|
+
.optional()
|
|
223
|
+
.describe("Default: the subscription's, else the customer's billing currency."),
|
|
224
|
+
subscription: idParam.optional(),
|
|
225
|
+
auto_advance: z.boolean().optional(),
|
|
226
|
+
collection_method: z.enum(COLLECTION_METHODS).optional(),
|
|
227
|
+
days_until_due: daysUntilDueParam.optional(),
|
|
228
|
+
due_date: unixSecondsParam.optional().describe('`send_invoice` only.'),
|
|
229
|
+
description: shortText(1500).optional(),
|
|
230
|
+
default_payment_method: idParam.optional(),
|
|
231
|
+
discounts: discountsParam.optional(),
|
|
232
|
+
automatic_tax: automaticTaxParam.optional(),
|
|
233
|
+
pending_invoice_items_behavior: z
|
|
234
|
+
.enum(PENDING_INVOICE_ITEMS_BEHAVIORS)
|
|
235
|
+
.optional()
|
|
236
|
+
.describe("Pull the customer's pending invoice items in. Default `exclude` (Stripe's)."),
|
|
237
|
+
metadata: metadataCreateParam.optional(),
|
|
238
|
+
expand: expandParam.optional(),
|
|
239
|
+
})
|
|
240
|
+
.strict();
|
|
241
|
+
/** Drafts only, except `metadata` and `auto_advance`. A field sent as `""` is cleared. */
|
|
242
|
+
export const updateInvoiceParams = z
|
|
243
|
+
.object({
|
|
244
|
+
auto_advance: z.boolean().optional(),
|
|
245
|
+
collection_method: z.enum(COLLECTION_METHODS).optional(),
|
|
246
|
+
days_until_due: daysUntilDueParam.optional(),
|
|
247
|
+
due_date: unixSecondsParam.optional(),
|
|
248
|
+
description: z.union([shortText(1500), z.literal('')]).optional(),
|
|
249
|
+
default_payment_method: z.union([idParam, z.literal('')]).optional(),
|
|
250
|
+
discounts: z.union([discountsParam, z.literal('')]).optional(),
|
|
251
|
+
automatic_tax: automaticTaxParam.optional(),
|
|
252
|
+
metadata: metadataUpdateParam.optional(),
|
|
253
|
+
expand: expandParam.optional(),
|
|
254
|
+
})
|
|
255
|
+
.strict();
|
|
256
|
+
export const finalizeInvoiceParams = z
|
|
257
|
+
.object({ auto_advance: z.boolean().optional(), expand: expandParam.optional() })
|
|
258
|
+
.strict();
|
|
259
|
+
export const payInvoiceParams = z
|
|
260
|
+
.object({
|
|
261
|
+
payment_method: idParam
|
|
262
|
+
.optional()
|
|
263
|
+
.describe("A saved `pm_…` of the customer; defaults to the invoice's, then the subscription's, then the customer's."),
|
|
264
|
+
paid_out_of_band: z.boolean().optional().describe('Record a payment made outside Orbit.'),
|
|
265
|
+
off_session: z.boolean().optional().describe('Default true: the customer is not present.'),
|
|
266
|
+
expand: expandParam.optional(),
|
|
267
|
+
})
|
|
268
|
+
.strict();
|
|
269
|
+
/** The body of an invoice action that takes nothing but `expand[]` (send, void, mark uncollectible). */
|
|
270
|
+
export const invoiceActionParams = z.object({ expand: expandParam.optional() }).strict();
|
|
271
|
+
export const listInvoicesQuery = listQuery({
|
|
272
|
+
customer: idParam.optional(),
|
|
273
|
+
subscription: idParam.optional(),
|
|
274
|
+
status: z.enum(INVOICE_STATUSES).optional(),
|
|
275
|
+
collection_method: z.enum(COLLECTION_METHODS).optional(),
|
|
276
|
+
due_date: rangeParam.optional(),
|
|
277
|
+
});
|
|
278
|
+
/** `GET /v1/invoices/upcoming` — a preview, never stored. */
|
|
279
|
+
export const upcomingInvoiceQuery = z
|
|
280
|
+
.object({
|
|
281
|
+
customer: idParam,
|
|
282
|
+
subscription: idParam
|
|
283
|
+
.optional()
|
|
284
|
+
.describe("Default: the customer's most recent subscription that will renew."),
|
|
285
|
+
subscription_items: z
|
|
286
|
+
.array(z
|
|
287
|
+
.object({
|
|
288
|
+
id: idParam.optional(),
|
|
289
|
+
price: idParam.optional(),
|
|
290
|
+
quantity: queryInteger({ min: 0 }).optional(),
|
|
291
|
+
deleted: queryBoolean.optional(),
|
|
292
|
+
})
|
|
293
|
+
.strict())
|
|
294
|
+
.max(20)
|
|
295
|
+
.optional()
|
|
296
|
+
.describe('Preview a change: the items it would have (`subscription_items[0][price]=…`).'),
|
|
297
|
+
subscription_proration_behavior: z.enum(PRORATION_BEHAVIORS).optional(),
|
|
298
|
+
subscription_proration_date: queryUnixSeconds.optional(),
|
|
299
|
+
expand: expandParam.optional(),
|
|
300
|
+
})
|
|
301
|
+
.strict();
|
|
302
|
+
// ---- Routes --------------------------------------------------------------------------
|
|
303
|
+
const invoiceId = { id: 'The invoice (`in_…`).' };
|
|
304
|
+
export const invoiceRoutes = [
|
|
305
|
+
defineRoute({
|
|
306
|
+
operationId: 'createInvoice',
|
|
307
|
+
method: 'post',
|
|
308
|
+
path: '/v1/invoices',
|
|
309
|
+
tag: 'Invoices',
|
|
310
|
+
summary: 'Create an invoice',
|
|
311
|
+
description: 'A draft, for a customer; it finalizes on its own when `auto_advance` is set.',
|
|
312
|
+
auth: 'service',
|
|
313
|
+
scope: 'payments:write',
|
|
314
|
+
idempotent: true,
|
|
315
|
+
body: createInvoiceParams,
|
|
316
|
+
response: invoiceSchema,
|
|
317
|
+
sdk: 'invoices.create',
|
|
318
|
+
expandable: 'invoice',
|
|
319
|
+
}),
|
|
320
|
+
defineRoute({
|
|
321
|
+
operationId: 'listInvoices',
|
|
322
|
+
method: 'get',
|
|
323
|
+
path: '/v1/invoices',
|
|
324
|
+
tag: 'Invoices',
|
|
325
|
+
summary: 'List invoices',
|
|
326
|
+
auth: 'service',
|
|
327
|
+
scope: 'payments:read',
|
|
328
|
+
query: listInvoicesQuery,
|
|
329
|
+
response: listOf(invoiceSchema),
|
|
330
|
+
sdk: 'invoices.list',
|
|
331
|
+
expandable: 'invoice',
|
|
332
|
+
}),
|
|
333
|
+
defineRoute({
|
|
334
|
+
operationId: 'retrieveUpcomingInvoice',
|
|
335
|
+
method: 'get',
|
|
336
|
+
path: '/v1/invoices/upcoming',
|
|
337
|
+
tag: 'Invoices',
|
|
338
|
+
summary: 'Preview the upcoming invoice',
|
|
339
|
+
description: "The invoice a customer's subscription will renew with — or, with `subscription_items`, the one a change would produce. Computed, never stored (its `id` is empty). 404 when the customer has no subscription that will renew.",
|
|
340
|
+
auth: 'service',
|
|
341
|
+
scope: 'payments:read',
|
|
342
|
+
query: upcomingInvoiceQuery,
|
|
343
|
+
response: invoiceSchema,
|
|
344
|
+
sdk: 'invoices.retrieveUpcoming',
|
|
345
|
+
expandable: 'invoice',
|
|
346
|
+
}),
|
|
347
|
+
defineRoute({
|
|
348
|
+
operationId: 'retrieveInvoice',
|
|
349
|
+
method: 'get',
|
|
350
|
+
path: '/v1/invoices/{id}',
|
|
351
|
+
tag: 'Invoices',
|
|
352
|
+
summary: 'Retrieve an invoice',
|
|
353
|
+
auth: 'service',
|
|
354
|
+
scope: 'payments:read',
|
|
355
|
+
params: invoiceId,
|
|
356
|
+
query: expandOnlyQuery,
|
|
357
|
+
response: invoiceSchema,
|
|
358
|
+
sdk: 'invoices.retrieve',
|
|
359
|
+
expandable: 'invoice',
|
|
360
|
+
}),
|
|
361
|
+
defineRoute({
|
|
362
|
+
operationId: 'updateInvoice',
|
|
363
|
+
method: 'post',
|
|
364
|
+
path: '/v1/invoices/{id}',
|
|
365
|
+
tag: 'Invoices',
|
|
366
|
+
summary: 'Update an invoice',
|
|
367
|
+
description: 'Drafts only, except `metadata` and `auto_advance`. A field sent as `""` is cleared; `metadata` is a patch.',
|
|
368
|
+
auth: 'service',
|
|
369
|
+
scope: 'payments:write',
|
|
370
|
+
idempotent: true,
|
|
371
|
+
params: invoiceId,
|
|
372
|
+
body: updateInvoiceParams,
|
|
373
|
+
response: invoiceSchema,
|
|
374
|
+
sdk: 'invoices.update',
|
|
375
|
+
expandable: 'invoice',
|
|
376
|
+
}),
|
|
377
|
+
defineRoute({
|
|
378
|
+
operationId: 'deleteInvoice',
|
|
379
|
+
method: 'delete',
|
|
380
|
+
path: '/v1/invoices/{id}',
|
|
381
|
+
tag: 'Invoices',
|
|
382
|
+
summary: 'Delete a draft invoice',
|
|
383
|
+
description: 'Only a draft can be deleted; a finalized invoice is voided instead.',
|
|
384
|
+
auth: 'service',
|
|
385
|
+
scope: 'payments:write',
|
|
386
|
+
params: invoiceId,
|
|
387
|
+
response: deletedInvoiceSchema,
|
|
388
|
+
sdk: 'invoices.del',
|
|
389
|
+
}),
|
|
390
|
+
defineRoute({
|
|
391
|
+
operationId: 'finalizeInvoice',
|
|
392
|
+
method: 'post',
|
|
393
|
+
path: '/v1/invoices/{id}/finalize',
|
|
394
|
+
tag: 'Invoices',
|
|
395
|
+
summary: 'Finalize a draft invoice',
|
|
396
|
+
description: 'It gets its number, its tax and its payer-facing page.',
|
|
397
|
+
auth: 'service',
|
|
398
|
+
scope: 'payments:write',
|
|
399
|
+
idempotent: true,
|
|
400
|
+
params: invoiceId,
|
|
401
|
+
body: finalizeInvoiceParams,
|
|
402
|
+
response: invoiceSchema,
|
|
403
|
+
sdk: 'invoices.finalizeInvoice',
|
|
404
|
+
expandable: 'invoice',
|
|
405
|
+
}),
|
|
406
|
+
defineRoute({
|
|
407
|
+
operationId: 'payInvoice',
|
|
408
|
+
method: 'post',
|
|
409
|
+
path: '/v1/invoices/{id}/pay',
|
|
410
|
+
tag: 'Invoices',
|
|
411
|
+
summary: 'Pay an invoice',
|
|
412
|
+
description: 'Charge a saved card off-session, or record a payment made outside Orbit (`paid_out_of_band`). A decline is a `card_error` carrying the invoice as it now is.',
|
|
413
|
+
auth: 'service',
|
|
414
|
+
scope: 'payments:write',
|
|
415
|
+
idempotent: true,
|
|
416
|
+
params: invoiceId,
|
|
417
|
+
body: payInvoiceParams,
|
|
418
|
+
response: invoiceSchema,
|
|
419
|
+
sdk: 'invoices.pay',
|
|
420
|
+
expandable: 'invoice',
|
|
421
|
+
}),
|
|
422
|
+
defineRoute({
|
|
423
|
+
operationId: 'sendInvoice',
|
|
424
|
+
method: 'post',
|
|
425
|
+
path: '/v1/invoices/{id}/send',
|
|
426
|
+
tag: 'Invoices',
|
|
427
|
+
summary: 'Send an invoice to its customer',
|
|
428
|
+
auth: 'service',
|
|
429
|
+
scope: 'payments:write',
|
|
430
|
+
idempotent: true,
|
|
431
|
+
params: invoiceId,
|
|
432
|
+
body: invoiceActionParams,
|
|
433
|
+
response: invoiceSchema,
|
|
434
|
+
sdk: 'invoices.sendInvoice',
|
|
435
|
+
expandable: 'invoice',
|
|
436
|
+
}),
|
|
437
|
+
defineRoute({
|
|
438
|
+
operationId: 'voidInvoice',
|
|
439
|
+
method: 'post',
|
|
440
|
+
path: '/v1/invoices/{id}/void',
|
|
441
|
+
tag: 'Invoices',
|
|
442
|
+
summary: 'Void an invoice',
|
|
443
|
+
auth: 'service',
|
|
444
|
+
scope: 'payments:write',
|
|
445
|
+
idempotent: true,
|
|
446
|
+
params: invoiceId,
|
|
447
|
+
body: invoiceActionParams,
|
|
448
|
+
response: invoiceSchema,
|
|
449
|
+
sdk: 'invoices.voidInvoice',
|
|
450
|
+
expandable: 'invoice',
|
|
451
|
+
}),
|
|
452
|
+
defineRoute({
|
|
453
|
+
operationId: 'markInvoiceUncollectible',
|
|
454
|
+
method: 'post',
|
|
455
|
+
path: '/v1/invoices/{id}/mark_uncollectible',
|
|
456
|
+
tag: 'Invoices',
|
|
457
|
+
summary: 'Mark an invoice uncollectible',
|
|
458
|
+
auth: 'service',
|
|
459
|
+
scope: 'payments:write',
|
|
460
|
+
idempotent: true,
|
|
461
|
+
params: invoiceId,
|
|
462
|
+
body: invoiceActionParams,
|
|
463
|
+
response: invoiceSchema,
|
|
464
|
+
sdk: 'invoices.markUncollectible',
|
|
465
|
+
expandable: 'invoice',
|
|
466
|
+
}),
|
|
467
|
+
defineRoute({
|
|
468
|
+
operationId: 'listInvoiceLineItems',
|
|
469
|
+
method: 'get',
|
|
470
|
+
path: '/v1/invoices/{id}/lines',
|
|
471
|
+
tag: 'Invoices',
|
|
472
|
+
summary: "List an invoice's lines",
|
|
473
|
+
description: 'Every line, on one page.',
|
|
474
|
+
auth: 'service',
|
|
475
|
+
scope: 'payments:read',
|
|
476
|
+
params: invoiceId,
|
|
477
|
+
response: listOf(invoiceLineItemSchema),
|
|
478
|
+
sdk: 'invoices.listLineItems',
|
|
479
|
+
}),
|
|
480
|
+
defineRoute({
|
|
481
|
+
operationId: 'retrieveInvoicePdf',
|
|
482
|
+
method: 'get',
|
|
483
|
+
path: '/v1/invoices/{id}/pdf',
|
|
484
|
+
tag: 'Invoices',
|
|
485
|
+
summary: "Download an invoice's PDF",
|
|
486
|
+
auth: 'service',
|
|
487
|
+
scope: 'payments:read',
|
|
488
|
+
params: invoiceId,
|
|
489
|
+
response: { kind: 'binary', contentType: 'application/pdf' },
|
|
490
|
+
sdk: 'invoices.retrievePdf',
|
|
491
|
+
}),
|
|
492
|
+
defineRoute({
|
|
493
|
+
operationId: 'searchInvoices',
|
|
494
|
+
method: 'get',
|
|
495
|
+
path: '/v1/invoices/search',
|
|
496
|
+
tag: 'Invoices',
|
|
497
|
+
summary: 'Search invoices',
|
|
498
|
+
description: "Stripe's query language over the invoice's fields and `metadata['key']`.",
|
|
499
|
+
auth: 'service',
|
|
500
|
+
scope: 'payments:read',
|
|
501
|
+
query: searchQuery,
|
|
502
|
+
response: searchResultOf(invoiceSchema),
|
|
503
|
+
sdk: 'invoices.search',
|
|
504
|
+
expandable: 'invoice',
|
|
505
|
+
}),
|
|
506
|
+
];
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { idParam } from '../../common/params.js';
|
|
3
|
+
import { CURRENCY_CODES, isBaseUnitString } from '../../vocabulary/money.js';
|
|
4
|
+
/**
|
|
5
|
+
* Request (and response) pieces the billing engine's resources share (ADR
|
|
6
|
+
* 0018). Internal to this group: not re-exported from its `index.ts`, so no
|
|
7
|
+
* name here can collide with another group's at the package root.
|
|
8
|
+
*/
|
|
9
|
+
/** A quantity: a whole number of units, 0 to a billion. */
|
|
10
|
+
export const quantityParam = z.number().int().min(0).max(1000000000);
|
|
11
|
+
/** Non-empty bounded text. */
|
|
12
|
+
export const shortText = (max) => z.string().min(1).max(max);
|
|
13
|
+
/** `send_invoice` only: days from finalization to the due date. */
|
|
14
|
+
export const daysUntilDueParam = z.number().int().min(0).max(365);
|
|
15
|
+
/** A currency a request names. */
|
|
16
|
+
export const currencyParam = z.enum(CURRENCY_CODES);
|
|
17
|
+
/** A canonical base-unit integer string: `"1999"`, never `"19.99"` or `1999`. */
|
|
18
|
+
export const amountParam = z
|
|
19
|
+
.string()
|
|
20
|
+
.refine(isBaseUnitString, 'must be a non-negative integer string in the smallest currency unit');
|
|
21
|
+
/** A signed base-unit integer string (a balance adjustment). */
|
|
22
|
+
export const signedAmountParam = z
|
|
23
|
+
.string()
|
|
24
|
+
.regex(/^(0|-?[1-9][0-9]{0,30})$/, 'must be an integer string in the smallest currency unit, optionally negative');
|
|
25
|
+
/** One entry of `discounts[]`: a coupon or a promotion code. */
|
|
26
|
+
export const discountParams = z
|
|
27
|
+
.object({ coupon: idParam.optional(), promotion_code: idParam.optional() })
|
|
28
|
+
.strict();
|
|
29
|
+
/** `discounts[]`, at most twenty. */
|
|
30
|
+
export const discountsParam = z.array(discountParams).max(20);
|
|
31
|
+
/** `automatic_tax[enabled]`: compute Peable Tax (ADR 0011) before the invoice finalizes. */
|
|
32
|
+
export const automaticTaxParam = z.object({ enabled: z.boolean() }).strict();
|
|
33
|
+
/** An http(s) URL a request names (a return URL, a policy link). */
|
|
34
|
+
export const httpUrlParam = z
|
|
35
|
+
.string()
|
|
36
|
+
.regex(/^https?:\/\//)
|
|
37
|
+
.max(2048);
|
|
38
|
+
/** A request with no parameters at all. */
|
|
39
|
+
export const emptyBody = z.object({}).strict();
|