Skip to main content

Overview

The Navio Node.js SDK provides a modern, type-safe interface for integrating Navio payments into your Node.js and TypeScript applications. Built with TypeScript and async/await for the best developer experience.

TypeScript Native

Full TypeScript support with complete type definitions

Promise-based

Native Promise support with async/await

Simple API

Clean, intuitive interface

Error Handling

Custom exceptions for different error types

Requirements

  • Node.js 16.0.0 or higher
  • npm, yarn, or pnpm

Installation

Install via npm:
Or with yarn:
Or with pnpm:

Quick Start

1. Initialize SDK

Store your API key in environment variables, never in code

3. Check Payment Status

Complete E-commerce Example

Here’s a complete flow for an e-commerce checkout:

Framework Integration

Express.js

NestJS

Next.js (App Router)

API Reference

OCPay Class

Main SDK entry point.

Constructor

Parameters:
  • accessToken (string) - Your API access token
  • options (ClientOptions) - Optional client configuration:
    • timeout (number) - Request timeout in milliseconds (default: 30000)
    • baseURL (string) - Custom base URL (mainly for testing)
    • headers (object) - Additional headers
Example:

Methods

createLink(request: CreateLinkRequest): Promise<CreateLinkResponse> Creates a payment link. checkPayment(paymentRef: string): Promise<CheckPaymentResponse> Checks payment status.

Types & Interfaces

ProductInfo

CreateLinkRequest

FeeMode Enum:

CreateLinkResponse

CheckPaymentResponse

PaymentStatus Enum:

Exception Handling

All exceptions extend OCPayException: All exceptions provide:

Important Notes

Merchant Validation Required

Complete merchant validation at app.oneclickdz.com before using the API

Amount Limits

  • Minimum: 500 DZD
  • Maximum: 500,000 DZD
  • Must be whole numbers (integers)

Fee Structure

Low Fees: 0% on balance, only 1% withdrawal fee
Links expire 20 minutes after creation if payment not initiated.

Payment Status Flow

  1. PENDING - Payment in progress → Poll again later
  2. CONFIRMED - Payment successful → Fulfill order
  3. FAILED - Payment declined/expired → Mark order failed

TypeScript Support

This SDK is written in TypeScript and includes complete type definitions. No need to install @types packages!

JavaScript Usage

The SDK works perfectly with plain JavaScript too:

Testing

Using Sandbox

The API automatically uses sandbox mode for test accounts:

Best Practices

Store paymentRef immediately after creating the link. You need it to check payment status.
Set up a background job to check payment status every 20 minutes for pending orders.
Catch and handle all exception types appropriately. Log errors for debugging.
Store API keys in environment variables, never commit them to version control.
Always use HTTPS for redirect URLs and your application endpoints.

Support & Resources

GitHub Repository

Source code, examples, and issues

API Documentation

Detailed API reference

npm Package

View on npm registry

Contact Support

Get help from our team

Next Steps

Navio Best Practices

Learn production-ready tips and security best practices