@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,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.invoiceItemRoutes = exports.listInvoiceItemsQuery = exports.updateInvoiceItemParams = exports.createInvoiceItemParams = exports.deletedInvoiceItemSchema = exports.invoiceItemSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const objects_1 = require("../../common/objects");
6
+ const prices_1 = require("../catalog/prices");
7
+ const envelopes_1 = require("../../common/envelopes");
8
+ const objects_2 = require("../../common/objects");
9
+ const params_1 = require("../../common/params");
10
+ const primitives_1 = require("../../common/primitives");
11
+ const route_1 = require("../../route");
12
+ const params_2 = require("./params");
13
+ /**
14
+ * Invoice items (`ii_…`, ADR 0018 §2): a charge waiting for an invoice — a
15
+ * pending item is pulled into the customer's next invoice (a subscription's
16
+ * renewal, or a manual invoice with `pending_invoice_items_behavior=include`),
17
+ * or it is created directly on a draft.
18
+ */
19
+ exports.invoiceItemSchema = (0, objects_2.defineObject)('invoiceitem', 'InvoiceItem', zod_1.z
20
+ .object({
21
+ id: zod_1.z.string(),
22
+ object: zod_1.z.literal('invoiceitem'),
23
+ livemode: primitives_1.livemode,
24
+ customer: (0, objects_2.expandable)('customer', '`cus_…`, or the Customer with `expand[]=customer`.'),
25
+ invoice: (0, objects_2.expandable)('invoice', 'The draft it is on (`in_…`, or the Invoice with `expand[]=invoice`); `null` while pending.').nullable(),
26
+ subscription: (0, objects_2.expandable)('subscription', '`sub_…`, or the Subscription with `expand[]=subscription`.').nullable(),
27
+ subscription_item: zod_1.z.string().nullable(),
28
+ price: (0, objects_1.embedded)('price', 'The Price, embedded; `null` for a fixed amount.').nullable(),
29
+ quantity: zod_1.z.number().int().nonnegative(),
30
+ unit_amount: primitives_1.amount
31
+ .nullable()
32
+ .describe('Base units per unit; `null` for a proration (an amount for a period, not per unit).'),
33
+ amount: primitives_1.signedAmount.describe('SIGNED (an engine-made proration credit is negative).'),
34
+ currency: primitives_1.currency,
35
+ description: zod_1.z.string().nullable(),
36
+ discountable: zod_1.z.boolean(),
37
+ period: zod_1.z.object({ start: primitives_1.unixSeconds, end: primitives_1.unixSeconds }).strict(),
38
+ proration: zod_1.z.boolean(),
39
+ metadata: primitives_1.metadata,
40
+ date: primitives_1.unixSeconds,
41
+ })
42
+ .strict());
43
+ exports.deletedInvoiceItemSchema = (0, objects_2.defineComponent)('DeletedInvoiceItem', (0, envelopes_1.deletedOf)('invoiceitem'));
44
+ /**
45
+ * A price (`price` or `price_data`) times `quantity`, or a fixed `amount` +
46
+ * `currency`. Never negative — a credit is a credit note or a customer balance
47
+ * transaction.
48
+ */
49
+ exports.createInvoiceItemParams = zod_1.z
50
+ .object({
51
+ customer: params_1.idParam,
52
+ invoice: params_1.idParam.optional().describe('A draft to put it on; absent, it is pending.'),
53
+ subscription: params_1.idParam.optional(),
54
+ price: params_1.idParam.optional(),
55
+ price_data: prices_1.priceDataParams
56
+ .optional()
57
+ .describe('A one-off per-unit price of an existing product, for an item that names no stored price.'),
58
+ quantity: params_2.quantityParam.optional(),
59
+ amount: params_2.amountParam.optional(),
60
+ currency: params_2.currencyParam.optional(),
61
+ description: (0, params_2.shortText)(500).optional(),
62
+ discountable: zod_1.z.boolean().optional(),
63
+ period: zod_1.z.object({ start: params_1.unixSecondsParam, end: params_1.unixSecondsParam }).strict().optional(),
64
+ metadata: params_1.metadataCreateParam.optional(),
65
+ expand: params_1.expandParam.optional(),
66
+ })
67
+ .strict();
68
+ /** Pending items, or items on a draft. A field sent as `""` is cleared; `metadata` is a patch. */
69
+ exports.updateInvoiceItemParams = zod_1.z
70
+ .object({
71
+ description: zod_1.z.union([(0, params_2.shortText)(500), zod_1.z.literal('')]).optional(),
72
+ quantity: params_2.quantityParam.optional(),
73
+ discountable: zod_1.z.boolean().optional(),
74
+ metadata: params_1.metadataUpdateParam.optional(),
75
+ expand: params_1.expandParam.optional(),
76
+ })
77
+ .strict();
78
+ exports.listInvoiceItemsQuery = (0, params_1.listQuery)({
79
+ customer: params_1.idParam.optional(),
80
+ invoice: params_1.idParam.optional(),
81
+ pending: params_1.queryBoolean.optional().describe('Only items not on any invoice yet.'),
82
+ });
83
+ const invoiceItemId = { id: 'The invoice item (`ii_…`).' };
84
+ exports.invoiceItemRoutes = [
85
+ (0, route_1.defineRoute)({
86
+ operationId: 'createInvoiceItem',
87
+ method: 'post',
88
+ path: '/v1/invoiceitems',
89
+ tag: 'Invoice items',
90
+ summary: 'Create an invoice item',
91
+ auth: 'service',
92
+ scope: 'payments:write',
93
+ idempotent: true,
94
+ body: exports.createInvoiceItemParams,
95
+ response: exports.invoiceItemSchema,
96
+ sdk: 'invoiceItems.create',
97
+ expandable: 'invoiceitem',
98
+ }),
99
+ (0, route_1.defineRoute)({
100
+ operationId: 'listInvoiceItems',
101
+ method: 'get',
102
+ path: '/v1/invoiceitems',
103
+ tag: 'Invoice items',
104
+ summary: 'List invoice items',
105
+ auth: 'service',
106
+ scope: 'payments:read',
107
+ query: exports.listInvoiceItemsQuery,
108
+ response: (0, envelopes_1.listOf)(exports.invoiceItemSchema),
109
+ sdk: 'invoiceItems.list',
110
+ expandable: 'invoiceitem',
111
+ }),
112
+ (0, route_1.defineRoute)({
113
+ operationId: 'retrieveInvoiceItem',
114
+ method: 'get',
115
+ path: '/v1/invoiceitems/{id}',
116
+ tag: 'Invoice items',
117
+ summary: 'Retrieve an invoice item',
118
+ auth: 'service',
119
+ scope: 'payments:read',
120
+ params: invoiceItemId,
121
+ query: params_1.expandOnlyQuery,
122
+ response: exports.invoiceItemSchema,
123
+ sdk: 'invoiceItems.retrieve',
124
+ expandable: 'invoiceitem',
125
+ }),
126
+ (0, route_1.defineRoute)({
127
+ operationId: 'updateInvoiceItem',
128
+ method: 'post',
129
+ path: '/v1/invoiceitems/{id}',
130
+ tag: 'Invoice items',
131
+ summary: 'Update an invoice item',
132
+ description: 'While it is pending or on a draft.',
133
+ auth: 'service',
134
+ scope: 'payments:write',
135
+ idempotent: true,
136
+ params: invoiceItemId,
137
+ body: exports.updateInvoiceItemParams,
138
+ response: exports.invoiceItemSchema,
139
+ sdk: 'invoiceItems.update',
140
+ expandable: 'invoiceitem',
141
+ }),
142
+ (0, route_1.defineRoute)({
143
+ operationId: 'deleteInvoiceItem',
144
+ method: 'delete',
145
+ path: '/v1/invoiceitems/{id}',
146
+ tag: 'Invoice items',
147
+ summary: 'Delete an invoice item',
148
+ description: 'While it is pending or on a draft.',
149
+ auth: 'service',
150
+ scope: 'payments:write',
151
+ params: invoiceItemId,
152
+ response: exports.deletedInvoiceItemSchema,
153
+ sdk: 'invoiceItems.del',
154
+ }),
155
+ ];
@@ -0,0 +1,509 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.invoiceRoutes = exports.upcomingInvoiceQuery = exports.listInvoicesQuery = exports.invoiceActionParams = exports.payInvoiceParams = exports.finalizeInvoiceParams = exports.updateInvoiceParams = exports.createInvoiceParams = exports.deletedInvoiceSchema = exports.invoiceSchema = exports.invoiceLineItemSchema = exports.invoiceTaxAmountSchema = void 0;
4
+ const zod_1 = require("zod");
5
+ const objects_1 = require("../../common/objects");
6
+ const envelopes_1 = require("../../common/envelopes");
7
+ const objects_2 = require("../../common/objects");
8
+ const params_1 = require("../../common/params");
9
+ const primitives_1 = require("../../common/primitives");
10
+ const route_1 = require("../../route");
11
+ const invoices_1 = require("../../vocabulary/invoices");
12
+ const subscriptions_1 = require("../../vocabulary/subscriptions");
13
+ const params_2 = require("./params");
14
+ const subscriptions_2 = require("./subscriptions");
15
+ /**
16
+ * Invoices (`in_…`) and their lines (`il_…`) — Orbit's native billing engine
17
+ * (ADR 0018 §2).
18
+ *
19
+ * ## Signed amounts
20
+ *
21
+ * Every amount is a base-unit STRING (ADR 0014 D1). Most are never negative;
22
+ * the ones documented as SIGNED may start with `-`: a proration credit line,
23
+ * an invoice whose credits exceed its charges, and a customer balance (where
24
+ * negative is credit the customer holds, Stripe's convention). A signed amount
25
+ * still has exactly one spelling: no `+`, no `-0`, no leading zeros.
26
+ */
27
+ /** One tax amount on a line. */
28
+ exports.invoiceTaxAmountSchema = (0, objects_2.defineComponent)('InvoiceTaxAmount', zod_1.z
29
+ .object({
30
+ amount: primitives_1.signedAmount.describe('SIGNED: a credit line carries negative tax.'),
31
+ inclusive: zod_1.z.boolean(),
32
+ tax_calculation: zod_1.z
33
+ .string()
34
+ .nullable()
35
+ .describe('The Peable Tax calculation (`taxcalc_…`) it came from; `null` for a derived credit.'),
36
+ taxability_reason: zod_1.z.string().nullable(),
37
+ })
38
+ .strict());
39
+ /** The amount a discount took off a line, or off the whole invoice. */
40
+ const discountAmountSchema = zod_1.z
41
+ .object({
42
+ amount: primitives_1.signedAmount.describe('SIGNED: a discount on a credit line is negative.'),
43
+ discount: zod_1.z.string().describe('The discount it comes from.'),
44
+ })
45
+ .strict();
46
+ const periodSchema = zod_1.z.object({ start: primitives_1.unixSeconds, end: primitives_1.unixSeconds }).strict();
47
+ exports.invoiceLineItemSchema = (0, objects_2.defineObject)('line_item', 'InvoiceLineItem', zod_1.z
48
+ .object({
49
+ id: zod_1.z.string(),
50
+ object: zod_1.z.literal('line_item'),
51
+ livemode: primitives_1.livemode,
52
+ invoice: zod_1.z.string().describe('The invoice (`in_…`) it is on.'),
53
+ type: zod_1.z.enum(invoices_1.INVOICE_LINE_TYPES),
54
+ amount: primitives_1.signedAmount.describe('SIGNED: before discounts; tax-inclusive when the price is.'),
55
+ currency: primitives_1.currency,
56
+ description: zod_1.z.string().nullable(),
57
+ discount_amounts: zod_1.z.array(discountAmountSchema),
58
+ discountable: zod_1.z.boolean(),
59
+ period: periodSchema,
60
+ price: (0, objects_1.embedded)('price', 'The Price, embedded; `null` for a fixed-amount item.').nullable(),
61
+ quantity: zod_1.z.number().int().nullable(),
62
+ proration: zod_1.z.boolean(),
63
+ subscription: zod_1.z.string().nullable(),
64
+ subscription_item: zod_1.z.string().nullable(),
65
+ invoice_item: zod_1.z.string().nullable(),
66
+ tax_amounts: zod_1.z.array(exports.invoiceTaxAmountSchema),
67
+ metadata: primitives_1.metadata,
68
+ })
69
+ .strict());
70
+ exports.invoiceSchema = (0, objects_2.defineObject)('invoice', 'Invoice', zod_1.z
71
+ .object({
72
+ id: zod_1.z.string(),
73
+ object: zod_1.z.literal('invoice'),
74
+ livemode: primitives_1.livemode,
75
+ number: zod_1.z
76
+ .string()
77
+ .nullable()
78
+ .describe('`null` while a draft; `PREFIX-0001` once finalized — gapless per merchant.'),
79
+ customer: (0, objects_2.expandable)('customer', '`cus_…`, or the Customer with `expand[]=customer`.'),
80
+ customer_email: zod_1.z.string().nullable(),
81
+ customer_name: zod_1.z.string().nullable(),
82
+ subscription: (0, objects_2.expandable)('subscription', '`sub_…`, or the Subscription with `expand[]=subscription`.').nullable(),
83
+ status: zod_1.z.enum(invoices_1.INVOICE_STATUSES),
84
+ billing_reason: zod_1.z.enum(invoices_1.INVOICE_BILLING_REASONS),
85
+ collection_method: zod_1.z.enum(subscriptions_1.COLLECTION_METHODS),
86
+ currency: primitives_1.currency,
87
+ description: zod_1.z.string().nullable(),
88
+ auto_advance: zod_1.z.boolean(),
89
+ automatically_finalizes_at: primitives_1.unixSeconds
90
+ .nullable()
91
+ .describe('When a draft with `auto_advance` will finalize.'),
92
+ lines: (0, envelopes_1.listOf)(exports.invoiceLineItemSchema).describe('Every line, on one page.'),
93
+ subtotal: primitives_1.signedAmount.describe('SIGNED. Sum of the lines before discounts.'),
94
+ subtotal_excluding_tax: primitives_1.signedAmount.describe('SIGNED. `subtotal` less the tax included in it (inclusive prices).'),
95
+ total_discount_amounts: zod_1.z.array(discountAmountSchema),
96
+ discount: subscriptions_2.discountSchema.nullable(),
97
+ tax: primitives_1.signedAmount
98
+ .nullable()
99
+ .describe('SIGNED; `null` on a draft whose tax is not calculated yet.'),
100
+ total: primitives_1.signedAmount.describe('SIGNED.'),
101
+ total_excluding_tax: primitives_1.signedAmount.describe('SIGNED.'),
102
+ starting_balance: primitives_1.signedAmount.describe("SIGNED: the customer's balance applied when it finalized."),
103
+ ending_balance: primitives_1.signedAmount
104
+ .nullable()
105
+ .describe("SIGNED: what the customer's balance became; `null` until finalized."),
106
+ amount_due: primitives_1.amount,
107
+ amount_paid: primitives_1.amount,
108
+ amount_remaining: primitives_1.amount,
109
+ pre_payment_credit_notes_amount: primitives_1.amount,
110
+ post_payment_credit_notes_amount: primitives_1.amount,
111
+ attempt_count: zod_1.z.number().int().nonnegative(),
112
+ attempted: zod_1.z.boolean(),
113
+ next_payment_attempt: primitives_1.unixSeconds.nullable(),
114
+ due_date: primitives_1.unixSeconds.nullable(),
115
+ days_until_due: zod_1.z.number().int().nullable(),
116
+ period_start: primitives_1.unixSeconds,
117
+ period_end: primitives_1.unixSeconds,
118
+ payment_intent: (0, objects_2.expandable)('payment_intent', '`pi_…`, or the PaymentIntent with `expand[]=payment_intent`.').nullable(),
119
+ default_payment_method: (0, objects_2.expandable)('payment_method', '`pm_…`, or the PaymentMethod with `expand[]=default_payment_method`.').nullable(),
120
+ automatic_tax: zod_1.z
121
+ .object({
122
+ enabled: zod_1.z.boolean(),
123
+ status: zod_1.z.enum(invoices_1.AUTOMATIC_TAX_STATUSES).nullable(),
124
+ tax_calculation: zod_1.z
125
+ .string()
126
+ .nullable()
127
+ .describe('The Peable Tax calculation (`taxcalc_…`) the invoice finalized with.'),
128
+ })
129
+ .strict(),
130
+ hosted_invoice_url: zod_1.z
131
+ .string()
132
+ .nullable()
133
+ .describe('The payer-facing page (anonymous, an unguessable token); `null` while a draft.'),
134
+ invoice_pdf: zod_1.z.string().nullable().describe('The PDF of the same; `null` while a draft.'),
135
+ last_finalization_error: zod_1.z
136
+ .object({ code: zod_1.z.string(), message: zod_1.z.string() })
137
+ .strict()
138
+ .nullable(),
139
+ status_transitions: zod_1.z
140
+ .object({
141
+ finalized_at: primitives_1.unixSeconds.nullable(),
142
+ paid_at: primitives_1.unixSeconds.nullable(),
143
+ voided_at: primitives_1.unixSeconds.nullable(),
144
+ marked_uncollectible_at: primitives_1.unixSeconds.nullable(),
145
+ })
146
+ .strict(),
147
+ paid_out_of_band: zod_1.z.boolean(),
148
+ test_clock: zod_1.z.string().nullable(),
149
+ metadata: primitives_1.metadata,
150
+ created: primitives_1.unixSeconds,
151
+ effective_at: primitives_1.unixSeconds.nullable(),
152
+ })
153
+ .strict(), {
154
+ examples: [
155
+ {
156
+ id: 'in_0193b8f2c1a87d3e9f4a',
157
+ object: 'invoice',
158
+ livemode: false,
159
+ number: 'ACME-0001',
160
+ customer: 'cus_0193b8f2c1a87d3e9f4a',
161
+ customer_email: 'jenny@example.com',
162
+ customer_name: 'Jenny Rosen',
163
+ subscription: 'sub_0193b8f2c1a87d3e9f4a',
164
+ status: 'paid',
165
+ billing_reason: 'subscription_create',
166
+ collection_method: 'charge_automatically',
167
+ currency: 'EUR',
168
+ description: null,
169
+ auto_advance: true,
170
+ automatically_finalizes_at: null,
171
+ lines: {
172
+ object: 'list',
173
+ data: [],
174
+ has_more: false,
175
+ url: '/v1/invoices/in_0193b8f2c1a87d3e9f4a/lines',
176
+ },
177
+ subtotal: '1999',
178
+ subtotal_excluding_tax: '1999',
179
+ total_discount_amounts: [],
180
+ discount: null,
181
+ tax: '0',
182
+ total: '1999',
183
+ total_excluding_tax: '1999',
184
+ starting_balance: '0',
185
+ ending_balance: '0',
186
+ amount_due: '1999',
187
+ amount_paid: '1999',
188
+ amount_remaining: '0',
189
+ pre_payment_credit_notes_amount: '0',
190
+ post_payment_credit_notes_amount: '0',
191
+ attempt_count: 1,
192
+ attempted: true,
193
+ next_payment_attempt: null,
194
+ due_date: null,
195
+ days_until_due: null,
196
+ period_start: 1793750400,
197
+ period_end: 1793750400,
198
+ payment_intent: 'pi_0193b8f2c1a87d3e9f4a',
199
+ default_payment_method: null,
200
+ automatic_tax: { enabled: false, status: null, tax_calculation: null },
201
+ hosted_invoice_url: 'https://checkout.peable.to/invoice/inv_tok_…',
202
+ invoice_pdf: 'https://api.peable.to/v1/invoices/public/inv_tok_…/pdf',
203
+ last_finalization_error: null,
204
+ status_transitions: {
205
+ finalized_at: 1793750400,
206
+ paid_at: 1793750401,
207
+ voided_at: null,
208
+ marked_uncollectible_at: null,
209
+ },
210
+ paid_out_of_band: false,
211
+ test_clock: null,
212
+ metadata: {},
213
+ created: 1793750400,
214
+ effective_at: 1793750400,
215
+ },
216
+ ],
217
+ });
218
+ /** What `DELETE /v1/invoices/:id` (a draft) answers. */
219
+ exports.deletedInvoiceSchema = (0, objects_2.defineComponent)('DeletedInvoice', (0, envelopes_1.deletedOf)('invoice'));
220
+ // ---- Requests ------------------------------------------------------------------------
221
+ exports.createInvoiceParams = zod_1.z
222
+ .object({
223
+ customer: params_1.idParam,
224
+ currency: params_2.currencyParam
225
+ .optional()
226
+ .describe("Default: the subscription's, else the customer's billing currency."),
227
+ subscription: params_1.idParam.optional(),
228
+ auto_advance: zod_1.z.boolean().optional(),
229
+ collection_method: zod_1.z.enum(subscriptions_1.COLLECTION_METHODS).optional(),
230
+ days_until_due: params_2.daysUntilDueParam.optional(),
231
+ due_date: params_1.unixSecondsParam.optional().describe('`send_invoice` only.'),
232
+ description: (0, params_2.shortText)(1500).optional(),
233
+ default_payment_method: params_1.idParam.optional(),
234
+ discounts: params_2.discountsParam.optional(),
235
+ automatic_tax: params_2.automaticTaxParam.optional(),
236
+ pending_invoice_items_behavior: zod_1.z
237
+ .enum(invoices_1.PENDING_INVOICE_ITEMS_BEHAVIORS)
238
+ .optional()
239
+ .describe("Pull the customer's pending invoice items in. Default `exclude` (Stripe's)."),
240
+ metadata: params_1.metadataCreateParam.optional(),
241
+ expand: params_1.expandParam.optional(),
242
+ })
243
+ .strict();
244
+ /** Drafts only, except `metadata` and `auto_advance`. A field sent as `""` is cleared. */
245
+ exports.updateInvoiceParams = zod_1.z
246
+ .object({
247
+ auto_advance: zod_1.z.boolean().optional(),
248
+ collection_method: zod_1.z.enum(subscriptions_1.COLLECTION_METHODS).optional(),
249
+ days_until_due: params_2.daysUntilDueParam.optional(),
250
+ due_date: params_1.unixSecondsParam.optional(),
251
+ description: zod_1.z.union([(0, params_2.shortText)(1500), zod_1.z.literal('')]).optional(),
252
+ default_payment_method: zod_1.z.union([params_1.idParam, zod_1.z.literal('')]).optional(),
253
+ discounts: zod_1.z.union([params_2.discountsParam, zod_1.z.literal('')]).optional(),
254
+ automatic_tax: params_2.automaticTaxParam.optional(),
255
+ metadata: params_1.metadataUpdateParam.optional(),
256
+ expand: params_1.expandParam.optional(),
257
+ })
258
+ .strict();
259
+ exports.finalizeInvoiceParams = zod_1.z
260
+ .object({ auto_advance: zod_1.z.boolean().optional(), expand: params_1.expandParam.optional() })
261
+ .strict();
262
+ exports.payInvoiceParams = zod_1.z
263
+ .object({
264
+ payment_method: params_1.idParam
265
+ .optional()
266
+ .describe("A saved `pm_…` of the customer; defaults to the invoice's, then the subscription's, then the customer's."),
267
+ paid_out_of_band: zod_1.z.boolean().optional().describe('Record a payment made outside Orbit.'),
268
+ off_session: zod_1.z.boolean().optional().describe('Default true: the customer is not present.'),
269
+ expand: params_1.expandParam.optional(),
270
+ })
271
+ .strict();
272
+ /** The body of an invoice action that takes nothing but `expand[]` (send, void, mark uncollectible). */
273
+ exports.invoiceActionParams = zod_1.z.object({ expand: params_1.expandParam.optional() }).strict();
274
+ exports.listInvoicesQuery = (0, params_1.listQuery)({
275
+ customer: params_1.idParam.optional(),
276
+ subscription: params_1.idParam.optional(),
277
+ status: zod_1.z.enum(invoices_1.INVOICE_STATUSES).optional(),
278
+ collection_method: zod_1.z.enum(subscriptions_1.COLLECTION_METHODS).optional(),
279
+ due_date: params_1.rangeParam.optional(),
280
+ });
281
+ /** `GET /v1/invoices/upcoming` — a preview, never stored. */
282
+ exports.upcomingInvoiceQuery = zod_1.z
283
+ .object({
284
+ customer: params_1.idParam,
285
+ subscription: params_1.idParam
286
+ .optional()
287
+ .describe("Default: the customer's most recent subscription that will renew."),
288
+ subscription_items: zod_1.z
289
+ .array(zod_1.z
290
+ .object({
291
+ id: params_1.idParam.optional(),
292
+ price: params_1.idParam.optional(),
293
+ quantity: (0, params_1.queryInteger)({ min: 0 }).optional(),
294
+ deleted: params_1.queryBoolean.optional(),
295
+ })
296
+ .strict())
297
+ .max(20)
298
+ .optional()
299
+ .describe('Preview a change: the items it would have (`subscription_items[0][price]=…`).'),
300
+ subscription_proration_behavior: zod_1.z.enum(subscriptions_1.PRORATION_BEHAVIORS).optional(),
301
+ subscription_proration_date: params_1.queryUnixSeconds.optional(),
302
+ expand: params_1.expandParam.optional(),
303
+ })
304
+ .strict();
305
+ // ---- Routes --------------------------------------------------------------------------
306
+ const invoiceId = { id: 'The invoice (`in_…`).' };
307
+ exports.invoiceRoutes = [
308
+ (0, route_1.defineRoute)({
309
+ operationId: 'createInvoice',
310
+ method: 'post',
311
+ path: '/v1/invoices',
312
+ tag: 'Invoices',
313
+ summary: 'Create an invoice',
314
+ description: 'A draft, for a customer; it finalizes on its own when `auto_advance` is set.',
315
+ auth: 'service',
316
+ scope: 'payments:write',
317
+ idempotent: true,
318
+ body: exports.createInvoiceParams,
319
+ response: exports.invoiceSchema,
320
+ sdk: 'invoices.create',
321
+ expandable: 'invoice',
322
+ }),
323
+ (0, route_1.defineRoute)({
324
+ operationId: 'listInvoices',
325
+ method: 'get',
326
+ path: '/v1/invoices',
327
+ tag: 'Invoices',
328
+ summary: 'List invoices',
329
+ auth: 'service',
330
+ scope: 'payments:read',
331
+ query: exports.listInvoicesQuery,
332
+ response: (0, envelopes_1.listOf)(exports.invoiceSchema),
333
+ sdk: 'invoices.list',
334
+ expandable: 'invoice',
335
+ }),
336
+ (0, route_1.defineRoute)({
337
+ operationId: 'retrieveUpcomingInvoice',
338
+ method: 'get',
339
+ path: '/v1/invoices/upcoming',
340
+ tag: 'Invoices',
341
+ summary: 'Preview the upcoming invoice',
342
+ description: "The invoice a customer's subscription will renew with — or, with `subscription_items`, the one a change would produce. Computed, never stored (its `id` is empty). 404 when the customer has no subscription that will renew.",
343
+ auth: 'service',
344
+ scope: 'payments:read',
345
+ query: exports.upcomingInvoiceQuery,
346
+ response: exports.invoiceSchema,
347
+ sdk: 'invoices.retrieveUpcoming',
348
+ expandable: 'invoice',
349
+ }),
350
+ (0, route_1.defineRoute)({
351
+ operationId: 'retrieveInvoice',
352
+ method: 'get',
353
+ path: '/v1/invoices/{id}',
354
+ tag: 'Invoices',
355
+ summary: 'Retrieve an invoice',
356
+ auth: 'service',
357
+ scope: 'payments:read',
358
+ params: invoiceId,
359
+ query: params_1.expandOnlyQuery,
360
+ response: exports.invoiceSchema,
361
+ sdk: 'invoices.retrieve',
362
+ expandable: 'invoice',
363
+ }),
364
+ (0, route_1.defineRoute)({
365
+ operationId: 'updateInvoice',
366
+ method: 'post',
367
+ path: '/v1/invoices/{id}',
368
+ tag: 'Invoices',
369
+ summary: 'Update an invoice',
370
+ description: 'Drafts only, except `metadata` and `auto_advance`. A field sent as `""` is cleared; `metadata` is a patch.',
371
+ auth: 'service',
372
+ scope: 'payments:write',
373
+ idempotent: true,
374
+ params: invoiceId,
375
+ body: exports.updateInvoiceParams,
376
+ response: exports.invoiceSchema,
377
+ sdk: 'invoices.update',
378
+ expandable: 'invoice',
379
+ }),
380
+ (0, route_1.defineRoute)({
381
+ operationId: 'deleteInvoice',
382
+ method: 'delete',
383
+ path: '/v1/invoices/{id}',
384
+ tag: 'Invoices',
385
+ summary: 'Delete a draft invoice',
386
+ description: 'Only a draft can be deleted; a finalized invoice is voided instead.',
387
+ auth: 'service',
388
+ scope: 'payments:write',
389
+ params: invoiceId,
390
+ response: exports.deletedInvoiceSchema,
391
+ sdk: 'invoices.del',
392
+ }),
393
+ (0, route_1.defineRoute)({
394
+ operationId: 'finalizeInvoice',
395
+ method: 'post',
396
+ path: '/v1/invoices/{id}/finalize',
397
+ tag: 'Invoices',
398
+ summary: 'Finalize a draft invoice',
399
+ description: 'It gets its number, its tax and its payer-facing page.',
400
+ auth: 'service',
401
+ scope: 'payments:write',
402
+ idempotent: true,
403
+ params: invoiceId,
404
+ body: exports.finalizeInvoiceParams,
405
+ response: exports.invoiceSchema,
406
+ sdk: 'invoices.finalizeInvoice',
407
+ expandable: 'invoice',
408
+ }),
409
+ (0, route_1.defineRoute)({
410
+ operationId: 'payInvoice',
411
+ method: 'post',
412
+ path: '/v1/invoices/{id}/pay',
413
+ tag: 'Invoices',
414
+ summary: 'Pay an invoice',
415
+ description: 'Charge a saved card off-session, or record a payment made outside Orbit (`paid_out_of_band`). A decline is a `card_error` carrying the invoice as it now is.',
416
+ auth: 'service',
417
+ scope: 'payments:write',
418
+ idempotent: true,
419
+ params: invoiceId,
420
+ body: exports.payInvoiceParams,
421
+ response: exports.invoiceSchema,
422
+ sdk: 'invoices.pay',
423
+ expandable: 'invoice',
424
+ }),
425
+ (0, route_1.defineRoute)({
426
+ operationId: 'sendInvoice',
427
+ method: 'post',
428
+ path: '/v1/invoices/{id}/send',
429
+ tag: 'Invoices',
430
+ summary: 'Send an invoice to its customer',
431
+ auth: 'service',
432
+ scope: 'payments:write',
433
+ idempotent: true,
434
+ params: invoiceId,
435
+ body: exports.invoiceActionParams,
436
+ response: exports.invoiceSchema,
437
+ sdk: 'invoices.sendInvoice',
438
+ expandable: 'invoice',
439
+ }),
440
+ (0, route_1.defineRoute)({
441
+ operationId: 'voidInvoice',
442
+ method: 'post',
443
+ path: '/v1/invoices/{id}/void',
444
+ tag: 'Invoices',
445
+ summary: 'Void an invoice',
446
+ auth: 'service',
447
+ scope: 'payments:write',
448
+ idempotent: true,
449
+ params: invoiceId,
450
+ body: exports.invoiceActionParams,
451
+ response: exports.invoiceSchema,
452
+ sdk: 'invoices.voidInvoice',
453
+ expandable: 'invoice',
454
+ }),
455
+ (0, route_1.defineRoute)({
456
+ operationId: 'markInvoiceUncollectible',
457
+ method: 'post',
458
+ path: '/v1/invoices/{id}/mark_uncollectible',
459
+ tag: 'Invoices',
460
+ summary: 'Mark an invoice uncollectible',
461
+ auth: 'service',
462
+ scope: 'payments:write',
463
+ idempotent: true,
464
+ params: invoiceId,
465
+ body: exports.invoiceActionParams,
466
+ response: exports.invoiceSchema,
467
+ sdk: 'invoices.markUncollectible',
468
+ expandable: 'invoice',
469
+ }),
470
+ (0, route_1.defineRoute)({
471
+ operationId: 'listInvoiceLineItems',
472
+ method: 'get',
473
+ path: '/v1/invoices/{id}/lines',
474
+ tag: 'Invoices',
475
+ summary: "List an invoice's lines",
476
+ description: 'Every line, on one page.',
477
+ auth: 'service',
478
+ scope: 'payments:read',
479
+ params: invoiceId,
480
+ response: (0, envelopes_1.listOf)(exports.invoiceLineItemSchema),
481
+ sdk: 'invoices.listLineItems',
482
+ }),
483
+ (0, route_1.defineRoute)({
484
+ operationId: 'retrieveInvoicePdf',
485
+ method: 'get',
486
+ path: '/v1/invoices/{id}/pdf',
487
+ tag: 'Invoices',
488
+ summary: "Download an invoice's PDF",
489
+ auth: 'service',
490
+ scope: 'payments:read',
491
+ params: invoiceId,
492
+ response: { kind: 'binary', contentType: 'application/pdf' },
493
+ sdk: 'invoices.retrievePdf',
494
+ }),
495
+ (0, route_1.defineRoute)({
496
+ operationId: 'searchInvoices',
497
+ method: 'get',
498
+ path: '/v1/invoices/search',
499
+ tag: 'Invoices',
500
+ summary: 'Search invoices',
501
+ description: "Stripe's query language over the invoice's fields and `metadata['key']`.",
502
+ auth: 'service',
503
+ scope: 'payments:read',
504
+ query: params_1.searchQuery,
505
+ response: (0, envelopes_1.searchResultOf)(exports.invoiceSchema),
506
+ sdk: 'invoices.search',
507
+ expandable: 'invoice',
508
+ }),
509
+ ];