@peable.to/contracts 1.2.0 → 3.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/resources/catalog/index.js +1 -5
- package/dist/cjs/resources/checkout/checkoutSessions.js +0 -4
- package/dist/cjs/resources/events/events.js +1 -32
- package/dist/cjs/resources/tax/calculations.js +33 -30
- package/dist/cjs/resources/tax/reports.js +4 -4
- package/dist/cjs/resources/tax/shared.js +7 -11
- package/dist/cjs/resources/tax/transactions.js +7 -10
- package/dist/cjs/vocabulary/catalog.js +1 -17
- package/dist/cjs/vocabulary/errors.js +0 -13
- package/dist/cjs/vocabulary/events.js +0 -1
- package/dist/esm/resources/catalog/index.js +1 -5
- package/dist/esm/resources/checkout/checkoutSessions.js +0 -4
- package/dist/esm/resources/events/events.js +0 -31
- package/dist/esm/resources/tax/calculations.js +29 -26
- package/dist/esm/resources/tax/reports.js +6 -6
- package/dist/esm/resources/tax/shared.js +6 -10
- package/dist/esm/resources/tax/transactions.js +8 -11
- package/dist/esm/vocabulary/catalog.js +0 -16
- package/dist/esm/vocabulary/errors.js +0 -13
- package/dist/esm/vocabulary/events.js +0 -1
- package/dist/types/resources/catalog/index.d.ts +1 -851
- package/dist/types/resources/checkout/checkoutSessions.d.ts +13 -61
- package/dist/types/resources/checkout/index.d.ts +10 -46
- package/dist/types/resources/events/events.d.ts +0 -22
- package/dist/types/resources/events/index.d.ts +2 -15
- package/dist/types/resources/events/webhookDeliveries.d.ts +0 -3
- package/dist/types/resources/events/webhookEndpoints.d.ts +4 -16
- package/dist/types/resources/payments/index.d.ts +10 -10
- package/dist/types/resources/payments/paymentIntents.d.ts +10 -10
- package/dist/types/resources/payments/testHelpers.d.ts +1 -1
- package/dist/types/resources/tax/calculations.d.ts +37 -37
- package/dist/types/resources/tax/index.d.ts +57 -57
- package/dist/types/resources/tax/registrations.d.ts +2 -2
- package/dist/types/resources/tax/reports.d.ts +6 -6
- package/dist/types/resources/tax/shared.d.ts +6 -7
- package/dist/types/resources/tax/transactions.d.ts +61 -61
- package/dist/types/vocabulary/catalog.d.ts +0 -9
- package/dist/types/vocabulary/errors.d.ts +0 -13
- package/dist/types/vocabulary/events.d.ts +0 -1
- package/package.json +1 -1
- package/dist/cjs/resources/catalog/billing.js +0 -755
- package/dist/esm/resources/catalog/billing.js +0 -752
- package/dist/types/resources/catalog/billing.d.ts +0 -1723
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
2
|
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
3
3
|
import { queryUnixSeconds } from '../../common/params.js';
|
|
4
|
-
import { nullableString, unixSeconds } from '../../common/primitives.js';
|
|
4
|
+
import { nullableString, signedAmount, unixSeconds } from '../../common/primitives.js';
|
|
5
5
|
import { defineRoute } from '../../route.js';
|
|
6
6
|
import { TAX_COLLECTIONS, TAX_REGISTRATION_SCHEMES } from '../../vocabulary/tax.js';
|
|
7
|
-
import { taxCountry,
|
|
7
|
+
import { taxCountry, taxState } from './shared.js';
|
|
8
8
|
/**
|
|
9
9
|
* The Peable Tax summary report: totals per jurisdiction, registration, tax
|
|
10
10
|
* type and rate — the lines a return (an OSS return, a state filing) is
|
|
@@ -23,8 +23,8 @@ export const taxReportRowSchema = defineComponent('TaxReportRow', z
|
|
|
23
23
|
currency: z.string().describe('Uppercase ISO 4217.'),
|
|
24
24
|
transactions: z.number().int().nonnegative(),
|
|
25
25
|
reversals: z.number().int().nonnegative().describe('Reversals netted into this row.'),
|
|
26
|
-
taxable_amount:
|
|
27
|
-
tax_amount:
|
|
26
|
+
taxable_amount: signedAmount,
|
|
27
|
+
tax_amount: signedAmount,
|
|
28
28
|
})
|
|
29
29
|
.strict());
|
|
30
30
|
export const taxReportSchema = defineObject('tax.report', 'TaxReport', z
|
|
@@ -52,8 +52,8 @@ export const taxReportSchema = defineObject('tax.report', 'TaxReport', z
|
|
|
52
52
|
currency: 'EUR',
|
|
53
53
|
transactions: 42,
|
|
54
54
|
reversals: 1,
|
|
55
|
-
taxable_amount: 41000,
|
|
56
|
-
tax_amount: 7790,
|
|
55
|
+
taxable_amount: '41000',
|
|
56
|
+
tax_amount: '7790',
|
|
57
57
|
},
|
|
58
58
|
],
|
|
59
59
|
},
|
|
@@ -4,11 +4,12 @@ import { unixSecondsParam } from '../../common/params.js';
|
|
|
4
4
|
/**
|
|
5
5
|
* Building blocks every Peable Tax resource shares.
|
|
6
6
|
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
*
|
|
7
|
+
* Every tax amount — a calculation's, a transaction's, a reversal's, a report
|
|
8
|
+
* row's, a compliance measure's — is a base-unit integer STRING of its
|
|
9
|
+
* `currency`, as ADR 0014 D1 has it for every amount on the wire: `amount`
|
|
10
|
+
* where it cannot be negative, `signedAmount` where a reversal makes it so
|
|
11
|
+
* (a line item and its breakdown carry a reversal's negative share, and a
|
|
12
|
+
* report row nets them in).
|
|
12
13
|
*/
|
|
13
14
|
/** ISO 3166-1 alpha-2, as returned. */
|
|
14
15
|
export const taxCountry = z.string().describe('ISO 3166-1 alpha-2.');
|
|
@@ -17,11 +18,6 @@ export const taxState = z
|
|
|
17
18
|
.string()
|
|
18
19
|
.nullable()
|
|
19
20
|
.describe('ISO 3166-2 subdivision without the country prefix (`CA`, `QC`).');
|
|
20
|
-
/** A minor-unit integer amount (cents), signed: a reversal's amounts are negative. */
|
|
21
|
-
export const taxMinorAmount = z
|
|
22
|
-
.number()
|
|
23
|
-
.int()
|
|
24
|
-
.describe('Minor units of `currency` (cents), as an integer.');
|
|
25
21
|
/** A Peable-side reference: a product, a customer, a refund. */
|
|
26
22
|
export const taxReferenceParam = z
|
|
27
23
|
.string()
|
|
@@ -2,11 +2,11 @@ import { z } from 'zod';
|
|
|
2
2
|
import { listOf } from '../../common/envelopes.js';
|
|
3
3
|
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
4
4
|
import { listQuery } from '../../common/params.js';
|
|
5
|
-
import { nullableString, unixSeconds } from '../../common/primitives.js';
|
|
5
|
+
import { nullableString, signedAmount, unixSeconds } from '../../common/primitives.js';
|
|
6
6
|
import { defineRoute } from '../../route.js';
|
|
7
7
|
import { TAX_TRANSACTION_TYPES } from '../../vocabulary/tax.js';
|
|
8
|
+
import { baseUnitAmountParam } from '../catalog/shared.js';
|
|
8
9
|
import { taxCalculationLineItemSchema, taxCalculationSchema } from './calculations.js';
|
|
9
|
-
import { taxMinorAmount } from './shared.js';
|
|
10
10
|
/**
|
|
11
11
|
* A tax transaction (`taxtxn_…`, ADR 0011/0013): a calculation that was paid,
|
|
12
12
|
* created by Peable when the payment it priced is accepted on its rail. The
|
|
@@ -21,9 +21,9 @@ import { taxMinorAmount } from './shared.js';
|
|
|
21
21
|
*/
|
|
22
22
|
export const taxTransactionReversalSchema = defineComponent('TaxTransactionReversal', z
|
|
23
23
|
.object({
|
|
24
|
-
amount_total:
|
|
25
|
-
amount_net:
|
|
26
|
-
tax_amount:
|
|
24
|
+
amount_total: signedAmount,
|
|
25
|
+
amount_net: signedAmount,
|
|
26
|
+
tax_amount: signedAmount,
|
|
27
27
|
line_items: z.array(taxCalculationLineItemSchema),
|
|
28
28
|
})
|
|
29
29
|
.strict());
|
|
@@ -56,13 +56,10 @@ export const createTaxReversalParams = z
|
|
|
56
56
|
.max(200)
|
|
57
57
|
.regex(/^[A-Za-z0-9_.:-]+$/)
|
|
58
58
|
.describe("The refund's own reference; a repeated reference returns the same reversal."),
|
|
59
|
-
amount:
|
|
60
|
-
.
|
|
61
|
-
.int()
|
|
62
|
-
.positive()
|
|
63
|
-
.safe()
|
|
59
|
+
amount: baseUnitAmountParam
|
|
60
|
+
.refine((value) => value !== '0', 'must be positive')
|
|
64
61
|
.optional()
|
|
65
|
-
.describe('Gross
|
|
62
|
+
.describe('Gross base units refunded (what the payer got back). Omitted: everything not yet reversed.'),
|
|
66
63
|
})
|
|
67
64
|
.strict();
|
|
68
65
|
export const taxTransactionRoutes = [
|
|
@@ -87,20 +87,4 @@ export const BILLING_SETTINGS_LIMITS = Object.freeze({
|
|
|
87
87
|
/** How a meter combines a period's events into the quantity billed. */
|
|
88
88
|
export const METER_AGGREGATIONS = ['sum', 'count', 'last'];
|
|
89
89
|
export const METER_STATUSES = ['active', 'inactive'];
|
|
90
|
-
// ---- Recurring billing transport (`/v1/billing/*`) ---------------------------
|
|
91
|
-
/** A provider subscription's status, as the recurring transport observes it. */
|
|
92
|
-
export const BILLING_SUBSCRIPTION_STATUSES = [
|
|
93
|
-
'incomplete',
|
|
94
|
-
'incomplete_expired',
|
|
95
|
-
'trialing',
|
|
96
|
-
'active',
|
|
97
|
-
'past_due',
|
|
98
|
-
'canceled',
|
|
99
|
-
'unpaid',
|
|
100
|
-
'paused',
|
|
101
|
-
];
|
|
102
|
-
/** `fiat` (Stripe and any further provider) or `faircoin` (native, to the merchant's watch-only wallet). */
|
|
103
|
-
export const BILLING_RAIL_SETTLEMENTS = ['fiat', 'faircoin'];
|
|
104
|
-
/** `automatic`: the provider charges each period. `payer_initiated`: each period is an explicit payment. */
|
|
105
|
-
export const BILLING_RAIL_RENEWALS = ['automatic', 'payer_initiated'];
|
|
106
90
|
// Product tax codes are Peable Tax's vocabulary: `vocabulary/tax.ts` (`TAX_CODES`).
|
|
@@ -42,19 +42,15 @@ export const ERROR_CODE_DESCRIPTIONS = {
|
|
|
42
42
|
account_invalid: 'The `Peable-Account` header names no connected account of this platform.',
|
|
43
43
|
account_missing: 'The merchant has no account object yet.',
|
|
44
44
|
amount_not_representable: 'The amount does not fit the currency or the rail.',
|
|
45
|
-
billing_not_enabled: 'Billing is not enabled for this merchant.',
|
|
46
|
-
billing_provider_unavailable: 'The billing provider could not be reached; retry.',
|
|
47
45
|
domain_taken: 'The domain is already registered by another merchant.',
|
|
48
46
|
file_too_large: 'The uploaded file is larger than its purpose allows.',
|
|
49
47
|
file_unavailable: 'The file exists but its contents cannot be served right now.',
|
|
50
48
|
idempotency_error: 'The `Idempotency-Key` was used with a different request, or its first request is still running.',
|
|
51
49
|
idempotency_key_invalid: 'The `Idempotency-Key` header is not a valid key.',
|
|
52
50
|
insufficient_scope: 'The credential is valid but was not granted the Oxy scope this route requires (`payments:read`, `payments:write`, …); `message` names it.',
|
|
53
|
-
invalid_billing_request: 'The billing request is not valid for this subscription or offer.',
|
|
54
51
|
keyless_recipient: 'The recipient has no receive key, so no address can be derived for them.',
|
|
55
52
|
link_not_found: 'The link does not exist or is no longer active.',
|
|
56
53
|
live_payments_gated: 'Live payments are not enabled for this application yet.',
|
|
57
|
-
local_test_request_required: 'This test helper only answers a local test request.',
|
|
58
54
|
parameter_invalid: 'A parameter is invalid; `param` names it.',
|
|
59
55
|
parameter_missing: 'A required parameter is missing; `param` names it.',
|
|
60
56
|
parameter_unknown: 'The request carries a parameter this route does not accept; `param` names it.',
|
|
@@ -83,10 +79,7 @@ export const ERROR_CODE_DESCRIPTIONS = {
|
|
|
83
79
|
customer_location_invalid: "The tax provider could not use the customer's location.",
|
|
84
80
|
dispute_already_submitted: 'Evidence for this dispute has already been submitted; it is one shot.',
|
|
85
81
|
dispute_not_answerable: 'The dispute is in a status that no longer accepts evidence.',
|
|
86
|
-
idempotency_conflict: 'The same operation key was used for a different billing request.',
|
|
87
|
-
identity_conflict: 'The billing identity already belongs to another customer or subscription.',
|
|
88
82
|
in_progress: 'The same operation is still running; retry with the same key.',
|
|
89
|
-
invalid_provider_response: 'The provider answered with something Peable cannot trust; the operation was not applied.',
|
|
90
83
|
invalid_registration: 'The tax registration is not valid.',
|
|
91
84
|
invalid_registration_declaration: 'The tax registration declaration is not valid.',
|
|
92
85
|
invalid_tax_code: 'The tax code does not exist.',
|
|
@@ -101,12 +94,9 @@ export const ERROR_CODE_DESCRIPTIONS = {
|
|
|
101
94
|
product_in_use: 'The product is referenced by a subscription or a link.',
|
|
102
95
|
promotion_code_invalid: 'The promotion code does not exist, is inactive or does not apply.',
|
|
103
96
|
promotion_code_taken: 'Another active promotion code already uses this `code`.',
|
|
104
|
-
provider_unavailable: 'The payment provider could not be reached; retry.',
|
|
105
97
|
rail_unavailable: 'The payment rail this request needs is not available.',
|
|
106
|
-
reconciliation_required: 'The billing operation has an unknown outcome at the provider and is being reconciled.',
|
|
107
98
|
registration_immutable: 'An approved or ended tax registration cannot be deleted or changed this way; end it instead.',
|
|
108
99
|
resource_already_exists: 'An object with this identity already exists.',
|
|
109
|
-
result_expired: 'The stored result of this operation has expired.',
|
|
110
100
|
review_item_not_open: 'The review item is already resolved or dismissed.',
|
|
111
101
|
rule_set_version_unavailable: 'The tax rule set version is not available.',
|
|
112
102
|
subscription_line_invalid: 'A subscription line item is not valid for Checkout.',
|
|
@@ -114,9 +104,6 @@ export const ERROR_CODE_DESCRIPTIONS = {
|
|
|
114
104
|
tax_calculation_unavailable: 'Tax could not be calculated; a covered sale fails closed.',
|
|
115
105
|
tax_provider_registration_mismatch: "The provider's registrations disagree with the ones Peable has approved.",
|
|
116
106
|
tax_settings_not_active: 'Tax settings are not active for this merchant.',
|
|
117
|
-
local_test_unavailable: 'The local test checkout is not available.',
|
|
118
|
-
local_test_configuration_unavailable: 'The local test checkout has no provider configuration.',
|
|
119
|
-
local_test_subscription_unavailable: 'The local test subscription cannot be read.',
|
|
120
107
|
rail_mismatch: 'The operation does not apply to the rail this payment uses.',
|
|
121
108
|
checkout_session_changed: 'The Checkout Session changed while this request ran (a price, a discount, its tax); read it again and retry.',
|
|
122
109
|
checkout_session_locked: 'The Checkout Session is being confirmed and cannot change.',
|
|
@@ -58,7 +58,6 @@ export const WEBHOOK_EVENT_OBJECTS = {
|
|
|
58
58
|
'setup_intent.succeeded': 'setup_intent',
|
|
59
59
|
'setup_intent.setup_failed': 'setup_intent',
|
|
60
60
|
'setup_intent.canceled': 'setup_intent',
|
|
61
|
-
'billing.observation.updated': 'billing_observation',
|
|
62
61
|
'connected_account.updated': 'connected_account',
|
|
63
62
|
'product.created': 'product',
|
|
64
63
|
'product.updated': 'product',
|