@peable.to/contracts 0.3.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (316) hide show
  1. package/dist/cjs/common/address.js +81 -0
  2. package/dist/cjs/common/envelopes.js +101 -0
  3. package/dist/cjs/common/objects.js +85 -0
  4. package/dist/cjs/common/params.js +211 -0
  5. package/dist/cjs/common/primitives.js +39 -0
  6. package/dist/cjs/contributions.js +22 -0
  7. package/dist/cjs/index.js +40 -97
  8. package/dist/cjs/openapi/document.js +297 -0
  9. package/dist/cjs/openapi/index.js +7 -0
  10. package/dist/cjs/openapi/webhooks.js +17 -0
  11. package/dist/cjs/resources/billingEngine/billingPortal.js +237 -0
  12. package/dist/cjs/resources/billingEngine/creditNotes.js +189 -0
  13. package/dist/cjs/resources/billingEngine/customerBalanceTransactions.js +90 -0
  14. package/dist/cjs/resources/billingEngine/index.js +43 -0
  15. package/dist/cjs/resources/billingEngine/invoiceItems.js +155 -0
  16. package/dist/cjs/resources/billingEngine/invoices.js +509 -0
  17. package/dist/cjs/resources/billingEngine/params.js +43 -0
  18. package/dist/cjs/resources/billingEngine/public.js +326 -0
  19. package/dist/cjs/resources/billingEngine/subscriptions.js +476 -0
  20. package/dist/cjs/resources/catalog/billing.js +755 -0
  21. package/dist/cjs/resources/catalog/billingSettings.js +131 -0
  22. package/dist/cjs/resources/catalog/coupons.js +222 -0
  23. package/dist/cjs/resources/catalog/entitlements.js +257 -0
  24. package/dist/cjs/resources/catalog/index.js +58 -0
  25. package/dist/cjs/resources/catalog/meters.js +279 -0
  26. package/dist/cjs/resources/catalog/prices.js +423 -0
  27. package/dist/cjs/resources/catalog/products.js +228 -0
  28. package/dist/cjs/resources/catalog/promotionCodes.js +174 -0
  29. package/dist/cjs/resources/catalog/shared.js +75 -0
  30. package/dist/cjs/resources/catalog/testClocks.js +127 -0
  31. package/dist/cjs/resources/checkout/checkoutSessions.js +582 -0
  32. package/dist/cjs/resources/checkout/contributions.js +172 -0
  33. package/dist/cjs/resources/checkout/files.js +133 -0
  34. package/dist/cjs/resources/checkout/index.js +57 -0
  35. package/dist/cjs/resources/checkout/merchants.js +290 -0
  36. package/dist/cjs/resources/checkout/paymentLinks.js +330 -0
  37. package/dist/cjs/resources/checkout/paymentMethodConfigurations.js +262 -0
  38. package/dist/cjs/resources/checkout/shared.js +368 -0
  39. package/dist/cjs/resources/connect/account.js +332 -0
  40. package/dist/cjs/resources/connect/applicationFees.js +113 -0
  41. package/dist/cjs/resources/connect/balance.js +212 -0
  42. package/dist/cjs/resources/connect/connectedAccounts.js +260 -0
  43. package/dist/cjs/resources/connect/index.js +51 -0
  44. package/dist/cjs/resources/connect/onboarding.js +82 -0
  45. package/dist/cjs/resources/connect/payouts.js +196 -0
  46. package/dist/cjs/resources/connect/reporting.js +235 -0
  47. package/dist/cjs/resources/connect/requestLogs.js +110 -0
  48. package/dist/cjs/resources/connect/transfers.js +227 -0
  49. package/dist/cjs/resources/core/customers.js +194 -0
  50. package/dist/cjs/resources/core/index.js +23 -0
  51. package/dist/cjs/resources/core/paymentMethods.js +134 -0
  52. package/dist/cjs/resources/events/events.js +357 -0
  53. package/dist/cjs/resources/events/index.js +29 -0
  54. package/dist/cjs/resources/events/webhookDeliveries.js +93 -0
  55. package/dist/cjs/resources/events/webhookEndpoints.js +215 -0
  56. package/dist/cjs/resources/payments/charges.js +157 -0
  57. package/dist/cjs/resources/payments/disputes.js +204 -0
  58. package/dist/cjs/resources/payments/index.js +41 -0
  59. package/dist/cjs/resources/payments/paymentIntents.js +529 -0
  60. package/dist/cjs/resources/payments/refunds.js +245 -0
  61. package/dist/cjs/resources/payments/setupIntents.js +158 -0
  62. package/dist/cjs/resources/payments/social.js +182 -0
  63. package/dist/cjs/resources/payments/testHelpers.js +39 -0
  64. package/dist/cjs/resources/tax/assessments.js +217 -0
  65. package/dist/cjs/resources/tax/businessProfile.js +99 -0
  66. package/dist/cjs/resources/tax/calculations.js +176 -0
  67. package/dist/cjs/resources/tax/capabilities.js +42 -0
  68. package/dist/cjs/resources/tax/codes.js +37 -0
  69. package/dist/cjs/resources/tax/complianceActions.js +56 -0
  70. package/dist/cjs/resources/tax/deadlines.js +59 -0
  71. package/dist/cjs/resources/tax/documents.js +128 -0
  72. package/dist/cjs/resources/tax/index.js +80 -0
  73. package/dist/cjs/resources/tax/locationEvidence.js +131 -0
  74. package/dist/cjs/resources/tax/operatingLocations.js +98 -0
  75. package/dist/cjs/resources/tax/products.js +67 -0
  76. package/dist/cjs/resources/tax/registrationDeclarations.js +124 -0
  77. package/dist/cjs/resources/tax/registrations.js +82 -0
  78. package/dist/cjs/resources/tax/reports.js +92 -0
  79. package/dist/cjs/resources/tax/reviewItems.js +116 -0
  80. package/dist/cjs/resources/tax/ruleSet.js +68 -0
  81. package/dist/cjs/resources/tax/salesDestinations.js +94 -0
  82. package/dist/cjs/resources/tax/settings.js +104 -0
  83. package/dist/cjs/resources/tax/shared.js +62 -0
  84. package/dist/cjs/resources/tax/transactions.js +102 -0
  85. package/dist/cjs/route.js +22 -0
  86. package/dist/cjs/routes.js +31 -0
  87. package/dist/cjs/vocabulary/billingPortal.js +15 -0
  88. package/dist/cjs/vocabulary/catalog.js +110 -0
  89. package/dist/cjs/vocabulary/checkout.js +53 -0
  90. package/dist/cjs/vocabulary/connect.js +95 -0
  91. package/dist/cjs/vocabulary/errors.js +174 -0
  92. package/dist/cjs/vocabulary/events.js +176 -0
  93. package/dist/cjs/vocabulary/files.js +44 -0
  94. package/dist/cjs/vocabulary/index.js +37 -0
  95. package/dist/cjs/vocabulary/invoices.js +52 -0
  96. package/dist/cjs/vocabulary/lists.js +22 -0
  97. package/dist/cjs/vocabulary/merchants.js +23 -0
  98. package/dist/cjs/vocabulary/money.js +104 -0
  99. package/dist/cjs/vocabulary/paymentMethodConfigurations.js +36 -0
  100. package/dist/cjs/vocabulary/payments.js +195 -0
  101. package/dist/cjs/vocabulary/reporting.js +27 -0
  102. package/dist/cjs/vocabulary/subscriptions.js +60 -0
  103. package/dist/cjs/vocabulary/tax.js +237 -0
  104. package/dist/cjs/vocabulary/version.js +12 -0
  105. package/dist/esm/common/address.js +76 -0
  106. package/dist/esm/common/envelopes.js +95 -0
  107. package/dist/esm/common/objects.js +74 -0
  108. package/dist/esm/common/params.js +203 -0
  109. package/dist/esm/common/primitives.js +35 -0
  110. package/dist/esm/contributions.js +5 -0
  111. package/dist/esm/index.js +26 -94
  112. package/dist/esm/openapi/document.js +294 -0
  113. package/dist/esm/openapi/index.js +2 -0
  114. package/dist/esm/openapi/webhooks.js +14 -0
  115. package/dist/esm/resources/billingEngine/billingPortal.js +234 -0
  116. package/dist/esm/resources/billingEngine/creditNotes.js +186 -0
  117. package/dist/esm/resources/billingEngine/customerBalanceTransactions.js +87 -0
  118. package/dist/esm/resources/billingEngine/index.js +26 -0
  119. package/dist/esm/resources/billingEngine/invoiceItems.js +152 -0
  120. package/dist/esm/resources/billingEngine/invoices.js +506 -0
  121. package/dist/esm/resources/billingEngine/params.js +39 -0
  122. package/dist/esm/resources/billingEngine/public.js +323 -0
  123. package/dist/esm/resources/billingEngine/subscriptions.js +473 -0
  124. package/dist/esm/resources/catalog/billing.js +752 -0
  125. package/dist/esm/resources/catalog/billingSettings.js +128 -0
  126. package/dist/esm/resources/catalog/coupons.js +219 -0
  127. package/dist/esm/resources/catalog/entitlements.js +254 -0
  128. package/dist/esm/resources/catalog/index.js +38 -0
  129. package/dist/esm/resources/catalog/meters.js +276 -0
  130. package/dist/esm/resources/catalog/prices.js +419 -0
  131. package/dist/esm/resources/catalog/products.js +225 -0
  132. package/dist/esm/resources/catalog/promotionCodes.js +171 -0
  133. package/dist/esm/resources/catalog/shared.js +67 -0
  134. package/dist/esm/resources/catalog/testClocks.js +124 -0
  135. package/dist/esm/resources/checkout/checkoutSessions.js +579 -0
  136. package/dist/esm/resources/checkout/contributions.js +167 -0
  137. package/dist/esm/resources/checkout/files.js +130 -0
  138. package/dist/esm/resources/checkout/index.js +25 -0
  139. package/dist/esm/resources/checkout/merchants.js +287 -0
  140. package/dist/esm/resources/checkout/paymentLinks.js +327 -0
  141. package/dist/esm/resources/checkout/paymentMethodConfigurations.js +259 -0
  142. package/dist/esm/resources/checkout/shared.js +363 -0
  143. package/dist/esm/resources/connect/account.js +329 -0
  144. package/dist/esm/resources/connect/applicationFees.js +110 -0
  145. package/dist/esm/resources/connect/balance.js +209 -0
  146. package/dist/esm/resources/connect/connectedAccounts.js +257 -0
  147. package/dist/esm/resources/connect/index.js +34 -0
  148. package/dist/esm/resources/connect/onboarding.js +79 -0
  149. package/dist/esm/resources/connect/payouts.js +193 -0
  150. package/dist/esm/resources/connect/reporting.js +232 -0
  151. package/dist/esm/resources/connect/requestLogs.js +107 -0
  152. package/dist/esm/resources/connect/transfers.js +224 -0
  153. package/dist/esm/resources/core/customers.js +191 -0
  154. package/dist/esm/resources/core/index.js +6 -0
  155. package/dist/esm/resources/core/paymentMethods.js +131 -0
  156. package/dist/esm/resources/events/events.js +353 -0
  157. package/dist/esm/resources/events/index.js +12 -0
  158. package/dist/esm/resources/events/webhookDeliveries.js +90 -0
  159. package/dist/esm/resources/events/webhookEndpoints.js +212 -0
  160. package/dist/esm/resources/payments/charges.js +154 -0
  161. package/dist/esm/resources/payments/disputes.js +201 -0
  162. package/dist/esm/resources/payments/index.js +24 -0
  163. package/dist/esm/resources/payments/paymentIntents.js +526 -0
  164. package/dist/esm/resources/payments/refunds.js +242 -0
  165. package/dist/esm/resources/payments/setupIntents.js +155 -0
  166. package/dist/esm/resources/payments/social.js +179 -0
  167. package/dist/esm/resources/payments/testHelpers.js +36 -0
  168. package/dist/esm/resources/tax/assessments.js +214 -0
  169. package/dist/esm/resources/tax/businessProfile.js +96 -0
  170. package/dist/esm/resources/tax/calculations.js +173 -0
  171. package/dist/esm/resources/tax/capabilities.js +39 -0
  172. package/dist/esm/resources/tax/codes.js +34 -0
  173. package/dist/esm/resources/tax/complianceActions.js +53 -0
  174. package/dist/esm/resources/tax/deadlines.js +56 -0
  175. package/dist/esm/resources/tax/documents.js +125 -0
  176. package/dist/esm/resources/tax/index.js +63 -0
  177. package/dist/esm/resources/tax/locationEvidence.js +128 -0
  178. package/dist/esm/resources/tax/operatingLocations.js +95 -0
  179. package/dist/esm/resources/tax/products.js +64 -0
  180. package/dist/esm/resources/tax/registrationDeclarations.js +121 -0
  181. package/dist/esm/resources/tax/registrations.js +79 -0
  182. package/dist/esm/resources/tax/reports.js +89 -0
  183. package/dist/esm/resources/tax/reviewItems.js +113 -0
  184. package/dist/esm/resources/tax/ruleSet.js +65 -0
  185. package/dist/esm/resources/tax/salesDestinations.js +91 -0
  186. package/dist/esm/resources/tax/settings.js +101 -0
  187. package/dist/esm/resources/tax/shared.js +58 -0
  188. package/dist/esm/resources/tax/transactions.js +99 -0
  189. package/dist/esm/route.js +16 -0
  190. package/dist/esm/routes.js +27 -0
  191. package/dist/esm/vocabulary/billingPortal.js +12 -0
  192. package/dist/esm/vocabulary/catalog.js +106 -0
  193. package/dist/esm/vocabulary/checkout.js +50 -0
  194. package/dist/esm/vocabulary/connect.js +92 -0
  195. package/dist/esm/vocabulary/errors.js +169 -0
  196. package/dist/esm/vocabulary/events.js +173 -0
  197. package/dist/esm/vocabulary/files.js +41 -0
  198. package/dist/esm/vocabulary/index.js +21 -0
  199. package/dist/esm/vocabulary/invoices.js +49 -0
  200. package/dist/esm/vocabulary/lists.js +19 -0
  201. package/dist/esm/vocabulary/merchants.js +20 -0
  202. package/dist/esm/vocabulary/money.js +98 -0
  203. package/dist/esm/vocabulary/paymentMethodConfigurations.js +33 -0
  204. package/dist/esm/vocabulary/payments.js +192 -0
  205. package/dist/esm/vocabulary/reporting.js +24 -0
  206. package/dist/esm/vocabulary/subscriptions.js +57 -0
  207. package/dist/esm/vocabulary/tax.js +233 -0
  208. package/dist/esm/vocabulary/version.js +9 -0
  209. package/dist/types/common/address.d.ts +62 -0
  210. package/dist/types/common/envelopes.d.ts +88 -0
  211. package/dist/types/common/objects.d.ts +107 -0
  212. package/dist/types/common/params.d.ts +156 -0
  213. package/dist/types/common/primitives.d.ts +56 -0
  214. package/dist/types/contributions.d.ts +1 -0
  215. package/dist/types/index.d.ts +16 -134
  216. package/dist/types/openapi/document.d.ts +16 -0
  217. package/dist/types/openapi/index.d.ts +2 -0
  218. package/dist/types/openapi/webhooks.d.ts +15 -0
  219. package/dist/types/resources/billingEngine/billingPortal.d.ts +742 -0
  220. package/dist/types/resources/billingEngine/creditNotes.d.ts +655 -0
  221. package/dist/types/resources/billingEngine/customerBalanceTransactions.d.ts +282 -0
  222. package/dist/types/resources/billingEngine/index.d.ts +6071 -0
  223. package/dist/types/resources/billingEngine/invoiceItems.d.ts +502 -0
  224. package/dist/types/resources/billingEngine/invoices.d.ts +2547 -0
  225. package/dist/types/resources/billingEngine/params.d.ts +51 -0
  226. package/dist/types/resources/billingEngine/public.d.ts +1860 -0
  227. package/dist/types/resources/billingEngine/subscriptions.d.ts +1519 -0
  228. package/dist/types/resources/catalog/billing.d.ts +1723 -0
  229. package/dist/types/resources/catalog/billingSettings.d.ts +160 -0
  230. package/dist/types/resources/catalog/coupons.d.ts +403 -0
  231. package/dist/types/resources/catalog/entitlements.d.ts +422 -0
  232. package/dist/types/resources/catalog/index.d.ts +3155 -0
  233. package/dist/types/resources/catalog/meters.d.ts +474 -0
  234. package/dist/types/resources/catalog/prices.d.ts +1091 -0
  235. package/dist/types/resources/catalog/products.d.ts +430 -0
  236. package/dist/types/resources/catalog/promotionCodes.d.ts +369 -0
  237. package/dist/types/resources/catalog/shared.d.ts +34 -0
  238. package/dist/types/resources/catalog/testClocks.d.ts +220 -0
  239. package/dist/types/resources/checkout/checkoutSessions.d.ts +3207 -0
  240. package/dist/types/resources/checkout/contributions.d.ts +375 -0
  241. package/dist/types/resources/checkout/files.d.ts +280 -0
  242. package/dist/types/resources/checkout/index.d.ts +5678 -0
  243. package/dist/types/resources/checkout/merchants.d.ts +395 -0
  244. package/dist/types/resources/checkout/paymentLinks.d.ts +1728 -0
  245. package/dist/types/resources/checkout/paymentMethodConfigurations.d.ts +2104 -0
  246. package/dist/types/resources/checkout/shared.d.ts +419 -0
  247. package/dist/types/resources/connect/account.d.ts +483 -0
  248. package/dist/types/resources/connect/applicationFees.d.ts +198 -0
  249. package/dist/types/resources/connect/balance.d.ts +399 -0
  250. package/dist/types/resources/connect/connectedAccounts.d.ts +494 -0
  251. package/dist/types/resources/connect/index.d.ts +2094 -0
  252. package/dist/types/resources/connect/onboarding.d.ts +95 -0
  253. package/dist/types/resources/connect/payouts.d.ts +527 -0
  254. package/dist/types/resources/connect/reporting.d.ts +506 -0
  255. package/dist/types/resources/connect/requestLogs.d.ts +236 -0
  256. package/dist/types/resources/connect/transfers.d.ts +436 -0
  257. package/dist/types/resources/core/customers.d.ts +619 -0
  258. package/dist/types/resources/core/index.d.ts +679 -0
  259. package/dist/types/resources/core/paymentMethods.d.ts +336 -0
  260. package/dist/types/resources/events/events.d.ts +731 -0
  261. package/dist/types/resources/events/index.d.ts +1727 -0
  262. package/dist/types/resources/events/webhookDeliveries.d.ts +436 -0
  263. package/dist/types/resources/events/webhookEndpoints.d.ts +1502 -0
  264. package/dist/types/resources/payments/charges.d.ts +390 -0
  265. package/dist/types/resources/payments/disputes.d.ts +822 -0
  266. package/dist/types/resources/payments/index.d.ts +3517 -0
  267. package/dist/types/resources/payments/paymentIntents.d.ts +2080 -0
  268. package/dist/types/resources/payments/refunds.d.ts +684 -0
  269. package/dist/types/resources/payments/setupIntents.d.ts +391 -0
  270. package/dist/types/resources/payments/social.d.ts +266 -0
  271. package/dist/types/resources/payments/testHelpers.d.ts +178 -0
  272. package/dist/types/resources/tax/assessments.d.ts +787 -0
  273. package/dist/types/resources/tax/businessProfile.d.ts +134 -0
  274. package/dist/types/resources/tax/calculations.d.ts +261 -0
  275. package/dist/types/resources/tax/capabilities.d.ts +81 -0
  276. package/dist/types/resources/tax/codes.d.ts +29 -0
  277. package/dist/types/resources/tax/complianceActions.d.ts +97 -0
  278. package/dist/types/resources/tax/deadlines.d.ts +133 -0
  279. package/dist/types/resources/tax/documents.d.ts +257 -0
  280. package/dist/types/resources/tax/index.d.ts +1946 -0
  281. package/dist/types/resources/tax/locationEvidence.d.ts +246 -0
  282. package/dist/types/resources/tax/operatingLocations.d.ts +170 -0
  283. package/dist/types/resources/tax/products.d.ts +68 -0
  284. package/dist/types/resources/tax/registrationDeclarations.d.ts +270 -0
  285. package/dist/types/resources/tax/registrations.d.ts +103 -0
  286. package/dist/types/resources/tax/reports.d.ts +129 -0
  287. package/dist/types/resources/tax/reviewItems.d.ts +226 -0
  288. package/dist/types/resources/tax/ruleSet.d.ts +219 -0
  289. package/dist/types/resources/tax/salesDestinations.d.ts +158 -0
  290. package/dist/types/resources/tax/settings.d.ts +122 -0
  291. package/dist/types/resources/tax/shared.d.ts +43 -0
  292. package/dist/types/resources/tax/transactions.d.ts +404 -0
  293. package/dist/types/route.d.ts +86 -0
  294. package/dist/types/routes.d.ts +23 -0
  295. package/dist/types/vocabulary/billingPortal.d.ts +15 -0
  296. package/dist/types/vocabulary/catalog.d.ts +97 -0
  297. package/dist/types/vocabulary/checkout.d.ts +49 -0
  298. package/dist/types/vocabulary/connect.d.ts +62 -0
  299. package/dist/types/vocabulary/errors.d.ts +145 -0
  300. package/dist/types/vocabulary/events.d.ts +171 -0
  301. package/dist/types/vocabulary/files.d.ts +30 -0
  302. package/dist/types/vocabulary/index.d.ts +17 -0
  303. package/dist/types/vocabulary/invoices.d.ts +39 -0
  304. package/dist/types/vocabulary/lists.d.ts +9 -0
  305. package/dist/types/vocabulary/merchants.d.ts +9 -0
  306. package/dist/types/vocabulary/money.d.ts +59 -0
  307. package/dist/types/vocabulary/paymentMethodConfigurations.d.ts +22 -0
  308. package/dist/types/vocabulary/payments.d.ts +117 -0
  309. package/dist/types/vocabulary/reporting.d.ts +18 -0
  310. package/dist/types/vocabulary/subscriptions.d.ts +45 -0
  311. package/dist/types/vocabulary/tax.d.ts +163 -0
  312. package/dist/types/vocabulary/version.d.ts +10 -0
  313. package/package.json +51 -11
  314. package/dist/cjs/openapi.js +0 -138
  315. package/dist/esm/openapi.js +0 -134
  316. package/dist/types/openapi.d.ts +0 -145
@@ -0,0 +1,12 @@
1
+ // The customer portal (ADR 0018 §9) — the closed value sets its schemas are
2
+ // built from. Zod-free: `@peable.to/shared-types` re-exports them at runtime.
3
+ /** What a portal customer may edit about themselves. */
4
+ export const PORTAL_CUSTOMER_UPDATES = ['email', 'name', 'address', 'phone'];
5
+ /** When a cancellation from the portal takes effect. */
6
+ export const PORTAL_CANCEL_MODES = ['at_period_end', 'immediately'];
7
+ /** How a cancellation from the portal prorates. */
8
+ export const PORTAL_CANCEL_PRORATION_BEHAVIORS = ['create_prorations', 'none'];
9
+ /** What a plan change from the portal may change. */
10
+ export const PORTAL_SUBSCRIPTION_UPDATES = ['price', 'quantity'];
11
+ /** What finishing a payment method update from the portal answered. */
12
+ export const PORTAL_PAYMENT_METHOD_UPDATE_STATUSES = ['succeeded', 'pending'];
@@ -0,0 +1,106 @@
1
+ // The catalog's and the billing engine platform's closed value sets (ADR 0016,
2
+ // ADR 0018): what a price, a coupon, a test clock, a meter and the billing
3
+ // settings can say, and the bounds the gateway enforces — restated so a form
4
+ // can say them first. Zod-free: the wallet bundles this.
5
+ import { decimalsFor } from './money.js';
6
+ /** How a price's amount is computed from a quantity. */
7
+ export const PRICE_BILLING_SCHEMES = ['per_unit', 'tiered'];
8
+ /**
9
+ * How a tiered price reads its tiers.
10
+ *
11
+ * - `volume` — the WHOLE quantity is priced at the tier it falls into.
12
+ * - `graduated` — each unit is priced at the tier it falls into, so a
13
+ * quantity crossing two tiers pays each tier's rate for its
14
+ * share, plus the flat amount of every tier it reaches.
15
+ */
16
+ export const PRICE_TIERS_MODES = ['graduated', 'volume'];
17
+ /** `recurring` when the price has a recurring component, `one_time` otherwise. */
18
+ export const PRICE_TYPES = ['one_time', 'recurring'];
19
+ export const RECURRING_INTERVALS = ['day', 'week', 'month', 'year'];
20
+ /**
21
+ * `licensed` bills the quantity on the subscription. `metered` bills the usage
22
+ * a meter (`recurring.meter`, `mtr_…`) aggregated over the period, in arrears.
23
+ */
24
+ export const RECURRING_USAGE_TYPES = ['licensed', 'metered'];
25
+ /**
26
+ * Whether a price includes tax (Peable Tax, ADR 0011). `unspecified` defers to
27
+ * the merchant's default tax behavior; once a price says `inclusive` or
28
+ * `exclusive` it can never change.
29
+ */
30
+ export const PRICE_TAX_BEHAVIORS = ['inclusive', 'exclusive', 'unspecified'];
31
+ export const TRANSFORM_QUANTITY_ROUNDS = ['up', 'down'];
32
+ /** How long a coupon's discount lasts once applied to a subscription. */
33
+ export const COUPON_DURATIONS = ['once', 'repeating', 'forever'];
34
+ /** The bounds the gateway enforces, published so a form can say them first. */
35
+ export const CATALOG_LIMITS = Object.freeze({
36
+ productNameMax: 250,
37
+ productDescriptionMax: 40000,
38
+ productImagesMax: 8,
39
+ urlMax: 2048,
40
+ unitLabelMax: 12,
41
+ statementDescriptorMax: 22,
42
+ marketingFeaturesMax: 15,
43
+ marketingFeatureNameMax: 80,
44
+ priceNicknameMax: 250,
45
+ lookupKeyMax: 200,
46
+ lookupKeysFilterMax: 10,
47
+ priceTiersMax: 250,
48
+ couponIdMax: 64,
49
+ couponNameMax: 40,
50
+ couponAppliesToProductsMax: 100,
51
+ couponDurationInMonthsMax: 1200,
52
+ promotionCodeMax: 64,
53
+ idsFilterMax: 100,
54
+ });
55
+ /**
56
+ * The largest amount the catalog stores, in whole units of any currency, so a
57
+ * FAIR amount (8 decimals) and a EUR amount (2) are bounded at the same real
58
+ * size rather than the same number of digits.
59
+ */
60
+ export const CATALOG_MAX_WHOLE_UNITS = 1000000000n;
61
+ /** The largest base-unit amount of `currency` the catalog accepts. */
62
+ export function maxBaseUnits(currency) {
63
+ return CATALOG_MAX_WHOLE_UNITS * 10n ** BigInt(decimalsFor(currency)) - 1n;
64
+ }
65
+ /** The longest a recurring interval may be: three years, in each unit. */
66
+ export const RECURRING_INTERVAL_COUNT_MAX = Object.freeze({
67
+ day: 1095,
68
+ week: 156,
69
+ month: 36,
70
+ year: 3,
71
+ });
72
+ // ---- Test clocks -------------------------------------------------------------
73
+ export const TEST_CLOCK_STATUSES = ['ready', 'advancing', 'internal_failure'];
74
+ // ---- Billing settings --------------------------------------------------------
75
+ /** What dunning does to a subscription once the last retry has failed. */
76
+ export const DUNNING_FINAL_ACTIONS = ['cancel', 'unpaid', 'past_due'];
77
+ /** What happens to the invoice itself once the last retry has failed. */
78
+ export const DUNNING_INVOICE_ACTIONS = ['leave_open', 'mark_uncollectible'];
79
+ /** The bounds the gateway enforces on billing settings. */
80
+ export const BILLING_SETTINGS_LIMITS = Object.freeze({
81
+ retriesMax: 8,
82
+ retryDaysMax: 60,
83
+ daysUntilDueMax: 365,
84
+ invoicePrefixPattern: '^[A-Z0-9]{3,12}$',
85
+ });
86
+ // ---- Meters ------------------------------------------------------------------
87
+ /** How a meter combines a period's events into the quantity billed. */
88
+ export const METER_AGGREGATIONS = ['sum', 'count', 'last'];
89
+ export const METER_STATUSES = ['active', 'inactive'];
90
+ // ---- Recurring billing transport (`/v1/billing/*`) ---------------------------
91
+ /** A provider subscription's status, as the recurring transport observes it. */
92
+ export const BILLING_SUBSCRIPTION_STATUSES = [
93
+ 'incomplete',
94
+ 'incomplete_expired',
95
+ 'trialing',
96
+ 'active',
97
+ 'past_due',
98
+ 'canceled',
99
+ 'unpaid',
100
+ 'paused',
101
+ ];
102
+ /** `fiat` (Stripe and any further provider) or `faircoin` (native, to the merchant's watch-only wallet). */
103
+ export const BILLING_RAIL_SETTLEMENTS = ['fiat', 'faircoin'];
104
+ /** `automatic`: the provider charges each period. `payer_initiated`: each period is an explicit payment. */
105
+ export const BILLING_RAIL_RENEWALS = ['automatic', 'payer_initiated'];
106
+ // Product tax codes are Peable Tax's vocabulary: `vocabulary/tax.ts` (`TAX_CODES`).
@@ -0,0 +1,50 @@
1
+ // Checkout vocabulary (Orbit Phase 3): the closed value sets and bounds of
2
+ // Checkout Sessions and Payment Links. Zod-free, so the hosted checkout and
3
+ // the wallet import them without the schemas (`@peable.to/contracts/vocabulary`,
4
+ // re-exported by `@peable.to/shared-types`).
5
+ export const CHECKOUT_SESSION_MODES = ['payment', 'setup', 'subscription'];
6
+ export const CHECKOUT_SESSION_STATUSES = ['open', 'complete', 'expired'];
7
+ export const CHECKOUT_PAYMENT_STATUSES = ['paid', 'unpaid', 'no_payment_required'];
8
+ export const CHECKOUT_UI_MODES = ['hosted', 'embedded'];
9
+ /** The languages the hosted and embedded checkout speak. */
10
+ export const CHECKOUT_LOCALES = ['en', 'es', 'fr', 'de', 'it', 'pt'];
11
+ export const CHECKOUT_SUBMIT_TYPES = ['auto', 'pay', 'book', 'donate'];
12
+ export const CHECKOUT_CUSTOMER_CREATIONS = ['always', 'if_required'];
13
+ export const CHECKOUT_BILLING_ADDRESS_COLLECTIONS = ['auto', 'required'];
14
+ export const CHECKOUT_CUSTOM_FIELD_TYPES = ['text', 'numeric', 'dropdown'];
15
+ /** Stripe's tax id types Peable collects; `eu_vat` covers every EU member state. */
16
+ export const CHECKOUT_TAX_ID_TYPES = [
17
+ 'eu_vat',
18
+ 'gb_vat',
19
+ 'ch_vat',
20
+ 'no_vat',
21
+ 'us_ein',
22
+ 'ca_bn',
23
+ ];
24
+ /**
25
+ * Bounds of the session contract, shared by the gateway's validators and the
26
+ * clients that build requests, so the two cannot drift.
27
+ */
28
+ export const CHECKOUT_LIMITS = Object.freeze({
29
+ lineItemsMax: 20,
30
+ quantityMax: 999999,
31
+ customFieldsMax: 3,
32
+ customFieldKeyMax: 200,
33
+ customFieldLabelMax: 50,
34
+ customFieldTextMax: 255,
35
+ dropdownOptionsMax: 200,
36
+ dropdownOptionLabelMax: 100,
37
+ dropdownOptionValueMax: 100,
38
+ clientReferenceIdMax: 200,
39
+ /** `expires_at` must be between 30 minutes and 24 hours from creation. */
40
+ expiresMinSeconds: 30 * 60,
41
+ expiresMaxSeconds: 24 * 3600,
42
+ shippingCountriesMax: 250,
43
+ termsTextMax: 1200,
44
+ });
45
+ /** The template a `success_url` may carry; replaced with the session's `cs_…`. */
46
+ export const CHECKOUT_SESSION_ID_TEMPLATE = '{CHECKOUT_SESSION_ID}';
47
+ export const PAYMENT_LINK_LIMITS = Object.freeze({
48
+ lineItemsMax: 20,
49
+ customMessageMax: 500,
50
+ });
@@ -0,0 +1,92 @@
1
+ // Connect and money vocabulary (ADR 0012, ADR 0015): the closed value sets of
2
+ // accounts, balances, payouts, application fees, transfers and reconciliation.
3
+ // Zod-free, like every vocabulary module.
4
+ /** Which half of an account a business type opens: the provider's two kinds. */
5
+ export const ACCOUNT_BUSINESS_TYPES = ['individual', 'company'];
6
+ /** A capability's state as the provider reports it; `null` on the wire means never requested. */
7
+ export const ACCOUNT_CAPABILITY_STATUSES = ['active', 'pending', 'inactive'];
8
+ /** Whose account an `account` is: the merchant's own, or one of its marketplace sellers. */
9
+ export const ACCOUNT_TYPES = ['merchant', 'connected'];
10
+ /** What a hosted onboarding link for the merchant's own account is for. */
11
+ export const ACCOUNT_LINK_TYPES = ['account_onboarding', 'account_update'];
12
+ /**
13
+ * Which rails a seller's account was opened for (ADR 0012 D1). One seller is
14
+ * ONE `ca_…`: `card` is the provider account a marketplace settles to by
15
+ * transfer, `faircoin` is the seller's own watch-only key.
16
+ */
17
+ export const CONNECTED_ACCOUNT_RAILS = ['card', 'faircoin'];
18
+ /**
19
+ * Where a seller's FairCoin half stands: `pending` until the seller registers
20
+ * a key, `active` once they did.
21
+ */
22
+ export const CONNECTED_ACCOUNT_FAIRCOIN_STATUSES = ['pending', 'active'];
23
+ export const PAYOUT_INTERVALS = ['manual', 'daily', 'weekly', 'monthly'];
24
+ export const PAYOUT_WEEKLY_ANCHORS = [
25
+ 'monday',
26
+ 'tuesday',
27
+ 'wednesday',
28
+ 'thursday',
29
+ 'friday',
30
+ 'saturday',
31
+ 'sunday',
32
+ ];
33
+ /** Orbit's vocabulary for what moved — the provider's own types, provider-neutral. */
34
+ export const BALANCE_TRANSACTION_TYPES = [
35
+ 'charge',
36
+ 'payment',
37
+ 'refund',
38
+ 'payment_refund',
39
+ 'adjustment',
40
+ 'application_fee',
41
+ 'application_fee_refund',
42
+ 'payout',
43
+ 'payout_cancel',
44
+ 'payout_failure',
45
+ 'transfer',
46
+ 'transfer_refund',
47
+ 'dispute',
48
+ 'dispute_reversal',
49
+ 'processing_fee',
50
+ 'faircoin_payment',
51
+ 'faircoin_payment_reversal',
52
+ 'other',
53
+ ];
54
+ /**
55
+ * - `pending` / `available` — the provider's own status for the funds.
56
+ * - `informational` — a FairCoin payment: recorded, never part of a payable balance.
57
+ */
58
+ export const BALANCE_TRANSACTION_STATUSES = ['available', 'pending', 'informational'];
59
+ /** One component of a transaction's fee. `processing_fee` is the acquirer's own. */
60
+ export const BALANCE_TRANSACTION_FEE_TYPES = [
61
+ 'application_fee',
62
+ 'processing_fee',
63
+ 'tax',
64
+ 'other',
65
+ ];
66
+ export const PAYOUT_STATUSES = ['pending', 'in_transit', 'paid', 'failed', 'canceled'];
67
+ export const PAYOUT_METHODS = ['standard', 'instant'];
68
+ export const PAYOUT_DESTINATION_TYPES = ['bank_account', 'card'];
69
+ /**
70
+ * A payout reconciliation report's state: `complete` once the payout is `paid`
71
+ * and its transactions were read from the provider, `pending` before.
72
+ */
73
+ export const PAYOUT_RECONCILIATION_STATUSES = ['complete', 'pending'];
74
+ /** What the daily reconciliation found disagreeing with the provider. Never auto-corrected. */
75
+ export const RECONCILIATION_MISMATCH_KINDS = [
76
+ 'missing_in_ledger',
77
+ 'amount_mismatch',
78
+ 'status_mismatch',
79
+ 'missing_at_provider',
80
+ 'payout_mismatch',
81
+ 'unbalanced_journal',
82
+ ];
83
+ /** Where one settlement stands. */
84
+ export const TRANSFER_STATUSES = [
85
+ 'pending',
86
+ 'paid',
87
+ 'partially_reversed',
88
+ 'reversed',
89
+ 'failed',
90
+ ];
91
+ /** Where one reversal of a settlement stands. */
92
+ export const TRANSFER_REVERSAL_STATUSES = ['pending', 'succeeded', 'failed'];
@@ -0,0 +1,169 @@
1
+ // The error vocabulary (ADR 0014 D1). Zod-free: the documentation site renders
2
+ // its errors page from these two tables, and the backend's `sendError` takes an
3
+ // `ErrorCode`, so a code the gateway can answer with and the page does not list
4
+ // is a compile error rather than a dead `doc_url`.
5
+ /** `error.type`: the broad class a caller branches on first. */
6
+ export const ERROR_TYPES = [
7
+ 'api_error',
8
+ 'authentication_error',
9
+ 'card_error',
10
+ 'idempotency_error',
11
+ 'invalid_request_error',
12
+ 'permission_error',
13
+ 'rate_limit_error',
14
+ ];
15
+ /** What each `error.type` means, and the HTTP status it comes with. */
16
+ export const ERROR_TYPE_DESCRIPTIONS = {
17
+ api_error: 'Something went wrong on Peable or its provider (5xx, or 502 for a retryable provider fault). Safe to retry with the same `Idempotency-Key`.',
18
+ authentication_error: 'The credential is missing, expired or invalid (401).',
19
+ card_error: 'The payment method was declined (402). `decline_code` carries the issuer reason when there is one.',
20
+ idempotency_error: 'The `Idempotency-Key` was reused with a different request (400), or the first request with it is still running (409).',
21
+ invalid_request_error: 'The request is malformed, names something that does not exist, or conflicts with the state of an object (400, 404, 409).',
22
+ permission_error: 'The credential is valid but may not do this (403).',
23
+ rate_limit_error: 'Too many requests (429). Back off and retry.',
24
+ };
25
+ /**
26
+ * Where every code is documented: the error-code page of Peable's docs on the
27
+ * Oxy developer site, generated from this file (`bun run generate:api-docs`,
28
+ * `packages/sdk/docs/errors.mdx`). The trailing slash is the page's canonical
29
+ * form; each code is its own fragment.
30
+ */
31
+ export const ERROR_DOCS_BASE_URL = 'https://oxy.so/developers/docs/peable/errors/';
32
+ /** The `doc_url` of a code. */
33
+ export function errorDocUrl(code) {
34
+ return `${ERROR_DOCS_BASE_URL}#${code}`;
35
+ }
36
+ /**
37
+ * Every `error.code` the gateway answers with, and what it means. The keys ARE
38
+ * the list — {@link ERROR_CODES} is derived from them — so a new code cannot be
39
+ * added without its description.
40
+ */
41
+ export const ERROR_CODE_DESCRIPTIONS = {
42
+ account_invalid: 'The `Peable-Account` header names no connected account of this platform.',
43
+ account_missing: 'The merchant has no account object yet.',
44
+ amount_not_representable: 'The amount does not fit the currency or the rail.',
45
+ billing_not_enabled: 'Billing is not enabled for this merchant.',
46
+ billing_provider_unavailable: 'The billing provider could not be reached; retry.',
47
+ domain_taken: 'The domain is already registered by another merchant.',
48
+ file_too_large: 'The uploaded file is larger than its purpose allows.',
49
+ file_unavailable: 'The file exists but its contents cannot be served right now.',
50
+ idempotency_error: 'The `Idempotency-Key` was used with a different request, or its first request is still running.',
51
+ idempotency_key_invalid: 'The `Idempotency-Key` header is not a valid key.',
52
+ insufficient_scope: 'The credential is valid but was not granted the Oxy scope this route requires (`payments:read`, `payments:write`, …); `message` names it.',
53
+ invalid_billing_request: 'The billing request is not valid for this subscription or offer.',
54
+ keyless_recipient: 'The recipient has no receive key, so no address can be derived for them.',
55
+ link_not_found: 'The link does not exist or is no longer active.',
56
+ live_payments_gated: 'Live payments are not enabled for this application yet.',
57
+ local_test_request_required: 'This test helper only answers a local test request.',
58
+ parameter_invalid: 'A parameter is invalid; `param` names it.',
59
+ parameter_missing: 'A required parameter is missing; `param` names it.',
60
+ parameter_unknown: 'The request carries a parameter this route does not accept; `param` names it.',
61
+ payment_intent_unexpected_state: 'The PaymentIntent is in a status that does not allow this operation.',
62
+ payout_not_allowed: 'Payouts cannot be created for this account.',
63
+ rate_limited: 'Too many requests; back off and retry.',
64
+ refund_not_cancelable: 'The refund has already left a cancelable state.',
65
+ resource_conflict: 'The object changed under this request; read it again and retry.',
66
+ resource_missing: 'The object does not exist, or this credential cannot read it.',
67
+ setup_intent_unexpected_state: 'The SetupIntent is in a status that does not allow this operation.',
68
+ tax_not_enabled: 'Peable Tax is not enabled for this merchant.',
69
+ test_mode_only: 'This operation exists in test mode only.',
70
+ too_many_streams: 'Too many live streams are open for this merchant.',
71
+ url_invalid: 'The URL is not an allowed https URL.',
72
+ watch_only_violation: 'The extended key carries a private key. Peable only ever accepts watch-only (public) keys.',
73
+ webhook_endpoint_disabled: 'The webhook endpoint is disabled.',
74
+ webhook_endpoint_limit_reached: 'The merchant already has the maximum number of webhook endpoints.',
75
+ account_not_ready: 'The connected account cannot take this payment yet: its onboarding or a capability is incomplete.',
76
+ approval_incomplete: 'The tax settings cannot be approved yet: a legal name and head office are required, or they changed during the approval.',
77
+ approval_requires_provider: 'Registered sales need a tax provider, and this application has none: the approval would leave covered sales unpriceable.',
78
+ checkout_session_expired: 'The Checkout Session has expired.',
79
+ checkout_session_not_open: 'The Checkout Session is no longer open (complete or expired).',
80
+ customer_location_conflicting: "The customer's location evidence disagrees, so the sale cannot be placed in one jurisdiction.",
81
+ customer_location_expired: "The customer's location evidence is too old to price a sale with.",
82
+ customer_location_insufficient: "There is not enough evidence of the customer's location to decide whether the sale is taxed.",
83
+ customer_location_invalid: "The tax provider could not use the customer's location.",
84
+ dispute_already_submitted: 'Evidence for this dispute has already been submitted; it is one shot.',
85
+ dispute_not_answerable: 'The dispute is in a status that no longer accepts evidence.',
86
+ idempotency_conflict: 'The same operation key was used for a different billing request.',
87
+ identity_conflict: 'The billing identity already belongs to another customer or subscription.',
88
+ in_progress: 'The same operation is still running; retry with the same key.',
89
+ invalid_provider_response: 'The provider answered with something Peable cannot trust; the operation was not applied.',
90
+ invalid_registration: 'The tax registration is not valid.',
91
+ invalid_registration_declaration: 'The tax registration declaration is not valid.',
92
+ invalid_tax_code: 'The tax code does not exist.',
93
+ invalid_tax_document: 'The tax document is not valid for its declared purpose.',
94
+ invalid_tax_request: 'The tax request is not valid.',
95
+ lookup_key_taken: 'Another price already uses this `lookup_key`.',
96
+ mode_unavailable: 'This Checkout mode is not available to this merchant.',
97
+ not_found: 'The object does not exist, or this credential cannot read it.',
98
+ payment_link_inactive: 'The Payment Link is deactivated.',
99
+ price_is_default: "The price is its product's `default_price` and cannot be archived.",
100
+ product_has_prices: 'The product still has prices; archive it instead.',
101
+ product_in_use: 'The product is referenced by a subscription or a link.',
102
+ promotion_code_invalid: 'The promotion code does not exist, is inactive or does not apply.',
103
+ promotion_code_taken: 'Another active promotion code already uses this `code`.',
104
+ provider_unavailable: 'The payment provider could not be reached; retry.',
105
+ rail_unavailable: 'The payment rail this request needs is not available.',
106
+ reconciliation_required: 'The billing operation has an unknown outcome at the provider and is being reconciled.',
107
+ registration_immutable: 'An approved or ended tax registration cannot be deleted or changed this way; end it instead.',
108
+ resource_already_exists: 'An object with this identity already exists.',
109
+ result_expired: 'The stored result of this operation has expired.',
110
+ review_item_not_open: 'The review item is already resolved or dismissed.',
111
+ rule_set_version_unavailable: 'The tax rule set version is not available.',
112
+ subscription_line_invalid: 'A subscription line item is not valid for Checkout.',
113
+ tax_behavior_locked: "The price's `tax_behavior` cannot change once set.",
114
+ tax_calculation_unavailable: 'Tax could not be calculated; a covered sale fails closed.',
115
+ tax_provider_registration_mismatch: "The provider's registrations disagree with the ones Peable has approved.",
116
+ tax_settings_not_active: 'Tax settings are not active for this merchant.',
117
+ local_test_unavailable: 'The local test checkout is not available.',
118
+ local_test_configuration_unavailable: 'The local test checkout has no provider configuration.',
119
+ local_test_subscription_unavailable: 'The local test subscription cannot be read.',
120
+ rail_mismatch: 'The operation does not apply to the rail this payment uses.',
121
+ checkout_session_changed: 'The Checkout Session changed while this request ran (a price, a discount, its tax); read it again and retry.',
122
+ checkout_session_locked: 'The Checkout Session is being confirmed and cannot change.',
123
+ tax_calculation_failed: 'The tax for this Checkout Session could not be calculated.',
124
+ payment_cancellation_failed: 'The payment could not be cancelled at the provider; the Checkout Session stays as it was.',
125
+ invoice_not_editable: 'The invoice is finalized and can no longer be edited.',
126
+ invoice_unexpected_state: 'The invoice is in a status that does not allow this operation.',
127
+ invoice_no_customer_line_items: 'The invoice has no line items to finalize.',
128
+ invoice_payment_intent_requires_action: "The invoice's payment needs the customer to act (a card challenge).",
129
+ subscription_unexpected_state: 'The subscription is in a status that does not allow this operation.',
130
+ customer_currency_mismatch: "The currency differs from the customer's billing currency.",
131
+ customer_test_clock_mismatch: 'The objects live on different test clocks.',
132
+ coupon_invalid: 'The coupon does not exist or is no longer valid.',
133
+ coupon_currency_mismatch: "The coupon's currency differs from the purchase's.",
134
+ coupon_not_applicable: 'The coupon does not apply to these products.',
135
+ promotion_code_inactive: 'The promotion code is inactive.',
136
+ promotion_code_customer_mismatch: 'The promotion code is restricted to another customer.',
137
+ promotion_code_expired: 'The promotion code has expired.',
138
+ promotion_code_max_redemptions: 'The promotion code has been redeemed its maximum number of times.',
139
+ promotion_code_minimum_amount: 'The purchase is below the promotion code minimum amount.',
140
+ payment_method_missing: 'No payment method is available to charge.',
141
+ faircoin_cannot_debit: 'A FairCoin invoice cannot be charged automatically: the payer signs every payment.',
142
+ credit_note_exceeds_invoice: "The credit note's amount exceeds what the invoice can still credit.",
143
+ test_clock_unexpected_state: 'The test clock is advancing; wait until it is ready.',
144
+ meter_event_customer_missing: 'The meter event names no customer of this merchant.',
145
+ feature_lookup_key_taken: 'Another feature already uses this `lookup_key`.',
146
+ portal_feature_disabled: 'The customer portal configuration does not allow this action.',
147
+ portal_session_expired: 'The customer portal session has expired.',
148
+ card_declined: 'The card was declined.',
149
+ promotion_code_first_time_only: "The promotion code is for a customer's first purchase only.",
150
+ network_mismatch: 'The FairCoin network differs from the one this object uses.',
151
+ // Connect onboarding (ADR 0012 D3): the seller-facing refusals.
152
+ link_expired: 'The onboarding link has expired or was already used; `refresh_url` is where the seller gets a fresh one.',
153
+ wrong_seller: 'The onboarding link names a different Oxy account; sign in as the seller it was minted for.',
154
+ already_registered: 'The seller already registered a FairCoin key, and it cannot be changed.',
155
+ key_in_use: 'The key already receives payments for another account.',
156
+ no_faircoin_half: 'The connected account has no FairCoin half to register a key for.',
157
+ // The dashboard routes (`/v1/dashboard/*`, Orbit): the signed-in person, not a credential.
158
+ merchant_missing: 'The application has no merchant in this environment yet; register one (Orbit shows "Set up payments").',
159
+ application_membership_required: 'The signed-in Oxy account is not a member of the account that owns this application.',
160
+ permission_required: 'The member lacks an Oxy permission this needs; `param` names it (`billing:read`, `billing:manage`). An owner grants it in Oxy Console.',
161
+ membership_unavailable: 'Oxy could not be asked whether the signed-in person is a member of this application; retry.',
162
+ session_invalid: 'Oxy no longer accepts the signed-in session; sign in again.',
163
+ };
164
+ /** Every error code, sorted. */
165
+ export const ERROR_CODES = Object.keys(ERROR_CODE_DESCRIPTIONS).sort();
166
+ /** Whether a string is a documented error code. */
167
+ export function isErrorCode(value) {
168
+ return Object.hasOwn(ERROR_CODE_DESCRIPTIONS, value);
169
+ }
@@ -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'];