@fantastic.dev/better-stripe 0.23.2 → 0.25.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (358) hide show
  1. package/CHANGELOG.md +27 -2
  2. package/README.md +46 -5
  3. package/dist/client/affiliateRecovery/disputes.d.ts +18 -0
  4. package/dist/client/affiliateRecovery/disputes.d.ts.map +1 -0
  5. package/dist/client/affiliateRecovery/disputes.js +33 -0
  6. package/dist/client/affiliateRecovery/disputes.js.map +1 -0
  7. package/dist/client/affiliateRecovery/engine.d.ts +29 -0
  8. package/dist/client/affiliateRecovery/engine.d.ts.map +1 -0
  9. package/dist/client/affiliateRecovery/engine.js +116 -0
  10. package/dist/client/affiliateRecovery/engine.js.map +1 -0
  11. package/dist/client/affiliateRecovery/payoutGate.d.ts +24 -0
  12. package/dist/client/affiliateRecovery/payoutGate.d.ts.map +1 -0
  13. package/dist/client/affiliateRecovery/payoutGate.js +30 -0
  14. package/dist/client/affiliateRecovery/payoutGate.js.map +1 -0
  15. package/dist/client/affiliateRecovery/provider.d.ts +14 -0
  16. package/dist/client/affiliateRecovery/provider.d.ts.map +1 -0
  17. package/dist/client/affiliateRecovery/provider.js +96 -0
  18. package/dist/client/affiliateRecovery/provider.js.map +1 -0
  19. package/dist/client/affiliateRecovery/review.d.ts +28 -0
  20. package/dist/client/affiliateRecovery/review.d.ts.map +1 -0
  21. package/dist/client/affiliateRecovery/review.js +86 -0
  22. package/dist/client/affiliateRecovery/review.js.map +1 -0
  23. package/dist/client/affiliateRecovery/validators.d.ts +402 -0
  24. package/dist/client/affiliateRecovery/validators.d.ts.map +1 -0
  25. package/dist/client/affiliateRecovery/validators.js +27 -0
  26. package/dist/client/affiliateRecovery/validators.js.map +1 -0
  27. package/dist/client/affiliateRecovery.d.ts +131 -0
  28. package/dist/client/affiliateRecovery.d.ts.map +1 -0
  29. package/dist/client/affiliateRecovery.js +69 -0
  30. package/dist/client/affiliateRecovery.js.map +1 -0
  31. package/dist/client/billing/checkout.d.ts +3 -43
  32. package/dist/client/billing/checkout.d.ts.map +1 -1
  33. package/dist/client/billing/checkout.js +5 -260
  34. package/dist/client/billing/checkout.js.map +1 -1
  35. package/dist/client/billing/checkoutRequest.d.ts +129 -0
  36. package/dist/client/billing/checkoutRequest.d.ts.map +1 -0
  37. package/dist/client/billing/checkoutRequest.js +263 -0
  38. package/dist/client/billing/checkoutRequest.js.map +1 -0
  39. package/dist/client/billing/preparedCheckout.d.ts +22 -0
  40. package/dist/client/billing/preparedCheckout.d.ts.map +1 -0
  41. package/dist/client/billing/preparedCheckout.js +86 -0
  42. package/dist/client/billing/preparedCheckout.js.map +1 -0
  43. package/dist/client/checkoutRequests.d.ts +80 -0
  44. package/dist/client/checkoutRequests.d.ts.map +1 -0
  45. package/dist/client/checkoutRequests.js +28 -0
  46. package/dist/client/checkoutRequests.js.map +1 -0
  47. package/dist/client/connect/commissionReceipts.d.ts +4 -0
  48. package/dist/client/connect/commissionReceipts.d.ts.map +1 -0
  49. package/dist/client/connect/commissionReceipts.js +17 -0
  50. package/dist/client/connect/commissionReceipts.js.map +1 -0
  51. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +958 -2
  52. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  53. package/dist/client/connect/payoutCollection.d.ts +21 -0
  54. package/dist/client/connect/payoutCollection.d.ts.map +1 -0
  55. package/dist/client/connect/payoutCollection.js +47 -0
  56. package/dist/client/connect/payoutCollection.js.map +1 -0
  57. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +1805 -0
  58. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -0
  59. package/dist/client/connect/payoutExecutionTestHelpers.js +194 -0
  60. package/dist/client/connect/payoutExecutionTestHelpers.js.map +1 -0
  61. package/dist/client/connect/payoutSyncTestHelpers.d.ts +479 -1
  62. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  63. package/dist/client/connect/payoutWorker.d.ts +48 -0
  64. package/dist/client/connect/payoutWorker.d.ts.map +1 -0
  65. package/dist/client/connect/payoutWorker.js +78 -0
  66. package/dist/client/connect/payoutWorker.js.map +1 -0
  67. package/dist/client/connect/payouts.d.ts +3 -1
  68. package/dist/client/connect/payouts.d.ts.map +1 -1
  69. package/dist/client/connect/payouts.js +45 -12
  70. package/dist/client/connect/payouts.js.map +1 -1
  71. package/dist/client/connect/refundPrincipal.d.ts +4 -0
  72. package/dist/client/connect/refundPrincipal.d.ts.map +1 -0
  73. package/dist/client/connect/refundPrincipal.js +21 -0
  74. package/dist/client/connect/refundPrincipal.js.map +1 -0
  75. package/dist/client/connect/reversalExecution.d.ts +47 -0
  76. package/dist/client/connect/reversalExecution.d.ts.map +1 -0
  77. package/dist/client/connect/reversalExecution.js +84 -0
  78. package/dist/client/connect/reversalExecution.js.map +1 -0
  79. package/dist/client/connect/transfers.d.ts +8 -4
  80. package/dist/client/connect/transfers.d.ts.map +1 -1
  81. package/dist/client/connect/transfers.js +52 -57
  82. package/dist/client/connect/transfers.js.map +1 -1
  83. package/dist/client/index.d.ts +7 -11
  84. package/dist/client/index.d.ts.map +1 -1
  85. package/dist/client/index.js +10 -10
  86. package/dist/client/index.js.map +1 -1
  87. package/dist/client/payoutPolicy.d.ts +67 -0
  88. package/dist/client/payoutPolicy.d.ts.map +1 -1
  89. package/dist/client/payoutPolicy.js +10 -0
  90. package/dist/client/payoutPolicy.js.map +1 -1
  91. package/dist/client/readContracts.d.ts +11 -1
  92. package/dist/client/readContracts.d.ts.map +1 -1
  93. package/dist/client/readContracts.js +10 -0
  94. package/dist/client/readContracts.js.map +1 -1
  95. package/dist/client/settlement/execution.d.ts.map +1 -1
  96. package/dist/client/settlement/execution.js +30 -3
  97. package/dist/client/settlement/execution.js.map +1 -1
  98. package/dist/client/settlement/reconciliation.d.ts.map +1 -1
  99. package/dist/client/settlement/reconciliation.js +16 -2
  100. package/dist/client/settlement/reconciliation.js.map +1 -1
  101. package/dist/client/webhooks/disputeRecovery.d.ts +4 -0
  102. package/dist/client/webhooks/disputeRecovery.d.ts.map +1 -0
  103. package/dist/client/webhooks/disputeRecovery.js +40 -0
  104. package/dist/client/webhooks/disputeRecovery.js.map +1 -0
  105. package/dist/client/webhooks/processors.d.ts.map +1 -1
  106. package/dist/client/webhooks/processors.js +14 -29
  107. package/dist/client/webhooks/processors.js.map +1 -1
  108. package/dist/component/_generated/component.d.ts +784 -0
  109. package/dist/component/_generated/component.d.ts.map +1 -1
  110. package/dist/component/affiliateEarnings/mutations.d.ts +22 -0
  111. package/dist/component/affiliateEarnings/mutations.d.ts.map +1 -0
  112. package/dist/component/affiliateEarnings/mutations.js +160 -0
  113. package/dist/component/affiliateEarnings/mutations.js.map +1 -0
  114. package/dist/component/affiliatePayouts/mutations.d.ts +25 -0
  115. package/dist/component/affiliatePayouts/mutations.d.ts.map +1 -0
  116. package/dist/component/affiliatePayouts/mutations.js +104 -0
  117. package/dist/component/affiliatePayouts/mutations.js.map +1 -0
  118. package/dist/component/affiliatePayouts/queries.d.ts +23 -0
  119. package/dist/component/affiliatePayouts/queries.d.ts.map +1 -0
  120. package/dist/component/affiliatePayouts/queries.js +23 -0
  121. package/dist/component/affiliatePayouts/queries.js.map +1 -0
  122. package/dist/component/affiliatePayouts/recipientGuard.d.ts +12 -0
  123. package/dist/component/affiliatePayouts/recipientGuard.d.ts.map +1 -0
  124. package/dist/component/affiliatePayouts/recipientGuard.js +26 -0
  125. package/dist/component/affiliatePayouts/recipientGuard.js.map +1 -0
  126. package/dist/component/affiliateRecovery/accounting.d.ts +28 -0
  127. package/dist/component/affiliateRecovery/accounting.d.ts.map +1 -0
  128. package/dist/component/affiliateRecovery/accounting.js +71 -0
  129. package/dist/component/affiliateRecovery/accounting.js.map +1 -0
  130. package/dist/component/affiliateRecovery/mutations.d.ts +65 -0
  131. package/dist/component/affiliateRecovery/mutations.d.ts.map +1 -0
  132. package/dist/component/affiliateRecovery/mutations.js +250 -0
  133. package/dist/component/affiliateRecovery/mutations.js.map +1 -0
  134. package/dist/component/affiliateRecovery/queries.d.ts +305 -0
  135. package/dist/component/affiliateRecovery/queries.d.ts.map +1 -0
  136. package/dist/component/affiliateRecovery/queries.js +113 -0
  137. package/dist/component/affiliateRecovery/queries.js.map +1 -0
  138. package/dist/component/affiliateRecovery/schema.d.ts +171 -0
  139. package/dist/component/affiliateRecovery/schema.d.ts.map +1 -0
  140. package/dist/component/affiliateRecovery/schema.js +71 -0
  141. package/dist/component/affiliateRecovery/schema.js.map +1 -0
  142. package/dist/component/connect/mutations.d.ts +36 -23
  143. package/dist/component/connect/mutations.d.ts.map +1 -1
  144. package/dist/component/connect/mutations.js +7 -124
  145. package/dist/component/connect/mutations.js.map +1 -1
  146. package/dist/component/connect/queries.d.ts +10 -0
  147. package/dist/component/connect/queries.d.ts.map +1 -1
  148. package/dist/component/connect/queries.js +3 -40
  149. package/dist/component/connect/queries.js.map +1 -1
  150. package/dist/component/connect/reversalClaims.d.ts +169 -0
  151. package/dist/component/connect/reversalClaims.d.ts.map +1 -0
  152. package/dist/component/connect/reversalClaims.js +176 -0
  153. package/dist/component/connect/reversalClaims.js.map +1 -0
  154. package/dist/component/connect/reversalDiagnostics.d.ts +59 -0
  155. package/dist/component/connect/reversalDiagnostics.d.ts.map +1 -0
  156. package/dist/component/connect/reversalDiagnostics.js +50 -0
  157. package/dist/component/connect/reversalDiagnostics.js.map +1 -0
  158. package/dist/component/connect/reversalReceipts.d.ts +27 -0
  159. package/dist/component/connect/reversalReceipts.d.ts.map +1 -0
  160. package/dist/component/connect/reversalReceipts.js +85 -0
  161. package/dist/component/connect/reversalReceipts.js.map +1 -0
  162. package/dist/component/connect/schema.d.ts +31 -1
  163. package/dist/component/connect/schema.d.ts.map +1 -1
  164. package/dist/component/connect/schema.js +3 -1
  165. package/dist/component/connect/schema.js.map +1 -1
  166. package/dist/component/connect/validators.d.ts +49 -1
  167. package/dist/component/connect/validators.d.ts.map +1 -1
  168. package/dist/component/connect/validators.js +2 -0
  169. package/dist/component/connect/validators.js.map +1 -1
  170. package/dist/component/core/mutations.d.ts.map +1 -1
  171. package/dist/component/core/mutations.js +2 -0
  172. package/dist/component/core/mutations.js.map +1 -1
  173. package/dist/component/core/resetSafety.d.ts +4 -0
  174. package/dist/component/core/resetSafety.d.ts.map +1 -0
  175. package/dist/component/core/resetSafety.js +54 -0
  176. package/dist/component/core/resetSafety.js.map +1 -0
  177. package/dist/component/earnings/triggers.d.ts +828 -2
  178. package/dist/component/earnings/triggers.d.ts.map +1 -1
  179. package/dist/component/earnings/triggers.js +2 -0
  180. package/dist/component/earnings/triggers.js.map +1 -1
  181. package/dist/component/payoutPolicy/schema.d.ts +2 -0
  182. package/dist/component/payoutPolicy/schema.d.ts.map +1 -1
  183. package/dist/component/payoutPolicy/schema.js +3 -1
  184. package/dist/component/payoutPolicy/schema.js.map +1 -1
  185. package/dist/component/payoutRelease/mutations.d.ts.map +1 -1
  186. package/dist/component/payoutRelease/mutations.js +7 -1
  187. package/dist/component/payoutRelease/mutations.js.map +1 -1
  188. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  189. package/dist/component/payoutRelease/queries.js +3 -1
  190. package/dist/component/payoutRelease/queries.js.map +1 -1
  191. package/dist/component/payoutRelease/schema.d.ts +1 -0
  192. package/dist/component/payoutRelease/schema.d.ts.map +1 -1
  193. package/dist/component/payoutRelease/schema.js +1 -0
  194. package/dist/component/payoutRelease/schema.js.map +1 -1
  195. package/dist/component/payoutSnapshots/localState.d.ts +89 -0
  196. package/dist/component/payoutSnapshots/localState.d.ts.map +1 -0
  197. package/dist/component/payoutSnapshots/localState.js +186 -0
  198. package/dist/component/payoutSnapshots/localState.js.map +1 -0
  199. package/dist/component/payoutSnapshots/mutations.d.ts +108 -0
  200. package/dist/component/payoutSnapshots/mutations.d.ts.map +1 -0
  201. package/dist/component/payoutSnapshots/mutations.js +263 -0
  202. package/dist/component/payoutSnapshots/mutations.js.map +1 -0
  203. package/dist/component/payoutSnapshots/revisions.d.ts +12 -0
  204. package/dist/component/payoutSnapshots/revisions.d.ts.map +1 -0
  205. package/dist/component/payoutSnapshots/revisions.js +173 -0
  206. package/dist/component/payoutSnapshots/revisions.js.map +1 -0
  207. package/dist/component/payoutSnapshots/schema.d.ts +285 -0
  208. package/dist/component/payoutSnapshots/schema.d.ts.map +1 -0
  209. package/dist/component/payoutSnapshots/schema.js +108 -0
  210. package/dist/component/payoutSnapshots/schema.js.map +1 -0
  211. package/dist/component/payoutSnapshots/scope.d.ts +7 -0
  212. package/dist/component/payoutSnapshots/scope.d.ts.map +1 -0
  213. package/dist/component/payoutSnapshots/scope.js +8 -0
  214. package/dist/component/payoutSnapshots/scope.js.map +1 -0
  215. package/dist/component/payoutWorker/helpers.d.ts +30 -0
  216. package/dist/component/payoutWorker/helpers.d.ts.map +1 -0
  217. package/dist/component/payoutWorker/helpers.js +21 -0
  218. package/dist/component/payoutWorker/helpers.js.map +1 -0
  219. package/dist/component/payoutWorker/mutations.d.ts +68 -0
  220. package/dist/component/payoutWorker/mutations.d.ts.map +1 -0
  221. package/dist/component/payoutWorker/mutations.js +161 -0
  222. package/dist/component/payoutWorker/mutations.js.map +1 -0
  223. package/dist/component/payoutWorker/queries.d.ts +123 -0
  224. package/dist/component/payoutWorker/queries.d.ts.map +1 -0
  225. package/dist/component/payoutWorker/queries.js +61 -0
  226. package/dist/component/payoutWorker/queries.js.map +1 -0
  227. package/dist/component/payoutWorker/schema.d.ts +91 -0
  228. package/dist/component/payoutWorker/schema.d.ts.map +1 -0
  229. package/dist/component/payoutWorker/schema.js +27 -0
  230. package/dist/component/payoutWorker/schema.js.map +1 -0
  231. package/dist/component/schema.d.ts +479 -1
  232. package/dist/component/schema.js +19 -0
  233. package/dist/component/schema.js.map +1 -1
  234. package/dist/component/settlement/clawbackSchema.d.ts +161 -0
  235. package/dist/component/settlement/clawbackSchema.d.ts.map +1 -0
  236. package/dist/component/settlement/clawbackSchema.js +73 -0
  237. package/dist/component/settlement/clawbackSchema.js.map +1 -0
  238. package/dist/component/settlement/clawbacks.d.ts +55 -0
  239. package/dist/component/settlement/clawbacks.d.ts.map +1 -0
  240. package/dist/component/settlement/clawbacks.js +146 -0
  241. package/dist/component/settlement/clawbacks.js.map +1 -0
  242. package/dist/component/settlement/mutations.d.ts +16 -0
  243. package/dist/component/settlement/mutations.d.ts.map +1 -1
  244. package/dist/component/settlement/mutations.js +48 -0
  245. package/dist/component/settlement/mutations.js.map +1 -1
  246. package/dist/component/settlement/queries.d.ts +53 -0
  247. package/dist/component/settlement/queries.d.ts.map +1 -1
  248. package/dist/component/settlement/queries.js +26 -0
  249. package/dist/component/settlement/queries.js.map +1 -1
  250. package/dist/react/workflows/AffiliateRecovery.d.ts +46 -0
  251. package/dist/react/workflows/AffiliateRecovery.d.ts.map +1 -0
  252. package/dist/react/workflows/AffiliateRecovery.js +84 -0
  253. package/dist/react/workflows/AffiliateRecovery.js.map +1 -0
  254. package/dist/react/workflows/index.d.ts +2 -0
  255. package/dist/react/workflows/index.d.ts.map +1 -1
  256. package/dist/react/workflows/index.js +1 -0
  257. package/dist/react/workflows/index.js.map +1 -1
  258. package/dist/testing/affiliate-recovery.d.ts +10 -0
  259. package/dist/testing/affiliate-recovery.d.ts.map +1 -0
  260. package/dist/testing/affiliate-recovery.js +126 -0
  261. package/dist/testing/affiliate-recovery.js.map +1 -0
  262. package/dist/testing/index.d.ts +2 -0
  263. package/dist/testing/index.d.ts.map +1 -1
  264. package/dist/testing/index.js +1 -0
  265. package/dist/testing/index.js.map +1 -1
  266. package/docs/affiliate-clawbacks.md +306 -0
  267. package/docs/read-contracts.md +48 -0
  268. package/docs/settlement.md +145 -1
  269. package/package.json +2 -1
  270. package/src/client/affiliateRecovery/disputes.ts +62 -0
  271. package/src/client/affiliateRecovery/engine.ts +196 -0
  272. package/src/client/affiliateRecovery/payoutGate.ts +65 -0
  273. package/src/client/affiliateRecovery/provider.ts +127 -0
  274. package/src/client/affiliateRecovery/review.ts +117 -0
  275. package/src/client/affiliateRecovery/validators.ts +38 -0
  276. package/src/client/affiliateRecovery.ts +173 -0
  277. package/src/client/billing/checkout.ts +11 -359
  278. package/src/client/billing/checkoutRequest.ts +362 -0
  279. package/src/client/billing/prepared-checkout.test.ts +430 -0
  280. package/src/client/billing/preparedCheckout.ts +143 -0
  281. package/src/client/checkoutRequests.ts +40 -0
  282. package/src/client/connect/commissionReceipts.test.ts +157 -0
  283. package/src/client/connect/commissionReceipts.ts +23 -0
  284. package/src/client/connect/payoutCollection.test.ts +74 -0
  285. package/src/client/connect/payoutCollection.ts +82 -0
  286. package/src/client/connect/payoutExecution.test.ts +1 -211
  287. package/src/client/connect/payoutExecutionTestHelpers.ts +213 -0
  288. package/src/client/connect/payoutWorker.test.ts +145 -0
  289. package/src/client/connect/payoutWorker.ts +144 -0
  290. package/src/client/connect/payouts.ts +75 -15
  291. package/src/client/connect/refundPrincipal.test.ts +46 -0
  292. package/src/client/connect/refundPrincipal.ts +26 -0
  293. package/src/client/connect/reversalExecution.ts +130 -0
  294. package/src/client/connect/transfers.test.ts +3 -3
  295. package/src/client/connect/transfers.ts +93 -92
  296. package/src/client/index.ts +16 -28
  297. package/src/client/payoutPolicy.ts +26 -1
  298. package/src/client/readContracts.ts +23 -0
  299. package/src/client/settlement/execution.test.ts +5 -0
  300. package/src/client/settlement/execution.ts +50 -3
  301. package/src/client/settlement/reconciliation.ts +20 -2
  302. package/src/client/webhooks/disputeRecovery.ts +74 -0
  303. package/src/client/webhooks/processors.test.ts +36 -53
  304. package/src/client/webhooks/processors.ts +18 -31
  305. package/src/component/_generated/api.ts +40 -0
  306. package/src/component/_generated/component.ts +975 -1
  307. package/src/component/affiliate-clawbacks.test.ts +370 -0
  308. package/src/component/affiliate-component-pagination.test.ts +83 -0
  309. package/src/component/affiliate-direct-payout.test.ts +160 -0
  310. package/src/component/affiliate-recovery-lifecycle.test.ts +587 -0
  311. package/src/component/affiliateEarnings/mutations.ts +196 -0
  312. package/src/component/affiliatePayouts/mutations.ts +121 -0
  313. package/src/component/affiliatePayouts/queries.ts +28 -0
  314. package/src/component/affiliatePayouts/recipientGuard.ts +42 -0
  315. package/src/component/affiliateRecovery/accounting.ts +111 -0
  316. package/src/component/affiliateRecovery/mutations.ts +275 -0
  317. package/src/component/affiliateRecovery/queries.ts +138 -0
  318. package/src/component/affiliateRecovery/schema.ts +86 -0
  319. package/src/component/connect/mutations.ts +9 -160
  320. package/src/component/connect/queries.ts +4 -47
  321. package/src/component/connect/reversalClaims.ts +232 -0
  322. package/src/component/connect/reversalDiagnostics.ts +61 -0
  323. package/src/component/connect/reversalReceipts.ts +147 -0
  324. package/src/component/connect/schema.ts +3 -3
  325. package/src/component/connect/validators.ts +2 -0
  326. package/src/component/core/mutations.ts +2 -0
  327. package/src/component/core/resetSafety.ts +67 -0
  328. package/src/component/earnings/triggers.ts +2 -0
  329. package/src/component/payout-recovery-integration.test.ts +172 -0
  330. package/src/component/payout-reset-safety.test.ts +148 -0
  331. package/src/component/payout-revisions.test.ts +125 -0
  332. package/src/component/payout-snapshots.test.ts +395 -0
  333. package/src/component/payout-worker.test.ts +165 -0
  334. package/src/component/payoutPolicy/schema.ts +3 -1
  335. package/src/component/payoutRelease/mutations.ts +10 -1
  336. package/src/component/payoutRelease/queries.ts +3 -1
  337. package/src/component/payoutRelease/schema.ts +1 -0
  338. package/src/component/payoutSnapshots/localState.ts +238 -0
  339. package/src/component/payoutSnapshots/mutations.ts +275 -0
  340. package/src/component/payoutSnapshots/revisions.ts +247 -0
  341. package/src/component/payoutSnapshots/schema.ts +125 -0
  342. package/src/component/payoutSnapshots/scope.ts +7 -0
  343. package/src/component/payoutWorker/helpers.ts +30 -0
  344. package/src/component/payoutWorker/mutations.ts +181 -0
  345. package/src/component/payoutWorker/queries.ts +64 -0
  346. package/src/component/payoutWorker/schema.ts +26 -0
  347. package/src/component/public.test.ts +2 -2
  348. package/src/component/schema.ts +36 -0
  349. package/src/component/settlement/clawbackSchema.ts +78 -0
  350. package/src/component/settlement/clawbacks.ts +233 -0
  351. package/src/component/settlement/mutations.ts +54 -0
  352. package/src/component/settlement/queries.ts +35 -0
  353. package/src/component/summary-arithmetic.test.ts +9 -4
  354. package/src/react/workflows/AffiliateRecovery.test.tsx +106 -0
  355. package/src/react/workflows/AffiliateRecovery.tsx +273 -0
  356. package/src/react/workflows/index.ts +9 -0
  357. package/src/testing/affiliate-recovery.ts +137 -0
  358. package/src/testing/index.ts +2 -0
@@ -0,0 +1,131 @@
1
+ import type Stripe from "stripe";
2
+ import type { PaginationOptions } from "convex/server";
3
+ import type { Component, RunCtx } from "./helpers.js";
4
+ import type { RecoveryObligation, RecoveryOperation } from "./affiliateRecovery/provider.js";
5
+ import type { Doc } from "../component/_generated/dataModel.js";
6
+ export type AffiliateRecoveryObligation = RecoveryObligation;
7
+ export type AffiliateRecoveryOperation = RecoveryOperation;
8
+ export type AffiliateRecoveryBalance = Doc<"affiliateRecoveryBalances">;
9
+ export type AffiliateRecoverySnapshot = {
10
+ balance: AffiliateRecoveryBalance | null;
11
+ obligations: {
12
+ page: RecoveryObligation[];
13
+ continueCursor: string;
14
+ isDone: boolean;
15
+ };
16
+ };
17
+ /** Server API. Host must authorize account ownership and operator retries. */
18
+ export declare class AffiliateRecoveryClient {
19
+ private readonly component;
20
+ private readonly provider;
21
+ constructor(component: Component, provider: () => Stripe);
22
+ snapshot(ctx: RunCtx, opts: {
23
+ affiliateAccountId: string;
24
+ currency: string;
25
+ paginationOpts: PaginationOptions;
26
+ }): Promise<AffiliateRecoverySnapshot>;
27
+ obligation(ctx: RunCtx, opts: {
28
+ obligationId: string;
29
+ }): Promise<RecoveryObligation | null>;
30
+ history(ctx: RunCtx, opts: {
31
+ obligationId: string;
32
+ paginationOpts: PaginationOptions;
33
+ }): Promise<{
34
+ page: RecoveryOperation[];
35
+ continueCursor: string;
36
+ isDone: boolean;
37
+ }>;
38
+ reviewLegacy(ctx: RunCtx, opts: {
39
+ obligationId: string;
40
+ reversalIds: string[];
41
+ restorationTransferIds?: string[];
42
+ note: string;
43
+ }): Promise<{
44
+ _creationTime: number;
45
+ _id: import("convex/values").GenericId<"affiliateObligations">;
46
+ accounted?: boolean | undefined;
47
+ activeOperationId?: import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined;
48
+ affiliateAccountId: string;
49
+ chargeAmount: number;
50
+ creditAmount?: number | undefined;
51
+ currency: string;
52
+ debtAmount?: number | undefined;
53
+ debtStatus?: "open" | "settled" | undefined;
54
+ disputeId?: string | undefined;
55
+ disputeState?: "lost" | "open" | "won" | undefined;
56
+ disputedPrincipal: number;
57
+ earningId?: import("convex/values").GenericId<"affiliateEarnings"> | undefined;
58
+ finalizedAmount: number;
59
+ lastError?: string | undefined;
60
+ lastRefundId?: string | undefined;
61
+ lastState?: string | undefined;
62
+ legacyReceiptIds?: string[] | undefined;
63
+ legacyRestorationIds?: string[] | undefined;
64
+ lostPrincipal: number;
65
+ needsReconciliation: boolean;
66
+ offsetAmount?: number | undefined;
67
+ operationSequence?: number | undefined;
68
+ operatorNote?: string | undefined;
69
+ originalCommission: number;
70
+ paymentId?: string | undefined;
71
+ paymentIntentId?: string | undefined;
72
+ provisionalAmount: number;
73
+ recoveredAmount: number;
74
+ refundedPrincipal: number;
75
+ releasedCommission?: number | undefined;
76
+ reservedRecovery?: number | undefined;
77
+ reservedRestoration?: number | undefined;
78
+ restoredAmount?: number | undefined;
79
+ sourceChargeId: string;
80
+ sourceInvoiceId?: string | undefined;
81
+ storeAccountId?: string | undefined;
82
+ stripeTransferId?: string | undefined;
83
+ } | null>;
84
+ retry(ctx: RunCtx, opts: {
85
+ obligationId: string;
86
+ }): Promise<{
87
+ state: string;
88
+ reason: string;
89
+ error?: undefined;
90
+ } | {
91
+ reason?: undefined;
92
+ state: string;
93
+ error: string;
94
+ } | {
95
+ reason?: undefined;
96
+ error?: undefined;
97
+ state: string;
98
+ }>;
99
+ reconcilePayouts(ctx: RunCtx, opts: {
100
+ paginationOpts: PaginationOptions;
101
+ state: "pending" | "unknown";
102
+ }): Promise<{
103
+ page: Doc<"affiliatePayoutReleases">[];
104
+ continueCursor: string;
105
+ isDone: boolean;
106
+ }>;
107
+ /** Run from a host cron for both pending and unknown outcomes. */
108
+ reconcilePending(ctx: RunCtx, opts: {
109
+ paginationOpts: PaginationOptions;
110
+ state: "pending" | "unknown";
111
+ }): Promise<{
112
+ page: RecoveryOperation[];
113
+ continueCursor: string;
114
+ isDone: boolean;
115
+ results: ({
116
+ state: string;
117
+ reason: string;
118
+ error?: undefined;
119
+ } | {
120
+ reason?: undefined;
121
+ state: string;
122
+ error: string;
123
+ } | {
124
+ reason?: undefined;
125
+ error?: undefined;
126
+ state: string;
127
+ })[];
128
+ }>;
129
+ }
130
+ export { affiliateSnapshotValidator, affiliateObligationValidator, affiliateOperationValidator, } from "./affiliateRecovery/validators.js";
131
+ //# sourceMappingURL=affiliateRecovery.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affiliateRecovery.d.ts","sourceRoot":"","sources":["../../src/client/affiliateRecovery.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,cAAc,CAAC;AAGtD,OAAO,KAAK,EACV,kBAAkB,EAClB,iBAAiB,EAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,sCAAsC,CAAC;AAChE,MAAM,MAAM,2BAA2B,GAAG,kBAAkB,CAAC;AAC7D,MAAM,MAAM,0BAA0B,GAAG,iBAAiB,CAAC;AAC3D,MAAM,MAAM,wBAAwB,GAAG,GAAG,CAAC,2BAA2B,CAAC,CAAC;AACxE,MAAM,MAAM,yBAAyB,GAAG;IACtC,OAAO,EAAE,wBAAwB,GAAG,IAAI,CAAC;IACzC,WAAW,EAAE;QACX,IAAI,EAAE,kBAAkB,EAAE,CAAC;QAC3B,cAA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AAG,SAAS,CAAA;KAAE;cAMjE,GAAG,CAAC,yBAAyB,CAAC,EAAE;wBACtB,MAAM;gBACd,OAAO;OAiClB;IACD,kEAAkE;IAC5D,gBAAgB,CACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;QAAE,cAAc,EAAE,iBAAiB,CAAC;QAAC,KAAK,EAAE,SAAS,GAAG,SAAS,CAAA;KAAE;cASjE,iBAAiB,EAAE;wBACT,MAAM;gBACd,OAAO;;;;;;;;;;;;;;OAMlB;CACF;AACD,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,mCAAmC,CAAC"}
@@ -0,0 +1,69 @@
1
+ import { reconcileAffiliatePayout, completeAffiliatePayout, } from "./affiliateRecovery/payoutGate.js";
2
+ import { verifiedLegacyReview } from "./affiliateRecovery/review.js";
3
+ import { runMutationOrThrow } from "./helpers.js";
4
+ import { createPayout } from "./connect/payouts.js";
5
+ import { componentRef } from "./webhooks/helpers.js";
6
+ import { reconcileObligation } from "./affiliateRecovery/engine.js";
7
+ /** Server API. Host must authorize account ownership and operator retries. */
8
+ export class AffiliateRecoveryClient {
9
+ component;
10
+ provider;
11
+ constructor(component, provider) {
12
+ this.component = component;
13
+ this.provider = provider;
14
+ }
15
+ async snapshot(ctx, opts) {
16
+ return ctx.runQuery(componentRef(this.component, "affiliateRecovery/queries/recoverySnapshot"), opts);
17
+ }
18
+ async obligation(ctx, opts) {
19
+ return ctx.runQuery(componentRef(this.component, "affiliateRecovery/queries/getObligation"), opts);
20
+ }
21
+ async history(ctx, opts) {
22
+ return ctx.runQuery(componentRef(this.component, "affiliateRecovery/queries/operationHistory"), opts);
23
+ }
24
+ async reviewLegacy(ctx, opts) {
25
+ const row = await this.obligation(ctx, opts);
26
+ if (!row)
27
+ throw new Error("Affiliate obligation not found.");
28
+ const review = await verifiedLegacyReview(this.provider(), row, opts);
29
+ await runMutationOrThrow(ctx, componentRef(this.component, "affiliateRecovery/mutations/reviewLegacy"), review);
30
+ return this.obligation(ctx, opts);
31
+ }
32
+ async retry(ctx, opts) {
33
+ return reconcileObligation(this.provider(), this.component, ctx, opts.obligationId);
34
+ }
35
+ async reconcilePayouts(ctx, opts) {
36
+ const page = (await ctx.runQuery(componentRef(this.component, "affiliatePayouts/queries/pendingPayouts"), opts));
37
+ for (const row of page.page) {
38
+ try {
39
+ // Confirm money already moved even when new debt blocks another attempt.
40
+ const receipt = await reconcileAffiliatePayout(this.provider(), row);
41
+ if (receipt) {
42
+ await completeAffiliatePayout(this.component, ctx, row.operationKey, "submitted", receipt);
43
+ continue;
44
+ }
45
+ await createPayout(this.provider(), ctx, {
46
+ stripeAccountId: row.affiliateAccountId,
47
+ currency: row.currency,
48
+ amount: row.amount,
49
+ minimumAmount: row.minimumAmount,
50
+ idempotencyKey: row.operationKey,
51
+ }, this.component);
52
+ }
53
+ catch {
54
+ /* The payout gate retains the durable failure/unknown outcome. */
55
+ }
56
+ }
57
+ return page;
58
+ }
59
+ /** Run from a host cron for both pending and unknown outcomes. */
60
+ async reconcilePending(ctx, opts) {
61
+ const page = (await ctx.runQuery(componentRef(this.component, "affiliateRecovery/queries/pendingOperations"), opts));
62
+ const results = [];
63
+ for (const op of page.page)
64
+ results.push(await this.retry(ctx, { obligationId: op.obligationId }));
65
+ return { ...page, results };
66
+ }
67
+ }
68
+ export { affiliateSnapshotValidator, affiliateObligationValidator, affiliateOperationValidator, } from "./affiliateRecovery/validators.js";
69
+ //# sourceMappingURL=affiliateRecovery.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"affiliateRecovery.js","sourceRoot":"","sources":["../../src/client/affiliateRecovery.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,wBAAwB,EACxB,uBAAuB,GACxB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EAAE,oBAAoB,EAAE,MAAM,+BAA+B,CAAC;AACrE,OAAO,EAAE,kBAAkB,EAAE,MAAM,cAAc,CAAC;AAClD,OAAO,EAAE,YAAY,EAAE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yE;QAEzE,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,QAAQ,CAC9B,YAAY,CACV,IAAI,CAAC,SAAS,EACd,6CAA6C,CAC9C,EACD,IAAI,CACL,CAIA,CAAC;QACF,MAAM,OAAO,GAAG,EAAE,CAAC;QACnB,KAAK,MAAM,EAAE,IAAI,IAAI,CAAC,IAAI;YACxB,OAAO,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,EAAE,EAAE,YAAY,EAAE,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC,CAAC;QACzE,OAAO,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,CAAC;IAC9B,CAAC;CACF;AACD,OAAO,EACL,0BAA0B,EAC1B,4BAA4B,EAC5B,2BAA2B,GAC5B,MAAM,mCAAmC,CAAC"}
@@ -1,48 +1,8 @@
1
+ import { renderCheckoutSession } from "./checkoutRequest.js";
1
2
  import type Stripe from "stripe";
2
- import type { SplitRecipient } from "../../component/lib/fees.js";
3
3
  import type { Component, RunCtx } from "../helpers.js";
4
- import type { PlatformFeeConfig, StripeComponentCheckoutSession } from "../types.js";
5
- export declare function createCheckoutSession(stripe: Stripe, component: Component, ctx: RunCtx, opts: {
6
- idempotencyKey?: string;
7
- userId: string;
8
- orgId?: string;
9
- stripePriceId: string;
10
- mode: "payment" | "subscription" | "setup";
11
- uiMode?: "embedded" | "redirect" | "custom" | "form";
12
- quantity?: number;
13
- returnUrl: string;
14
- trialDays?: number;
15
- accountId?: string;
16
- customerEmail?: string;
17
- /**
18
- * The seller/recipient connected account funds are routed to (destination
19
- * charge). Fees only apply when this is set.
20
- */
21
- destinationAccountId?: string;
22
- /**
23
- * Multiple recipients for one sale (store + affiliate[s]). With >1 recipient
24
- * this routes via separate charges & transfers (no `application_fee`); the
25
- * transfers are created by the webhook engine. A single-recipient split is
26
- * treated as a destination charge. Takes precedence over `destinationAccountId`.
27
- */
28
- split?: SplitRecipient[];
29
- /** Resolved platform fee config (the caller resolves override → default). */
30
- feeConfig?: PlatformFeeConfig;
31
- /**
32
- * Charge total in minor units (one-time payment mode). When known, the
33
- * fixed `application_fee_amount` is computed up front; otherwise the fee is
34
- * deferred to the webhook.
35
- */
36
- amount?: number;
37
- /**
38
- * Platform-default statement-descriptor suffix (BTS-32), used when the
39
- * destination account record carries no per-store suffix. The caller
40
- * (BetterStripe) passes its validated configured default.
41
- */
42
- defaultStatementDescriptorSuffix?: string;
43
- metadata?: Record<string, string>;
44
- sessionOverrides?: Record<string, unknown>;
45
- }): Promise<{
4
+ import type { StripeComponentCheckoutSession } from "../types.js";
5
+ export declare function createCheckoutSession(stripe: Stripe, component: Component, ctx: RunCtx, opts: Parameters<typeof renderCheckoutSession>[3]): Promise<{
46
6
  stripeSessionId: string;
47
7
  clientSecret: string | undefined;
48
8
  url: string | undefined;
@@ -1 +1 @@
1
- {"version":3,"file":"checkout.d.ts","sourceRoot":"","sources":["../../../src/client/billing/checkout.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,6BAA6B,CAAC;AAGlE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAGvD,OAAO,KAAK,EACV,iBAAiB,EACjB,8BAA8B,EAC/B,MAAM,aAAa,CAAC;AAgGrB,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IACJ,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,aAAa,EAAE,MAAM,CAAC;IACtB,IAAI,EAAE,SAAS,GAAG,cAAc,GAAG,OAAO,CAAC;IAC3C,MAAM,CAAC,EAAE,UAAU,GAAG,UAAU,GAAG,QAAQ,GAAG,MAAM,CAAC;IACrD,QAA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AAO,CAAC,8BAA8B,GAAG,IAAI,CAAC,CAKhD;AAED,wBAAsB,4BAA4B,CAChD,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC,8BAA8B,GAAG,IAAI,CAAC,CAKhD;AAED,wBAAsB,0BAA0B,CAC9C,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAA;CAAE,GACxC,OAAO,CAAC,8BAA8B,EAAE,CAAC,CAK3C;AAED,wBAAsB,qBAAqB,CACzC,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IACJ,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,IAAI,EAAE,SAAS,GAAG,cAAc,GAAG,OAAO,CAAC;IAC3C,MAAM,EAAE,MAAM,GAAG,UAAU,GAAG,SAAS,CAAC;IACxC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC,iBAQF;AAED,wBAAsB,qBAAqB,CACzC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,MAAM,EACZ,IAAI,EAAE;IACJ,eAAe,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACnC,qDAMF"}
@@ -1,265 +1,10 @@
1
- import { idempotencyOptions } from "../core/idempotency.js";
2
- import { computeFee, isPercentOnlyFee, validateSplit } from "../core/fees.js";
3
- import { throwStripeError } from "../errors.js";
4
- import { runMutationOrThrow, stripReservedMetadata } from "../helpers.js";
1
+ import { renderCheckoutSession } from "./checkoutRequest.js";
2
+ import { submitPreparedCheckout } from "./preparedCheckout.js";
3
+ import { runMutationOrThrow } from "../helpers.js";
5
4
  import { componentRef } from "../webhooks/helpers.js";
6
- /**
7
- * Derive the persisted fee/routing fields (BTS-11) from the FINAL Checkout
8
- * Session request, reading the nested `subscription_data`/`payment_intent_data`
9
- * that will actually be sent to Stripe. Deriving from the final request (rather
10
- * than a pre-override draft) keeps the stored row consistent when callers pass
11
- * `sessionOverrides` that replace those nested params.
12
- */
13
- function deriveFeeRow(params) {
14
- const dest = (d) => typeof d === "string"
15
- ? d
16
- : (d?.id ?? undefined);
17
- if (params.mode === "subscription") {
18
- const destination = dest(params.subscription_data?.transfer_data?.destination);
19
- if (!destination)
20
- return {};
21
- const pct = params.subscription_data?.application_fee_percent;
22
- return {
23
- chargeType: "destination",
24
- destinationAccountId: destination,
25
- ...(pct !== undefined ? { applicationFeePercent: pct } : {}),
26
- };
27
- }
28
- if (params.mode === "payment") {
29
- const destination = dest(params.payment_intent_data?.transfer_data?.destination);
30
- if (!destination)
31
- return {};
32
- const amt = params.payment_intent_data?.application_fee_amount;
33
- return {
34
- chargeType: "destination",
35
- destinationAccountId: destination,
36
- ...(amt !== undefined ? { applicationFeeAmount: amt } : {}),
37
- };
38
- }
39
- return {};
40
- }
41
- /**
42
- * Destination and separate charges use platform prices. Catalog accountId is a
43
- * store attribution tag, not Stripe ownership (createProduct uses the platform).
44
- * For tagged products, verify the price in the platform Stripe context before
45
- * rejecting it. Untagged/unknown catalog entries are validated by Checkout.
46
- */
47
- async function assertPlatformPrice(stripe, component, ctx, stripePriceId) {
48
- const price = (await ctx.runQuery(componentRef(component, "products/queries/getPriceByStripeId"), { stripePriceId }));
49
- if (!price?.stripeProductId)
50
- return;
51
- const product = (await ctx.runQuery(componentRef(component, "products/queries/getProductByStripeId"), { stripeProductId: price.stripeProductId }));
52
- if (product?.accountId) {
53
- try {
54
- await stripe.prices.retrieve(stripePriceId);
55
- }
56
- catch (error) {
57
- // Only absence on the platform means the ownership check failed.
58
- // Auth/network/rate-limit failures must not be misreported as ownership.
59
- if (!error ||
60
- typeof error !== "object" ||
61
- !("code" in error) ||
62
- error.code !== "resource_missing")
63
- throw error;
64
- throwStripeError("INVALID_CONFIGURATION", `Price ${stripePriceId} is unavailable on the platform account; destination charges require a platform-owned price.`);
65
- }
66
- }
67
- }
68
- // =============================================================================
69
- // Checkout methods
70
- // =============================================================================
71
5
  export async function createCheckoutSession(stripe, component, ctx, opts) {
72
- const uiMode = opts.uiMode ?? "embedded";
73
- // Setup-mode sessions create no charge, so routing/fees are meaningless and
74
- // would persist an unfunded `chargeType` the webhook engine can't act on.
75
- if (opts.mode === "setup" &&
76
- (opts.split?.length || opts.destinationAccountId || opts.feeConfig)) {
77
- throwStripeError("INVALID_CONFIGURATION", "split/destinationAccountId/fee are not supported for setup-mode Checkout Sessions");
78
- }
79
- // Resolve the routing model. A `split` with >1 recipient uses separate charges
80
- // & transfers (no application_fee; webhook engine creates the transfers); a
81
- // single-recipient split is just a destination charge. `split` wins over
82
- // `destinationAccountId`.
83
- let isSeparate = false;
84
- let destinationAccountId = opts.destinationAccountId;
85
- if (opts.split && opts.split.length > 0) {
86
- validateSplit(opts.split);
87
- if (opts.split.length === 1) {
88
- destinationAccountId = opts.split[0].destinationAccountId;
89
- }
90
- else {
91
- isSeparate = true;
92
- }
93
- }
94
- // Metadata markers the webhook split engine reads to create the transfers.
95
- // For subscriptions these live on the subscription and are consumed on each
96
- // invoice.paid; for one-time payments they live on the PaymentIntent.
97
- const separateMeta = isSeparate
98
- ? {
99
- bsChargeType: "separate",
100
- bsSplit: JSON.stringify(opts.split),
101
- ...(opts.feeConfig
102
- ? { bsFeeConfig: JSON.stringify(opts.feeConfig) }
103
- : {}),
104
- }
105
- : {};
106
- // Strip the reserved `bs*` namespace from caller metadata so it can't forge
107
- // webhook instructions (e.g. trigger split transfers without routing).
108
- const metadata = {
109
- ...stripReservedMetadata(opts.metadata),
110
- userId: opts.userId,
111
- ...(opts.orgId ? { orgId: opts.orgId } : {}),
112
- };
113
- // Per-store statement descriptor (BTS-32). Destination charges are platform
114
- // charges (platform = merchant of record), so buyer recognition is
115
- // suffix-based: the store's stored suffix, else the configured platform
116
- // default. Resolved from the component account record at session creation.
117
- let statementDescriptorSuffix;
118
- if (destinationAccountId && !isSeparate && opts.mode !== "setup") {
119
- const account = (await ctx.runQuery(componentRef(component, "core/queries/getAccountByStripeId"), { stripeAccountId: destinationAccountId }));
120
- statementDescriptorSuffix =
121
- account?.statementDescriptor ?? opts.defaultStatementDescriptorSuffix;
122
- }
123
- const sessionParams = {
124
- mode: opts.mode,
125
- line_items: [{ price: opts.stripePriceId, quantity: opts.quantity ?? 1 }],
126
- metadata,
127
- };
128
- if (opts.mode === "subscription") {
129
- const subscriptionData = {
130
- metadata,
131
- };
132
- if (opts.trialDays) {
133
- subscriptionData.trial_period_days = opts.trialDays;
134
- }
135
- if (isSeparate) {
136
- // Separate charges & transfers: NO transfer_data / application_fee. The
137
- // split is carried in metadata for the webhook engine to execute.
138
- subscriptionData.metadata = { ...metadata, ...separateMeta };
139
- }
140
- else if (destinationAccountId) {
141
- // Single-recipient destination charge: route funds to the seller and take
142
- // the platform's cut. Percent-only fees map to `application_fee_percent`;
143
- // percent+fixed/tiered fees can't be expressed that way, so flag the
144
- // subscription for per-invoice fee computation (handled by WEBHOOK_FEE).
145
- subscriptionData.transfer_data = { destination: destinationAccountId };
146
- if (opts.feeConfig) {
147
- if (isPercentOnlyFee(opts.feeConfig)) {
148
- subscriptionData.application_fee_percent = opts.feeConfig.percent;
149
- }
150
- else {
151
- subscriptionData.metadata = {
152
- ...metadata,
153
- bsFeeMode: "per_invoice",
154
- bsFeeConfig: JSON.stringify(opts.feeConfig),
155
- };
156
- }
157
- }
158
- if (statementDescriptorSuffix) {
159
- // Subscriptions can't carry a suffix directly; the invoice.created
160
- // processor reads this marker and sets it on each invoice.
161
- subscriptionData.metadata = {
162
- ...(subscriptionData.metadata ?? metadata),
163
- bsStatementDescriptor: statementDescriptorSuffix,
164
- };
165
- }
166
- }
167
- sessionParams.subscription_data = subscriptionData;
168
- }
169
- if (opts.mode === "payment") {
170
- const paymentIntentData = { metadata };
171
- if (isSeparate) {
172
- paymentIntentData.metadata = { ...metadata, ...separateMeta };
173
- }
174
- else if (destinationAccountId) {
175
- // Single-recipient destination charge for a one-time purchase. The platform
176
- // fee is a fixed `application_fee_amount`: compute it when the amount is
177
- // known; otherwise flag the PI with `bsFeeMode=per_charge` and the webhook
178
- // collects it at payment_intent.succeeded via a partial reversal of the
179
- // destination transfer, sized from the amount actually charged (BTS-60).
180
- paymentIntentData.transfer_data = {
181
- destination: destinationAccountId,
182
- };
183
- if (statementDescriptorSuffix) {
184
- paymentIntentData.statement_descriptor_suffix =
185
- statementDescriptorSuffix;
186
- }
187
- if (opts.feeConfig) {
188
- if (opts.amount !== undefined) {
189
- paymentIntentData.application_fee_amount = computeFee(opts.amount, opts.feeConfig).feeAmount;
190
- }
191
- else {
192
- paymentIntentData.metadata = {
193
- ...metadata,
194
- bsFeeMode: "per_charge",
195
- bsFeeConfig: JSON.stringify(opts.feeConfig),
196
- };
197
- }
198
- }
199
- }
200
- sessionParams.payment_intent_data = paymentIntentData;
201
- }
202
- if (uiMode === "embedded" || uiMode === "custom" || uiMode === "form") {
203
- sessionParams.ui_mode =
204
- uiMode === "custom"
205
- ? "elements"
206
- : uiMode === "form"
207
- ? "form"
208
- : "embedded_page";
209
- sessionParams.return_url = opts.returnUrl;
210
- }
211
- else {
212
- sessionParams.success_url = `${opts.returnUrl}?session_id={CHECKOUT_SESSION_ID}`;
213
- sessionParams.cancel_url = opts.returnUrl;
214
- }
215
- if (opts.accountId) {
216
- sessionParams.customer_account = opts.accountId;
217
- }
218
- else if (opts.customerEmail) {
219
- sessionParams.customer_email = opts.customerEmail;
220
- }
221
- // Merge overrides, then derive the persisted fee/routing row from the FINAL
222
- // request — sessionOverrides can replace subscription_data/payment_intent_data
223
- // wholesale, so the row must reflect what was actually sent to Stripe.
224
- const finalSessionParams = {
225
- ...sessionParams,
226
- ...opts.sessionOverrides,
227
- };
228
- // Separate-charge sales persist the split + chargeType directly; single-recipient
229
- // destination charges derive the row from the final transfer_data/fee.
230
- const feeRow = isSeparate
231
- ? { chargeType: "separate", splitRecipients: opts.split }
232
- : deriveFeeRow(finalSessionParams);
233
- // Both destination and separate charges run on the platform account, so the
234
- // price must be platform-owned. Validate the FINAL request (post-overrides) so
235
- // callers can't inject transfer_data or swap line_items to bypass the check.
236
- const finalPriceId = finalSessionParams.line_items?.[0]?.price;
237
- if ((isSeparate || feeRow.chargeType === "destination") &&
238
- typeof finalPriceId === "string") {
239
- await assertPlatformPrice(stripe, component, ctx, finalPriceId);
240
- }
241
- const requestOptions = idempotencyOptions(opts.idempotencyKey);
242
- const session = requestOptions
243
- ? await stripe.checkout.sessions.create(finalSessionParams, requestOptions)
244
- : await stripe.checkout.sessions.create(finalSessionParams);
245
- await runMutationOrThrow(ctx, componentRef(component, "billing/mutations/upsertCheckoutSession"), {
246
- stripeSessionId: session.id,
247
- userId: opts.userId,
248
- orgId: opts.orgId,
249
- accountId: opts.accountId,
250
- mode: finalSessionParams.mode,
251
- status: (session.status ?? "open"),
252
- clientSecret: session.client_secret ?? undefined,
253
- url: session.url ?? undefined,
254
- priceId: opts.stripePriceId,
255
- ...feeRow,
256
- metadata,
257
- });
258
- return {
259
- stripeSessionId: session.id,
260
- clientSecret: session.client_secret ?? undefined,
261
- url: session.url ?? undefined,
262
- };
6
+ const prepared = await renderCheckoutSession(stripe, component, ctx, opts);
7
+ return submitPreparedCheckout(stripe, component, ctx, prepared, opts.idempotencyKey);
263
8
  }
264
9
  export async function getCheckoutSession(component, ctx, opts) {
265
10
  return (await ctx.runQuery(componentRef(component, "billing/queries/getCheckoutSession"), opts));
@@ -1 +1 @@
1
- {"version":3,"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