@fantastic.dev/better-stripe 0.7.0 → 0.8.1

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 (359) hide show
  1. package/CHANGELOG.md +29 -18
  2. package/README.md +123 -91
  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/disputes.d.ts +1 -1
  8. package/dist/client/connect/disputes.d.ts.map +1 -1
  9. package/dist/client/connect/disputes.js +12 -6
  10. package/dist/client/connect/disputes.js.map +1 -1
  11. package/dist/client/connect/paymentMethods.d.ts.map +1 -1
  12. package/dist/client/connect/paymentMethods.js.map +1 -1
  13. package/dist/client/connect/refundActor.d.ts.map +1 -1
  14. package/dist/client/connect/refundActor.js.map +1 -1
  15. package/dist/client/connect/refunds.d.ts.map +1 -1
  16. package/dist/client/connect/refunds.js.map +1 -1
  17. package/dist/client/connect/transfers.d.ts.map +1 -1
  18. package/dist/client/connect/transfers.js +15 -4
  19. package/dist/client/connect/transfers.js.map +1 -1
  20. package/dist/client/core/accountDefaults.d.ts +6 -0
  21. package/dist/client/core/accountDefaults.d.ts.map +1 -0
  22. package/dist/client/core/accountDefaults.js +15 -0
  23. package/dist/client/core/accountDefaults.js.map +1 -0
  24. package/dist/client/core/accounts.d.ts +1 -5
  25. package/dist/client/core/accounts.d.ts.map +1 -1
  26. package/dist/client/core/accounts.js +2 -14
  27. package/dist/client/core/accounts.js.map +1 -1
  28. package/dist/client/core/fees.d.ts.map +1 -1
  29. package/dist/client/core/fees.js +7 -2
  30. package/dist/client/core/fees.js.map +1 -1
  31. package/dist/client/index.d.ts +1 -1
  32. package/dist/client/index.d.ts.map +1 -1
  33. package/dist/client/products/prices.d.ts.map +1 -1
  34. package/dist/client/products/prices.js.map +1 -1
  35. package/dist/client/products/products.d.ts.map +1 -1
  36. package/dist/client/products/products.js +3 -1
  37. package/dist/client/products/products.js.map +1 -1
  38. package/dist/client/utils/owner.d.ts.map +1 -1
  39. package/dist/client/utils/owner.js +3 -1
  40. package/dist/client/utils/owner.js.map +1 -1
  41. package/dist/client/utils/stripeDashboardUrl.d.ts.map +1 -1
  42. package/dist/client/utils/stripeDashboardUrl.js.map +1 -1
  43. package/dist/client/webhooks/helpers.d.ts +10 -0
  44. package/dist/client/webhooks/helpers.d.ts.map +1 -1
  45. package/dist/client/webhooks/helpers.js +18 -0
  46. package/dist/client/webhooks/helpers.js.map +1 -1
  47. package/dist/client/webhooks/processors.d.ts.map +1 -1
  48. package/dist/client/webhooks/processors.js +1 -19
  49. package/dist/client/webhooks/processors.js.map +1 -1
  50. package/dist/component/connect/mutations.d.ts.map +1 -1
  51. package/dist/component/connect/mutations.js +4 -33
  52. package/dist/component/connect/mutations.js.map +1 -1
  53. package/dist/component/connect/schema.d.ts.map +1 -1
  54. package/dist/component/connect/schema.js.map +1 -1
  55. package/dist/component/lib/paymentSeller.d.ts +3 -0
  56. package/dist/component/lib/paymentSeller.d.ts.map +1 -0
  57. package/dist/component/lib/paymentSeller.js +10 -0
  58. package/dist/component/lib/paymentSeller.js.map +1 -0
  59. package/dist/component/lib/reversals.d.ts +10 -0
  60. package/dist/component/lib/reversals.d.ts.map +1 -1
  61. package/dist/component/lib/reversals.js +17 -0
  62. package/dist/component/lib/reversals.js.map +1 -1
  63. package/dist/react/components/ConnectProvider.d.ts +1 -1
  64. package/dist/react/components/ConnectProvider.d.ts.map +1 -1
  65. package/dist/react/components/ConnectProvider.js +18 -4
  66. package/dist/react/components/ConnectProvider.js.map +1 -1
  67. package/dist/react/components/ConnectStatusBadge.d.ts.map +1 -1
  68. package/dist/react/components/ConnectStatusBadge.js.map +1 -1
  69. package/dist/react/components/DisputeDetail.d.ts +4 -1
  70. package/dist/react/components/DisputeDetail.d.ts.map +1 -1
  71. package/dist/react/components/DisputeDetail.js +12 -6
  72. package/dist/react/components/DisputeDetail.js.map +1 -1
  73. package/dist/react/components/DisputesList.d.ts.map +1 -1
  74. package/dist/react/components/DisputesList.js +2 -1
  75. package/dist/react/components/DisputesList.js.map +1 -1
  76. package/dist/react/components/EmbeddedDisputes.d.ts +1 -1
  77. package/dist/react/components/EmbeddedDisputes.d.ts.map +1 -1
  78. package/dist/react/components/EmbeddedDisputes.js +1 -1
  79. package/dist/react/components/EmbeddedDisputes.js.map +1 -1
  80. package/dist/react/components/SplitBreakdown.d.ts.map +1 -1
  81. package/dist/react/components/SplitBreakdown.js +12 -2
  82. package/dist/react/components/SplitBreakdown.js.map +1 -1
  83. package/dist/react/hooks/useCheckoutSession.d.ts.map +1 -1
  84. package/dist/react/hooks/useCheckoutSession.js.map +1 -1
  85. package/dist/react/hooks/useConfirmPayment.d.ts.map +1 -1
  86. package/dist/react/hooks/useConfirmPayment.js.map +1 -1
  87. package/dist/react/index.d.ts +2 -1
  88. package/dist/react/index.d.ts.map +1 -1
  89. package/dist/react/index.js +3 -1
  90. package/dist/react/index.js.map +1 -1
  91. package/dist/react/workflows/Account.d.ts +67 -0
  92. package/dist/react/workflows/Account.d.ts.map +1 -0
  93. package/dist/react/workflows/Account.js +74 -0
  94. package/dist/react/workflows/Account.js.map +1 -0
  95. package/dist/react/workflows/Billing.d.ts +60 -0
  96. package/dist/react/workflows/Billing.d.ts.map +1 -0
  97. package/dist/react/workflows/Billing.js +84 -0
  98. package/dist/react/workflows/Billing.js.map +1 -0
  99. package/dist/react/workflows/BillingPlans.d.ts +45 -0
  100. package/dist/react/workflows/BillingPlans.d.ts.map +1 -0
  101. package/dist/react/workflows/BillingPlans.js +51 -0
  102. package/dist/react/workflows/BillingPlans.js.map +1 -0
  103. package/dist/react/workflows/Checkout.d.ts +46 -0
  104. package/dist/react/workflows/Checkout.d.ts.map +1 -0
  105. package/dist/react/workflows/Checkout.js +61 -0
  106. package/dist/react/workflows/Checkout.js.map +1 -0
  107. package/dist/react/workflows/CheckoutChooser.d.ts +20 -0
  108. package/dist/react/workflows/CheckoutChooser.d.ts.map +1 -0
  109. package/dist/react/workflows/CheckoutChooser.js +24 -0
  110. package/dist/react/workflows/CheckoutChooser.js.map +1 -0
  111. package/dist/react/workflows/CheckoutForms.d.ts +26 -0
  112. package/dist/react/workflows/CheckoutForms.d.ts.map +1 -0
  113. package/dist/react/workflows/CheckoutForms.js +126 -0
  114. package/dist/react/workflows/CheckoutForms.js.map +1 -0
  115. package/dist/react/workflows/ClipboardButton.d.ts +17 -0
  116. package/dist/react/workflows/ClipboardButton.d.ts.map +1 -0
  117. package/dist/react/workflows/ClipboardButton.js +35 -0
  118. package/dist/react/workflows/ClipboardButton.js.map +1 -0
  119. package/dist/react/workflows/Collection.d.ts +30 -0
  120. package/dist/react/workflows/Collection.d.ts.map +1 -0
  121. package/dist/react/workflows/Collection.js +25 -0
  122. package/dist/react/workflows/Collection.js.map +1 -0
  123. package/dist/react/workflows/Collections.d.ts +56 -0
  124. package/dist/react/workflows/Collections.d.ts.map +1 -0
  125. package/dist/react/workflows/Collections.js +111 -0
  126. package/dist/react/workflows/Collections.js.map +1 -0
  127. package/dist/react/workflows/Connect.d.ts +19 -0
  128. package/dist/react/workflows/Connect.d.ts.map +1 -0
  129. package/dist/react/workflows/Connect.js +43 -0
  130. package/dist/react/workflows/Connect.js.map +1 -0
  131. package/dist/react/workflows/Costs.d.ts +48 -0
  132. package/dist/react/workflows/Costs.d.ts.map +1 -0
  133. package/dist/react/workflows/Costs.js +66 -0
  134. package/dist/react/workflows/Costs.js.map +1 -0
  135. package/dist/react/workflows/Disputes.d.ts +36 -0
  136. package/dist/react/workflows/Disputes.d.ts.map +1 -0
  137. package/dist/react/workflows/Disputes.js +74 -0
  138. package/dist/react/workflows/Disputes.js.map +1 -0
  139. package/dist/react/workflows/Earnings.d.ts +42 -0
  140. package/dist/react/workflows/Earnings.d.ts.map +1 -0
  141. package/dist/react/workflows/Earnings.js +38 -0
  142. package/dist/react/workflows/Earnings.js.map +1 -0
  143. package/dist/react/workflows/Financials.d.ts +43 -0
  144. package/dist/react/workflows/Financials.d.ts.map +1 -0
  145. package/dist/react/workflows/Financials.js +57 -0
  146. package/dist/react/workflows/Financials.js.map +1 -0
  147. package/dist/react/workflows/IntegrationSwitch.d.ts +23 -0
  148. package/dist/react/workflows/IntegrationSwitch.d.ts.map +1 -0
  149. package/dist/react/workflows/IntegrationSwitch.js +31 -0
  150. package/dist/react/workflows/IntegrationSwitch.js.map +1 -0
  151. package/dist/react/workflows/Onboarding.d.ts +56 -0
  152. package/dist/react/workflows/Onboarding.d.ts.map +1 -0
  153. package/dist/react/workflows/Onboarding.js +86 -0
  154. package/dist/react/workflows/Onboarding.js.map +1 -0
  155. package/dist/react/workflows/Overview.d.ts +51 -0
  156. package/dist/react/workflows/Overview.d.ts.map +1 -0
  157. package/dist/react/workflows/Overview.js +63 -0
  158. package/dist/react/workflows/Overview.js.map +1 -0
  159. package/dist/react/workflows/PaymentMethods.d.ts +35 -0
  160. package/dist/react/workflows/PaymentMethods.d.ts.map +1 -0
  161. package/dist/react/workflows/PaymentMethods.js +63 -0
  162. package/dist/react/workflows/PaymentMethods.js.map +1 -0
  163. package/dist/react/workflows/PaymentReceipt.d.ts +20 -0
  164. package/dist/react/workflows/PaymentReceipt.d.ts.map +1 -0
  165. package/dist/react/workflows/PaymentReceipt.js +24 -0
  166. package/dist/react/workflows/PaymentReceipt.js.map +1 -0
  167. package/dist/react/workflows/Payouts.d.ts +48 -0
  168. package/dist/react/workflows/Payouts.d.ts.map +1 -0
  169. package/dist/react/workflows/Payouts.js +88 -0
  170. package/dist/react/workflows/Payouts.js.map +1 -0
  171. package/dist/react/workflows/Products.d.ts +92 -0
  172. package/dist/react/workflows/Products.d.ts.map +1 -0
  173. package/dist/react/workflows/Products.js +179 -0
  174. package/dist/react/workflows/Products.js.map +1 -0
  175. package/dist/react/workflows/ReferralLinks.d.ts +26 -0
  176. package/dist/react/workflows/ReferralLinks.d.ts.map +1 -0
  177. package/dist/react/workflows/ReferralLinks.js +30 -0
  178. package/dist/react/workflows/ReferralLinks.js.map +1 -0
  179. package/dist/react/workflows/Refunds.d.ts +72 -0
  180. package/dist/react/workflows/Refunds.d.ts.map +1 -0
  181. package/dist/react/workflows/Refunds.js +95 -0
  182. package/dist/react/workflows/Refunds.js.map +1 -0
  183. package/dist/react/workflows/Setup.d.ts +50 -0
  184. package/dist/react/workflows/Setup.d.ts.map +1 -0
  185. package/dist/react/workflows/Setup.js +59 -0
  186. package/dist/react/workflows/Setup.js.map +1 -0
  187. package/dist/react/workflows/Storefront.d.ts +53 -0
  188. package/dist/react/workflows/Storefront.d.ts.map +1 -0
  189. package/dist/react/workflows/Storefront.js +44 -0
  190. package/dist/react/workflows/Storefront.js.map +1 -0
  191. package/dist/react/workflows/SubscriptionOverview.d.ts +13 -0
  192. package/dist/react/workflows/SubscriptionOverview.d.ts.map +1 -0
  193. package/dist/react/workflows/SubscriptionOverview.js +26 -0
  194. package/dist/react/workflows/SubscriptionOverview.js.map +1 -0
  195. package/dist/react/workflows/Subscriptions.d.ts +92 -0
  196. package/dist/react/workflows/Subscriptions.d.ts.map +1 -0
  197. package/dist/react/workflows/Subscriptions.js +149 -0
  198. package/dist/react/workflows/Subscriptions.js.map +1 -0
  199. package/dist/react/workflows/Tasks.d.ts +40 -0
  200. package/dist/react/workflows/Tasks.d.ts.map +1 -0
  201. package/dist/react/workflows/Tasks.js +113 -0
  202. package/dist/react/workflows/Tasks.js.map +1 -0
  203. package/dist/react/workflows/checkout-options.d.ts +37 -0
  204. package/dist/react/workflows/checkout-options.d.ts.map +1 -0
  205. package/dist/react/workflows/checkout-options.js +43 -0
  206. package/dist/react/workflows/checkout-options.js.map +1 -0
  207. package/dist/react/workflows/current-subscription.d.ts +11 -0
  208. package/dist/react/workflows/current-subscription.d.ts.map +1 -0
  209. package/dist/react/workflows/current-subscription.js +14 -0
  210. package/dist/react/workflows/current-subscription.js.map +1 -0
  211. package/dist/react/workflows/filters.d.ts +17 -0
  212. package/dist/react/workflows/filters.d.ts.map +1 -0
  213. package/dist/react/workflows/filters.js +23 -0
  214. package/dist/react/workflows/filters.js.map +1 -0
  215. package/dist/react/workflows/index.d.ts +70 -0
  216. package/dist/react/workflows/index.d.ts.map +1 -0
  217. package/dist/react/workflows/index.js +38 -0
  218. package/dist/react/workflows/index.js.map +1 -0
  219. package/dist/react/workflows/useWorkflowAction.d.ts +11 -0
  220. package/dist/react/workflows/useWorkflowAction.d.ts.map +1 -0
  221. package/dist/react/workflows/useWorkflowAction.js +68 -0
  222. package/dist/react/workflows/useWorkflowAction.js.map +1 -0
  223. package/dist/react/workflows/useWorkflowResource.d.ts +9 -0
  224. package/dist/react/workflows/useWorkflowResource.d.ts.map +1 -0
  225. package/dist/react/workflows/useWorkflowResource.js +67 -0
  226. package/dist/react/workflows/useWorkflowResource.js.map +1 -0
  227. package/docs/react-workflows-audit.md +88 -0
  228. package/docs/react-workflows.md +234 -0
  229. package/package.json +19 -3
  230. package/src/client/billing/checkout-ui-modes.test.ts +49 -0
  231. package/src/client/billing/checkout.ts +8 -3
  232. package/src/client/billing/invoices.test.ts +12 -6
  233. package/src/client/connect/disputes.test.ts +15 -0
  234. package/src/client/connect/disputes.ts +13 -7
  235. package/src/client/connect/paymentMethods.test.ts +3 -1
  236. package/src/client/connect/paymentMethods.ts +4 -1
  237. package/src/client/connect/refundActor.ts +1 -2
  238. package/src/client/connect/refunds.test.ts +35 -10
  239. package/src/client/connect/refunds.ts +4 -1
  240. package/src/client/connect/transfers.test.ts +66 -12
  241. package/src/client/connect/transfers.ts +32 -8
  242. package/src/client/core/accountDefaults.ts +15 -0
  243. package/src/client/core/accounts.ts +14 -17
  244. package/src/client/core/config.test.ts +2 -1
  245. package/src/client/core/descriptors.test.ts +6 -4
  246. package/src/client/core/fees.test.ts +20 -28
  247. package/src/client/core/fees.ts +9 -2
  248. package/src/client/index.test.ts +22 -22
  249. package/src/client/index.ts +1 -1
  250. package/src/client/products/prices.test.ts +8 -2
  251. package/src/client/products/prices.ts +4 -1
  252. package/src/client/products/products.test.ts +61 -20
  253. package/src/client/products/products.ts +3 -1
  254. package/src/client/utils/data.test.ts +3 -1
  255. package/src/client/utils/owner.test.ts +4 -1
  256. package/src/client/utils/owner.ts +5 -1
  257. package/src/client/utils/stripeDashboardUrl.ts +1 -4
  258. package/src/client/webhooks/handler.test.ts +16 -19
  259. package/src/client/webhooks/helpers.test.ts +26 -13
  260. package/src/client/webhooks/helpers.ts +23 -0
  261. package/src/client/webhooks/hooks.test.ts +1 -2
  262. package/src/client/webhooks/processors.test.ts +18 -34
  263. package/src/client/webhooks/processors.ts +1 -23
  264. package/src/client/webhooks.test.ts +1 -2
  265. package/src/component/_generated/api.ts +2 -0
  266. package/src/component/connect/mutations.ts +5 -46
  267. package/src/component/connect/schema.ts +4 -3
  268. package/src/component/connect.test.ts +1 -5
  269. package/src/component/lib/paymentSeller.ts +15 -0
  270. package/src/component/lib/reversals.ts +30 -2
  271. package/src/component/subscription-scoping.test.ts +5 -1
  272. package/src/component/triggers.test.ts +7 -4
  273. package/src/react/components/BuyerBillingView.render.test.tsx +7 -2
  274. package/src/react/components/ConnectProvider.live.test.tsx +61 -0
  275. package/src/react/components/ConnectProvider.tsx +18 -4
  276. package/src/react/components/ConnectStatusBadge.tsx +1 -4
  277. package/src/react/components/DisputeDetail.render.test.tsx +5 -1
  278. package/src/react/components/DisputeDetail.tsx +14 -5
  279. package/src/react/components/DisputesList.render.test.tsx +21 -0
  280. package/src/react/components/DisputesList.tsx +2 -1
  281. package/src/react/components/EarningsSummary.render.test.tsx +2 -6
  282. package/src/react/components/EmbeddedDisputes.render.test.tsx +7 -5
  283. package/src/react/components/EmbeddedDisputes.tsx +4 -1
  284. package/src/react/components/EvidenceForm.render.test.tsx +3 -10
  285. package/src/react/components/SplitBreakdown.render.test.tsx +28 -5
  286. package/src/react/components/SplitBreakdown.tsx +12 -2
  287. package/src/react/hooks/useCheckoutSession.ts +1 -2
  288. package/src/react/hooks/useConfirmPayment.ts +1 -2
  289. package/src/react/hooks/useEarnings.test.ts +43 -8
  290. package/src/react/hooks/useStripeMode.test.ts +5 -8
  291. package/src/react/index.ts +7 -1
  292. package/src/react/workflows/Account.test.tsx +31 -0
  293. package/src/react/workflows/Account.tsx +183 -0
  294. package/src/react/workflows/Billing.test.tsx +45 -0
  295. package/src/react/workflows/Billing.tsx +213 -0
  296. package/src/react/workflows/BillingPlans.test.tsx +31 -0
  297. package/src/react/workflows/BillingPlans.tsx +130 -0
  298. package/src/react/workflows/Checkout.test.tsx +118 -0
  299. package/src/react/workflows/Checkout.tsx +135 -0
  300. package/src/react/workflows/CheckoutChooser.test.tsx +44 -0
  301. package/src/react/workflows/CheckoutChooser.tsx +77 -0
  302. package/src/react/workflows/CheckoutForm.test.tsx +66 -0
  303. package/src/react/workflows/CheckoutForms.test.tsx +123 -0
  304. package/src/react/workflows/CheckoutForms.tsx +247 -0
  305. package/src/react/workflows/ClipboardButton.test.tsx +34 -0
  306. package/src/react/workflows/ClipboardButton.tsx +67 -0
  307. package/src/react/workflows/Collection.tsx +76 -0
  308. package/src/react/workflows/Collections.test.tsx +86 -0
  309. package/src/react/workflows/Collections.tsx +213 -0
  310. package/src/react/workflows/Connect.test.tsx +50 -0
  311. package/src/react/workflows/Connect.tsx +107 -0
  312. package/src/react/workflows/Costs.test.tsx +41 -0
  313. package/src/react/workflows/Costs.tsx +133 -0
  314. package/src/react/workflows/Disputes.test.tsx +64 -0
  315. package/src/react/workflows/Disputes.tsx +173 -0
  316. package/src/react/workflows/Earnings.test.ts +19 -0
  317. package/src/react/workflows/Earnings.tsx +84 -0
  318. package/src/react/workflows/Financials.test.tsx +35 -0
  319. package/src/react/workflows/Financials.tsx +117 -0
  320. package/src/react/workflows/IntegrationSwitch.test.tsx +36 -0
  321. package/src/react/workflows/IntegrationSwitch.tsx +63 -0
  322. package/src/react/workflows/Onboarding.test.tsx +75 -0
  323. package/src/react/workflows/Onboarding.tsx +171 -0
  324. package/src/react/workflows/Overview.test.tsx +57 -0
  325. package/src/react/workflows/Overview.tsx +123 -0
  326. package/src/react/workflows/PaymentMethods.test.tsx +60 -0
  327. package/src/react/workflows/PaymentMethods.tsx +117 -0
  328. package/src/react/workflows/PaymentReceipt.test.tsx +24 -0
  329. package/src/react/workflows/PaymentReceipt.tsx +46 -0
  330. package/src/react/workflows/Payouts.test.tsx +112 -0
  331. package/src/react/workflows/Payouts.tsx +215 -0
  332. package/src/react/workflows/Products.test.tsx +90 -0
  333. package/src/react/workflows/Products.tsx +377 -0
  334. package/src/react/workflows/ReferralLinks.test.tsx +39 -0
  335. package/src/react/workflows/ReferralLinks.tsx +75 -0
  336. package/src/react/workflows/Refunds.test.tsx +75 -0
  337. package/src/react/workflows/Refunds.tsx +223 -0
  338. package/src/react/workflows/Setup.test.tsx +25 -0
  339. package/src/react/workflows/Setup.tsx +166 -0
  340. package/src/react/workflows/Storefront.test.tsx +82 -0
  341. package/src/react/workflows/Storefront.tsx +138 -0
  342. package/src/react/workflows/SubscriptionOverview.test.tsx +27 -0
  343. package/src/react/workflows/SubscriptionOverview.tsx +48 -0
  344. package/src/react/workflows/Subscriptions.test.tsx +61 -0
  345. package/src/react/workflows/Subscriptions.tsx +282 -0
  346. package/src/react/workflows/Tasks.test.tsx +23 -0
  347. package/src/react/workflows/Tasks.tsx +199 -0
  348. package/src/react/workflows/checkout-options.ts +42 -0
  349. package/src/react/workflows/current-subscription.test.ts +29 -0
  350. package/src/react/workflows/current-subscription.ts +25 -0
  351. package/src/react/workflows/filters.test.ts +12 -0
  352. package/src/react/workflows/filters.ts +22 -0
  353. package/src/react/workflows/index.ts +238 -0
  354. package/src/react/workflows/native-interactions.test.tsx +73 -0
  355. package/src/react/workflows/public-workflows.test.tsx +216 -0
  356. package/src/react/workflows/useWorkflowAction.test.tsx +54 -0
  357. package/src/react/workflows/useWorkflowAction.ts +75 -0
  358. package/src/react/workflows/useWorkflowResource.test.tsx +41 -0
  359. package/src/react/workflows/useWorkflowResource.ts +78 -0
@@ -0,0 +1,25 @@
1
+ /**
2
+ * Picks the subscription that best represents a buyer's "current plan" for
3
+ * display (`billing.tsx`). A `cancelAtPeriodEnd` sub is only preferred while
4
+ * it's still active/trialing, so a re-subscribed buyer's new subscription
5
+ * wins over a stale canceled one.
6
+ */
7
+ export function currentSubscriptionFrom<
8
+ T extends {
9
+ status: string;
10
+ cancelAtPeriodEnd: boolean;
11
+ },
12
+ >(subscriptions: T[]) {
13
+ return (
14
+ subscriptions.find(
15
+ (s) =>
16
+ s.cancelAtPeriodEnd &&
17
+ (s.status === "active" || s.status === "trialing"),
18
+ ) ??
19
+ subscriptions.find((s) =>
20
+ ["trialing", "active", "paused", "past_due", "unpaid"].includes(s.status),
21
+ ) ??
22
+ subscriptions[0] ??
23
+ null
24
+ );
25
+ }
@@ -0,0 +1,12 @@
1
+ import { expect, it } from "vitest";
2
+ import { webhookQueryArgs } from "./filters.js";
3
+ it("omits all sentinels from server filters", () => {
4
+ expect(webhookQueryArgs("all", "all")).toEqual({
5
+ eventType: undefined,
6
+ status: undefined,
7
+ });
8
+ expect(webhookQueryArgs("invoice.paid", "failed")).toEqual({
9
+ eventType: "invoice.paid",
10
+ status: "failed",
11
+ });
12
+ });
@@ -0,0 +1,22 @@
1
+ "use client";
2
+ import { useState } from "react";
3
+ export function webhookQueryArgs(eventType: string, status: string) {
4
+ return {
5
+ eventType: eventType === "all" ? undefined : eventType,
6
+ status: status === "all" ? undefined : status,
7
+ };
8
+ }
9
+ export function useWebhookFilters() {
10
+ const [typeFilter, setTypeFilter] = useState("all");
11
+ const [statusFilter, setStatusFilter] = useState("all");
12
+ const [expandedEvent, setExpandedEvent] = useState<string | null>(null);
13
+ return {
14
+ typeFilter,
15
+ setTypeFilter,
16
+ statusFilter,
17
+ setStatusFilter,
18
+ expandedEvent,
19
+ setExpandedEvent,
20
+ queryArgs: webhookQueryArgs(typeFilter, statusFilter),
21
+ };
22
+ }
@@ -0,0 +1,238 @@
1
+ export { useWorkflowAction } from "./useWorkflowAction.js";
2
+ export type { WorkflowActionState } from "./useWorkflowAction.js";
3
+ export { useWorkflowResource } from "./useWorkflowResource.js";
4
+ export { Checkout } from "./Checkout.js";
5
+ export type {
6
+ CheckoutProps,
7
+ CheckoutMode,
8
+ CheckoutRequest,
9
+ CheckoutSessionResult,
10
+ CheckoutIntentResult,
11
+ CheckoutRenderProps,
12
+ } from "./Checkout.js";
13
+ export {
14
+ CheckoutElementsForm,
15
+ PaymentIntentForm,
16
+ CheckoutForm,
17
+ } from "./CheckoutForms.js";
18
+ export type {
19
+ CheckoutFormState,
20
+ CheckoutFormOptions,
21
+ CheckoutFormProps,
22
+ } from "./CheckoutForms.js";
23
+ export { Connect } from "./Connect.js";
24
+ export type {
25
+ ConnectProps,
26
+ ConnectComponent,
27
+ ConnectRenderProps,
28
+ } from "./Connect.js";
29
+ export { Payouts } from "./Payouts.js";
30
+ export type {
31
+ PayoutsProps,
32
+ HeadlessPayoutsProps,
33
+ PayoutsRenderProps,
34
+ PayoutSnapshot,
35
+ PayoutRow,
36
+ } from "./Payouts.js";
37
+ export { Refunds, useRefunds, parseAmountCents } from "./Refunds.js";
38
+ export type {
39
+ RefundsProps,
40
+ RefundsRenderProps,
41
+ RefundActionsProps,
42
+ RefundRequest,
43
+ ReversalRequest,
44
+ RefundResult,
45
+ ReversalResult,
46
+ } from "./Refunds.js";
47
+ export { Collection } from "./Collection.js";
48
+ export type {
49
+ CollectionProps,
50
+ CollectionRenderProps,
51
+ WorkflowColumn,
52
+ } from "./Collection.js";
53
+ export {
54
+ Sales,
55
+ Invoices,
56
+ RefundHistory,
57
+ ReferredSales,
58
+ WebhookEvents,
59
+ } from "./Collections.js";
60
+ export type {
61
+ ResourceCollectionProps,
62
+ SaleRow,
63
+ InvoiceRow,
64
+ RefundRow,
65
+ ReferredSaleRow,
66
+ WebhookEventRow,
67
+ } from "./Collections.js";
68
+ export { Products, useProductManager } from "./Products.js";
69
+ export type {
70
+ ProductsProps,
71
+ ProductsRenderProps,
72
+ ProductActions,
73
+ CatalogProduct,
74
+ ProductInput,
75
+ PriceInput,
76
+ ProductEdit,
77
+ } from "./Products.js";
78
+ export { Onboarding, useOnboarding } from "./Onboarding.js";
79
+ export type {
80
+ OnboardingProps,
81
+ OnboardingActions,
82
+ OnboardingAccount,
83
+ OnboardingRenderProps,
84
+ } from "./Onboarding.js";
85
+ export { Disputes, useDisputeResponse } from "./Disputes.js";
86
+ export type {
87
+ DisputesProps,
88
+ HeadlessDisputesProps,
89
+ DisputesRenderProps,
90
+ DisputeResponseOptions,
91
+ } from "./Disputes.js";
92
+ export {
93
+ InvoiceEstimate,
94
+ useInvoiceEstimate,
95
+ BalancePaymentSource,
96
+ useBalanceFunding,
97
+ BillingPortal,
98
+ } from "./Billing.js";
99
+ export type {
100
+ InvoiceEstimateProps,
101
+ EstimatedInvoice,
102
+ BalanceFundingActions,
103
+ BalancePaymentSourceProps,
104
+ BillingPortalProps,
105
+ } from "./Billing.js";
106
+ export {
107
+ SubscriptionManager,
108
+ useSubscriptionManager,
109
+ Subscriptions,
110
+ useSubscriptionFilter,
111
+ SUBSCRIPTION_FILTERS,
112
+ } from "./Subscriptions.js";
113
+ export type {
114
+ SubscriptionManagerProps,
115
+ SubscriptionManagerOptions,
116
+ SubscriptionActionType,
117
+ SubscriptionCommand,
118
+ SubscriptionRow,
119
+ SubscriptionsProps,
120
+ } from "./Subscriptions.js";
121
+ export {
122
+ PaymentMethods,
123
+ usePaymentMethodsManager,
124
+ toPaymentMethodItem,
125
+ } from "./PaymentMethods.js";
126
+ export type {
127
+ PaymentMethodsProps,
128
+ PaymentMethodsActions,
129
+ } from "./PaymentMethods.js";
130
+ export { ReferralLinks, useReferralLinks } from "./ReferralLinks.js";
131
+ export type { ReferralLink, ReferralLinksProps } from "./ReferralLinks.js";
132
+ export { IntegrationSwitch } from "./IntegrationSwitch.js";
133
+ export type {
134
+ IntegrationSwitchProps,
135
+ IntegrationSwitchState,
136
+ IntegrationMode,
137
+ } from "./IntegrationSwitch.js";
138
+ export { CHECKOUT_OPTIONS } from "./checkout-options.js";
139
+ export { Account, useAccountManager } from "./Account.js";
140
+ export type {
141
+ AccountProps,
142
+ HeadlessAccountProps,
143
+ AccountSummary,
144
+ AccountConfiguration,
145
+ AccountManagerOptions,
146
+ } from "./Account.js";
147
+ export {
148
+ WorkflowTasks,
149
+ StripeSetup,
150
+ SandboxTesting,
151
+ useTaskRunner,
152
+ } from "./Tasks.js";
153
+ export type {
154
+ WorkflowTasksProps,
155
+ WorkflowTask,
156
+ WorkflowLogEntry,
157
+ TaskRunnerOptions,
158
+ } from "./Tasks.js";
159
+ export {
160
+ WebhookSetup,
161
+ useWebhookSetup,
162
+ EnvironmentStatus,
163
+ FixtureProgress,
164
+ } from "./Setup.js";
165
+ export type {
166
+ WebhookSetupOptions,
167
+ EnvironmentCheck,
168
+ FixtureProgressState,
169
+ } from "./Setup.js";
170
+ export { BillingPlans, usePlanBilling } from "./BillingPlans.js";
171
+ export type {
172
+ BillingPlansProps,
173
+ BillingPlan,
174
+ PlanBillingOptions,
175
+ } from "./BillingPlans.js";
176
+ export { CostRecovery, ChargebackLedger } from "./Costs.js";
177
+ export type {
178
+ CostRecoveryRow,
179
+ ChargebackSummary,
180
+ ChargebackTransfer,
181
+ ChargebackLedgerRenderProps,
182
+ } from "./Costs.js";
183
+ export { Storefront } from "./Storefront.js";
184
+ export type {
185
+ StorefrontProps,
186
+ StorefrontRenderProps,
187
+ StorefrontCard,
188
+ StorefrontSelection,
189
+ StorefrontPrice,
190
+ StorefrontProduct,
191
+ StorefrontStore,
192
+ } from "./Storefront.js";
193
+ export { PaymentReceipt } from "./PaymentReceipt.js";
194
+ export type {
195
+ PaymentReceiptProps,
196
+ PaymentReceiptState,
197
+ ReceiptPayment,
198
+ } from "./PaymentReceipt.js";
199
+ export { Earnings, earningsFromBalance } from "./Earnings.js";
200
+ export type {
201
+ EarningsProps,
202
+ HeadlessEarningsProps,
203
+ EarningsRenderProps,
204
+ EarningsMetric,
205
+ BalanceSnapshot,
206
+ StoreEarnings,
207
+ } from "./Earnings.js";
208
+ export { ClipboardButton } from "./ClipboardButton.js";
209
+ export type { ClipboardButtonProps } from "./ClipboardButton.js";
210
+ export { useWebhookFilters, webhookQueryArgs } from "./filters.js";
211
+ export { AccountConfigurations } from "./Account.js";
212
+ export type { AccountConfigurationsProps } from "./Account.js";
213
+ export { Overview, getPayoutTotals } from "./Overview.js";
214
+ export type { OverviewProps, OverviewState } from "./Overview.js";
215
+ export { currentSubscriptionFrom } from "./current-subscription.js";
216
+ export { CheckoutChooser } from "./CheckoutChooser.js";
217
+ export type {
218
+ CheckoutChooserProps,
219
+ CheckoutChooserState,
220
+ CheckoutOption,
221
+ } from "./CheckoutChooser.js";
222
+ export { SubscriptionOverview } from "./SubscriptionOverview.js";
223
+ export type {
224
+ SubscriptionOverviewProps,
225
+ SubscriptionOverviewState,
226
+ } from "./SubscriptionOverview.js";
227
+ export { DEFAULT_CONNECT_COUNTRIES } from "./Onboarding.js";
228
+ export { PayoutHistory } from "./Payouts.js";
229
+ export type { PayoutHistoryProps, PayoutHistoryRow } from "./Payouts.js";
230
+ export { PayoutOverview } from "./Overview.js";
231
+ export type { PayoutOverviewProps, PayoutOverviewRow } from "./Overview.js";
232
+ export { ChargeSummary, PaymentDetails } from "./Financials.js";
233
+ export type {
234
+ ChargeSummaryProps,
235
+ PaymentDetailsProps,
236
+ PaymentDetailsPayment,
237
+ PaymentDetailsState,
238
+ } from "./Financials.js";
@@ -0,0 +1,73 @@
1
+ // @vitest-environment jsdom
2
+ import { cleanup, render, screen, waitFor } from "@testing-library/react";
3
+ import userEvent from "@testing-library/user-event";
4
+ import { afterEach, expect, it, vi } from "vitest";
5
+ import { Products, Refunds, BalancePaymentSource } from "../index.js";
6
+
7
+ afterEach(cleanup);
8
+ it("lets a package consumer create a recurring product price without example providers", async () => {
9
+ const createPrice = vi.fn(async () => null);
10
+ render(
11
+ <Products
12
+ scopeKey="store"
13
+ products={[
14
+ {
15
+ stripeProductId: "prod_tee",
16
+ name: "Tee club",
17
+ active: true,
18
+ prices: [],
19
+ },
20
+ ]}
21
+ createProduct={async () => null}
22
+ createPrice={createPrice}
23
+ />,
24
+ );
25
+ await userEvent.click(screen.getByRole("button", { name: "Add price" }));
26
+ await userEvent.type(screen.getByLabelText("Price in minor units"), "2900");
27
+ await userEvent.selectOptions(screen.getByLabelText("Interval"), "month");
28
+ await userEvent.click(screen.getByRole("button", { name: "Create price" }));
29
+ await waitFor(() =>
30
+ expect(createPrice).toHaveBeenCalledWith({
31
+ stripeProductId: "prod_tee",
32
+ unitAmount: 2900,
33
+ currency: "usd",
34
+ type: "recurring",
35
+ interval: "month",
36
+ }),
37
+ );
38
+ await waitFor(() =>
39
+ expect(screen.queryByLabelText("Price in minor units")).toBeNull(),
40
+ );
41
+ });
42
+ it("submits a partial refund through the native UI and renders its receipt", async () => {
43
+ const issueRefund = vi.fn(async () => ({ stripeRefundId: "re_partial" }));
44
+ render(<Refunds scopeKey="store" issueRefund={issueRefund} />);
45
+ await userEvent.type(screen.getByLabelText("PaymentIntent ID"), "pi_one");
46
+ await userEvent.type(screen.getByLabelText("Partial refund amount"), "12.34");
47
+ await userEvent.click(screen.getByRole("button", { name: "Partial refund" }));
48
+ await waitFor(() =>
49
+ expect(issueRefund).toHaveBeenCalledWith({
50
+ stripePaymentIntentId: "pi_one",
51
+ amountCents: 1234,
52
+ reason: "requested_by_customer",
53
+ }),
54
+ );
55
+ expect((await screen.findByRole("status")).textContent).toContain(
56
+ "Refund created: re_partial",
57
+ );
58
+ });
59
+ it("requires explicit consent before the native balance-funding UI can submit", async () => {
60
+ const change = vi.fn(async () => null);
61
+ render(
62
+ <BalancePaymentSource scopeKey="store" enabled={false} change={change} />,
63
+ );
64
+ const confirm = screen.getByRole("button", {
65
+ name: "Confirm balance payments",
66
+ });
67
+ expect((confirm as HTMLButtonElement).disabled).toBe(true);
68
+ await userEvent.click(screen.getByRole("checkbox"));
69
+ await userEvent.click(confirm);
70
+ await waitFor(() =>
71
+ expect(change).toHaveBeenCalledWith({ enabled: true, consent: true }),
72
+ );
73
+ });
@@ -0,0 +1,216 @@
1
+ import { renderToStaticMarkup } from "react-dom/server";
2
+ import { describe, expect, it, vi } from "vitest";
3
+ import {
4
+ CheckoutChooser,
5
+ SubscriptionOverview,
6
+ PayoutHistory,
7
+ PayoutOverview,
8
+ ChargeSummary,
9
+ PaymentDetails,
10
+ Account,
11
+ Onboarding,
12
+ Payouts,
13
+ Refunds,
14
+ Products,
15
+ Subscriptions,
16
+ SubscriptionManager,
17
+ BillingPlans,
18
+ InvoiceEstimate,
19
+ BalancePaymentSource,
20
+ BillingPortal,
21
+ ReferralLinks,
22
+ Sales,
23
+ Invoices,
24
+ RefundHistory,
25
+ ReferredSales,
26
+ WebhookEvents,
27
+ ChargebackLedger,
28
+ CostRecovery,
29
+ Overview,
30
+ EnvironmentStatus,
31
+ StripeSetup,
32
+ SandboxTesting,
33
+ PaymentReceipt,
34
+ Earnings,
35
+ Storefront,
36
+ } from "../index.js";
37
+ import type { ReactNode } from "react";
38
+ const action = vi.fn(async () => null);
39
+ const account = {
40
+ stripeAccountId: "acct_public",
41
+ email: "seller@example.com",
42
+ country: "US",
43
+ onboardingStatus: "complete",
44
+ configurations: ["recipient"],
45
+ };
46
+ const subscription = {
47
+ stripeSubscriptionId: "sub_public",
48
+ status: "active",
49
+ isTrialing: false,
50
+ cancelAtPeriodEnd: false,
51
+ };
52
+ describe("public workflows without example providers, a router, or CSS", () => {
53
+ const cases: [string, ReactNode][] = [
54
+ ["CheckoutChooser", <CheckoutChooser />],
55
+ ["SubscriptionOverview", <SubscriptionOverview subscriptions={[]} />],
56
+ ["PayoutHistory", <PayoutHistory rows={[]} />],
57
+ ["PayoutOverview", <PayoutOverview payouts={[]} currency="usd" />],
58
+ [
59
+ "ChargeSummary",
60
+ <ChargeSummary
61
+ gross={1000}
62
+ fee={90}
63
+ net={910}
64
+ currency="usd"
65
+ reconciles
66
+ />,
67
+ ],
68
+ ["PaymentDetails", <PaymentDetails payment={null} />],
69
+ ["Account", <Account scopeKey="seller" account={account} />],
70
+ [
71
+ "Onboarding",
72
+ <Onboarding
73
+ scopeKey="seller"
74
+ account={null}
75
+ createAccount={async () => ({
76
+ onboardingUrl: "https://connect.stripe.com",
77
+ })}
78
+ continueOnboarding={async () => ({ url: "https://connect.stripe.com" })}
79
+ />,
80
+ ],
81
+ [
82
+ "Payouts",
83
+ <Payouts
84
+ scopeKey="seller"
85
+ load={async () => ({
86
+ balances: [],
87
+ payouts: [],
88
+ upcoming: [],
89
+ nextCursor: null,
90
+ })}
91
+ />,
92
+ ],
93
+ [
94
+ "Refunds",
95
+ <Refunds
96
+ scopeKey="seller"
97
+ issueRefund={async () => ({ stripeRefundId: "re_public" })}
98
+ />,
99
+ ],
100
+ [
101
+ "Products",
102
+ <Products
103
+ scopeKey="seller"
104
+ products={[]}
105
+ createProduct={action}
106
+ createPrice={action}
107
+ />,
108
+ ],
109
+ ["Subscriptions", <Subscriptions rows={[subscription]} />],
110
+ [
111
+ "SubscriptionManager",
112
+ <SubscriptionManager
113
+ scopeKey="buyer"
114
+ subscription={subscription}
115
+ onAction={action}
116
+ />,
117
+ ],
118
+ [
119
+ "BillingPlans",
120
+ <BillingPlans
121
+ scopeKey="seller"
122
+ publishableKey="pk_test_public"
123
+ plans={[
124
+ {
125
+ id: "starter",
126
+ name: "Starter",
127
+ monthlyAmount: 900,
128
+ currency: "usd",
129
+ },
130
+ ]}
131
+ createCheckout={async () => ({
132
+ stripeSessionId: "cs_public",
133
+ clientSecret: "cs_public_secret",
134
+ })}
135
+ createPortal={async () => "https://billing.stripe.com"}
136
+ />,
137
+ ],
138
+ [
139
+ "InvoiceEstimate",
140
+ <InvoiceEstimate
141
+ scopeKey="seller"
142
+ load={async () => ({
143
+ total: 900,
144
+ currency: "usd",
145
+ nextBillingAt: 1800000000000,
146
+ lines: [],
147
+ })}
148
+ />,
149
+ ],
150
+ [
151
+ "BalancePaymentSource",
152
+ <BalancePaymentSource
153
+ scopeKey="seller"
154
+ enabled={false}
155
+ change={action}
156
+ />,
157
+ ],
158
+ [
159
+ "BillingPortal",
160
+ <BillingPortal
161
+ createSession={async () => "https://billing.stripe.com"}
162
+ />,
163
+ ],
164
+ ["ReferralLinks", <ReferralLinks links={[]} />],
165
+ ["Sales", <Sales rows={[]} />],
166
+ ["Invoices", <Invoices rows={[]} />],
167
+ ["RefundHistory", <RefundHistory rows={[]} />],
168
+ ["ReferredSales", <ReferredSales rows={[]} />],
169
+ ["WebhookEvents", <WebhookEvents rows={[]} />],
170
+ ["CostRecovery", <CostRecovery rows={[]} />],
171
+ ["ChargebackLedger", <ChargebackLedger chargeback={null} />],
172
+ ["Overview", <Overview products={[]} subscriptions={[]} />],
173
+ [
174
+ "EnvironmentStatus",
175
+ <EnvironmentStatus
176
+ checks={[{ id: "secret", label: "Stripe key", configured: true }]}
177
+ />,
178
+ ],
179
+ [
180
+ "StripeSetup",
181
+ <StripeSetup tasks={[{ id: "sync", label: "Sync", run: action }]} />,
182
+ ],
183
+ [
184
+ "SandboxTesting",
185
+ <SandboxTesting tasks={[{ id: "seed", label: "Seed", run: action }]} />,
186
+ ],
187
+ [
188
+ "PaymentReceipt",
189
+ <PaymentReceipt
190
+ payment={{ status: "succeeded", amount: 2900, currency: "usd" }}
191
+ />,
192
+ ],
193
+ [
194
+ "Earnings",
195
+ <Earnings
196
+ gross={2900}
197
+ reversed={0}
198
+ net={2900}
199
+ paidOut={0}
200
+ payouts={[]}
201
+ />,
202
+ ],
203
+ ["Storefront", <Storefront stores={[]} />],
204
+ ];
205
+ it.each(cases)(
206
+ "%s renders unstyled native HTML independently",
207
+ (_name, component) => {
208
+ const markup = renderToStaticMarkup(component);
209
+ expect(markup.length).toBeGreaterThan(0);
210
+ expect(markup).not.toContain("class=");
211
+ expect(markup).not.toContain("style=");
212
+ expect(markup).not.toContain("localhost");
213
+ expect(action).not.toHaveBeenCalled();
214
+ },
215
+ );
216
+ });
@@ -0,0 +1,54 @@
1
+ // @vitest-environment jsdom
2
+ import { act, renderHook, cleanup } from "@testing-library/react";
3
+ import { afterEach, expect, it, vi } from "vitest";
4
+ import { useWorkflowAction } from "./useWorkflowAction.js";
5
+ afterEach(cleanup);
6
+ it("prevents duplicate requests and exposes pending, errors, and retry", async () => {
7
+ let reject!: (error: Error) => void;
8
+ const callback = vi.fn(
9
+ () =>
10
+ new Promise<string>((_resolve, fail) => {
11
+ reject = fail;
12
+ }),
13
+ );
14
+ const { result } = renderHook(() => useWorkflowAction(callback));
15
+ let first!: Promise<string | undefined>;
16
+ act(() => {
17
+ first = result.current.run();
18
+ });
19
+ expect(result.current.isPending).toBe(true);
20
+ await act(async () => {
21
+ await result.current.run();
22
+ });
23
+ expect(callback).toHaveBeenCalledOnce();
24
+ await act(async () => {
25
+ reject(new Error("Stripe declined"));
26
+ await first;
27
+ });
28
+ expect(result.current.error).toBe("Stripe declined");
29
+ expect(result.current.isPending).toBe(false);
30
+ });
31
+ it("does not publish an old account's action result after a scope change", async () => {
32
+ let resolve!: (value: string) => void;
33
+ const callback = vi.fn(
34
+ () =>
35
+ new Promise<string>((done) => {
36
+ resolve = done;
37
+ }),
38
+ );
39
+ const { result, rerender } = renderHook(
40
+ ({ scope }) => useWorkflowAction(callback, scope),
41
+ { initialProps: { scope: "seller_one" } },
42
+ );
43
+ let request!: Promise<string | undefined>;
44
+ act(() => {
45
+ request = result.current.run();
46
+ });
47
+ rerender({ scope: "seller_two" });
48
+ await act(async () => {
49
+ resolve("seller_one_secret");
50
+ await request;
51
+ });
52
+ expect(result.current.result).toBeUndefined();
53
+ expect(result.current.isPending).toBe(false);
54
+ });