@fantastic.dev/better-stripe 0.19.0 → 0.20.1
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 +12 -0
- package/README.md +22 -3
- package/dist/client/connect/transferReceipt.d.ts.map +1 -1
- package/dist/client/connect/transferReceipt.js +1 -14
- package/dist/client/connect/transferReceipt.js.map +1 -1
- package/dist/component/_generated/component.d.ts +297 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/earnings/triggers.d.ts +134 -0
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/payoutRelease/allocation.d.ts +48 -0
- package/dist/component/payoutRelease/allocation.d.ts.map +1 -0
- package/dist/component/payoutRelease/allocation.js +98 -0
- package/dist/component/payoutRelease/allocation.js.map +1 -0
- package/dist/component/payoutRelease/helpers.d.ts +106 -0
- package/dist/component/payoutRelease/helpers.d.ts.map +1 -0
- package/dist/component/payoutRelease/helpers.js +119 -0
- package/dist/component/payoutRelease/helpers.js.map +1 -0
- package/dist/component/payoutRelease/mutations.d.ts +218 -0
- package/dist/component/payoutRelease/mutations.d.ts.map +1 -0
- package/dist/component/payoutRelease/mutations.js +254 -0
- package/dist/component/payoutRelease/mutations.js.map +1 -0
- package/dist/component/payoutRelease/queries.d.ts +84 -0
- package/dist/component/payoutRelease/queries.d.ts.map +1 -0
- package/dist/component/payoutRelease/queries.js +51 -0
- package/dist/component/payoutRelease/queries.js.map +1 -0
- package/dist/component/payoutRelease/schema.d.ts +289 -0
- package/dist/component/payoutRelease/schema.d.ts.map +1 -0
- package/dist/component/payoutRelease/schema.js +56 -0
- package/dist/component/payoutRelease/schema.js.map +1 -0
- package/dist/component/schema.d.ts +110 -0
- package/dist/component/schema.js +3 -0
- package/dist/component/schema.js.map +1 -1
- package/docs/accounts-v2-preview.md +39 -1
- package/docs/react-workflows.md +31 -0
- package/docs/settlement.md +31 -0
- package/package.json +1 -1
- package/src/client/connect/payoutAllocation.test.ts +292 -0
- package/src/client/connect/transferReceipt.ts +1 -14
- package/src/component/_generated/api.ts +8 -0
- package/src/component/_generated/component.ts +372 -0
- package/src/component/payout-release.test.ts +588 -0
- package/src/component/payoutRelease/allocation.ts +147 -0
- package/src/component/payoutRelease/helpers.ts +168 -0
- package/src/component/payoutRelease/mutations.ts +309 -0
- package/src/component/payoutRelease/queries.ts +56 -0
- package/src/component/payoutRelease/schema.ts +69 -0
- package/src/component/schema.ts +6 -0
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
function money(value) {
|
|
2
|
+
if (!Number.isSafeInteger(value))
|
|
3
|
+
throw new Error("Unsafe payout arithmetic.");
|
|
4
|
+
return value;
|
|
5
|
+
}
|
|
6
|
+
function nonnegative(value) {
|
|
7
|
+
if (money(value) < 0)
|
|
8
|
+
throw new Error("Invalid payout accounting amount.");
|
|
9
|
+
}
|
|
10
|
+
function currency(value) {
|
|
11
|
+
if (value.length !== 3 || !/^[a-z]{3}$/.test(value))
|
|
12
|
+
throw new Error("Invalid payout currency.");
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Pure allocation step, not authorization to call Stripe. Inputs must be a
|
|
16
|
+
* complete, verified still-unpaid snapshot for this recipient. Policy controls,
|
|
17
|
+
* source ownership/maturity, prior payout adoption, independent liabilities and
|
|
18
|
+
* atomic reservations must be established by the execution boundary.
|
|
19
|
+
*
|
|
20
|
+
* Negative source entitlement survives refunds after payout. Pending credits
|
|
21
|
+
* never qualify. Each source's reservations reduce entitlement; they are not
|
|
22
|
+
* subtracted again from fresh provider availability, which may already include
|
|
23
|
+
* the provider debit for those same in-flight payouts.
|
|
24
|
+
*/
|
|
25
|
+
export function planRecipientPayout(opts) {
|
|
26
|
+
currency(opts.currency);
|
|
27
|
+
if (money(opts.threshold) <= 0)
|
|
28
|
+
throw new Error("Invalid payout threshold.");
|
|
29
|
+
money(opts.providerAvailable);
|
|
30
|
+
nonnegative(opts.independentLiabilities);
|
|
31
|
+
const seen = new Set();
|
|
32
|
+
for (const source of opts.sources) {
|
|
33
|
+
if (!/^tr_\w+$/.test(source.stripeTransferId) ||
|
|
34
|
+
source.stripeTransferId.trim() !== source.stripeTransferId ||
|
|
35
|
+
source.stripeTransferId.length > 100)
|
|
36
|
+
throw new Error("Invalid payout source identity.");
|
|
37
|
+
if (seen.has(source.stripeTransferId))
|
|
38
|
+
throw new Error("Duplicate payout source.");
|
|
39
|
+
seen.add(source.stripeTransferId);
|
|
40
|
+
currency(source.currency);
|
|
41
|
+
money(source.matureNet);
|
|
42
|
+
nonnegative(source.paidAmount);
|
|
43
|
+
nonnegative(source.reservedAmount);
|
|
44
|
+
nonnegative(source.pendingCredits);
|
|
45
|
+
if (source.role !== undefined &&
|
|
46
|
+
!["store", "affiliate", "other"].includes(source.role))
|
|
47
|
+
throw new Error("Invalid payout source role.");
|
|
48
|
+
}
|
|
49
|
+
const sources = opts.sources
|
|
50
|
+
.filter((source) => source.currency === opts.currency)
|
|
51
|
+
.sort((a, b) => a.stripeTransferId < b.stripeTransferId
|
|
52
|
+
? -1
|
|
53
|
+
: a.stripeTransferId > b.stripeTransferId
|
|
54
|
+
? 1
|
|
55
|
+
: 0);
|
|
56
|
+
let matureUnpaid = 0;
|
|
57
|
+
let pendingCredits = 0;
|
|
58
|
+
const credits = sources.map((source) => {
|
|
59
|
+
const unpaid = money(money(source.matureNet - source.paidAmount) - source.reservedAmount);
|
|
60
|
+
matureUnpaid = money(matureUnpaid + unpaid);
|
|
61
|
+
pendingCredits = money(pendingCredits + source.pendingCredits);
|
|
62
|
+
return { source, unpaid };
|
|
63
|
+
});
|
|
64
|
+
const totals = {
|
|
65
|
+
currency: opts.currency,
|
|
66
|
+
matureUnpaid,
|
|
67
|
+
pendingCredits,
|
|
68
|
+
providerMinimum: null,
|
|
69
|
+
};
|
|
70
|
+
const providerAvailable = money(opts.providerAvailable - opts.independentLiabilities);
|
|
71
|
+
if (matureUnpaid < opts.threshold)
|
|
72
|
+
return { ...totals, status: "held", reason: "below_threshold", amount: 0 };
|
|
73
|
+
const amount = Math.min(matureUnpaid, providerAvailable);
|
|
74
|
+
if (amount < opts.threshold)
|
|
75
|
+
return {
|
|
76
|
+
...totals,
|
|
77
|
+
status: "held",
|
|
78
|
+
reason: "insufficient_available",
|
|
79
|
+
amount: 0,
|
|
80
|
+
};
|
|
81
|
+
let remaining = amount;
|
|
82
|
+
const allocations = [];
|
|
83
|
+
for (const { source, unpaid } of credits) {
|
|
84
|
+
const allocated = Math.min(Math.max(0, unpaid), remaining);
|
|
85
|
+
if (allocated) {
|
|
86
|
+
allocations.push({
|
|
87
|
+
stripeTransferId: source.stripeTransferId,
|
|
88
|
+
amount: allocated,
|
|
89
|
+
...(source.role === undefined ? {} : { role: source.role }),
|
|
90
|
+
});
|
|
91
|
+
remaining = money(remaining - allocated);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
if (remaining !== 0)
|
|
95
|
+
throw new Error("Invalid payout source allocation.");
|
|
96
|
+
return { ...totals, status: "qualified", amount, allocations };
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=allocation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"allocation.js","sourceRoot":"","sources":["../../../src/component/payoutRelease/allocation.ts"],"names":[],"mappings":"AAsCA,SAAS,KAAK,CAAC,KAAa;IAC1B,IAAI,CAAC,MAAM,CAAC,aAAa,CAAC,KAAK,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,2BAA2B,CAAC,CAAC;IAC/C,OAAO,KAAK,CAAC;AACf,CAAC;AACD,SAAS,WAAW,CAAC,KAAa;IAChC,IAAI,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;AAC7E,CAAC;AACD,SAAS,QAAQ,CAAC,KAAa;IAC7B,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,KAAK,CAAC;Q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@
|
|
|
1
|
+
import type { Infer } from "convex/values";
|
|
2
|
+
import type { transferDocValidator } from "../connect/validators.js";
|
|
3
|
+
import type { MutationCtx } from "../_generated/server.js";
|
|
4
|
+
import type { Doc } from "../_generated/dataModel.js";
|
|
5
|
+
import type { observation } from "./schema.js";
|
|
6
|
+
import { addSummaryAmounts } from "../earnings/arithmetic.js";
|
|
7
|
+
export declare const add: typeof addSummaryAmounts;
|
|
8
|
+
export declare function transferFingerprint(t: Infer<typeof transferDocValidator>): string;
|
|
9
|
+
export declare function validateIdentity(args: {
|
|
10
|
+
accountId: string;
|
|
11
|
+
ownerKey: string;
|
|
12
|
+
operationKey: string;
|
|
13
|
+
}): void;
|
|
14
|
+
export declare function claimByKey(ctx: MutationCtx, args: {
|
|
15
|
+
accountId: string;
|
|
16
|
+
ownerKey: string;
|
|
17
|
+
operationKey: string;
|
|
18
|
+
}): Promise<{
|
|
19
|
+
_creationTime: number;
|
|
20
|
+
_id: import("convex/values").GenericId<"payoutReleaseClaims">;
|
|
21
|
+
accountId: string;
|
|
22
|
+
allocations: {
|
|
23
|
+
amount: number;
|
|
24
|
+
role?: "affiliate" | "other" | "store" | undefined;
|
|
25
|
+
stripeTransferId: string;
|
|
26
|
+
}[];
|
|
27
|
+
amount: number;
|
|
28
|
+
attemptedAt?: number | undefined;
|
|
29
|
+
currency: string;
|
|
30
|
+
expectedRevision: number;
|
|
31
|
+
observations: {
|
|
32
|
+
currency: string;
|
|
33
|
+
ledgerFingerprint: string;
|
|
34
|
+
matureNet: number;
|
|
35
|
+
observedAt: number;
|
|
36
|
+
pendingCredits: number;
|
|
37
|
+
stripeTransferId: string;
|
|
38
|
+
transactionIds: string[];
|
|
39
|
+
}[];
|
|
40
|
+
operationKey: string;
|
|
41
|
+
ownerKey: string;
|
|
42
|
+
rejection?: {
|
|
43
|
+
code: "amount_too_small" | "balance_insufficient";
|
|
44
|
+
requestId: string;
|
|
45
|
+
} | undefined;
|
|
46
|
+
returnTransactionId?: string | undefined;
|
|
47
|
+
status: "canceled" | "paid" | "rejected" | "reserved" | "returned" | "submitted";
|
|
48
|
+
stripePayoutId?: string | undefined;
|
|
49
|
+
} | null>;
|
|
50
|
+
export declare function readyPolicy(ctx: MutationCtx, args: {
|
|
51
|
+
accountId: string;
|
|
52
|
+
ownerKey: string;
|
|
53
|
+
expectedRevision: number;
|
|
54
|
+
}): Promise<{
|
|
55
|
+
_creationTime: number;
|
|
56
|
+
_id: import("convex/values").GenericId<"payoutPolicies">;
|
|
57
|
+
accountId: string;
|
|
58
|
+
country: string;
|
|
59
|
+
holdDeadline?: number | undefined;
|
|
60
|
+
mode: "custom" | "stripe_managed";
|
|
61
|
+
operationKey: string;
|
|
62
|
+
ownerKey: string;
|
|
63
|
+
previousSchedule?: {
|
|
64
|
+
interval: "daily" | "manual" | "monthly" | "weekly";
|
|
65
|
+
monthlyDays?: number[] | undefined;
|
|
66
|
+
weeklyDays?: string[] | undefined;
|
|
67
|
+
} | undefined;
|
|
68
|
+
revision: number;
|
|
69
|
+
status: "changing" | "ready";
|
|
70
|
+
thresholds: {
|
|
71
|
+
amount: number;
|
|
72
|
+
currency: string;
|
|
73
|
+
}[];
|
|
74
|
+
}>;
|
|
75
|
+
/** Full local account membership is checked under OCC before any reservation. */
|
|
76
|
+
export declare function checkSnapshot(ctx: MutationCtx, accountId: string, observations: Infer<typeof observation>[], fresh: boolean): Promise<Map<string, {
|
|
77
|
+
_creationTime: number;
|
|
78
|
+
_id: import("convex/values").GenericId<"transfers">;
|
|
79
|
+
amount: number;
|
|
80
|
+
currency: string;
|
|
81
|
+
destinationAccountId: string;
|
|
82
|
+
metadata?: any;
|
|
83
|
+
paymentId?: string | undefined;
|
|
84
|
+
reinstatement?: boolean | undefined;
|
|
85
|
+
reversalClaimedAmount?: number | undefined;
|
|
86
|
+
reversalStatus?: "fully_reversed" | "partially_reversed" | undefined;
|
|
87
|
+
reversedAmount?: number | undefined;
|
|
88
|
+
role?: "affiliate" | "other" | "store" | undefined;
|
|
89
|
+
sourceChargeId?: string | undefined;
|
|
90
|
+
sourceInvoiceId?: string | undefined;
|
|
91
|
+
status: "failed" | "paid" | "pending" | "reversed";
|
|
92
|
+
stripeTransferId: string;
|
|
93
|
+
totalsRecorded?: true | undefined;
|
|
94
|
+
}>>;
|
|
95
|
+
export declare function sourceById(ctx: MutationCtx, stripeTransferId: string): Promise<{
|
|
96
|
+
_creationTime: number;
|
|
97
|
+
_id: import("convex/values").GenericId<"payoutSourceAllocations">;
|
|
98
|
+
accountId: string;
|
|
99
|
+
currency: string;
|
|
100
|
+
ownerKey: string;
|
|
101
|
+
paidAmount: number;
|
|
102
|
+
reservedAmount: number;
|
|
103
|
+
stripeTransferId: string;
|
|
104
|
+
} | null>;
|
|
105
|
+
export declare function moveAllocations(ctx: MutationCtx, claim: Doc<"payoutReleaseClaims">, transition: "pay" | "release" | "return"): Promise<void>;
|
|
106
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AAC3C,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAC;AACrE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,4BAA4B,CAAC;AAEtD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,eAAO,MAAM,GAAG,0BAAoB,CAAC;AACrC,wBAAgB,mBAAmB,CAAC,CAAC,EAAE,KAAK,CAAC,OAAO,oBAAoB,CAAC,UAaxE;AACD,wBAAgB,gBAAgB,CAAC,IAAI,EAAE;IACrC,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,EAAE,MAAM,CAAC;CACtB,QAQA;AACD,wBAAsB,UAAU,CAC9B,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;UAapE;AACD,wBAAsB,WAAW,CAC/B,GAAG,EAAE,WAAW,EAChB,IAAI,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,gBAAgB,EAAE,MAAM,CAAA;CAAE;;;;;;;;;;;;;;;;;;;;GAaxE;AACD,iFAAiF;AACjF,wBAAsB,aAAa,CACjC,GAAG,EAAE,WAAW,EAChB,SAAS,EAAE,MAAM,EACjB,YAAY,EAAE,KAAK,CAAC,OAAO,WAAW,CAAC,EAAE,EACzC,KAAK,EAAE,OAAO;;;;;;;;;;;;;;;;;;IAuDf;AACD,wBAAsB,UAAU,CAAC,GAAG,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM;;;;;;;;;UAK1E;AACD,wBAAsB,eAAe,CACnC,GAAG,EAAE,WAAW,EAChB,KAAK,EAAE,GAAG,CAAC,qBAAqB,CAAC,EACjC,UAAU,EAAE,KAAK,GAAG,SAAS,GAAG,QAAQ,iBA8BzC"}
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
import { readPolicy, validateScope } from "../payoutPolicy/helpers.js";
|
|
2
|
+
import { addSummaryAmounts } from "../earnings/arithmetic.js";
|
|
3
|
+
export const add = addSummaryAmounts;
|
|
4
|
+
export function transferFingerprint(t) {
|
|
5
|
+
return JSON.stringify([
|
|
6
|
+
t.stripeTransferId,
|
|
7
|
+
t.destinationAccountId,
|
|
8
|
+
t.sourceChargeId,
|
|
9
|
+
t.amount,
|
|
10
|
+
t.currency,
|
|
11
|
+
t.role,
|
|
12
|
+
t.status,
|
|
13
|
+
t.reversedAmount ?? 0,
|
|
14
|
+
t.reversalClaimedAmount ?? 0,
|
|
15
|
+
t.reinstatement ?? false,
|
|
16
|
+
]);
|
|
17
|
+
}
|
|
18
|
+
export function validateIdentity(args) {
|
|
19
|
+
validateScope(args);
|
|
20
|
+
if (!args.operationKey.trim() ||
|
|
21
|
+
args.operationKey.length > 180 ||
|
|
22
|
+
/[\r\n]/.test(args.operationKey))
|
|
23
|
+
throw new Error("Invalid payout claim identity.");
|
|
24
|
+
}
|
|
25
|
+
export async function claimByKey(ctx, args) {
|
|
26
|
+
validateIdentity(args);
|
|
27
|
+
const claim = await ctx.db
|
|
28
|
+
.query("payoutReleaseClaims")
|
|
29
|
+
.withIndex("by_operation", (q) => q.eq("operationKey", args.operationKey))
|
|
30
|
+
.unique();
|
|
31
|
+
if (claim &&
|
|
32
|
+
(claim.accountId !== args.accountId || claim.ownerKey !== args.ownerKey))
|
|
33
|
+
throw new Error("Payout claim identity does not match.");
|
|
34
|
+
return claim;
|
|
35
|
+
}
|
|
36
|
+
export async function readyPolicy(ctx, args) {
|
|
37
|
+
const policy = await readPolicy(ctx, args);
|
|
38
|
+
if (!Number.isSafeInteger(args.expectedRevision) ||
|
|
39
|
+
policy?.revision !== args.expectedRevision ||
|
|
40
|
+
policy.mode !== "custom" ||
|
|
41
|
+
policy.status !== "ready" ||
|
|
42
|
+
!policy.holdDeadline ||
|
|
43
|
+
policy.holdDeadline <= Date.now())
|
|
44
|
+
throw new Error("Payout policy is not ready at this revision.");
|
|
45
|
+
return policy;
|
|
46
|
+
}
|
|
47
|
+
/** Full local account membership is checked under OCC before any reservation. */
|
|
48
|
+
export async function checkSnapshot(ctx, accountId, observations, fresh) {
|
|
49
|
+
const rows = await ctx.db
|
|
50
|
+
.query("transfers")
|
|
51
|
+
.withIndex("by_destination_account_id", (q) => q.eq("destinationAccountId", accountId))
|
|
52
|
+
.take(101);
|
|
53
|
+
if (rows.length > 100 ||
|
|
54
|
+
observations.length !== rows.length ||
|
|
55
|
+
new Set(observations.map((o) => o.stripeTransferId)).size !== rows.length)
|
|
56
|
+
throw new Error("Payout source snapshot is incomplete or duplicated.");
|
|
57
|
+
const byId = new Map(rows.map((row) => [row.stripeTransferId, row]));
|
|
58
|
+
const allocated = await ctx.db
|
|
59
|
+
.query("payoutSourceAllocations")
|
|
60
|
+
.withIndex("by_account", (q) => q.eq("accountId", accountId))
|
|
61
|
+
.take(101);
|
|
62
|
+
if (allocated.length > 100 ||
|
|
63
|
+
allocated.some((source) => !byId.has(source.stripeTransferId)))
|
|
64
|
+
throw new Error("Payout source allocation snapshot is incomplete.");
|
|
65
|
+
const receiptIds = new Set();
|
|
66
|
+
for (const o of observations) {
|
|
67
|
+
const row = byId.get(o.stripeTransferId);
|
|
68
|
+
if (!row ||
|
|
69
|
+
transferFingerprint(row) !== o.ledgerFingerprint ||
|
|
70
|
+
(row.status !== "paid" && row.status !== "reversed") ||
|
|
71
|
+
(row.reversalClaimedAmount ?? 0) > (row.reversedAmount ?? 0))
|
|
72
|
+
throw new Error("Payout source snapshot changed or is not ready.");
|
|
73
|
+
if (fresh &&
|
|
74
|
+
(!Number.isSafeInteger(o.observedAt) ||
|
|
75
|
+
o.observedAt > Date.now() ||
|
|
76
|
+
o.observedAt < Date.now() - 30000))
|
|
77
|
+
throw new Error("Payout source observation is stale or in the future.");
|
|
78
|
+
if (!o.transactionIds.length ||
|
|
79
|
+
o.transactionIds.length > 1000 ||
|
|
80
|
+
new Set(o.transactionIds).size !== o.transactionIds.length ||
|
|
81
|
+
o.transactionIds.some((id) => !/^txn_\w+$/.test(id) || id.trim() !== id))
|
|
82
|
+
throw new Error("Invalid payout source receipt identities.");
|
|
83
|
+
for (const id of o.transactionIds) {
|
|
84
|
+
if (receiptIds.has(id))
|
|
85
|
+
throw new Error("Duplicate payout source receipt.");
|
|
86
|
+
receiptIds.add(id);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
return byId;
|
|
90
|
+
}
|
|
91
|
+
export async function sourceById(ctx, stripeTransferId) {
|
|
92
|
+
return ctx.db
|
|
93
|
+
.query("payoutSourceAllocations")
|
|
94
|
+
.withIndex("by_transfer", (q) => q.eq("stripeTransferId", stripeTransferId))
|
|
95
|
+
.unique();
|
|
96
|
+
}
|
|
97
|
+
export async function moveAllocations(ctx, claim, transition) {
|
|
98
|
+
for (const allocation of claim.allocations) {
|
|
99
|
+
const source = await sourceById(ctx, allocation.stripeTransferId);
|
|
100
|
+
if (!source ||
|
|
101
|
+
source.accountId !== claim.accountId ||
|
|
102
|
+
source.ownerKey !== claim.ownerKey ||
|
|
103
|
+
source.currency !== claim.currency)
|
|
104
|
+
throw new Error("Payout source allocation identity changed.");
|
|
105
|
+
const reservedAmount = add(source.reservedAmount, transition === "return" ? 0 : -allocation.amount);
|
|
106
|
+
const paidAmount = add(source.paidAmount, transition === "pay"
|
|
107
|
+
? allocation.amount
|
|
108
|
+
: transition === "return"
|
|
109
|
+
? -allocation.amount
|
|
110
|
+
: 0);
|
|
111
|
+
if (reservedAmount < 0 || paidAmount < 0)
|
|
112
|
+
throw new Error("Payout source allocation underflow.");
|
|
113
|
+
await ctx.db.patch("payoutSourceAllocations", source._id, {
|
|
114
|
+
reservedAmount,
|
|
115
|
+
paidAmount,
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../src/component/payoutRelease/helpers.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,UAAU,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAEvE,OAAO,EAAE,iBAAiB,EAAE,MAAM,2BAA2B,CAAC;AAC9D,MAAM,CAAC,MAAM,GAAG,GAAG,iBAAiB,CAAC;AACrC,MAAM,UAAU,mBAAmB,CAAC,CAAqC;IACvE,OAAO,IAAI,CAAC,SAAS,CAAC;QACpB,CA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YAClC,MAAM,CAAC,QAAQ,KAAK,KAAK,CAAC,QAAQ;YAElC,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;QAChE,MAAM,cAAc,GAAG,GAAG,CACxB,MAAM,CAAC,cAAc,EACrB,UAAU,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM,CACjD,CAAC;QACF,MAAM,UAAU,GAAG,GAAG,CACpB,MAAM,CAAC,UAAU,EACjB,UAAU,KAAK,KAAK;YAClB,CAAC,CAAC,UAAU,CAAC,MAAM;YACnB,CAAC,CAAC,UAAU,KAAK,QAAQ;gBACvB,CAAC,CAAC,CAAC,UAAU,CAAC,MAAM;gBACpB,CAAC,CAAC,CAAC,CACR,CAAC;QACF,IAAI,cAAc,GAAG,CAAC,IAAI,UAAU,GAAG,CAAC;YACtC,MAAM,IAAI,KAAK,CAAC,qCAAqC,CAAC,CAAC;QACzD,MAAM,GAAG,CAAC,EAAE,CAAC,KAAK,CAAC,yBAAyB,EAAE,MAAM,CAAC,GAAG,EAAE;YACxD,cAAc;YACd,UAAU;SACX,CAAC,CAAC;IACL,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
/** Trusted server package boundary only: provider observations are verified upstream. Not a Stripe executor. */
|
|
2
|
+
export declare const claim: import("convex/server").RegisteredMutation<"public", {
|
|
3
|
+
accountId: string;
|
|
4
|
+
currency: string;
|
|
5
|
+
expectedRevision: number;
|
|
6
|
+
independentLiabilities: number;
|
|
7
|
+
observations: {
|
|
8
|
+
currency: string;
|
|
9
|
+
ledgerFingerprint: string;
|
|
10
|
+
matureNet: number;
|
|
11
|
+
observedAt: number;
|
|
12
|
+
pendingCredits: number;
|
|
13
|
+
stripeTransferId: string;
|
|
14
|
+
transactionIds: string[];
|
|
15
|
+
}[];
|
|
16
|
+
operationKey: string;
|
|
17
|
+
ownerKey: string;
|
|
18
|
+
providerAvailable: number;
|
|
19
|
+
}, Promise<{
|
|
20
|
+
_creationTime: number;
|
|
21
|
+
_id: import("convex/values").GenericId<"payoutReleaseClaims">;
|
|
22
|
+
accountId: string;
|
|
23
|
+
allocations: {
|
|
24
|
+
amount: number;
|
|
25
|
+
role?: "affiliate" | "other" | "store" | undefined;
|
|
26
|
+
stripeTransferId: string;
|
|
27
|
+
}[];
|
|
28
|
+
amount: number;
|
|
29
|
+
attemptedAt?: number | undefined;
|
|
30
|
+
currency: string;
|
|
31
|
+
expectedRevision: number;
|
|
32
|
+
observations: {
|
|
33
|
+
currency: string;
|
|
34
|
+
ledgerFingerprint: string;
|
|
35
|
+
matureNet: number;
|
|
36
|
+
observedAt: number;
|
|
37
|
+
pendingCredits: number;
|
|
38
|
+
stripeTransferId: string;
|
|
39
|
+
transactionIds: string[];
|
|
40
|
+
}[];
|
|
41
|
+
operationKey: string;
|
|
42
|
+
ownerKey: string;
|
|
43
|
+
rejection?: {
|
|
44
|
+
code: "amount_too_small" | "balance_insufficient";
|
|
45
|
+
requestId: string;
|
|
46
|
+
} | undefined;
|
|
47
|
+
returnTransactionId?: string | undefined;
|
|
48
|
+
status: "canceled" | "paid" | "rejected" | "reserved" | "returned" | "submitted";
|
|
49
|
+
stripePayoutId?: string | undefined;
|
|
50
|
+
} | {
|
|
51
|
+
status: "held";
|
|
52
|
+
reason: "pending_claim";
|
|
53
|
+
amount: 0;
|
|
54
|
+
currency: string;
|
|
55
|
+
providerMinimum: null;
|
|
56
|
+
} | ({
|
|
57
|
+
currency: string;
|
|
58
|
+
matureUnpaid: number;
|
|
59
|
+
pendingCredits: number;
|
|
60
|
+
providerMinimum: null;
|
|
61
|
+
} & {
|
|
62
|
+
status: "held";
|
|
63
|
+
reason: "below_threshold" | "insufficient_available";
|
|
64
|
+
amount: 0;
|
|
65
|
+
})>>;
|
|
66
|
+
export declare const beginAttempt: import("convex/server").RegisteredMutation<"public", {
|
|
67
|
+
accountId: string;
|
|
68
|
+
operationKey: string;
|
|
69
|
+
ownerKey: string;
|
|
70
|
+
}, Promise<{
|
|
71
|
+
_creationTime: number;
|
|
72
|
+
_id: import("convex/values").GenericId<"payoutReleaseClaims">;
|
|
73
|
+
accountId: string;
|
|
74
|
+
allocations: {
|
|
75
|
+
amount: number;
|
|
76
|
+
role?: "affiliate" | "other" | "store" | undefined;
|
|
77
|
+
stripeTransferId: string;
|
|
78
|
+
}[];
|
|
79
|
+
amount: number;
|
|
80
|
+
attemptedAt?: number | undefined;
|
|
81
|
+
currency: string;
|
|
82
|
+
expectedRevision: number;
|
|
83
|
+
observations: {
|
|
84
|
+
currency: string;
|
|
85
|
+
ledgerFingerprint: string;
|
|
86
|
+
matureNet: number;
|
|
87
|
+
observedAt: number;
|
|
88
|
+
pendingCredits: number;
|
|
89
|
+
stripeTransferId: string;
|
|
90
|
+
transactionIds: string[];
|
|
91
|
+
}[];
|
|
92
|
+
operationKey: string;
|
|
93
|
+
ownerKey: string;
|
|
94
|
+
rejection?: {
|
|
95
|
+
code: "amount_too_small" | "balance_insufficient";
|
|
96
|
+
requestId: string;
|
|
97
|
+
} | undefined;
|
|
98
|
+
returnTransactionId?: string | undefined;
|
|
99
|
+
status: "canceled" | "paid" | "rejected" | "reserved" | "returned" | "submitted";
|
|
100
|
+
stripePayoutId?: string | undefined;
|
|
101
|
+
}>>;
|
|
102
|
+
export declare const cancelUnattempted: import("convex/server").RegisteredMutation<"public", {
|
|
103
|
+
accountId: string;
|
|
104
|
+
operationKey: string;
|
|
105
|
+
ownerKey: string;
|
|
106
|
+
}, Promise<{
|
|
107
|
+
_creationTime: number;
|
|
108
|
+
_id: import("convex/values").GenericId<"payoutReleaseClaims">;
|
|
109
|
+
accountId: string;
|
|
110
|
+
allocations: {
|
|
111
|
+
amount: number;
|
|
112
|
+
role?: "affiliate" | "other" | "store" | undefined;
|
|
113
|
+
stripeTransferId: string;
|
|
114
|
+
}[];
|
|
115
|
+
amount: number;
|
|
116
|
+
attemptedAt?: number | undefined;
|
|
117
|
+
currency: string;
|
|
118
|
+
expectedRevision: number;
|
|
119
|
+
observations: {
|
|
120
|
+
currency: string;
|
|
121
|
+
ledgerFingerprint: string;
|
|
122
|
+
matureNet: number;
|
|
123
|
+
observedAt: number;
|
|
124
|
+
pendingCredits: number;
|
|
125
|
+
stripeTransferId: string;
|
|
126
|
+
transactionIds: string[];
|
|
127
|
+
}[];
|
|
128
|
+
operationKey: string;
|
|
129
|
+
ownerKey: string;
|
|
130
|
+
rejection?: {
|
|
131
|
+
code: "amount_too_small" | "balance_insufficient";
|
|
132
|
+
requestId: string;
|
|
133
|
+
} | undefined;
|
|
134
|
+
returnTransactionId?: string | undefined;
|
|
135
|
+
status: "canceled" | "paid" | "rejected" | "reserved" | "returned" | "submitted";
|
|
136
|
+
stripePayoutId?: string | undefined;
|
|
137
|
+
}>>;
|
|
138
|
+
export declare const recordOutcome: import("convex/server").RegisteredMutation<"public", {
|
|
139
|
+
accountId: string;
|
|
140
|
+
amount: number;
|
|
141
|
+
currency: string;
|
|
142
|
+
operationKey: string;
|
|
143
|
+
ownerKey: string;
|
|
144
|
+
providerStatus: "canceled" | "failed" | "in_transit" | "paid" | "pending";
|
|
145
|
+
returnTransactionId?: string | undefined;
|
|
146
|
+
stripePayoutId: string;
|
|
147
|
+
}, Promise<{
|
|
148
|
+
_creationTime: number;
|
|
149
|
+
_id: import("convex/values").GenericId<"payoutReleaseClaims">;
|
|
150
|
+
accountId: string;
|
|
151
|
+
allocations: {
|
|
152
|
+
amount: number;
|
|
153
|
+
role?: "affiliate" | "other" | "store" | undefined;
|
|
154
|
+
stripeTransferId: string;
|
|
155
|
+
}[];
|
|
156
|
+
amount: number;
|
|
157
|
+
attemptedAt?: number | undefined;
|
|
158
|
+
currency: string;
|
|
159
|
+
expectedRevision: number;
|
|
160
|
+
observations: {
|
|
161
|
+
currency: string;
|
|
162
|
+
ledgerFingerprint: string;
|
|
163
|
+
matureNet: number;
|
|
164
|
+
observedAt: number;
|
|
165
|
+
pendingCredits: number;
|
|
166
|
+
stripeTransferId: string;
|
|
167
|
+
transactionIds: string[];
|
|
168
|
+
}[];
|
|
169
|
+
operationKey: string;
|
|
170
|
+
ownerKey: string;
|
|
171
|
+
rejection?: {
|
|
172
|
+
code: "amount_too_small" | "balance_insufficient";
|
|
173
|
+
requestId: string;
|
|
174
|
+
} | undefined;
|
|
175
|
+
returnTransactionId?: string | undefined;
|
|
176
|
+
status: "canceled" | "paid" | "rejected" | "reserved" | "returned" | "submitted";
|
|
177
|
+
stripePayoutId?: string | undefined;
|
|
178
|
+
}>>;
|
|
179
|
+
/** Only a verified, no-object rejection within the original idempotency window. */
|
|
180
|
+
export declare const recordRejection: import("convex/server").RegisteredMutation<"public", {
|
|
181
|
+
accountId: string;
|
|
182
|
+
code: "amount_too_small" | "balance_insufficient";
|
|
183
|
+
operationKey: string;
|
|
184
|
+
ownerKey: string;
|
|
185
|
+
requestId: string;
|
|
186
|
+
}, Promise<{
|
|
187
|
+
_creationTime: number;
|
|
188
|
+
_id: import("convex/values").GenericId<"payoutReleaseClaims">;
|
|
189
|
+
accountId: string;
|
|
190
|
+
allocations: {
|
|
191
|
+
amount: number;
|
|
192
|
+
role?: "affiliate" | "other" | "store" | undefined;
|
|
193
|
+
stripeTransferId: string;
|
|
194
|
+
}[];
|
|
195
|
+
amount: number;
|
|
196
|
+
attemptedAt?: number | undefined;
|
|
197
|
+
currency: string;
|
|
198
|
+
expectedRevision: number;
|
|
199
|
+
observations: {
|
|
200
|
+
currency: string;
|
|
201
|
+
ledgerFingerprint: string;
|
|
202
|
+
matureNet: number;
|
|
203
|
+
observedAt: number;
|
|
204
|
+
pendingCredits: number;
|
|
205
|
+
stripeTransferId: string;
|
|
206
|
+
transactionIds: string[];
|
|
207
|
+
}[];
|
|
208
|
+
operationKey: string;
|
|
209
|
+
ownerKey: string;
|
|
210
|
+
rejection?: {
|
|
211
|
+
code: "amount_too_small" | "balance_insufficient";
|
|
212
|
+
requestId: string;
|
|
213
|
+
} | undefined;
|
|
214
|
+
returnTransactionId?: string | undefined;
|
|
215
|
+
status: "canceled" | "paid" | "rejected" | "reserved" | "returned" | "submitted";
|
|
216
|
+
stripePayoutId?: string | undefined;
|
|
217
|
+
}>>;
|
|
218
|
+
//# sourceMappingURL=mutations.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mutations.d.ts","sourceRoot":"","sources":["../../../src/component/payoutRelease/mutations.ts"],"names":[],"mappings":"AA0BA,gHAAgH;AAChH,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;YAkCF,MAAM;YACN,eAAe;YACf,CAAC;;;;;;;;;;;;IAgEf,CAAC;AACH,eAAO,MAAM,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAevB,CAAC;AACH,eAAO,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkB5B,CAAC;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4FxB,CAAC;AAEH,mFAAmF;AACnF,eAAO,MAAM,eAAe;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkD1B,CAAC"}
|