send_invoice
Sends an invoice to a customer via Visa Acceptance. Requires only the invoice ID for processing.
Instructions
This tool will send an invoice to the customer from Visa Acceptance.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| invoice_id | Yes | Invoice ID (required) |
Implementation Reference
- The main handler function that executes the 'send_invoice' tool logic. It uses the CyberSource InvoicesApi.performSendAction() to send an invoice by ID, then masks customer info in the result.
export const sendInvoice = async ( visaClient: any, context: VisaContext, params: z.infer<ReturnType<typeof sendInvoiceParameters>> ) => { try { const invoiceApiInstance = new cybersourceRestApi.InvoicesApi(visaClient.configuration, visaClient.visaApiClient); const result = await new Promise((resolve, reject) => { invoiceApiInstance.performSendAction(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 send invoice'; } }; - Zod schema defining the input parameter for the tool: invoice_id (string, required).
export const sendInvoiceParameters = ( context: VisaContext = {} as VisaContext ) => { return z.object({ invoice_id: z.string().describe('Invoice ID (required)') }); }; - typescript/src/shared/invoices/sendInvoice.ts:57-68 (registration)The tool definition object registering 'send_invoice' as the method name, with name, description, parameters, actions, and execute handler.
const tool = (context: VisaContext): Tool => ({ method: 'send_invoice', name: 'Send Invoice', description: sendInvoicePrompt(context), parameters: sendInvoiceParameters(context), actions: { invoices: { update: true, }, }, execute: sendInvoice, }); - typescript/src/shared/tools.ts:40-53 (registration)The createTools function that aggregates all tools including sendInvoiceToolModule into a Tool array.
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) ]; } - Helper function maskInvoiceCustomerInfo used by the sendInvoice handler to mask customer PII before returning the result.
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'; } };