On this page3 sections

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

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

bun

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

pnpm

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

The action

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.