Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/neat-eel-walk.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@exactly/server": patch
---

🦺 acknowledge panda dispute events
7 changes: 7 additions & 0 deletions server/hooks/panda.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down Expand Up @@ -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"
Expand Down
16 changes: 16 additions & 0 deletions server/test/hooks/panda.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<ReturnType<typeof http>, typeof chain, ReturnType<typeof privateKeyToAccount>>;
let account2: Address;
Expand Down