list_transactions
Retrieve a list of transactions with optional filters for customer, invoice, status, type, date range, gateway, and pagination.
Instructions
List transactions. GET /transactions. Optional: customerId, invoiceId, status (settled|authorized|declined|error|voided|requiresPaymentMethod|awaitingForSettlement|authorizeAndHold), type (sale|refund), dateFrom, dateTo, companyGatewayId, orderBy, sortBy, itemPerPage, pageNo.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| customerId | No | Filter by customer ID | |
| invoiceId | No | Filter by invoice ID | |
| status | No | Filter by transaction status | |
| type | No | Filter by transaction type | |
| dateFrom | No | Filter by date from (YYYY-MM-DD) | |
| dateTo | No | Filter by date to (YYYY-MM-DD) | |
| companyGatewayId | No | Filter by company gateway ID | |
| orderBy | No | Sort column | |
| sortBy | No | Sort direction | |
| itemPerPage | No | Items per page | |
| pageNo | No | Page number |
Implementation Reference
- Handler function for list_transactions. Parses args with Zod schema, then calls transactionService.listTransactions.
async function handler(client: Client, args: Record<string, unknown> | undefined) { const parsed = schema.safeParse(args); if (!parsed.success) { return errorResult(parsed.error.errors.map((e) => e.message).join("; ")); } return handleToolCall(() => transactionService.listTransactions(client, parsed.data)); } - Zod input validation schema for list_transactions tool parameters.
const schema = z.object({ customerId: z.number().int().optional(), invoiceId: z.number().int().optional(), status: z .enum([ "settled", "authorized", "declined", "error", "voided", "requiresPaymentMethod", "awaitingForSettlement", "authorizeAndHold", ]) .optional(), type: z.enum(["sale", "refund"]).optional(), dateFrom: z.string().optional(), dateTo: z.string().optional(), companyGatewayId: z.number().int().optional(), orderBy: z.string().optional(), sortBy: z.string().optional(), itemPerPage: z.number().int().min(1).optional(), pageNo: z.number().int().min(1).optional(), }); - src/tools/transactions/index.ts:1-25 (registration)Registration of listTransactionsTool as part of the transaction tools array.
/** * Transaction tools: list, get, refund, void. */ import type { Tool } from "../types.js"; import { getTransactionTool } from "./getTransaction.js"; import { listTransactionsTool } from "./listTransactions.js"; import { refundTransactionTool } from "./refundTransaction.js"; import { voidTransactionTool } from "./voidTransaction.js"; /** All 4 transaction tools. */ export function registerTransactionTools(): Tool[] { return [ listTransactionsTool, getTransactionTool, refundTransactionTool, voidTransactionTool, ]; } export { listTransactionsTool } from "./listTransactions.js"; export { getTransactionTool } from "./getTransaction.js"; export { refundTransactionTool } from "./refundTransaction.js"; export { voidTransactionTool } from "./voidTransaction.js"; - Service function that makes the actual HTTP GET /transactions API call with query parameters.
export async function listTransactions( client: Client, params?: ListTransactionsParams ): Promise<PaginatedResponse<unknown>> { const search = new URLSearchParams(); if (params?.customerId != null) search.append("customerId", String(params.customerId)); if (params?.invoiceId != null) search.append("invoiceId", String(params.invoiceId)); if (params?.status) search.append("status", params.status); if (params?.type) search.append("type", params.type); if (params?.dateFrom) search.append("dateFrom", params.dateFrom); if (params?.dateTo) search.append("dateTo", params.dateTo); if (params?.companyGatewayId != null) { search.append("companyGatewayId", String(params.companyGatewayId)); } if (params?.orderBy) search.append("orderBy", params.orderBy); if (params?.sortBy) search.append("sortBy", params.sortBy); if (params?.itemPerPage != null) search.append("itemPerPage", String(params.itemPerPage)); if (params?.pageNo != null) search.append("pageNo", String(params.pageNo)); const q = search.toString(); return client.get<PaginatedResponse<unknown>>(`/transactions${q ? `?${q}` : ""}`); - TypeScript interface for the listTransactions API parameters.
export interface ListTransactionsParams { customerId?: number; invoiceId?: number; status?: | "settled" | "authorized" | "declined" | "error" | "voided" | "requiresPaymentMethod" | "awaitingForSettlement" | "authorizeAndHold"; type?: "sale" | "refund"; dateFrom?: string; dateTo?: string; companyGatewayId?: number; orderBy?: string; sortBy?: string; itemPerPage?: number; pageNo?: number; }