@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,323 @@
|
|
|
1
|
+
import { z } from 'zod';
|
|
2
|
+
import { addressParams, addressSchema, emailParam } from '../../common/address.js';
|
|
3
|
+
import { defineComponent, defineObject } from '../../common/objects.js';
|
|
4
|
+
import { idParam } from '../../common/params.js';
|
|
5
|
+
import { amount, currency, livemode, signedAmount, unixSeconds } from '../../common/primitives.js';
|
|
6
|
+
import { defineRoute } from '../../route.js';
|
|
7
|
+
import { PORTAL_PAYMENT_METHOD_UPDATE_STATUSES } from '../../vocabulary/billingPortal.js';
|
|
8
|
+
import { INVOICE_STATUSES, PUBLIC_INVOICE_PAYMENT_METHOD_TYPES } from '../../vocabulary/invoices.js';
|
|
9
|
+
import { COLLECTION_METHODS, SUBSCRIPTION_STATUSES } from '../../vocabulary/subscriptions.js';
|
|
10
|
+
import { billingPortalBusinessProfileSchema, billingPortalFeaturesSchema } from './billingPortal.js';
|
|
11
|
+
import { emptyBody, quantityParam, shortText } from './params.js';
|
|
12
|
+
/**
|
|
13
|
+
* The payer-facing billing routes (ADR 0018) — anonymous, authorized by an
|
|
14
|
+
* unguessable bearer token in the path, like a payment link: a finalized
|
|
15
|
+
* invoice as its payer sees it, and the customer portal. Nothing here reveals
|
|
16
|
+
* anything but the one invoice or the one customer the token names. Called by
|
|
17
|
+
* the hosted checkout (`checkout.peable.to`), never by the server SDK.
|
|
18
|
+
*/
|
|
19
|
+
/** The merchant as a payer sees it. */
|
|
20
|
+
const publicMerchantSchema = z
|
|
21
|
+
.object({ name: z.string().nullable(), avatar_url: z.string().nullable() })
|
|
22
|
+
.strict();
|
|
23
|
+
/** A finalized invoice as its payer sees it. */
|
|
24
|
+
export const publicInvoiceSchema = defineObject('public_invoice', 'PublicInvoice', z
|
|
25
|
+
.object({
|
|
26
|
+
object: z.literal('public_invoice'),
|
|
27
|
+
livemode,
|
|
28
|
+
number: z.string().nullable(),
|
|
29
|
+
status: z.enum(INVOICE_STATUSES),
|
|
30
|
+
currency,
|
|
31
|
+
merchant: publicMerchantSchema,
|
|
32
|
+
customer_name: z.string().nullable(),
|
|
33
|
+
customer_email: z.string().nullable(),
|
|
34
|
+
description: z.string().nullable(),
|
|
35
|
+
lines: z.array(z
|
|
36
|
+
.object({
|
|
37
|
+
description: z.string().nullable(),
|
|
38
|
+
quantity: z.number().int().nullable(),
|
|
39
|
+
amount: signedAmount,
|
|
40
|
+
period: z.object({ start: unixSeconds, end: unixSeconds }).strict(),
|
|
41
|
+
proration: z.boolean(),
|
|
42
|
+
})
|
|
43
|
+
.strict()),
|
|
44
|
+
subtotal: signedAmount,
|
|
45
|
+
total_discount: signedAmount,
|
|
46
|
+
tax: signedAmount.nullable(),
|
|
47
|
+
total: signedAmount,
|
|
48
|
+
amount_due: amount,
|
|
49
|
+
amount_paid: amount,
|
|
50
|
+
amount_remaining: amount,
|
|
51
|
+
due_date: unixSeconds.nullable(),
|
|
52
|
+
created: unixSeconds,
|
|
53
|
+
finalized_at: unixSeconds.nullable(),
|
|
54
|
+
paid_at: unixSeconds.nullable(),
|
|
55
|
+
payment_method_types: z
|
|
56
|
+
.array(z.enum(PUBLIC_INVOICE_PAYMENT_METHOD_TYPES))
|
|
57
|
+
.describe("Which rail pays it: a card through the provider's fields, FairCoin from the payer's wallet."),
|
|
58
|
+
invoice_pdf: z.string(),
|
|
59
|
+
})
|
|
60
|
+
.strict());
|
|
61
|
+
/**
|
|
62
|
+
* The PaymentIntent the payer completes on the hosted checkout
|
|
63
|
+
* (`/i/:id#client_secret=…`). The same invoice always answers the same intent
|
|
64
|
+
* while it can still be paid.
|
|
65
|
+
*/
|
|
66
|
+
export const publicInvoicePaymentSchema = defineObject('public_invoice_payment', 'PublicInvoicePayment', z
|
|
67
|
+
.object({
|
|
68
|
+
object: z.literal('public_invoice_payment'),
|
|
69
|
+
payment_intent: z.string().describe('The PaymentIntent (`pi_…`) that pays the invoice.'),
|
|
70
|
+
client_secret: z
|
|
71
|
+
.string()
|
|
72
|
+
.describe("The intent's payer credential (`pi_…_secret_…`), as a payment link hands out."),
|
|
73
|
+
})
|
|
74
|
+
.strict());
|
|
75
|
+
/** One subscription as the hosted portal shows it. */
|
|
76
|
+
export const publicPortalSubscriptionSchema = defineComponent('PublicPortalSubscription', z
|
|
77
|
+
.object({
|
|
78
|
+
id: z.string(),
|
|
79
|
+
status: z.enum(SUBSCRIPTION_STATUSES),
|
|
80
|
+
currency,
|
|
81
|
+
current_period_end: unixSeconds,
|
|
82
|
+
cancel_at_period_end: z.boolean(),
|
|
83
|
+
cancel_at: unixSeconds.nullable(),
|
|
84
|
+
trial_end: unixSeconds.nullable(),
|
|
85
|
+
collection_method: z.enum(COLLECTION_METHODS),
|
|
86
|
+
items: z.array(z
|
|
87
|
+
.object({
|
|
88
|
+
id: z.string(),
|
|
89
|
+
price: z.string(),
|
|
90
|
+
product: z.string(),
|
|
91
|
+
product_name: z.string(),
|
|
92
|
+
quantity: z.number().int().nonnegative(),
|
|
93
|
+
unit_amount: amount.nullable(),
|
|
94
|
+
interval: z.string().nullable(),
|
|
95
|
+
})
|
|
96
|
+
.strict()),
|
|
97
|
+
})
|
|
98
|
+
.strict());
|
|
99
|
+
/** The hosted portal's view of its customer. */
|
|
100
|
+
export const publicPortalSessionSchema = defineObject('billing_portal.public_session', 'PublicPortalSession', z
|
|
101
|
+
.object({
|
|
102
|
+
object: z.literal('billing_portal.public_session'),
|
|
103
|
+
livemode,
|
|
104
|
+
merchant: publicMerchantSchema,
|
|
105
|
+
business_profile: billingPortalBusinessProfileSchema,
|
|
106
|
+
features: billingPortalFeaturesSchema,
|
|
107
|
+
return_url: z.string().nullable(),
|
|
108
|
+
expires_at: unixSeconds,
|
|
109
|
+
customer: z
|
|
110
|
+
.object({
|
|
111
|
+
id: z.string(),
|
|
112
|
+
email: z.string().nullable(),
|
|
113
|
+
name: z.string().nullable(),
|
|
114
|
+
phone: z.string().nullable(),
|
|
115
|
+
address: addressSchema.nullable(),
|
|
116
|
+
default_payment_method: z
|
|
117
|
+
.object({
|
|
118
|
+
id: z.string(),
|
|
119
|
+
card: z
|
|
120
|
+
.object({
|
|
121
|
+
brand: z.string(),
|
|
122
|
+
last4: z.string(),
|
|
123
|
+
exp_month: z.number().int(),
|
|
124
|
+
exp_year: z.number().int(),
|
|
125
|
+
})
|
|
126
|
+
.strict()
|
|
127
|
+
.nullable(),
|
|
128
|
+
})
|
|
129
|
+
.strict()
|
|
130
|
+
.nullable(),
|
|
131
|
+
})
|
|
132
|
+
.strict(),
|
|
133
|
+
subscriptions: z.array(publicPortalSubscriptionSchema),
|
|
134
|
+
invoices: z.array(z
|
|
135
|
+
.object({
|
|
136
|
+
id: z.string(),
|
|
137
|
+
number: z.string().nullable(),
|
|
138
|
+
status: z.enum(INVOICE_STATUSES),
|
|
139
|
+
currency,
|
|
140
|
+
total: signedAmount,
|
|
141
|
+
amount_due: amount,
|
|
142
|
+
created: unixSeconds,
|
|
143
|
+
hosted_invoice_url: z.string().nullable(),
|
|
144
|
+
invoice_pdf: z.string().nullable(),
|
|
145
|
+
})
|
|
146
|
+
.strict()),
|
|
147
|
+
plans: z
|
|
148
|
+
.array(z
|
|
149
|
+
.object({
|
|
150
|
+
product: z.string(),
|
|
151
|
+
product_name: z.string(),
|
|
152
|
+
prices: z.array(z
|
|
153
|
+
.object({
|
|
154
|
+
id: z.string(),
|
|
155
|
+
unit_amount: amount.nullable(),
|
|
156
|
+
currency,
|
|
157
|
+
interval: z.string().nullable(),
|
|
158
|
+
interval_count: z.number().int().nullable(),
|
|
159
|
+
})
|
|
160
|
+
.strict()),
|
|
161
|
+
})
|
|
162
|
+
.strict())
|
|
163
|
+
.describe('The plans `subscription_update` allows, priced.'),
|
|
164
|
+
})
|
|
165
|
+
.strict());
|
|
166
|
+
/** A card update begun: the SetupIntent the portal page confirms with the provider's own fields. */
|
|
167
|
+
export const portalPaymentMethodUpdateSchema = defineComponent('PortalPaymentMethodUpdate', z
|
|
168
|
+
.object({
|
|
169
|
+
setup_intent: z.string().describe('The SetupIntent (`seti_…`) to confirm.'),
|
|
170
|
+
client_secret: z.string().describe('Its payer credential.'),
|
|
171
|
+
})
|
|
172
|
+
.strict());
|
|
173
|
+
/** A card update finished: `pending` until the SetupIntent succeeded. */
|
|
174
|
+
export const portalPaymentMethodUpdateResultSchema = defineComponent('PortalPaymentMethodUpdateResult', z
|
|
175
|
+
.object({
|
|
176
|
+
status: z.enum(PORTAL_PAYMENT_METHOD_UPDATE_STATUSES),
|
|
177
|
+
session: publicPortalSessionSchema,
|
|
178
|
+
})
|
|
179
|
+
.strict());
|
|
180
|
+
// ---- Requests ------------------------------------------------------------------------
|
|
181
|
+
export const payPublicInvoiceParams = emptyBody;
|
|
182
|
+
/** A portal action on one of the customer's subscriptions. */
|
|
183
|
+
export const portalSubscriptionParams = z.object({ subscription: idParam }).strict();
|
|
184
|
+
/** Switch a (single-item) subscription to one of the configuration's plans, or change its quantity. */
|
|
185
|
+
export const portalChangePlanParams = z
|
|
186
|
+
.object({
|
|
187
|
+
subscription: idParam,
|
|
188
|
+
price: idParam.optional(),
|
|
189
|
+
quantity: quantityParam.optional(),
|
|
190
|
+
})
|
|
191
|
+
.strict();
|
|
192
|
+
/** The fields the configuration's `customer_update.allowed_updates` names. */
|
|
193
|
+
export const portalCustomerParams = z
|
|
194
|
+
.object({
|
|
195
|
+
email: emailParam.optional(),
|
|
196
|
+
name: shortText(500).optional(),
|
|
197
|
+
phone: shortText(40).optional(),
|
|
198
|
+
address: addressParams.optional(),
|
|
199
|
+
})
|
|
200
|
+
.strict();
|
|
201
|
+
export const startPortalPaymentMethodUpdateParams = emptyBody;
|
|
202
|
+
export const completePortalPaymentMethodUpdateParams = z.object({ setup_intent: idParam }).strict();
|
|
203
|
+
// ---- Routes --------------------------------------------------------------------------
|
|
204
|
+
const invoiceToken = { token: 'The hosted invoice token (from `hosted_invoice_url`).' };
|
|
205
|
+
const portalToken = { token: 'The portal session token (from the session `url`).' };
|
|
206
|
+
export const publicBillingRoutes = [
|
|
207
|
+
defineRoute({
|
|
208
|
+
operationId: 'retrievePublicInvoice',
|
|
209
|
+
method: 'get',
|
|
210
|
+
path: '/v1/invoices/public/{token}',
|
|
211
|
+
tag: 'Hosted invoices',
|
|
212
|
+
summary: 'Retrieve a hosted invoice',
|
|
213
|
+
description: 'A finalized invoice as its payer sees it.',
|
|
214
|
+
auth: 'public',
|
|
215
|
+
params: invoiceToken,
|
|
216
|
+
response: publicInvoiceSchema,
|
|
217
|
+
}),
|
|
218
|
+
defineRoute({
|
|
219
|
+
operationId: 'payPublicInvoice',
|
|
220
|
+
method: 'post',
|
|
221
|
+
path: '/v1/invoices/public/{token}/pay',
|
|
222
|
+
tag: 'Hosted invoices',
|
|
223
|
+
summary: 'Pay a hosted invoice',
|
|
224
|
+
description: 'The PaymentIntent the payer completes — a card through the provider’s own fields, FairCoin from the payer’s wallet. The same invoice answers the same intent while it can still be paid.',
|
|
225
|
+
auth: 'public',
|
|
226
|
+
params: invoiceToken,
|
|
227
|
+
body: payPublicInvoiceParams,
|
|
228
|
+
response: publicInvoicePaymentSchema,
|
|
229
|
+
}),
|
|
230
|
+
defineRoute({
|
|
231
|
+
operationId: 'retrievePublicInvoicePdf',
|
|
232
|
+
method: 'get',
|
|
233
|
+
path: '/v1/invoices/public/{token}/pdf',
|
|
234
|
+
tag: 'Hosted invoices',
|
|
235
|
+
summary: "Download a hosted invoice's PDF",
|
|
236
|
+
auth: 'public',
|
|
237
|
+
params: invoiceToken,
|
|
238
|
+
response: { kind: 'binary', contentType: 'application/pdf' },
|
|
239
|
+
}),
|
|
240
|
+
defineRoute({
|
|
241
|
+
operationId: 'retrievePublicPortalSession',
|
|
242
|
+
method: 'get',
|
|
243
|
+
path: '/v1/billing_portal/public/{token}',
|
|
244
|
+
tag: 'Hosted portal',
|
|
245
|
+
summary: 'Retrieve the hosted portal',
|
|
246
|
+
description: 'The customer, their subscriptions, invoices and the plans they may switch to.',
|
|
247
|
+
auth: 'public',
|
|
248
|
+
params: portalToken,
|
|
249
|
+
response: publicPortalSessionSchema,
|
|
250
|
+
}),
|
|
251
|
+
defineRoute({
|
|
252
|
+
operationId: 'cancelPortalSubscription',
|
|
253
|
+
method: 'post',
|
|
254
|
+
path: '/v1/billing_portal/public/{token}/cancel',
|
|
255
|
+
tag: 'Hosted portal',
|
|
256
|
+
summary: 'Cancel a subscription from the portal',
|
|
257
|
+
description: 'At period end or now, as the configuration says. Answers the portal as it now is.',
|
|
258
|
+
auth: 'public',
|
|
259
|
+
params: portalToken,
|
|
260
|
+
body: portalSubscriptionParams,
|
|
261
|
+
response: publicPortalSessionSchema,
|
|
262
|
+
}),
|
|
263
|
+
defineRoute({
|
|
264
|
+
operationId: 'renewPortalSubscription',
|
|
265
|
+
method: 'post',
|
|
266
|
+
path: '/v1/billing_portal/public/{token}/renew',
|
|
267
|
+
tag: 'Hosted portal',
|
|
268
|
+
summary: 'Undo a cancellation at period end',
|
|
269
|
+
description: 'Answers the portal as it now is.',
|
|
270
|
+
auth: 'public',
|
|
271
|
+
params: portalToken,
|
|
272
|
+
body: portalSubscriptionParams,
|
|
273
|
+
response: publicPortalSessionSchema,
|
|
274
|
+
}),
|
|
275
|
+
defineRoute({
|
|
276
|
+
operationId: 'changePortalSubscriptionPlan',
|
|
277
|
+
method: 'post',
|
|
278
|
+
path: '/v1/billing_portal/public/{token}/change_plan',
|
|
279
|
+
tag: 'Hosted portal',
|
|
280
|
+
summary: 'Change plan from the portal',
|
|
281
|
+
description: 'Answers the portal as it now is.',
|
|
282
|
+
auth: 'public',
|
|
283
|
+
params: portalToken,
|
|
284
|
+
body: portalChangePlanParams,
|
|
285
|
+
response: publicPortalSessionSchema,
|
|
286
|
+
}),
|
|
287
|
+
defineRoute({
|
|
288
|
+
operationId: 'updatePortalCustomer',
|
|
289
|
+
method: 'post',
|
|
290
|
+
path: '/v1/billing_portal/public/{token}/customer',
|
|
291
|
+
tag: 'Hosted portal',
|
|
292
|
+
summary: 'Update billing details from the portal',
|
|
293
|
+
description: 'Answers the portal as it now is.',
|
|
294
|
+
auth: 'public',
|
|
295
|
+
params: portalToken,
|
|
296
|
+
body: portalCustomerParams,
|
|
297
|
+
response: publicPortalSessionSchema,
|
|
298
|
+
}),
|
|
299
|
+
defineRoute({
|
|
300
|
+
operationId: 'startPortalPaymentMethodUpdate',
|
|
301
|
+
method: 'post',
|
|
302
|
+
path: '/v1/billing_portal/public/{token}/payment_method_update',
|
|
303
|
+
tag: 'Hosted portal',
|
|
304
|
+
summary: 'Begin a card update from the portal',
|
|
305
|
+
description: 'A SetupIntent for the customer; card customers only.',
|
|
306
|
+
auth: 'public',
|
|
307
|
+
params: portalToken,
|
|
308
|
+
body: startPortalPaymentMethodUpdateParams,
|
|
309
|
+
response: portalPaymentMethodUpdateSchema,
|
|
310
|
+
}),
|
|
311
|
+
defineRoute({
|
|
312
|
+
operationId: 'completePortalPaymentMethodUpdate',
|
|
313
|
+
method: 'post',
|
|
314
|
+
path: '/v1/billing_portal/public/{token}/payment_method_update/complete',
|
|
315
|
+
tag: 'Hosted portal',
|
|
316
|
+
summary: 'Finish a card update from the portal',
|
|
317
|
+
description: "Once the SetupIntent succeeded, its method becomes the customer's default and every live subscription's.",
|
|
318
|
+
auth: 'public',
|
|
319
|
+
params: portalToken,
|
|
320
|
+
body: completePortalPaymentMethodUpdateParams,
|
|
321
|
+
response: portalPaymentMethodUpdateResultSchema,
|
|
322
|
+
}),
|
|
323
|
+
];
|