On This Page
Visa Acceptance Agent Toolkit Quick Start
Visa Acceptance Agent Toolkit
Quick StartFollow these steps to install and configure the
Visa Acceptance Agent Toolkit
.- Run this command to install theVisa Acceptance Agent Toolkit:npm install @visaacceptance/agent-toolkit
- To enable environment variables, create a new.envfile and insert this code snippet in the file. Replace the sample values with your merchant credentials. To create a REST API shared secret key, see theCreating and Using Security Keys User Guide.VISA_ACCEPTANCE_MERCHANT_ID=your_merchant_id_here VISA_ACCEPTANCE_API_KEY_ID=your_api_key_id_here VISA_ACCEPTANCE_SECRET_KEY=your_secret_key_here
- Use this sample code for your AI agents. In this sample, the toolkit is configured to use the test environment and has all of the Invoicing andPay by Linktools enabled.import { VisaAcceptanceAgentToolkit } from "@visaacceptance/agent-toolkit/ai-sdk"; const toolkit = new VisaAcceptanceAgentToolkit({ merchantId: process.env.VISA_ACCEPTANCE_MERCHANT_ID, apiKeyId: process.env.VISA_ACCEPTANCE_API_KEY_ID, secretKey: process.env.VISA_ACCEPTANCE_SECRET_KEY, configuration: { context: { environment: "SANDBOX", }, actions: { invoices: { create: true, update: true, list: true, get: true, send: true, cancel: true }, paymentLinks: { create: true, update: true, list: true, get: true, }, }, }, });
Example: Creating a Chatbot with the Visa Acceptance Agent Toolkit
Visa Acceptance Agent Toolkit
This example shows the toolkit being used to create an AI
chatbot.
require('dotenv').config(); import { VisaAcceptanceAgentToolkit } from '@visaacceptance/agent-toolkit/ai-sdk'; import { openai } from '@ai-sdk/openai'; import { generateText } from 'ai'; const configuration = { actions: { paymentLinks: { create: true } }, }; const visaAcceptanceAgentToolkit = new VisaAcceptanceAgentToolkit( process.env.VISA_ACCEPTANCE_MERCHANT_ID, process.env.VISA_ACCEPTANCE_API_KEY_ID, process.env.VISA_ACCEPTANCE_SECRET_KEY, "SANDBOX", configuration ); async function aiGeneratedPaymentLink() { console.log("Attempting to generate a payment link..."); const userPrompt = `Create a payment link for a Ski trip to Whistler Canada with a compelling selling point in the description. The total amount is $1000.00.`; const result = await generateText({ model: openai('gpt-4o'), tools: { ...visaAcceptanceAgentToolkit.getTools(), }, maxSteps: 5, prompt: userPrompt, }); console.log(result); } aiGeneratedPaymentLink();