@fantastic.dev/better-stripe 0.24.0 → 0.25.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 +13 -0
- package/README.md +7 -1
- package/dist/client/billing/checkout.d.ts +3 -43
- package/dist/client/billing/checkout.d.ts.map +1 -1
- package/dist/client/billing/checkout.js +5 -260
- package/dist/client/billing/checkout.js.map +1 -1
- package/dist/client/billing/checkoutRequest.d.ts +129 -0
- package/dist/client/billing/checkoutRequest.d.ts.map +1 -0
- package/dist/client/billing/checkoutRequest.js +263 -0
- package/dist/client/billing/checkoutRequest.js.map +1 -0
- package/dist/client/billing/preparedCheckout.d.ts +22 -0
- package/dist/client/billing/preparedCheckout.d.ts.map +1 -0
- package/dist/client/billing/preparedCheckout.js +86 -0
- package/dist/client/billing/preparedCheckout.js.map +1 -0
- package/dist/client/checkoutRequests.d.ts +80 -0
- package/dist/client/checkoutRequests.d.ts.map +1 -0
- package/dist/client/checkoutRequests.js +28 -0
- package/dist/client/checkoutRequests.js.map +1 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts +464 -0
- package/dist/client/connect/payoutAdoptionTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutCollection.d.ts +21 -0
- package/dist/client/connect/payoutCollection.d.ts.map +1 -0
- package/dist/client/connect/payoutCollection.js +47 -0
- package/dist/client/connect/payoutCollection.js.map +1 -0
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts +1805 -0
- package/dist/client/connect/payoutExecutionTestHelpers.d.ts.map +1 -0
- package/dist/client/connect/payoutExecutionTestHelpers.js +194 -0
- package/dist/client/connect/payoutExecutionTestHelpers.js.map +1 -0
- package/dist/client/connect/payoutSyncTestHelpers.d.ts +232 -0
- package/dist/client/connect/payoutSyncTestHelpers.d.ts.map +1 -1
- package/dist/client/connect/payoutWorker.d.ts +48 -0
- package/dist/client/connect/payoutWorker.d.ts.map +1 -0
- package/dist/client/connect/payoutWorker.js +78 -0
- package/dist/client/connect/payoutWorker.js.map +1 -0
- package/dist/client/index.d.ts +4 -14
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +6 -13
- package/dist/client/index.js.map +1 -1
- package/dist/client/payoutPolicy.d.ts +67 -0
- package/dist/client/payoutPolicy.d.ts.map +1 -1
- package/dist/client/payoutPolicy.js +10 -0
- package/dist/client/payoutPolicy.js.map +1 -1
- package/dist/client/readContracts.d.ts +14 -1
- package/dist/client/readContracts.d.ts.map +1 -1
- package/dist/client/readContracts.js +14 -0
- package/dist/client/readContracts.js.map +1 -1
- package/dist/client/setup.test.d.ts +18 -0
- package/dist/client/setup.test.d.ts.map +1 -0
- package/dist/client/setup.test.js +33 -0
- package/dist/client/setup.test.js.map +1 -0
- package/dist/client/types/triggers.d.ts +1 -1
- package/dist/client/types/triggers.d.ts.map +1 -1
- package/dist/client/webhooks/helpers.d.ts.map +1 -1
- package/dist/client/webhooks/helpers.js +1 -0
- package/dist/client/webhooks/helpers.js.map +1 -1
- package/dist/client/webhooks/payoutReconciliation.d.ts +8 -0
- package/dist/client/webhooks/payoutReconciliation.d.ts.map +1 -0
- package/dist/client/webhooks/payoutReconciliation.js +36 -0
- package/dist/client/webhooks/payoutReconciliation.js.map +1 -0
- package/dist/client/webhooks/payoutReconciliationTestHelpers.d.ts +117 -0
- package/dist/client/webhooks/payoutReconciliationTestHelpers.d.ts.map +1 -0
- package/dist/client/webhooks/payoutReconciliationTestHelpers.js +105 -0
- package/dist/client/webhooks/payoutReconciliationTestHelpers.js.map +1 -0
- package/dist/client/webhooks/processors.d.ts.map +1 -1
- package/dist/client/webhooks/processors.js +1 -20
- package/dist/client/webhooks/processors.js.map +1 -1
- package/dist/component/_generated/component.d.ts +293 -0
- package/dist/component/_generated/component.d.ts.map +1 -1
- package/dist/component/core/mutations.d.ts.map +1 -1
- package/dist/component/core/mutations.js +2 -0
- package/dist/component/core/mutations.js.map +1 -1
- package/dist/component/core/resetSafety.d.ts +4 -0
- package/dist/component/core/resetSafety.d.ts.map +1 -0
- package/dist/component/core/resetSafety.js +54 -0
- package/dist/component/core/resetSafety.js.map +1 -0
- package/dist/component/earnings/triggers.d.ts +418 -0
- package/dist/component/earnings/triggers.d.ts.map +1 -1
- package/dist/component/earnings/triggers.js +2 -0
- package/dist/component/earnings/triggers.js.map +1 -1
- package/dist/component/payoutPolicy/schema.d.ts +2 -0
- package/dist/component/payoutPolicy/schema.d.ts.map +1 -1
- package/dist/component/payoutPolicy/schema.js +3 -1
- package/dist/component/payoutPolicy/schema.js.map +1 -1
- package/dist/component/payoutRelease/mutations.js +1 -1
- package/dist/component/payoutRelease/schema.d.ts +1 -0
- package/dist/component/payoutRelease/schema.d.ts.map +1 -1
- package/dist/component/payoutRelease/schema.js +1 -0
- package/dist/component/payoutRelease/schema.js.map +1 -1
- package/dist/component/payoutSnapshots/localState.d.ts +89 -0
- package/dist/component/payoutSnapshots/localState.d.ts.map +1 -0
- package/dist/component/payoutSnapshots/localState.js +186 -0
- package/dist/component/payoutSnapshots/localState.js.map +1 -0
- package/dist/component/payoutSnapshots/mutations.d.ts +108 -0
- package/dist/component/payoutSnapshots/mutations.d.ts.map +1 -0
- package/dist/component/payoutSnapshots/mutations.js +263 -0
- package/dist/component/payoutSnapshots/mutations.js.map +1 -0
- package/dist/component/payoutSnapshots/revisions.d.ts +12 -0
- package/dist/component/payoutSnapshots/revisions.d.ts.map +1 -0
- package/dist/component/payoutSnapshots/revisions.js +173 -0
- package/dist/component/payoutSnapshots/revisions.js.map +1 -0
- package/dist/component/payoutSnapshots/schema.d.ts +285 -0
- package/dist/component/payoutSnapshots/schema.d.ts.map +1 -0
- package/dist/component/payoutSnapshots/schema.js +108 -0
- package/dist/component/payoutSnapshots/schema.js.map +1 -0
- package/dist/component/payoutSnapshots/scope.d.ts +7 -0
- package/dist/component/payoutSnapshots/scope.d.ts.map +1 -0
- package/dist/component/payoutSnapshots/scope.js +8 -0
- package/dist/component/payoutSnapshots/scope.js.map +1 -0
- package/dist/component/payoutWorker/helpers.d.ts +30 -0
- package/dist/component/payoutWorker/helpers.d.ts.map +1 -0
- package/dist/component/payoutWorker/helpers.js +21 -0
- package/dist/component/payoutWorker/helpers.js.map +1 -0
- package/dist/component/payoutWorker/mutations.d.ts +68 -0
- package/dist/component/payoutWorker/mutations.d.ts.map +1 -0
- package/dist/component/payoutWorker/mutations.js +161 -0
- package/dist/component/payoutWorker/mutations.js.map +1 -0
- package/dist/component/payoutWorker/queries.d.ts +123 -0
- package/dist/component/payoutWorker/queries.d.ts.map +1 -0
- package/dist/component/payoutWorker/queries.js +61 -0
- package/dist/component/payoutWorker/queries.js.map +1 -0
- package/dist/component/payoutWorker/schema.d.ts +91 -0
- package/dist/component/payoutWorker/schema.d.ts.map +1 -0
- package/dist/component/payoutWorker/schema.js +27 -0
- package/dist/component/payoutWorker/schema.js.map +1 -0
- package/dist/component/schema.d.ts +232 -0
- package/dist/component/schema.js +10 -0
- package/dist/component/schema.js.map +1 -1
- package/docs/read-contracts.md +69 -5
- package/docs/settlement.md +128 -1
- package/package.json +1 -1
- package/src/client/billing/checkout.ts +11 -359
- package/src/client/billing/checkoutRequest.ts +362 -0
- package/src/client/billing/prepared-checkout.test.ts +430 -0
- package/src/client/billing/preparedCheckout.ts +143 -0
- package/src/client/checkoutRequests.ts +40 -0
- package/src/client/connect/payoutCollection.test.ts +74 -0
- package/src/client/connect/payoutCollection.ts +82 -0
- package/src/client/connect/payoutExecution.test.ts +1 -211
- package/src/client/connect/payoutExecutionTestHelpers.ts +213 -0
- package/src/client/connect/payoutWorker.test.ts +145 -0
- package/src/client/connect/payoutWorker.ts +144 -0
- package/src/client/index.ts +13 -27
- package/src/client/payoutPolicy.ts +26 -1
- package/src/client/readContracts.ts +28 -0
- package/src/client/types/triggers.ts +1 -0
- package/src/client/webhooks/helpers.ts +1 -0
- package/src/client/webhooks/payout-canceled.integration.test.ts +14 -1
- package/src/client/webhooks/payout-reconciliation.integration.test.ts +168 -0
- package/src/client/webhooks/payoutReconciliation.ts +72 -0
- package/src/client/webhooks/payoutReconciliationTestHelpers.ts +135 -0
- package/src/client/webhooks/processors.test.ts +44 -29
- package/src/client/webhooks/processors.ts +1 -27
- package/src/component/_generated/api.ts +16 -0
- package/src/component/_generated/component.ts +361 -0
- package/src/component/core/mutations.ts +2 -0
- package/src/component/core/resetSafety.ts +67 -0
- package/src/component/earnings/triggers.ts +2 -0
- package/src/component/payout-reset-safety.test.ts +148 -0
- package/src/component/payout-revisions.test.ts +125 -0
- package/src/component/payout-snapshots.test.ts +395 -0
- package/src/component/payout-worker.test.ts +165 -0
- package/src/component/payoutPolicy/schema.ts +3 -1
- package/src/component/payoutRelease/mutations.ts +1 -1
- package/src/component/payoutRelease/schema.ts +1 -0
- package/src/component/payoutSnapshots/localState.ts +238 -0
- package/src/component/payoutSnapshots/mutations.ts +275 -0
- package/src/component/payoutSnapshots/revisions.ts +247 -0
- package/src/component/payoutSnapshots/schema.ts +125 -0
- package/src/component/payoutSnapshots/scope.ts +7 -0
- package/src/component/payoutWorker/helpers.ts +30 -0
- package/src/component/payoutWorker/mutations.ts +181 -0
- package/src/component/payoutWorker/queries.ts +64 -0
- package/src/component/payoutWorker/schema.ts +26 -0
- package/src/component/public.test.ts +2 -2
- package/src/component/schema.ts +18 -0
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// @vitest-environment edge-runtime
|
|
2
|
+
import Stripe from "stripe";
|
|
3
|
+
import { vi } from "vitest";
|
|
4
|
+
import schema from "../../component/schema.js";
|
|
5
|
+
import { convexTest } from "convex-test";
|
|
6
|
+
import {
|
|
7
|
+
defineSchema,
|
|
8
|
+
defineTable,
|
|
9
|
+
makeFunctionReference,
|
|
10
|
+
internalMutationGeneric,
|
|
11
|
+
} from "convex/server";
|
|
12
|
+
import { v } from "convex/values";
|
|
13
|
+
import { BetterStripe } from "../index.js";
|
|
14
|
+
import { components } from "../setup.test.js";
|
|
15
|
+
import { getStripeClient } from "../helpers.js";
|
|
16
|
+
import type {
|
|
17
|
+
SyncTriggers,
|
|
18
|
+
RegisterRoutesConfig,
|
|
19
|
+
WebhookHandlerRefs,
|
|
20
|
+
} from "../types.js";
|
|
21
|
+
import { handleWebhookRequest } from "./handler.js";
|
|
22
|
+
export const observationRef = makeFunctionReference<
|
|
23
|
+
"mutation",
|
|
24
|
+
{ status: string; oldStatus?: string },
|
|
25
|
+
null
|
|
26
|
+
>("payoutHost:recordObservation");
|
|
27
|
+
const modules = import.meta.glob("../../component/**/*.{ts,js,tsx,jsx}");
|
|
28
|
+
const key = "sk_test_signed_authoritative_payout";
|
|
29
|
+
const secret = "whsec_signed_authoritative_payout";
|
|
30
|
+
export function payoutFixture(triggers?: SyncTriggers) {
|
|
31
|
+
const handlers = new BetterStripe(components.betterStripe, {
|
|
32
|
+
triggers,
|
|
33
|
+
}).webhookHandlers();
|
|
34
|
+
const t = convexTest(
|
|
35
|
+
defineSchema({
|
|
36
|
+
observations: defineTable({
|
|
37
|
+
status: v.string(),
|
|
38
|
+
oldStatus: v.optional(v.string()),
|
|
39
|
+
}),
|
|
40
|
+
}),
|
|
41
|
+
{
|
|
42
|
+
"./_generated/server.ts": () =>
|
|
43
|
+
import("../../component/_generated/server.js"),
|
|
44
|
+
"./payoutHost.ts": async () => ({
|
|
45
|
+
...handlers,
|
|
46
|
+
recordObservation: internalMutationGeneric({
|
|
47
|
+
args: { status: v.string(), oldStatus: v.optional(v.string()) },
|
|
48
|
+
returns: v.null(),
|
|
49
|
+
handler: async (ctx, args) => {
|
|
50
|
+
await ctx.db.insert("observations", args);
|
|
51
|
+
return null;
|
|
52
|
+
},
|
|
53
|
+
}),
|
|
54
|
+
}),
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
t.registerComponent("betterStripe", schema, modules);
|
|
58
|
+
const webhooks: WebhookHandlerRefs | undefined = triggers
|
|
59
|
+
? {
|
|
60
|
+
syncWebhook: makeFunctionReference<"mutation">(
|
|
61
|
+
"payoutHost:syncWebhook",
|
|
62
|
+
) as unknown as WebhookHandlerRefs["syncWebhook"],
|
|
63
|
+
asyncWebhook: makeFunctionReference<"action">(
|
|
64
|
+
"payoutHost:asyncWebhook",
|
|
65
|
+
) as unknown as WebhookHandlerRefs["asyncWebhook"],
|
|
66
|
+
}
|
|
67
|
+
: undefined;
|
|
68
|
+
let current = {
|
|
69
|
+
id: "po_current",
|
|
70
|
+
object: "payout",
|
|
71
|
+
amount: 1200,
|
|
72
|
+
currency: "usd",
|
|
73
|
+
status: "paid",
|
|
74
|
+
arrival_date: 1792108800,
|
|
75
|
+
automatic: true,
|
|
76
|
+
method: "standard",
|
|
77
|
+
failure_code: null,
|
|
78
|
+
failure_message: null,
|
|
79
|
+
metadata: { accountId: "acct_untrusted" },
|
|
80
|
+
} as unknown as Stripe.Payout;
|
|
81
|
+
const retrieve = vi
|
|
82
|
+
.spyOn(getStripeClient(key).payouts, "retrieve")
|
|
83
|
+
.mockImplementation(
|
|
84
|
+
async () => ({ ...current }) as Stripe.Response<Stripe.Payout>,
|
|
85
|
+
);
|
|
86
|
+
const event = {
|
|
87
|
+
id: "evt_payout_first",
|
|
88
|
+
object: "event",
|
|
89
|
+
type: "payout.updated",
|
|
90
|
+
created: 1792010000,
|
|
91
|
+
livemode: false,
|
|
92
|
+
account: "acct_recipient" as string | undefined,
|
|
93
|
+
data: { object: { ...current, status: "pending" } },
|
|
94
|
+
};
|
|
95
|
+
const row = () =>
|
|
96
|
+
t.query(components.betterStripe.connect.queries.getPayoutByStripeId, {
|
|
97
|
+
stripePayoutId: "po_current",
|
|
98
|
+
});
|
|
99
|
+
const ledger = () =>
|
|
100
|
+
t.query(components.betterStripe.webhooks.queries.getWebhookEvent, {
|
|
101
|
+
stripeEventId: event.id,
|
|
102
|
+
});
|
|
103
|
+
const deliver = async (config: RegisterRoutesConfig = {}) => {
|
|
104
|
+
const body = JSON.stringify(event);
|
|
105
|
+
const signature = await Stripe.webhooks.generateTestHeaderStringAsync({
|
|
106
|
+
payload: body,
|
|
107
|
+
secret,
|
|
108
|
+
});
|
|
109
|
+
return t.action(async (ctx) => {
|
|
110
|
+
const response = await handleWebhookRequest(
|
|
111
|
+
ctx,
|
|
112
|
+
new Request("https://example.test/stripe/webhook", {
|
|
113
|
+
method: "POST",
|
|
114
|
+
body,
|
|
115
|
+
headers: { "stripe-signature": signature },
|
|
116
|
+
}),
|
|
117
|
+
components.betterStripe,
|
|
118
|
+
{ stripeSecretKey: key, webhookSecret: secret, webhooks, ...config },
|
|
119
|
+
);
|
|
120
|
+
return { status: response.status, body: await response.json() };
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
return {
|
|
124
|
+
t,
|
|
125
|
+
event,
|
|
126
|
+
deliver,
|
|
127
|
+
row,
|
|
128
|
+
ledger,
|
|
129
|
+
retrieve,
|
|
130
|
+
current: () => ({ ...current }),
|
|
131
|
+
set: (patch: Partial<Stripe.Payout>) => {
|
|
132
|
+
current = { ...current, ...patch };
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
@@ -96,6 +96,7 @@ type MockReversal = {
|
|
|
96
96
|
|
|
97
97
|
function makeStripe() {
|
|
98
98
|
return {
|
|
99
|
+
payouts: { retrieve: vi.fn() },
|
|
99
100
|
refunds: {
|
|
100
101
|
list: vi.fn(() =>
|
|
101
102
|
(async function* () {
|
|
@@ -791,63 +792,77 @@ describe("processEvent — payments (status collapse)", () => {
|
|
|
791
792
|
});
|
|
792
793
|
|
|
793
794
|
describe("processEvent — payouts", () => {
|
|
794
|
-
|
|
795
|
+
function context(id: string, status = "paid") {
|
|
795
796
|
const whCtx = makeWhCtx();
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
797
|
+
whCtx.ctx.runMutation.mockResolvedValue(1 as never);
|
|
798
|
+
whCtx.stripe.payouts.retrieve.mockResolvedValue({
|
|
799
|
+
id,
|
|
799
800
|
amount: 5000,
|
|
800
801
|
currency: "usd",
|
|
801
|
-
status
|
|
802
|
+
status,
|
|
802
803
|
arrival_date: 1700000000,
|
|
803
|
-
|
|
804
|
+
automatic: true,
|
|
805
|
+
method: "standard",
|
|
806
|
+
metadata: { accountId: "acct_untrusted" },
|
|
807
|
+
});
|
|
808
|
+
return whCtx;
|
|
809
|
+
}
|
|
810
|
+
it("scopes connected provider reads to the signed event account", async () => {
|
|
811
|
+
const whCtx = context("po_connected");
|
|
812
|
+
const payoutEvent = event("payout.paid", {
|
|
813
|
+
id: "po_connected",
|
|
814
|
+
destination: "ba_bank",
|
|
815
|
+
metadata: { accountId: "acct_untrusted" },
|
|
804
816
|
});
|
|
805
817
|
payoutEvent.account = "acct_store";
|
|
806
818
|
await processEvent(whCtx, payoutEvent);
|
|
807
|
-
expect(
|
|
819
|
+
expect(whCtx.stripe.payouts.retrieve).toHaveBeenCalledWith(
|
|
820
|
+
"po_connected",
|
|
821
|
+
{},
|
|
822
|
+
{ stripeAccount: "acct_store" },
|
|
823
|
+
);
|
|
824
|
+
expect(dispatchedPayload(whCtx.ctx, 1).data).toMatchObject({
|
|
825
|
+
accountId: "acct_store",
|
|
826
|
+
generation: 1,
|
|
827
|
+
payout: { status: "paid", accountId: "acct_store" },
|
|
828
|
+
});
|
|
808
829
|
});
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
const whCtx = makeWhCtx();
|
|
830
|
+
it("uses explicit platform scope instead of a bank destination or metadata account", async () => {
|
|
831
|
+
const whCtx = context("po_1");
|
|
812
832
|
await processEvent(
|
|
813
833
|
whCtx,
|
|
814
834
|
event("payout.paid", {
|
|
815
835
|
id: "po_1",
|
|
816
836
|
destination: "ba_123",
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
status: "paid",
|
|
820
|
-
arrival_date: 1700000000,
|
|
821
|
-
method: "standard",
|
|
822
|
-
metadata: {},
|
|
837
|
+
status: "pending",
|
|
838
|
+
metadata: { accountId: "acct_forged" },
|
|
823
839
|
}),
|
|
824
840
|
);
|
|
825
|
-
const { path, data } = dispatchedPayload(whCtx.ctx);
|
|
826
|
-
expect(path).toBe("betterStripe/
|
|
841
|
+
const { path, data } = dispatchedPayload(whCtx.ctx, 1);
|
|
842
|
+
expect(path).toBe("betterStripe/payoutSync/mutations/finish");
|
|
827
843
|
expect(data).toMatchObject({
|
|
828
844
|
stripePayoutId: "po_1",
|
|
829
|
-
accountId: "
|
|
830
|
-
|
|
831
|
-
status: "paid",
|
|
832
|
-
method: "standard",
|
|
845
|
+
accountId: "platform",
|
|
846
|
+
generation: 1,
|
|
847
|
+
payout: { status: "paid", amount: 5000, accountId: "platform" },
|
|
833
848
|
});
|
|
849
|
+
expect(whCtx.stripe.payouts.retrieve).toHaveBeenCalledWith("po_1", {}, {});
|
|
834
850
|
});
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
const whCtx = makeWhCtx();
|
|
851
|
+
it("ignores malformed stale event fields when the current platform payout is valid", async () => {
|
|
852
|
+
const whCtx = context("po_2", "failed");
|
|
838
853
|
await processEvent(
|
|
839
854
|
whCtx,
|
|
840
855
|
event("payout.failed", {
|
|
841
856
|
id: "po_2",
|
|
842
857
|
destination: {},
|
|
843
|
-
amount: 100,
|
|
844
|
-
currency: "usd",
|
|
845
|
-
status: "failed",
|
|
846
858
|
arrival_date: null,
|
|
847
859
|
metadata: {},
|
|
848
860
|
}),
|
|
849
861
|
);
|
|
850
|
-
expect(dispatchedPayload(whCtx.ctx).data
|
|
862
|
+
expect(dispatchedPayload(whCtx.ctx, 1).data).toMatchObject({
|
|
863
|
+
accountId: "platform",
|
|
864
|
+
payout: { status: "failed", arrivalDate: "2023-11-14T22:13:20.000Z" },
|
|
865
|
+
});
|
|
851
866
|
});
|
|
852
867
|
});
|
|
853
868
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { handlePayoutEvent } from "./payoutReconciliation.js";
|
|
1
2
|
import { reconcileDisputeMoney } from "./disputeRecovery.js";
|
|
2
3
|
import { successfulRefundPrincipal } from "../connect/refundPrincipal.js";
|
|
3
4
|
import { subscriptionRouting } from "../billing/subscriptionRouting.js";
|
|
@@ -900,33 +901,6 @@ async function upsertPaymentFromStripe(
|
|
|
900
901
|
});
|
|
901
902
|
}
|
|
902
903
|
|
|
903
|
-
async function handlePayoutEvent(
|
|
904
|
-
whCtx: WebhookContext,
|
|
905
|
-
payout: Stripe.Payout,
|
|
906
|
-
connectedAccountId?: string,
|
|
907
|
-
): Promise<void> {
|
|
908
|
-
await dispatchUpsert(whCtx, "payoutUpserted", {
|
|
909
|
-
stripePayoutId: payout.id,
|
|
910
|
-
accountId:
|
|
911
|
-
connectedAccountId ??
|
|
912
|
-
(payout.metadata?.accountId?.startsWith("acct_")
|
|
913
|
-
? payout.metadata.accountId
|
|
914
|
-
: undefined) ??
|
|
915
|
-
(typeof payout.destination === "string"
|
|
916
|
-
? payout.destination
|
|
917
|
-
: (payout.destination?.id ?? "")),
|
|
918
|
-
amount: payout.amount,
|
|
919
|
-
currency: payout.currency,
|
|
920
|
-
status: payout.status as
|
|
921
|
-
"pending" | "paid" | "failed" | "canceled" | "in_transit",
|
|
922
|
-
arrivalDate: epochToIso(payout.arrival_date),
|
|
923
|
-
method: payout.method ?? undefined,
|
|
924
|
-
failureCode: payout.failure_code ?? undefined,
|
|
925
|
-
failureMessage: payout.failure_message ?? undefined,
|
|
926
|
-
metadata: payout.metadata ?? undefined,
|
|
927
|
-
});
|
|
928
|
-
}
|
|
929
|
-
|
|
930
904
|
// Stripe types Refund.status as `string | null`; clamp to the documented union.
|
|
931
905
|
const REFUND_STATUSES = new Set([
|
|
932
906
|
"pending",
|
|
@@ -27,6 +27,7 @@ import type * as connect_reversalReceipts from "../connect/reversalReceipts.js";
|
|
|
27
27
|
import type * as connect_validators from "../connect/validators.js";
|
|
28
28
|
import type * as core_mutations from "../core/mutations.js";
|
|
29
29
|
import type * as core_queries from "../core/queries.js";
|
|
30
|
+
import type * as core_resetSafety from "../core/resetSafety.js";
|
|
30
31
|
import type * as core_validators from "../core/validators.js";
|
|
31
32
|
import type * as costRecovery_claims from "../costRecovery/claims.js";
|
|
32
33
|
import type * as costRecovery_completion from "../costRecovery/completion.js";
|
|
@@ -56,10 +57,17 @@ import type * as payoutRelease_helpers from "../payoutRelease/helpers.js";
|
|
|
56
57
|
import type * as payoutRelease_mutations from "../payoutRelease/mutations.js";
|
|
57
58
|
import type * as payoutRelease_observation from "../payoutRelease/observation.js";
|
|
58
59
|
import type * as payoutRelease_queries from "../payoutRelease/queries.js";
|
|
60
|
+
import type * as payoutSnapshots_localState from "../payoutSnapshots/localState.js";
|
|
61
|
+
import type * as payoutSnapshots_mutations from "../payoutSnapshots/mutations.js";
|
|
62
|
+
import type * as payoutSnapshots_revisions from "../payoutSnapshots/revisions.js";
|
|
63
|
+
import type * as payoutSnapshots_scope from "../payoutSnapshots/scope.js";
|
|
59
64
|
import type * as payoutSync_helpers from "../payoutSync/helpers.js";
|
|
60
65
|
import type * as payoutSync_mutations from "../payoutSync/mutations.js";
|
|
61
66
|
import type * as payoutSync_queries from "../payoutSync/queries.js";
|
|
62
67
|
import type * as payoutSync_validators from "../payoutSync/validators.js";
|
|
68
|
+
import type * as payoutWorker_helpers from "../payoutWorker/helpers.js";
|
|
69
|
+
import type * as payoutWorker_mutations from "../payoutWorker/mutations.js";
|
|
70
|
+
import type * as payoutWorker_queries from "../payoutWorker/queries.js";
|
|
63
71
|
import type * as products_mutations from "../products/mutations.js";
|
|
64
72
|
import type * as products_queries from "../products/queries.js";
|
|
65
73
|
import type * as products_validators from "../products/validators.js";
|
|
@@ -99,6 +107,7 @@ const fullApi: ApiFromModules<{
|
|
|
99
107
|
"connect/validators": typeof connect_validators;
|
|
100
108
|
"core/mutations": typeof core_mutations;
|
|
101
109
|
"core/queries": typeof core_queries;
|
|
110
|
+
"core/resetSafety": typeof core_resetSafety;
|
|
102
111
|
"core/validators": typeof core_validators;
|
|
103
112
|
"costRecovery/claims": typeof costRecovery_claims;
|
|
104
113
|
"costRecovery/completion": typeof costRecovery_completion;
|
|
@@ -128,10 +137,17 @@ const fullApi: ApiFromModules<{
|
|
|
128
137
|
"payoutRelease/mutations": typeof payoutRelease_mutations;
|
|
129
138
|
"payoutRelease/observation": typeof payoutRelease_observation;
|
|
130
139
|
"payoutRelease/queries": typeof payoutRelease_queries;
|
|
140
|
+
"payoutSnapshots/localState": typeof payoutSnapshots_localState;
|
|
141
|
+
"payoutSnapshots/mutations": typeof payoutSnapshots_mutations;
|
|
142
|
+
"payoutSnapshots/revisions": typeof payoutSnapshots_revisions;
|
|
143
|
+
"payoutSnapshots/scope": typeof payoutSnapshots_scope;
|
|
131
144
|
"payoutSync/helpers": typeof payoutSync_helpers;
|
|
132
145
|
"payoutSync/mutations": typeof payoutSync_mutations;
|
|
133
146
|
"payoutSync/queries": typeof payoutSync_queries;
|
|
134
147
|
"payoutSync/validators": typeof payoutSync_validators;
|
|
148
|
+
"payoutWorker/helpers": typeof payoutWorker_helpers;
|
|
149
|
+
"payoutWorker/mutations": typeof payoutWorker_mutations;
|
|
150
|
+
"payoutWorker/queries": typeof payoutWorker_queries;
|
|
135
151
|
"products/mutations": typeof products_mutations;
|
|
136
152
|
"products/queries": typeof products_queries;
|
|
137
153
|
"products/validators": typeof products_validators;
|