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
environmentoption.
Configuration Options
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | required | Your public Nylon Pay API key (starts with npk_...) |
apiSecret | string | required | Your private Nylon Pay API secret (starts with nps_...) |
timeoutMs | number | 30000 | Per-request timeout in milliseconds |
maxRetries | number | 3 | Maximum retry attempts for failed requests |
maxPollDurationMs | number | 300000 | Maximum wait time for wait() in milliseconds (5 min) |
maxPollAttempts | number | 150 | Maximum poll attempts for wait() |
fetch | typeof fetch | none | Custom fetch implementation (for edge runtimes, Deno, etc.) |
force | boolean | false | Force a new SDK instance even if one already exists for this key + secret + base URL |
hooks | SdkHooks | none | Lifecycle hooks for logging, enrichment, and analytics. See Hooks. |
Python: The
fetchoption is replaced byhttp_client(accepts anhttpx.Clientinstance). 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
});