@peable.to/contracts 0.4.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 -137
- 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 -134
- 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 -171
- 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 -165
- package/dist/esm/openapi.js +0 -161
- package/dist/types/openapi.d.ts +0 -148
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
4
|
+
import { expandOnlyQuery, listQuery, metadataCreateParam } from '../../common/params.js';
|
|
5
|
+
import { livemode, metadata, nullableString, unixSeconds } from '../../common/primitives.js';
|
|
6
|
+
import { defineRoute } from '../../route.js';
|
|
7
|
+
import { TAX_DOCUMENT_CHECKLIST_STATUSES, TAX_DOCUMENT_KINDS } from '../../vocabulary/tax.js';
|
|
8
|
+
import { complianceCountryParam, complianceIdParam, complianceStateParam, complianceTextParam, taxState, } from './shared.js';
|
|
9
|
+
/**
|
|
10
|
+
* A supporting document (`taxdoc_…`): a `file_…` of purpose `tax_document`
|
|
11
|
+
* (private, never addressable by URL) with what it is for. Attaching a
|
|
12
|
+
* document proves nothing by itself; it is what a reviewer reads.
|
|
13
|
+
*/
|
|
14
|
+
export const taxDocumentSchema = defineObject('tax.document', 'TaxDocument', z
|
|
15
|
+
.object({
|
|
16
|
+
object: z.literal('tax.document'),
|
|
17
|
+
id: z.string().describe('`taxdoc_…`.'),
|
|
18
|
+
livemode,
|
|
19
|
+
file: z.string().describe('The file (`file_…`, purpose `tax_document`).'),
|
|
20
|
+
// The file's `status` vocabulary (`available` / `withheld` / `removed`).
|
|
21
|
+
file_status: z
|
|
22
|
+
.enum(['available', 'withheld', 'removed'])
|
|
23
|
+
.describe("The file's standing now: a `removed` file is a document that is gone."),
|
|
24
|
+
filename: nullableString,
|
|
25
|
+
kind: z.enum(TAX_DOCUMENT_KINDS),
|
|
26
|
+
country: nullableString.describe('ISO 3166-1 alpha-2.'),
|
|
27
|
+
state: taxState,
|
|
28
|
+
registration_declaration: nullableString.describe('The declaration (`taxrd_…`) it supports, when it names one.'),
|
|
29
|
+
description: nullableString,
|
|
30
|
+
metadata,
|
|
31
|
+
created: unixSeconds,
|
|
32
|
+
})
|
|
33
|
+
.strict(), {
|
|
34
|
+
examples: [
|
|
35
|
+
{
|
|
36
|
+
object: 'tax.document',
|
|
37
|
+
id: 'taxdoc_0193b8f2c1a87d3e9f4a',
|
|
38
|
+
livemode: false,
|
|
39
|
+
file: 'file_0193b8f2c1a87d3e9f4a',
|
|
40
|
+
file_status: 'available',
|
|
41
|
+
filename: 'oss-registration.pdf',
|
|
42
|
+
kind: 'registration_certificate',
|
|
43
|
+
country: 'ES',
|
|
44
|
+
state: null,
|
|
45
|
+
registration_declaration: 'taxrd_0193b8f2c1a87d3e9f4a',
|
|
46
|
+
description: null,
|
|
47
|
+
metadata: {},
|
|
48
|
+
created: 1793750400,
|
|
49
|
+
},
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
export const taxDocumentChecklistItemSchema = defineComponent('TaxDocumentChecklistItem', z
|
|
53
|
+
.object({
|
|
54
|
+
key: z.string(),
|
|
55
|
+
kind: z.enum(TAX_DOCUMENT_KINDS),
|
|
56
|
+
country: nullableString,
|
|
57
|
+
state: taxState,
|
|
58
|
+
status: z
|
|
59
|
+
.enum(TAX_DOCUMENT_CHECKLIST_STATUSES)
|
|
60
|
+
.describe('`provided`: an available document is attached; `unavailable`: only removed ones are.'),
|
|
61
|
+
documents: z.array(z.string()).describe('The attached documents (`taxdoc_…`).'),
|
|
62
|
+
reason: z.string(),
|
|
63
|
+
})
|
|
64
|
+
.strict());
|
|
65
|
+
/** The documents the recorded facts call for, and which are attached. */
|
|
66
|
+
export const taxDocumentChecklistSchema = defineObject('tax.document_checklist', 'TaxDocumentChecklist', z
|
|
67
|
+
.object({
|
|
68
|
+
object: z.literal('tax.document_checklist'),
|
|
69
|
+
livemode,
|
|
70
|
+
items: z.array(taxDocumentChecklistItemSchema),
|
|
71
|
+
})
|
|
72
|
+
.strict());
|
|
73
|
+
/** Orbit's attachment of a document (the owner's). Attaching the same file again answers the same document. */
|
|
74
|
+
export const createTaxDocumentParams = z
|
|
75
|
+
.object({
|
|
76
|
+
file: complianceIdParam.describe('A `file_…` of purpose `tax_document`.'),
|
|
77
|
+
kind: z.enum(TAX_DOCUMENT_KINDS),
|
|
78
|
+
country: complianceCountryParam.nullable().optional(),
|
|
79
|
+
state: complianceStateParam.optional(),
|
|
80
|
+
registration_declaration: complianceIdParam.nullable().optional(),
|
|
81
|
+
description: complianceTextParam(500).optional(),
|
|
82
|
+
metadata: metadataCreateParam.optional(),
|
|
83
|
+
})
|
|
84
|
+
.strict();
|
|
85
|
+
export const listTaxDocumentsQuery = listQuery({});
|
|
86
|
+
export const taxDocumentRoutes = [
|
|
87
|
+
defineRoute({
|
|
88
|
+
operationId: 'listTaxDocuments',
|
|
89
|
+
method: 'get',
|
|
90
|
+
path: '/v1/tax/documents',
|
|
91
|
+
tag: 'Tax compliance',
|
|
92
|
+
summary: 'List tax documents',
|
|
93
|
+
auth: 'service',
|
|
94
|
+
scope: 'payments:read',
|
|
95
|
+
query: listTaxDocumentsQuery,
|
|
96
|
+
response: listOf(taxDocumentSchema),
|
|
97
|
+
sdk: 'tax.compliance.listDocuments',
|
|
98
|
+
expandable: 'tax.document',
|
|
99
|
+
}),
|
|
100
|
+
defineRoute({
|
|
101
|
+
operationId: 'retrieveTaxDocument',
|
|
102
|
+
method: 'get',
|
|
103
|
+
path: '/v1/tax/documents/{id}',
|
|
104
|
+
tag: 'Tax compliance',
|
|
105
|
+
summary: 'Retrieve a tax document',
|
|
106
|
+
auth: 'service',
|
|
107
|
+
scope: 'payments:read',
|
|
108
|
+
params: { id: 'The document (`taxdoc_…`).' },
|
|
109
|
+
query: expandOnlyQuery,
|
|
110
|
+
response: taxDocumentSchema,
|
|
111
|
+
sdk: 'tax.compliance.retrieveDocument',
|
|
112
|
+
expandable: 'tax.document',
|
|
113
|
+
}),
|
|
114
|
+
defineRoute({
|
|
115
|
+
operationId: 'retrieveTaxDocumentChecklist',
|
|
116
|
+
method: 'get',
|
|
117
|
+
path: '/v1/tax/document_checklist',
|
|
118
|
+
tag: 'Tax compliance',
|
|
119
|
+
summary: 'Retrieve the document checklist',
|
|
120
|
+
auth: 'service',
|
|
121
|
+
scope: 'payments:read',
|
|
122
|
+
response: taxDocumentChecklistSchema,
|
|
123
|
+
sdk: 'tax.compliance.retrieveDocumentChecklist',
|
|
124
|
+
}),
|
|
125
|
+
];
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
// Peable Tax (ADR 0011) and its business compliance (ADR 0020): one module per
|
|
2
|
+
// resource, re-exported here, and their routes concatenated into `taxRoutes`.
|
|
3
|
+
import { taxAssessmentRoutes } from './assessments.js';
|
|
4
|
+
import { taxBusinessProfileRoutes } from './businessProfile.js';
|
|
5
|
+
import { taxCalculationRoutes } from './calculations.js';
|
|
6
|
+
import { taxCapabilityRoutes } from './capabilities.js';
|
|
7
|
+
import { taxCodeRoutes } from './codes.js';
|
|
8
|
+
import { taxComplianceActionRoutes } from './complianceActions.js';
|
|
9
|
+
import { taxDeadlineRoutes } from './deadlines.js';
|
|
10
|
+
import { taxDocumentRoutes } from './documents.js';
|
|
11
|
+
import { taxLocationEvidenceRoutes } from './locationEvidence.js';
|
|
12
|
+
import { taxOperatingLocationRoutes } from './operatingLocations.js';
|
|
13
|
+
import { taxProductRoutes } from './products.js';
|
|
14
|
+
import { taxRegistrationDeclarationRoutes } from './registrationDeclarations.js';
|
|
15
|
+
import { taxRegistrationRoutes } from './registrations.js';
|
|
16
|
+
import { taxReportRoutes } from './reports.js';
|
|
17
|
+
import { taxReviewItemRoutes } from './reviewItems.js';
|
|
18
|
+
import { taxRuleSetRoutes } from './ruleSet.js';
|
|
19
|
+
import { taxSalesDestinationRoutes } from './salesDestinations.js';
|
|
20
|
+
import { taxSettingsRoutes } from './settings.js';
|
|
21
|
+
import { taxTransactionRoutes } from './transactions.js';
|
|
22
|
+
export * from './assessments.js';
|
|
23
|
+
export * from './businessProfile.js';
|
|
24
|
+
export * from './calculations.js';
|
|
25
|
+
export * from './capabilities.js';
|
|
26
|
+
export * from './codes.js';
|
|
27
|
+
export * from './complianceActions.js';
|
|
28
|
+
export * from './deadlines.js';
|
|
29
|
+
export * from './documents.js';
|
|
30
|
+
export * from './locationEvidence.js';
|
|
31
|
+
export * from './operatingLocations.js';
|
|
32
|
+
export * from './products.js';
|
|
33
|
+
export * from './registrationDeclarations.js';
|
|
34
|
+
export * from './registrations.js';
|
|
35
|
+
export * from './reports.js';
|
|
36
|
+
export * from './reviewItems.js';
|
|
37
|
+
export * from './ruleSet.js';
|
|
38
|
+
export * from './salesDestinations.js';
|
|
39
|
+
export * from './settings.js';
|
|
40
|
+
export * from './shared.js';
|
|
41
|
+
export * from './transactions.js';
|
|
42
|
+
/** Peable Tax: collection (settings, evidence, calculations, transactions, reports) and business compliance. */
|
|
43
|
+
export const taxRoutes = [
|
|
44
|
+
...taxCodeRoutes,
|
|
45
|
+
...taxSettingsRoutes,
|
|
46
|
+
...taxRegistrationRoutes,
|
|
47
|
+
...taxProductRoutes,
|
|
48
|
+
...taxLocationEvidenceRoutes,
|
|
49
|
+
...taxCalculationRoutes,
|
|
50
|
+
...taxTransactionRoutes,
|
|
51
|
+
...taxReportRoutes,
|
|
52
|
+
...taxBusinessProfileRoutes,
|
|
53
|
+
...taxOperatingLocationRoutes,
|
|
54
|
+
...taxSalesDestinationRoutes,
|
|
55
|
+
...taxRegistrationDeclarationRoutes,
|
|
56
|
+
...taxDocumentRoutes,
|
|
57
|
+
...taxRuleSetRoutes,
|
|
58
|
+
...taxCapabilityRoutes,
|
|
59
|
+
...taxDeadlineRoutes,
|
|
60
|
+
...taxAssessmentRoutes,
|
|
61
|
+
...taxReviewItemRoutes,
|
|
62
|
+
...taxComplianceActionRoutes,
|
|
63
|
+
];
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
3
|
+
import { livemode, unixSeconds } from '../../common/primitives.js';
|
|
4
|
+
import { defineRoute } from '../../route.js';
|
|
5
|
+
import { TAX_EVIDENCE_STATUSES, TAX_LOCATION_EVIDENCE_TYPES } from '../../vocabulary/tax.js';
|
|
6
|
+
import { taxAddressParams } from './settings.js';
|
|
7
|
+
import { taxCountry, taxReferenceParam, taxState } from './shared.js';
|
|
8
|
+
/**
|
|
9
|
+
* Customer location evidence (`taxloc_…`, ADR 0011): what places a customer
|
|
10
|
+
* in a jurisdiction, judged against that jurisdiction's own rule. There is
|
|
11
|
+
* deliberately no language, currency, locale or timezone evidence. An IP
|
|
12
|
+
* address is never stored; at most its salted hash.
|
|
13
|
+
*/
|
|
14
|
+
/** An item as judged: the place it points at, never more of the customer than the rule needs. */
|
|
15
|
+
export const taxLocationEvidenceResultItemSchema = defineComponent('TaxLocationEvidenceResultItem', z
|
|
16
|
+
.object({
|
|
17
|
+
type: z.enum(TAX_LOCATION_EVIDENCE_TYPES),
|
|
18
|
+
country: taxCountry,
|
|
19
|
+
state: taxState,
|
|
20
|
+
})
|
|
21
|
+
.strict());
|
|
22
|
+
export const taxLocationEvidenceSchema = defineObject('tax.location_evidence', 'TaxLocationEvidence', z
|
|
23
|
+
.object({
|
|
24
|
+
object: z.literal('tax.location_evidence'),
|
|
25
|
+
id: z.string().describe('`taxloc_…`.'),
|
|
26
|
+
customer_ref: z.string().describe('The customer this evidence is about.'),
|
|
27
|
+
status: z
|
|
28
|
+
.enum(TAX_EVIDENCE_STATUSES)
|
|
29
|
+
.describe('Only `sufficient` evidence can be calculated against.'),
|
|
30
|
+
rule: z
|
|
31
|
+
.string()
|
|
32
|
+
.describe('The jurisdiction rule applied: `eu_digital_two_items`, `gb_digital_two_items`, `us_billing_address`, `ca_billing_address`, `default_one_item`, or `none` when no item names a country.'),
|
|
33
|
+
country: taxCountry
|
|
34
|
+
.nullable()
|
|
35
|
+
.describe('Where the evidence places the customer, when it does.'),
|
|
36
|
+
state: taxState,
|
|
37
|
+
items: z.array(taxLocationEvidenceResultItemSchema),
|
|
38
|
+
observed_at: unixSeconds,
|
|
39
|
+
expires_at: unixSeconds.describe('Evidence stays usable for a day.'),
|
|
40
|
+
livemode,
|
|
41
|
+
})
|
|
42
|
+
.strict(), {
|
|
43
|
+
examples: [
|
|
44
|
+
{
|
|
45
|
+
object: 'tax.location_evidence',
|
|
46
|
+
id: 'taxloc_0193b8f2c1a87d3e9f4a',
|
|
47
|
+
customer_ref: 'cus_0193b8f2c1a87d3e9f4a',
|
|
48
|
+
status: 'sufficient',
|
|
49
|
+
rule: 'eu_digital_two_items',
|
|
50
|
+
country: 'DE',
|
|
51
|
+
state: null,
|
|
52
|
+
items: [
|
|
53
|
+
{ type: 'billing_address', country: 'DE', state: null },
|
|
54
|
+
{ type: 'ip_address', country: 'DE', state: null },
|
|
55
|
+
],
|
|
56
|
+
observed_at: 1793750400,
|
|
57
|
+
expires_at: 1793836800,
|
|
58
|
+
livemode: false,
|
|
59
|
+
},
|
|
60
|
+
],
|
|
61
|
+
});
|
|
62
|
+
const evidenceCountry = z.string().regex(/^[A-Z]{2}$/);
|
|
63
|
+
const evidenceState = z
|
|
64
|
+
.string()
|
|
65
|
+
.regex(/^[A-Z0-9]{1,3}$/)
|
|
66
|
+
.nullish();
|
|
67
|
+
const ipv4 = z.ipv4();
|
|
68
|
+
const ipv6 = z.ipv6();
|
|
69
|
+
/**
|
|
70
|
+
* One piece of evidence. Strict: an item claiming a language, currency, locale
|
|
71
|
+
* or timezone is not a smaller kind of evidence, it is refused.
|
|
72
|
+
*/
|
|
73
|
+
export const taxLocationEvidenceItemParams = z.discriminatedUnion('type', [
|
|
74
|
+
z.object({ type: z.literal('billing_address'), address: taxAddressParams }).strict(),
|
|
75
|
+
z
|
|
76
|
+
.object({
|
|
77
|
+
type: z.literal('ip_address'),
|
|
78
|
+
ip_address: z
|
|
79
|
+
.string()
|
|
80
|
+
.refine((value) => ipv4.safeParse(value).success || ipv6.safeParse(value).success, 'Not an IP address'),
|
|
81
|
+
country: evidenceCountry,
|
|
82
|
+
state: evidenceState,
|
|
83
|
+
})
|
|
84
|
+
.strict(),
|
|
85
|
+
z
|
|
86
|
+
.object({
|
|
87
|
+
type: z.enum(['payment_method_country', 'bank_country', 'sim_country', 'landline_country']),
|
|
88
|
+
country: evidenceCountry,
|
|
89
|
+
})
|
|
90
|
+
.strict(),
|
|
91
|
+
]);
|
|
92
|
+
/** At least one item and at most six. */
|
|
93
|
+
export const taxLocationEvidenceItemsParam = z.array(taxLocationEvidenceItemParams).min(1).max(6);
|
|
94
|
+
export const createTaxLocationEvidenceParams = z
|
|
95
|
+
.object({
|
|
96
|
+
customer_ref: taxReferenceParam.describe('The customer this evidence is about; for billing, the `storeId`.'),
|
|
97
|
+
evidence: taxLocationEvidenceItemsParam,
|
|
98
|
+
})
|
|
99
|
+
.strict();
|
|
100
|
+
export const taxLocationEvidenceRoutes = [
|
|
101
|
+
defineRoute({
|
|
102
|
+
operationId: 'createTaxLocationEvidence',
|
|
103
|
+
method: 'post',
|
|
104
|
+
path: '/v1/tax/location_evidence',
|
|
105
|
+
tag: 'Tax',
|
|
106
|
+
summary: 'Record customer location evidence',
|
|
107
|
+
description: "Judged at once against the customer's jurisdiction rule; the answer says whether it is `sufficient` to calculate against.",
|
|
108
|
+
auth: 'service',
|
|
109
|
+
scope: 'payments:write',
|
|
110
|
+
idempotent: true,
|
|
111
|
+
body: createTaxLocationEvidenceParams,
|
|
112
|
+
response: taxLocationEvidenceSchema,
|
|
113
|
+
status: 201,
|
|
114
|
+
sdk: 'tax.locationEvidence.create',
|
|
115
|
+
}),
|
|
116
|
+
defineRoute({
|
|
117
|
+
operationId: 'retrieveTaxLocationEvidence',
|
|
118
|
+
method: 'get',
|
|
119
|
+
path: '/v1/tax/location_evidence/{id}',
|
|
120
|
+
tag: 'Tax',
|
|
121
|
+
summary: 'Retrieve customer location evidence',
|
|
122
|
+
auth: 'service',
|
|
123
|
+
scope: 'payments:read',
|
|
124
|
+
params: { id: 'The evidence (`taxloc_…`).' },
|
|
125
|
+
response: taxLocationEvidenceSchema,
|
|
126
|
+
sdk: 'tax.locationEvidence.retrieve',
|
|
127
|
+
}),
|
|
128
|
+
];
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineObject } from '../../common/objects.js';
|
|
4
|
+
import { expandOnlyQuery, listQuery, metadataCreateParam, metadataUpdateParam, } from '../../common/params.js';
|
|
5
|
+
import { livemode, metadata, nullableString, unixSeconds } from '../../common/primitives.js';
|
|
6
|
+
import { defineRoute } from '../../route.js';
|
|
7
|
+
import { TAX_OPERATING_LOCATION_KINDS } from '../../vocabulary/tax.js';
|
|
8
|
+
import { complianceCountryParam, complianceStateParam, complianceTextParam, taxCountry, taxInstantParam, taxState, } from './shared.js';
|
|
9
|
+
/**
|
|
10
|
+
* Where the business ACTUALLY operates (`taxol_…`). `head_office` and
|
|
11
|
+
* `fixed_establishment` are the owner's statement of establishment (the EU
|
|
12
|
+
* rule reads them); any location in a US state is physical presence there.
|
|
13
|
+
*/
|
|
14
|
+
export const taxOperatingLocationSchema = defineObject('tax.operating_location', 'TaxOperatingLocation', z
|
|
15
|
+
.object({
|
|
16
|
+
object: z.literal('tax.operating_location'),
|
|
17
|
+
id: z.string().describe('`taxol_…`.'),
|
|
18
|
+
livemode,
|
|
19
|
+
kind: z.enum(TAX_OPERATING_LOCATION_KINDS),
|
|
20
|
+
country: taxCountry,
|
|
21
|
+
state: taxState,
|
|
22
|
+
description: nullableString,
|
|
23
|
+
started: unixSeconds.nullable(),
|
|
24
|
+
ended: unixSeconds.nullable().describe('Set once the business no longer operates there.'),
|
|
25
|
+
metadata,
|
|
26
|
+
created: unixSeconds,
|
|
27
|
+
})
|
|
28
|
+
.strict(), {
|
|
29
|
+
examples: [
|
|
30
|
+
{
|
|
31
|
+
object: 'tax.operating_location',
|
|
32
|
+
id: 'taxol_0193b8f2c1a87d3e9f4a',
|
|
33
|
+
livemode: false,
|
|
34
|
+
kind: 'head_office',
|
|
35
|
+
country: 'ES',
|
|
36
|
+
state: null,
|
|
37
|
+
description: 'Registered office, Barcelona',
|
|
38
|
+
started: 1735689600,
|
|
39
|
+
ended: null,
|
|
40
|
+
metadata: {},
|
|
41
|
+
created: 1793750400,
|
|
42
|
+
},
|
|
43
|
+
],
|
|
44
|
+
});
|
|
45
|
+
/** Orbit's new operating location (the owner's). */
|
|
46
|
+
export const createTaxOperatingLocationParams = z
|
|
47
|
+
.object({
|
|
48
|
+
kind: z.enum(TAX_OPERATING_LOCATION_KINDS),
|
|
49
|
+
country: complianceCountryParam,
|
|
50
|
+
state: complianceStateParam.optional(),
|
|
51
|
+
description: complianceTextParam(500).optional(),
|
|
52
|
+
started: taxInstantParam.nullable().optional(),
|
|
53
|
+
ended: taxInstantParam.nullable().optional(),
|
|
54
|
+
metadata: metadataCreateParam.optional(),
|
|
55
|
+
})
|
|
56
|
+
.strict();
|
|
57
|
+
/** Orbit's update (the owner's): `kind` and the place are fixed; `metadata` is a patch. */
|
|
58
|
+
export const updateTaxOperatingLocationParams = z
|
|
59
|
+
.object({
|
|
60
|
+
description: complianceTextParam(500).optional(),
|
|
61
|
+
started: taxInstantParam.nullable().optional(),
|
|
62
|
+
ended: taxInstantParam.nullable().optional(),
|
|
63
|
+
metadata: metadataUpdateParam.optional(),
|
|
64
|
+
})
|
|
65
|
+
.strict();
|
|
66
|
+
export const listTaxOperatingLocationsQuery = listQuery({});
|
|
67
|
+
export const taxOperatingLocationRoutes = [
|
|
68
|
+
defineRoute({
|
|
69
|
+
operationId: 'listTaxOperatingLocations',
|
|
70
|
+
method: 'get',
|
|
71
|
+
path: '/v1/tax/operating_locations',
|
|
72
|
+
tag: 'Tax compliance',
|
|
73
|
+
summary: 'List operating locations',
|
|
74
|
+
auth: 'service',
|
|
75
|
+
scope: 'payments:read',
|
|
76
|
+
query: listTaxOperatingLocationsQuery,
|
|
77
|
+
response: listOf(taxOperatingLocationSchema),
|
|
78
|
+
sdk: 'tax.compliance.listOperatingLocations',
|
|
79
|
+
expandable: 'tax.operating_location',
|
|
80
|
+
}),
|
|
81
|
+
defineRoute({
|
|
82
|
+
operationId: 'retrieveTaxOperatingLocation',
|
|
83
|
+
method: 'get',
|
|
84
|
+
path: '/v1/tax/operating_locations/{id}',
|
|
85
|
+
tag: 'Tax compliance',
|
|
86
|
+
summary: 'Retrieve an operating location',
|
|
87
|
+
auth: 'service',
|
|
88
|
+
scope: 'payments:read',
|
|
89
|
+
params: { id: 'The operating location (`taxol_…`).' },
|
|
90
|
+
query: expandOnlyQuery,
|
|
91
|
+
response: taxOperatingLocationSchema,
|
|
92
|
+
sdk: 'tax.compliance.retrieveOperatingLocation',
|
|
93
|
+
expandable: 'tax.operating_location',
|
|
94
|
+
}),
|
|
95
|
+
];
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineObject } from '../../common/objects.js';
|
|
4
|
+
import { unixSeconds } from '../../common/primitives.js';
|
|
5
|
+
import { defineRoute } from '../../route.js';
|
|
6
|
+
import { taxReferenceParam } from './shared.js';
|
|
7
|
+
/**
|
|
8
|
+
* A product's tax code: what a calculation line naming `product_ref` is taxed
|
|
9
|
+
* as when the line does not say. Classifying a product is the seller's call.
|
|
10
|
+
*/
|
|
11
|
+
export const taxProductCodeSchema = defineObject('tax.product', 'TaxProductCode', z
|
|
12
|
+
.object({
|
|
13
|
+
object: z.literal('tax.product'),
|
|
14
|
+
product_ref: z
|
|
15
|
+
.string()
|
|
16
|
+
.describe("The merchant's product or plan reference (a billing `planId`)."),
|
|
17
|
+
tax_code: z.string().describe('`txcd_…`.'),
|
|
18
|
+
updated_at: unixSeconds,
|
|
19
|
+
})
|
|
20
|
+
.strict(), {
|
|
21
|
+
examples: [
|
|
22
|
+
{
|
|
23
|
+
object: 'tax.product',
|
|
24
|
+
product_ref: 'plan_pro_monthly',
|
|
25
|
+
tax_code: 'txcd_10103001',
|
|
26
|
+
updated_at: 1793750400,
|
|
27
|
+
},
|
|
28
|
+
],
|
|
29
|
+
});
|
|
30
|
+
/** `{productRef}` of `PUT /v1/tax/products/{productRef}`. */
|
|
31
|
+
export const taxProductRefParam = taxReferenceParam;
|
|
32
|
+
export const setTaxProductCodeParams = z
|
|
33
|
+
.object({ tax_code: z.string().describe('A `txcd_…` from `GET /v1/tax/codes`.') })
|
|
34
|
+
.strict();
|
|
35
|
+
export const taxProductRoutes = [
|
|
36
|
+
defineRoute({
|
|
37
|
+
operationId: 'listTaxProducts',
|
|
38
|
+
method: 'get',
|
|
39
|
+
path: '/v1/tax/products',
|
|
40
|
+
tag: 'Tax',
|
|
41
|
+
summary: 'List product tax codes',
|
|
42
|
+
description: 'Every classified product, by `product_ref`: a complete list, `has_more` is `false`.',
|
|
43
|
+
auth: 'service',
|
|
44
|
+
scope: 'payments:read',
|
|
45
|
+
response: listOf(taxProductCodeSchema),
|
|
46
|
+
sdk: 'tax.products.list',
|
|
47
|
+
}),
|
|
48
|
+
defineRoute({
|
|
49
|
+
operationId: 'setTaxProductCode',
|
|
50
|
+
method: 'put',
|
|
51
|
+
path: '/v1/tax/products/{productRef}',
|
|
52
|
+
tag: 'Tax',
|
|
53
|
+
summary: "Set a product's tax code",
|
|
54
|
+
description: 'Creates the classification or replaces it.',
|
|
55
|
+
auth: 'service',
|
|
56
|
+
scope: 'payments:write',
|
|
57
|
+
params: {
|
|
58
|
+
productRef: "The merchant's product or plan reference: 1–128 of `A-Z a-z 0-9 _ . : -`.",
|
|
59
|
+
},
|
|
60
|
+
body: setTaxProductCodeParams,
|
|
61
|
+
response: taxProductCodeSchema,
|
|
62
|
+
sdk: 'tax.products.setTaxCode',
|
|
63
|
+
}),
|
|
64
|
+
];
|
|
@@ -0,0 +1,121 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
4
|
+
import { expandOnlyQuery, listQuery, metadataCreateParam, metadataUpdateParam, } from '../../common/params.js';
|
|
5
|
+
import { livemode, metadata, nullableString, unixSeconds } from '../../common/primitives.js';
|
|
6
|
+
import { defineRoute } from '../../route.js';
|
|
7
|
+
import { TAX_FILING_FREQUENCIES, TAX_REGISTRATION_DECLARATION_STATUSES, TAX_REGISTRATION_SCHEMES, } from '../../vocabulary/tax.js';
|
|
8
|
+
import { complianceCountryParam, complianceIdParam, complianceStateParam, complianceTextParam, taxCountry, taxInstantParam, taxState, } from './shared.js';
|
|
9
|
+
/** No authority integration confirms anything yet: every declaration is `unverified`. */
|
|
10
|
+
export const taxDeclarationVerificationSchema = defineComponent('TaxRegistrationDeclarationVerification', z
|
|
11
|
+
.object({
|
|
12
|
+
status: z.literal('unverified'),
|
|
13
|
+
reason: z.literal('no_authority_integration'),
|
|
14
|
+
})
|
|
15
|
+
.strict());
|
|
16
|
+
/**
|
|
17
|
+
* A declared registration status (`taxrd_…`): where the business stands with a
|
|
18
|
+
* tax authority, IN ITS OWN WORDS. Storing one is NOT registration with a
|
|
19
|
+
* government, and it never makes Peable collect: collection needs a Peable Tax
|
|
20
|
+
* registration (`taxreg_…`) the owner approved.
|
|
21
|
+
*/
|
|
22
|
+
export const taxRegistrationDeclarationSchema = defineObject('tax.registration_declaration', 'TaxRegistrationDeclaration', z
|
|
23
|
+
.object({
|
|
24
|
+
object: z.literal('tax.registration_declaration'),
|
|
25
|
+
id: z.string().describe('`taxrd_…`.'),
|
|
26
|
+
livemode,
|
|
27
|
+
country: taxCountry,
|
|
28
|
+
state: taxState,
|
|
29
|
+
scheme: z
|
|
30
|
+
.enum(TAX_REGISTRATION_SCHEMES)
|
|
31
|
+
.nullable()
|
|
32
|
+
.describe('The scheme, when the owner knows it; `null` for `unknown`.'),
|
|
33
|
+
status: z.enum(TAX_REGISTRATION_DECLARATION_STATUSES),
|
|
34
|
+
effective_from: unixSeconds.nullable(),
|
|
35
|
+
effective_to: unixSeconds.nullable(),
|
|
36
|
+
filing_frequency: z.enum(TAX_FILING_FREQUENCIES),
|
|
37
|
+
collection_registration: nullableString.describe('The Peable Tax collection registration (`taxreg_…`) it corresponds to, when there is one.'),
|
|
38
|
+
verification: taxDeclarationVerificationSchema,
|
|
39
|
+
note: nullableString,
|
|
40
|
+
metadata,
|
|
41
|
+
created: unixSeconds,
|
|
42
|
+
updated: unixSeconds,
|
|
43
|
+
})
|
|
44
|
+
.strict(), {
|
|
45
|
+
examples: [
|
|
46
|
+
{
|
|
47
|
+
object: 'tax.registration_declaration',
|
|
48
|
+
id: 'taxrd_0193b8f2c1a87d3e9f4a',
|
|
49
|
+
livemode: false,
|
|
50
|
+
country: 'ES',
|
|
51
|
+
state: null,
|
|
52
|
+
scheme: 'eu_oss_union',
|
|
53
|
+
status: 'registered',
|
|
54
|
+
effective_from: 1767225600,
|
|
55
|
+
effective_to: null,
|
|
56
|
+
filing_frequency: 'quarterly',
|
|
57
|
+
collection_registration: 'taxreg_0193b8f2c1a87d3e9f4a',
|
|
58
|
+
verification: { status: 'unverified', reason: 'no_authority_integration' },
|
|
59
|
+
note: null,
|
|
60
|
+
metadata: {},
|
|
61
|
+
created: 1793750400,
|
|
62
|
+
updated: 1793750400,
|
|
63
|
+
},
|
|
64
|
+
],
|
|
65
|
+
});
|
|
66
|
+
const declarationFields = {
|
|
67
|
+
scheme: z.enum(TAX_REGISTRATION_SCHEMES).nullable().optional(),
|
|
68
|
+
status: z.enum(TAX_REGISTRATION_DECLARATION_STATUSES),
|
|
69
|
+
effective_from: taxInstantParam.nullable().optional(),
|
|
70
|
+
effective_to: taxInstantParam.nullable().optional(),
|
|
71
|
+
filing_frequency: z.enum(TAX_FILING_FREQUENCIES).optional(),
|
|
72
|
+
collection_registration: complianceIdParam.nullable().optional(),
|
|
73
|
+
note: complianceTextParam(1000).optional(),
|
|
74
|
+
};
|
|
75
|
+
/** Orbit's new declaration (the owner's). */
|
|
76
|
+
export const createTaxRegistrationDeclarationParams = z
|
|
77
|
+
.object({
|
|
78
|
+
country: complianceCountryParam,
|
|
79
|
+
state: complianceStateParam.optional(),
|
|
80
|
+
...declarationFields,
|
|
81
|
+
metadata: metadataCreateParam.optional(),
|
|
82
|
+
})
|
|
83
|
+
.strict();
|
|
84
|
+
/** Orbit's update (the owner's): the place is fixed; `metadata` is a patch. */
|
|
85
|
+
export const updateTaxRegistrationDeclarationParams = z
|
|
86
|
+
.object({
|
|
87
|
+
...declarationFields,
|
|
88
|
+
status: declarationFields.status.optional(),
|
|
89
|
+
metadata: metadataUpdateParam.optional(),
|
|
90
|
+
})
|
|
91
|
+
.strict();
|
|
92
|
+
export const listTaxRegistrationDeclarationsQuery = listQuery({});
|
|
93
|
+
export const taxRegistrationDeclarationRoutes = [
|
|
94
|
+
defineRoute({
|
|
95
|
+
operationId: 'listTaxRegistrationDeclarations',
|
|
96
|
+
method: 'get',
|
|
97
|
+
path: '/v1/tax/registration_declarations',
|
|
98
|
+
tag: 'Tax compliance',
|
|
99
|
+
summary: 'List registration declarations',
|
|
100
|
+
auth: 'service',
|
|
101
|
+
scope: 'payments:read',
|
|
102
|
+
query: listTaxRegistrationDeclarationsQuery,
|
|
103
|
+
response: listOf(taxRegistrationDeclarationSchema),
|
|
104
|
+
sdk: 'tax.compliance.listRegistrationDeclarations',
|
|
105
|
+
expandable: 'tax.registration_declaration',
|
|
106
|
+
}),
|
|
107
|
+
defineRoute({
|
|
108
|
+
operationId: 'retrieveTaxRegistrationDeclaration',
|
|
109
|
+
method: 'get',
|
|
110
|
+
path: '/v1/tax/registration_declarations/{id}',
|
|
111
|
+
tag: 'Tax compliance',
|
|
112
|
+
summary: 'Retrieve a registration declaration',
|
|
113
|
+
auth: 'service',
|
|
114
|
+
scope: 'payments:read',
|
|
115
|
+
params: { id: 'The declaration (`taxrd_…`).' },
|
|
116
|
+
query: expandOnlyQuery,
|
|
117
|
+
response: taxRegistrationDeclarationSchema,
|
|
118
|
+
sdk: 'tax.compliance.retrieveRegistrationDeclaration',
|
|
119
|
+
expandable: 'tax.registration_declaration',
|
|
120
|
+
}),
|
|
121
|
+
];
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { listOf } from '../../common/envelopes.js';
|
|
3
|
+
import { defineObject } from '../../common/objects.js';
|
|
4
|
+
import { nullableString, unixSeconds } from '../../common/primitives.js';
|
|
5
|
+
import { defineRoute } from '../../route.js';
|
|
6
|
+
import { TAX_REGISTRATION_SCHEMES, TAX_REGISTRATION_STATUSES } from '../../vocabulary/tax.js';
|
|
7
|
+
import { taxCountry, taxInstantParam, taxState } from './shared.js';
|
|
8
|
+
/**
|
|
9
|
+
* A Peable Tax registration (`taxreg_…`, ADR 0011): where the seller says it
|
|
10
|
+
* is registered to collect. Only registrations the owner approved make Peable
|
|
11
|
+
* collect. Registering with a government is the seller's job, never Peable's.
|
|
12
|
+
*/
|
|
13
|
+
export const taxRegistrationSchema = defineObject('tax.registration', 'TaxRegistration', z
|
|
14
|
+
.object({
|
|
15
|
+
object: z.literal('tax.registration'),
|
|
16
|
+
id: z.string().describe('`taxreg_…`.'),
|
|
17
|
+
country: taxCountry,
|
|
18
|
+
state: taxState,
|
|
19
|
+
scheme: z.enum(TAX_REGISTRATION_SCHEMES),
|
|
20
|
+
registration_number: nullableString.describe('The government-issued number (VAT id, state permit), when there is one.'),
|
|
21
|
+
active_from: unixSeconds,
|
|
22
|
+
expires_at: unixSeconds.nullable(),
|
|
23
|
+
status: z
|
|
24
|
+
.enum(TAX_REGISTRATION_STATUSES)
|
|
25
|
+
.describe('`pending_approval` until the owner approves; `scheduled` before `active_from`.'),
|
|
26
|
+
approved_at: unixSeconds.nullable(),
|
|
27
|
+
provider_registration_ref: nullableString.describe('The mirrored registration at the calculating provider, once synced.'),
|
|
28
|
+
created: unixSeconds,
|
|
29
|
+
})
|
|
30
|
+
.strict(), {
|
|
31
|
+
examples: [
|
|
32
|
+
{
|
|
33
|
+
object: 'tax.registration',
|
|
34
|
+
id: 'taxreg_0193b8f2c1a87d3e9f4a',
|
|
35
|
+
country: 'ES',
|
|
36
|
+
state: null,
|
|
37
|
+
scheme: 'eu_oss_union',
|
|
38
|
+
registration_number: 'ESB12345678',
|
|
39
|
+
active_from: 1793750400,
|
|
40
|
+
expires_at: null,
|
|
41
|
+
status: 'active',
|
|
42
|
+
approved_at: 1793750400,
|
|
43
|
+
provider_registration_ref: 'taxreg_1QxYz2AbCdEf',
|
|
44
|
+
created: 1793664000,
|
|
45
|
+
},
|
|
46
|
+
],
|
|
47
|
+
});
|
|
48
|
+
/** Orbit's new registration (the owner's): pending until the owner approves. */
|
|
49
|
+
export const createTaxRegistrationParams = z
|
|
50
|
+
.object({
|
|
51
|
+
country: z.string().regex(/^[A-Z]{2}$/),
|
|
52
|
+
state: z
|
|
53
|
+
.string()
|
|
54
|
+
.regex(/^[A-Z0-9]{1,3}$/)
|
|
55
|
+
.nullish(),
|
|
56
|
+
scheme: z.enum(TAX_REGISTRATION_SCHEMES),
|
|
57
|
+
registration_number: z.string().trim().min(1).max(64).nullish(),
|
|
58
|
+
active_from: taxInstantParam
|
|
59
|
+
.optional()
|
|
60
|
+
.describe('Unix seconds; omitted means immediately on approval.'),
|
|
61
|
+
expires_at: taxInstantParam.nullish(),
|
|
62
|
+
})
|
|
63
|
+
.strict();
|
|
64
|
+
/** Orbit's end of a registration at `expires_at`. */
|
|
65
|
+
export const endTaxRegistrationParams = z.object({ expires_at: taxInstantParam }).strict();
|
|
66
|
+
export const taxRegistrationRoutes = [
|
|
67
|
+
defineRoute({
|
|
68
|
+
operationId: 'listTaxRegistrations',
|
|
69
|
+
method: 'get',
|
|
70
|
+
path: '/v1/tax/registrations',
|
|
71
|
+
tag: 'Tax',
|
|
72
|
+
summary: 'List tax registrations',
|
|
73
|
+
description: 'Every registration of the merchant, oldest first: a complete list, `has_more` is `false`. Registrations are added and approved by the owner in Orbit.',
|
|
74
|
+
auth: 'service',
|
|
75
|
+
scope: 'payments:read',
|
|
76
|
+
response: listOf(taxRegistrationSchema),
|
|
77
|
+
sdk: 'tax.listRegistrations',
|
|
78
|
+
}),
|
|
79
|
+
];
|