Skip to main content
Glama

create_invoice

Generate invoices in the Visa Acceptance system by providing invoice details, customer information, and payment terms to facilitate billing and payment processing.

Instructions

This tool will create an invoice in Visa Acceptance.

Input Schema

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

Implementation Reference

  • The async handler function 'createInvoice' that executes the tool logic by constructing a request object and calling the Cybersource InvoicesApi.createInvoice method.
    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 the create_invoice tool, including invoice details, customer info, and invoice information.
    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'), }); };
  • Tool object definition for 'create_invoice', including method name, description, parameters schema, actions, and reference to the execute handler.
    const tool = (context: VisaContext): Tool => ({ method: 'create_invoice', name: 'Create Invoice', description: createInvoicePrompt(context), parameters: createInvoiceParameters(context), actions: { invoices: { create: true, }, }, execute: createInvoice, });
  • Function that registers and returns the list of tools, including the create_invoice tool module instantiated with context.
    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) ]; }

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