The Xendit Node.js SDK, currently at version 7.0.0, provides an official, convenient, and type-safe interface for integrating Node.js applications with the Xendit REST API. It abstracts direct HTTP requests, offering a structured way to interact with Xendit's various payment and financial services, including invoicing, payment requests, refunds, and balance inquiries. The SDK ships with first-class TypeScript support, enhancing developer experience through strong typing and autocompletion. It requires Node.js 18.0 or later for execution. While specific release cadence for major versions isn't explicitly stated, minor and patch versions are released regularly to add new features, support new payment channels, and fix bugs. A key differentiator is its direct support from Xendit, ensuring up-to-date API coverage and adherence to best practices for secure and reliable payment processing in Southeast Asia.
npm install xendit-nodeVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to initialize the Xendit client using an environment variable for the API key, create a new invoice, retrieve it by ID, and fetch the account balance.
Ensure that `invoice_duration` is always passed as a `number` (representing seconds) when creating invoices. Update your payload objects accordingly.
If processing refund callbacks, update your code to reference `payment_id` instead of `payment_request_id`.
Ensure your code expects the `failure_code` in Payment Callbacks to be a string type.
Upgrade your Node.js environment to version 18.0.0 or higher to ensure compatibility and leverage modern JavaScript features.
Store your `secretKey` securely, ideally as an environment variable (e.g., `process.env.XENDit_SECRET_KEY`) and load it at runtime. Access tokens should not be hardcoded.
Ensure `secretKey` is a non-empty string when initializing `new Xendit({ secretKey: 'YOUR_SECRET_KEY' })`.Convert `invoice_duration` to a `number` type. For example, `invoice_duration: 86400` instead of `invoice_duration: '86400'`.
Run `npm install xendit-node@latest` (or `yarn add xendit-node@latest`). Ensure your `tsconfig.json` includes `node_modules` in `typeRoots` if custom configurations are used.
Use the correct ESM named import: `import { Xendit } from 'xendit-node';`No dependency data recorded yet.