Nylon PayNylon Pay

Configuration

Initialize the Nylon Pay SDK with your credentials

createNylonPay()

The factory function createNylonPay() returns a configured SDK instance.

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

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

Test vs. live mode is selected by your API key, not by config. A sandbox key runs in the test environment, a live key processes real money. There is no environment option.

Configuration Options

OptionTypeDefaultDescription
apiKeystringrequiredYour public Nylon Pay API key (starts with npk_...)
apiSecretstringrequiredYour private Nylon Pay API secret (starts with nps_...)
timeoutMsnumber30000Per-request timeout in milliseconds
maxRetriesnumber3Maximum retry attempts for failed requests
maxPollDurationMsnumber300000Maximum wait time for wait() in milliseconds (5 min)
maxPollAttemptsnumber150Maximum poll attempts for wait()
fetchtypeof fetchnoneCustom fetch implementation (for edge runtimes, Deno, etc.)
forcebooleanfalseForce a new SDK instance even if one already exists for this key + secret + base URL
hooksSdkHooksnoneLifecycle hooks for logging, enrichment, and analytics. See Hooks.

Python: The fetch option is replaced by http_client (accepts an httpx.Client instance). All other options use snake_case names (e.g., timeout_ms, max_retries, max_poll_duration_ms).

Environment Setup

Sandbox (Devlopment and Testing )

Use sandbox credentials for development and testing.

const nylonpay = createNylonPay({
  apiKey: 'npk_test_...',
  apiSecret: 'nps_test_...',
});

Production(Live payments)

Use live credentials for production transactions.

const nylonpay = createNylonPay({
  apiKey: 'npk_live_...',
  apiSecret: 'nps_live_...',
});

Note: Sandbox and live credentials are different. You cannot use sandbox keys in production or vice versa.

Adjusting Timeout and Polling

For long running payments or high traffic scenarios:

const nylonpay = createNylonPay({
  apiKey: 'npk_...',
  apiSecret: 'nps_...',
  maxPollDurationMs: 600000, // 10 minutes
  maxPollAttempts: 300,
  timeoutMs: 60000, // 1 minute per request
});

On this page