Visa API SDK
This is an unnofficial Typescript NodeJS sdk for VISA API's. Initially created at SmallBusinessWeek Hackathon 2019.
Note: This SDK is only implemented for a subset of all the Visa REST API's. PR's welcome!
Currently this SDK contains type definitons for the following API's:
Complete:
- Data and Analytics
- Merchant Search
Partial:
- Commercial
- Visa B2B Connect
- Visa B2B Virtual Account Payment Method
- Visa DPS
- Visa DPS Card and Account Services
Other API's may be typed as
any
;
Setup
yarn add visa-sdk# or npm install visa-sdk
Authentication
Visa API's use Two way SSL and credentials to authenticate to their api.
To authenticate NodeJS to the Visa, you will need the following information:
VISA_USER_ID
- a project User IDVISA_PASSWORD
- a project PasswordCERTIFICATE_PASSPHRASE
- your passphrase set when creating the.p12
bundleCERTIFICATE_FILE
- the path to the.p12
bundle file
Visa has documentation on how to generate your .p12
bundle from a CSR file (Visa can generate a CSR if you do not have one).
- Create a Project. While creating the project you will generate or upload a CSR file.
- Download the Certificate private key (
cert.pem
) from the the projectCredentials
page. - Use the OpenSSL cli to bundle both the CSR and private key. You will encrypt the bundle by entering a passphrase. This passphrase is
CERTIFICATE_PASSPHRASE
.
openssl pkcs12 -export -in cert.pem -inkey "privateKey.pem" -certfile cert.pem -out myProject_keyAndCertBundle.p12
In the above example, the path to myProject_keyAndCertBundle.p12
is CERTIFICATE_FILE
- After creating the project, the web interface will present you with both the generated
User ID
andpassword
.
Usage
Hello World
; ; ;visa.helloWorld.then;
Merchant Search
; ; ;merchantSearch.searchquery.then;
Development
Setup:
yarn# --or-- npm install
Build:
# Transpile typescript yarn build# Transpile on file changes yarn watch # --or-- # Transpile typescript npm run build# Transpile on file changes npm run watch