Installation
Install the Fingo Pay TypeScript SDK using your preferred package manager:- npm
- pnpm
- yarn
- bun
Quick start
Initialize the SDK with your API key and make your first request:Request & response types
This library includes TypeScript definitions for all request params and response fields. Import and use them for full type safety:Handling errors
When the library is unable to connect to the API, or if the API returns a non-success status code (i.e., 4xx or 5xx response), a subclass ofAPIError will be thrown:
Error codes
Retries
Certain errors are automatically retried 2 times by default, with a short exponential backoff. The following errors are retried:- Connection errors (e.g., network connectivity problems)
- 408 Request Timeout
- 409 Conflict
- 429 Rate Limit
-
=500 Internal errors
maxRetries option:
Timeouts
Requests time out after 1 minute by default. Configure this with thetimeout option:
On timeout, an
APIConnectionTimeoutError is thrown. Requests that time out will be retried twice by default.Advanced usage
Accessing raw response data
The “raw”Response returned by fetch() can be accessed through the .asResponse() method on the APIPromise type. This method returns as soon as the headers for a successful response are received and does not consume the response body, allowing custom parsing or streaming logic.
Use .withResponse() to get the raw Response along with the parsed data:
Logging
All log messages are intended for debugging only. The format and content of log messages may change between releases.
Log levels
Configure the log level in two ways:- Via the
FINGO_PAY_LOGenvironment variable - Using the
logLevelclient option (overrides the environment variable)
Custom logger
Provide a custom logger instead of the defaultglobalThis.console. Most logging libraries are supported, including pino, winston, bunyan, consola, signale, and @std/log.
Making custom/undocumented requests
Undocumented endpoints
Make requests to undocumented endpoints usingclient.get, client.post, and other HTTP verbs:
Undocumented request params
Use// @ts-expect-error for undocumented parameters:
Customizing the fetch client
By default, this library expects a globalfetch function. You can polyfill it globally or pass a custom one:
Fetch options
Provide custom fetch options when instantiating the client or making a request:Configuring proxies
Provide customfetchOptions to add runtime-specific proxy options:
- Node.js
- Bun
- Deno
Requirements
TypeScript >= 4.9 is supported.
Semantic versioning
This package generally follows SemVer conventions, though certain backwards-incompatible changes may be released as minor versions:- Changes that only affect static types, without breaking runtime behavior
- Changes to library internals which are technically public but not intended or documented for external use
- Changes that we do not expect to impact the vast majority of users in practice
SDK Source Code
View the SDK source code and contribute on GitHub
npm Package
View the package on npm