Complete working examples demonstrating how to use the @visa/api-client package for direct REST API integration with VIC platform.
This package contains example code and workflows that demonstrate:
- Direct REST API calls to VIC platform using
VicApiClient - Automatic X-Pay token generation and MLE encryption
- End-to-end workflow orchestration
- Error handling and response processing patterns
- Node.js >= 18.0.0
- Visa API credentials (VIC, VDP, MLE certificates)
- Consumer ID and Enrollment Reference ID for testing
- Packages must be built first (see Building section below)
Before running the examples, you must build the required packages:
# From api-examples directory
npm run buildThis will automatically build all required packages and install dependencies.
cd ../..
npm run build:packages-
Copy the environment template:
cp .env.example .env
-
Edit
.envwith your actual Visa credentials:- VIC API credentials (API Key, Shared Secret)
- MLE certificates and private key
- Consumer ID and Enrollment Reference ID
- Visa API base URL
After building the packages and configuring your environment, run the workflow examples:
npm run api:create-cancelnpx tsx workflows/create-and-cancel-instruction.tsvic-api-examples/
├── workflows/ # End-to-end workflow examples
├── package.json # Dependencies and scripts
├── tsconfig.json # TypeScript configuration
├── .env.example # Environment variable template
└── README.md # This file
Make sure you've built the packages first:
npm run buildCheck that:
.envfile exists- All required variables are set
- No extra whitespace in values
If you get API errors:
- Check the correlation ID in the error message
- Verify your credentials are correct
- Ensure certificates are in correct PEM format
- Check that Consumer ID and Enrollment Reference ID are valid
- MCP Examples: See MCP Examples - MCP-based examples using the same APIs
- VDP Examples: See VDP Examples - VDP connectivity testing
- API Client Package: See @visa/api-client README - API client implementation details
- Shared Utils: See Shared Utils - Shared utilities for payload building
- Main Project: See Root README
- Visa Developer Portal: developer.visa.com