diff --git a/.changeset/neat-eel-walk.md b/.changeset/neat-eel-walk.md new file mode 100644 index 000000000..855c6cb07 --- /dev/null +++ b/.changeset/neat-eel-walk.md @@ -0,0 +1,5 @@ +--- +"@exactly/server": patch +--- + +🦺 acknowledge panda dispute events diff --git a/server/hooks/panda.ts b/server/hooks/panda.ts index 46a3bc0ba..2965fb0fe 100644 --- a/server/hooks/panda.ts +++ b/server/hooks/panda.ts @@ -189,6 +189,12 @@ const Card = v.variant("action", [ const Payload = v.variant("resource", [ Transaction, Card, + v.object({ + resource: v.literal("dispute"), + action: v.string(), + body: v.looseObject({ id: v.string() }), + id: v.string(), + }), v.object({ resource: v.literal("user"), action: v.literal("updated"), @@ -219,6 +225,7 @@ export default new Hono().post( getActiveSpan()?.setAttribute(SEMANTIC_ATTRIBUTE_SENTRY_OP, `panda.${payload.resource}.${payload.action}`); if (payload.resource !== "transaction") { + if (payload.resource === "dispute") return c.json({ code: "ok" }); const pandaId = payload.resource === "card" ? payload.action === "updated" diff --git a/server/test/hooks/panda.test.ts b/server/test/hooks/panda.test.ts index 27e113230..a4606fb4b 100644 --- a/server/test/hooks/panda.test.ts +++ b/server/test/hooks/panda.test.ts @@ -1363,6 +1363,22 @@ describe("card notification", () => { }); }); +describe("dispute", () => { + it("returns ok", async () => { + const response = await appClient.index.$post({ + header: { signature: "panda-signature" }, + json: { + resource: "dispute", + action: "created", + body: { id: "dispute-id", status: "pending", transactionId: "tx-id" }, + id: "webhook-id", + }, + }); + expect(response.status).toBe(200); + await expect(response.json()).resolves.toStrictEqual({ code: "ok" }); + }); +}); + describe("concurrency", () => { let owner2: WalletClient, typeof chain, ReturnType>; let account2: Address;