Skip to main content
Glama

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
NameRequiredDescriptionDefault

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) }],
            };
        }
    );
  • 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');
    }
  • Input schema for the tool, defined as empty object indicating no input parameters required.
    description: 'Get available payment methods',
    inputSchema: {},
  • 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;
    }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/scarecr0w12/whmcs-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server