@fantastic.dev/better-stripe 0.113.0 → 0.119.2

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 (1144) hide show
  1. package/CHANGELOG.md +94 -0
  2. package/MIGRATION.md +50 -4
  3. package/README.md +69 -2
  4. package/dist/client/billing/renewalAggregate/phases.d.ts.map +1 -1
  5. package/dist/client/billing/renewalAggregate/phases.js +27 -13
  6. package/dist/client/billing/renewalAggregate/phases.js.map +1 -1
  7. package/dist/client/billing/renewalAggregate/preflight.d.ts +1 -0
  8. package/dist/client/billing/renewalAggregate/preflight.d.ts.map +1 -1
  9. package/dist/client/billing/renewalAggregate/readMaterial.d.ts +2 -1
  10. package/dist/client/billing/renewalAggregate/readMaterial.d.ts.map +1 -1
  11. package/dist/client/billing/renewalAggregate/readMaterial.js +28 -5
  12. package/dist/client/billing/renewalAggregate/readMaterial.js.map +1 -1
  13. package/dist/client/billing/renewalAggregate/sourceDiscounts.d.ts +1 -1
  14. package/dist/client/billing/renewalAggregate/sourceDiscounts.d.ts.map +1 -1
  15. package/dist/client/billing/renewalAggregate/sourceDiscounts.js +2 -2
  16. package/dist/client/billing/renewalAggregate/sourceDiscounts.js.map +1 -1
  17. package/dist/client/billing/renewalAttach/attachmentProfile.d.ts +13 -0
  18. package/dist/client/billing/renewalAttach/attachmentProfile.d.ts.map +1 -0
  19. package/dist/client/billing/renewalAttach/attachmentProfile.js +15 -0
  20. package/dist/client/billing/renewalAttach/attachmentProfile.js.map +1 -0
  21. package/dist/client/billing/renewalAttach/internal/c10/eventCapture.js +1 -1
  22. package/dist/client/billing/renewalAttach/internal/c10/eventCapture.js.map +1 -1
  23. package/dist/client/billing/renewalAttach/internal/material/classifiers.d.ts +1 -1
  24. package/dist/client/billing/renewalAttach/internal/material/classifiers.d.ts.map +1 -1
  25. package/dist/client/billing/renewalAttach/internal/material/classifiers.js +11 -10
  26. package/dist/client/billing/renewalAttach/internal/material/classifiers.js.map +1 -1
  27. package/dist/client/billing/renewalAttach/internal/material/readMaterial.d.ts +1 -1
  28. package/dist/client/billing/renewalAttach/internal/material/readMaterial.d.ts.map +1 -1
  29. package/dist/client/billing/renewalAttach/internal/material/readMaterial.js +20 -5
  30. package/dist/client/billing/renewalAttach/internal/material/readMaterial.js.map +1 -1
  31. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.d.ts.map +1 -1
  32. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js +7 -7
  33. package/dist/client/billing/renewalAttach/internal/operations/configureReadTransport.js.map +1 -1
  34. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.d.ts.map +1 -1
  35. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js +5 -3
  36. package/dist/client/billing/renewalAttach/internal/operations/initialAttach.js.map +1 -1
  37. package/dist/client/billing/renewalAttach/internal/preflight/grammar.js +1 -1
  38. package/dist/client/billing/renewalAttach/internal/preflight/grammar.js.map +1 -1
  39. package/dist/client/billing/renewalAttach/internal/producer/attachAcknowledgement.d.ts.map +1 -1
  40. package/dist/client/billing/renewalAttach/internal/producer/attachAcknowledgement.js +4 -4
  41. package/dist/client/billing/renewalAttach/internal/producer/attachAcknowledgement.js.map +1 -1
  42. package/dist/client/billing/renewalAttach/internal/producer/configureWriteFactory.d.ts.map +1 -1
  43. package/dist/client/billing/renewalAttach/internal/producer/configureWriteFactory.js +7 -6
  44. package/dist/client/billing/renewalAttach/internal/producer/configureWriteFactory.js.map +1 -1
  45. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts +3 -0
  46. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.d.ts.map +1 -1
  47. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js +16 -1
  48. package/dist/client/billing/renewalAttach/internal/producer/invocationProducer.js.map +1 -1
  49. package/dist/client/billing/renewalAttach/internal/producer/nodeAttachmentProfile.d.ts +9 -0
  50. package/dist/client/billing/renewalAttach/internal/producer/nodeAttachmentProfile.d.ts.map +1 -0
  51. package/dist/client/billing/renewalAttach/internal/producer/nodeAttachmentProfile.js +83 -0
  52. package/dist/client/billing/renewalAttach/internal/producer/nodeAttachmentProfile.js.map +1 -0
  53. package/dist/client/billing/renewalAttach/liveAttachment.d.ts +12 -0
  54. package/dist/client/billing/renewalAttach/liveAttachment.d.ts.map +1 -0
  55. package/dist/client/billing/renewalAttach/liveAttachment.js +23 -0
  56. package/dist/client/billing/renewalAttach/liveAttachment.js.map +1 -0
  57. package/dist/client/billing/renewalAttach/nodeAttachment.d.ts +4 -0
  58. package/dist/client/billing/renewalAttach/nodeAttachment.d.ts.map +1 -0
  59. package/dist/client/billing/renewalAttach/nodeAttachment.js +154 -0
  60. package/dist/client/billing/renewalAttach/nodeAttachment.js.map +1 -0
  61. package/dist/client/billing/renewalAttach/nodeConfiguration.d.ts +3 -0
  62. package/dist/client/billing/renewalAttach/nodeConfiguration.d.ts.map +1 -0
  63. package/dist/client/billing/renewalAttach/nodeConfiguration.js +126 -0
  64. package/dist/client/billing/renewalAttach/nodeConfiguration.js.map +1 -0
  65. package/dist/client/billing/renewalV2/configureInput.d.ts +1 -0
  66. package/dist/client/billing/renewalV2/configureInput.d.ts.map +1 -1
  67. package/dist/client/billing/renewalV2/configureInput.js +2 -1
  68. package/dist/client/billing/renewalV2/configureInput.js.map +1 -1
  69. package/dist/client/billing/renewalV2/index.d.ts +3 -0
  70. package/dist/client/billing/renewalV2/index.d.ts.map +1 -1
  71. package/dist/client/billing/renewalV2/index.js +1 -1
  72. package/dist/client/billing/renewalV2/index.js.map +1 -1
  73. package/dist/client/billing/renewalV2/observationInput.d.ts +1 -0
  74. package/dist/client/billing/renewalV2/observationInput.d.ts.map +1 -1
  75. package/dist/client/index.d.ts +7 -14
  76. package/dist/client/index.d.ts.map +1 -1
  77. package/dist/client/index.js +10 -2
  78. package/dist/client/index.js.map +1 -1
  79. package/dist/client/node.d.ts +2 -0
  80. package/dist/client/node.d.ts.map +1 -0
  81. package/dist/client/node.js +9 -0
  82. package/dist/client/node.js.map +1 -0
  83. package/dist/client/renewal.d.ts +4 -0
  84. package/dist/client/renewal.d.ts.map +1 -1
  85. package/dist/client/renewal.js +2 -1
  86. package/dist/client/renewal.js.map +1 -1
  87. package/dist/client/renewalAttachmentPreparation.d.ts +23 -0
  88. package/dist/client/renewalAttachmentPreparation.d.ts.map +1 -0
  89. package/dist/client/renewalAttachmentPreparation.js +89 -0
  90. package/dist/client/renewalAttachmentPreparation.js.map +1 -0
  91. package/dist/client/renewalAttachmentRuntime.d.ts +6 -0
  92. package/dist/client/renewalAttachmentRuntime.d.ts.map +1 -0
  93. package/dist/client/renewalAttachmentRuntime.js +13 -0
  94. package/dist/client/renewalAttachmentRuntime.js.map +1 -0
  95. package/dist/client/renewalAttachmentTypes.d.ts +45 -0
  96. package/dist/client/renewalAttachmentTypes.d.ts.map +1 -0
  97. package/dist/client/renewalAttachmentTypes.js +2 -0
  98. package/dist/client/renewalAttachmentTypes.js.map +1 -0
  99. package/dist/client/renewalConfigurationPreparation.d.ts +27 -0
  100. package/dist/client/renewalConfigurationPreparation.d.ts.map +1 -0
  101. package/dist/client/renewalConfigurationPreparation.js +78 -0
  102. package/dist/client/renewalConfigurationPreparation.js.map +1 -0
  103. package/dist/client/renewalConfigurationRuntime.d.ts +6 -0
  104. package/dist/client/renewalConfigurationRuntime.d.ts.map +1 -0
  105. package/dist/client/renewalConfigurationRuntime.js +12 -0
  106. package/dist/client/renewalConfigurationRuntime.js.map +1 -0
  107. package/dist/client/renewalConfigurationTypes.d.ts +19 -0
  108. package/dist/client/renewalConfigurationTypes.d.ts.map +1 -0
  109. package/dist/client/renewalConfigurationTypes.js +2 -0
  110. package/dist/client/renewalConfigurationTypes.js.map +1 -0
  111. package/dist/client/renewalContextClient.d.ts +5 -0
  112. package/dist/client/renewalContextClient.d.ts.map +1 -1
  113. package/dist/client/renewalContextClient.js +9 -0
  114. package/dist/client/renewalContextClient.js.map +1 -1
  115. package/dist/client/types/documents.d.ts +2 -0
  116. package/dist/client/types/documents.d.ts.map +1 -1
  117. package/dist/client/webhooks/helpers.d.ts.map +1 -1
  118. package/dist/client/webhooks/helpers.js +1 -0
  119. package/dist/client/webhooks/helpers.js.map +1 -1
  120. package/dist/client/webhooks/ledger.d.ts +31 -0
  121. package/dist/client/webhooks/ledger.d.ts.map +1 -0
  122. package/dist/client/webhooks/ledger.js +13 -0
  123. package/dist/client/webhooks/ledger.js.map +1 -0
  124. package/dist/client/webhooks/processors.d.ts.map +1 -1
  125. package/dist/client/webhooks/processors.js +6 -3
  126. package/dist/client/webhooks/processors.js.map +1 -1
  127. package/dist/client/webhooks/subscriptionDeleted.d.ts.map +1 -1
  128. package/dist/client/webhooks/subscriptionDeleted.js +3 -2
  129. package/dist/client/webhooks/subscriptionDeleted.js.map +1 -1
  130. package/dist/component/_generated/api.d.ts +2 -0
  131. package/dist/component/_generated/api.d.ts.map +1 -1
  132. package/dist/component/_generated/api.js.map +1 -1
  133. package/dist/component/_generated/component.d.ts +18 -1
  134. package/dist/component/_generated/component.d.ts.map +1 -1
  135. package/dist/component/balanceFunding/internal/actions.d.ts +11 -11
  136. package/dist/component/balanceFunding/preparationHandlers.d.ts +8 -8
  137. package/dist/component/billing/mutations.d.ts +2 -1
  138. package/dist/component/billing/mutations.d.ts.map +1 -1
  139. package/dist/component/billing/mutations.js +28 -3
  140. package/dist/component/billing/mutations.js.map +1 -1
  141. package/dist/component/billing/queries.d.ts +8 -0
  142. package/dist/component/billing/queries.d.ts.map +1 -1
  143. package/dist/component/billing/schema.d.ts +3 -1
  144. package/dist/component/billing/schema.d.ts.map +1 -1
  145. package/dist/component/billing/validators.d.ts +16 -1
  146. package/dist/component/billing/validators.d.ts.map +1 -1
  147. package/dist/component/billing/validators.js +8 -0
  148. package/dist/component/billing/validators.js.map +1 -1
  149. package/dist/component/billingHistory/queries.d.ts +1 -0
  150. package/dist/component/billingHistory/queries.d.ts.map +1 -1
  151. package/dist/component/core/mutations.d.ts +4 -0
  152. package/dist/component/core/mutations.d.ts.map +1 -1
  153. package/dist/component/core/mutations.js +6 -0
  154. package/dist/component/core/mutations.js.map +1 -1
  155. package/dist/component/core/stripeMode.d.ts +8 -0
  156. package/dist/component/core/stripeMode.d.ts.map +1 -0
  157. package/dist/component/core/stripeMode.js +23 -0
  158. package/dist/component/core/stripeMode.js.map +1 -0
  159. package/dist/component/earnings/triggers.d.ts +6 -4
  160. package/dist/component/earnings/triggers.d.ts.map +1 -1
  161. package/dist/component/financialObservations/settlementHelpers.d.ts +3 -3
  162. package/dist/component/payoutRelease/queries.d.ts +2 -2
  163. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  164. package/dist/component/processingCostReconciliation/rollback.d.ts +1 -1
  165. package/dist/component/schema.d.ts +4 -2
  166. package/dist/component/webhooks/mutations.d.ts +19 -0
  167. package/dist/component/webhooks/mutations.d.ts.map +1 -1
  168. package/dist/component/webhooks/mutations.js +56 -0
  169. package/dist/component/webhooks/mutations.js.map +1 -1
  170. package/dist/component/webhooks/schema.d.ts +1 -1
  171. package/dist/component/webhooks/schema.d.ts.map +1 -1
  172. package/dist/component/webhooks/schema.js +2 -1
  173. package/dist/component/webhooks/schema.js.map +1 -1
  174. package/docs/README.md +43 -8
  175. package/docs/billing-history.md +1 -1
  176. package/docs/client-api.md +63 -10
  177. package/docs/evidence/native-metering/mixed-settlement-2026-10-20.json +1 -1
  178. package/docs/evidence/native-metering/product-flows-2026-10-19.json +1 -1
  179. package/docs/example-routing.md +93 -0
  180. package/docs/pull-request-standard.md +142 -0
  181. package/docs/react-workflows-audit.md +1 -2
  182. package/docs/read-contracts.md +6 -5
  183. package/docs/releasing.md +30 -2
  184. package/docs/renewal-attachment.md +176 -0
  185. package/docs/renewal-configuration.md +127 -0
  186. package/docs/renewal-context-reads.md +9 -5
  187. package/docs/settlement.md +2 -1
  188. package/docs/stripe-sandbox-worktrees.md +245 -0
  189. package/docs/webhooks.md +110 -1
  190. package/docs/worktrees.md +134 -0
  191. package/package.json +14 -2
  192. package/src/client/billing/renewalAggregate/phases.ts +31 -13
  193. package/src/client/billing/renewalAggregate/readMaterial.ts +36 -2
  194. package/src/client/billing/renewalAggregate/sourceDiscounts.ts +3 -1
  195. package/src/client/billing/renewalAttach/attachmentProfile.ts +22 -0
  196. package/src/client/billing/renewalAttach/internal/c10/eventCapture.ts +1 -1
  197. package/src/client/billing/renewalAttach/internal/material/classifiers.ts +26 -7
  198. package/src/client/billing/renewalAttach/internal/material/readMaterial.ts +26 -2
  199. package/src/client/billing/renewalAttach/internal/operations/configureReadTransport.ts +10 -9
  200. package/src/client/billing/renewalAttach/internal/operations/initialAttach.ts +5 -3
  201. package/src/client/billing/renewalAttach/internal/preflight/grammar.ts +1 -1
  202. package/src/client/billing/renewalAttach/internal/producer/attachAcknowledgement.ts +4 -6
  203. package/src/client/billing/renewalAttach/internal/producer/configureWriteFactory.ts +10 -8
  204. package/src/client/billing/renewalAttach/internal/producer/invocationProducer.ts +28 -1
  205. package/src/client/billing/renewalAttach/internal/producer/nodeAttachmentProfile.ts +108 -0
  206. package/src/client/billing/renewalAttach/liveAttachment.ts +43 -0
  207. package/src/client/billing/renewalAttach/nodeAttachment.ts +181 -0
  208. package/src/client/billing/renewalAttach/nodeConfiguration.ts +147 -0
  209. package/src/client/billing/renewalV2/configureInput.ts +2 -1
  210. package/src/client/billing/renewalV2/index.ts +7 -1
  211. package/src/client/index.ts +13 -15
  212. package/src/client/node.ts +8 -0
  213. package/src/client/renewal.ts +17 -0
  214. package/src/client/renewalAttachmentPreparation.ts +118 -0
  215. package/src/client/renewalAttachmentRuntime.ts +25 -0
  216. package/src/client/renewalAttachmentTypes.ts +51 -0
  217. package/src/client/renewalConfigurationPreparation.ts +92 -0
  218. package/src/client/renewalConfigurationRuntime.ts +24 -0
  219. package/src/client/renewalConfigurationTypes.ts +30 -0
  220. package/src/client/renewalContextClient.ts +22 -0
  221. package/src/client/types/documents.ts +2 -0
  222. package/src/client/webhooks/helpers.ts +1 -0
  223. package/src/client/webhooks/ledger.ts +48 -0
  224. package/src/client/webhooks/processors.ts +5 -0
  225. package/src/client/webhooks/subscriptionDeleted.ts +3 -2
  226. package/src/component/_generated/api.ts +2 -0
  227. package/src/component/_generated/component.ts +18 -1
  228. package/src/component/billing/mutations.ts +35 -2
  229. package/src/component/billing/validators.ts +12 -0
  230. package/src/component/core/mutations.ts +6 -0
  231. package/src/component/core/stripeMode.ts +30 -0
  232. package/src/component/webhooks/mutations.ts +66 -0
  233. package/src/component/webhooks/schema.ts +2 -1
  234. package/dist/client/billing/renewalAttach/internal/acquisition/array-order.test.d.ts +0 -2
  235. package/dist/client/billing/renewalAttach/internal/acquisition/array-order.test.d.ts.map +0 -1
  236. package/dist/client/billing/renewalAttach/internal/acquisition/array-order.test.js +0 -61
  237. package/dist/client/billing/renewalAttach/internal/acquisition/array-order.test.js.map +0 -1
  238. package/dist/client/billing/renewalAttach/internal/acquisition/coupon-stop-order.test.d.ts +0 -2
  239. package/dist/client/billing/renewalAttach/internal/acquisition/coupon-stop-order.test.d.ts.map +0 -1
  240. package/dist/client/billing/renewalAttach/internal/acquisition/coupon-stop-order.test.js +0 -18
  241. package/dist/client/billing/renewalAttach/internal/acquisition/coupon-stop-order.test.js.map +0 -1
  242. package/dist/client/billing/renewalAttach/internal/acquisition/fetch-metadata.test.d.ts +0 -2
  243. package/dist/client/billing/renewalAttach/internal/acquisition/fetch-metadata.test.d.ts.map +0 -1
  244. package/dist/client/billing/renewalAttach/internal/acquisition/fetch-metadata.test.js +0 -67
  245. package/dist/client/billing/renewalAttach/internal/acquisition/fetch-metadata.test.js.map +0 -1
  246. package/dist/client/billing/renewalAttach/internal/acquisition/raw-acquisition.test.d.ts +0 -2
  247. package/dist/client/billing/renewalAttach/internal/acquisition/raw-acquisition.test.d.ts.map +0 -1
  248. package/dist/client/billing/renewalAttach/internal/acquisition/raw-acquisition.test.js +0 -372
  249. package/dist/client/billing/renewalAttach/internal/acquisition/raw-acquisition.test.js.map +0 -1
  250. package/dist/client/billing/renewalAttach/internal/acquisition/sourceBinding.test.d.ts +0 -2
  251. package/dist/client/billing/renewalAttach/internal/acquisition/sourceBinding.test.d.ts.map +0 -1
  252. package/dist/client/billing/renewalAttach/internal/acquisition/sourceBinding.test.js +0 -126
  253. package/dist/client/billing/renewalAttach/internal/acquisition/sourceBinding.test.js.map +0 -1
  254. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/fixture.d.mts +0 -627
  255. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/fixture.d.mts.map +0 -1
  256. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/fixture.mjs +0 -488
  257. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/fixture.mjs.map +0 -1
  258. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/raw-retention-fixture.d.mts +0 -214
  259. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/raw-retention-fixture.d.mts.map +0 -1
  260. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/raw-retention-fixture.mjs +0 -63
  261. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/raw-retention-fixture.mjs.map +0 -1
  262. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/scenario.d.mts +0 -75
  263. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/scenario.d.mts.map +0 -1
  264. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/scenario.mjs +0 -145
  265. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/scenario.mjs.map +0 -1
  266. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.d.mts +0 -7
  267. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.d.mts.map +0 -1
  268. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.mjs +0 -26
  269. package/dist/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.mjs.map +0 -1
  270. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/compilerIndex.d.mts +0 -3
  271. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/compilerIndex.d.mts.map +0 -1
  272. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/compilerIndex.mjs +0 -4
  273. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/compilerIndex.mjs.map +0 -1
  274. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/fixture.d.mts +0 -26
  275. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/fixture.d.mts.map +0 -1
  276. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/fixture.mjs +0 -42
  277. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/fixture.mjs.map +0 -1
  278. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f00.d.mts +0 -7
  279. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f00.d.mts.map +0 -1
  280. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f00.mjs +0 -60
  281. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f00.mjs.map +0 -1
  282. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f01.d.mts +0 -335
  283. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f01.d.mts.map +0 -1
  284. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f01.mjs +0 -122
  285. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f01.mjs.map +0 -1
  286. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f02.d.mts +0 -46
  287. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f02.d.mts.map +0 -1
  288. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f02.mjs +0 -87
  289. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f02.mjs.map +0 -1
  290. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f03.d.mts +0 -35
  291. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f03.d.mts.map +0 -1
  292. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f03.mjs +0 -90
  293. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f03.mjs.map +0 -1
  294. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f04.d.mts +0 -132
  295. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f04.d.mts.map +0 -1
  296. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f04.mjs +0 -82
  297. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f04.mjs.map +0 -1
  298. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f05.d.mts +0 -4
  299. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f05.d.mts.map +0 -1
  300. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f05.mjs +0 -23
  301. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f05.mjs.map +0 -1
  302. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f06.d.mts +0 -16
  303. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f06.d.mts.map +0 -1
  304. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f06.mjs +0 -41
  305. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f06.mjs.map +0 -1
  306. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f07.d.mts +0 -43
  307. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f07.d.mts.map +0 -1
  308. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f07.mjs +0 -132
  309. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f07.mjs.map +0 -1
  310. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f08.d.mts +0 -200
  311. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f08.d.mts.map +0 -1
  312. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f08.mjs +0 -150
  313. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f08.mjs.map +0 -1
  314. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f09.d.mts +0 -124
  315. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f09.d.mts.map +0 -1
  316. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f09.mjs +0 -127
  317. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f09.mjs.map +0 -1
  318. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f10.d.mts +0 -3
  319. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f10.d.mts.map +0 -1
  320. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f10.mjs +0 -69
  321. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f10.mjs.map +0 -1
  322. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f11.d.mts +0 -2
  323. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f11.d.mts.map +0 -1
  324. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f11.mjs +0 -152
  325. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f11.mjs.map +0 -1
  326. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f12.d.mts +0 -2
  327. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f12.d.mts.map +0 -1
  328. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f12.mjs +0 -2
  329. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f12.mjs.map +0 -1
  330. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f13.d.mts +0 -5
  331. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f13.d.mts.map +0 -1
  332. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f13.mjs +0 -243
  333. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f13.mjs.map +0 -1
  334. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f14.d.mts +0 -17
  335. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f14.d.mts.map +0 -1
  336. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f14.mjs +0 -75
  337. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f14.mjs.map +0 -1
  338. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f15.d.mts +0 -2
  339. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f15.d.mts.map +0 -1
  340. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f15.mjs +0 -173
  341. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f15.mjs.map +0 -1
  342. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f16.d.mts +0 -4
  343. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f16.d.mts.map +0 -1
  344. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f16.mjs +0 -4
  345. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f16.mjs.map +0 -1
  346. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f17.d.mts +0 -7
  347. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f17.d.mts.map +0 -1
  348. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f17.mjs +0 -30
  349. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f17.mjs.map +0 -1
  350. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f18.d.mts +0 -29
  351. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f18.d.mts.map +0 -1
  352. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f18.mjs +0 -33
  353. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f18.mjs.map +0 -1
  354. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f19.json +0 -452
  355. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f20.d.mts +0 -2
  356. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f20.d.mts.map +0 -1
  357. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f20.mjs +0 -173
  358. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f20.mjs.map +0 -1
  359. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f21.d.mts +0 -2
  360. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f21.d.mts.map +0 -1
  361. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f21.mjs +0 -449
  362. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f21.mjs.map +0 -1
  363. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f22.d.mts +0 -9
  364. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f22.d.mts.map +0 -1
  365. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f22.mjs +0 -27
  366. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f22.mjs.map +0 -1
  367. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f23.d.mts +0 -7
  368. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f23.d.mts.map +0 -1
  369. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f23.mjs +0 -150
  370. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f23.mjs.map +0 -1
  371. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f24.d.mts +0 -3
  372. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f24.d.mts.map +0 -1
  373. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f24.mjs +0 -503
  374. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f24.mjs.map +0 -1
  375. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f25.d.mts +0 -2
  376. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f25.d.mts.map +0 -1
  377. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f25.mjs +0 -91
  378. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f25.mjs.map +0 -1
  379. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f26.d.mts +0 -14
  380. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f26.d.mts.map +0 -1
  381. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f26.mjs +0 -41
  382. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f26.mjs.map +0 -1
  383. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f27.d.mts +0 -103
  384. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f27.d.mts.map +0 -1
  385. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f27.mjs +0 -46
  386. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f27.mjs.map +0 -1
  387. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f28.d.mts +0 -73
  388. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f28.d.mts.map +0 -1
  389. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f28.mjs +0 -294
  390. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f28.mjs.map +0 -1
  391. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f29.d.mts +0 -2
  392. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f29.d.mts.map +0 -1
  393. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f29.mjs +0 -60
  394. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f29.mjs.map +0 -1
  395. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/publishedRawkeyHelper.d.mts +0 -58
  396. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/publishedRawkeyHelper.d.mts.map +0 -1
  397. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/publishedRawkeyHelper.mjs +0 -96
  398. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/publishedRawkeyHelper.mjs.map +0 -1
  399. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/semanticSetup.d.ts +0 -2
  400. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/semanticSetup.d.ts.map +0 -1
  401. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/semanticSetup.js +0 -40
  402. package/dist/client/billing/renewalAttach/internal/c10/test-fixtures/semanticSetup.js.map +0 -1
  403. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +0 -10349
  404. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +0 -1
  405. package/dist/client/connect/payoutAdoptionTestHelpers.js +0 -242
  406. package/dist/client/connect/payoutAdoptionTestHelpers.js.map +0 -1
  407. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +0 -5166
  408. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +0 -1
  409. package/dist/client/connect/payoutExecutionTestHelpers.js +0 -208
  410. package/dist/client/connect/payoutExecutionTestHelpers.js.map +0 -1
  411. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +0 -10341
  412. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +0 -1
  413. package/dist/client/connect/payoutLargeAdoptionTestHelpers.js +0 -55
  414. package/dist/client/connect/payoutLargeAdoptionTestHelpers.js.map +0 -1
  415. package/dist/client/connect/payoutSyncTestHelpers.d.ts +0 -5098
  416. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +0 -1
  417. package/dist/client/connect/payoutSyncTestHelpers.js +0 -62
  418. package/dist/client/connect/payoutSyncTestHelpers.js.map +0 -1
  419. package/dist/client/paymentSource/resolver.fixtures.d.ts +0 -220
  420. package/dist/client/paymentSource/resolver.fixtures.d.ts.map +0 -1
  421. package/dist/client/paymentSource/resolver.fixtures.js +0 -189
  422. package/dist/client/paymentSource/resolver.fixtures.js.map +0 -1
  423. package/dist/client/recoveryWorkflow/provider.fixture.d.ts +0 -21
  424. package/dist/client/recoveryWorkflow/provider.fixture.d.ts.map +0 -1
  425. package/dist/client/recoveryWorkflow/provider.fixture.js +0 -125
  426. package/dist/client/recoveryWorkflow/provider.fixture.js.map +0 -1
  427. package/dist/client/settlement/authorization.fixture.d.ts +0 -148
  428. package/dist/client/settlement/authorization.fixture.d.ts.map +0 -1
  429. package/dist/client/settlement/authorization.fixture.js +0 -178
  430. package/dist/client/settlement/authorization.fixture.js.map +0 -1
  431. package/dist/client/setup.test.d.ts +0 -18
  432. package/dist/client/setup.test.d.ts.map +0 -1
  433. package/dist/client/setup.test.js +0 -33
  434. package/dist/client/setup.test.js.map +0 -1
  435. package/dist/client/usage/correctionTransport.fixtures.d.ts +0 -37
  436. package/dist/client/usage/correctionTransport.fixtures.d.ts.map +0 -1
  437. package/dist/client/usage/correctionTransport.fixtures.js +0 -322
  438. package/dist/client/usage/correctionTransport.fixtures.js.map +0 -1
  439. package/dist/client/usage/creditSettlement.fixtures.d.ts +0 -216
  440. package/dist/client/usage/creditSettlement.fixtures.d.ts.map +0 -1
  441. package/dist/client/usage/creditSettlement.fixtures.js +0 -59
  442. package/dist/client/usage/creditSettlement.fixtures.js.map +0 -1
  443. package/dist/client/usage/creditTransport.fixtures.d.ts +0 -108
  444. package/dist/client/usage/creditTransport.fixtures.d.ts.map +0 -1
  445. package/dist/client/usage/creditTransport.fixtures.js +0 -293
  446. package/dist/client/usage/creditTransport.fixtures.js.map +0 -1
  447. package/dist/client/usage/invoiceSale.fixtures.d.ts +0 -285
  448. package/dist/client/usage/invoiceSale.fixtures.d.ts.map +0 -1
  449. package/dist/client/usage/invoiceSale.fixtures.js +0 -104
  450. package/dist/client/usage/invoiceSale.fixtures.js.map +0 -1
  451. package/dist/client/usage/mixedInvoice.fixtures.d.ts +0 -315
  452. package/dist/client/usage/mixedInvoice.fixtures.d.ts.map +0 -1
  453. package/dist/client/usage/mixedInvoice.fixtures.js +0 -55
  454. package/dist/client/usage/mixedInvoice.fixtures.js.map +0 -1
  455. package/dist/client/usage/subscription.fixtures.d.ts +0 -118
  456. package/dist/client/usage/subscription.fixtures.d.ts.map +0 -1
  457. package/dist/client/usage/subscription.fixtures.js +0 -84
  458. package/dist/client/usage/subscription.fixtures.js.map +0 -1
  459. package/dist/client/usage/subscriptionTransport.fixtures.d.ts +0 -25
  460. package/dist/client/usage/subscriptionTransport.fixtures.d.ts.map +0 -1
  461. package/dist/client/usage/subscriptionTransport.fixtures.js +0 -206
  462. package/dist/client/usage/subscriptionTransport.fixtures.js.map +0 -1
  463. package/dist/client/webhooks/payoutReconciliationTestHelpers.d.ts +0 -117
  464. package/dist/client/webhooks/payoutReconciliationTestHelpers.d.ts.map +0 -1
  465. package/dist/client/webhooks/payoutReconciliationTestHelpers.js +0 -105
  466. package/dist/client/webhooks/payoutReconciliationTestHelpers.js.map +0 -1
  467. package/dist/component/usage/allowance.fixtures.d.ts +0 -5088
  468. package/dist/component/usage/allowance.fixtures.d.ts.map +0 -1
  469. package/dist/component/usage/allowance.fixtures.js +0 -67
  470. package/dist/component/usage/allowance.fixtures.js.map +0 -1
  471. package/dist/component/usageCredits/accounting.fixtures.d.ts +0 -5111
  472. package/dist/component/usageCredits/accounting.fixtures.d.ts.map +0 -1
  473. package/dist/component/usageCredits/accounting.fixtures.js +0 -89
  474. package/dist/component/usageCredits/accounting.fixtures.js.map +0 -1
  475. package/dist/react/workflows/Usage.fixtures.d.ts +0 -17
  476. package/dist/react/workflows/Usage.fixtures.d.ts.map +0 -1
  477. package/dist/react/workflows/Usage.fixtures.js +0 -79
  478. package/dist/react/workflows/Usage.fixtures.js.map +0 -1
  479. package/dist/test.d.ts +0 -6
  480. package/dist/test.d.ts.map +0 -1
  481. package/dist/test.js +0 -15
  482. package/dist/test.js.map +0 -1
  483. package/dist/testing/component-db.d.ts +0 -3
  484. package/dist/testing/component-db.d.ts.map +0 -1
  485. package/dist/testing/component-db.js +0 -26
  486. package/dist/testing/component-db.js.map +0 -1
  487. package/src/client/balanceFundingWorkflow/capture.test.ts +0 -144
  488. package/src/client/billing/balanceFunding.test.ts +0 -257
  489. package/src/client/billing/balanceFundingTransport.test.ts +0 -89
  490. package/src/client/billing/captured-checkout-payment.test.ts +0 -272
  491. package/src/client/billing/checkout-idempotency.test.ts +0 -82
  492. package/src/client/billing/checkout-ui-modes.test.ts +0 -49
  493. package/src/client/billing/checkout.test.ts +0 -1282
  494. package/src/client/billing/checkoutPages.test.ts +0 -270
  495. package/src/client/billing/historyPages.test.ts +0 -58
  496. package/src/client/billing/intents.test.ts +0 -216
  497. package/src/client/billing/intentsTransport.test.ts +0 -94
  498. package/src/client/billing/invoicePages.test.ts +0 -174
  499. package/src/client/billing/invoicePaymentPages.test.ts +0 -354
  500. package/src/client/billing/invoicePaymentRead.test.ts +0 -233
  501. package/src/client/billing/invoicePaymentReadTransport.test.ts +0 -101
  502. package/src/client/billing/invoicePreview.test.ts +0 -123
  503. package/src/client/billing/invoicePreviewTransport.test.ts +0 -70
  504. package/src/client/billing/invoices.test.ts +0 -243
  505. package/src/client/billing/prepared-checkout.test.ts +0 -430
  506. package/src/client/billing/providerReads.test.ts +0 -60
  507. package/src/client/billing/renewal-discount-projection.test.ts +0 -207
  508. package/src/client/billing/renewal-item-settings-projection.test.ts +0 -79
  509. package/src/client/billing/renewal-price-replacement.test.ts +0 -503
  510. package/src/client/billing/renewal-settings-projection.test.ts +0 -300
  511. package/src/client/billing/renewalAggregate/configure.test.ts +0 -372
  512. package/src/client/billing/renewalAggregate/preflight.test.ts +0 -233
  513. package/src/client/billing/renewalAggregate/sourceAndTaxRetention.test.ts +0 -247
  514. package/src/client/billing/renewalAttach/couponEvidence.test.ts +0 -103
  515. package/src/client/billing/renewalAttach/internal/acquisition/array-order.test.js +0 -70
  516. package/src/client/billing/renewalAttach/internal/acquisition/coupon-stop-order.test.js +0 -23
  517. package/src/client/billing/renewalAttach/internal/acquisition/fetch-metadata.test.js +0 -77
  518. package/src/client/billing/renewalAttach/internal/acquisition/raw-acquisition.test.js +0 -418
  519. package/src/client/billing/renewalAttach/internal/acquisition/sourceBinding.test.js +0 -138
  520. package/src/client/billing/renewalAttach/internal/acquisition/test-fixtures/fixture.mjs +0 -510
  521. package/src/client/billing/renewalAttach/internal/acquisition/test-fixtures/raw-retention-fixture.mjs +0 -64
  522. package/src/client/billing/renewalAttach/internal/acquisition/test-fixtures/scenario.mjs +0 -159
  523. package/src/client/billing/renewalAttach/internal/acquisition/test-fixtures/sourcePort.mjs +0 -25
  524. package/src/client/billing/renewalAttach/internal/c10/appendAck.first.test.ts +0 -86
  525. package/src/client/billing/renewalAttach/internal/c10/appendCodec.test.ts +0 -186
  526. package/src/client/billing/renewalAttach/internal/c10/arrayOrder.test.ts +0 -47
  527. package/src/client/billing/renewalAttach/internal/c10/compiler.test.ts +0 -443
  528. package/src/client/billing/renewalAttach/internal/c10/hardening.test.ts +0 -175
  529. package/src/client/billing/renewalAttach/internal/c10/historicalClassifier.test.ts +0 -114
  530. package/src/client/billing/renewalAttach/internal/c10/ownerContinuations.test.ts +0 -283
  531. package/src/client/billing/renewalAttach/internal/c10/reflectionPrivacy.test.ts +0 -87
  532. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/compilerIndex.mjs +0 -3
  533. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/fixture.mjs +0 -49
  534. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f00.mjs +0 -63
  535. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f01.mjs +0 -160
  536. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f02.mjs +0 -88
  537. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f03.mjs +0 -102
  538. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f04.mjs +0 -82
  539. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f05.mjs +0 -20
  540. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f06.mjs +0 -41
  541. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f07.mjs +0 -137
  542. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f08.mjs +0 -153
  543. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f09.mjs +0 -127
  544. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f10.mjs +0 -85
  545. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f11.mjs +0 -170
  546. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f12.mjs +0 -6
  547. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f13.mjs +0 -295
  548. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f14.mjs +0 -78
  549. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f15.mjs +0 -177
  550. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f16.mjs +0 -8
  551. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f17.mjs +0 -34
  552. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f18.mjs +0 -32
  553. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f19.json +0 -452
  554. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f20.mjs +0 -177
  555. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f21.mjs +0 -466
  556. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f22.mjs +0 -29
  557. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f23.mjs +0 -165
  558. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f24.mjs +0 -507
  559. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f25.mjs +0 -89
  560. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f26.mjs +0 -38
  561. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f27.mjs +0 -45
  562. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f28.mjs +0 -309
  563. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/frozen/f29.mjs +0 -58
  564. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/publishedRawkeyHelper.mjs +0 -104
  565. package/src/client/billing/renewalAttach/internal/c10/test-fixtures/semanticSetup.ts +0 -43
  566. package/src/client/billing/renewalAttach/internal/configure/dispatch.integration.test.ts +0 -32
  567. package/src/client/billing/renewalAttach/internal/configure/limits.test.ts +0 -510
  568. package/src/client/billing/renewalAttach/internal/configure/order.integration.test.ts +0 -207
  569. package/src/client/billing/renewalAttach/internal/configure/ownership.integration.test.ts +0 -148
  570. package/src/client/billing/renewalAttach/internal/configure/replay.integration.test.ts +0 -173
  571. package/src/client/billing/renewalAttach/internal/configure/transport.integration.test.ts +0 -507
  572. package/src/client/billing/renewalAttach/internal/material/classifiers.test.ts +0 -510
  573. package/src/client/billing/renewalAttach/internal/observation/freshActor.integration.test.ts +0 -360
  574. package/src/client/billing/renewalAttach/internal/observation/freshActorControls.integration.test.ts +0 -442
  575. package/src/client/billing/renewalAttach/internal/observation/history.integration.test.ts +0 -79
  576. package/src/client/billing/renewalAttach/internal/observation/historyControls.integration.test.ts +0 -238
  577. package/src/client/billing/renewalAttach/internal/observation/invoiceActor.integration.test.ts +0 -142
  578. package/src/client/billing/renewalAttach/internal/observation/invoiceActorControls.integration.test.ts +0 -495
  579. package/src/client/billing/renewalAttach/internal/observation/observation.integration.test.ts +0 -220
  580. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACK.integration.test.ts +0 -36
  581. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKControls.integration.test.ts +0 -48
  582. package/src/client/billing/renewalAttach/internal/observation/observationConfigureACKLifecycle.integration.test.ts +0 -44
  583. package/src/client/billing/renewalAttach/internal/observation/observationConfiguredHistory.integration.test.ts +0 -34
  584. package/src/client/billing/renewalAttach/internal/observation/observationRetirement.integration.test.ts +0 -60
  585. package/src/client/billing/renewalAttach/internal/observation/reader.integration.test.ts +0 -93
  586. package/src/client/billing/renewalAttach/internal/observation/readerControls.integration.test.ts +0 -553
  587. package/src/client/billing/renewalAttach/internal/observation/witnessAcquisition.integration.test.ts +0 -348
  588. package/src/client/billing/renewalAttach/internal/observation/witnessActor.integration.test.ts +0 -204
  589. package/src/client/billing/renewalAttach/internal/observation/witnessCapabilities.integration.test.ts +0 -231
  590. package/src/client/billing/renewalAttach/internal/observation/witnessHistorical.integration.test.ts +0 -98
  591. package/src/client/billing/renewalAttach/internal/observation/witnessImmutable.integration.test.ts +0 -78
  592. package/src/client/billing/renewalAttach/internal/observation/witnessInvoice.integration.test.ts +0 -85
  593. package/src/client/billing/renewalAttach/internal/observation/witnessLifecycle.integration.test.ts +0 -264
  594. package/src/client/billing/renewalAttach/internal/observation/witnessProfile.integration.test.ts +0 -93
  595. package/src/client/billing/renewalAttach/internal/observation/witnessRPCControls.integration.test.ts +0 -256
  596. package/src/client/billing/renewalAttach/internal/operationJournal.acknowledgement.integration.test.ts +0 -500
  597. package/src/client/billing/renewalAttach/internal/operationJournal.c10.integration.test.ts +0 -560
  598. package/src/client/billing/renewalAttach/internal/operationJournal.controls.integration.test.ts +0 -356
  599. package/src/client/billing/renewalAttach/internal/operationJournal.integration.test.ts +0 -560
  600. package/src/client/billing/renewalAttach/internal/operationJournal.methods.integration.test.ts +0 -534
  601. package/src/client/billing/renewalAttach/internal/operations/defaultBindings.test.ts +0 -69
  602. package/src/client/billing/renewalAttach/internal/operations/initialAttach.integration.test.ts +0 -34
  603. package/src/client/billing/renewalAttach/internal/operations/providerFailure.integration.test.ts +0 -61
  604. package/src/client/billing/renewalAttach/internal/operations/transport.integration.test.ts +0 -116
  605. package/src/client/billing/renewalAttach/internal/originalOwner.test.ts +0 -258
  606. package/src/client/billing/renewalAttach/internal/preflight/configurePreflight.integration.test.ts +0 -285
  607. package/src/client/billing/renewalAttach/internal/preflight/configureReads.integration.test.ts +0 -139
  608. package/src/client/billing/renewalAttach/internal/preflight/owner.integration.test.ts +0 -82
  609. package/src/client/billing/renewalAttach/internal/preflight/preflight.integration.test.ts +0 -354
  610. package/src/client/billing/renewalAttach/internal/producer/producerAcknowledgement.integration.test.ts +0 -320
  611. package/src/client/billing/renewalAttach/internal/producer/producerAcknowledgementControls.integration.test.ts +0 -411
  612. package/src/client/billing/renewalAttach/internal/producer/producerAcquisition.integration.test.ts +0 -240
  613. package/src/client/billing/renewalAttach/internal/producer/producerActor.integration.test.ts +0 -526
  614. package/src/client/billing/renewalAttach/internal/producer/producerChannels.integration.test.ts +0 -350
  615. package/src/client/billing/renewalAttach/internal/producer/producerClock.integration.test.ts +0 -175
  616. package/src/client/billing/renewalAttach/internal/producer/producerConfigureAdmission.integration.test.ts +0 -203
  617. package/src/client/billing/renewalAttach/internal/producer/producerConfigureChannelControls.integration.test.ts +0 -542
  618. package/src/client/billing/renewalAttach/internal/producer/producerConfigureChannels.integration.test.ts +0 -321
  619. package/src/client/billing/renewalAttach/internal/producer/producerConfigureControls.integration.test.ts +0 -566
  620. package/src/client/billing/renewalAttach/internal/producer/producerConfigurePreflight.integration.test.ts +0 -67
  621. package/src/client/billing/renewalAttach/internal/producer/producerConfigurePreflightControls.integration.test.ts +0 -475
  622. package/src/client/billing/renewalAttach/internal/producer/producerConfigureRecovery.integration.test.ts +0 -99
  623. package/src/client/billing/renewalAttach/internal/producer/producerConfigureRecoveryControls.integration.test.ts +0 -420
  624. package/src/client/billing/renewalAttach/internal/producer/producerConfigureWrite.integration.test.ts +0 -158
  625. package/src/client/billing/renewalAttach/internal/producer/producerConfigureWriteControls.integration.test.ts +0 -549
  626. package/src/client/billing/renewalAttach/internal/producer/producerGuards.integration.test.ts +0 -323
  627. package/src/client/billing/renewalAttach/internal/producer/producerInitial.integration.test.ts +0 -301
  628. package/src/client/billing/renewalAttach/internal/producer/producerIsolation.integration.test.ts +0 -531
  629. package/src/client/billing/renewalAttach/internal/producer/producerMaterial.integration.test.ts +0 -251
  630. package/src/client/billing/renewalAttach/internal/producer/producerOwner.integration.test.ts +0 -449
  631. package/src/client/billing/renewalAttach/internal/producer/producerRecovery.integration.test.ts +0 -394
  632. package/src/client/billing/renewalAttach/internal/producer/producerRecoveryControls.integration.test.ts +0 -437
  633. package/src/client/billing/renewalAttach/internal/producer/producerRecoveryIsolation.integration.test.ts +0 -332
  634. package/src/client/billing/renewalAttach/internal/producer/producerTransport.integration.test.ts +0 -440
  635. package/src/client/billing/renewalAttach/internal/recovery/recovery.integration.test.ts +0 -463
  636. package/src/client/billing/renewalAttach/internal/sourceBindings.test.ts +0 -13
  637. package/src/client/billing/renewalAttach/internal/stockRawDelegate.test.ts +0 -156
  638. package/src/client/billing/renewalAttach/internal/test-fixtures/attachEntries.ts +0 -217
  639. package/src/client/billing/renewalAttach/internal/test-fixtures/attachObservations.ts +0 -226
  640. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenario.ts +0 -556
  641. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioAssertions.ts +0 -180
  642. package/src/client/billing/renewalAttach/internal/test-fixtures/attachScenarioBarriers.ts +0 -144
  643. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightAssertions.ts +0 -122
  644. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightBarriers.ts +0 -330
  645. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightControls.ts +0 -139
  646. package/src/client/billing/renewalAttach/internal/test-fixtures/configurePreflightOperation.ts +0 -513
  647. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadNativeBaseline.ts +0 -344
  648. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadOperation.ts +0 -278
  649. package/src/client/billing/renewalAttach/internal/test-fixtures/configureReadPort.ts +0 -17
  650. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteAssertions.ts +0 -537
  651. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteBarriers.ts +0 -125
  652. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDeclarations.ts +0 -325
  653. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteDelegate.ts +0 -38
  654. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteHistory.ts +0 -471
  655. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteObservations.ts +0 -515
  656. package/src/client/billing/renewalAttach/internal/test-fixtures/configureWriteOperation.ts +0 -587
  657. package/src/client/billing/renewalAttach/internal/test-fixtures/freshObservation.ts +0 -94
  658. package/src/client/billing/renewalAttach/internal/test-fixtures/historySnapshot.ts +0 -51
  659. package/src/client/billing/renewalAttach/internal/test-fixtures/invoiceObservation.ts +0 -160
  660. package/src/client/billing/renewalAttach/internal/test-fixtures/observationAssertions.ts +0 -211
  661. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKAssertions.ts +0 -115
  662. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKDeclarations.ts +0 -141
  663. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleAssertions.ts +0 -74
  664. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleDeclarations.ts +0 -79
  665. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleInstrumentation.ts +0 -207
  666. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKLifecycleOperation.ts +0 -494
  667. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfigureACKOperation.ts +0 -452
  668. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryAssertions.ts +0 -88
  669. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryDeclarations.ts +0 -170
  670. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryNative.ts +0 -99
  671. package/src/client/billing/renewalAttach/internal/test-fixtures/observationConfiguredHistoryOperation.ts +0 -411
  672. package/src/client/billing/renewalAttach/internal/test-fixtures/observationDeclarations.ts +0 -192
  673. package/src/client/billing/renewalAttach/internal/test-fixtures/observationHTTP.ts +0 -197
  674. package/src/client/billing/renewalAttach/internal/test-fixtures/observationObservations.ts +0 -269
  675. package/src/client/billing/renewalAttach/internal/test-fixtures/observationOperation.ts +0 -262
  676. package/src/client/billing/renewalAttach/internal/test-fixtures/observationProbe.ts +0 -319
  677. package/src/client/billing/renewalAttach/internal/test-fixtures/observationReader.ts +0 -101
  678. package/src/client/billing/renewalAttach/internal/test-fixtures/ownedOperations.ts +0 -94
  679. package/src/client/billing/renewalAttach/internal/test-fixtures/producerConfigureAdmission.ts +0 -538
  680. package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialDeclarations.ts +0 -5
  681. package/src/client/billing/renewalAttach/internal/test-fixtures/producerInitialOperation.ts +0 -335
  682. package/src/client/billing/renewalAttach/internal/test-fixtures/sourceOperationPort.ts +0 -16
  683. package/src/client/billing/renewalAttach/internal/test-fixtures/stockHttp.ts +0 -21
  684. package/src/client/billing/renewalAttach/internal/test-fixtures/witnessHistory.ts +0 -70
  685. package/src/client/billing/renewalAttach/internal/test-fixtures/witnessObservation.ts +0 -353
  686. package/src/client/billing/renewalAttach/reader.test.ts +0 -409
  687. package/src/client/billing/renewalAttach/wireJson.test.ts +0 -265
  688. package/src/client/billing/renewalObservation/evidence-admission.test.ts +0 -219
  689. package/src/client/billing/renewalObservation/evidence-history.test.ts +0 -187
  690. package/src/client/billing/renewalObservation/evidence-invoice-controls.test.ts +0 -293
  691. package/src/client/billing/renewalObservation/evidence-invoice-identity.test.ts +0 -61
  692. package/src/client/billing/renewalObservation/evidence-invoice.test.ts +0 -177
  693. package/src/client/billing/renewalObservation/evidence-material.test.ts +0 -289
  694. package/src/client/billing/renewalObservation/evidence-v1.test.ts +0 -371
  695. package/src/client/billing/renewalV2/configure.test.ts +0 -362
  696. package/src/client/billing/renewalV2/configureReceipt.test.ts +0 -558
  697. package/src/client/billing/renewalV2/index.test.ts +0 -414
  698. package/src/client/billing/renewalV2/observation.boundary-review.test.ts +0 -49
  699. package/src/client/billing/renewalV2/observation.test.ts +0 -334
  700. package/src/client/billing/renewalV2/rawRetention.test.ts +0 -293
  701. package/src/client/billing/renewalV2/receipt.test.ts +0 -289
  702. package/src/client/billing/setup-intent-read.test.ts +0 -324
  703. package/src/client/billing/subscription-payment-method.test.ts +0 -460
  704. package/src/client/billing/subscriptionCancellation.test.ts +0 -68
  705. package/src/client/billing/subscriptions.test.ts +0 -1049
  706. package/src/client/charge-currency.test.ts +0 -113
  707. package/src/client/component-api-types.test.ts +0 -137
  708. package/src/client/connect/commissionReceipts.test.ts +0 -157
  709. package/src/client/connect/dispute-upload.test.ts +0 -208
  710. package/src/client/connect/disputes.test.ts +0 -502
  711. package/src/client/connect/paymentMethodUtils.test.ts +0 -83
  712. package/src/client/connect/paymentMethods.test.ts +0 -68
  713. package/src/client/connect/payoutAdoption.test.ts +0 -186
  714. package/src/client/connect/payoutAdoptionAge.test.ts +0 -89
  715. package/src/client/connect/payoutAdoptionAllocation.test.ts +0 -132
  716. package/src/client/connect/payoutAdoptionConcurrency.test.ts +0 -266
  717. package/src/client/connect/payoutAdoptionTestHelpers.ts +0 -269
  718. package/src/client/connect/payoutAllocation.test.ts +0 -325
  719. package/src/client/connect/payoutCacheIdentity.test.ts +0 -93
  720. package/src/client/connect/payoutCollection.test.ts +0 -74
  721. package/src/client/connect/payoutDeadline.test.ts +0 -238
  722. package/src/client/connect/payoutExecution.test.ts +0 -294
  723. package/src/client/connect/payoutExecutionTestHelpers.ts +0 -244
  724. package/src/client/connect/payoutHistory.test.ts +0 -145
  725. package/src/client/connect/payoutLargeAdoption.test.ts +0 -541
  726. package/src/client/connect/payoutLargeAdoptionTestHelpers.ts +0 -74
  727. package/src/client/connect/payoutLargeHistory.test.ts +0 -222
  728. package/src/client/connect/payoutLiabilityVersion.test.ts +0 -221
  729. package/src/client/connect/payoutOutcomeBatches.test.ts +0 -40
  730. package/src/client/connect/payoutPreview.test.ts +0 -414
  731. package/src/client/connect/payoutQualificationFreshness.test.ts +0 -192
  732. package/src/client/connect/payoutReceipt.test.ts +0 -312
  733. package/src/client/connect/payoutReconciliation.test.ts +0 -414
  734. package/src/client/connect/payoutReturnedAdoption.test.ts +0 -157
  735. package/src/client/connect/payoutSnapshot.test.ts +0 -118
  736. package/src/client/connect/payoutSync.test.ts +0 -313
  737. package/src/client/connect/payoutSyncTestHelpers.ts +0 -82
  738. package/src/client/connect/payoutWorker.test.ts +0 -201
  739. package/src/client/connect/payouts.test.ts +0 -132
  740. package/src/client/connect/refundActor.test.ts +0 -121
  741. package/src/client/connect/refundPrincipal.test.ts +0 -46
  742. package/src/client/connect/refundSync.test.ts +0 -239
  743. package/src/client/connect/refundSync.transport.test.ts +0 -396
  744. package/src/client/connect/refunds.test.ts +0 -438
  745. package/src/client/connect/transferReceipt.pagination.test.ts +0 -209
  746. package/src/client/connect/transferReceipt.test.ts +0 -520
  747. package/src/client/connect/transferReceiptBaseline.test.ts +0 -55
  748. package/src/client/connect/transfers.test.ts +0 -557
  749. package/src/client/core/account-close-guard.test.ts +0 -349
  750. package/src/client/core/account-close-orchestration.test.ts +0 -131
  751. package/src/client/core/account-closure-preview.test.ts +0 -219
  752. package/src/client/core/account-closure.test.ts +0 -317
  753. package/src/client/core/account-idempotency.test.ts +0 -78
  754. package/src/client/core/account-session-client.test.ts +0 -74
  755. package/src/client/core/accountConfigurations.test.ts +0 -183
  756. package/src/client/core/accountLinks.test.ts +0 -389
  757. package/src/client/core/accountStatus.test.ts +0 -169
  758. package/src/client/core/accounts.test.ts +0 -1385
  759. package/src/client/core/billingPortal.test.ts +0 -249
  760. package/src/client/core/billingPortalFlow.test.ts +0 -349
  761. package/src/client/core/billingPortalIdentity.test.ts +0 -418
  762. package/src/client/core/config.test.ts +0 -69
  763. package/src/client/core/descriptors.test.ts +0 -70
  764. package/src/client/core/fees.test.ts +0 -369
  765. package/src/client/core/idempotency.test.ts +0 -10
  766. package/src/client/core/personal-account-mapping.test.ts +0 -71
  767. package/src/client/costRecovery-import.test.ts +0 -174
  768. package/src/client/costRecovery-invoiceReceipt.test.ts +0 -140
  769. package/src/client/costRecovery-invoices.test.ts +0 -470
  770. package/src/client/costRecovery-invoices.transport.test.ts +0 -107
  771. package/src/client/costRecovery.test.ts +0 -110
  772. package/src/client/customer-preview-thin.test.ts +0 -41
  773. package/src/client/customer-preview-webhooks.test.ts +0 -150
  774. package/src/client/customer-preview.test.ts +0 -366
  775. package/src/client/errors.test.ts +0 -66
  776. package/src/client/financialObservations.test.ts +0 -109
  777. package/src/client/financialOutcomes/outcomes.test.ts +0 -254
  778. package/src/client/financialOwnership.test.ts +0 -80
  779. package/src/client/helpers.test.ts +0 -74
  780. package/src/client/index.test.ts +0 -1784
  781. package/src/client/operationEvidence.test.ts +0 -110
  782. package/src/client/originalIdReadOptions.test.ts +0 -63
  783. package/src/client/paymentSource/resolver.fixtures.ts +0 -216
  784. package/src/client/paymentSource/resolver.test.ts +0 -386
  785. package/src/client/payoutPolicy.test.ts +0 -579
  786. package/src/client/payoutRevisionMigration.test.ts +0 -40
  787. package/src/client/processingCostDeficit/calculator.test.ts +0 -176
  788. package/src/client/processingCostReconciliation/invoiceProvider.test.ts +0 -353
  789. package/src/client/processingCostReconciliation/provider.test.ts +0 -324
  790. package/src/client/products/catalog-idempotency.test.ts +0 -116
  791. package/src/client/products/catalog.test.ts +0 -389
  792. package/src/client/products/fixedPrice.test.ts +0 -57
  793. package/src/client/products/identity.test.ts +0 -91
  794. package/src/client/products/prices.test.ts +0 -375
  795. package/src/client/products/product-descriptor-inheritance.test.ts +0 -245
  796. package/src/client/products/product-descriptors.test.ts +0 -260
  797. package/src/client/products/product-set-idempotency.test.ts +0 -188
  798. package/src/client/products/products.test.ts +0 -517
  799. package/src/client/readPagination.test.ts +0 -83
  800. package/src/client/recoveryWorkflow/client.test.ts +0 -37
  801. package/src/client/recoveryWorkflow/provider.fixture.ts +0 -143
  802. package/src/client/recoveryWorkflow/provider.test.ts +0 -509
  803. package/src/client/refund-command-evidence.test.ts +0 -68
  804. package/src/client/refund-command-normalization.test.ts +0 -61
  805. package/src/client/refund-context-shapes.test.ts +0 -127
  806. package/src/client/refund-context.test.ts +0 -404
  807. package/src/client/refund-history.test.ts +0 -67
  808. package/src/client/reversalObservations.test.ts +0 -69
  809. package/src/client/settlement/allocation.test.ts +0 -98
  810. package/src/client/settlement/authorization.fixture.ts +0 -199
  811. package/src/client/settlement/authorization.test.ts +0 -160
  812. package/src/client/settlement/commissions.test.ts +0 -103
  813. package/src/client/settlement/execution.test.ts +0 -191
  814. package/src/client/settlement/policy-context.test.ts +0 -277
  815. package/src/client/settlement/processingCosts.test.ts +0 -349
  816. package/src/client/settlement/processingCostsTransport.test.ts +0 -135
  817. package/src/client/settlement/verifiedSale.test.ts +0 -139
  818. package/src/client/setup.test.ts +0 -47
  819. package/src/client/singleAttemptHttpClient.test.ts +0 -70
  820. package/src/client/strictStripeTransport.test.ts +0 -73
  821. package/src/client/stripe-version.test.ts +0 -53
  822. package/src/client/transferContinuation.test.ts +0 -90
  823. package/src/client/transferObservations.test.ts +0 -98
  824. package/src/client/usage/allowanceClient.test.ts +0 -93
  825. package/src/client/usage/allowanceTerms.test.ts +0 -131
  826. package/src/client/usage/boundaries.test.ts +0 -136
  827. package/src/client/usage/catalog.test.ts +0 -464
  828. package/src/client/usage/catalogMath.test.ts +0 -13
  829. package/src/client/usage/contracts.test.ts +0 -145
  830. package/src/client/usage/correctionClient.test.ts +0 -153
  831. package/src/client/usage/correctionCredits.test.ts +0 -156
  832. package/src/client/usage/correctionInvoice.test.ts +0 -127
  833. package/src/client/usage/correctionRecovery.test.ts +0 -113
  834. package/src/client/usage/correctionTransport.fixtures.ts +0 -372
  835. package/src/client/usage/creditBackingIsolation.test.ts +0 -110
  836. package/src/client/usage/creditCapacity.test.ts +0 -162
  837. package/src/client/usage/creditClient.test.ts +0 -221
  838. package/src/client/usage/creditInvoice.test.ts +0 -149
  839. package/src/client/usage/creditObservation.test.ts +0 -150
  840. package/src/client/usage/creditProofBounds.test.ts +0 -187
  841. package/src/client/usage/creditProvider.test.ts +0 -276
  842. package/src/client/usage/creditRevenue.test.ts +0 -105
  843. package/src/client/usage/creditSettlement.fixtures.ts +0 -70
  844. package/src/client/usage/creditSettlement.test.ts +0 -66
  845. package/src/client/usage/creditSettlementRecovery.test.ts +0 -173
  846. package/src/client/usage/creditTerms.test.ts +0 -48
  847. package/src/client/usage/creditTransport.fixtures.ts +0 -308
  848. package/src/client/usage/deliveryProvider.test.ts +0 -316
  849. package/src/client/usage/invoiceObservation.test.ts +0 -195
  850. package/src/client/usage/invoiceSale.fixtures.ts +0 -103
  851. package/src/client/usage/invoiceSale.test.ts +0 -252
  852. package/src/client/usage/ledger-client.test.ts +0 -74
  853. package/src/client/usage/mixedInvoice.fixtures.ts +0 -54
  854. package/src/client/usage/mixedInvoiceSale.test.ts +0 -92
  855. package/src/client/usage/mixedSettlement.test.ts +0 -187
  856. package/src/client/usage/providerObservation.test.ts +0 -207
  857. package/src/client/usage/reconciliation.test.ts +0 -117
  858. package/src/client/usage/record-composition.test.ts +0 -195
  859. package/src/client/usage/settlement.test.ts +0 -179
  860. package/src/client/usage/subscription.fixtures.ts +0 -84
  861. package/src/client/usage/subscriptionAbandonment.test.ts +0 -124
  862. package/src/client/usage/subscriptionCheckout.test.ts +0 -44
  863. package/src/client/usage/subscriptionClient.test.ts +0 -375
  864. package/src/client/usage/subscriptionProvider.test.ts +0 -48
  865. package/src/client/usage/subscriptionTerms.test.ts +0 -158
  866. package/src/client/usage/subscriptionTransport.fixtures.ts +0 -247
  867. package/src/client/usage/summary.test.ts +0 -222
  868. package/src/client/utils/data.test.ts +0 -61
  869. package/src/client/utils/owner.test.ts +0 -38
  870. package/src/client/utils/stripeDashboardUrl.test.ts +0 -71
  871. package/src/client/utils/webhookEndpoints.test.ts +0 -459
  872. package/src/client/webhook-handlers.test.ts +0 -569
  873. package/src/client/webhooks/handler.test.ts +0 -601
  874. package/src/client/webhooks/helpers.test.ts +0 -343
  875. package/src/client/webhooks/hooks.test.ts +0 -119
  876. package/src/client/webhooks/meterErrors.test.ts +0 -164
  877. package/src/client/webhooks/payout-canceled.integration.test.ts +0 -230
  878. package/src/client/webhooks/payout-reconciliation.integration.test.ts +0 -168
  879. package/src/client/webhooks/payoutReconciliationTestHelpers.ts +0 -135
  880. package/src/client/webhooks/processors.test.ts +0 -2553
  881. package/src/client/webhooks/refund-delivery.test.ts +0 -512
  882. package/src/client/webhooks/refund-reconciliation.test.ts +0 -320
  883. package/src/client/webhooks/retry.integration.test.ts +0 -196
  884. package/src/client/webhooks/subscription-deleted-dispatch.test.ts +0 -61
  885. package/src/client/webhooks/subscription-deleted.integration.test.ts +0 -313
  886. package/src/client/webhooks/usageSubscriptions.test.ts +0 -162
  887. package/src/client/webhooks/v2.test.ts +0 -432
  888. package/src/client/webhooks.test.ts +0 -1681
  889. package/src/component/accountClosure/blockers.test.ts +0 -114
  890. package/src/component/affiliatePayouts/affiliate-direct-payout.test.ts +0 -159
  891. package/src/component/affiliateRecovery/affiliate-component-pagination.test.ts +0 -56
  892. package/src/component/affiliateRecovery/affiliate-recovery-lifecycle.test.ts +0 -586
  893. package/src/component/balanceFunding/failure.test.ts +0 -116
  894. package/src/component/balanceFunding/import.test.ts +0 -221
  895. package/src/component/balanceFunding/lookup.test.ts +0 -113
  896. package/src/component/balanceFunding/preparation.test.ts +0 -146
  897. package/src/component/balanceFunding/requestLookup.test.ts +0 -160
  898. package/src/component/balanceFunding/scopeLookup.test.ts +0 -94
  899. package/src/component/balanceFunding/state.test.ts +0 -352
  900. package/src/component/balanceFunding/validation.test.ts +0 -100
  901. package/src/component/balanceFunding/workflow.fixtures.ts +0 -366
  902. package/src/component/balanceFunding/workflow.test.ts +0 -552
  903. package/src/component/billing/checkout.test.ts +0 -89
  904. package/src/component/billing/invoices.test.ts +0 -294
  905. package/src/component/billing/store-subscriptions.test.ts +0 -31
  906. package/src/component/billing/subscription-scoping.test.ts +0 -120
  907. package/src/component/billing/subscriptions.test.ts +0 -477
  908. package/src/component/billingHistory/guards.test.ts +0 -235
  909. package/src/component/billingHistory/options.test.ts +0 -35
  910. package/src/component/billingHistory/pages.test.ts +0 -74
  911. package/src/component/connect/connect.test.ts +0 -715
  912. package/src/component/connect/fee-routing.test.ts +0 -122
  913. package/src/component/connect/payment-unique.test.ts +0 -195
  914. package/src/component/connect/payments.test.ts +0 -88
  915. package/src/component/connect/payouts.test.ts +0 -173
  916. package/src/component/connect/reversal-races.test.ts +0 -958
  917. package/src/component/connect/seller-case-ownership.test.ts +0 -60
  918. package/src/component/connect/transfers.test.ts +0 -517
  919. package/src/component/core/accounts.test.ts +0 -266
  920. package/src/component/core/config-queries.test.ts +0 -49
  921. package/src/component/core/original-id-unique.test.ts +0 -209
  922. package/src/component/core/payout-reset-safety.test.ts +0 -175
  923. package/src/component/core/personal-account-mapping.test.ts +0 -173
  924. package/src/component/core/reset.test.ts +0 -131
  925. package/src/component/costRecovery/cost-recovery.test.ts +0 -343
  926. package/src/component/costRecovery/preparation.test.ts +0 -355
  927. package/src/component/durableExecution/composition.test.ts +0 -568
  928. package/src/component/durableExecution/crossDomain.test.ts +0 -241
  929. package/src/component/durableExecution/crossDomainBoundaries.test.ts +0 -233
  930. package/src/component/durableExecution/crossDomainDisputes.test.ts +0 -108
  931. package/src/component/durableExecution/crossDomainMigration.test.ts +0 -192
  932. package/src/component/durableExecution/crossDomainWebhooks.test.ts +0 -122
  933. package/src/component/earnings/currency-migration.test.ts +0 -118
  934. package/src/component/earnings/currency-totals.test.ts +0 -94
  935. package/src/component/earnings/earnings-totals.test.ts +0 -237
  936. package/src/component/earnings/paired-adjustment.test.ts +0 -258
  937. package/src/component/earnings/summary-arithmetic.test.ts +0 -250
  938. package/src/component/financialObservations/continuation.test.ts +0 -445
  939. package/src/component/financialObservations/observation-boundaries.test.ts +0 -466
  940. package/src/component/financialObservations/settlement-observations.test.ts +0 -86
  941. package/src/component/financialObservations/transfer-batches.test.ts +0 -61
  942. package/src/component/financialObservations/transfer-boundaries.test.ts +0 -116
  943. package/src/component/financialObservations/transfer-continuation-guards.test.ts +0 -428
  944. package/src/component/financialObservations/transfer-continuation.test.ts +0 -154
  945. package/src/component/financialObservations/transfer-observations.test.ts +0 -212
  946. package/src/component/financialObservations/transfer-overflow.test.ts +0 -181
  947. package/src/component/financialObservations/transfer-writers.test.ts +0 -162
  948. package/src/component/financialOwnership/financial-ownership.test.ts +0 -102
  949. package/src/component/financialOwnership/ownership-boundaries.test.ts +0 -308
  950. package/src/component/lib/idempotency.test.ts +0 -37
  951. package/src/component/operationEvidence/integrity.test.ts +0 -257
  952. package/src/component/operationEvidence/maintenance.test.ts +0 -152
  953. package/src/component/operationEvidence/reads.test.ts +0 -140
  954. package/src/component/payoutPolicy/payout-policy-adoption.test.ts +0 -130
  955. package/src/component/payoutPolicy/payout-policy.test.ts +0 -247
  956. package/src/component/payoutRelease/payout-adoption.test.ts +0 -268
  957. package/src/component/payoutRelease/payout-fees.test.ts +0 -223
  958. package/src/component/payoutRelease/payout-recovery-integration.test.ts +0 -171
  959. package/src/component/payoutRelease/payout-release-snapshot.test.ts +0 -56
  960. package/src/component/payoutRelease/payout-release.test.ts +0 -587
  961. package/src/component/payoutRelease/progress.test.ts +0 -63
  962. package/src/component/payoutSnapshots/legacy-revisions.test.ts +0 -246
  963. package/src/component/payoutSnapshots/payout-revisions.test.ts +0 -124
  964. package/src/component/payoutSnapshots/payout-snapshots.test.ts +0 -438
  965. package/src/component/payoutSnapshots/revision-journal-callbacks.test.ts +0 -160
  966. package/src/component/payoutSnapshots/revision-journal-held.test.ts +0 -94
  967. package/src/component/payoutSnapshots/revision-journal.test.ts +0 -310
  968. package/src/component/payoutSnapshots/revision-migration.test.ts +0 -128
  969. package/src/component/payoutSync/payout-sync.test.ts +0 -116
  970. package/src/component/payoutWorker/payout-component-pagination.test.ts +0 -211
  971. package/src/component/payoutWorker/payout-worker.test.ts +0 -164
  972. package/src/component/processingCostReconciliation/adoption.test.ts +0 -206
  973. package/src/component/processingCostReconciliation/invoice.test.ts +0 -152
  974. package/src/component/processingCostReconciliation/state.test.ts +0 -407
  975. package/src/component/processingCostReconciliation/workflow.test.ts +0 -329
  976. package/src/component/products/identity.test.ts +0 -217
  977. package/src/component/products/products.test.ts +0 -239
  978. package/src/component/products/provider-price-pagination.test.ts +0 -174
  979. package/src/component/products/read-pagination.test.ts +0 -192
  980. package/src/component/recoveryWorkflow/bridge.test.ts +0 -481
  981. package/src/component/recoveryWorkflow/journal.test.ts +0 -104
  982. package/src/component/recoveryWorkflow/state.test.ts +0 -191
  983. package/src/component/refundHistory/command-evidence.test.ts +0 -288
  984. package/src/component/refundHistory/command-normalization-resource.test.ts +0 -77
  985. package/src/component/refundHistory/command-normalization.test.ts +0 -229
  986. package/src/component/refundHistory/command-provenance.test.ts +0 -59
  987. package/src/component/refundHistory/original-seller-boundaries.test.ts +0 -138
  988. package/src/component/refundHistory/original-seller.test.ts +0 -175
  989. package/src/component/refundHistory/refund-history.test.ts +0 -197
  990. package/src/component/refundSync/refund-sync.test.ts +0 -255
  991. package/src/component/renewalOperations/acknowledgement.fixtures.ts +0 -552
  992. package/src/component/renewalOperations/acknowledgement.test.ts +0 -573
  993. package/src/component/renewalOperations/acknowledgementReads.test.ts +0 -442
  994. package/src/component/renewalOperations/acknowledgementV2.test.ts +0 -493
  995. package/src/component/renewalOperations/acknowledgementV2Publication.test.ts +0 -373
  996. package/src/component/renewalOperations/basisBinding.test.ts +0 -567
  997. package/src/component/renewalOperations/basisLifecycle.test.ts +0 -569
  998. package/src/component/renewalOperations/boundHistory.test.ts +0 -474
  999. package/src/component/renewalOperations/configureAcknowledgement.test.ts +0 -30
  1000. package/src/component/renewalOperations/configureAcknowledgementControls.test.ts +0 -96
  1001. package/src/component/renewalOperations/configureBasis.test.ts +0 -77
  1002. package/src/component/renewalOperations/configureCreation.test.ts +0 -75
  1003. package/src/component/renewalOperations/configureJournal.fixtures.ts +0 -407
  1004. package/src/component/renewalOperations/configurePolicy.test.ts +0 -105
  1005. package/src/component/renewalOperations/configurePublication.test.ts +0 -85
  1006. package/src/component/renewalOperations/configureReceiptBounds.test.ts +0 -39
  1007. package/src/component/renewalOperations/configureSourceControls.test.ts +0 -65
  1008. package/src/component/renewalOperations/historyReads.test.ts +0 -595
  1009. package/src/component/renewalOperations/initialBasis.test.ts +0 -578
  1010. package/src/component/renewalOperations/journal.test.ts +0 -567
  1011. package/src/component/renewalOperations/payload.test.ts +0 -589
  1012. package/src/component/renewalOperations/payloadEncoding.test.ts +0 -592
  1013. package/src/component/renewalOperations/timingPolicy.fixtures.ts +0 -193
  1014. package/src/component/renewalOperations/timingPolicy.test.ts +0 -523
  1015. package/src/component/renewalWitnesses/bounds.test.ts +0 -204
  1016. package/src/component/renewalWitnesses/codec.test.ts +0 -84
  1017. package/src/component/renewalWitnesses/controls.test.ts +0 -250
  1018. package/src/component/renewalWitnesses/protocol.test.ts +0 -63
  1019. package/src/component/renewalWitnesses/routes.test.ts +0 -154
  1020. package/src/component/reversalObservations/boundaries.test.ts +0 -62
  1021. package/src/component/reversalObservations/capture-integrity.test.ts +0 -119
  1022. package/src/component/reversalObservations/continuation.test.ts +0 -131
  1023. package/src/component/reversalObservations/lifecycle.test.ts +0 -81
  1024. package/src/component/reversalObservations/provenance.test.ts +0 -167
  1025. package/src/component/settlement/affiliate-clawbacks.test.ts +0 -369
  1026. package/src/component/settlement/settlement-claims.test.ts +0 -130
  1027. package/src/component/usage/allowance.fixtures.ts +0 -77
  1028. package/src/component/usage/allowance.test.ts +0 -372
  1029. package/src/component/usage/allowanceBounds.test.ts +0 -79
  1030. package/src/component/usage/historyIsolation.test.ts +0 -124
  1031. package/src/component/usage/ledger.test.ts +0 -303
  1032. package/src/component/usageCorrections/corrections.test.ts +0 -389
  1033. package/src/component/usageCredits/accounting.fixtures.ts +0 -96
  1034. package/src/component/usageCredits/accounting.test.ts +0 -483
  1035. package/src/component/usageCredits/freshness.test.ts +0 -33
  1036. package/src/component/usageCredits/quotas.test.ts +0 -63
  1037. package/src/component/usageDelivery/concurrency.test.ts +0 -62
  1038. package/src/component/usageDelivery/workflow.test.ts +0 -402
  1039. package/src/component/usageObservations/history.test.ts +0 -87
  1040. package/src/component/usageObservations/queries.test.ts +0 -162
  1041. package/src/component/usageSubscriptions/acceptance.test.ts +0 -122
  1042. package/src/component/usageSubscriptions/history.test.ts +0 -126
  1043. package/src/component/usageSubscriptions/mutations.test.ts +0 -205
  1044. package/src/component/webhooks/events.test.ts +0 -121
  1045. package/src/component/webhooks/triggers.test.ts +0 -360
  1046. package/src/react/components/AccountOnboardingCard.test.ts +0 -27
  1047. package/src/react/components/BuyerBillingView.render.test.tsx +0 -212
  1048. package/src/react/components/ConnectProvider.live.test.tsx +0 -61
  1049. package/src/react/components/DisputeDetail.render.test.tsx +0 -147
  1050. package/src/react/components/DisputesList.render.test.tsx +0 -265
  1051. package/src/react/components/EarningsSummary.render.test.tsx +0 -149
  1052. package/src/react/components/EmbeddedCheckout.render.test.tsx +0 -57
  1053. package/src/react/components/EmbeddedCheckout.test.ts +0 -25
  1054. package/src/react/components/EmbeddedDisputes.render.test.tsx +0 -144
  1055. package/src/react/components/EvidenceForm.render.test.tsx +0 -208
  1056. package/src/react/components/PayoutSchedule.render.test.tsx +0 -193
  1057. package/src/react/components/PriceBadge.render.test.tsx +0 -134
  1058. package/src/react/components/PriceCard.render.test.tsx +0 -172
  1059. package/src/react/components/SplitBreakdown.render.test.tsx +0 -191
  1060. package/src/react/components/StripeProvider.test.ts +0 -45
  1061. package/src/react/components/TrialAlert.render.test.tsx +0 -132
  1062. package/src/react/hooks/skipSentinel.test.ts +0 -85
  1063. package/src/react/hooks/useAccountOnboarding.test.ts +0 -75
  1064. package/src/react/hooks/useCheckoutSession.promotions.test.tsx +0 -303
  1065. package/src/react/hooks/useConfirmPayment.test.tsx +0 -47
  1066. package/src/react/hooks/useCurrencyEarnings.test.ts +0 -59
  1067. package/src/react/hooks/useDisputeWithCountdown.test.ts +0 -90
  1068. package/src/react/hooks/useDisputes.test.ts +0 -75
  1069. package/src/react/hooks/useEarnings.test.ts +0 -194
  1070. package/src/react/hooks/useInvoices.test.ts +0 -79
  1071. package/src/react/hooks/useProducts.test.ts +0 -75
  1072. package/src/react/hooks/useSplitBreakdown.test.ts +0 -151
  1073. package/src/react/hooks/useStripeMode.test.ts +0 -46
  1074. package/src/react/hooks/useStripePublishableKey.test.ts +0 -35
  1075. package/src/react/index.payment-element.test.ts +0 -26
  1076. package/src/react/index.test.ts +0 -172
  1077. package/src/react/lib/connect-requirement-keys.test.ts +0 -73
  1078. package/src/react/lib/price-helpers.test.ts +0 -212
  1079. package/src/react/lib/stripe-element-styles.test.ts +0 -94
  1080. package/src/react/lib/subscription-helpers.test.ts +0 -127
  1081. package/src/react/read-contracts.render.test.tsx +0 -20
  1082. package/src/react/workflows/Account.test.tsx +0 -31
  1083. package/src/react/workflows/AffiliatePayoutEditor.test.tsx +0 -90
  1084. package/src/react/workflows/AffiliateRateEditor.test.tsx +0 -36
  1085. package/src/react/workflows/AffiliateRecovery.test.tsx +0 -106
  1086. package/src/react/workflows/Billing.test.tsx +0 -45
  1087. package/src/react/workflows/BillingPlans.test.tsx +0 -31
  1088. package/src/react/workflows/BillingPortal.test.tsx +0 -101
  1089. package/src/react/workflows/Checkout.test.tsx +0 -148
  1090. package/src/react/workflows/CheckoutChooser.test.tsx +0 -44
  1091. package/src/react/workflows/CheckoutForm.test.tsx +0 -66
  1092. package/src/react/workflows/CheckoutForms.test.tsx +0 -163
  1093. package/src/react/workflows/ClipboardButton.test.tsx +0 -34
  1094. package/src/react/workflows/Collections.test.tsx +0 -122
  1095. package/src/react/workflows/Connect.test.tsx +0 -50
  1096. package/src/react/workflows/Costs.test.tsx +0 -62
  1097. package/src/react/workflows/Disputes.test.tsx +0 -64
  1098. package/src/react/workflows/Earnings.test.ts +0 -19
  1099. package/src/react/workflows/EvidenceUpload.test.tsx +0 -56
  1100. package/src/react/workflows/Financials.test.tsx +0 -35
  1101. package/src/react/workflows/IntegrationSwitch.test.tsx +0 -61
  1102. package/src/react/workflows/Onboarding.test.tsx +0 -148
  1103. package/src/react/workflows/Overview.test.tsx +0 -57
  1104. package/src/react/workflows/Pagination.test.tsx +0 -53
  1105. package/src/react/workflows/PaymentMethods.test.tsx +0 -60
  1106. package/src/react/workflows/PaymentReceipt.test.tsx +0 -24
  1107. package/src/react/workflows/PayoutProgress.test.tsx +0 -356
  1108. package/src/react/workflows/PayoutSettings.test.tsx +0 -139
  1109. package/src/react/workflows/Payouts.test.tsx +0 -145
  1110. package/src/react/workflows/PlanPricingEditor.currency.test.tsx +0 -164
  1111. package/src/react/workflows/PlanPricingEditor.test.tsx +0 -79
  1112. package/src/react/workflows/PlanPricingEditor.zero.test.tsx +0 -100
  1113. package/src/react/workflows/Products.test.tsx +0 -282
  1114. package/src/react/workflows/ReferralLinks.test.tsx +0 -39
  1115. package/src/react/workflows/Refunds.currency.test.tsx +0 -290
  1116. package/src/react/workflows/Refunds.test.tsx +0 -75
  1117. package/src/react/workflows/SaveCard.test.tsx +0 -127
  1118. package/src/react/workflows/Setup.test.tsx +0 -25
  1119. package/src/react/workflows/Storefront.test.tsx +0 -82
  1120. package/src/react/workflows/SubscriptionOverview.test.tsx +0 -27
  1121. package/src/react/workflows/Subscriptions.test.tsx +0 -61
  1122. package/src/react/workflows/Tasks.test.tsx +0 -23
  1123. package/src/react/workflows/Usage.fixtures.ts +0 -88
  1124. package/src/react/workflows/Usage.test.tsx +0 -388
  1125. package/src/react/workflows/UsageConfiguration.test.tsx +0 -393
  1126. package/src/react/workflows/UsageHistory.test.tsx +0 -206
  1127. package/src/react/workflows/UsagePriceRow.test.tsx +0 -140
  1128. package/src/react/workflows/current-subscription.test.ts +0 -29
  1129. package/src/react/workflows/filters.test.ts +0 -12
  1130. package/src/react/workflows/native-interactions.test.tsx +0 -73
  1131. package/src/react/workflows/public-workflows.test.tsx +0 -216
  1132. package/src/react/workflows/refund-preview.test.ts +0 -65
  1133. package/src/react/workflows/usage-configuration-validation.test.ts +0 -107
  1134. package/src/react/workflows/useWorkflowAction.commit.test.tsx +0 -194
  1135. package/src/react/workflows/useWorkflowAction.ssr.test.tsx +0 -20
  1136. package/src/react/workflows/useWorkflowAction.test.tsx +0 -54
  1137. package/src/react/workflows/useWorkflowResource.test.tsx +0 -41
  1138. package/src/test.ts +0 -21
  1139. package/src/testing/assert-test-env.test.ts +0 -33
  1140. package/src/testing/component-db.ts +0 -24
  1141. package/src/testing/crossDomain/fixture.ts +0 -96
  1142. package/src/testing/crossDomain/host.ts +0 -288
  1143. package/src/testing/crossDomain/transport.ts +0 -293
  1144. package/src/testing/mock-webhooks.test.ts +0 -97
@@ -1,2553 +0,0 @@
1
- // @vitest-environment edge-runtime
2
- import type Stripe from "stripe";
3
- import { beforeEach, describe, expect, it, vi } from "vitest";
4
-
5
- import { computeReversalSlices } from "../../component/lib/reversals.js";
6
- import type { WebhookContext } from "./helpers.js";
7
- import { processEvent } from "./processors.js";
8
- import { processRefund } from "../../../tests/fixtures/refund-recovery.js";
9
-
10
- const TO_REF = Symbol.for("toReferencePath");
11
-
12
- function makeComponent() {
13
- const refs = (namespace: string, names: string[]) =>
14
- Object.fromEntries(
15
- names.map((name) => [
16
- name,
17
- { [TO_REF]: `betterStripe/${namespace}/${name}` },
18
- ]),
19
- );
20
- return {
21
- products: {
22
- queries: refs("products/queries", ["getProductByStripeId"]),
23
- mutations: refs("products/mutations", ["upsertProduct", "upsertPrice"]),
24
- },
25
- billing: {
26
- queries: refs("billing/queries", ["getCheckoutSessionByStripeId"]),
27
- mutations: refs("billing/mutations", [
28
- "upsertSubscription",
29
- "upsertCheckoutSession",
30
- "upsertInvoice",
31
- ]),
32
- },
33
- connect: {
34
- mutations: refs("connect/mutations", ["upsertPayment", "upsertPayout"]),
35
- },
36
- };
37
- }
38
-
39
- function makeCtx(opts?: { query?: unknown; queryThrows?: boolean }) {
40
- const runQuery = vi.fn();
41
- if (opts?.queryThrows) runQuery.mockRejectedValue(new Error("not found"));
42
- else runQuery.mockResolvedValue(opts?.query ?? null);
43
- // Fake claim storage; use the shared reversal sizing math.
44
- const runMutation = vi.fn(
45
- async (ref: Record<symbol, string>, args: Record<string, unknown>) => {
46
- const path = ref?.[TO_REF] ?? "";
47
- if (
48
- String(path).endsWith(
49
- "settlement/mutations/reserveSettlementAllocation",
50
- )
51
- )
52
- return args;
53
- if (!String(path).endsWith("connect/mutations/claimReversalSlices")) {
54
- return undefined;
55
- }
56
- const legs = (Array.isArray(opts?.query) ? opts.query : []) as {
57
- stripeTransferId: string;
58
- amount: number;
59
- reversedAmount?: number;
60
- reversalClaimedAmount?: number;
61
- }[];
62
- const slices = computeReversalSlices(
63
- legs.map((t) => ({
64
- stripeTransferId: t.stripeTransferId,
65
- amount: t.amount,
66
- frontier: Math.max(
67
- t.reversedAmount ?? 0,
68
- t.reversalClaimedAmount ?? 0,
69
- ),
70
- })),
71
- args.mode as Parameters<typeof computeReversalSlices>[1],
72
- );
73
- return {
74
- replay: false,
75
- slices: slices.map((s) => ({
76
- ...s,
77
- confirmed:
78
- legs.find((t) => t.stripeTransferId === s.stripeTransferId)
79
- ?.reversedAmount ?? 0,
80
- })),
81
- };
82
- },
83
- );
84
- return { runQuery, runMutation };
85
- }
86
-
87
- let trCreateSeq = 0;
88
-
89
- /** Minimal transfer-reversal shape the mocks record/return (BTS-69). */
90
- type MockReversal = {
91
- id: string;
92
- amount: number;
93
- metadata: Record<string, string> | null;
94
- /** Test-only join back to the reversed transfer id. */
95
- _transfer?: string;
96
- };
97
-
98
- function makeStripe() {
99
- return {
100
- payouts: { retrieve: vi.fn() },
101
- refunds: {
102
- retrieve: vi.fn(),
103
- list: vi.fn(() =>
104
- (async function* () {
105
- yield { amount: 5000, status: "succeeded" };
106
- })(),
107
- ),
108
- },
109
- products: { retrieve: vi.fn() },
110
- subscriptions: {
111
- retrieve: vi.fn(),
112
- update: vi.fn().mockResolvedValue({}),
113
- cancel: vi.fn().mockResolvedValue({}),
114
- },
115
- invoices: {
116
- update: vi.fn().mockResolvedValue({}),
117
- retrieve: vi.fn(),
118
- },
119
- charges: { retrieve: vi.fn().mockResolvedValue({ created: 1 }) },
120
- transfers: {
121
- list: vi.fn().mockResolvedValue({ data: [], has_more: false }),
122
- create: vi.fn(async (_params: unknown) => ({
123
- id: `tr_${++trCreateSeq}`,
124
- })),
125
- createReversal: vi.fn(
126
- async (
127
- _id: unknown,
128
- _params?: unknown,
129
- _opts?: unknown,
130
- ): Promise<MockReversal> => ({
131
- id: "trr_x",
132
- amount: 0,
133
- metadata: null,
134
- }),
135
- ),
136
- // No prior reversals by default; the first-invoice-fee adoption guard
137
- // (BTS-69) lists these before reversing.
138
- listReversals: vi.fn(
139
- async (
140
- _id: unknown,
141
- _opts?: unknown,
142
- ): Promise<{ data: MockReversal[] }> => ({
143
- data: [],
144
- }),
145
- ),
146
- },
147
- invoicePayments: {
148
- list: vi.fn(
149
- async (
150
- _params: unknown,
151
- ): Promise<{ data: Record<string, unknown>[] }> => ({
152
- data: [{ payment: { charge: "ch_inv" } }],
153
- }),
154
- ),
155
- },
156
- paymentIntents: {
157
- retrieve: vi.fn(),
158
- update: vi.fn().mockResolvedValue({}),
159
- },
160
- };
161
- }
162
-
163
- function makeWhCtx(overrides?: {
164
- ctx?: ReturnType<typeof makeCtx>;
165
- stripe?: ReturnType<typeof makeStripe>;
166
- config?: Record<string, unknown>;
167
- }): WebhookContext & {
168
- ctx: ReturnType<typeof makeCtx>;
169
- stripe: ReturnType<typeof makeStripe>;
170
- } {
171
- const ctx = overrides?.ctx ?? makeCtx();
172
- const stripe = overrides?.stripe ?? makeStripe();
173
- return {
174
- ctx,
175
- component: makeComponent(),
176
- stripe,
177
- webhookSecret: "whsec_test",
178
- ...(overrides?.config ? { config: overrides.config } : {}),
179
- // no `config.webhooks` → dispatchUpsert uses the direct component path
180
- } as unknown as WebhookContext & {
181
- ctx: ReturnType<typeof makeCtx>;
182
- stripe: ReturnType<typeof makeStripe>;
183
- };
184
- }
185
-
186
- /** Wrap an object as a minimal Stripe.Event of the given type. */
187
- function event(type: string, object: unknown): Stripe.Event {
188
- return { type, data: { object } } as unknown as Stripe.Event;
189
- }
190
-
191
- /** The payload + resolved ref path from the Nth runMutation call. */
192
- function dispatchedPayload(ctx: ReturnType<typeof makeCtx>, n = 0) {
193
- const call = ctx.runMutation.mock.calls[n];
194
- return {
195
- path: call[0][TO_REF] as string,
196
- data: call[1] as Record<string, unknown>,
197
- };
198
- }
199
-
200
- beforeEach(() => {
201
- vi.restoreAllMocks();
202
- });
203
-
204
- describe("processEvent — products", () => {
205
- it("normalizes a product.created event, carrying a Connect account id", async () => {
206
- const whCtx = makeWhCtx();
207
- await processEvent(
208
- whCtx,
209
- event("product.created", {
210
- id: "prod_1",
211
- account: "acct_connect",
212
- name: "Widget",
213
- description: null,
214
- active: true,
215
- metadata: { k: "v" },
216
- }),
217
- );
218
-
219
- const { path, data } = dispatchedPayload(whCtx.ctx);
220
- expect(path).toBe("betterStripe/products/mutations/upsertProduct");
221
- expect(data).toEqual({
222
- stripeProductId: "prod_1",
223
- accountId: "acct_connect",
224
- name: "Widget",
225
- description: undefined,
226
- active: true,
227
- metadata: { k: "v" },
228
- });
229
- });
230
-
231
- it("leaves accountId undefined when no Connect account is present", async () => {
232
- const whCtx = makeWhCtx();
233
- await processEvent(
234
- whCtx,
235
- event("product.updated", {
236
- id: "prod_2",
237
- name: "Gadget",
238
- description: "d",
239
- active: false,
240
- metadata: {},
241
- }),
242
- );
243
- expect(dispatchedPayload(whCtx.ctx).data.accountId).toBeUndefined();
244
- });
245
- });
246
-
247
- describe("processEvent — prices", () => {
248
- const price = {
249
- id: "price_1",
250
- product: "prod_1",
251
- nickname: "Monthly",
252
- unit_amount: 1500,
253
- currency: "usd",
254
- active: true,
255
- type: "recurring",
256
- recurring: { interval: "month", interval_count: 3 },
257
- metadata: {},
258
- };
259
-
260
- it("dispatches a price upsert when the product already exists in the DB", async () => {
261
- const ctx = makeCtx({ query: { _id: "internal_prod_1" } });
262
- const whCtx = makeWhCtx({ ctx });
263
-
264
- await processEvent(whCtx, event("price.created", price));
265
-
266
- // last runMutation is the price upsert (no auto-create happened)
267
- const calls = ctx.runMutation.mock.calls;
268
- const upsert = calls[calls.length - 1];
269
- expect(upsert[0][TO_REF]).toBe(
270
- "betterStripe/products/mutations/upsertPrice",
271
- );
272
- expect(upsert[1]).toMatchObject({
273
- stripePriceId: "price_1",
274
- productId: "internal_prod_1",
275
- stripeProductId: "prod_1",
276
- unitAmount: 1500,
277
- interval: "month",
278
- intervalCount: 3,
279
- });
280
- });
281
-
282
- it("auto-creates a missing product, then dispatches the price", async () => {
283
- // first getProductByStripeId → null, second (after create) → the row
284
- const runQuery = vi
285
- .fn()
286
- .mockResolvedValueOnce(null)
287
- .mockResolvedValueOnce({ _id: "internal_new" });
288
- const ctx = {
289
- runQuery,
290
- runMutation: vi.fn().mockResolvedValue(undefined),
291
- };
292
- const stripe = makeStripe();
293
- stripe.products.retrieve.mockResolvedValue({
294
- id: "prod_1",
295
- name: "Recovered",
296
- description: null,
297
- active: true,
298
- metadata: {},
299
- });
300
- const whCtx = makeWhCtx({ ctx: ctx as never, stripe });
301
-
302
- await processEvent(whCtx, event("price.updated", price));
303
-
304
- expect(stripe.products.retrieve).toHaveBeenCalledWith("prod_1");
305
- // product upsert then price upsert both ran
306
- const paths = ctx.runMutation.mock.calls.map((c) => c[0][TO_REF]);
307
- expect(paths).toContain("betterStripe/products/mutations/upsertProduct");
308
- expect(paths).toContain("betterStripe/products/mutations/upsertPrice");
309
- });
310
-
311
- it("skips the price (no dispatch) when product auto-create fails", async () => {
312
- const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
313
- const ctx = makeCtx({ query: null });
314
- const stripe = makeStripe();
315
- stripe.products.retrieve.mockRejectedValue(new Error("gone"));
316
- const whCtx = makeWhCtx({ ctx, stripe });
317
-
318
- await processEvent(whCtx, event("price.created", price));
319
-
320
- // no upsertPrice dispatch happened
321
- const paths = ctx.runMutation.mock.calls.map((c) => c[0][TO_REF]);
322
- expect(paths).not.toContain("betterStripe/products/mutations/upsertPrice");
323
- expect(warn).toHaveBeenCalled();
324
- });
325
-
326
- it("skips a price with no resolvable product id", async () => {
327
- const warn = vi.spyOn(console, "warn").mockImplementation(() => {});
328
- const ctx = makeCtx({ query: null });
329
- const stripe = makeStripe();
330
- const whCtx = makeWhCtx({ ctx, stripe });
331
-
332
- await processEvent(
333
- whCtx,
334
- event("price.created", { ...price, product: null }),
335
- );
336
-
337
- // never even attempted to retrieve a product
338
- expect(stripe.products.retrieve).not.toHaveBeenCalled();
339
- expect(ctx.runMutation).not.toHaveBeenCalled();
340
- expect(warn).toHaveBeenCalled();
341
- });
342
- });
343
-
344
- describe("processEvent — subscriptions", () => {
345
- const baseSub = {
346
- id: "sub_1",
347
- status: "active",
348
- customer: "acct_cust",
349
- cancel_at_period_end: false,
350
- canceled_at: null,
351
- trial_start: null,
352
- trial_end: null,
353
- metadata: { userId: "user_1", orgId: "org_1" },
354
- items: {
355
- data: [
356
- {
357
- price: { id: "price_x" },
358
- quantity: 2,
359
- current_period_start: 1700000000,
360
- current_period_end: 1702592000,
361
- },
362
- ],
363
- },
364
- };
365
-
366
- it("normalizes a created subscription with identifiers, trial, period, and price", async () => {
367
- const whCtx = makeWhCtx();
368
- await processEvent(whCtx, event("customer.subscription.created", baseSub));
369
-
370
- const { path, data } = dispatchedPayload(whCtx.ctx);
371
- expect(path).toBe("betterStripe/billing/mutations/upsertSubscription");
372
- expect(data).toMatchObject({
373
- stripeSubscriptionId: "sub_1",
374
- accountId: "acct_cust",
375
- userId: "user_1",
376
- orgId: "org_1",
377
- status: "active",
378
- priceId: "price_x",
379
- quantity: 2,
380
- cancelAtPeriodEnd: false,
381
- isTrialing: false,
382
- });
383
- expect(data.currentPeriodStart).toBe(
384
- new Date(1700000000 * 1000).toISOString(),
385
- );
386
- });
387
-
388
- it("tracks collection pause separately from subscription status", async () => {
389
- const whCtx = makeWhCtx();
390
- await processEvent(
391
- whCtx,
392
- event("customer.subscription.updated", {
393
- ...baseSub,
394
- pause_collection: { behavior: "keep_as_draft" },
395
- }),
396
- );
397
- expect(dispatchedPayload(whCtx.ctx).data).toMatchObject({
398
- status: "active",
399
- isCollectionPaused: true,
400
- });
401
- const resumed = makeWhCtx();
402
- await processEvent(
403
- resumed,
404
- event("customer.subscription.updated", {
405
- ...baseSub,
406
- pause_collection: null,
407
- }),
408
- );
409
- expect(dispatchedPayload(resumed.ctx).data).toMatchObject({
410
- status: "active",
411
- isCollectionPaused: false,
412
- });
413
- });
414
-
415
- it("routes a deleted subscription through the subscriptionDeleted dispatcher", async () => {
416
- const whCtx = makeWhCtx();
417
- await processEvent(whCtx, event("customer.subscription.deleted", baseSub));
418
- // both dispatchers map to the same upsertSubscription path, so assert the
419
- // event still produces exactly one subscription upsert
420
- expect(whCtx.ctx.runMutation).toHaveBeenCalledTimes(1);
421
- expect(dispatchedPayload(whCtx.ctx).path).toBe(
422
- "betterStripe/billing/mutations/upsertSubscription",
423
- );
424
- });
425
-
426
- it("derives accountId from an expanded customer object", async () => {
427
- const whCtx = makeWhCtx();
428
- await processEvent(
429
- whCtx,
430
- event("customer.subscription.updated", {
431
- ...baseSub,
432
- customer: { id: "acct_obj" },
433
- }),
434
- );
435
- expect(dispatchedPayload(whCtx.ctx).data.accountId).toBe("acct_obj");
436
- });
437
-
438
- it("prefers the V2 customer_account over the legacy customer id", async () => {
439
- const whCtx = makeWhCtx();
440
- await processEvent(
441
- whCtx,
442
- event("customer.subscription.created", {
443
- ...baseSub,
444
- customer: "cus_legacy",
445
- customer_account: "acct_v2",
446
- }),
447
- );
448
- expect(dispatchedPayload(whCtx.ctx).data.accountId).toBe("acct_v2");
449
- });
450
-
451
- it.each(["customer.subscription.created", "customer.subscription.updated"])(
452
- "preserves checkout destination and platform fee on %s",
453
- async (type) => {
454
- const whCtx = makeWhCtx();
455
- await processEvent(
456
- whCtx,
457
- event(type, {
458
- ...baseSub,
459
- customer_account: "acct_buyer",
460
- transfer_data: { destination: "acct_store" },
461
- application_fee_percent: 10,
462
- }),
463
- );
464
- expect(dispatchedPayload(whCtx.ctx).data).toMatchObject({
465
- accountId: "acct_buyer",
466
- chargeType: "destination",
467
- destinationAccountId: "acct_store",
468
- applicationFeePercent: 10,
469
- });
470
- },
471
- );
472
-
473
- it("falls back to the empty-string userId sentinel when metadata is absent", async () => {
474
- const whCtx = makeWhCtx();
475
- await processEvent(
476
- whCtx,
477
- event("customer.subscription.updated", { ...baseSub, metadata: null }),
478
- );
479
- const { data } = dispatchedPayload(whCtx.ctx);
480
- expect(data.userId).toBe("");
481
- expect(data.orgId).toBeUndefined();
482
- });
483
-
484
- it("leaves price/period/quantity undefined when the subscription has no items", async () => {
485
- const whCtx = makeWhCtx();
486
- await processEvent(
487
- whCtx,
488
- event("customer.subscription.updated", {
489
- ...baseSub,
490
- items: { data: [] },
491
- }),
492
- );
493
- const { data } = dispatchedPayload(whCtx.ctx);
494
- expect(data.priceId).toBeUndefined();
495
- expect(data.quantity).toBeUndefined();
496
- expect(data.currentPeriodStart).toBeUndefined();
497
- });
498
-
499
- it("marks a trialing subscription and converts the trial epochs", async () => {
500
- const whCtx = makeWhCtx();
501
- await processEvent(
502
- whCtx,
503
- event("customer.subscription.trial_will_end", {
504
- ...baseSub,
505
- status: "trialing",
506
- trial_start: 1700000000,
507
- trial_end: 1700600000,
508
- }),
509
- );
510
- const { data } = dispatchedPayload(whCtx.ctx);
511
- expect(data.isTrialing).toBe(true);
512
- expect(data.trialEnd).toBe(new Date(1700600000 * 1000).toISOString());
513
- });
514
-
515
- // BTS-33: when a recurring charge fails, Stripe drives the subscription to
516
- // `past_due` (then `unpaid` once retries are exhausted) via
517
- // customer.subscription.updated. The raw delinquent status must reach the
518
- // table unchanged so `onSubscriptionUpdated` consumers can act on it.
519
- it.each(["past_due", "unpaid"] as const)(
520
- "passes through the delinquent subscription status %s",
521
- async (status) => {
522
- const whCtx = makeWhCtx();
523
- await processEvent(
524
- whCtx,
525
- event("customer.subscription.updated", { ...baseSub, status }),
526
- );
527
- expect(dispatchedPayload(whCtx.ctx).data.status).toBe(status);
528
- },
529
- );
530
- });
531
-
532
- describe("processEvent — checkout", () => {
533
- const session = {
534
- id: "cs_1",
535
- customer: "acct_c",
536
- mode: "subscription",
537
- status: "complete",
538
- client_secret: "cs_secret",
539
- url: "https://pay",
540
- metadata: { userId: "user_1", new: "fromEvent" },
541
- line_items: { data: [{ price: { id: "price_co" } }] },
542
- };
543
-
544
- it("merges stored metadata with event metadata (event wins on conflicts)", async () => {
545
- const ctx = makeCtx({
546
- query: { metadata: { stored: "fromDb", new: "old" } },
547
- });
548
- const whCtx = makeWhCtx({ ctx });
549
-
550
- await processEvent(whCtx, event("checkout.session.completed", session));
551
-
552
- const calls = ctx.runMutation.mock.calls;
553
- const upsert = calls[calls.length - 1];
554
- expect(upsert[0][TO_REF]).toBe(
555
- "betterStripe/billing/mutations/upsertCheckoutSession",
556
- );
557
- expect(upsert[1]).toMatchObject({
558
- stripeSessionId: "cs_1",
559
- priceId: "price_co",
560
- mode: "subscription",
561
- status: "complete",
562
- metadata: { stored: "fromDb", new: "fromEvent", userId: "user_1" },
563
- });
564
- });
565
-
566
- it("uses only event metadata when the session is seen for the first time", async () => {
567
- const ctx = makeCtx({ queryThrows: true });
568
- const whCtx = makeWhCtx({ ctx });
569
-
570
- await processEvent(whCtx, event("checkout.session.completed", session));
571
-
572
- const calls = ctx.runMutation.mock.calls;
573
- const upsert = calls[calls.length - 1];
574
- expect(upsert[1].metadata).toEqual({ userId: "user_1", new: "fromEvent" });
575
- });
576
-
577
- it("prefers the V2 customer_account over the legacy customer id", async () => {
578
- const ctx = makeCtx({ queryThrows: true });
579
- const whCtx = makeWhCtx({ ctx });
580
-
581
- await processEvent(
582
- whCtx,
583
- event("checkout.session.completed", {
584
- ...session,
585
- customer: "cus_legacy",
586
- customer_account: "acct_v2",
587
- }),
588
- );
589
-
590
- const calls = ctx.runMutation.mock.calls;
591
- const upsert = calls[calls.length - 1];
592
- expect(upsert[1].accountId).toBe("acct_v2");
593
- });
594
- });
595
-
596
- describe("processEvent — invoices", () => {
597
- it.each([false, true])(
598
- "inherits subscription identifiers when invoice metadata is empty (override=%s)",
599
- async (override) => {
600
- const whCtx = makeWhCtx();
601
- await processEvent(
602
- whCtx,
603
- event("invoice.paid", {
604
- id: "in_inherited",
605
- currency: "usd",
606
- amount_due: 2900,
607
- amount_paid: 2900,
608
- status: "paid",
609
- metadata: override
610
- ? { userId: "invoice_user", orgId: "invoice_org" }
611
- : {},
612
- parent: {
613
- subscription_details: {
614
- subscription: "sub_parent",
615
- metadata: { userId: "buyer_1", orgId: "store_org" },
616
- },
617
- },
618
- }),
619
- );
620
- const { data } = dispatchedPayload(whCtx.ctx);
621
- expect(data.userId).toBe(override ? "invoice_user" : "buyer_1");
622
- expect(data.orgId).toBe(override ? "invoice_org" : "store_org");
623
- },
624
- );
625
-
626
- it("normalizes an invoice and resolves the parent subscription id", async () => {
627
- const whCtx = makeWhCtx();
628
- await processEvent(
629
- whCtx,
630
- event("invoice.paid", {
631
- id: "in_1",
632
- customer: "acct_i",
633
- currency: "usd",
634
- amount_due: 1000,
635
- amount_paid: 1000,
636
- status: "paid",
637
- period_start: 1700000000,
638
- period_end: 1702592000,
639
- hosted_invoice_url: "https://inv",
640
- invoice_pdf: "https://pdf",
641
- metadata: {},
642
- parent: { subscription_details: { subscription: "sub_parent" } },
643
- }),
644
- );
645
-
646
- const { path, data } = dispatchedPayload(whCtx.ctx);
647
- expect(path).toBe("betterStripe/billing/mutations/upsertInvoice");
648
- expect(data).toMatchObject({
649
- stripeInvoiceId: "in_1",
650
- accountId: "acct_i",
651
- subscriptionId: "sub_parent",
652
- status: "paid",
653
- amountDue: 1000,
654
- amountPaid: 1000,
655
- });
656
- });
657
-
658
- it("defaults a missing invoice status to draft, derives accountId from an expanded customer, and leaves subscriptionId undefined", async () => {
659
- const whCtx = makeWhCtx();
660
- await processEvent(
661
- whCtx,
662
- event("invoice.created", {
663
- id: "in_2",
664
- customer: { id: "acct_obj_i" },
665
- currency: "usd",
666
- amount_due: 0,
667
- amount_paid: 0,
668
- status: null,
669
- period_start: null,
670
- period_end: null,
671
- metadata: {},
672
- }),
673
- );
674
- const { data } = dispatchedPayload(whCtx.ctx);
675
- expect(data.status).toBe("draft");
676
- expect(data.accountId).toBe("acct_obj_i");
677
- expect(data.subscriptionId).toBeUndefined();
678
- });
679
-
680
- it("prefers the V2 customer_account over the legacy customer id", async () => {
681
- const whCtx = makeWhCtx();
682
- await processEvent(
683
- whCtx,
684
- event("invoice.paid", {
685
- id: "in_3",
686
- customer: "cus_legacy",
687
- customer_account: "acct_v2",
688
- currency: "usd",
689
- amount_due: 0,
690
- amount_paid: 0,
691
- status: "paid",
692
- period_start: null,
693
- period_end: null,
694
- metadata: {},
695
- }),
696
- );
697
- expect(dispatchedPayload(whCtx.ctx).data.accountId).toBe("acct_v2");
698
- });
699
-
700
- // BTS-33: a failed subscription charge transitions the invoice (Stripe leaves
701
- // it `open` for retry) and carries the smart-retry schedule so a dunning hook
702
- // can surface when Stripe will try again.
703
- it("transitions state and surfaces retry metadata on invoice.payment_failed", async () => {
704
- const whCtx = makeWhCtx();
705
- await processEvent(
706
- whCtx,
707
- event("invoice.payment_failed", {
708
- id: "in_failed",
709
- customer: "acct_i",
710
- currency: "usd",
711
- amount_due: 5000,
712
- amount_paid: 0,
713
- status: "open",
714
- attempt_count: 1,
715
- next_payment_attempt: 1700003600,
716
- period_start: null,
717
- period_end: null,
718
- metadata: {},
719
- parent: { subscription_details: { subscription: "sub_delinquent" } },
720
- }),
721
- );
722
-
723
- const { path, data } = dispatchedPayload(whCtx.ctx);
724
- expect(path).toBe("betterStripe/billing/mutations/upsertInvoice");
725
- expect(data).toMatchObject({
726
- stripeInvoiceId: "in_failed",
727
- subscriptionId: "sub_delinquent",
728
- status: "open",
729
- amountPaid: 0,
730
- attemptCount: 1,
731
- });
732
- expect(data.nextPaymentAttempt).toBe(
733
- new Date(1700003600 * 1000).toISOString(),
734
- );
735
- });
736
- });
737
-
738
- describe("processEvent — payments (status collapse)", () => {
739
- const base = {
740
- id: "pi_1",
741
- customer: "acct_p",
742
- amount: 2000,
743
- currency: "usd",
744
- metadata: {},
745
- };
746
-
747
- it.each([
748
- ["succeeded", "succeeded"],
749
- ["canceled", "canceled"],
750
- ["processing", "processing"],
751
- ["requires_action", "requires_action"],
752
- ["requires_confirmation", "requires_action"],
753
- ["requires_payment_method", "requires_action"],
754
- ["requires_capture", "requires_action"],
755
- ])(
756
- "maps Stripe status %s to app status %s",
757
- async (stripeStatus, expected) => {
758
- const whCtx = makeWhCtx();
759
- await processEvent(
760
- whCtx,
761
- event("payment_intent.succeeded", { ...base, status: stripeStatus }),
762
- );
763
- expect(dispatchedPayload(whCtx.ctx).data.status).toBe(expected);
764
- },
765
- );
766
-
767
- it("maps any unrecognized status to failed", async () => {
768
- const whCtx = makeWhCtx();
769
- await processEvent(
770
- whCtx,
771
- event("payment_intent.payment_failed", {
772
- ...base,
773
- status: "some_new_state",
774
- }),
775
- );
776
- const { path, data } = dispatchedPayload(whCtx.ctx);
777
- expect(path).toBe("betterStripe/connect/mutations/upsertPayment");
778
- expect(data.status).toBe("failed");
779
- });
780
-
781
- it("prefers the V2 customer_account over the legacy customer id", async () => {
782
- const whCtx = makeWhCtx();
783
- await processEvent(
784
- whCtx,
785
- event("payment_intent.succeeded", {
786
- ...base,
787
- customer: "cus_legacy",
788
- customer_account: "acct_v2",
789
- status: "succeeded",
790
- }),
791
- );
792
- expect(dispatchedPayload(whCtx.ctx).data.accountId).toBe("acct_v2");
793
- });
794
- });
795
-
796
- describe("processEvent — payouts", () => {
797
- function context(id: string, status = "paid") {
798
- const whCtx = makeWhCtx();
799
- whCtx.ctx.runMutation.mockResolvedValue(1 as never);
800
- whCtx.stripe.payouts.retrieve.mockResolvedValue({
801
- id,
802
- amount: 5000,
803
- currency: "usd",
804
- status,
805
- arrival_date: 1700000000,
806
- automatic: true,
807
- method: "standard",
808
- metadata: { accountId: "acct_untrusted" },
809
- });
810
- return whCtx;
811
- }
812
- it("scopes connected provider reads to the signed event account", async () => {
813
- const whCtx = context("po_connected");
814
- const payoutEvent = event("payout.paid", {
815
- id: "po_connected",
816
- destination: "ba_bank",
817
- metadata: { accountId: "acct_untrusted" },
818
- });
819
- payoutEvent.account = "acct_store";
820
- await processEvent(whCtx, payoutEvent);
821
- expect(whCtx.stripe.payouts.retrieve).toHaveBeenCalledWith(
822
- "po_connected",
823
- {},
824
- { stripeAccount: "acct_store" },
825
- );
826
- expect(dispatchedPayload(whCtx.ctx, 1).data).toMatchObject({
827
- accountId: "acct_store",
828
- generation: 1,
829
- payout: { status: "paid", accountId: "acct_store" },
830
- });
831
- });
832
- it("uses explicit platform scope instead of a bank destination or metadata account", async () => {
833
- const whCtx = context("po_1");
834
- await processEvent(
835
- whCtx,
836
- event("payout.paid", {
837
- id: "po_1",
838
- destination: "ba_123",
839
- status: "pending",
840
- metadata: { accountId: "acct_forged" },
841
- }),
842
- );
843
- const { path, data } = dispatchedPayload(whCtx.ctx, 1);
844
- expect(path).toBe("betterStripe/payoutSync/mutations/finish");
845
- expect(data).toMatchObject({
846
- stripePayoutId: "po_1",
847
- accountId: "platform",
848
- generation: 1,
849
- payout: { status: "paid", amount: 5000, accountId: "platform" },
850
- });
851
- expect(whCtx.stripe.payouts.retrieve).toHaveBeenCalledWith("po_1", {}, {});
852
- });
853
- it("ignores malformed stale event fields when the current platform payout is valid", async () => {
854
- const whCtx = context("po_2", "failed");
855
- await processEvent(
856
- whCtx,
857
- event("payout.failed", {
858
- id: "po_2",
859
- destination: {},
860
- arrival_date: null,
861
- metadata: {},
862
- }),
863
- );
864
- expect(dispatchedPayload(whCtx.ctx, 1).data).toMatchObject({
865
- accountId: "platform",
866
- payout: { status: "failed", arrivalDate: "2023-11-14T22:13:20.000Z" },
867
- });
868
- });
869
- });
870
-
871
- describe("processEvent — unhandled", () => {
872
- it("logs and dispatches nothing for an unknown event type", async () => {
873
- const info = vi.spyOn(console, "info").mockImplementation(() => {});
874
- const whCtx = makeWhCtx();
875
- await processEvent(whCtx, event("customer.created", { id: "cus_1" }));
876
- expect(whCtx.ctx.runMutation).not.toHaveBeenCalled();
877
- expect(info).toHaveBeenCalledWith(
878
- expect.stringContaining("Unhandled event type: customer.created"),
879
- );
880
- });
881
- });
882
-
883
- describe("processEvent — fee & transfer capture (BTS-20)", () => {
884
- it("denormalizes application_fee + transfer destination onto a payment", async () => {
885
- const whCtx = makeWhCtx();
886
- await processEvent(
887
- whCtx,
888
- event("payment_intent.succeeded", {
889
- id: "pi_fee",
890
- amount: 10000,
891
- currency: "usd",
892
- status: "succeeded",
893
- application_fee_amount: 1000,
894
- transfer_data: { destination: "acct_store" },
895
- metadata: {},
896
- }),
897
- );
898
- expect(dispatchedPayload(whCtx.ctx).data).toMatchObject({
899
- stripePaymentIntentId: "pi_fee",
900
- chargeType: "destination",
901
- destinationAccountId: "acct_store",
902
- applicationFeeAmount: 1000,
903
- feeCollectedAmount: 1000,
904
- });
905
- });
906
-
907
- it("handles a transfer destination given as an expanded object", async () => {
908
- const whCtx = makeWhCtx();
909
- await processEvent(
910
- whCtx,
911
- event("payment_intent.succeeded", {
912
- id: "pi_fee2",
913
- amount: 10000,
914
- currency: "usd",
915
- status: "succeeded",
916
- transfer_data: { destination: { id: "acct_store" } },
917
- metadata: {},
918
- }),
919
- );
920
- expect(dispatchedPayload(whCtx.ctx).data.destinationAccountId).toBe(
921
- "acct_store",
922
- );
923
- });
924
-
925
- it("leaves fee fields unset for a plain payment", async () => {
926
- const whCtx = makeWhCtx();
927
- await processEvent(
928
- whCtx,
929
- event("payment_intent.succeeded", {
930
- id: "pi_plain",
931
- amount: 10000,
932
- currency: "usd",
933
- status: "succeeded",
934
- metadata: {},
935
- }),
936
- );
937
- const { data } = dispatchedPayload(whCtx.ctx);
938
- expect(data.chargeType).toBeUndefined();
939
- expect(data.destinationAccountId).toBeUndefined();
940
- expect(data.applicationFeeAmount).toBeUndefined();
941
- });
942
-
943
- it("does not denormalize fees for a non-succeeded payment intent", async () => {
944
- const whCtx = makeWhCtx();
945
- await processEvent(
946
- whCtx,
947
- event("payment_intent.payment_failed", {
948
- id: "pi_failed",
949
- amount: 10000,
950
- currency: "usd",
951
- status: "requires_payment_method",
952
- application_fee_amount: 1000,
953
- transfer_data: { destination: "acct_store" },
954
- metadata: {},
955
- }),
956
- );
957
- const { data } = dispatchedPayload(whCtx.ctx);
958
- expect(data.status).toBe("requires_action"); // requires_payment_method → requires_action
959
- expect(data.feeCollectedAmount).toBeUndefined();
960
- expect(data.applicationFeeAmount).toBeUndefined();
961
- expect(data.destinationAccountId).toBeUndefined();
962
- expect(data.chargeType).toBeUndefined();
963
- });
964
-
965
- // Note: the platform fee lives on the charge/PaymentIntent, not the typed
966
- // Stripe.Invoice, so fee denormalization is captured on the `payments` row
967
- // (above) rather than the invoice.
968
- });
969
-
970
- describe("processEvent — split transfer engine (BTS-22)", () => {
971
- it("fans funds out to recipients on a separate-charges payment_intent.succeeded", async () => {
972
- const stripe = makeStripe();
973
- const whCtx = makeWhCtx({ stripe });
974
-
975
- await processEvent(
976
- whCtx,
977
- event("payment_intent.succeeded", {
978
- id: "pi_split",
979
- amount: 10000,
980
- currency: "usd",
981
- status: "succeeded",
982
- latest_charge: "ch_split",
983
- metadata: {
984
- bsChargeType: "separate",
985
- bsFeeConfig: JSON.stringify({ percent: 10 }),
986
- bsSplit: JSON.stringify([
987
- { destinationAccountId: "acct_store", role: "store", percent: 80 },
988
- { destinationAccountId: "acct_aff", role: "affiliate", percent: 5 },
989
- ]),
990
- },
991
- }),
992
- );
993
-
994
- expect(stripe.transfers.create).toHaveBeenCalledTimes(2);
995
- expect(stripe.transfers.create.mock.calls[0][0]).toMatchObject({
996
- amount: 8000,
997
- destination: "acct_store",
998
- source_transaction: "ch_split",
999
- });
1000
- expect(stripe.transfers.create.mock.calls[1][0]).toMatchObject({
1001
- amount: 500,
1002
- destination: "acct_aff",
1003
- });
1004
- });
1005
-
1006
- it("throws (not silently skips) when a separate sale has no latest_charge", async () => {
1007
- const stripe = makeStripe();
1008
- const whCtx = makeWhCtx({ stripe });
1009
-
1010
- await expect(
1011
- processEvent(
1012
- whCtx,
1013
- event("payment_intent.succeeded", {
1014
- id: "pi_nocharge",
1015
- amount: 10000,
1016
- currency: "usd",
1017
- status: "succeeded",
1018
- latest_charge: null,
1019
- metadata: {
1020
- bsChargeType: "separate",
1021
- bsSplit: JSON.stringify([
1022
- {
1023
- destinationAccountId: "acct_store",
1024
- role: "store",
1025
- percent: 90,
1026
- },
1027
- ]),
1028
- },
1029
- }),
1030
- ),
1031
- ).rejects.toThrow(/latest_charge|transfer/i);
1032
- });
1033
-
1034
- it("throws when a separate sale has malformed bsSplit metadata", async () => {
1035
- const stripe = makeStripe();
1036
- const whCtx = makeWhCtx({ stripe });
1037
-
1038
- await expect(
1039
- processEvent(
1040
- whCtx,
1041
- event("payment_intent.succeeded", {
1042
- id: "pi_badjson",
1043
- amount: 10000,
1044
- currency: "usd",
1045
- status: "succeeded",
1046
- latest_charge: "ch_x",
1047
- metadata: { bsChargeType: "separate", bsSplit: "{not-json" },
1048
- }),
1049
- ),
1050
- ).rejects.toThrow(/malformed/i);
1051
- expect(stripe.transfers.create).not.toHaveBeenCalled();
1052
- });
1053
-
1054
- it("splits a recurring subscription invoice on invoice.paid (BTS-52)", async () => {
1055
- const stripe = makeStripe();
1056
- stripe.subscriptions.retrieve.mockResolvedValue({
1057
- id: "sub_1",
1058
- metadata: {
1059
- bsChargeType: "separate",
1060
- bsFeeConfig: JSON.stringify({ percent: 10 }),
1061
- bsSplit: JSON.stringify([
1062
- { destinationAccountId: "acct_store", role: "store", percent: 80 },
1063
- { destinationAccountId: "acct_aff", role: "affiliate", percent: 5 },
1064
- ]),
1065
- },
1066
- });
1067
- const whCtx = makeWhCtx({ stripe });
1068
-
1069
- await processEvent(
1070
- whCtx,
1071
- event("invoice.paid", {
1072
- id: "in_1",
1073
- currency: "usd",
1074
- amount_due: 10000,
1075
- amount_paid: 10000,
1076
- status: "paid",
1077
- metadata: {},
1078
- parent: { subscription_details: { subscription: "sub_1" } },
1079
- }),
1080
- );
1081
-
1082
- expect(stripe.transfers.create).toHaveBeenCalledTimes(2);
1083
- expect(stripe.transfers.create.mock.calls[0][0]).toMatchObject({
1084
- amount: 8000,
1085
- destination: "acct_store",
1086
- source_transaction: "ch_inv",
1087
- });
1088
- expect(stripe.transfers.create.mock.calls[1][0]).toMatchObject({
1089
- amount: 500,
1090
- destination: "acct_aff",
1091
- });
1092
- });
1093
-
1094
- it("skips a zero-amount invoice without throwing (no charge to split)", async () => {
1095
- const stripe = makeStripe();
1096
- stripe.subscriptions.retrieve.mockResolvedValue({
1097
- id: "sub_1",
1098
- metadata: {
1099
- bsChargeType: "separate",
1100
- bsSplit: JSON.stringify([
1101
- { destinationAccountId: "acct_store", role: "store", percent: 80 },
1102
- ]),
1103
- },
1104
- });
1105
- const whCtx = makeWhCtx({ stripe });
1106
-
1107
- await processEvent(
1108
- whCtx,
1109
- event("invoice.paid", {
1110
- id: "in_zero",
1111
- currency: "usd",
1112
- amount_due: 0,
1113
- amount_paid: 0, // 100%-off coupon / credit → no charge
1114
- status: "paid",
1115
- metadata: {},
1116
- parent: { subscription_details: { subscription: "sub_1" } },
1117
- }),
1118
- );
1119
- // No charge resolution, no transfers, no throw.
1120
- expect(stripe.invoicePayments.list).not.toHaveBeenCalled();
1121
- expect(stripe.transfers.create).not.toHaveBeenCalled();
1122
- });
1123
-
1124
- it("does not split a normal (non-separate) subscription invoice", async () => {
1125
- const stripe = makeStripe();
1126
- stripe.subscriptions.retrieve.mockResolvedValue({
1127
- id: "sub_1",
1128
- metadata: {},
1129
- });
1130
- const whCtx = makeWhCtx({ stripe });
1131
-
1132
- await processEvent(
1133
- whCtx,
1134
- event("invoice.paid", {
1135
- id: "in_2",
1136
- currency: "usd",
1137
- amount_due: 10000,
1138
- amount_paid: 10000,
1139
- status: "paid",
1140
- metadata: {},
1141
- parent: { subscription_details: { subscription: "sub_1" } },
1142
- }),
1143
- );
1144
- expect(stripe.transfers.create).not.toHaveBeenCalled();
1145
- });
1146
-
1147
- it("[BTS-27] claws back the charge's transfers on charge.dispute.created", async () => {
1148
- const stripe = makeStripe();
1149
- // The charge funded a store + affiliate transfer.
1150
- const ctx = makeCtx({
1151
- query: [
1152
- {
1153
- stripeTransferId: "tr_store",
1154
- destinationAccountId: "acct_store",
1155
- role: "store",
1156
- amount: 8000,
1157
- },
1158
- {
1159
- stripeTransferId: "tr_aff",
1160
- destinationAccountId: "acct_aff",
1161
- role: "affiliate",
1162
- amount: 1000,
1163
- },
1164
- ],
1165
- });
1166
- const whCtx = makeWhCtx({ stripe, ctx });
1167
-
1168
- await processEvent(
1169
- whCtx,
1170
- event("charge.dispute.created", {
1171
- id: "dp_1",
1172
- charge: "ch_1",
1173
- amount: 9000,
1174
- currency: "usd",
1175
- status: "needs_response",
1176
- reason: "fraudulent",
1177
- is_charge_refundable: true,
1178
- evidence_details: { due_by: 1700000000 },
1179
- metadata: {},
1180
- }),
1181
- );
1182
-
1183
- // Both recipient transfers reversed, with the dispute id as the idempotency op.
1184
- expect(stripe.transfers.createReversal).toHaveBeenCalledWith(
1185
- "tr_store",
1186
- { amount: 8000 },
1187
- { idempotencyKey: "bs_rev_dp_1_tr_store" },
1188
- );
1189
- expect(stripe.transfers.createReversal).toHaveBeenCalledWith(
1190
- "tr_aff",
1191
- { amount: 1000 },
1192
- { idempotencyKey: "bs_rev_dp_1_tr_aff" },
1193
- );
1194
- });
1195
-
1196
- it("does not claw back transfers on a dispute that isn't newly created", async () => {
1197
- const stripe = makeStripe();
1198
- const ctx = makeCtx({
1199
- query: [
1200
- {
1201
- stripeTransferId: "tr_store",
1202
- destinationAccountId: "acct_store",
1203
- role: "store",
1204
- amount: 8000,
1205
- },
1206
- ],
1207
- });
1208
- const whCtx = makeWhCtx({ stripe, ctx });
1209
-
1210
- await processEvent(
1211
- whCtx,
1212
- event("charge.dispute.updated", {
1213
- id: "dp_2",
1214
- charge: "ch_1",
1215
- amount: 8000,
1216
- currency: "usd",
1217
- status: "under_review",
1218
- reason: "fraudulent",
1219
- is_charge_refundable: true,
1220
- evidence_details: { due_by: 1700000000 },
1221
- metadata: {},
1222
- }),
1223
- );
1224
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
1225
- });
1226
-
1227
- it("[BTS-29] reinstates transfers when a dispute closes as won", async () => {
1228
- const stripe = makeStripe();
1229
- const ctx = makeCtx({
1230
- query: [
1231
- {
1232
- stripeTransferId: "tr_store",
1233
- destinationAccountId: "acct_store",
1234
- role: "store",
1235
- amount: 8000,
1236
- currency: "usd",
1237
- reversedAmount: 8000,
1238
- },
1239
- ],
1240
- });
1241
- const whCtx = makeWhCtx({ stripe, ctx });
1242
-
1243
- await processEvent(
1244
- whCtx,
1245
- event("charge.dispute.closed", {
1246
- id: "dp_1",
1247
- charge: "ch_1",
1248
- amount: 8000,
1249
- currency: "usd",
1250
- status: "won",
1251
- reason: "fraudulent",
1252
- is_charge_refundable: true,
1253
- evidence_details: { due_by: 1700000000 },
1254
- metadata: {},
1255
- }),
1256
- );
1257
-
1258
- expect(stripe.transfers.create).toHaveBeenCalledWith(
1259
- expect.objectContaining({ amount: 8000, destination: "acct_store" }),
1260
- { idempotencyKey: "bs_reinstate_dp_1_acct_store_store" },
1261
- );
1262
- });
1263
-
1264
- it("[BTS-29] does not reinstate when a dispute closes as lost", async () => {
1265
- const stripe = makeStripe();
1266
- const ctx = makeCtx({
1267
- query: [
1268
- {
1269
- stripeTransferId: "tr_store",
1270
- destinationAccountId: "acct_store",
1271
- role: "store",
1272
- amount: 8000,
1273
- currency: "usd",
1274
- reversedAmount: 8000,
1275
- },
1276
- ],
1277
- });
1278
- const whCtx = makeWhCtx({ stripe, ctx });
1279
-
1280
- await processEvent(
1281
- whCtx,
1282
- event("charge.dispute.closed", {
1283
- id: "dp_2",
1284
- charge: "ch_1",
1285
- amount: 8000,
1286
- currency: "usd",
1287
- status: "lost",
1288
- reason: "fraudulent",
1289
- is_charge_refundable: true,
1290
- evidence_details: { due_by: 1700000000 },
1291
- metadata: {},
1292
- }),
1293
- );
1294
- expect(stripe.transfers.create).not.toHaveBeenCalled();
1295
- });
1296
-
1297
- it("[BTS-28] cancels the disputed subscription at period end (default)", async () => {
1298
- const stripe = makeStripe();
1299
- stripe.invoicePayments.list.mockResolvedValue({
1300
- data: [{ invoice: "in_1", payment: { charge: "ch_1" } }],
1301
- });
1302
- stripe.invoices.retrieve.mockResolvedValue({
1303
- id: "in_1",
1304
- parent: { subscription_details: { subscription: "sub_1" } },
1305
- });
1306
- const whCtx = makeWhCtx({ stripe });
1307
-
1308
- await processEvent(
1309
- whCtx,
1310
- event("charge.dispute.created", {
1311
- id: "dp_1",
1312
- charge: "ch_1",
1313
- payment_intent: "pi_1",
1314
- amount: 5000,
1315
- currency: "usd",
1316
- status: "needs_response",
1317
- reason: "fraudulent",
1318
- is_charge_refundable: true,
1319
- evidence_details: { due_by: 1700000000 },
1320
- metadata: {},
1321
- }),
1322
- );
1323
-
1324
- expect(stripe.subscriptions.update).toHaveBeenCalledWith(
1325
- "sub_1",
1326
- { cancel_at_period_end: true },
1327
- { idempotencyKey: "bs_dispute_cancel_dp_1" },
1328
- );
1329
- expect(stripe.subscriptions.cancel).not.toHaveBeenCalled();
1330
- });
1331
-
1332
- it("[BTS-28] does not cancel when autoCancelOnDispute is off", async () => {
1333
- const stripe = makeStripe();
1334
- stripe.invoicePayments.list.mockResolvedValue({
1335
- data: [{ invoice: "in_1", payment: { charge: "ch_1" } }],
1336
- });
1337
- stripe.invoices.retrieve.mockResolvedValue({
1338
- id: "in_1",
1339
- parent: { subscription_details: { subscription: "sub_1" } },
1340
- });
1341
- const whCtx = makeWhCtx({ stripe, config: { autoCancelOnDispute: false } });
1342
-
1343
- await processEvent(
1344
- whCtx,
1345
- event("charge.dispute.created", {
1346
- id: "dp_2",
1347
- charge: "ch_1",
1348
- payment_intent: "pi_1",
1349
- amount: 5000,
1350
- currency: "usd",
1351
- status: "needs_response",
1352
- reason: "fraudulent",
1353
- is_charge_refundable: true,
1354
- evidence_details: { due_by: 1700000000 },
1355
- metadata: {},
1356
- }),
1357
- );
1358
- expect(stripe.subscriptions.update).not.toHaveBeenCalled();
1359
- });
1360
-
1361
- it("[BTS-28] cancels immediately when configured", async () => {
1362
- const stripe = makeStripe();
1363
- stripe.invoicePayments.list.mockResolvedValue({
1364
- data: [{ invoice: "in_1", payment: { charge: "ch_1" } }],
1365
- });
1366
- stripe.invoices.retrieve.mockResolvedValue({
1367
- id: "in_1",
1368
- parent: { subscription_details: { subscription: "sub_1" } },
1369
- });
1370
- const whCtx = makeWhCtx({
1371
- stripe,
1372
- config: { cancelDisputedSubscriptionImmediately: true },
1373
- });
1374
-
1375
- await processEvent(
1376
- whCtx,
1377
- event("charge.dispute.created", {
1378
- id: "dp_3",
1379
- charge: "ch_1",
1380
- payment_intent: "pi_1",
1381
- amount: 5000,
1382
- currency: "usd",
1383
- status: "needs_response",
1384
- reason: "fraudulent",
1385
- is_charge_refundable: true,
1386
- evidence_details: { due_by: 1700000000 },
1387
- metadata: {},
1388
- }),
1389
- );
1390
- expect(stripe.subscriptions.cancel).toHaveBeenCalledWith(
1391
- "sub_1",
1392
- undefined,
1393
- { idempotencyKey: "bs_dispute_cancel_dp_3" },
1394
- );
1395
- });
1396
-
1397
- it("[BTS-26] stores the charge's statement descriptor on the dispute", async () => {
1398
- const stripe = makeStripe();
1399
- stripe.charges.retrieve.mockResolvedValue({
1400
- id: "ch_1",
1401
- calculated_statement_descriptor: "ACME STORE",
1402
- });
1403
- const whCtx = makeWhCtx({ stripe });
1404
-
1405
- await processEvent(
1406
- whCtx,
1407
- event("charge.dispute.created", {
1408
- id: "dp_desc",
1409
- charge: "ch_1",
1410
- amount: 5000,
1411
- currency: "usd",
1412
- status: "needs_response",
1413
- reason: "fraudulent",
1414
- is_charge_refundable: true,
1415
- evidence_details: { due_by: 1700000000 },
1416
- metadata: {},
1417
- }),
1418
- );
1419
- const { data } = dispatchedPayload(whCtx.ctx);
1420
- expect(data.statementDescriptor).toBe("ACME STORE");
1421
- });
1422
-
1423
- it("records the dispute but retries recovery when the charge basis is unavailable", async () => {
1424
- const stripe = makeStripe();
1425
- stripe.charges.retrieve.mockRejectedValue(new Error("stripe down"));
1426
- const ctx = makeCtx({
1427
- query: [
1428
- {
1429
- stripeTransferId: "tr_store",
1430
- destinationAccountId: "acct_store",
1431
- role: "store",
1432
- amount: 9000,
1433
- },
1434
- ],
1435
- });
1436
- const whCtx = makeWhCtx({ stripe, ctx });
1437
-
1438
- await expect(
1439
- processEvent(
1440
- whCtx,
1441
- event("charge.dispute.created", {
1442
- id: "dp_bf",
1443
- charge: "ch_1",
1444
- amount: 9000,
1445
- currency: "usd",
1446
- status: "needs_response",
1447
- reason: "fraudulent",
1448
- is_charge_refundable: true,
1449
- evidence_details: { due_by: 1700000000 },
1450
- metadata: {},
1451
- }),
1452
- ),
1453
- ).rejects.toThrow("stripe down");
1454
-
1455
- // Record the dispute, but require an authoritative basis before recovery.
1456
- const { path, data } = dispatchedPayload(whCtx.ctx);
1457
- expect(path).toBe("betterStripe/connect/mutations/upsertDispute");
1458
- expect(data.statementDescriptor).toBeUndefined();
1459
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
1460
- });
1461
-
1462
- it("[BTS-27] claws back a single-recipient transfer on dispute", async () => {
1463
- const stripe = makeStripe();
1464
- const ctx = makeCtx({
1465
- query: [
1466
- {
1467
- stripeTransferId: "tr_only",
1468
- destinationAccountId: "acct_store",
1469
- role: "store",
1470
- amount: 9000,
1471
- },
1472
- ],
1473
- });
1474
- const whCtx = makeWhCtx({ stripe, ctx });
1475
-
1476
- await processEvent(
1477
- whCtx,
1478
- event("charge.dispute.created", {
1479
- id: "dp_single",
1480
- charge: "ch_1",
1481
- amount: 9000,
1482
- currency: "usd",
1483
- status: "needs_response",
1484
- reason: "fraudulent",
1485
- is_charge_refundable: true,
1486
- evidence_details: { due_by: 1700000000 },
1487
- metadata: {},
1488
- }),
1489
- );
1490
-
1491
- expect(stripe.transfers.createReversal).toHaveBeenCalledTimes(1);
1492
- expect(stripe.transfers.createReversal).toHaveBeenCalledWith(
1493
- "tr_only",
1494
- { amount: 9000 },
1495
- { idempotencyKey: "bs_rev_dp_single_tr_only" },
1496
- );
1497
- });
1498
-
1499
- it("[BTS-26] populates evidenceDueBy from the dispute's evidence_details", async () => {
1500
- const whCtx = makeWhCtx();
1501
- await processEvent(
1502
- whCtx,
1503
- event("charge.dispute.created", {
1504
- id: "dp_1",
1505
- charge: "ch_1",
1506
- payment_intent: "pi_1",
1507
- amount: 5000,
1508
- currency: "usd",
1509
- status: "needs_response",
1510
- reason: "fraudulent",
1511
- is_charge_refundable: true,
1512
- evidence_details: { due_by: 1700000000 },
1513
- metadata: {},
1514
- }),
1515
- );
1516
- const { path, data } = dispatchedPayload(whCtx.ctx);
1517
- expect(path).toBe("betterStripe/connect/mutations/upsertDispute");
1518
- expect(data.evidenceDueBy).toBe(new Date(1700000000 * 1000).toISOString());
1519
- });
1520
-
1521
- it("does not create transfers for a normal (non-split) payment", async () => {
1522
- const stripe = makeStripe();
1523
- const whCtx = makeWhCtx({ stripe });
1524
-
1525
- await processEvent(
1526
- whCtx,
1527
- event("payment_intent.succeeded", {
1528
- id: "pi_plain",
1529
- amount: 10000,
1530
- currency: "usd",
1531
- status: "succeeded",
1532
- latest_charge: "ch_plain",
1533
- metadata: {},
1534
- }),
1535
- );
1536
- expect(stripe.transfers.create).not.toHaveBeenCalled();
1537
- });
1538
- });
1539
-
1540
- describe("processEvent — per-invoice statement descriptor (BTS-32)", () => {
1541
- const subInvoice = (overrides: Record<string, unknown> = {}) => ({
1542
- id: "in_sd",
1543
- customer: "acct_buyer",
1544
- currency: "usd",
1545
- amount_due: 10000,
1546
- amount_paid: 0,
1547
- status: "draft",
1548
- metadata: {},
1549
- parent: { subscription_details: { subscription: "sub_sd" } },
1550
- ...overrides,
1551
- });
1552
-
1553
- it("sets the invoice statement_descriptor from the subscription's bsStatementDescriptor marker", async () => {
1554
- const stripe = makeStripe();
1555
- stripe.subscriptions.retrieve.mockResolvedValue({
1556
- id: "sub_sd",
1557
- metadata: { bsStatementDescriptor: "MAYAS FITNESS" },
1558
- });
1559
- const whCtx = makeWhCtx({ stripe });
1560
-
1561
- await processEvent(whCtx, event("invoice.created", subInvoice()));
1562
-
1563
- expect(stripe.invoices.update).toHaveBeenCalledWith("in_sd", {
1564
- statement_descriptor: "MAYAS FITNESS",
1565
- });
1566
- });
1567
-
1568
- it("coexists with the per-invoice fee: both updates land on a doubly-flagged subscription", async () => {
1569
- const stripe = makeStripe();
1570
- stripe.subscriptions.retrieve.mockResolvedValue({
1571
- id: "sub_sd",
1572
- metadata: {
1573
- bsFeeMode: "per_invoice",
1574
- bsFeeConfig: JSON.stringify({ percent: 2.9, fixed: 30 }),
1575
- bsStatementDescriptor: "MAYAS FITNESS",
1576
- },
1577
- });
1578
- const whCtx = makeWhCtx({ stripe });
1579
-
1580
- await processEvent(whCtx, event("invoice.created", subInvoice()));
1581
-
1582
- expect(stripe.invoices.update).toHaveBeenCalledWith("in_sd", {
1583
- application_fee_amount: 320,
1584
- metadata: { bsFeeApplied: "1" },
1585
- });
1586
- expect(stripe.invoices.update).toHaveBeenCalledWith("in_sd", {
1587
- statement_descriptor: "MAYAS FITNESS",
1588
- });
1589
- });
1590
-
1591
- it("does nothing when the subscription carries no descriptor marker", async () => {
1592
- const stripe = makeStripe();
1593
- stripe.subscriptions.retrieve.mockResolvedValue({
1594
- id: "sub_sd",
1595
- metadata: {},
1596
- });
1597
- const whCtx = makeWhCtx({ stripe });
1598
-
1599
- await processEvent(whCtx, event("invoice.created", subInvoice()));
1600
- expect(stripe.invoices.update).not.toHaveBeenCalled();
1601
- });
1602
-
1603
- it("never overwrites an already-set statement_descriptor (idempotent on retries)", async () => {
1604
- const stripe = makeStripe();
1605
- stripe.subscriptions.retrieve.mockResolvedValue({
1606
- id: "sub_sd",
1607
- metadata: { bsStatementDescriptor: "MAYAS FITNESS" },
1608
- });
1609
- const whCtx = makeWhCtx({ stripe });
1610
-
1611
- await processEvent(
1612
- whCtx,
1613
- event(
1614
- "invoice.created",
1615
- subInvoice({ statement_descriptor: "APP SET THIS" }),
1616
- ),
1617
- );
1618
- expect(stripe.invoices.update).not.toHaveBeenCalled();
1619
- });
1620
-
1621
- it("skips a marker that fails defensive validation instead of sending it to Stripe", async () => {
1622
- const stripe = makeStripe();
1623
- stripe.subscriptions.retrieve.mockResolvedValue({
1624
- id: "sub_sd",
1625
- // Should be impossible (validated at set time) but webhooks are
1626
- // defensive: never forward a rule-breaking descriptor.
1627
- metadata: { bsStatementDescriptor: "BAD*NAME" },
1628
- });
1629
- const whCtx = makeWhCtx({ stripe });
1630
-
1631
- await processEvent(whCtx, event("invoice.created", subInvoice()));
1632
- expect(stripe.invoices.update).not.toHaveBeenCalled();
1633
- });
1634
-
1635
- it("never breaks invoice processing when the descriptor update fails (cosmetic, reconciled next cycle)", async () => {
1636
- const stripe = makeStripe();
1637
- stripe.subscriptions.retrieve.mockResolvedValue({
1638
- id: "sub_sd",
1639
- metadata: { bsStatementDescriptor: "MAYAS FITNESS" },
1640
- });
1641
- stripe.invoices.update.mockRejectedValue(new Error("stripe down"));
1642
- const errSpy = vi.spyOn(console, "error").mockImplementation(() => {});
1643
- const whCtx = makeWhCtx({ stripe });
1644
-
1645
- await expect(
1646
- processEvent(whCtx, event("invoice.created", subInvoice())),
1647
- ).resolves.toBeUndefined();
1648
-
1649
- expect(errSpy).toHaveBeenCalled();
1650
- // The invoice row still lands in the component DB.
1651
- const paths = (whCtx.ctx.runMutation as ReturnType<typeof vi.fn>).mock
1652
- .calls;
1653
- expect(paths.length).toBeGreaterThan(0);
1654
- });
1655
- });
1656
-
1657
- describe("processEvent — per-invoice fixed/tier fee (BTS-51)", () => {
1658
- const flaggedInvoice = (overrides: Record<string, unknown> = {}) => ({
1659
- id: "in_fee",
1660
- customer: "acct_buyer",
1661
- currency: "usd",
1662
- amount_due: 10000,
1663
- amount_paid: 0,
1664
- status: "draft",
1665
- metadata: {},
1666
- parent: { subscription_details: { subscription: "sub_1" } },
1667
- ...overrides,
1668
- });
1669
-
1670
- it("applies a fixed/tier application_fee_amount on invoice.created for a flagged subscription", async () => {
1671
- const stripe = makeStripe();
1672
- stripe.subscriptions.retrieve.mockResolvedValue({
1673
- id: "sub_1",
1674
- metadata: {
1675
- bsFeeMode: "per_invoice",
1676
- bsFeeConfig: JSON.stringify({ percent: 2.9, fixed: 30 }),
1677
- },
1678
- });
1679
- const whCtx = makeWhCtx({ stripe });
1680
-
1681
- await processEvent(whCtx, event("invoice.created", flaggedInvoice()));
1682
-
1683
- // round(10000 * 0.029) + 30 = 320
1684
- expect(stripe.invoices.update).toHaveBeenCalledWith("in_fee", {
1685
- application_fee_amount: 320,
1686
- metadata: { bsFeeApplied: "1" },
1687
- });
1688
- });
1689
-
1690
- it("does nothing for a subscription that is not flagged", async () => {
1691
- const stripe = makeStripe();
1692
- stripe.subscriptions.retrieve.mockResolvedValue({
1693
- id: "sub_1",
1694
- metadata: {},
1695
- });
1696
- const whCtx = makeWhCtx({ stripe });
1697
-
1698
- await processEvent(whCtx, event("invoice.created", flaggedInvoice()));
1699
- expect(stripe.invoices.update).not.toHaveBeenCalled();
1700
- });
1701
-
1702
- it("is idempotent — skips invoices already marked bsFeeApplied", async () => {
1703
- const stripe = makeStripe();
1704
- // The BTS-32 descriptor processor shares this event and may retrieve the
1705
- // subscription; give it an unflagged sub so only the fee path is observed.
1706
- stripe.subscriptions.retrieve.mockResolvedValue({
1707
- id: "sub_1",
1708
- metadata: {},
1709
- });
1710
- const whCtx = makeWhCtx({ stripe });
1711
-
1712
- await processEvent(
1713
- whCtx,
1714
- event(
1715
- "invoice.created",
1716
- flaggedInvoice({ metadata: { bsFeeApplied: "1" } }),
1717
- ),
1718
- );
1719
- expect(stripe.invoices.update).not.toHaveBeenCalled();
1720
- });
1721
-
1722
- it("does not send a non-finite fee from a shape-invalid config", async () => {
1723
- const stripe = makeStripe();
1724
- stripe.subscriptions.retrieve.mockResolvedValue({
1725
- id: "sub_1",
1726
- metadata: {
1727
- bsFeeMode: "per_invoice",
1728
- // No `percent` → computeFee returns NaN; must not reach Stripe.
1729
- bsFeeConfig: JSON.stringify({ fixed: 30 }),
1730
- },
1731
- });
1732
- const whCtx = makeWhCtx({ stripe });
1733
-
1734
- await processEvent(whCtx, event("invoice.created", flaggedInvoice()));
1735
- expect(stripe.invoices.update).not.toHaveBeenCalled();
1736
- });
1737
-
1738
- it("does nothing for an invoice with no parent subscription", async () => {
1739
- const stripe = makeStripe();
1740
- const whCtx = makeWhCtx({ stripe });
1741
-
1742
- await processEvent(
1743
- whCtx,
1744
- event("invoice.created", flaggedInvoice({ parent: null })),
1745
- );
1746
- expect(stripe.subscriptions.retrieve).not.toHaveBeenCalled();
1747
- expect(stripe.invoices.update).not.toHaveBeenCalled();
1748
- });
1749
-
1750
- // BTS-68: the first subscription invoice is finalized (`open`) synchronously at
1751
- // creation, so `invoice.created` fires with a NON-draft invoice and the
1752
- // `invoices.update` that applies the fee is rejected by Stripe (monetary values
1753
- // are uneditable once finalized). This characterizes the silent miss the fix
1754
- // must compensate for elsewhere — it must not crash the webhook.
1755
- it("silently no-ops (no crash) when the first invoice is already finalized at invoice.created", async () => {
1756
- const stripe = makeStripe();
1757
- stripe.subscriptions.retrieve.mockResolvedValue({
1758
- id: "sub_1",
1759
- metadata: {
1760
- bsFeeMode: "per_invoice",
1761
- bsFeeConfig: JSON.stringify({ percent: 2.9, fixed: 30 }),
1762
- },
1763
- });
1764
- // Stripe rejects a monetary update on a finalized invoice.
1765
- stripe.invoices.update.mockRejectedValue(
1766
- new Error("This invoice is no longer a draft."),
1767
- );
1768
- const whCtx = makeWhCtx({ stripe });
1769
-
1770
- await expect(
1771
- processEvent(
1772
- whCtx,
1773
- event("invoice.created", flaggedInvoice({ status: "open" })),
1774
- ),
1775
- ).resolves.toBeUndefined();
1776
- // The fee was NOT collected on the first invoice via the draft path.
1777
- expect(stripe.invoices.update).toHaveBeenCalled(); // attempted, rejected
1778
- });
1779
- });
1780
-
1781
- describe("processEvent — first-invoice fee correction (BTS-68)", () => {
1782
- /** A paid first invoice for a per_invoice destination-charge subscription. */
1783
- const paidFirstInvoice = (overrides: Record<string, unknown> = {}) => ({
1784
- id: "in_first",
1785
- customer: "acct_buyer",
1786
- currency: "usd",
1787
- amount_due: 10000,
1788
- amount_paid: 10000,
1789
- status: "paid",
1790
- application_fee_amount: null,
1791
- metadata: {},
1792
- parent: { subscription_details: { subscription: "sub_1" } },
1793
- ...overrides,
1794
- });
1795
-
1796
- /** Flag sub_1 as per_invoice with the given fee config. */
1797
- function wireSub(
1798
- stripe: ReturnType<typeof makeStripe>,
1799
- config: unknown = { percent: 2.9, fixed: 30 },
1800
- ) {
1801
- stripe.subscriptions.retrieve.mockResolvedValue({
1802
- id: "sub_1",
1803
- metadata: {
1804
- bsFeeMode: "per_invoice",
1805
- bsFeeConfig: JSON.stringify(config),
1806
- },
1807
- });
1808
- }
1809
-
1810
- /** Wire the fresh-invoice retrieve + charge → transfer resolution. */
1811
- function wireInvoiceCharge(
1812
- stripe: ReturnType<typeof makeStripe>,
1813
- fresh: Record<string, unknown>,
1814
- ) {
1815
- stripe.invoices.retrieve.mockResolvedValue(fresh);
1816
- stripe.invoicePayments.list.mockResolvedValue({
1817
- data: [{ payment: { charge: "ch_first" } }],
1818
- });
1819
- stripe.charges.retrieve.mockResolvedValue({
1820
- id: "ch_first",
1821
- transfer: "tr_first",
1822
- });
1823
- }
1824
-
1825
- it("collects the first invoice's fixed/tier fee by reversing the destination transfer", async () => {
1826
- const stripe = makeStripe();
1827
- wireSub(stripe);
1828
- wireInvoiceCharge(stripe, paidFirstInvoice());
1829
- const whCtx = makeWhCtx({ stripe });
1830
-
1831
- await processEvent(whCtx, event("invoice.paid", paidFirstInvoice()));
1832
-
1833
- // round(10000 * 0.029) + 30 = 320, clawed back from the auto-transfer.
1834
- expect(stripe.transfers.createReversal).toHaveBeenCalledWith(
1835
- "tr_first",
1836
- { amount: 320, metadata: { bsFeeFor: "in_first" } },
1837
- { idempotencyKey: "bs_infee_in_first" },
1838
- );
1839
- // Marked collected on the invoice (metadata is editable post-finalization).
1840
- expect(stripe.invoices.update).toHaveBeenCalledWith(
1841
- "in_first",
1842
- expect.objectContaining({
1843
- metadata: expect.objectContaining({
1844
- bsFeeCollected: "1",
1845
- bsFeeAmount: "320",
1846
- }),
1847
- }),
1848
- );
1849
- });
1850
-
1851
- it("collects a tiered first-invoice fee (matching tier's percent + fixed)", async () => {
1852
- const stripe = makeStripe();
1853
- wireSub(stripe, {
1854
- percent: 10,
1855
- tiers: [
1856
- { upTo: 5000, percent: 5 },
1857
- { upTo: null, percent: 8, fixed: 100 },
1858
- ],
1859
- });
1860
- wireInvoiceCharge(stripe, paidFirstInvoice());
1861
- const whCtx = makeWhCtx({ stripe });
1862
-
1863
- await processEvent(whCtx, event("invoice.paid", paidFirstInvoice()));
1864
-
1865
- // amount 10000 → catch-all tier: round(10000 * 0.08) + 100 = 900
1866
- expect(stripe.transfers.createReversal).toHaveBeenCalledWith(
1867
- "tr_first",
1868
- expect.objectContaining({ amount: 900 }),
1869
- { idempotencyKey: "bs_infee_in_first" },
1870
- );
1871
- });
1872
-
1873
- it("does NOT reverse a renewal invoice that already carries application_fee_amount", async () => {
1874
- const stripe = makeStripe();
1875
- wireSub(stripe);
1876
- // Draft-window path already set the fee on this (renewal) invoice.
1877
- wireInvoiceCharge(
1878
- stripe,
1879
- paidFirstInvoice({ application_fee_amount: 320 }),
1880
- );
1881
- const whCtx = makeWhCtx({ stripe });
1882
-
1883
- await processEvent(whCtx, event("invoice.paid", paidFirstInvoice()));
1884
-
1885
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
1886
- expect(stripe.invoices.update).not.toHaveBeenCalled();
1887
- });
1888
-
1889
- it("does NOT reverse a renewal invoice already marked bsFeeApplied", async () => {
1890
- const stripe = makeStripe();
1891
- wireSub(stripe);
1892
- wireInvoiceCharge(
1893
- stripe,
1894
- paidFirstInvoice({ metadata: { bsFeeApplied: "1" } }),
1895
- );
1896
- const whCtx = makeWhCtx({ stripe });
1897
-
1898
- await processEvent(whCtx, event("invoice.paid", paidFirstInvoice()));
1899
-
1900
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
1901
- });
1902
-
1903
- it("does nothing for a subscription that is not flagged per_invoice (e.g. percent-only)", async () => {
1904
- const stripe = makeStripe();
1905
- stripe.subscriptions.retrieve.mockResolvedValue({
1906
- id: "sub_1",
1907
- metadata: {}, // percent-only fees ride application_fee_percent, not per_invoice
1908
- });
1909
- const whCtx = makeWhCtx({ stripe });
1910
-
1911
- await processEvent(whCtx, event("invoice.paid", paidFirstInvoice()));
1912
-
1913
- expect(stripe.invoices.retrieve).not.toHaveBeenCalled();
1914
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
1915
- });
1916
-
1917
- it("is idempotent — an invoice already marked bsFeeCollected is not reversed again", async () => {
1918
- const stripe = makeStripe();
1919
- wireSub(stripe);
1920
- wireInvoiceCharge(
1921
- stripe,
1922
- paidFirstInvoice({
1923
- metadata: { bsFeeCollected: "1", bsFeeAmount: "320" },
1924
- }),
1925
- );
1926
- const whCtx = makeWhCtx({ stripe });
1927
-
1928
- await processEvent(whCtx, event("invoice.paid", paidFirstInvoice()));
1929
-
1930
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
1931
- expect(stripe.invoices.update).not.toHaveBeenCalled();
1932
- });
1933
-
1934
- it("skips a zero-amount invoice (100%-off / trial) before touching the subscription", async () => {
1935
- const stripe = makeStripe();
1936
- const whCtx = makeWhCtx({ stripe });
1937
-
1938
- await processEvent(
1939
- whCtx,
1940
- event("invoice.paid", paidFirstInvoice({ amount_paid: 0 })),
1941
- );
1942
-
1943
- expect(stripe.subscriptions.retrieve).not.toHaveBeenCalled();
1944
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
1945
- });
1946
-
1947
- it("does not send a non-finite fee from a shape-invalid config", async () => {
1948
- const stripe = makeStripe();
1949
- // No `percent` → computeFee returns NaN; must never reach a reversal.
1950
- wireSub(stripe, { fixed: 30 });
1951
- wireInvoiceCharge(stripe, paidFirstInvoice());
1952
- const whCtx = makeWhCtx({ stripe });
1953
-
1954
- await processEvent(whCtx, event("invoice.paid", paidFirstInvoice()));
1955
-
1956
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
1957
- });
1958
-
1959
- it("logs and skips (no crash) when the charge has no destination transfer to reverse", async () => {
1960
- const err = vi.spyOn(console, "error").mockImplementation(() => {});
1961
- const stripe = makeStripe();
1962
- wireSub(stripe);
1963
- stripe.invoices.retrieve.mockResolvedValue(paidFirstInvoice());
1964
- stripe.invoicePayments.list.mockResolvedValue({
1965
- data: [{ payment: { charge: "ch_first" } }],
1966
- });
1967
- stripe.charges.retrieve.mockResolvedValue({ id: "ch_first" }); // no transfer
1968
- const whCtx = makeWhCtx({ stripe });
1969
-
1970
- await expect(
1971
- processEvent(whCtx, event("invoice.paid", paidFirstInvoice())),
1972
- ).resolves.toBeUndefined();
1973
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
1974
- expect(err).toHaveBeenCalled();
1975
- });
1976
-
1977
- it("propagates a reversal failure so the event is marked failed and Stripe retries", async () => {
1978
- const stripe = makeStripe();
1979
- wireSub(stripe);
1980
- wireInvoiceCharge(stripe, paidFirstInvoice());
1981
- stripe.transfers.createReversal.mockRejectedValue(new Error("stripe down"));
1982
- const whCtx = makeWhCtx({ stripe });
1983
-
1984
- // A swallowed failure would 200 → event ledger "processed" (terminal) → the
1985
- // first-invoice fee is lost forever. It must throw so Stripe retries.
1986
- await expect(
1987
- processEvent(whCtx, event("invoice.paid", paidFirstInvoice())),
1988
- ).rejects.toThrow("stripe down");
1989
- });
1990
-
1991
- it("[BTS-69] does NOT double-reverse when the marker write failed and bsFeeConfig was edited before a retry past the idempotency-key TTL", async () => {
1992
- const stripe = makeStripe();
1993
- wireSub(stripe, { percent: 2.9, fixed: 30 }); // first-delivery fee F1 = 320
1994
- wireInvoiceCharge(stripe, paidFirstInvoice());
1995
-
1996
- // Stateful reversal store: createReversal records, listReversals returns them
1997
- // — modelling that a reversal PERSISTS across webhook deliveries (Stripe's
1998
- // reversal ledger), independent of our bsFeeCollected invoice marker and of
1999
- // Stripe's ≤24h idempotency-key window.
2000
- const reversals: MockReversal[] = [];
2001
- stripe.transfers.createReversal.mockImplementation(
2002
- async (id: unknown, params: unknown) => {
2003
- const p = params as {
2004
- amount: number;
2005
- metadata?: Record<string, string>;
2006
- };
2007
- const rev: MockReversal = {
2008
- id: `trr_${reversals.length + 1}`,
2009
- amount: p.amount,
2010
- metadata: p.metadata ?? null,
2011
- _transfer: id as string,
2012
- };
2013
- reversals.push(rev);
2014
- return rev;
2015
- },
2016
- );
2017
- stripe.transfers.listReversals.mockImplementation(async (id: unknown) => ({
2018
- data: reversals.filter((r) => r._transfer === (id as string)),
2019
- }));
2020
-
2021
- const whCtx = makeWhCtx({ stripe });
2022
-
2023
- // ── Delivery 1: the reversal SUCCEEDS, then the bsFeeCollected marker write
2024
- // FAILS → the error propagates → the event is marked `failed`. So the money
2025
- // moved (F1=320 reversed) but the invoice was never marked collected.
2026
- stripe.invoices.update.mockRejectedValueOnce(
2027
- new Error("marker write failed"),
2028
- );
2029
- await expect(
2030
- processEvent(whCtx, event("invoice.paid", paidFirstInvoice())),
2031
- ).rejects.toThrow("marker write failed");
2032
- expect(stripe.transfers.createReversal).toHaveBeenCalledTimes(1);
2033
- expect(reversals).toHaveLength(1);
2034
-
2035
- // ── The platform edits bsFeeConfig before the retry, so a recompute would now
2036
- // produce a DIFFERENT fee (F2=900) — the config-drift that defeats Stripe's
2037
- // idempotency key once it expires.
2038
- wireSub(stripe, { percent: 8, fixed: 100 });
2039
- stripe.invoices.update.mockResolvedValue({}); // marker write now succeeds
2040
-
2041
- // ── Delivery 2: retry AFTER the idempotency key expired (the mock doesn't
2042
- // enforce keys, so a second createReversal WOULD land a real second reversal).
2043
- // The invoice still carries NO bsFeeCollected marker (delivery 1's write
2044
- // failed), so the marker guard can't save us. Only adopting the existing
2045
- // bsFeeFor:in_first reversal prevents the double collection.
2046
- await processEvent(whCtx, event("invoice.paid", paidFirstInvoice()));
2047
-
2048
- // THE INVARIANT: exactly ONE reversal across both deliveries — no double
2049
- // collection — and the recorded amount is the originally-reversed F1, not the
2050
- // drifted F2.
2051
- expect(stripe.transfers.createReversal).toHaveBeenCalledTimes(1);
2052
- expect(reversals).toHaveLength(1);
2053
- expect(reversals[0].amount).toBe(320);
2054
- // The retry re-records the marker with the actually-reversed amount.
2055
- expect(stripe.invoices.update).toHaveBeenCalledWith(
2056
- "in_first",
2057
- expect.objectContaining({
2058
- metadata: expect.objectContaining({
2059
- bsFeeCollected: "1",
2060
- bsFeeAmount: "320",
2061
- }),
2062
- }),
2063
- );
2064
- });
2065
- });
2066
-
2067
- describe("processEvent — per-charge fixed/tier fee (BTS-60)", () => {
2068
- /** A succeeded one-time destination-charge PI flagged for per-charge fee. */
2069
- const flaggedPi = (overrides: Record<string, unknown> = {}) => ({
2070
- id: "pi_fee",
2071
- amount: 10000,
2072
- currency: "usd",
2073
- status: "succeeded",
2074
- latest_charge: "ch_fee",
2075
- transfer_data: { destination: "acct_seller" },
2076
- metadata: {
2077
- bsFeeMode: "per_charge",
2078
- bsFeeConfig: JSON.stringify({ percent: 2.9, fixed: 30 }),
2079
- },
2080
- ...overrides,
2081
- });
2082
-
2083
- /** Wire the retrieve mocks for the happy path: fresh PI + charge w/ transfer. */
2084
- function wireHappyPath(
2085
- stripe: ReturnType<typeof makeStripe>,
2086
- pi: Record<string, unknown>,
2087
- opts: {
2088
- amountReceived?: number;
2089
- freshMetadata?: Record<string, string>;
2090
- } = {},
2091
- ) {
2092
- stripe.paymentIntents.retrieve.mockResolvedValue({
2093
- ...pi,
2094
- amount_received: opts.amountReceived ?? (pi.amount as number),
2095
- ...(opts.freshMetadata ? { metadata: opts.freshMetadata } : {}),
2096
- });
2097
- stripe.charges.retrieve.mockResolvedValue({
2098
- id: pi.latest_charge,
2099
- transfer: "tr_auto",
2100
- });
2101
- }
2102
-
2103
- it("collects a fixed fee by partially reversing the destination transfer", async () => {
2104
- const stripe = makeStripe();
2105
- const pi = flaggedPi();
2106
- wireHappyPath(stripe, pi);
2107
- const whCtx = makeWhCtx({ stripe });
2108
-
2109
- await processEvent(whCtx, event("payment_intent.succeeded", pi));
2110
-
2111
- // round(10000 * 0.029) + 30 = 320, clawed back from the auto-transfer.
2112
- expect(stripe.transfers.createReversal).toHaveBeenCalledWith(
2113
- "tr_auto",
2114
- expect.objectContaining({ amount: 320 }),
2115
- { idempotencyKey: "bs_pcfee_pi_fee" },
2116
- );
2117
- // Marked collected on the PI so retries beyond Stripe's idempotency window skip.
2118
- expect(stripe.paymentIntents.update).toHaveBeenCalledWith(
2119
- "pi_fee",
2120
- expect.objectContaining({
2121
- metadata: expect.objectContaining({
2122
- bsFeeCollected: "1",
2123
- bsFeeAmount: "320",
2124
- }),
2125
- }),
2126
- );
2127
- // Denormalized onto the payments row.
2128
- const { path, data } = dispatchedPayload(whCtx.ctx);
2129
- expect(path).toBe("betterStripe/connect/mutations/upsertPayment");
2130
- expect(data.feeCollectedAmount).toBe(320);
2131
- });
2132
-
2133
- it("collects a tiered fee (matching tier's percent + fixed)", async () => {
2134
- const stripe = makeStripe();
2135
- const pi = flaggedPi({
2136
- metadata: {
2137
- bsFeeMode: "per_charge",
2138
- bsFeeConfig: JSON.stringify({
2139
- percent: 10,
2140
- tiers: [
2141
- { upTo: 5000, percent: 5 },
2142
- { upTo: null, percent: 8, fixed: 100 },
2143
- ],
2144
- }),
2145
- },
2146
- });
2147
- wireHappyPath(stripe, pi);
2148
- const whCtx = makeWhCtx({ stripe });
2149
-
2150
- await processEvent(whCtx, event("payment_intent.succeeded", pi));
2151
-
2152
- // amount 10000 → catch-all tier: round(10000 * 0.08) + 100 = 900
2153
- expect(stripe.transfers.createReversal).toHaveBeenCalledWith(
2154
- "tr_auto",
2155
- expect.objectContaining({ amount: 900 }),
2156
- { idempotencyKey: "bs_pcfee_pi_fee" },
2157
- );
2158
- });
2159
-
2160
- it("computes the fee from the amount actually charged, not the list amount", async () => {
2161
- const stripe = makeStripe();
2162
- const pi = flaggedPi();
2163
- // A Checkout promotion code discounted the final charge to 8000.
2164
- wireHappyPath(stripe, pi, { amountReceived: 8000 });
2165
- const whCtx = makeWhCtx({ stripe });
2166
-
2167
- await processEvent(whCtx, event("payment_intent.succeeded", pi));
2168
-
2169
- // round(8000 * 0.029) + 30 = 262 — NOT 320 from the stale event amount.
2170
- expect(stripe.transfers.createReversal).toHaveBeenCalledWith(
2171
- "tr_auto",
2172
- expect.objectContaining({ amount: 262 }),
2173
- expect.anything(),
2174
- );
2175
- });
2176
-
2177
- it("is idempotent — a PI already marked bsFeeCollected is not reversed again", async () => {
2178
- const stripe = makeStripe();
2179
- const pi = flaggedPi();
2180
- // The fresh PI (not the stale event snapshot) carries the marker.
2181
- wireHappyPath(stripe, pi, {
2182
- freshMetadata: {
2183
- bsFeeMode: "per_charge",
2184
- bsFeeConfig: JSON.stringify({ percent: 2.9, fixed: 30 }),
2185
- bsFeeCollected: "1",
2186
- bsFeeAmount: "320",
2187
- },
2188
- });
2189
- const whCtx = makeWhCtx({ stripe });
2190
-
2191
- await processEvent(whCtx, event("payment_intent.succeeded", pi));
2192
-
2193
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
2194
- expect(stripe.paymentIntents.update).not.toHaveBeenCalled();
2195
- // The payments row still reflects the previously collected fee.
2196
- expect(dispatchedPayload(whCtx.ctx).data.feeCollectedAmount).toBe(320);
2197
- });
2198
-
2199
- it("does nothing for a PI without the per_charge marker", async () => {
2200
- const stripe = makeStripe();
2201
- const whCtx = makeWhCtx({ stripe });
2202
-
2203
- await processEvent(
2204
- whCtx,
2205
- event("payment_intent.succeeded", flaggedPi({ metadata: {} })),
2206
- );
2207
-
2208
- expect(stripe.paymentIntents.retrieve).not.toHaveBeenCalled();
2209
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
2210
- expect(
2211
- dispatchedPayload(whCtx.ctx).data.feeCollectedAmount,
2212
- ).toBeUndefined();
2213
- });
2214
-
2215
- it("swallows malformed bsFeeConfig without reversing or crashing", async () => {
2216
- const stripe = makeStripe();
2217
- const pi = flaggedPi({
2218
- metadata: { bsFeeMode: "per_charge", bsFeeConfig: "not json" },
2219
- });
2220
- wireHappyPath(stripe, pi);
2221
- const whCtx = makeWhCtx({ stripe });
2222
-
2223
- await expect(
2224
- processEvent(whCtx, event("payment_intent.succeeded", pi)),
2225
- ).resolves.toBeUndefined();
2226
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
2227
- });
2228
-
2229
- it("propagates a reversal failure so the event is marked failed and Stripe retries", async () => {
2230
- const stripe = makeStripe();
2231
- const pi = flaggedPi();
2232
- wireHappyPath(stripe, pi);
2233
- stripe.transfers.createReversal.mockRejectedValue(new Error("stripe down"));
2234
- const whCtx = makeWhCtx({ stripe });
2235
-
2236
- // A swallowed failure would 200 → event ledger "processed" (terminal) →
2237
- // the fee is silently lost forever. Throwing marks the event "failed",
2238
- // Stripe retries, and the whole case re-runs idempotently.
2239
- await expect(
2240
- processEvent(whCtx, event("payment_intent.succeeded", pi)),
2241
- ).rejects.toThrow("stripe down");
2242
-
2243
- // The PI was never marked collected, so the retry collects the fee.
2244
- expect(stripe.paymentIntents.update).not.toHaveBeenCalled();
2245
- // Collection runs before the payment upsert, so nothing landed this
2246
- // delivery — the retry writes the row (with the fee) in one pass instead
2247
- // of leaving a partial row a second write would have to patch.
2248
- expect(whCtx.ctx.runMutation).not.toHaveBeenCalled();
2249
- });
2250
-
2251
- it("rethrows a mark failure after a successful reversal; the replay converges on the same idempotency key", async () => {
2252
- const stripe = makeStripe();
2253
- const pi = flaggedPi();
2254
- wireHappyPath(stripe, pi);
2255
- stripe.paymentIntents.update.mockRejectedValueOnce(
2256
- new Error("mark failed"),
2257
- );
2258
- const whCtx = makeWhCtx({ stripe });
2259
-
2260
- // Delivery 1: reversal succeeds, marking the PI fails → must throw (the
2261
- // event goes "failed" and retries) rather than end "processed" with an
2262
- // unmarked PI and no feeCollectedAmount on the payments row.
2263
- await expect(
2264
- processEvent(whCtx, event("payment_intent.succeeded", pi)),
2265
- ).rejects.toThrow("mark failed");
2266
-
2267
- // Delivery 2 (Stripe retry): the fresh PI is still unmarked, so the
2268
- // reversal is re-sent — with the IDENTICAL idempotency key and params
2269
- // (inputs are immutable post-success), so Stripe replays it without a
2270
- // second money movement. Then the mark and the payment upsert land.
2271
- await processEvent(whCtx, event("payment_intent.succeeded", pi));
2272
-
2273
- expect(stripe.transfers.createReversal).toHaveBeenCalledTimes(2);
2274
- const [firstCall, secondCall] = stripe.transfers.createReversal.mock
2275
- .calls as unknown as [unknown, unknown, unknown][];
2276
- expect(secondCall).toEqual(firstCall);
2277
- expect(firstCall[2]).toEqual({ idempotencyKey: "bs_pcfee_pi_fee" });
2278
- expect(stripe.paymentIntents.update).toHaveBeenCalledTimes(2);
2279
- const { path, data } = dispatchedPayload(whCtx.ctx);
2280
- expect(path).toBe("betterStripe/connect/mutations/upsertPayment");
2281
- expect(data.feeCollectedAmount).toBe(320);
2282
- });
2283
-
2284
- it("skips (without throwing) when the charge has no destination transfer", async () => {
2285
- const stripe = makeStripe();
2286
- const pi = flaggedPi();
2287
- wireHappyPath(stripe, pi);
2288
- // Anomalous config a retry can't fix — rethrowing would loop the event
2289
- // "failed" forever. Logged skip instead.
2290
- stripe.charges.retrieve.mockResolvedValue({ id: "ch_fee", transfer: null });
2291
- const errSpy = vi.spyOn(console, "error").mockImplementation(() => {});
2292
- const whCtx = makeWhCtx({ stripe });
2293
-
2294
- await expect(
2295
- processEvent(whCtx, event("payment_intent.succeeded", pi)),
2296
- ).resolves.toBeUndefined();
2297
-
2298
- expect(errSpy).toHaveBeenCalled();
2299
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
2300
- // The payment row still lands (without a fee) — the sale itself is real.
2301
- expect(dispatchedPayload(whCtx.ctx).path).toBe(
2302
- "betterStripe/connect/mutations/upsertPayment",
2303
- );
2304
- });
2305
-
2306
- it("[regression] the per_invoice path is untouched by the per-charge consumer", async () => {
2307
- const stripe = makeStripe();
2308
- stripe.subscriptions.retrieve.mockResolvedValue({
2309
- id: "sub_1",
2310
- metadata: {
2311
- bsFeeMode: "per_invoice",
2312
- bsFeeConfig: JSON.stringify({ percent: 2.9, fixed: 30 }),
2313
- },
2314
- });
2315
- const whCtx = makeWhCtx({ stripe });
2316
-
2317
- await processEvent(
2318
- whCtx,
2319
- event("invoice.created", {
2320
- id: "in_fee",
2321
- currency: "usd",
2322
- amount_due: 10000,
2323
- amount_paid: 0,
2324
- status: "draft",
2325
- metadata: {},
2326
- parent: { subscription_details: { subscription: "sub_1" } },
2327
- }),
2328
- );
2329
-
2330
- // Still applied as an application_fee_amount on the draft invoice…
2331
- expect(stripe.invoices.update).toHaveBeenCalledWith("in_fee", {
2332
- application_fee_amount: 320,
2333
- metadata: { bsFeeApplied: "1" },
2334
- });
2335
- // …and never via the per-charge reversal machinery.
2336
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
2337
- expect(stripe.paymentIntents.retrieve).not.toHaveBeenCalled();
2338
- });
2339
- });
2340
-
2341
- describe("processEvent — refunds: split clawback + fee-refund denormalization (BTS-34)", () => {
2342
- /** Two split-engine ledger legs for ch_1 (original amounts, minor units). */
2343
- const ledgerLegs = (
2344
- overrides: { reversedStore?: number; reversedAff?: number } = {},
2345
- ) => [
2346
- {
2347
- stripeTransferId: "tr_s",
2348
- amount: 7000,
2349
- destinationAccountId: "acct_store",
2350
- role: "store",
2351
- currency: "usd",
2352
- ...(overrides.reversedStore !== undefined
2353
- ? { reversedAmount: overrides.reversedStore }
2354
- : {}),
2355
- },
2356
- {
2357
- stripeTransferId: "tr_a",
2358
- amount: 1000,
2359
- destinationAccountId: "acct_aff",
2360
- role: "affiliate",
2361
- currency: "usd",
2362
- ...(overrides.reversedAff !== undefined
2363
- ? { reversedAmount: overrides.reversedAff }
2364
- : {}),
2365
- },
2366
- ];
2367
- const refundEvent = (overrides: Record<string, unknown> = {}) =>
2368
- event("refund.created", {
2369
- id: "re_1",
2370
- charge: "ch_1",
2371
- payment_intent: "pi_1",
2372
- amount: 5000,
2373
- currency: "usd",
2374
- status: "succeeded",
2375
- metadata: {},
2376
- ...overrides,
2377
- });
2378
- it("reverses split-sale transfers pro-rata on a succeeded partial refund", async () => {
2379
- const ctx = makeCtx({ query: ledgerLegs() });
2380
- const stripe = makeStripe();
2381
- stripe.charges.retrieve.mockResolvedValue({
2382
- id: "ch_1",
2383
- amount: 10000,
2384
- amount_refunded: 5000,
2385
- });
2386
- const whCtx = makeWhCtx({ ctx, stripe });
2387
- await processRefund(whCtx, refundEvent());
2388
- expect(stripe.transfers.createReversal).toHaveBeenCalledTimes(2);
2389
- expect(stripe.transfers.createReversal).toHaveBeenCalledWith(
2390
- "tr_s",
2391
- { amount: 3500 },
2392
- { idempotencyKey: "bs_rev_re_1_tr_s" },
2393
- );
2394
- expect(stripe.transfers.createReversal).toHaveBeenCalledWith(
2395
- "tr_a",
2396
- { amount: 500 },
2397
- { idempotencyKey: "bs_rev_re_1_tr_a" },
2398
- );
2399
- });
2400
- it("reverses the full transfer amounts on a full refund", async () => {
2401
- const ctx = makeCtx({ query: ledgerLegs() });
2402
- const stripe = makeStripe();
2403
- stripe.refunds.list.mockImplementation(() =>
2404
- (async function* () {
2405
- yield { amount: 10000, status: "succeeded" };
2406
- })(),
2407
- );
2408
- stripe.charges.retrieve.mockResolvedValue({
2409
- id: "ch_1",
2410
- amount: 10000,
2411
- amount_refunded: 10000,
2412
- });
2413
- const whCtx = makeWhCtx({ ctx, stripe });
2414
- await processRefund(whCtx, refundEvent({ amount: 10000 }));
2415
- expect(stripe.transfers.createReversal).toHaveBeenCalledWith(
2416
- "tr_s",
2417
- { amount: 7000 },
2418
- { idempotencyKey: "bs_rev_re_1_tr_s" },
2419
- );
2420
- expect(stripe.transfers.createReversal).toHaveBeenCalledWith(
2421
- "tr_a",
2422
- { amount: 1000 },
2423
- { idempotencyKey: "bs_rev_re_1_tr_a" },
2424
- );
2425
- });
2426
- it("a second partial refund reverses only the delta up to the new cumulative target", async () => {
2427
- const ctx = makeCtx({
2428
- query: ledgerLegs({ reversedStore: 3500, reversedAff: 500 }),
2429
- });
2430
- const stripe = makeStripe();
2431
- stripe.refunds.list.mockImplementation(() =>
2432
- (async function* () {
2433
- yield { amount: 7000, status: "succeeded" };
2434
- })(),
2435
- );
2436
- stripe.charges.retrieve.mockResolvedValue({
2437
- id: "ch_1",
2438
- amount: 10000,
2439
- amount_refunded: 7000, // cumulative: 5000 + this refund's 2000
2440
- });
2441
- const whCtx = makeWhCtx({ ctx, stripe });
2442
- await processRefund(whCtx, refundEvent({ id: "re_2", amount: 2000 }));
2443
- expect(stripe.transfers.createReversal).toHaveBeenCalledWith(
2444
- "tr_s",
2445
- { amount: 1400 },
2446
- { idempotencyKey: "bs_rev_re_2_tr_s" },
2447
- );
2448
- expect(stripe.transfers.createReversal).toHaveBeenCalledWith(
2449
- "tr_a",
2450
- { amount: 200 },
2451
- { idempotencyKey: "bs_rev_re_2_tr_a" },
2452
- );
2453
- });
2454
- it("is idempotent — a redelivered refund event whose reversals are recorded reverses nothing", async () => {
2455
- const ctx = makeCtx({
2456
- query: ledgerLegs({ reversedStore: 3500, reversedAff: 500 }),
2457
- });
2458
- const stripe = makeStripe();
2459
- stripe.charges.retrieve.mockResolvedValue({
2460
- id: "ch_1",
2461
- amount: 10000,
2462
- amount_refunded: 5000,
2463
- });
2464
- const whCtx = makeWhCtx({ ctx, stripe });
2465
- await processRefund(whCtx, refundEvent());
2466
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
2467
- });
2468
- it("skips clawback quietly for a refund on a non-split sale", async () => {
2469
- const ctx = makeCtx({ query: [] });
2470
- const stripe = makeStripe();
2471
- const whCtx = makeWhCtx({ ctx, stripe });
2472
- await processRefund(whCtx, refundEvent());
2473
- expect(stripe.charges.retrieve).not.toHaveBeenCalled();
2474
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
2475
- });
2476
- it("does not claw back for a pending refund", async () => {
2477
- const ctx = makeCtx({ query: ledgerLegs() });
2478
- const stripe = makeStripe();
2479
- const whCtx = makeWhCtx({ ctx, stripe });
2480
- await processRefund(whCtx, refundEvent({ status: "pending" }));
2481
- expect(stripe.transfers.createReversal).not.toHaveBeenCalled();
2482
- });
2483
- it("propagates a reversal failure so the event is marked failed and Stripe retries", async () => {
2484
- const ctx = makeCtx({ query: ledgerLegs() });
2485
- const stripe = makeStripe();
2486
- stripe.charges.retrieve.mockResolvedValue({
2487
- id: "ch_1",
2488
- amount: 10000,
2489
- amount_refunded: 5000,
2490
- });
2491
- stripe.transfers.createReversal.mockRejectedValue(new Error("stripe down"));
2492
- const whCtx = makeWhCtx({ ctx, stripe });
2493
- await expect(processRefund(whCtx, refundEvent())).rejects.toThrow(
2494
- "stripe down",
2495
- );
2496
- });
2497
- it("application_fee.refunded sets absolute fee totals on the linked payment", async () => {
2498
- const stripe = makeStripe();
2499
- stripe.charges.retrieve.mockResolvedValue({
2500
- id: "ch_1",
2501
- payment_intent: "pi_1",
2502
- });
2503
- const whCtx = makeWhCtx({ stripe });
2504
- const feeEvent = event("application_fee.refunded", {
2505
- id: "fee_1",
2506
- charge: "ch_1",
2507
- amount: 320,
2508
- amount_refunded: 160,
2509
- currency: "usd",
2510
- });
2511
- await processEvent(whCtx, feeEvent);
2512
- const calls = whCtx.ctx.runMutation.mock.calls;
2513
- const feeCall = calls.find(
2514
- (c) =>
2515
- c[0][TO_REF] ===
2516
- "betterStripe/connect/mutations/recordPaymentFeeRefund",
2517
- );
2518
- expect(feeCall).toBeDefined();
2519
- expect(feeCall![1]).toEqual({
2520
- stripePaymentIntentId: "pi_1",
2521
- feeCollectedAmount: 160,
2522
- feeRefundedAmount: 160,
2523
- });
2524
- await processEvent(whCtx, feeEvent);
2525
- const feeCalls = whCtx.ctx.runMutation.mock.calls.filter(
2526
- (c) =>
2527
- c[0][TO_REF] ===
2528
- "betterStripe/connect/mutations/recordPaymentFeeRefund",
2529
- );
2530
- expect(feeCalls).toHaveLength(2);
2531
- expect(feeCalls[1][1]).toEqual(feeCalls[0][1]);
2532
- });
2533
- it("application_fee.refunded skips quietly when the charge has no payment intent", async () => {
2534
- const stripe = makeStripe();
2535
- stripe.charges.retrieve.mockResolvedValue({
2536
- id: "ch_1",
2537
- payment_intent: null,
2538
- });
2539
- const whCtx = makeWhCtx({ stripe });
2540
- await expect(
2541
- processEvent(
2542
- whCtx,
2543
- event("application_fee.refunded", {
2544
- id: "fee_1",
2545
- charge: "ch_1",
2546
- amount: 320,
2547
- amount_refunded: 320,
2548
- }),
2549
- ),
2550
- ).resolves.toBeUndefined();
2551
- expect(whCtx.ctx.runMutation).not.toHaveBeenCalled();
2552
- });
2553
- });