@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,174 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.promotionCodeRoutes = exports.listPromotionCodesQuery = exports.updatePromotionCodeParams = exports.createPromotionCodeParams = exports.promotionCodeSchema = exports.promotionCodeRestrictionsSchema = 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 catalog_1 = require("../../vocabulary/catalog");
|
|
11
|
+
const shared_1 = require("./shared");
|
|
12
|
+
/**
|
|
13
|
+
* Promotion codes (`promo_…`, ADR 0018) — a customer-facing `code` that
|
|
14
|
+
* redeems a coupon, with its own limits. Codes are case-insensitive and unique
|
|
15
|
+
* among a merchant's ACTIVE codes.
|
|
16
|
+
*/
|
|
17
|
+
exports.promotionCodeRestrictionsSchema = (0, objects_1.defineComponent)('PromotionCodeRestrictions', zod_1.z
|
|
18
|
+
.object({
|
|
19
|
+
first_time_transaction: zod_1.z
|
|
20
|
+
.boolean()
|
|
21
|
+
.describe("Only a customer's first transaction may redeem it."),
|
|
22
|
+
minimum_amount: primitives_1.amount
|
|
23
|
+
.nullable()
|
|
24
|
+
.describe('The smallest order total it applies to, in `minimum_amount_currency`.'),
|
|
25
|
+
minimum_amount_currency: primitives_1.currency.nullable(),
|
|
26
|
+
})
|
|
27
|
+
.strict());
|
|
28
|
+
exports.promotionCodeSchema = (0, objects_1.defineObject)('promotion_code', 'PromotionCode', zod_1.z
|
|
29
|
+
.object({
|
|
30
|
+
id: zod_1.z.string(),
|
|
31
|
+
object: zod_1.z.literal('promotion_code'),
|
|
32
|
+
livemode: primitives_1.livemode,
|
|
33
|
+
code: zod_1.z.string(),
|
|
34
|
+
coupon: (0, objects_1.expandable)('coupon', 'The coupon it redeems: its id, or the Coupon with `expand[]=coupon`.'),
|
|
35
|
+
customer: (0, objects_1.expandable)('customer', 'The one customer who may redeem it (`cus_…`, or the Customer with `expand[]=customer`); `null` for anyone.').nullable(),
|
|
36
|
+
active: zod_1.z.boolean(),
|
|
37
|
+
max_redemptions: zod_1.z.number().int().nullable(),
|
|
38
|
+
expires_at: primitives_1.unixSeconds.nullable().describe("Never after the coupon's `redeem_by`."),
|
|
39
|
+
times_redeemed: zod_1.z.number().int(),
|
|
40
|
+
restrictions: exports.promotionCodeRestrictionsSchema,
|
|
41
|
+
metadata: primitives_1.metadata,
|
|
42
|
+
created: primitives_1.unixSeconds,
|
|
43
|
+
})
|
|
44
|
+
.strict(), {
|
|
45
|
+
examples: [
|
|
46
|
+
{
|
|
47
|
+
id: 'promo_0193b8f2c1a87d3e9f4c',
|
|
48
|
+
object: 'promotion_code',
|
|
49
|
+
livemode: false,
|
|
50
|
+
code: 'SUMMER25',
|
|
51
|
+
coupon: 'SUMMER25',
|
|
52
|
+
customer: null,
|
|
53
|
+
active: true,
|
|
54
|
+
max_redemptions: null,
|
|
55
|
+
expires_at: null,
|
|
56
|
+
times_redeemed: 0,
|
|
57
|
+
restrictions: {
|
|
58
|
+
first_time_transaction: true,
|
|
59
|
+
minimum_amount: null,
|
|
60
|
+
minimum_amount_currency: null,
|
|
61
|
+
},
|
|
62
|
+
metadata: {},
|
|
63
|
+
created: 1793750400,
|
|
64
|
+
},
|
|
65
|
+
],
|
|
66
|
+
});
|
|
67
|
+
const code = zod_1.z
|
|
68
|
+
.string()
|
|
69
|
+
.regex(new RegExp(`^[A-Za-z0-9]{1,${catalog_1.CATALOG_LIMITS.promotionCodeMax}}$`), `a code is 1–${catalog_1.CATALOG_LIMITS.promotionCodeMax} letters and digits`);
|
|
70
|
+
exports.createPromotionCodeParams = zod_1.z
|
|
71
|
+
.object({
|
|
72
|
+
coupon: params_1.idParam,
|
|
73
|
+
code: code.optional().describe('Letters and digits; generated when absent.'),
|
|
74
|
+
customer: params_1.idParam.optional().describe('Only this customer (`cus_…`) may redeem it.'),
|
|
75
|
+
active: zod_1.z.boolean().optional(),
|
|
76
|
+
max_redemptions: shared_1.countParam.optional(),
|
|
77
|
+
expires_at: shared_1.positiveUnixSecondsParam.optional(),
|
|
78
|
+
restrictions: zod_1.z
|
|
79
|
+
.object({
|
|
80
|
+
first_time_transaction: zod_1.z.boolean().optional(),
|
|
81
|
+
minimum_amount: shared_1.baseUnitAmountParam.optional(),
|
|
82
|
+
minimum_amount_currency: primitives_1.currency.optional(),
|
|
83
|
+
})
|
|
84
|
+
.strict()
|
|
85
|
+
.superRefine((restrictions, ctx) => {
|
|
86
|
+
if ((restrictions.minimum_amount === undefined) !==
|
|
87
|
+
(restrictions.minimum_amount_currency === undefined)) {
|
|
88
|
+
ctx.addIssue({
|
|
89
|
+
code: 'custom',
|
|
90
|
+
path: ['minimum_amount_currency'],
|
|
91
|
+
message: 'minimum_amount and minimum_amount_currency go together',
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
(0, shared_1.checkAmountBound)(ctx, restrictions.minimum_amount, restrictions.minimum_amount_currency, [
|
|
95
|
+
'minimum_amount',
|
|
96
|
+
]);
|
|
97
|
+
})
|
|
98
|
+
.optional(),
|
|
99
|
+
metadata: params_1.metadataCreateParam.optional(),
|
|
100
|
+
expand: params_1.expandParam.optional(),
|
|
101
|
+
})
|
|
102
|
+
.strict();
|
|
103
|
+
exports.updatePromotionCodeParams = zod_1.z
|
|
104
|
+
.object({
|
|
105
|
+
active: zod_1.z.boolean().optional(),
|
|
106
|
+
metadata: params_1.metadataUpdateParam.optional(),
|
|
107
|
+
expand: params_1.expandParam.optional(),
|
|
108
|
+
})
|
|
109
|
+
.strict();
|
|
110
|
+
exports.listPromotionCodesQuery = (0, params_1.listQuery)({
|
|
111
|
+
code: zod_1.z.string().min(1).max(255).optional().describe('Case-insensitive.'),
|
|
112
|
+
coupon: params_1.idParam.optional(),
|
|
113
|
+
customer: params_1.idParam.optional(),
|
|
114
|
+
active: shared_1.queryFlag.optional(),
|
|
115
|
+
});
|
|
116
|
+
exports.promotionCodeRoutes = [
|
|
117
|
+
(0, route_1.defineRoute)({
|
|
118
|
+
operationId: 'createPromotionCode',
|
|
119
|
+
method: 'post',
|
|
120
|
+
path: '/v1/promotion_codes',
|
|
121
|
+
tag: 'Promotion codes',
|
|
122
|
+
summary: 'Create a promotion code',
|
|
123
|
+
auth: 'service',
|
|
124
|
+
scope: 'payments:write',
|
|
125
|
+
idempotent: true,
|
|
126
|
+
body: exports.createPromotionCodeParams,
|
|
127
|
+
response: exports.promotionCodeSchema,
|
|
128
|
+
sdk: 'promotionCodes.create',
|
|
129
|
+
expandable: 'promotion_code',
|
|
130
|
+
}),
|
|
131
|
+
(0, route_1.defineRoute)({
|
|
132
|
+
operationId: 'listPromotionCodes',
|
|
133
|
+
method: 'get',
|
|
134
|
+
path: '/v1/promotion_codes',
|
|
135
|
+
tag: 'Promotion codes',
|
|
136
|
+
summary: 'List promotion codes',
|
|
137
|
+
auth: 'service',
|
|
138
|
+
scope: 'payments:read',
|
|
139
|
+
query: exports.listPromotionCodesQuery,
|
|
140
|
+
response: (0, envelopes_1.listOf)(exports.promotionCodeSchema),
|
|
141
|
+
sdk: 'promotionCodes.list',
|
|
142
|
+
expandable: 'promotion_code',
|
|
143
|
+
}),
|
|
144
|
+
(0, route_1.defineRoute)({
|
|
145
|
+
operationId: 'retrievePromotionCode',
|
|
146
|
+
method: 'get',
|
|
147
|
+
path: '/v1/promotion_codes/{id}',
|
|
148
|
+
tag: 'Promotion codes',
|
|
149
|
+
summary: 'Retrieve a promotion code',
|
|
150
|
+
auth: 'service',
|
|
151
|
+
scope: 'payments:read',
|
|
152
|
+
params: { id: 'The promotion code (`promo_…`).' },
|
|
153
|
+
query: params_1.expandOnlyQuery,
|
|
154
|
+
response: exports.promotionCodeSchema,
|
|
155
|
+
sdk: 'promotionCodes.retrieve',
|
|
156
|
+
expandable: 'promotion_code',
|
|
157
|
+
}),
|
|
158
|
+
(0, route_1.defineRoute)({
|
|
159
|
+
operationId: 'updatePromotionCode',
|
|
160
|
+
method: 'post',
|
|
161
|
+
path: '/v1/promotion_codes/{id}',
|
|
162
|
+
tag: 'Promotion codes',
|
|
163
|
+
summary: 'Update a promotion code',
|
|
164
|
+
description: 'Only `active` and `metadata` change.',
|
|
165
|
+
auth: 'service',
|
|
166
|
+
scope: 'payments:write',
|
|
167
|
+
idempotent: true,
|
|
168
|
+
params: { id: 'The promotion code (`promo_…`).' },
|
|
169
|
+
body: exports.updatePromotionCodeParams,
|
|
170
|
+
response: exports.promotionCodeSchema,
|
|
171
|
+
sdk: 'promotionCodes.update',
|
|
172
|
+
expandable: 'promotion_code',
|
|
173
|
+
}),
|
|
174
|
+
];
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.clearing = exports.queryFlag = exports.positiveUnixSecondsParam = exports.countParam = exports.baseUnitAmountParam = void 0;
|
|
4
|
+
exports.queryIdList = queryIdList;
|
|
5
|
+
exports.issuer = issuer;
|
|
6
|
+
exports.amountWithinBound = amountWithinBound;
|
|
7
|
+
exports.checkAmountBound = checkAmountBound;
|
|
8
|
+
const zod_1 = require("zod");
|
|
9
|
+
const objects_1 = require("../../common/objects");
|
|
10
|
+
const params_1 = require("../../common/params");
|
|
11
|
+
const catalog_1 = require("../../vocabulary/catalog");
|
|
12
|
+
const money_1 = require("../../vocabulary/money");
|
|
13
|
+
/**
|
|
14
|
+
* Request pieces the catalog's bodies share — and that every other body naming
|
|
15
|
+
* an amount, a currency or an inline price reuses (checkout line items,
|
|
16
|
+
* invoice items), so one shape rule is written once and every caller refuses
|
|
17
|
+
* the same mistake with the same `param`.
|
|
18
|
+
*/
|
|
19
|
+
/** A canonical base-unit integer string: `"1999"`, never `"19.99"` or `1999`. */
|
|
20
|
+
exports.baseUnitAmountParam = zod_1.z
|
|
21
|
+
.string()
|
|
22
|
+
.refine(money_1.isBaseUnitString, 'must be a non-negative integer string in the smallest currency unit')
|
|
23
|
+
.describe('Base units of the currency, as an integer string (`"1999"` is 19.99 EUR).');
|
|
24
|
+
/** A positive count that fits a Postgres `integer`. */
|
|
25
|
+
exports.countParam = zod_1.z.number().int().min(1).max(2147483647);
|
|
26
|
+
/** A future instant in a body (`redeem_by`, `expires_at`): positive Unix seconds. */
|
|
27
|
+
exports.positiveUnixSecondsParam = zod_1.z.number().int().positive().max(params_1.MAX_UNIX_SECONDS);
|
|
28
|
+
/**
|
|
29
|
+
* A boolean filter in a query string. A typed caller passes `true` / `false`
|
|
30
|
+
* (the SDK spells it for the URL); the URL carries `'true'` / `'false'`,
|
|
31
|
+
* which the gateway reads the same.
|
|
32
|
+
*/
|
|
33
|
+
exports.queryFlag = params_1.queryBoolean;
|
|
34
|
+
/** `ids[]=a&ids[]=b` or `ids=a`: one id is a list of one. */
|
|
35
|
+
function queryIdList(max) {
|
|
36
|
+
return (0, objects_1.describe)(zod_1.z
|
|
37
|
+
.union([zod_1.z.string(), zod_1.z.array(zod_1.z.string())])
|
|
38
|
+
.transform((value) => (typeof value === 'string' ? [value] : value))
|
|
39
|
+
.pipe(zod_1.z.array(zod_1.z.string().min(1).max(255)).min(1).max(max)), {
|
|
40
|
+
jsonSchema: {
|
|
41
|
+
type: 'array',
|
|
42
|
+
items: { type: 'string', maxLength: 255 },
|
|
43
|
+
minItems: 1,
|
|
44
|
+
maxItems: max,
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
/** `""` on an update clears the field (Stripe's rule): the parsed value is `null`. */
|
|
49
|
+
const clearing = (schema) => zod_1.z
|
|
50
|
+
.union([schema, zod_1.z.literal('')])
|
|
51
|
+
.transform((value) => (value === '' ? null : value));
|
|
52
|
+
exports.clearing = clearing;
|
|
53
|
+
function issuer(ctx) {
|
|
54
|
+
let failed = false;
|
|
55
|
+
return {
|
|
56
|
+
issue: (path, message) => {
|
|
57
|
+
failed = true;
|
|
58
|
+
ctx.addIssue({ code: 'custom', path, message });
|
|
59
|
+
},
|
|
60
|
+
failed: () => failed,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
/** Refuse an amount above the catalog's bound for `currency`. */
|
|
64
|
+
function amountWithinBound(issue, amount, currency, path) {
|
|
65
|
+
if (amount === undefined || !(0, money_1.isBaseUnitString)(amount))
|
|
66
|
+
return;
|
|
67
|
+
if (BigInt(amount) > (0, catalog_1.maxBaseUnits)(currency)) {
|
|
68
|
+
issue(path, `must be at most ${(0, catalog_1.maxBaseUnits)(currency)} (${catalog_1.CATALOG_MAX_WHOLE_UNITS} whole ${currency})`);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/** Add a bound issue for a coupon or promotion amount in `currency`. */
|
|
72
|
+
function checkAmountBound(ctx, amount, currency, path) {
|
|
73
|
+
if (currency !== undefined)
|
|
74
|
+
amountWithinBound(issuer(ctx).issue, amount, currency, path);
|
|
75
|
+
}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.testClockRoutes = exports.listTestClocksQuery = exports.advanceTestClockParams = exports.createTestClockParams = exports.deletedTestClockSchema = exports.testClockSchema = 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 catalog_1 = require("../../vocabulary/catalog");
|
|
11
|
+
/**
|
|
12
|
+
* Test clocks (`clock_…`, ADR 0018 §3, test mode only). Customers attached to
|
|
13
|
+
* a clock — and every subscription and invoice of theirs — live at
|
|
14
|
+
* `frozen_time` instead of the wall clock, so a trial, a renewal or a dunning
|
|
15
|
+
* schedule runs in seconds. Advancing it runs the engine for everything on the
|
|
16
|
+
* clock up to the new time.
|
|
17
|
+
*/
|
|
18
|
+
exports.testClockSchema = (0, objects_1.defineObject)('test_helpers.test_clock', 'TestClock', zod_1.z
|
|
19
|
+
.object({
|
|
20
|
+
id: zod_1.z.string(),
|
|
21
|
+
object: zod_1.z.literal('test_helpers.test_clock'),
|
|
22
|
+
livemode: zod_1.z.literal(false).describe('Always `false`: test clocks exist in test mode only.'),
|
|
23
|
+
name: zod_1.z.string().nullable(),
|
|
24
|
+
frozen_time: primitives_1.unixSeconds.describe('The instant everything on the clock lives at.'),
|
|
25
|
+
status: zod_1.z.enum(catalog_1.TEST_CLOCK_STATUSES),
|
|
26
|
+
deletes_after: primitives_1.unixSeconds.describe('Deleted, with everything on it, after this instant.'),
|
|
27
|
+
created: primitives_1.unixSeconds,
|
|
28
|
+
})
|
|
29
|
+
.strict(), {
|
|
30
|
+
examples: [
|
|
31
|
+
{
|
|
32
|
+
id: 'clock_0193b8f2c1a87d3e9f4d',
|
|
33
|
+
object: 'test_helpers.test_clock',
|
|
34
|
+
livemode: false,
|
|
35
|
+
name: 'Annual renewal',
|
|
36
|
+
frozen_time: 1793750400,
|
|
37
|
+
status: 'ready',
|
|
38
|
+
deletes_after: 1796342400,
|
|
39
|
+
created: 1793750400,
|
|
40
|
+
},
|
|
41
|
+
],
|
|
42
|
+
});
|
|
43
|
+
exports.deletedTestClockSchema = (0, objects_1.defineComponent)('DeletedTestClock', (0, envelopes_1.deletedOf)('test_helpers.test_clock'));
|
|
44
|
+
exports.createTestClockParams = zod_1.z
|
|
45
|
+
.object({ frozen_time: params_1.unixSecondsParam, name: zod_1.z.string().min(1).max(300).optional() })
|
|
46
|
+
.strict();
|
|
47
|
+
exports.advanceTestClockParams = zod_1.z
|
|
48
|
+
.object({
|
|
49
|
+
frozen_time: params_1.unixSecondsParam.describe("Later than the clock's current `frozen_time`, and at most two years after it."),
|
|
50
|
+
})
|
|
51
|
+
.strict();
|
|
52
|
+
exports.listTestClocksQuery = (0, params_1.listQuery)({});
|
|
53
|
+
const id = { id: 'The test clock (`clock_…`).' };
|
|
54
|
+
exports.testClockRoutes = [
|
|
55
|
+
(0, route_1.defineRoute)({
|
|
56
|
+
operationId: 'createTestClock',
|
|
57
|
+
method: 'post',
|
|
58
|
+
path: '/v1/test_helpers/test_clocks',
|
|
59
|
+
tag: 'Test clocks',
|
|
60
|
+
summary: 'Create a test clock',
|
|
61
|
+
auth: 'service',
|
|
62
|
+
scope: 'payments:write',
|
|
63
|
+
idempotent: true,
|
|
64
|
+
testModeOnly: true,
|
|
65
|
+
body: exports.createTestClockParams,
|
|
66
|
+
response: exports.testClockSchema,
|
|
67
|
+
sdk: 'testHelpers.testClocks.create',
|
|
68
|
+
}),
|
|
69
|
+
(0, route_1.defineRoute)({
|
|
70
|
+
operationId: 'listTestClocks',
|
|
71
|
+
method: 'get',
|
|
72
|
+
path: '/v1/test_helpers/test_clocks',
|
|
73
|
+
tag: 'Test clocks',
|
|
74
|
+
summary: 'List test clocks',
|
|
75
|
+
auth: 'service',
|
|
76
|
+
scope: 'payments:read',
|
|
77
|
+
testModeOnly: true,
|
|
78
|
+
query: exports.listTestClocksQuery,
|
|
79
|
+
response: (0, envelopes_1.listOf)(exports.testClockSchema),
|
|
80
|
+
sdk: 'testHelpers.testClocks.list',
|
|
81
|
+
expandable: 'test_helpers.test_clock',
|
|
82
|
+
}),
|
|
83
|
+
(0, route_1.defineRoute)({
|
|
84
|
+
operationId: 'retrieveTestClock',
|
|
85
|
+
method: 'get',
|
|
86
|
+
path: '/v1/test_helpers/test_clocks/{id}',
|
|
87
|
+
tag: 'Test clocks',
|
|
88
|
+
summary: 'Retrieve a test clock',
|
|
89
|
+
auth: 'service',
|
|
90
|
+
scope: 'payments:read',
|
|
91
|
+
testModeOnly: true,
|
|
92
|
+
params: id,
|
|
93
|
+
query: params_1.expandOnlyQuery,
|
|
94
|
+
response: exports.testClockSchema,
|
|
95
|
+
sdk: 'testHelpers.testClocks.retrieve',
|
|
96
|
+
}),
|
|
97
|
+
(0, route_1.defineRoute)({
|
|
98
|
+
operationId: 'advanceTestClock',
|
|
99
|
+
method: 'post',
|
|
100
|
+
path: '/v1/test_helpers/test_clocks/{id}/advance',
|
|
101
|
+
tag: 'Test clocks',
|
|
102
|
+
summary: 'Advance a test clock',
|
|
103
|
+
description: 'Moves `frozen_time` forward and runs the billing engine for everything on the clock up to it: trials end, subscriptions renew, invoices finalize and dunning retries.',
|
|
104
|
+
auth: 'service',
|
|
105
|
+
scope: 'payments:write',
|
|
106
|
+
idempotent: true,
|
|
107
|
+
testModeOnly: true,
|
|
108
|
+
params: id,
|
|
109
|
+
body: exports.advanceTestClockParams,
|
|
110
|
+
response: exports.testClockSchema,
|
|
111
|
+
sdk: 'testHelpers.testClocks.advance',
|
|
112
|
+
}),
|
|
113
|
+
(0, route_1.defineRoute)({
|
|
114
|
+
operationId: 'deleteTestClock',
|
|
115
|
+
method: 'delete',
|
|
116
|
+
path: '/v1/test_helpers/test_clocks/{id}',
|
|
117
|
+
tag: 'Test clocks',
|
|
118
|
+
summary: 'Delete a test clock',
|
|
119
|
+
description: 'Every live subscription on the clock is cancelled at its frozen time; the clock stays readable to the objects that name it.',
|
|
120
|
+
auth: 'service',
|
|
121
|
+
scope: 'payments:write',
|
|
122
|
+
testModeOnly: true,
|
|
123
|
+
params: id,
|
|
124
|
+
response: exports.deletedTestClockSchema,
|
|
125
|
+
sdk: 'testHelpers.testClocks.del',
|
|
126
|
+
}),
|
|
127
|
+
];
|