@fantastic.dev/better-stripe 0.20.1 → 0.22.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 (73) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/README.md +16 -5
  3. package/dist/client/connect/payoutExecution.d.ts +34 -0
  4. package/dist/client/connect/payoutExecution.d.ts.map +1 -0
  5. package/dist/client/connect/payoutExecution.js +189 -0
  6. package/dist/client/connect/payoutExecution.js.map +1 -0
  7. package/dist/client/connect/payoutHistory.d.ts +22 -0
  8. package/dist/client/connect/payoutHistory.d.ts.map +1 -0
  9. package/dist/client/connect/payoutHistory.js +122 -0
  10. package/dist/client/connect/payoutHistory.js.map +1 -0
  11. package/dist/client/connect/payoutReceipt.d.ts +53 -0
  12. package/dist/client/connect/payoutReceipt.d.ts.map +1 -0
  13. package/dist/client/connect/payoutReceipt.js +185 -0
  14. package/dist/client/connect/payoutReceipt.js.map +1 -0
  15. package/dist/client/connect/payoutReconciliation.d.ts +38 -0
  16. package/dist/client/connect/payoutReconciliation.d.ts.map +1 -0
  17. package/dist/client/connect/payoutReconciliation.js +112 -0
  18. package/dist/client/connect/payoutReconciliation.js.map +1 -0
  19. package/dist/client/payoutPolicy.d.ts +9 -0
  20. package/dist/client/payoutPolicy.d.ts.map +1 -1
  21. package/dist/client/payoutPolicy.js +12 -0
  22. package/dist/client/payoutPolicy.js.map +1 -1
  23. package/dist/component/_generated/component.d.ts +112 -0
  24. package/dist/component/_generated/component.d.ts.map +1 -1
  25. package/dist/component/earnings/triggers.d.ts +52 -2
  26. package/dist/component/earnings/triggers.d.ts.map +1 -1
  27. package/dist/component/payoutRelease/allocation.d.ts +1 -0
  28. package/dist/component/payoutRelease/allocation.d.ts.map +1 -1
  29. package/dist/component/payoutRelease/allocation.js +3 -0
  30. package/dist/component/payoutRelease/allocation.js.map +1 -1
  31. package/dist/component/payoutRelease/fees.d.ts +22 -0
  32. package/dist/component/payoutRelease/fees.d.ts.map +1 -0
  33. package/dist/component/payoutRelease/fees.js +73 -0
  34. package/dist/component/payoutRelease/fees.js.map +1 -0
  35. package/dist/component/payoutRelease/helpers.d.ts +5 -0
  36. package/dist/component/payoutRelease/helpers.d.ts.map +1 -1
  37. package/dist/component/payoutRelease/mutations.d.ts +29 -0
  38. package/dist/component/payoutRelease/mutations.d.ts.map +1 -1
  39. package/dist/component/payoutRelease/mutations.js +24 -1
  40. package/dist/component/payoutRelease/mutations.js.map +1 -1
  41. package/dist/component/payoutRelease/queries.d.ts +87 -0
  42. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  43. package/dist/component/payoutRelease/queries.js +39 -0
  44. package/dist/component/payoutRelease/queries.js.map +1 -1
  45. package/dist/component/payoutRelease/schema.d.ts +43 -2
  46. package/dist/component/payoutRelease/schema.d.ts.map +1 -1
  47. package/dist/component/payoutRelease/schema.js +12 -0
  48. package/dist/component/payoutRelease/schema.js.map +1 -1
  49. package/dist/component/schema.d.ts +27 -1
  50. package/dist/component/schema.js +2 -1
  51. package/dist/component/schema.js.map +1 -1
  52. package/docs/settlement.md +134 -3
  53. package/package.json +1 -1
  54. package/src/client/connect/payoutAllocation.test.ts +36 -3
  55. package/src/client/connect/payoutExecution.test.ts +504 -0
  56. package/src/client/connect/payoutExecution.ts +265 -0
  57. package/src/client/connect/payoutHistory.test.ts +145 -0
  58. package/src/client/connect/payoutHistory.ts +149 -0
  59. package/src/client/connect/payoutReceipt.test.ts +312 -0
  60. package/src/client/connect/payoutReceipt.ts +287 -0
  61. package/src/client/connect/payoutReconciliation.test.ts +398 -0
  62. package/src/client/connect/payoutReconciliation.ts +178 -0
  63. package/src/client/payoutPolicy.ts +30 -0
  64. package/src/component/_generated/api.ts +2 -0
  65. package/src/component/_generated/component.ts +118 -0
  66. package/src/component/payout-fees.test.ts +224 -0
  67. package/src/component/payout-release-snapshot.test.ts +57 -0
  68. package/src/component/payoutRelease/allocation.ts +6 -0
  69. package/src/component/payoutRelease/fees.ts +93 -0
  70. package/src/component/payoutRelease/mutations.ts +26 -1
  71. package/src/component/payoutRelease/queries.ts +46 -0
  72. package/src/component/payoutRelease/schema.ts +13 -0
  73. package/src/component/schema.ts +2 -0
@@ -14,7 +14,11 @@ export declare const get: import("convex/server").RegisteredQuery<"public", {
14
14
  amount: number;
15
15
  attemptedAt?: number | undefined;
16
16
  currency: string;
17
+ debitFee?: number | undefined;
18
+ debitTransactionId?: string | undefined;
19
+ destinationId?: string | undefined;
17
20
  expectedRevision: number;
21
+ feeRevision?: number | undefined;
18
22
  observations: {
19
23
  currency: string;
20
24
  ledgerFingerprint: string;
@@ -26,6 +30,7 @@ export declare const get: import("convex/server").RegisteredQuery<"public", {
26
30
  }[];
27
31
  operationKey: string;
28
32
  ownerKey: string;
33
+ providerFee?: number | undefined;
29
34
  rejection?: {
30
35
  code: "amount_too_small" | "balance_insufficient";
31
36
  requestId: string;
@@ -58,7 +63,11 @@ export declare const pending: import("convex/server").RegisteredQuery<"public",
58
63
  amount: number;
59
64
  attemptedAt?: number | undefined;
60
65
  currency: string;
66
+ debitFee?: number | undefined;
67
+ debitTransactionId?: string | undefined;
68
+ destinationId?: string | undefined;
61
69
  expectedRevision: number;
70
+ feeRevision?: number | undefined;
62
71
  observations: {
63
72
  currency: string;
64
73
  ledgerFingerprint: string;
@@ -70,6 +79,7 @@ export declare const pending: import("convex/server").RegisteredQuery<"public",
70
79
  }[];
71
80
  operationKey: string;
72
81
  ownerKey: string;
82
+ providerFee?: number | undefined;
73
83
  rejection?: {
74
84
  code: "amount_too_small" | "balance_insufficient";
75
85
  requestId: string;
@@ -81,4 +91,81 @@ export declare const pending: import("convex/server").RegisteredQuery<"public",
81
91
  continueCursor: string;
82
92
  isDone: boolean;
83
93
  }>>;
94
+ export declare const fees: import("convex/server").RegisteredQuery<"public", {
95
+ accountId: string;
96
+ currency: string;
97
+ ownerKey: string;
98
+ }, Promise<{
99
+ amount: number;
100
+ revision: number;
101
+ }>>;
102
+ /** Complete bounded input for package qualification. Partial membership never qualifies. */
103
+ export declare const snapshot: import("convex/server").RegisteredQuery<"public", {
104
+ accountId: string;
105
+ ownerKey: string;
106
+ }, Promise<{
107
+ status: "held";
108
+ reason: "snapshot_limit";
109
+ transfers?: undefined;
110
+ claims?: undefined;
111
+ } | {
112
+ reason?: undefined;
113
+ status: "ready";
114
+ transfers: {
115
+ _creationTime: number;
116
+ _id: import("convex/values").GenericId<"transfers">;
117
+ amount: number;
118
+ currency: string;
119
+ destinationAccountId: string;
120
+ metadata?: any;
121
+ paymentId?: string | undefined;
122
+ reinstatement?: boolean | undefined;
123
+ reversalClaimedAmount?: number | undefined;
124
+ reversalStatus?: "fully_reversed" | "partially_reversed" | undefined;
125
+ reversedAmount?: number | undefined;
126
+ role?: "affiliate" | "other" | "store" | undefined;
127
+ sourceChargeId?: string | undefined;
128
+ sourceInvoiceId?: string | undefined;
129
+ status: "failed" | "paid" | "pending" | "reversed";
130
+ stripeTransferId: string;
131
+ totalsRecorded?: true | undefined;
132
+ }[];
133
+ claims: {
134
+ _creationTime: number;
135
+ _id: import("convex/values").GenericId<"payoutReleaseClaims">;
136
+ accountId: string;
137
+ allocations: {
138
+ amount: number;
139
+ role?: "affiliate" | "other" | "store" | undefined;
140
+ stripeTransferId: string;
141
+ }[];
142
+ amount: number;
143
+ attemptedAt?: number | undefined;
144
+ currency: string;
145
+ debitFee?: number | undefined;
146
+ debitTransactionId?: string | undefined;
147
+ destinationId?: string | undefined;
148
+ expectedRevision: number;
149
+ feeRevision?: number | undefined;
150
+ observations: {
151
+ currency: string;
152
+ ledgerFingerprint: string;
153
+ matureNet: number;
154
+ observedAt: number;
155
+ pendingCredits: number;
156
+ stripeTransferId: string;
157
+ transactionIds: string[];
158
+ }[];
159
+ operationKey: string;
160
+ ownerKey: string;
161
+ providerFee?: number | undefined;
162
+ rejection?: {
163
+ code: "amount_too_small" | "balance_insufficient";
164
+ requestId: string;
165
+ } | undefined;
166
+ returnTransactionId?: string | undefined;
167
+ status: "canceled" | "paid" | "rejected" | "reserved" | "returned" | "submitted";
168
+ stripePayoutId?: string | undefined;
169
+ }[];
170
+ }>>;
84
171
  //# sourceMappingURL=queries.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/queries.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAiBd,CAAC;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BlB,CAAC"}
1
+ {"version":3,"file":"queries.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/queries.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAiBd,CAAC;AACH,eAAO,MAAM,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BlB,CAAC;AAEH,eAAO,MAAM,IAAI;;;;;;;GAQf,CAAC;AAEH,4FAA4F;AAC5F,eAAO,MAAM,QAAQ;;;;YA0BE,MAAM;YAAmB,gBAAgB;;;;;YAG3C,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAE1B,CAAC"}
@@ -1,3 +1,5 @@
1
+ import { transferDocValidator } from "../connect/validators.js";
2
+ import { readFees } from "./fees.js";
1
3
  import { paginationOptsValidator } from "convex/server";
2
4
  import { v } from "convex/values";
3
5
  import { query } from "../_generated/server.js";
@@ -48,4 +50,41 @@ export const pending = query({
48
50
  };
49
51
  },
50
52
  });
53
+ export const fees = query({
54
+ args: { accountId: v.string(), ownerKey: v.string(), currency: v.string() },
55
+ returns: v.object({ amount: v.number(), revision: v.number() }),
56
+ handler: async (ctx, args) => {
57
+ await readPolicy(ctx, args);
58
+ const balance = await readFees(ctx, args);
59
+ return { amount: balance?.amount ?? 0, revision: balance?.revision ?? 0 };
60
+ },
61
+ });
62
+ /** Complete bounded input for package qualification. Partial membership never qualifies. */
63
+ export const snapshot = query({
64
+ args: { accountId: v.string(), ownerKey: v.string() },
65
+ returns: v.union(v.object({
66
+ status: v.literal("held"),
67
+ reason: v.literal("snapshot_limit"),
68
+ }), v.object({
69
+ status: v.literal("ready"),
70
+ transfers: v.array(transferDocValidator),
71
+ claims: v.array(claimDoc),
72
+ })),
73
+ handler: async (ctx, args) => {
74
+ await readPolicy(ctx, args);
75
+ const transfers = await ctx.db
76
+ .query("transfers")
77
+ .withIndex("by_destination_account_id", (q) => q.eq("destinationAccountId", args.accountId))
78
+ .take(101);
79
+ const claims = await ctx.db
80
+ .query("payoutReleaseClaims")
81
+ .withIndex("by_account_status", (q) => q.eq("accountId", args.accountId))
82
+ .take(101);
83
+ if (transfers.length > 100 || claims.length > 100)
84
+ return { status: "held", reason: "snapshot_limit" };
85
+ if (claims.some((c) => c.ownerKey !== args.ownerKey))
86
+ throw new Error("Payout history owner does not match.");
87
+ return { status: "ready", transfers, claims };
88
+ },
89
+ });
51
90
  //# sourceMappingURL=queries.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"queries.js","sourceRoot":"","sources":["../../../src/component/payoutRelease/queries.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AACxD,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,MAAM,CAAC,MAAM,GAAG,GAAG,KAAK,CAAC;IACvB,IAAI,EAAE,QAAQ;IACd,OAAO,EAAE,CAAC,CAAC,KAAK,CAAC,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AAC,CAAC;QACb,IAAI,SAAS,CAAC,MAAM,GAAG,GAAG,IAAI,MAAM,CAAC,MAAM,GAAG,GAAG;YAC/C,OAAO,EAAE,MAAM,EAAE,MAAe,EAAE,MAAM,EAAE,gBAAyB,EAAE,CAAC;QACxE,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,KAAK,IAAI,CAAC,QAAQ,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1D,OAAO,EAAE,MAAM,EAAE,OAAgB,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IACzD,CAAC;CACF,CAAC,CAAC"}
@@ -31,6 +31,7 @@ export declare const claimFields: {
31
31
  expectedRevision: import("convex/values").VFloat64<number, "required">;
32
32
  currency: import("convex/values").VString<string, "required">;
33
33
  amount: import("convex/values").VFloat64<number, "required">;
34
+ destinationId: import("convex/values").VString<string | undefined, "optional">;
34
35
  allocations: import("convex/values").VArray<{
35
36
  amount: number;
36
37
  role?: "affiliate" | "other" | "store" | undefined;
@@ -73,6 +74,10 @@ export declare const claimFields: {
73
74
  attemptedAt: import("convex/values").VFloat64<number | undefined, "optional">;
74
75
  stripePayoutId: import("convex/values").VString<string | undefined, "optional">;
75
76
  returnTransactionId: import("convex/values").VString<string | undefined, "optional">;
77
+ feeRevision: import("convex/values").VFloat64<number | undefined, "optional">;
78
+ debitTransactionId: import("convex/values").VString<string | undefined, "optional">;
79
+ debitFee: import("convex/values").VFloat64<number | undefined, "optional">;
80
+ providerFee: import("convex/values").VFloat64<number | undefined, "optional">;
76
81
  rejection: import("convex/values").VObject<{
77
82
  code: "amount_too_small" | "balance_insufficient";
78
83
  requestId: string;
@@ -93,7 +98,11 @@ export declare const claimDoc: import("convex/values").VObject<{
93
98
  amount: number;
94
99
  attemptedAt?: number | undefined;
95
100
  currency: string;
101
+ debitFee?: number | undefined;
102
+ debitTransactionId?: string | undefined;
103
+ destinationId?: string | undefined;
96
104
  expectedRevision: number;
105
+ feeRevision?: number | undefined;
97
106
  observations: {
98
107
  currency: string;
99
108
  ledgerFingerprint: string;
@@ -105,6 +114,7 @@ export declare const claimDoc: import("convex/values").VObject<{
105
114
  }[];
106
115
  operationKey: string;
107
116
  ownerKey: string;
117
+ providerFee?: number | undefined;
108
118
  rejection?: {
109
119
  code: "amount_too_small" | "balance_insufficient";
110
120
  requestId: string;
@@ -119,6 +129,7 @@ export declare const claimDoc: import("convex/values").VObject<{
119
129
  expectedRevision: import("convex/values").VFloat64<number, "required">;
120
130
  currency: import("convex/values").VString<string, "required">;
121
131
  amount: import("convex/values").VFloat64<number, "required">;
132
+ destinationId: import("convex/values").VString<string | undefined, "optional">;
122
133
  allocations: import("convex/values").VArray<{
123
134
  amount: number;
124
135
  role?: "affiliate" | "other" | "store" | undefined;
@@ -161,6 +172,10 @@ export declare const claimDoc: import("convex/values").VObject<{
161
172
  attemptedAt: import("convex/values").VFloat64<number | undefined, "optional">;
162
173
  stripePayoutId: import("convex/values").VString<string | undefined, "optional">;
163
174
  returnTransactionId: import("convex/values").VString<string | undefined, "optional">;
175
+ feeRevision: import("convex/values").VFloat64<number | undefined, "optional">;
176
+ debitTransactionId: import("convex/values").VString<string | undefined, "optional">;
177
+ debitFee: import("convex/values").VFloat64<number | undefined, "optional">;
178
+ providerFee: import("convex/values").VFloat64<number | undefined, "optional">;
164
179
  rejection: import("convex/values").VObject<{
165
180
  code: "amount_too_small" | "balance_insufficient";
166
181
  requestId: string;
@@ -170,7 +185,7 @@ export declare const claimDoc: import("convex/values").VObject<{
170
185
  }, "optional", "code" | "requestId">;
171
186
  _id: import("convex/values").VId<import("convex/values").GenericId<"payoutReleaseClaims">, "required">;
172
187
  _creationTime: import("convex/values").VFloat64<number, "required">;
173
- }, "required", "_creationTime" | "_id" | "accountId" | "allocations" | "amount" | "attemptedAt" | "currency" | "expectedRevision" | "observations" | "operationKey" | "ownerKey" | "rejection" | "rejection.code" | "rejection.requestId" | "returnTransactionId" | "status" | "stripePayoutId">;
188
+ }, "required", "_creationTime" | "_id" | "accountId" | "allocations" | "amount" | "attemptedAt" | "currency" | "debitFee" | "debitTransactionId" | "destinationId" | "expectedRevision" | "feeRevision" | "observations" | "operationKey" | "ownerKey" | "providerFee" | "rejection" | "rejection.code" | "rejection.requestId" | "returnTransactionId" | "status" | "stripePayoutId">;
174
189
  export declare const claimsTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
175
190
  accountId: string;
176
191
  allocations: {
@@ -181,7 +196,11 @@ export declare const claimsTable: import("convex/server").TableDefinition<import
181
196
  amount: number;
182
197
  attemptedAt?: number | undefined;
183
198
  currency: string;
199
+ debitFee?: number | undefined;
200
+ debitTransactionId?: string | undefined;
201
+ destinationId?: string | undefined;
184
202
  expectedRevision: number;
203
+ feeRevision?: number | undefined;
185
204
  observations: {
186
205
  currency: string;
187
206
  ledgerFingerprint: string;
@@ -193,6 +212,7 @@ export declare const claimsTable: import("convex/server").TableDefinition<import
193
212
  }[];
194
213
  operationKey: string;
195
214
  ownerKey: string;
215
+ providerFee?: number | undefined;
196
216
  rejection?: {
197
217
  code: "amount_too_small" | "balance_insufficient";
198
218
  requestId: string;
@@ -207,6 +227,7 @@ export declare const claimsTable: import("convex/server").TableDefinition<import
207
227
  expectedRevision: import("convex/values").VFloat64<number, "required">;
208
228
  currency: import("convex/values").VString<string, "required">;
209
229
  amount: import("convex/values").VFloat64<number, "required">;
230
+ destinationId: import("convex/values").VString<string | undefined, "optional">;
210
231
  allocations: import("convex/values").VArray<{
211
232
  amount: number;
212
233
  role?: "affiliate" | "other" | "store" | undefined;
@@ -249,6 +270,10 @@ export declare const claimsTable: import("convex/server").TableDefinition<import
249
270
  attemptedAt: import("convex/values").VFloat64<number | undefined, "optional">;
250
271
  stripePayoutId: import("convex/values").VString<string | undefined, "optional">;
251
272
  returnTransactionId: import("convex/values").VString<string | undefined, "optional">;
273
+ feeRevision: import("convex/values").VFloat64<number | undefined, "optional">;
274
+ debitTransactionId: import("convex/values").VString<string | undefined, "optional">;
275
+ debitFee: import("convex/values").VFloat64<number | undefined, "optional">;
276
+ providerFee: import("convex/values").VFloat64<number | undefined, "optional">;
252
277
  rejection: import("convex/values").VObject<{
253
278
  code: "amount_too_small" | "balance_insufficient";
254
279
  requestId: string;
@@ -256,8 +281,9 @@ export declare const claimsTable: import("convex/server").TableDefinition<import
256
281
  requestId: import("convex/values").VString<string, "required">;
257
282
  code: import("convex/values").VUnion<"amount_too_small" | "balance_insufficient", [import("convex/values").VLiteral<"balance_insufficient", "required">, import("convex/values").VLiteral<"amount_too_small", "required">], "required", never>;
258
283
  }, "optional", "code" | "requestId">;
259
- }, "required", "accountId" | "allocations" | "amount" | "attemptedAt" | "currency" | "expectedRevision" | "observations" | "operationKey" | "ownerKey" | "rejection" | "rejection.code" | "rejection.requestId" | "returnTransactionId" | "status" | "stripePayoutId">, {
284
+ }, "required", "accountId" | "allocations" | "amount" | "attemptedAt" | "currency" | "debitFee" | "debitTransactionId" | "destinationId" | "expectedRevision" | "feeRevision" | "observations" | "operationKey" | "ownerKey" | "providerFee" | "rejection" | "rejection.code" | "rejection.requestId" | "returnTransactionId" | "status" | "stripePayoutId">, {
260
285
  by_account_status: ["accountId", "status", "_creationTime"];
286
+ by_debit_receipt: ["debitTransactionId", "_creationTime"];
261
287
  by_operation: ["operationKey", "_creationTime"];
262
288
  by_provider_payout: ["stripePayoutId", "_creationTime"];
263
289
  by_rejection_request: ["rejection.requestId", "_creationTime"];
@@ -286,4 +312,19 @@ export declare const identity: {
286
312
  ownerKey: import("convex/values").VString<string, "required">;
287
313
  operationKey: import("convex/values").VString<string, "required">;
288
314
  };
315
+ export declare const feeBalancesTable: import("convex/server").TableDefinition<import("convex/values").VObject<{
316
+ accountId: string;
317
+ amount: number;
318
+ currency: string;
319
+ ownerKey: string;
320
+ revision: number;
321
+ }, {
322
+ accountId: import("convex/values").VString<string, "required">;
323
+ ownerKey: import("convex/values").VString<string, "required">;
324
+ currency: import("convex/values").VString<string, "required">;
325
+ amount: import("convex/values").VFloat64<number, "required">;
326
+ revision: import("convex/values").VFloat64<number, "required">;
327
+ }, "required", "accountId" | "amount" | "currency" | "ownerKey" | "revision">, {
328
+ by_account_currency: ["accountId", "currency", "_creationTime"];
329
+ }, {}, {}>;
289
330
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/schema.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;wIAQtB,CAAC;AACH,eAAO,MAAM,UAAU;;;;;;;;sDAMrB,CAAC;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA4BvB,CAAC;AACF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;gSAInB,CAAC;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAKiC,CAAC;AAC1D,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;UAQY,CAAC;AACtC,eAAO,MAAM,QAAQ;;;;CAA+C,CAAC"}
1
+ {"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/schema.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;wIAQtB,CAAC;AACH,eAAO,MAAM,UAAU;;;;;;;;sDAMrB,CAAC;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiCvB,CAAC;AACF,eAAO,MAAM,QAAQ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;sXAInB,CAAC;AACH,eAAO,MAAM,WAAW;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAMiC,CAAC;AAC1D,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;UAQY,CAAC;AACtC,eAAO,MAAM,QAAQ;;;;CAA+C,CAAC;AAErE,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;UAK6B,CAAC"}
@@ -21,12 +21,17 @@ export const claimFields = {
21
21
  expectedRevision: v.number(),
22
22
  currency: v.string(),
23
23
  amount: v.number(),
24
+ destinationId: v.optional(v.string()),
24
25
  allocations: v.array(allocation),
25
26
  observations: v.array(observation),
26
27
  status: v.union(v.literal("reserved"), v.literal("submitted"), v.literal("paid"), v.literal("returned"), v.literal("canceled"), v.literal("rejected")),
27
28
  attemptedAt: v.optional(v.number()),
28
29
  stripePayoutId: v.optional(v.string()),
29
30
  returnTransactionId: v.optional(v.string()),
31
+ feeRevision: v.optional(v.number()),
32
+ debitTransactionId: v.optional(v.string()),
33
+ debitFee: v.optional(v.number()),
34
+ providerFee: v.optional(v.number()),
30
35
  rejection: v.optional(v.object({
31
36
  requestId: v.string(),
32
37
  code: v.union(v.literal("balance_insufficient"), v.literal("amount_too_small")),
@@ -41,6 +46,7 @@ export const claimsTable = defineTable(claimFields)
41
46
  .index("by_operation", ["operationKey"])
42
47
  .index("by_account_status", ["accountId", "status"])
43
48
  .index("by_provider_payout", ["stripePayoutId"])
49
+ .index("by_debit_receipt", ["debitTransactionId"])
44
50
  .index("by_return_receipt", ["returnTransactionId"])
45
51
  .index("by_rejection_request", ["rejection.requestId"]);
46
52
  export const sourcesTable = defineTable({
@@ -53,4 +59,10 @@ export const sourcesTable = defineTable({
53
59
  .index("by_transfer", ["stripeTransferId"])
54
60
  .index("by_account", ["accountId"]);
55
61
  export const identity = { ...scopeFields, operationKey: v.string() };
62
+ export const feeBalancesTable = defineTable({
63
+ ...scopeFields,
64
+ currency: v.string(),
65
+ amount: v.number(),
66
+ revision: v.number(),
67
+ }).index("by_account_currency", ["accountId", "currency"]);
56
68
  //# sourceMappingURL=schema.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../../src/component/payoutRelease/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,CAAC,EAAE,MAAM,eAAe,CAAC;AAClC,OAAO,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AACxD,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,CAAC,MAAM,CAAC;IAClC,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC5B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,SAAS,EAAE,CAAC,CAAC,MAAM,EAAE;IACrB,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;IAC1B,iBAAiB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC7B,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,cAAc,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC;CACpC,CAAC,CAAC;AACH,MAAM,CAAC,MAAM,UAAU,GAAG,CAAC,CAAC,MAAM,CAAC;IACjC,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC5B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,IAAI,EAAE,CAAC,CAAC,QAAQ,CACd,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,CAA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AAC;KAChD,KAAK,CAAC,cAAc,EAAE,CAAC,cAAc,CAAC,CAAC;KACvC,KAAK,CAAC,mBAAmB,EAAE,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;KACnD,KAAK,CAAC,oBAAoB,EAAE,CAAC,gBAAgB,CAAC,CAAC;KAC/C,KAAK,CAAC,kBAAkB,EAAE,CAAC,oBAAoB,CAAC,CAAC;KACjD,KAAK,CAAC,mBAAmB,EAAE,CAAC,qBAAqB,CAAC,CAAC;KACnD,KAAK,CAAC,sBAAsB,EAAE,CAAC,qBAAqB,CAAC,CAAC,CAAC;AAC1D,MAAM,CAAC,MAAM,YAAY,GAAG,WAAW,CAAC;IACtC,GAAG,WAAW;IACd,gBAAgB,EAAE,CAAC,CAAC,MAAM,EAAE;IAC5B,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,UAAU,EAAE,CAAC,CAAC,MAAM,EAAE;IACtB,cAAc,EAAE,CAAC,CAAC,MAAM,EAAE;CAC3B,CAAC;KACC,KAAK,CAAC,aAAa,EAAE,CAAC,kBAAkB,CAAC,CAAC;KAC1C,KAAK,CAAC,YAAY,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;AACtC,MAAM,CAAC,MAAM,QAAQ,GAAG,EAAE,GAAG,WAAW,EAAE,YAAY,EAAE,CAAC,CAAC,MAAM,EAAE,EAAE,CAAC;AAErE,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC;IAC1C,GAAG,WAAW;IACd,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;IACpB,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE;IAClB,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE;CACrB,CAAC,CAAC,KAAK,CAAC,qBAAqB,EAAE,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC,CAAC"}
@@ -1,4 +1,19 @@
1
1
  declare const _default: import("convex/server").SchemaDefinition<{
2
+ payoutFeeBalances: import("convex/server").TableDefinition<import("convex/values").VObject<{
3
+ accountId: string;
4
+ amount: number;
5
+ currency: string;
6
+ ownerKey: string;
7
+ revision: number;
8
+ }, {
9
+ accountId: import("convex/values").VString<string, "required">;
10
+ ownerKey: import("convex/values").VString<string, "required">;
11
+ currency: import("convex/values").VString<string, "required">;
12
+ amount: import("convex/values").VFloat64<number, "required">;
13
+ revision: import("convex/values").VFloat64<number, "required">;
14
+ }, "required", "accountId" | "amount" | "currency" | "ownerKey" | "revision">, {
15
+ by_account_currency: ["accountId", "currency", "_creationTime"];
16
+ }, {}, {}>;
2
17
  payoutReleaseClaims: import("convex/server").TableDefinition<import("convex/values").VObject<{
3
18
  accountId: string;
4
19
  allocations: {
@@ -9,7 +24,11 @@ declare const _default: import("convex/server").SchemaDefinition<{
9
24
  amount: number;
10
25
  attemptedAt?: number | undefined;
11
26
  currency: string;
27
+ debitFee?: number | undefined;
28
+ debitTransactionId?: string | undefined;
29
+ destinationId?: string | undefined;
12
30
  expectedRevision: number;
31
+ feeRevision?: number | undefined;
13
32
  observations: {
14
33
  currency: string;
15
34
  ledgerFingerprint: string;
@@ -21,6 +40,7 @@ declare const _default: import("convex/server").SchemaDefinition<{
21
40
  }[];
22
41
  operationKey: string;
23
42
  ownerKey: string;
43
+ providerFee?: number | undefined;
24
44
  rejection?: {
25
45
  code: "amount_too_small" | "balance_insufficient";
26
46
  requestId: string;
@@ -35,6 +55,7 @@ declare const _default: import("convex/server").SchemaDefinition<{
35
55
  expectedRevision: import("convex/values").VFloat64<number, "required">;
36
56
  currency: import("convex/values").VString<string, "required">;
37
57
  amount: import("convex/values").VFloat64<number, "required">;
58
+ destinationId: import("convex/values").VString<string | undefined, "optional">;
38
59
  allocations: import("convex/values").VArray<{
39
60
  amount: number;
40
61
  role?: "affiliate" | "other" | "store" | undefined;
@@ -77,6 +98,10 @@ declare const _default: import("convex/server").SchemaDefinition<{
77
98
  attemptedAt: import("convex/values").VFloat64<number | undefined, "optional">;
78
99
  stripePayoutId: import("convex/values").VString<string | undefined, "optional">;
79
100
  returnTransactionId: import("convex/values").VString<string | undefined, "optional">;
101
+ feeRevision: import("convex/values").VFloat64<number | undefined, "optional">;
102
+ debitTransactionId: import("convex/values").VString<string | undefined, "optional">;
103
+ debitFee: import("convex/values").VFloat64<number | undefined, "optional">;
104
+ providerFee: import("convex/values").VFloat64<number | undefined, "optional">;
80
105
  rejection: import("convex/values").VObject<{
81
106
  code: "amount_too_small" | "balance_insufficient";
82
107
  requestId: string;
@@ -84,8 +109,9 @@ declare const _default: import("convex/server").SchemaDefinition<{
84
109
  requestId: import("convex/values").VString<string, "required">;
85
110
  code: import("convex/values").VUnion<"amount_too_small" | "balance_insufficient", [import("convex/values").VLiteral<"balance_insufficient", "required">, import("convex/values").VLiteral<"amount_too_small", "required">], "required", never>;
86
111
  }, "optional", "code" | "requestId">;
87
- }, "required", "accountId" | "allocations" | "amount" | "attemptedAt" | "currency" | "expectedRevision" | "observations" | "operationKey" | "ownerKey" | "rejection" | "rejection.code" | "rejection.requestId" | "returnTransactionId" | "status" | "stripePayoutId">, {
112
+ }, "required", "accountId" | "allocations" | "amount" | "attemptedAt" | "currency" | "debitFee" | "debitTransactionId" | "destinationId" | "expectedRevision" | "feeRevision" | "observations" | "operationKey" | "ownerKey" | "providerFee" | "rejection" | "rejection.code" | "rejection.requestId" | "returnTransactionId" | "status" | "stripePayoutId">, {
88
113
  by_account_status: ["accountId", "status", "_creationTime"];
114
+ by_debit_receipt: ["debitTransactionId", "_creationTime"];
89
115
  by_operation: ["operationKey", "_creationTime"];
90
116
  by_provider_payout: ["stripePayoutId", "_creationTime"];
91
117
  by_rejection_request: ["rejection.requestId", "_creationTime"];
@@ -1,4 +1,4 @@
1
- import { claimsTable as payoutReleaseClaimsTable, sourcesTable as payoutSourceAllocationsTable, } from "./payoutRelease/schema.js";
1
+ import { feeBalancesTable as payoutFeeBalancesTable, claimsTable as payoutReleaseClaimsTable, sourcesTable as payoutSourceAllocationsTable, } from "./payoutRelease/schema.js";
2
2
  import { policiesTable, operationsTable } from "./payoutPolicy/schema.js";
3
3
  import { currencyTotalsTable } from "./earnings/schema.js";
4
4
  import { claimsTable, balancesTable, groupsTable, reservationsTable, } from "./costRecovery/schema";
@@ -10,6 +10,7 @@ import { accountsTable } from "./core/schema";
10
10
  import { pricesTable, productsTable } from "./products/schema";
11
11
  import { webhookEventsTable } from "./webhooks/schema";
12
12
  export default defineSchema({
13
+ payoutFeeBalances: payoutFeeBalancesTable,
13
14
  payoutReleaseClaims: payoutReleaseClaimsTable,
14
15
  payoutSourceAllocations: payoutSourceAllocationsTable,
15
16
  payoutPolicies: policiesTable,
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","sourceRoot":"","sources":["../../src/component/schema.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,IAAI,wBAAwB,EACvC,YAAY,IAAI,4BAA4B,GAC7C,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,aAAa,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAC1E,OAAO,EAAE,mBAAmB,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EACL,WAAW,EACX,aAAa,EACb,WAAW,EACX,iBAAiB,GAClB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EACL,gBAAgB,EAChB,oBAAoB,EACpB,wBAAwB,GACzB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAE7C,OAAO,EACL,qBAAqB,EACrB,aAAa,EACb,kBAAkB,GACnB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,aAAa,EACb,aAAa,EACb,YAAY,EACZ,sBAAsB,EACtB,YAAY,EACZ,wBAAwB,EACxB,cAAc,GACf,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,M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AE,wBAAwB;IAE7C,WAAW;IACX,aAAa,EAAE,kBAAkB;CAClC,CAAC,CAAC"}
@@ -222,8 +222,8 @@ Sources: [payout schedules](https://docs.stripe.com/connect/manage-payout-schedu
222
222
  ### Transactional claim ledger implementation status
223
223
 
224
224
  The component contains `payoutRelease` claim and source-allocation tables. These
225
- are server-side building blocks for the release boundary, with no public client
226
- executor or scheduled bank-payout integration yet. Do not call the claim
225
+ are server-side building blocks for the release boundary, with no automatic
226
+ payout-creation or scheduled bank-payout integration yet. Do not call the claim
227
227
  mutation with UI totals or a transfer receipt alone. Its trusted upstream caller
228
228
  must establish complete provider history, still-unpaid ownership, adoption of
229
229
  prior payouts, independent liabilities, and live payout controls first.
@@ -245,7 +245,7 @@ held. This window stays below Stripe's [24-hour v1 idempotency retention minimum
245
245
  The current claim snapshot is deliberately bounded to 100 account transfer rows
246
246
  and 1,000 receipt IDs per source. Larger or incomplete histories reject the whole
247
247
  claim, without using partial totals. A resumable reconciliation/adoption process,
248
- provider payout creation and receipt verification, payout-fee accounting, and
248
+ provider payout creation and receipt verification, historical fee adoption, other account debit allocation, and
249
249
  recurring release/expiry integration remain required before custom payout
250
250
  minimums can be presented as an operational feature. In-memory claim tests are
251
251
  not evidence of a completed Stripe bank payout.
@@ -299,3 +299,134 @@ remains intact for retries.
299
299
  Sources: [transfer provenance](https://docs.stripe.com/api/transfers/object),
300
300
  [receipt maturity](https://docs.stripe.com/api/balance_transactions/object), and
301
301
  [history pagination and payout-filter limits](https://docs.stripe.com/api/balance_transactions/list).
302
+
303
+ ## Verified payout receipts and reconciliation
304
+
305
+ In an authorized server action, read a Connect Stripe-balance payout with:
306
+
307
+ ```ts
308
+ const receipt = await stripe.payoutPolicy.payoutReceipt({
309
+ accountId,
310
+ stripePayoutId,
311
+ });
312
+ ```
313
+
314
+ The reader retrieves the payout and its actual account-scoped balance
315
+ transactions, including a failed/canceled payout's return transaction. It checks
316
+ transaction identity, currency, exact principal, signed fees, net amounts and
317
+ maturity, then re-reads the payout to detect changes. Expanded transaction
318
+ objects are not trusted in place of scoped retrieval. Automatic and manual
319
+ history can both be inspected; a manual payout receipt does not identify the
320
+ transfers that funded it. Changed snapshots, missing debit/return receipts,
321
+ pending debits or returns, unsupported currency allocation and bank-payout reversals return
322
+ `not_ready` without partial financial totals.
323
+
324
+ A ready receipt preserves `providerStatus`, original `debit`, optional returned
325
+ `credit`, `returnedPrincipal` and `returnedNet`. A returned principal can differ
326
+ from net cash because payout fees are retained or credited separately. This data
327
+ alone does not authorize releasing a reservation, identify still-unpaid earnings,
328
+ or prove that a pending payout reached the bank. Global Payouts requires a
329
+ separate receipt and capability implementation.
330
+
331
+ To reconcile an already attempted durable claim:
332
+
333
+ ```ts
334
+ const outcome = await stripe.payoutPolicy.reconcilePayout(ctx, {
335
+ accountId,
336
+ ownerKey,
337
+ operationKey,
338
+ // stripePayoutId, // optional when the provider ID is already known
339
+ maxPages: 10,
340
+ });
341
+ ```
342
+
343
+ The host authenticates the account/owner/operation before this call. Reconciliation
344
+ requires `ctx.runMutation`. It never creates or retries a bank payout. A stored
345
+ provider ID must agree with any supplied ID. Otherwise, bounded provider history
346
+ is scanned for the exact reserved `bsPayoutClaim` marker. Discovery must finish;
347
+ partial history, duplicate matches and a changed history head stay held. The
348
+ page budget is 1 to 100, default 10. No match, including after idempotency expiry,
349
+ never proves that money did not move.
350
+
351
+ Adoption verifies the claim marker, amount, currency, creation window and
352
+ standard manual bank-payout type. Current claims use the card source balance;
353
+ other source rails return an explicit allocation limitation. A missing or
354
+ immature return keeps allocations reserved. Verified paid and returned outcomes
355
+ update source allocations and payout fees in one component transaction. Unknown
356
+ provider and persistence errors propagate so the host can retry reconciliation.
357
+ Canceled/rejected claim states are returned as terminal states, not as bank
358
+ payment confirmation.
359
+
360
+ Net non-refundable payout fees are retained per recipient/currency and deducted
361
+ from later mature unpaid entitlement. They are not deducted again from fresh
362
+ provider availability, which already reflects the debit. A newly observed fee
363
+ invalidates an unattempted claim prepared against an older fee revision. Fee
364
+ credits after a return reduce only the verified original fee; excess credits
365
+ require explicit allocation. Original debit receipts and their fees remain
366
+ immutable. Older returned claims can receive verified fee evidence without
367
+ releasing their principal again.
368
+
369
+ These receipt APIs reconcile existing claims. Use the release API below for
370
+ qualification and creation; receipt reconciliation by itself does not enforce a
371
+ minimum.
372
+
373
+ ## Combined recipient release
374
+
375
+ After authorized custom policy activation, a host scheduled action can call:
376
+
377
+ ```ts
378
+ const result = await stripe.payoutPolicy.release(ctx, {
379
+ accountId,
380
+ ownerKey,
381
+ operationKey, // stable unique identity for this scheduled operation
382
+ currency: "usd",
383
+ independentLiabilities, // authorized outstanding off-provider debts/reserves
384
+ maxPages: 10,
385
+ });
386
+ ```
387
+
388
+ Authenticate the recipient and policy, and read all known off-provider debts and
389
+ reserves before invoking this server-only method. Never pass an untrusted client
390
+ amount or assume that an omitted debt is zero. Provider source refunds and payout
391
+ fees are already reconciled by the package and must not be counted again in
392
+ `independentLiabilities`. The host must install the recurring release and expiry
393
+ jobs before offering custom scheduling. This method does not install a cron.
394
+
395
+ The package verifies live manual schedule controls, reads every account source,
396
+ retrieves transfer and payout receipts, and compares the complete settlement
397
+ currency balance history with those verified receipts. Unknown credits, refunds,
398
+ fees and prior payouts return `held/unallocated_history`. A current balance is
399
+ never treated as proof of unpaid ownership. History must reconcile to the live
400
+ available and pending balance; changing or incomplete snapshots stay held.
401
+
402
+ Mature unpaid creator and affiliate sources qualify together in integer minor
403
+ units. Pending credits do not qualify. Outstanding source reservations, prior
404
+ paid allocations, actual refunds, payout fees and supplied independent liabilities
405
+ reduce eligibility. The cap uses the available card-source balance, since the
406
+ immutable provider request explicitly selects `source_type: "card"` and a
407
+ standard bank payout. The complete bank-account listing must identify one
408
+ default bank for the settlement currency. Its ID is persisted with the claim,
409
+ passed explicitly to Stripe, and checked again in the payout receipt. Other rails and currencies cannot increase that cap.
410
+
411
+ A qualifying operation reserves its exact source allocations in a component
412
+ transaction, verifies live controls again, and records the attempted marker before
413
+ calling Stripe. The provider idempotency key and request are fixed by the durable
414
+ claim. Concurrent callers therefore share one financial operation. Subsequent
415
+ calls to an attempted operation only reconcile provider receipts, including when
416
+ the original call timed out. They never blindly recreate an unidentified payout.
417
+ A verified no-object `balance_insufficient` or `amount_too_small` rejection releases
418
+ reservations; unknown errors keep them held. An interrupted unattempted operation
419
+ is canceled on replay, and a new scheduled operation can collect fresh receipts.
420
+ Below-threshold money remains owed. The numeric provider floor remains `null`
421
+ unless a supported provider contract exposes it.
422
+
423
+ Current atomic collection accepts up to 100 account transfers and 100 historical
424
+ claims. Larger accounts return `held/snapshot_limit`, without paying a partial
425
+ page. Provider history uses a 1–100 page budget, default 10; exhaustion stays held.
426
+ Explicit prior-payout/source adoption, resumable larger-account collection,
427
+ independent provider-debit allocation, recurring example jobs and React controls
428
+ remain integration work. Existing funded accounts still follow the policy
429
+ migration safeguards; do not bypass `migration_required` to activate this API.
430
+
431
+ Sources: [payout creation and source balance selection](https://docs.stripe.com/api/payouts/create),
432
+ [complete balance history and automatic-only payout filtering](https://docs.stripe.com/api/balance_transactions/list).