@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,224 @@
1
+ import { z } from 'zod';
2
+ import { listOf } from '../../common/envelopes.js';
3
+ import { defineComponent, defineObject, expandable } from '../../common/objects.js';
4
+ import { expandOnlyQuery, idParam, listQuery } from '../../common/params.js';
5
+ import { amount, livemode, unixSeconds } from '../../common/primitives.js';
6
+ import { defineRoute } from '../../route.js';
7
+ import { TRANSFER_REVERSAL_STATUSES, TRANSFER_STATUSES } from '../../vocabulary/connect.js';
8
+ import { isBaseUnitString } from '../../vocabulary/money.js';
9
+ /**
10
+ * Transfers (`tr_…`) — a marketplace settling one seller out of a funded
11
+ * payment — and their reversals.
12
+ *
13
+ * The amounts come from the merchant and are recorded, never computed: Peable
14
+ * does not know what a marketplace fee is. The provider's own transfer id never
15
+ * crosses (ADR 0001 D3).
16
+ */
17
+ export const transferSchema = defineObject('transfer', 'Transfer', z
18
+ .object({
19
+ id: z.string(),
20
+ object: z.literal('transfer'),
21
+ livemode,
22
+ external_ref: z
23
+ .string()
24
+ .describe("The merchant's OWN id for what this settles. Their idempotency."),
25
+ connected_account: expandable('connected_account', "The seller's `ca_…` — never their account id at the provider — or the ConnectedAccount with `expand[]=connected_account`."),
26
+ payment_intent: expandable('payment_intent', 'The `pi_…` this settlement was funded by, or the PaymentIntent with `expand[]=payment_intent`.'),
27
+ amount,
28
+ currency: z.string(),
29
+ amount_reversed: amount.describe("CUMULATIVE, in the units of `amount` — the provider's own total, never a sum of the reversals."),
30
+ status: z.enum(TRANSFER_STATUSES),
31
+ failure_message: z.string().nullable(),
32
+ created: unixSeconds,
33
+ updated_at: unixSeconds,
34
+ })
35
+ .strict(), {
36
+ examples: [
37
+ {
38
+ id: 'tr_0193b8f33c5a4b7e9d02',
39
+ object: 'transfer',
40
+ livemode: false,
41
+ external_ref: 'order_6735_seller_4821',
42
+ connected_account: 'ca_0193b8f2d4e1aa07c3b2',
43
+ payment_intent: 'pi_0193b8f2e8a14f6c9d31',
44
+ amount: '1700',
45
+ currency: 'EUR',
46
+ amount_reversed: '0',
47
+ status: 'paid',
48
+ failure_message: null,
49
+ created: 1793750400,
50
+ updated_at: 1793750402,
51
+ },
52
+ ],
53
+ });
54
+ /**
55
+ * One reversal operation. It exists as an object because an AMOUNT IS NOT AN
56
+ * IDENTITY: two reversals of one settlement for the same amount are two
57
+ * operations, and a caller needs to tell which one a response is about.
58
+ */
59
+ export const transferReversalSchema = defineObject('transfer_reversal', 'TransferReversal', z
60
+ .object({
61
+ id: z.string(),
62
+ object: z.literal('transfer_reversal'),
63
+ livemode,
64
+ external_ref: z.string().describe("The merchant's own id for this reversal."),
65
+ amount,
66
+ currency: z.string(),
67
+ status: z.enum(TRANSFER_REVERSAL_STATUSES),
68
+ failure_message: z.string().nullable(),
69
+ created: unixSeconds,
70
+ })
71
+ .strict());
72
+ /** What `POST /v1/transfers/{transferId}/reversals` answers: the transfer, and the leg. */
73
+ export const transferWithReversalSchema = defineComponent('TransferWithReversal', transferSchema.extend({ reversal: transferReversalSchema }).strict());
74
+ /**
75
+ * A canonical base-unit integer string, validated with the SAME predicate the
76
+ * database CHECK is rendered from. A `z.number()` here would be a silent
77
+ * precision ceiling on a money value.
78
+ */
79
+ const transferAmount = z
80
+ .string()
81
+ .refine(isBaseUnitString, "amount must be a canonical integer string in the currency's smallest unit")
82
+ // `'0'` passes the predicate above, and a zero transfer is not a transfer:
83
+ // it would consume the merchant's `external_ref`, so the REAL settlement of
84
+ // that order could never be created afterwards.
85
+ .refine((value) => value !== '0', 'a transfer of 0 is not a transfer');
86
+ /**
87
+ * `POST /v1/transfers`: settle one seller out of a funded payment. The seller
88
+ * by exactly one of its two addresses; the currency is the payment's, never the
89
+ * request's (a transfer in another currency is an FX conversion nothing here
90
+ * performs).
91
+ */
92
+ export const createTransferParams = z
93
+ .object({
94
+ payment_intent: z.string().min(1).describe('The `pi_…` this settles out of.'),
95
+ connected_account: z.string().min(1).optional().describe("The seller's `ca_…`."),
96
+ connected_account_ref: z
97
+ .string()
98
+ .min(1)
99
+ .max(255)
100
+ .optional()
101
+ .describe('Or your own id for the seller (its `external_ref`).'),
102
+ external_ref: z
103
+ .string()
104
+ .min(1)
105
+ .max(255)
106
+ .describe('Your own id for what this settles — the idempotency: the same ref answers the stored settlement (200), a different payment or amount under it is a 409.'),
107
+ amount: transferAmount,
108
+ })
109
+ .strict()
110
+ .refine((body) => Boolean(body.connected_account) !== Boolean(body.connected_account_ref), {
111
+ message: 'name the seller by exactly one of connected_account or connected_account_ref',
112
+ });
113
+ export const reverseTransferParams = z
114
+ .object({
115
+ amount: transferAmount,
116
+ // Required, and durable. It used to be satisfiable by the
117
+ // `Idempotency-Key` header instead; that header is now the generic 24-hour
118
+ // retry layer (ADR 0014 D3), which the SDK fills with a fresh uuid per call
119
+ // — accepting it here would hand every un-referenced reversal a random
120
+ // identity, and an application's own retry a second reversal.
121
+ external_ref: z
122
+ .string()
123
+ .min(1)
124
+ .max(255)
125
+ .describe('Your own id for THIS reversal — required and durable: two reversals for the same amount are two operations.'),
126
+ })
127
+ .strict();
128
+ export const listTransfersQuery = listQuery({
129
+ payment_intent: idParam.optional().describe('Only the settlements of this payment (`pi_…`).'),
130
+ connected_account: idParam.optional().describe('Only the settlements to this seller (`ca_…`).'),
131
+ });
132
+ /** The per-payment list: the payment is in the path. */
133
+ export const listPaymentIntentTransfersQuery = listQuery({});
134
+ const transferIdParam = { transferId: 'The transfer (`tr_…`).' };
135
+ export const transferRoutes = [
136
+ defineRoute({
137
+ operationId: 'createTransfer',
138
+ method: 'post',
139
+ path: '/v1/transfers',
140
+ tag: 'Transfers',
141
+ summary: 'Create a transfer',
142
+ description: 'Settles one seller out of a funded payment (201). An order already settled answers the stored settlement (200): a merchant retrying after a timeout needs to know whether they just paid a seller twice.',
143
+ auth: 'service',
144
+ scope: 'payments:write',
145
+ idempotent: true,
146
+ body: createTransferParams,
147
+ response: transferSchema,
148
+ status: 201,
149
+ sdk: 'transfers.create',
150
+ }),
151
+ defineRoute({
152
+ operationId: 'createTransferReversal',
153
+ method: 'post',
154
+ path: '/v1/transfers/{transferId}/reversals',
155
+ tag: 'Transfers',
156
+ summary: 'Reverse a transfer',
157
+ description: 'Takes some or all of a settlement back (201), or answers the reversal this `external_ref` already made (200).',
158
+ auth: 'service',
159
+ scope: 'payments:write',
160
+ idempotent: true,
161
+ params: transferIdParam,
162
+ body: reverseTransferParams,
163
+ response: transferWithReversalSchema,
164
+ status: 201,
165
+ sdk: 'transfers.reverse',
166
+ }),
167
+ defineRoute({
168
+ operationId: 'listTransferReversals',
169
+ method: 'get',
170
+ path: '/v1/transfers/{transferId}/reversals',
171
+ tag: 'Transfers',
172
+ summary: "List a transfer's reversals",
173
+ description: 'Newest first. A complete set (`has_more: false`): a settlement can only be reversed down to zero.',
174
+ auth: 'service',
175
+ scope: 'payments:read',
176
+ params: transferIdParam,
177
+ query: expandOnlyQuery,
178
+ response: listOf(transferReversalSchema),
179
+ sdk: 'transfers.listReversals',
180
+ }),
181
+ defineRoute({
182
+ operationId: 'listTransfers',
183
+ method: 'get',
184
+ path: '/v1/transfers',
185
+ tag: 'Transfers',
186
+ summary: 'List transfers',
187
+ description: 'Newest first, narrowed by `payment_intent` and/or `connected_account`.',
188
+ auth: 'service',
189
+ scope: 'payments:read',
190
+ query: listTransfersQuery,
191
+ response: listOf(transferSchema),
192
+ sdk: 'transfers.list',
193
+ expandable: 'transfer',
194
+ }),
195
+ defineRoute({
196
+ operationId: 'retrieveTransfer',
197
+ method: 'get',
198
+ path: '/v1/transfers/{transferId}',
199
+ tag: 'Transfers',
200
+ summary: 'Retrieve a transfer',
201
+ auth: 'service',
202
+ scope: 'payments:read',
203
+ params: transferIdParam,
204
+ query: expandOnlyQuery,
205
+ response: transferSchema,
206
+ sdk: 'transfers.retrieve',
207
+ expandable: 'transfer',
208
+ }),
209
+ defineRoute({
210
+ operationId: 'listPaymentIntentTransfers',
211
+ method: 'get',
212
+ path: '/v1/payment_intents/{intentId}/transfers',
213
+ tag: 'Transfers',
214
+ summary: "List a payment's transfers",
215
+ description: 'What one payment settled, newest first. The reconciliation read.',
216
+ auth: 'service',
217
+ scope: 'payments:read',
218
+ params: { intentId: 'The payment intent (`pi_…`).' },
219
+ query: listPaymentIntentTransfersQuery,
220
+ response: listOf(transferSchema),
221
+ sdk: 'transfers.listForPaymentIntent',
222
+ expandable: 'transfer',
223
+ }),
224
+ ];
@@ -0,0 +1,191 @@
1
+ import { z } from 'zod';
2
+ import { addressParams, addressSchema, emailParam, shippingParams, shippingSchema, } from '../../common/address.js';
3
+ import { deletedOf, listOf, searchResultOf } from '../../common/envelopes.js';
4
+ import { defineComponent, defineObject, expandable } from '../../common/objects.js';
5
+ import { clearable, expandOnlyQuery, expandParam, idParam, listQuery, metadataCreateParam, metadataUpdateParam, searchQuery, } from '../../common/params.js';
6
+ import { currency, livemode, metadata, signedAmount, unixSeconds } from '../../common/primitives.js';
7
+ import { defineRoute } from '../../route.js';
8
+ /**
9
+ * Customers (`cus_…`) — Orbit's own object (ADR 0016). A provider customer is an
10
+ * internal binding created lazily, per mode, when a card payment method is
11
+ * first attached; it is never serialized.
12
+ */
13
+ export const customerSchema = defineObject('customer', 'Customer', z
14
+ .object({
15
+ id: z.string(),
16
+ object: z.literal('customer'),
17
+ livemode,
18
+ email: z.string().nullable(),
19
+ name: z.string().nullable(),
20
+ phone: z.string().nullable(),
21
+ description: z.string().nullable(),
22
+ address: addressSchema.nullable(),
23
+ shipping: shippingSchema.nullable(),
24
+ invoice_settings: z
25
+ .object({
26
+ default_payment_method: expandable('payment_method', '`pm_…`, or the PaymentMethod with `expand[]=invoice_settings.default_payment_method`.').nullable(),
27
+ })
28
+ .strict(),
29
+ metadata,
30
+ balance: signedAmount.describe('SIGNED base units in `currency`: negative is credit the customer holds, positive is owed. Applied to the next invoice when it finalizes.'),
31
+ currency: currency
32
+ .nullable()
33
+ .describe("The customer's billing currency, set by its first balance movement, subscription or invoice."),
34
+ test_clock: z
35
+ .string()
36
+ .nullable()
37
+ .describe('The test clock (`clock_…`) it lives on; test mode only.'),
38
+ created: unixSeconds,
39
+ })
40
+ .strict(), {
41
+ examples: [
42
+ {
43
+ id: 'cus_0193b8f2c1a87d3e9f4a',
44
+ object: 'customer',
45
+ livemode: false,
46
+ email: 'jenny@example.com',
47
+ name: 'Jenny Rosen',
48
+ phone: null,
49
+ description: null,
50
+ address: null,
51
+ shipping: null,
52
+ invoice_settings: { default_payment_method: null },
53
+ metadata: { order_id: '6735' },
54
+ balance: '0',
55
+ currency: 'EUR',
56
+ test_clock: null,
57
+ created: 1793750400,
58
+ },
59
+ ],
60
+ });
61
+ /** A deleted customer: a tombstone that still retrieves. */
62
+ export const deletedCustomerSchema = defineComponent('DeletedCustomer', deletedOf('customer'));
63
+ const name = z.string().max(500);
64
+ const phone = z.string().max(40);
65
+ const description = z.string().max(1000);
66
+ export const createCustomerParams = z
67
+ .object({
68
+ email: emailParam.optional(),
69
+ name: name.optional(),
70
+ phone: phone.optional(),
71
+ description: description.optional(),
72
+ address: addressParams.optional(),
73
+ shipping: shippingParams.optional(),
74
+ invoice_settings: z.object({ default_payment_method: idParam.optional() }).strict().optional(),
75
+ metadata: metadataCreateParam.optional(),
76
+ test_clock: idParam
77
+ .optional()
78
+ .describe('Create only, test mode only: attach the customer to a test clock (`clock_…`).'),
79
+ expand: expandParam.optional(),
80
+ })
81
+ .strict();
82
+ /** A field sent as `""` is cleared; `metadata` is a patch. */
83
+ export const updateCustomerParams = z
84
+ .object({
85
+ email: clearable(emailParam).optional(),
86
+ name: clearable(name).optional(),
87
+ phone: clearable(phone).optional(),
88
+ description: clearable(description).optional(),
89
+ address: clearable(addressParams).optional(),
90
+ shipping: clearable(shippingParams).optional(),
91
+ invoice_settings: z
92
+ .object({ default_payment_method: clearable(idParam).optional() })
93
+ .strict()
94
+ .optional(),
95
+ metadata: metadataUpdateParam.optional(),
96
+ expand: expandParam.optional(),
97
+ })
98
+ .strict();
99
+ export const listCustomersQuery = listQuery({
100
+ email: z.string().min(1).max(512).optional().describe('Exact match.'),
101
+ });
102
+ const customerOrDeleted = z.union([customerSchema, deletedCustomerSchema]);
103
+ export const customerRoutes = [
104
+ defineRoute({
105
+ operationId: 'createCustomer',
106
+ method: 'post',
107
+ path: '/v1/customers',
108
+ tag: 'Customers',
109
+ summary: 'Create a customer',
110
+ auth: 'service',
111
+ scope: 'payments:write',
112
+ idempotent: true,
113
+ body: createCustomerParams,
114
+ response: customerSchema,
115
+ status: 201,
116
+ sdk: 'customers.create',
117
+ expandable: 'customer',
118
+ }),
119
+ defineRoute({
120
+ operationId: 'listCustomers',
121
+ method: 'get',
122
+ path: '/v1/customers',
123
+ tag: 'Customers',
124
+ summary: 'List customers',
125
+ description: 'Your live customers, newest first. Deleted customers are not listed.',
126
+ auth: 'service',
127
+ scope: 'payments:read',
128
+ query: listCustomersQuery,
129
+ response: listOf(customerSchema),
130
+ sdk: 'customers.list',
131
+ expandable: 'customer',
132
+ }),
133
+ defineRoute({
134
+ operationId: 'retrieveCustomer',
135
+ method: 'get',
136
+ path: '/v1/customers/{id}',
137
+ tag: 'Customers',
138
+ summary: 'Retrieve a customer',
139
+ description: 'A deleted customer answers `{ id, object: "customer", deleted: true }`.',
140
+ auth: 'service',
141
+ scope: 'payments:read',
142
+ params: { id: 'The customer (`cus_…`).' },
143
+ query: expandOnlyQuery,
144
+ response: customerOrDeleted,
145
+ sdk: 'customers.retrieve',
146
+ expandable: 'customer',
147
+ }),
148
+ defineRoute({
149
+ operationId: 'updateCustomer',
150
+ method: 'post',
151
+ path: '/v1/customers/{id}',
152
+ tag: 'Customers',
153
+ summary: 'Update a customer',
154
+ description: 'A field sent as `""` is cleared; `metadata` is a patch.',
155
+ auth: 'service',
156
+ scope: 'payments:write',
157
+ idempotent: true,
158
+ params: { id: 'The customer (`cus_…`).' },
159
+ body: updateCustomerParams,
160
+ response: customerSchema,
161
+ sdk: 'customers.update',
162
+ expandable: 'customer',
163
+ }),
164
+ defineRoute({
165
+ operationId: 'deleteCustomer',
166
+ method: 'delete',
167
+ path: '/v1/customers/{id}',
168
+ tag: 'Customers',
169
+ summary: 'Delete a customer',
170
+ description: 'A tombstone, with every saved payment method of the customer detached. Deleting a deleted customer answers the tombstone again.',
171
+ auth: 'service',
172
+ scope: 'payments:write',
173
+ params: { id: 'The customer (`cus_…`).' },
174
+ response: deletedCustomerSchema,
175
+ sdk: 'customers.del',
176
+ }),
177
+ defineRoute({
178
+ operationId: 'searchCustomers',
179
+ method: 'get',
180
+ path: '/v1/customers/search',
181
+ tag: 'Customers',
182
+ summary: 'Search customers',
183
+ description: "Stripe's query language over `email`, `name`, `phone`, `created` and `metadata['key']`.",
184
+ auth: 'service',
185
+ scope: 'payments:read',
186
+ query: searchQuery,
187
+ response: searchResultOf(customerSchema),
188
+ sdk: 'customers.search',
189
+ expandable: 'customer',
190
+ }),
191
+ ];
@@ -0,0 +1,6 @@
1
+ import { customerRoutes } from './customers.js';
2
+ import { paymentMethodRoutes } from './paymentMethods.js';
3
+ export * from './customers.js';
4
+ export * from './paymentMethods.js';
5
+ /** Customers and their saved payment methods. */
6
+ export const coreRoutes = [...customerRoutes, ...paymentMethodRoutes];
@@ -0,0 +1,131 @@
1
+ import { z } from 'zod';
2
+ import { addressParams, addressSchema, emailParam } from '../../common/address.js';
3
+ import { listOf } from '../../common/envelopes.js';
4
+ import { defineComponent, defineObject, expandable } from '../../common/objects.js';
5
+ import { expandOnlyQuery, expandParam, idParam, listQuery, metadataUpdateParam, } from '../../common/params.js';
6
+ import { livemode, metadata, unixSeconds } from '../../common/primitives.js';
7
+ import { defineRoute } from '../../route.js';
8
+ /**
9
+ * PaymentMethods (`pm_…`) — Peable's wrapper over a provider payment method
10
+ * (ADR 0016). Card details are collected by the provider's own Elements in the
11
+ * browser; the card number never reaches Peable. A FairCoin customer has no
12
+ * payment method: signing stays on the payer's device.
13
+ */
14
+ /** Card details safe to show: never the number, never the CVC. */
15
+ export const cardDetailsSchema = defineComponent('CardDetails', z
16
+ .object({
17
+ brand: z.string().nullable(),
18
+ last4: z.string().nullable(),
19
+ exp_month: z.number().int().nullable(),
20
+ exp_year: z.number().int().nullable(),
21
+ country: z.string().nullable().describe('ISO 3166-1 alpha-2 of the issuer.'),
22
+ funding: z.string().nullable().describe('`credit`, `debit`, `prepaid` or `unknown`.'),
23
+ })
24
+ .strict());
25
+ export const billingDetailsSchema = defineComponent('BillingDetails', z
26
+ .object({
27
+ address: addressSchema.nullable(),
28
+ email: z.string().nullable(),
29
+ name: z.string().nullable(),
30
+ phone: z.string().nullable(),
31
+ })
32
+ .strict());
33
+ export const paymentMethodSchema = defineObject('payment_method', 'PaymentMethod', z
34
+ .object({
35
+ id: z.string(),
36
+ object: z.literal('payment_method'),
37
+ livemode,
38
+ type: z.literal('card'),
39
+ card: cardDetailsSchema,
40
+ billing_details: billingDetailsSchema,
41
+ customer: expandable('customer', '`cus_…`, or the Customer with `expand[]=customer`; `null` once detached.').nullable(),
42
+ metadata,
43
+ created: unixSeconds,
44
+ })
45
+ .strict());
46
+ /**
47
+ * Billing details (each named field replaces that field) and metadata (a
48
+ * patch). Orbit's record of the card holder; the provider's copy is not
49
+ * rewritten — the card was verified against what the payer entered there.
50
+ */
51
+ export const updatePaymentMethodParams = z
52
+ .object({
53
+ billing_details: z
54
+ .object({
55
+ address: addressParams.optional(),
56
+ email: emailParam.optional(),
57
+ name: z.string().max(500).optional(),
58
+ phone: z.string().max(40).optional(),
59
+ })
60
+ .strict()
61
+ .optional(),
62
+ metadata: metadataUpdateParam.optional(),
63
+ expand: expandParam.optional(),
64
+ })
65
+ .strict();
66
+ export const detachPaymentMethodParams = z.object({ expand: expandParam.optional() }).strict();
67
+ /** `customer` is REQUIRED: Stripe lists a customer's methods, never a merchant's whole wallet. */
68
+ export const listPaymentMethodsQuery = listQuery({
69
+ customer: idParam.describe('The customer (`cus_…`) whose methods to list.'),
70
+ type: z.literal('card').optional(),
71
+ });
72
+ export const paymentMethodRoutes = [
73
+ defineRoute({
74
+ operationId: 'listPaymentMethods',
75
+ method: 'get',
76
+ path: '/v1/payment_methods',
77
+ tag: 'Payment methods',
78
+ summary: "List a customer's payment methods",
79
+ auth: 'service',
80
+ scope: 'payments:read',
81
+ query: listPaymentMethodsQuery,
82
+ response: listOf(paymentMethodSchema),
83
+ sdk: 'paymentMethods.list',
84
+ expandable: 'payment_method',
85
+ }),
86
+ defineRoute({
87
+ operationId: 'retrievePaymentMethod',
88
+ method: 'get',
89
+ path: '/v1/payment_methods/{id}',
90
+ tag: 'Payment methods',
91
+ summary: 'Retrieve a payment method',
92
+ auth: 'service',
93
+ scope: 'payments:read',
94
+ params: { id: 'The payment method (`pm_…`).' },
95
+ query: expandOnlyQuery,
96
+ response: paymentMethodSchema,
97
+ sdk: 'paymentMethods.retrieve',
98
+ expandable: 'payment_method',
99
+ }),
100
+ defineRoute({
101
+ operationId: 'updatePaymentMethod',
102
+ method: 'post',
103
+ path: '/v1/payment_methods/{id}',
104
+ tag: 'Payment methods',
105
+ summary: 'Update a payment method',
106
+ auth: 'service',
107
+ scope: 'payments:write',
108
+ idempotent: true,
109
+ params: { id: 'The payment method (`pm_…`).' },
110
+ body: updatePaymentMethodParams,
111
+ response: paymentMethodSchema,
112
+ sdk: 'paymentMethods.update',
113
+ expandable: 'payment_method',
114
+ }),
115
+ defineRoute({
116
+ operationId: 'detachPaymentMethod',
117
+ method: 'post',
118
+ path: '/v1/payment_methods/{id}/detach',
119
+ tag: 'Payment methods',
120
+ summary: 'Detach a payment method',
121
+ description: 'Permanently. A second detach answers the detached method.',
122
+ auth: 'service',
123
+ scope: 'payments:write',
124
+ idempotent: true,
125
+ params: { id: 'The payment method (`pm_…`).' },
126
+ body: detachPaymentMethodParams,
127
+ response: paymentMethodSchema,
128
+ sdk: 'paymentMethods.detach',
129
+ expandable: 'payment_method',
130
+ }),
131
+ ];