Skip to main content
Glama

cancel_invoice

Cancel an invoice in the Visa Acceptance system by providing the invoice ID to reverse or void transactions.

Instructions

This tool will cancel an invoice in Visa Acceptance.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
invoice_idYesInvoice ID (required)

Implementation Reference

  • The main handler function 'cancelInvoice' that executes the tool logic. It takes visaClient, context, and params (including invoice_id), creates an InvoicesApi instance from Cybersource, calls performCancelAction, masks the result, and returns it or an error message.
    export const cancelInvoice = async ( visaClient: any, context: VisaContext, params: z.infer<ReturnType<typeof cancelInvoiceParameters>> ) => { try { const invoiceApiInstance = new cybersourceRestApi.InvoicesApi(visaClient.configuration, visaClient.visaApiClient); const result = await new Promise((resolve, reject) => { invoiceApiInstance.performCancelAction(params.invoice_id, (error: any, data: any, response: any) => { if (error) { reject(error); } else { resolve({ data, status: response['status'] }); } }); }); const maskedResult = maskInvoiceCustomerInfo(result); return maskedResult; } catch (error) { return 'Failed to cancel invoice'; } };
  • Zod schema 'cancelInvoiceParameters' defining the input parameters for the tool: invoice_id (string, required).
    export const cancelInvoiceParameters = ( context: VisaContext = {} as VisaContext ) => { return z.object({ invoice_id: z.string().describe('Invoice ID (required)') }); };
  • Local tool registration within the module: creates a Tool object with method: 'cancel_invoice', name, description (from prompt), parameters (from schema), actions, and execute: cancelInvoice. Exported as default.
    const tool = (context: VisaContext): Tool => ({ method: 'cancel_invoice', name: 'Cancel Invoice', description: cancelInvoicePrompt(context), parameters: cancelInvoiceParameters(context), actions: { invoices: { update: true, }, }, execute: cancelInvoice, });
  • Global tools registration in createTools function, which returns an array of all tools including cancelInvoiceToolModule(context) at line 47.
    export function createTools(context: VisaContext): Tool[] { return [ createInvoiceToolModule(context), updateInvoiceToolModule(context), getInvoiceToolModule(context), listInvoicesToolModule(context), sendInvoiceToolModule(context), cancelInvoiceToolModule(context), createPaymentLinkToolModule(context), updatePaymentLinkToolModule(context), getPaymentLinkToolModule(context), listPaymentLinkToolModule(context) ]; }
  • Import of the cancelInvoice tool module from './invoices/cancelInvoice'.
    import cancelInvoiceToolModule from './invoices/cancelInvoice';

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/visaacceptance/agent-toolkit'

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