charge_invoice_external
Charge an invoice via offline payment (cash/check/wire). Provide invoice ID and amount in cents.
Instructions
Charge an invoice via offline payment (cash/check/wire). POST /invoices/{invoiceId}/charge with paymentType: offlinePaymentProvider. AMOUNT IN CENTS: e.g. 5500 = $55.00. Required: invoiceId, amount (integer cents).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| invoiceId | Yes | Invoice ID (required) | |
| amount | Yes | Amount in CENTS (e.g. 5500 = $55.00). Integer, required. |
Implementation Reference
- Handler function that validates args via Zod schema and delegates to invoiceService.chargeInvoiceExternal with invoiceId and amount.
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("; ")); } const { invoiceId, amount } = parsed.data; return handleToolCall(() => invoiceService.chargeInvoiceExternal(client, invoiceId, { amount }) ); } - src/services/invoiceServices.ts:160-169 (handler)Core service function that POSTs to /invoices/{invoiceId}/charge with paymentType: offlinePaymentProvider, enabling offline/cash/check/wire charging.
export async function chargeInvoiceExternal( client: Client, invoiceId: string, body: Omit<ChargeInvoiceBody, "paymentType"> ): Promise<unknown> { return client.post<unknown>(`/invoices/${invoiceId}/charge`, { ...body, paymentType: "offlinePaymentProvider", }); } - Zod validation schema requiring invoiceId (string) and amount (positive integer in CENTS).
const schema = z.object({ invoiceId: z.string().min(1, "invoiceId is required"), amount: z.number().int().min(1, "amount is required and must be positive (in CENTS)"), }); - Tool definition including name 'charge_invoice_external', description, and JSON Schema input schema.
const definition = { name: "charge_invoice_external", description: "Charge an invoice via offline payment (cash/check/wire). POST /invoices/{invoiceId}/charge with paymentType: offlinePaymentProvider. AMOUNT IN CENTS: e.g. 5500 = $55.00. Required: invoiceId, amount (integer cents).", inputSchema: { type: "object" as const, properties: { invoiceId: { type: "string", description: "Invoice ID (required)" }, amount: { type: "number", description: "Amount in CENTS (e.g. 5500 = $55.00). Integer, required.", }, }, required: ["invoiceId", "amount"], }, }; - src/tools/invoices/index.ts:35-36 (registration)Re-export of chargeInvoiceExternalTool from the centralized invoice tools barrel module, making it available for registration.
export { chargeInvoiceExternalTool } from "./chargeInvoiceExternal.js"; export { voidInvoiceTool } from "./voidInvoice.js";