@nomba/node-sdk 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +550 -2
- package/dist/index.d.ts +86 -0
- package/dist/index.js +53 -0
- package/dist/interfaces/http/IHttpClient.d.ts +17 -0
- package/dist/interfaces/http/IHttpClient.js +5 -0
- package/dist/interfaces/http/index.d.ts +1 -0
- package/dist/interfaces/http/index.js +1 -0
- package/dist/interfaces/v1/accounts/IAccountsService.d.ts +24 -0
- package/dist/interfaces/v1/accounts/IAccountsService.js +5 -0
- package/dist/interfaces/v1/accounts/index.d.ts +1 -0
- package/dist/interfaces/v1/accounts/index.js +1 -0
- package/dist/interfaces/v1/betting/IBettingService.d.ts +11 -0
- package/dist/interfaces/v1/betting/IBettingService.js +5 -0
- package/dist/interfaces/v1/betting/index.d.ts +1 -0
- package/dist/interfaces/v1/betting/index.js +1 -0
- package/dist/interfaces/v1/cable/ICableService.d.ts +11 -0
- package/dist/interfaces/v1/cable/ICableService.js +5 -0
- package/dist/interfaces/v1/cable/index.d.ts +1 -0
- package/dist/interfaces/v1/cable/index.js +1 -0
- package/dist/interfaces/v1/charge/IChargeService.d.ts +33 -0
- package/dist/interfaces/v1/charge/IChargeService.js +5 -0
- package/dist/interfaces/v1/charge/index.d.ts +1 -0
- package/dist/interfaces/v1/charge/index.js +1 -0
- package/dist/interfaces/v1/checkout/ICheckoutService.d.ts +30 -0
- package/dist/interfaces/v1/checkout/ICheckoutService.js +5 -0
- package/dist/interfaces/v1/checkout/index.d.ts +1 -0
- package/dist/interfaces/v1/checkout/index.js +1 -0
- package/dist/interfaces/v1/data/IDataService.d.ts +9 -0
- package/dist/interfaces/v1/data/IDataService.js +5 -0
- package/dist/interfaces/v1/data/index.d.ts +1 -0
- package/dist/interfaces/v1/data/index.js +1 -0
- package/dist/interfaces/v1/direct-debits/IDirectDebitsService.d.ts +31 -0
- package/dist/interfaces/v1/direct-debits/IDirectDebitsService.js +5 -0
- package/dist/interfaces/v1/direct-debits/index.d.ts +1 -0
- package/dist/interfaces/v1/direct-debits/index.js +1 -0
- package/dist/interfaces/v1/electricity/IElectricityService.d.ts +11 -0
- package/dist/interfaces/v1/electricity/IElectricityService.js +5 -0
- package/dist/interfaces/v1/electricity/index.d.ts +1 -0
- package/dist/interfaces/v1/electricity/index.js +1 -0
- package/dist/interfaces/v1/globals/collections/IGlobalCollectionsService.d.ts +14 -0
- package/dist/interfaces/v1/globals/collections/IGlobalCollectionsService.js +5 -0
- package/dist/interfaces/v1/globals/collections/index.d.ts +1 -0
- package/dist/interfaces/v1/globals/collections/index.js +1 -0
- package/dist/interfaces/v1/globals/payouts/IGlobalPayoutService.d.ts +30 -0
- package/dist/interfaces/v1/globals/payouts/IGlobalPayoutService.js +5 -0
- package/dist/interfaces/v1/globals/payouts/index.d.ts +1 -0
- package/dist/interfaces/v1/globals/payouts/index.js +1 -0
- package/dist/interfaces/v1/requery/IRequeryService.d.ts +17 -0
- package/dist/interfaces/v1/requery/IRequeryService.js +5 -0
- package/dist/interfaces/v1/requery/index.d.ts +1 -0
- package/dist/interfaces/v1/requery/index.js +1 -0
- package/dist/interfaces/v1/terminals/ITerminalsService.d.ts +18 -0
- package/dist/interfaces/v1/terminals/ITerminalsService.js +5 -0
- package/dist/interfaces/v1/terminals/index.d.ts +1 -0
- package/dist/interfaces/v1/terminals/index.js +1 -0
- package/dist/interfaces/v1/transactions/ITransactionsService.d.ts +34 -0
- package/dist/interfaces/v1/transactions/ITransactionsService.js +5 -0
- package/dist/interfaces/v1/transactions/index.d.ts +1 -0
- package/dist/interfaces/v1/transactions/index.js +1 -0
- package/dist/interfaces/v1/virtual-accounts/IVirtualAccountsService.d.ts +27 -0
- package/dist/interfaces/v1/virtual-accounts/IVirtualAccountsService.js +5 -0
- package/dist/interfaces/v1/virtual-accounts/index.d.ts +1 -0
- package/dist/interfaces/v1/virtual-accounts/index.js +1 -0
- package/dist/interfaces/v1/webhooks/IWebhooksService.d.ts +21 -0
- package/dist/interfaces/v1/webhooks/IWebhooksService.js +5 -0
- package/dist/interfaces/v1/webhooks/index.d.ts +1 -0
- package/dist/interfaces/v1/webhooks/index.js +1 -0
- package/dist/interfaces/v2/airtime/IAirtimeV2Service.d.ts +12 -0
- package/dist/interfaces/v2/airtime/IAirtimeV2Service.js +5 -0
- package/dist/interfaces/v2/airtime/index.d.ts +1 -0
- package/dist/interfaces/v2/airtime/index.js +1 -0
- package/dist/interfaces/v2/betting/IBettingV2Service.d.ts +12 -0
- package/dist/interfaces/v2/betting/IBettingV2Service.js +5 -0
- package/dist/interfaces/v2/betting/index.d.ts +1 -0
- package/dist/interfaces/v2/betting/index.js +1 -0
- package/dist/interfaces/v2/cable/ICableV2Service.d.ts +12 -0
- package/dist/interfaces/v2/cable/ICableV2Service.js +5 -0
- package/dist/interfaces/v2/cable/index.d.ts +1 -0
- package/dist/interfaces/v2/cable/index.js +1 -0
- package/dist/interfaces/v2/data/IDataV2Service.d.ts +12 -0
- package/dist/interfaces/v2/data/IDataV2Service.js +5 -0
- package/dist/interfaces/v2/data/index.d.ts +1 -0
- package/dist/interfaces/v2/data/index.js +1 -0
- package/dist/interfaces/v2/electricity/IElectricityV2Service.d.ts +12 -0
- package/dist/interfaces/v2/electricity/IElectricityV2Service.js +5 -0
- package/dist/interfaces/v2/electricity/index.d.ts +1 -0
- package/dist/interfaces/v2/electricity/index.js +1 -0
- package/dist/interfaces/v2/transfers/ITransfersService.d.ts +20 -0
- package/dist/interfaces/v2/transfers/ITransfersService.js +5 -0
- package/dist/interfaces/v2/transfers/index.d.ts +1 -0
- package/dist/interfaces/v2/transfers/index.js +1 -0
- package/dist/lib/errors.d.ts +62 -0
- package/dist/lib/errors.js +92 -0
- package/dist/lib/outcome.d.ts +18 -0
- package/dist/lib/outcome.js +107 -0
- package/dist/lib/paginate.d.ts +21 -0
- package/dist/lib/paginate.js +25 -0
- package/dist/lib/sdk-version.d.ts +5 -0
- package/dist/lib/sdk-version.generated.d.ts +1 -0
- package/dist/lib/sdk-version.generated.js +1 -0
- package/dist/lib/sdk-version.js +5 -0
- package/dist/lib/token-store.d.ts +49 -0
- package/dist/lib/token-store.js +26 -0
- package/dist/lib/util.d.ts +31 -0
- package/dist/lib/util.js +31 -0
- package/dist/lib/webhooks.d.ts +43 -0
- package/dist/lib/webhooks.js +64 -0
- package/dist/nomba.d.ts +63 -0
- package/dist/nomba.js +97 -0
- package/dist/services/http/http-client.service.d.ts +27 -0
- package/dist/services/http/http-client.service.js +317 -0
- package/dist/services/v1/accounts/accounts.service.d.ts +38 -0
- package/dist/services/v1/accounts/accounts.service.js +58 -0
- package/dist/services/v1/betting/betting.service.d.ts +16 -0
- package/dist/services/v1/betting/betting.service.js +21 -0
- package/dist/services/v1/cable/cable.service.d.ts +16 -0
- package/dist/services/v1/cable/cable.service.js +23 -0
- package/dist/services/v1/charge/charge.service.d.ts +52 -0
- package/dist/services/v1/charge/charge.service.js +99 -0
- package/dist/services/v1/checkout/checkout.service.d.ts +44 -0
- package/dist/services/v1/checkout/checkout.service.js +100 -0
- package/dist/services/v1/data/data.service.d.ts +14 -0
- package/dist/services/v1/data/data.service.js +16 -0
- package/dist/services/v1/direct-debits/direct-debits.service.d.ts +45 -0
- package/dist/services/v1/direct-debits/direct-debits.service.js +69 -0
- package/dist/services/v1/electricity/electricity.service.d.ts +16 -0
- package/dist/services/v1/electricity/electricity.service.js +21 -0
- package/dist/services/v1/globals/collections.service.d.ts +28 -0
- package/dist/services/v1/globals/collections.service.js +38 -0
- package/dist/services/v1/globals/payout.service.d.ts +45 -0
- package/dist/services/v1/globals/payout.service.js +95 -0
- package/dist/services/v1/requery/requery.service.d.ts +31 -0
- package/dist/services/v1/requery/requery.service.js +41 -0
- package/dist/services/v1/terminals/terminals.service.d.ts +38 -0
- package/dist/services/v1/terminals/terminals.service.js +69 -0
- package/dist/services/v1/transactions/transactions.service.d.ts +48 -0
- package/dist/services/v1/transactions/transactions.service.js +98 -0
- package/dist/services/v1/virtual-accounts/virtual-accounts.service.d.ts +41 -0
- package/dist/services/v1/virtual-accounts/virtual-accounts.service.js +56 -0
- package/dist/services/v1/webhooks/webhooks.service.d.ts +36 -0
- package/dist/services/v1/webhooks/webhooks.service.js +60 -0
- package/dist/services/v2/airtime/airtime.service.d.ts +18 -0
- package/dist/services/v2/airtime/airtime.service.js +35 -0
- package/dist/services/v2/betting/betting.service.d.ts +19 -0
- package/dist/services/v2/betting/betting.service.js +36 -0
- package/dist/services/v2/cable/cable.service.d.ts +19 -0
- package/dist/services/v2/cable/cable.service.js +36 -0
- package/dist/services/v2/data/data.service.d.ts +18 -0
- package/dist/services/v2/data/data.service.js +35 -0
- package/dist/services/v2/electricity/electricity.service.d.ts +19 -0
- package/dist/services/v2/electricity/electricity.service.js +36 -0
- package/dist/services/v2/transfers/transfers.service.d.ts +30 -0
- package/dist/services/v2/transfers/transfers.service.js +67 -0
- package/dist/types/common/common.types.d.ts +78 -0
- package/dist/types/common/common.types.js +5 -0
- package/dist/types/common/outcome.types.d.ts +53 -0
- package/dist/types/common/outcome.types.js +5 -0
- package/dist/types/v1/accounts/accounts.types.d.ts +37 -0
- package/dist/types/v1/accounts/accounts.types.js +8 -0
- package/dist/types/v1/betting/betting.types.d.ts +26 -0
- package/dist/types/v1/betting/betting.types.js +5 -0
- package/dist/types/v1/cable/cable.types.d.ts +24 -0
- package/dist/types/v1/cable/cable.types.js +5 -0
- package/dist/types/v1/charge/charge.types.d.ts +102 -0
- package/dist/types/v1/charge/charge.types.js +5 -0
- package/dist/types/v1/checkout/checkout.types.d.ts +139 -0
- package/dist/types/v1/checkout/checkout.types.js +5 -0
- package/dist/types/v1/data/data.types.d.ts +14 -0
- package/dist/types/v1/data/data.types.js +5 -0
- package/dist/types/v1/direct-debits/direct-debits.types.d.ts +104 -0
- package/dist/types/v1/direct-debits/direct-debits.types.js +5 -0
- package/dist/types/v1/electricity/electricity.types.d.ts +21 -0
- package/dist/types/v1/electricity/electricity.types.js +5 -0
- package/dist/types/v1/globals/collections.types.d.ts +49 -0
- package/dist/types/v1/globals/collections.types.js +5 -0
- package/dist/types/v1/globals/payout.types.d.ts +183 -0
- package/dist/types/v1/globals/payout.types.js +5 -0
- package/dist/types/v1/requery/requery.types.d.ts +49 -0
- package/dist/types/v1/requery/requery.types.js +5 -0
- package/dist/types/v1/terminals/terminals.types.d.ts +44 -0
- package/dist/types/v1/terminals/terminals.types.js +5 -0
- package/dist/types/v1/transactions/transactions.types.d.ts +87 -0
- package/dist/types/v1/transactions/transactions.types.js +5 -0
- package/dist/types/v1/virtual-accounts/virtual-accounts.types.d.ts +64 -0
- package/dist/types/v1/virtual-accounts/virtual-accounts.types.js +5 -0
- package/dist/types/v1/webhooks/webhooks.types.d.ts +54 -0
- package/dist/types/v1/webhooks/webhooks.types.js +5 -0
- package/dist/types/v2/airtime/airtime.types.d.ts +31 -0
- package/dist/types/v2/airtime/airtime.types.js +5 -0
- package/dist/types/v2/betting/betting.types.d.ts +33 -0
- package/dist/types/v2/betting/betting.types.js +5 -0
- package/dist/types/v2/cable/cable.types.d.ts +32 -0
- package/dist/types/v2/cable/cable.types.js +5 -0
- package/dist/types/v2/data/data.types.d.ts +32 -0
- package/dist/types/v2/data/data.types.js +5 -0
- package/dist/types/v2/electricity/electricity.types.d.ts +34 -0
- package/dist/types/v2/electricity/electricity.types.js +5 -0
- package/dist/types/v2/transfers/transfers.types.d.ts +99 -0
- package/dist/types/v2/transfers/transfers.types.js +5 -0
- package/package.json +42 -5
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Nomba Financial Services
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,551 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Nomba Node SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
A TypeScript/Node.js client for [Nomba's](https://nomba.com) payments and banking APIs — checkout, transfers, virtual accounts, direct debits, terminals, electricity, cable TV, betting, airtime and data, cross-border payouts and collections, webhooks, and account/transaction lookups — built for production use: automatic token management, safe retries, idempotent mutations, and cursor pagination.
|
|
4
|
+
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
|
|
7
|
+
## Requirements
|
|
8
|
+
|
|
9
|
+
- Node.js **22** or newer (see `.nvmrc`)
|
|
10
|
+
- A Nomba account with API credentials (`clientId`, `clientSecret`, `accountId`) from the [Nomba dashboard](https://nomba.com)
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @nomba/node-sdk
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
## Quick start
|
|
19
|
+
|
|
20
|
+
```ts
|
|
21
|
+
import { Nomba } from "@nomba/node-sdk";
|
|
22
|
+
|
|
23
|
+
const nomba = new Nomba({
|
|
24
|
+
clientId: process.env.NOMBA_CLIENT_ID!,
|
|
25
|
+
clientSecret: process.env.NOMBA_CLIENT_SECRET!,
|
|
26
|
+
accountId: process.env.NOMBA_ACCOUNT_ID!,
|
|
27
|
+
environment: "sandbox", // "production" (default) or "sandbox"
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
const order = await nomba.checkout.createOrder({
|
|
31
|
+
order: {
|
|
32
|
+
orderReference: "order-1234",
|
|
33
|
+
customerEmail: "customer@example.com",
|
|
34
|
+
amount: 5000,
|
|
35
|
+
currency: "NGN",
|
|
36
|
+
callbackUrl: "https://example.com/callback",
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
|
|
40
|
+
console.log(order.checkoutLink); // send the customer here to pay
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The SDK issues an access token on first use and refreshes it automatically before it expires — no manual token handling required.
|
|
44
|
+
|
|
45
|
+
## Configuration
|
|
46
|
+
|
|
47
|
+
```ts
|
|
48
|
+
new Nomba({
|
|
49
|
+
clientId: string;
|
|
50
|
+
clientSecret: string;
|
|
51
|
+
accountId: string; // parent account ID of the business
|
|
52
|
+
environment?: "production" | "sandbox"; // default: "production"
|
|
53
|
+
tokenStore?: TokenStore; // default: in-memory, single process
|
|
54
|
+
onStoreError?: (error: unknown) => void;
|
|
55
|
+
timeoutMs?: number; // default: 30000
|
|
56
|
+
maxAttempts?: number; // default: 3 (GET/429 retries); 1 disables retries
|
|
57
|
+
retryDelayMs?: number; // default: 500, doubles each retry
|
|
58
|
+
fetch?: typeof fetch; // default: the global fetch (inject a proxy, tracing or a mock)
|
|
59
|
+
onRequest?: (info) => void; // before each HTTP attempt: { method, path, attempt }
|
|
60
|
+
onResponse?: (info) => void; // after each attempt: adds { httpStatus, code, durationMs }
|
|
61
|
+
onOutcome?: (event) => void; // once per money-moving call: { method, path, outcome, code, status, idempotencyKey }
|
|
62
|
+
});
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Hooks are for logging, metrics and alerting. An error thrown inside one is logged and never fails the request.
|
|
66
|
+
|
|
67
|
+
Credentials and `environment` must match — sandbox credentials only work against `environment: "sandbox"`.
|
|
68
|
+
|
|
69
|
+
### Sharing a token across multiple instances
|
|
70
|
+
|
|
71
|
+
Nomba allows a single active session per client. If you run more than one process/instance, provide a shared `TokenStore` (e.g. backed by Redis or a database) so they don't invalidate each other's tokens:
|
|
72
|
+
|
|
73
|
+
```ts
|
|
74
|
+
import type { TokenStore, TokenData } from "@nomba/node-sdk";
|
|
75
|
+
|
|
76
|
+
class RedisTokenStore implements TokenStore {
|
|
77
|
+
async get(): Promise<TokenData | undefined> { /* ... */ }
|
|
78
|
+
async set(token: TokenData): Promise<void> { /* ... */ }
|
|
79
|
+
async clear(): Promise<void> { /* ... */ }
|
|
80
|
+
async lock<T>(fn: () => Promise<T>): Promise<T> { /* ... */ } // must expire (TTL)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
const nomba = new Nomba({ ...credentials, tokenStore: new RedisTokenStore() });
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
Store errors never fail a request — the SDK falls back to its in-process copy of the token and reports the error via `onStoreError`.
|
|
87
|
+
|
|
88
|
+
## Resources
|
|
89
|
+
|
|
90
|
+
Every resource hangs off the client (`nomba.<resource>`), and every method maps to one documented Nomba endpoint. Methods return the response's `data` directly, typed. Mutating methods take an optional last argument, `RequestOptions` (`{ idempotencyKey }`).
|
|
91
|
+
|
|
92
|
+
| Resource | Covers |
|
|
93
|
+
|---|---|
|
|
94
|
+
| [`nomba.accounts`](#accounts) | Parent and sub-account details, balances, assigned terminals |
|
|
95
|
+
| [`nomba.virtualAccounts`](#virtual-accounts) | Create, update, expire, look up and list virtual accounts |
|
|
96
|
+
| [`nomba.checkout`](#checkout) | Hosted checkout orders, refunds, tokenized cards |
|
|
97
|
+
| [`nomba.charge`](#charge) | Custom card payment flow: card details, OTP, saved cards, pay by transfer |
|
|
98
|
+
| [`nomba.transfers`](#transfers) | Bank list, account lookup, bank and wallet transfers |
|
|
99
|
+
| [`nomba.directDebits`](#direct-debits) | Direct debit mandates: create, debit, list, suspend or reactivate |
|
|
100
|
+
| [`nomba.terminals`](#terminals) | Assign and unassign POS terminals, push payment requests |
|
|
101
|
+
| [`nomba.transactions`](#transactions) | List and filter transactions on parent, sub and virtual accounts |
|
|
102
|
+
| [`nomba.requery`](#requery) | Look up one transaction's current status |
|
|
103
|
+
| [`nomba.electricity`](#electricity-cable-tv-and-betting) | Electricity payments (version 2) |
|
|
104
|
+
| [`nomba.cable`](#electricity-cable-tv-and-betting) | Cable TV subscriptions (version 2) |
|
|
105
|
+
| [`nomba.betting`](#electricity-cable-tv-and-betting) | Betting top-ups (version 2) |
|
|
106
|
+
| [`nomba.airtime`](#airtime) | Airtime top-ups (version 2) |
|
|
107
|
+
| [`nomba.data`](#data) | Data bundles (version 2) |
|
|
108
|
+
| [`nomba.globalCollections`](#global-collections) | DRC mobile money collections |
|
|
109
|
+
| [`nomba.globalPayout`](#global-payout) | Currency wallets, exchange rates, cross-border transfers |
|
|
110
|
+
| [`nomba.webhooks`](#webhook-troubleshooting) | Webhook delivery logs, re-push and replay |
|
|
111
|
+
| [`verifyWebhook`](#webhooks) | Check a webhook's signature (a standalone function) |
|
|
112
|
+
|
|
113
|
+
## API reference
|
|
114
|
+
|
|
115
|
+
### Authentication
|
|
116
|
+
|
|
117
|
+
Token handling is automatic, but the client exposes it directly too:
|
|
118
|
+
|
|
119
|
+
| Method | Endpoint | Notes |
|
|
120
|
+
|---|---|---|
|
|
121
|
+
| `nomba.issueToken()` | `POST /v1/auth/token/issue` | Get a new token (normally done for you on first use) |
|
|
122
|
+
| `nomba.refreshToken()` | `POST /v1/auth/token/refresh` | Refresh the stored token (normally done 5 minutes before expiry) |
|
|
123
|
+
| `nomba.revokeToken()` | `POST /v1/auth/token/revoke` | End the session, e.g. on shutdown. Does nothing if no token is held |
|
|
124
|
+
|
|
125
|
+
### Accounts
|
|
126
|
+
|
|
127
|
+
| Method | Endpoint | Notes |
|
|
128
|
+
|---|---|---|
|
|
129
|
+
| `getParentAccount()` | `GET /v1/accounts/parent` | |
|
|
130
|
+
| `getParentBalance()` | `GET /v1/accounts/balance` | NGN only; use `globalPayout.listAccounts()` for other currencies |
|
|
131
|
+
| `getSubAccount(lookup?)` | `GET /v1/accounts/sub-account-details` | |
|
|
132
|
+
| `getSubAccountBalance(subAccountId)` | `GET /v1/accounts/{subAccountId}/balance` | |
|
|
133
|
+
| `listParentTerminals(params?)` / `iterateParentTerminals(params?)` | `GET /v1/accounts/terminals` | Paginated |
|
|
134
|
+
| `listSubAccountTerminals(accountId, params?)` / `iterateSubAccountTerminals(...)` | `GET /v1/accounts/{accountId}/terminals` | Paginated |
|
|
135
|
+
|
|
136
|
+
### Virtual accounts
|
|
137
|
+
|
|
138
|
+
| Method | Endpoint | Notes |
|
|
139
|
+
|---|---|---|
|
|
140
|
+
| `create(params)` | `POST /v1/accounts/virtual` | |
|
|
141
|
+
| `createForSubAccount(subAccountId, params)` | `POST /v1/accounts/virtual/{subAccountId}` | Funds land in that sub account |
|
|
142
|
+
| `get(identifier)` | `GET /v1/accounts/virtual/{identifier}` | `identifier` is the `accountRef` or the account number |
|
|
143
|
+
| `update(identifier, params)` | `PUT /v1/accounts/virtual/{identifier}` | |
|
|
144
|
+
| `expire(identifier)` | `DELETE /v1/accounts/virtual/{identifier}` | Stops the account accepting payments |
|
|
145
|
+
| `list(filter?, page?)` / `iterate(filter?, page?)` | `POST /v1/accounts/virtual/list` | Paginated |
|
|
146
|
+
|
|
147
|
+
### Checkout
|
|
148
|
+
|
|
149
|
+
| Method | Endpoint | Notes |
|
|
150
|
+
|---|---|---|
|
|
151
|
+
| `createOrder(params)` | `POST /v1/checkout/order` | Send the customer to `checkoutLink` |
|
|
152
|
+
| `fetchTransaction(params?)` | `GET /v1/checkout/transaction` | |
|
|
153
|
+
| `cancelOrder(orderReference)` | `POST /v1/checkout/order/cancel` | Unpaid orders only; use `refund` after payment |
|
|
154
|
+
| `refund(params)` | `POST /v1/checkout/refund` | |
|
|
155
|
+
| `chargeTokenizedCard(params)` | `POST /v1/checkout/tokenized-card-payment` | Check `status` on the result |
|
|
156
|
+
| `listTokenizedCards(params?)` / `iterateTokenizedCards(params?)` | `GET /v1/checkout/tokenized-card-data` | Paginated |
|
|
157
|
+
| `updateTokenizedCard(params)` | `POST /v1/checkout/tokenized-card-data` | |
|
|
158
|
+
| `deleteTokenizedCard(tokenKey)` | `DELETE /v1/checkout/tokenized-card-data` | |
|
|
159
|
+
|
|
160
|
+
### Charge
|
|
161
|
+
|
|
162
|
+
For building your own payment page on top of a checkout order.
|
|
163
|
+
|
|
164
|
+
| Method | Endpoint | Notes |
|
|
165
|
+
|---|---|---|
|
|
166
|
+
| `getOrder(orderReference)` | `GET /v1/checkout/order/{orderReference}` | |
|
|
167
|
+
| `submitCardDetails(params)` | `POST /v1/checkout/checkout-card-detail` | |
|
|
168
|
+
| `submitCardOtp(params)` | `POST /v1/checkout/checkout-card-otp` | |
|
|
169
|
+
| `resendOtp(orderReference)` | `POST /v1/checkout/resend-otp` | |
|
|
170
|
+
| `fetchTransactionDetails(orderReference)` | `POST /v1/checkout/confirm-transaction-receipt` | Status after the OTP or a transfer |
|
|
171
|
+
| `fetchFlashAccount(orderReference)` | `GET /v1/checkout/get-checkout-kta/{orderReference}` | An account number the customer can pay into |
|
|
172
|
+
| `cancelTransaction(params)` | `POST /v1/checkout/transaction/cancel` | |
|
|
173
|
+
| `requestSavedCardsOtp(orderReference)` / `getSavedCards(orderReference, otp)` | `POST /v1/checkout/user-card/saved-card/auth`, `GET /v1/checkout/user-card/{orderReference}` | Pay with a saved card |
|
|
174
|
+
| `requestSaveCardOtp(params)` / `submitSaveCardOtp(params)` | `POST /v1/checkout/user-card/auth`, `POST /v1/checkout/user-card` | Save a card after payment |
|
|
175
|
+
|
|
176
|
+
### Transfers
|
|
177
|
+
|
|
178
|
+
| Method | Endpoint | Notes |
|
|
179
|
+
|---|---|---|
|
|
180
|
+
| `listBanks()` | `GET /v1/transfers/banks` | |
|
|
181
|
+
| `lookupBankAccount({ accountNumber, bankCode })` | `POST /v1/transfers/bank/lookup` | |
|
|
182
|
+
| `bankTransfer(params)` | `POST /v2/transfers/bank` | Idempotency key defaults to `merchantTxRef` |
|
|
183
|
+
| `bankTransferFromSubAccount(subAccountId, params)` | `POST /v2/transfers/bank/{subAccountId}` | Nomba must enable this for your account |
|
|
184
|
+
| `walletTransfer(params)` | `POST /v2/transfers/wallet` | To another Nomba account |
|
|
185
|
+
| `walletTransferFromSubAccount(subAccountId, params)` | `POST /v2/transfers/wallet/{subAccountId}` | |
|
|
186
|
+
|
|
187
|
+
A `status` of `PENDING_BILLING` means the transfer is still processing: wait for the webhook or requery, and never send it again under a new reference.
|
|
188
|
+
|
|
189
|
+
### Direct debits
|
|
190
|
+
|
|
191
|
+
| Method | Endpoint | Notes |
|
|
192
|
+
|---|---|---|
|
|
193
|
+
| `createMandate(params)` | `POST /v1/direct-debits` | |
|
|
194
|
+
| `getMandateStatus(mandateId)` | `GET /v1/direct-debits/status` | |
|
|
195
|
+
| `debitMandate(params)` | `POST /v1/direct-debits/debit-mandate` | |
|
|
196
|
+
| `listMandates(params)` | `GET /v1/direct-debits/mandates` | |
|
|
197
|
+
| `updateMandateStatus(params)` | `PUT /v1/direct-debits/update-status` | Suspend or reactivate |
|
|
198
|
+
|
|
199
|
+
### Terminals
|
|
200
|
+
|
|
201
|
+
| Method | Endpoint | Notes |
|
|
202
|
+
|---|---|---|
|
|
203
|
+
| `assignToParent(params)` / `unassignFromParent(params)` | `POST /v1/terminals/assign`, `/unassign` | |
|
|
204
|
+
| `assignToSubAccount(subAccountId, params)` / `unassignFromSubAccount(...)` | `POST /v1/terminals/assign/{subAccountId}`, `/unassign/{subAccountId}` | |
|
|
205
|
+
| `pushPaymentRequest(terminalId, params)` | `POST /v1/terminals/payment-request/{terminalId}` | Prompts payment on the device |
|
|
206
|
+
|
|
207
|
+
### Transactions
|
|
208
|
+
|
|
209
|
+
| Method | Endpoint | Notes |
|
|
210
|
+
|---|---|---|
|
|
211
|
+
| `listBankTransactions(params?)` / `iterateBankTransactions(...)` | `GET /v1/transactions/bank` | Credits and debits on the parent account |
|
|
212
|
+
| `listParentTransactions(params?)` / `iterateParentTransactions(...)` | `GET /v1/transactions/accounts` | |
|
|
213
|
+
| `listSubAccountTransactions(subAccountId, params?)` / `iterateSubAccountTransactions(...)` | `GET /v1/transactions/accounts/{subAccountId}` | |
|
|
214
|
+
| `filterParentTransactions(filter?, page?)` / `iterateFilteredParentTransactions(...)` | `POST /v1/transactions/accounts` | |
|
|
215
|
+
| `filterSubAccountTransactions(subAccountId, filter?, page?)` / `iterateFilteredSubAccountTransactions(...)` | `POST /v1/transactions/accounts/{subAccountId}` | |
|
|
216
|
+
| `listVirtualAccountTransactions({ accountNumber, dateFrom?, dateTo? })` | `GET /v1/transactions/virtual` | First page only (see [Known limitations](#known-limitations)) |
|
|
217
|
+
|
|
218
|
+
### Requery
|
|
219
|
+
|
|
220
|
+
| Method | Endpoint | Notes |
|
|
221
|
+
|---|---|---|
|
|
222
|
+
| `fetchParentTransaction(lookup)` | `GET /v1/transactions/accounts/single` | |
|
|
223
|
+
| `fetchSubAccountTransaction(subAccountId, lookup)` | `GET /v1/transactions/accounts/{subAccountId}/single` | |
|
|
224
|
+
| `requeryBySession(sessionId)` | `GET /v1/transactions/requery/{sessionId}` | Bank transfers; wallet transfers have no session ID |
|
|
225
|
+
|
|
226
|
+
### Electricity, cable TV and betting
|
|
227
|
+
|
|
228
|
+
Each is its own product using **version 2** endpoints (payments only).
|
|
229
|
+
|
|
230
|
+
#### Electricity: `nomba.electricity` (`ElectricityV2Service`)
|
|
231
|
+
|
|
232
|
+
| Method | Endpoint | Notes |
|
|
233
|
+
|---|---|---|
|
|
234
|
+
| `payElectricity(params)` | `POST /v2/bill/electricity` | Prepaid meters get the token in `meta.phcnToken` |
|
|
235
|
+
| `payElectricityFromSubAccount(subAccountId, params)` | `POST /v2/bill/electricity/{subAccountId}` | |
|
|
236
|
+
|
|
237
|
+
#### Cable TV: `nomba.cable` (`CableV2Service`)
|
|
238
|
+
|
|
239
|
+
| Method | Endpoint | Notes |
|
|
240
|
+
|---|---|---|
|
|
241
|
+
| `subscribeCableTv(params)` | `POST /v2/bill/cabletv` | |
|
|
242
|
+
| `subscribeCableTvFromSubAccount(subAccountId, params)` | `POST /v2/bill/cabletv/{subAccountId}` | |
|
|
243
|
+
|
|
244
|
+
#### Betting: `nomba.betting` (`BettingV2Service`)
|
|
245
|
+
|
|
246
|
+
| Method | Endpoint | Notes |
|
|
247
|
+
|---|---|---|
|
|
248
|
+
| `payBetting(params)` | `POST /v2/bill/betting` | |
|
|
249
|
+
| `payBettingFromSubAccount(subAccountId, params)` | `POST /v2/bill/betting/{subAccountId}` | |
|
|
250
|
+
|
|
251
|
+
### Airtime
|
|
252
|
+
|
|
253
|
+
`nomba.airtime` uses **version 2** (`AirtimeV2Service`).
|
|
254
|
+
|
|
255
|
+
| Method | Endpoint | Notes |
|
|
256
|
+
|---|---|---|
|
|
257
|
+
| `buyAirtime(params)` | `POST /v2/bill/topup` | Returns `id`; use it to requery |
|
|
258
|
+
| `buyAirtimeFromSubAccount(subAccountId, params)` | `POST /v2/bill/topup/{subAccountId}` | |
|
|
259
|
+
|
|
260
|
+
### Data
|
|
261
|
+
|
|
262
|
+
`nomba.data` uses **version 2** (`DataV2Service`).
|
|
263
|
+
|
|
264
|
+
| Method | Endpoint | Notes |
|
|
265
|
+
|---|---|---|
|
|
266
|
+
| `buyData(params)` | `POST /v2/bill/data` | Select the bundle by `productId` |
|
|
267
|
+
| `buyDataFromSubAccount(subAccountId, params)` | `POST /v2/bill/data/{subAccountId}` | |
|
|
268
|
+
|
|
269
|
+
For both airtime and data, `network` is `GLO`, `MTN`, `9MOBILE` or `AIRTEL` (lowercase also accepted), and the idempotency key defaults to `merchantTxRef`.
|
|
270
|
+
|
|
271
|
+
#### Version 2 bill payments
|
|
272
|
+
|
|
273
|
+
`nomba.electricity`, `nomba.cable`, `nomba.betting`, `nomba.airtime` and `nomba.data` all use version 2 endpoints:
|
|
274
|
+
- **Success** is code `200` with `data.status: "SUCCESS"` (confirmed in sandbox for all five products); **pending** is code `201` or `data.status: "PENDING_BILLING"`.
|
|
275
|
+
- **The result** (`ElectricityPaymentV2Result`, `CablePaymentV2Result`, `BettingPaymentV2Result`, `AirtimePurchaseV2Result`, `DataPurchaseV2Result`) includes `id`, `source`, `customerBillerId`, `productId` and `userId`; `amount` is always a number.
|
|
276
|
+
|
|
277
|
+
### Global collections
|
|
278
|
+
|
|
279
|
+
| Method | Endpoint | Notes |
|
|
280
|
+
|---|---|---|
|
|
281
|
+
| `inflowProviders()` | `GET /v1/global-collection/drc/inflow/providers` | Use `code` as `topupVendor` |
|
|
282
|
+
| `initiateInflow(params)` | `POST /v1/global-collection/inflow/initiate` | Prompts the customer to approve on their phone |
|
|
283
|
+
| `getTransaction(transactionReference)` | `GET /v1/global-collection/transactions/{transactionId}` | `PENDING_APPROVAL` can still settle later |
|
|
284
|
+
|
|
285
|
+
### Global payout
|
|
286
|
+
|
|
287
|
+
| Method | Endpoint | Notes |
|
|
288
|
+
|---|---|---|
|
|
289
|
+
| `listAccounts()` / `getAccount(accountId)` | `GET /v1/global-payout/accounts[/{accountId}]` | Wallet balances; `UNAVAILABLE` means retry |
|
|
290
|
+
| `listSandboxAccounts()` / `getSandboxAccount(accountId)` | `GET /v1/sandbox/global-payout/accounts[/{accountId}]` | Canned test data |
|
|
291
|
+
| `exchangeRates({ from, to, region? })` | `GET /v1/global-payout/exchange-rates` | Pass `exchangeRateId` as `lockedExchangeRateId` |
|
|
292
|
+
| `convert(params)` | `POST /v1/global-payout/money/convert` | A quote only; no money moves |
|
|
293
|
+
| `institutionProviders({ isMobileMoney?, countryIsoCode? })` | `GET /v1/global-payout/bank/providers` | Banks or mobile money providers |
|
|
294
|
+
| `paymentMethods({ destinationCountryIsoCode?, ... })` | `GET /v1/global-payout/payment-methods` | The fields each corridor requires |
|
|
295
|
+
| `authorizeTransfer(params)` | `POST /v1/global-payout/transfer/authorize` | Cross-border transfer |
|
|
296
|
+
| `authorizeExchange(params)` | `POST /v1/global-payout/exchange/authorize` | Between your own wallets |
|
|
297
|
+
| `getTransaction(wtTransactionId)` | `GET /v1/global-payout/transactions/{transactionId}` | |
|
|
298
|
+
|
|
299
|
+
### Webhook troubleshooting
|
|
300
|
+
|
|
301
|
+
| Method | Endpoint | Notes |
|
|
302
|
+
|---|---|---|
|
|
303
|
+
| `eventLogs(filters?)` | `POST /v1/webhooks/event-logs` | What was sent and how your server answered |
|
|
304
|
+
| `events(filters?)` | `POST /v1/webhooks/events` | Your subscriptions |
|
|
305
|
+
| `repush(hookRequestId)` | `POST /v1/webhooks/re-push` | Resend one event |
|
|
306
|
+
| `bulkRepush(hookRequestIds)` | `POST /v1/webhooks/bulk-re-push` | |
|
|
307
|
+
| `replay({ startDate, endDate, filter? })` | `POST /v1/webhooks/replay` | Resend every matching event in a window |
|
|
308
|
+
|
|
309
|
+
## Examples
|
|
310
|
+
|
|
311
|
+
### Virtual accounts
|
|
312
|
+
|
|
313
|
+
```ts
|
|
314
|
+
const account = await nomba.virtualAccounts.create({
|
|
315
|
+
accountRef: "cust-4821",
|
|
316
|
+
accountName: "Jane Doe",
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
const page = await nomba.virtualAccounts.list({ accountName: "Jane Doe" }, { limit: 50 });
|
|
320
|
+
|
|
321
|
+
for await (const account of nomba.virtualAccounts.iterate({ resourceAcquired: true })) {
|
|
322
|
+
console.log(account.bankAccountNumber);
|
|
323
|
+
}
|
|
324
|
+
```
|
|
325
|
+
|
|
326
|
+
### Bank transfer
|
|
327
|
+
|
|
328
|
+
```ts
|
|
329
|
+
const banks = await nomba.transfers.listBanks();
|
|
330
|
+
|
|
331
|
+
const result = await nomba.transfers.bankTransfer({
|
|
332
|
+
amount: 1000,
|
|
333
|
+
accountNumber: "0123456789",
|
|
334
|
+
accountName: "Jane Doe",
|
|
335
|
+
bankCode: banks[0].code!,
|
|
336
|
+
merchantTxRef: "payout-9981", // your own reference; reuse it to check status, never to retry blindly
|
|
337
|
+
});
|
|
338
|
+
```
|
|
339
|
+
|
|
340
|
+
### Bill payment
|
|
341
|
+
|
|
342
|
+
```ts
|
|
343
|
+
const paid = await nomba.electricity.payElectricity({
|
|
344
|
+
disco: "ikeja",
|
|
345
|
+
customerId: "12345678901",
|
|
346
|
+
meterType: "PREPAID",
|
|
347
|
+
amount: 2000,
|
|
348
|
+
payerName: "Jane Doe",
|
|
349
|
+
merchantTxRef: "bill-5521", // also the idempotency key
|
|
350
|
+
});
|
|
351
|
+
console.log(paid.meta?.phcnToken); // prepaid meter token
|
|
352
|
+
```
|
|
353
|
+
|
|
354
|
+
### Cross-border payout
|
|
355
|
+
|
|
356
|
+
```ts
|
|
357
|
+
const [rate] = await nomba.globalPayout.exchangeRates({ from: "USD", to: "KES" });
|
|
358
|
+
|
|
359
|
+
const payout = await nomba.globalPayout.authorizeTransfer({
|
|
360
|
+
amount: 100,
|
|
361
|
+
sourceCurrency: "USD",
|
|
362
|
+
destinationCurrency: "KES",
|
|
363
|
+
receiverName: "Jane Doe",
|
|
364
|
+
accountNumber: "0712345678",
|
|
365
|
+
institutionName: "M-Pesa",
|
|
366
|
+
sourceCountryIsoCode: "NG",
|
|
367
|
+
destinationCountryIsoCode: "KE",
|
|
368
|
+
paymentMethod: "MobileMoney",
|
|
369
|
+
accountType: "INDIVIDUAL",
|
|
370
|
+
lockedExchangeRateId: rate.exchangeRateId,
|
|
371
|
+
});
|
|
372
|
+
|
|
373
|
+
const status = await nomba.globalPayout.getTransaction(payout.wtTransactionId);
|
|
374
|
+
```
|
|
375
|
+
|
|
376
|
+
Call `nomba.globalPayout.paymentMethods({ destinationCountryIsoCode })` first to see which fields a corridor requires.
|
|
377
|
+
|
|
378
|
+
## Webhooks
|
|
379
|
+
|
|
380
|
+
Verify every webhook before acting on it. Pass the raw request body, the `nomba-signature` and `nomba-timestamp` headers, and the signature key you set on the Nomba dashboard:
|
|
381
|
+
|
|
382
|
+
```ts
|
|
383
|
+
import express from "express";
|
|
384
|
+
import { verifyWebhook } from "@nomba/node-sdk";
|
|
385
|
+
|
|
386
|
+
app.post("/nomba/webhook", express.raw({ type: "application/json" }), (req, res) => {
|
|
387
|
+
const ok = verifyWebhook(
|
|
388
|
+
req.body, // raw body (Buffer or string) or the parsed event
|
|
389
|
+
req.header("nomba-signature"),
|
|
390
|
+
req.header("nomba-timestamp"),
|
|
391
|
+
process.env.NOMBA_WEBHOOK_SECRET!,
|
|
392
|
+
);
|
|
393
|
+
if (!ok) return res.sendStatus(401);
|
|
394
|
+
// handle the event, idempotently: re-pushed and replayed events can arrive more than once
|
|
395
|
+
res.sendStatus(200);
|
|
396
|
+
});
|
|
397
|
+
```
|
|
398
|
+
|
|
399
|
+
`verifyWebhook` returns `false` (never throws) for a missing header or unreadable body. It does not reject old timestamps yet; the maximum age is an open question with Nomba.
|
|
400
|
+
|
|
401
|
+
Missed a webhook? Use `nomba.webhooks.eventLogs()` to see what was delivered, then `repush(hookRequestId)`, `bulkRepush(ids)` or `replay({ startDate, endDate, filter })` to send events again.
|
|
402
|
+
|
|
403
|
+
## Pagination
|
|
404
|
+
|
|
405
|
+
List endpoints return `{ results, cursor }`; pass the returned `cursor` back to fetch the next page, or use the `iterate*` method on the same resource to walk every page automatically:
|
|
406
|
+
|
|
407
|
+
```ts
|
|
408
|
+
for await (const txn of nomba.transactions.iterateParentTransactions()) {
|
|
409
|
+
// one transaction at a time, across all pages
|
|
410
|
+
}
|
|
411
|
+
```
|
|
412
|
+
|
|
413
|
+
## Outcomes
|
|
414
|
+
|
|
415
|
+
Every call that moves money ends in exactly one of three outcomes, decided only from the codes and statuses Nomba documents for that endpoint (see [Response Codes](https://developer.nomba.com/docs/api-basics/response-codes)):
|
|
416
|
+
|
|
417
|
+
| Outcome | Means | What to do |
|
|
418
|
+
|---|---|---|
|
|
419
|
+
| `success` | A documented success code and a documented final status | Fulfil the order |
|
|
420
|
+
| `pending` | Still processing, the response was lost, **or a code or status the docs don't list** | Nothing yet: wait for the webhook or requery. Never refund and never resend under a new reference |
|
|
421
|
+
| `failed` | A definite rejection (a documented 4xx) | Tell the customer it failed |
|
|
422
|
+
|
|
423
|
+
Pass a closure for each outcome you care about. The call resolves to whatever that closure returns:
|
|
424
|
+
|
|
425
|
+
```ts
|
|
426
|
+
const result = await nomba.transfers.bankTransfer(params, {
|
|
427
|
+
onSuccess: (tx) => markPaid(tx),
|
|
428
|
+
onPending: ({ code, status, idempotencyKey }) => scheduleRequery(idempotencyKey),
|
|
429
|
+
onFailed: ({ error, code }) => markFailed(code),
|
|
430
|
+
});
|
|
431
|
+
```
|
|
432
|
+
|
|
433
|
+
Leave a closure out and that outcome gets the default behavior: success resolves the response `data`; a rejection throws `NombaError`; **pending throws `UnconfirmedOutcomeError`** (whether documented or not) so it can never be mistaken for success. A lost response also throws `UnconfirmedOutcomeError`. Errors thrown inside your closures reach you untouched.
|
|
434
|
+
|
|
435
|
+
**Important:** Without `onPending`, a transfer or bill payment that returns code `201` or status `PENDING_BILLING` will throw, even though these are documented pending states. This forces you to explicitly handle pending results (via closure or try/catch) rather than silently treating them as success.
|
|
436
|
+
|
|
437
|
+
Methods that take outcome closures:
|
|
438
|
+
|
|
439
|
+
| Resource | Methods | Success when |
|
|
440
|
+
|---|---|---|
|
|
441
|
+
| `transfers` | `bankTransfer`, `bankTransferFromSubAccount`, `walletTransfer`, `walletTransferFromSubAccount` | code `00`/`200`, status `SUCCESS` (`201` or `PENDING_BILLING` is pending) |
|
|
442
|
+
| `v1.electricity`, `v1.cable`, `v1.betting` | `payElectricity`, `subscribeCableTv`, `payBetting` and their `…FromSubAccount` versions | code `00`, status `SUCCESS` (`PROCESSING` is pending) |
|
|
443
|
+
| `electricity`, `cable`, `betting`, `airtime`, `data` (v2) | every payment and purchase method, and their `…FromSubAccount` versions | code `200`, status `SUCCESS` (`201` or `PENDING_BILLING` is pending) |
|
|
444
|
+
| `v1.airtime` | `buyAirtime` | code `00`, status `SUCCESS` (`201`/`202` or `PROCESSING` is pending) |
|
|
445
|
+
| `v1.airtime` | `buyAirtimeFromSubAccount` | code `00`, status `SUCCESS` (`PROCESSING` is pending; its page documents no `201`/`202`) |
|
|
446
|
+
| `v1.data` | `buyData`, `buyDataFromSubAccount` | code `00`, status `SUCCESS` (`PROCESSING` is pending) |
|
|
447
|
+
| `globalPayout` | `authorizeTransfer` | code `00`, status `COMPLETED` (`PROCESSING`, `PENDING` and `FAILED` are pending) |
|
|
448
|
+
| `globalPayout` | `authorizeExchange` | code `00` |
|
|
449
|
+
| `terminals` | `pushPaymentRequest` | code `00`, status `completed` (`pending` and `failed` are pending) |
|
|
450
|
+
| `checkout` | `refund` | code `00`, `success: true` (`success: false` is pending) |
|
|
451
|
+
|
|
452
|
+
`FAILED` (Global Payout), `failed` (terminal payment requests) and `success: false` (refunds) are documented, but the docs never say they are final, so the SDK treats them as pending until that is confirmed.
|
|
453
|
+
|
|
454
|
+
## Errors
|
|
455
|
+
|
|
456
|
+
```ts
|
|
457
|
+
import { isPending, NombaError } from "@nomba/node-sdk";
|
|
458
|
+
|
|
459
|
+
try {
|
|
460
|
+
await nomba.transfers.bankTransfer(params);
|
|
461
|
+
} catch (err) {
|
|
462
|
+
if (isPending(err)) {
|
|
463
|
+
// OutcomeUnknownError (no readable answer) or UnconfirmedOutcomeError (pending result without onPending closure).
|
|
464
|
+
// It may still complete. Do NOT retry it as a new request: wait for the webhook or requery first.
|
|
465
|
+
} else if (err instanceof NombaError) {
|
|
466
|
+
// A definite rejection: err.status, err.code, err.description
|
|
467
|
+
} else {
|
|
468
|
+
throw err;
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
```
|
|
472
|
+
|
|
473
|
+
- **`NombaError`** — a definite, non-2xx (or non-"00" body code) response. Safe to treat as "did not happen."
|
|
474
|
+
- **`TokenError`** — getting or renewing the access token failed, so the request was never sent and nothing happened on Nomba's side. `err.cause` holds the underlying error. It is never reported as a pending payment.
|
|
475
|
+
- **`UnconfirmedOutcomeError`** — a money-moving call got a pending result (documented or undocumented) without an `onPending` closure to handle it. Also thrown when the `code` or `data.status` isn't documented for that endpoint (`err.reason` says which). Treat it as pending: wait for the webhook or requery. It carries `code`, `status`, `data` and `idempotencyKey`.
|
|
476
|
+
- **`OutcomeUnknownError`** — thrown only for mutating calls (transfers, checkout orders, etc.) after a failure that doesn't reveal whether the operation was processed. **Never retry by sending the same request again** — check the transaction's real status first (via `requery`, or your webhook), and only resubmit with the same `idempotencyKey` once you know it wasn't processed.
|
|
477
|
+
|
|
478
|
+
## Idempotency
|
|
479
|
+
|
|
480
|
+
Nomba implements idempotency differently across its APIs:
|
|
481
|
+
|
|
482
|
+
### Transfers and Bill Payments (v2)
|
|
483
|
+
|
|
484
|
+
**Idempotency is via `merchantTxRef` in the request body.** Each transfer, electricity, cable, betting, airtime, or data purchase must use a unique `merchantTxRef`. Reusing the same reference will result in a "suspected duplicate" response instead of creating a new transaction.
|
|
485
|
+
|
|
486
|
+
```ts
|
|
487
|
+
// merchantTxRef is your idempotency key - reuse it to check status, never to retry blindly
|
|
488
|
+
await nomba.transfers.bankTransfer({
|
|
489
|
+
amount: 1000,
|
|
490
|
+
accountNumber: "0123456789",
|
|
491
|
+
accountName: "Jane Doe",
|
|
492
|
+
bankCode: "058",
|
|
493
|
+
merchantTxRef: "payout-9981", // unique per transaction
|
|
494
|
+
});
|
|
495
|
+
```
|
|
496
|
+
|
|
497
|
+
The SDK tracks `idempotencyKey` internally (defaults to `merchantTxRef` for these operations) for error reporting and `onOutcome` events, but **does not send it as a header** — Nomba's server-side idempotency relies solely on the `merchantTxRef` field in the request body.
|
|
498
|
+
|
|
499
|
+
> **Important:** The SDK does **not** auto-retry mutating calls on timeouts, network errors, 5xx, or 409 — only `GET` requests and 429 responses are retried automatically. A failed mutating call surfaces as `OutcomeUnknownError` so you can decide how to proceed safely: check the transaction status first (via webhook or requery), then retry with the **same** `merchantTxRef` if it wasn't processed, or use a new reference if you're changing the payment.
|
|
500
|
+
|
|
501
|
+
### Global Payout and Global Collections
|
|
502
|
+
|
|
503
|
+
**These take an `idempotencyKey` in the request body** (not `merchantTxRef`), and Nomba documents that it deduplicates correctly: resending the same key returns the original transaction (`idempotentReplay: true`) instead of creating a new one. The SDK always sends one, generating a UUID if you don't provide it.
|
|
504
|
+
|
|
505
|
+
```ts
|
|
506
|
+
await nomba.globalPayout.authorizeTransfer(params, {
|
|
507
|
+
idempotencyKey: "stable-key-123", // optional; SDK generates UUID if omitted
|
|
508
|
+
});
|
|
509
|
+
```
|
|
510
|
+
|
|
511
|
+
After an `OutcomeUnknownError`, retry with `err.idempotencyKey`. If you change anything about the payment, use a new key.
|
|
512
|
+
|
|
513
|
+
## TypeScript
|
|
514
|
+
|
|
515
|
+
Every parameter and response type is exported, so you can type your own code against them:
|
|
516
|
+
|
|
517
|
+
```ts
|
|
518
|
+
import type { BankTransferParams, ElectricityPaymentResult, PayoutResult, WebhookEvent } from "@nomba/node-sdk";
|
|
519
|
+
```
|
|
520
|
+
|
|
521
|
+
## Known limitations
|
|
522
|
+
|
|
523
|
+
Where the Nomba docs are unclear or contradict themselves, the SDK makes a documented choice, noted in the method's doc comment. These are unconfirmed against the live API:
|
|
524
|
+
|
|
525
|
+
- **Version 2 pending answers:** the reference says an in-flight electricity, cable, betting, airtime or data purchase answers `201` / `PENDING_BILLING`; the guides say `PROCESSING`. Only success has been seen in sandbox. `PROCESSING` is treated as unconfirmed: it goes to `onPending`, or throws `UnconfirmedOutcomeError` without one.
|
|
526
|
+
- **`v1.data.buyData`:** a `"202"` (processing) answer is unconfirmed, because it's only documented for airtime.
|
|
527
|
+
- **`transactions.listVirtualAccountTransactions`** and **`webhooks.eventLogs`/`events`:** return the first page only, because the docs don't name the paging parameter.
|
|
528
|
+
- **`verifyWebhook`:** doesn't reject old timestamps yet.
|
|
529
|
+
- **Direct debits:** the accepted `frequency` values and the `startDate`/`endDate` response format differ between the API reference and the guide. The types accept both.
|
|
530
|
+
|
|
531
|
+
## Environments
|
|
532
|
+
|
|
533
|
+
| Environment | Base URL |
|
|
534
|
+
|---|---|
|
|
535
|
+
| `production` (default) | `https://api.nomba.com` |
|
|
536
|
+
| `sandbox` | `https://sandbox.nomba.com` |
|
|
537
|
+
|
|
538
|
+
## Development
|
|
539
|
+
|
|
540
|
+
```bash
|
|
541
|
+
npm run lint # Biome
|
|
542
|
+
npm run typecheck # tsc --noEmit
|
|
543
|
+
npm test # Vitest
|
|
544
|
+
npm run build # emit dist/
|
|
545
|
+
```
|
|
546
|
+
|
|
547
|
+
See [CONTRIBUTING.md](CONTRIBUTING.md) for the full contribution guide (Nomba-docs-first, tests required, Conventional Commits).
|
|
548
|
+
|
|
549
|
+
## License
|
|
550
|
+
|
|
551
|
+
[MIT](LICENSE)
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @module nomba
|
|
3
|
+
* @description Nomba SDK for Node.js
|
|
4
|
+
* @author Nomba Financial Services
|
|
5
|
+
* @version 1.0.0
|
|
6
|
+
* @license MIT
|
|
7
|
+
* @copyright 2026 Nomba
|
|
8
|
+
* @homepage https://nomba.com
|
|
9
|
+
* @support https://nomba.com/support
|
|
10
|
+
* @repository https://github.com/kudi-inc/nomba-sdk-node
|
|
11
|
+
* @docs https://developer.nomba.com
|
|
12
|
+
*/
|
|
13
|
+
export type { IHttpClient } from "./interfaces/http/IHttpClient.js";
|
|
14
|
+
export type * from "./interfaces/v1/accounts/IAccountsService.js";
|
|
15
|
+
export type * from "./interfaces/v1/betting/index.js";
|
|
16
|
+
export type * from "./interfaces/v1/cable/index.js";
|
|
17
|
+
export type * from "./interfaces/v1/charge/IChargeService.js";
|
|
18
|
+
export type * from "./interfaces/v1/checkout/ICheckoutService.js";
|
|
19
|
+
export type * from "./interfaces/v1/data/index.js";
|
|
20
|
+
export type * from "./interfaces/v1/direct-debits/IDirectDebitsService.js";
|
|
21
|
+
export type * from "./interfaces/v1/electricity/index.js";
|
|
22
|
+
export type * from "./interfaces/v1/globals/collections/IGlobalCollectionsService.js";
|
|
23
|
+
export type * from "./interfaces/v1/globals/payouts/IGlobalPayoutService.js";
|
|
24
|
+
export type * from "./interfaces/v1/requery/IRequeryService.js";
|
|
25
|
+
export type * from "./interfaces/v1/terminals/ITerminalsService.js";
|
|
26
|
+
export type * from "./interfaces/v1/transactions/ITransactionsService.js";
|
|
27
|
+
export type * from "./interfaces/v1/virtual-accounts/IVirtualAccountsService.js";
|
|
28
|
+
export type * from "./interfaces/v1/webhooks/IWebhooksService.js";
|
|
29
|
+
export type * from "./interfaces/v2/airtime/index.js";
|
|
30
|
+
export type * from "./interfaces/v2/betting/index.js";
|
|
31
|
+
export type * from "./interfaces/v2/cable/index.js";
|
|
32
|
+
export type * from "./interfaces/v2/data/index.js";
|
|
33
|
+
export type * from "./interfaces/v2/electricity/index.js";
|
|
34
|
+
export type * from "./interfaces/v2/transfers/ITransfersService.js";
|
|
35
|
+
export { isPending, NombaError, OutcomeUnknownError, TokenError, UnconfirmedOutcomeError, } from "./lib/errors.js";
|
|
36
|
+
export type { TokenData, TokenStore } from "./lib/token-store.js";
|
|
37
|
+
export { MemoryTokenStore } from "./lib/token-store.js";
|
|
38
|
+
export type { PageParams } from "./lib/util.js";
|
|
39
|
+
export type { WebhookEvent } from "./lib/webhooks.js";
|
|
40
|
+
export { verifyWebhook } from "./lib/webhooks.js";
|
|
41
|
+
export { Nomba } from "./nomba.js";
|
|
42
|
+
export { HttpClient } from "./services/http/http-client.service.js";
|
|
43
|
+
export { AccountsService, AccountsService as Accounts, } from "./services/v1/accounts/accounts.service.js";
|
|
44
|
+
export { BettingService } from "./services/v1/betting/betting.service.js";
|
|
45
|
+
export { CableService } from "./services/v1/cable/cable.service.js";
|
|
46
|
+
export { ChargeService, ChargeService as Charge, } from "./services/v1/charge/charge.service.js";
|
|
47
|
+
export { CheckoutService, CheckoutService as Checkout, } from "./services/v1/checkout/checkout.service.js";
|
|
48
|
+
export { DataService } from "./services/v1/data/data.service.js";
|
|
49
|
+
export { DirectDebitsService, DirectDebitsService as DirectDebits, } from "./services/v1/direct-debits/direct-debits.service.js";
|
|
50
|
+
export { ElectricityService } from "./services/v1/electricity/electricity.service.js";
|
|
51
|
+
export { GlobalCollectionsService, GlobalCollectionsService as GlobalCollections, } from "./services/v1/globals/collections.service.js";
|
|
52
|
+
export { GlobalPayoutService, GlobalPayoutService as GlobalPayout, } from "./services/v1/globals/payout.service.js";
|
|
53
|
+
export { RequeryService, RequeryService as Requery, } from "./services/v1/requery/requery.service.js";
|
|
54
|
+
export { TerminalsService, TerminalsService as Terminals, } from "./services/v1/terminals/terminals.service.js";
|
|
55
|
+
export { TransactionsService, TransactionsService as Transactions, } from "./services/v1/transactions/transactions.service.js";
|
|
56
|
+
export { VirtualAccountsService, VirtualAccountsService as VirtualAccounts, } from "./services/v1/virtual-accounts/virtual-accounts.service.js";
|
|
57
|
+
export { WebhooksService, WebhooksService as Webhooks, } from "./services/v1/webhooks/webhooks.service.js";
|
|
58
|
+
export { AirtimeV2Service } from "./services/v2/airtime/airtime.service.js";
|
|
59
|
+
export { BettingV2Service } from "./services/v2/betting/betting.service.js";
|
|
60
|
+
export { CableV2Service } from "./services/v2/cable/cable.service.js";
|
|
61
|
+
export { DataV2Service } from "./services/v2/data/data.service.js";
|
|
62
|
+
export { ElectricityV2Service } from "./services/v2/electricity/electricity.service.js";
|
|
63
|
+
export { TransfersService, TransfersService as Transfers, } from "./services/v2/transfers/transfers.service.js";
|
|
64
|
+
export type * from "./types/common/common.types.js";
|
|
65
|
+
export type * from "./types/common/outcome.types.js";
|
|
66
|
+
export type * from "./types/v1/accounts/accounts.types.js";
|
|
67
|
+
export type * from "./types/v1/betting/betting.types.js";
|
|
68
|
+
export type * from "./types/v1/cable/cable.types.js";
|
|
69
|
+
export type * from "./types/v1/charge/charge.types.js";
|
|
70
|
+
export type * from "./types/v1/checkout/checkout.types.js";
|
|
71
|
+
export type * from "./types/v1/data/data.types.js";
|
|
72
|
+
export type * from "./types/v1/direct-debits/direct-debits.types.js";
|
|
73
|
+
export type * from "./types/v1/electricity/electricity.types.js";
|
|
74
|
+
export type * from "./types/v1/globals/collections.types.js";
|
|
75
|
+
export type * from "./types/v1/globals/payout.types.js";
|
|
76
|
+
export type * from "./types/v1/requery/requery.types.js";
|
|
77
|
+
export type * from "./types/v1/terminals/terminals.types.js";
|
|
78
|
+
export type * from "./types/v1/transactions/transactions.types.js";
|
|
79
|
+
export type * from "./types/v1/virtual-accounts/virtual-accounts.types.js";
|
|
80
|
+
export type * from "./types/v1/webhooks/webhooks.types.js";
|
|
81
|
+
export type * from "./types/v2/airtime/airtime.types.js";
|
|
82
|
+
export type * from "./types/v2/betting/betting.types.js";
|
|
83
|
+
export type * from "./types/v2/cable/cable.types.js";
|
|
84
|
+
export type * from "./types/v2/data/data.types.js";
|
|
85
|
+
export type * from "./types/v2/electricity/electricity.types.js";
|
|
86
|
+
export type * from "./types/v2/transfers/transfers.types.js";
|