@fantastic.dev/better-stripe 0.8.1 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (175) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/MIGRATION.md +12 -0
  3. package/README.md +46 -2
  4. package/dist/client/billing/checkout.d.ts +1 -0
  5. package/dist/client/billing/checkout.d.ts.map +1 -1
  6. package/dist/client/billing/checkout.js +5 -1
  7. package/dist/client/billing/checkout.js.map +1 -1
  8. package/dist/client/billing/providerReads.d.ts +18 -0
  9. package/dist/client/billing/providerReads.d.ts.map +1 -0
  10. package/dist/client/billing/providerReads.js +15 -0
  11. package/dist/client/billing/providerReads.js.map +1 -0
  12. package/dist/client/billing/subscriptions.d.ts +1 -1
  13. package/dist/client/billing/subscriptions.d.ts.map +1 -1
  14. package/dist/client/billing/subscriptions.js.map +1 -1
  15. package/dist/client/connect/payoutSnapshot.d.ts +28 -0
  16. package/dist/client/connect/payoutSnapshot.d.ts.map +1 -0
  17. package/dist/client/connect/payoutSnapshot.js +81 -0
  18. package/dist/client/connect/payoutSnapshot.js.map +1 -0
  19. package/dist/client/connect/transfers.d.ts.map +1 -1
  20. package/dist/client/connect/transfers.js +13 -32
  21. package/dist/client/connect/transfers.js.map +1 -1
  22. package/dist/client/core/accounts.d.ts +12 -23
  23. package/dist/client/core/accounts.d.ts.map +1 -1
  24. package/dist/client/core/accounts.js +5 -1
  25. package/dist/client/core/accounts.js.map +1 -1
  26. package/dist/client/core/idempotency.d.ts +5 -0
  27. package/dist/client/core/idempotency.d.ts.map +1 -0
  28. package/dist/client/core/idempotency.js +10 -0
  29. package/dist/client/core/idempotency.js.map +1 -0
  30. package/dist/client/index.d.ts +31 -25
  31. package/dist/client/index.d.ts.map +1 -1
  32. package/dist/client/index.js +29 -52
  33. package/dist/client/index.js.map +1 -1
  34. package/dist/client/settlement/allocation.d.ts +30 -0
  35. package/dist/client/settlement/allocation.d.ts.map +1 -0
  36. package/dist/client/settlement/allocation.js +71 -0
  37. package/dist/client/settlement/allocation.js.map +1 -0
  38. package/dist/client/settlement/commissions.d.ts +27 -0
  39. package/dist/client/settlement/commissions.d.ts.map +1 -0
  40. package/dist/client/settlement/commissions.js +69 -0
  41. package/dist/client/settlement/commissions.js.map +1 -0
  42. package/dist/client/settlement/execution.d.ts +27 -0
  43. package/dist/client/settlement/execution.d.ts.map +1 -0
  44. package/dist/client/settlement/execution.js +70 -0
  45. package/dist/client/settlement/execution.js.map +1 -0
  46. package/dist/client/settlement/reconciliation.d.ts +10 -0
  47. package/dist/client/settlement/reconciliation.d.ts.map +1 -0
  48. package/dist/client/settlement/reconciliation.js +73 -0
  49. package/dist/client/settlement/reconciliation.js.map +1 -0
  50. package/dist/client/settlement/settleSale.d.ts +21 -0
  51. package/dist/client/settlement/settleSale.d.ts.map +1 -0
  52. package/dist/client/settlement/settleSale.js +27 -0
  53. package/dist/client/settlement/settleSale.js.map +1 -0
  54. package/dist/client/settlement/verifiedSale.d.ts +25 -0
  55. package/dist/client/settlement/verifiedSale.d.ts.map +1 -0
  56. package/dist/client/settlement/verifiedSale.js +100 -0
  57. package/dist/client/settlement/verifiedSale.js.map +1 -0
  58. package/dist/client/webhooks/asyncHooks.d.ts +5 -0
  59. package/dist/client/webhooks/asyncHooks.d.ts.map +1 -0
  60. package/dist/client/webhooks/asyncHooks.js +20 -0
  61. package/dist/client/webhooks/asyncHooks.js.map +1 -0
  62. package/dist/component/_generated/component.d.ts +115 -0
  63. package/dist/component/_generated/component.d.ts.map +1 -1
  64. package/dist/component/connect/queries.d.ts +30 -1
  65. package/dist/component/connect/queries.d.ts.map +1 -1
  66. package/dist/component/connect/queries.js +19 -2
  67. package/dist/component/connect/queries.js.map +1 -1
  68. package/dist/component/schema.d.ts +67 -0
  69. package/dist/component/schema.js +4 -0
  70. package/dist/component/schema.js.map +1 -1
  71. package/dist/component/settlement/mutations.d.ts +47 -0
  72. package/dist/component/settlement/mutations.d.ts.map +1 -0
  73. package/dist/component/settlement/mutations.js +104 -0
  74. package/dist/component/settlement/mutations.js.map +1 -0
  75. package/dist/component/settlement/queries.d.ts +29 -0
  76. package/dist/component/settlement/queries.d.ts.map +1 -0
  77. package/dist/component/settlement/queries.js +35 -0
  78. package/dist/component/settlement/queries.js.map +1 -0
  79. package/dist/component/settlement/schema.d.ts +99 -0
  80. package/dist/component/settlement/schema.d.ts.map +1 -0
  81. package/dist/component/settlement/schema.js +35 -0
  82. package/dist/component/settlement/schema.js.map +1 -0
  83. package/dist/react/workflows/AffiliatePayoutEditor.d.ts +41 -0
  84. package/dist/react/workflows/AffiliatePayoutEditor.d.ts.map +1 -0
  85. package/dist/react/workflows/AffiliatePayoutEditor.js +80 -0
  86. package/dist/react/workflows/AffiliatePayoutEditor.js.map +1 -0
  87. package/dist/react/workflows/AffiliateRateEditor.d.ts +26 -0
  88. package/dist/react/workflows/AffiliateRateEditor.d.ts.map +1 -0
  89. package/dist/react/workflows/AffiliateRateEditor.js +49 -0
  90. package/dist/react/workflows/AffiliateRateEditor.js.map +1 -0
  91. package/dist/react/workflows/Checkout.d.ts +3 -1
  92. package/dist/react/workflows/Checkout.d.ts.map +1 -1
  93. package/dist/react/workflows/Checkout.js +3 -2
  94. package/dist/react/workflows/Checkout.js.map +1 -1
  95. package/dist/react/workflows/CheckoutForms.d.ts +2 -0
  96. package/dist/react/workflows/CheckoutForms.d.ts.map +1 -1
  97. package/dist/react/workflows/CheckoutForms.js +22 -16
  98. package/dist/react/workflows/CheckoutForms.js.map +1 -1
  99. package/dist/react/workflows/IntegrationSwitch.js +2 -2
  100. package/dist/react/workflows/IntegrationSwitch.js.map +1 -1
  101. package/dist/react/workflows/Pagination.d.ts +32 -0
  102. package/dist/react/workflows/Pagination.d.ts.map +1 -0
  103. package/dist/react/workflows/Pagination.js +49 -0
  104. package/dist/react/workflows/Pagination.js.map +1 -0
  105. package/dist/react/workflows/Payouts.d.ts +3 -18
  106. package/dist/react/workflows/Payouts.d.ts.map +1 -1
  107. package/dist/react/workflows/Payouts.js +2 -2
  108. package/dist/react/workflows/Payouts.js.map +1 -1
  109. package/dist/react/workflows/PlanPricingEditor.d.ts +35 -0
  110. package/dist/react/workflows/PlanPricingEditor.d.ts.map +1 -0
  111. package/dist/react/workflows/PlanPricingEditor.js +64 -0
  112. package/dist/react/workflows/PlanPricingEditor.js.map +1 -0
  113. package/dist/react/workflows/index.d.ts +8 -0
  114. package/dist/react/workflows/index.d.ts.map +1 -1
  115. package/dist/react/workflows/index.js +4 -0
  116. package/dist/react/workflows/index.js.map +1 -1
  117. package/docs/react-workflows-audit.md +19 -0
  118. package/docs/react-workflows.md +94 -3
  119. package/docs/settlement.md +158 -0
  120. package/package.json +6 -4
  121. package/src/client/billing/checkout-idempotency.test.ts +82 -0
  122. package/src/client/billing/checkout.ts +6 -1
  123. package/src/client/billing/providerReads.test.ts +60 -0
  124. package/src/client/billing/providerReads.ts +30 -0
  125. package/src/client/billing/subscriptions.ts +1 -8
  126. package/src/client/connect/payoutSnapshot.test.ts +91 -0
  127. package/src/client/connect/payoutSnapshot.ts +130 -0
  128. package/src/client/connect/transfers.test.ts +15 -4
  129. package/src/client/connect/transfers.ts +13 -42
  130. package/src/client/core/account-idempotency.test.ts +78 -0
  131. package/src/client/core/accounts.ts +18 -25
  132. package/src/client/core/idempotency.test.ts +10 -0
  133. package/src/client/core/idempotency.ts +11 -0
  134. package/src/client/index.ts +84 -103
  135. package/src/client/settlement/allocation.test.ts +98 -0
  136. package/src/client/settlement/allocation.ts +110 -0
  137. package/src/client/settlement/commissions.test.ts +103 -0
  138. package/src/client/settlement/commissions.ts +125 -0
  139. package/src/client/settlement/execution.test.ts +186 -0
  140. package/src/client/settlement/execution.ts +134 -0
  141. package/src/client/settlement/reconciliation.ts +119 -0
  142. package/src/client/settlement/settleSale.ts +59 -0
  143. package/src/client/settlement/verifiedSale.test.ts +139 -0
  144. package/src/client/settlement/verifiedSale.ts +159 -0
  145. package/src/client/webhooks/asyncHooks.ts +38 -0
  146. package/src/client/webhooks/processors.test.ts +9 -9
  147. package/src/component/_generated/api.ts +4 -0
  148. package/src/component/_generated/component.ts +141 -0
  149. package/src/component/connect/queries.ts +26 -2
  150. package/src/component/earnings-totals.test.ts +13 -0
  151. package/src/component/schema.ts +8 -0
  152. package/src/component/settlement/mutations.ts +119 -0
  153. package/src/component/settlement/queries.ts +38 -0
  154. package/src/component/settlement/schema.ts +45 -0
  155. package/src/component/settlement-claims.test.ts +77 -0
  156. package/src/component/transfers.test.ts +48 -0
  157. package/src/react/components/EmbeddedDisputes.render.test.tsx +2 -2
  158. package/src/react/index.payment-element.test.ts +22 -37
  159. package/src/react/workflows/AffiliatePayoutEditor.test.tsx +90 -0
  160. package/src/react/workflows/AffiliatePayoutEditor.tsx +201 -0
  161. package/src/react/workflows/AffiliateRateEditor.test.tsx +36 -0
  162. package/src/react/workflows/AffiliateRateEditor.tsx +92 -0
  163. package/src/react/workflows/Checkout.test.tsx +30 -0
  164. package/src/react/workflows/Checkout.tsx +10 -3
  165. package/src/react/workflows/CheckoutForms.test.tsx +40 -0
  166. package/src/react/workflows/CheckoutForms.tsx +37 -16
  167. package/src/react/workflows/IntegrationSwitch.test.tsx +25 -0
  168. package/src/react/workflows/IntegrationSwitch.tsx +2 -2
  169. package/src/react/workflows/Pagination.test.tsx +53 -0
  170. package/src/react/workflows/Pagination.tsx +93 -0
  171. package/src/react/workflows/Payouts.test.tsx +33 -0
  172. package/src/react/workflows/Payouts.tsx +21 -15
  173. package/src/react/workflows/PlanPricingEditor.test.tsx +79 -0
  174. package/src/react/workflows/PlanPricingEditor.tsx +156 -0
  175. package/src/react/workflows/index.ts +22 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlanPricingEditor.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/PlanPricingEditor.tsx"],"names":[],"mappings":"AACA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,OAAO,CAAC;AAExD,MAAM,MAAM,WAAW,GAAG;IACxB,E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B"}
@@ -0,0 +1,64 @@
1
+ "use client";
2
+ import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ import { useId, useState } from "react";
4
+ import { useWorkflowAction } from "./useWorkflowAction.js";
5
+ /** Unstyled store-plan pricing editor. Authorization and Stripe price creation belong on the server. */
6
+ export function PlanPricingEditor({ plan, onSave, children, }) {
7
+ const id = useId();
8
+ const scope = `${plan.id}:${plan.version}`;
9
+ const initial = {
10
+ scope,
11
+ affiliateShare: String((plan.affiliateBasisPoints ?? 0) / 100),
12
+ monthlyPrice: (plan.monthlyAmount / 100).toFixed(2),
13
+ saleFee: plan.feeBasisPoints === null ? "" : String(plan.feeBasisPoints / 100),
14
+ };
15
+ const [fields, setFields] = useState(initial);
16
+ if (fields.scope !== scope)
17
+ setFields(initial);
18
+ const action = useWorkflowAction(async () => {
19
+ if (!/^\d+(\.\d{1,2})?$/.test(fields.monthlyPrice.trim()))
20
+ throw new Error("Enter a positive monthly price with at most two decimal places.");
21
+ const monthlyAmount = Math.round(Number(fields.monthlyPrice) * 100);
22
+ if (!Number.isSafeInteger(monthlyAmount) || monthlyAmount <= 0)
23
+ throw new Error("Enter a positive monthly price.");
24
+ const feeBasisPoints = fields.saleFee.trim() === ""
25
+ ? null
26
+ : Math.round(Number(fields.saleFee) * 100);
27
+ if (feeBasisPoints !== null &&
28
+ (!/^\d+(\.\d{1,2})?$/.test(fields.saleFee.trim()) ||
29
+ !Number.isSafeInteger(feeBasisPoints) ||
30
+ feeBasisPoints < 0 ||
31
+ feeBasisPoints > 10000))
32
+ throw new Error("Enter a sale fee from 0 to 100%, with at most two decimal places, or leave it blank for Stripe processing only.");
33
+ const affiliateBasisPoints = Math.round(Number(fields.affiliateShare) * 100);
34
+ if (!/^\d+(\.\d{1,2})?$/.test(fields.affiliateShare.trim()) ||
35
+ !Number.isSafeInteger(affiliateBasisPoints) ||
36
+ affiliateBasisPoints < 0 ||
37
+ affiliateBasisPoints > 10000)
38
+ throw new Error("Enter an affiliate payout from 0 to 100%, with at most two decimal places.");
39
+ await onSave({
40
+ monthlyAmount,
41
+ feeBasisPoints,
42
+ affiliateBasisPoints,
43
+ expectedVersion: plan.version,
44
+ });
45
+ return "Pricing saved. Existing subscriptions keep their monthly price.";
46
+ }, plan.id);
47
+ const state = {
48
+ ...fields,
49
+ setMonthlyPrice: (monthlyPrice) => setFields((previous) => ({ ...previous, monthlyPrice })),
50
+ setSaleFee: (saleFee) => setFields((previous) => ({ ...previous, saleFee })),
51
+ setAffiliateShare: (affiliateShare) => setFields((previous) => ({ ...previous, affiliateShare })),
52
+ save: action.run,
53
+ isPending: action.isPending,
54
+ error: action.error,
55
+ message: action.result,
56
+ };
57
+ if (children)
58
+ return _jsx(_Fragment, { children: children(state) });
59
+ return (_jsxs("form", { onSubmit: (event) => {
60
+ event.preventDefault();
61
+ void state.save();
62
+ }, "aria-label": `${plan.name} pricing`, children: [_jsx("h3", { children: plan.name }), _jsx("label", { htmlFor: `${id}-monthly`, children: "Monthly price (USD)" }), _jsx("input", { id: `${id}-monthly`, inputMode: "decimal", value: state.monthlyPrice, disabled: state.isPending, onChange: (event) => state.setMonthlyPrice(event.target.value) }), _jsx("label", { htmlFor: `${id}-fee`, children: "Sale fee (%)" }), _jsx("input", { id: `${id}-fee`, inputMode: "decimal", value: state.saleFee, disabled: state.isPending, onChange: (event) => state.setSaleFee(event.target.value) }), _jsx("p", { children: "Leave the sale fee blank for Stripe processing only. The seller always covers actual Stripe processing costs." }), _jsx("label", { htmlFor: `${id}-affiliate`, children: "Affiliate payout (%)" }), _jsx("input", { id: `${id}-affiliate`, inputMode: "decimal", value: state.affiliateShare, disabled: state.isPending, onChange: (event) => state.setAffiliateShare(event.target.value) }), _jsx("p", { children: "Percentage of a referred sale after the sale fee. The seller receives the remainder." }), state.error && _jsx("p", { role: "alert", children: state.error }), state.message && _jsx("p", { role: "status", children: state.message }), _jsx("button", { type: "submit", disabled: state.isPending, children: state.isPending ? "Saving…" : "Save pricing" })] }));
63
+ }
64
+ //# sourceMappingURL=PlanPricingEditor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PlanPricingEditor.js","sourceRoot":"","sources":["../../../src/react/workflows/PlanPricingEditor.tsx"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AACb,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAkB,MAAM,OAAO,CAAC;AACxD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAgC3D,wGAAwG;AACxG,MAAM,UAAU,iBAAiB,CAAC,EAChC,IAAI,EACJ,MAAM,EACN,QAAQ,GACe;IACvB,MAAM,EAAE,GAAG,KAAK,EAAE,CAAC;IACnB,MAAM,KAAK,GAAG,GAAG,IAAI,CAAC,EAAE,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAG;QACd,KAAK;QACL,cAAc,EAAE,MAAM,CAAC,CAAC,IAAI,CAAC,oBAAoB,IAAI,CAAC,CAAC,GAAG,GAAG,CAAC;QAC9D,YAAY,EAAE,CAAC,IAAI,CAAC,aAAa,GAAG,GAAG,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC;QACnD,OAAO,EACL,IAAI,CAAC,cAAc,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,cAAc,GAAG,GAAG,CAAC;KACxE,CAAC;IACF,MAAM,CAAC,MAAM,EAAE,SAAS,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC9C,IAAI,MAAM,CAAC,KAAK,KAAK,KAAK;QAAE,SAAS,CAAC,OAAO,CAAC,CAAC;IAC/C,MAAM,MAAM,GAAG,iBAAiB,CAAC,KAAK,IAAI,EAAE;QAC1C,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC;YACvD,MAAM,IAAI,KAAK,CACb,iEAAiE,CAClE,CAAC;QAC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,CAAC,MAAM,CAAC,KAAK,CAAC,GAC9D,EACF,gBAAO,OAAO,EAAE,GAAG,EAAE,MAAM,6BAAsB,EACjD,gBACE,EAAE,EAAE,GAAG,EAAE,MAAM,EACf,SAAS,EAAC,SAAS,EACnB,KAAK,EAAE,KAAK,CAAC,OAAO,EACpB,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,UAAU,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GACzD,EACF,wIAGI,EACJ,gBAAO,OAAO,EAAE,GAAG,EAAE,YAAY,qCAA8B,EAC/D,gBACE,EAAE,EAAE,GAAG,EAAE,YAAY,EACrB,SAAS,EAAC,SAAS,EACnB,KAAK,EAAE,KAAK,CAAC,cAAc,EAC3B,QAAQ,EAAE,KAAK,CAAC,SAAS,EACzB,QAAQ,EAAE,CAAC,KAAK,EAAE,EAAE,CAAC,KAAK,CAAC,iBAAiB,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,GAChE,EACF,+GAGI,EACH,KAAK,CAAC,KAAK,IAAI,YAAG,IAAI,EAAC,OAAO,YAAE,KAAK,CAAC,KAAK,GAAK,EAChD,KAAK,CAAC,OAAO,IAAI,YAAG,IAAI,EAAC,QAAQ,YAAE,KAAK,CAAC,OAAO,GAAK,EACtD,iBAAQ,IAAI,EAAC,QAAQ,EAAC,QAAQ,EAAE,KAAK,CAAC,SAAS,YAC5C,KAAK,CAAC,SAAS,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,cAAc,GACtC,IACJ,CACR,CAAC;AACJ,CAAC"}
@@ -67,4 +67,12 @@ export { PayoutOverview } from "./Overview.js";
67
67
  export type { PayoutOverviewProps, PayoutOverviewRow } from "./Overview.js";
68
68
  export { ChargeSummary, PaymentDetails } from "./Financials.js";
69
69
  export type { ChargeSummaryProps, PaymentDetailsProps, PaymentDetailsPayment, PaymentDetailsState, } from "./Financials.js";
70
+ export { Pagination, useCursorPagination } from "./Pagination.js";
71
+ export type { PaginationProps } from "./Pagination.js";
72
+ export { PlanPricingEditor } from "./PlanPricingEditor.js";
73
+ export type { PlanPricing, PlanPricingUpdate, PlanPricingEditorState, PlanPricingEditorProps, } from "./PlanPricingEditor.js";
74
+ export { AffiliateRateEditor } from "./AffiliateRateEditor.js";
75
+ export type { AffiliateRateUpdate, AffiliateRateEditorProps, AffiliateRateEditorState, } from "./AffiliateRateEditor.js";
76
+ export { AffiliatePayoutEditor } from "./AffiliatePayoutEditor.js";
77
+ export type { AffiliateCommissionTerm, AffiliatePayoutEditorProps, AffiliatePayoutEditorState, AffiliatePayoutUpdate, } from "./AffiliatePayoutEditor.js";
70
78
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/react/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAC3D,YAAY,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,YAAY,EACV,aAAa,EACb,YAAY,EACZ,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,mBAAmB,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,iBAAiB,EACjB,mBAAmB,EACnB,iBAAiB,GAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,EACV,YAAY,EACZ,gBAAgB,EAChB,kBAAkB,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACvC,YAAY,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CAAC;AAC/D,YAAY,EACV,mBAAmB,EACnB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC;AACnE,YAAY,EACV,uBAAuB,EACvB,0BAA0B,EAC1B,0BAA0B,EAC1B,qBAAqB,GACtB,MAAM,4BAA4B,CAAC"}
@@ -35,4 +35,8 @@ export { DEFAULT_CONNECT_COUNTRIES } from "./Onboarding.js";
35
35
  export { PayoutHistory } from "./Payouts.js";
36
36
  export { PayoutOverview } from "./Overview.js";
37
37
  export { ChargeSummary, PaymentDetails } from "./Financials.js";
38
+ export { Pagination, useCursorPagination } from "./Pagination.js";
39
+ export { PlanPricingEditor } from "./PlanPricingEditor.js";
40
+ export { AffiliateRateEditor } from "./AffiliateRateEditor.js";
41
+ export { AffiliatePayoutEditor } from "./AffiliatePayoutEditor.js";
38
42
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/react/workflows/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AASzC,OAAO,EACL,oBAAoB,EACpB,iBAAiB,EACjB,YAAY,GACb,MAAM,oBAAoB,CAAC;AAM5B,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAMvC,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAQvC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAUrE,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAM7C,OAAO,EACL,KAAK,EACL,QAAQ,EACR,aAAa,EACb,aAAa,EACb,aAAa,GACd,MAAM,kBAAkB,CAAC;AA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c,CAAC;AACnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,cAAc,CAAC;AAErD,OAAO,EAAE,QAAQ,EAAE,eAAe,EAAE,MAAM,eAAe,CAAC;AAE1D,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAC;AACpE,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAMvD,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAKjE,OAAO,EAAE,yBAAyB,EAAE,MAAM,iBAAiB,CAAC;AAC5D,OAAO,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAE7C,OAAO,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAE/C,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAOhE,OAAO,EAAE,UAAU,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAElE,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAO3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAM/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAC"}
@@ -30,6 +30,9 @@ uses render props or companion hooks to apply shadcn styling.
30
30
  | Affiliate earnings | `Earnings`, `EarningsSummary` |
31
31
  | Affiliate referred sales | `ReferredSales`, store attribution and commission |
32
32
  | Affiliate links | `useReferralLinks`, `ReferralLinks`, `ClipboardButton` |
33
+ | Seller affiliate payout rules | `AffiliatePayoutEditor` with amount, percentage/currency mode, inherited term, Save/Clear, and async feedback |
34
+ | Admin store plans | `PlanPricingEditor` and `AffiliatePayoutEditor`; the app binds Stripe pricing and inherited commission policy |
35
+ | Affiliate sales pagination | `Pagination` and `useCursorPagination`; the backend supplies indexed cursors |
33
36
  | Admin overview | `Overview` |
34
37
  | Admin subscriptions | `Subscriptions`, `useSubscriptionFilter` |
35
38
  | Admin webhooks | `WebhookEvents`, `useWebhookFilters` |
@@ -86,3 +89,19 @@ affiliate link copying, dispute evidence, and partial/remaining-balance refunds.
86
89
  The tests use Stripe sandbox objects and await action results or webhook state.
87
90
  Native public-entry tests also render the workflows without example providers,
88
91
  CSS classes, inline styles, or example URLs.
92
+
93
+ ## Pricing and affiliate updates
94
+
95
+ Seller product/price rows, store-wide defaults, admin plan rows, and platform-wide
96
+ defaults all use the public `AffiliatePayoutEditor`. It owns percentage/fixed
97
+ amount validation, commission-term selection, clear/inherit behavior, edit
98
+ versions, pending state, and errors. `PlanPricingEditor` owns the monthly-price
99
+ and sale-fee form. The example binds both to Convex functions and supplies shadcn
100
+ markup. Rule resolution, Stripe metadata, first-invoice claims, fee accounting,
101
+ and transfer execution remain backend application policy.
102
+
103
+ Browser regression checks cover equal cards/layouts in API and package views,
104
+ referral-sales pagination, inline payout controls, and plan pricing. Sandbox QA
105
+ covers all five checkout integrations, declined-card retries, inherited and fixed
106
+ commissions, and Forever/One-time subscription renewals using Stripe test clocks.
107
+ Existing subscriptions keep their monthly price and saved commission term.
@@ -52,8 +52,11 @@ function Purchase({ publishableKey, priceId, createSession }) {
52
52
 
53
53
  The callback returns `{ stripeSessionId, clientSecret?, url? }`. It must return
54
54
  `url` for `redirect` and `clientSecret` for the other session modes. Use the
55
- request ID for server idempotency. A user-triggered retry creates a new request
56
- ID; also enforce application-level duplicate-order protection on the server.
55
+ request ID for server idempotency. Retries and rerenders preserve the same ID.
56
+ Changing `orderKey` or checkout mode starts a new logical request. Pass a persisted
57
+ `requestId` prop to preserve identity across unmounts or page reloads. Forward it
58
+ to your authenticated server and Stripe request options; also enforce durable
59
+ application-level duplicate-order protection.
57
60
 
58
61
  | Mode | Stripe integration | Tradeoff |
59
62
  | ---------------- | ------------------------------------- | ---------------------------------------------------------------------- |
@@ -72,6 +75,10 @@ Use `renderForm` on the custom and PaymentIntent modes to render your own email
72
75
  input, `paymentElement`, error, and submit button. The preview `form` mode renders
73
76
  Stripe's form and does not use that renderer. `children` replaces the outer
74
77
  checkout frame and receives `content`, `isLoading`, `error`, and `retry`.
78
+ Respect `state.emailReadOnly` on your email input. Custom Checkout uses the
79
+ email Stripe supplied when the session loaded and skips `updateEmail` for that
80
+ session. Guest sessions without an email collect it before confirmation and
81
+ keep it editable if a payment attempt fails.
75
82
  The lower-level `CheckoutElementsForm`, `PaymentIntentForm`, and `CheckoutForm`
76
83
  are also exported for an existing client secret.
77
84
 
@@ -79,7 +86,14 @@ Only a server-confirmed payment or checkout session should grant access to the
79
86
  product. Use `PaymentReceipt` or `CheckoutStatus` with webhook-backed query data;
80
87
  a browser return URL alone does not prove payment.
81
88
 
82
- ## Headless or Stripe embedded
89
+ ## Via API, BetterStripe components, or Stripe embedded
90
+
91
+ The switch labels are **via API**, **BetterStripe components**, **Stripe embedded**,
92
+ and **Stripe hosted**. BetterStripe components are the unstyled exports from this
93
+ package; Stripe embedded views mount Stripe's Connect UI. The internal mode keys
94
+ remain `headless`, `components`, `embedded`, and `hosted` for compatibility, including
95
+ existing `?example=headless` links. The package's native components accept render
96
+ props so the example can match the API view's cards and layout.
83
97
 
84
98
  `Account`, `Onboarding`, `Disputes`, `Refunds`, `Earnings`, and `Payouts` accept
85
99
  `presentation="embedded"` with Connect session props. Their default headless
@@ -232,3 +246,80 @@ available and pending Stripe balances shown by `Payouts`.
232
246
  shared by its account pages and native `Onboarding`. Supply `countries` to limit
233
247
  or expand the UI for your platform. This default is not a complete list of
234
248
  Stripe-supported countries; your server must validate account eligibility.
249
+
250
+ ## Cursor pagination
251
+
252
+ Use `useCursorPagination(accountId)` to keep a page number, current cursor, and
253
+ Previous/Next history. Pass `cursor` to your backend's paginated query and call
254
+ `next(result.continueCursor)` only when `result.isDone` is false. Changing the
255
+ scope key resets the history to page 1.
256
+
257
+ `Pagination` renders unstyled Previous/Next buttons and an announced page number,
258
+ or accepts a render function for your design system. Supply `canPrevious`,
259
+ `canNext`, `isLoading`, `onPrevious`, and `onNext`. Navigation is disabled while
260
+ loading. The example's affiliate sales page uses this with the component query
261
+ `connect.queries.paginateTransfersByAccount`, which returns newest-first cursor
262
+ pages scoped to the recipient account. Earnings totals still use aggregate
263
+ queries independently of pagination.
264
+
265
+ ## Store-plan pricing editor
266
+
267
+ `PlanPricingEditor` accepts a `plan` with `id`, `name`, `monthlyAmount` in minor
268
+ units, nullable `feeBasisPoints`, and `version`, plus `onSave(update)`. The update
269
+ contains `monthlyAmount`, `feeBasisPoints`, and `expectedVersion`. Blank fees
270
+ mean processing-only. Native fields are unstyled; use the render prop to supply
271
+ your design system. Server-side authorization, fee floors, Stripe Price creation,
272
+ and conflict checks belong in your backend. Existing subscription migration is
273
+ an application policy, not an automatic side effect of this editor.
274
+
275
+ `PlanPricingEditor` also supports optional `affiliateBasisPoints` on the plan and
276
+ save update, defaulting to 0. Its render state exposes `affiliateShare` and
277
+ `setAffiliateShare`. The native field is labeled Affiliate payout (%), accepts
278
+ 0 through 100 with at most two decimal places, and saves integer basis points.
279
+ Omitting the field in an older backend request preserves an existing configured
280
+ rate. The example applies this rate after sale fees and records it with each
281
+ settled sale.
282
+
283
+ ## Product and subscription affiliate-rate editor
284
+
285
+ `AffiliateRateEditor` accepts `scopeKey`, nullable `affiliateBasisPoints`,
286
+ `effectiveBasisPoints`, `source` of global/store/plan/product/price/none, `version`, and `onSave`.
287
+ Its save update contains nullable `affiliateBasisPoints` and `expectedVersion`.
288
+ Blank input means inherit, zero disables commission, and percentages support
289
+ 0 to 100 with two decimal places. Use its native unstyled form or render state
290
+ `percentage`, `setPercentage`, `effectiveLabel`, `save`, `isPending`, `error`,
291
+ and `message` to supply styled controls. The backend must verify ownership and
292
+ resolve price overrides before product overrides and plan defaults. The example
293
+ uses the current subscription price on renewals and preserves settled economics.
294
+
295
+ ## Percentage or fixed affiliate payouts
296
+
297
+ `AffiliatePayoutEditor` is the unstyled editor used inline by the example's seller
298
+ product and price rows and admin store-plan rows. Supply `scopeKey`, nullable
299
+ `affiliateBasisPoints`, optional nullable `affiliateFixedAmount`, effective values,
300
+ `version`, `currency`, and `onSave`. Fixed amounts are major currency units,
301
+ not cents. The save callback receives both nullable fields and `expectedVersion`;
302
+ only one payout field is non-null. Blank means inherit; explicit zero disables.
303
+
304
+ The native form includes a number input, `%`/currency-symbol toggle, Save, and X.
305
+ X saves null for both fields to clear the override. `currency` defaults to USD
306
+ and controls the display symbol. A render prop exposes `value`, `mode`, `setValue`,
307
+ `setMode`, `currencySymbol`, `effectiveLabel`, `save`, `clear`, `isPending`, `error`,
308
+ and `message` so applications can supply their own markup. Server code must
309
+ resolve defaults, validate ownership and versions, convert major amounts into
310
+ Stripe minor units, and cap fixed payouts at proceeds after fees. The example
311
+ uses a nominal fixed amount per sale currency; it does not perform FX conversion.
312
+
313
+ Affiliate payout sources can be `global`, `store`, `plan`, `product`, `price`, or
314
+ `none`. Unset app rules fall back to zero. The example resolves price → product →
315
+ store-wide → plan → platform-wide → 0, and distinguishes explicit zero from null
316
+ inheritance. Both global controls use the same package editor as the row controls.
317
+
318
+ `AffiliatePayoutEditor` also exposes an optional `affiliateCommissionTerm`
319
+ (`"forever"`, `"one_time"`, or `null` to inherit) and
320
+ `effectiveCommissionTerm`. Its render state includes `term` and `setTerm`, and
321
+ `onSave` receives the selected term together with the payout amount. Clear
322
+ removes both overrides. The example saves the resolved subscription term in
323
+ Stripe metadata at checkout and claims the first paid invoice atomically in its
324
+ Convex ledger; the UI component does not itself create transfers or process
325
+ renewals.
@@ -0,0 +1,158 @@
1
+ # Verified settlement and recipient payouts
2
+
3
+ BetterStripe owns provider reads, immutable settlement claims, transfer execution,
4
+ and recovery. Your server authenticates the caller, resolves recipient accounts,
5
+ selects rates, and authorizes the allocation. Never accept these values directly
6
+ from a browser. Amounts below are integer minor units in one currency.
7
+
8
+ ## Read, allocate, settle
9
+
10
+ ```ts
11
+ import { allocateSale } from "@fantastic.dev/better-stripe";
12
+
13
+ const sale = await stripe.getVerifiedSale(ctx, {
14
+ paymentIntentId,
15
+ invoiceId, // Required for a subscription payment
16
+ subscriptionId,
17
+ });
18
+ if (sale.status !== "ready") {
19
+ // Only retry when sale.retryable is true. Missing processing fees are not zero.
20
+ return sale;
21
+ }
22
+ const allocation = allocateSale({
23
+ gross: sale.gross,
24
+ processingFee: sale.processingFee,
25
+ feeBasisPoints: 900,
26
+ creatorAccountId,
27
+ affiliate: { destinationAccountId: affiliateAccountId, basisPoints: 2000 },
28
+ collaborators: [
29
+ { destinationAccountId: collaboratorAccountId, basisPoints: 2500 },
30
+ ],
31
+ });
32
+ return stripe.settleSale(ctx, {
33
+ paymentIntentId,
34
+ invoiceId,
35
+ subscriptionId,
36
+ allocation: {
37
+ gross: sale.gross,
38
+ currency: sale.currency,
39
+ processingFee: sale.processingFee,
40
+ platformNet: allocation.platformNet,
41
+ transfers: allocation.transfers,
42
+ },
43
+ });
44
+ ```
45
+
46
+ `allocateSale` is pure. The inclusive sale fee is the greater of actual Stripe
47
+ processing and the selected gross percentage. The platform keeps the difference.
48
+ An affiliate receives a percentage of the amount after that fee, or a
49
+ `fixedAmount` in minor units, capped at the amount available. Collaborators
50
+ receive their percentages of the creator remainder. Rounding residue stays with
51
+ the creator. Omit the affiliate for zero commission; no application rate is built in.
52
+
53
+ `getVerifiedSale` expands the charge's actual balance transaction, verifies
54
+ currency and paid invoice linkage, and reads the subscription's current price.
55
+ It refuses refunded/disputed charges, converted settlement currencies, partial
56
+ invoice payments, and multi-price subscriptions rather than guessing allocations.
57
+ A `pending` result carries a retryable reason; `not_payable` must not trigger a transfer.
58
+
59
+ `settleSale` verifies the provider data again, then pins the original allocation
60
+ by charge. Retries use that original allocation even if rates have changed. The
61
+ shared transfer engine records legs in the existing component transfer ledger;
62
+ there is no required application `storeSales` table. Optional signed
63
+ `adjustmentAmount` accounts for an authorized application credit or recovered
64
+ cost; it must reconcile with all other amounts. An optional `onSettled` callback
65
+ runs after execution and can run again on retries: make application writes
66
+ idempotent by source charge.
67
+
68
+ Provider transfers carry the source charge and recipient role. If Stripe succeeds
69
+ and persistence fails, retries reconcile provider records before creating missing
70
+ legs, including legacy ungrouped transfers. Incomplete provider history fails
71
+ closed. Existing refund/dispute reversal APIs recover these original legs too.
72
+ Stripe API idempotency is an additional safeguard, not the only recovery record.
73
+ Do not delete financial component records while payments can be retried or reversed.
74
+
75
+ The Vite example exposes a [fee-first allocation preview](http://localhost:5173/demo/allocation)
76
+ from Admin → Testing Utilities. Its illustrative inputs use the public helper
77
+ and the package React `SplitBreakdown`; they do not alter store settings.
78
+
79
+ ## Subscription commission terms
80
+
81
+ ```ts
82
+ const commission = await stripe.selectCommissionInvoice(ctx, {
83
+ subscriptionId,
84
+ invoiceId,
85
+ affiliateAccountId, // Server-validated identity
86
+ term: "one_time", // Default: "forever"
87
+ });
88
+ ```
89
+
90
+ This selects eligibility, not a rate or a money movement. `one_time` selects the
91
+ earliest paid nonzero invoice from complete provider history, even if a renewal
92
+ arrives first. Failed invoices and zero-value trials do not consume eligibility.
93
+ The component pins the term and affiliate identity. Refunds do not reset the
94
+ first invoice. A replay returns the same `claimKey` and eligibility so interrupted
95
+ settlement can finish; deduplicate actual payment execution with `settleSale`.
96
+ If historical pagination exceeds the configured bound, selection refuses to guess.
97
+
98
+ The Vite example migrates its old subscription claims with
99
+ `pnpm exec convex run commissionMigration:run '{}'` from `example/`. Repeat until
100
+ it returns `0`. Run this after deploying the new component and before replaying
101
+ historical subscription events. The migration preserves terms and first invoices;
102
+ its batch deletes are transactional with component writes.
103
+
104
+ ## Payout snapshots
105
+
106
+ ```ts
107
+ const snapshot = await stripe.getPayoutSnapshot(ctx, {
108
+ stripeAccountId,
109
+ cursor,
110
+ limit: 25,
111
+ });
112
+ ```
113
+
114
+ The snapshot contains per-currency `balances`, cursor-paginated `payouts`,
115
+ deduplicated pending/in-transit `upcoming`, and `nextCursor`. Arrival dates are
116
+ provider estimates, nullable, in milliseconds. `upcomingComplete: false` means
117
+ only a bounded preview was retrieved. An unavailable account returns
118
+ `status: "not_ready"` with empty data and a reason; it does not imply a zero balance.
119
+ The React `PayoutSnapshot` contract accepts this shape directly.
120
+
121
+ A transfer moves money to a connected account; a payout moves that account's
122
+ available balance to its external bank. These boundaries have different controls.
123
+
124
+ ## Combined payout minimums: supported boundary
125
+
126
+ A single user-level recipient account naturally combines creator and affiliate
127
+ funds across communities. Keep currency balances separate. Only available funds
128
+ are mature; Stripe's available balance already reflects provider debits and known
129
+ reversals. A platform source ledger is still necessary to explain which earnings
130
+ remain owed and distinguish unrelated funds in an already-mixed account.
131
+
132
+ The supported default is Stripe-managed automatic payouts with no additional
133
+ application minimum. Stripe enforces its applicable currency/method floor. The
134
+ Balance Settings API does not expose a numeric payout-floor field; this package
135
+ does not invent one. `minimum_balance_by_currency` is a retained reserve after a
136
+ payout, **not a minimum payout trigger**. [Stripe reserve documentation](https://docs.stripe.com/payouts/minimum-balances-for-automatic-payouts).
137
+
138
+ Custom application thresholds need a separately controlled release boundary:
139
+
140
+ - Before transfer: retain funds on the platform and maintain a durable payable
141
+ ledger, maturity, adjustments, and release claims. This changes settlement timing
142
+ and must account for existing transferred balances.
143
+ - Before bank payout: use a manual payout schedule where the platform has
144
+ permission, and run an automatic application job. Otherwise provider automatic
145
+ sweeps can bypass the application threshold. A retained reserve cannot fix that.
146
+
147
+ Manual holding limits depend on country: Thailand 10 days, US 2 years, other
148
+ countries generally 90 days. Schedule permissions depend on account controls and
149
+ liability. Negative balances, refunds, and in-flight payouts must reduce any
150
+ release amount; source-category thresholds and currency netting are unsafe.
151
+ See [payout schedule permissions](https://docs.stripe.com/connect/manage-payout-schedule)
152
+ and [manual payout restrictions](https://docs.stripe.com/connect/manual-payouts).
153
+
154
+ Custom threshold enforcement is not provided by the snapshot or settlement APIs.
155
+ It requires a selected retention boundary and migration policy. Applications must
156
+ not describe a displayed threshold as enforced while Stripe controls automatic
157
+ payouts. A numeric below/exact/above provider-floor demonstration is unavailable
158
+ without a supported provider floor read; surface this capability limitation.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fantastic.dev/better-stripe",
3
- "version": "0.8.1",
3
+ "version": "0.10.0",
4
4
  "description": "A Convex component for Stripe V2 Accounts API integration.",
5
5
  "keywords": [
6
6
  "stripe",
@@ -58,6 +58,7 @@
58
58
  "dist",
59
59
  "src",
60
60
  "docs/react-workflows.md",
61
+ "docs/settlement.md",
61
62
  "docs/react-workflows-audit.md",
62
63
  "CHANGELOG.md",
63
64
  "MIGRATION.md"
@@ -103,12 +104,15 @@
103
104
  "@stripe/react-connect-js": "^3.4.4",
104
105
  "@stripe/react-stripe-js": "^7.0.0",
105
106
  "@stripe/stripe-js": "^10.0.0",
107
+ "convex-helpers": "^0.1.128",
106
108
  "stripe": "~23.0.0"
107
109
  },
108
110
  "devDependencies": {
109
111
  "@convex-dev/eslint-plugin": "^5.0.0",
110
112
  "@edge-runtime/vm": "^5.0.0",
111
113
  "@fantastic.dev/repo-gates": "^0.4.0",
114
+ "@shadcn/lint": "0.1.5",
115
+ "@shadscan/cli": "0.7.0",
112
116
  "@testing-library/jest-dom": "^7.0.1",
113
117
  "@testing-library/react": "^16.3.3",
114
118
  "@testing-library/user-event": "^14.6.7",
@@ -127,9 +131,7 @@
127
131
  "pretty-quick": "^4.2.2",
128
132
  "typescript": "npm:@typescript/typescript6@^6.0.2",
129
133
  "typescript-eslint": "^8.71.1",
130
- "vitest": "^5.0.3",
131
- "@shadcn/lint": "0.1.5",
132
- "@shadscan/cli": "0.7.0"
134
+ "vitest": "^5.0.3"
133
135
  },
134
136
  "peerDependencies": {
135
137
  "convex": "^1.29.3",
@@ -0,0 +1,82 @@
1
+ import { expect, it, vi } from "vitest";
2
+ import type Stripe from "stripe";
3
+ import { componentsGeneric } from "convex/server";
4
+ import type { Component, RunCtx } from "../helpers.js";
5
+ import { createCheckoutSession } from "./checkout.js";
6
+ function makeStripe() {
7
+ return {
8
+ prices: {
9
+ retrieve: vi.fn().mockRejectedValue({ code: "resource_missing" }),
10
+ },
11
+ checkout: { sessions: { create: vi.fn() } },
12
+ };
13
+ }
14
+ function makeCtx() {
15
+ return {
16
+ runQuery: vi.fn().mockResolvedValue(null),
17
+ runMutation: vi.fn().mockResolvedValue(undefined),
18
+ } as unknown as RunCtx & { runMutation: ReturnType<typeof vi.fn> };
19
+ }
20
+ const makeComponent = () =>
21
+ componentsGeneric().betterStripe as unknown as Component;
22
+ const asStripe = (value: ReturnType<typeof makeStripe>) =>
23
+ value as unknown as Stripe;
24
+ function sessionResponse(overrides: Record<string, unknown> = {}) {
25
+ return {
26
+ id: "cs_test",
27
+ status: "open",
28
+ client_secret: "secret",
29
+ url: null,
30
+ ...overrides,
31
+ };
32
+ }
33
+
34
+ it("forwards an order key as request options and recovers persistence without another session", async () => {
35
+ const stripe = makeStripe(),
36
+ ctx = makeCtx();
37
+ const cache = new Map<
38
+ string,
39
+ { params: string; session: ReturnType<typeof sessionResponse> }
40
+ >();
41
+ stripe.checkout.sessions.create.mockImplementation(
42
+ async (params, options?: { idempotencyKey?: string }) => {
43
+ const key = options?.idempotencyKey ?? `new-${cache.size}`,
44
+ prior = cache.get(key),
45
+ serialized = JSON.stringify(params);
46
+ if (prior && prior.params !== serialized)
47
+ throw new Error("idempotency_error");
48
+ if (prior) return prior.session;
49
+ const session = sessionResponse({ id: `cs_${cache.size}` });
50
+ cache.set(key, { params: serialized, session });
51
+ return session;
52
+ },
53
+ );
54
+ const opts = {
55
+ userId: "buyer",
56
+ stripePriceId: "price_1",
57
+ mode: "payment" as const,
58
+ returnUrl: "https://app.test/receipt",
59
+ idempotencyKey: "order:one",
60
+ };
61
+ ctx.runMutation.mockRejectedValueOnce(new Error("persistence unavailable"));
62
+ await expect(
63
+ createCheckoutSession(asStripe(stripe), makeComponent(), ctx, opts),
64
+ ).rejects.toThrow("persistence unavailable");
65
+ await createCheckoutSession(asStripe(stripe), makeComponent(), ctx, opts);
66
+ expect(cache.size).toBe(1);
67
+ expect(stripe.checkout.sessions.create).toHaveBeenLastCalledWith(
68
+ expect.anything(),
69
+ { idempotencyKey: "order:one" },
70
+ );
71
+ await createCheckoutSession(asStripe(stripe), makeComponent(), ctx, {
72
+ ...opts,
73
+ idempotencyKey: "order:two",
74
+ });
75
+ expect(cache.size).toBe(2);
76
+ await expect(
77
+ createCheckoutSession(asStripe(stripe), makeComponent(), ctx, {
78
+ ...opts,
79
+ stripePriceId: "price_other",
80
+ }),
81
+ ).rejects.toThrow("idempotency_error");
82
+ });
@@ -1,3 +1,4 @@
1
+ import { idempotencyOptions } from "../core/idempotency.js";
1
2
  import type Stripe from "stripe";
2
3
 
3
4
  import type { SplitRecipient } from "../../component/lib/fees.js";
@@ -110,6 +111,7 @@ export async function createCheckoutSession(
110
111
  component: Component,
111
112
  ctx: RunCtx,
112
113
  opts: {
114
+ idempotencyKey?: string;
113
115
  userId: string;
114
116
  orgId?: string;
115
117
  stripePriceId: string;
@@ -338,7 +340,10 @@ export async function createCheckoutSession(
338
340
  await assertPlatformPrice(stripe, component, ctx, finalPriceId);
339
341
  }
340
342
 
341
- const session = await stripe.checkout.sessions.create(finalSessionParams);
343
+ const requestOptions = idempotencyOptions(opts.idempotencyKey);
344
+ const session = requestOptions
345
+ ? await stripe.checkout.sessions.create(finalSessionParams, requestOptions)
346
+ : await stripe.checkout.sessions.create(finalSessionParams);
342
347
 
343
348
  await runMutationOrThrow(
344
349
  ctx,