charge_invoice
Charge an invoice via card/online payment. Provide invoice ID, amount in cents, and set paymentType to thirdPartyPaymentProvider for card/online.
Instructions
Charge an invoice (card/online payment). POST /invoices/{invoiceId}/charge. AMOUNT IN CENTS: e.g. 5500 = $55.00. Required: invoiceId, amount (integer cents), paymentType (offlinePaymentProvider | thirdPartyPaymentProvider | walletPaymentProvider | otherPayment). Use thirdPartyPaymentProvider for card/online.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| invoiceId | Yes | Invoice ID (required) | |
| amount | Yes | Amount in CENTS (e.g. 5500 = $55.00). Integer, required. | |
| paymentType | Yes | Payment type (required): offlinePaymentProvider, thirdPartyPaymentProvider, walletPaymentProvider, or otherPayment. Use thirdPartyPaymentProvider for card/online. |
Implementation Reference
- Handler function for the charge_invoice tool. Parses args with Zod schema (invoiceId, amount, paymentType), then calls invoiceService.chargeInvoice to POST /invoices/{invoiceId}/charge.
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, paymentType } = parsed.data; return handleToolCall(() => invoiceService.chargeInvoice(client, invoiceId, { amount, paymentType }) ); } - Zod validation schema for charge_invoice: invoiceId (string), amount (positive integer in cents), paymentType (enum of 4 values).
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)"), paymentType: z.enum(paymentTypeEnum, { required_error: "paymentType is required" }), }); - MCP tool definition (name: charge_invoice, description, inputSchema with properties invoiceId, amount, paymentType).
const definition = { name: "charge_invoice", description: "Charge an invoice (card/online payment). POST /invoices/{invoiceId}/charge. AMOUNT IN CENTS: e.g. 5500 = $55.00. Required: invoiceId, amount (integer cents), paymentType (offlinePaymentProvider | thirdPartyPaymentProvider | walletPaymentProvider | otherPayment). Use thirdPartyPaymentProvider for card/online.", 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.", }, paymentType: { type: "string", description: "Payment type (required): offlinePaymentProvider, thirdPartyPaymentProvider, walletPaymentProvider, or otherPayment. Use thirdPartyPaymentProvider for card/online.", }, }, required: ["invoiceId", "amount", "paymentType"], }, }; - src/tools/invoices/chargeInvoice.ts:47-50 (registration)Exported Tool object combining definition and handler for charge_invoice.
export const chargeInvoiceTool: Tool = { definition, handler, }; - src/tools/invoices/index.ts:16-27 (registration)registerInvoiceTools() includes chargeInvoiceTool in the list of all invoice tools returned.
export function registerInvoiceTools(): Tool[] { return [ listInvoicesTool, getInvoiceTool, createInvoiceTool, updateInvoiceTool, deleteInvoiceTool, chargeInvoiceTool, chargeInvoiceExternalTool, voidInvoiceTool, ]; }