Skip to main content
Glama
alamedaim-apps

Authorize.net MCP Server

get_batch_statistics

Retrieve aggregate statistics for a specific Authorize.net batch, including totals and payment method breakdowns.

Instructions

Get aggregate statistics for a specific batch (totals, counts by card type, etc.).

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
batchIdYesThe batch ID to retrieve statistics for.

Implementation Reference

  • The core handler function that constructs the Authorize.Net GetBatchStatisticsRequest, authenticates, executes the API controller, processes the response, handles errors, and returns the batch statistics.
    async function getBatchStatistics(batchId: string) {
      const request = new ApiContracts.GetBatchStatisticsRequest();
      request.setMerchantAuthentication(getMerchantAuth());
      request.setBatchId(batchId);
    
      const ctrl = new ApiControllers.GetBatchStatisticsController(request.getJSON());
      const response = await executeController(ctrl);
    
      const apiResponse = new ApiContracts.GetBatchStatisticsResponse(response);
      if (apiResponse.getMessages().getResultCode() !== ApiContracts.MessageTypeEnum.OK) {
        const errors = apiResponse.getMessages().getMessage();
        throw new Error(`API Error: ${errors[0].getCode()} - ${errors[0].getText()}`);
      }
    
      return apiResponse.getBatch();
    }
  • The input schema definition for the get_batch_statistics tool, specifying the required batchId parameter.
      inputSchema: {
        type: "object",
        properties: {
          batchId: {
            type: "string",
            description: "The batch ID to retrieve statistics for.",
          },
        },
        required: ["batchId"],
      },
    },
  • src/index.ts:267-281 (registration)
    Tool registration in the ListTools response, including name, description, and schema.
    {
      name: "get_batch_statistics",
      description: "Get aggregate statistics for a specific batch (totals, counts by card type, etc.).",
      inputSchema: {
        type: "object",
        properties: {
          batchId: {
            type: "string",
            description: "The batch ID to retrieve statistics for.",
          },
        },
        required: ["batchId"],
      },
    },
    {
  • src/index.ts:324-326 (registration)
    Registration in the CallToolRequest switch statement that dispatches to the handler.
    case "get_batch_statistics":
      result = await getBatchStatistics(args?.batchId as string);
      break;
  • Helper function used by all tools, including getBatchStatistics, to execute Authorize.Net API controllers with Promise wrapping and environment handling.
    function executeController(ctrl: any): Promise<any> {
      return new Promise((resolve, reject) => {
        if (ENVIRONMENT === "production") {
          ctrl.setEnvironment(SDKConstants.endpoint.production);
        }
        ctrl.execute(() => {
          const response = ctrl.getResponse();
          if (response === null) {
            reject(new Error(ctrl.getErrorResponse() || "No response from API"));
          } else {
            resolve(response);
          }
        });
      });
    }

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/alamedaim-apps/authnet-mcp'

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