@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,368 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.quantityParam = exports.adjustableQuantityParam = exports.collectionParams = exports.customFieldsParam = exports.checkoutEmailParam = exports.localeParam = exports.redirectUrlParam = exports.amountParam = exports.countryCodeParam = exports.checkoutIdParam = exports.checkoutBrandingSchema = exports.merchantDisplaySchema = exports.collectionResponseFields = exports.checkoutConsentSchema = exports.checkoutConsentCollectionSchema = exports.checkoutAutomaticTaxSchema = exports.checkoutTotalDetailsSchema = exports.checkoutDiscountSchema = exports.checkoutCustomFieldSchema = exports.checkoutCustomFieldDropdownOptionSchema = exports.checkoutCustomFieldLabelSchema = exports.checkoutShippingDetailsSchema = exports.checkoutCustomerDetailsSchema = exports.checkoutTaxIdSchema = exports.checkoutLineItemSchema = exports.checkoutAdjustableQuantitySchema = exports.railSchema = void 0;
|
|
4
|
+
exports.adjustableBoundsOf = adjustableBoundsOf;
|
|
5
|
+
exports.adjustableIssues = adjustableIssues;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const payments_1 = require("../../vocabulary/payments");
|
|
8
|
+
const address_1 = require("../../common/address");
|
|
9
|
+
const objects_1 = require("../../common/objects");
|
|
10
|
+
const primitives_1 = require("../../common/primitives");
|
|
11
|
+
const checkout_1 = require("../../vocabulary/checkout");
|
|
12
|
+
const merchants_1 = require("../../vocabulary/merchants");
|
|
13
|
+
const money_1 = require("../../vocabulary/money");
|
|
14
|
+
/**
|
|
15
|
+
* What Checkout Sessions and Payment Links share: the `item` a line renders
|
|
16
|
+
* as, the collection options (address, phone, tax id, terms, custom fields),
|
|
17
|
+
* the payer-facing merchant and branding, and the request halves of those.
|
|
18
|
+
* One shape rule is written once, so a link and a session refuse the same
|
|
19
|
+
* mistake with the same `param`.
|
|
20
|
+
*/
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
// Response side
|
|
23
|
+
// ---------------------------------------------------------------------------
|
|
24
|
+
/** The payment rail: FairCoin on chain, or a card (and the methods riding on it). */
|
|
25
|
+
exports.railSchema = zod_1.z.enum(payments_1.PAYMENT_INTENT_RAILS);
|
|
26
|
+
exports.checkoutAdjustableQuantitySchema = (0, objects_1.defineComponent)('CheckoutAdjustableQuantity', zod_1.z
|
|
27
|
+
.object({
|
|
28
|
+
enabled: zod_1.z.boolean(),
|
|
29
|
+
minimum: zod_1.z.number().int().nullable().describe('Default 0 when enabled.'),
|
|
30
|
+
maximum: zod_1.z.number().int().nullable().describe('Default 99 when enabled.'),
|
|
31
|
+
})
|
|
32
|
+
.strict());
|
|
33
|
+
/** One line of a session or link — Stripe's `item`. */
|
|
34
|
+
exports.checkoutLineItemSchema = (0, objects_1.defineObject)('item', 'CheckoutLineItem', zod_1.z
|
|
35
|
+
.object({
|
|
36
|
+
id: zod_1.z.string(),
|
|
37
|
+
object: zod_1.z.literal('item'),
|
|
38
|
+
description: zod_1.z.string().describe("The product's name, or the inline `product_data.name`."),
|
|
39
|
+
price: (0, objects_1.expandable)('price', 'The catalog price (`price_…`, or the Price with `expand[]=data.price`); `null` for an inline `price_data` line, which is a snapshot on the line and never a stored price.').nullable(),
|
|
40
|
+
product: (0, objects_1.expandable)('product', 'The catalog product (`prod_…`, expandable); `null` for `product_data`.').nullable(),
|
|
41
|
+
images: zod_1.z
|
|
42
|
+
.array(zod_1.z.string())
|
|
43
|
+
.describe("Images to show beside the line (the product's, or `product_data.images`)."),
|
|
44
|
+
quantity: zod_1.z.number().int(),
|
|
45
|
+
adjustable_quantity: exports.checkoutAdjustableQuantitySchema.nullable(),
|
|
46
|
+
currency: primitives_1.currency,
|
|
47
|
+
unit_amount: primitives_1.amount
|
|
48
|
+
.nullable()
|
|
49
|
+
.describe('The per-unit amount for a per-unit price; `null` for a tiered one.'),
|
|
50
|
+
amount_subtotal: primitives_1.amount.describe('Before discount and tax.'),
|
|
51
|
+
amount_discount: primitives_1.amount,
|
|
52
|
+
amount_tax: primitives_1.amount,
|
|
53
|
+
amount_total: primitives_1.amount.describe('`amount_subtotal - amount_discount + amount_tax` (exclusive tax only).'),
|
|
54
|
+
})
|
|
55
|
+
.strict(), {
|
|
56
|
+
examples: [
|
|
57
|
+
{
|
|
58
|
+
id: 'li_0193b8f2c1a87d3e9f4a',
|
|
59
|
+
object: 'item',
|
|
60
|
+
description: 'Pro plan',
|
|
61
|
+
price: 'price_0193b8f2c1a87d3e9f4b',
|
|
62
|
+
product: 'prod_0193b8f2c1a87d3e9f4c',
|
|
63
|
+
images: [],
|
|
64
|
+
quantity: 1,
|
|
65
|
+
adjustable_quantity: null,
|
|
66
|
+
currency: 'EUR',
|
|
67
|
+
unit_amount: '1999',
|
|
68
|
+
amount_subtotal: '1999',
|
|
69
|
+
amount_discount: '0',
|
|
70
|
+
amount_tax: '0',
|
|
71
|
+
amount_total: '1999',
|
|
72
|
+
},
|
|
73
|
+
],
|
|
74
|
+
});
|
|
75
|
+
exports.checkoutTaxIdSchema = (0, objects_1.defineComponent)('CheckoutTaxId', zod_1.z.object({ type: zod_1.z.enum(checkout_1.CHECKOUT_TAX_ID_TYPES), value: zod_1.z.string() }).strict());
|
|
76
|
+
/** What the payer told checkout about themselves — Stripe's `customer_details`. */
|
|
77
|
+
exports.checkoutCustomerDetailsSchema = (0, objects_1.defineComponent)('CheckoutCustomerDetails', zod_1.z
|
|
78
|
+
.object({
|
|
79
|
+
email: zod_1.z.string().nullable(),
|
|
80
|
+
name: zod_1.z.string().nullable(),
|
|
81
|
+
phone: zod_1.z.string().nullable(),
|
|
82
|
+
address: address_1.addressSchema.nullable(),
|
|
83
|
+
tax_ids: zod_1.z.array(exports.checkoutTaxIdSchema),
|
|
84
|
+
})
|
|
85
|
+
.strict());
|
|
86
|
+
exports.checkoutShippingDetailsSchema = (0, objects_1.defineComponent)('CheckoutShippingDetails', zod_1.z.object({ name: zod_1.z.string(), address: address_1.addressSchema }).strict());
|
|
87
|
+
exports.checkoutCustomFieldLabelSchema = zod_1.z
|
|
88
|
+
.object({ type: zod_1.z.literal('custom'), custom: zod_1.z.string() })
|
|
89
|
+
.strict();
|
|
90
|
+
exports.checkoutCustomFieldDropdownOptionSchema = zod_1.z
|
|
91
|
+
.object({ label: zod_1.z.string(), value: zod_1.z.string() })
|
|
92
|
+
.strict();
|
|
93
|
+
const customFieldBounds = zod_1.z
|
|
94
|
+
.object({
|
|
95
|
+
minimum_length: zod_1.z.number().int().nullable(),
|
|
96
|
+
maximum_length: zod_1.z.number().int().nullable(),
|
|
97
|
+
value: zod_1.z.string().nullable().describe('What the payer entered.'),
|
|
98
|
+
})
|
|
99
|
+
.strict();
|
|
100
|
+
/** A merchant-defined field the payer fills in; `value`s are what they entered. */
|
|
101
|
+
exports.checkoutCustomFieldSchema = (0, objects_1.defineComponent)('CheckoutCustomField', zod_1.z
|
|
102
|
+
.object({
|
|
103
|
+
key: zod_1.z.string(),
|
|
104
|
+
label: exports.checkoutCustomFieldLabelSchema,
|
|
105
|
+
type: zod_1.z.enum(checkout_1.CHECKOUT_CUSTOM_FIELD_TYPES),
|
|
106
|
+
optional: zod_1.z.boolean(),
|
|
107
|
+
dropdown: zod_1.z
|
|
108
|
+
.object({
|
|
109
|
+
options: zod_1.z.array(exports.checkoutCustomFieldDropdownOptionSchema),
|
|
110
|
+
value: zod_1.z.string().nullable(),
|
|
111
|
+
})
|
|
112
|
+
.strict()
|
|
113
|
+
.nullable(),
|
|
114
|
+
text: customFieldBounds.nullable(),
|
|
115
|
+
numeric: customFieldBounds.nullable(),
|
|
116
|
+
})
|
|
117
|
+
.strict());
|
|
118
|
+
exports.checkoutDiscountSchema = (0, objects_1.defineComponent)('CheckoutDiscount', zod_1.z
|
|
119
|
+
.object({
|
|
120
|
+
coupon: zod_1.z.string().describe('The coupon applied (merchant-chosen id or `coupon_…`).'),
|
|
121
|
+
promotion_code: zod_1.z
|
|
122
|
+
.string()
|
|
123
|
+
.nullable()
|
|
124
|
+
.describe('The promotion code it was redeemed through (`promo_…`), or `null`.'),
|
|
125
|
+
})
|
|
126
|
+
.strict());
|
|
127
|
+
exports.checkoutTotalDetailsSchema = (0, objects_1.defineComponent)('CheckoutTotalDetails', zod_1.z.object({ amount_discount: primitives_1.amount, amount_tax: primitives_1.amount, amount_shipping: primitives_1.amount }).strict());
|
|
128
|
+
/**
|
|
129
|
+
* `automatic_tax` — Peable Tax (ADR 0011). `requires_location_inputs` until
|
|
130
|
+
* the payer gave an address Peable Tax can locate them with; `failed` when the
|
|
131
|
+
* sale is covered and could not be priced (checkout refuses to proceed: tax
|
|
132
|
+
* fails CLOSED, never zero).
|
|
133
|
+
*/
|
|
134
|
+
exports.checkoutAutomaticTaxSchema = (0, objects_1.defineComponent)('CheckoutAutomaticTax', zod_1.z
|
|
135
|
+
.object({
|
|
136
|
+
enabled: zod_1.z.boolean(),
|
|
137
|
+
status: zod_1.z.enum(['complete', 'requires_location_inputs', 'failed']).nullable(),
|
|
138
|
+
})
|
|
139
|
+
.strict());
|
|
140
|
+
exports.checkoutConsentCollectionSchema = zod_1.z
|
|
141
|
+
.object({ terms_of_service: zod_1.z.enum(['none', 'required']) })
|
|
142
|
+
.strict();
|
|
143
|
+
exports.checkoutConsentSchema = zod_1.z
|
|
144
|
+
.object({ terms_of_service: zod_1.z.literal('accepted').nullable() })
|
|
145
|
+
.strict();
|
|
146
|
+
/** The collection options, as a session or link reports them. */
|
|
147
|
+
exports.collectionResponseFields = {
|
|
148
|
+
billing_address_collection: zod_1.z.enum(checkout_1.CHECKOUT_BILLING_ADDRESS_COLLECTIONS),
|
|
149
|
+
shipping_address_collection: zod_1.z
|
|
150
|
+
.object({ allowed_countries: zod_1.z.array(zod_1.z.string()) })
|
|
151
|
+
.strict()
|
|
152
|
+
.nullable(),
|
|
153
|
+
phone_number_collection: zod_1.z.object({ enabled: zod_1.z.boolean() }).strict(),
|
|
154
|
+
tax_id_collection: zod_1.z.object({ enabled: zod_1.z.boolean() }).strict(),
|
|
155
|
+
custom_fields: zod_1.z.array(exports.checkoutCustomFieldSchema),
|
|
156
|
+
consent_collection: exports.checkoutConsentCollectionSchema.nullable(),
|
|
157
|
+
};
|
|
158
|
+
/** The public, secret-free merchant identity a payer surface renders. */
|
|
159
|
+
exports.merchantDisplaySchema = (0, objects_1.defineComponent)('MerchantDisplay', zod_1.z
|
|
160
|
+
.object({
|
|
161
|
+
name: zod_1.z.string().describe("The merchant's display name, or a neutral fallback when unset."),
|
|
162
|
+
avatar_url: zod_1.z
|
|
163
|
+
.string()
|
|
164
|
+
.nullable()
|
|
165
|
+
.describe('Resolved server-side; `null` when the merchant has no avatar.'),
|
|
166
|
+
logo_url: zod_1.z
|
|
167
|
+
.string()
|
|
168
|
+
.nullable()
|
|
169
|
+
.describe("The merchant's `business_logo`, resolved; `null` when unset or not served."),
|
|
170
|
+
description: zod_1.z.string().nullable(),
|
|
171
|
+
})
|
|
172
|
+
.strict());
|
|
173
|
+
/**
|
|
174
|
+
* Branding as a payer surface renders it: every field resolved (defaults
|
|
175
|
+
* filled in), the logo and icon as URLs the gateway built through Oxy's media
|
|
176
|
+
* chokepoint — a withheld file is `null`, never a broken image.
|
|
177
|
+
*/
|
|
178
|
+
exports.checkoutBrandingSchema = (0, objects_1.defineComponent)('CheckoutBranding', zod_1.z
|
|
179
|
+
.object({
|
|
180
|
+
icon_url: zod_1.z.string().nullable(),
|
|
181
|
+
logo_url: zod_1.z.string().nullable(),
|
|
182
|
+
primary_color: zod_1.z.string(),
|
|
183
|
+
accent_color: zod_1.z.string(),
|
|
184
|
+
font: zod_1.z.enum(merchants_1.BRANDING_FONTS),
|
|
185
|
+
border_style: zod_1.z.enum(merchants_1.BRANDING_BORDER_STYLES),
|
|
186
|
+
})
|
|
187
|
+
.strict());
|
|
188
|
+
// ---------------------------------------------------------------------------
|
|
189
|
+
// Request side
|
|
190
|
+
// ---------------------------------------------------------------------------
|
|
191
|
+
exports.checkoutIdParam = zod_1.z.string().min(1).max(255);
|
|
192
|
+
exports.countryCodeParam = zod_1.z
|
|
193
|
+
.string()
|
|
194
|
+
.regex(/^[A-Z]{2}$/, 'must be an ISO 3166-1 alpha-2 country code');
|
|
195
|
+
/** A base-unit amount in a request. */
|
|
196
|
+
exports.amountParam = zod_1.z
|
|
197
|
+
.string()
|
|
198
|
+
.regex(money_1.BASE_UNIT_PATTERN, 'must be a non-negative integer string in the smallest currency unit');
|
|
199
|
+
/**
|
|
200
|
+
* A redirect target. `https` only, except `http://localhost` for development —
|
|
201
|
+
* a payer is sent there after paying, so an `http` URL elsewhere would leak the
|
|
202
|
+
* session id in the clear. `{CHECKOUT_SESSION_ID}` may appear anywhere.
|
|
203
|
+
*/
|
|
204
|
+
exports.redirectUrlParam = zod_1.z
|
|
205
|
+
.string()
|
|
206
|
+
.max(2048)
|
|
207
|
+
.refine((value) => {
|
|
208
|
+
const probe = value.split(checkout_1.CHECKOUT_SESSION_ID_TEMPLATE).join('cs_template');
|
|
209
|
+
try {
|
|
210
|
+
const url = new URL(probe);
|
|
211
|
+
return (url.protocol === 'https:' ||
|
|
212
|
+
(url.protocol === 'http:' && (url.hostname === 'localhost' || url.hostname === '127.0.0.1')));
|
|
213
|
+
}
|
|
214
|
+
catch {
|
|
215
|
+
return false;
|
|
216
|
+
}
|
|
217
|
+
}, 'must be an https URL (http only on localhost)')
|
|
218
|
+
.describe('`https` (or `http://localhost`); may carry `{CHECKOUT_SESSION_ID}`.');
|
|
219
|
+
/** `auto` follows the payer's browser: parsed as `null`. */
|
|
220
|
+
exports.localeParam = zod_1.z
|
|
221
|
+
.enum([...checkout_1.CHECKOUT_LOCALES, 'auto'])
|
|
222
|
+
.transform((value) => (value === 'auto' ? null : value))
|
|
223
|
+
.describe("`auto` follows the payer's browser.");
|
|
224
|
+
exports.checkoutEmailParam = zod_1.z.string().trim().max(254).email('must be an email address');
|
|
225
|
+
const customFieldParam = zod_1.z
|
|
226
|
+
.object({
|
|
227
|
+
key: zod_1.z
|
|
228
|
+
.string()
|
|
229
|
+
.regex(new RegExp(`^[A-Za-z0-9_]{1,${checkout_1.CHECKOUT_LIMITS.customFieldKeyMax}}$`), 'a key is letters, digits and underscores'),
|
|
230
|
+
label: zod_1.z
|
|
231
|
+
.object({
|
|
232
|
+
type: zod_1.z.literal('custom'),
|
|
233
|
+
custom: zod_1.z.string().trim().min(1).max(checkout_1.CHECKOUT_LIMITS.customFieldLabelMax),
|
|
234
|
+
})
|
|
235
|
+
.strict(),
|
|
236
|
+
type: zod_1.z.enum(checkout_1.CHECKOUT_CUSTOM_FIELD_TYPES),
|
|
237
|
+
optional: zod_1.z.boolean().optional(),
|
|
238
|
+
dropdown: zod_1.z
|
|
239
|
+
.object({
|
|
240
|
+
options: zod_1.z
|
|
241
|
+
.array(zod_1.z
|
|
242
|
+
.object({
|
|
243
|
+
label: zod_1.z.string().trim().min(1).max(checkout_1.CHECKOUT_LIMITS.dropdownOptionLabelMax),
|
|
244
|
+
value: zod_1.z
|
|
245
|
+
.string()
|
|
246
|
+
.regex(new RegExp(`^[A-Za-z0-9]{1,${checkout_1.CHECKOUT_LIMITS.dropdownOptionValueMax}}$`), 'an option value is letters and digits'),
|
|
247
|
+
})
|
|
248
|
+
.strict())
|
|
249
|
+
.min(1)
|
|
250
|
+
.max(checkout_1.CHECKOUT_LIMITS.dropdownOptionsMax),
|
|
251
|
+
})
|
|
252
|
+
.strict()
|
|
253
|
+
.optional(),
|
|
254
|
+
text: zod_1.z
|
|
255
|
+
.object({
|
|
256
|
+
minimum_length: zod_1.z.number().int().min(1).max(checkout_1.CHECKOUT_LIMITS.customFieldTextMax).optional(),
|
|
257
|
+
maximum_length: zod_1.z.number().int().min(1).max(checkout_1.CHECKOUT_LIMITS.customFieldTextMax).optional(),
|
|
258
|
+
})
|
|
259
|
+
.strict()
|
|
260
|
+
.optional(),
|
|
261
|
+
numeric: zod_1.z
|
|
262
|
+
.object({
|
|
263
|
+
minimum_length: zod_1.z.number().int().min(1).max(checkout_1.CHECKOUT_LIMITS.customFieldTextMax).optional(),
|
|
264
|
+
maximum_length: zod_1.z.number().int().min(1).max(checkout_1.CHECKOUT_LIMITS.customFieldTextMax).optional(),
|
|
265
|
+
})
|
|
266
|
+
.strict()
|
|
267
|
+
.optional(),
|
|
268
|
+
})
|
|
269
|
+
.strict()
|
|
270
|
+
.superRefine((field, ctx) => {
|
|
271
|
+
const issue = (path, message) => ctx.addIssue({ code: 'custom', path, message });
|
|
272
|
+
if (field.type === 'dropdown' && !field.dropdown) {
|
|
273
|
+
issue(['dropdown'], 'a dropdown field needs dropdown.options');
|
|
274
|
+
}
|
|
275
|
+
if (field.type !== 'dropdown' && field.dropdown) {
|
|
276
|
+
issue(['dropdown'], 'dropdown is only for a dropdown field');
|
|
277
|
+
}
|
|
278
|
+
if (field.type !== 'text' && field.text)
|
|
279
|
+
issue(['text'], 'text is only for a text field');
|
|
280
|
+
if (field.type !== 'numeric' && field.numeric) {
|
|
281
|
+
issue(['numeric'], 'numeric is only for a numeric field');
|
|
282
|
+
}
|
|
283
|
+
const bounds = field.text ?? field.numeric;
|
|
284
|
+
if (bounds?.minimum_length !== undefined &&
|
|
285
|
+
bounds.maximum_length !== undefined &&
|
|
286
|
+
bounds.minimum_length > bounds.maximum_length) {
|
|
287
|
+
issue([field.type, 'minimum_length'], 'minimum_length cannot exceed maximum_length');
|
|
288
|
+
}
|
|
289
|
+
if (field.dropdown) {
|
|
290
|
+
const values = field.dropdown.options.map((option) => option.value);
|
|
291
|
+
if (new Set(values).size !== values.length) {
|
|
292
|
+
issue(['dropdown', 'options'], 'option values must be unique');
|
|
293
|
+
}
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
/** At most three, keys unique. */
|
|
297
|
+
exports.customFieldsParam = zod_1.z
|
|
298
|
+
.array(customFieldParam)
|
|
299
|
+
.max(checkout_1.CHECKOUT_LIMITS.customFieldsMax)
|
|
300
|
+
.superRefine((fields, ctx) => {
|
|
301
|
+
const keys = fields.map((field) => field.key);
|
|
302
|
+
if (new Set(keys).size !== keys.length) {
|
|
303
|
+
ctx.addIssue({ code: 'custom', message: 'custom field keys must be unique' });
|
|
304
|
+
}
|
|
305
|
+
});
|
|
306
|
+
/** The collection options, as a request names them — shared by sessions and links. */
|
|
307
|
+
exports.collectionParams = {
|
|
308
|
+
billing_address_collection: zod_1.z.enum(checkout_1.CHECKOUT_BILLING_ADDRESS_COLLECTIONS).optional(),
|
|
309
|
+
shipping_address_collection: zod_1.z
|
|
310
|
+
.object({
|
|
311
|
+
allowed_countries: zod_1.z.array(exports.countryCodeParam).min(1).max(checkout_1.CHECKOUT_LIMITS.shippingCountriesMax),
|
|
312
|
+
})
|
|
313
|
+
.strict()
|
|
314
|
+
.optional(),
|
|
315
|
+
phone_number_collection: zod_1.z.object({ enabled: zod_1.z.boolean() }).strict().optional(),
|
|
316
|
+
tax_id_collection: zod_1.z.object({ enabled: zod_1.z.boolean() }).strict().optional(),
|
|
317
|
+
consent_collection: zod_1.z
|
|
318
|
+
.object({ terms_of_service: zod_1.z.enum(['none', 'required']).optional() })
|
|
319
|
+
.strict()
|
|
320
|
+
.optional(),
|
|
321
|
+
custom_fields: exports.customFieldsParam.optional(),
|
|
322
|
+
};
|
|
323
|
+
exports.adjustableQuantityParam = zod_1.z
|
|
324
|
+
.object({
|
|
325
|
+
enabled: zod_1.z.boolean(),
|
|
326
|
+
minimum: zod_1.z.number().int().min(0).max(checkout_1.CHECKOUT_LIMITS.quantityMax).optional(),
|
|
327
|
+
maximum: zod_1.z.number().int().min(1).max(checkout_1.CHECKOUT_LIMITS.quantityMax).optional(),
|
|
328
|
+
})
|
|
329
|
+
.strict();
|
|
330
|
+
exports.quantityParam = zod_1.z.number().int().min(1).max(checkout_1.CHECKOUT_LIMITS.quantityMax);
|
|
331
|
+
/** Stripe's defaults: 0–99 when enabled. */
|
|
332
|
+
function adjustableBoundsOf(adjustable) {
|
|
333
|
+
if (!adjustable?.enabled)
|
|
334
|
+
return null;
|
|
335
|
+
return { minimum: adjustable.minimum ?? 0, maximum: adjustable.maximum ?? 99 };
|
|
336
|
+
}
|
|
337
|
+
/** The refusals of a line's `quantity` against its `adjustable_quantity`. */
|
|
338
|
+
function adjustableIssues(quantity, adjustable, ctx) {
|
|
339
|
+
if (!adjustable)
|
|
340
|
+
return;
|
|
341
|
+
if (!adjustable.enabled) {
|
|
342
|
+
if (adjustable.minimum !== undefined || adjustable.maximum !== undefined) {
|
|
343
|
+
ctx.addIssue({
|
|
344
|
+
code: 'custom',
|
|
345
|
+
path: ['adjustable_quantity', 'enabled'],
|
|
346
|
+
message: 'minimum and maximum need adjustable_quantity.enabled',
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
return;
|
|
350
|
+
}
|
|
351
|
+
const bounds = adjustableBoundsOf(adjustable);
|
|
352
|
+
if (!bounds)
|
|
353
|
+
return;
|
|
354
|
+
if (bounds.minimum > bounds.maximum) {
|
|
355
|
+
ctx.addIssue({
|
|
356
|
+
code: 'custom',
|
|
357
|
+
path: ['adjustable_quantity', 'minimum'],
|
|
358
|
+
message: 'minimum cannot exceed maximum',
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
else if (quantity < bounds.minimum || quantity > bounds.maximum) {
|
|
362
|
+
ctx.addIssue({
|
|
363
|
+
code: 'custom',
|
|
364
|
+
path: ['quantity'],
|
|
365
|
+
message: `quantity must be between ${bounds.minimum} and ${bounds.maximum}`,
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
}
|