@fantastic.dev/better-stripe 0.23.2 → 0.24.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.
- package/CHANGELOG.md +20 -2
- package/README.md +40 -5
- package/dist/client/affiliateRecovery/disputes.d.ts +18 -0
- package/dist/client/affiliateRecovery/disputes.d.ts.map +1 -0
- package/dist/client/affiliateRecovery/disputes.js +33 -0
- package/dist/client/affiliateRecovery/disputes.js.map +1 -0
- package/dist/client/affiliateRecovery/engine.d.ts +29 -0
- package/dist/client/affiliateRecovery/engine.d.ts.map +1 -0
- package/dist/client/affiliateRecovery/engine.js +116 -0
- package/dist/client/affiliateRecovery/engine.js.map +1 -0
- package/dist/client/affiliateRecovery/payoutGate.d.ts +24 -0
- package/dist/client/affiliateRecovery/payoutGate.d.ts.map +1 -0
- package/dist/client/affiliateRecovery/payoutGate.js +30 -0
- package/dist/client/affiliateRecovery/payoutGate.js.map +1 -0
- package/dist/client/affiliateRecovery/provider.d.ts +14 -0
- package/dist/client/affiliateRecovery/provider.d.ts.map +1 -0
- package/dist/client/affiliateRecovery/provider.js +96 -0
- package/dist/client/affiliateRecovery/provider.js.map +1 -0
- package/dist/client/affiliateRecovery/review.d.ts +28 -0
- package/dist/client/affiliateRecovery/review.d.ts.map +1 -0
- package/dist/client/affiliateRecovery/review.js +86 -0
- package/dist/client/affiliateRecovery/review.js.map +1 -0
- package/dist/client/affiliateRecovery/validators.d.ts +402 -0
- package/dist/client/affiliateRecovery/validators.d.ts.map +1 -0
- package/dist/client/affiliateRecovery/validators.js +27 -0
- package/dist/client/affiliateRecovery/validators.js.map +1 -0
- package/dist/client/affiliateRecovery.d.ts +131 -0
- package/dist/client/affiliateRecovery.d.ts.map +1 -0
- package/dist/client/affiliateRecovery.js +69 -0
- package/dist/client/affiliateRecovery.js.map +1 -0
- package/dist/client/connect/commissionReceipts.d.ts +4 -0
- package/dist/client/connect/commissionReceipts.d.ts.map +1 -0
- package/dist/client/connect/commissionReceipts.js +17 -0
- package/dist/client/connect/commissionReceipts.js.map +1 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +494 -2
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +247 -1
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payouts.d.ts +3 -1
- package/dist/client/connect/payouts.d.ts.map +1 -1
- package/dist/client/connect/payouts.js +45 -12
- package/dist/client/connect/payouts.js.map +1 -1
- package/dist/client/connect/refundPrincipal.d.ts +4 -0
- package/dist/client/connect/refundPrincipal.d.ts.map +1 -0
- package/dist/client/connect/refundPrincipal.js +21 -0
- package/dist/client/connect/refundPrincipal.js.map +1 -0
- package/dist/client/connect/reversalExecution.d.ts +47 -0
- package/dist/client/connect/reversalExecution.d.ts.map +1 -0
- package/dist/client/connect/reversalExecution.js +84 -0
- package/dist/client/connect/reversalExecution.js.map +1 -0
- package/dist/client/connect/transfers.d.ts +8 -4
- package/dist/client/connect/transfers.d.ts.map +1 -1
- package/dist/client/connect/transfers.js +52 -57
- package/dist/client/connect/transfers.js.map +1 -1
- package/dist/client/index.d.ts +3 -0
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +6 -1
- package/dist/client/index.js.map +1 -1
- package/dist/client/settlement/execution.d.ts.map +1 -1
- package/dist/client/settlement/execution.js +30 -3
- package/dist/client/settlement/execution.js.map +1 -1
- package/dist/client/settlement/reconciliation.d.ts.map +1 -1
- package/dist/client/settlement/reconciliation.js +16 -2
- package/dist/client/settlement/reconciliation.js.map +1 -1
- package/dist/client/webhooks/disputeRecovery.d.ts +4 -0
- package/dist/client/webhooks/disputeRecovery.d.ts.map +1 -0
- package/dist/client/webhooks/disputeRecovery.js +40 -0
- package/dist/client/webhooks/disputeRecovery.js.map +1 -0
- package/dist/client/webhooks/processors.d.ts.map +1 -1
- package/dist/client/webhooks/processors.js +14 -29
- package/dist/client/webhooks/processors.js.map +1 -1
- package/dist/component/_generated/component.d.ts +491 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/affiliateEarnings/mutations.d.ts +22 -0
- package/dist/component/affiliateEarnings/mutations.d.ts.map +1 -0
- package/dist/component/affiliateEarnings/mutations.js +160 -0
- package/dist/component/affiliateEarnings/mutations.js.map +1 -0
- package/dist/component/affiliatePayouts/mutations.d.ts +25 -0
- package/dist/component/affiliatePayouts/mutations.d.ts.map +1 -0
- package/dist/component/affiliatePayouts/mutations.js +104 -0
- package/dist/component/affiliatePayouts/mutations.js.map +1 -0
- package/dist/component/affiliatePayouts/queries.d.ts +23 -0
- package/dist/component/affiliatePayouts/queries.d.ts.map +1 -0
- package/dist/component/affiliatePayouts/queries.js +23 -0
- package/dist/component/affiliatePayouts/queries.js.map +1 -0
- package/dist/component/affiliatePayouts/recipientGuard.d.ts +12 -0
- package/dist/component/affiliatePayouts/recipientGuard.d.ts.map +1 -0
- package/dist/component/affiliatePayouts/recipientGuard.js +26 -0
- package/dist/component/affiliatePayouts/recipientGuard.js.map +1 -0
- package/dist/component/affiliateRecovery/accounting.d.ts +28 -0
- package/dist/component/affiliateRecovery/accounting.d.ts.map +1 -0
- package/dist/component/affiliateRecovery/accounting.js +71 -0
- package/dist/component/affiliateRecovery/accounting.js.map +1 -0
- package/dist/component/affiliateRecovery/mutations.d.ts +65 -0
- package/dist/component/affiliateRecovery/mutations.d.ts.map +1 -0
- package/dist/component/affiliateRecovery/mutations.js +250 -0
- package/dist/component/affiliateRecovery/mutations.js.map +1 -0
- package/dist/component/affiliateRecovery/queries.d.ts +305 -0
- package/dist/component/affiliateRecovery/queries.d.ts.map +1 -0
- package/dist/component/affiliateRecovery/queries.js +113 -0
- package/dist/component/affiliateRecovery/queries.js.map +1 -0
- package/dist/component/affiliateRecovery/schema.d.ts +171 -0
- package/dist/component/affiliateRecovery/schema.d.ts.map +1 -0
- package/dist/component/affiliateRecovery/schema.js +71 -0
- package/dist/component/affiliateRecovery/schema.js.map +1 -0
- package/dist/component/connect/mutations.d.ts +36 -23
- package/dist/component/connect/mutations.d.ts.map +1 -1
- package/dist/component/connect/mutations.js +7 -124
- package/dist/component/connect/mutations.js.map +1 -1
- package/dist/component/connect/queries.d.ts +10 -0
- package/dist/component/connect/queries.d.ts.map +1 -1
- package/dist/component/connect/queries.js +3 -40
- package/dist/component/connect/queries.js.map +1 -1
- package/dist/component/connect/reversalClaims.d.ts +169 -0
- package/dist/component/connect/reversalClaims.d.ts.map +1 -0
- package/dist/component/connect/reversalClaims.js +176 -0
- package/dist/component/connect/reversalClaims.js.map +1 -0
- package/dist/component/connect/reversalDiagnostics.d.ts +59 -0
- package/dist/component/connect/reversalDiagnostics.d.ts.map +1 -0
- package/dist/component/connect/reversalDiagnostics.js +50 -0
- package/dist/component/connect/reversalDiagnostics.js.map +1 -0
- package/dist/component/connect/reversalReceipts.d.ts +27 -0
- package/dist/component/connect/reversalReceipts.d.ts.map +1 -0
- package/dist/component/connect/reversalReceipts.js +85 -0
- package/dist/component/connect/reversalReceipts.js.map +1 -0
- package/dist/component/connect/schema.d.ts +31 -1
- package/dist/component/connect/schema.d.ts.map +1 -1
- package/dist/component/connect/schema.js +3 -1
- package/dist/component/connect/schema.js.map +1 -1
- package/dist/component/connect/validators.d.ts +49 -1
- package/dist/component/connect/validators.d.ts.map +1 -1
- package/dist/component/connect/validators.js +2 -0
- package/dist/component/connect/validators.js.map +1 -1
- package/dist/component/earnings/triggers.d.ts +410 -2
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/payoutRelease/mutations.d.ts.map +1 -1
- package/dist/component/payoutRelease/mutations.js +6 -0
- package/dist/component/payoutRelease/mutations.js.map +1 -1
- package/dist/component/payoutRelease/queries.d.ts.map +1 -1
- package/dist/component/payoutRelease/queries.js +3 -1
- package/dist/component/payoutRelease/queries.js.map +1 -1
- package/dist/component/schema.d.ts +247 -1
- package/dist/component/schema.js +9 -0
- package/dist/component/schema.js.map +1 -1
- package/dist/component/settlement/clawbackSchema.d.ts +161 -0
- package/dist/component/settlement/clawbackSchema.d.ts.map +1 -0
- package/dist/component/settlement/clawbackSchema.js +73 -0
- package/dist/component/settlement/clawbackSchema.js.map +1 -0
- package/dist/component/settlement/clawbacks.d.ts +55 -0
- package/dist/component/settlement/clawbacks.d.ts.map +1 -0
- package/dist/component/settlement/clawbacks.js +146 -0
- package/dist/component/settlement/clawbacks.js.map +1 -0
- package/dist/component/settlement/mutations.d.ts +16 -0
- package/dist/component/settlement/mutations.d.ts.map +1 -1
- package/dist/component/settlement/mutations.js +48 -0
- package/dist/component/settlement/mutations.js.map +1 -1
- package/dist/component/settlement/queries.d.ts +53 -0
- package/dist/component/settlement/queries.d.ts.map +1 -1
- package/dist/component/settlement/queries.js +26 -0
- package/dist/component/settlement/queries.js.map +1 -1
- package/dist/react/workflows/AffiliateRecovery.d.ts +46 -0
- package/dist/react/workflows/AffiliateRecovery.d.ts.map +1 -0
- package/dist/react/workflows/AffiliateRecovery.js +84 -0
- package/dist/react/workflows/AffiliateRecovery.js.map +1 -0
- package/dist/react/workflows/index.d.ts +2 -0
- package/dist/react/workflows/index.d.ts.map +1 -1
- package/dist/react/workflows/index.js +1 -0
- package/dist/react/workflows/index.js.map +1 -1
- package/dist/testing/affiliate-recovery.d.ts +10 -0
- package/dist/testing/affiliate-recovery.d.ts.map +1 -0
- package/dist/testing/affiliate-recovery.js +126 -0
- package/dist/testing/affiliate-recovery.js.map +1 -0
- package/dist/testing/index.d.ts +2 -0
- package/dist/testing/index.d.ts.map +1 -1
- package/dist/testing/index.js +1 -0
- package/dist/testing/index.js.map +1 -1
- package/docs/affiliate-clawbacks.md +306 -0
- package/docs/settlement.md +17 -0
- package/package.json +2 -1
- package/src/client/affiliateRecovery/disputes.ts +62 -0
- package/src/client/affiliateRecovery/engine.ts +196 -0
- package/src/client/affiliateRecovery/payoutGate.ts +65 -0
- package/src/client/affiliateRecovery/provider.ts +127 -0
- package/src/client/affiliateRecovery/review.ts +117 -0
- package/src/client/affiliateRecovery/validators.ts +38 -0
- package/src/client/affiliateRecovery.ts +173 -0
- package/src/client/connect/commissionReceipts.test.ts +157 -0
- package/src/client/connect/commissionReceipts.ts +23 -0
- package/src/client/connect/payouts.ts +75 -15
- package/src/client/connect/refundPrincipal.test.ts +46 -0
- package/src/client/connect/refundPrincipal.ts +26 -0
- package/src/client/connect/reversalExecution.ts +130 -0
- package/src/client/connect/transfers.test.ts +3 -3
- package/src/client/connect/transfers.ts +93 -92
- package/src/client/index.ts +6 -7
- package/src/client/settlement/execution.test.ts +5 -0
- package/src/client/settlement/execution.ts +50 -3
- package/src/client/settlement/reconciliation.ts +20 -2
- package/src/client/webhooks/disputeRecovery.ts +74 -0
- package/src/client/webhooks/processors.test.ts +36 -53
- package/src/client/webhooks/processors.ts +18 -31
- package/src/component/_generated/api.ts +24 -0
- package/src/component/_generated/component.ts +614 -1
- package/src/component/affiliate-clawbacks.test.ts +370 -0
- package/src/component/affiliate-component-pagination.test.ts +83 -0
- package/src/component/affiliate-direct-payout.test.ts +160 -0
- package/src/component/affiliate-recovery-lifecycle.test.ts +587 -0
- package/src/component/affiliateEarnings/mutations.ts +196 -0
- package/src/component/affiliatePayouts/mutations.ts +121 -0
- package/src/component/affiliatePayouts/queries.ts +28 -0
- package/src/component/affiliatePayouts/recipientGuard.ts +42 -0
- package/src/component/affiliateRecovery/accounting.ts +111 -0
- package/src/component/affiliateRecovery/mutations.ts +275 -0
- package/src/component/affiliateRecovery/queries.ts +138 -0
- package/src/component/affiliateRecovery/schema.ts +86 -0
- package/src/component/connect/mutations.ts +9 -160
- package/src/component/connect/queries.ts +4 -47
- package/src/component/connect/reversalClaims.ts +232 -0
- package/src/component/connect/reversalDiagnostics.ts +61 -0
- package/src/component/connect/reversalReceipts.ts +147 -0
- package/src/component/connect/schema.ts +3 -3
- package/src/component/connect/validators.ts +2 -0
- package/src/component/payout-recovery-integration.test.ts +172 -0
- package/src/component/payoutRelease/mutations.ts +9 -0
- package/src/component/payoutRelease/queries.ts +3 -1
- package/src/component/schema.ts +18 -0
- package/src/component/settlement/clawbackSchema.ts +78 -0
- package/src/component/settlement/clawbacks.ts +233 -0
- package/src/component/settlement/mutations.ts +54 -0
- package/src/component/settlement/queries.ts +35 -0
- package/src/component/summary-arithmetic.test.ts +9 -4
- package/src/react/workflows/AffiliateRecovery.test.tsx +106 -0
- package/src/react/workflows/AffiliateRecovery.tsx +273 -0
- package/src/react/workflows/index.ts +9 -0
- package/src/testing/affiliate-recovery.ts +137 -0
- package/src/testing/index.ts +2 -0
|
@@ -14,6 +14,222 @@ type Sync = (stripe: Stripe, component: Component, ctx: RunCtx, opts: {
|
|
|
14
14
|
export declare function operation(): Promise<Sync>;
|
|
15
15
|
export declare function setup(scope?: Scope): Promise<{
|
|
16
16
|
t: import("convex-test").TestConvex<import("convex/server").SchemaDefinition<{
|
|
17
|
+
affiliateObligations: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
18
|
+
accounted?: boolean | undefined;
|
|
19
|
+
activeOperationId?: import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined;
|
|
20
|
+
affiliateAccountId: string;
|
|
21
|
+
chargeAmount: number;
|
|
22
|
+
creditAmount?: number | undefined;
|
|
23
|
+
currency: string;
|
|
24
|
+
debtAmount?: number | undefined;
|
|
25
|
+
debtStatus?: "open" | "settled" | undefined;
|
|
26
|
+
disputeId?: string | undefined;
|
|
27
|
+
disputeState?: "lost" | "open" | "won" | undefined;
|
|
28
|
+
disputedPrincipal: number;
|
|
29
|
+
earningId?: import("convex/values").GenericId<"affiliateEarnings"> | undefined;
|
|
30
|
+
finalizedAmount: number;
|
|
31
|
+
lastError?: string | undefined;
|
|
32
|
+
lastRefundId?: string | undefined;
|
|
33
|
+
lastState?: string | undefined;
|
|
34
|
+
legacyReceiptIds?: string[] | undefined;
|
|
35
|
+
legacyRestorationIds?: string[] | undefined;
|
|
36
|
+
lostPrincipal: number;
|
|
37
|
+
needsReconciliation: boolean;
|
|
38
|
+
offsetAmount?: number | undefined;
|
|
39
|
+
operationSequence?: number | undefined;
|
|
40
|
+
operatorNote?: string | undefined;
|
|
41
|
+
originalCommission: number;
|
|
42
|
+
paymentId?: string | undefined;
|
|
43
|
+
paymentIntentId?: string | undefined;
|
|
44
|
+
provisionalAmount: number;
|
|
45
|
+
recoveredAmount: number;
|
|
46
|
+
refundedPrincipal: number;
|
|
47
|
+
releasedCommission?: number | undefined;
|
|
48
|
+
reservedRecovery?: number | undefined;
|
|
49
|
+
reservedRestoration?: number | undefined;
|
|
50
|
+
restoredAmount?: number | undefined;
|
|
51
|
+
sourceChargeId: string;
|
|
52
|
+
sourceInvoiceId?: string | undefined;
|
|
53
|
+
storeAccountId?: string | undefined;
|
|
54
|
+
stripeTransferId?: string | undefined;
|
|
55
|
+
}, {
|
|
56
|
+
stripeTransferId: import("convex/values").VString<string | undefined, "optional">;
|
|
57
|
+
sourceChargeId: import("convex/values").VString<string, "required">;
|
|
58
|
+
sourceInvoiceId: import("convex/values").VString<string | undefined, "optional">;
|
|
59
|
+
paymentIntentId: import("convex/values").VString<string | undefined, "optional">;
|
|
60
|
+
paymentId: import("convex/values").VString<string | undefined, "optional">;
|
|
61
|
+
storeAccountId: import("convex/values").VString<string | undefined, "optional">;
|
|
62
|
+
lastRefundId: import("convex/values").VString<string | undefined, "optional">;
|
|
63
|
+
affiliateAccountId: import("convex/values").VString<string, "required">;
|
|
64
|
+
currency: import("convex/values").VString<string, "required">;
|
|
65
|
+
chargeAmount: import("convex/values").VFloat64<number, "required">;
|
|
66
|
+
originalCommission: import("convex/values").VFloat64<number, "required">;
|
|
67
|
+
refundedPrincipal: import("convex/values").VFloat64<number, "required">;
|
|
68
|
+
disputedPrincipal: import("convex/values").VFloat64<number, "required">;
|
|
69
|
+
lostPrincipal: import("convex/values").VFloat64<number, "required">;
|
|
70
|
+
finalizedAmount: import("convex/values").VFloat64<number, "required">;
|
|
71
|
+
provisionalAmount: import("convex/values").VFloat64<number, "required">;
|
|
72
|
+
recoveredAmount: import("convex/values").VFloat64<number, "required">;
|
|
73
|
+
needsReconciliation: import("convex/values").VBoolean<boolean, "required">;
|
|
74
|
+
accounted: import("convex/values").VBoolean<boolean | undefined, "optional">;
|
|
75
|
+
legacyReceiptIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
|
|
76
|
+
legacyRestorationIds: import("convex/values").VArray<string[] | undefined, import("convex/values").VString<string, "required">, "optional">;
|
|
77
|
+
operatorNote: import("convex/values").VString<string | undefined, "optional">;
|
|
78
|
+
earningId: import("convex/values").VId<import("convex/values").GenericId<"affiliateEarnings"> | undefined, "optional">;
|
|
79
|
+
releasedCommission: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
80
|
+
offsetAmount: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
81
|
+
restoredAmount: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
82
|
+
reservedRecovery: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
83
|
+
reservedRestoration: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
84
|
+
debtAmount: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
85
|
+
creditAmount: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
86
|
+
debtStatus: import("convex/values").VUnion<"open" | "settled" | undefined, [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"settled", "required">], "optional", never>;
|
|
87
|
+
disputeState: import("convex/values").VUnion<"lost" | "open" | "won" | undefined, [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"lost", "required">, import("convex/values").VLiteral<"won", "required">], "optional", never>;
|
|
88
|
+
disputeId: import("convex/values").VString<string | undefined, "optional">;
|
|
89
|
+
activeOperationId: import("convex/values").VId<import("convex/values").GenericId<"affiliateRecoveryOperations"> | undefined, "optional">;
|
|
90
|
+
lastState: import("convex/values").VString<string | undefined, "optional">;
|
|
91
|
+
lastError: import("convex/values").VString<string | undefined, "optional">;
|
|
92
|
+
operationSequence: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
93
|
+
}, "required", "accounted" | "activeOperationId" | "affiliateAccountId" | "chargeAmount" | "creditAmount" | "currency" | "debtAmount" | "debtStatus" | "disputeId" | "disputeState" | "disputedPrincipal" | "earningId" | "finalizedAmount" | "lastError" | "lastRefundId" | "lastState" | "legacyReceiptIds" | "legacyRestorationIds" | "lostPrincipal" | "needsReconciliation" | "offsetAmount" | "operationSequence" | "operatorNote" | "originalCommission" | "paymentId" | "paymentIntentId" | "provisionalAmount" | "recoveredAmount" | "refundedPrincipal" | "releasedCommission" | "reservedRecovery" | "reservedRestoration" | "restoredAmount" | "sourceChargeId" | "sourceInvoiceId" | "storeAccountId" | "stripeTransferId">, {
|
|
94
|
+
by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
|
|
95
|
+
by_affiliate_currency_debt: ["affiliateAccountId", "currency", "debtStatus", "_creationTime"];
|
|
96
|
+
by_charge: ["sourceChargeId", "_creationTime"];
|
|
97
|
+
by_transfer: ["stripeTransferId", "_creationTime"];
|
|
98
|
+
}, {}, {}>;
|
|
99
|
+
affiliateRecoveryOperations: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
100
|
+
amount: number;
|
|
101
|
+
attempted: boolean;
|
|
102
|
+
createdAt: number;
|
|
103
|
+
error?: string | undefined;
|
|
104
|
+
kind: "recovery" | "restoration";
|
|
105
|
+
obligationId: import("convex/values").GenericId<"affiliateObligations">;
|
|
106
|
+
providerBaseline?: number | undefined;
|
|
107
|
+
receiptId?: string | undefined;
|
|
108
|
+
sourceEventId?: string | undefined;
|
|
109
|
+
state: "canceled" | "failed" | "insufficient_balance" | "pending" | "succeeded" | "unknown" | "unsupported";
|
|
110
|
+
}, {
|
|
111
|
+
obligationId: import("convex/values").VId<import("convex/values").GenericId<"affiliateObligations">, "required">;
|
|
112
|
+
sourceEventId: import("convex/values").VString<string | undefined, "optional">;
|
|
113
|
+
kind: import("convex/values").VUnion<"recovery" | "restoration", [import("convex/values").VLiteral<"recovery", "required">, import("convex/values").VLiteral<"restoration", "required">], "required", never>;
|
|
114
|
+
amount: import("convex/values").VFloat64<number, "required">;
|
|
115
|
+
state: import("convex/values").VUnion<"canceled" | "failed" | "insufficient_balance" | "pending" | "succeeded" | "unknown" | "unsupported", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"insufficient_balance", "required">, import("convex/values").VLiteral<"unsupported", "required">, import("convex/values").VLiteral<"failed", "required">, import("convex/values").VLiteral<"succeeded", "required">, import("convex/values").VLiteral<"canceled", "required">], "required", never>;
|
|
116
|
+
receiptId: import("convex/values").VString<string | undefined, "optional">;
|
|
117
|
+
error: import("convex/values").VString<string | undefined, "optional">;
|
|
118
|
+
attempted: import("convex/values").VBoolean<boolean, "required">;
|
|
119
|
+
providerBaseline: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
120
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
121
|
+
}, "required", "amount" | "attempted" | "createdAt" | "error" | "kind" | "obligationId" | "providerBaseline" | "receiptId" | "sourceEventId" | "state">, {
|
|
122
|
+
by_obligation: ["obligationId", "_creationTime"];
|
|
123
|
+
by_state: ["state", "_creationTime"];
|
|
124
|
+
}, {}, {}>;
|
|
125
|
+
affiliatePayoutReleases: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
126
|
+
affiliateAccountId: string;
|
|
127
|
+
amount: number;
|
|
128
|
+
createdAt: number;
|
|
129
|
+
currency: string;
|
|
130
|
+
minimumAmount: number;
|
|
131
|
+
operationKey: string;
|
|
132
|
+
state: "failed" | "pending" | "submitted" | "unknown";
|
|
133
|
+
stripePayoutId?: string | undefined;
|
|
134
|
+
}, {
|
|
135
|
+
affiliateAccountId: import("convex/values").VString<string, "required">;
|
|
136
|
+
currency: import("convex/values").VString<string, "required">;
|
|
137
|
+
operationKey: import("convex/values").VString<string, "required">;
|
|
138
|
+
amount: import("convex/values").VFloat64<number, "required">;
|
|
139
|
+
minimumAmount: import("convex/values").VFloat64<number, "required">;
|
|
140
|
+
state: import("convex/values").VUnion<"failed" | "pending" | "submitted" | "unknown", [import("convex/values").VLiteral<"pending", "required">, import("convex/values").VLiteral<"unknown", "required">, import("convex/values").VLiteral<"submitted", "required">, import("convex/values").VLiteral<"failed", "required">], "required", never>;
|
|
141
|
+
stripePayoutId: import("convex/values").VString<string | undefined, "optional">;
|
|
142
|
+
createdAt: import("convex/values").VFloat64<number, "required">;
|
|
143
|
+
}, "required", "affiliateAccountId" | "amount" | "createdAt" | "currency" | "minimumAmount" | "operationKey" | "state" | "stripePayoutId">, {
|
|
144
|
+
by_key: ["operationKey", "_creationTime"];
|
|
145
|
+
by_state: ["state", "_creationTime"];
|
|
146
|
+
}, {}, {}>;
|
|
147
|
+
affiliateEarnings: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
148
|
+
affiliateAccountId: string;
|
|
149
|
+
currency: string;
|
|
150
|
+
originalCommission: number;
|
|
151
|
+
paymentIntentId?: string | undefined;
|
|
152
|
+
releaseAmount: number;
|
|
153
|
+
sourceChargeId: string;
|
|
154
|
+
sourceInvoiceId?: string | undefined;
|
|
155
|
+
status: "paid" | "reserved";
|
|
156
|
+
stripeTransferId?: string | undefined;
|
|
157
|
+
withheldAmount: number;
|
|
158
|
+
}, {
|
|
159
|
+
sourceChargeId: import("convex/values").VString<string, "required">;
|
|
160
|
+
affiliateAccountId: import("convex/values").VString<string, "required">;
|
|
161
|
+
currency: import("convex/values").VString<string, "required">;
|
|
162
|
+
originalCommission: import("convex/values").VFloat64<number, "required">;
|
|
163
|
+
withheldAmount: import("convex/values").VFloat64<number, "required">;
|
|
164
|
+
releaseAmount: import("convex/values").VFloat64<number, "required">;
|
|
165
|
+
sourceInvoiceId: import("convex/values").VString<string | undefined, "optional">;
|
|
166
|
+
paymentIntentId: import("convex/values").VString<string | undefined, "optional">;
|
|
167
|
+
stripeTransferId: import("convex/values").VString<string | undefined, "optional">;
|
|
168
|
+
status: import("convex/values").VUnion<"paid" | "reserved", [import("convex/values").VLiteral<"reserved", "required">, import("convex/values").VLiteral<"paid", "required">], "required", never>;
|
|
169
|
+
}, "required", "affiliateAccountId" | "currency" | "originalCommission" | "paymentIntentId" | "releaseAmount" | "sourceChargeId" | "sourceInvoiceId" | "status" | "stripeTransferId" | "withheldAmount">, {
|
|
170
|
+
by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
|
|
171
|
+
by_charge_affiliate: ["sourceChargeId", "affiliateAccountId", "_creationTime"];
|
|
172
|
+
}, {}, {}>;
|
|
173
|
+
affiliateOffsets: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
174
|
+
amount: number;
|
|
175
|
+
earningId: import("convex/values").GenericId<"affiliateEarnings">;
|
|
176
|
+
obligationId: import("convex/values").GenericId<"affiliateObligations">;
|
|
177
|
+
}, {
|
|
178
|
+
earningId: import("convex/values").VId<import("convex/values").GenericId<"affiliateEarnings">, "required">;
|
|
179
|
+
obligationId: import("convex/values").VId<import("convex/values").GenericId<"affiliateObligations">, "required">;
|
|
180
|
+
amount: import("convex/values").VFloat64<number, "required">;
|
|
181
|
+
}, "required", "amount" | "earningId" | "obligationId">, {
|
|
182
|
+
by_earning: ["earningId", "_creationTime"];
|
|
183
|
+
by_obligation: ["obligationId", "_creationTime"];
|
|
184
|
+
}, {}, {}>;
|
|
185
|
+
affiliateRecoveryBalances: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
186
|
+
activePayoutKey?: string | undefined;
|
|
187
|
+
affiliateAccountId: string;
|
|
188
|
+
currency: string;
|
|
189
|
+
netPayable: number;
|
|
190
|
+
offsetAmount: number;
|
|
191
|
+
originalCommission: number;
|
|
192
|
+
outstandingDebt: number;
|
|
193
|
+
pendingPayoutAmount?: number | undefined;
|
|
194
|
+
recoveredAmount: number;
|
|
195
|
+
reservedRecovery: number;
|
|
196
|
+
reservedRestoration: number;
|
|
197
|
+
restorationDue: number;
|
|
198
|
+
restoredAmount: number;
|
|
199
|
+
withheldAmount: number;
|
|
200
|
+
}, {
|
|
201
|
+
activePayoutKey: import("convex/values").VString<string | undefined, "optional">;
|
|
202
|
+
pendingPayoutAmount: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
203
|
+
affiliateAccountId: import("convex/values").VString<string, "required">;
|
|
204
|
+
currency: import("convex/values").VString<string, "required">;
|
|
205
|
+
originalCommission: import("convex/values").VFloat64<number, "required">;
|
|
206
|
+
recoveredAmount: import("convex/values").VFloat64<number, "required">;
|
|
207
|
+
offsetAmount: import("convex/values").VFloat64<number, "required">;
|
|
208
|
+
restoredAmount: import("convex/values").VFloat64<number, "required">;
|
|
209
|
+
outstandingDebt: import("convex/values").VFloat64<number, "required">;
|
|
210
|
+
reservedRecovery: import("convex/values").VFloat64<number, "required">;
|
|
211
|
+
reservedRestoration: import("convex/values").VFloat64<number, "required">;
|
|
212
|
+
restorationDue: import("convex/values").VFloat64<number, "required">;
|
|
213
|
+
withheldAmount: import("convex/values").VFloat64<number, "required">;
|
|
214
|
+
netPayable: import("convex/values").VFloat64<number, "required">;
|
|
215
|
+
}, "required", "activePayoutKey" | "affiliateAccountId" | "currency" | "netPayable" | "offsetAmount" | "originalCommission" | "outstandingDebt" | "pendingPayoutAmount" | "recoveredAmount" | "reservedRecovery" | "reservedRestoration" | "restorationDue" | "restoredAmount" | "withheldAmount">, {
|
|
216
|
+
by_affiliate_currency: ["affiliateAccountId", "currency", "_creationTime"];
|
|
217
|
+
}, {}, {}>;
|
|
218
|
+
affiliateReversalReceipts: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
219
|
+
amount: number;
|
|
220
|
+
operationId: string;
|
|
221
|
+
stripeReversalId: string;
|
|
222
|
+
stripeTransferId: string;
|
|
223
|
+
}, {
|
|
224
|
+
stripeReversalId: import("convex/values").VString<string, "required">;
|
|
225
|
+
stripeTransferId: import("convex/values").VString<string, "required">;
|
|
226
|
+
operationId: import("convex/values").VString<string, "required">;
|
|
227
|
+
amount: import("convex/values").VFloat64<number, "required">;
|
|
228
|
+
}, "required", "amount" | "operationId" | "stripeReversalId" | "stripeTransferId">, {
|
|
229
|
+
by_receipt: ["stripeReversalId", "_creationTime"];
|
|
230
|
+
by_transfer: ["stripeTransferId", "_creationTime"];
|
|
231
|
+
by_transfer_operation: ["stripeTransferId", "operationId", "_creationTime"];
|
|
232
|
+
}, {}, {}>;
|
|
17
233
|
payoutSyncClaims: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
18
234
|
acceptedAt?: number | undefined;
|
|
19
235
|
acceptedFingerprint?: string | undefined;
|
|
@@ -1134,6 +1350,16 @@ export declare function setup(scope?: Scope): Promise<{
|
|
|
1134
1350
|
by_stripe_transfer_id: ["stripeTransferId", "_creationTime"];
|
|
1135
1351
|
}, {}, {}>;
|
|
1136
1352
|
transferReversalOps: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
1353
|
+
commissionExposure?: {
|
|
1354
|
+
chargeAmount: number;
|
|
1355
|
+
disputeId?: string | undefined;
|
|
1356
|
+
disputeState?: "lost" | "open" | "won" | undefined;
|
|
1357
|
+
finalized: boolean;
|
|
1358
|
+
kind: "dispute" | "refund";
|
|
1359
|
+
principal: number;
|
|
1360
|
+
refundId?: string | undefined;
|
|
1361
|
+
refundedPrincipal?: number | undefined;
|
|
1362
|
+
} | undefined;
|
|
1137
1363
|
operationId: string;
|
|
1138
1364
|
slices: {
|
|
1139
1365
|
from: number;
|
|
@@ -1157,8 +1383,28 @@ export declare function setup(scope?: Scope): Promise<{
|
|
|
1157
1383
|
from: import("convex/values").VFloat64<number, "required">;
|
|
1158
1384
|
to: import("convex/values").VFloat64<number, "required">;
|
|
1159
1385
|
}, "required", "from" | "stripeTransferId" | "to">, "required">;
|
|
1160
|
-
|
|
1386
|
+
commissionExposure: import("convex/values").VObject<{
|
|
1387
|
+
chargeAmount: number;
|
|
1388
|
+
disputeId?: string | undefined;
|
|
1389
|
+
disputeState?: "lost" | "open" | "won" | undefined;
|
|
1390
|
+
finalized: boolean;
|
|
1391
|
+
kind: "dispute" | "refund";
|
|
1392
|
+
principal: number;
|
|
1393
|
+
refundId?: string | undefined;
|
|
1394
|
+
refundedPrincipal?: number | undefined;
|
|
1395
|
+
} | undefined, {
|
|
1396
|
+
kind: import("convex/values").VUnion<"dispute" | "refund", [import("convex/values").VLiteral<"refund", "required">, import("convex/values").VLiteral<"dispute", "required">], "required", never>;
|
|
1397
|
+
chargeAmount: import("convex/values").VFloat64<number, "required">;
|
|
1398
|
+
principal: import("convex/values").VFloat64<number, "required">;
|
|
1399
|
+
finalized: import("convex/values").VBoolean<boolean, "required">;
|
|
1400
|
+
disputeState: import("convex/values").VUnion<"lost" | "open" | "won" | undefined, [import("convex/values").VLiteral<"open", "required">, import("convex/values").VLiteral<"lost", "required">, import("convex/values").VLiteral<"won", "required">], "optional", never>;
|
|
1401
|
+
disputeId: import("convex/values").VString<string | undefined, "optional">;
|
|
1402
|
+
refundedPrincipal: import("convex/values").VFloat64<number | undefined, "optional">;
|
|
1403
|
+
refundId: import("convex/values").VString<string | undefined, "optional">;
|
|
1404
|
+
}, "optional", "chargeAmount" | "disputeId" | "disputeState" | "finalized" | "kind" | "principal" | "refundId" | "refundedPrincipal">;
|
|
1405
|
+
}, "required", "commissionExposure" | "commissionExposure.chargeAmount" | "commissionExposure.disputeId" | "commissionExposure.disputeState" | "commissionExposure.finalized" | "commissionExposure.kind" | "commissionExposure.principal" | "commissionExposure.refundId" | "commissionExposure.refundedPrincipal" | "operationId" | "slices" | "sourceChargeId">, {
|
|
1161
1406
|
by_operation_id: ["operationId", "_creationTime"];
|
|
1407
|
+
by_source_charge: ["sourceChargeId", "_creationTime"];
|
|
1162
1408
|
}, {}, {}>;
|
|
1163
1409
|
webhookEvents: import("convex/server").TableDefinition<import("convex/values").VObject<{
|
|
1164
1410
|
eventType: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payoutSyncTestHelpers.d.ts","sourceRoot":"","sources":["../../../src/client/connect/payoutSyncTestHelpers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIvD,eAAO,MAAM,SAAS,EAIN,SAAS,CAAC;AAC1B,MAAM,MAAM,KAAK,GACf;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AAClE,KAAK,IAAI,GAAG,CACV,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,KAC3C,OAAO,CAAC,OAAO,CAAC,CAAC;AACtB,wBAAsB,SAAS,kBAU9B;AACD,wBAAsB,KAAK,CACzB,KAAK,GAAE,KAAsD
|
|
1
|
+
{"version":3,"file":"payoutSyncTestHelpers.d.ts","sourceRoot":"","sources":["../../../src/client/connect/payoutSyncTestHelpers.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAIvD,eAAO,MAAM,SAAS,EAIN,SAAS,CAAC;AAC1B,MAAM,MAAM,KAAK,GACf;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,SAAS,EAAE,MAAM,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,UAAU,CAAA;CAAE,CAAC;AAClE,KAAK,IAAI,GAAG,CACV,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,KAAK,CAAA;CAAE,KAC3C,OAAO,CAAC,OAAO,CAAC,CAAC;AACt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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;kBAKxC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,QAAQ,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;iBAkCzC,OAAO,CAAC,MAAM,CAAC,MAAM,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAQtC"}
|
|
@@ -27,6 +27,8 @@ export declare function getAccountBalance(stripe: Stripe, opts: {
|
|
|
27
27
|
stripeAccountId: string;
|
|
28
28
|
}): Promise<AccountBalance[]>;
|
|
29
29
|
export type CreatePayoutOptions = {
|
|
30
|
+
/** Host-authorized minimum in the payout currency. */
|
|
31
|
+
minimumAmount?: number;
|
|
30
32
|
stripeAccountId: string;
|
|
31
33
|
amount: number;
|
|
32
34
|
currency?: string;
|
|
@@ -34,7 +36,7 @@ export type CreatePayoutOptions = {
|
|
|
34
36
|
/** Stripe idempotency key for retry-safe payout creation. */
|
|
35
37
|
idempotencyKey?: string;
|
|
36
38
|
};
|
|
37
|
-
export declare function createPayout(stripe: Stripe,
|
|
39
|
+
export declare function createPayout(stripe: Stripe, ctx: RunCtx, opts: CreatePayoutOptions, component?: Component): Promise<{
|
|
38
40
|
stripePayoutId: string;
|
|
39
41
|
}>;
|
|
40
42
|
export declare function getPayout(component: Component, ctx: RunCtx, opts: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payouts.d.ts","sourceRoot":"","sources":["../../../src/client/connect/payouts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"payouts.d.ts","sourceRoot":"","sources":["../../../src/client/connect/payouts.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,uCAAuC,CAAC;AAC1E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAOvD;;;;;;GAMG;AACH,MAAM,MAAM,cAAc,GAAG;IAC3B,6DAA6D;IAC7D,SAAS,EAAE,MAAM,CAAC;IAClB,4BAA4B;IAC5B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF;;;;;;;GAOG;AACH,wBAAsB,iBAAiB,CACrC,MAAM,EAAE,MAAM,EACd,IAAI,EAAE;IAAE,eAAe,EAAE,MAAM,CAAA;CAAE,GAChC,OAAO,CAAC,cAAc,EAAE,CAAC,CAiB3B;AAED,MAAM,MAAM,mBAAmB,GAAG;IAChC,sDAAsD;IACtD,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,eAAe,EAAE,MAAM,CAAC;IACxB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAClC,6DAA6D;IAC7D,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB,CAAC;AAEF,wBAAsB,YAAY,CAChC,MAAM,EAAE,MAAM,EACd,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,mBAAmB,EACzB,SAAS,CAAC,EAAE,SAAS;;GAmEtB;AAED,wBAAsB,SAAS,CAC7B,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,EAAE;IAAE,QAAQ,EAAE,MAAM,CAAA;CAAE,gBAM3B;AAED,wBAAsB,WAAW,CAC/B,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,IAAI,CAAC,EAAE;IAAE,eAAe,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,YAAY,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,gBAO3E"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { reserveAffiliatePayout, completeAffiliatePayout, reconcileAffiliatePayout, } from "../affiliateRecovery/payoutGate.js";
|
|
2
|
+
import { classifyRecoveryError } from "../affiliateRecovery/provider.js";
|
|
1
3
|
import { componentRef } from "../webhooks/helpers.js";
|
|
2
4
|
/**
|
|
3
5
|
* Retrieve a connected account's balance (BTS-65), scoped to that account via
|
|
@@ -26,18 +28,49 @@ export async function getAccountBalance(stripe, opts) {
|
|
|
26
28
|
entryFor(p.currency).pending += p.amount;
|
|
27
29
|
return [...byCurrency.values()];
|
|
28
30
|
}
|
|
29
|
-
export async function createPayout(stripe,
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
31
|
+
export async function createPayout(stripe, ctx, opts, component) {
|
|
32
|
+
const release = component
|
|
33
|
+
? await reserveAffiliatePayout(component, ctx, opts)
|
|
34
|
+
: null;
|
|
35
|
+
if (release?.state === "submitted")
|
|
36
|
+
return { stripePayoutId: release.stripePayoutId };
|
|
37
|
+
if (release?.state === "failed")
|
|
38
|
+
throw new Error("Affiliate payout failed; use a new authorized operation key.");
|
|
39
|
+
try {
|
|
40
|
+
if (release) {
|
|
41
|
+
const receiptId = await reconcileAffiliatePayout(stripe, release);
|
|
42
|
+
if (receiptId) {
|
|
43
|
+
await completeAffiliatePayout(component, ctx, release.operationKey, "submitted", receiptId);
|
|
44
|
+
return { stripePayoutId: receiptId };
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
if (release) {
|
|
48
|
+
if (Date.now() - release.createdAt >= 23 * 60 * 60 * 1000)
|
|
49
|
+
throw new Error("Affiliate payout idempotency window expired; reconcile the provider receipt before retrying.");
|
|
50
|
+
// Receipt lookup may yield while a refund records new debt.
|
|
51
|
+
await reserveAffiliatePayout(component, ctx, opts);
|
|
52
|
+
}
|
|
53
|
+
const payout = await stripe.payouts.create({
|
|
54
|
+
amount: opts.amount,
|
|
55
|
+
currency: opts.currency ?? "usd",
|
|
56
|
+
metadata: release
|
|
57
|
+
? { ...opts.metadata, bsAffiliatePayout: release._id }
|
|
58
|
+
: (opts.metadata ?? undefined),
|
|
59
|
+
}, {
|
|
60
|
+
stripeAccount: opts.stripeAccountId,
|
|
61
|
+
...(opts.idempotencyKey !== undefined
|
|
62
|
+
? { idempotencyKey: opts.idempotencyKey }
|
|
63
|
+
: {}),
|
|
64
|
+
});
|
|
65
|
+
if (release)
|
|
66
|
+
await completeAffiliatePayout(component, ctx, release.operationKey, "submitted", payout.id);
|
|
67
|
+
return { stripePayoutId: payout.id };
|
|
68
|
+
}
|
|
69
|
+
catch (error) {
|
|
70
|
+
if (release)
|
|
71
|
+
await completeAffiliatePayout(component, ctx, release.operationKey, classifyRecoveryError(error).state === "unknown" ? "unknown" : "failed");
|
|
72
|
+
throw error;
|
|
73
|
+
}
|
|
41
74
|
}
|
|
42
75
|
export async function getPayout(component, ctx, opts) {
|
|
43
76
|
return ctx.runQuery(componentRef(component, "connect/queries/getPayout"), opts);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"payouts.js","sourceRoot":"","sources":["../../../src/client/connect/payouts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"payouts.js","sour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eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,eAAe,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;KACzE,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refundPrincipal.d.ts","sourceRoot":"","sources":["../../../src/client/connect/refundPrincipal.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AAEjC,mFAAmF;AACnF,wBAAsB,yBAAyB,CAC7C,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,mBAoBjB"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/** Charge.amount_refunded also includes pending refunds; only success is final. */
|
|
2
|
+
export async function successfulRefundPrincipal(stripe, chargeId) {
|
|
3
|
+
let principal = 0;
|
|
4
|
+
let count = 0;
|
|
5
|
+
for await (const refund of stripe.refunds.list({
|
|
6
|
+
charge: chargeId,
|
|
7
|
+
limit: 100,
|
|
8
|
+
})) {
|
|
9
|
+
if (++count > 1000)
|
|
10
|
+
throw new Error("Successful refund lookup limit exceeded.");
|
|
11
|
+
if (refund.status !== "succeeded")
|
|
12
|
+
continue;
|
|
13
|
+
if (!Number.isSafeInteger(refund.amount) ||
|
|
14
|
+
refund.amount < 0 ||
|
|
15
|
+
!Number.isSafeInteger(principal + refund.amount))
|
|
16
|
+
throw new Error("Invalid successful refund principal.");
|
|
17
|
+
principal += refund.amount;
|
|
18
|
+
}
|
|
19
|
+
return principal;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=refundPrincipal.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"refundPrincipal.js","sourceRoot":"","sources":["../../../src/client/connect/refundPrincipal.ts"],"names":[],"mappings":"AAEA,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,yBAAyB,CAC7C,MAAc,EACd,QAAgB;IAEhB,IAAI,SAAS,GAAG,CAAC,CAAC;IAClB,IAAI,KAAK,GAAG,CAAC,CAAC;IACd,IAAI,KAAK,EAAE,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC;QAC7C,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,GAAG;KACX,CAAC,EAAE,CAAC;QACH,IAAI,EAAE,KAAK,GAAG,IAAI;YAChB,MAAM,IAAI,KAAK,CAAC,0CAA0C,CAAC,CAAC;QAC9D,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW;YAAE,SAAS;QAC5C,IACE,CAAC,MAAM,CAAC,aAAa,CAAC,MAAM,CAAC,MAAM,CAAC;YACpC,MAAM,CAAC,MAAM,GAAG,CAAC;YACjB,CAAC,MAAM,CAAC,aAAa,CAAC,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC;YAEhD,MAAM,IAAI,KAAK,CAAC,sCAAsC,CAAC,CAAC;QAC1D,SAAS,IAAI,MAAM,CAAC,MAAM,CAAC;IAC7B,CAAC;IACD,OAAO,SAAS,CAAC;AACnB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import type Stripe from "stripe";
|
|
2
|
+
import type { Component, RunCtx } from "../helpers.js";
|
|
3
|
+
export type ClaimedSlice = {
|
|
4
|
+
stripeTransferId: string;
|
|
5
|
+
/** Cumulative reversed amount this slice starts from. */
|
|
6
|
+
from: number;
|
|
7
|
+
/** Cumulative reversed amount this slice raises the leg to. */
|
|
8
|
+
to: number;
|
|
9
|
+
/** The leg's confirmed `reversedAmount` at claim time. */
|
|
10
|
+
confirmed: number;
|
|
11
|
+
commissionTracked?: boolean;
|
|
12
|
+
};
|
|
13
|
+
export type ReversalClaim = {
|
|
14
|
+
replay: boolean;
|
|
15
|
+
slices: ClaimedSlice[];
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Execute the slices an operation claimed via `claimReversalSlices` (BTS-63).
|
|
19
|
+
* The claim already reserved this money atomically, so all that's left is
|
|
20
|
+
* moving it: one `bs_rev_<operationId>_<transferId>` reversal per slice, then
|
|
21
|
+
* confirming the new cumulative total in the ledger. A replayed claim always
|
|
22
|
+
* re-sends byte-identical params under the same key, which Stripe answers
|
|
23
|
+
* from its idempotency cache without moving money twice.
|
|
24
|
+
*
|
|
25
|
+
* Because Stripe prunes idempotency keys after ~24h (and a crash can land
|
|
26
|
+
* between the Stripe call and the ledger confirm), a replay first checks the
|
|
27
|
+
* transfer's live `amount_reversed`: if the slice's money already moved, it
|
|
28
|
+
* just confirms the ledger instead of re-sending the reversal.
|
|
29
|
+
*
|
|
30
|
+
* A slice only executes once every predecessor slice on its leg is confirmed
|
|
31
|
+
* (`confirmed ≥ from`). Without that gate, a sibling operation landing behind
|
|
32
|
+
* a transiently-failed claim would execute and confirm PAST the hole; the
|
|
33
|
+
* failed operation's retry would then see `confirmed ≥ to` and silently skip
|
|
34
|
+
* — its money would never move while the ledger says it did. Throwing instead
|
|
35
|
+
* fails this operation's webhook event, and at-least-once delivery retries
|
|
36
|
+
* both operations until the predecessor fills its hole and each claimed slice
|
|
37
|
+
* has actually moved. The ledger's `reversedAmount` therefore always covers a
|
|
38
|
+
* solid, hole-free prefix of the reversed axis — which is exactly what makes
|
|
39
|
+
* the `confirmed`/`amount_reversed` checks above sound.
|
|
40
|
+
*/
|
|
41
|
+
export declare function executeClaimedSlices(stripe: Stripe, component: Component, ctx: RunCtx, operationId: string, claim: ReversalClaim): Promise<{
|
|
42
|
+
reversals: {
|
|
43
|
+
stripeTransferId: string;
|
|
44
|
+
amount: number;
|
|
45
|
+
}[];
|
|
46
|
+
}>;
|
|
47
|
+
//# sourceMappingURL=reversalExecution.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reversalExecution.d.ts","sourceRoot":"","sources":["../../../src/client/connect/reversalExecution.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,QAAQ,CAAC;AACjC,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,eAAe,CAAC;AAKvD,MAAM,MAAM,YAAY,GAAG;IACzB,gBAAgB,EAAE,MAAM,CAAC;IACzB,yDAAyD;IACzD,IAAI,EAAE,MAAM,CAAC;IACb,+DAA+D;IAC/D,EAAE,EAAE,MAAM,CAAC;IACX,0DAA0D;IAC1D,SAAS,EAAE,MAAM,CAAC;IAClB,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAAE,MAAM,EAAE,OAAO,CAAC;IAAC,MAAM,EAAE,YAAY,EAAE,CAAA;CAAE,CAAC;AAExE;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,SAAS,EAAE,SAAS,EACpB,GAAG,EAAE,MAAM,EACX,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,aAAa,GACnB,OAAO,CAAC;IAAE,SAAS,EAAE;QAAE,gBAAgB,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAA;CAAE,CAAC,CAgFxE"}
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { runMutationOrThrow } from "../helpers.js";
|
|
2
|
+
import { componentRef } from "../webhooks/helpers.js";
|
|
3
|
+
import { findCommissionReversal } from "./commissionReceipts.js";
|
|
4
|
+
/**
|
|
5
|
+
* Execute the slices an operation claimed via `claimReversalSlices` (BTS-63).
|
|
6
|
+
* The claim already reserved this money atomically, so all that's left is
|
|
7
|
+
* moving it: one `bs_rev_<operationId>_<transferId>` reversal per slice, then
|
|
8
|
+
* confirming the new cumulative total in the ledger. A replayed claim always
|
|
9
|
+
* re-sends byte-identical params under the same key, which Stripe answers
|
|
10
|
+
* from its idempotency cache without moving money twice.
|
|
11
|
+
*
|
|
12
|
+
* Because Stripe prunes idempotency keys after ~24h (and a crash can land
|
|
13
|
+
* between the Stripe call and the ledger confirm), a replay first checks the
|
|
14
|
+
* transfer's live `amount_reversed`: if the slice's money already moved, it
|
|
15
|
+
* just confirms the ledger instead of re-sending the reversal.
|
|
16
|
+
*
|
|
17
|
+
* A slice only executes once every predecessor slice on its leg is confirmed
|
|
18
|
+
* (`confirmed ≥ from`). Without that gate, a sibling operation landing behind
|
|
19
|
+
* a transiently-failed claim would execute and confirm PAST the hole; the
|
|
20
|
+
* failed operation's retry would then see `confirmed ≥ to` and silently skip
|
|
21
|
+
* — its money would never move while the ledger says it did. Throwing instead
|
|
22
|
+
* fails this operation's webhook event, and at-least-once delivery retries
|
|
23
|
+
* both operations until the predecessor fills its hole and each claimed slice
|
|
24
|
+
* has actually moved. The ledger's `reversedAmount` therefore always covers a
|
|
25
|
+
* solid, hole-free prefix of the reversed axis — which is exactly what makes
|
|
26
|
+
* the `confirmed`/`amount_reversed` checks above sound.
|
|
27
|
+
*/
|
|
28
|
+
export async function executeClaimedSlices(stripe, component, ctx, operationId, claim) {
|
|
29
|
+
const reversals = [];
|
|
30
|
+
for (const slice of claim.slices) {
|
|
31
|
+
const receiptAmount = slice.to - slice.from;
|
|
32
|
+
if (slice.commissionTracked && claim.replay) {
|
|
33
|
+
const receipt = await findCommissionReversal(stripe, slice.stripeTransferId, operationId, receiptAmount);
|
|
34
|
+
if (receipt) {
|
|
35
|
+
await runMutationOrThrow(ctx, componentRef(component, "connect/mutations/recordTransferReversal"), {
|
|
36
|
+
stripeTransferId: slice.stripeTransferId,
|
|
37
|
+
reversedAmount: slice.to,
|
|
38
|
+
receipt: {
|
|
39
|
+
stripeReversalId: receipt.id,
|
|
40
|
+
operationId,
|
|
41
|
+
amount: receiptAmount,
|
|
42
|
+
},
|
|
43
|
+
});
|
|
44
|
+
continue;
|
|
45
|
+
}
|
|
46
|
+
if (slice.confirmed >= slice.to)
|
|
47
|
+
throw new Error("Commission reversal requires receipt reconciliation.");
|
|
48
|
+
}
|
|
49
|
+
if (slice.confirmed >= slice.to)
|
|
50
|
+
continue; // executed and recorded already
|
|
51
|
+
if (slice.confirmed < slice.from) {
|
|
52
|
+
throw new Error(`reversal slice [${slice.from},${slice.to}) on ${slice.stripeTransferId} ` +
|
|
53
|
+
`blocked: predecessor claim unexecuted (confirmed=${slice.confirmed})`);
|
|
54
|
+
}
|
|
55
|
+
if (claim.replay && !slice.commissionTracked) {
|
|
56
|
+
const transfer = await stripe.transfers.retrieve(slice.stripeTransferId);
|
|
57
|
+
if ((transfer.amount_reversed ?? 0) >= slice.to) {
|
|
58
|
+
// The money moved on a previous attempt that died before confirming.
|
|
59
|
+
await runMutationOrThrow(ctx, componentRef(component, "connect/mutations/recordTransferReversal"), {
|
|
60
|
+
stripeTransferId: slice.stripeTransferId,
|
|
61
|
+
reversedAmount: slice.to,
|
|
62
|
+
});
|
|
63
|
+
continue;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
const amount = slice.to - slice.from;
|
|
67
|
+
const receipt = await stripe.transfers.createReversal(slice.stripeTransferId, {
|
|
68
|
+
amount,
|
|
69
|
+
...(slice.commissionTracked
|
|
70
|
+
? { metadata: { bsReversalOperation: operationId } }
|
|
71
|
+
: {}),
|
|
72
|
+
}, { idempotencyKey: `bs_rev_${operationId}_${slice.stripeTransferId}` });
|
|
73
|
+
await runMutationOrThrow(ctx, componentRef(component, "connect/mutations/recordTransferReversal"), {
|
|
74
|
+
stripeTransferId: slice.stripeTransferId,
|
|
75
|
+
reversedAmount: slice.to,
|
|
76
|
+
...(slice.commissionTracked
|
|
77
|
+
? { receipt: { stripeReversalId: receipt.id, operationId, amount } }
|
|
78
|
+
: {}),
|
|
79
|
+
});
|
|
80
|
+
reversals.push({ stripeTransferId: slice.stripeTransferId, amount });
|
|
81
|
+
}
|
|
82
|
+
return { reversals };
|
|
83
|
+
}
|
|
84
|
+
//# sourceMappingURL=reversalExecution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reversalExecution.js","sourceRoot":"","sources":["../../../src/client/connect/reversalExecution.ts"],"names":[],"mappings":"AAEA,OAAO,E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EAAE;YACxB,GAAG,CAAC,KAAK,CAAC,iBAAiB;gBACzB,CAAC,CAAC,EAAE,OAAO,EAAE,EAAE,gBAAgB,EAAE,OAAO,CAAC,EAAE,EAAE,WAAW,EAAE,MAAM,EAAE,EAAE;gBACpE,CAAC,CAAC,EAAE,CAAC;SACR,CACF,CAAC;QACF,SAAS,CAAC,IAAI,CAAC,EAAE,gBAAgB,EAAE,KAAK,CAAC,gBAAgB,EAAE,MAAM,EAAE,CAAC,CAAC;IACvE,CAAC;IACD,OAAO,EAAE,SAAS,EAAE,CAAC;AACvB,CAAC"}
|
|
@@ -104,9 +104,9 @@ export declare function reverseTransfers(stripe: Stripe, component: Component, c
|
|
|
104
104
|
}[];
|
|
105
105
|
}>;
|
|
106
106
|
/**
|
|
107
|
-
* Reverse a split sale's transfers pro-rata to
|
|
108
|
-
*
|
|
109
|
-
*
|
|
107
|
+
* Reverse a split sale's transfers pro-rata to cumulative succeeded refunds.
|
|
108
|
+
* Affiliate legs retain the larger refund/dispute commission exposure. Other
|
|
109
|
+
* legs converge on a cumulative reversal TARGET, `round(leg × amountRefunded /
|
|
110
110
|
* chargeAmount)`, and only the delta above the ledger's recorded
|
|
111
111
|
* `reversedAmount` is reversed. Delta-to-target (rather than percent-of-
|
|
112
112
|
* original like {@link reverseTransfers}) is what makes at-least-once webhook
|
|
@@ -127,7 +127,7 @@ export declare function reverseTransfersForRefund(stripe: Stripe, component: Com
|
|
|
127
127
|
refundId: string;
|
|
128
128
|
/** The original charge amount (minor units). */
|
|
129
129
|
chargeAmount: number;
|
|
130
|
-
/**
|
|
130
|
+
/** Cumulative principal of succeeded refunds; exclude pending/failed refunds. */
|
|
131
131
|
amountRefunded: number;
|
|
132
132
|
}): Promise<{
|
|
133
133
|
reversals: {
|
|
@@ -135,6 +135,7 @@ export declare function reverseTransfersForRefund(stripe: Stripe, component: Com
|
|
|
135
135
|
amount: number;
|
|
136
136
|
}[];
|
|
137
137
|
}>;
|
|
138
|
+
export { reverseTransfersForDispute } from "../affiliateRecovery/disputes.js";
|
|
138
139
|
/**
|
|
139
140
|
* Webhook-driven split transfer engine (BTS-22). After a charge succeeds for a
|
|
140
141
|
* separate-charges sale, fan funds out to each split recipient: compute the
|
|
@@ -163,6 +164,9 @@ export declare function reinstateTransfers(stripe: Stripe, component: Component,
|
|
|
163
164
|
sourceChargeId: string;
|
|
164
165
|
operationId: string;
|
|
165
166
|
currency: string;
|
|
167
|
+
excludeAffiliates?: boolean;
|
|
168
|
+
chargeAmount?: number;
|
|
169
|
+
refundedPrincipal?: number;
|
|
166
170
|
}): Promise<{
|
|
167
171
|
reinstated: {
|
|
168
172
|
destinationAccountId: string;
|