### Install Finix Node.js SDK Source: https://github.com/finix-payments/finix-nodejs/blob/main/README.md Installs the Finix Node.js SDK using npm. Ensure you have Node.js 16 or higher. ```bash npm install --save @finix-payments/finix ``` -------------------------------- ### Create a Transfer Source: https://github.com/finix-payments/finix-nodejs/blob/main/README.md Example of creating a transfer using the Finix client. Requires initialized client and transfer details. ```typescript const createTransferRequest: Models.CreateTransferRequest = { currency: Models.Currency.Usd, merchant: "MUeDVrf2ahuKc9Eg5TeZugvs", tags: { "test": "sale" }, source: "PIe2YvpcjvoVJ6PzoRPBK137", amount: 662154, }; const transfer = await client.Transfers.create(saleRequest); ``` -------------------------------- ### Upload Dispute Evidence File Source: https://github.com/finix-payments/finix-nodejs/blob/main/README.md Example of uploading a file, specifically dispute evidence, using `fs.ReadStream`. Requires the `fs` module and a file path. ```typescript import * as fs from 'fs'; const fileName : string = __dirname.concat("/test.png"); const fileObject: fs.ReadStream = fs.createReadStream(fileName); const uploadedDisputeEvidence = await client.Disputes.createDisputeEvidence(disputeId, { file: fileObject}); ``` -------------------------------- ### Initialize Finix Client Source: https://github.com/finix-payments/finix-nodejs/blob/main/README.md Initializes the Finix client with API credentials and the target environment (e.g., Sandbox). Requires Node.js 16+. ```typescript import {Client, Environment, Models} from '@finix-payments/finix'; const userName = 'USsRhsHYZGBPnQw8CByJyEQW'; const password = '8a14c2f9-d94b-4c72-8f5c-a62908e5b30e'; const client = new Client(userName, password, Environment.Sandbox); ``` -------------------------------- ### Retrieve Transfers List Source: https://github.com/finix-payments/finix-nodejs/blob/main/README.md Demonstrates retrieving lists of transfers, including filtering by parameters like limit, amount, and type. Shows how to access pagination details and iterate through results. ```typescript // Retrieving list of all transfers const transfersList : Models.finixList = await client.Transfers.list(); // Retrieving list of transfers with the following filters: // List limit: 2 // Amount less than 100 // Transfer type: Debits const transfersListWithFilter = await client.Transfers.list({ limit: 2, amountLt: 100, type: "Debits" }); // Accessing transfers in the list and print out value for (let currTransfer of transfersList){ console.log(currTransfer); } // Get the size of the current list const transferListSize : number = transfersList.size; // Get the page object that contains properties including offset/nextCursor, limit. // Note: refer to the specific api to see if the page object associated is of type pageCursor or pageOffset const page : Models.PageCursor = transfersList.page; // Get the links const links : Models.ListLinks = transfersList.links; // Check if there is more to list, value equals to False if end of list has been reached const hasMore : Boolean = transfersList.hasMore; // Get the next list const nextTransfersList : Models.finixList = await transfersList.listNext(); ``` -------------------------------- ### Handle API Errors Source: https://github.com/finix-payments/finix-nodejs/blob/main/README.md Demonstrates how to use try-catch blocks to handle errors during API calls. Shows how to access error details like status code, headers, and messages. ```typescript const userName = 'USsRhsHYZGBPnQw8CByJyEQW'; const wrongPassword = '123'; try{ const invalidClient = new Client(userName, wrongPassword, Environment.Sandbox); let transferList = await invalidClient.Transfers.list(); }catch(error){ // Print basic http information of the error console.log(error.statusCode); console.log(error.headers); // Print message of each error for (let e of error.body){ console.log(e.message); } // Access raw http incoming message of the error const errorRawResponse = error.response; } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.