API Reference
TypeScript SDK reference for Nile Pay integration.
Overview
Nile Pay is an SDK-first platform. All integrations use the TypeScript SDK rather than direct REST API calls. This provides:
- Automatic request signing
- Built-in retry logic
- Type safety
- Simplified error handling
SDK Packages
| Package | Description |
|---|---|
@nilepay/sdk | Core SDK for payments and invoices |
@nilepay/react | React hooks and components |
Quick Reference
Initialize
import { createNilePay } from '@nilepay/sdk';
const nilePay = createNilePay({
environment: 'sandbox', // or 'live'
apiKey: 'npk_sandbox_your_key',
apiSecret: 'nps_sandbox_your_secret',
});Create Collection
const collection = await nilePay.createCollection({
amount: 50000,
reference: 'ORDER-001',
customer: { phone: '+256700000000' },
});Create Invoice
const invoice = await nilePay.createInvoice({
amount: 50000,
reference: 'ORDER-001',
});Check Status
const status = await nilePay.getStatus({
reference: 'ORDER-001',
});Reference Sections
- Types, full TypeScript type definitions
- Authentication, security model and headers
Error Handling
All SDK methods return a result pattern. Always check the response:
const result = await nilePay.createCollection(data);
if (!result.status) {
console.error(result.message);
// Handle error
return;
}
// Access data on success
console.log(result.data.transactionId);Environment Configuration
| Environment | Value | Description |
|---|---|---|
| Sandbox | 'sandbox' | For development and testing |
| Live | 'live' | Production payments |