@peable.to/contracts 0.4.0 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 -137
  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 -134
  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 -171
  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 -165
  315. package/dist/esm/openapi.js +0 -161
  316. package/dist/types/openapi.d.ts +0 -148
@@ -0,0 +1,752 @@
1
+ import { z } from 'zod';
2
+ import { defineComponent } from '../../common/objects.js';
3
+ import { defineRoute } from '../../route.js';
4
+ import { BILLING_RAIL_RENEWALS, BILLING_RAIL_SETTLEMENTS, BILLING_SUBSCRIPTION_STATUSES, } from '../../vocabulary/catalog.js';
5
+ /**
6
+ * The recurring billing transport (`/v1/billing/*`): an Oxy app's own
7
+ * subscription checkout — Oxy One, Mention Plus — over a configured settlement
8
+ * rail (a fiat provider such as Stripe, or FairCoin). Store and plan references
9
+ * belong to the authenticated app; they do not identify an Oxy payer or convey
10
+ * entitlements. Payment success and access require the authoritative backend
11
+ * outcome read here — never a closed sheet or a browser callback.
12
+ *
13
+ * Every write takes an `Idempotency-Key` header, which the route REQUIRES
14
+ * (a missing or malformed key is a 400): the key is the operation's identity
15
+ * at the provider, not a replay convenience.
16
+ */
17
+ // ---- Shared pieces ---------------------------------------------------------------
18
+ /** An opaque app or provider reference: 1–128 of `A–Z a–z 0–9 _ . : -`. */
19
+ export const billingReference = z
20
+ .string()
21
+ .min(1)
22
+ .max(128)
23
+ .regex(/^[A-Za-z0-9_.:-]+$/);
24
+ /** The `Idempotency-Key` of a billing write: 1–200 of `A–Z a–z 0–9 _ . : -`. */
25
+ export const billingIdempotencyKey = z
26
+ .string()
27
+ .min(1)
28
+ .max(200)
29
+ .regex(/^[A-Za-z0-9_.:-]+$/);
30
+ /**
31
+ * A configured settlement rail's name (`stripe`, `faircoin`, a further fiat
32
+ * provider). Selecting one never configures it: an unconfigured rail is
33
+ * refused.
34
+ */
35
+ export const billingRailId = z
36
+ .string()
37
+ .regex(/^[a-z][a-z0-9_]{1,31}$/)
38
+ .describe('A settlement rail: `stripe`, `faircoin`, or a further fiat provider.');
39
+ /** HTTPS destinations only; the authenticated app supplies its own return page. */
40
+ export const billingReturnUrl = z
41
+ .string()
42
+ .url()
43
+ .max(2048)
44
+ .refine((value) => {
45
+ const url = new URL(value);
46
+ return url.protocol === 'https:' && !url.username && !url.password;
47
+ }, 'An HTTPS return URL without credentials is required');
48
+ /** An instant in signed billing evidence: integer Unix seconds that stay a safe integer. */
49
+ export const billingInstant = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
50
+ /** A whole number of minor units (cents) in signed billing evidence. */
51
+ const minorUnits = z.number().int().nonnegative().max(Number.MAX_SAFE_INTEGER);
52
+ /** A billing customer reference (`cus_…`). */
53
+ export const billingCustomerRef = z
54
+ .string()
55
+ .regex(/^cus_[A-Za-z0-9]+$/)
56
+ .max(128);
57
+ /** A billing price reference (`price_…`). */
58
+ export const billingPriceRef = z
59
+ .string()
60
+ .regex(/^price_[A-Za-z0-9]+$/)
61
+ .max(128);
62
+ const mode = z.enum(['test', 'live']);
63
+ const environment = z.enum(['development', 'staging', 'production']);
64
+ const taxTreatment = z.enum(['inclusive', 'exclusive']);
65
+ const billingInterval = z.enum(['month', 'year']);
66
+ const ed25519Signature = z
67
+ .object({
68
+ algorithm: z.literal('Ed25519'),
69
+ key_id: billingReference,
70
+ value: z.string().regex(/^[A-Za-z0-9_-]{86}$/),
71
+ })
72
+ .strict()
73
+ .describe('Ed25519 over the canonical JSON (v1) of everything beside it.');
74
+ // ---- Rails -------------------------------------------------------------------------
75
+ /**
76
+ * One offer a rail can sell. Fiat provider rails bind their prices from the
77
+ * app's own provider catalogue, so they list `offers: null`.
78
+ */
79
+ export const billingRailOfferSchema = defineComponent('BillingRailOffer', z
80
+ .object({
81
+ provider_price_id: z.string(),
82
+ plan_id: z.string(),
83
+ interval: billingInterval,
84
+ currency: z.string(),
85
+ gross_minor_units: z.number().int(),
86
+ tax_treatment: taxTreatment,
87
+ })
88
+ .strict());
89
+ export const billingRailOptionSchema = defineComponent('BillingRailOption', z
90
+ .object({
91
+ rail: z.string().describe('The rail: `stripe`, `faircoin`, or a further fiat provider.'),
92
+ settlement: z.enum(BILLING_RAIL_SETTLEMENTS),
93
+ default: z
94
+ .boolean()
95
+ .describe('The rail a request that names none is served by: the first configured.'),
96
+ tax_quotes: z.boolean().describe('Whether `POST /v1/billing/tax_quotes` answers for it.'),
97
+ renewal: z
98
+ .enum(BILLING_RAIL_RENEWALS)
99
+ .describe('`automatic`: the provider charges each period. `payer_initiated`: each period is an explicit payment (`renew`).'),
100
+ offers: z.array(billingRailOfferSchema).nullable(),
101
+ })
102
+ .strict());
103
+ /** Every rail this merchant's payers can choose between, default first. A complete set. */
104
+ export const billingRailListSchema = defineComponent('BillingRailList', z.object({ object: z.literal('list'), data: z.array(billingRailOptionSchema) }).strict());
105
+ // ---- Customers ---------------------------------------------------------------------
106
+ export const ensureBillingCustomerParams = z
107
+ .object({
108
+ store_id: billingReference.describe("The app's own store / account reference."),
109
+ store_name: z.string().min(1).max(200),
110
+ rail: billingRailId
111
+ .optional()
112
+ .describe("The payer's chosen rail; default: the merchant's first. A customer belongs to one rail, and its checkouts and subscriptions follow it."),
113
+ })
114
+ .strict();
115
+ export const billingCustomerSchema = defineComponent('BillingCustomer', z.object({ provider_customer_id: z.string() }).strict());
116
+ // ---- Tax quotes ----------------------------------------------------------------------
117
+ /**
118
+ * A merchant asks Peable to quote a registered product. Monetary and fiscal
119
+ * configuration is resolved inside Peable, never supplied by a consumer.
120
+ */
121
+ export const createBillingTaxQuoteParams = z
122
+ .object({
123
+ rail: billingRailId
124
+ .optional()
125
+ .describe("Default: the first of the merchant's rails that answers tax quotes."),
126
+ store_id: billingReference,
127
+ plan_id: billingReference,
128
+ provider_price_id: billingReference
129
+ .optional()
130
+ .describe('Selects one offer when a plan is sold at several prices.'),
131
+ customer_location_evidence_id: billingReference.describe('A `tax.location_evidence` id (`taxloc_…`) recorded for this `store_id`.'),
132
+ })
133
+ .strict();
134
+ /** A signed, immutable, single-use Peable Tax quote (schema version 2). */
135
+ export const billingTaxQuoteSchema = defineComponent('BillingTaxQuote', z
136
+ .object({
137
+ schema_version: z.literal(2),
138
+ source: z
139
+ .object({
140
+ merchant_id: billingReference,
141
+ app_id: billingReference,
142
+ store_id: billingReference,
143
+ plan_id: billingReference,
144
+ mode,
145
+ environment,
146
+ })
147
+ .strict(),
148
+ quote: z
149
+ .object({
150
+ id: billingReference,
151
+ currency: z.string().regex(/^[A-Z]{3}$/),
152
+ gross_minor_units: minorUnits,
153
+ net_minor_units: minorUnits,
154
+ tax_minor_units: minorUnits,
155
+ tax_treatment: taxTreatment,
156
+ seller_id: billingReference,
157
+ invoice_issuer_id: billingReference,
158
+ tax_remitter_id: billingReference,
159
+ tax_service_ref: billingReference,
160
+ country: z.string().regex(/^[A-Z]{2}$/),
161
+ coverage_evidence_id: billingReference,
162
+ tax_rate_evidence_id: billingReference,
163
+ customer_location_evidence_id: billingReference,
164
+ quoted_at: billingInstant,
165
+ expires_at: billingInstant,
166
+ })
167
+ .strict(),
168
+ signature: ed25519Signature,
169
+ })
170
+ .strict());
171
+ // ---- Checkout ------------------------------------------------------------------------
172
+ export const createBillingCheckoutParams = z
173
+ .object({
174
+ rail: billingRailId
175
+ .optional()
176
+ .describe('An assertion of the rail; it must be the rail of `provider_customer_id`.'),
177
+ provider_customer_id: billingCustomerRef,
178
+ provider_price_id: billingPriceRef,
179
+ trial_days: z.number().int().min(0).max(730),
180
+ tax_quote: billingTaxQuoteSchema
181
+ .optional()
182
+ .describe('Opt-in fiscal checkout: the complete signed quote, immutable and single-use. Peable validates its pinned authority and retains immutable evidence before creating a session.'),
183
+ return_url: billingReturnUrl,
184
+ store_id: billingReference,
185
+ plan_id: billingReference,
186
+ })
187
+ .strict();
188
+ /** A sensitive, owner-only URL. The gateway refuses replay after `expires_at`. */
189
+ export const billingHostedSessionSchema = defineComponent('BillingHostedSession', z.object({ url: z.string(), expires_at: z.number().int() }).strict());
190
+ /** An owned recurring checkout. Completing it is not paid evidence. */
191
+ export const billingCheckoutSessionSchema = defineComponent('BillingCheckoutSession', z.object({ id: z.string(), url: z.string(), expires_at: z.number().int() }).strict());
192
+ /** A durable embedded-session reference. Provider secrets are never in it. */
193
+ export const billingEmbeddedCheckoutSessionSchema = defineComponent('BillingEmbeddedCheckoutSession', z
194
+ .object({
195
+ id: z.string(),
196
+ presentation: z.literal('embedded'),
197
+ expires_at: z.number().int(),
198
+ })
199
+ .strict());
200
+ export const billingEmbeddedCheckoutScopeSchema = defineComponent('BillingEmbeddedCheckoutScope', z
201
+ .object({
202
+ merchant_id: z.string(),
203
+ app_id: z.string(),
204
+ environment,
205
+ mode,
206
+ })
207
+ .strict());
208
+ export const billingEmbeddedCheckoutConfigurationSchema = defineComponent('BillingEmbeddedCheckoutConfiguration', z
209
+ .object({
210
+ scope: billingEmbeddedCheckoutScopeSchema,
211
+ publishable_key: z.string(),
212
+ payment_methods: z.array(z.object({ id: z.literal('card'), available: z.boolean() }).strict()),
213
+ })
214
+ .strict());
215
+ /** An ephemeral processor capability, released only to the authenticated owning workload. */
216
+ export const billingEmbeddedCheckoutActionSchema = defineComponent('BillingEmbeddedCheckoutAction', z
217
+ .object({
218
+ kind: z.literal('checkout_session'),
219
+ provider: z.literal('stripe'),
220
+ session_id: z.string(),
221
+ client_secret: z.string(),
222
+ publishable_key: z.string(),
223
+ amount_minor_units: z.number().int(),
224
+ currency: z.string(),
225
+ })
226
+ .strict());
227
+ export const billingEmbeddedCheckoutBindingSchema = defineComponent('BillingEmbeddedCheckoutBinding', z
228
+ .object({
229
+ status: z.enum(['open', 'complete', 'expired']),
230
+ action: billingEmbeddedCheckoutActionSchema
231
+ .nullable()
232
+ .describe('`null` once the session is complete or expired.'),
233
+ scope: billingEmbeddedCheckoutScopeSchema
234
+ .extend({
235
+ store_id: z.string(),
236
+ plan_id: z.string(),
237
+ provider_customer_id: z.string(),
238
+ provider_price_id: z.string(),
239
+ })
240
+ .strict(),
241
+ tax_quote: billingTaxQuoteSchema,
242
+ expires_at: z.number().int(),
243
+ })
244
+ .strict());
245
+ // ---- Subscriptions -------------------------------------------------------------------
246
+ /** Provider observations only. Consumers own plan, status and entitlement interpretation. */
247
+ export const billingSubscriptionSchema = defineComponent('BillingSubscription', z
248
+ .object({
249
+ provider_subscription_id: z.string(),
250
+ latest_invoice_id: z
251
+ .string()
252
+ .nullable()
253
+ .optional()
254
+ .describe('Discovery only: the invoice must still be read and proven paid.'),
255
+ provider_customer_id: z.string(),
256
+ provider_price_id: z.string(),
257
+ store_id: z.string(),
258
+ plan_id: z.string(),
259
+ livemode: z.boolean(),
260
+ status: z.enum(BILLING_SUBSCRIPTION_STATUSES),
261
+ interval: billingInterval,
262
+ cancel_at_period_end: z.boolean(),
263
+ current_period_start: z.number().int(),
264
+ current_period_end: z.number().int(),
265
+ trial_ends_at: z.number().int().nullable(),
266
+ cancel_at: z.number().int().nullable(),
267
+ cancelled_at: z.number().int().nullable(),
268
+ })
269
+ .strict());
270
+ export const billingCheckoutObservationSchema = defineComponent('BillingCheckoutObservation', z
271
+ .object({
272
+ initial_invoice_id: z
273
+ .string()
274
+ .nullable()
275
+ .describe('The immutable `subscription_create` invoice proven for this exact checkout. Discovery only, never paid authority.'),
276
+ id: z.string(),
277
+ status: z.enum(['open', 'complete', 'expired']),
278
+ store_id: z.string(),
279
+ plan_id: z.string(),
280
+ provider_customer_id: z.string(),
281
+ provider_price_id: z.string(),
282
+ subscription: billingSubscriptionSchema.nullable(),
283
+ })
284
+ .strict());
285
+ // ---- Checkout operation recovery -----------------------------------------------------
286
+ /** The query of a recovery read; the `Idempotency-Key` is its path. */
287
+ export const retrieveBillingCheckoutOperationQuery = z
288
+ .object({
289
+ provider_customer_id: billingReference,
290
+ provider_price_id: billingReference,
291
+ store_id: billingReference,
292
+ plan_id: billingReference,
293
+ })
294
+ .strict();
295
+ /** A recovery read as a caller names it: the key and the operation it keyed. */
296
+ export const billingCheckoutOperationParams = retrieveBillingCheckoutOperationQuery
297
+ .extend({ idempotency_key: billingIdempotencyKey })
298
+ .strict();
299
+ const checkoutOperationSource = z
300
+ .object({
301
+ idempotency_key: z.string(),
302
+ provider_customer_id: z.string(),
303
+ provider_price_id: z.string(),
304
+ store_id: z.string(),
305
+ plan_id: z.string(),
306
+ tax_quote_id: z.string().nullable(),
307
+ merchant_id: z.string(),
308
+ app_id: z.string(),
309
+ mode,
310
+ environment,
311
+ })
312
+ .strict();
313
+ export const billingCheckoutOperationSourceSchema = defineComponent('BillingCheckoutOperationSource', checkoutOperationSource);
314
+ /**
315
+ * Read-only recovery of one previously attempted recurring checkout. Neither
316
+ * absence nor uncertainty permits cancellation or another financial operation.
317
+ */
318
+ export const billingCheckoutOperationRecoverySchema = defineComponent('BillingCheckoutOperationRecovery', z.union([
319
+ z
320
+ .object({
321
+ state: z.enum(['not_found', 'pending', 'indeterminate']),
322
+ source: billingCheckoutOperationSourceSchema,
323
+ })
324
+ .strict(),
325
+ z
326
+ .object({
327
+ state: z.literal('succeeded'),
328
+ source: billingCheckoutOperationSourceSchema,
329
+ checkout: z
330
+ .object({ id: z.string(), expires_at: z.number().int(), url: z.string().optional() })
331
+ .strict(),
332
+ })
333
+ .strict(),
334
+ ]));
335
+ // ---- Portal ----------------------------------------------------------------------------
336
+ export const createBillingPortalParams = z
337
+ .object({ provider_customer_id: billingCustomerRef, return_url: billingReturnUrl })
338
+ .strict();
339
+ // ---- Invoices ---------------------------------------------------------------------------
340
+ /** An authenticated authoritative read: one settled, full, non-prorated line only. */
341
+ export const billingPaidInvoiceSchema = defineComponent('BillingPaidInvoice', z
342
+ .object({
343
+ invoice_id: z.string(),
344
+ line_id: z.string(),
345
+ payment_intent_id: z.string(),
346
+ provider_subscription_id: z.string(),
347
+ provider_customer_id: z.string(),
348
+ provider_price_id: z.string(),
349
+ store_id: z.string(),
350
+ plan_id: z.string(),
351
+ livemode: z.boolean(),
352
+ currency: z.string(),
353
+ amount_paid: z.string(),
354
+ net_amount: z.string().nullable(),
355
+ tax_amount: z
356
+ .string()
357
+ .nullable()
358
+ .describe('A provider observation, not a tax quote or seller configuration.'),
359
+ period_start: z.number().int(),
360
+ period_end: z.number().int(),
361
+ paid_at: z.number().int(),
362
+ observed_at: z.number().int(),
363
+ })
364
+ .strict());
365
+ export const billingInvoiceStateSchema = defineComponent('BillingInvoiceState', billingPaidInvoiceSchema
366
+ .extend({
367
+ charge_id: z.string(),
368
+ amount_refunded: z.string(),
369
+ state: z.enum(['paid', 'fully_refunded', 'partially_refunded']),
370
+ })
371
+ .strict());
372
+ /** One frozen Peable Tax line behind a signed invoice's tax amount. */
373
+ export const billingInvoiceTaxLineSchema = defineComponent('BillingInvoiceTaxLine', z
374
+ .object({
375
+ calculation_id: billingReference,
376
+ country: z.string().regex(/^[A-Z]{2}$/),
377
+ state: z.string().nullable(),
378
+ tax_type: z.string().nullable(),
379
+ rate_percentage: z.string().nullable(),
380
+ taxable_minor_units: minorUnits,
381
+ tax_minor_units: minorUnits,
382
+ inclusive: z.boolean(),
383
+ taxability_reason: z.string().min(1),
384
+ })
385
+ .strict());
386
+ /**
387
+ * Provider-independent fiscal evidence. Values come from the configured
388
+ * authority, never from invoice amounts, merchant metadata, or an application
389
+ * tax guess.
390
+ */
391
+ export const billingInvoiceAuthoritySourceSchema = defineComponent('BillingInvoiceAuthoritySource', z
392
+ .object({
393
+ invoice_id: billingReference,
394
+ payment_intent_id: billingReference,
395
+ customer_id: billingReference,
396
+ subscription_id: billingReference,
397
+ price_id: billingReference,
398
+ plan_id: billingReference,
399
+ merchant_id: billingReference,
400
+ app_id: billingReference,
401
+ mode,
402
+ environment,
403
+ })
404
+ .strict());
405
+ export const billingFinalInvoiceSchema = defineComponent('BillingFinalInvoice', z
406
+ .object({
407
+ platform: z.literal('peable'),
408
+ currency: z.string().regex(/^[A-Z]{3}$/),
409
+ gross_minor_units: minorUnits,
410
+ net_minor_units: minorUnits,
411
+ tax_minor_units: minorUnits,
412
+ merchant_fee_minor_units: minorUnits,
413
+ tax_treatment: taxTreatment,
414
+ seller_id: billingReference,
415
+ invoice_issuer_id: billingReference,
416
+ tax_quote_id: billingReference,
417
+ customer_location_evidence_id: billingReference,
418
+ tax_rate_evidence_id: billingReference,
419
+ context: z
420
+ .object({
421
+ payer_account_id: billingReference,
422
+ beneficiary_account_id: billingReference,
423
+ provider_subscription_id: billingReference,
424
+ offer_id: billingReference,
425
+ offer_version: z.number().int().positive(),
426
+ period_start: billingInstant,
427
+ period_end: billingInstant,
428
+ mode,
429
+ environment,
430
+ })
431
+ .strict(),
432
+ issued_at: billingInstant,
433
+ expires_at: billingInstant,
434
+ faircoin_quote: z
435
+ .object({
436
+ id: billingReference,
437
+ amount_base_units: z
438
+ .string()
439
+ .regex(/^[1-9][0-9]*$/)
440
+ .max(80),
441
+ quoted_at: billingInstant,
442
+ expires_at: billingInstant,
443
+ rounding_evidence_id: billingReference,
444
+ })
445
+ .strict()
446
+ .optional()
447
+ .describe('On a FairCoin invoice: the FX quote that bounds the payment.'),
448
+ tax_lines: z
449
+ .array(billingInvoiceTaxLineSchema)
450
+ .max(500)
451
+ .optional()
452
+ .describe('Present only when asked for (`include=tax_lines`): the frozen Peable Tax lines behind `tax_minor_units`, covered by the same signature.'),
453
+ })
454
+ .strict());
455
+ /** A signed final invoice authority (schema version 2). Verify it against the pinned keys. */
456
+ export const billingFinalInvoiceAuthoritySchema = defineComponent('BillingFinalInvoiceAuthority', z
457
+ .object({
458
+ schema_version: z.literal(2),
459
+ source: billingInvoiceAuthoritySourceSchema,
460
+ invoice: billingFinalInvoiceSchema,
461
+ method: z.enum(['card', 'faircoin']),
462
+ signature: ed25519Signature,
463
+ })
464
+ .strict());
465
+ export const retrieveBillingInvoiceAuthorityQuery = z.object({
466
+ include: z
467
+ .literal('tax_lines')
468
+ .optional()
469
+ .describe('`tax_lines`: include the frozen Peable Tax lines, inside the signature.'),
470
+ });
471
+ // ---- FairCoin renewal authority -------------------------------------------------------
472
+ const positiveBaseUnits = z
473
+ .string()
474
+ .regex(/^[1-9][0-9]*$/)
475
+ .max(80);
476
+ /**
477
+ * An automatic FairCoin renewal authorization: an explicit, bounded
478
+ * instruction. Transporting it creates no mandate and authorizes no custody of
479
+ * payer keys.
480
+ */
481
+ export const billingFaircoinRenewalConsentSchema = defineComponent('BillingFaircoinRenewalConsent', z
482
+ .object({
483
+ authorization_id: billingReference,
484
+ payer_account_id: billingReference,
485
+ merchant_id: billingReference,
486
+ app_id: billingReference,
487
+ subscription_id: billingReference,
488
+ plan_id: billingReference,
489
+ mode,
490
+ environment,
491
+ explicit_consent: z.literal(true),
492
+ consent_evidence_id: billingReference,
493
+ maximum_amount_base_units: positiveBaseUnits,
494
+ interval: z.literal('month'),
495
+ interval_count: z.literal(1),
496
+ starts_at: billingInstant,
497
+ expires_at: billingInstant,
498
+ accepted_at: billingInstant,
499
+ })
500
+ .strict()
501
+ .refine((value) => value.expires_at > value.starts_at &&
502
+ value.accepted_at <= value.starts_at &&
503
+ (value.mode === 'live') === (value.environment === 'production'), 'Invalid consent period or environment'));
504
+ export const billingFaircoinRenewalRevocationSchema = defineComponent('BillingFaircoinRenewalRevocation', z
505
+ .object({
506
+ authorization_id: billingReference,
507
+ revoked_at: billingInstant,
508
+ revocation_evidence_id: billingReference,
509
+ })
510
+ .strict());
511
+ export const billingFaircoinRenewalChoiceSchema = defineComponent('BillingFaircoinRenewalChoice', z.union([
512
+ z.object({ method: z.literal('faircoin'), renewal: z.literal('manual_monthly') }).strict(),
513
+ z
514
+ .object({
515
+ method: z.literal('faircoin'),
516
+ renewal: z.literal('automatic'),
517
+ consent: billingFaircoinRenewalConsentSchema,
518
+ })
519
+ .strict(),
520
+ ]));
521
+ /** A FAIR/USD quote: the FAIR a USD amount costs, ceiled to a base unit, for a bounded time. */
522
+ export const billingFaircoinFxQuoteSchema = defineComponent('BillingFaircoinFxQuote', z
523
+ .object({
524
+ id: z.string(),
525
+ currency: z.literal('USD'),
526
+ gross_minor_units: z.number().int(),
527
+ amount_base_units: z.string(),
528
+ usd_per_fair: z.string(),
529
+ source: z.string(),
530
+ observed_at: z.number().int(),
531
+ quoted_at: z.number().int(),
532
+ expires_at: z.number().int(),
533
+ rounding: z.literal('ceil_to_base_unit'),
534
+ })
535
+ .strict());
536
+ // ---- Routes ----------------------------------------------------------------------------
537
+ /** The body of `cancel_at_period_end`: nothing. */
538
+ export const cancelBillingSubscriptionParams = z.object({}).strict();
539
+ const requiresKey = 'Requires an `Idempotency-Key` header: it is the operation’s identity at the provider.';
540
+ const subscription = { id: 'The provider subscription (`provider_subscription_id`).' };
541
+ const invoice = {
542
+ ...subscription,
543
+ invoiceId: 'The invoice of that subscription.',
544
+ };
545
+ export const billingRoutes = [
546
+ defineRoute({
547
+ operationId: 'listBillingRails',
548
+ method: 'get',
549
+ path: '/v1/billing/rails',
550
+ tag: 'Recurring billing',
551
+ summary: 'List the settlement rails',
552
+ description: "The rails this merchant's payers can choose between (card and other fiat providers, FairCoin), default first, with each rail's offers. Pass the payer's choice as `rail` to `ensureCustomer`.",
553
+ auth: 'service',
554
+ scope: 'payments:read',
555
+ response: billingRailListSchema,
556
+ sdk: 'billing.listRails',
557
+ }),
558
+ defineRoute({
559
+ operationId: 'createBillingTaxQuote',
560
+ method: 'post',
561
+ path: '/v1/billing/tax_quotes',
562
+ tag: 'Recurring billing',
563
+ summary: 'Quote the tax of a plan',
564
+ description: 'A signed Peable Tax quote for one plan and one customer location. Verify its signature against the pinned keys before passing it to a checkout.',
565
+ auth: 'service',
566
+ scope: 'payments:read',
567
+ body: createBillingTaxQuoteParams,
568
+ response: billingTaxQuoteSchema,
569
+ sdk: 'billing.createTaxQuote',
570
+ }),
571
+ defineRoute({
572
+ operationId: 'ensureBillingCustomer',
573
+ method: 'post',
574
+ path: '/v1/billing/customers',
575
+ tag: 'Recurring billing',
576
+ summary: 'Ensure the billing customer of a store',
577
+ description: `The same store always answers the same customer. ${requiresKey}`,
578
+ auth: 'service',
579
+ scope: 'payments:write',
580
+ body: ensureBillingCustomerParams,
581
+ response: billingCustomerSchema,
582
+ sdk: 'billing.ensureCustomer',
583
+ }),
584
+ defineRoute({
585
+ operationId: 'createBillingCheckoutSession',
586
+ method: 'post',
587
+ path: '/v1/billing/checkout_sessions',
588
+ tag: 'Recurring billing',
589
+ summary: 'Create a subscription checkout',
590
+ description: `A hosted checkout for one plan. Completing it is not paid evidence: read the subscription and its paid invoice. ${requiresKey}`,
591
+ auth: 'service',
592
+ scope: 'payments:write',
593
+ body: createBillingCheckoutParams,
594
+ response: billingCheckoutSessionSchema,
595
+ sdk: 'billing.createCheckoutSession',
596
+ }),
597
+ defineRoute({
598
+ operationId: 'retrieveBillingEmbeddedCheckoutConfiguration',
599
+ method: 'get',
600
+ path: '/v1/billing/embedded_checkout_configuration',
601
+ tag: 'Recurring billing',
602
+ summary: 'Retrieve the embedded checkout configuration',
603
+ auth: 'service',
604
+ scope: 'payments:read',
605
+ response: billingEmbeddedCheckoutConfigurationSchema,
606
+ sdk: 'billing.embeddedCheckoutConfiguration',
607
+ }),
608
+ defineRoute({
609
+ operationId: 'createBillingEmbeddedCheckoutSession',
610
+ method: 'post',
611
+ path: '/v1/billing/embedded_checkout_sessions',
612
+ tag: 'Recurring billing',
613
+ summary: 'Create an embedded subscription checkout',
614
+ description: `Fiscal checkout only: \`tax_quote\` is required. ${requiresKey}`,
615
+ auth: 'service',
616
+ scope: 'payments:write',
617
+ body: createBillingCheckoutParams,
618
+ response: billingEmbeddedCheckoutSessionSchema,
619
+ sdk: 'billing.createEmbeddedCheckoutSession',
620
+ }),
621
+ defineRoute({
622
+ operationId: 'retrieveBillingEmbeddedCheckoutAction',
623
+ method: 'get',
624
+ path: '/v1/billing/embedded_checkout_sessions/{id}/client_action',
625
+ tag: 'Recurring billing',
626
+ summary: 'Retrieve an embedded checkout’s client action',
627
+ description: 'The ephemeral processor capability to mount the embedded checkout, released only to the owning workload; `action` is `null` once the session is complete or expired.',
628
+ auth: 'service',
629
+ scope: 'payments:read',
630
+ params: { id: 'The embedded checkout session (`cs_…`).' },
631
+ response: billingEmbeddedCheckoutBindingSchema,
632
+ sdk: 'billing.retrieveEmbeddedCheckoutAction',
633
+ }),
634
+ defineRoute({
635
+ operationId: 'createRecurringBillingPortalSession',
636
+ method: 'post',
637
+ path: '/v1/billing/portal_sessions',
638
+ tag: 'Recurring billing',
639
+ summary: "Open the provider's billing portal",
640
+ description: `A short-lived, owner-only URL. ${requiresKey}`,
641
+ auth: 'service',
642
+ scope: 'payments:write',
643
+ body: createBillingPortalParams,
644
+ response: billingHostedSessionSchema,
645
+ sdk: 'billing.createPortalSession',
646
+ }),
647
+ defineRoute({
648
+ operationId: 'retrieveBillingCheckoutOperation',
649
+ method: 'get',
650
+ path: '/v1/billing/checkout_operations/{key}',
651
+ tag: 'Recurring billing',
652
+ summary: 'Recover a checkout operation',
653
+ description: 'Reads the state of a checkout attempted under this `Idempotency-Key`, even after its quote or session expired. Missing, pending or indeterminate never authorizes another create or a cancellation.',
654
+ auth: 'service',
655
+ scope: 'payments:read',
656
+ params: { key: 'The `Idempotency-Key` the checkout was created with.' },
657
+ query: retrieveBillingCheckoutOperationQuery,
658
+ response: billingCheckoutOperationRecoverySchema,
659
+ sdk: 'billing.retrieveCheckoutOperation',
660
+ }),
661
+ defineRoute({
662
+ operationId: 'retrieveBillingCheckoutSession',
663
+ method: 'get',
664
+ path: '/v1/billing/checkout_sessions/{id}',
665
+ tag: 'Recurring billing',
666
+ summary: 'Retrieve a subscription checkout',
667
+ auth: 'service',
668
+ scope: 'payments:read',
669
+ params: { id: 'The checkout session (`cs_…`).' },
670
+ response: billingCheckoutObservationSchema,
671
+ sdk: 'billing.retrieveCheckout',
672
+ }),
673
+ defineRoute({
674
+ operationId: 'retrieveBillingInvoiceAuthority',
675
+ method: 'get',
676
+ path: '/v1/billing/subscriptions/{id}/invoice_authorities/{invoiceId}',
677
+ tag: 'Recurring billing',
678
+ summary: 'Retrieve the signed final invoice authority',
679
+ description: 'Signed fiscal evidence of one paid invoice. Verify the signature against the pinned keys (`PEABLE_BILLING_AUTHORITY_KEYS`).',
680
+ auth: 'service',
681
+ scope: 'payments:read',
682
+ params: invoice,
683
+ query: retrieveBillingInvoiceAuthorityQuery,
684
+ response: billingFinalInvoiceAuthoritySchema,
685
+ sdk: 'billing.retrieveFinalInvoiceAuthority',
686
+ }),
687
+ defineRoute({
688
+ operationId: 'retrieveBillingInvoiceState',
689
+ method: 'get',
690
+ path: '/v1/billing/subscriptions/{id}/invoice_states/{invoiceId}',
691
+ tag: 'Recurring billing',
692
+ summary: 'Retrieve the refund state of a paid invoice',
693
+ auth: 'service',
694
+ scope: 'payments:read',
695
+ params: invoice,
696
+ response: billingInvoiceStateSchema,
697
+ sdk: 'billing.retrieveInvoiceState',
698
+ }),
699
+ defineRoute({
700
+ operationId: 'retrieveBillingPaidInvoice',
701
+ method: 'get',
702
+ path: '/v1/billing/subscriptions/{id}/paid_invoices/{invoiceId}',
703
+ tag: 'Recurring billing',
704
+ summary: 'Retrieve a paid invoice',
705
+ description: 'Paid-period evidence: answers only for a settled, full, non-prorated invoice.',
706
+ auth: 'service',
707
+ scope: 'payments:read',
708
+ params: invoice,
709
+ response: billingPaidInvoiceSchema,
710
+ sdk: 'billing.retrievePaidInvoice',
711
+ }),
712
+ defineRoute({
713
+ operationId: 'retrieveBillingSubscription',
714
+ method: 'get',
715
+ path: '/v1/billing/subscriptions/{id}',
716
+ tag: 'Recurring billing',
717
+ summary: 'Retrieve a subscription',
718
+ auth: 'service',
719
+ scope: 'payments:read',
720
+ params: subscription,
721
+ response: billingSubscriptionSchema,
722
+ sdk: 'billing.retrieveSubscription',
723
+ }),
724
+ defineRoute({
725
+ operationId: 'renewBillingSubscription',
726
+ method: 'post',
727
+ path: '/v1/billing/subscriptions/{id}/renew',
728
+ tag: 'Recurring billing',
729
+ summary: 'Renew a payer-initiated subscription',
730
+ description: `Opens a new expiring FAIR payment for one monthly period. Never auto-debits. ${requiresKey}`,
731
+ auth: 'service',
732
+ scope: 'payments:write',
733
+ params: subscription,
734
+ body: createBillingCheckoutParams,
735
+ response: billingCheckoutSessionSchema,
736
+ sdk: 'billing.renewSubscription',
737
+ }),
738
+ defineRoute({
739
+ operationId: 'cancelBillingSubscriptionAtPeriodEnd',
740
+ method: 'post',
741
+ path: '/v1/billing/subscriptions/{id}/cancel_at_period_end',
742
+ tag: 'Recurring billing',
743
+ summary: 'Cancel a subscription at period end',
744
+ description: `Access continues to the end of the paid period. ${requiresKey}`,
745
+ auth: 'service',
746
+ scope: 'payments:write',
747
+ params: subscription,
748
+ body: cancelBillingSubscriptionParams,
749
+ response: billingSubscriptionSchema,
750
+ sdk: 'billing.cancelAtPeriodEnd',
751
+ }),
752
+ ];