@fantastic.dev/better-stripe 0.7.0 → 0.8.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 (343) hide show
  1. package/CHANGELOG.md +23 -18
  2. package/README.md +122 -90
  3. package/dist/client/billing/checkout.d.ts +1 -1
  4. package/dist/client/billing/checkout.d.ts.map +1 -1
  5. package/dist/client/billing/checkout.js +7 -2
  6. package/dist/client/billing/checkout.js.map +1 -1
  7. package/dist/client/connect/paymentMethods.d.ts.map +1 -1
  8. package/dist/client/connect/paymentMethods.js.map +1 -1
  9. package/dist/client/connect/refundActor.d.ts.map +1 -1
  10. package/dist/client/connect/refundActor.js.map +1 -1
  11. package/dist/client/connect/refunds.d.ts.map +1 -1
  12. package/dist/client/connect/refunds.js.map +1 -1
  13. package/dist/client/connect/transfers.d.ts.map +1 -1
  14. package/dist/client/connect/transfers.js +15 -4
  15. package/dist/client/connect/transfers.js.map +1 -1
  16. package/dist/client/core/accountDefaults.d.ts +6 -0
  17. package/dist/client/core/accountDefaults.d.ts.map +1 -0
  18. package/dist/client/core/accountDefaults.js +15 -0
  19. package/dist/client/core/accountDefaults.js.map +1 -0
  20. package/dist/client/core/accounts.d.ts +1 -5
  21. package/dist/client/core/accounts.d.ts.map +1 -1
  22. package/dist/client/core/accounts.js +2 -14
  23. package/dist/client/core/accounts.js.map +1 -1
  24. package/dist/client/core/fees.d.ts.map +1 -1
  25. package/dist/client/core/fees.js +7 -2
  26. package/dist/client/core/fees.js.map +1 -1
  27. package/dist/client/index.d.ts +1 -1
  28. package/dist/client/index.d.ts.map +1 -1
  29. package/dist/client/products/prices.d.ts.map +1 -1
  30. package/dist/client/products/prices.js.map +1 -1
  31. package/dist/client/products/products.d.ts.map +1 -1
  32. package/dist/client/products/products.js +3 -1
  33. package/dist/client/products/products.js.map +1 -1
  34. package/dist/client/utils/owner.d.ts.map +1 -1
  35. package/dist/client/utils/owner.js +3 -1
  36. package/dist/client/utils/owner.js.map +1 -1
  37. package/dist/client/utils/stripeDashboardUrl.d.ts.map +1 -1
  38. package/dist/client/utils/stripeDashboardUrl.js.map +1 -1
  39. package/dist/client/webhooks/helpers.d.ts +10 -0
  40. package/dist/client/webhooks/helpers.d.ts.map +1 -1
  41. package/dist/client/webhooks/helpers.js +18 -0
  42. package/dist/client/webhooks/helpers.js.map +1 -1
  43. package/dist/client/webhooks/processors.d.ts.map +1 -1
  44. package/dist/client/webhooks/processors.js +1 -19
  45. package/dist/client/webhooks/processors.js.map +1 -1
  46. package/dist/component/connect/mutations.d.ts.map +1 -1
  47. package/dist/component/connect/mutations.js +4 -33
  48. package/dist/component/connect/mutations.js.map +1 -1
  49. package/dist/component/connect/schema.d.ts.map +1 -1
  50. package/dist/component/connect/schema.js.map +1 -1
  51. package/dist/component/lib/paymentSeller.d.ts +3 -0
  52. package/dist/component/lib/paymentSeller.d.ts.map +1 -0
  53. package/dist/component/lib/paymentSeller.js +10 -0
  54. package/dist/component/lib/paymentSeller.js.map +1 -0
  55. package/dist/component/lib/reversals.d.ts +10 -0
  56. package/dist/component/lib/reversals.d.ts.map +1 -1
  57. package/dist/component/lib/reversals.js +17 -0
  58. package/dist/component/lib/reversals.js.map +1 -1
  59. package/dist/react/components/ConnectProvider.d.ts +1 -1
  60. package/dist/react/components/ConnectProvider.d.ts.map +1 -1
  61. package/dist/react/components/ConnectProvider.js +18 -4
  62. package/dist/react/components/ConnectProvider.js.map +1 -1
  63. package/dist/react/components/ConnectStatusBadge.d.ts.map +1 -1
  64. package/dist/react/components/ConnectStatusBadge.js.map +1 -1
  65. package/dist/react/components/EmbeddedDisputes.d.ts +1 -1
  66. package/dist/react/components/EmbeddedDisputes.d.ts.map +1 -1
  67. package/dist/react/components/EmbeddedDisputes.js +1 -1
  68. package/dist/react/components/EmbeddedDisputes.js.map +1 -1
  69. package/dist/react/components/SplitBreakdown.d.ts.map +1 -1
  70. package/dist/react/components/SplitBreakdown.js +12 -2
  71. package/dist/react/components/SplitBreakdown.js.map +1 -1
  72. package/dist/react/hooks/useCheckoutSession.d.ts.map +1 -1
  73. package/dist/react/hooks/useCheckoutSession.js.map +1 -1
  74. package/dist/react/hooks/useConfirmPayment.d.ts.map +1 -1
  75. package/dist/react/hooks/useConfirmPayment.js.map +1 -1
  76. package/dist/react/index.d.ts +1 -0
  77. package/dist/react/index.d.ts.map +1 -1
  78. package/dist/react/index.js +2 -0
  79. package/dist/react/index.js.map +1 -1
  80. package/dist/react/workflows/Account.d.ts +67 -0
  81. package/dist/react/workflows/Account.d.ts.map +1 -0
  82. package/dist/react/workflows/Account.js +74 -0
  83. package/dist/react/workflows/Account.js.map +1 -0
  84. package/dist/react/workflows/Billing.d.ts +60 -0
  85. package/dist/react/workflows/Billing.d.ts.map +1 -0
  86. package/dist/react/workflows/Billing.js +84 -0
  87. package/dist/react/workflows/Billing.js.map +1 -0
  88. package/dist/react/workflows/BillingPlans.d.ts +45 -0
  89. package/dist/react/workflows/BillingPlans.d.ts.map +1 -0
  90. package/dist/react/workflows/BillingPlans.js +51 -0
  91. package/dist/react/workflows/BillingPlans.js.map +1 -0
  92. package/dist/react/workflows/Checkout.d.ts +46 -0
  93. package/dist/react/workflows/Checkout.d.ts.map +1 -0
  94. package/dist/react/workflows/Checkout.js +61 -0
  95. package/dist/react/workflows/Checkout.js.map +1 -0
  96. package/dist/react/workflows/CheckoutChooser.d.ts +20 -0
  97. package/dist/react/workflows/CheckoutChooser.d.ts.map +1 -0
  98. package/dist/react/workflows/CheckoutChooser.js +24 -0
  99. package/dist/react/workflows/CheckoutChooser.js.map +1 -0
  100. package/dist/react/workflows/CheckoutForms.d.ts +26 -0
  101. package/dist/react/workflows/CheckoutForms.d.ts.map +1 -0
  102. package/dist/react/workflows/CheckoutForms.js +126 -0
  103. package/dist/react/workflows/CheckoutForms.js.map +1 -0
  104. package/dist/react/workflows/ClipboardButton.d.ts +17 -0
  105. package/dist/react/workflows/ClipboardButton.d.ts.map +1 -0
  106. package/dist/react/workflows/ClipboardButton.js +35 -0
  107. package/dist/react/workflows/ClipboardButton.js.map +1 -0
  108. package/dist/react/workflows/Collection.d.ts +30 -0
  109. package/dist/react/workflows/Collection.d.ts.map +1 -0
  110. package/dist/react/workflows/Collection.js +25 -0
  111. package/dist/react/workflows/Collection.js.map +1 -0
  112. package/dist/react/workflows/Collections.d.ts +56 -0
  113. package/dist/react/workflows/Collections.d.ts.map +1 -0
  114. package/dist/react/workflows/Collections.js +111 -0
  115. package/dist/react/workflows/Collections.js.map +1 -0
  116. package/dist/react/workflows/Connect.d.ts +19 -0
  117. package/dist/react/workflows/Connect.d.ts.map +1 -0
  118. package/dist/react/workflows/Connect.js +43 -0
  119. package/dist/react/workflows/Connect.js.map +1 -0
  120. package/dist/react/workflows/Costs.d.ts +48 -0
  121. package/dist/react/workflows/Costs.d.ts.map +1 -0
  122. package/dist/react/workflows/Costs.js +66 -0
  123. package/dist/react/workflows/Costs.js.map +1 -0
  124. package/dist/react/workflows/Disputes.d.ts +36 -0
  125. package/dist/react/workflows/Disputes.d.ts.map +1 -0
  126. package/dist/react/workflows/Disputes.js +74 -0
  127. package/dist/react/workflows/Disputes.js.map +1 -0
  128. package/dist/react/workflows/Earnings.d.ts +42 -0
  129. package/dist/react/workflows/Earnings.d.ts.map +1 -0
  130. package/dist/react/workflows/Earnings.js +38 -0
  131. package/dist/react/workflows/Earnings.js.map +1 -0
  132. package/dist/react/workflows/Financials.d.ts +43 -0
  133. package/dist/react/workflows/Financials.d.ts.map +1 -0
  134. package/dist/react/workflows/Financials.js +57 -0
  135. package/dist/react/workflows/Financials.js.map +1 -0
  136. package/dist/react/workflows/IntegrationSwitch.d.ts +23 -0
  137. package/dist/react/workflows/IntegrationSwitch.d.ts.map +1 -0
  138. package/dist/react/workflows/IntegrationSwitch.js +31 -0
  139. package/dist/react/workflows/IntegrationSwitch.js.map +1 -0
  140. package/dist/react/workflows/Onboarding.d.ts +56 -0
  141. package/dist/react/workflows/Onboarding.d.ts.map +1 -0
  142. package/dist/react/workflows/Onboarding.js +86 -0
  143. package/dist/react/workflows/Onboarding.js.map +1 -0
  144. package/dist/react/workflows/Overview.d.ts +51 -0
  145. package/dist/react/workflows/Overview.d.ts.map +1 -0
  146. package/dist/react/workflows/Overview.js +63 -0
  147. package/dist/react/workflows/Overview.js.map +1 -0
  148. package/dist/react/workflows/PaymentMethods.d.ts +35 -0
  149. package/dist/react/workflows/PaymentMethods.d.ts.map +1 -0
  150. package/dist/react/workflows/PaymentMethods.js +63 -0
  151. package/dist/react/workflows/PaymentMethods.js.map +1 -0
  152. package/dist/react/workflows/PaymentReceipt.d.ts +20 -0
  153. package/dist/react/workflows/PaymentReceipt.d.ts.map +1 -0
  154. package/dist/react/workflows/PaymentReceipt.js +24 -0
  155. package/dist/react/workflows/PaymentReceipt.js.map +1 -0
  156. package/dist/react/workflows/Payouts.d.ts +47 -0
  157. package/dist/react/workflows/Payouts.d.ts.map +1 -0
  158. package/dist/react/workflows/Payouts.js +87 -0
  159. package/dist/react/workflows/Payouts.js.map +1 -0
  160. package/dist/react/workflows/Products.d.ts +92 -0
  161. package/dist/react/workflows/Products.d.ts.map +1 -0
  162. package/dist/react/workflows/Products.js +179 -0
  163. package/dist/react/workflows/Products.js.map +1 -0
  164. package/dist/react/workflows/ReferralLinks.d.ts +26 -0
  165. package/dist/react/workflows/ReferralLinks.d.ts.map +1 -0
  166. package/dist/react/workflows/ReferralLinks.js +30 -0
  167. package/dist/react/workflows/ReferralLinks.js.map +1 -0
  168. package/dist/react/workflows/Refunds.d.ts +72 -0
  169. package/dist/react/workflows/Refunds.d.ts.map +1 -0
  170. package/dist/react/workflows/Refunds.js +95 -0
  171. package/dist/react/workflows/Refunds.js.map +1 -0
  172. package/dist/react/workflows/Setup.d.ts +50 -0
  173. package/dist/react/workflows/Setup.d.ts.map +1 -0
  174. package/dist/react/workflows/Setup.js +59 -0
  175. package/dist/react/workflows/Setup.js.map +1 -0
  176. package/dist/react/workflows/Storefront.d.ts +53 -0
  177. package/dist/react/workflows/Storefront.d.ts.map +1 -0
  178. package/dist/react/workflows/Storefront.js +44 -0
  179. package/dist/react/workflows/Storefront.js.map +1 -0
  180. package/dist/react/workflows/SubscriptionOverview.d.ts +13 -0
  181. package/dist/react/workflows/SubscriptionOverview.d.ts.map +1 -0
  182. package/dist/react/workflows/SubscriptionOverview.js +26 -0
  183. package/dist/react/workflows/SubscriptionOverview.js.map +1 -0
  184. package/dist/react/workflows/Subscriptions.d.ts +92 -0
  185. package/dist/react/workflows/Subscriptions.d.ts.map +1 -0
  186. package/dist/react/workflows/Subscriptions.js +149 -0
  187. package/dist/react/workflows/Subscriptions.js.map +1 -0
  188. package/dist/react/workflows/Tasks.d.ts +40 -0
  189. package/dist/react/workflows/Tasks.d.ts.map +1 -0
  190. package/dist/react/workflows/Tasks.js +113 -0
  191. package/dist/react/workflows/Tasks.js.map +1 -0
  192. package/dist/react/workflows/checkout-options.d.ts +37 -0
  193. package/dist/react/workflows/checkout-options.d.ts.map +1 -0
  194. package/dist/react/workflows/checkout-options.js +43 -0
  195. package/dist/react/workflows/checkout-options.js.map +1 -0
  196. package/dist/react/workflows/current-subscription.d.ts +11 -0
  197. package/dist/react/workflows/current-subscription.d.ts.map +1 -0
  198. package/dist/react/workflows/current-subscription.js +14 -0
  199. package/dist/react/workflows/current-subscription.js.map +1 -0
  200. package/dist/react/workflows/filters.d.ts +17 -0
  201. package/dist/react/workflows/filters.d.ts.map +1 -0
  202. package/dist/react/workflows/filters.js +23 -0
  203. package/dist/react/workflows/filters.js.map +1 -0
  204. package/dist/react/workflows/index.d.ts +70 -0
  205. package/dist/react/workflows/index.d.ts.map +1 -0
  206. package/dist/react/workflows/index.js +38 -0
  207. package/dist/react/workflows/index.js.map +1 -0
  208. package/dist/react/workflows/useWorkflowAction.d.ts +11 -0
  209. package/dist/react/workflows/useWorkflowAction.d.ts.map +1 -0
  210. package/dist/react/workflows/useWorkflowAction.js +68 -0
  211. package/dist/react/workflows/useWorkflowAction.js.map +1 -0
  212. package/dist/react/workflows/useWorkflowResource.d.ts +9 -0
  213. package/dist/react/workflows/useWorkflowResource.d.ts.map +1 -0
  214. package/dist/react/workflows/useWorkflowResource.js +67 -0
  215. package/dist/react/workflows/useWorkflowResource.js.map +1 -0
  216. package/docs/react-workflows-audit.md +66 -0
  217. package/docs/react-workflows.md +231 -0
  218. package/package.json +19 -3
  219. package/src/client/billing/checkout-ui-modes.test.ts +49 -0
  220. package/src/client/billing/checkout.ts +8 -3
  221. package/src/client/billing/invoices.test.ts +12 -6
  222. package/src/client/connect/paymentMethods.test.ts +3 -1
  223. package/src/client/connect/paymentMethods.ts +4 -1
  224. package/src/client/connect/refundActor.ts +1 -2
  225. package/src/client/connect/refunds.test.ts +35 -10
  226. package/src/client/connect/refunds.ts +4 -1
  227. package/src/client/connect/transfers.test.ts +66 -12
  228. package/src/client/connect/transfers.ts +32 -8
  229. package/src/client/core/accountDefaults.ts +15 -0
  230. package/src/client/core/accounts.ts +14 -17
  231. package/src/client/core/config.test.ts +2 -1
  232. package/src/client/core/descriptors.test.ts +6 -4
  233. package/src/client/core/fees.test.ts +20 -28
  234. package/src/client/core/fees.ts +9 -2
  235. package/src/client/index.test.ts +22 -22
  236. package/src/client/index.ts +1 -1
  237. package/src/client/products/prices.test.ts +8 -2
  238. package/src/client/products/prices.ts +4 -1
  239. package/src/client/products/products.test.ts +61 -20
  240. package/src/client/products/products.ts +3 -1
  241. package/src/client/utils/data.test.ts +3 -1
  242. package/src/client/utils/owner.test.ts +4 -1
  243. package/src/client/utils/owner.ts +5 -1
  244. package/src/client/utils/stripeDashboardUrl.ts +1 -4
  245. package/src/client/webhooks/handler.test.ts +16 -19
  246. package/src/client/webhooks/helpers.test.ts +26 -13
  247. package/src/client/webhooks/helpers.ts +23 -0
  248. package/src/client/webhooks/hooks.test.ts +1 -2
  249. package/src/client/webhooks/processors.test.ts +18 -34
  250. package/src/client/webhooks/processors.ts +1 -23
  251. package/src/client/webhooks.test.ts +1 -2
  252. package/src/component/_generated/api.ts +2 -0
  253. package/src/component/connect/mutations.ts +5 -46
  254. package/src/component/connect/schema.ts +4 -3
  255. package/src/component/connect.test.ts +1 -5
  256. package/src/component/lib/paymentSeller.ts +15 -0
  257. package/src/component/lib/reversals.ts +30 -2
  258. package/src/component/subscription-scoping.test.ts +5 -1
  259. package/src/component/triggers.test.ts +7 -4
  260. package/src/react/components/BuyerBillingView.render.test.tsx +7 -2
  261. package/src/react/components/ConnectProvider.live.test.tsx +61 -0
  262. package/src/react/components/ConnectProvider.tsx +18 -4
  263. package/src/react/components/ConnectStatusBadge.tsx +1 -4
  264. package/src/react/components/DisputeDetail.render.test.tsx +5 -1
  265. package/src/react/components/EarningsSummary.render.test.tsx +2 -6
  266. package/src/react/components/EmbeddedDisputes.render.test.tsx +7 -5
  267. package/src/react/components/EmbeddedDisputes.tsx +4 -1
  268. package/src/react/components/EvidenceForm.render.test.tsx +2 -8
  269. package/src/react/components/SplitBreakdown.render.test.tsx +28 -5
  270. package/src/react/components/SplitBreakdown.tsx +12 -2
  271. package/src/react/hooks/useCheckoutSession.ts +1 -2
  272. package/src/react/hooks/useConfirmPayment.ts +1 -2
  273. package/src/react/hooks/useEarnings.test.ts +43 -8
  274. package/src/react/hooks/useStripeMode.test.ts +5 -8
  275. package/src/react/index.ts +3 -0
  276. package/src/react/workflows/Account.test.tsx +31 -0
  277. package/src/react/workflows/Account.tsx +183 -0
  278. package/src/react/workflows/Billing.test.tsx +45 -0
  279. package/src/react/workflows/Billing.tsx +213 -0
  280. package/src/react/workflows/BillingPlans.test.tsx +31 -0
  281. package/src/react/workflows/BillingPlans.tsx +130 -0
  282. package/src/react/workflows/Checkout.test.tsx +118 -0
  283. package/src/react/workflows/Checkout.tsx +135 -0
  284. package/src/react/workflows/CheckoutChooser.test.tsx +44 -0
  285. package/src/react/workflows/CheckoutChooser.tsx +77 -0
  286. package/src/react/workflows/CheckoutForm.test.tsx +66 -0
  287. package/src/react/workflows/CheckoutForms.test.tsx +123 -0
  288. package/src/react/workflows/CheckoutForms.tsx +247 -0
  289. package/src/react/workflows/ClipboardButton.test.tsx +34 -0
  290. package/src/react/workflows/ClipboardButton.tsx +67 -0
  291. package/src/react/workflows/Collection.tsx +76 -0
  292. package/src/react/workflows/Collections.test.tsx +86 -0
  293. package/src/react/workflows/Collections.tsx +213 -0
  294. package/src/react/workflows/Connect.test.tsx +50 -0
  295. package/src/react/workflows/Connect.tsx +107 -0
  296. package/src/react/workflows/Costs.test.tsx +41 -0
  297. package/src/react/workflows/Costs.tsx +133 -0
  298. package/src/react/workflows/Disputes.test.tsx +25 -0
  299. package/src/react/workflows/Disputes.tsx +164 -0
  300. package/src/react/workflows/Earnings.test.ts +19 -0
  301. package/src/react/workflows/Earnings.tsx +84 -0
  302. package/src/react/workflows/Financials.test.tsx +35 -0
  303. package/src/react/workflows/Financials.tsx +117 -0
  304. package/src/react/workflows/IntegrationSwitch.test.tsx +36 -0
  305. package/src/react/workflows/IntegrationSwitch.tsx +63 -0
  306. package/src/react/workflows/Onboarding.test.tsx +75 -0
  307. package/src/react/workflows/Onboarding.tsx +171 -0
  308. package/src/react/workflows/Overview.test.tsx +57 -0
  309. package/src/react/workflows/Overview.tsx +123 -0
  310. package/src/react/workflows/PaymentMethods.test.tsx +60 -0
  311. package/src/react/workflows/PaymentMethods.tsx +117 -0
  312. package/src/react/workflows/PaymentReceipt.test.tsx +24 -0
  313. package/src/react/workflows/PaymentReceipt.tsx +46 -0
  314. package/src/react/workflows/Payouts.test.tsx +82 -0
  315. package/src/react/workflows/Payouts.tsx +212 -0
  316. package/src/react/workflows/Products.test.tsx +90 -0
  317. package/src/react/workflows/Products.tsx +377 -0
  318. package/src/react/workflows/ReferralLinks.test.tsx +39 -0
  319. package/src/react/workflows/ReferralLinks.tsx +75 -0
  320. package/src/react/workflows/Refunds.test.tsx +75 -0
  321. package/src/react/workflows/Refunds.tsx +223 -0
  322. package/src/react/workflows/Setup.test.tsx +25 -0
  323. package/src/react/workflows/Setup.tsx +166 -0
  324. package/src/react/workflows/Storefront.test.tsx +82 -0
  325. package/src/react/workflows/Storefront.tsx +138 -0
  326. package/src/react/workflows/SubscriptionOverview.test.tsx +27 -0
  327. package/src/react/workflows/SubscriptionOverview.tsx +48 -0
  328. package/src/react/workflows/Subscriptions.test.tsx +61 -0
  329. package/src/react/workflows/Subscriptions.tsx +282 -0
  330. package/src/react/workflows/Tasks.test.tsx +23 -0
  331. package/src/react/workflows/Tasks.tsx +199 -0
  332. package/src/react/workflows/checkout-options.ts +42 -0
  333. package/src/react/workflows/current-subscription.test.ts +29 -0
  334. package/src/react/workflows/current-subscription.ts +25 -0
  335. package/src/react/workflows/filters.test.ts +12 -0
  336. package/src/react/workflows/filters.ts +22 -0
  337. package/src/react/workflows/index.ts +238 -0
  338. package/src/react/workflows/native-interactions.test.tsx +73 -0
  339. package/src/react/workflows/public-workflows.test.tsx +216 -0
  340. package/src/react/workflows/useWorkflowAction.test.tsx +54 -0
  341. package/src/react/workflows/useWorkflowAction.ts +75 -0
  342. package/src/react/workflows/useWorkflowResource.test.tsx +41 -0
  343. package/src/react/workflows/useWorkflowResource.ts +78 -0
@@ -0,0 +1,38 @@
1
+ export { useWorkflowAction } from "./useWorkflowAction.js";
2
+ export { useWorkflowResource } from "./useWorkflowResource.js";
3
+ export { Checkout } from "./Checkout.js";
4
+ export { CheckoutElementsForm, PaymentIntentForm, CheckoutForm, } from "./CheckoutForms.js";
5
+ export { Connect } from "./Connect.js";
6
+ export { Payouts } from "./Payouts.js";
7
+ export { Refunds, useRefunds, parseAmountCents } from "./Refunds.js";
8
+ export { Collection } from "./Collection.js";
9
+ export { Sales, Invoices, RefundHistory, ReferredSales, WebhookEvents, } from "./Collections.js";
10
+ export { Products, useProductManager } from "./Products.js";
11
+ export { Onboarding, useOnboarding } from "./Onboarding.js";
12
+ export { Disputes, useDisputeResponse } from "./Disputes.js";
13
+ export { InvoiceEstimate, useInvoiceEstimate, BalancePaymentSource, useBalanceFunding, BillingPortal, } from "./Billing.js";
14
+ export { SubscriptionManager, useSubscriptionManager, Subscriptions, useSubscriptionFilter, SUBSCRIPTION_FILTERS, } from "./Subscriptions.js";
15
+ export { PaymentMethods, usePaymentMethodsManager, toPaymentMethodItem, } from "./PaymentMethods.js";
16
+ export { ReferralLinks, useReferralLinks } from "./ReferralLinks.js";
17
+ export { IntegrationSwitch } from "./IntegrationSwitch.js";
18
+ export { CHECKOUT_OPTIONS } from "./checkout-options.js";
19
+ export { Account, useAccountManager } from "./Account.js";
20
+ export { WorkflowTasks, StripeSetup, SandboxTesting, useTaskRunner, } from "./Tasks.js";
21
+ export { WebhookSetup, useWebhookSetup, EnvironmentStatus, FixtureProgress, } from "./Setup.js";
22
+ export { BillingPlans, usePlanBilling } from "./BillingPlans.js";
23
+ export { CostRecovery, ChargebackLedger } from "./Costs.js";
24
+ export { Storefront } from "./Storefront.js";
25
+ export { PaymentReceipt } from "./PaymentReceipt.js";
26
+ export { Earnings, earningsFromBalance } from "./Earnings.js";
27
+ export { ClipboardButton } from "./ClipboardButton.js";
28
+ export { useWebhookFilters, webhookQueryArgs } from "./filters.js";
29
+ export { AccountConfigurations } from "./Account.js";
30
+ export { Overview, getPayoutTotals } from "./Overview.js";
31
+ export { currentSubscriptionFrom } from "./current-subscription.js";
32
+ export { CheckoutChooser } from "./CheckoutChooser.js";
33
+ export { SubscriptionOverview } from "./SubscriptionOverview.js";
34
+ export { DEFAULT_CONNECT_COUNTRIES } from "./Onboarding.js";
35
+ export { PayoutHistory } from "./Payouts.js";
36
+ export { PayoutOverview } from "./Overview.js";
37
+ export { ChargeSummary, PaymentDetails } from "./Financials.js";
38
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,Q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AAO,EACL,YAAY,EACZ,eAAe,EACf,iBAAiB,EACjB,eAAe,GAChB,MAAM,YAAY,CAAC;AAMpB,OAAO,EAAE,YAAY,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAMjE,OAAO,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAO5D,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAU7C,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAMrD,OAAO,EAAE,QAAQ,EAAE,mBAAmB,EAAE,MAAM,eAAe,CAAC;AAS9D,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,iBAAiB,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAMvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAKjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC"}
@@ -0,0 +1,11 @@
1
+ export type WorkflowActionState<T, Args extends unknown[]> = {
2
+ isPending: boolean;
3
+ error: string | null;
4
+ result: T | undefined;
5
+ /** Errors are exposed in state; failed and duplicate calls return undefined. */
6
+ run: (...args: Args) => Promise<T | undefined>;
7
+ reset: () => void;
8
+ };
9
+ /** Shared async action lifecycle. Scope identifies the authenticated account/resource, not authorization. */
10
+ export declare function useWorkflowAction<T, Args extends unknown[]>(action: (...args: Args) => Promise<T>, scope?: string): WorkflowActionState<T, Args>;
11
+ //# sourceMappingURL=useWorkflowAction.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWorkflowAction.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/useWorkflowAction.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,mBAAmB,CAAC,CAAC,EAAE,IAAI,SAAS,OAAO,EAAE,IAAI;IAC3D,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,MAAM,EAAE,CAAC,GAAG,SAAS,CAAC;IACtB,gFAAgF;IAChF,GAAG,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,GAAG,SAAS,CAAC,CAAC;IAC/C,KAAK,EAAE,MAAM,IAAI,CAAC;CACnB,CAAC;AACF,6GAA6G;AAC7G,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,IAAI,SAAS,OAAO,EAAE,EACzD,MAAM,EAAE,CAAC,GAAG,IAAI,EAAE,IAAI,KAAK,OAAO,CAAC,CAAC,CAAC,EACrC,KAAK,GAAE,MAAkB,GACxB,mBAAmB,CAAC,CAAC,EAAE,IAAI,CAAC,CA4D9B"}
@@ -0,0 +1,68 @@
1
+ "use client";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ /** Shared async action lifecycle. Scope identifies the authenticated account/resource, not authorization. */
4
+ export function useWorkflowAction(action, scope = "default") {
5
+ const initial = {
6
+ scope,
7
+ isPending: false,
8
+ error: null,
9
+ result: undefined,
10
+ };
11
+ const [state, setState] = useState(initial);
12
+ if (state.scope !== scope)
13
+ setState(initial);
14
+ const callback = useRef(action);
15
+ const lifecycle = useRef({ version: 0, mounted: false });
16
+ const lock = useRef(null);
17
+ useEffect(() => {
18
+ callback.current = action;
19
+ }, [action]);
20
+ useEffect(() => {
21
+ const version = ++lifecycle.current.version;
22
+ lifecycle.current.mounted = true;
23
+ lock.current = null;
24
+ return () => {
25
+ if (lifecycle.current.version === version) {
26
+ lifecycle.current.mounted = false;
27
+ lifecycle.current.version++;
28
+ lock.current = null;
29
+ }
30
+ };
31
+ }, [scope]);
32
+ const reset = useCallback(() => {
33
+ if (lock.current !== null)
34
+ return;
35
+ setState({ scope, isPending: false, error: null, result: undefined });
36
+ }, [scope]);
37
+ const run = useCallback(async (...args) => {
38
+ if (lock.current !== null)
39
+ return undefined;
40
+ const version = lifecycle.current.version;
41
+ lock.current = version;
42
+ setState({ scope, isPending: true, error: null, result: undefined });
43
+ const current = () => lifecycle.current.mounted && lifecycle.current.version === version;
44
+ try {
45
+ const result = await callback.current(...args);
46
+ if (!current())
47
+ return undefined;
48
+ setState({ scope, isPending: false, error: null, result });
49
+ return result;
50
+ }
51
+ catch (error) {
52
+ if (current())
53
+ setState({
54
+ scope,
55
+ isPending: false,
56
+ error: error instanceof Error ? error.message : String(error),
57
+ result: undefined,
58
+ });
59
+ return undefined;
60
+ }
61
+ finally {
62
+ if (lock.current === version)
63
+ lock.current = null;
64
+ }
65
+ }, [scope]);
66
+ return { ...state, run, reset };
67
+ }
68
+ //# sourceMappingURL=useWorkflowAction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWorkflowAction.js","sourceRoot":"","sources":["../../../src/react/workflows/useWorkflowAction.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AASjE,6GAA6G;AAC7G,MAAM,UAAU,iBAAiB,CAC/B,MAAqC,EACrC,KAAK,GAAW,SAAS;IAEzB,MAAM,OAAO,GAAG;QACd,KAAK;QACL,SAAS,EAAE,KAAK;QAChB,KAAK,EAAE,IAAqB;QAC5B,MAAM,EAAE,SAA0B;KACnC,CAAC;IACF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,OAAO,C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AO,EAAE,GAAG,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,CAAC;AAClC,CAAC"}
@@ -0,0 +1,9 @@
1
+ /** Loads once per scope/refresh, including under React StrictMode. Stale requests cannot update another scope. */
2
+ export declare function useWorkflowResource<T>(load: () => Promise<T>, scope?: string): {
3
+ revision: number;
4
+ data: T | undefined;
5
+ error: string | null;
6
+ isLoading: boolean;
7
+ refresh: () => void;
8
+ };
9
+ //# sourceMappingURL=useWorkflowResource.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWorkflowResource.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/useWorkflowResource.ts"],"names":[],"mappings":"AAEA,kHAAkH;AAClH,wBAAgB,mBAAmB,CAAC,CAAC,EACnC,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EACtB,KAAK,SAAY;;;;;;EAwElB"}
@@ -0,0 +1,67 @@
1
+ "use client";
2
+ import { useCallback, useEffect, useRef, useState } from "react";
3
+ /** Loads once per scope/refresh, including under React StrictMode. Stale requests cannot update another scope. */
4
+ export function useWorkflowResource(load, scope = "default") {
5
+ const initial = {
6
+ scope,
7
+ attempt: 0,
8
+ data: undefined,
9
+ error: null,
10
+ isLoading: true,
11
+ };
12
+ const [state, setState] = useState(initial);
13
+ if (state.scope !== scope)
14
+ setState(initial);
15
+ const loader = useRef(load);
16
+ const request = useRef(null);
17
+ useEffect(() => {
18
+ loader.current = load;
19
+ }, [load]);
20
+ useEffect(() => {
21
+ let active = true;
22
+ if (!request.current ||
23
+ request.current.scope !== scope ||
24
+ request.current.attempt !== state.attempt) {
25
+ request.current = {
26
+ scope,
27
+ attempt: state.attempt,
28
+ promise: Promise.resolve().then(() => loader.current()),
29
+ };
30
+ }
31
+ void request.current.promise
32
+ .then((data) => {
33
+ if (active)
34
+ setState((previous) => ({
35
+ ...previous,
36
+ data,
37
+ error: null,
38
+ isLoading: false,
39
+ }));
40
+ })
41
+ .catch((error) => {
42
+ if (active)
43
+ setState((previous) => ({
44
+ ...previous,
45
+ error: error instanceof Error ? error.message : String(error),
46
+ isLoading: false,
47
+ }));
48
+ });
49
+ return () => {
50
+ active = false;
51
+ };
52
+ }, [scope, state.attempt]);
53
+ const refresh = useCallback(() => setState((previous) => ({
54
+ ...previous,
55
+ attempt: previous.attempt + 1,
56
+ isLoading: true,
57
+ error: null,
58
+ })), []);
59
+ return {
60
+ revision: state.attempt,
61
+ data: state.data,
62
+ error: state.error,
63
+ isLoading: state.isLoading,
64
+ refresh,
65
+ };
66
+ }
67
+ //# sourceMappingURL=useWorkflowResource.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWorkflowResource.js","sourceRoot":"","sources":["../../../src/react/workflows/useWorkflowResource.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;AACb,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACjE,kHAAkH;AAClH,MAAM,UAAU,mBAAmB,CACjC,IAAsB,EACtB,KAAK,GAAG,SAAS;IAEjB,MAAM,OAAO,GAAG;QACd,KAAK;QACL,OAAO,EAAE,CAAC;QACV,IAAI,EAAE,SAA0B;QAChC,KAAK,EAAE,IAAqB;QAC5B,SAAS,EAAE,IAAI;KAChB,CAAC;IACF,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC5C,IAAI,KAAK,CAAC,KAAK,KAAK,KAAK;QAAE,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC7C,MAAM,MAAM,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC;IAC5B,MAAM,OAAO,GAAG,MAAM,CAIZ,IAAI,CAAC,CAAC;IAChB,SAAS,CAAC,GAAG,EAAE;QACb,MAAM,CAAC,OAAO,GAAG,IAAI,CAAC;IACxB,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;IACX,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,MAAM,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CAAC;QACtB,GAAG,QAAQ;QACX,OAAO,EAAE,QAAQ,CAAC,OAAO,GAAG,CAAC;QAC7B,SAAS,EAAE,IAAI;QACf,KAAK,EAAE,IAAI;KACZ,CAAC,CAAC,EACL,EAAE,CACH,CAAC;IACF,OAAO;QACL,QAAQ,EAAE,KAAK,CAAC,OAAO;QACvB,IAAI,EAAE,KAAK,CAAC,IAAI;QAChB,KAAK,EAAE,KAAK,CAAC,KAAK;QAClB,SAAS,EAAE,KAAK,CAAC,SAAS;QAC1B,OAAO;KACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,66 @@
1
+ # Example UI audit
2
+
3
+ Every financial/account page has a public React component or workflow hook in
4
+ `@fantastic.dev/better-stripe/react`. Native unstyled components implement the
5
+ shared workflows. The example binds authenticated Convex queries/actions and
6
+ uses render props or companion hooks to apply shadcn styling.
7
+
8
+ | Example page or adapter | Package UI and workflow ownership |
9
+ | ----------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ |
10
+ | Home and stores | `Storefront`, including store filtering, active catalog prices, purchase actions, and referral attribution |
11
+ | Checkout chooser | `CheckoutChooser`, `CHECKOUT_OPTIONS`, recurring-product compatibility and selection |
12
+ | Checkout session / PaymentIntent adapters | `Checkout`, `CheckoutElementsForm`, `PaymentIntentForm`, `CheckoutForm`, `EmbeddedCheckout`, including loading, retry, validation and confirmation |
13
+ | Checkout status | `CheckoutStatus`, `PaymentReceipt`, server/webhook confirmation |
14
+ | Customer overview | `SubscriptionOverview` |
15
+ | Customer subscription billing | `useSubscriptionManager`, `SubscriptionManager`, `BuyerBillingView`, `SubscriptionCard`, `Invoices`, `BillingPortalLink` |
16
+ | Customer invoices | `Invoices` |
17
+ | Customer payment methods | `usePaymentMethodsManager`, `PaymentMethods`, `PaymentMethodsList`, `AddCardForm`, Stripe providers |
18
+ | Seller overview | `PayoutOverview`, `AccountCreateCard`, `ConnectStatusBadge` |
19
+ | Seller and affiliate payouts | `Payouts`, `PayoutHistory`, live balances, upcoming date, history and pagination |
20
+ | Seller earnings | `EarningsSummary`, `PayoutSchedule`, `PayoutHistory`, `earningsFromBalance`, `useWorkflowResource` |
21
+ | Seller sales | `Sales` |
22
+ | Seller subscriptions | `Subscriptions`, `SubscriptionCard` |
23
+ | Seller and admin products | `useProductManager`, `Products`, `PriceCard`, product/price creation, editing and archiving |
24
+ | Seller account details | `useAccountManager`, `Account`, `AccountLoginCard`, `ConnectRequirements` |
25
+ | Seller onboarding / account setup | `useOnboarding`, `Onboarding`, `AccountCloseCard`, `DEFAULT_CONNECT_COUNTRIES` |
26
+ | Seller marketplace account | Account/onboarding hooks, `AccountConfigurations`, `ConnectStatusBadge`, `CheckoutStatus`, shared action lifecycle |
27
+ | Seller billing | `usePlanBilling`, `BillingPlans`, `EmbeddedCheckout`, `useInvoiceEstimate`, `InvoiceEstimate`, `useBalanceFunding`, `BalancePaymentSource` |
28
+ | Seller refunds | `useRefunds`, `Refunds`, `RefundHistory`, `PaymentDetails`, `CostRecovery` |
29
+ | Seller disputes | `useDisputeResponse`, `Disputes`, `DisputesList`, `DisputeDetail`, `EvidenceForm`, `ChargebackLedger`, `CostRecovery` |
30
+ | Affiliate earnings | `Earnings`, `EarningsSummary` |
31
+ | Affiliate referred sales | `ReferredSales`, store attribution and commission |
32
+ | Affiliate links | `useReferralLinks`, `ReferralLinks`, `ClipboardButton` |
33
+ | Admin overview | `Overview` |
34
+ | Admin subscriptions | `Subscriptions`, `useSubscriptionFilter` |
35
+ | Admin webhooks | `WebhookEvents`, `useWebhookFilters` |
36
+ | Admin setup | `useWebhookSetup`, `WebhookSetup`, `EnvironmentStatus`, `FixtureProgress`, `useTaskRunner`, `StripeSetup`, `ClipboardButton`, shared actions/resources |
37
+ | Admin sandbox testing | `useTaskRunner`, `SandboxTesting`, `WorkflowTasks` |
38
+ | Legacy affiliate split demo | `Checkout`, `SplitBreakdown`, `EarningsSummary`, bound package hook factories |
39
+ | Legacy destination-charge module | `Checkout`, `ChargeSummary`; the legacy public route currently resolves to the split demo |
40
+ | Integration presentation switch | `IntegrationSwitch`; only the active view mounts |
41
+ | Connect alternatives | `Connect` with account management, onboarding, payments/refunds, disputes, balances, payouts and notifications |
42
+ | Styled shared tables | `Collection` and domain collections; `WorkflowTable` only maps their state/columns to shadcn |
43
+
44
+ The example owns app branding, navigation, theme controls, the persona/store
45
+ switcher, route guards, URL state, and styling. It also owns its users and
46
+ server bindings, fee plans, referral-share policy, recovery billing rules,
47
+ sandbox scenario definitions, and authorization. These are application choices,
48
+ not prerequisites imposed by the public React package.
49
+
50
+ Some examples use companion hooks with styled markup instead of mounting the
51
+ native component. That markup changes presentation; the package owns the
52
+ workflow state, validation, duplicate-action handling, and async errors. Reusable
53
+ native components exist for consumers who do not want to write those renderers.
54
+ Connect and hosted Stripe UI remain available only where Stripe supports them.
55
+
56
+ ## Verification
57
+
58
+ - Public-entry tests render native components without example providers, routing,
59
+ CSS classes, or inline styling and without calling server actions during render.
60
+ - Interaction tests exercise native product-price creation, partial refunds,
61
+ balance consent, checkout selection, and other workflow controllers.
62
+ - Account changes and duplicate actions have regression tests.
63
+ - Browser smoke coverage visits all five personas' pages and the integration views.
64
+ - Checkout tests complete referred guest purchases through all five integrations
65
+ in a Stripe sandbox and verify webhook receipts and settlement.
66
+ - `pnpm run check:all` enforces all repository gates, including Shadscan at 100.
@@ -0,0 +1,231 @@
1
+ # React workflows
2
+
3
+ Import the example's reusable UI and workflow hooks from
4
+ `@fantastic.dev/better-stripe/react`. You do not need the example's route tree,
5
+ role provider, Tailwind, or shadcn components.
6
+
7
+ Components render semantic HTML without package CSS. Use their render props or
8
+ companion hooks to supply your own design system. Stripe iframe contents use
9
+ Stripe's `appearance` options and retain Stripe's own styling.
10
+
11
+ ## Bind your backend
12
+
13
+ Pass authenticated server callbacks and query results to the components. This
14
+ keeps your user IDs, authorization, database schema, and business rules in your
15
+ application. The example's pages demonstrate Convex adapters for these callbacks.
16
+ A callback is an API contract, not an authorization boundary. The server must
17
+ check account ownership, price IDs, amounts, referral attribution, and permissions.
18
+
19
+ `scopeKey` identifies the authenticated account or customer. Change it when that
20
+ identity changes so pending responses cannot populate another account's UI.
21
+ For checkout, change `orderKey` when the customer, price, or attribution changes.
22
+ Do not put secret keys in these props. Browser code needs only a publishable key
23
+ and short-lived client secrets returned by your server.
24
+
25
+ ## Choose a checkout
26
+
27
+ `Checkout` supports all five checkout integrations. It creates the session or
28
+ PaymentIntent, handles loading and retry, mounts the required Stripe provider,
29
+ and reports confirmation errors. Hosted Checkout waits for an explicit click.
30
+ `CheckoutChooser` renders the five choices and their pros and cons. It supports
31
+ controlled selection, render props, and a recurring-product compatibility notice.
32
+ `CHECKOUT_OPTIONS` also exports the descriptions.
33
+
34
+ ```tsx
35
+ import { Checkout } from "@fantastic.dev/better-stripe/react";
36
+
37
+ // createSession is your authenticated server binding. It must validate priceId.
38
+ function Purchase({ publishableKey, priceId, createSession }) {
39
+ return (
40
+ <Checkout
41
+ mode="custom"
42
+ publishableKey={publishableKey}
43
+ orderKey={priceId}
44
+ returnUrl={`${window.location.origin}/receipt?session_id={CHECKOUT_SESSION_ID}`}
45
+ createSession={({ mode, requestId }) =>
46
+ createSession({ priceId, uiMode: mode, requestId })
47
+ }
48
+ />
49
+ );
50
+ }
51
+ ```
52
+
53
+ The callback returns `{ stripeSessionId, clientSecret?, url? }`. It must return
54
+ `url` for `redirect` and `clientSecret` for the other session modes. Use the
55
+ request ID for server idempotency. A user-triggered retry creates a new request
56
+ ID; also enforce application-level duplicate-order protection on the server.
57
+
58
+ | Mode | Stripe integration | Tradeoff |
59
+ | ---------------- | ------------------------------------- | ---------------------------------------------------------------------- |
60
+ | `redirect` | Hosted Checkout Session | Least UI work, leaves your app |
61
+ | `embedded` | Embedded Checkout Session | Complete Stripe checkout in your page, less layout control |
62
+ | `custom` | Checkout Session with Payment Element | Custom form layout with Checkout's session model |
63
+ | `payment-intent` | PaymentIntent with Payment Element | Payment control, application owns order and subscription orchestration |
64
+ | `form` | Preview Embedded Checkout Form | Compact Stripe form, requires the supported Stripe preview |
65
+
66
+ For `payment-intent`, provide `createPaymentIntent({ requestId })` instead of
67
+ `createSession`. Return `{ paymentIntentId, clientSecret }`. Payment Intents do
68
+ not create subscriptions. Stripe.js supplies the browser SDK and publishable-key
69
+ handling for these flows; it is not a separate server payment model.
70
+
71
+ Use `renderForm` on the custom and PaymentIntent modes to render your own email
72
+ input, `paymentElement`, error, and submit button. The preview `form` mode renders
73
+ Stripe's form and does not use that renderer. `children` replaces the outer
74
+ checkout frame and receives `content`, `isLoading`, `error`, and `retry`.
75
+ The lower-level `CheckoutElementsForm`, `PaymentIntentForm`, and `CheckoutForm`
76
+ are also exported for an existing client secret.
77
+
78
+ Only a server-confirmed payment or checkout session should grant access to the
79
+ product. Use `PaymentReceipt` or `CheckoutStatus` with webhook-backed query data;
80
+ a browser return URL alone does not prove payment.
81
+
82
+ ## Headless or Stripe embedded
83
+
84
+ `Account`, `Onboarding`, `Disputes`, `Refunds`, `Earnings`, and `Payouts` accept
85
+ `presentation="embedded"` with Connect session props. Their default headless
86
+ presentation accepts domain-specific data and callbacks. `Connect` also exposes
87
+ account, onboarding, payments, refunds, disputes, balances, payouts, and
88
+ notifications widgets directly.
89
+
90
+ ```tsx
91
+ import { IntegrationSwitch, Payouts } from "@fantastic.dev/better-stripe/react";
92
+
93
+ function AccountPayouts({
94
+ accountId,
95
+ publishableKey,
96
+ loadPayouts,
97
+ createSession,
98
+ }) {
99
+ return (
100
+ <IntegrationSwitch
101
+ views={{
102
+ headless: <Payouts scopeKey={accountId} load={loadPayouts} />,
103
+ embedded: (
104
+ <Payouts
105
+ presentation="embedded"
106
+ scopeKey={accountId}
107
+ publishableKey={publishableKey}
108
+ fetchClientSecret={async () => (await createSession()).clientSecret}
109
+ />
110
+ ),
111
+ }}
112
+ />
113
+ );
114
+ }
115
+ ```
116
+
117
+ The server creates an Account Session for the authenticated connected account
118
+ and enables the requested component and features. Session refresh uses the latest callback. Appearance and locale updates apply
119
+ to the active Connect instance without remounting it. Changing the publishable
120
+ key creates a new instance. `IntegrationSwitch` mounts only the active view and has
121
+ no router dependency. It also supports controlled `value`/`onValueChange` and
122
+ `components` and `hosted` views when your workflow has those alternatives.
123
+
124
+ Connect displays only the payment data supported for that connected account.
125
+ The example's platform-owned separate-charges-and-transfers ledger remains in
126
+ its headless sales/refund/dispute views. A Connect embed cannot turn that ledger
127
+ into connected-account-owned charges. Refunds use the Connect Payments widget;
128
+ there is no separate Connect refund catalog widget. Product management,
129
+ customer subscriptions, and platform billing do not have equivalent Connect
130
+ widgets. Use package UI or the hosted Billing Portal for those workflows.
131
+
132
+ ## Component and hook reference
133
+
134
+ | Workflow | Unstyled components | Companion hooks/helpers |
135
+ | --------------------- | -------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------- |
136
+ | Store browsing | `Storefront`, `PriceCard` | Store/product/price models and purchase callbacks |
137
+ | Checkout | `CheckoutChooser`, `Checkout`, `CheckoutElementsForm`, `PaymentIntentForm`, `CheckoutForm`, `EmbeddedCheckout` | `CHECKOUT_OPTIONS` |
138
+ | Receipts | `PaymentReceipt`, `CheckoutStatus` | Server-backed payment/session data |
139
+ | Earnings | `Earnings`, `EarningsSummary` | `earningsFromBalance` |
140
+ | Payouts | `Payouts`, `PayoutSchedule`, `PayoutHistory`, `PayoutOverview` | `getPayoutTotals` |
141
+ | Sales | `Sales`, `ReferredSales` | Server-authoritative economic rows |
142
+ | Refunds | `Refunds`, `RefundHistory` | `useRefunds`, `parseAmountCents` |
143
+ | Disputes | `Disputes`, `DisputesList`, `DisputeDetail`, `EvidenceForm`, `ChargebackLedger` | `useDisputeResponse` |
144
+ | Onboarding | `Onboarding` | `useOnboarding` |
145
+ | Accounts | `Account`, `AccountConfigurations` | `useAccountManager` |
146
+ | Product management | `Products` | `useProductManager` |
147
+ | Subscriptions | `Subscriptions`, `SubscriptionManager`, `SubscriptionOverview`, `SubscriptionCard` | `useSubscriptionManager`, `useSubscriptionFilter`, `currentSubscriptionFrom` |
148
+ | Billing | `BillingPlans`, `BillingPortal`, `InvoiceEstimate`, `Invoices`, `BalancePaymentSource` | `usePlanBilling`, `useInvoiceEstimate`, `useBalanceFunding` |
149
+ | Payment methods | `PaymentMethods`, `PaymentMethodsList`, `AddCardForm` | `usePaymentMethodsManager`, `toPaymentMethodItem` |
150
+ | Seller cost recovery | `CostRecovery` | Server-calculated outstanding/collected/invoiced amounts |
151
+ | Referral sharing | `ReferralLinks`, `ClipboardButton` | `useReferralLinks` |
152
+ | Admin | `Overview`, `WebhookEvents` | `useWebhookFilters`, `webhookQueryArgs` |
153
+ | Sandbox setup/testing | `StripeSetup`, `SandboxTesting`, `WorkflowTasks`, `WebhookSetup`, `EnvironmentStatus`, `FixtureProgress` | `useTaskRunner`, `useWebhookSetup` |
154
+ | Shared state/tables | `IntegrationSwitch`, `Collection` | `useWorkflowAction`, `useWorkflowResource` |
155
+
156
+ The example still owns its navigation, persona switcher, application branding,
157
+ server authorization, sandbox fixture definitions, and marketplace fee policy.
158
+ Its styled forms and tables consume package hooks/render props. The package's
159
+ default components implement those workflows without the example's providers.
160
+ The package does not seed or reset a Stripe account just because a component
161
+ mounts. Setup/testing tasks call the operations you explicitly bind.
162
+
163
+ ## Data contracts and styling
164
+
165
+ `Payouts.load(cursor?)` returns a `PayoutSnapshot` with `balances`, `payouts`,
166
+ `upcoming`, and `nextCursor`. Each balance has `currency`, `available`, and
167
+ `pending`. Payout rows include `id`, `amount`, `currency`, `status`, `arrivalDate`,
168
+ and `created`. The component shows available and pending balances, the next
169
+ known payout and arrival date, upcoming payouts, and paginated previous payouts.
170
+ If Stripe has not provided an upcoming payout, the UI says so rather than
171
+ inventing a date.
172
+
173
+ Payout, invoice-estimate, cost, and webhook timestamps use Unix milliseconds.
174
+ Subscription period/trial fields use ISO date strings, matching the existing
175
+ subscription API. Convert raw Stripe Unix seconds in your adapter. Money values use integer minor units. The current decimal refund
176
+ input and price-formatting helpers use two decimal places, as in the USD
177
+ example. Supply custom rendering/input conversion for zero-decimal and
178
+ three-decimal currencies. Never combine balances across currencies.
179
+
180
+ Sale fees, affiliate shares, recovery costs, invoice estimates, and settlement
181
+ statuses come from server data. The UI does not recalculate the example's fee
182
+ policy or charge outstanding costs by itself. Balance funding requires explicit
183
+ consent and a server integration with Stripe's supported preview. Card fallback,
184
+ renewal recovery, and debt collection remain server business rules.
185
+
186
+ Use exported `*Props`, row models, and render-state types for typed adapters.
187
+ Tables accept optional columns and a `children(state)` renderer. Action hooks
188
+ expose pending, error, and results so your buttons and alerts share the same
189
+ validation and duplicate-submit handling as the native components.
190
+
191
+ ```tsx
192
+ import { Invoices } from "@fantastic.dev/better-stripe/react";
193
+
194
+ function InvoiceList({ invoices }) {
195
+ return (
196
+ <Invoices rows={invoices}>
197
+ {({ rows, isLoading, isEmpty }) =>
198
+ isLoading ? (
199
+ <p>Loading invoices…</p>
200
+ ) : isEmpty ? (
201
+ <p>No invoices yet.</p>
202
+ ) : (
203
+ <ul>
204
+ {rows.map((row) => (
205
+ <li key={row.stripeInvoiceId}>{row.stripeInvoiceId}</li>
206
+ ))}
207
+ </ul>
208
+ )
209
+ }
210
+ </Invoices>
211
+ );
212
+ }
213
+ ```
214
+
215
+ Default markup has `data-better-stripe` attributes for scoped CSS. Use render
216
+ props to replace markup with your design system, including labels and locale
217
+ formatting. A render function replaces the supplied markup; render its `content`
218
+ or `paymentElement` where those are part of the state's contract.
219
+
220
+ ## Example coverage
221
+
222
+ See [the page audit](react-workflows-audit.md) for the mapping from every example
223
+ page to package components and hooks. `ChargeSummary` displays server-calculated
224
+ charge/fee/payout figures. `PaymentDetails` displays recorded charge and refund
225
+ state. `PayoutOverview` shows payout activity totals, which are separate from the
226
+ available and pending Stripe balances shown by `Payouts`.
227
+
228
+ `DEFAULT_CONNECT_COUNTRIES` provides the example's eight country choices and is
229
+ shared by its account pages and native `Onboarding`. Supply `countries` to limit
230
+ or expand the UI for your platform. This default is not a complete list of
231
+ Stripe-supported countries; your server must validate account eligibility.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fantastic.dev/better-stripe",
3
- "version": "0.7.0",
3
+ "version": "0.8.0",
4
4
  "description": "A Convex component for Stripe V2 Accounts API integration.",
5
5
  "keywords": [
6
6
  "stripe",
@@ -57,6 +57,8 @@
57
57
  "files": [
58
58
  "dist",
59
59
  "src",
60
+ "docs/react-workflows.md",
61
+ "docs/react-workflows-audit.md",
60
62
  "CHANGELOG.md",
61
63
  "MIGRATION.md"
62
64
  ],
@@ -83,7 +85,18 @@
83
85
  "prepublishOnly": "npm run clean && npm run build && npm run typecheck",
84
86
  "test": "vitest run",
85
87
  "test:watch": "vitest",
86
- "test:coverage": "vitest run --coverage"
88
+ "test:coverage": "vitest run --coverage",
89
+ "check:design-system": "eslint --config eslint.design-system.config.mjs . --max-warnings 0",
90
+ "check:shadscan": "shadscan \"./example\" --json --fail-under 100 --no-roast --no-interactive",
91
+ "check:all": "repo-gates check-all",
92
+ "check:size": "repo-gates check-size",
93
+ "check:debt": "repo-gates check-debt",
94
+ "check:circular": "repo-gates check-circular",
95
+ "check:secrets": "repo-gates check-secrets",
96
+ "check:ci-parity": "repo-gates check-ci-parity",
97
+ "check:coverage": "repo-gates check-coverage",
98
+ "format:check": "pnpm run format",
99
+ "check:agents": "repo-gates check-agents"
87
100
  },
88
101
  "dependencies": {
89
102
  "@stripe/connect-js": "^3.4.6",
@@ -95,6 +108,7 @@
95
108
  "devDependencies": {
96
109
  "@convex-dev/eslint-plugin": "^5.0.0",
97
110
  "@edge-runtime/vm": "^5.0.0",
111
+ "@fantastic.dev/repo-gates": "^0.4.0",
98
112
  "@testing-library/jest-dom": "^7.0.1",
99
113
  "@testing-library/react": "^16.3.3",
100
114
  "@testing-library/user-event": "^14.6.7",
@@ -113,7 +127,9 @@
113
127
  "pretty-quick": "^4.2.2",
114
128
  "typescript": "npm:@typescript/typescript6@^6.0.2",
115
129
  "typescript-eslint": "^8.71.1",
116
- "vitest": "^5.0.3"
130
+ "vitest": "^5.0.3",
131
+ "@shadcn/lint": "0.1.5",
132
+ "@shadscan/cli": "0.7.0"
117
133
  },
118
134
  "peerDependencies": {
119
135
  "convex": "^1.29.3",
@@ -0,0 +1,49 @@
1
+ import { expect, it, vi } from "vitest";
2
+ import type Stripe from "stripe";
3
+ import type { Component, RunCtx } from "../helpers.js";
4
+ import { createCheckoutSession } from "./checkout.js";
5
+ for (const [mode, expected] of [
6
+ ["custom", "elements"],
7
+ ["form", "form"],
8
+ ] as const)
9
+ it(`creates ${mode} checkout without hosted URLs`, async () => {
10
+ const create = vi.fn().mockResolvedValue({
11
+ id: "cs_test",
12
+ status: "open",
13
+ mode: "payment",
14
+ client_secret: "client_secret_test",
15
+ metadata: {},
16
+ expires_at: 1800000000,
17
+ });
18
+ const component = {
19
+ billing: {
20
+ mutations: {
21
+ upsertCheckoutSession: {
22
+ [Symbol.for("toReferencePath")]:
23
+ "betterStripe/billing/mutations/upsertCheckoutSession",
24
+ },
25
+ },
26
+ },
27
+ } as unknown as Component;
28
+ await createCheckoutSession(
29
+ { checkout: { sessions: { create } } } as unknown as Stripe,
30
+ component,
31
+ {
32
+ runQuery: vi.fn().mockResolvedValue(null),
33
+ runMutation: vi.fn(),
34
+ } as unknown as RunCtx,
35
+ {
36
+ userId: "user_1",
37
+ stripePriceId: "price_1",
38
+ mode: "payment",
39
+ uiMode: mode,
40
+ returnUrl: "https://app.test/return",
41
+ },
42
+ );
43
+ expect(create.mock.calls[0][0]).toMatchObject({
44
+ ui_mode: expected,
45
+ return_url: "https://app.test/return",
46
+ });
47
+ expect(create.mock.calls[0][0].success_url).toBeUndefined();
48
+ expect(create.mock.calls[0][0].cancel_url).toBeUndefined();
49
+ });