@fantastic.dev/better-stripe 0.37.1 → 0.39.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 (210) hide show
  1. package/CHANGELOG.md +53 -0
  2. package/MIGRATION.md +9 -0
  3. package/README.md +25 -1
  4. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +506 -2
  5. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  6. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +253 -1
  7. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  8. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts +506 -2
  9. package/dist/client/connect/payoutLargeAdoptionTestHelpers.d.ts.map +1 -1
  10. package/dist/client/connect/payoutSyncTestHelpers.d.ts +253 -1
  11. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  12. package/dist/client/core/accountCapabilities.d.ts +20 -0
  13. package/dist/client/core/accountCapabilities.d.ts.map +1 -0
  14. package/dist/client/core/accountCapabilities.js +7 -0
  15. package/dist/client/core/accountCapabilities.js.map +1 -0
  16. package/dist/client/core/accountConfigurations.d.ts +46 -0
  17. package/dist/client/core/accountConfigurations.d.ts.map +1 -0
  18. package/dist/client/core/accountConfigurations.js +99 -0
  19. package/dist/client/core/accountConfigurations.js.map +1 -0
  20. package/dist/client/core/accountLinks.d.ts +29 -2
  21. package/dist/client/core/accountLinks.d.ts.map +1 -1
  22. package/dist/client/core/accountLinks.js +56 -4
  23. package/dist/client/core/accountLinks.js.map +1 -1
  24. package/dist/client/core/accounts.d.ts +2 -36
  25. package/dist/client/core/accounts.d.ts.map +1 -1
  26. package/dist/client/core/accounts.js +3 -73
  27. package/dist/client/core/accounts.js.map +1 -1
  28. package/dist/client/core/billingPortalClient.d.ts +14 -0
  29. package/dist/client/core/billingPortalClient.d.ts.map +1 -0
  30. package/dist/client/core/billingPortalClient.js +18 -0
  31. package/dist/client/core/billingPortalClient.js.map +1 -0
  32. package/dist/client/costRecovery-invoices.d.ts +4 -4
  33. package/dist/client/costRecovery.d.ts +19 -1
  34. package/dist/client/costRecovery.d.ts.map +1 -1
  35. package/dist/client/costRecovery.js +4 -0
  36. package/dist/client/costRecovery.js.map +1 -1
  37. package/dist/client/financialOutcomes/adapters.d.ts +18 -0
  38. package/dist/client/financialOutcomes/adapters.d.ts.map +1 -0
  39. package/dist/client/financialOutcomes/adapters.js +60 -0
  40. package/dist/client/financialOutcomes/adapters.js.map +1 -0
  41. package/dist/client/financialOutcomes/contracts.d.ts +42 -0
  42. package/dist/client/financialOutcomes/contracts.d.ts.map +1 -0
  43. package/dist/client/financialOutcomes/contracts.js +39 -0
  44. package/dist/client/financialOutcomes/contracts.js.map +1 -0
  45. package/dist/client/financialOutcomes/errors.d.ts +6 -0
  46. package/dist/client/financialOutcomes/errors.d.ts.map +1 -0
  47. package/dist/client/financialOutcomes/errors.js +22 -0
  48. package/dist/client/financialOutcomes/errors.js.map +1 -0
  49. package/dist/client/financialOutcomes/index.d.ts +6 -0
  50. package/dist/client/financialOutcomes/index.d.ts.map +1 -0
  51. package/dist/client/financialOutcomes/index.js +4 -0
  52. package/dist/client/financialOutcomes/index.js.map +1 -0
  53. package/dist/client/financialOutcomes/retry.d.ts +24 -0
  54. package/dist/client/financialOutcomes/retry.d.ts.map +1 -0
  55. package/dist/client/financialOutcomes/retry.js +31 -0
  56. package/dist/client/financialOutcomes/retry.js.map +1 -0
  57. package/dist/client/index.d.ts +21 -111
  58. package/dist/client/index.d.ts.map +1 -1
  59. package/dist/client/index.js +11 -85
  60. package/dist/client/index.js.map +1 -1
  61. package/dist/client/processingCostDeficit/index.d.ts +27 -0
  62. package/dist/client/processingCostDeficit/index.d.ts.map +1 -0
  63. package/dist/client/processingCostDeficit/index.js +54 -0
  64. package/dist/client/processingCostDeficit/index.js.map +1 -0
  65. package/dist/client/products/catalog.d.ts +26 -0
  66. package/dist/client/products/catalog.d.ts.map +1 -0
  67. package/dist/client/products/catalog.js +140 -0
  68. package/dist/client/products/catalog.js.map +1 -0
  69. package/dist/client/products/catalogClient.d.ts +109 -0
  70. package/dist/client/products/catalogClient.d.ts.map +1 -0
  71. package/dist/client/products/catalogClient.js +84 -0
  72. package/dist/client/products/catalogClient.js.map +1 -0
  73. package/dist/client/products/prices.d.ts +1 -0
  74. package/dist/client/products/prices.d.ts.map +1 -1
  75. package/dist/client/products/prices.js +1 -0
  76. package/dist/client/products/prices.js.map +1 -1
  77. package/dist/client/publicTypes.d.ts +2 -0
  78. package/dist/client/publicTypes.d.ts.map +1 -1
  79. package/dist/component/_generated/api.d.ts +284 -0
  80. package/dist/component/_generated/api.d.ts.map +1 -0
  81. package/dist/component/_generated/api.js +31 -0
  82. package/dist/component/_generated/api.js.map +1 -0
  83. package/dist/component/_generated/component.d.ts +535 -0
  84. package/dist/component/_generated/component.d.ts.map +1 -1
  85. package/dist/component/balanceFunding/helpers.d.ts +86 -0
  86. package/dist/component/balanceFunding/helpers.d.ts.map +1 -0
  87. package/dist/component/balanceFunding/helpers.js +68 -0
  88. package/dist/component/balanceFunding/helpers.js.map +1 -0
  89. package/dist/component/balanceFunding/importHandler.d.ts +13 -0
  90. package/dist/component/balanceFunding/importHandler.d.ts.map +1 -0
  91. package/dist/component/balanceFunding/importHandler.js +130 -0
  92. package/dist/component/balanceFunding/importHandler.js.map +1 -0
  93. package/dist/component/balanceFunding/lifecycleHandlers.d.ts +85 -0
  94. package/dist/component/balanceFunding/lifecycleHandlers.d.ts.map +1 -0
  95. package/dist/component/balanceFunding/lifecycleHandlers.js +60 -0
  96. package/dist/component/balanceFunding/lifecycleHandlers.js.map +1 -0
  97. package/dist/component/balanceFunding/mutationValidators.d.ts +238 -0
  98. package/dist/component/balanceFunding/mutationValidators.d.ts.map +1 -0
  99. package/dist/component/balanceFunding/mutationValidators.js +55 -0
  100. package/dist/component/balanceFunding/mutationValidators.js.map +1 -0
  101. package/dist/component/balanceFunding/mutations.d.ts +335 -0
  102. package/dist/component/balanceFunding/mutations.d.ts.map +1 -0
  103. package/dist/component/balanceFunding/mutations.js +106 -0
  104. package/dist/component/balanceFunding/mutations.js.map +1 -0
  105. package/dist/component/balanceFunding/preparationHandlers.d.ts +55 -0
  106. package/dist/component/balanceFunding/preparationHandlers.d.ts.map +1 -0
  107. package/dist/component/balanceFunding/preparationHandlers.js +165 -0
  108. package/dist/component/balanceFunding/preparationHandlers.js.map +1 -0
  109. package/dist/component/balanceFunding/queries.d.ts +151 -0
  110. package/dist/component/balanceFunding/queries.d.ts.map +1 -0
  111. package/dist/component/balanceFunding/queries.js +180 -0
  112. package/dist/component/balanceFunding/queries.js.map +1 -0
  113. package/dist/component/balanceFunding/schema.d.ts +748 -0
  114. package/dist/component/balanceFunding/schema.d.ts.map +1 -0
  115. package/dist/component/balanceFunding/schema.js +124 -0
  116. package/dist/component/balanceFunding/schema.js.map +1 -0
  117. package/dist/component/balanceFunding/stateHandlers.d.ts +58 -0
  118. package/dist/component/balanceFunding/stateHandlers.d.ts.map +1 -0
  119. package/dist/component/balanceFunding/stateHandlers.js +160 -0
  120. package/dist/component/balanceFunding/stateHandlers.js.map +1 -0
  121. package/dist/component/convex.config.d.ts.map +1 -1
  122. package/dist/component/convex.config.js +2 -0
  123. package/dist/component/convex.config.js.map +1 -1
  124. package/dist/component/costRecovery/completion.d.ts +1 -0
  125. package/dist/component/costRecovery/completion.d.ts.map +1 -1
  126. package/dist/component/costRecovery/helpers.d.ts +1 -0
  127. package/dist/component/costRecovery/helpers.d.ts.map +1 -1
  128. package/dist/component/costRecovery/mutations.d.ts +5 -0
  129. package/dist/component/costRecovery/mutations.d.ts.map +1 -1
  130. package/dist/component/costRecovery/preparation.d.ts +50 -0
  131. package/dist/component/costRecovery/preparation.d.ts.map +1 -0
  132. package/dist/component/costRecovery/preparation.js +108 -0
  133. package/dist/component/costRecovery/preparation.js.map +1 -0
  134. package/dist/component/costRecovery/queries.d.ts +1 -0
  135. package/dist/component/costRecovery/queries.d.ts.map +1 -1
  136. package/dist/component/costRecovery/reservations.d.ts +2 -0
  137. package/dist/component/costRecovery/reservations.d.ts.map +1 -1
  138. package/dist/component/costRecovery/schema.d.ts +7 -2
  139. package/dist/component/costRecovery/schema.d.ts.map +1 -1
  140. package/dist/component/costRecovery/schema.js +1 -0
  141. package/dist/component/costRecovery/schema.js.map +1 -1
  142. package/dist/component/durableExecution/runtime.d.ts +3 -0
  143. package/dist/component/durableExecution/runtime.d.ts.map +1 -0
  144. package/dist/component/durableExecution/runtime.js +12 -0
  145. package/dist/component/durableExecution/runtime.js.map +1 -0
  146. package/dist/component/earnings/triggers.d.ts +242 -2
  147. package/dist/component/earnings/triggers.d.ts.map +1 -1
  148. package/dist/component/products/mutations.d.ts +9 -0
  149. package/dist/component/products/mutations.d.ts.map +1 -1
  150. package/dist/component/products/mutations.js +31 -2
  151. package/dist/component/products/mutations.js.map +1 -1
  152. package/dist/component/schema.d.ts +253 -1
  153. package/dist/component/schema.js +4 -0
  154. package/dist/component/schema.js.map +1 -1
  155. package/docs/read-contracts.md +33 -0
  156. package/package.json +4 -2
  157. package/src/client/core/account-session-client.test.ts +74 -0
  158. package/src/client/core/accountCapabilities.ts +22 -0
  159. package/src/client/core/accountConfigurations.test.ts +183 -0
  160. package/src/client/core/accountConfigurations.ts +161 -0
  161. package/src/client/core/accountLinks.test.ts +6 -2
  162. package/src/client/core/accountLinks.ts +122 -5
  163. package/src/client/core/accounts.ts +8 -115
  164. package/src/client/core/billingPortal.test.ts +247 -0
  165. package/src/client/core/billingPortalClient.ts +35 -0
  166. package/src/client/costRecovery.test.ts +34 -0
  167. package/src/client/costRecovery.ts +21 -0
  168. package/src/client/financialOutcomes/adapters.ts +88 -0
  169. package/src/client/financialOutcomes/contracts.ts +43 -0
  170. package/src/client/financialOutcomes/errors.ts +29 -0
  171. package/src/client/financialOutcomes/index.ts +5 -0
  172. package/src/client/financialOutcomes/outcomes.test.ts +254 -0
  173. package/src/client/financialOutcomes/retry.ts +52 -0
  174. package/src/client/index.test.ts +0 -64
  175. package/src/client/index.ts +35 -185
  176. package/src/client/processingCostDeficit/README.md +35 -0
  177. package/src/client/processingCostDeficit/calculator.test.ts +176 -0
  178. package/src/client/processingCostDeficit/index.ts +91 -0
  179. package/src/client/products/catalog.test.ts +389 -0
  180. package/src/client/products/catalog.ts +225 -0
  181. package/src/client/products/catalogClient.ts +172 -0
  182. package/src/client/products/prices.test.ts +24 -0
  183. package/src/client/products/prices.ts +2 -0
  184. package/src/client/publicTypes.ts +13 -0
  185. package/src/component/_generated/api.ts +27 -1
  186. package/src/component/_generated/component.ts +707 -0
  187. package/src/component/balanceFunding/failure.test.ts +116 -0
  188. package/src/component/balanceFunding/helpers.ts +102 -0
  189. package/src/component/balanceFunding/import.test.ts +221 -0
  190. package/src/component/balanceFunding/importHandler.ts +146 -0
  191. package/src/component/balanceFunding/lifecycleHandlers.ts +90 -0
  192. package/src/component/balanceFunding/lookup.test.ts +113 -0
  193. package/src/component/balanceFunding/mutationValidators.ts +63 -0
  194. package/src/component/balanceFunding/mutations.ts +136 -0
  195. package/src/component/balanceFunding/preparation.test.ts +146 -0
  196. package/src/component/balanceFunding/preparationHandlers.ts +204 -0
  197. package/src/component/balanceFunding/queries.ts +221 -0
  198. package/src/component/balanceFunding/requestLookup.test.ts +160 -0
  199. package/src/component/balanceFunding/schema.ts +169 -0
  200. package/src/component/balanceFunding/state.test.ts +352 -0
  201. package/src/component/balanceFunding/stateHandlers.ts +198 -0
  202. package/src/component/balanceFunding/validation.test.ts +100 -0
  203. package/src/component/convex.config.ts +2 -0
  204. package/src/component/costRecovery/preparation.test.ts +355 -0
  205. package/src/component/costRecovery/preparation.ts +124 -0
  206. package/src/component/costRecovery/schema.ts +1 -0
  207. package/src/component/durableExecution/composition.test.ts +568 -0
  208. package/src/component/durableExecution/runtime.ts +12 -0
  209. package/src/component/products/mutations.ts +39 -2
  210. package/src/component/schema.ts +8 -0
@@ -1,4 +1,254 @@
1
1
  declare const _default: import("convex/server").SchemaDefinition<{
2
+ balanceFundingPreparations: import("convex/server").TableDefinition<import("convex/values").VObject<{
3
+ accountId: string;
4
+ activeOperationId?: import("convex/values").GenericId<"balanceFundingOperations"> | undefined;
5
+ consentAt: number;
6
+ consentReference: string;
7
+ enabled: boolean;
8
+ operationVersion: number;
9
+ preparation: {
10
+ customerAccount: string;
11
+ paymentMethodId?: string | undefined;
12
+ previousPaymentMethodId: string | null;
13
+ previousPaymentMethodTypes: string[] | null;
14
+ stripeSubscriptionId: string;
15
+ };
16
+ preparationOperationId?: import("convex/values").GenericId<"balanceFundingOperations"> | undefined;
17
+ providerApiVersion: string;
18
+ scopeKey: string;
19
+ startsPaused: boolean;
20
+ verified: boolean;
21
+ }, {
22
+ accountId: import("convex/values").VString<string, "required">;
23
+ scopeKey: import("convex/values").VString<string, "required">;
24
+ preparation: import("convex/values").VObject<{
25
+ customerAccount: string;
26
+ paymentMethodId?: string | undefined;
27
+ previousPaymentMethodId: string | null;
28
+ previousPaymentMethodTypes: string[] | null;
29
+ stripeSubscriptionId: string;
30
+ }, {
31
+ customerAccount: import("convex/values").VString<string, "required">;
32
+ stripeSubscriptionId: import("convex/values").VString<string, "required">;
33
+ previousPaymentMethodId: import("convex/values").VUnion<string | null, [import("convex/values").VString<string, "required">, import("convex/values").VNull<null, "required">], "required", never>;
34
+ previousPaymentMethodTypes: import("convex/values").VUnion<string[] | null, [import("convex/values").VArray<string[], import("convex/values").VString<string, "required">, "required">, import("convex/values").VNull<null, "required">], "required", never>;
35
+ paymentMethodId: import("convex/values").VString<string | undefined, "optional">;
36
+ }, "required", "customerAccount" | "paymentMethodId" | "previousPaymentMethodId" | "previousPaymentMethodTypes" | "stripeSubscriptionId">;
37
+ consentAt: import("convex/values").VFloat64<number, "required">;
38
+ consentReference: import("convex/values").VString<string, "required">;
39
+ providerApiVersion: import("convex/values").VString<string, "required">;
40
+ enabled: import("convex/values").VBoolean<boolean, "required">;
41
+ startsPaused: import("convex/values").VBoolean<boolean, "required">;
42
+ verified: import("convex/values").VBoolean<boolean, "required">;
43
+ preparationOperationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations"> | undefined, "optional">;
44
+ operationVersion: import("convex/values").VFloat64<number, "required">;
45
+ activeOperationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations"> | undefined, "optional">;
46
+ }, "required", "accountId" | "activeOperationId" | "consentAt" | "consentReference" | "enabled" | "operationVersion" | "preparation" | "preparation.customerAccount" | "preparation.paymentMethodId" | "preparation.previousPaymentMethodId" | "preparation.previousPaymentMethodTypes" | "preparation.stripeSubscriptionId" | "preparationOperationId" | "providerApiVersion" | "scopeKey" | "startsPaused" | "verified">, {
47
+ by_account_subscription: ["accountId", "preparation.stripeSubscriptionId", "_creationTime"];
48
+ }, {}, {}>;
49
+ balanceFundingOperations: import("convex/server").TableDefinition<import("convex/values").VObject<{
50
+ accountId: string;
51
+ cancelRequested: boolean;
52
+ enabled: boolean;
53
+ failureCode?: "invalid_scope" | "policy_invalid" | "unsupported_source" | undefined;
54
+ kind: "apply" | "prepare";
55
+ preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
56
+ providerKey: string;
57
+ providerKeys: {
58
+ attach?: string | undefined;
59
+ create?: string | undefined;
60
+ disable: string;
61
+ enable: string;
62
+ };
63
+ receipt?: {
64
+ customerAccount: string;
65
+ paymentMethodId: string | null;
66
+ paymentMethodTypes: string[] | null;
67
+ providerApiVersion: string;
68
+ stripeSubscriptionId: string;
69
+ } | undefined;
70
+ scopeKey: string;
71
+ state: "canceled" | "failed" | "pending" | "running" | "succeeded" | "unknown";
72
+ version: number;
73
+ }, {
74
+ accountId: import("convex/values").VString<string, "required">;
75
+ scopeKey: import("convex/values").VString<string, "required">;
76
+ preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
77
+ version: import("convex/values").VFloat64<number, "required">;
78
+ enabled: import("convex/values").VBoolean<boolean, "required">;
79
+ kind: import("convex/values").VUnion<"apply" | "prepare", [import("convex/values").VLiteral<"prepare", "required">, import("convex/values").VLiteral<"apply", "required">], "required", never>;
80
+ providerKey: import("convex/values").VString<string, "required">;
81
+ state: import("convex/values").VUnion<"canceled" | "failed" | "pending" | "running" | "succeeded" | "unknown", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"running", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"succeeded", "required">, import("convex/values").VLiteral<"canceled", "required">, import("convex/values").VLiteral<"failed", "required">], "required", never>;
82
+ cancelRequested: import("convex/values").VBoolean<boolean, "required">;
83
+ failureCode: import("convex/values").VUnion<"invalid_scope" | "policy_invalid" | "unsupported_source" | undefined, [import("convex/values").VLiteral<"invalid_scope", "required">, import("convex/values").VLiteral<"unsupported_source", "required">, import("convex/values").VLiteral<"policy_invalid", "required">], "optional", never>;
84
+ providerKeys: import("convex/values").VObject<{
85
+ attach?: string | undefined;
86
+ create?: string | undefined;
87
+ disable: string;
88
+ enable: string;
89
+ }, {
90
+ enable: import("convex/values").VString<string, "required">;
91
+ disable: import("convex/values").VString<string, "required">;
92
+ create: import("convex/values").VString<string | undefined, "optional">;
93
+ attach: import("convex/values").VString<string | undefined, "optional">;
94
+ }, "required", "attach" | "create" | "disable" | "enable">;
95
+ receipt: import("convex/values").VObject<{
96
+ customerAccount: string;
97
+ paymentMethodId: string | null;
98
+ paymentMethodTypes: string[] | null;
99
+ providerApiVersion: string;
100
+ stripeSubscriptionId: string;
101
+ } | undefined, {
102
+ customerAccount: import("convex/values").VString<string, "required">;
103
+ stripeSubscriptionId: import("convex/values").VString<string, "required">;
104
+ paymentMethodId: import("convex/values").VUnion<string | null, [import("convex/values").VString<string, "required">, import("convex/values").VNull<null, "required">], "required", never>;
105
+ paymentMethodTypes: import("convex/values").VUnion<string[] | null, [import("convex/values").VArray<string[], import("convex/values").VString<string, "required">, "required">, import("convex/values").VNull<null, "required">], "required", never>;
106
+ providerApiVersion: import("convex/values").VString<string, "required">;
107
+ }, "optional", "customerAccount" | "paymentMethodId" | "paymentMethodTypes" | "providerApiVersion" | "stripeSubscriptionId">;
108
+ }, "required", "accountId" | "cancelRequested" | "enabled" | "failureCode" | "kind" | "preparationId" | "providerKey" | "providerKeys" | "providerKeys.attach" | "providerKeys.create" | "providerKeys.disable" | "providerKeys.enable" | "receipt" | "receipt.customerAccount" | "receipt.paymentMethodId" | "receipt.paymentMethodTypes" | "receipt.providerApiVersion" | "receipt.stripeSubscriptionId" | "scopeKey" | "state" | "version">, {
109
+ by_preparation_version: ["preparationId", "version", "_creationTime"];
110
+ }, {}, {}>;
111
+ balanceFundingRequests: import("convex/server").TableDefinition<import("convex/values").VObject<{
112
+ imported?: {
113
+ operation?: {
114
+ accountId: string;
115
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
116
+ scopeKey: string;
117
+ version: number;
118
+ } | undefined;
119
+ preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
120
+ } | undefined;
121
+ payload: string;
122
+ preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
123
+ requestKey: string;
124
+ result?: {
125
+ operation: {
126
+ accountId: string;
127
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
128
+ scopeKey: string;
129
+ version: number;
130
+ };
131
+ status: "accepted";
132
+ } | {
133
+ enabled: boolean;
134
+ status: "unchanged";
135
+ } | {
136
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
137
+ retryable: false;
138
+ status: "conflict";
139
+ } | {
140
+ reason: "policy_invalid";
141
+ retryable: false;
142
+ status: "rejected";
143
+ } | {
144
+ reason: "provider_pending";
145
+ retryable: true;
146
+ status: "not_ready";
147
+ } | undefined;
148
+ }, {
149
+ requestKey: import("convex/values").VString<string, "required">;
150
+ payload: import("convex/values").VString<string, "required">;
151
+ preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
152
+ result: import("convex/values").VUnion<{
153
+ operation: {
154
+ accountId: string;
155
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
156
+ scopeKey: string;
157
+ version: number;
158
+ };
159
+ status: "accepted";
160
+ } | {
161
+ enabled: boolean;
162
+ status: "unchanged";
163
+ } | {
164
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
165
+ retryable: false;
166
+ status: "conflict";
167
+ } | {
168
+ reason: "policy_invalid";
169
+ retryable: false;
170
+ status: "rejected";
171
+ } | {
172
+ reason: "provider_pending";
173
+ retryable: true;
174
+ status: "not_ready";
175
+ } | undefined, [import("convex/values").VObject<{
176
+ operation: {
177
+ accountId: string;
178
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
179
+ scopeKey: string;
180
+ version: number;
181
+ };
182
+ status: "accepted";
183
+ }, {
184
+ status: import("convex/values").VLiteral<"accepted", "required">;
185
+ operation: import("convex/values").VObject<{
186
+ accountId: string;
187
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
188
+ scopeKey: string;
189
+ version: number;
190
+ }, {
191
+ accountId: import("convex/values").VString<string, "required">;
192
+ scopeKey: import("convex/values").VString<string, "required">;
193
+ operationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations">, "required">;
194
+ version: import("convex/values").VFloat64<number, "required">;
195
+ }, "required", "accountId" | "operationId" | "scopeKey" | "version">;
196
+ }, "required", "operation" | "operation.accountId" | "operation.operationId" | "operation.scopeKey" | "operation.version" | "status">, import("convex/values").VObject<{
197
+ enabled: boolean;
198
+ status: "unchanged";
199
+ }, {
200
+ status: import("convex/values").VLiteral<"unchanged", "required">;
201
+ enabled: import("convex/values").VBoolean<boolean, "required">;
202
+ }, "required", "enabled" | "status">, import("convex/values").VObject<{
203
+ reason: "identity_changed" | "revision_changed" | "scope_busy";
204
+ retryable: false;
205
+ status: "conflict";
206
+ }, {
207
+ status: import("convex/values").VLiteral<"conflict", "required">;
208
+ reason: import("convex/values").VUnion<"identity_changed" | "revision_changed" | "scope_busy", [import("convex/values").VLiteral<"scope_busy", "required">, import("convex/values").VLiteral<"identity_changed", "required">, import("convex/values").VLiteral<"revision_changed", "required">], "required", never>;
209
+ retryable: import("convex/values").VLiteral<false, "required">;
210
+ }, "required", "reason" | "retryable" | "status">, import("convex/values").VObject<{
211
+ reason: "policy_invalid";
212
+ retryable: false;
213
+ status: "rejected";
214
+ }, {
215
+ status: import("convex/values").VLiteral<"rejected", "required">;
216
+ reason: import("convex/values").VLiteral<"policy_invalid", "required">;
217
+ retryable: import("convex/values").VLiteral<false, "required">;
218
+ }, "required", "reason" | "retryable" | "status">, import("convex/values").VObject<{
219
+ reason: "provider_pending";
220
+ retryable: true;
221
+ status: "not_ready";
222
+ }, {
223
+ status: import("convex/values").VLiteral<"not_ready", "required">;
224
+ reason: import("convex/values").VLiteral<"provider_pending", "required">;
225
+ retryable: import("convex/values").VLiteral<true, "required">;
226
+ }, "required", "reason" | "retryable" | "status">], "optional", "enabled" | "operation" | "operation.accountId" | "operation.operationId" | "operation.scopeKey" | "operation.version" | "reason" | "retryable" | "status">;
227
+ imported: import("convex/values").VObject<{
228
+ operation?: {
229
+ accountId: string;
230
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
231
+ scopeKey: string;
232
+ version: number;
233
+ } | undefined;
234
+ preparationId: import("convex/values").GenericId<"balanceFundingPreparations">;
235
+ } | undefined, {
236
+ preparationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingPreparations">, "required">;
237
+ operation: import("convex/values").VObject<{
238
+ accountId: string;
239
+ operationId: import("convex/values").GenericId<"balanceFundingOperations">;
240
+ scopeKey: string;
241
+ version: number;
242
+ } | undefined, {
243
+ accountId: import("convex/values").VString<string, "required">;
244
+ scopeKey: import("convex/values").VString<string, "required">;
245
+ operationId: import("convex/values").VId<import("convex/values").GenericId<"balanceFundingOperations">, "required">;
246
+ version: import("convex/values").VFloat64<number, "required">;
247
+ }, "optional", "accountId" | "operationId" | "scopeKey" | "version">;
248
+ }, "optional", "operation" | "operation.accountId" | "operation.operationId" | "operation.scopeKey" | "operation.version" | "preparationId">;
249
+ }, "required", "imported" | "imported.operation" | "imported.operation.accountId" | "imported.operation.operationId" | "imported.operation.scopeKey" | "imported.operation.version" | "imported.preparationId" | "payload" | "preparationId" | "requestKey" | "result" | "result.enabled" | "result.operation" | "result.operation.accountId" | "result.operation.operationId" | "result.operation.scopeKey" | "result.operation.version" | "result.reason" | "result.retryable" | "result.status">, {
250
+ by_request: ["requestKey", "_creationTime"];
251
+ }, {}, {}>;
2
252
  operationEvidencePayloads: import("convex/server").TableDefinition<import("convex/values").VObject<{
3
253
  commissionExposure?: {
4
254
  chargeAmount: number;
@@ -1291,6 +1541,7 @@ declare const _default: import("convex/server").SchemaDefinition<{
1291
1541
  maxCredit: number;
1292
1542
  maxDebit: number;
1293
1543
  pendingOperations: number;
1544
+ preparationSequence?: number | undefined;
1294
1545
  scopeKey: string;
1295
1546
  sourceGross?: number | undefined;
1296
1547
  sourceId: string;
@@ -1310,6 +1561,7 @@ declare const _default: import("convex/server").SchemaDefinition<{
1310
1561
  maxCredit: import("convex/values").VFloat64<number, "required">;
1311
1562
  amount: import("convex/values").VFloat64<number, "required">;
1312
1563
  pendingOperations: import("convex/values").VFloat64<number, "required">;
1564
+ preparationSequence: import("convex/values").VFloat64<number | undefined, "optional">;
1313
1565
  invoiceItemId: import("convex/values").VString<string | undefined, "optional">;
1314
1566
  invoiceFunding: import("convex/values").VObject<{
1315
1567
  sourceChargeId: string;
@@ -1321,7 +1573,7 @@ declare const _default: import("convex/server").SchemaDefinition<{
1321
1573
  sourceProcessingFee: import("convex/values").VFloat64<number, "required">;
1322
1574
  }, "optional", "sourceChargeId" | "sourceGross" | "sourceProcessingFee">;
1323
1575
  status: import("convex/values").VUnion<"collected" | "collecting" | "open" | "released" | "releasing" | "sealed", [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"sealed", "required">, import("convex/values").VLiteral<"collecting", "required">, import("convex/values").VLiteral<"releasing", "required">, import("convex/values").VLiteral<"collected", "required">, import("convex/values").VLiteral<"released", "required">], "required", never>;
1324
- }, "required", "accountId" | "amount" | "currency" | "groupKey" | "invoiceFunding" | "invoiceFunding.sourceChargeId" | "invoiceFunding.sourceGross" | "invoiceFunding.sourceProcessingFee" | "invoiceItemId" | "maxCredit" | "maxDebit" | "pendingOperations" | "scopeKey" | "sourceGross" | "sourceId" | "sourceKind" | "sourceProcessingFee" | "status">, {
1576
+ }, "required", "accountId" | "amount" | "currency" | "groupKey" | "invoiceFunding" | "invoiceFunding.sourceChargeId" | "invoiceFunding.sourceGross" | "invoiceFunding.sourceProcessingFee" | "invoiceItemId" | "maxCredit" | "maxDebit" | "pendingOperations" | "preparationSequence" | "scopeKey" | "sourceGross" | "sourceId" | "sourceKind" | "sourceProcessingFee" | "status">, {
1325
1577
  by_key: ["groupKey", "_creationTime"];
1326
1578
  }, {}, {}>;
1327
1579
  recoveryReservations: import("convex/server").TableDefinition<import("convex/values").VObject<{
@@ -1,3 +1,4 @@
1
+ import { preparationsTable as balanceFundingPreparations, operationsTable as balanceFundingOperations, requestsTable as balanceFundingRequests, } from "./balanceFunding/schema.js";
1
2
  import { payloadsTable as operationEvidencePayloads, headersTable as operationEvidenceHeaders, } from "./operationEvidence/schema.js";
2
3
  import { transferBatchReferencesTable } from "./financialObservations/transferReferenceSchema.js";
3
4
  import { transferObservationsTable, transferBatchesTable, } from "./financialObservations/transferSchema.js";
@@ -21,6 +22,9 @@ import { accountsTable } from "./core/schema";
21
22
  import { pricesTable, productsTable } from "./products/schema";
22
23
  import { webhookEventsTable } from "./webhooks/schema";
23
24
  export default defineSchema({
25
+ balanceFundingPreparations,
26
+ balanceFundingOperations,
27
+ balanceFundingRequests,
24
28
  operationEvidencePayloads,
25
29
  operationEvidenceHeaders,
26
30
  financialTransferObservations: transferObservationsTable,
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,IAAI,yBAAyB,EAC1C,YAAY,IAAI,wBAAwB,GACzC,MAAM,+BAA+B,CAA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E,oBAAoB;IACrC,mBAAmB,EAAE,wBAAwB;IAC7C,OAAO;IACP,QAAQ,EAAE,aAAa;IACvB,eAAe,EAAE,oBAAoB;IAErC,WAAW;IACX,QAAQ,EAAE,aAAa;IACvB,MAAM,EAAE,WAAW;IAEnB,UAAU;IACV,aAAa,EAAE,kBAAkB;IACjC,gBAAgB,EAAE,qBAAqB;IACvC,QAAQ,EAAE,aAAa;IAEvB,UAAU;IACV,QAAQ,EAAE,aAAa;IACvB,OAAO,EAAE,YAAY;IACrB,iBAAiB,EAAE,sBAAsB;IACzC,OAAO,EAAE,YAAY;IACrB,QAAQ,EAAE,aAAa;IACvB,SAAS,EAAE,cAAc;IACzB,mBAAmB,EAAE,wBAAwB;IAE7C,WAAW;IACX,aAAa,EAAE,kBAAkB;CAClC,CAAC,CAAC"}
@@ -322,3 +322,36 @@ partial-capture units, history budgets and creation-time host obligations are
322
322
  specified in [refund context](./refund-context.md). Invoice allocations and
323
323
  authorized gross amounts are not remaining refundable principal. No access,
324
324
  subscription or financial state is changed by this reader.
325
+
326
+ ## Financial readiness and bounded retries
327
+
328
+ The additive `verifiedSaleOutcome` and `processingCostOutcome` adapters preserve
329
+ the original SDK reader results. A ready outcome contains that result in
330
+ `value`. Missing provider data becomes `not_ready` with `provider_pending` or
331
+ `fee_pending`; it never becomes a zero fee. Unsupported sources and currency
332
+ mismatches are rejected. Unknown legacy reason strings fail closed.
333
+
334
+ `FinancialUnavailable` distinguishes pending reads, conflicts, rejections and
335
+ uncertain provider writes. A conflict requires fresh state and a policy decision.
336
+ An `unknown` provider outcome requires reconciliation of the original operation
337
+ and receipts before another write. Bounded history that is still incomplete
338
+ after exhaustion must remain unknown.
339
+
340
+ `financialRetryDecision(outcome, attempt, policy)` is a pure scheduling decision.
341
+ It retries only validated `not_ready` outcomes. The caller supplies all policy
342
+ fields: `maxRetries` from 0 to 20, positive integer `initialDelayMs`, and
343
+ `maxDelayMs` no greater than one day or less than the initial delay. Attempt zero
344
+ is the initial call; a limit of ten allows ten additional calls. Delays double
345
+ until the configured cap. Exhaustion returns `stop/exhausted`. The helper runs
346
+ no action and provides no permission to repeat an uncertain money movement.
347
+
348
+ `throwFinancialOutcome` carries only the validated status, reason and retryable
349
+ flag in a structured Convex error. `readFinancialOutcomeError` reads that data
350
+ across action boundaries, without inspecting exception messages. Other errors
351
+ propagate unchanged. These helpers do not classify transport errors or establish
352
+ whether a provider write succeeded.
353
+
354
+ The example settlement and processing-cost wrappers use ten retries, a one-second
355
+ initial delay and a one-minute cap. They retry structured readiness observations.
356
+ Revision conflicts and terminal errors now propagate for fresh-state handling
357
+ instead of matching English text and rerunning the financial action.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fantastic.dev/better-stripe",
3
- "version": "0.37.1",
3
+ "version": "0.39.0",
4
4
  "description": "A Convex component for Stripe V2 Accounts API integration.",
5
5
  "keywords": [
6
6
  "stripe",
@@ -110,6 +110,8 @@
110
110
  "check:agents": "repo-gates check-agents"
111
111
  },
112
112
  "dependencies": {
113
+ "@convex-dev/workflow": "0.4.10",
114
+ "@convex-dev/workpool": "0.4.14",
113
115
  "@stripe/connect-js": "^3.4.6",
114
116
  "@stripe/react-connect-js": "^3.4.4",
115
117
  "@stripe/react-stripe-js": "^7.0.0",
@@ -145,7 +147,7 @@
145
147
  "vitest": "^5.0.3"
146
148
  },
147
149
  "peerDependencies": {
148
- "convex": "^1.29.3",
150
+ "convex": "^1.46.0",
149
151
  "react": "^18.3.1 || ^19.0.0",
150
152
  "react-dom": "^18.3.1 || ^19.0.0"
151
153
  },
@@ -0,0 +1,74 @@
1
+ import { ConvexError } from "convex/values";
2
+ import { beforeEach, describe, expect, it, vi } from "vitest";
3
+ import { components } from "../setup.test.js";
4
+
5
+ const { create } = vi.hoisted(() => ({ create: vi.fn() }));
6
+ vi.mock("stripe", () => ({
7
+ default: class {
8
+ accountSessions = { create };
9
+ },
10
+ }));
11
+ const { BetterStripe } = await import("../index.js");
12
+ const mockCtx = { runQuery: vi.fn(), runMutation: vi.fn(), runAction: vi.fn() };
13
+ beforeEach(() => vi.resetAllMocks());
14
+
15
+ describe("createAccountSession", () => {
16
+ it("returns the provider client secret and expiry through BetterStripe", async () => {
17
+ const bs = new BetterStripe(components.betterStripe, {
18
+ STRIPE_SECRET_KEY: "sk_test_xxx",
19
+ });
20
+
21
+ create.mockResolvedValue({
22
+ client_secret: "as_secret_123",
23
+ expires_at: 1234567890,
24
+ });
25
+
26
+ const result = await bs.createAccountSession(mockCtx, {
27
+ stripeAccountId: "acct_123",
28
+ components: {
29
+ account_management: { enabled: true },
30
+ },
31
+ });
32
+
33
+ expect(create).toHaveBeenCalledWith({
34
+ account: "acct_123",
35
+ components: {
36
+ account_management: { enabled: true },
37
+ },
38
+ });
39
+ expect(result).toEqual({
40
+ clientSecret: "as_secret_123",
41
+ expiresAt: 1234567890,
42
+ });
43
+ });
44
+
45
+ it("wraps Stripe failures in a structured STRIPE_API_ERROR", async () => {
46
+ const bs = new BetterStripe(components.betterStripe, {
47
+ STRIPE_SECRET_KEY: "sk_test_xxx",
48
+ });
49
+
50
+ create.mockRejectedValue(
51
+ Object.assign(new Error("No such account: acct_missing"), {
52
+ type: "StripeInvalidRequestError",
53
+ code: "resource_missing",
54
+ }),
55
+ );
56
+
57
+ const error = await bs
58
+ .createAccountSession(mockCtx, {
59
+ stripeAccountId: "acct_missing",
60
+ components: { account_onboarding: { enabled: true } },
61
+ })
62
+ .catch((e: unknown) => e);
63
+
64
+ expect(error).toBeInstanceOf(ConvexError);
65
+ expect((error as { data: Record<string, unknown> }).data).toMatchObject({
66
+ code: "STRIPE_API_ERROR",
67
+ stripeError: {
68
+ type: "StripeInvalidRequestError",
69
+ code: "resource_missing",
70
+ message: "No such account: acct_missing",
71
+ },
72
+ });
73
+ });
74
+ });
@@ -0,0 +1,22 @@
1
+ /** Provider capability shape shared by V1 and V2 accounts. */
2
+ export type TransferCapabilityAccount = {
3
+ configuration?: {
4
+ recipient?: {
5
+ capabilities?: {
6
+ stripe_balance?: { stripe_transfers?: { status?: string } };
7
+ };
8
+ } | null;
9
+ } | null;
10
+ capabilities?: { transfers?: string } | null;
11
+ };
12
+
13
+ /** True when Stripe reports active recipient transfers in either supported API shape. */
14
+ export function canReceiveTransfers(
15
+ account: TransferCapabilityAccount | null | undefined,
16
+ ): boolean {
17
+ return (
18
+ account?.configuration?.recipient?.capabilities?.stripe_balance
19
+ ?.stripe_transfers?.status === "active" ||
20
+ account?.capabilities?.transfers === "active"
21
+ );
22
+ }