Add Payment
whmcs_add_paymentRecord a payment on a WHMCS invoice by providing invoice ID, transaction ID, and gateway. Optionally specify amount, fees, payment date, and suppress email notifications.
Instructions
Record a payment on an invoice
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| invoiceid | Yes | Invoice ID | |
| transid | Yes | Transaction ID | |
| gateway | Yes | Payment gateway name | |
| amount | No | Payment amount | |
| fees | No | Transaction fees | |
| noemail | No | Do not send email | |
| date | No | Payment date (YYYY-MM-DD) |
Implementation Reference
- src/index.ts:349-370 (registration)Registration of the 'whmcs_add_payment' tool with the MCP server. Defines input schema using Zod for invoiceid (required), transid (required), gateway (required), and optional amount, fees, noemail, date. The handler delegates to whmcsClient.addPayment().
server.registerTool( 'whmcs_add_payment', { title: 'Add Payment', description: 'Record a payment on an invoice', inputSchema: { invoiceid: z.number().describe('Invoice ID'), transid: z.string().describe('Transaction ID'), gateway: z.string().describe('Payment gateway name'), amount: z.number().optional().describe('Payment amount'), fees: z.number().optional().describe('Transaction fees'), noemail: z.boolean().optional().describe('Do not send email'), date: z.string().optional().describe('Payment date (YYYY-MM-DD)'), }, }, async (params) => { const result = await whmcsClient.addPayment(params); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } ); - src/index.ts:364-369 (handler)The inline handler function for the whmcs_add_payment tool. It calls whmcsClient.addPayment(params) and returns the result as JSON text content.
async (params) => { const result = await whmcsClient.addPayment(params); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } - src/whmcs-client.ts:555-565 (helper)The addPayment method in the WhmcsApiClient class. Sends an 'AddInvoicePayment' API action to WHMCS with parameters: invoiceid, transid, gateway, amount, fees, noemail, date. This is the actual implementation that calls the WHMCS API.
async addPayment(params: { invoiceid: number; transid: string; gateway: string; amount?: number; fees?: number; noemail?: boolean; date?: string; }) { return this.call<WhmcsApiResponse>('AddInvoicePayment', params); }