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
| Name | Required | Description | Default |
|---|---|---|---|
| batchId | Yes | The batch ID to retrieve statistics for. |
Implementation Reference
- src/index.ts:145-160 (handler)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(); }
- src/index.ts:270-280 (schema)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;
- src/index.ts:37-51 (helper)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); } }); }); }