//------------------------------------------------------------------------------------ //npm install --save axios moment dotenv const axios = require("axios"); const moment = require("moment"); require('dotenv').config() //------------------------------------------------------------------------------------ /* BEFORE RUNNING THIS EXAMPLE: * Set CONNECTFI_CLIENTID, CONNECTFI_PASSWORD, and CONNECTFI_BASE_URL in an .env file (Speak to a support representative to be issued client credentials and URL after receiving access to the sandbox.) * Set UNIQUE_CUSTOMER_REFERENCE_ID, UNIQUE_CARD_REFERENCE_ID, UNIQUE_FEIN, UNIQUE_SSN_REPRESENTATIVE, and UNIQUE_SSN_EMPLOYEE each to a unique identifier. */ const CONNECTFI_CLIENTID = process.env.CONNECTFI_CLIENTID; const CONNECTFI_PASSWORD = process.env.CONNECTFI_PASSWORD; const CONNECTFI_BASE_URL = process.env.CONNECTFI_BASE_URL; const UNIQUE_CUSTOMER_REFERENCE_ID = "exampleCustRef1024"; //Update this value so that it is a unique ID before running const UNIQUE_CARD_REFERENCE_ID = "exampleRef1024"; //Update this value so that it is a unique ID before running const UNIQUE_FEIN = "000000024"; //Update this value so that it is unique before running const UNIQUE_SSN_REPRESENTATIVE = "000000024"; //Business Representative SSN const UNIQUE_SSN_EMPLOYEE = "100000024"; //Employee SSN //------------------------------------------------------------------------------------ //Get Authorization Token /* All other requests must have a valid authorization token in the request headers, so your first request in any workflow should be to /auth/get-token in order to receive an authorization token. A valid token should be included in the headers of all subsequent requests. */ async function getAuthToken() { const data = { "user": { "login": `${CONNECTFI_CLIENTID}`, "password": `${CONNECTFI_PASSWORD}` } }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/auth/get-token`, headers: { 'Content-Type': "application/json" }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Create (Customer) /* After you have received an authorization token, you may then initialize a customer. Here is an example of how to initialize your choice of a business customer or an employee (as an individual customer). For this walkthrough, we will first initialize the business with a POST request to /customer/init using details for the business. Then we will initialize an employee as an individual customer using a separate /customer/init request using details for the individual employee. Later, we will make a call to /customer/add-employee to add the employee to the business customer. */ async function initCustomer(authToken, reference, ssn, isBusiness, fein) { const data = isBusiness ? { //Details for a business "customerReference": reference, //reference must be unique "customerType": "business", "customer": { "businessName": "ABC123 Inc.", "businessFederalEin": fein, //federal EIN for the business "businessPhones": [ { "type": "PRIMARY", "countryDialingCode": "01", "phoneNumber": "5555555555" } ], "businessAddresses": [ { "type": "PRIMARY", "addressLine1": "123 Main Str.", "addressLine2": "Suite 456", "city": "Harrisburg", "stateCode": "PA", "postalCode": "12345", "countryCodeA3": "USA" } ] }, "businessRepresentatives": [{ "firstName": "John", "lastName": "Doe", "gender": "M", "businessRepresentativeType": "principal_owner", "email": "bus_rep_email_address@email.sample", "phones": [ { "type": "MOBILE", "countryDialingCode": "01", "phoneNumber": "5555555555" } ], "dateOfBirth": "1969-08-04", "citizenshipCountryCodeA3": "USA", "addresses": [ { "type": "PRIMARY", "addressLine1": "123 Main Str.", "addressLine2": "apt 1", "city": "Harrisburg", "stateCode": "PA", "postalCode": "12345", "countryCodeA3": "USA" } ], "identificationDocuments": [ { "type": "SSN", "value": ssn, "issuanceCountryCodeA3": "USA" }, { "type": "DRIVING LICENSE", "value": "PA99999999", "issuanceCountryCodeA3": "USA", "issuanceRegion": "PA", "expiryDate": "2029-12-28" } ] }] } : { //Details for an employee (as an individual customer) "customerReference": reference, //reference must be unique "customerType": "individual", "customer": { "firstName": "John", "lastName": "Jacob", "gender": "M", "email": "your_email_address@email.sample", "phones": [ { "type": "MOBILE", "countryDialingCode": "01", "phoneNumber": "5556667777" } ], "dateOfBirth": "1969-09-04", "citizenshipCountryCodeA3": "USA", "addresses": [ { "type": "PRIMARY", "addressLine1": "456 Main Str.", "addressLine2": "apt 2", "city": "Harrisburg", "stateCode": "PA", "postalCode": "12345", "countryCodeA3": "USA" } ], "identificationDocuments": [ { "type": "SSN", "value": ssn, // The SSN 666989698 is a trigger value to allow the customer to pass a credit check if desired "issuanceCountryCodeA3": "USA" }, { "type": "DRIVING LICENSE", "value": "PA99999999", "issuanceCountryCodeA3": "USA", "issuanceRegion": "PA", "expiryDate": "2029-12-28" } ] } }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/customer/init`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Add Employee /* The term "employee" refers to an individual entity who is employed by the business. The term "business representative" refers to an entity that is specifically designated as a principal owner or authorized signer for the business. Before an individual can be added to a business as an employee, the potential employee must first exist in the connectFi system as an individual customer entity. Therefore, a /customer/init request with "customerType": "individual" and the potential employee's details in the customer personal object is a pre-requisite to making a /customer/add-employee request. After adding the potential employee to the connectFi system using /customer/init, the individual customerId that is returned will be included as the "employeeId" in the /customer/add-employee request. The business customerId will be included as the "companyId" in the /customer/add-employee request. */ async function addEmployee(authToken, customerId, employeeCustomerId) { const data = { "companyId": customerId, "position": "Engineer 1", "employeeId": employeeCustomerId }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/customer/add-employee`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Disable Employee /* The following is an example of how to disable an employee that is associated with a business customer. The disabled employee will still exist and can function as an individual customer, but will no longer be able to open new business cards and/or business accounts that are associated with the business customer for which the employee was disabled. */ async function disableEmployee(authToken, customerId, employeeCustomerId) { const data = { "companyId": customerId, "employeeId": employeeCustomerId }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/customer/disable-employee`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Add vAccount /* You may add a vAccount (virtual account) through a POST request to ibis/account/add. The vAccount that is created can be used both as a bank account (using the account number and routing number) and similar to a debit card (using the cFiAccountId that is issued in place of the cFiCardId where applicable). The cFiAccountId can be used to make requests to the following debit card related endpoints: /ibis/card/activate, /ibis/card/cardholder-profile, /ibis/card/status, /ibis/card/list (will include all cards and vAccounts for the specified customer), /ibis/financial/funds-credit, /ibis/financial/funds-debit, /ibis/financial/card-to-card, and /ibis/inquiry/transaction-history */ async function addVAccount(authToken, customerId, accountHolderId, reference) { const data = { "customerId": customerId, //received when initializing the customer with /customer/init, "reference": reference, //reference must be unique "profile": { "accountHolderId": accountHolderId } }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/account/add`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Add Debit Card /* You may add a Debit Card through a POST request to /ibis/debit-card/add. */ async function addDebitCard(authToken, customerId, cardHolderId, cardHolderType, reference) { const data = { "customerId": customerId, //received when initializing the customer with /customer/init, "reference": reference, //reference must be unique "cardProgramId": "d_gpr_test", "businessInfo": { "companyNameOnCard": "ABC123 Inc." }, "profile": { //Profile for the cardholder (could be a business representative or an employee) "cardHolderId": cardHolderId, "occupation": cardHolderType === "representative" ? "Business Owner" : "Engineer 1", "nameOnCard": cardHolderType === "representative" ? "JOHN DOE" : "JOHN JACOB" } }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/debit-card/add`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Activate Card /* Activate a card that has been issued through a POST request to /ibis/card/activate. */ async function activateCard(authToken, cFiCardId) { const data = { "cFiCardId": cFiCardId }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/card/activate`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Get Card Auth Data /* The POST /ibis/card/get-auth-data endpoint can be used to retrieve the CVV/CVC card security code for the specified card. The connectFi API uses tokenization to redact the CVV/CVC card security code while in our system and does not store the security code or card PAN at any point. It is your (the client's) responsibility to ensure that sensitive card data is redacted when being handled in your system. */ async function getCardAuthData(authToken, cFiCardId) { const data = { "cFiCardId": cFiCardId }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/card/get-auth-data`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Sync Cardholder Profile /* The POST /ibis/card/sync-profile endpoint can be used to sync the current customer profile details stored in connectFi to the relevant card profile at the card processor. After the businessAddresses and/or businessPhones of a business customer have been updated in connectFi using the /customer/update endpoint, then the updated information should be synced with any relevant accounts and/or cards that have been issued through /ibis endpoints. Likewise, if a businessRepresentative on a business customer has been updated via /customer/update, then the /ibis/card/sync-profile endpoint can be called to sync the new businessRepresentative profile information to the specified cards, if applicable, at the card processor. */ async function syncCardholderProfile(authToken, customerId, cardHolderId, cFiCardId) { const data = { "customerId": customerId, "cFiCardId": cFiCardId, "profile": { "cardHolderId": cardHolderId } }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/card/sync-profile`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Set PIN /* Set the card PIN through a POST request to /ibis/card/set-pin. */ async function setPIN(authToken, cFiCardId) { const data = { "cFiCardId": cFiCardId, "pin": "1234" }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/card/set-pin`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Check PIN /* Check the card PIN through a POST request to /ibis/card/check-pin. */ async function checkPIN(authToken, cFiCardId) { const data = { "cFiCardId": cFiCardId, "pin": "1234" }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/card/check-pin`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Check Status /* Check the card status through a POST request to /ibis/card/status. */ async function checkStatus(authToken, cFiCardId) { const data = { "cFiCardId": cFiCardId }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/card/status`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Set Status /* Set the card status through a POST request to /ibis/card/set-status. */ async function setStatus(authToken, cFiCardId, status) { const data = { "cFiCardId": cFiCardId, "statusCode": status }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/card/set-status`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Cardholder Profile /* Retrieve the cardholder profile through a POST request to /ibis/card/cardholder-profile. */ async function cardholderProfile(authToken, cFiCardId) { const data = { "cFiCardId": cFiCardId }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/card/cardholder-profile`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //List Cards/Accounts /* List all cards and vAccounts belonging to a specified customer through a POST request to /ibis/card/list. */ async function list(authToken, customerId) { const data = { "customerId": customerId }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/card/list`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Credit /* Post a credit transaction through a POST request to /ibis/financial/funds-credit. */ async function creditTransaction(authToken, cFiCardId, amount) { const data = { "reference": `cT${UNIQUE_CARD_REFERENCE_ID}`, //reference must be unique "cFiCardId": cFiCardId, "description": "Credit transaction (add funds to card)", "amount": amount, "currency": "USD" }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/financial/funds-credit`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Debit /* Post a debit transaction through a POST request to /ibis/financial/funds-debit. */ async function debitTransaction(authToken, cFiCardId, amount) { const data = { "reference": `dT${UNIQUE_CARD_REFERENCE_ID}`, //reference must be unique "cFiCardId": cFiCardId, "description": "Debit transaction (subtract funds from card)", "amount": amount, "currency": "USD" }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/financial/funds-debit`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Card-to-Card /* Post a card-to-card transaction through a POST request to /ibis/financial/card-to-card. cardFromId and cardToId must have been created using the same card program ID. The cardFromId card must have funds loaded prior to transferring funds through a card-to-card transaction request. */ async function c2cTransaction(authToken, cFiCardId1, cFiCardId2, amount) { const data = { "reference": `c2c${UNIQUE_CARD_REFERENCE_ID}`, //reference must be unique "cardFromId": cFiCardId1, "cardToId": cFiCardId2, "description": "Card-to-card transaction", "amount": amount, "currency": "USD" }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/financial/card-to-card`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Retrieve Transaction /* Retrieve a specified transaction through a POST request to /ibis/financial/retrieve. */ async function retrieveTransaction(authToken, cFiFundsId) { const data = { "cFiFundsId": cFiFundsId }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/financial/retrieve`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Transaction History /* Retrieve the transaction history for a specified card through a POST request to /ibis/inquiry/transaction-history. */ async function transactionHistory(authToken, cFiCardId) { const data = { "cFiCardId": cFiCardId, "dateFrom": `${moment(new Date()).add(-1, "day").format("YYYY-MM-DD")}`, "dateTo": `${moment(new Date()).format("YYYY-MM-DD")}` }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/inquiry/transaction-history`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Reverse Transaction /* Reverse a previous card-to-card transaction through a POST request to /ibis/financial/reversal. */ async function reverseTransaction(authToken, cFiFundsId) { const data = { "cFiFundsId": cFiFundsId }; const config = { method: 'POST', url: `${CONNECTFI_BASE_URL}/ibis/financial/reversal`, headers: { 'Content-Type': "application/json", 'x-connectfi-token': authToken //previously obtained authorization token is required }, data }; let result; try { result = await axios.request(config); if (result.status === 200) { return Promise.resolve(result.data.data); } } catch (err) { console.log({ errCode: err.code, responseStatus: err.response && err.response.status, data: err.response && JSON.stringify(err.response.data) }); } } //------------------------------------------------------------------------------------ //Run the walkthrough async function cardsWalkthroughBus() { //Get Authorization Token console.log(`Start /auth/get-token example.\n`); const authObject = await getAuthToken(); let authToken = undefined; if (authObject) { console.log(`Successfully obtained authorization: ${JSON.stringify(authObject)}\n`); authToken = authObject.token; console.log(`Authorization token: ${authToken}\n`); } else { console.log(`Error getting authorization token\n`) } console.log(`End /auth/get-token example.\n`); //Create (Business Customer) console.log(`Start /customer/init example - Business.\n`); let customerId = undefined; let cardHolderId = undefined; let customerInitResult; if (authToken) { customerInitResult = await initCustomer(authToken, UNIQUE_CUSTOMER_REFERENCE_ID, UNIQUE_SSN_REPRESENTATIVE, true, UNIQUE_FEIN); } else { console.log(`Authorization token is required. Customer not initialized.\n`) } if (customerInitResult) { customerId = customerInitResult.customerId; cardHolderId = customerInitResult.businessRepresentatives[0].id; console.log(`Successfully created business customer: ${JSON.stringify(customerInitResult)}\n`); } console.log(`End /customer/init example - Business.\n`); //Create (Employee - Individual Customer) console.log(`Start /customer/init example - Employee.\n`); let employeeCustomerId = undefined; let employeeCustomerInitResult; if (authToken) { employeeCustomerInitResult = await initCustomer(authToken, `empl${UNIQUE_CUSTOMER_REFERENCE_ID}`, UNIQUE_SSN_EMPLOYEE, false, undefined); } else { console.log(`Authorization token is required. Customer not initialized.\n`) } if (employeeCustomerInitResult) { employeeCustomerId = employeeCustomerInitResult.customerId; console.log(`Successfully created individual customer to represent employee: ${JSON.stringify(employeeCustomerInitResult)}\n`); } console.log(`End /customer/init example - Employee.\n`); //Add Employee console.log(`Start /customer/add-employee example.\n`); let addEmployeeResult; if (authToken && customerId && employeeCustomerId) { addEmployeeResult = await addEmployee(authToken, customerId, employeeCustomerId); } else { console.log(`Authorization token, customerId, and employeeCustomerId are required. Employee not added.\n`) } if (addEmployeeResult) { console.log(`Successfully added employee to business customer: ${JSON.stringify(addEmployeeResult)}\n`); } console.log(`End /customer/add-employee example.\n`); //Add Account console.log(`Start /ibis/account/add example.\n`); let addAccountResult; if (authToken && customerId && cardHolderId) { addAccountResult = await addVAccount(authToken, customerId, cardHolderId, `vA${UNIQUE_CARD_REFERENCE_ID}`); } else { console.log(`Authorization token, cardHolderId, and customerId are required.\n`) } if (addAccountResult) { console.log(`Successfully added a vAccount to customer: ${JSON.stringify(addAccountResult)}\n`); } console.log(`End /ibis/account/add example.\n`); //Add Debit Card (Business Representative is the cardholder) console.log(`Start /ibis/debit-card/add example.\n`); let addDebitCardResult1; let debitCFiCardId1; if (authToken && customerId && cardHolderId) { addDebitCardResult1 = await addDebitCard(authToken, customerId, cardHolderId, "representative", `DC1${UNIQUE_CARD_REFERENCE_ID}`); } else { console.log(`Authorization token, cardHolderId, and customerId are required.\n`) } if (addDebitCardResult1) { debitCFiCardId1 = addDebitCardResult1.cFiCardId; console.log(`Successfully added debit card to customer: ${JSON.stringify(addDebitCardResult1)}\n`); } console.log(`End /ibis/debit-card/add example.\n`); //Add Debit Card 2 (Employee is the cardholder) console.log(`Start /ibis/debit-card/add example 2.\n`); let addDebitCardResult2; let debitCFiCardId2; if (authToken && customerId && employeeCustomerId) { addDebitCardResult2 = await addDebitCard(authToken, customerId, employeeCustomerId, "individual", `DC2${UNIQUE_CARD_REFERENCE_ID}`); } else { console.log(`Authorization token, employeeCustomerId, and customerId are required.\n`) } if (addDebitCardResult2) { debitCFiCardId2 = addDebitCardResult2.cFiCardId; console.log(`Successfully added debit card to customer: ${JSON.stringify(addDebitCardResult2)}\n`); } console.log(`End /ibis/debit-card/add example 2.\n`); //Activate Debit Card console.log(`Start /ibis/card/activate example.\n`); let activateCardResult; if (authToken && debitCFiCardId1) { activateCardResult = await activateCard(authToken, debitCFiCardId1); } else { console.log(`Authorization token and cFiCardId are required.\n`) } if (activateCardResult) { console.log(`Successfully activated card: ${JSON.stringify(activateCardResult)}\n`); } console.log(`End /ibis/card/activate example.\n`); //Get Card Auth Data console.log(`Start /ibis/card/get-auth-data example.\n`); let getCardAuthDataResult; if (authToken && debitCFiCardId1) { getCardAuthDataResult = await getCardAuthData(authToken, debitCFiCardId1); } else { console.log(`Authorization token and cFiCardId are required.\n`) } if (getCardAuthDataResult) { console.log(`Successfully retrieved card auth data: ${JSON.stringify(getCardAuthDataResult)}\n`); } console.log(`End /ibis/card/get-auth-data example.\n`); //Sync Cardholder Profile console.log(`Start /ibis/card/sync-profile example.\n`); let syncCardholderProfileResult; if (authToken && customerId && cardHolderId && debitCFiCardId1) { syncCardholderProfileResult = await syncCardholderProfile(authToken, customerId, cardHolderId, debitCFiCardId1); } else { console.log(`Authorization token, customerId, cardHolderId, and cFiCardId are required.\n`) } if (syncCardholderProfileResult) { console.log(`Successfully synced profile data: ${JSON.stringify(syncCardholderProfileResult)}\n`); } console.log(`End /ibis/card/sync-profile example.\n`); //Set Card PIN console.log(`Start /ibis/card/set-pin example.\n`); let setPINResult; if (authToken && debitCFiCardId1) { setPINResult = await setPIN(authToken, debitCFiCardId1); } else { console.log(`Authorization token and cFiCardId are required.\n`) } if (setPINResult) { console.log(`Successfully set card PIN: ${JSON.stringify(setPINResult)}\n`); } console.log(`End /ibis/card/set-pin example.\n`); //Check Card PIN console.log(`Start /ibis/card/check-pin example.\n`); let checkCardPINResult; if (authToken && debitCFiCardId1) { checkCardPINResult = await checkPIN(authToken, debitCFiCardId1); } else { console.log(`Authorization token and cFiCardId are required.\n`) } if (checkCardPINResult) { console.log(`Successfully checked card PIN: ${JSON.stringify(checkCardPINResult)}\n`); } console.log(`End /ibis/card/check-pin example.\n`); //Check Card Status console.log(`Start /ibis/card/status example.\n`); let checkCardStatusResult; if (authToken && debitCFiCardId1) { checkCardStatusResult = await checkStatus(authToken, debitCFiCardId1); } else { console.log(`Authorization token and cFiCardId are required.\n`) } if (checkCardStatusResult) { console.log(`Successfully retrieved card status: ${JSON.stringify(checkCardStatusResult)}\n`); } console.log(`End /ibis/card/status example.\n`); //Set Card Status "I" console.log(`Start /ibis/card/set-status example - Inactive.\n`); let setCardStatusResult; if (authToken && debitCFiCardId1) { setCardStatusResult = await setStatus(authToken, debitCFiCardId1, "I"); } else { console.log(`Authorization token and cFiCardId are required.\n`) } if (setCardStatusResult) { console.log(`Successfully set card status: ${JSON.stringify(setCardStatusResult)}\n`); } console.log(`End /ibis/card/set-status example - Inactive.\n`); //Set Card Status "B" console.log(`Start /ibis/card/set-status example - Active.\n`); if (authToken && debitCFiCardId1) { setCardStatusResult = await setStatus(authToken, debitCFiCardId1, "B"); } else { console.log(`Authorization token and cFiCardId are required.\n`) } if (setCardStatusResult) { console.log(`Successfully set card status: ${JSON.stringify(setCardStatusResult)}\n`); } console.log(`End /ibis/card/set-status example - Active.\n`); //Get Cardholder Profile console.log(`Start /ibis/card/cardholder-profile example.\n`); let cardholderProfileResult; if (authToken && debitCFiCardId1) { cardholderProfileResult = await cardholderProfile(authToken, debitCFiCardId1); } else { console.log(`Authorization token and cFiCardId are required.\n`) } if (cardholderProfileResult) { console.log(`Successfully retrieved cardholder profile: ${JSON.stringify(cardholderProfileResult)}\n`); } console.log(`End /ibis/card/cardholder-profile example.\n`); //List Cards/Accounts console.log(`Start /ibis/card/list example.\n`); let listResult; if (authToken && customerId) { listResult = await list(authToken, customerId); } else { console.log(`Authorization token and customerId are required.\n`) } if (listResult) { console.log(`Successfully retrieved list of cards and accounts: ${JSON.stringify(listResult)}\n`); } console.log(`End /ibis/card/list example.\n`); //Credit Transaction console.log(`Start /ibis/financial/funds-credit example.\n`); let creditTransactionResult; if (authToken && debitCFiCardId1) { creditTransactionResult = await creditTransaction(authToken, debitCFiCardId1, 30.00); } else { console.log(`Authorization token and cFiCardId are required.\n`) } if (creditTransactionResult) { console.log(`Successfully credited funds: ${JSON.stringify(creditTransactionResult)}\n`); } console.log(`End /ibis/financial/funds-credit example.\n`); //Debit Transaction console.log(`Start /ibis/financial/funds-debit example.\n`); let debitTransactionResult; if (authToken && debitCFiCardId1) { debitTransactionResult = await debitTransaction(authToken, debitCFiCardId1, 1.01); } else { console.log(`Authorization token and cFiCardId are required.\n`) } if (debitTransactionResult) { console.log(`Successfully debited funds: ${JSON.stringify(debitTransactionResult)}\n`); } console.log(`End /ibis/financial/funds-debit example.\n`); //Card-to-Card Transaction console.log(`Start /ibis/financial/card-to-card example.\n`); let c2cTransactionResult; let transactionId = undefined; if (authToken && debitCFiCardId1 && debitCFiCardId2) { c2cTransactionResult = await c2cTransaction(authToken, debitCFiCardId1, debitCFiCardId2, 20.00); } else { console.log(`Authorization token, cFiCardId1, and cFiCardId2 are required.\n`) } if (c2cTransactionResult) { transactionId = c2cTransactionResult.cFiFundsId; console.log(`Successfully transferred funds card-to-card: ${JSON.stringify(c2cTransactionResult)}\n`); } console.log(`End /ibis/financial/card-to-card example.\n`); //Retrieve Transaction console.log(`Start /ibis/financial/retrieve example.\n`); let retrieveTransactionResult; if (authToken && transactionId) { retrieveTransactionResult = await retrieveTransaction(authToken, transactionId); } else { console.log(`Authorization token and cFiFundsId are required.\n`) } if (retrieveTransactionResult) { console.log(`Successfully retrieved transaction details: ${JSON.stringify(retrieveTransactionResult)}\n`); } console.log(`End /ibis/financial/retrieve example.\n`); //Reverse Transaction console.log(`Start /ibis/financial/reversal example.\n`); let reverseTransactionResult; if (authToken && transactionId) { reverseTransactionResult = await reverseTransaction(authToken, transactionId); } else { console.log(`Authorization token and cFiFundsId are required.\n`) } if (reverseTransactionResult) { console.log(`Successfully reversed transaction: ${JSON.stringify(reverseTransactionResult)}\n`); } console.log(`End /ibis/financial/reversal example.\n`); //Transaction History console.log(`Start /ibis/inquiry/transaction-history example.\n`); let transactionHistoryResult; if (authToken && debitCFiCardId1) { transactionHistoryResult = await transactionHistory(authToken, debitCFiCardId1); } else { console.log(`Authorization token and cFiCardId are required.\n`) } if (transactionHistoryResult) { console.log(`Successfully retrieved transaction history: ${JSON.stringify(transactionHistoryResult)}\n`); } console.log(`End /ibis/inquiry/transaction-history example.\n`); //Disable Employee console.log(`Start /customer/disable-employee example.\n`); let disableEmployeeResult; if (authToken && customerId && employeeCustomerId) { disableEmployeeResult = await disableEmployee(authToken, customerId, employeeCustomerId); } else { console.log(`Authorization token, customerId, and employeeCustomerId are required. Employee not disabled.\n`) } if (disableEmployeeResult) { console.log(`Successfully disabled employee: ${JSON.stringify(disableEmployeeResult)}\n`); } console.log(`End /customer/disable-employee example.\n`); } if (process.env.CONNECTFI_CLIENTID && process.env.CONNECTFI_PASSWORD && process.env.CONNECTFI_BASE_URL) { cardsWalkthroughBus(); } else { console.log("Before running the walkthrough, set the required .env variables."); }