FILTER BY TAG

Visa Acceptance Agent Toolkit
Quick Start

Follow these steps to install and configure the
Visa Acceptance Agent Toolkit
.
  1. Run this command to install the
    Visa Acceptance Agent Toolkit
    :
    npm install @visaacceptance/agent-toolkit
  2. To enable environment variables, create a new
    .env
    file 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 the
    Creating 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
  3. 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 and
    Pay by Link
    tools 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

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();