Skip to main content
Glama
visaacceptance

Visa Acceptance

create_invoice

Generate a customer invoice with total amount, currency, and due date. Send immediately via email or set delivery mode.

Instructions

This tool will create an invoice in Visa Acceptance.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
invoice_numberYesUnique invoice number (letters & numbers only, <20 chars)
totalAmountYesInvoice total amount e.g. "100.00"
currencyYesInvoice currency code e.g. "USD"
customerNameNoCustomer name for invoice
customerEmailNoCustomer email for invoice
invoiceInformationYesInvoice information object

Implementation Reference

  • The main handler function that executes the create_invoice tool logic. It accepts parameters validated by createInvoiceParameters, constructs a request object with merchantId, customer info, order info, and invoice info, then calls the CyberSource InvoicesApi.createInvoice() API. Returns masked result via maskInvoiceCustomerInfo helper.
    export const createInvoice = async (
      visaClient: any,
      context: VisaContext,
      params: z.infer<ReturnType<typeof createInvoiceParameters>>
    ) => {
      try {
        const invoiceApiInstance = new cybersourceRestApi.InvoicesApi(visaClient.configuration, visaClient.visaApiClient);
        
        const requestObj = {
          merchantId: context.merchantId,
          customerInformation: {
            name: params.customerName,
            email: params.customerEmail
          },
          orderInformation: {
            amountDetails: {
              totalAmount: params.totalAmount,
              currency: params.currency
            }
          },
          invoiceInformation: {
            description: params.invoiceInformation?.description,
            dueDate: params.invoiceInformation?.dueDate || new Date(Date.now() + 30 * 24 * 60 * 60 * 1000).toISOString().split('T')[0],
            invoiceNumber: params.invoice_number,
            sendImmediately: params.invoiceInformation?.sendImmediately !== undefined ? params.invoiceInformation.sendImmediately : true,
            deliveryMode: params.invoiceInformation?.deliveryMode || 'email'
          }
        };
        
        const result = await new Promise((resolve, reject) => {
          invoiceApiInstance.createInvoice(requestObj, (error: any, data: any) => {
            if (error) {
              reject(error);
            } else {
              resolve(data);
            }
          });
        });
        
        const maskedResult = maskInvoiceCustomerInfo(result);
        return maskedResult;
      } catch (error) {
        return 'Failed to create invoice';
      }
    };
  • Zod schema defining the input parameters for create_invoice tool: invoice_number (string), totalAmount (string), currency (string), customerName (optional string), customerEmail (optional string), and invoiceInformation object (description, dueDate, sendImmediately, deliveryMode).
    export const createInvoiceParameters = (
      context: VisaContext = {} as VisaContext
    ) => {
      return z.object({
        invoice_number: z.string().describe('Unique invoice number (letters & numbers only, <20 chars)'),
        totalAmount: z.string().describe('Invoice total amount e.g. "100.00"'),
        currency: z.string().describe('Invoice currency code e.g. "USD"'),
        customerName: z.string().optional().describe('Customer name for invoice'),
        customerEmail: z.string().optional().describe('Customer email for invoice'),
        invoiceInformation: z.object({
          description: z.string().describe('Short invoice description (max 50 characters)'),
          dueDate: z.string().describe('Due date in YYYY-MM-DD format'),
          sendImmediately: z.boolean().describe('Whether to send the invoice immediately'),
          deliveryMode: z.string().describe('Delivery mode e.g. "email"')
        }).required().describe('Invoice information object'),
      });
    };
  • Registration of the create_invoice tool as a Tool object with method 'create_invoice', name 'Create Invoice', description, parameters, actions, and execute handler. Exported as default and imported into tools.ts where it's added to the tools array.
    const tool = (context: VisaContext): Tool => ({
      method: 'create_invoice',
      name: 'Create Invoice',
      description: createInvoicePrompt(context),
      parameters: createInvoiceParameters(context),
      actions: {
        invoices: {
          create: true,
        },
      },
      execute: createInvoice,
    });
  • The create_invoice tool module is imported from './invoices/createInvoice' and added to the array of tools returned by the createTools function.
    createInvoiceToolModule(context),
  • Helper function maskInvoiceCustomerInfo that masks PII (name and email) in the invoice result returned by the create_invoice handler, using maskPII utility to preserve privacy.
    export const maskInvoiceCustomerInfo = (
      invoice: any,
      context?: Context
    ): any => {
      try {
        if (!invoice) return invoice;
        
        const maskedInvoice = JSON.parse(JSON.stringify(invoice));
        
        if (maskedInvoice.customerInformation) {
          if (maskedInvoice.customerInformation.name) {
            maskedInvoice.customerInformation.name = maskPII(maskedInvoice.customerInformation.name, 'end');
          }
          
          if (maskedInvoice.customerInformation.email) {
            const emailParts = maskedInvoice.customerInformation.email.split('@');
            if (emailParts.length === 2) {
              const maskedLocalPart = maskPII(emailParts[0], 'end');
              maskedInvoice.customerInformation.email = `${maskedLocalPart}@${emailParts[1]}`;
            } else {
              maskedInvoice.customerInformation.email = maskPII(maskedInvoice.customerInformation.email, 'end');
            }
          }
        }
        
        return maskedInvoice;
      } catch (error) {
        return 'Failed to mask invoice customer information';
      }
    };
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are present, so the description must convey behavioral traits. It only says 'create an invoice' without mentioning side effects like sending, persistence, or output expectations. Critical details like automatic sending or delivery are absent.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is a single focused sentence, highly concise and front-loaded. There is no extraneous information, though it lacks depth.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness2/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool has 6 parameters including a nested object and no output schema, the description is too minimal. It does not explain return values, error conditions, or the effect of parameters like 'sendImmediately', leaving the agent underinformed.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema description coverage is 100%, so the schema already documents parameter purposes. The description adds no additional meaning beyond what the schema provides, meeting the baseline for high coverage.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool creates an invoice in 'Visa Acceptance', distinguishing it from sibling creation tools like 'create_payment_link'. The verb 'create' is specific and the resource 'invoice' is unambiguous.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines1/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives such as 'create_payment_link', nor does it specify prerequisites or scenarios where creation is inappropriate.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

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