@peable.to/contracts 0.4.0 → 1.1.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/dashboard.js +68 -0
- package/dist/cjs/vocabulary/errors.js +175 -0
- package/dist/cjs/vocabulary/events.js +176 -0
- package/dist/cjs/vocabulary/files.js +44 -0
- package/dist/cjs/vocabulary/identity.js +12 -0
- package/dist/cjs/vocabulary/index.js +39 -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/dashboard.js +64 -0
- package/dist/esm/vocabulary/errors.js +170 -0
- package/dist/esm/vocabulary/events.js +173 -0
- package/dist/esm/vocabulary/files.js +41 -0
- package/dist/esm/vocabulary/identity.js +9 -0
- package/dist/esm/vocabulary/index.js +23 -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/dashboard.d.ts +44 -0
- package/dist/types/vocabulary/errors.d.ts +146 -0
- package/dist/types/vocabulary/events.d.ts +171 -0
- package/dist/types/vocabulary/files.d.ts +30 -0
- package/dist/types/vocabulary/identity.d.ts +9 -0
- package/dist/types/vocabulary/index.d.ts +19 -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,582 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.checkoutSessionRoutes = exports.expireCheckoutSessionTestHelperParams = exports.confirmCheckoutSessionPublicParams = exports.updateCheckoutSessionPublicParams = exports.listCheckoutSessionLineItemsQuery = exports.listCheckoutSessionsQuery = exports.expireCheckoutSessionParams = exports.updateCheckoutSessionParams = exports.createCheckoutSessionParams = exports.sessionLineItemParams = exports.checkoutSessionPublicSchema = exports.checkoutSessionSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const catalog_1 = require("../../vocabulary/catalog");
|
|
6
|
+
const payments_1 = require("../../vocabulary/payments");
|
|
7
|
+
const billing_1 = require("../catalog/billing");
|
|
8
|
+
const objects_1 = require("../../common/objects");
|
|
9
|
+
const envelopes_1 = require("../../common/envelopes");
|
|
10
|
+
const objects_2 = require("../../common/objects");
|
|
11
|
+
const params_1 = require("../../common/params");
|
|
12
|
+
const primitives_1 = require("../../common/primitives");
|
|
13
|
+
const route_1 = require("../../route");
|
|
14
|
+
const checkout_1 = require("../../vocabulary/checkout");
|
|
15
|
+
const shared_1 = require("./shared");
|
|
16
|
+
/**
|
|
17
|
+
* Checkout Sessions (`cs_…`, Orbit Phase 3) — Stripe Checkout's session model:
|
|
18
|
+
* a session is an ORDER (line items, discounts, tax, what to collect from the
|
|
19
|
+
* payer) that a payer completes on Peable's hosted or embedded checkout. The
|
|
20
|
+
* PaymentIntent (or SetupIntent) is created when the payer confirms, with the
|
|
21
|
+
* amount the session computed, and linked. Amounts are base-unit strings.
|
|
22
|
+
*/
|
|
23
|
+
const sessionFields = {
|
|
24
|
+
id: zod_1.z.string(),
|
|
25
|
+
object: zod_1.z.literal('checkout_session'),
|
|
26
|
+
livemode: primitives_1.livemode,
|
|
27
|
+
mode: zod_1.z.enum(checkout_1.CHECKOUT_SESSION_MODES),
|
|
28
|
+
status: zod_1.z.enum(checkout_1.CHECKOUT_SESSION_STATUSES),
|
|
29
|
+
payment_status: zod_1.z.enum(checkout_1.CHECKOUT_PAYMENT_STATUSES),
|
|
30
|
+
ui_mode: zod_1.z.enum(checkout_1.CHECKOUT_UI_MODES),
|
|
31
|
+
locale: zod_1.z
|
|
32
|
+
.enum(checkout_1.CHECKOUT_LOCALES)
|
|
33
|
+
.nullable()
|
|
34
|
+
.describe("The language checkout renders in; `null` follows the payer's browser."),
|
|
35
|
+
submit_type: zod_1.z.enum(checkout_1.CHECKOUT_SUBMIT_TYPES),
|
|
36
|
+
currency: primitives_1.currency,
|
|
37
|
+
rail: shared_1.railSchema,
|
|
38
|
+
network: primitives_1.network.nullable().describe('FairCoin rail only; `null` on a card session.'),
|
|
39
|
+
amount_subtotal: primitives_1.amount,
|
|
40
|
+
amount_total: primitives_1.amount,
|
|
41
|
+
total_details: shared_1.checkoutTotalDetailsSchema,
|
|
42
|
+
allow_promotion_codes: zod_1.z.boolean(),
|
|
43
|
+
automatic_tax: shared_1.checkoutAutomaticTaxSchema,
|
|
44
|
+
...shared_1.collectionResponseFields,
|
|
45
|
+
shipping_details: shared_1.checkoutShippingDetailsSchema.nullable(),
|
|
46
|
+
consent: shared_1.checkoutConsentSchema.nullable(),
|
|
47
|
+
expires_at: primitives_1.unixSeconds,
|
|
48
|
+
};
|
|
49
|
+
/** The merchant/SDK-facing session — Stripe's Checkout Session. */
|
|
50
|
+
exports.checkoutSessionSchema = (0, objects_2.defineObject)('checkout_session', 'CheckoutSession', zod_1.z
|
|
51
|
+
.object({
|
|
52
|
+
...sessionFields,
|
|
53
|
+
payment_method_types: zod_1.z.array(shared_1.railSchema),
|
|
54
|
+
discounts: zod_1.z.array(shared_1.checkoutDiscountSchema),
|
|
55
|
+
customer: (0, objects_2.expandable)('customer', '`cus_…` (expandable) — given on create, or created at completion.').nullable(),
|
|
56
|
+
customer_email: zod_1.z.string().nullable(),
|
|
57
|
+
customer_creation: zod_1.z.enum(checkout_1.CHECKOUT_CUSTOMER_CREATIONS),
|
|
58
|
+
customer_details: shared_1.checkoutCustomerDetailsSchema.nullable(),
|
|
59
|
+
payment_intent: (0, objects_2.expandable)('payment_intent', 'The payment this session created (`pi_…`, expandable) once the payer confirmed; `null` before, and always in `setup` mode.').nullable(),
|
|
60
|
+
setup_intent: (0, objects_2.expandable)('setup_intent', '`setup` mode: the SetupIntent (`seti_…`, expandable) once confirmed.').nullable(),
|
|
61
|
+
connected_account: (0, objects_2.expandable)('connected_account', 'The seller an on-behalf payment pays (`ca_…`, expandable).').nullable(),
|
|
62
|
+
payment_link: zod_1.z
|
|
63
|
+
.string()
|
|
64
|
+
.nullable()
|
|
65
|
+
.describe('The payment link this session was created from (`link_…`), if any.'),
|
|
66
|
+
client_reference_id: zod_1.z.string().nullable(),
|
|
67
|
+
metadata: primitives_1.metadata,
|
|
68
|
+
success_url: zod_1.z
|
|
69
|
+
.string()
|
|
70
|
+
.nullable()
|
|
71
|
+
.describe('With `{CHECKOUT_SESSION_ID}` as given; checkout substitutes it.'),
|
|
72
|
+
cancel_url: zod_1.z.string().nullable(),
|
|
73
|
+
url: zod_1.z
|
|
74
|
+
.string()
|
|
75
|
+
.nullable()
|
|
76
|
+
.describe('Hosted mode: the URL to send the payer to. `null` in embedded mode.'),
|
|
77
|
+
client_secret: zod_1.z
|
|
78
|
+
.string()
|
|
79
|
+
.nullable()
|
|
80
|
+
.describe('Embedded mode: what `PeableCheckout.mountCheckout` takes. `null` in hosted mode.'),
|
|
81
|
+
created: primitives_1.unixSeconds,
|
|
82
|
+
})
|
|
83
|
+
.strict(), {
|
|
84
|
+
examples: [
|
|
85
|
+
{
|
|
86
|
+
id: 'cs_0193b8f2c1a87d3e9f4a',
|
|
87
|
+
object: 'checkout_session',
|
|
88
|
+
livemode: false,
|
|
89
|
+
mode: 'payment',
|
|
90
|
+
status: 'open',
|
|
91
|
+
payment_status: 'unpaid',
|
|
92
|
+
ui_mode: 'hosted',
|
|
93
|
+
locale: null,
|
|
94
|
+
submit_type: 'auto',
|
|
95
|
+
currency: 'EUR',
|
|
96
|
+
rail: 'card',
|
|
97
|
+
network: null,
|
|
98
|
+
payment_method_types: ['card'],
|
|
99
|
+
amount_subtotal: '1999',
|
|
100
|
+
amount_total: '1999',
|
|
101
|
+
total_details: { amount_discount: '0', amount_tax: '0', amount_shipping: '0' },
|
|
102
|
+
discounts: [],
|
|
103
|
+
allow_promotion_codes: false,
|
|
104
|
+
automatic_tax: { enabled: false, status: null },
|
|
105
|
+
customer: null,
|
|
106
|
+
customer_email: 'jenny@example.com',
|
|
107
|
+
customer_creation: 'if_required',
|
|
108
|
+
customer_details: null,
|
|
109
|
+
billing_address_collection: 'auto',
|
|
110
|
+
shipping_address_collection: null,
|
|
111
|
+
shipping_details: null,
|
|
112
|
+
phone_number_collection: { enabled: false },
|
|
113
|
+
tax_id_collection: { enabled: false },
|
|
114
|
+
custom_fields: [],
|
|
115
|
+
consent_collection: null,
|
|
116
|
+
consent: null,
|
|
117
|
+
payment_intent: null,
|
|
118
|
+
setup_intent: null,
|
|
119
|
+
connected_account: null,
|
|
120
|
+
payment_link: null,
|
|
121
|
+
client_reference_id: null,
|
|
122
|
+
metadata: {},
|
|
123
|
+
success_url: 'https://example.com/thanks?session={CHECKOUT_SESSION_ID}',
|
|
124
|
+
cancel_url: null,
|
|
125
|
+
url: 'https://checkout.peable.to/c/cs_0193b8f2c1a87d3e9f4a#cs=cs_0193b8f2c1a87d3e9f4a_secret_x',
|
|
126
|
+
client_secret: null,
|
|
127
|
+
expires_at: 1793836800,
|
|
128
|
+
created: 1793750400,
|
|
129
|
+
},
|
|
130
|
+
],
|
|
131
|
+
});
|
|
132
|
+
/**
|
|
133
|
+
* What the hosted/embedded checkout loads, authorized by the session's
|
|
134
|
+
* `client_secret` (or, for a session wrapping a payment, that payment's). No
|
|
135
|
+
* metadata, no client reference, no internal ids.
|
|
136
|
+
*/
|
|
137
|
+
exports.checkoutSessionPublicSchema = (0, objects_2.defineComponent)('CheckoutSessionPublic', zod_1.z
|
|
138
|
+
.object({
|
|
139
|
+
...sessionFields,
|
|
140
|
+
line_items: zod_1.z.array(shared_1.checkoutLineItemSchema),
|
|
141
|
+
discount: zod_1.z
|
|
142
|
+
.object({
|
|
143
|
+
promotion_code: zod_1.z.string().nullable().describe('The code the payer typed.'),
|
|
144
|
+
coupon_name: zod_1.z.string().nullable(),
|
|
145
|
+
amount_off: primitives_1.amount.nullable(),
|
|
146
|
+
percent_off: zod_1.z.number().nullable(),
|
|
147
|
+
})
|
|
148
|
+
.strict()
|
|
149
|
+
.nullable()
|
|
150
|
+
.describe('The discount applied, as the payer sees it.'),
|
|
151
|
+
customer_details: shared_1.checkoutCustomerDetailsSchema.describe('Prefilled from `customer_email` / the customer; then what the payer entered.'),
|
|
152
|
+
customer_email_locked: zod_1.z
|
|
153
|
+
.boolean()
|
|
154
|
+
.describe('Whether the email is fixed by the merchant (a `customer` or `customer_email`).'),
|
|
155
|
+
terms_of_service_url: zod_1.z
|
|
156
|
+
.string()
|
|
157
|
+
.nullable()
|
|
158
|
+
.describe("The merchant's terms URL when `consent_collection.terms_of_service` is required."),
|
|
159
|
+
payment_intent: (0, objects_1.embedded)('payment_intent')
|
|
160
|
+
.nullable()
|
|
161
|
+
.describe("The payment the payer confirmed — with its `client_secret`, the payer's capability."),
|
|
162
|
+
setup_intent: zod_1.z
|
|
163
|
+
.object({
|
|
164
|
+
id: zod_1.z.string(),
|
|
165
|
+
client_secret: zod_1.z.string(),
|
|
166
|
+
status: zod_1.z.enum(payments_1.SETUP_INTENT_STATUSES),
|
|
167
|
+
})
|
|
168
|
+
.strict()
|
|
169
|
+
.nullable()
|
|
170
|
+
.describe('`setup` mode: the SetupIntent id and client secret, once confirmed.'),
|
|
171
|
+
success_url: zod_1.z
|
|
172
|
+
.string()
|
|
173
|
+
.nullable()
|
|
174
|
+
.describe('`success_url` with `{CHECKOUT_SESSION_ID}` substituted; only once `complete`.'),
|
|
175
|
+
cancel_url: zod_1.z.string().nullable().describe('Shown as "Back to <merchant>" before payment.'),
|
|
176
|
+
confirmation_message: zod_1.z
|
|
177
|
+
.string()
|
|
178
|
+
.nullable()
|
|
179
|
+
.describe("A payment link's hosted confirmation, shown once `complete`."),
|
|
180
|
+
merchant: shared_1.merchantDisplaySchema,
|
|
181
|
+
branding: shared_1.checkoutBrandingSchema,
|
|
182
|
+
publishable_key: zod_1.z
|
|
183
|
+
.string()
|
|
184
|
+
.nullable()
|
|
185
|
+
.describe("The card provider's PUBLIC key for this session's mode, so the payment fields can mount before the payment exists. `null` on FairCoin."),
|
|
186
|
+
billing_quote: billing_1.billingFaircoinFxQuoteSchema
|
|
187
|
+
.optional()
|
|
188
|
+
.describe('FairCoin billing invoices: the frozen USD price and FAIR settlement quote.'),
|
|
189
|
+
})
|
|
190
|
+
.strict());
|
|
191
|
+
// ---- Merchant create/update ---------------------------------------------------
|
|
192
|
+
const productDataParams = zod_1.z
|
|
193
|
+
.object({
|
|
194
|
+
name: zod_1.z.string().trim().min(1).max(catalog_1.CATALOG_LIMITS.productNameMax),
|
|
195
|
+
description: zod_1.z.string().min(1).max(catalog_1.CATALOG_LIMITS.productDescriptionMax).optional(),
|
|
196
|
+
images: zod_1.z
|
|
197
|
+
.array(zod_1.z
|
|
198
|
+
.string()
|
|
199
|
+
.max(catalog_1.CATALOG_LIMITS.urlMax)
|
|
200
|
+
.regex(/^https:\/\/\S+$/, 'must be an https URL'))
|
|
201
|
+
.max(8)
|
|
202
|
+
.optional(),
|
|
203
|
+
tax_code: zod_1.z
|
|
204
|
+
.string()
|
|
205
|
+
.regex(/^txcd_[0-9]{8}$/, 'is not a Peable Tax code (GET /v1/tax/codes lists them)')
|
|
206
|
+
.optional()
|
|
207
|
+
.describe('A Peable Tax code (`GET /v1/tax/codes`).'),
|
|
208
|
+
})
|
|
209
|
+
.strict();
|
|
210
|
+
const priceDataParams = zod_1.z
|
|
211
|
+
.object({
|
|
212
|
+
currency: primitives_1.currency,
|
|
213
|
+
unit_amount: shared_1.amountParam,
|
|
214
|
+
product: shared_1.checkoutIdParam.optional(),
|
|
215
|
+
product_data: productDataParams.optional(),
|
|
216
|
+
recurring: zod_1.z
|
|
217
|
+
.object({
|
|
218
|
+
interval: zod_1.z.enum(catalog_1.RECURRING_INTERVALS),
|
|
219
|
+
interval_count: zod_1.z.number().int().min(1).max(1095).optional(),
|
|
220
|
+
})
|
|
221
|
+
.strict()
|
|
222
|
+
.optional(),
|
|
223
|
+
tax_behavior: zod_1.z.enum(catalog_1.PRICE_TAX_BEHAVIORS).optional(),
|
|
224
|
+
})
|
|
225
|
+
.strict()
|
|
226
|
+
.superRefine((data, ctx) => {
|
|
227
|
+
if ((data.product === undefined) === (data.product_data === undefined)) {
|
|
228
|
+
ctx.addIssue({
|
|
229
|
+
code: 'custom',
|
|
230
|
+
path: ['product'],
|
|
231
|
+
message: 'exactly one of product and product_data',
|
|
232
|
+
});
|
|
233
|
+
}
|
|
234
|
+
});
|
|
235
|
+
/** One `line_items[]` entry of a session: exactly one of `price` and `price_data`. */
|
|
236
|
+
exports.sessionLineItemParams = zod_1.z
|
|
237
|
+
.object({
|
|
238
|
+
price: shared_1.checkoutIdParam.optional(),
|
|
239
|
+
price_data: priceDataParams.optional(),
|
|
240
|
+
quantity: shared_1.quantityParam,
|
|
241
|
+
adjustable_quantity: shared_1.adjustableQuantityParam.optional(),
|
|
242
|
+
})
|
|
243
|
+
.strict()
|
|
244
|
+
.superRefine((line, ctx) => {
|
|
245
|
+
if ((line.price === undefined) === (line.price_data === undefined)) {
|
|
246
|
+
ctx.addIssue({
|
|
247
|
+
code: 'custom',
|
|
248
|
+
path: ['price'],
|
|
249
|
+
message: 'exactly one of price and price_data',
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
(0, shared_1.adjustableIssues)(line.quantity, line.adjustable_quantity, ctx);
|
|
253
|
+
});
|
|
254
|
+
const discountParam = zod_1.z.union([
|
|
255
|
+
zod_1.z.object({ coupon: shared_1.checkoutIdParam }).strict(),
|
|
256
|
+
zod_1.z.object({ promotion_code: shared_1.checkoutIdParam }).strict(),
|
|
257
|
+
]);
|
|
258
|
+
exports.createCheckoutSessionParams = zod_1.z
|
|
259
|
+
.object({
|
|
260
|
+
mode: zod_1.z.enum(checkout_1.CHECKOUT_SESSION_MODES).optional().describe('Default `payment`.'),
|
|
261
|
+
line_items: zod_1.z
|
|
262
|
+
.array(exports.sessionLineItemParams)
|
|
263
|
+
.min(1)
|
|
264
|
+
.max(checkout_1.CHECKOUT_LIMITS.lineItemsMax)
|
|
265
|
+
.optional()
|
|
266
|
+
.describe('Required in `payment` and `subscription` mode; refused in `setup` mode.'),
|
|
267
|
+
currency: primitives_1.currency
|
|
268
|
+
.optional()
|
|
269
|
+
.describe('`setup` mode: the currency of the method being saved (card rail only).'),
|
|
270
|
+
discounts: zod_1.z
|
|
271
|
+
.array(discountParam)
|
|
272
|
+
.max(1)
|
|
273
|
+
.optional()
|
|
274
|
+
.describe('At most one; mutually exclusive with `allow_promotion_codes`.'),
|
|
275
|
+
allow_promotion_codes: zod_1.z.boolean().optional(),
|
|
276
|
+
customer: shared_1.checkoutIdParam
|
|
277
|
+
.optional()
|
|
278
|
+
.describe('`cus_…`; mutually exclusive with `customer_email`.'),
|
|
279
|
+
customer_email: shared_1.checkoutEmailParam.optional(),
|
|
280
|
+
customer_creation: zod_1.z
|
|
281
|
+
.enum(checkout_1.CHECKOUT_CUSTOMER_CREATIONS)
|
|
282
|
+
.optional()
|
|
283
|
+
.describe('Default `if_required` (a customer is created only when something needs one).'),
|
|
284
|
+
...shared_1.collectionParams,
|
|
285
|
+
automatic_tax: zod_1.z.object({ enabled: zod_1.z.boolean() }).strict().optional(),
|
|
286
|
+
payment_method_types: zod_1.z
|
|
287
|
+
.array(zod_1.z.enum(['card', 'faircoin']))
|
|
288
|
+
.min(1)
|
|
289
|
+
.max(1)
|
|
290
|
+
.optional()
|
|
291
|
+
.describe("`['card']` or `['faircoin']` — the rail the line items' currency allows."),
|
|
292
|
+
locale: shared_1.localeParam.optional(),
|
|
293
|
+
ui_mode: zod_1.z.enum(checkout_1.CHECKOUT_UI_MODES).optional(),
|
|
294
|
+
success_url: shared_1.redirectUrlParam
|
|
295
|
+
.optional()
|
|
296
|
+
.describe('Required in hosted mode; may carry `{CHECKOUT_SESSION_ID}`.'),
|
|
297
|
+
cancel_url: shared_1.redirectUrlParam
|
|
298
|
+
.optional()
|
|
299
|
+
.describe('Hosted mode only: the "Back to merchant" link.'),
|
|
300
|
+
expires_at: zod_1.z
|
|
301
|
+
.number()
|
|
302
|
+
.int()
|
|
303
|
+
.positive()
|
|
304
|
+
.optional()
|
|
305
|
+
.describe('Unix seconds, 30 minutes to 24 hours from now. Default 24 hours.'),
|
|
306
|
+
client_reference_id: zod_1.z.string().min(1).max(checkout_1.CHECKOUT_LIMITS.clientReferenceIdMax).optional(),
|
|
307
|
+
metadata: params_1.metadataCreateParam.optional(),
|
|
308
|
+
submit_type: zod_1.z.enum(checkout_1.CHECKOUT_SUBMIT_TYPES).optional(),
|
|
309
|
+
connected_account: shared_1.checkoutIdParam
|
|
310
|
+
.optional()
|
|
311
|
+
.describe('Pay this seller (`ca_…`) rather than the merchant (ADR 0012); FairCoin only.'),
|
|
312
|
+
expand: params_1.expandParam.optional(),
|
|
313
|
+
})
|
|
314
|
+
.strict()
|
|
315
|
+
.superRefine((body, ctx) => {
|
|
316
|
+
const issue = (path, message) => ctx.addIssue({ code: 'custom', path: [path], message });
|
|
317
|
+
const mode = body.mode ?? 'payment';
|
|
318
|
+
if (mode === 'setup') {
|
|
319
|
+
if (body.line_items)
|
|
320
|
+
issue('line_items', 'a setup session has no line items');
|
|
321
|
+
if (body.discounts || body.allow_promotion_codes) {
|
|
322
|
+
issue('discounts', 'a setup session takes no discounts');
|
|
323
|
+
}
|
|
324
|
+
if (body.automatic_tax?.enabled)
|
|
325
|
+
issue('automatic_tax', 'a setup session has no tax');
|
|
326
|
+
if (!body.currency)
|
|
327
|
+
issue('currency', 'a setup session needs a currency');
|
|
328
|
+
}
|
|
329
|
+
else {
|
|
330
|
+
if (!body.line_items)
|
|
331
|
+
issue('line_items', `line_items is required in ${mode} mode`);
|
|
332
|
+
if (body.currency !== undefined) {
|
|
333
|
+
issue('currency', 'the currency of a priced session is its line items’');
|
|
334
|
+
}
|
|
335
|
+
}
|
|
336
|
+
if (body.customer !== undefined && body.customer_email !== undefined) {
|
|
337
|
+
issue('customer_email', 'customer and customer_email are mutually exclusive');
|
|
338
|
+
}
|
|
339
|
+
if (body.discounts && body.allow_promotion_codes) {
|
|
340
|
+
issue('allow_promotion_codes', 'discounts and allow_promotion_codes are mutually exclusive');
|
|
341
|
+
}
|
|
342
|
+
const ui = body.ui_mode ?? 'hosted';
|
|
343
|
+
if (ui === 'hosted' && body.success_url === undefined) {
|
|
344
|
+
issue('success_url', 'success_url is required in hosted mode');
|
|
345
|
+
}
|
|
346
|
+
if (ui === 'embedded' && body.cancel_url !== undefined) {
|
|
347
|
+
issue('cancel_url', 'an embedded session has no cancel_url; the page around it is yours');
|
|
348
|
+
}
|
|
349
|
+
if (body.submit_type !== undefined && mode !== 'payment') {
|
|
350
|
+
issue('submit_type', 'submit_type is for payment mode');
|
|
351
|
+
}
|
|
352
|
+
});
|
|
353
|
+
/** `POST /v1/checkout_sessions/{id}` — the merchant's `metadata`, as a patch. */
|
|
354
|
+
exports.updateCheckoutSessionParams = zod_1.z
|
|
355
|
+
.object({ metadata: params_1.metadataUpdateParam.optional(), expand: params_1.expandParam.optional() })
|
|
356
|
+
.strict();
|
|
357
|
+
exports.expireCheckoutSessionParams = zod_1.z.object({ expand: params_1.expandParam.optional() }).strict();
|
|
358
|
+
exports.listCheckoutSessionsQuery = (0, params_1.listQuery)({
|
|
359
|
+
payment_intent: shared_1.checkoutIdParam.optional().describe('Sessions that created this payment.'),
|
|
360
|
+
payment_link: shared_1.checkoutIdParam.optional().describe('Sessions started from this link.'),
|
|
361
|
+
customer: shared_1.checkoutIdParam.optional(),
|
|
362
|
+
status: zod_1.z.enum(checkout_1.CHECKOUT_SESSION_STATUSES).optional(),
|
|
363
|
+
});
|
|
364
|
+
/** A session's lines, in their order; `created` does not apply to them. */
|
|
365
|
+
exports.listCheckoutSessionLineItemsQuery = (0, params_1.listQuery)({});
|
|
366
|
+
// ---- Payer side ------------------------------------------------------------------
|
|
367
|
+
const payerAddressParams = zod_1.z
|
|
368
|
+
.object({
|
|
369
|
+
line1: zod_1.z.string().trim().min(1).max(200).optional(),
|
|
370
|
+
line2: zod_1.z.string().trim().min(1).max(200).optional(),
|
|
371
|
+
city: zod_1.z.string().trim().min(1).max(200).optional(),
|
|
372
|
+
state: zod_1.z.string().trim().min(1).max(100).optional(),
|
|
373
|
+
postal_code: zod_1.z.string().trim().min(1).max(20).optional(),
|
|
374
|
+
country: shared_1.countryCodeParam.optional(),
|
|
375
|
+
})
|
|
376
|
+
.strict();
|
|
377
|
+
/** `POST /v1/checkout_sessions/{id}/public` — what the payer changes before confirming. */
|
|
378
|
+
exports.updateCheckoutSessionPublicParams = zod_1.z
|
|
379
|
+
.object({
|
|
380
|
+
line_items: zod_1.z
|
|
381
|
+
.array(zod_1.z
|
|
382
|
+
.object({
|
|
383
|
+
id: shared_1.checkoutIdParam,
|
|
384
|
+
quantity: zod_1.z.number().int().min(0).max(checkout_1.CHECKOUT_LIMITS.quantityMax),
|
|
385
|
+
})
|
|
386
|
+
.strict())
|
|
387
|
+
.max(checkout_1.CHECKOUT_LIMITS.lineItemsMax)
|
|
388
|
+
.optional()
|
|
389
|
+
.describe("Adjust a line's quantity, within its `adjustable_quantity` bounds."),
|
|
390
|
+
promotion_code: zod_1.z
|
|
391
|
+
.union([zod_1.z.literal(''), zod_1.z.string().trim().min(1).max(catalog_1.CATALOG_LIMITS.promotionCodeMax)])
|
|
392
|
+
.optional()
|
|
393
|
+
.describe('A code to redeem (`allow_promotion_codes`), or `""` to remove the one applied.'),
|
|
394
|
+
customer_details: zod_1.z
|
|
395
|
+
.object({
|
|
396
|
+
email: shared_1.checkoutEmailParam.optional(),
|
|
397
|
+
name: zod_1.z.string().trim().min(1).max(200).optional(),
|
|
398
|
+
phone: zod_1.z
|
|
399
|
+
.string()
|
|
400
|
+
.trim()
|
|
401
|
+
.regex(/^\+?[0-9 ()-]{5,25}$/, 'must be a phone number')
|
|
402
|
+
.optional(),
|
|
403
|
+
address: payerAddressParams.optional(),
|
|
404
|
+
tax_ids: zod_1.z
|
|
405
|
+
.array(zod_1.z
|
|
406
|
+
.object({
|
|
407
|
+
type: zod_1.z.enum(checkout_1.CHECKOUT_TAX_ID_TYPES),
|
|
408
|
+
value: zod_1.z
|
|
409
|
+
.string()
|
|
410
|
+
.trim()
|
|
411
|
+
.regex(/^[A-Za-z0-9 .-]{2,30}$/, 'must be a tax id'),
|
|
412
|
+
})
|
|
413
|
+
.strict())
|
|
414
|
+
.max(1)
|
|
415
|
+
.optional(),
|
|
416
|
+
})
|
|
417
|
+
.strict()
|
|
418
|
+
.optional(),
|
|
419
|
+
shipping_details: zod_1.z
|
|
420
|
+
.object({ name: zod_1.z.string().trim().min(1).max(200), address: payerAddressParams })
|
|
421
|
+
.strict()
|
|
422
|
+
.nullable()
|
|
423
|
+
.optional(),
|
|
424
|
+
custom_fields: zod_1.z
|
|
425
|
+
.array(zod_1.z.object({ key: zod_1.z.string().min(1).max(200), value: zod_1.z.string().max(255) }).strict())
|
|
426
|
+
.max(checkout_1.CHECKOUT_LIMITS.customFieldsMax)
|
|
427
|
+
.optional()
|
|
428
|
+
.describe("By `key`: the payer's value for each custom field."),
|
|
429
|
+
consent: zod_1.z
|
|
430
|
+
.object({ terms_of_service: zod_1.z.literal('accepted').optional() })
|
|
431
|
+
.strict()
|
|
432
|
+
.optional(),
|
|
433
|
+
})
|
|
434
|
+
.strict();
|
|
435
|
+
/** `POST /v1/checkout_sessions/{id}/public/confirm` takes nothing: the order is the session's. */
|
|
436
|
+
exports.confirmCheckoutSessionPublicParams = zod_1.z.object({}).strict();
|
|
437
|
+
/** `POST /v1/test_helpers/checkout_sessions/{id}/expire` takes nothing. */
|
|
438
|
+
exports.expireCheckoutSessionTestHelperParams = zod_1.z.object({}).strict();
|
|
439
|
+
const sessionId = { id: 'The Checkout Session (`cs_…`).' };
|
|
440
|
+
const payerAuth = "Authorized by the session's `client_secret` (or, for a session wrapping a payment, that payment's) in the `X-Peable-Client-Secret` header — never a URL. Unauthenticated and rate-limited; the answer is `Cache-Control: no-store`.";
|
|
441
|
+
exports.checkoutSessionRoutes = [
|
|
442
|
+
(0, route_1.defineRoute)({
|
|
443
|
+
operationId: 'createCheckoutSession',
|
|
444
|
+
method: 'post',
|
|
445
|
+
path: '/v1/checkout_sessions',
|
|
446
|
+
tag: 'Checkout Sessions',
|
|
447
|
+
summary: 'Create a Checkout Session',
|
|
448
|
+
auth: 'service',
|
|
449
|
+
scope: 'payments:write',
|
|
450
|
+
idempotent: true,
|
|
451
|
+
body: exports.createCheckoutSessionParams,
|
|
452
|
+
response: exports.checkoutSessionSchema,
|
|
453
|
+
status: 201,
|
|
454
|
+
sdk: 'checkout.sessions.create',
|
|
455
|
+
expandable: 'checkout_session',
|
|
456
|
+
}),
|
|
457
|
+
(0, route_1.defineRoute)({
|
|
458
|
+
operationId: 'listCheckoutSessions',
|
|
459
|
+
method: 'get',
|
|
460
|
+
path: '/v1/checkout_sessions',
|
|
461
|
+
tag: 'Checkout Sessions',
|
|
462
|
+
summary: 'List Checkout Sessions',
|
|
463
|
+
auth: 'service',
|
|
464
|
+
scope: 'payments:read',
|
|
465
|
+
query: exports.listCheckoutSessionsQuery,
|
|
466
|
+
response: (0, envelopes_1.listOf)(exports.checkoutSessionSchema),
|
|
467
|
+
sdk: 'checkout.sessions.list',
|
|
468
|
+
expandable: 'checkout_session',
|
|
469
|
+
}),
|
|
470
|
+
(0, route_1.defineRoute)({
|
|
471
|
+
operationId: 'retrieveCheckoutSession',
|
|
472
|
+
method: 'get',
|
|
473
|
+
path: '/v1/checkout_sessions/{id}',
|
|
474
|
+
tag: 'Checkout Sessions',
|
|
475
|
+
summary: 'Retrieve a Checkout Session',
|
|
476
|
+
auth: 'service',
|
|
477
|
+
scope: 'payments:read',
|
|
478
|
+
params: sessionId,
|
|
479
|
+
query: params_1.expandOnlyQuery,
|
|
480
|
+
response: exports.checkoutSessionSchema,
|
|
481
|
+
sdk: 'checkout.sessions.retrieve',
|
|
482
|
+
expandable: 'checkout_session',
|
|
483
|
+
}),
|
|
484
|
+
(0, route_1.defineRoute)({
|
|
485
|
+
operationId: 'updateCheckoutSession',
|
|
486
|
+
method: 'post',
|
|
487
|
+
path: '/v1/checkout_sessions/{id}',
|
|
488
|
+
tag: 'Checkout Sessions',
|
|
489
|
+
summary: 'Update a Checkout Session',
|
|
490
|
+
description: '`metadata` only, as a patch.',
|
|
491
|
+
auth: 'service',
|
|
492
|
+
scope: 'payments:write',
|
|
493
|
+
idempotent: true,
|
|
494
|
+
params: sessionId,
|
|
495
|
+
body: exports.updateCheckoutSessionParams,
|
|
496
|
+
response: exports.checkoutSessionSchema,
|
|
497
|
+
sdk: 'checkout.sessions.update',
|
|
498
|
+
expandable: 'checkout_session',
|
|
499
|
+
}),
|
|
500
|
+
(0, route_1.defineRoute)({
|
|
501
|
+
operationId: 'expireCheckoutSession',
|
|
502
|
+
method: 'post',
|
|
503
|
+
path: '/v1/checkout_sessions/{id}/expire',
|
|
504
|
+
tag: 'Checkout Sessions',
|
|
505
|
+
summary: 'Expire a Checkout Session',
|
|
506
|
+
description: 'An `open` session the payer has not confirmed; it can no longer be completed.',
|
|
507
|
+
auth: 'service',
|
|
508
|
+
scope: 'payments:write',
|
|
509
|
+
idempotent: true,
|
|
510
|
+
params: sessionId,
|
|
511
|
+
body: exports.expireCheckoutSessionParams,
|
|
512
|
+
response: exports.checkoutSessionSchema,
|
|
513
|
+
sdk: 'checkout.sessions.expire',
|
|
514
|
+
expandable: 'checkout_session',
|
|
515
|
+
}),
|
|
516
|
+
(0, route_1.defineRoute)({
|
|
517
|
+
operationId: 'listCheckoutSessionLineItems',
|
|
518
|
+
method: 'get',
|
|
519
|
+
path: '/v1/checkout_sessions/{id}/line_items',
|
|
520
|
+
tag: 'Checkout Sessions',
|
|
521
|
+
summary: "List a Checkout Session's line items",
|
|
522
|
+
description: "In their order (at most twenty); the cursor is a line's own `li_…`.",
|
|
523
|
+
auth: 'service',
|
|
524
|
+
scope: 'payments:read',
|
|
525
|
+
params: sessionId,
|
|
526
|
+
query: exports.listCheckoutSessionLineItemsQuery,
|
|
527
|
+
response: (0, envelopes_1.listOf)(shared_1.checkoutLineItemSchema),
|
|
528
|
+
sdk: 'checkout.sessions.listLineItems',
|
|
529
|
+
expandable: 'item',
|
|
530
|
+
}),
|
|
531
|
+
(0, route_1.defineRoute)({
|
|
532
|
+
operationId: 'retrieveCheckoutSessionPublic',
|
|
533
|
+
method: 'get',
|
|
534
|
+
path: '/v1/checkout_sessions/{id}/public',
|
|
535
|
+
tag: 'Checkout Sessions',
|
|
536
|
+
summary: 'Retrieve a Checkout Session as its payer',
|
|
537
|
+
description: payerAuth,
|
|
538
|
+
auth: 'public',
|
|
539
|
+
params: sessionId,
|
|
540
|
+
response: exports.checkoutSessionPublicSchema,
|
|
541
|
+
}),
|
|
542
|
+
(0, route_1.defineRoute)({
|
|
543
|
+
operationId: 'updateCheckoutSessionPublic',
|
|
544
|
+
method: 'post',
|
|
545
|
+
path: '/v1/checkout_sessions/{id}/public',
|
|
546
|
+
tag: 'Checkout Sessions',
|
|
547
|
+
summary: 'Update a Checkout Session as its payer',
|
|
548
|
+
description: `Quantities, promotion code, the payer's details. ${payerAuth}`,
|
|
549
|
+
auth: 'public',
|
|
550
|
+
params: sessionId,
|
|
551
|
+
body: exports.updateCheckoutSessionPublicParams,
|
|
552
|
+
response: exports.checkoutSessionPublicSchema,
|
|
553
|
+
}),
|
|
554
|
+
(0, route_1.defineRoute)({
|
|
555
|
+
operationId: 'confirmCheckoutSessionPublic',
|
|
556
|
+
method: 'post',
|
|
557
|
+
path: '/v1/checkout_sessions/{id}/public/confirm',
|
|
558
|
+
tag: 'Checkout Sessions',
|
|
559
|
+
summary: 'Confirm a Checkout Session as its payer',
|
|
560
|
+
description: `Locks the order and creates its payment (or setup): the answer carries \`payment_intent\` / \`setup_intent\`. Resolving is not completion — \`complete\` is only ever what the gateway says. ${payerAuth}`,
|
|
561
|
+
auth: 'public',
|
|
562
|
+
params: sessionId,
|
|
563
|
+
body: exports.confirmCheckoutSessionPublicParams,
|
|
564
|
+
response: exports.checkoutSessionPublicSchema,
|
|
565
|
+
}),
|
|
566
|
+
(0, route_1.defineRoute)({
|
|
567
|
+
operationId: 'expireCheckoutSessionTestHelper',
|
|
568
|
+
method: 'post',
|
|
569
|
+
path: '/v1/test_helpers/checkout_sessions/{id}/expire',
|
|
570
|
+
tag: 'Test helpers',
|
|
571
|
+
summary: 'Expire a test-mode Checkout Session now',
|
|
572
|
+
description: 'A session nobody confirmed expires on its own deadline; one around a payment expires with that payment, in the same transition.',
|
|
573
|
+
auth: 'service',
|
|
574
|
+
scope: 'payments:write',
|
|
575
|
+
idempotent: true,
|
|
576
|
+
testModeOnly: true,
|
|
577
|
+
params: sessionId,
|
|
578
|
+
body: exports.expireCheckoutSessionTestHelperParams,
|
|
579
|
+
response: exports.checkoutSessionSchema,
|
|
580
|
+
sdk: 'testHelpers.checkoutSessions.expire',
|
|
581
|
+
}),
|
|
582
|
+
];
|