@fantastic.dev/better-stripe 0.28.6 → 0.29.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 (136) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/MIGRATION.md +6 -0
  3. package/README.md +5 -1
  4. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +28 -8
  5. package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
  6. package/dist/client/connect/payoutCollectedInput.d.ts +110 -0
  7. package/dist/client/connect/payoutCollectedInput.d.ts.map +1 -0
  8. package/dist/client/connect/payoutCollectedInput.js +70 -0
  9. package/dist/client/connect/payoutCollectedInput.js.map +1 -0
  10. package/dist/client/connect/payoutExecution.d.ts +1 -0
  11. package/dist/client/connect/payoutExecution.d.ts.map +1 -1
  12. package/dist/client/connect/payoutExecution.js +94 -67
  13. package/dist/client/connect/payoutExecution.js.map +1 -1
  14. package/dist/client/connect/payoutExecutionTestHelpers.d.ts +16 -4
  15. package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -1
  16. package/dist/client/connect/payoutExecutionTestHelpers.js +9 -6
  17. package/dist/client/connect/payoutExecutionTestHelpers.js.map +1 -1
  18. package/dist/client/connect/payoutPreview.d.ts +1 -0
  19. package/dist/client/connect/payoutPreview.d.ts.map +1 -1
  20. package/dist/client/connect/payoutPreview.js +31 -19
  21. package/dist/client/connect/payoutPreview.js.map +1 -1
  22. package/dist/client/connect/payoutQualification.d.ts +7 -1
  23. package/dist/client/connect/payoutQualification.d.ts.map +1 -1
  24. package/dist/client/connect/payoutQualification.js +34 -19
  25. package/dist/client/connect/payoutQualification.js.map +1 -1
  26. package/dist/client/connect/payoutSyncTestHelpers.d.ts +14 -4
  27. package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
  28. package/dist/client/connect/payoutWorker.d.ts.map +1 -1
  29. package/dist/client/connect/payoutWorker.js +4 -1
  30. package/dist/client/connect/payoutWorker.js.map +1 -1
  31. package/dist/client/costRecovery.d.ts +5 -0
  32. package/dist/client/costRecovery.d.ts.map +1 -1
  33. package/dist/client/costRecovery.js +5 -0
  34. package/dist/client/costRecovery.js.map +1 -1
  35. package/dist/client/payoutPolicy.d.ts +4 -0
  36. package/dist/client/payoutPolicy.d.ts.map +1 -1
  37. package/dist/component/_generated/component.d.ts +175 -0
  38. package/dist/component/_generated/component.d.ts.map +1 -1
  39. package/dist/component/costRecovery/mutations.js +1 -1
  40. package/dist/component/costRecovery/queries.d.ts +9 -0
  41. package/dist/component/costRecovery/queries.d.ts.map +1 -1
  42. package/dist/component/costRecovery/queries.js +20 -0
  43. package/dist/component/costRecovery/queries.js.map +1 -1
  44. package/dist/component/earnings/triggers.d.ts +16 -6
  45. package/dist/component/earnings/triggers.d.ts.map +1 -1
  46. package/dist/component/payoutRelease/adoption.d.ts +6 -0
  47. package/dist/component/payoutRelease/adoption.d.ts.map +1 -1
  48. package/dist/component/payoutRelease/helpers.d.ts +4 -1
  49. package/dist/component/payoutRelease/helpers.d.ts.map +1 -1
  50. package/dist/component/payoutRelease/helpers.js +17 -10
  51. package/dist/component/payoutRelease/helpers.js.map +1 -1
  52. package/dist/component/payoutRelease/mutations.d.ts +20 -0
  53. package/dist/component/payoutRelease/mutations.d.ts.map +1 -1
  54. package/dist/component/payoutRelease/mutations.js +14 -2
  55. package/dist/component/payoutRelease/mutations.js.map +1 -1
  56. package/dist/component/payoutRelease/planning.d.ts +4 -0
  57. package/dist/component/payoutRelease/planning.d.ts.map +1 -1
  58. package/dist/component/payoutRelease/planning.js +4 -2
  59. package/dist/component/payoutRelease/planning.js.map +1 -1
  60. package/dist/component/payoutRelease/preview.d.ts +2 -0
  61. package/dist/component/payoutRelease/preview.d.ts.map +1 -1
  62. package/dist/component/payoutRelease/preview.js +2 -0
  63. package/dist/component/payoutRelease/preview.js.map +1 -1
  64. package/dist/component/payoutRelease/queries.d.ts +11 -0
  65. package/dist/component/payoutRelease/queries.d.ts.map +1 -1
  66. package/dist/component/payoutRelease/schema.d.ts +17 -2
  67. package/dist/component/payoutRelease/schema.d.ts.map +1 -1
  68. package/dist/component/payoutRelease/schema.js +3 -0
  69. package/dist/component/payoutRelease/schema.js.map +1 -1
  70. package/dist/component/payoutSnapshots/financial.d.ts +35 -0
  71. package/dist/component/payoutSnapshots/financial.d.ts.map +1 -0
  72. package/dist/component/payoutSnapshots/financial.js +89 -0
  73. package/dist/component/payoutSnapshots/financial.js.map +1 -0
  74. package/dist/component/payoutSnapshots/liabilities.d.ts +7 -0
  75. package/dist/component/payoutSnapshots/liabilities.d.ts.map +1 -0
  76. package/dist/component/payoutSnapshots/liabilities.js +18 -0
  77. package/dist/component/payoutSnapshots/liabilities.js.map +1 -0
  78. package/dist/component/payoutSnapshots/localState.d.ts +2 -0
  79. package/dist/component/payoutSnapshots/localState.d.ts.map +1 -1
  80. package/dist/component/payoutSnapshots/localState.js +6 -3
  81. package/dist/component/payoutSnapshots/localState.js.map +1 -1
  82. package/dist/component/payoutSnapshots/mutations.d.ts +6 -0
  83. package/dist/component/payoutSnapshots/mutations.d.ts.map +1 -1
  84. package/dist/component/payoutSnapshots/mutations.js +2 -0
  85. package/dist/component/payoutSnapshots/mutations.js.map +1 -1
  86. package/dist/component/payoutSnapshots/queries.d.ts +133 -0
  87. package/dist/component/payoutSnapshots/queries.d.ts.map +1 -0
  88. package/dist/component/payoutSnapshots/queries.js +84 -0
  89. package/dist/component/payoutSnapshots/queries.js.map +1 -0
  90. package/dist/component/payoutSnapshots/revisions.d.ts.map +1 -1
  91. package/dist/component/payoutSnapshots/revisions.js +19 -0
  92. package/dist/component/payoutSnapshots/revisions.js.map +1 -1
  93. package/dist/component/payoutSnapshots/schema.d.ts +15 -5
  94. package/dist/component/payoutSnapshots/schema.d.ts.map +1 -1
  95. package/dist/component/payoutSnapshots/schema.js +3 -1
  96. package/dist/component/payoutSnapshots/schema.js.map +1 -1
  97. package/dist/component/payoutWorker/mutations.d.ts.map +1 -1
  98. package/dist/component/payoutWorker/mutations.js +3 -1
  99. package/dist/component/payoutWorker/mutations.js.map +1 -1
  100. package/dist/component/schema.d.ts +14 -4
  101. package/dist/react/workflows/payout-attempt-state.d.ts.map +1 -1
  102. package/dist/react/workflows/payout-attempt-state.js +3 -0
  103. package/dist/react/workflows/payout-attempt-state.js.map +1 -1
  104. package/dist/react/workflows/payout-progress-state.d.ts.map +1 -1
  105. package/dist/react/workflows/payout-progress-state.js +3 -0
  106. package/dist/react/workflows/payout-progress-state.js.map +1 -1
  107. package/docs/settlement.md +75 -16
  108. package/package.json +1 -1
  109. package/src/client/connect/payoutCollectedInput.ts +120 -0
  110. package/src/client/connect/payoutExecution.ts +116 -84
  111. package/src/client/connect/payoutExecutionTestHelpers.ts +19 -6
  112. package/src/client/connect/payoutLargeHistory.test.ts +222 -0
  113. package/src/client/connect/payoutLiabilityVersion.test.ts +221 -0
  114. package/src/client/connect/payoutPreview.ts +42 -24
  115. package/src/client/connect/payoutQualification.ts +62 -21
  116. package/src/client/connect/payoutWorker.ts +4 -1
  117. package/src/client/costRecovery.ts +8 -0
  118. package/src/component/_generated/api.ts +6 -0
  119. package/src/component/_generated/component.ts +203 -0
  120. package/src/component/costRecovery/mutations.ts +1 -1
  121. package/src/component/costRecovery/queries.ts +21 -0
  122. package/src/component/payoutRelease/helpers.ts +19 -11
  123. package/src/component/payoutRelease/mutations.ts +18 -1
  124. package/src/component/payoutRelease/planning.ts +7 -1
  125. package/src/component/payoutRelease/preview.ts +2 -0
  126. package/src/component/payoutRelease/schema.ts +3 -0
  127. package/src/component/payoutSnapshots/financial.ts +121 -0
  128. package/src/component/payoutSnapshots/liabilities.ts +25 -0
  129. package/src/component/payoutSnapshots/localState.ts +7 -3
  130. package/src/component/payoutSnapshots/mutations.ts +2 -0
  131. package/src/component/payoutSnapshots/queries.ts +102 -0
  132. package/src/component/payoutSnapshots/revisions.ts +26 -0
  133. package/src/component/payoutSnapshots/schema.ts +3 -0
  134. package/src/component/payoutWorker/mutations.ts +3 -1
  135. package/src/react/workflows/payout-attempt-state.ts +6 -0
  136. package/src/react/workflows/payout-progress-state.ts +6 -0
package/CHANGELOG.md CHANGED
@@ -26,6 +26,12 @@
26
26
  - Remove internal tracker references from public documentation and add a
27
27
  regression check that prevents their reintroduction.
28
28
 
29
+ ## [0.29.0](https://github.com/FantasticDevHQ/better-stripe/compare/v0.28.6...v0.29.0) (2026-10-15)
30
+
31
+ ### Features
32
+
33
+ - **payouts:** bind complete history and version recovery liabilities ([#222](https://github.com/FantasticDevHQ/better-stripe/issues/222)) ([65ee1e0](https://github.com/FantasticDevHQ/better-stripe/commit/65ee1e034309d687df9eb989d97437b87f607537))
34
+
29
35
  ## [0.28.6](https://github.com/FantasticDevHQ/better-stripe/compare/v0.28.5...v0.28.6) (2026-10-15)
30
36
 
31
37
  ### Bug Fixes
package/MIGRATION.md CHANGED
@@ -198,3 +198,9 @@ A cancellation timestamp at another date is not classified as period-end cancell
198
198
  See the [read contract guide](docs/read-contracts.md) for reactive product, price and payout
199
199
  cursors, exact currency summaries, legacy backfill, payout failure details, and
200
200
  published-version adoption requirements.
201
+
202
+ ## Versioned payout recovery quotes
203
+
204
+ Hosts with component recovery balance records must now pass `stripe.costRecovery.payoutQuote(ctx, authorizedScope)` into payout preview/release/worker options. Pass the returned `independentLiabilities` and `liabilityRevision` together for the same authorized account/currency/scope. Calls without a required version fail safely; accounts without recovery records retain the unversioned path. The example adapters are updated. Additional host-owned liabilities still require host authorization and consistency guards; the component version does not cover external databases.
205
+
206
+ Do not backfill old attempted claims with guessed quotes. Reconcile their existing request, or replay an unattempted operation to cancel its exact reservations, then use a new operation and fresh quote. Obsolete read-only collection fingerprints can be discarded and recollected; financially bound or unresolved claim state must remain intact.
package/README.md CHANGED
@@ -70,7 +70,7 @@ claim execution are completed.
70
70
 
71
71
  ## Status
72
72
 
73
- **Version**: `0.28.6` <!-- x-release-please-version --> (pre-1.0). API may change between minor versions until 1.0.
73
+ **Version**: `0.29.0` <!-- x-release-please-version --> (pre-1.0). API may change between minor versions until 1.0.
74
74
 
75
75
  Used in production by its authors. Webhook pipeline is covered by unit tests and a live E2E harness (`npm run e2e:webhooks`) that fires real Stripe-signed events and asserts the ledger.
76
76
 
@@ -1742,3 +1742,7 @@ Holding-expiry recovery remains visible and retryable after schedule restoration
1742
1742
  Automatic payout status is reusable through `payoutAttemptStatus`, `payoutAttemptValidator`, and the React `PayoutAttemptStatus` workflow. Rejection reasons and retry times remain separate from eligibility previews and bank arrival dates. See [React workflow guidance](docs/react-workflows.md).
1743
1743
 
1744
1744
  Payout qualification renews source verification for the selected currency only after a complete matching provider-history check. Slower receipt scans retain the same freshness and local reservation safeguards; partial or changed history stays held. See [settlement guidance](docs/settlement.md).
1745
+
1746
+ Automatic combined payouts use a complete paginated ledger collection above 100 historical sources or claims. The collection is checked and bound to the immutable claim before Stripe is contacted; incomplete scans resume without authorizing money. See [settlement guidance](docs/settlement.md#resumable-local-collections).
1747
+
1748
+ Resolve recovery-backed payout liabilities with `stripe.costRecovery.payoutQuote(ctx, authorizedScope)` and pass its amount/version together to preview or automatic release. The example does this for seller refund/dispute costs; stale or missing required versions fail safely. See [versioned liability guidance](docs/settlement.md#versioned-recovery-liabilities).
@@ -59,13 +59,13 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
59
59
  payoutRiskEvents: import("convex/server").TableDefinition<import("convex/values").VObject<{
60
60
  accountId: string;
61
61
  key: string;
62
- kind: "allocation" | "claim" | "fee" | "provider_payout" | "transfer";
62
+ kind: "allocation" | "claim" | "fee" | "liability" | "provider_payout" | "transfer";
63
63
  removed?: boolean | undefined;
64
64
  riskRevision: number;
65
65
  }, {
66
66
  accountId: import("convex/values").VString<string, "required">;
67
67
  riskRevision: import("convex/values").VFloat64<number, "required">;
68
- kind: import("convex/values").VUnion<"allocation" | "claim" | "fee" | "provider_payout" | "transfer", [import("convex/values").VLiteral<"transfer", "required">, import("convex/values").VLiteral<"provider_payout", "required">, import("convex/values").VLiteral<"allocation", "required">, import("convex/values").VLiteral<"claim", "required">, import("convex/values").VLiteral<"fee", "required">], "required", never>;
68
+ kind: import("convex/values").VUnion<"allocation" | "claim" | "fee" | "liability" | "provider_payout" | "transfer", [import("convex/values").VLiteral<"transfer", "required">, import("convex/values").VLiteral<"provider_payout", "required">, import("convex/values").VLiteral<"allocation", "required">, import("convex/values").VLiteral<"claim", "required">, import("convex/values").VLiteral<"fee", "required">, import("convex/values").VLiteral<"liability", "required">], "required", never>;
69
69
  key: import("convex/values").VString<string, "required">;
70
70
  removed: import("convex/values").VBoolean<boolean | undefined, "optional">;
71
71
  }, "required", "accountId" | "key" | "kind" | "removed" | "riskRevision">, {
@@ -84,6 +84,8 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
84
84
  accountId: string;
85
85
  allocationCount: number;
86
86
  allocationCursor?: string | undefined;
87
+ boundOperationKey?: string | undefined;
88
+ boundRiskRevision?: number | undefined;
87
89
  claimCount: number;
88
90
  claimCursor?: string | undefined;
89
91
  deferredPositiveChanges: boolean;
@@ -109,6 +111,8 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
109
111
  step: number;
110
112
  }, {
111
113
  readOnly: import("convex/values").VBoolean<boolean, "required">;
114
+ boundOperationKey: import("convex/values").VString<string | undefined, "optional">;
115
+ boundRiskRevision: import("convex/values").VFloat64<number | undefined, "optional">;
112
116
  accountId: import("convex/values").VString<string, "required">;
113
117
  ownerKey: import("convex/values").VString<string, "required">;
114
118
  operationKey: import("convex/values").VString<string, "required">;
@@ -134,7 +138,7 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
134
138
  providerChanged: import("convex/values").VBoolean<boolean, "required">;
135
139
  expiresAt: import("convex/values").VFloat64<number, "required">;
136
140
  reason: import("convex/values").VString<string | undefined, "optional">;
137
- }, "required", "accountId" | "allocationCount" | "allocationCursor" | "claimCount" | "claimCursor" | "deferredPositiveChanges" | "expectedRevision" | "expiresAt" | "feeCount" | "feeCursor" | "initialRevision" | "initialRiskRevision" | "observedRevision" | "operationKey" | "ownerKey" | "phase" | "policyMode" | "policyOperationKey" | "providerChanged" | "readOnly" | "reason" | "riskRevision" | "sourceCount" | "sourceCursor" | "sourceFence" | "step">, {
141
+ }, "required", "accountId" | "allocationCount" | "allocationCursor" | "boundOperationKey" | "boundRiskRevision" | "claimCount" | "claimCursor" | "deferredPositiveChanges" | "expectedRevision" | "expiresAt" | "feeCount" | "feeCursor" | "initialRevision" | "initialRiskRevision" | "observedRevision" | "operationKey" | "ownerKey" | "phase" | "policyMode" | "policyOperationKey" | "providerChanged" | "readOnly" | "reason" | "riskRevision" | "sourceCount" | "sourceCursor" | "sourceFence" | "step">, {
138
142
  by_account_phase: ["accountId", "phase", "_creationTime"];
139
143
  by_operation: ["operationKey", "_creationTime"];
140
144
  by_read_only: ["readOnly", "_creationTime"];
@@ -508,6 +512,8 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
508
512
  expectedRevision: number;
509
513
  feeRevision?: number | undefined;
510
514
  historical?: boolean | undefined;
515
+ independentLiabilities?: number | undefined;
516
+ liabilityRevision?: number | undefined;
511
517
  observations: {
512
518
  currency: string;
513
519
  ledgerFingerprint: string;
@@ -525,12 +531,16 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
525
531
  requestId: string;
526
532
  } | undefined;
527
533
  returnTransactionId?: string | undefined;
534
+ snapshotId?: import("convex/values").GenericId<"payoutSnapshots"> | undefined;
528
535
  status: "canceled" | "paid" | "rejected" | "reserved" | "returned" | "submitted";
529
536
  stripePayoutId?: string | undefined;
530
537
  }, {
531
538
  accountId: import("convex/values").VString<string, "required">;
532
539
  ownerKey: import("convex/values").VString<string, "required">;
533
540
  historical: import("convex/values").VBoolean<boolean | undefined, "optional">;
541
+ snapshotId: import("convex/values").VId<import("convex/values").GenericId<"payoutSnapshots"> | undefined, "optional">;
542
+ liabilityRevision: import("convex/values").VFloat64<number | undefined, "optional">;
543
+ independentLiabilities: import("convex/values").VFloat64<number | undefined, "optional">;
534
544
  operationKey: import("convex/values").VString<string, "required">;
535
545
  expectedRevision: import("convex/values").VFloat64<number, "required">;
536
546
  currency: import("convex/values").VString<string, "required">;
@@ -589,7 +599,7 @@ export declare function setup(amounts?: number[], currency?: string): Promise<{
589
599
  requestId: import("convex/values").VString<string, "required">;
590
600
  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>;
591
601
  }, "optional", "code" | "requestId">;
592
- }, "required", "accountId" | "allocations" | "amount" | "attemptedAt" | "currency" | "debitFee" | "debitTransactionId" | "destinationId" | "expectedRevision" | "feeRevision" | "historical" | "observations" | "operationKey" | "ownerKey" | "providerFee" | "rejection" | "rejection.code" | "rejection.requestId" | "returnTransactionId" | "status" | "stripePayoutId">, {
602
+ }, "required", "accountId" | "allocations" | "amount" | "attemptedAt" | "currency" | "debitFee" | "debitTransactionId" | "destinationId" | "expectedRevision" | "feeRevision" | "historical" | "independentLiabilities" | "liabilityRevision" | "observations" | "operationKey" | "ownerKey" | "providerFee" | "rejection" | "rejection.code" | "rejection.requestId" | "returnTransactionId" | "snapshotId" | "status" | "stripePayoutId">, {
593
603
  by_account_status: ["accountId", "status", "_creationTime"];
594
604
  by_debit_receipt: ["debitTransactionId", "_creationTime"];
595
605
  by_operation: ["operationKey", "_creationTime"];
@@ -1903,13 +1913,13 @@ export declare function historical(currency?: string): Promise<{
1903
1913
  payoutRiskEvents: import("convex/server").TableDefinition<import("convex/values").VObject<{
1904
1914
  accountId: string;
1905
1915
  key: string;
1906
- kind: "allocation" | "claim" | "fee" | "provider_payout" | "transfer";
1916
+ kind: "allocation" | "claim" | "fee" | "liability" | "provider_payout" | "transfer";
1907
1917
  removed?: boolean | undefined;
1908
1918
  riskRevision: number;
1909
1919
  }, {
1910
1920
  accountId: import("convex/values").VString<string, "required">;
1911
1921
  riskRevision: import("convex/values").VFloat64<number, "required">;
1912
- kind: import("convex/values").VUnion<"allocation" | "claim" | "fee" | "provider_payout" | "transfer", [import("convex/values").VLiteral<"transfer", "required">, import("convex/values").VLiteral<"provider_payout", "required">, import("convex/values").VLiteral<"allocation", "required">, import("convex/values").VLiteral<"claim", "required">, import("convex/values").VLiteral<"fee", "required">], "required", never>;
1922
+ kind: import("convex/values").VUnion<"allocation" | "claim" | "fee" | "liability" | "provider_payout" | "transfer", [import("convex/values").VLiteral<"transfer", "required">, import("convex/values").VLiteral<"provider_payout", "required">, import("convex/values").VLiteral<"allocation", "required">, import("convex/values").VLiteral<"claim", "required">, import("convex/values").VLiteral<"fee", "required">, import("convex/values").VLiteral<"liability", "required">], "required", never>;
1913
1923
  key: import("convex/values").VString<string, "required">;
1914
1924
  removed: import("convex/values").VBoolean<boolean | undefined, "optional">;
1915
1925
  }, "required", "accountId" | "key" | "kind" | "removed" | "riskRevision">, {
@@ -1928,6 +1938,8 @@ export declare function historical(currency?: string): Promise<{
1928
1938
  accountId: string;
1929
1939
  allocationCount: number;
1930
1940
  allocationCursor?: string | undefined;
1941
+ boundOperationKey?: string | undefined;
1942
+ boundRiskRevision?: number | undefined;
1931
1943
  claimCount: number;
1932
1944
  claimCursor?: string | undefined;
1933
1945
  deferredPositiveChanges: boolean;
@@ -1953,6 +1965,8 @@ export declare function historical(currency?: string): Promise<{
1953
1965
  step: number;
1954
1966
  }, {
1955
1967
  readOnly: import("convex/values").VBoolean<boolean, "required">;
1968
+ boundOperationKey: import("convex/values").VString<string | undefined, "optional">;
1969
+ boundRiskRevision: import("convex/values").VFloat64<number | undefined, "optional">;
1956
1970
  accountId: import("convex/values").VString<string, "required">;
1957
1971
  ownerKey: import("convex/values").VString<string, "required">;
1958
1972
  operationKey: import("convex/values").VString<string, "required">;
@@ -1978,7 +1992,7 @@ export declare function historical(currency?: string): Promise<{
1978
1992
  providerChanged: import("convex/values").VBoolean<boolean, "required">;
1979
1993
  expiresAt: import("convex/values").VFloat64<number, "required">;
1980
1994
  reason: import("convex/values").VString<string | undefined, "optional">;
1981
- }, "required", "accountId" | "allocationCount" | "allocationCursor" | "claimCount" | "claimCursor" | "deferredPositiveChanges" | "expectedRevision" | "expiresAt" | "feeCount" | "feeCursor" | "initialRevision" | "initialRiskRevision" | "observedRevision" | "operationKey" | "ownerKey" | "phase" | "policyMode" | "policyOperationKey" | "providerChanged" | "readOnly" | "reason" | "riskRevision" | "sourceCount" | "sourceCursor" | "sourceFence" | "step">, {
1995
+ }, "required", "accountId" | "allocationCount" | "allocationCursor" | "boundOperationKey" | "boundRiskRevision" | "claimCount" | "claimCursor" | "deferredPositiveChanges" | "expectedRevision" | "expiresAt" | "feeCount" | "feeCursor" | "initialRevision" | "initialRiskRevision" | "observedRevision" | "operationKey" | "ownerKey" | "phase" | "policyMode" | "policyOperationKey" | "providerChanged" | "readOnly" | "reason" | "riskRevision" | "sourceCount" | "sourceCursor" | "sourceFence" | "step">, {
1982
1996
  by_account_phase: ["accountId", "phase", "_creationTime"];
1983
1997
  by_operation: ["operationKey", "_creationTime"];
1984
1998
  by_read_only: ["readOnly", "_creationTime"];
@@ -2352,6 +2366,8 @@ export declare function historical(currency?: string): Promise<{
2352
2366
  expectedRevision: number;
2353
2367
  feeRevision?: number | undefined;
2354
2368
  historical?: boolean | undefined;
2369
+ independentLiabilities?: number | undefined;
2370
+ liabilityRevision?: number | undefined;
2355
2371
  observations: {
2356
2372
  currency: string;
2357
2373
  ledgerFingerprint: string;
@@ -2369,12 +2385,16 @@ export declare function historical(currency?: string): Promise<{
2369
2385
  requestId: string;
2370
2386
  } | undefined;
2371
2387
  returnTransactionId?: string | undefined;
2388
+ snapshotId?: import("convex/values").GenericId<"payoutSnapshots"> | undefined;
2372
2389
  status: "canceled" | "paid" | "rejected" | "reserved" | "returned" | "submitted";
2373
2390
  stripePayoutId?: string | undefined;
2374
2391
  }, {
2375
2392
  accountId: import("convex/values").VString<string, "required">;
2376
2393
  ownerKey: import("convex/values").VString<string, "required">;
2377
2394
  historical: import("convex/values").VBoolean<boolean | undefined, "optional">;
2395
+ snapshotId: import("convex/values").VId<import("convex/values").GenericId<"payoutSnapshots"> | undefined, "optional">;
2396
+ liabilityRevision: import("convex/values").VFloat64<number | undefined, "optional">;
2397
+ independentLiabilities: import("convex/values").VFloat64<number | undefined, "optional">;
2378
2398
  operationKey: import("convex/values").VString<string, "required">;
2379
2399
  expectedRevision: import("convex/values").VFloat64<number, "required">;
2380
2400
  currency: import("convex/values").VString<string, "required">;
@@ -2433,7 +2453,7 @@ export declare function historical(currency?: string): Promise<{
2433
2453
  requestId: import("convex/values").VString<string, "required">;
2434
2454
  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>;
2435
2455
  }, "optional", "code" | "requestId">;
2436
- }, "required", "accountId" | "allocations" | "amount" | "attemptedAt" | "currency" | "debitFee" | "debitTransactionId" | "destinationId" | "expectedRevision" | "feeRevision" | "historical" | "observations" | "operationKey" | "ownerKey" | "providerFee" | "rejection" | "rejection.code" | "rejection.requestId" | "returnTransactionId" | "status" | "stripePayoutId">, {
2456
+ }, "required", "accountId" | "allocations" | "amount" | "attemptedAt" | "currency" | "debitFee" | "debitTransactionId" | "destinationId" | "expectedRevision" | "feeRevision" | "historical" | "independentLiabilities" | "liabilityRevision" | "observations" | "operationKey" | "ownerKey" | "providerFee" | "rejection" | "rejection.code" | "rejection.requestId" | "returnTransactionId" | "snapshotId" | "status" | "stripePayoutId">, {
2437
2457
  by_account_status: ["accountId", "status", "_creationTime"];
2438
2458
  by_debit_receipt: ["debitTransactionId", "_creationTime"];
2439
2459
  by_operation: ["operationKey", "_creationTime"];
@@ -1 +1 @@
1
- {"version":3,"file":"payoutAdoptionTestHelpers.d.ts","sourceRoot":"","sources":["../../../src/client/connect/payoutAdoptionTestHelpers.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAKvD,eAAO,MAAM,SAAS,EAI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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqDrB"}
@@ -0,0 +1,110 @@
1
+ import type { Infer } from "convex/values";
2
+ import type { Component, RunCtx } from "../helpers.js";
3
+ import type { snapshotDoc } from "../../component/payoutSnapshots/schema.js";
4
+ import type { transferDocValidator } from "../../component/connect/validators.js";
5
+ import type { claimDoc } from "../../component/payoutRelease/schema.js";
6
+ export type CollectionRef = {
7
+ accountId: string;
8
+ ownerKey: string;
9
+ operationKey: string;
10
+ snapshotId: Infer<typeof snapshotDoc>["_id"];
11
+ };
12
+ export type PayoutInput = {
13
+ status: "ready";
14
+ transfers: Infer<typeof transferDocValidator>[];
15
+ claims: Infer<typeof claimDoc>[];
16
+ };
17
+ export declare function collectLargePayoutInput(component: Component, ctx: RunCtx, opts: {
18
+ accountId: string;
19
+ ownerKey: string;
20
+ operationKey?: string;
21
+ }, maxPages: number): Promise<{
22
+ status: "held";
23
+ reason: string;
24
+ transfers?: undefined;
25
+ claims?: undefined;
26
+ collection?: undefined;
27
+ } | {
28
+ status: "held";
29
+ reason: string;
30
+ collection: {
31
+ accountId: string;
32
+ ownerKey: string;
33
+ operationKey: string;
34
+ snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
35
+ };
36
+ transfers?: undefined;
37
+ claims?: undefined;
38
+ } | {
39
+ reason?: undefined;
40
+ status: "ready";
41
+ transfers: {
42
+ _creationTime: number;
43
+ _id: import("convex/values").GenericId<"transfers">;
44
+ amount: number;
45
+ currency: string;
46
+ destinationAccountId: string;
47
+ metadata?: any;
48
+ paymentId?: string | undefined;
49
+ reinstatement?: boolean | undefined;
50
+ reversalClaimedAmount?: number | undefined;
51
+ reversalStatus?: "fully_reversed" | "partially_reversed" | undefined;
52
+ reversedAmount?: number | undefined;
53
+ role?: "affiliate" | "other" | "store" | undefined;
54
+ sourceChargeId?: string | undefined;
55
+ sourceInvoiceId?: string | undefined;
56
+ status: "failed" | "paid" | "pending" | "reversed";
57
+ stripeTransferId: string;
58
+ totalsRecorded?: true | undefined;
59
+ }[];
60
+ claims: {
61
+ _creationTime: number;
62
+ _id: import("convex/values").GenericId<"payoutReleaseClaims">;
63
+ accountId: string;
64
+ allocations: {
65
+ amount: number;
66
+ role?: "affiliate" | "other" | "store" | undefined;
67
+ stripeTransferId: string;
68
+ }[];
69
+ amount: number;
70
+ attemptedAt?: number | undefined;
71
+ currency: string;
72
+ debitFee?: number | undefined;
73
+ debitTransactionId?: string | undefined;
74
+ destinationId?: string | undefined;
75
+ expectedRevision: number;
76
+ feeRevision?: number | undefined;
77
+ historical?: boolean | undefined;
78
+ independentLiabilities?: number | undefined;
79
+ liabilityRevision?: number | undefined;
80
+ observations: {
81
+ currency: string;
82
+ ledgerFingerprint: string;
83
+ matureNet: number;
84
+ observedAt: number;
85
+ pendingCredits: number;
86
+ stripeTransferId: string;
87
+ transactionIds: string[];
88
+ }[];
89
+ operationKey: string;
90
+ ownerKey: string;
91
+ providerFee?: number | undefined;
92
+ rejection?: {
93
+ code: "amount_too_small" | "balance_insufficient";
94
+ requestId: string;
95
+ } | undefined;
96
+ returnTransactionId?: string | undefined;
97
+ snapshotId?: import("convex/values").GenericId<"payoutSnapshots"> | undefined;
98
+ status: "canceled" | "paid" | "rejected" | "reserved" | "returned" | "submitted";
99
+ stripePayoutId?: string | undefined;
100
+ }[];
101
+ collection: {
102
+ accountId: string;
103
+ ownerKey: string;
104
+ operationKey: string;
105
+ snapshotId: import("convex/values").GenericId<"payoutSnapshots">;
106
+ };
107
+ }>;
108
+ /** Bound unattempted claims retain their cache. Attempted/terminal claims keep their own immutable financial proof. */
109
+ export declare function discardQualificationInput(component: Component, ctx: RunCtx, collection?: CollectionRef, keep?: boolean): Promise<void>;
110
+ //# sourceMappingURL=payoutCollectedInput.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payoutCollectedInput.d.ts","sourceRoot":"","sources":["../../../src/client/connect/payoutCollectedInput.ts"],"names":[],"mapp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
+ import { componentRef } from "../webhooks/helpers.js";
2
+ import { collectPayoutSnapshot, discardPayoutSnapshot, } from "./payoutCollection.js";
3
+ export async function collectLargePayoutInput(component, ctx, opts, maxPages) {
4
+ if (!ctx.runMutation)
5
+ return { status: "held", reason: "collection_requires_action" };
6
+ const policy = (await ctx.runQuery(componentRef(component, "payoutPolicy/queries/get"), { accountId: opts.accountId, ownerKey: opts.ownerKey }));
7
+ const scope = {
8
+ accountId: opts.accountId,
9
+ ownerKey: opts.ownerKey,
10
+ operationKey: opts.operationKey ?? crypto.randomUUID(),
11
+ };
12
+ let h = await collectPayoutSnapshot(component, ctx, {
13
+ ...scope,
14
+ expectedRevision: policy?.revision ?? -1,
15
+ });
16
+ for (let i = 0; i < maxPages * 25 && h.phase !== "local_ready" && h.phase !== "invalidated"; i++)
17
+ h = await collectPayoutSnapshot(component, ctx, {
18
+ ...scope,
19
+ expectedRevision: h.expectedRevision,
20
+ expectedStep: h.step,
21
+ });
22
+ const collection = { ...scope, snapshotId: h._id };
23
+ if (h.phase !== "local_ready")
24
+ return {
25
+ status: "held",
26
+ reason: h.phase === "invalidated"
27
+ ? "collection_invalidated"
28
+ : "collection_pending",
29
+ collection,
30
+ };
31
+ async function pages(kind, count) {
32
+ const rows = [];
33
+ let cursor = null;
34
+ for (let i = 0; i <= Math.ceil(count / 25); i++) {
35
+ const page = (await ctx.runQuery(componentRef(component, `payoutSnapshots/queries/${kind}`), { ...scope, paginationOpts: { cursor, numItems: 25 } }));
36
+ rows.push(...page.page);
37
+ if (page.isDone) {
38
+ if (rows.length !== count)
39
+ throw new Error("Collected payout membership changed.");
40
+ return rows;
41
+ }
42
+ if (!page.continueCursor || page.continueCursor === cursor)
43
+ throw new Error("Collected payout cursor did not advance.");
44
+ cursor = page.continueCursor;
45
+ }
46
+ throw new Error("Collected payout page budget exhausted; preserve collection for retry.");
47
+ }
48
+ return {
49
+ status: "ready",
50
+ transfers: await pages("sources", h.sourceCount),
51
+ claims: await pages("claims", h.claimCount),
52
+ collection,
53
+ };
54
+ }
55
+ /** Bound unattempted claims retain their cache. Attempted/terminal claims keep their own immutable financial proof. */
56
+ export async function discardQualificationInput(component, ctx, collection, keep = false) {
57
+ if (!collection || keep || !ctx.runMutation)
58
+ return;
59
+ const { snapshotId: _, ...scope } = collection;
60
+ const h = (await ctx.runQuery(componentRef(component, "payoutSnapshots/queries/get"), scope));
61
+ if (!h?.readOnly)
62
+ return;
63
+ for (let i = 0; i < 1000; i++)
64
+ if (!(await discardPayoutSnapshot(component, ctx, {
65
+ ...scope,
66
+ batchSize: 100,
67
+ })))
68
+ return;
69
+ }
70
+ //# sourceMappingURL=payoutCollectedInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"payoutCollectedInput.js","sourceRoot":"","sources":["../../../src/client/connect/payoutCollectedInput.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AACtD,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,uBAAuB,CAAC;AAY/B,MAAM,CAAC,KAAK,UAAU,uBAAuB,CAC3C,SAAoB,EACpB,GAAW,EACX,IAAoE,EACpE,QAAgB;IAEhB,IAAI,CAAC,GAAG,CAAC,WAAW;QAClB,OAAO,EAAE,MAAM,EAAE,MAAe,EAAE,MAAM,EAAE,4BAA4B,EAAE,CAAC;IAC3E,MAAM,MAAM,GAAG,CAAC,MAAM,GAAG,CAAC,QAAQ,CAChC,YAAY,CAAC,SAAS,EAAE,0BAA0B,CAAC,EACnD,EAAE,SAAS,EAAE,IAAI,CAAC,SAAS,EAAE,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,CACvD,CAAgC,CAAC;IAClC,MAAM,KAAK,GAAG;QACZ,SAAS,EAAE,IAAI,CAAC,SAAS;QACzB,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,YAAY,EAAE,IAAI,CAAC,YAAY,IAAI,MAAM,CAAC,UAAU,EAAE;KACvD,CAAC;IACF,IA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,GAAG,IAAI,EAAE,CAAC,EAAE;QAC3B,IACE,CAAC,CAAC,MAAM,qBAAqB,CAAC,SAAS,EAAE,GAAG,EAAE;YAC5C,GAAG,KAAK;YACR,SAAS,EAAE,GAAG;SACf,CAAC,CAAC;YAEH,OAAO;AACb,CAAC"}
@@ -11,6 +11,7 @@ export type PayoutReleaseOptions = {
11
11
  currency: string;
12
12
  /** Host supplies all authorized off-provider debts/reserves, without double counting provider receipt debits. */
13
13
  independentLiabilities: number;
14
+ liabilityRevision?: number;
14
15
  maxPages?: number;
15
16
  };
16
17
  type Held = {
@@ -1 +1 @@
1
- {"version":3,"file":"payoutExecution.d.ts","sourceRoot":"","sources":["../../../src/client/connect/payoutExecution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIvD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAC;AAGxE,OAAO,EAEL,KAAK,oBAAoB,EAC1B,MAAM,2BAA2B,CAAC;AAEnC,KAAK,MAAM,GAAG,KAAK,CAAC,OAAO,SAAS,CAAC,CAAC;AACtC,MAAM,MAAM,oBAAoB,GAAG;IACjC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,MAAM,CAAC;IACjB,iHAAiH;IACjH,sBAAsB,EAAE,MAAM,CAAC;IAC/B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,CAAC;AACF,KAAK,IAAI,GAAG;IAAE,MAAM,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AAC/C,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,GAAG,IAAI,CAAC;AAC9D;;;;;GAKG;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AC1C,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,oBAAoB,EAC1B,MAAM,EAAE,MAAM,OAAO,CACnB;IAAE,MAAM,EAAE,UAAU,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,MAAM,EAAE,MAAM,CAAA;CAAE,CAC5D,GACA,OAAO,CAAC,mBAAmB,CAAC,CAuK9B"}
@@ -1,3 +1,4 @@
1
+ import { discardQualificationInput } from "./payoutCollectedInput.js";
1
2
  import { runMutationOrThrow } from "../helpers.js";
2
3
  import { componentRef } from "../webhooks/helpers.js";
3
4
  import { validateIdentity } from "../../component/payoutRelease/helpers.js";
@@ -29,86 +30,112 @@ export async function releaseRecipientPayout(stripe, component, ctx, opts, verif
29
30
  if (existing) {
30
31
  if (existing.currency !== opts.currency)
31
32
  throw new Error("Payout claim currency cannot be changed.");
32
- if (existing.attemptedAt !== undefined || existing.status !== "reserved")
33
- return reconcileRecipientPayout(stripe, component, ctx, {
34
- ...identity,
35
- maxPages,
36
- });
33
+ if (existing.attemptedAt !== undefined || existing.status !== "reserved") {
34
+ try {
35
+ return await reconcileRecipientPayout(stripe, component, ctx, {
36
+ ...identity,
37
+ maxPages,
38
+ });
39
+ }
40
+ finally {
41
+ if (existing.snapshotId)
42
+ await discardQualificationInput(component, ctx, {
43
+ ...identity,
44
+ snapshotId: existing.snapshotId,
45
+ });
46
+ }
47
+ }
37
48
  // A crash before the attempt has no provider side effect. Release its exact
38
49
  // reservations; the next scheduled operation must collect fresh receipts.
39
50
  const claim = (await runMutationOrThrow(ctx, componentRef(component, "payoutRelease/mutations/cancelUnattempted"), identity));
51
+ if (existing.snapshotId)
52
+ await discardQualificationInput(component, ctx, {
53
+ ...identity,
54
+ snapshotId: existing.snapshotId,
55
+ });
40
56
  return { status: "terminal", claim };
41
57
  }
42
58
  const controls = await verify();
43
59
  if (controls.status !== "verified" || !("policy" in controls))
44
60
  return { status: "held", reason: controls.status };
45
61
  const proof = await collectPayoutQualification(stripe, component, ctx, opts, maxPages);
46
- if (proof.status !== "verified")
47
- return proof;
48
- const claim = (await runMutationOrThrow(ctx, componentRef(component, "payoutRelease/mutations/claim"), {
49
- ...identity,
50
- expectedRevision: controls.policy.revision,
51
- currency: opts.currency,
52
- destinationId: proof.destinationId,
53
- providerAvailable: proof.providerAvailable,
54
- independentLiabilities: opts.independentLiabilities,
55
- observations: proof.observations,
56
- }));
57
- if (claim.status === "held")
58
- return claim;
59
- // Another caller can win this operation while receipts were being collected.
60
- if (claim.attemptedAt !== undefined || claim.status !== "reserved")
61
- return reconcileRecipientPayout(stripe, component, ctx, {
62
+ try {
63
+ if (proof.status !== "verified")
64
+ return { status: "held", reason: proof.reason };
65
+ const claim = (await runMutationOrThrow(ctx, componentRef(component, "payoutRelease/mutations/claim"), {
66
+ ...identity,
67
+ expectedRevision: controls.policy.revision,
68
+ currency: opts.currency,
69
+ destinationId: proof.destinationId,
70
+ providerAvailable: proof.providerAvailable,
71
+ independentLiabilities: opts.independentLiabilities,
72
+ observations: proof.observations,
73
+ ...(opts.liabilityRevision === undefined
74
+ ? {}
75
+ : { liabilityRevision: opts.liabilityRevision }),
76
+ ...(proof.collection
77
+ ? { snapshotId: proof.collection.snapshotId }
78
+ : {}),
79
+ }));
80
+ if (claim.status === "held")
81
+ return claim;
82
+ // Another caller can win this operation while receipts were being collected.
83
+ if (claim.attemptedAt !== undefined || claim.status !== "reserved")
84
+ return reconcileRecipientPayout(stripe, component, ctx, {
85
+ ...identity,
86
+ maxPages,
87
+ });
88
+ const latest = await verify();
89
+ if (latest.status !== "verified" ||
90
+ !("policy" in latest) ||
91
+ latest.policy.revision !== controls.policy.revision) {
92
+ await runMutationOrThrow(ctx, componentRef(component, "payoutRelease/mutations/cancelUnattempted"), identity);
93
+ return {
94
+ status: "held",
95
+ reason: latest.status === "verified" ? "policy_changed" : latest.status,
96
+ };
97
+ }
98
+ await runMutationOrThrow(ctx, componentRef(component, "payoutRelease/mutations/beginAttempt"), identity);
99
+ let payout;
100
+ try {
101
+ payout = await stripe.payouts.create({
102
+ amount: claim.amount,
103
+ currency: claim.currency,
104
+ destination: claim.destinationId,
105
+ method: "standard",
106
+ source_type: "card",
107
+ metadata: { bsPayoutClaim: claim.operationKey },
108
+ }, {
109
+ stripeAccount: claim.accountId,
110
+ idempotencyKey: `bs:payout-release:${claim.operationKey}`,
111
+ });
112
+ }
113
+ catch (error) {
114
+ if (error instanceof Error &&
115
+ "type" in error &&
116
+ error.type === "StripeInvalidRequestError" &&
117
+ "code" in error &&
118
+ ["balance_insufficient", "amount_too_small"].includes(String(error.code)) &&
119
+ "requestId" in error &&
120
+ typeof error.requestId === "string" &&
121
+ /^req_\w+$/.test(error.requestId)) {
122
+ const saved = (await runMutationOrThrow(ctx, componentRef(component, "payoutRelease/mutations/recordRejection"), {
123
+ ...identity,
124
+ requestId: error.requestId,
125
+ code: error.code,
126
+ }));
127
+ return { status: "terminal", claim: saved };
128
+ }
129
+ throw error;
130
+ }
131
+ return await reconcileRecipientPayout(stripe, component, ctx, {
62
132
  ...identity,
133
+ stripePayoutId: payout.id,
63
134
  maxPages,
64
135
  });
65
- const latest = await verify();
66
- if (latest.status !== "verified" ||
67
- !("policy" in latest) ||
68
- latest.policy.revision !== controls.policy.revision) {
69
- await runMutationOrThrow(ctx, componentRef(component, "payoutRelease/mutations/cancelUnattempted"), identity);
70
- return {
71
- status: "held",
72
- reason: latest.status === "verified" ? "policy_changed" : latest.status,
73
- };
74
136
  }
75
- await runMutationOrThrow(ctx, componentRef(component, "payoutRelease/mutations/beginAttempt"), identity);
76
- let payout;
77
- try {
78
- payout = await stripe.payouts.create({
79
- amount: claim.amount,
80
- currency: claim.currency,
81
- destination: claim.destinationId,
82
- method: "standard",
83
- source_type: "card",
84
- metadata: { bsPayoutClaim: claim.operationKey },
85
- }, {
86
- stripeAccount: claim.accountId,
87
- idempotencyKey: `bs:payout-release:${claim.operationKey}`,
88
- });
89
- }
90
- catch (error) {
91
- if (error instanceof Error &&
92
- "type" in error &&
93
- error.type === "StripeInvalidRequestError" &&
94
- "code" in error &&
95
- ["balance_insufficient", "amount_too_small"].includes(String(error.code)) &&
96
- "requestId" in error &&
97
- typeof error.requestId === "string" &&
98
- /^req_\w+$/.test(error.requestId)) {
99
- const saved = (await runMutationOrThrow(ctx, componentRef(component, "payoutRelease/mutations/recordRejection"), {
100
- ...identity,
101
- requestId: error.requestId,
102
- code: error.code,
103
- }));
104
- return { status: "terminal", claim: saved };
105
- }
106
- throw error;
137
+ finally {
138
+ await discardQualificationInput(component, ctx, proof.collection, proof.status === "held" && proof.reason === "collection_pending");
107
139
  }
108
- return reconcileRecipientPayout(stripe, component, ctx, {
109
- ...identity,
110
- stripePayoutId: payout.id,
111
- maxPages,
112
- });
113
140
  }
114
141
  //# sourceMappingURL=payoutExecution.js.map