whmcs_get_payment_methods
Retrieve available payment methods from a WHMCS installation to display options for customer transactions.
Instructions
Get available payment methods
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/index.ts:1014-1026 (registration)Registers the 'whmcs_get_payment_methods' tool on the MCP server. Defines empty input schema and a handler that calls whmcsClient.getPaymentMethods() and returns JSON stringified result.'whmcs_get_payment_methods', { title: 'Get Payment Methods', description: 'Get available payment methods', inputSchema: {}, }, async () => { const result = await whmcsClient.getPaymentMethods(); return { content: [{ type: 'text', text: JSON.stringify(result, null, 2) }], }; } );
- src/whmcs-client.ts:1206-1214 (handler)Core handler method in WhmcsApiClient class that executes the WHMCS API 'GetPaymentMethods' action using the generic call() method, returning payment methods list with modules and display names.async getPaymentMethods() { return this.call<WhmcsApiResponse & { totalresults: number; paymentmethods: { paymentmethod: Array<{ module: string; displayname: string; }> }; }>('GetPaymentMethods'); }
- src/index.ts:1017-1018 (schema)Input schema for the tool, defined as empty object indicating no input parameters required.description: 'Get available payment methods', inputSchema: {},
- src/whmcs-client.ts:29-63 (helper)Generic call method used by all API wrappers including getPaymentMethods to make authenticated POST requests to WHMCS API endpoint.async call<T extends WhmcsApiResponse>(action: string, params: Record<string, unknown> = {}): Promise<T> { const url = `${this.config.apiUrl.replace(/\/$/, '')}/includes/api.php`; const postData: Record<string, string> = { identifier: this.config.apiIdentifier, secret: this.config.apiSecret, action: action, responsetype: 'json', ...this.flattenParams(params) }; if (this.config.accessKey) { postData.accesskey = this.config.accessKey; } const response = await fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded', }, body: new URLSearchParams(postData).toString(), }); if (!response.ok) { throw new Error(`WHMCS API request failed: ${response.status} ${response.statusText}`); } const data = await response.json() as T; if (data.result === 'error') { throw new Error(`WHMCS API error: ${data.message || 'Unknown error'}`); } return data; }