Nylon PayNylon Pay

SDK Overview

Server-side SDK for Nylon Pay

The Nylon Pay SDK is a server-side library that handles payment collection, status tracking, and security. Focus on your business logic and we handle the complexity.

Key Features

  • Type-safe: Full TypeScript support with complete type definitions
  • Event-driven: Real-time payment status updates via event listeners
  • Automatic retries: Built-in retry logic for failed network requests
  • Result pattern: Consistent error handling across all methods

Quick Example

import { createNylonPay } from '@nile-squad/nylonpay-ts';

const nylonpay = createNylonPay({
  apiKey: 'npk_...',
  apiSecret: 'nps_...',
});

// Initiate payment
const payment = await nylonpay.collectPayment({
  amount: 5000,
  currency: 'UGX',
  customer: { name: 'John Doe', phoneNumber: '+256700000000' },
  description: 'Order #1234',
  reference: crypto.randomUUID(),
});

// Listen for events
payment.on('success', ({ transaction }) => {
  console.log('Payment successful:', transaction.id);
});

payment.on('failed', ({ error }) => {
  console.log('Payment failed:', error);
});

payment.on('error', ({ error, category }) => {
  console.log('Payment error:', error, 'category:', category);
});

// Or wait for terminal state
const transaction = await payment.wait();

Available Documentation

On this page