@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,24 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { CHECKOUT_OPTIONS } from "./checkout-options.js";
5
+ /** Checkout tradeoffs and mode selection, independent of routing and session creation. */
6
+ export function CheckoutChooser({ value, defaultValue = "embedded", onValueChange, recurring = false, children, }) {
7
+ const [internal, setInternal] = useState(defaultValue);
8
+ const selected = CHECKOUT_OPTIONS.find((option) => option.id === (value ?? internal)) ??
9
+ CHECKOUT_OPTIONS[1];
10
+ const select = (mode) => {
11
+ setInternal(mode);
12
+ onValueChange?.(mode);
13
+ };
14
+ const state = {
15
+ options: CHECKOUT_OPTIONS,
16
+ selected,
17
+ select,
18
+ unsupported: recurring && selected.id === "payment-intent",
19
+ };
20
+ if (children)
21
+ return _jsx(_Fragment, { children: children(state) });
22
+ return (_jsxs("section", { "data-better-stripe": "checkout-chooser", children: [_jsx("h2", { children: "Choose your checkout type" }), _jsx("div", { role: "group", "aria-label": "Checkout types", children: state.options.map((option) => (_jsx("button", { type: "button", "aria-pressed": selected.id === option.id, onClick: () => select(option.id), children: option.title }, option.id))) }), _jsx("h3", { children: selected.title }), _jsx("p", { children: selected.api }), _jsxs("dl", { children: [_jsx("dt", { children: "Pros" }), _jsx("dd", { children: selected.pros }), _jsx("dt", { children: "Cons" }), _jsx("dd", { children: selected.cons })] }), _jsx("a", { href: selected.docs, target: "_blank", rel: "noreferrer", children: "Stripe documentation" }), selected.id === "form" && _jsx("p", { children: "Preview" }), state.unsupported && (_jsx("p", { role: "status", children: "Payment Intents alone do not create subscriptions. Choose a Checkout Sessions integration for a recurring product." }))] }));
23
+ }
24
+ //# sourceMappingURL=CheckoutChooser.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckoutChooser.js","sourceRoot":"","sources":["../../../src/react/workflows/CheckoutChooser.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,QAAQ,EAAkB,MA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EACN,uBAAK,QAAQ,CAAC,KAAK,GAAM,EACzB,sBAAI,QAAQ,CAAC,GAAG,GAAK,EACrB,yBACE,gCAAa,EACb,uBAAK,QAAQ,CAAC,IAAI,GAAM,EACxB,gCAAa,EACb,uBAAK,QAAQ,CAAC,IAAI,GAAM,IACrB,EACL,YAAG,IAAI,EAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAC,QAAQ,EAAC,GAAG,EAAC,YAAY,qCAEpD,EACH,QAAQ,CAAC,EAAE,KAAK,MAAM,IAAI,kCAAc,EACxC,KAAK,CAAC,WAAW,IAAI,CACpB,YAAG,IAAI,EAAC,QAAQ,mIAGZ,CACL,IACO,CACX,CAAC;AACJ,CAAC"}
@@ -0,0 +1,26 @@
1
+ import { type FormEvent, type ReactNode } from "react";
2
+ import { type Appearance } from "@stripe/stripe-js";
3
+ export type CheckoutFormState = {
4
+ email: string;
5
+ setEmail: (email: string) => void;
6
+ emailInputId: string;
7
+ isPending: boolean;
8
+ error: string | null;
9
+ paymentElement: ReactNode;
10
+ submit: (event: FormEvent<HTMLFormElement>) => void;
11
+ };
12
+ export type CheckoutFormOptions = {
13
+ email?: string;
14
+ appearance?: Appearance;
15
+ renderForm?: (state: CheckoutFormState) => ReactNode;
16
+ };
17
+ export type CheckoutFormProps = CheckoutFormOptions & {
18
+ publishableKey: string;
19
+ clientSecret: string;
20
+ returnUrl: string;
21
+ onNavigate: (url: string) => void;
22
+ };
23
+ export declare function CheckoutElementsForm(props: CheckoutFormProps): import("react").JSX.Element;
24
+ export declare function PaymentIntentForm(props: CheckoutFormProps): import("react").JSX.Element;
25
+ export declare function CheckoutForm(props: CheckoutFormProps): import("react").JSX.Element;
26
+ //# sourceMappingURL=CheckoutForms.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckoutForms.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/CheckoutForms.tsx"],"names":[],"mappings":"AACA,OAAO,EAIL,KAAK,SAAS,EACd,KAAK,SAAS,EACf,MAAM,OAAO,CAAC;AACf,OAAO,EAAc,KAAK,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAgBhE,MAAM,MAAM,iBAAiB,GAAG;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAClC,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,cAAc,EAAE,SAAS,CAAC;IAC1B,MAAM,EAAE,CAAC,KAAK,EAAE,SAAS,CAAC,eAAe,CAAC,KAAK,IAAI,CAAC;CACrD,CAAC;AACF,MAAM,MAAM,mBAAmB,GAAG;IAChC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB,UAAU,CAAC,EAAE,CAAC,KAAK,EAAE,iBAAiB,KAAK,SAAS,CAAC;CACtD,CAAC;AACF,MAAM,MAAM,iBAAiB,GAAG,mBAAmB,GAAG;IACpD,cAAc,EAAE,MAAM,CAAC;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,IAAI,CAAC;CACnC,CAAC;AAkCF,wBAAgB,oBAAoB,CAAC,KAAK,EAAE,iBAAiB,+BAU5D;AAsCD,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,iBAAiB,+BAYzD;AAiDD,wBAAgB,YAAY,CAAC,KAAK,EAAE,iBAAiB,+BAkBpD"}
@@ -0,0 +1,126 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId, useMemo, useState, } from "react";
4
+ import { loadStripe } from "@stripe/stripe-js";
5
+ import { PaymentElement as IntentElement, useElements, useStripe, } from "@stripe/react-stripe-js";
6
+ import { PaymentElement, useCheckout, CheckoutFormProvider, CheckoutForm as StripeCheckoutForm, useCheckoutForm, } from "@stripe/react-stripe-js/checkout";
7
+ import { CheckoutSessionProvider } from "../components/CheckoutSessionProvider.js";
8
+ import { StripeProvider } from "../components/StripeProvider.js";
9
+ import { useWorkflowAction } from "./useWorkflowAction.js";
10
+ function NativeForm({ email, setEmail, emailInputId, paymentElement, submit, isPending, error, }) {
11
+ return (_jsxs("form", { onSubmit: submit, "data-better-stripe": "checkout-form", "aria-busy": isPending, children: [_jsx("label", { htmlFor: emailInputId, children: "Email for your receipt" }), _jsx("input", { id: emailInputId, type: "email", name: "email", required: true, autoComplete: "email", value: email, onChange: (event) => setEmail(event.target.value) }), paymentElement, error && _jsx("p", { role: "alert", children: error }), _jsx("button", { type: "submit", disabled: isPending, children: isPending ? "Processing…" : "Pay" })] }));
12
+ }
13
+ export function CheckoutElementsForm(props) {
14
+ return (_jsx(CheckoutSessionProvider, { publishableKey: props.publishableKey, clientSecret: props.clientSecret, appearance: props.appearance, children: _jsx(SessionForm, { ...props }) }));
15
+ }
16
+ function SessionForm({ email: initialEmail = "", returnUrl, onNavigate, renderForm, }) {
17
+ const checkout = useCheckout();
18
+ const [email, setEmail] = useState(initialEmail);
19
+ const emailInputId = useId();
20
+ const action = useWorkflowAction(async () => {
21
+ if (checkout.type !== "success")
22
+ throw new Error("Checkout is not ready.");
23
+ const updated = await checkout.checkout.updateEmail(email);
24
+ if (updated.type === "error")
25
+ throw new Error(updated.error.message);
26
+ const confirmed = await checkout.checkout.confirm();
27
+ if (confirmed.type === "error")
28
+ throw new Error(confirmed.error.message);
29
+ onNavigate(returnUrl.replace("{CHECKOUT_SESSION_ID}", checkout.checkout.id));
30
+ });
31
+ if (checkout.type === "loading")
32
+ return _jsx("p", { role: "status", children: "Loading checkout\u2026" });
33
+ if (checkout.type === "error")
34
+ return _jsx("p", { role: "alert", children: checkout.error.message });
35
+ const state = {
36
+ email,
37
+ setEmail,
38
+ emailInputId,
39
+ paymentElement: _jsx(PaymentElement, {}),
40
+ error: action.error,
41
+ isPending: action.isPending,
42
+ submit: (event) => {
43
+ event.preventDefault();
44
+ void action.run();
45
+ },
46
+ };
47
+ return _jsx(_Fragment, { children: renderForm ? renderForm(state) : _jsx(NativeForm, { ...state }) });
48
+ }
49
+ export function PaymentIntentForm(props) {
50
+ return (_jsx(StripeProvider, { publishableKey: props.publishableKey, elementsOptions: {
51
+ clientSecret: props.clientSecret,
52
+ ...(props.appearance ? { appearance: props.appearance } : {}),
53
+ }, children: _jsx(IntentForm, { ...props }) }));
54
+ }
55
+ function IntentForm({ email: initialEmail = "", returnUrl, onNavigate, renderForm, }) {
56
+ const stripe = useStripe();
57
+ const elements = useElements();
58
+ const emailInputId = useId();
59
+ const [email, setEmail] = useState(initialEmail);
60
+ const action = useWorkflowAction(async () => {
61
+ if (!stripe || !elements)
62
+ throw new Error("Payment details are still loading.");
63
+ const validation = await elements.submit();
64
+ if (validation.error)
65
+ throw new Error(validation.error.message ?? "Check your payment details.");
66
+ const result = await stripe.confirmPayment({
67
+ elements,
68
+ confirmParams: {
69
+ return_url: returnUrl,
70
+ payment_method_data: { billing_details: { email } },
71
+ },
72
+ redirect: "if_required",
73
+ });
74
+ if (result.error)
75
+ throw new Error(result.error.message ?? "Payment failed.");
76
+ if (result.paymentIntent) {
77
+ const url = new URL(returnUrl, window.location.origin);
78
+ url.searchParams.set("payment_intent", result.paymentIntent.id);
79
+ onNavigate(url.toString());
80
+ }
81
+ });
82
+ const state = {
83
+ email,
84
+ setEmail,
85
+ emailInputId,
86
+ paymentElement: _jsx(IntentElement, {}),
87
+ error: action.error,
88
+ isPending: action.isPending || !stripe || !elements,
89
+ submit: (event) => {
90
+ event.preventDefault();
91
+ void action.run();
92
+ },
93
+ };
94
+ return _jsx(_Fragment, { children: renderForm ? renderForm(state) : _jsx(NativeForm, { ...state }) });
95
+ }
96
+ export function CheckoutForm(props) {
97
+ const stripe = useMemo(() => loadStripe(props.publishableKey), [props.publishableKey]);
98
+ return (_jsx(CheckoutFormProvider, { stripe: stripe, options: {
99
+ clientSecret: props.clientSecret,
100
+ ...(props.appearance
101
+ ? { elementsOptions: { appearance: props.appearance } }
102
+ : {}),
103
+ }, children: _jsx(CompactForm, { ...props }) }));
104
+ }
105
+ function CompactForm({ returnUrl, onNavigate }) {
106
+ const checkout = useCheckoutForm();
107
+ const [loadError, setLoadError] = useState(null);
108
+ const action = useWorkflowAction(async (event) => {
109
+ if (checkout.type !== "success")
110
+ throw new Error("Checkout is not ready.");
111
+ const result = await checkout.checkout.confirm({
112
+ formConfirmEvent: event,
113
+ });
114
+ if (result.type === "error")
115
+ throw new Error(result.error.message);
116
+ onNavigate(returnUrl.replace("{CHECKOUT_SESSION_ID}", checkout.checkout.id));
117
+ });
118
+ if (checkout.type === "loading")
119
+ return _jsx("p", { role: "status", children: "Loading embedded form\u2026" });
120
+ if (checkout.type === "error")
121
+ return _jsx("p", { role: "alert", children: checkout.error.message });
122
+ return (_jsxs("div", { "data-better-stripe": "checkout-form", "aria-busy": action.isPending, children: [_jsx(StripeCheckoutForm, { onLoadError: ({ error }) => setLoadError(error.message ?? "Could not load checkout."), onConfirm: async (event) => {
123
+ await action.run(event);
124
+ } }), (loadError || action.error) && (_jsx("p", { role: "alert", children: loadError || action.error }))] }));
125
+ }
126
+ //# sourceMappingURL=CheckoutForms.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckoutForms.js","sourceRoot":"","sources":["../../../src/react/workflows/CheckoutForms.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EACL,KAAK,EACL,OAAO,EACP,QAAQ,GAGT,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,UAAU,EAAmB,MAAM,mBAAmB,CAAC;AAChE,OAAO,EACL,cAAc,IAAI,aAAa,EAC/B,WAAW,EACX,SAAS,GACV,MAAM,yBAAyB,CAAC;AACjC,OAAO,EACL,cAAc,EACd,WAAW,EACX,oBAAoB,EACpB,YAAY,IAAI,kBAAkB,EAClC,eAAe,GA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,4CAA2B,CAAC;IACrD,IAAI,QAAQ,CAAC,IAAI,KAAK,OAAO;QAC3B,OAAO,YAAG,IAAI,EAAC,OAAO,YAAE,QAAQ,CAAC,KAAK,CAAC,OAAO,GAAK,CAAC;IACtD,OAAO,CACL,qCAAwB,eAAe,eAAY,MAAM,CAAC,SAAS,aACjE,KAAC,kBAAkB,IACjB,WAAW,EAAE,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CACzB,YAAY,CAAC,KAAK,CAAC,OAAO,IAAI,0BAA0B,CAAC,EAE3D,SAAS,EAAE,KAAK,EAAE,KAAK,EAAE,EAAE;oBACzB,MAAM,MAAM,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;gBAC1B,CAAC,GACD,EACD,CAAC,SAAS,IAAI,MAAM,CAAC,KAAK,CAAC,IAAI,CAC9B,YAAG,IAAI,EAAC,OAAO,YAAE,SAAS,IAAI,MAAM,CAAC,KAAK,GAAK,CAChD,IACG,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,17 @@
1
+ import { type ReactNode } from "react";
2
+ export type ClipboardButtonProps = {
3
+ text: string;
4
+ label?: string;
5
+ copiedLabel?: string;
6
+ resetAfterMs?: number;
7
+ writeText?: (text: string) => Promise<void>;
8
+ children?: (state: {
9
+ copy: () => Promise<void>;
10
+ copied: boolean;
11
+ isPending: boolean;
12
+ error: string | null;
13
+ label: string;
14
+ }) => ReactNode;
15
+ };
16
+ export declare function ClipboardButton({ text, label, copiedLabel, resetAfterMs, writeText, children, }: ClipboardButtonProps): import("react").JSX.Element;
17
+ //# sourceMappingURL=ClipboardButton.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClipboardButton.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/ClipboardButton.tsx"],"names":[],"mappings":"AACA,OAAO,EAAqB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAE1D,MAAM,MAAM,oBAAoB,GAAG;IACjC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,SAAS,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAC5C,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE;QACjB,IAAI,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;QAC1B,MAAM,EAAE,OAAO,CAAC;QAChB,SAAS,EAAE,OAAO,CAAC;QACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;QACrB,KAAK,EAAE,MAAM,CAAC;KACf,KAAK,SAAS,CAAC;CACjB,CAAC;AACF,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,KAAc,EACd,WAAuB,EACvB,YAAmB,EACnB,SAAyD,EACzD,QAAQ,GACT,EAAE,oBAAoB,+BA0CtB"}
@@ -0,0 +1,35 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useEffect, useRef } from "react";
4
+ import { useWorkflowAction } from "./useWorkflowAction.js";
5
+ export function ClipboardButton({ text, label = "Copy", copiedLabel = "Copied!", resetAfterMs = 2000, writeText = (text) => navigator.clipboard.writeText(text), children, }) {
6
+ const action = useWorkflowAction(async () => {
7
+ await writeText(text);
8
+ return text;
9
+ });
10
+ const timer = useRef(undefined);
11
+ useEffect(() => () => {
12
+ clearTimeout(timer.current);
13
+ }, []);
14
+ const copied = action.result === text;
15
+ const copy = async () => {
16
+ const result = await action.run();
17
+ if (result !== undefined) {
18
+ clearTimeout(timer.current);
19
+ timer.current = setTimeout(action.reset, resetAfterMs);
20
+ }
21
+ };
22
+ const state = {
23
+ copy,
24
+ copied,
25
+ isPending: action.isPending,
26
+ error: action.error,
27
+ label: copied ? copiedLabel : label,
28
+ };
29
+ if (children)
30
+ return _jsx(_Fragment, { children: children(state) });
31
+ return (_jsxs("span", { "data-better-stripe": "clipboard", children: [_jsx("button", { type: "button", disabled: state.isPending, onClick: () => {
32
+ void copy();
33
+ }, children: state.label }), state.error && _jsx("span", { role: "alert", children: state.error })] }));
34
+ }
35
+ //# sourceMappingURL=ClipboardButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ClipboardButton.js","sourceRoot":"","sources":["../../../src/react/workflows/ClipboardButton.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,SAAS,EAAE,MAAM,EAAkB,MAAM,OAAO,CAAC;AAC1D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAe3D,MAAM,UAAU,eAAe,CAAC,EAC9B,IAAI,EACJ,KAAK,GAAG,MAAM,EACd,WAAW,GAAG,SAAS,EACvB,YAAY,GAAG,IAAI,EACnB,SAAS,GAAG,CAAC,IAAI,EAAE,EAAE,CAAC,SAAS,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,EACzD,QAAQ,GACa;IACrB,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,IAAI,EAAE;QAC1C,MAAM,SAAS,CAAC,IAAI,CAAC,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACH,MAAM,KAAK,GAAG,MAAM,CAA4C,SAAS,CAAC,CAAC;IAC3E,SAAS,CACP,GAAG,EAAE,CAAC,GAAG,EAAE;QACT,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;IAC9B,CAAC,EACD,EAAE,CACH,CAAC;IACF,MAAM,MAAM,GAAG,MAAM,CAAC,MAAM,KAAK,IAAI,CAAC;IACtC,MAAM,IAAI,GAAG,KAAK,IAAI,EAAE;QACtB,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,GAAG,EAAE,CAAC;QAClC,IAAI,MAAM,KAAK,SAAS,EAAE,CAAC;YACzB,YAAY,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC;YAC5B,KAAK,CAAC,OAAO,GAAG,UAAU,CAAC,MAAM,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QACzD,CAAC;IACH,CAAC,CAAC;IACF,MAAM,KAAK,GAAG;QACZ,IAAI;QACJ,MAAM;QACN,SAAS,EAAE,MAAM,CAAC,SAAS;QAC3B,KAAK,EAAE,MAAM,CAAC,KAAK;QACnB,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,KAAK;KACpC,CAAC;IACF,IAAI,QAAQ;QAAE,OAAO,4BAAG,QAAQ,CAAC,KAAK,CAAC,GAAI,CAAC;IAC5C,OAAO,CACL,sCAAyB,WAAW,aAClC,iBACE,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,OAAO,EAAE,GAAG,EAAE;oBACZ,KAAK,IAAI,EAAE,CAAC;gBACd,CAAC,YAEA,KAAK,CAAC,KAAK,GACL,EACR,KAAK,CAAC,KAAK,IAAI,eAAM,IAAI,EAAC,OAAO,YAAE,KAAK,CAAC,KAAK,GAAQ,IAClD,CACR,CAAC;AACJ,CAAC"}
@@ -0,0 +1,30 @@
1
+ import type { Key, ReactNode } from "react";
2
+ export type WorkflowColumn<Row> = {
3
+ id: string;
4
+ label: string;
5
+ align?: "start" | "end";
6
+ cell: (row: Row) => ReactNode;
7
+ };
8
+ export type CollectionRenderProps<Row> = {
9
+ rows: Row[];
10
+ columns: WorkflowColumn<Row>[];
11
+ getKey: (row: Row) => Key;
12
+ isLoading: boolean;
13
+ isEmpty: boolean;
14
+ error: string | null;
15
+ emptyLabel: string;
16
+ loadingLabel: string;
17
+ };
18
+ export type CollectionProps<Row> = {
19
+ rows: Row[] | null | undefined;
20
+ columns: WorkflowColumn<Row>[];
21
+ getKey: (row: Row) => Key;
22
+ isLoading?: boolean;
23
+ error?: string | null;
24
+ emptyLabel?: string;
25
+ loadingLabel?: string;
26
+ children?: (state: CollectionRenderProps<Row>) => ReactNode;
27
+ };
28
+ /** Accessible native table by default. Render props let the application supply its design-system elements. */
29
+ export declare function Collection<Row>({ rows, columns, getKey, isLoading, error, emptyLabel, loadingLabel, children, }: CollectionProps<Row>): import("react").JSX.Element;
30
+ //# sourceMappingURL=Collection.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Collection.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/Collection.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,GAAG,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAC5C,MAAM,MAAM,cAAc,CAAC,GAAG,IAAI;IAChC,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,GAAG,KAAK,CAAC;IACxB,IAAI,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,SAAS,CAAC;CAC/B,CAAC;AACF,MAAM,MAAM,qBAAqB,CAAC,GAAG,IAAI;IACvC,IAAI,EAAE,GAAG,EAAE,CAAC;IACZ,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;IAC/B,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC;IAC1B,SAAS,EAAE,OAAO,CAAC;IACnB,OAAO,EAAE,OAAO,CAAC;IACjB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,MAAM,MAAM,eAAe,CAAC,GAAG,IAAI;IACjC,IAAI,EAAE,GAAG,EAAE,GAAG,IAAI,GAAG,SAAS,CAAC;IAC/B,OAAO,EAAE,cAAc,CAAC,GAAG,CAAC,EAAE,CAAC;IAC/B,MAAM,EAAE,CAAC,GAAG,EAAE,GAAG,KAAK,GAAG,CAAC;IAC1B,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,qBAAqB,CAAC,GAAG,CAAC,KAAK,SAAS,CAAC;CAC7D,CAAC;AACF,8GAA8G;AAC9G,wBAAgB,UAAU,CAAC,GAAG,EAAE,EAC9B,IAAI,EACJ,OAAO,EACP,MAAM,EACN,SAA8B,EAC9B,KAAY,EACZ,UAA8B,EAC9B,YAAyB,EACzB,QAAQ,GACT,EAAE,eAAe,CAAC,GAAG,CAAC,+BAqCtB"}
@@ -0,0 +1,25 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ /** Accessible native table by default. Render props let the application supply its design-system elements. */
4
+ export function Collection({ rows, columns, getKey, isLoading = rows === undefined, error = null, emptyLabel = "No records yet.", loadingLabel = "Loading…", children, }) {
5
+ const state = {
6
+ rows: rows ?? [],
7
+ columns,
8
+ getKey,
9
+ isLoading,
10
+ isEmpty: !isLoading && !rows?.length,
11
+ error,
12
+ emptyLabel,
13
+ loadingLabel,
14
+ };
15
+ if (children)
16
+ return _jsx(_Fragment, { children: children(state) });
17
+ if (error)
18
+ return _jsx("p", { role: "alert", children: error });
19
+ if (isLoading)
20
+ return _jsx("p", { role: "status", children: loadingLabel });
21
+ if (state.isEmpty)
22
+ return _jsx("p", { children: emptyLabel });
23
+ return (_jsxs("table", { "data-better-stripe": "collection", children: [_jsx("thead", { children: _jsx("tr", { children: columns.map((column) => (_jsx("th", { scope: "col", children: column.label }, column.id))) }) }), _jsx("tbody", { children: state.rows.map((row) => (_jsx("tr", { children: columns.map((column) => (_jsx("td", { children: column.cell(row) }, column.id))) }, getKey(row)))) })] }));
24
+ }
25
+ //# sourceMappingURL=Collection.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Collection.js","sourceRoot":"","sources":["../../../src/react/workflows/Collection.tsx"],"names":[],"mappings":"AAAA,YAAY,C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,CAAC;AACJ,CAAC"}
@@ -0,0 +1,56 @@
1
+ import type { CollectionProps, WorkflowColumn } from "./Collection.js";
2
+ export type ResourceCollectionProps<Row> = Omit<CollectionProps<Row>, "columns" | "getKey"> & {
3
+ columns?: WorkflowColumn<Row>[];
4
+ };
5
+ export type SaleRow = {
6
+ _id?: string;
7
+ planId: string;
8
+ paymentIntentId: string;
9
+ chargeId?: string;
10
+ gross: number;
11
+ processingFee: number;
12
+ platformNet: number;
13
+ affiliateNet: number;
14
+ costRecoveryAmount?: number;
15
+ sellerNet: number;
16
+ currency: string;
17
+ status: string;
18
+ };
19
+ export declare function Sales(props: ResourceCollectionProps<SaleRow>): import("react").JSX.Element;
20
+ export type InvoiceRow = {
21
+ stripeInvoiceId: string;
22
+ amountPaid?: number;
23
+ amountDue?: number;
24
+ currency: string;
25
+ status: string;
26
+ hostedInvoiceUrl?: string;
27
+ };
28
+ export declare function Invoices(props: ResourceCollectionProps<InvoiceRow>): import("react").JSX.Element;
29
+ export type RefundRow = {
30
+ /** Unix milliseconds, matching Convex creation timestamps. */
31
+ _creationTime?: number;
32
+ stripeRefundId: string;
33
+ amount: number;
34
+ currency: string;
35
+ status: string;
36
+ reason?: string;
37
+ };
38
+ export declare function RefundHistory(props: ResourceCollectionProps<RefundRow>): import("react").JSX.Element;
39
+ export type ReferredSaleRow = {
40
+ stripeTransferId: string;
41
+ sourceChargeId?: string;
42
+ storeName?: string | null;
43
+ amount: number;
44
+ currency?: string;
45
+ };
46
+ export declare function ReferredSales(props: ResourceCollectionProps<ReferredSaleRow>): import("react").JSX.Element;
47
+ export type WebhookEventRow = {
48
+ stripeEventId: string;
49
+ eventType: string;
50
+ status: string;
51
+ processedAt?: number;
52
+ lastError?: string;
53
+ livemode?: boolean;
54
+ };
55
+ export declare function WebhookEvents<Row extends WebhookEventRow>(props: ResourceCollectionProps<Row>): import("react").JSX.Element;
56
+ //# sourceMappingURL=Collections.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"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AE,MAAM,CAAC;IACvB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AACF,wBAAgB,aAAa,CAAC,KAAK,EAAE,uBAAuB,CAAC,SAAS,CAAC,+BAgCtE;AACD,MAAM,MAAM,eAAe,GAAG;IAC5B,gBAAgB,EAAE,MAAM,CAAC;IACzB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC1B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,wBAAgB,aAAa,CAAC,KAAK,EAAE,uBAAuB,CAAC,eAAe,CAAC,+BA2B5E;AACD,MAAM,MAAM,eAAe,GAAG;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;CACpB,CAAC;AACF,wBAAgB,aAAa,CAAC,GAAG,SAAS,eAAe,EACvD,KAAK,EAAE,uBAAuB,CAAC,GAAG,CAAC,+BA6BpC"}
@@ -0,0 +1,111 @@
1
+ "use client";
2
+ import { jsx as _jsx } from "react/jsx-runtime";
3
+ import { Collection } from "./Collection.js";
4
+ import { formatPrice } from "../lib/price-helpers.js";
5
+ export function Sales(props) {
6
+ const columns = [
7
+ { id: "planId", label: "Plan", cell: (row) => row.planId },
8
+ ...[
9
+ ["gross", "Sale"],
10
+ ["processingFee", "Stripe processing"],
11
+ ["platformNet", "Platform"],
12
+ ["affiliateNet", "Affiliate"],
13
+ ["costRecoveryAmount", "Cost recovery"],
14
+ ["sellerNet", "Your earnings"],
15
+ ].map(([field, label]) => ({
16
+ id: field,
17
+ label,
18
+ align: "end",
19
+ cell: (row) => formatPrice(row[field] ?? 0, row.currency),
20
+ })),
21
+ { id: "status", label: "Status", cell: (row) => row.status },
22
+ { id: "payment", label: "Payment", cell: (row) => row.paymentIntentId },
23
+ ];
24
+ return (_jsx(Collection, { emptyLabel: "No sales yet.", ...props, getKey: (row) => row._id ?? row.paymentIntentId, columns: props.columns ?? columns }));
25
+ }
26
+ export function Invoices(props) {
27
+ const columns = [
28
+ { id: "id", label: "Invoice ID", cell: (row) => row.stripeInvoiceId },
29
+ {
30
+ id: "amount",
31
+ label: "Amount",
32
+ align: "end",
33
+ cell: (row) => formatPrice(row.amountPaid ?? row.amountDue ?? 0, row.currency),
34
+ },
35
+ { id: "status", label: "Status", cell: (row) => row.status },
36
+ {
37
+ id: "invoice",
38
+ label: "Invoice",
39
+ cell: (row) => row.hostedInvoiceUrl ? (_jsx("a", { href: row.hostedInvoiceUrl, target: "_blank", rel: "noopener noreferrer", children: "View invoice" })) : ("Unavailable"),
40
+ },
41
+ ];
42
+ return (_jsx(Collection, { emptyLabel: "No invoices yet.", ...props, getKey: (row) => row.stripeInvoiceId, columns: props.columns ?? columns }));
43
+ }
44
+ export function RefundHistory(props) {
45
+ const columns = [
46
+ { id: "id", label: "Refund ID", cell: (row) => row.stripeRefundId },
47
+ {
48
+ id: "amount",
49
+ label: "Amount",
50
+ align: "end",
51
+ cell: (row) => formatPrice(row.amount, row.currency),
52
+ },
53
+ { id: "status", label: "Status", cell: (row) => row.status },
54
+ {
55
+ id: "reason",
56
+ label: "Reason",
57
+ cell: (row) => row.reason ?? "Not supplied",
58
+ },
59
+ {
60
+ id: "created",
61
+ label: "Created",
62
+ cell: (row) => row._creationTime === undefined
63
+ ? "Not supplied"
64
+ : new Date(row._creationTime).toLocaleString(),
65
+ },
66
+ ];
67
+ return (_jsx(Collection, { emptyLabel: "No refunds yet.", ...props, getKey: (row) => row.stripeRefundId, columns: props.columns ?? columns }));
68
+ }
69
+ export function ReferredSales(props) {
70
+ const columns = [
71
+ {
72
+ id: "store",
73
+ label: "Store",
74
+ cell: (row) => row.storeName ?? "Store unavailable",
75
+ },
76
+ {
77
+ id: "payment",
78
+ label: "Payment",
79
+ cell: (row) => row.sourceChargeId ?? row.stripeTransferId,
80
+ },
81
+ {
82
+ id: "commission",
83
+ label: "Commission",
84
+ align: "end",
85
+ cell: (row) => formatPrice(row.amount, row.currency ?? "usd"),
86
+ },
87
+ ];
88
+ return (_jsx(Collection, { emptyLabel: "No referred sales yet.", ...props, getKey: (row) => row.stripeTransferId, columns: props.columns ?? columns }));
89
+ }
90
+ export function WebhookEvents(props) {
91
+ const columns = [
92
+ { id: "type", label: "Type", cell: (row) => row.eventType },
93
+ { id: "status", label: "Status", cell: (row) => row.status },
94
+ { id: "id", label: "Event ID", cell: (row) => row.stripeEventId },
95
+ { id: "error", label: "Error", cell: (row) => row.lastError ?? "None" },
96
+ {
97
+ id: "processed",
98
+ label: "Processed",
99
+ cell: (row) => row.processedAt === undefined
100
+ ? "Not supplied"
101
+ : new Date(row.processedAt).toLocaleString(),
102
+ },
103
+ {
104
+ id: "mode",
105
+ label: "Mode",
106
+ cell: (row) => (row.livemode ? "Live" : "Test"),
107
+ },
108
+ ];
109
+ return (_jsx(Collection, { emptyLabel: "No webhook events yet.", ...props, getKey: (row) => row.stripeEventId, columns: props.columns ?? columns }));
110
+ }
111
+ //# sourceMappingURL=Collections.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Collections.js","sourceRoot":"","sources":["../../../src/react/workflows/Collections.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAEb,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAmBtD,MAAM,UAAU,KAAK,CAAC,KAAuC;IAC3D,MAAM,OAAO,GAA8B;QACzC,EAAE,EAAE,EAAE,QAAQ,EAAE,KAAK,EAAE,MAAM,EAAE,IAAI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,EAAE,EAAE,CAAC,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC;SAChD;KACF,CAAC;IACF,OAAO,CACL,KAAC,UAAU,IACT,UAAU,EAAC,wBAAwB,KAC/B,KAAK,EACT,MAAM,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,GAAG,CAAC,aAAa,EAClC,OAAO,EAAE,KAAK,CAAC,OAAO,IAAI,OAAO,GACjC,CACH,CAAC;AACJ,CAAC"}
@@ -0,0 +1,19 @@
1
+ import { type ReactNode } from "react";
2
+ import { type ConnectProviderProps } from "../components/ConnectProvider.js";
3
+ export type ConnectComponent = "account" | "onboarding" | "payments" | "refunds" | "disputes" | "balances" | "payouts" | "notifications";
4
+ export type ConnectRenderProps = {
5
+ content: ReactNode;
6
+ error: string | null;
7
+ retry: () => void;
8
+ completed: boolean;
9
+ };
10
+ export type ConnectProps = Omit<ConnectProviderProps, "children"> & {
11
+ component: ConnectComponent;
12
+ /** Remounts the Stripe instance when the authenticated account changes. The server must authorize it independently. */
13
+ scopeKey: string;
14
+ onExit?: () => void;
15
+ children?: (state: ConnectRenderProps) => ReactNode;
16
+ };
17
+ /** Unstyled, account-scoped Connect component with session refresh, error recovery, appearance, and locale. */
18
+ export declare function Connect(props: ConnectProps): import("react").JSX.Element;
19
+ //# sourceMappingURL=Connect.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Connect.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/Connect.tsx"],"names":[],"mappings":"AACA,OAAO,EAAY,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAUjD,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,kCAAkC,CAAC;AAC1C,MAAM,MAAM,gBAAgB,GACxB,SAAS,GACT,YAAY,GACZ,UAAU,GACV,SAAS,GACT,UAAU,GACV,UAAU,GACV,SAAS,GACT,eAAe,CAAC;AACpB,MAAM,MAAM,kBAAkB,GAAG;IAC/B,OAAO,EAAE,SAAS,CAAC;IACnB,KAAK,EAAE,MAAM,GAAG,IAAI,CAAC;IACrB,KAAK,EAAE,MAAM,IAAI,CAAC;IAClB,SAAS,EAAE,OAAO,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,YAAY,GAAG,IAAI,CAAC,oBAAoB,EAAE,UAAU,CAAC,GAAG;IAClE,SAAS,EAAE,gBAAgB,CAAC;IAC5B,uHAAuH;IACvH,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,IAAI,CAAC;IACpB,QAAQ,CAAC,EAAE,CAAC,KAAK,EAAE,kBAAkB,KAAK,SAAS,CAAC;CACrD,CAAC;AAWF,+GAA+G;AAC/G,wBAAgB,OAAO,CAAC,KAAK,EAAE,YAAY,+BAI1C"}
@@ -0,0 +1,43 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useState } from "react";
4
+ import { ConnectAccountManagement, ConnectAccountOnboarding, ConnectBalances, ConnectDisputesList, ConnectNotificationBanner, ConnectPayments, ConnectPayouts, } from "@stripe/react-connect-js";
5
+ import { ConnectProvider, } from "../components/ConnectProvider.js";
6
+ const widgets = {
7
+ account: ConnectAccountManagement,
8
+ onboarding: ConnectAccountOnboarding,
9
+ payments: ConnectPayments,
10
+ refunds: ConnectPayments,
11
+ disputes: ConnectDisputesList,
12
+ balances: ConnectBalances,
13
+ payouts: ConnectPayouts,
14
+ notifications: ConnectNotificationBanner,
15
+ };
16
+ /** Unstyled, account-scoped Connect component with session refresh, error recovery, appearance, and locale. */
17
+ export function Connect(props) {
18
+ return (_jsx(ConnectBody, { ...props }, `${props.scopeKey}:${props.component}`));
19
+ }
20
+ function ConnectBody({ component, publishableKey, fetchClientSecret, appearance, locale, onExit, children, }) {
21
+ const [attempt, setAttempt] = useState(0);
22
+ const [error, setError] = useState(null);
23
+ const [completed, setCompleted] = useState(false);
24
+ const Widget = widgets[component];
25
+ const retry = () => {
26
+ setError(null);
27
+ setAttempt((value) => value + 1);
28
+ };
29
+ const content = error ? (_jsxs("div", { role: "alert", children: [_jsx("p", { children: error }), _jsx("button", { type: "button", onClick: retry, children: "Retry" })] })) : (_jsx(ConnectProvider, { publishableKey: publishableKey, appearance: appearance, locale: locale, fetchClientSecret: async () => {
30
+ try {
31
+ return await fetchClientSecret();
32
+ }
33
+ catch (error) {
34
+ setError(error instanceof Error ? error.message : String(error));
35
+ throw error;
36
+ }
37
+ }, children: _jsx(Widget, { onLoadError: ({ error }) => setError(error.message ?? "Stripe could not load this component."), onExit: () => {
38
+ setCompleted(true);
39
+ onExit?.();
40
+ } }) }, attempt));
41
+ return (_jsx(_Fragment, { children: children ? children({ content, error, retry, completed }) : content }));
42
+ }
43
+ //# sourceMappingURL=Connect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Connect.js","sourceRoot":"","sources":["../../../src/react/workflows/Connect.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACjD,OAAO,EACL,wBAAwB,EACxB,wBAAwB,EACxB,eAAe,EACf,mBAAmB,EACnB,yBAAyB,EACzB,eAAe,EACf,cAAc,GACf,MAAM,0BAA0B,CAAC;AAClC,OAAO,EACL,eAAe,GAEhB,MAAM,kCAAkC,CAAC;AAuB1C,MAAM,OAAO,GAAG;IACd,OAAO,EAAE,wBAAwB;IACjC,UAAU,EAAE,wBAAwB;IACpC,QAAQ,EAAE,eAAe;IACzB,OAAO,EAAE,eAAe;IACxB,QAAQ,EAAE,mBAAmB;IAC7B,QAAQ,EAAE,eAAe;IACzB,OAAO,EAAE,cAAc;IACvB,aAAa,EAAE,yBAAyB;CACzC,CAAC;AACF,+GAA+G;AAC/G,MAAM,UAAU,OAAO,CAAC,KAAmB;IACzC,OAAO,CACL,KAAC,WAAW,OAAkD,KAAK,IAAjD,GAAG,KAAK,CAAC,QAAQ,IAAI,KAA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