# A refund tool in 60 lines

> Build the tool support asks for most often: look up an order, refund part of it, and log who did it.

- URL: https://devtool-changelog-example.notra.site/blog/refund-tool-in-60-lines
- Published: 2026-09-10
- Authors: Ines Varga, Kofi Mensah
- Tags: guides

Every support team ends up asking engineering for the same tool: find an order, refund some of it, and keep a record. Here’s the whole thing in Forgekit.

## Set up

**npm**

```bash
npx forgekit init refunds && cd refunds && npm install
```

**bun**

```bash
bunx forgekit init refunds && cd refunds && bun install
```

**pnpm**

```bash
pnpm dlx forgekit init refunds && cd refunds && pnpm install
```

## The action

```typescript
import { defineAction } from "@forgekit/sdk";
import { z } from "zod";

export const refund = defineAction({
  input: z.object({ orderId: z.string(), amountCents: z.number().int().positive() }),
  access: { groups: ["support"] },
  async run({ input, ctx, stripe, audit }) {
    const result = await stripe.refunds.create({
      payment_intent: input.orderId,
      amount: input.amountCents,
    });
    await audit.log("refund", { by: ctx.user.email, ...input });
    return result;
  },
});
```

`access.groups` limits the action to your support group in Okta, and `audit.log` writes to the tool’s audit table, which shows up under **Activity** in the deployed tool.

## The screen

The UI is a lookup field, an order table and a form bound to the action. The form fields come from the schema, so there’s nothing else to wire up.

> **Note**
>
> Run `forge dev` and the tool opens at `localhost:4310` with a fake Stripe account seeded with 50 orders.
