Skip to main content
Glama

create_invoice

Generate invoices in Visa Acceptance by providing invoice details, customer information, and delivery preferences to process payments.

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 'createInvoice' that executes the tool logic by calling the Cybersource Invoices API to create an invoice.
    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.
    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 registration object that defines the 'create_invoice' tool, wiring the schema, description, and handler.
    const tool = (context: VisaContext): Tool => ({ method: 'create_invoice', name: 'Create Invoice', description: createInvoicePrompt(context), parameters: createInvoiceParameters(context), actions: { invoices: { create: true, }, }, execute: createInvoice, });
  • Central registration where the create_invoice tool module is included in the list of all tools returned by createTools.
    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