A fintech API for user onboarding, account management, and payments.
The SDK relies on Node.js and npm (to resolve dependencies). It also requires Typescript version >=4.1. You can download and install Node.js and npm from the official Node.js website.
NOTE: npm is installed by default when Node.js is installed.
Run the following commands in the command prompt or shell of your choice to check if Node.js and npm are successfully installed:
-
Node.js:
node --version -
npm:
npm --version
- To resolve all dependencies, go to the SDK root directory and run the following command with npm:
npm install- This will install all dependencies in the node_modules folder.
The following section explains how to use the generated library in a new project.
-
Open an IDE/text editor for JavaScript like Visual Studio Code. The basic workflow presented here is also applicable if you prefer using a different editor or IDE.
-
Click on File and select Open Folder. Select an empty folder of your project, the folder will become visible in the sidebar on the left.
- To initialize the Node project, click on Terminal and select New Terminal. Execute the following command in the terminal:
npm init --y- The created project manages its dependencies using its
package.jsonfile. In order to add a dependency on the Fintech Payment & Banking APILib client library, double click on thepackage.jsonfile in the bar on the left and add the dependency to the package in it.
- To install the package in the project, run the following command in the terminal:
npm installTo validate the functionality of this SDK, you can execute all tests located in the test directory. This SDK utilizes Jest as both the testing framework and test runner.
To run the tests, navigate to the root directory of the SDK and execute the following command:
npm run testOr you can also run tests with coverage report:
npm run test:coverageThe following test files cover all SDK controllers and their endpoints:
| Test File | Controller |
|---|---|
test/controllers/accountsController.test.ts |
AccountsController |
test/controllers/paymentsController.test.ts |
PaymentsController |
Customization: The test files in
test/controllers/were added as SDK customizations beyond the generated output.
Note: Documentation for the client can be found here.
The following parameters are configurable for the API Client:
| Parameter | Type | Description |
|---|---|---|
| timeout | number |
Timeout for API calls. Default: 30000 |
| httpClientOptions | Partial<HttpClientOptions> |
Stable configurable http client options. |
| unstableHttpClientOptions | any |
Unstable configurable http client options. |
| logging | PartialLoggingOptions |
Logging Configuration to enable logging |
| basicAuthCredentials | BasicAuthCredentials |
The credential object for basicAuth |
| customAuthCredentials | CustomAuthCredentials |
The credential object for customAuth |
The API client can be initialized as follows:
import { Client, LogLevel } from 'fintech-payment-banking-apilib';
const client = new Client({
basicAuthCredentials: {
username: 'Username',
password: 'Password',
},
customAuthCredentials: {
'hash': 'hash',
},
timeout: 30000,
logging: {
logLevel: LogLevel.Info,
logRequest: {
logBody: true,
},
logResponse: {
logHeaders: true,
},
},
});import * as path from 'path';
import * as fs from 'fs';
import { Client } from 'fintech-payment-banking-apilib';
// Provide absolute path for the configuration file
const absolutePath = path.resolve('./config.json');
// Read the configuration file content
const fileContent = fs.readFileSync(absolutePath, 'utf-8');
// Initialize client from JSON configuration content
const client = Client.fromJsonConfig(fileContent);See the Configuration-Based Client Initialization section for details.
import * as dotenv from 'dotenv';
import * as path from 'path';
import * as fs from 'fs';
import { Client } from 'fintech-payment-banking-apilib';
// Optional - Provide absolute path for the .env file
const absolutePath = path.resolve('./.env');
if (fs.existsSync(absolutePath)) {
// Load environment variables from .env file
dotenv.config({ path: absolutePath, override: true });
}
// Initialize client using environment variables
const client = Client.fromEnvironment(process.env);See the Environment-Based Client Initialization section for details.
This API uses the following authentication schemes.
Customization: The
customAuthprovider is implemented insrc/authentication.tsusing a customcustomAuthenticationProvider. This replaces the generatedcustomHeaderAuthenticationProviderfrom@apimatic/authentication-adaptersand applies thehashheader to every outgoing request.
Customization: Flows are custom additions to the generated SDK that orchestrate multi-step operations across controllers.
| Flow | Description |
|---|---|
| Refund Flow | Fetches a payment, validates eligibility, submits a full or partial refund, and waits for terminal status in one call. |
The handler expects the signature to be delivered in the X-Fintech-Ed25519-Signature header as a 128-character hex-encoded string (64 bytes).
Initialize the handler with your Ed25519 public key:
import { FintechWebhooksHandler } from 'fintech-payment-banking-apilib';
const handler = new FintechWebhooksHandler('<64-hex-char-ed25519-public-key>');
// Verify and parse an incoming webhook request
const result = handler.verifyAndParseEvent(request);To use a custom signature header name, pass it as the second argument to CustomSignatureVerifier directly:
import { CustomSignatureVerifier } from 'fintech-payment-banking-apilib';
const verifier = new CustomSignatureVerifier('<public-key-hex>', 'X-My-Custom-Signature');Customization: Webhook signature verification has been replaced from the generated HMAC-SHA256 implementation with Ed25519 public-key cryptography, implemented in
src/customSignatureVerifier.ts.
- HttpClientOptions
- RetryConfiguration
- ProxySettings
- Configuration-Based Client Initialization
- Environment-Based Client Initialization
- PartialLoggingOptions
- PartialRequestLoggingOptions
- PartialResponseLoggingOptions
- LoggerInterface
The Sdk Save Changes workflow synchronizes customization changes from this SDK repository to the build repository. It is triggered automatically on pushes to the main branch, and runs only when the commit message starts with customize:. It uses the APIMatic CLI to save customizations into the build source tree and commits those updates to the main branch of the build repository.
The following secret has been configured in the repository settings to enable the workflow:
- Type: Personal Access Token (PAT)
- Permissions Needed:
repo- Read/write access to repository contents
- Purpose: Grants authenticated access to
apimatic/sample-build-with-sdk-source-treeto push customization updates to the build repository