@peable.to/contracts 0.4.0 → 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/address.js +81 -0
- package/dist/cjs/common/envelopes.js +101 -0
- package/dist/cjs/common/objects.js +85 -0
- package/dist/cjs/common/params.js +211 -0
- package/dist/cjs/common/primitives.js +39 -0
- package/dist/cjs/contributions.js +22 -0
- package/dist/cjs/index.js +40 -137
- package/dist/cjs/openapi/document.js +297 -0
- package/dist/cjs/openapi/index.js +7 -0
- package/dist/cjs/openapi/webhooks.js +17 -0
- package/dist/cjs/resources/billingEngine/billingPortal.js +237 -0
- package/dist/cjs/resources/billingEngine/creditNotes.js +189 -0
- package/dist/cjs/resources/billingEngine/customerBalanceTransactions.js +90 -0
- package/dist/cjs/resources/billingEngine/index.js +43 -0
- package/dist/cjs/resources/billingEngine/invoiceItems.js +155 -0
- package/dist/cjs/resources/billingEngine/invoices.js +509 -0
- package/dist/cjs/resources/billingEngine/params.js +43 -0
- package/dist/cjs/resources/billingEngine/public.js +326 -0
- package/dist/cjs/resources/billingEngine/subscriptions.js +476 -0
- package/dist/cjs/resources/catalog/billing.js +755 -0
- package/dist/cjs/resources/catalog/billingSettings.js +131 -0
- package/dist/cjs/resources/catalog/coupons.js +222 -0
- package/dist/cjs/resources/catalog/entitlements.js +257 -0
- package/dist/cjs/resources/catalog/index.js +58 -0
- package/dist/cjs/resources/catalog/meters.js +279 -0
- package/dist/cjs/resources/catalog/prices.js +423 -0
- package/dist/cjs/resources/catalog/products.js +228 -0
- package/dist/cjs/resources/catalog/promotionCodes.js +174 -0
- package/dist/cjs/resources/catalog/shared.js +75 -0
- package/dist/cjs/resources/catalog/testClocks.js +127 -0
- package/dist/cjs/resources/checkout/checkoutSessions.js +582 -0
- package/dist/cjs/resources/checkout/contributions.js +172 -0
- package/dist/cjs/resources/checkout/files.js +133 -0
- package/dist/cjs/resources/checkout/index.js +57 -0
- package/dist/cjs/resources/checkout/merchants.js +290 -0
- package/dist/cjs/resources/checkout/paymentLinks.js +330 -0
- package/dist/cjs/resources/checkout/paymentMethodConfigurations.js +262 -0
- package/dist/cjs/resources/checkout/shared.js +368 -0
- package/dist/cjs/resources/connect/account.js +332 -0
- package/dist/cjs/resources/connect/applicationFees.js +113 -0
- package/dist/cjs/resources/connect/balance.js +212 -0
- package/dist/cjs/resources/connect/connectedAccounts.js +260 -0
- package/dist/cjs/resources/connect/index.js +51 -0
- package/dist/cjs/resources/connect/onboarding.js +82 -0
- package/dist/cjs/resources/connect/payouts.js +196 -0
- package/dist/cjs/resources/connect/reporting.js +235 -0
- package/dist/cjs/resources/connect/requestLogs.js +110 -0
- package/dist/cjs/resources/connect/transfers.js +227 -0
- package/dist/cjs/resources/core/customers.js +194 -0
- package/dist/cjs/resources/core/index.js +23 -0
- package/dist/cjs/resources/core/paymentMethods.js +134 -0
- package/dist/cjs/resources/events/events.js +357 -0
- package/dist/cjs/resources/events/index.js +29 -0
- package/dist/cjs/resources/events/webhookDeliveries.js +93 -0
- package/dist/cjs/resources/events/webhookEndpoints.js +215 -0
- package/dist/cjs/resources/payments/charges.js +157 -0
- package/dist/cjs/resources/payments/disputes.js +204 -0
- package/dist/cjs/resources/payments/index.js +41 -0
- package/dist/cjs/resources/payments/paymentIntents.js +529 -0
- package/dist/cjs/resources/payments/refunds.js +245 -0
- package/dist/cjs/resources/payments/setupIntents.js +158 -0
- package/dist/cjs/resources/payments/social.js +182 -0
- package/dist/cjs/resources/payments/testHelpers.js +39 -0
- package/dist/cjs/resources/tax/assessments.js +217 -0
- package/dist/cjs/resources/tax/businessProfile.js +99 -0
- package/dist/cjs/resources/tax/calculations.js +176 -0
- package/dist/cjs/resources/tax/capabilities.js +42 -0
- package/dist/cjs/resources/tax/codes.js +37 -0
- package/dist/cjs/resources/tax/complianceActions.js +56 -0
- package/dist/cjs/resources/tax/deadlines.js +59 -0
- package/dist/cjs/resources/tax/documents.js +128 -0
- package/dist/cjs/resources/tax/index.js +80 -0
- package/dist/cjs/resources/tax/locationEvidence.js +131 -0
- package/dist/cjs/resources/tax/operatingLocations.js +98 -0
- package/dist/cjs/resources/tax/products.js +67 -0
- package/dist/cjs/resources/tax/registrationDeclarations.js +124 -0
- package/dist/cjs/resources/tax/registrations.js +82 -0
- package/dist/cjs/resources/tax/reports.js +92 -0
- package/dist/cjs/resources/tax/reviewItems.js +116 -0
- package/dist/cjs/resources/tax/ruleSet.js +68 -0
- package/dist/cjs/resources/tax/salesDestinations.js +94 -0
- package/dist/cjs/resources/tax/settings.js +104 -0
- package/dist/cjs/resources/tax/shared.js +62 -0
- package/dist/cjs/resources/tax/transactions.js +102 -0
- package/dist/cjs/route.js +22 -0
- package/dist/cjs/routes.js +31 -0
- package/dist/cjs/vocabulary/billingPortal.js +15 -0
- package/dist/cjs/vocabulary/catalog.js +110 -0
- package/dist/cjs/vocabulary/checkout.js +53 -0
- package/dist/cjs/vocabulary/connect.js +95 -0
- package/dist/cjs/vocabulary/errors.js +174 -0
- package/dist/cjs/vocabulary/events.js +176 -0
- package/dist/cjs/vocabulary/files.js +44 -0
- package/dist/cjs/vocabulary/index.js +37 -0
- package/dist/cjs/vocabulary/invoices.js +52 -0
- package/dist/cjs/vocabulary/lists.js +22 -0
- package/dist/cjs/vocabulary/merchants.js +23 -0
- package/dist/cjs/vocabulary/money.js +104 -0
- package/dist/cjs/vocabulary/paymentMethodConfigurations.js +36 -0
- package/dist/cjs/vocabulary/payments.js +195 -0
- package/dist/cjs/vocabulary/reporting.js +27 -0
- package/dist/cjs/vocabulary/subscriptions.js +60 -0
- package/dist/cjs/vocabulary/tax.js +237 -0
- package/dist/cjs/vocabulary/version.js +12 -0
- package/dist/esm/common/address.js +76 -0
- package/dist/esm/common/envelopes.js +95 -0
- package/dist/esm/common/objects.js +74 -0
- package/dist/esm/common/params.js +203 -0
- package/dist/esm/common/primitives.js +35 -0
- package/dist/esm/contributions.js +5 -0
- package/dist/esm/index.js +26 -134
- package/dist/esm/openapi/document.js +294 -0
- package/dist/esm/openapi/index.js +2 -0
- package/dist/esm/openapi/webhooks.js +14 -0
- package/dist/esm/resources/billingEngine/billingPortal.js +234 -0
- package/dist/esm/resources/billingEngine/creditNotes.js +186 -0
- package/dist/esm/resources/billingEngine/customerBalanceTransactions.js +87 -0
- package/dist/esm/resources/billingEngine/index.js +26 -0
- package/dist/esm/resources/billingEngine/invoiceItems.js +152 -0
- package/dist/esm/resources/billingEngine/invoices.js +506 -0
- package/dist/esm/resources/billingEngine/params.js +39 -0
- package/dist/esm/resources/billingEngine/public.js +323 -0
- package/dist/esm/resources/billingEngine/subscriptions.js +473 -0
- package/dist/esm/resources/catalog/billing.js +752 -0
- package/dist/esm/resources/catalog/billingSettings.js +128 -0
- package/dist/esm/resources/catalog/coupons.js +219 -0
- package/dist/esm/resources/catalog/entitlements.js +254 -0
- package/dist/esm/resources/catalog/index.js +38 -0
- package/dist/esm/resources/catalog/meters.js +276 -0
- package/dist/esm/resources/catalog/prices.js +419 -0
- package/dist/esm/resources/catalog/products.js +225 -0
- package/dist/esm/resources/catalog/promotionCodes.js +171 -0
- package/dist/esm/resources/catalog/shared.js +67 -0
- package/dist/esm/resources/catalog/testClocks.js +124 -0
- package/dist/esm/resources/checkout/checkoutSessions.js +579 -0
- package/dist/esm/resources/checkout/contributions.js +167 -0
- package/dist/esm/resources/checkout/files.js +130 -0
- package/dist/esm/resources/checkout/index.js +25 -0
- package/dist/esm/resources/checkout/merchants.js +287 -0
- package/dist/esm/resources/checkout/paymentLinks.js +327 -0
- package/dist/esm/resources/checkout/paymentMethodConfigurations.js +259 -0
- package/dist/esm/resources/checkout/shared.js +363 -0
- package/dist/esm/resources/connect/account.js +329 -0
- package/dist/esm/resources/connect/applicationFees.js +110 -0
- package/dist/esm/resources/connect/balance.js +209 -0
- package/dist/esm/resources/connect/connectedAccounts.js +257 -0
- package/dist/esm/resources/connect/index.js +34 -0
- package/dist/esm/resources/connect/onboarding.js +79 -0
- package/dist/esm/resources/connect/payouts.js +193 -0
- package/dist/esm/resources/connect/reporting.js +232 -0
- package/dist/esm/resources/connect/requestLogs.js +107 -0
- package/dist/esm/resources/connect/transfers.js +224 -0
- package/dist/esm/resources/core/customers.js +191 -0
- package/dist/esm/resources/core/index.js +6 -0
- package/dist/esm/resources/core/paymentMethods.js +131 -0
- package/dist/esm/resources/events/events.js +353 -0
- package/dist/esm/resources/events/index.js +12 -0
- package/dist/esm/resources/events/webhookDeliveries.js +90 -0
- package/dist/esm/resources/events/webhookEndpoints.js +212 -0
- package/dist/esm/resources/payments/charges.js +154 -0
- package/dist/esm/resources/payments/disputes.js +201 -0
- package/dist/esm/resources/payments/index.js +24 -0
- package/dist/esm/resources/payments/paymentIntents.js +526 -0
- package/dist/esm/resources/payments/refunds.js +242 -0
- package/dist/esm/resources/payments/setupIntents.js +155 -0
- package/dist/esm/resources/payments/social.js +179 -0
- package/dist/esm/resources/payments/testHelpers.js +36 -0
- package/dist/esm/resources/tax/assessments.js +214 -0
- package/dist/esm/resources/tax/businessProfile.js +96 -0
- package/dist/esm/resources/tax/calculations.js +173 -0
- package/dist/esm/resources/tax/capabilities.js +39 -0
- package/dist/esm/resources/tax/codes.js +34 -0
- package/dist/esm/resources/tax/complianceActions.js +53 -0
- package/dist/esm/resources/tax/deadlines.js +56 -0
- package/dist/esm/resources/tax/documents.js +125 -0
- package/dist/esm/resources/tax/index.js +63 -0
- package/dist/esm/resources/tax/locationEvidence.js +128 -0
- package/dist/esm/resources/tax/operatingLocations.js +95 -0
- package/dist/esm/resources/tax/products.js +64 -0
- package/dist/esm/resources/tax/registrationDeclarations.js +121 -0
- package/dist/esm/resources/tax/registrations.js +79 -0
- package/dist/esm/resources/tax/reports.js +89 -0
- package/dist/esm/resources/tax/reviewItems.js +113 -0
- package/dist/esm/resources/tax/ruleSet.js +65 -0
- package/dist/esm/resources/tax/salesDestinations.js +91 -0
- package/dist/esm/resources/tax/settings.js +101 -0
- package/dist/esm/resources/tax/shared.js +58 -0
- package/dist/esm/resources/tax/transactions.js +99 -0
- package/dist/esm/route.js +16 -0
- package/dist/esm/routes.js +27 -0
- package/dist/esm/vocabulary/billingPortal.js +12 -0
- package/dist/esm/vocabulary/catalog.js +106 -0
- package/dist/esm/vocabulary/checkout.js +50 -0
- package/dist/esm/vocabulary/connect.js +92 -0
- package/dist/esm/vocabulary/errors.js +169 -0
- package/dist/esm/vocabulary/events.js +173 -0
- package/dist/esm/vocabulary/files.js +41 -0
- package/dist/esm/vocabulary/index.js +21 -0
- package/dist/esm/vocabulary/invoices.js +49 -0
- package/dist/esm/vocabulary/lists.js +19 -0
- package/dist/esm/vocabulary/merchants.js +20 -0
- package/dist/esm/vocabulary/money.js +98 -0
- package/dist/esm/vocabulary/paymentMethodConfigurations.js +33 -0
- package/dist/esm/vocabulary/payments.js +192 -0
- package/dist/esm/vocabulary/reporting.js +24 -0
- package/dist/esm/vocabulary/subscriptions.js +57 -0
- package/dist/esm/vocabulary/tax.js +233 -0
- package/dist/esm/vocabulary/version.js +9 -0
- package/dist/types/common/address.d.ts +62 -0
- package/dist/types/common/envelopes.d.ts +88 -0
- package/dist/types/common/objects.d.ts +107 -0
- package/dist/types/common/params.d.ts +156 -0
- package/dist/types/common/primitives.d.ts +56 -0
- package/dist/types/contributions.d.ts +1 -0
- package/dist/types/index.d.ts +16 -171
- package/dist/types/openapi/document.d.ts +16 -0
- package/dist/types/openapi/index.d.ts +2 -0
- package/dist/types/openapi/webhooks.d.ts +15 -0
- package/dist/types/resources/billingEngine/billingPortal.d.ts +742 -0
- package/dist/types/resources/billingEngine/creditNotes.d.ts +655 -0
- package/dist/types/resources/billingEngine/customerBalanceTransactions.d.ts +282 -0
- package/dist/types/resources/billingEngine/index.d.ts +6071 -0
- package/dist/types/resources/billingEngine/invoiceItems.d.ts +502 -0
- package/dist/types/resources/billingEngine/invoices.d.ts +2547 -0
- package/dist/types/resources/billingEngine/params.d.ts +51 -0
- package/dist/types/resources/billingEngine/public.d.ts +1860 -0
- package/dist/types/resources/billingEngine/subscriptions.d.ts +1519 -0
- package/dist/types/resources/catalog/billing.d.ts +1723 -0
- package/dist/types/resources/catalog/billingSettings.d.ts +160 -0
- package/dist/types/resources/catalog/coupons.d.ts +403 -0
- package/dist/types/resources/catalog/entitlements.d.ts +422 -0
- package/dist/types/resources/catalog/index.d.ts +3155 -0
- package/dist/types/resources/catalog/meters.d.ts +474 -0
- package/dist/types/resources/catalog/prices.d.ts +1091 -0
- package/dist/types/resources/catalog/products.d.ts +430 -0
- package/dist/types/resources/catalog/promotionCodes.d.ts +369 -0
- package/dist/types/resources/catalog/shared.d.ts +34 -0
- package/dist/types/resources/catalog/testClocks.d.ts +220 -0
- package/dist/types/resources/checkout/checkoutSessions.d.ts +3207 -0
- package/dist/types/resources/checkout/contributions.d.ts +375 -0
- package/dist/types/resources/checkout/files.d.ts +280 -0
- package/dist/types/resources/checkout/index.d.ts +5678 -0
- package/dist/types/resources/checkout/merchants.d.ts +395 -0
- package/dist/types/resources/checkout/paymentLinks.d.ts +1728 -0
- package/dist/types/resources/checkout/paymentMethodConfigurations.d.ts +2104 -0
- package/dist/types/resources/checkout/shared.d.ts +419 -0
- package/dist/types/resources/connect/account.d.ts +483 -0
- package/dist/types/resources/connect/applicationFees.d.ts +198 -0
- package/dist/types/resources/connect/balance.d.ts +399 -0
- package/dist/types/resources/connect/connectedAccounts.d.ts +494 -0
- package/dist/types/resources/connect/index.d.ts +2094 -0
- package/dist/types/resources/connect/onboarding.d.ts +95 -0
- package/dist/types/resources/connect/payouts.d.ts +527 -0
- package/dist/types/resources/connect/reporting.d.ts +506 -0
- package/dist/types/resources/connect/requestLogs.d.ts +236 -0
- package/dist/types/resources/connect/transfers.d.ts +436 -0
- package/dist/types/resources/core/customers.d.ts +619 -0
- package/dist/types/resources/core/index.d.ts +679 -0
- package/dist/types/resources/core/paymentMethods.d.ts +336 -0
- package/dist/types/resources/events/events.d.ts +731 -0
- package/dist/types/resources/events/index.d.ts +1727 -0
- package/dist/types/resources/events/webhookDeliveries.d.ts +436 -0
- package/dist/types/resources/events/webhookEndpoints.d.ts +1502 -0
- package/dist/types/resources/payments/charges.d.ts +390 -0
- package/dist/types/resources/payments/disputes.d.ts +822 -0
- package/dist/types/resources/payments/index.d.ts +3517 -0
- package/dist/types/resources/payments/paymentIntents.d.ts +2080 -0
- package/dist/types/resources/payments/refunds.d.ts +684 -0
- package/dist/types/resources/payments/setupIntents.d.ts +391 -0
- package/dist/types/resources/payments/social.d.ts +266 -0
- package/dist/types/resources/payments/testHelpers.d.ts +178 -0
- package/dist/types/resources/tax/assessments.d.ts +787 -0
- package/dist/types/resources/tax/businessProfile.d.ts +134 -0
- package/dist/types/resources/tax/calculations.d.ts +261 -0
- package/dist/types/resources/tax/capabilities.d.ts +81 -0
- package/dist/types/resources/tax/codes.d.ts +29 -0
- package/dist/types/resources/tax/complianceActions.d.ts +97 -0
- package/dist/types/resources/tax/deadlines.d.ts +133 -0
- package/dist/types/resources/tax/documents.d.ts +257 -0
- package/dist/types/resources/tax/index.d.ts +1946 -0
- package/dist/types/resources/tax/locationEvidence.d.ts +246 -0
- package/dist/types/resources/tax/operatingLocations.d.ts +170 -0
- package/dist/types/resources/tax/products.d.ts +68 -0
- package/dist/types/resources/tax/registrationDeclarations.d.ts +270 -0
- package/dist/types/resources/tax/registrations.d.ts +103 -0
- package/dist/types/resources/tax/reports.d.ts +129 -0
- package/dist/types/resources/tax/reviewItems.d.ts +226 -0
- package/dist/types/resources/tax/ruleSet.d.ts +219 -0
- package/dist/types/resources/tax/salesDestinations.d.ts +158 -0
- package/dist/types/resources/tax/settings.d.ts +122 -0
- package/dist/types/resources/tax/shared.d.ts +43 -0
- package/dist/types/resources/tax/transactions.d.ts +404 -0
- package/dist/types/route.d.ts +86 -0
- package/dist/types/routes.d.ts +23 -0
- package/dist/types/vocabulary/billingPortal.d.ts +15 -0
- package/dist/types/vocabulary/catalog.d.ts +97 -0
- package/dist/types/vocabulary/checkout.d.ts +49 -0
- package/dist/types/vocabulary/connect.d.ts +62 -0
- package/dist/types/vocabulary/errors.d.ts +145 -0
- package/dist/types/vocabulary/events.d.ts +171 -0
- package/dist/types/vocabulary/files.d.ts +30 -0
- package/dist/types/vocabulary/index.d.ts +17 -0
- package/dist/types/vocabulary/invoices.d.ts +39 -0
- package/dist/types/vocabulary/lists.d.ts +9 -0
- package/dist/types/vocabulary/merchants.d.ts +9 -0
- package/dist/types/vocabulary/money.d.ts +59 -0
- package/dist/types/vocabulary/paymentMethodConfigurations.d.ts +22 -0
- package/dist/types/vocabulary/payments.d.ts +117 -0
- package/dist/types/vocabulary/reporting.d.ts +18 -0
- package/dist/types/vocabulary/subscriptions.d.ts +45 -0
- package/dist/types/vocabulary/tax.d.ts +163 -0
- package/dist/types/vocabulary/version.d.ts +10 -0
- package/package.json +51 -11
- package/dist/cjs/openapi.js +0 -165
- package/dist/esm/openapi.js +0 -161
- package/dist/types/openapi.d.ts +0 -148
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.contributionRoutes = exports.contributionPatchSchema = exports.contributionOperationKeySchema = exports.contributionMintSchema = exports.contributionPageQuerySchema = exports.contributionScopeQuerySchema = exports.contributionCollectionListSchema = exports.contributionCollectionSchema = exports.contributionListSchema = exports.contributionLinkSchema = exports.createContributionSchema = exports.contributionDetailsSchema = exports.contributionAmountSchema = void 0;
|
|
4
|
+
exports.decimalContributionAmount = decimalContributionAmount;
|
|
5
|
+
exports.formatContributionAmount = formatContributionAmount;
|
|
6
|
+
const zod_1 = require("zod");
|
|
7
|
+
const envelopes_1 = require("../../common/envelopes");
|
|
8
|
+
const objects_1 = require("../../common/objects");
|
|
9
|
+
const params_1 = require("../../common/params");
|
|
10
|
+
const route_1 = require("../../route");
|
|
11
|
+
const merchants_1 = require("../../vocabulary/merchants");
|
|
12
|
+
/**
|
|
13
|
+
* Organization contributions — an Oxy organization's FairCoin collection,
|
|
14
|
+
* managed by its members with their Oxy USER session (never a merchant service
|
|
15
|
+
* token). A contribution is a payment link whose one line is the contribution
|
|
16
|
+
* itself: a fixed amount, or one the payer chooses.
|
|
17
|
+
*
|
|
18
|
+
* Zod-light on purpose: `@peable.to/contracts/contributions` re-exports this
|
|
19
|
+
* module for the hosted checkout and Orbit, which must not construct every
|
|
20
|
+
* schema of the API.
|
|
21
|
+
*/
|
|
22
|
+
const FAIR_UNITS_PER_COIN = 100000000n;
|
|
23
|
+
/** A FairCoin base-unit amount a contribution can carry: positive, within a JS-safe integer. */
|
|
24
|
+
exports.contributionAmountSchema = zod_1.z
|
|
25
|
+
.string()
|
|
26
|
+
.regex(/^[1-9][0-9]{0,15}$/)
|
|
27
|
+
.refine((v) => /^[1-9][0-9]{0,15}$/.test(v) && BigInt(v) <= 9007199254740991n, 'Enter a positive FairCoin base-unit amount within the supported range');
|
|
28
|
+
/** Every instant on the wire is integer Unix seconds (ADR 0014 D1). */
|
|
29
|
+
const unixSecondsSchema = zod_1.z.number().int().nonnegative();
|
|
30
|
+
exports.contributionDetailsSchema = (0, objects_1.defineComponent)('ContributionDetails', zod_1.z
|
|
31
|
+
.object({
|
|
32
|
+
organization_id: zod_1.z.string().min(1).max(200).describe('The Oxy organization collecting.'),
|
|
33
|
+
purpose: zod_1.z.string().trim().min(1).max(500),
|
|
34
|
+
amount_mode: zod_1.z
|
|
35
|
+
.enum(['fixed', 'free'])
|
|
36
|
+
.describe('`fixed`: the link names the amount; `free`: the payer chooses it.'),
|
|
37
|
+
expires_at: unixSecondsSchema.nullable(),
|
|
38
|
+
})
|
|
39
|
+
.strict());
|
|
40
|
+
exports.createContributionSchema = zod_1.z
|
|
41
|
+
.object({
|
|
42
|
+
purpose: exports.contributionDetailsSchema.shape.purpose,
|
|
43
|
+
amount_mode: exports.contributionDetailsSchema.shape.amount_mode,
|
|
44
|
+
amount: exports.contributionAmountSchema.optional(),
|
|
45
|
+
currency: zod_1.z.literal('FAIR'),
|
|
46
|
+
expires_at: unixSecondsSchema.nullable().optional(),
|
|
47
|
+
})
|
|
48
|
+
.strict()
|
|
49
|
+
.refine((v) => (v.amount_mode === 'free' ? v.amount === undefined : v.amount !== undefined), 'Fixed contributions require an amount; free contributions omit it');
|
|
50
|
+
/** A contribution link, as its members manage it. */
|
|
51
|
+
exports.contributionLinkSchema = (0, objects_1.defineComponent)('ContributionLink', zod_1.z
|
|
52
|
+
.object({
|
|
53
|
+
id: zod_1.z.string(),
|
|
54
|
+
object: zod_1.z.literal('payment_link'),
|
|
55
|
+
amount: zod_1.z.string().describe('FAIR base units; `"0"` when the payer chooses.'),
|
|
56
|
+
currency: zod_1.z.literal('FAIR'),
|
|
57
|
+
network: zod_1.z.enum(['mainnet', 'testnet']),
|
|
58
|
+
active: zod_1.z.boolean(),
|
|
59
|
+
url: zod_1.z.url().describe('The hosted link to share.'),
|
|
60
|
+
contribution: exports.contributionDetailsSchema,
|
|
61
|
+
created: unixSecondsSchema,
|
|
62
|
+
})
|
|
63
|
+
.strict());
|
|
64
|
+
exports.contributionListSchema = (0, envelopes_1.listOf)(exports.contributionLinkSchema);
|
|
65
|
+
/** A payment made through a contribution link. Non-custodial: Peable cannot refund it. */
|
|
66
|
+
exports.contributionCollectionSchema = (0, objects_1.defineComponent)('ContributionCollection', zod_1.z
|
|
67
|
+
.object({
|
|
68
|
+
id: zod_1.z.string(),
|
|
69
|
+
object: zod_1.z.literal('payment_intent'),
|
|
70
|
+
amount: zod_1.z.string(),
|
|
71
|
+
currency: zod_1.z.literal('FAIR'),
|
|
72
|
+
status: zod_1.z.string(),
|
|
73
|
+
created: unixSecondsSchema,
|
|
74
|
+
refund_capability: zod_1.z.literal('unsupported_non_custodial'),
|
|
75
|
+
refunds: zod_1.z.array(zod_1.z
|
|
76
|
+
.object({
|
|
77
|
+
id: zod_1.z.string(),
|
|
78
|
+
object: zod_1.z.literal('refund'),
|
|
79
|
+
amount: zod_1.z.string(),
|
|
80
|
+
status: zod_1.z.string(),
|
|
81
|
+
created: unixSecondsSchema,
|
|
82
|
+
})
|
|
83
|
+
.strict()),
|
|
84
|
+
})
|
|
85
|
+
.strict());
|
|
86
|
+
exports.contributionCollectionListSchema = (0, envelopes_1.listOf)(exports.contributionCollectionSchema);
|
|
87
|
+
/** The environment the Test/Live toggle selects: the application's merchant in it is the scope. */
|
|
88
|
+
const environmentParam = zod_1.z
|
|
89
|
+
.enum(merchants_1.MERCHANT_ENVIRONMENTS)
|
|
90
|
+
.describe("Which of the application's merchants: its Test/Live toggle.");
|
|
91
|
+
/** The query of every contribution write: the environment and nothing else. */
|
|
92
|
+
exports.contributionScopeQuerySchema = zod_1.z.object({ environment: environmentParam }).strict();
|
|
93
|
+
/**
|
|
94
|
+
* Paging a contribution list: the list parameters every list accepts
|
|
95
|
+
* (`link_…` cursors for links, `pi_…` for collections) plus the environment.
|
|
96
|
+
*/
|
|
97
|
+
exports.contributionPageQuerySchema = (0, params_1.listQuery)({ environment: environmentParam });
|
|
98
|
+
/** What a payer may say when starting a free contribution's checkout. */
|
|
99
|
+
exports.contributionMintSchema = zod_1.z
|
|
100
|
+
.object({ amount: exports.contributionAmountSchema.optional() })
|
|
101
|
+
.strict();
|
|
102
|
+
/** A contribution start's `Idempotency-Key`: a UUID the page writes before the request. */
|
|
103
|
+
exports.contributionOperationKeySchema = zod_1.z.uuid();
|
|
104
|
+
exports.contributionPatchSchema = zod_1.z.object({ active: zod_1.z.boolean() }).strict();
|
|
105
|
+
/** `"1.25"` FAIR → `"125000000"` base units, with exact integer arithmetic. */
|
|
106
|
+
function decimalContributionAmount(value) {
|
|
107
|
+
if (!/^(0|[1-9][0-9]{0,7})(\.[0-9]{1,8})?$/.test(value))
|
|
108
|
+
throw new Error('Enter a FAIR amount with at most eight decimals');
|
|
109
|
+
const [whole = '0', fraction = ''] = value.split('.');
|
|
110
|
+
return exports.contributionAmountSchema.parse((BigInt(whole) * FAIR_UNITS_PER_COIN + BigInt(fraction.padEnd(8, '0'))).toString());
|
|
111
|
+
}
|
|
112
|
+
/** Base units → the shortest exact FAIR decimal. */
|
|
113
|
+
function formatContributionAmount(value) {
|
|
114
|
+
const units = BigInt(value);
|
|
115
|
+
const fraction = (units % FAIR_UNITS_PER_COIN).toString().padStart(8, '0').replace(/0+$/, '');
|
|
116
|
+
return (units / FAIR_UNITS_PER_COIN).toString() + (fraction ? `.${fraction}` : '');
|
|
117
|
+
}
|
|
118
|
+
const scopeParams = {
|
|
119
|
+
organizationId: 'The Oxy organization.',
|
|
120
|
+
applicationId: "The organization's Oxy application whose merchant collects.",
|
|
121
|
+
};
|
|
122
|
+
const root = '/v1/organizations/{organizationId}/applications/{applicationId}/contributions';
|
|
123
|
+
exports.contributionRoutes = [
|
|
124
|
+
(0, route_1.defineRoute)({
|
|
125
|
+
operationId: 'createContribution',
|
|
126
|
+
method: 'post',
|
|
127
|
+
path: root,
|
|
128
|
+
tag: 'Contributions',
|
|
129
|
+
summary: 'Create a contribution link',
|
|
130
|
+
description: 'Requires a UUID `Idempotency-Key` header: the operation key, so a retry after a lost answer returns the same link.',
|
|
131
|
+
auth: 'user',
|
|
132
|
+
params: scopeParams,
|
|
133
|
+
query: exports.contributionScopeQuerySchema,
|
|
134
|
+
body: exports.createContributionSchema,
|
|
135
|
+
response: exports.contributionLinkSchema,
|
|
136
|
+
status: 201,
|
|
137
|
+
}),
|
|
138
|
+
(0, route_1.defineRoute)({
|
|
139
|
+
operationId: 'listContributions',
|
|
140
|
+
method: 'get',
|
|
141
|
+
path: root,
|
|
142
|
+
tag: 'Contributions',
|
|
143
|
+
summary: "List an organization's contribution links",
|
|
144
|
+
auth: 'user',
|
|
145
|
+
params: scopeParams,
|
|
146
|
+
query: exports.contributionPageQuerySchema,
|
|
147
|
+
response: exports.contributionListSchema,
|
|
148
|
+
}),
|
|
149
|
+
(0, route_1.defineRoute)({
|
|
150
|
+
operationId: 'updateContribution',
|
|
151
|
+
method: 'post',
|
|
152
|
+
path: `${root}/{id}`,
|
|
153
|
+
tag: 'Contributions',
|
|
154
|
+
summary: 'Enable or disable a contribution link',
|
|
155
|
+
auth: 'user',
|
|
156
|
+
params: { ...scopeParams, id: 'The contribution link (`link_…`).' },
|
|
157
|
+
query: exports.contributionScopeQuerySchema,
|
|
158
|
+
body: exports.contributionPatchSchema,
|
|
159
|
+
response: exports.contributionLinkSchema,
|
|
160
|
+
}),
|
|
161
|
+
(0, route_1.defineRoute)({
|
|
162
|
+
operationId: 'listContributionCollections',
|
|
163
|
+
method: 'get',
|
|
164
|
+
path: `${root}/{id}/collections`,
|
|
165
|
+
tag: 'Contributions',
|
|
166
|
+
summary: 'List the payments made through a contribution link',
|
|
167
|
+
auth: 'user',
|
|
168
|
+
params: { ...scopeParams, id: 'The contribution link (`link_…`).' },
|
|
169
|
+
query: exports.contributionPageQuerySchema,
|
|
170
|
+
response: exports.contributionCollectionListSchema,
|
|
171
|
+
}),
|
|
172
|
+
];
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.fileRoutes = exports.listFilesQuery = exports.createFileFromOxyParams = exports.createFileUploadParams = exports.fileSchema = 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 files_1 = require("../../vocabulary/files");
|
|
11
|
+
/**
|
|
12
|
+
* Files (`file_…`) — bytes a merchant gives Orbit for one stated purpose
|
|
13
|
+
* (ADR 0016: Orbit owns the object; the storage is Oxy Files, a binding that
|
|
14
|
+
* never reaches the wire). Stripe's Files API, with Oxy Files underneath.
|
|
15
|
+
*/
|
|
16
|
+
exports.fileSchema = (0, objects_1.defineObject)('file', 'File', zod_1.z
|
|
17
|
+
.object({
|
|
18
|
+
id: zod_1.z.string(),
|
|
19
|
+
object: zod_1.z.literal('file'),
|
|
20
|
+
livemode: primitives_1.livemode,
|
|
21
|
+
purpose: zod_1.z.enum(files_1.FILE_PURPOSES),
|
|
22
|
+
filename: zod_1.z
|
|
23
|
+
.string()
|
|
24
|
+
.nullable()
|
|
25
|
+
.describe('The name it was uploaded with, if it had a printable one.'),
|
|
26
|
+
size: zod_1.z.number().int().nonnegative().describe('Bytes.'),
|
|
27
|
+
type: zod_1.z.enum(files_1.FILE_TYPES),
|
|
28
|
+
status: zod_1.z.enum(files_1.FILE_STATUSES),
|
|
29
|
+
url: zod_1.z
|
|
30
|
+
.string()
|
|
31
|
+
.nullable()
|
|
32
|
+
.describe('Where the bytes can be read while the file is `available`: a public URL for a `business_logo`, `GET /v1/files/{id}/contents` for a `finance_report_run`. `null` for every other purpose — evidence and identity documents are never addressable by URL.'),
|
|
33
|
+
created: primitives_1.unixSeconds,
|
|
34
|
+
})
|
|
35
|
+
.strict(), {
|
|
36
|
+
examples: [
|
|
37
|
+
{
|
|
38
|
+
id: 'file_0193b8f2c1a87d3e9f4a',
|
|
39
|
+
object: 'file',
|
|
40
|
+
livemode: false,
|
|
41
|
+
purpose: 'business_logo',
|
|
42
|
+
filename: 'logo.png',
|
|
43
|
+
size: 18432,
|
|
44
|
+
type: 'png',
|
|
45
|
+
status: 'available',
|
|
46
|
+
url: 'https://cloud.oxy.so/assets/0193b8f2c1a87d3e9f4b',
|
|
47
|
+
created: 1793750400,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
/**
|
|
52
|
+
* `POST /v1/files` as `multipart/form-data`: a `purpose` field and a `file`
|
|
53
|
+
* part. The gateway reads the form itself, bounded by the largest purpose's
|
|
54
|
+
* ceiling, and checks each part with these schemas.
|
|
55
|
+
*/
|
|
56
|
+
exports.createFileUploadParams = zod_1.z
|
|
57
|
+
.object({
|
|
58
|
+
purpose: zod_1.z.enum(files_1.FILE_UPLOAD_PURPOSES, {
|
|
59
|
+
error: `purpose must be one of ${files_1.FILE_UPLOAD_PURPOSES.join(', ')}`,
|
|
60
|
+
}),
|
|
61
|
+
file: zod_1.z.file({ error: 'file is required' }).describe('The bytes, with their filename.'),
|
|
62
|
+
})
|
|
63
|
+
.strict();
|
|
64
|
+
/**
|
|
65
|
+
* `POST /v1/files` as JSON: an Oxy file the caller already owns (their
|
|
66
|
+
* application's, or an account they are or act for). Its ownership is checked
|
|
67
|
+
* once, here, and never again.
|
|
68
|
+
*/
|
|
69
|
+
exports.createFileFromOxyParams = zod_1.z
|
|
70
|
+
.object({
|
|
71
|
+
purpose: zod_1.z.enum(files_1.FILE_UPLOAD_PURPOSES),
|
|
72
|
+
oxy_file: zod_1.z.string().min(1).max(128).describe('The Oxy file id.'),
|
|
73
|
+
})
|
|
74
|
+
.strict();
|
|
75
|
+
exports.listFilesQuery = (0, params_1.listQuery)({ purpose: zod_1.z.enum(files_1.FILE_PURPOSES).optional() });
|
|
76
|
+
exports.fileRoutes = [
|
|
77
|
+
(0, route_1.defineRoute)({
|
|
78
|
+
operationId: 'createFile',
|
|
79
|
+
method: 'post',
|
|
80
|
+
path: '/v1/files',
|
|
81
|
+
tag: 'Files',
|
|
82
|
+
summary: 'Upload a file',
|
|
83
|
+
description: 'The bytes as `multipart/form-data` (`purpose`, `file`), or — as JSON — `{ purpose, oxy_file }` to import an Oxy file you own. The type is recognised from the bytes, never from a `Content-Type`; each purpose has its own formats and size ceiling.',
|
|
84
|
+
auth: 'service',
|
|
85
|
+
scope: 'payments:write',
|
|
86
|
+
idempotent: true,
|
|
87
|
+
body: exports.createFileUploadParams,
|
|
88
|
+
bodyEncoding: 'multipart',
|
|
89
|
+
response: exports.fileSchema,
|
|
90
|
+
sdk: 'files.create',
|
|
91
|
+
}),
|
|
92
|
+
(0, route_1.defineRoute)({
|
|
93
|
+
operationId: 'listFiles',
|
|
94
|
+
method: 'get',
|
|
95
|
+
path: '/v1/files',
|
|
96
|
+
tag: 'Files',
|
|
97
|
+
summary: 'List files',
|
|
98
|
+
auth: 'service',
|
|
99
|
+
scope: 'payments:read',
|
|
100
|
+
query: exports.listFilesQuery,
|
|
101
|
+
response: (0, envelopes_1.listOf)(exports.fileSchema),
|
|
102
|
+
sdk: 'files.list',
|
|
103
|
+
expandable: 'file',
|
|
104
|
+
}),
|
|
105
|
+
(0, route_1.defineRoute)({
|
|
106
|
+
operationId: 'retrieveFile',
|
|
107
|
+
method: 'get',
|
|
108
|
+
path: '/v1/files/{id}',
|
|
109
|
+
tag: 'Files',
|
|
110
|
+
summary: 'Retrieve a file',
|
|
111
|
+
auth: 'service',
|
|
112
|
+
scope: 'payments:read',
|
|
113
|
+
params: { id: 'The file (`file_…`).' },
|
|
114
|
+
query: params_1.expandOnlyQuery,
|
|
115
|
+
response: exports.fileSchema,
|
|
116
|
+
sdk: 'files.retrieve',
|
|
117
|
+
expandable: 'file',
|
|
118
|
+
}),
|
|
119
|
+
(0, route_1.defineRoute)({
|
|
120
|
+
operationId: 'retrieveFileContents',
|
|
121
|
+
method: 'get',
|
|
122
|
+
path: '/v1/files/{id}/contents',
|
|
123
|
+
tag: 'Files',
|
|
124
|
+
summary: "Download a file's contents",
|
|
125
|
+
description: "The bytes of a file you read back — a report run's CSV — as an attachment. Any other purpose answers 404: evidence and identity documents leave Peable only to their provider.",
|
|
126
|
+
auth: 'service',
|
|
127
|
+
scope: 'payments:read',
|
|
128
|
+
params: { id: 'The file (`file_…`).' },
|
|
129
|
+
query: params_1.emptyQuery,
|
|
130
|
+
response: { kind: 'binary', contentType: 'text/csv' },
|
|
131
|
+
sdk: 'files.contents',
|
|
132
|
+
}),
|
|
133
|
+
];
|
|
@@ -0,0 +1,57 @@
|
|
|
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.checkoutRoutes = exports.merchantDisplaySchema = exports.customFieldsParam = exports.checkoutTotalDetailsSchema = exports.checkoutTaxIdSchema = exports.checkoutShippingDetailsSchema = exports.checkoutLineItemSchema = exports.checkoutDiscountSchema = exports.checkoutCustomFieldSchema = exports.checkoutCustomerDetailsSchema = exports.checkoutConsentSchema = exports.checkoutConsentCollectionSchema = exports.checkoutBrandingSchema = exports.checkoutAutomaticTaxSchema = exports.checkoutAdjustableQuantitySchema = exports.adjustableBoundsOf = void 0;
|
|
18
|
+
const checkoutSessions_1 = require("./checkoutSessions");
|
|
19
|
+
const contributions_1 = require("./contributions");
|
|
20
|
+
const files_1 = require("./files");
|
|
21
|
+
const merchants_1 = require("./merchants");
|
|
22
|
+
const paymentLinks_1 = require("./paymentLinks");
|
|
23
|
+
const paymentMethodConfigurations_1 = require("./paymentMethodConfigurations");
|
|
24
|
+
__exportStar(require("./checkoutSessions"), exports);
|
|
25
|
+
__exportStar(require("./contributions"), exports);
|
|
26
|
+
__exportStar(require("./files"), exports);
|
|
27
|
+
__exportStar(require("./merchants"), exports);
|
|
28
|
+
__exportStar(require("./paymentLinks"), exports);
|
|
29
|
+
__exportStar(require("./paymentMethodConfigurations"), exports);
|
|
30
|
+
// The shared building blocks' public half: the sub-objects sessions and links
|
|
31
|
+
// return, and what a backend needs to store a parsed request. The rest of
|
|
32
|
+
// `./shared` (rail, locale, URL and amount params) stays internal to checkout.
|
|
33
|
+
var shared_1 = require("./shared");
|
|
34
|
+
Object.defineProperty(exports, "adjustableBoundsOf", { enumerable: true, get: function () { return shared_1.adjustableBoundsOf; } });
|
|
35
|
+
Object.defineProperty(exports, "checkoutAdjustableQuantitySchema", { enumerable: true, get: function () { return shared_1.checkoutAdjustableQuantitySchema; } });
|
|
36
|
+
Object.defineProperty(exports, "checkoutAutomaticTaxSchema", { enumerable: true, get: function () { return shared_1.checkoutAutomaticTaxSchema; } });
|
|
37
|
+
Object.defineProperty(exports, "checkoutBrandingSchema", { enumerable: true, get: function () { return shared_1.checkoutBrandingSchema; } });
|
|
38
|
+
Object.defineProperty(exports, "checkoutConsentCollectionSchema", { enumerable: true, get: function () { return shared_1.checkoutConsentCollectionSchema; } });
|
|
39
|
+
Object.defineProperty(exports, "checkoutConsentSchema", { enumerable: true, get: function () { return shared_1.checkoutConsentSchema; } });
|
|
40
|
+
Object.defineProperty(exports, "checkoutCustomerDetailsSchema", { enumerable: true, get: function () { return shared_1.checkoutCustomerDetailsSchema; } });
|
|
41
|
+
Object.defineProperty(exports, "checkoutCustomFieldSchema", { enumerable: true, get: function () { return shared_1.checkoutCustomFieldSchema; } });
|
|
42
|
+
Object.defineProperty(exports, "checkoutDiscountSchema", { enumerable: true, get: function () { return shared_1.checkoutDiscountSchema; } });
|
|
43
|
+
Object.defineProperty(exports, "checkoutLineItemSchema", { enumerable: true, get: function () { return shared_1.checkoutLineItemSchema; } });
|
|
44
|
+
Object.defineProperty(exports, "checkoutShippingDetailsSchema", { enumerable: true, get: function () { return shared_1.checkoutShippingDetailsSchema; } });
|
|
45
|
+
Object.defineProperty(exports, "checkoutTaxIdSchema", { enumerable: true, get: function () { return shared_1.checkoutTaxIdSchema; } });
|
|
46
|
+
Object.defineProperty(exports, "checkoutTotalDetailsSchema", { enumerable: true, get: function () { return shared_1.checkoutTotalDetailsSchema; } });
|
|
47
|
+
Object.defineProperty(exports, "customFieldsParam", { enumerable: true, get: function () { return shared_1.customFieldsParam; } });
|
|
48
|
+
Object.defineProperty(exports, "merchantDisplaySchema", { enumerable: true, get: function () { return shared_1.merchantDisplaySchema; } });
|
|
49
|
+
/** Checkout, payment links, the merchant and its branding, files and contributions. */
|
|
50
|
+
exports.checkoutRoutes = [
|
|
51
|
+
...checkoutSessions_1.checkoutSessionRoutes,
|
|
52
|
+
...paymentLinks_1.paymentLinkRoutes,
|
|
53
|
+
...paymentMethodConfigurations_1.paymentMethodConfigurationRoutes,
|
|
54
|
+
...merchants_1.merchantRoutes,
|
|
55
|
+
...files_1.fileRoutes,
|
|
56
|
+
...contributions_1.contributionRoutes,
|
|
57
|
+
];
|
|
@@ -0,0 +1,290 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.merchantRoutes = exports.updateMerchantEmailSettingsParams = exports.merchantEmailSettingsSchema = exports.updateMerchantBrandingParams = exports.merchantBrandingSchema = exports.updateMerchantParams = exports.registerMerchantParams = exports.merchantSchema = void 0;
|
|
4
|
+
const zod_1 = require("zod");
|
|
5
|
+
const objects_1 = require("../../common/objects");
|
|
6
|
+
const primitives_1 = require("../../common/primitives");
|
|
7
|
+
const route_1 = require("../../route");
|
|
8
|
+
const merchants_1 = require("../../vocabulary/merchants");
|
|
9
|
+
/**
|
|
10
|
+
* The merchant (`merch_…`) — one per Oxy application and environment — with
|
|
11
|
+
* its branding and customer-email settings. `next_derivation_index` is never
|
|
12
|
+
* on the wire: it is an internal derivation counter with no meaning to an
|
|
13
|
+
* integration. Where events go is not a merchant field: it is the
|
|
14
|
+
* `webhook_endpoint` resource.
|
|
15
|
+
*/
|
|
16
|
+
exports.merchantSchema = (0, objects_1.defineObject)('merchant', 'Merchant', zod_1.z
|
|
17
|
+
.object({
|
|
18
|
+
id: zod_1.z.string(),
|
|
19
|
+
object: zod_1.z.literal('merchant'),
|
|
20
|
+
livemode: primitives_1.livemode.describe('`true` for a `production` merchant (ADR 0017).'),
|
|
21
|
+
oxy_app_id: zod_1.z.string().describe('The Oxy application this merchant belongs to.'),
|
|
22
|
+
environment: zod_1.z.enum(merchants_1.MERCHANT_ENVIRONMENTS),
|
|
23
|
+
network: primitives_1.network
|
|
24
|
+
.nullable()
|
|
25
|
+
.describe('The FairCoin chain this merchant accepts on; `null` on a card-only merchant. Nullable together with `xpub`.'),
|
|
26
|
+
xpub: zod_1.z
|
|
27
|
+
.string()
|
|
28
|
+
.nullable()
|
|
29
|
+
.describe('The watch-only account key receive addresses derive from; `null` on a card-only merchant.'),
|
|
30
|
+
required_confirmations: zod_1.z.number().int().positive(),
|
|
31
|
+
display_name: zod_1.z
|
|
32
|
+
.string()
|
|
33
|
+
.optional()
|
|
34
|
+
.describe('Payer-facing name. Absent when unset: payer surfaces substitute a fallback.'),
|
|
35
|
+
avatar_file_id: zod_1.z
|
|
36
|
+
.string()
|
|
37
|
+
.optional()
|
|
38
|
+
.describe('The square identity image: a bare Oxy file id. Absent again once Oxy reports the file deleted or taken down.'),
|
|
39
|
+
business_logo: zod_1.z
|
|
40
|
+
.string()
|
|
41
|
+
.optional()
|
|
42
|
+
.describe('The wide wordmark payer surfaces show: a `file_…` of purpose `business_logo`.'),
|
|
43
|
+
description: zod_1.z.string().optional(),
|
|
44
|
+
created: primitives_1.unixSeconds,
|
|
45
|
+
updated_at: primitives_1.unixSeconds,
|
|
46
|
+
})
|
|
47
|
+
.strict(), {
|
|
48
|
+
examples: [
|
|
49
|
+
{
|
|
50
|
+
id: 'merch_0193b8f2c1a87d3e9f4a',
|
|
51
|
+
object: 'merchant',
|
|
52
|
+
livemode: false,
|
|
53
|
+
oxy_app_id: 'app_0193b8f2c1a87d3e9f4b',
|
|
54
|
+
environment: 'development',
|
|
55
|
+
network: 'testnet',
|
|
56
|
+
xpub: 'tpubDC5FSnBiZDMmhiuCmWAYsLwgLYrrT9rAqvTySfuCCrgsWz8wxMXUS9Tb9iVMvcRbvFcAHGkMD5Kx8koh4GquNGNTfohfk7pgjhaPCdXpoba',
|
|
57
|
+
required_confirmations: 6,
|
|
58
|
+
display_name: 'Jenny’s Plants',
|
|
59
|
+
created: 1793750400,
|
|
60
|
+
updated_at: 1793750400,
|
|
61
|
+
},
|
|
62
|
+
],
|
|
63
|
+
});
|
|
64
|
+
// The branding columns are bare `text()` with no CHECK, so these bounds are
|
|
65
|
+
// the ONLY thing between a merchant and an unbounded write. `display_name` is
|
|
66
|
+
// rendered in a payer's transaction history and on the checkout chip, so it is
|
|
67
|
+
// held to a chip-sized length rather than a paragraph.
|
|
68
|
+
const displayName = zod_1.z.string().min(1).max(64);
|
|
69
|
+
const avatarFileId = zod_1.z.string().min(1).max(128);
|
|
70
|
+
const merchantDescription = zod_1.z.string().min(1).max(512);
|
|
71
|
+
/**
|
|
72
|
+
* `POST /v1/merchants`. The FairCoin half is OPTIONAL — both `network` and
|
|
73
|
+
* `xpub`, or neither: a card-only merchant supplies no key for a chain it
|
|
74
|
+
* never intends to use.
|
|
75
|
+
*/
|
|
76
|
+
exports.registerMerchantParams = zod_1.z
|
|
77
|
+
.object({
|
|
78
|
+
network: primitives_1.network.optional(),
|
|
79
|
+
xpub: zod_1.z
|
|
80
|
+
.string()
|
|
81
|
+
.min(1)
|
|
82
|
+
.optional()
|
|
83
|
+
.describe('A watch-only account xpub. A private extended key is refused.'),
|
|
84
|
+
required_confirmations: zod_1.z.number().int().positive().optional(),
|
|
85
|
+
display_name: displayName.optional(),
|
|
86
|
+
avatar_file_id: avatarFileId.optional(),
|
|
87
|
+
description: merchantDescription.optional(),
|
|
88
|
+
})
|
|
89
|
+
.strict()
|
|
90
|
+
.refine((body) => (body.network === undefined) === (body.xpub === undefined), {
|
|
91
|
+
message: 'accepting FairCoin needs both a network and a watch-only xpub, or neither — ' +
|
|
92
|
+
'omit both to register a card-only merchant',
|
|
93
|
+
});
|
|
94
|
+
/**
|
|
95
|
+
* `POST /v1/merchants/me`. `null` clears a field. The key, network and
|
|
96
|
+
* environment never change: addresses already derived from the key, and the
|
|
97
|
+
* test/live firewall, depend on them.
|
|
98
|
+
*/
|
|
99
|
+
exports.updateMerchantParams = zod_1.z
|
|
100
|
+
.object({
|
|
101
|
+
required_confirmations: zod_1.z.number().int().positive().optional(),
|
|
102
|
+
display_name: displayName.nullable().optional(),
|
|
103
|
+
avatar_file_id: avatarFileId.nullable().optional(),
|
|
104
|
+
business_logo: zod_1.z
|
|
105
|
+
.string()
|
|
106
|
+
.min(1)
|
|
107
|
+
.max(255)
|
|
108
|
+
.nullable()
|
|
109
|
+
.optional()
|
|
110
|
+
.describe('A `file_…` of purpose `business_logo` — set on an update, never at registration.'),
|
|
111
|
+
description: merchantDescription.nullable().optional(),
|
|
112
|
+
})
|
|
113
|
+
.strict();
|
|
114
|
+
// ---- Branding ----------------------------------------------------------------
|
|
115
|
+
/** A merchant's branding: what its hosted checkout, embedded checkout and receipts look like. */
|
|
116
|
+
exports.merchantBrandingSchema = (0, objects_1.defineObject)('branding_settings', 'BrandingSettings', zod_1.z
|
|
117
|
+
.object({
|
|
118
|
+
object: zod_1.z.literal('branding_settings'),
|
|
119
|
+
livemode: primitives_1.livemode,
|
|
120
|
+
use_avatar_as_icon: zod_1.z
|
|
121
|
+
.boolean()
|
|
122
|
+
.describe('Show the merchant avatar (`avatar_file_id`) as the square icon.'),
|
|
123
|
+
logo: zod_1.z
|
|
124
|
+
.string()
|
|
125
|
+
.nullable()
|
|
126
|
+
.describe('The wide logo: a `file_…` of purpose `business_logo`, or `null` — the same field as `POST /v1/merchants/me {business_logo}`.'),
|
|
127
|
+
primary_color: zod_1.z.string().nullable().describe('`#rrggbb`; `null` for Peable’s default.'),
|
|
128
|
+
accent_color: zod_1.z.string().nullable(),
|
|
129
|
+
font: zod_1.z.enum(merchants_1.BRANDING_FONTS).nullable(),
|
|
130
|
+
border_style: zod_1.z.enum(merchants_1.BRANDING_BORDER_STYLES).nullable(),
|
|
131
|
+
terms_of_service_url: zod_1.z
|
|
132
|
+
.string()
|
|
133
|
+
.nullable()
|
|
134
|
+
.describe('Your terms (`https://`). Required before a session or link can ask for terms acceptance.'),
|
|
135
|
+
updated_at: primitives_1.unixSeconds.nullable(),
|
|
136
|
+
})
|
|
137
|
+
.strict());
|
|
138
|
+
/** `#rgb` or `#rrggbb`, any case — stored as lowercase `#rrggbb`. */
|
|
139
|
+
const colorParam = zod_1.z
|
|
140
|
+
.string()
|
|
141
|
+
.regex(/^#(?:[0-9a-fA-F]{3}|[0-9a-fA-F]{6})$/, 'must be a #rrggbb colour')
|
|
142
|
+
.transform((value) => {
|
|
143
|
+
const hex = value.slice(1).toLowerCase();
|
|
144
|
+
return `#${hex.length === 3 ? [...hex].map((c) => c + c).join('') : hex}`;
|
|
145
|
+
});
|
|
146
|
+
const httpsUrlParam = zod_1.z
|
|
147
|
+
.string()
|
|
148
|
+
.max(2048)
|
|
149
|
+
.regex(/^https:\/\/\S+$/, 'must be an https URL');
|
|
150
|
+
exports.updateMerchantBrandingParams = zod_1.z
|
|
151
|
+
.object({
|
|
152
|
+
use_avatar_as_icon: zod_1.z.boolean().optional(),
|
|
153
|
+
logo: zod_1.z
|
|
154
|
+
.string()
|
|
155
|
+
.min(1)
|
|
156
|
+
.max(255)
|
|
157
|
+
.nullable()
|
|
158
|
+
.optional()
|
|
159
|
+
.describe('A `file_…` of purpose `business_logo`; `null` removes it.'),
|
|
160
|
+
primary_color: colorParam
|
|
161
|
+
.nullable()
|
|
162
|
+
.optional()
|
|
163
|
+
.describe('`#rrggbb` (any case; stored lowercase), `null` for Peable’s default.'),
|
|
164
|
+
accent_color: colorParam.nullable().optional(),
|
|
165
|
+
font: zod_1.z.enum(merchants_1.BRANDING_FONTS).nullable().optional(),
|
|
166
|
+
border_style: zod_1.z.enum(merchants_1.BRANDING_BORDER_STYLES).nullable().optional(),
|
|
167
|
+
terms_of_service_url: httpsUrlParam.nullable().optional(),
|
|
168
|
+
})
|
|
169
|
+
.strict();
|
|
170
|
+
/** Which customer emails Peable sends for this merchant. */
|
|
171
|
+
exports.merchantEmailSettingsSchema = (0, objects_1.defineObject)('email_settings', 'EmailSettings', zod_1.z
|
|
172
|
+
.object({
|
|
173
|
+
object: zod_1.z.literal('email_settings'),
|
|
174
|
+
livemode: primitives_1.livemode,
|
|
175
|
+
payment_receipts: zod_1.z
|
|
176
|
+
.boolean()
|
|
177
|
+
.describe('A receipt when a payment succeeds and has a `receipt_email` (or a collected one).'),
|
|
178
|
+
refund_notices: zod_1.z.boolean().describe('A notice when a refund succeeds.'),
|
|
179
|
+
checkout_confirmations: zod_1.z
|
|
180
|
+
.boolean()
|
|
181
|
+
.describe('A confirmation when a checkout session completes.'),
|
|
182
|
+
support_email: zod_1.z
|
|
183
|
+
.string()
|
|
184
|
+
.nullable()
|
|
185
|
+
.describe('The reply-to address shown on emails, or `null` for none.'),
|
|
186
|
+
updated_at: primitives_1.unixSeconds.nullable(),
|
|
187
|
+
})
|
|
188
|
+
.strict());
|
|
189
|
+
exports.updateMerchantEmailSettingsParams = zod_1.z
|
|
190
|
+
.object({
|
|
191
|
+
payment_receipts: zod_1.z.boolean().optional(),
|
|
192
|
+
refund_notices: zod_1.z.boolean().optional(),
|
|
193
|
+
checkout_confirmations: zod_1.z.boolean().optional(),
|
|
194
|
+
support_email: zod_1.z
|
|
195
|
+
.string()
|
|
196
|
+
.trim()
|
|
197
|
+
.max(254)
|
|
198
|
+
.email('must be an email address')
|
|
199
|
+
.nullable()
|
|
200
|
+
.optional(),
|
|
201
|
+
})
|
|
202
|
+
.strict();
|
|
203
|
+
exports.merchantRoutes = [
|
|
204
|
+
(0, route_1.defineRoute)({
|
|
205
|
+
operationId: 'registerMerchant',
|
|
206
|
+
method: 'post',
|
|
207
|
+
path: '/v1/merchants',
|
|
208
|
+
tag: 'Merchants',
|
|
209
|
+
summary: 'Register the merchant',
|
|
210
|
+
description: "Registers the calling application's merchant in the credential's environment. A non-production credential can register a testnet merchant only. A second registration for the same application and environment answers 409. Outside the generic idempotency layer: the merchant is the scope it keys on.",
|
|
211
|
+
auth: 'service',
|
|
212
|
+
scope: 'payments:write',
|
|
213
|
+
body: exports.registerMerchantParams,
|
|
214
|
+
response: exports.merchantSchema,
|
|
215
|
+
status: 201,
|
|
216
|
+
sdk: 'merchants.register',
|
|
217
|
+
}),
|
|
218
|
+
(0, route_1.defineRoute)({
|
|
219
|
+
operationId: 'retrieveMerchant',
|
|
220
|
+
method: 'get',
|
|
221
|
+
path: '/v1/merchants/me',
|
|
222
|
+
tag: 'Merchants',
|
|
223
|
+
summary: 'Retrieve your merchant',
|
|
224
|
+
auth: 'service',
|
|
225
|
+
scope: 'payments:read',
|
|
226
|
+
response: exports.merchantSchema,
|
|
227
|
+
sdk: 'merchants.retrieve',
|
|
228
|
+
}),
|
|
229
|
+
(0, route_1.defineRoute)({
|
|
230
|
+
operationId: 'updateMerchant',
|
|
231
|
+
method: 'post',
|
|
232
|
+
path: '/v1/merchants/me',
|
|
233
|
+
tag: 'Merchants',
|
|
234
|
+
summary: 'Update your merchant',
|
|
235
|
+
auth: 'service',
|
|
236
|
+
scope: 'payments:write',
|
|
237
|
+
idempotent: true,
|
|
238
|
+
body: exports.updateMerchantParams,
|
|
239
|
+
response: exports.merchantSchema,
|
|
240
|
+
sdk: 'merchants.update',
|
|
241
|
+
}),
|
|
242
|
+
(0, route_1.defineRoute)({
|
|
243
|
+
operationId: 'retrieveBrandingSettings',
|
|
244
|
+
method: 'get',
|
|
245
|
+
path: '/v1/merchants/me/branding',
|
|
246
|
+
tag: 'Merchants',
|
|
247
|
+
summary: 'Retrieve your branding',
|
|
248
|
+
auth: 'service',
|
|
249
|
+
scope: 'payments:read',
|
|
250
|
+
response: exports.merchantBrandingSchema,
|
|
251
|
+
sdk: 'merchants.branding.retrieve',
|
|
252
|
+
}),
|
|
253
|
+
(0, route_1.defineRoute)({
|
|
254
|
+
operationId: 'updateBrandingSettings',
|
|
255
|
+
method: 'post',
|
|
256
|
+
path: '/v1/merchants/me/branding',
|
|
257
|
+
tag: 'Merchants',
|
|
258
|
+
summary: 'Update your branding',
|
|
259
|
+
auth: 'service',
|
|
260
|
+
scope: 'payments:write',
|
|
261
|
+
idempotent: true,
|
|
262
|
+
body: exports.updateMerchantBrandingParams,
|
|
263
|
+
response: exports.merchantBrandingSchema,
|
|
264
|
+
sdk: 'merchants.branding.update',
|
|
265
|
+
}),
|
|
266
|
+
(0, route_1.defineRoute)({
|
|
267
|
+
operationId: 'retrieveEmailSettings',
|
|
268
|
+
method: 'get',
|
|
269
|
+
path: '/v1/merchants/me/email_settings',
|
|
270
|
+
tag: 'Merchants',
|
|
271
|
+
summary: 'Retrieve your customer email settings',
|
|
272
|
+
auth: 'service',
|
|
273
|
+
scope: 'payments:read',
|
|
274
|
+
response: exports.merchantEmailSettingsSchema,
|
|
275
|
+
sdk: 'merchants.emailSettings.retrieve',
|
|
276
|
+
}),
|
|
277
|
+
(0, route_1.defineRoute)({
|
|
278
|
+
operationId: 'updateEmailSettings',
|
|
279
|
+
method: 'post',
|
|
280
|
+
path: '/v1/merchants/me/email_settings',
|
|
281
|
+
tag: 'Merchants',
|
|
282
|
+
summary: 'Update your customer email settings',
|
|
283
|
+
auth: 'service',
|
|
284
|
+
scope: 'payments:write',
|
|
285
|
+
idempotent: true,
|
|
286
|
+
body: exports.updateMerchantEmailSettingsParams,
|
|
287
|
+
response: exports.merchantEmailSettingsSchema,
|
|
288
|
+
sdk: 'merchants.emailSettings.update',
|
|
289
|
+
}),
|
|
290
|
+
];
|