@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,173 @@
|
|
|
1
|
+
// The event vocabulary (ADR 0014 D4, ADR 0019): every event type the gateway
|
|
2
|
+
// emits and the `object` type its `data.object` carries. Zod-free, so the SDK's
|
|
3
|
+
// signature check, the CLI and the backend's CHECK constraints read the same
|
|
4
|
+
// closed set without constructing a schema.
|
|
5
|
+
/**
|
|
6
|
+
* Event type → the `object` value of the resource under `data.object`.
|
|
7
|
+
*
|
|
8
|
+
* TOTAL and the ONLY list: {@link WEBHOOK_EVENT_TYPES} is its keys, so a new
|
|
9
|
+
* event type cannot exist without saying what it delivers — an event added
|
|
10
|
+
* with a default would silently ship a PaymentIntent to a consumer expecting
|
|
11
|
+
* something else, which typechecks on both sides and fails only in production.
|
|
12
|
+
* The precise payload TYPE is `WebhookEventPayload` (`resources/events`), the
|
|
13
|
+
* registered object of each value.
|
|
14
|
+
*
|
|
15
|
+
* The order is the database's: the backend's CHECK constraints list the types
|
|
16
|
+
* in this order, so reordering it is a migration.
|
|
17
|
+
*
|
|
18
|
+
* - `payment_intent.*` follow the status the intent reached (ADR 0019):
|
|
19
|
+
* `created` when it is minted, then one per transition — `requires_action`,
|
|
20
|
+
* `processing`, `amount_capturable_updated` (authorized, awaiting capture),
|
|
21
|
+
* `succeeded`, `payment_failed` (an attempt failed; a card returns to
|
|
22
|
+
* `requires_payment_method`, a FairCoin underpayment is also `canceled`) and
|
|
23
|
+
* `canceled` (by the merchant, by expiry — `abandoned` — or underpaid).
|
|
24
|
+
* - Refunds are not PaymentIntent statuses: `refund.*` carry the Refund, and
|
|
25
|
+
* `charge.refunded` the Charge whose `amount_refunded` moved.
|
|
26
|
+
* - A dispute is the network's process beside a payment that stays
|
|
27
|
+
* `succeeded`; its events carry the Dispute, never the evidence (which is not
|
|
28
|
+
* stored).
|
|
29
|
+
* - The catalog has no `price.deleted` or `promotion_code.deleted`: those are
|
|
30
|
+
* archived with `active: false`, and a type that can never be sent is a
|
|
31
|
+
* promise the catalog cannot keep.
|
|
32
|
+
*/
|
|
33
|
+
export const WEBHOOK_EVENT_OBJECTS = {
|
|
34
|
+
'payment_intent.created': 'payment_intent',
|
|
35
|
+
'payment_intent.requires_action': 'payment_intent',
|
|
36
|
+
'payment_intent.processing': 'payment_intent',
|
|
37
|
+
'payment_intent.amount_capturable_updated': 'payment_intent',
|
|
38
|
+
'payment_intent.succeeded': 'payment_intent',
|
|
39
|
+
'payment_intent.payment_failed': 'payment_intent',
|
|
40
|
+
'payment_intent.canceled': 'payment_intent',
|
|
41
|
+
'charge.refunded': 'charge',
|
|
42
|
+
'charge.dispute.created': 'dispute',
|
|
43
|
+
'charge.dispute.updated': 'dispute',
|
|
44
|
+
'charge.dispute.closed': 'dispute',
|
|
45
|
+
'charge.dispute.funds_withdrawn': 'dispute',
|
|
46
|
+
'charge.dispute.funds_reinstated': 'dispute',
|
|
47
|
+
'refund.created': 'refund',
|
|
48
|
+
'refund.updated': 'refund',
|
|
49
|
+
'refund.failed': 'refund',
|
|
50
|
+
'customer.created': 'customer',
|
|
51
|
+
'customer.updated': 'customer',
|
|
52
|
+
'customer.deleted': 'customer',
|
|
53
|
+
'payment_method.attached': 'payment_method',
|
|
54
|
+
'payment_method.detached': 'payment_method',
|
|
55
|
+
'payment_method.updated': 'payment_method',
|
|
56
|
+
'setup_intent.created': 'setup_intent',
|
|
57
|
+
'setup_intent.requires_action': 'setup_intent',
|
|
58
|
+
'setup_intent.succeeded': 'setup_intent',
|
|
59
|
+
'setup_intent.setup_failed': 'setup_intent',
|
|
60
|
+
'setup_intent.canceled': 'setup_intent',
|
|
61
|
+
'billing.observation.updated': 'billing_observation',
|
|
62
|
+
'connected_account.updated': 'connected_account',
|
|
63
|
+
'product.created': 'product',
|
|
64
|
+
'product.updated': 'product',
|
|
65
|
+
'product.deleted': 'product',
|
|
66
|
+
'price.created': 'price',
|
|
67
|
+
'price.updated': 'price',
|
|
68
|
+
'coupon.created': 'coupon',
|
|
69
|
+
'coupon.updated': 'coupon',
|
|
70
|
+
'coupon.deleted': 'coupon',
|
|
71
|
+
'promotion_code.created': 'promotion_code',
|
|
72
|
+
'promotion_code.updated': 'promotion_code',
|
|
73
|
+
'account.updated': 'account',
|
|
74
|
+
'application_fee.created': 'application_fee',
|
|
75
|
+
'application_fee.refunded': 'application_fee',
|
|
76
|
+
'payout.created': 'payout',
|
|
77
|
+
'payout.updated': 'payout',
|
|
78
|
+
'payout.paid': 'payout',
|
|
79
|
+
'payout.failed': 'payout',
|
|
80
|
+
'payout.canceled': 'payout',
|
|
81
|
+
'balance.available': 'balance',
|
|
82
|
+
'checkout.session.completed': 'checkout_session',
|
|
83
|
+
'checkout.session.expired': 'checkout_session',
|
|
84
|
+
'checkout.session.async_payment_succeeded': 'checkout_session',
|
|
85
|
+
'checkout.session.async_payment_failed': 'checkout_session',
|
|
86
|
+
'payment_link.created': 'payment_link',
|
|
87
|
+
'payment_link.updated': 'payment_link',
|
|
88
|
+
'reporting.report_run.succeeded': 'reporting.report_run',
|
|
89
|
+
'reporting.report_run.failed': 'reporting.report_run',
|
|
90
|
+
'customer.subscription.created': 'subscription',
|
|
91
|
+
'customer.subscription.updated': 'subscription',
|
|
92
|
+
'customer.subscription.deleted': 'subscription',
|
|
93
|
+
'customer.subscription.trial_will_end': 'subscription',
|
|
94
|
+
'customer.subscription.paused': 'subscription',
|
|
95
|
+
'customer.subscription.resumed': 'subscription',
|
|
96
|
+
'invoice.created': 'invoice',
|
|
97
|
+
'invoice.updated': 'invoice',
|
|
98
|
+
'invoice.deleted': 'invoice',
|
|
99
|
+
'invoice.finalized': 'invoice',
|
|
100
|
+
'invoice.paid': 'invoice',
|
|
101
|
+
'invoice.payment_failed': 'invoice',
|
|
102
|
+
'invoice.payment_action_required': 'invoice',
|
|
103
|
+
'invoice.voided': 'invoice',
|
|
104
|
+
'invoice.marked_uncollectible': 'invoice',
|
|
105
|
+
'invoice.upcoming': 'invoice',
|
|
106
|
+
'invoice.sent': 'invoice',
|
|
107
|
+
'invoiceitem.created': 'invoiceitem',
|
|
108
|
+
'invoiceitem.deleted': 'invoiceitem',
|
|
109
|
+
'credit_note.created': 'credit_note',
|
|
110
|
+
'credit_note.updated': 'credit_note',
|
|
111
|
+
'credit_note.voided': 'credit_note',
|
|
112
|
+
'test_helpers.test_clock.created': 'test_helpers.test_clock',
|
|
113
|
+
'test_helpers.test_clock.advancing': 'test_helpers.test_clock',
|
|
114
|
+
'test_helpers.test_clock.ready': 'test_helpers.test_clock',
|
|
115
|
+
'test_helpers.test_clock.deleted': 'test_helpers.test_clock',
|
|
116
|
+
'billing.meter.created': 'billing.meter',
|
|
117
|
+
'billing.meter.updated': 'billing.meter',
|
|
118
|
+
'billing.meter.deactivated': 'billing.meter',
|
|
119
|
+
'billing.meter.reactivated': 'billing.meter',
|
|
120
|
+
'entitlements.active_entitlement_summary.updated': 'entitlements.active_entitlement_summary',
|
|
121
|
+
'billing_portal.configuration.created': 'billing_portal.configuration',
|
|
122
|
+
'billing_portal.configuration.updated': 'billing_portal.configuration',
|
|
123
|
+
'billing_portal.session.created': 'billing_portal.session',
|
|
124
|
+
'tax.assessment.created': 'tax.assessment',
|
|
125
|
+
'tax.review_item.created': 'tax.review_item',
|
|
126
|
+
'tax.review_item.updated': 'tax.review_item',
|
|
127
|
+
'webhook_endpoint.test': 'webhook_endpoint',
|
|
128
|
+
};
|
|
129
|
+
/** Every event type, in {@link WEBHOOK_EVENT_OBJECTS} order. */
|
|
130
|
+
export const WEBHOOK_EVENT_TYPES = Object.keys(WEBHOOK_EVENT_OBJECTS);
|
|
131
|
+
/**
|
|
132
|
+
* The event types never fanned out by subscription — sent only to the one
|
|
133
|
+
* endpoint they name. `enabled_events` refuses them.
|
|
134
|
+
*/
|
|
135
|
+
export const TARGETED_WEBHOOK_EVENT_TYPES = [
|
|
136
|
+
'webhook_endpoint.test',
|
|
137
|
+
];
|
|
138
|
+
/** What `enabled_events` may hold: `*`, then every subscribable type. */
|
|
139
|
+
export const WEBHOOK_ENABLED_EVENTS = [
|
|
140
|
+
'*',
|
|
141
|
+
...WEBHOOK_EVENT_TYPES.filter((type) => !TARGETED_WEBHOOK_EVENT_TYPES.includes(type)),
|
|
142
|
+
];
|
|
143
|
+
export const WEBHOOK_ENDPOINT_STATUSES = ['enabled', 'disabled'];
|
|
144
|
+
/**
|
|
145
|
+
* Why an endpoint is `disabled`.
|
|
146
|
+
*
|
|
147
|
+
* - `disabled_by_merchant` — its owner set `disabled: true`.
|
|
148
|
+
* - `delivery_failures` — every delivery to it failed for three days
|
|
149
|
+
* straight, so Peable stopped sending. Re-enabling it (`disabled: false`)
|
|
150
|
+
* starts the clock again.
|
|
151
|
+
*/
|
|
152
|
+
export const WEBHOOK_ENDPOINT_DISABLED_REASONS = [
|
|
153
|
+
'disabled_by_merchant',
|
|
154
|
+
'delivery_failures',
|
|
155
|
+
];
|
|
156
|
+
/** At most this many endpoints per merchant (per mode). */
|
|
157
|
+
export const WEBHOOK_ENDPOINTS_MAX_PER_MERCHANT = 16;
|
|
158
|
+
/** The longest an endpoint's `description` may be. */
|
|
159
|
+
export const WEBHOOK_ENDPOINT_DESCRIPTION_MAX = 5000;
|
|
160
|
+
/** The longest a rolled secret may keep signing beside its replacement. */
|
|
161
|
+
export const WEBHOOK_SECRET_ROLL_MAX_EXPIRES_IN_SECONDS = 24 * 60 * 60;
|
|
162
|
+
/**
|
|
163
|
+
* Where one webhook delivery stands (ADR 0001 D7).
|
|
164
|
+
*
|
|
165
|
+
* - `pending` — will be attempted. `next_attempt_at` says when.
|
|
166
|
+
* - `delivered` — terminal success.
|
|
167
|
+
* - `failed` — the endpoint REFUSED it (a 4xx, a blocked address), or the
|
|
168
|
+
* endpoint was disabled before it could be attempted. No retry
|
|
169
|
+
* can fix that, so none is made.
|
|
170
|
+
* - `dead` — every attempt failed transiently over three days and the
|
|
171
|
+
* budget ran out. It can be redelivered by hand.
|
|
172
|
+
*/
|
|
173
|
+
export const WEBHOOK_DELIVERY_STATUSES = ['pending', 'delivered', 'failed', 'dead'];
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Files vocabulary (`file_…`): what a file is for, the formats it is stored
|
|
2
|
+
// in, and whether its bytes are being served. Zod-free.
|
|
3
|
+
/**
|
|
4
|
+
* What a file is FOR. Decided at upload and never changed: the purpose is what
|
|
5
|
+
* sets the type and size policy, who may see the bytes, and which objects may
|
|
6
|
+
* reference the file — a `business_logo` is public, a `dispute_evidence` file
|
|
7
|
+
* is private and can only be attached to the merchant's own disputes.
|
|
8
|
+
*/
|
|
9
|
+
export const FILE_PURPOSES = [
|
|
10
|
+
'dispute_evidence',
|
|
11
|
+
'business_logo',
|
|
12
|
+
'identity_document',
|
|
13
|
+
'additional_verification',
|
|
14
|
+
'finance_report_run',
|
|
15
|
+
'tax_document',
|
|
16
|
+
];
|
|
17
|
+
/**
|
|
18
|
+
* The purposes a merchant may upload or import. `finance_report_run` is not
|
|
19
|
+
* among them: a report's CSV is written by Peable's report runs
|
|
20
|
+
* (`/v1/reporting/report_runs`) and nobody else, so a file of that purpose is
|
|
21
|
+
* always a report Peable produced.
|
|
22
|
+
*/
|
|
23
|
+
export const FILE_UPLOAD_PURPOSES = [
|
|
24
|
+
'dispute_evidence',
|
|
25
|
+
'business_logo',
|
|
26
|
+
'identity_document',
|
|
27
|
+
'additional_verification',
|
|
28
|
+
'tax_document',
|
|
29
|
+
];
|
|
30
|
+
/** The stored format, by its conventional extension (Stripe's `type`). */
|
|
31
|
+
export const FILE_TYPES = ['pdf', 'png', 'jpg', 'csv'];
|
|
32
|
+
/**
|
|
33
|
+
* Whether the bytes can be used right now.
|
|
34
|
+
*
|
|
35
|
+
* - `available` — Oxy serves the file; it can be shown or forwarded.
|
|
36
|
+
* - `withheld` — the file still exists and is not being served (its owner
|
|
37
|
+
* trashed it or made it private); it can come back.
|
|
38
|
+
* - `removed` — Oxy said the file is gone for good (deleted, taken down, lost).
|
|
39
|
+
* The object stays so whatever referenced it can say why it stopped working.
|
|
40
|
+
*/
|
|
41
|
+
export const FILE_STATUSES = ['available', 'withheld', 'removed'];
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Peable's own Oxy application: the identity the gateway runs as (`OxyServer`'s
|
|
3
|
+
* `applicationId`) and the one an Oxy service addresses when it calls the
|
|
4
|
+
* gateway. One constant, so the gateway's accepted audience and the SDK's
|
|
5
|
+
* requested one cannot name two different applications.
|
|
6
|
+
*/
|
|
7
|
+
export const PEABLE_OXY_APPLICATION_ID = '6a2f851751b784a86fd0e958';
|
|
8
|
+
/** The service-token audience of Peable's gateway (`oxy-service:<application id>`). */
|
|
9
|
+
export const PEABLE_SERVICE_AUDIENCE = `oxy-service:${PEABLE_OXY_APPLICATION_ID}`;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
// `@peable.to/contracts/vocabulary` — the zod-free half of the contract: the
|
|
2
|
+
// closed value sets (currencies, statuses, event types, error codes) a schema
|
|
3
|
+
// is built from. A bundle that must stay small imports this subpath, never the
|
|
4
|
+
// package root, which constructs every schema at load.
|
|
5
|
+
export * from './billingPortal.js';
|
|
6
|
+
export * from './connect.js';
|
|
7
|
+
export * from './dashboard.js';
|
|
8
|
+
export * from './catalog.js';
|
|
9
|
+
export * from './errors.js';
|
|
10
|
+
export * from './invoices.js';
|
|
11
|
+
export * from './events.js';
|
|
12
|
+
export * from './lists.js';
|
|
13
|
+
export * from './money.js';
|
|
14
|
+
export * from './tax.js';
|
|
15
|
+
export * from './subscriptions.js';
|
|
16
|
+
export * from './reporting.js';
|
|
17
|
+
export * from './payments.js';
|
|
18
|
+
export * from './version.js';
|
|
19
|
+
export * from './checkout.js';
|
|
20
|
+
export * from './files.js';
|
|
21
|
+
export * from './identity.js';
|
|
22
|
+
export * from './merchants.js';
|
|
23
|
+
export * from './paymentMethodConfigurations.js';
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// Invoices, invoice items, credit notes and the customer balance (ADR 0018
|
|
2
|
+
// §2–4) — the closed value sets their schemas are built from. Zod-free:
|
|
3
|
+
// `@peable.to/shared-types` re-exports them at runtime.
|
|
4
|
+
export const INVOICE_STATUSES = ['draft', 'open', 'paid', 'void', 'uncollectible'];
|
|
5
|
+
/** Why an invoice exists. */
|
|
6
|
+
export const INVOICE_BILLING_REASONS = [
|
|
7
|
+
'manual',
|
|
8
|
+
'subscription_create',
|
|
9
|
+
'subscription_cycle',
|
|
10
|
+
'subscription_update',
|
|
11
|
+
'subscription_cancel',
|
|
12
|
+
'upcoming',
|
|
13
|
+
];
|
|
14
|
+
/**
|
|
15
|
+
* `automatic_tax.status` — Peable Tax (ADR 0011) is computed before an invoice
|
|
16
|
+
* finalizes (ADR 0018 §2).
|
|
17
|
+
*
|
|
18
|
+
* - `requires_location_inputs` — the customer's location could not be
|
|
19
|
+
* established; the invoice cannot finalize until it can.
|
|
20
|
+
* - `failed` — the calculation failed closed (the provider
|
|
21
|
+
* was unavailable, or disagreed with Peable's registrations); retried.
|
|
22
|
+
* - `complete` — calculated (including `not_registered`,
|
|
23
|
+
* which is a calculation that collects zero).
|
|
24
|
+
*/
|
|
25
|
+
export const AUTOMATIC_TAX_STATUSES = ['requires_location_inputs', 'failed', 'complete'];
|
|
26
|
+
/** Where an invoice line comes from: a subscription item's period, or an invoice item. */
|
|
27
|
+
export const INVOICE_LINE_TYPES = ['subscription', 'invoiceitem'];
|
|
28
|
+
/** `pending_invoice_items_behavior` on an invoice create. Default `exclude` (Stripe's). */
|
|
29
|
+
export const PENDING_INVOICE_ITEMS_BEHAVIORS = ['include', 'exclude'];
|
|
30
|
+
export const CREDIT_NOTE_STATUSES = ['issued', 'void'];
|
|
31
|
+
/** `pre_payment` reduces what an open invoice asks for; `post_payment` gives back on a paid one. */
|
|
32
|
+
export const CREDIT_NOTE_TYPES = ['pre_payment', 'post_payment'];
|
|
33
|
+
export const CREDIT_NOTE_REASONS = [
|
|
34
|
+
'duplicate',
|
|
35
|
+
'fraudulent',
|
|
36
|
+
'order_change',
|
|
37
|
+
'product_unsatisfactory',
|
|
38
|
+
];
|
|
39
|
+
/** A credit note line: part of an invoice line, or a custom amount. */
|
|
40
|
+
export const CREDIT_NOTE_LINE_TYPES = ['invoice_line_item', 'custom_line_item'];
|
|
41
|
+
export const CUSTOMER_BALANCE_TRANSACTION_TYPES = [
|
|
42
|
+
'adjustment',
|
|
43
|
+
'applied_to_invoice',
|
|
44
|
+
'credit_note',
|
|
45
|
+
'invoice_overpaid',
|
|
46
|
+
'unapplied_from_invoice',
|
|
47
|
+
];
|
|
48
|
+
/** The rails a hosted invoice is paid on: a card through the provider's fields, FairCoin from the payer's wallet. */
|
|
49
|
+
export const PUBLIC_INVOICE_PAYMENT_METHOD_TYPES = ['card', 'faircoin'];
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
// List and search bounds (ADR 0014 D1) — the gateway's, restated so a client
|
|
2
|
+
// can check before it asks.
|
|
3
|
+
export const LIST_LIMIT_DEFAULT = 10;
|
|
4
|
+
export const LIST_LIMIT_MAX = 100;
|
|
5
|
+
export const SEARCH_QUERY_MAX_LENGTH = 1000;
|
|
6
|
+
export const SEARCH_QUERY_MAX_CLAUSES = 10;
|
|
7
|
+
/** A `~` substring needs at least this many characters (Stripe's rule). */
|
|
8
|
+
export const SEARCH_SUBSTRING_MIN_LENGTH = 3;
|
|
9
|
+
/** Every searchable resource, by its path segment (`/v1/<resource>/search`). */
|
|
10
|
+
export const SEARCHABLE_RESOURCES = [
|
|
11
|
+
'payment_intents',
|
|
12
|
+
'charges',
|
|
13
|
+
'customers',
|
|
14
|
+
'products',
|
|
15
|
+
'prices',
|
|
16
|
+
'refunds',
|
|
17
|
+
'subscriptions',
|
|
18
|
+
'invoices',
|
|
19
|
+
];
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Merchant vocabulary: the environments a merchant lives in, and the closed
|
|
2
|
+
// sets branding draws from. Every branding value is from a CLOSED set or a
|
|
3
|
+
// validated colour, so nothing a merchant stores can inject markup or a remote
|
|
4
|
+
// font into a payer's page or an email. Zod-free.
|
|
5
|
+
export const MERCHANT_ENVIRONMENTS = ['development', 'staging', 'production'];
|
|
6
|
+
/** The fonts checkout may render in — system stacks only, no remote font is ever loaded. */
|
|
7
|
+
export const BRANDING_FONTS = [
|
|
8
|
+
'system',
|
|
9
|
+
'inter',
|
|
10
|
+
'roboto',
|
|
11
|
+
'open_sans',
|
|
12
|
+
'lato',
|
|
13
|
+
'source_sans',
|
|
14
|
+
'noto_sans',
|
|
15
|
+
'serif',
|
|
16
|
+
'monospace',
|
|
17
|
+
];
|
|
18
|
+
export const BRANDING_BORDER_STYLES = ['rounded', 'rectangular', 'pill'];
|
|
19
|
+
/** `#rrggbb`, lowercase — the only colour spelling branding stores. */
|
|
20
|
+
export const BRANDING_COLOR_PATTERN = /^#[0-9a-f]{6}$/;
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
// Money vocabulary. Every monetary value moves through the gateway as a
|
|
2
|
+
// canonical integer string in the currency's SMALLEST unit — m⊜ for FairCoin,
|
|
3
|
+
// cents for a fiat currency — so no float ever touches one.
|
|
4
|
+
//
|
|
5
|
+
// Zod-free on purpose: `@peable.to/contracts/vocabulary` is what a bundle that
|
|
6
|
+
// must stay small (the wallet, the hosted checkout) imports at runtime, through
|
|
7
|
+
// `@peable.to/shared-types`.
|
|
8
|
+
/**
|
|
9
|
+
* The currencies this gateway can denominate a payment in: FairCoin on the
|
|
10
|
+
* chain rail, and on the card rail the fiat set the provider settles for the
|
|
11
|
+
* payment methods Orbit offers (cards, wallets, SEPA Debit, iDEAL, Bancontact,
|
|
12
|
+
* EPS). A local method narrows it further per payment
|
|
13
|
+
* (`PAYMENT_METHOD_CURRENCIES` in `paymentMethodConfiguration.ts`).
|
|
14
|
+
*
|
|
15
|
+
* A closed set, and the database mirrors it as a CHECK
|
|
16
|
+
* (`db/schema/valueSets.ts`). ADR 0001 D4: the scale of an amount is a property
|
|
17
|
+
* of its currency and is NOT implied by the field's type, which is why
|
|
18
|
+
* {@link CURRENCY_DECIMALS} exists and why {@link UNITS_PER_COIN} must never be
|
|
19
|
+
* used to interpret a fiat amount.
|
|
20
|
+
*/
|
|
21
|
+
export const CURRENCY_CODES = [
|
|
22
|
+
'FAIR',
|
|
23
|
+
'EUR',
|
|
24
|
+
'USD',
|
|
25
|
+
'GBP',
|
|
26
|
+
'CHF',
|
|
27
|
+
'SEK',
|
|
28
|
+
'NOK',
|
|
29
|
+
'DKK',
|
|
30
|
+
'PLN',
|
|
31
|
+
'CZK',
|
|
32
|
+
'CAD',
|
|
33
|
+
'AUD',
|
|
34
|
+
'JPY',
|
|
35
|
+
];
|
|
36
|
+
/** Whether an arbitrary string is a currency this gateway knows. */
|
|
37
|
+
export function isCurrencyCode(value) {
|
|
38
|
+
return CURRENCY_CODES.includes(value);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* How many decimal places each currency's smallest unit represents — i.e. an
|
|
42
|
+
* amount of `1` means `10^-decimals` of one whole unit.
|
|
43
|
+
*
|
|
44
|
+
* ISO 4217's minor units for every fiat member (JPY has none). FairCoin's 8 is
|
|
45
|
+
* a consensus constant and is pinned against {@link UNITS_PER_COIN} by this
|
|
46
|
+
* package's own tests, so the two spellings of one fact cannot drift.
|
|
47
|
+
*/
|
|
48
|
+
export const CURRENCY_DECIMALS = Object.freeze({
|
|
49
|
+
FAIR: 8,
|
|
50
|
+
EUR: 2,
|
|
51
|
+
USD: 2,
|
|
52
|
+
GBP: 2,
|
|
53
|
+
CHF: 2,
|
|
54
|
+
SEK: 2,
|
|
55
|
+
NOK: 2,
|
|
56
|
+
DKK: 2,
|
|
57
|
+
PLN: 2,
|
|
58
|
+
CZK: 2,
|
|
59
|
+
CAD: 2,
|
|
60
|
+
AUD: 2,
|
|
61
|
+
// A zero-decimal currency: an amount of `1` is one yen, never a hundredth of
|
|
62
|
+
// one. The provider counts JPY the same way, so the base unit crosses as is.
|
|
63
|
+
JPY: 0,
|
|
64
|
+
});
|
|
65
|
+
/** The fiat members — every currency the card rail can denominate a payment in. */
|
|
66
|
+
export const FIAT_CURRENCY_CODES = CURRENCY_CODES.filter((code) => code !== 'FAIR');
|
|
67
|
+
/** The decimal places of `currency`'s smallest unit. */
|
|
68
|
+
export function decimalsFor(currency) {
|
|
69
|
+
return CURRENCY_DECIMALS[currency];
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Frozen FairCoin consensus constant (smallest units per FAIR). Mirrors
|
|
73
|
+
* `@fairco.in/core`'s branding.ts; inlined to keep this module zero-dependency
|
|
74
|
+
* for a clean CJS+ESM publish — must stay a bigint, never converted to number.
|
|
75
|
+
*
|
|
76
|
+
* FAIRCOIN ONLY. A fiat amount has its own scale (`CURRENCY_DECIMALS`), and
|
|
77
|
+
* dividing a EUR amount by this constant is off by six orders of magnitude with
|
|
78
|
+
* nothing failing.
|
|
79
|
+
*/
|
|
80
|
+
export const UNITS_PER_COIN = 100000000n;
|
|
81
|
+
/** The spelling of a base-unit amount: digits, no sign, no leading zeros but `0`. */
|
|
82
|
+
export const BASE_UNIT_PATTERN = /^(0|[1-9][0-9]*)$/;
|
|
83
|
+
/** A signed base-unit amount (a customer balance, a balance transaction's net). */
|
|
84
|
+
export const SIGNED_BASE_UNIT_PATTERN = /^(0|-?[1-9][0-9]*)$/;
|
|
85
|
+
/**
|
|
86
|
+
* True only for a canonical non-negative integer string in the currency's
|
|
87
|
+
* smallest unit: one or more decimal digits, no sign, no decimal point, no
|
|
88
|
+
* leading zeros (except the literal "0"). Floats and negatives are rejected.
|
|
89
|
+
*
|
|
90
|
+
* Currency-agnostic on purpose — the pattern is about the SPELLING of an
|
|
91
|
+
* amount, not its scale, and the same one is restated as a CHECK in the
|
|
92
|
+
* database (`BASE_UNIT_STRING_PATTERN`), byte-identical.
|
|
93
|
+
*/
|
|
94
|
+
export function isBaseUnitString(s) {
|
|
95
|
+
return BASE_UNIT_PATTERN.test(s);
|
|
96
|
+
}
|
|
97
|
+
/** FairCoin network identifier, mirroring `@fairco.in/core`'s `NetworkType`. */
|
|
98
|
+
export const NETWORK_TYPES = ['mainnet', 'testnet'];
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
// Payment method breadth on the card rail (`pmc_…`, `pmd_…`). Zod-free.
|
|
2
|
+
/**
|
|
3
|
+
* The methods a configuration can turn on.
|
|
4
|
+
*
|
|
5
|
+
* `apple_pay` and `google_pay` are WALLETS over a card: a payment made with one
|
|
6
|
+
* is a `card` payment, so they appear here and never in a PaymentIntent's
|
|
7
|
+
* `payment_method_types`. `bizum` is listed because merchants ask for it and the
|
|
8
|
+
* honest answer is a reason, not an absence: the provider does not offer it.
|
|
9
|
+
*
|
|
10
|
+
* Deliberately absent: the provider's own consumer wallet (its brand on Orbit's
|
|
11
|
+
* checkout, `payment-provider-boundary.md`) and giropay (discontinued by the
|
|
12
|
+
* scheme).
|
|
13
|
+
*/
|
|
14
|
+
export const PAYMENT_METHOD_CONFIGURATION_TYPES = [
|
|
15
|
+
'card',
|
|
16
|
+
'apple_pay',
|
|
17
|
+
'google_pay',
|
|
18
|
+
'sepa_debit',
|
|
19
|
+
'ideal',
|
|
20
|
+
'bancontact',
|
|
21
|
+
'eps',
|
|
22
|
+
'bizum',
|
|
23
|
+
];
|
|
24
|
+
/**
|
|
25
|
+
* Why a method cannot be offered whatever the merchant chooses.
|
|
26
|
+
*
|
|
27
|
+
* - `provider_unsupported` — the processing provider does not offer it;
|
|
28
|
+
* - `requires_card` — a wallet rides on card payments, and card is off.
|
|
29
|
+
*/
|
|
30
|
+
export const PAYMENT_METHOD_UNAVAILABLE_REASONS = [
|
|
31
|
+
'provider_unsupported',
|
|
32
|
+
'requires_card',
|
|
33
|
+
];
|
|
@@ -0,0 +1,192 @@
|
|
|
1
|
+
// The payments vocabulary (ADR 0014 D5): the closed value sets the payment
|
|
2
|
+
// intent, charge, refund, dispute, setup intent, social and test-helper
|
|
3
|
+
// contracts are built from. Zod-free, so the wallet and the shared types read
|
|
4
|
+
// them without bundling a schema.
|
|
5
|
+
/**
|
|
6
|
+
* Which rail moves the money (ADR 0001 D1). On the INTENT, not on the merchant:
|
|
7
|
+
* one merchant takes both, and the rail decides which fields mean anything.
|
|
8
|
+
*/
|
|
9
|
+
export const PAYMENT_INTENT_RAILS = ['faircoin', 'card'];
|
|
10
|
+
/**
|
|
11
|
+
* Stripe's seven statuses, and no others (ADR 0019). The FairCoin rail walks
|
|
12
|
+
* four of them (`requires_action` → `processing` → `succeeded` | `canceled`); a
|
|
13
|
+
* card walks all seven. The order is the lifecycle table's
|
|
14
|
+
* (`@peable.to/shared-types`), which the database CHECK is rendered from.
|
|
15
|
+
*/
|
|
16
|
+
export const PAYMENT_INTENT_STATUSES = [
|
|
17
|
+
'requires_payment_method',
|
|
18
|
+
'requires_confirmation',
|
|
19
|
+
'requires_action',
|
|
20
|
+
'processing',
|
|
21
|
+
'requires_capture',
|
|
22
|
+
'succeeded',
|
|
23
|
+
'canceled',
|
|
24
|
+
];
|
|
25
|
+
/**
|
|
26
|
+
* Why an intent was cancelled — Stripe's reasons, plus `underpaid` (FairCoin
|
|
27
|
+
* only: a transaction paid less than the amount).
|
|
28
|
+
*/
|
|
29
|
+
export const PAYMENT_INTENT_CANCELLATION_REASONS = [
|
|
30
|
+
'abandoned',
|
|
31
|
+
'automatic',
|
|
32
|
+
'duplicate',
|
|
33
|
+
'fraudulent',
|
|
34
|
+
'requested_by_customer',
|
|
35
|
+
'underpaid',
|
|
36
|
+
];
|
|
37
|
+
/** The reasons a MERCHANT may give `POST /v1/payment_intents/:id/cancel`. */
|
|
38
|
+
export const MERCHANT_CANCELLATION_REASONS = [
|
|
39
|
+
'abandoned',
|
|
40
|
+
'duplicate',
|
|
41
|
+
'fraudulent',
|
|
42
|
+
'requested_by_customer',
|
|
43
|
+
];
|
|
44
|
+
/** When a card is captured: at confirmation, or by `POST …/capture` (card only). */
|
|
45
|
+
export const PAYMENT_INTENT_CAPTURE_METHODS = ['automatic', 'manual'];
|
|
46
|
+
/** Card only: keep the payment method on the customer for later (ADR 0016). */
|
|
47
|
+
export const PAYMENT_INTENT_SETUP_FUTURE_USAGES = ['on_session', 'off_session'];
|
|
48
|
+
/** The card-rail types a PaymentIntent can carry in `payment_method_types`. */
|
|
49
|
+
export const CARD_RAIL_PAYMENT_METHOD_TYPES = [
|
|
50
|
+
'card',
|
|
51
|
+
'sepa_debit',
|
|
52
|
+
'ideal',
|
|
53
|
+
'bancontact',
|
|
54
|
+
'eps',
|
|
55
|
+
];
|
|
56
|
+
/**
|
|
57
|
+
* Every payment method type a PaymentIntent can carry: `faircoin` on the chain
|
|
58
|
+
* rail, the card rail's otherwise. Wallets (Apple Pay, Google Pay) are `card`.
|
|
59
|
+
*/
|
|
60
|
+
export const PAYMENT_METHOD_TYPES = ['faircoin', ...CARD_RAIL_PAYMENT_METHOD_TYPES];
|
|
61
|
+
/** The kinds of `last_payment_error` (and a SetupIntent's `last_setup_error`). */
|
|
62
|
+
export const PAYMENT_ERROR_TYPES = ['card_error', 'payment_error', 'api_error'];
|
|
63
|
+
/** How the payer's client continues: a confirmation credential, or a redirect. */
|
|
64
|
+
export const CLIENT_ACTION_KINDS = ['client_secret', 'redirect'];
|
|
65
|
+
// ---------------------------------------------------------------------------
|
|
66
|
+
// Refunds and settlements
|
|
67
|
+
// ---------------------------------------------------------------------------
|
|
68
|
+
/**
|
|
69
|
+
* Where one refund stands — the MONEY's own lifecycle, not the payment's.
|
|
70
|
+
* `canceled` only through `POST /v1/refunds/:id/cancel`.
|
|
71
|
+
*/
|
|
72
|
+
export const REFUND_STATUSES = ['pending', 'succeeded', 'failed', 'canceled'];
|
|
73
|
+
/** Stripe's refund reasons. */
|
|
74
|
+
export const REFUND_REASONS = ['duplicate', 'fraudulent', 'requested_by_customer'];
|
|
75
|
+
/**
|
|
76
|
+
* Who created a refund. `provider`: it appeared at the acquirer (a dashboard
|
|
77
|
+
* refund, a dispute's resolution) and was imported, without an `external_ref`.
|
|
78
|
+
*/
|
|
79
|
+
export const REFUND_ORIGINS = ['merchant', 'provider'];
|
|
80
|
+
/** Where a payment's settlement figures stand. `unknown` is not zero. */
|
|
81
|
+
export const SETTLEMENT_STATUSES = ['available', 'pending', 'unknown'];
|
|
82
|
+
// ---------------------------------------------------------------------------
|
|
83
|
+
// Disputes
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
/**
|
|
86
|
+
* Where a dispute stands. `needs_response` and `under_review` are open; `won`
|
|
87
|
+
* and `lost` are terminal. There is deliberately no `closed`.
|
|
88
|
+
*/
|
|
89
|
+
export const DISPUTE_STATUSES = ['needs_response', 'under_review', 'won', 'lost'];
|
|
90
|
+
/** Why the cardholder disputed — Stripe's enum; an unmapped network reason reads `general`. */
|
|
91
|
+
export const DISPUTE_REASONS = [
|
|
92
|
+
'bank_cannot_process',
|
|
93
|
+
'check_returned',
|
|
94
|
+
'credit_not_processed',
|
|
95
|
+
'customer_initiated',
|
|
96
|
+
'debit_not_authorized',
|
|
97
|
+
'duplicate',
|
|
98
|
+
'fraudulent',
|
|
99
|
+
'general',
|
|
100
|
+
'incorrect_account_details',
|
|
101
|
+
'insufficient_funds',
|
|
102
|
+
'noncompliant',
|
|
103
|
+
'product_not_received',
|
|
104
|
+
'product_unacceptable',
|
|
105
|
+
'subscription_canceled',
|
|
106
|
+
'unrecognized',
|
|
107
|
+
];
|
|
108
|
+
/**
|
|
109
|
+
* The TEXT evidence fields — the network's names, never a Peable paraphrase: a
|
|
110
|
+
* merchant assembling a defence reads their acquirer's guidance, and renamed
|
|
111
|
+
* fields would make it not apply. The Stripe adapter's name map is a total
|
|
112
|
+
* `Record` over this set, so a field added here does not compile until it
|
|
113
|
+
* carries it.
|
|
114
|
+
*/
|
|
115
|
+
export const DISPUTE_TEXT_EVIDENCE_FIELDS = [
|
|
116
|
+
'access_activity_log',
|
|
117
|
+
'billing_address',
|
|
118
|
+
'cancellation_policy_disclosure',
|
|
119
|
+
'cancellation_rebuttal',
|
|
120
|
+
'customer_email_address',
|
|
121
|
+
'customer_name',
|
|
122
|
+
'customer_purchase_ip',
|
|
123
|
+
'duplicate_charge_explanation',
|
|
124
|
+
'product_description',
|
|
125
|
+
'refund_policy_disclosure',
|
|
126
|
+
'refund_refusal_explanation',
|
|
127
|
+
'service_date',
|
|
128
|
+
'shipping_address',
|
|
129
|
+
'shipping_carrier',
|
|
130
|
+
'shipping_date',
|
|
131
|
+
'shipping_tracking_number',
|
|
132
|
+
'uncategorized_text',
|
|
133
|
+
];
|
|
134
|
+
/** The FILE evidence fields: each names a `file_…` of purpose `dispute_evidence`. */
|
|
135
|
+
export const DISPUTE_FILE_EVIDENCE_FIELDS = [
|
|
136
|
+
'cancellation_policy',
|
|
137
|
+
'customer_communication',
|
|
138
|
+
'customer_signature',
|
|
139
|
+
'duplicate_charge_documentation',
|
|
140
|
+
'receipt',
|
|
141
|
+
'refund_policy',
|
|
142
|
+
'service_documentation',
|
|
143
|
+
'shipping_documentation',
|
|
144
|
+
'uncategorized_file',
|
|
145
|
+
];
|
|
146
|
+
/** The provider's ceiling on one TEXT evidence field, restated where the request is parsed. */
|
|
147
|
+
export const DISPUTE_EVIDENCE_TEXT_MAX = 20000;
|
|
148
|
+
// ---------------------------------------------------------------------------
|
|
149
|
+
// SetupIntents
|
|
150
|
+
// ---------------------------------------------------------------------------
|
|
151
|
+
export const SETUP_INTENT_STATUSES = [
|
|
152
|
+
'requires_payment_method',
|
|
153
|
+
'requires_confirmation',
|
|
154
|
+
'requires_action',
|
|
155
|
+
'processing',
|
|
156
|
+
'canceled',
|
|
157
|
+
'succeeded',
|
|
158
|
+
];
|
|
159
|
+
export const SETUP_INTENT_USAGES = ['on_session', 'off_session'];
|
|
160
|
+
export const SETUP_INTENT_CANCELLATION_REASONS = [
|
|
161
|
+
'abandoned',
|
|
162
|
+
'duplicate',
|
|
163
|
+
'requested_by_customer',
|
|
164
|
+
];
|
|
165
|
+
// ---------------------------------------------------------------------------
|
|
166
|
+
// Social payments and enrichment
|
|
167
|
+
// ---------------------------------------------------------------------------
|
|
168
|
+
/**
|
|
169
|
+
* Longest `source.app` of a social payment: an app slug, not a label. The
|
|
170
|
+
* column CHECK reads the same bound.
|
|
171
|
+
*/
|
|
172
|
+
export const SOCIAL_SOURCE_APP_MAX_LENGTH = 32;
|
|
173
|
+
/**
|
|
174
|
+
* Longest `source.ref` of a social payment. The bound is the whole defence: the
|
|
175
|
+
* value is opaque, so nothing downstream would notice it growing.
|
|
176
|
+
*/
|
|
177
|
+
export const SOCIAL_SOURCE_REF_MAX_LENGTH = 128;
|
|
178
|
+
/** Which side of a social payment the caller was on. */
|
|
179
|
+
export const SOCIAL_PAYMENT_DIRECTIONS = ['sent', 'received'];
|
|
180
|
+
/** Where a transaction's counterparty identity came from. */
|
|
181
|
+
export const ENRICHMENT_KINDS = ['merchant', 'user', 'unknown'];
|
|
182
|
+
/** How many addresses one `POST /v1/enrich` resolves (and one social history lists). */
|
|
183
|
+
export const ENRICH_MAX_ADDRESSES = 50;
|
|
184
|
+
// ---------------------------------------------------------------------------
|
|
185
|
+
// Test helpers
|
|
186
|
+
// ---------------------------------------------------------------------------
|
|
187
|
+
/**
|
|
188
|
+
* What `simulate_faircoin_payment` pretends the payer did: `settled` paid the
|
|
189
|
+
* full amount (`processing` → `succeeded`); `underpaid` sent less
|
|
190
|
+
* (`processing` → `canceled`, `cancellation_reason: 'underpaid'`).
|
|
191
|
+
*/
|
|
192
|
+
export const SIMULATED_FAIRCOIN_OUTCOMES = ['settled', 'underpaid'];
|