@peable.to/contracts 0.3.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 -97
- 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 -94
- 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 -134
- 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 -138
- package/dist/esm/openapi.js +0 -134
- package/dist/types/openapi.d.ts +0 -145
|
@@ -0,0 +1,237 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.billingPortalRoutes = exports.createBillingPortalSessionParams = exports.listBillingPortalConfigurationsQuery = exports.updateBillingPortalConfigurationParams = exports.createBillingPortalConfigurationParams = exports.billingPortalSessionSchema = exports.billingPortalConfigurationSchema = exports.billingPortalBusinessProfileSchema = exports.billingPortalFeaturesSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const envelopes_1 = require("../../common/envelopes");
|
|
6
|
+
const objects_1 = require("../../common/objects");
|
|
7
|
+
const params_1 = require("../../common/params");
|
|
8
|
+
const primitives_1 = require("../../common/primitives");
|
|
9
|
+
const route_1 = require("../../route");
|
|
10
|
+
const billingPortal_1 = require("../../vocabulary/billingPortal");
|
|
11
|
+
const subscriptions_1 = require("../../vocabulary/subscriptions");
|
|
12
|
+
const params_2 = require("./params");
|
|
13
|
+
/**
|
|
14
|
+
* The customer portal's merchant side (ADR 0018 §9): configurations (`bpc_…`)
|
|
15
|
+
* say what the Orbit-hosted portal lets a customer do; a session (`bps_…`) is
|
|
16
|
+
* a short-lived URL for ONE customer.
|
|
17
|
+
*/
|
|
18
|
+
/** What the hosted portal lets a customer do. */
|
|
19
|
+
exports.billingPortalFeaturesSchema = (0, objects_1.defineComponent)('BillingPortalFeatures', zod_1.z
|
|
20
|
+
.object({
|
|
21
|
+
customer_update: zod_1.z
|
|
22
|
+
.object({
|
|
23
|
+
enabled: zod_1.z.boolean(),
|
|
24
|
+
allowed_updates: zod_1.z.array(zod_1.z.enum(billingPortal_1.PORTAL_CUSTOMER_UPDATES)),
|
|
25
|
+
})
|
|
26
|
+
.strict(),
|
|
27
|
+
invoice_history: zod_1.z.object({ enabled: zod_1.z.boolean() }).strict(),
|
|
28
|
+
payment_method_update: zod_1.z.object({ enabled: zod_1.z.boolean() }).strict(),
|
|
29
|
+
subscription_cancel: zod_1.z
|
|
30
|
+
.object({
|
|
31
|
+
enabled: zod_1.z.boolean(),
|
|
32
|
+
mode: zod_1.z.enum(billingPortal_1.PORTAL_CANCEL_MODES),
|
|
33
|
+
proration_behavior: zod_1.z.enum(billingPortal_1.PORTAL_CANCEL_PRORATION_BEHAVIORS),
|
|
34
|
+
})
|
|
35
|
+
.strict(),
|
|
36
|
+
subscription_update: zod_1.z
|
|
37
|
+
.object({
|
|
38
|
+
enabled: zod_1.z.boolean(),
|
|
39
|
+
default_allowed_updates: zod_1.z.array(zod_1.z.enum(billingPortal_1.PORTAL_SUBSCRIPTION_UPDATES)),
|
|
40
|
+
proration_behavior: zod_1.z.enum(subscriptions_1.PRORATION_BEHAVIORS),
|
|
41
|
+
products: zod_1.z
|
|
42
|
+
.array(zod_1.z.object({ product: zod_1.z.string(), prices: zod_1.z.array(zod_1.z.string()) }).strict())
|
|
43
|
+
.describe('The plans a customer may switch between: per product, its allowed prices.'),
|
|
44
|
+
})
|
|
45
|
+
.strict(),
|
|
46
|
+
})
|
|
47
|
+
.strict());
|
|
48
|
+
/** The business the portal presents. */
|
|
49
|
+
exports.billingPortalBusinessProfileSchema = (0, objects_1.defineComponent)('BillingPortalBusinessProfile', zod_1.z
|
|
50
|
+
.object({
|
|
51
|
+
headline: zod_1.z.string().nullable(),
|
|
52
|
+
privacy_policy_url: zod_1.z.string().nullable(),
|
|
53
|
+
terms_of_service_url: zod_1.z.string().nullable(),
|
|
54
|
+
})
|
|
55
|
+
.strict());
|
|
56
|
+
exports.billingPortalConfigurationSchema = (0, objects_1.defineObject)('billing_portal.configuration', 'BillingPortalConfiguration', zod_1.z
|
|
57
|
+
.object({
|
|
58
|
+
id: zod_1.z.string(),
|
|
59
|
+
object: zod_1.z.literal('billing_portal.configuration'),
|
|
60
|
+
livemode: primitives_1.livemode,
|
|
61
|
+
active: zod_1.z.boolean(),
|
|
62
|
+
is_default: zod_1.z
|
|
63
|
+
.boolean()
|
|
64
|
+
.describe('The configuration a session uses when it names none (created on first use).'),
|
|
65
|
+
business_profile: exports.billingPortalBusinessProfileSchema,
|
|
66
|
+
default_return_url: zod_1.z.string().nullable(),
|
|
67
|
+
features: exports.billingPortalFeaturesSchema,
|
|
68
|
+
metadata: primitives_1.metadata,
|
|
69
|
+
created: primitives_1.unixSeconds,
|
|
70
|
+
updated: primitives_1.unixSeconds,
|
|
71
|
+
})
|
|
72
|
+
.strict());
|
|
73
|
+
/**
|
|
74
|
+
* A portal session: a short-lived URL for ONE customer. The URL is a bearer
|
|
75
|
+
* credential — hand it to that customer only, right away. It is answered once
|
|
76
|
+
* and never stored.
|
|
77
|
+
*/
|
|
78
|
+
exports.billingPortalSessionSchema = (0, objects_1.defineObject)('billing_portal.session', 'BillingPortalSession', zod_1.z
|
|
79
|
+
.object({
|
|
80
|
+
id: zod_1.z.string(),
|
|
81
|
+
object: zod_1.z.literal('billing_portal.session'),
|
|
82
|
+
livemode: primitives_1.livemode,
|
|
83
|
+
customer: zod_1.z.string().describe('The customer (`cus_…`) the portal is for.'),
|
|
84
|
+
configuration: zod_1.z.string().describe('The configuration (`bpc_…`) it applies.'),
|
|
85
|
+
return_url: zod_1.z.string().nullable(),
|
|
86
|
+
url: zod_1.z.string().describe('The portal, for this customer only. A bearer credential.'),
|
|
87
|
+
expires_at: primitives_1.unixSeconds.describe('The URL stops working after this instant.'),
|
|
88
|
+
created: primitives_1.unixSeconds,
|
|
89
|
+
})
|
|
90
|
+
.strict());
|
|
91
|
+
// ---- Requests ------------------------------------------------------------------------
|
|
92
|
+
const businessProfileParams = zod_1.z
|
|
93
|
+
.object({
|
|
94
|
+
headline: (0, params_2.shortText)(60).optional(),
|
|
95
|
+
privacy_policy_url: params_2.httpUrlParam.optional(),
|
|
96
|
+
terms_of_service_url: params_2.httpUrlParam.optional(),
|
|
97
|
+
})
|
|
98
|
+
.strict();
|
|
99
|
+
/** Each named feature field replaces that field; the others keep their value (or default). */
|
|
100
|
+
const featuresParams = zod_1.z
|
|
101
|
+
.object({
|
|
102
|
+
customer_update: zod_1.z
|
|
103
|
+
.object({
|
|
104
|
+
enabled: zod_1.z.boolean().optional(),
|
|
105
|
+
allowed_updates: zod_1.z.array(zod_1.z.enum(billingPortal_1.PORTAL_CUSTOMER_UPDATES)).max(4).optional(),
|
|
106
|
+
})
|
|
107
|
+
.strict()
|
|
108
|
+
.optional(),
|
|
109
|
+
invoice_history: zod_1.z.object({ enabled: zod_1.z.boolean() }).strict().optional(),
|
|
110
|
+
payment_method_update: zod_1.z.object({ enabled: zod_1.z.boolean() }).strict().optional(),
|
|
111
|
+
subscription_cancel: zod_1.z
|
|
112
|
+
.object({
|
|
113
|
+
enabled: zod_1.z.boolean().optional(),
|
|
114
|
+
mode: zod_1.z.enum(billingPortal_1.PORTAL_CANCEL_MODES).optional(),
|
|
115
|
+
proration_behavior: zod_1.z.enum(billingPortal_1.PORTAL_CANCEL_PRORATION_BEHAVIORS).optional(),
|
|
116
|
+
})
|
|
117
|
+
.strict()
|
|
118
|
+
.optional(),
|
|
119
|
+
subscription_update: zod_1.z
|
|
120
|
+
.object({
|
|
121
|
+
enabled: zod_1.z.boolean().optional(),
|
|
122
|
+
default_allowed_updates: zod_1.z.array(zod_1.z.enum(billingPortal_1.PORTAL_SUBSCRIPTION_UPDATES)).max(2).optional(),
|
|
123
|
+
proration_behavior: zod_1.z.enum(subscriptions_1.PRORATION_BEHAVIORS).optional(),
|
|
124
|
+
products: zod_1.z
|
|
125
|
+
.array(zod_1.z.object({ product: params_1.idParam, prices: zod_1.z.array(params_1.idParam).min(1).max(10) }).strict())
|
|
126
|
+
.max(10)
|
|
127
|
+
.optional(),
|
|
128
|
+
})
|
|
129
|
+
.strict()
|
|
130
|
+
.optional(),
|
|
131
|
+
})
|
|
132
|
+
.strict();
|
|
133
|
+
exports.createBillingPortalConfigurationParams = zod_1.z
|
|
134
|
+
.object({
|
|
135
|
+
business_profile: businessProfileParams.optional(),
|
|
136
|
+
default_return_url: params_2.httpUrlParam.optional(),
|
|
137
|
+
features: featuresParams,
|
|
138
|
+
metadata: params_1.metadataCreateParam.optional(),
|
|
139
|
+
})
|
|
140
|
+
.strict();
|
|
141
|
+
/** A field sent as `""` is cleared; `metadata` is a patch. */
|
|
142
|
+
exports.updateBillingPortalConfigurationParams = zod_1.z
|
|
143
|
+
.object({
|
|
144
|
+
active: zod_1.z.boolean().optional().describe('The default configuration cannot be deactivated.'),
|
|
145
|
+
business_profile: businessProfileParams.optional(),
|
|
146
|
+
default_return_url: zod_1.z.union([params_2.httpUrlParam, zod_1.z.literal('')]).optional(),
|
|
147
|
+
features: featuresParams.optional(),
|
|
148
|
+
metadata: params_1.metadataUpdateParam.optional(),
|
|
149
|
+
})
|
|
150
|
+
.strict();
|
|
151
|
+
exports.listBillingPortalConfigurationsQuery = (0, params_1.listQuery)({
|
|
152
|
+
active: params_1.queryBoolean.optional(),
|
|
153
|
+
is_default: params_1.queryBoolean.optional(),
|
|
154
|
+
});
|
|
155
|
+
exports.createBillingPortalSessionParams = zod_1.z
|
|
156
|
+
.object({
|
|
157
|
+
customer: params_1.idParam,
|
|
158
|
+
configuration: params_1.idParam
|
|
159
|
+
.optional()
|
|
160
|
+
.describe("Default: the merchant's default configuration (created on first use)."),
|
|
161
|
+
return_url: params_2.httpUrlParam.optional(),
|
|
162
|
+
})
|
|
163
|
+
.strict();
|
|
164
|
+
// ---- Routes --------------------------------------------------------------------------
|
|
165
|
+
const configurationId = { id: 'The portal configuration (`bpc_…`).' };
|
|
166
|
+
exports.billingPortalRoutes = [
|
|
167
|
+
(0, route_1.defineRoute)({
|
|
168
|
+
operationId: 'createBillingPortalConfiguration',
|
|
169
|
+
method: 'post',
|
|
170
|
+
path: '/v1/billing_portal/configurations',
|
|
171
|
+
tag: 'Customer portal',
|
|
172
|
+
summary: 'Create a portal configuration',
|
|
173
|
+
description: "Features not named take the safe defaults. The merchant's first configuration becomes the default.",
|
|
174
|
+
auth: 'service',
|
|
175
|
+
scope: 'payments:write',
|
|
176
|
+
idempotent: true,
|
|
177
|
+
body: exports.createBillingPortalConfigurationParams,
|
|
178
|
+
response: exports.billingPortalConfigurationSchema,
|
|
179
|
+
sdk: 'billingPortal.configurations.create',
|
|
180
|
+
}),
|
|
181
|
+
(0, route_1.defineRoute)({
|
|
182
|
+
operationId: 'listBillingPortalConfigurations',
|
|
183
|
+
method: 'get',
|
|
184
|
+
path: '/v1/billing_portal/configurations',
|
|
185
|
+
tag: 'Customer portal',
|
|
186
|
+
summary: 'List portal configurations',
|
|
187
|
+
auth: 'service',
|
|
188
|
+
scope: 'payments:read',
|
|
189
|
+
query: exports.listBillingPortalConfigurationsQuery,
|
|
190
|
+
response: (0, envelopes_1.listOf)(exports.billingPortalConfigurationSchema),
|
|
191
|
+
sdk: 'billingPortal.configurations.list',
|
|
192
|
+
expandable: 'billing_portal.configuration',
|
|
193
|
+
}),
|
|
194
|
+
(0, route_1.defineRoute)({
|
|
195
|
+
operationId: 'retrieveBillingPortalConfiguration',
|
|
196
|
+
method: 'get',
|
|
197
|
+
path: '/v1/billing_portal/configurations/{id}',
|
|
198
|
+
tag: 'Customer portal',
|
|
199
|
+
summary: 'Retrieve a portal configuration',
|
|
200
|
+
auth: 'service',
|
|
201
|
+
scope: 'payments:read',
|
|
202
|
+
params: configurationId,
|
|
203
|
+
query: params_1.expandOnlyQuery,
|
|
204
|
+
response: exports.billingPortalConfigurationSchema,
|
|
205
|
+
sdk: 'billingPortal.configurations.retrieve',
|
|
206
|
+
expandable: 'billing_portal.configuration',
|
|
207
|
+
}),
|
|
208
|
+
(0, route_1.defineRoute)({
|
|
209
|
+
operationId: 'updateBillingPortalConfiguration',
|
|
210
|
+
method: 'post',
|
|
211
|
+
path: '/v1/billing_portal/configurations/{id}',
|
|
212
|
+
tag: 'Customer portal',
|
|
213
|
+
summary: 'Update a portal configuration',
|
|
214
|
+
description: 'Each named feature field replaces that field; the others are kept.',
|
|
215
|
+
auth: 'service',
|
|
216
|
+
scope: 'payments:write',
|
|
217
|
+
idempotent: true,
|
|
218
|
+
params: configurationId,
|
|
219
|
+
body: exports.updateBillingPortalConfigurationParams,
|
|
220
|
+
response: exports.billingPortalConfigurationSchema,
|
|
221
|
+
sdk: 'billingPortal.configurations.update',
|
|
222
|
+
}),
|
|
223
|
+
(0, route_1.defineRoute)({
|
|
224
|
+
operationId: 'createBillingPortalSession',
|
|
225
|
+
method: 'post',
|
|
226
|
+
path: '/v1/billing_portal/sessions',
|
|
227
|
+
tag: 'Customer portal',
|
|
228
|
+
summary: 'Create a portal session',
|
|
229
|
+
description: 'A one-hour URL of the Orbit-hosted portal for one customer. The URL is a bearer credential: hand it to that customer only, right away.',
|
|
230
|
+
auth: 'service',
|
|
231
|
+
scope: 'payments:write',
|
|
232
|
+
idempotent: true,
|
|
233
|
+
body: exports.createBillingPortalSessionParams,
|
|
234
|
+
response: exports.billingPortalSessionSchema,
|
|
235
|
+
sdk: 'billingPortal.sessions.create',
|
|
236
|
+
}),
|
|
237
|
+
];
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.creditNoteRoutes = exports.listCreditNotesQuery = exports.voidCreditNoteParams = exports.previewCreditNoteQuery = exports.createCreditNoteParams = exports.creditNoteSchema = exports.creditNoteLineItemSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const envelopes_1 = require("../../common/envelopes");
|
|
6
|
+
const objects_1 = require("../../common/objects");
|
|
7
|
+
const params_1 = require("../../common/params");
|
|
8
|
+
const primitives_1 = require("../../common/primitives");
|
|
9
|
+
const route_1 = require("../../route");
|
|
10
|
+
const invoices_1 = require("../../vocabulary/invoices");
|
|
11
|
+
const invoices_2 = require("./invoices");
|
|
12
|
+
const params_2 = require("./params");
|
|
13
|
+
/**
|
|
14
|
+
* Credit notes (`cn_…`, ADR 0018 §4): a finalized invoice credited — on an
|
|
15
|
+
* `open` one it reduces what is due; on a `paid` one it is given back
|
|
16
|
+
* (refunded through the invoice's payment, credited to the customer balance,
|
|
17
|
+
* or recorded as returned outside Orbit).
|
|
18
|
+
*/
|
|
19
|
+
exports.creditNoteLineItemSchema = (0, objects_1.defineComponent)('CreditNoteLineItem', zod_1.z
|
|
20
|
+
.object({
|
|
21
|
+
id: zod_1.z.string(),
|
|
22
|
+
object: zod_1.z.literal('credit_note_line_item'),
|
|
23
|
+
type: zod_1.z.enum(invoices_1.CREDIT_NOTE_LINE_TYPES),
|
|
24
|
+
invoice_line_item: zod_1.z.string().nullable().describe('The invoice line (`il_…`) it credits.'),
|
|
25
|
+
description: zod_1.z.string().nullable(),
|
|
26
|
+
quantity: zod_1.z.number().int().nullable(),
|
|
27
|
+
amount: primitives_1.amount.describe('Before tax; tax-inclusive when the invoice line is.'),
|
|
28
|
+
tax_amount: primitives_1.amount,
|
|
29
|
+
})
|
|
30
|
+
.strict());
|
|
31
|
+
exports.creditNoteSchema = (0, objects_1.defineObject)('credit_note', 'CreditNote', zod_1.z
|
|
32
|
+
.object({
|
|
33
|
+
id: zod_1.z.string(),
|
|
34
|
+
object: zod_1.z.literal('credit_note'),
|
|
35
|
+
livemode: primitives_1.livemode,
|
|
36
|
+
number: zod_1.z.string().describe('`<invoice number>-CN-<nn>`.'),
|
|
37
|
+
invoice: (0, objects_1.expandable)('invoice', '`in_…`, or the Invoice with `expand[]=invoice`.'),
|
|
38
|
+
customer: (0, objects_1.expandable)('customer', '`cus_…`, or the Customer with `expand[]=customer`.'),
|
|
39
|
+
status: zod_1.z.enum(invoices_1.CREDIT_NOTE_STATUSES),
|
|
40
|
+
type: zod_1.z.enum(invoices_1.CREDIT_NOTE_TYPES),
|
|
41
|
+
reason: zod_1.z.enum(invoices_1.CREDIT_NOTE_REASONS).nullable(),
|
|
42
|
+
currency: primitives_1.currency,
|
|
43
|
+
lines: (0, envelopes_1.listOf)(exports.creditNoteLineItemSchema),
|
|
44
|
+
subtotal: primitives_1.amount,
|
|
45
|
+
tax: primitives_1.amount,
|
|
46
|
+
total: primitives_1.amount.describe('What is credited, tax included.'),
|
|
47
|
+
refund_amount: primitives_1.amount.describe("Of `total`: refunded through the invoice's payment."),
|
|
48
|
+
credit_amount: primitives_1.amount.describe('Of `total`: credited to the customer balance.'),
|
|
49
|
+
out_of_band_amount: primitives_1.amount.describe('Of `total`: recorded as returned outside Orbit.'),
|
|
50
|
+
refund: zod_1.z.string().nullable().describe('The Refund (`re_…`) when part of it was refunded.'),
|
|
51
|
+
customer_balance_transaction: zod_1.z
|
|
52
|
+
.string()
|
|
53
|
+
.nullable()
|
|
54
|
+
.describe('The customer balance transaction (`cbtxn_…`) of `credit_amount`.'),
|
|
55
|
+
memo: zod_1.z.string().nullable(),
|
|
56
|
+
metadata: primitives_1.metadata,
|
|
57
|
+
voided_at: primitives_1.unixSeconds.nullable(),
|
|
58
|
+
created: primitives_1.unixSeconds,
|
|
59
|
+
})
|
|
60
|
+
.strict());
|
|
61
|
+
const creditNoteFields = {
|
|
62
|
+
invoice: params_1.idParam,
|
|
63
|
+
amount: params_2.amountParam
|
|
64
|
+
.optional()
|
|
65
|
+
.describe('Credit this much of the invoice, tax included, spread over its lines.'),
|
|
66
|
+
reason: zod_1.z.enum(invoices_1.CREDIT_NOTE_REASONS).optional(),
|
|
67
|
+
memo: (0, params_2.shortText)(5000).optional(),
|
|
68
|
+
refund_amount: params_2.amountParam.optional(),
|
|
69
|
+
credit_amount: params_2.amountParam.optional(),
|
|
70
|
+
out_of_band_amount: params_2.amountParam.optional(),
|
|
71
|
+
};
|
|
72
|
+
const creditNoteLineFields = {
|
|
73
|
+
type: zod_1.z.enum(invoices_1.CREDIT_NOTE_LINE_TYPES),
|
|
74
|
+
invoice_line_item: params_1.idParam.optional(),
|
|
75
|
+
amount: params_2.amountParam
|
|
76
|
+
.optional()
|
|
77
|
+
.describe('For an invoice line: the amount of it to credit (default all of it).'),
|
|
78
|
+
description: (0, params_2.shortText)(500).optional(),
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* Credit `lines`, or a whole `amount` (custom).
|
|
82
|
+
*
|
|
83
|
+
* On a `paid` invoice the credit must be distributed: `refund_amount` (through
|
|
84
|
+
* the invoice's payment; card only), `credit_amount` (to the customer balance)
|
|
85
|
+
* and `out_of_band_amount` must add up to the total. Omitted, all of it is
|
|
86
|
+
* refunded on a card invoice and credited to the balance otherwise. On an
|
|
87
|
+
* `open` invoice it reduces `amount_due` and none of the three apply.
|
|
88
|
+
*/
|
|
89
|
+
exports.createCreditNoteParams = zod_1.z
|
|
90
|
+
.object({
|
|
91
|
+
...creditNoteFields,
|
|
92
|
+
lines: zod_1.z
|
|
93
|
+
.array(zod_1.z.object({ ...creditNoteLineFields, quantity: params_2.quantityParam.optional() }).strict())
|
|
94
|
+
.min(1)
|
|
95
|
+
.max(100)
|
|
96
|
+
.optional(),
|
|
97
|
+
metadata: params_1.metadataCreateParam.optional(),
|
|
98
|
+
expand: params_1.expandParam.optional(),
|
|
99
|
+
})
|
|
100
|
+
.strict();
|
|
101
|
+
/** The create's fields as a query (`lines[0][type]=…`). */
|
|
102
|
+
exports.previewCreditNoteQuery = zod_1.z
|
|
103
|
+
.object({
|
|
104
|
+
...creditNoteFields,
|
|
105
|
+
lines: zod_1.z
|
|
106
|
+
.array(zod_1.z
|
|
107
|
+
.object({ ...creditNoteLineFields, quantity: (0, params_1.queryInteger)({ min: 0 }).optional() })
|
|
108
|
+
.strict())
|
|
109
|
+
.max(100)
|
|
110
|
+
.optional(),
|
|
111
|
+
})
|
|
112
|
+
.strict();
|
|
113
|
+
exports.voidCreditNoteParams = invoices_2.invoiceActionParams;
|
|
114
|
+
exports.listCreditNotesQuery = (0, params_1.listQuery)({
|
|
115
|
+
invoice: params_1.idParam.optional(),
|
|
116
|
+
customer: params_1.idParam.optional(),
|
|
117
|
+
});
|
|
118
|
+
const creditNoteId = { id: 'The credit note (`cn_…`).' };
|
|
119
|
+
exports.creditNoteRoutes = [
|
|
120
|
+
(0, route_1.defineRoute)({
|
|
121
|
+
operationId: 'createCreditNote',
|
|
122
|
+
method: 'post',
|
|
123
|
+
path: '/v1/credit_notes',
|
|
124
|
+
tag: 'Credit notes',
|
|
125
|
+
summary: 'Issue a credit note',
|
|
126
|
+
auth: 'service',
|
|
127
|
+
scope: 'payments:write',
|
|
128
|
+
idempotent: true,
|
|
129
|
+
body: exports.createCreditNoteParams,
|
|
130
|
+
response: exports.creditNoteSchema,
|
|
131
|
+
sdk: 'creditNotes.create',
|
|
132
|
+
expandable: 'credit_note',
|
|
133
|
+
}),
|
|
134
|
+
(0, route_1.defineRoute)({
|
|
135
|
+
operationId: 'listCreditNotes',
|
|
136
|
+
method: 'get',
|
|
137
|
+
path: '/v1/credit_notes',
|
|
138
|
+
tag: 'Credit notes',
|
|
139
|
+
summary: 'List credit notes',
|
|
140
|
+
auth: 'service',
|
|
141
|
+
scope: 'payments:read',
|
|
142
|
+
query: exports.listCreditNotesQuery,
|
|
143
|
+
response: (0, envelopes_1.listOf)(exports.creditNoteSchema),
|
|
144
|
+
sdk: 'creditNotes.list',
|
|
145
|
+
expandable: 'credit_note',
|
|
146
|
+
}),
|
|
147
|
+
(0, route_1.defineRoute)({
|
|
148
|
+
operationId: 'previewCreditNote',
|
|
149
|
+
method: 'get',
|
|
150
|
+
path: '/v1/credit_notes/preview',
|
|
151
|
+
tag: 'Credit notes',
|
|
152
|
+
summary: 'Preview a credit note',
|
|
153
|
+
description: 'The note `POST /v1/credit_notes` would issue with the same fields, computed and never stored (its `id` and `number` are empty).',
|
|
154
|
+
auth: 'service',
|
|
155
|
+
scope: 'payments:read',
|
|
156
|
+
query: exports.previewCreditNoteQuery,
|
|
157
|
+
response: exports.creditNoteSchema,
|
|
158
|
+
sdk: 'creditNotes.preview',
|
|
159
|
+
}),
|
|
160
|
+
(0, route_1.defineRoute)({
|
|
161
|
+
operationId: 'retrieveCreditNote',
|
|
162
|
+
method: 'get',
|
|
163
|
+
path: '/v1/credit_notes/{id}',
|
|
164
|
+
tag: 'Credit notes',
|
|
165
|
+
summary: 'Retrieve a credit note',
|
|
166
|
+
auth: 'service',
|
|
167
|
+
scope: 'payments:read',
|
|
168
|
+
params: creditNoteId,
|
|
169
|
+
query: params_1.expandOnlyQuery,
|
|
170
|
+
response: exports.creditNoteSchema,
|
|
171
|
+
sdk: 'creditNotes.retrieve',
|
|
172
|
+
expandable: 'credit_note',
|
|
173
|
+
}),
|
|
174
|
+
(0, route_1.defineRoute)({
|
|
175
|
+
operationId: 'voidCreditNote',
|
|
176
|
+
method: 'post',
|
|
177
|
+
path: '/v1/credit_notes/{id}/void',
|
|
178
|
+
tag: 'Credit notes',
|
|
179
|
+
summary: 'Void a credit note',
|
|
180
|
+
auth: 'service',
|
|
181
|
+
scope: 'payments:write',
|
|
182
|
+
idempotent: true,
|
|
183
|
+
params: creditNoteId,
|
|
184
|
+
body: exports.voidCreditNoteParams,
|
|
185
|
+
response: exports.creditNoteSchema,
|
|
186
|
+
sdk: 'creditNotes.voidCreditNote',
|
|
187
|
+
expandable: 'credit_note',
|
|
188
|
+
}),
|
|
189
|
+
];
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.customerBalanceTransactionRoutes = exports.listCustomerBalanceTransactionsQuery = exports.createCustomerBalanceTransactionParams = exports.customerBalanceTransactionSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const envelopes_1 = require("../../common/envelopes");
|
|
6
|
+
const objects_1 = require("../../common/objects");
|
|
7
|
+
const params_1 = require("../../common/params");
|
|
8
|
+
const primitives_1 = require("../../common/primitives");
|
|
9
|
+
const route_1 = require("../../route");
|
|
10
|
+
const invoices_1 = require("../../vocabulary/invoices");
|
|
11
|
+
const params_2 = require("./params");
|
|
12
|
+
/**
|
|
13
|
+
* The customer balance ledger (`cbtxn_…`, ADR 0018 §3): every movement of a
|
|
14
|
+
* customer's balance. Negative is credit the customer holds (Stripe's
|
|
15
|
+
* convention), applied to their next invoice when it finalizes.
|
|
16
|
+
*/
|
|
17
|
+
exports.customerBalanceTransactionSchema = (0, objects_1.defineObject)('customer_balance_transaction', 'CustomerBalanceTransaction', zod_1.z
|
|
18
|
+
.object({
|
|
19
|
+
id: zod_1.z.string(),
|
|
20
|
+
object: zod_1.z.literal('customer_balance_transaction'),
|
|
21
|
+
livemode: primitives_1.livemode,
|
|
22
|
+
customer: (0, objects_1.expandable)('customer', '`cus_…`, or the Customer with `expand[]=customer`.'),
|
|
23
|
+
type: zod_1.z.enum(invoices_1.CUSTOMER_BALANCE_TRANSACTION_TYPES),
|
|
24
|
+
amount: primitives_1.signedAmount.describe('SIGNED: negative credits the customer, positive debits.'),
|
|
25
|
+
currency: primitives_1.currency,
|
|
26
|
+
ending_balance: primitives_1.signedAmount.describe('SIGNED: the balance after this transaction.'),
|
|
27
|
+
description: zod_1.z.string().nullable(),
|
|
28
|
+
invoice: (0, objects_1.expandable)('invoice', 'The invoice it moved with (`in_…`, or the Invoice with `expand[]=invoice`).').nullable(),
|
|
29
|
+
credit_note: zod_1.z.string().nullable().describe('The credit note (`cn_…`) it came from.'),
|
|
30
|
+
metadata: primitives_1.metadata,
|
|
31
|
+
created: primitives_1.unixSeconds,
|
|
32
|
+
})
|
|
33
|
+
.strict());
|
|
34
|
+
/** An adjustment: a negative `amount` credits the customer, a positive one adds to what they owe. */
|
|
35
|
+
exports.createCustomerBalanceTransactionParams = zod_1.z
|
|
36
|
+
.object({
|
|
37
|
+
amount: params_2.signedAmountParam.describe('SIGNED: negative credits the customer, positive debits.'),
|
|
38
|
+
currency: params_2.currencyParam,
|
|
39
|
+
description: (0, params_2.shortText)(350).optional(),
|
|
40
|
+
metadata: params_1.metadataCreateParam.optional(),
|
|
41
|
+
expand: params_1.expandParam.optional(),
|
|
42
|
+
})
|
|
43
|
+
.strict();
|
|
44
|
+
exports.listCustomerBalanceTransactionsQuery = (0, params_1.listQuery)({});
|
|
45
|
+
const customerId = 'The customer (`cus_…`).';
|
|
46
|
+
exports.customerBalanceTransactionRoutes = [
|
|
47
|
+
(0, route_1.defineRoute)({
|
|
48
|
+
operationId: 'createCustomerBalanceTransaction',
|
|
49
|
+
method: 'post',
|
|
50
|
+
path: '/v1/customers/{id}/balance_transactions',
|
|
51
|
+
tag: 'Customer balance',
|
|
52
|
+
summary: "Adjust a customer's balance",
|
|
53
|
+
auth: 'service',
|
|
54
|
+
scope: 'payments:write',
|
|
55
|
+
idempotent: true,
|
|
56
|
+
params: { id: customerId },
|
|
57
|
+
body: exports.createCustomerBalanceTransactionParams,
|
|
58
|
+
response: exports.customerBalanceTransactionSchema,
|
|
59
|
+
sdk: 'customerBalanceTransactions.create',
|
|
60
|
+
expandable: 'customer_balance_transaction',
|
|
61
|
+
}),
|
|
62
|
+
(0, route_1.defineRoute)({
|
|
63
|
+
operationId: 'listCustomerBalanceTransactions',
|
|
64
|
+
method: 'get',
|
|
65
|
+
path: '/v1/customers/{id}/balance_transactions',
|
|
66
|
+
tag: 'Customer balance',
|
|
67
|
+
summary: "List a customer's balance transactions",
|
|
68
|
+
auth: 'service',
|
|
69
|
+
scope: 'payments:read',
|
|
70
|
+
params: { id: customerId },
|
|
71
|
+
query: exports.listCustomerBalanceTransactionsQuery,
|
|
72
|
+
response: (0, envelopes_1.listOf)(exports.customerBalanceTransactionSchema),
|
|
73
|
+
sdk: 'customerBalanceTransactions.list',
|
|
74
|
+
expandable: 'customer_balance_transaction',
|
|
75
|
+
}),
|
|
76
|
+
(0, route_1.defineRoute)({
|
|
77
|
+
operationId: 'retrieveCustomerBalanceTransaction',
|
|
78
|
+
method: 'get',
|
|
79
|
+
path: '/v1/customers/{id}/balance_transactions/{transaction}',
|
|
80
|
+
tag: 'Customer balance',
|
|
81
|
+
summary: 'Retrieve a customer balance transaction',
|
|
82
|
+
auth: 'service',
|
|
83
|
+
scope: 'payments:read',
|
|
84
|
+
params: { id: customerId, transaction: 'The balance transaction (`cbtxn_…`).' },
|
|
85
|
+
query: params_1.expandOnlyQuery,
|
|
86
|
+
response: exports.customerBalanceTransactionSchema,
|
|
87
|
+
sdk: 'customerBalanceTransactions.retrieve',
|
|
88
|
+
expandable: 'customer_balance_transaction',
|
|
89
|
+
}),
|
|
90
|
+
];
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.billingEngineRoutes = void 0;
|
|
18
|
+
// Contracts of this group: one module per resource, re-exported here, and
|
|
19
|
+
// their routes concatenated into `billingEngineRoutes`.
|
|
20
|
+
const billingPortal_1 = require("./billingPortal");
|
|
21
|
+
const creditNotes_1 = require("./creditNotes");
|
|
22
|
+
const customerBalanceTransactions_1 = require("./customerBalanceTransactions");
|
|
23
|
+
const invoiceItems_1 = require("./invoiceItems");
|
|
24
|
+
const invoices_1 = require("./invoices");
|
|
25
|
+
const public_1 = require("./public");
|
|
26
|
+
const subscriptions_1 = require("./subscriptions");
|
|
27
|
+
__exportStar(require("./billingPortal"), exports);
|
|
28
|
+
__exportStar(require("./creditNotes"), exports);
|
|
29
|
+
__exportStar(require("./customerBalanceTransactions"), exports);
|
|
30
|
+
__exportStar(require("./invoiceItems"), exports);
|
|
31
|
+
__exportStar(require("./invoices"), exports);
|
|
32
|
+
__exportStar(require("./public"), exports);
|
|
33
|
+
__exportStar(require("./subscriptions"), exports);
|
|
34
|
+
/** Orbit's native billing engine (ADR 0018): subscriptions, invoices, credit notes, the balance ledger and the customer portal. */
|
|
35
|
+
exports.billingEngineRoutes = [
|
|
36
|
+
...subscriptions_1.subscriptionRoutes,
|
|
37
|
+
...invoices_1.invoiceRoutes,
|
|
38
|
+
...invoiceItems_1.invoiceItemRoutes,
|
|
39
|
+
...creditNotes_1.creditNoteRoutes,
|
|
40
|
+
...customerBalanceTransactions_1.customerBalanceTransactionRoutes,
|
|
41
|
+
...billingPortal_1.billingPortalRoutes,
|
|
42
|
+
...public_1.publicBillingRoutes,
|
|
43
|
+
];
|