@nomba/node-sdk 0.1.0 → 0.4.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.
Files changed (82) hide show
  1. package/README.md +77 -16
  2. package/dist/index.d.ts +1 -1
  3. package/dist/index.js +1 -1
  4. package/dist/interfaces/v1/accounts/IAccountsService.d.ts +46 -8
  5. package/dist/interfaces/v1/betting/IBettingService.d.ts +11 -2
  6. package/dist/interfaces/v1/cable/ICableService.d.ts +12 -2
  7. package/dist/interfaces/v1/charge/IChargeService.d.ts +80 -19
  8. package/dist/interfaces/v1/checkout/ICheckoutService.d.ts +64 -15
  9. package/dist/interfaces/v1/data/IDataService.d.ts +6 -1
  10. package/dist/interfaces/v1/direct-debits/IDirectDebitsService.d.ts +37 -14
  11. package/dist/interfaces/v1/electricity/IElectricityService.d.ts +11 -2
  12. package/dist/interfaces/v1/globals/collections/IGlobalCollectionsService.d.ts +22 -5
  13. package/dist/interfaces/v1/globals/payouts/IGlobalPayoutService.d.ts +76 -13
  14. package/dist/interfaces/v1/requery/IRequeryService.d.ts +19 -5
  15. package/dist/interfaces/v1/terminals/ITerminalsService.d.ts +43 -10
  16. package/dist/interfaces/v1/transactions/ITransactionsService.d.ts +71 -12
  17. package/dist/interfaces/v1/virtual-accounts/IVirtualAccountsService.d.ts +50 -12
  18. package/dist/interfaces/v1/webhooks/IWebhooksService.d.ts +29 -10
  19. package/dist/interfaces/v2/airtime/IAirtimeV2Service.d.ts +21 -2
  20. package/dist/interfaces/v2/betting/IBettingV2Service.d.ts +21 -2
  21. package/dist/interfaces/v2/cable/ICableV2Service.d.ts +21 -2
  22. package/dist/interfaces/v2/data/IDataV2Service.d.ts +21 -2
  23. package/dist/interfaces/v2/electricity/IElectricityV2Service.d.ts +22 -2
  24. package/dist/interfaces/v2/transfers/ITransfersService.d.ts +57 -6
  25. package/dist/lib/errors.d.ts +19 -0
  26. package/dist/lib/errors.js +23 -0
  27. package/dist/lib/outcome.d.ts +30 -5
  28. package/dist/lib/outcome.js +31 -6
  29. package/dist/lib/sdk-version.generated.d.ts +1 -1
  30. package/dist/lib/sdk-version.generated.js +1 -1
  31. package/dist/lib/util.d.ts +0 -1
  32. package/dist/lib/util.js +0 -6
  33. package/dist/nomba.d.ts +38 -5
  34. package/dist/nomba.js +38 -5
  35. package/dist/services/http/http-client.service.d.ts +40 -6
  36. package/dist/services/http/http-client.service.js +44 -9
  37. package/dist/services/v1/accounts/accounts.service.d.ts +46 -8
  38. package/dist/services/v1/accounts/accounts.service.js +46 -8
  39. package/dist/services/v1/betting/betting.service.d.ts +12 -2
  40. package/dist/services/v1/betting/betting.service.js +12 -2
  41. package/dist/services/v1/cable/cable.service.d.ts +13 -2
  42. package/dist/services/v1/cable/cable.service.js +13 -2
  43. package/dist/services/v1/charge/charge.service.d.ts +80 -19
  44. package/dist/services/v1/charge/charge.service.js +88 -26
  45. package/dist/services/v1/checkout/checkout.service.d.ts +63 -15
  46. package/dist/services/v1/checkout/checkout.service.js +70 -24
  47. package/dist/services/v1/data/data.service.d.ts +7 -1
  48. package/dist/services/v1/data/data.service.js +7 -1
  49. package/dist/services/v1/direct-debits/direct-debits.service.d.ts +38 -14
  50. package/dist/services/v1/direct-debits/direct-debits.service.js +39 -17
  51. package/dist/services/v1/electricity/electricity.service.d.ts +12 -2
  52. package/dist/services/v1/electricity/electricity.service.js +12 -2
  53. package/dist/services/v1/globals/collections.service.d.ts +23 -5
  54. package/dist/services/v1/globals/collections.service.js +29 -7
  55. package/dist/services/v1/globals/payout.service.d.ts +77 -13
  56. package/dist/services/v1/globals/payout.service.js +83 -17
  57. package/dist/services/v1/requery/requery.service.d.ts +23 -5
  58. package/dist/services/v1/requery/requery.service.js +23 -5
  59. package/dist/services/v1/terminals/terminals.service.d.ts +42 -14
  60. package/dist/services/v1/terminals/terminals.service.js +44 -27
  61. package/dist/services/v1/transactions/transactions.service.d.ts +70 -12
  62. package/dist/services/v1/transactions/transactions.service.js +70 -12
  63. package/dist/services/v1/virtual-accounts/virtual-accounts.service.d.ts +52 -12
  64. package/dist/services/v1/virtual-accounts/virtual-accounts.service.js +55 -15
  65. package/dist/services/v1/webhooks/webhooks.service.d.ts +31 -10
  66. package/dist/services/v1/webhooks/webhooks.service.js +35 -14
  67. package/dist/services/v2/airtime/airtime.service.d.ts +26 -2
  68. package/dist/services/v2/airtime/airtime.service.js +27 -7
  69. package/dist/services/v2/betting/betting.service.d.ts +27 -3
  70. package/dist/services/v2/betting/betting.service.js +28 -8
  71. package/dist/services/v2/cable/cable.service.d.ts +27 -3
  72. package/dist/services/v2/cable/cable.service.js +28 -8
  73. package/dist/services/v2/data/data.service.d.ts +26 -2
  74. package/dist/services/v2/data/data.service.js +27 -7
  75. package/dist/services/v2/electricity/electricity.service.d.ts +28 -3
  76. package/dist/services/v2/electricity/electricity.service.js +29 -8
  77. package/dist/services/v2/transfers/transfers.service.d.ts +51 -6
  78. package/dist/services/v2/transfers/transfers.service.js +55 -25
  79. package/dist/types/common/common.types.d.ts +10 -13
  80. package/dist/types/v1/globals/collections.types.d.ts +3 -3
  81. package/dist/types/v1/globals/payout.types.d.ts +3 -3
  82. package/package.json +1 -1
package/README.md CHANGED
@@ -87,7 +87,7 @@ Store errors never fail a request — the SDK falls back to its in-process copy
87
87
 
88
88
  ## Resources
89
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 }`).
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. Each money-moving call takes its idempotency key from its params (`merchantTxRef`, `transactionId` or `idempotencyKey`), not from an options argument.
91
91
 
92
92
  | Resource | Covers |
93
93
  |---|---|
@@ -179,7 +179,7 @@ For building your own payment page on top of a checkout order.
179
179
  |---|---|---|
180
180
  | `listBanks()` | `GET /v1/transfers/banks` | |
181
181
  | `lookupBankAccount({ accountNumber, bankCode })` | `POST /v1/transfers/bank/lookup` | |
182
- | `bankTransfer(params)` | `POST /v2/transfers/bank` | Idempotency key defaults to `merchantTxRef` |
182
+ | `bankTransfer(params)` | `POST /v2/transfers/bank` | Idempotency key is `merchantTxRef` (required) |
183
183
  | `bankTransferFromSubAccount(subAccountId, params)` | `POST /v2/transfers/bank/{subAccountId}` | Nomba must enable this for your account |
184
184
  | `walletTransfer(params)` | `POST /v2/transfers/wallet` | To another Nomba account |
185
185
  | `walletTransferFromSubAccount(subAccountId, params)` | `POST /v2/transfers/wallet/{subAccountId}` | |
@@ -223,6 +223,37 @@ A `status` of `PENDING_BILLING` means the transfer is still processing: wait for
223
223
  | `fetchSubAccountTransaction(subAccountId, lookup)` | `GET /v1/transactions/accounts/{subAccountId}/single` | |
224
224
  | `requeryBySession(sessionId)` | `GET /v1/transactions/requery/{sessionId}` | Bank transfers; wallet transfers have no session ID |
225
225
 
226
+ ### Bill lookups (version 1)
227
+
228
+ Provider lists, meter/customer lookups and data plans — no money moves here. Pay with the version 2 services below.
229
+
230
+ #### Electricity: `nomba.billElectricity` (`ElectricityService`)
231
+
232
+ | Method | Endpoint | Notes |
233
+ |---|---|---|
234
+ | `getElectricityProviders()` | `GET /v1/bill/electricity/discos` | |
235
+ | `lookupMeter(params)` | `GET /v1/bill/electricity/lookup` | |
236
+
237
+ #### Cable TV: `nomba.billCable` (`CableService`)
238
+
239
+ | Method | Endpoint | Notes |
240
+ |---|---|---|
241
+ | `getCablePlans(params)` | `GET /v1/bill/cableTvProduct` | |
242
+ | `lookupCustomer(params)` | `GET /v1/bill/cable/lookup` | |
243
+
244
+ #### Betting: `nomba.billBetting` (`BettingService`)
245
+
246
+ | Method | Endpoint | Notes |
247
+ |---|---|---|
248
+ | `getBettingProviders()` | `GET /v1/bill/betting/providers` | |
249
+ | `lookupCustomer(params)` | `GET /v1/bill/betting/lookup` | |
250
+
251
+ #### Data: `nomba.billData` (`DataService`)
252
+
253
+ | Method | Endpoint | Notes |
254
+ |---|---|---|
255
+ | `getDataPlans(telco)` | `GET /v1/bill/data-plan/{telco}` | |
256
+
226
257
  ### Electricity, cable TV and betting
227
258
 
228
259
  Each is its own product using **version 2** endpoints (payments only).
@@ -266,7 +297,7 @@ Each is its own product using **version 2** endpoints (payments only).
266
297
  | `buyData(params)` | `POST /v2/bill/data` | Select the bundle by `productId` |
267
298
  | `buyDataFromSubAccount(subAccountId, params)` | `POST /v2/bill/data/{subAccountId}` | |
268
299
 
269
- For both airtime and data, `network` is `GLO`, `MTN`, `9MOBILE` or `AIRTEL` (lowercase also accepted), and the idempotency key defaults to `merchantTxRef`.
300
+ For both airtime and data, `network` is `GLO`, `MTN`, `9MOBILE` or `AIRTEL` (lowercase also accepted), and the idempotency key is `merchantTxRef` (required).
270
301
 
271
302
  #### Version 2 bill payments
272
303
 
@@ -279,7 +310,7 @@ For both airtime and data, `network` is `GLO`, `MTN`, `9MOBILE` or `AIRTEL` (low
279
310
  | Method | Endpoint | Notes |
280
311
  |---|---|---|
281
312
  | `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 |
313
+ | `initiateInflow(params)` | `POST /v1/global-collection/inflow/initiate` | `idempotencyKey` required in body; prompts the customer to approve on their phone |
283
314
  | `getTransaction(transactionReference)` | `GET /v1/global-collection/transactions/{transactionId}` | `PENDING_APPROVAL` can still settle later |
284
315
 
285
316
  ### Global payout
@@ -292,8 +323,8 @@ For both airtime and data, `network` is `GLO`, `MTN`, `9MOBILE` or `AIRTEL` (low
292
323
  | `convert(params)` | `POST /v1/global-payout/money/convert` | A quote only; no money moves |
293
324
  | `institutionProviders({ isMobileMoney?, countryIsoCode? })` | `GET /v1/global-payout/bank/providers` | Banks or mobile money providers |
294
325
  | `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 |
326
+ | `authorizeTransfer(params)` | `POST /v1/global-payout/transfer/authorize` | `idempotencyKey` required in body; cross-border transfer |
327
+ | `authorizeExchange(params)` | `POST /v1/global-payout/exchange/authorize` | `idempotencyKey` required in body; between your own wallets |
297
328
  | `getTransaction(wtTransactionId)` | `GET /v1/global-payout/transactions/{transactionId}` | |
298
329
 
299
330
  ### Webhook troubleshooting
@@ -368,6 +399,7 @@ const payout = await nomba.globalPayout.authorizeTransfer({
368
399
  paymentMethod: "MobileMoney",
369
400
  accountType: "INDIVIDUAL",
370
401
  lockedExchangeRateId: rate.exchangeRateId,
402
+ idempotencyKey: "payout-ke-9981", // required; use a stable key for safe retries
371
403
  });
372
404
 
373
405
  const status = await nomba.globalPayout.getTransaction(payout.wtTransactionId);
@@ -375,6 +407,24 @@ const status = await nomba.globalPayout.getTransaction(payout.wtTransactionId);
375
407
 
376
408
  Call `nomba.globalPayout.paymentMethods({ destinationCountryIsoCode })` first to see which fields a corridor requires.
377
409
 
410
+ ### DRC mobile money collection
411
+
412
+ ```ts
413
+ const providers = await nomba.globalCollections.inflowProviders();
414
+
415
+ const inflow = await nomba.globalCollections.initiateInflow({
416
+ phoneNumber: "0980802000",
417
+ callbackUrl: "https://example.com/hook",
418
+ amount: 100,
419
+ currency: "CDF",
420
+ topupVendor: providers[0].code, // e.g. "AIRTEL"
421
+ idempotencyKey: "inflow-drc-1234", // required; use a stable key for safe retries
422
+ });
423
+
424
+ // Poll for status or wait for webhook
425
+ const status = await nomba.globalCollections.getTransaction(inflow.transactionReference);
426
+ ```
427
+
378
428
  ## Webhooks
379
429
 
380
430
  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:
@@ -439,11 +489,7 @@ Methods that take outcome closures:
439
489
  | Resource | Methods | Success when |
440
490
  |---|---|---|
441
491
  | `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
492
  | `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
493
  | `globalPayout` | `authorizeTransfer` | code `00`, status `COMPLETED` (`PROCESSING`, `PENDING` and `FAILED` are pending) |
448
494
  | `globalPayout` | `authorizeExchange` | code `00` |
449
495
  | `terminals` | `pushPaymentRequest` | code `00`, status `completed` (`pending` and `failed` are pending) |
@@ -454,12 +500,15 @@ Methods that take outcome closures:
454
500
  ## Errors
455
501
 
456
502
  ```ts
457
- import { isPending, NombaError } from "@nomba/node-sdk";
503
+ import { IdempotencyKeyAbsentError, isPending, NombaError } from "@nomba/node-sdk";
458
504
 
459
505
  try {
460
506
  await nomba.transfers.bankTransfer(params);
461
507
  } catch (err) {
462
- if (isPending(err)) {
508
+ if (err instanceof IdempotencyKeyAbsentError) {
509
+ // Missing required idempotency key: err.field tells you which field (e.g. "merchantTxRef")
510
+ console.error(`Set ${err.field} in the request body for ${err.path}`);
511
+ } else if (isPending(err)) {
463
512
  // OutcomeUnknownError (no readable answer) or UnconfirmedOutcomeError (pending result without onPending closure).
464
513
  // It may still complete. Do NOT retry it as a new request: wait for the webhook or requery first.
465
514
  } else if (err instanceof NombaError) {
@@ -472,6 +521,7 @@ try {
472
521
 
473
522
  - **`NombaError`** — a definite, non-2xx (or non-"00" body code) response. Safe to treat as "did not happen."
474
523
  - **`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.
524
+ - **`IdempotencyKeyAbsentError`** — a money-moving operation was attempted without a valid idempotency key. The SDK refuses to generate random keys for these operations to prevent double disbursement. Provides `err.field` (the required field name, e.g. `"merchantTxRef"` or `"idempotencyKey"`) and `err.path` (the endpoint).
475
525
  - **`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
526
  - **`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
527
 
@@ -494,22 +544,33 @@ await nomba.transfers.bankTransfer({
494
544
  });
495
545
  ```
496
546
 
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.
547
+ The SDK tracks `idempotencyKey` internally (it is `merchantTxRef` for these operations, and an empty one throws `IdempotencyKeyAbsentError`) 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
548
 
499
549
  > **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
550
 
501
551
  ### Global Payout and Global Collections
502
552
 
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.
553
+ **These require 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. **You must always provide this key — the SDK never generates one for you** to prevent accidental double disbursement.
504
554
 
505
555
  ```ts
506
- await nomba.globalPayout.authorizeTransfer(params, {
507
- idempotencyKey: "stable-key-123", // optional; SDK generates UUID if omitted
556
+ await nomba.globalPayout.authorizeTransfer({
557
+ // ... other params
558
+ idempotencyKey: "stable-key-123", // required
508
559
  });
509
560
  ```
510
561
 
511
562
  After an `OutcomeUnknownError`, retry with `err.idempotencyKey`. If you change anything about the payment, use a new key.
512
563
 
564
+ ### Checkout, Charge, and Direct Debits
565
+
566
+ These operations track an idempotency key **internally only** — for error reporting (`OutcomeUnknownError.idempotencyKey`) and the `onOutcome` hook. The key is **not sent to Nomba** and does not affect server-side behavior.
567
+
568
+ - **Checkout**: Uses `orderReference` when provided; falls back to a generated UUID if omitted
569
+ - **Charge**: Uses `orderReference`, `transactionId`, or `tokenKey` depending on the method
570
+ - **Direct Debits**: Uses `merchantReference` for `createMandate`
571
+
572
+ Because these keys are only used locally for tracking, generating a UUID when none is provided is harmless — it does not risk double disbursement. `IdempotencyKeyAbsentError` is thrown only when the key is required: an empty `idempotencyKey` for Global Payout and Global Collections (sent to Nomba, which dedupes on it), and an empty `merchantTxRef` or `transactionId` for transfers, bill payments, terminal payment requests and checkout refunds.
573
+
513
574
  ## TypeScript
514
575
 
515
576
  Every parameter and response type is exported, so you can type your own code against them:
package/dist/index.d.ts CHANGED
@@ -32,7 +32,7 @@ export type * from "./interfaces/v2/cable/index.js";
32
32
  export type * from "./interfaces/v2/data/index.js";
33
33
  export type * from "./interfaces/v2/electricity/index.js";
34
34
  export type * from "./interfaces/v2/transfers/ITransfersService.js";
35
- export { isPending, NombaError, OutcomeUnknownError, TokenError, UnconfirmedOutcomeError, } from "./lib/errors.js";
35
+ export { IdempotencyKeyAbsentError, isPending, NombaError, OutcomeUnknownError, TokenError, UnconfirmedOutcomeError, } from "./lib/errors.js";
36
36
  export type { TokenData, TokenStore } from "./lib/token-store.js";
37
37
  export { MemoryTokenStore } from "./lib/token-store.js";
38
38
  export type { PageParams } from "./lib/util.js";
package/dist/index.js CHANGED
@@ -10,7 +10,7 @@
10
10
  * @repository https://github.com/kudi-inc/nomba-sdk-node
11
11
  * @docs https://developer.nomba.com
12
12
  */
13
- export { isPending, NombaError, OutcomeUnknownError, TokenError, UnconfirmedOutcomeError, } from "./lib/errors.js";
13
+ export { IdempotencyKeyAbsentError, isPending, NombaError, OutcomeUnknownError, TokenError, UnconfirmedOutcomeError, } from "./lib/errors.js";
14
14
  export { MemoryTokenStore } from "./lib/token-store.js";
15
15
  export { verifyWebhook } from "./lib/webhooks.js";
16
16
  export { Nomba } from "./nomba.js";
@@ -5,20 +5,58 @@
5
5
  import type { AccountBalance, AccountDetails, SubAccountLookup } from "../../../types/v1/accounts/accounts.types.js";
6
6
  import type { Terminal, TerminalList, TerminalListParams } from "../../../types/v1/terminals/terminals.types.js";
7
7
  export interface IAccountsService {
8
- /** GET /v1/accounts/parent */
8
+ /**
9
+ * `GET /v1/accounts/parent`.
10
+ * @returns The parent account's details.
11
+ * @throws {NombaError} The call failed.
12
+ */
9
13
  getParentAccount(): Promise<AccountDetails>;
10
- /** GET /v1/accounts/balance */
14
+ /**
15
+ * `GET /v1/accounts/balance`.
16
+ * @returns The parent account's balance.
17
+ * @throws {NombaError} The call failed.
18
+ */
11
19
  getParentBalance(): Promise<AccountBalance>;
12
- /** GET /v1/accounts/sub-account-details */
20
+ /**
21
+ * `GET /v1/accounts/sub-account-details`.
22
+ * @param lookup Which sub account to fetch, by account ID or account number.
23
+ * @returns The sub account's details.
24
+ * @throws {NombaError} The call failed, e.g. no sub account matches `lookup`.
25
+ */
13
26
  getSubAccount(lookup?: SubAccountLookup): Promise<AccountDetails>;
14
- /** GET /v1/accounts/{subAccountId}/balance */
27
+ /**
28
+ * `GET /v1/accounts/{subAccountId}/balance`.
29
+ * @param subAccountId The sub account's ID.
30
+ * @returns The sub account's balance.
31
+ * @throws {NombaError} The call failed, e.g. `subAccountId` does not exist.
32
+ */
15
33
  getSubAccountBalance(subAccountId: string): Promise<AccountBalance>;
16
- /** GET /v1/accounts/terminals */
34
+ /**
35
+ * `GET /v1/accounts/terminals`.
36
+ * @param params Pagination (`cursor`, `size`) and other list filters.
37
+ * @returns One page of the parent account's terminals.
38
+ * @throws {NombaError} The call failed.
39
+ */
17
40
  listParentTerminals(params?: TerminalListParams): Promise<TerminalList>;
18
- /** GET /v1/accounts/{accountId}/terminals */
41
+ /**
42
+ * `GET /v1/accounts/{accountId}/terminals`.
43
+ * @param accountId The sub account's ID.
44
+ * @param params Pagination (`cursor`, `size`) and other list filters.
45
+ * @returns One page of the sub account's terminals.
46
+ * @throws {NombaError} The call failed, e.g. `accountId` does not exist.
47
+ */
19
48
  listSubAccountTerminals(accountId: string, params?: TerminalListParams): Promise<TerminalList>;
20
- /** Every terminal of the parent account, across all pages. */
49
+ /**
50
+ * Every terminal of the parent account, across all pages. Starts at `params.cursor` if given.
51
+ * @param params Starting cursor and other list filters.
52
+ * @throws {NombaError} A page request failed.
53
+ */
21
54
  iterateParentTerminals(params?: TerminalListParams): AsyncGenerator<Terminal>;
22
- /** Every terminal of a sub account, across all pages. */
55
+ /**
56
+ * Every terminal of a sub account, across all pages. Starts at `params.cursor` if given.
57
+ * @param accountId The sub account's ID.
58
+ * @param params Starting cursor and other list filters.
59
+ * @throws {NombaError} A page request failed, e.g. `accountId` does not exist.
60
+ */
23
61
  iterateSubAccountTerminals(accountId: string, params?: TerminalListParams): AsyncGenerator<Terminal>;
24
62
  }
@@ -4,8 +4,17 @@
4
4
  */
5
5
  import type { BettingCustomerLookupParams, BettingCustomerLookupResult, BettingProvidersResult } from "../../../types/v1/betting/betting.types.js";
6
6
  export interface IBettingService {
7
- /** GET /v1/bill/betting/providers - Fetch betting providers */
7
+ /**
8
+ * `GET /v1/bill/betting/providers`.
9
+ * @returns The supported betting providers.
10
+ * @throws {NombaError} The call failed.
11
+ */
8
12
  getBettingProviders(): Promise<BettingProvidersResult>;
9
- /** GET /v1/bill/betting/lookup - Validate customer and get name */
13
+ /**
14
+ * `GET /v1/bill/betting/lookup`. Validates a customer ID and returns the account name.
15
+ * @param params The provider and customer ID to look up.
16
+ * @returns The customer's account name.
17
+ * @throws {NombaError} The call failed, e.g. the customer ID is invalid.
18
+ */
10
19
  lookupCustomer(params: BettingCustomerLookupParams): Promise<BettingCustomerLookupResult>;
11
20
  }
@@ -4,8 +4,18 @@
4
4
  */
5
5
  import type { CableCustomerLookupParams, CableCustomerLookupResult, CablePlansParams, CablePlansResult } from "../../../types/v1/cable/cable.types.js";
6
6
  export interface ICableService {
7
- /** GET /v1/bill/cableTvProduct - Fetch cable TV plans */
7
+ /**
8
+ * `GET /v1/bill/cableTvProduct`.
9
+ * @param params The provider whose plans to fetch.
10
+ * @returns The provider's cable TV plans.
11
+ * @throws {NombaError} The call failed.
12
+ */
8
13
  getCablePlans(params: CablePlansParams): Promise<CablePlansResult>;
9
- /** GET /v1/bill/cable/lookup - Validate customer and get name */
14
+ /**
15
+ * `GET /v1/bill/cable/lookup`. Validates a smartcard number and returns the account name.
16
+ * @param params The provider and smartcard number to look up.
17
+ * @returns The customer's account name.
18
+ * @throws {NombaError} The call failed, e.g. the smartcard number is invalid.
19
+ */
10
20
  lookupCustomer(params: CableCustomerLookupParams): Promise<CableCustomerLookupResult>;
11
21
  }
@@ -2,32 +2,93 @@
2
2
  * @module nomba/interfaces/charge
3
3
  * @description Charge service contract
4
4
  */
5
- import type { RequestOptions } from "../../../types/common/common.types.js";
6
5
  import type { CancelChargeTransactionParams, ChargeOrder, ChargeTransactionDetails, FlashAccount, SaveCardOtpRequest, SubmitCardDetailsParams, SubmitCardDetailsResult, SubmitCardOtpParams, SubmitCardOtpResult, SubmitSaveCardOtpParams } from "../../../types/v1/charge/charge.types.js";
7
6
  import type { CheckoutResult, TokenizedCardData } from "../../../types/v1/checkout/checkout.types.js";
8
7
  export interface IChargeService {
9
- /** GET /v1/checkout/order/{orderReference} */
8
+ /**
9
+ * `GET /v1/checkout/order/{orderReference}`.
10
+ * @param orderReference The order's reference, from `nomba.checkout.createOrder`.
11
+ * @returns The order's details.
12
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
13
+ */
10
14
  getOrder(orderReference: string): Promise<ChargeOrder>;
11
- /** POST /v1/checkout/checkout-card-detail */
12
- submitCardDetails(params: SubmitCardDetailsParams, options?: RequestOptions): Promise<SubmitCardDetailsResult>;
13
- /** POST /v1/checkout/checkout-card-otp */
14
- submitCardOtp(params: SubmitCardOtpParams, options?: RequestOptions): Promise<SubmitCardOtpResult>;
15
- /** POST /v1/checkout/resend-otp. Resends the payment OTP to the customer's phone. */
16
- resendOtp(orderReference: string, options?: RequestOptions): Promise<CheckoutResult>;
17
- /** POST /v1/checkout/confirm-transaction-receipt. The status after the OTP is submitted or a transfer is made. */
15
+ /**
16
+ * `POST /v1/checkout/checkout-card-detail`.
17
+ * @param params The order reference and card details to charge.
18
+ * @returns The result of submitting the card; an OTP is typically sent next.
19
+ * @throws {NombaError} The call failed, e.g. the card was declined.
20
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
21
+ */
22
+ submitCardDetails(params: SubmitCardDetailsParams): Promise<SubmitCardDetailsResult>;
23
+ /**
24
+ * `POST /v1/checkout/checkout-card-otp`.
25
+ * @param params The order reference and OTP the customer received.
26
+ * @returns The result of submitting the OTP.
27
+ * @throws {NombaError} The call failed, e.g. the OTP was wrong or expired.
28
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
29
+ */
30
+ submitCardOtp(params: SubmitCardOtpParams): Promise<SubmitCardOtpResult>;
31
+ /**
32
+ * `POST /v1/checkout/resend-otp`. Resends the payment OTP to the customer's phone.
33
+ * @param orderReference The order's reference.
34
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
35
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
36
+ */
37
+ resendOtp(orderReference: string): Promise<CheckoutResult>;
38
+ /**
39
+ * `POST /v1/checkout/confirm-transaction-receipt`. The status after the OTP is submitted or a transfer
40
+ * is made.
41
+ * @param orderReference The order's reference.
42
+ * @returns The transaction's current status.
43
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
44
+ */
18
45
  fetchTransactionDetails(orderReference: string): Promise<ChargeTransactionDetails>;
19
- /** GET /v1/checkout/get-checkout-kta/{orderReference}. A Flash account number the customer can pay by transfer. */
46
+ /**
47
+ * `GET /v1/checkout/get-checkout-kta/{orderReference}`. A Flash account number the customer can pay by
48
+ * transfer.
49
+ * @param orderReference The order's reference.
50
+ * @returns The Flash account to transfer payment to.
51
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
52
+ */
20
53
  fetchFlashAccount(orderReference: string): Promise<FlashAccount>;
21
- /** POST /v1/checkout/transaction/cancel. Cancels an incomplete checkout transaction. */
22
- cancelTransaction(params: CancelChargeTransactionParams, options?: RequestOptions): Promise<CheckoutResult>;
23
- /** POST /v1/checkout/user-card/saved-card/auth. Sends an OTP; use when getOrder says the user has saved cards. */
24
- requestSavedCardsOtp(orderReference: string, options?: RequestOptions): Promise<CheckoutResult>;
25
- /** GET /v1/checkout/user-card/{orderReference}. Needs the OTP from requestSavedCardsOtp. */
54
+ /**
55
+ * `POST /v1/checkout/transaction/cancel`. Cancels an incomplete checkout transaction.
56
+ * @param params The order reference to cancel.
57
+ * @throws {NombaError} The call failed, e.g. the transaction already completed.
58
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
59
+ */
60
+ cancelTransaction(params: CancelChargeTransactionParams): Promise<CheckoutResult>;
61
+ /**
62
+ * `POST /v1/checkout/user-card/saved-card/auth`. Sends an OTP; use when `getOrder` says the user has
63
+ * saved cards.
64
+ * @param orderReference The order's reference.
65
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
66
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
67
+ */
68
+ requestSavedCardsOtp(orderReference: string): Promise<CheckoutResult>;
69
+ /**
70
+ * `GET /v1/checkout/user-card/{orderReference}`. Needs the OTP from `requestSavedCardsOtp`.
71
+ * @param orderReference The order's reference.
72
+ * @param otp The OTP sent by `requestSavedCardsOtp`.
73
+ * @returns The customer's saved, tokenized cards.
74
+ * @throws {NombaError} The call failed, e.g. the OTP was wrong or expired.
75
+ */
26
76
  getSavedCards(orderReference: string, otp: string): Promise<{
27
77
  tokenizedCardData?: TokenizedCardData[];
28
78
  }>;
29
- /** POST /v1/checkout/user-card/auth. Sends an OTP before saving a card; call after a successful payment. */
30
- requestSaveCardOtp(params: SaveCardOtpRequest, options?: RequestOptions): Promise<CheckoutResult>;
31
- /** POST /v1/checkout/user-card. Submits the OTP, which saves the card for later use. */
32
- submitSaveCardOtp(params: SubmitSaveCardOtpParams, options?: RequestOptions): Promise<CheckoutResult>;
79
+ /**
80
+ * `POST /v1/checkout/user-card/auth`. Sends an OTP before saving a card; call after a successful
81
+ * payment.
82
+ * @param params The order reference and card to save.
83
+ * @throws {NombaError} The call failed, e.g. `orderReference` does not exist.
84
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
85
+ */
86
+ requestSaveCardOtp(params: SaveCardOtpRequest): Promise<CheckoutResult>;
87
+ /**
88
+ * `POST /v1/checkout/user-card`. Submits the OTP, which saves the card for later use.
89
+ * @param params The order reference and OTP from `requestSaveCardOtp`.
90
+ * @throws {NombaError} The call failed, e.g. the OTP was wrong or expired.
91
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
92
+ */
93
+ submitSaveCardOtp(params: SubmitSaveCardOtpParams): Promise<CheckoutResult>;
33
94
  }
@@ -2,29 +2,78 @@
2
2
  * @module nomba/interfaces/checkout
3
3
  * @description Checkout service contract
4
4
  */
5
- import type { CallOptions, RequestOptions } from "../../../types/common/common.types.js";
5
+ import type { CallOptions } from "../../../types/common/common.types.js";
6
6
  import type { ChargeTokenizedCardParams, CheckoutOrderCreated, CheckoutResult, CheckoutTransaction, CreateCheckoutOrderParams, FetchCheckoutTransactionParams, ListTokenizedCardsParams, RefundCheckoutTransactionParams, TokenizedCardData, TokenizedCardList, TokenizedCardResult, UpdatedTokenizedCard, UpdateTokenizedCardParams } from "../../../types/v1/checkout/checkout.types.js";
7
7
  export interface ICheckoutService {
8
8
  /**
9
- * POST /v1/checkout/order. Send the customer to `checkoutLink` to pay.
9
+ * `POST /v1/checkout/order`. Send the customer to `checkoutLink` to pay.
10
10
  * Verified against a real sandbox call to use /v1/checkout/order, not /sandbox/checkout/order as the
11
11
  * sandbox-testing guide claims (that path 404s); sandbox and production share this path.
12
+ * @param params The order to create; `order.orderReference` is the idempotency key.
13
+ * @returns The created order, including `checkoutLink`.
14
+ * @throws {NombaError} The call failed.
15
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
16
+ */
17
+ createOrder(params: CreateCheckoutOrderParams): Promise<CheckoutOrderCreated>;
18
+ /**
19
+ * `GET /v1/checkout/transaction`. Verified in sandbox; see the note on `createOrder`.
20
+ * @param params Which transaction to fetch, e.g. by `orderReference`.
21
+ * @returns The matching transaction.
22
+ * @throws {NombaError} The call failed, e.g. no transaction matches.
12
23
  */
13
- createOrder(params: CreateCheckoutOrderParams, options?: RequestOptions): Promise<CheckoutOrderCreated>;
14
- /** GET /v1/checkout/transaction. Verified in sandbox; see the note on createOrder. */
15
24
  fetchTransaction(params?: FetchCheckoutTransactionParams): Promise<CheckoutTransaction>;
16
- /** POST /v1/checkout/order/cancel. Only for orders not yet paid; use `refund` after payment. */
17
- cancelOrder(orderReference: string, options?: RequestOptions): Promise<CheckoutResult>;
18
- /** POST /v1/checkout/refund. Verified in sandbox; see the note on createOrder. */
25
+ /**
26
+ * `POST /v1/checkout/order/cancel`. Only for orders not yet paid; use `refund` after payment.
27
+ * @param orderReference The order's reference (used as idempotency key).
28
+ * @throws {NombaError} The call failed, e.g. the order was already paid.
29
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
30
+ */
31
+ cancelOrder(orderReference: string): Promise<CheckoutResult>;
32
+ /**
33
+ * `POST /v1/checkout/refund`. Verified in sandbox; see the note on `createOrder`.
34
+ * @param params The transaction to refund; `transactionId` is the idempotency key.
35
+ * @param options Outcome handlers (`onSuccess`, `onPending`, `onFailed`).
36
+ * @returns The refund result, or the outcome `options` maps it to.
37
+ * @throws {NombaError} The call failed and is not retryable.
38
+ * @throws {OutcomeUnknownError} The request outcome could not be determined and no `onPending` was supplied.
39
+ * @throws {UnconfirmedOutcomeError} The response was pending or undocumented and no `onPending` was supplied.
40
+ */
19
41
  refund<R = CheckoutResult>(params: RefundCheckoutTransactionParams, options?: CallOptions<CheckoutResult, R>): Promise<CheckoutResult | R>;
20
- /** POST /v1/checkout/tokenized-card-payment. Check `status` on the result: it says whether the charge went through. */
21
- chargeTokenizedCard(params: ChargeTokenizedCardParams, options?: RequestOptions): Promise<TokenizedCardResult>;
22
- /** GET /v1/checkout/tokenized-card-data */
42
+ /**
43
+ * `POST /v1/checkout/tokenized-card-payment`. Check `status` on the result: it says whether the charge
44
+ * went through.
45
+ * @param params The tokenized card and amount to charge; `order.orderReference` is the idempotency key.
46
+ * @returns The charge result.
47
+ * @throws {NombaError} The call failed, e.g. the token is invalid or expired.
48
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
49
+ */
50
+ chargeTokenizedCard(params: ChargeTokenizedCardParams): Promise<TokenizedCardResult>;
51
+ /**
52
+ * `GET /v1/checkout/tokenized-card-data`.
53
+ * @param params Pagination (`page`) and other list filters.
54
+ * @returns One page of the customer's saved, tokenized cards.
55
+ * @throws {NombaError} The call failed.
56
+ */
23
57
  listTokenizedCards(params?: ListTokenizedCardsParams): Promise<TokenizedCardList>;
24
- /** Every tokenized card matching the filters, across all pages. Starts at `params.page` if given. */
58
+ /**
59
+ * Every tokenized card matching the filters, across all pages. Starts at `params.page` if given.
60
+ * @param params Starting page and other list filters.
61
+ * @throws {NombaError} A page request failed.
62
+ */
25
63
  iterateTokenizedCards(params?: ListTokenizedCardsParams): AsyncGenerator<TokenizedCardData>;
26
- /** POST /v1/checkout/tokenized-card-data */
27
- updateTokenizedCard(params: UpdateTokenizedCardParams, options?: RequestOptions): Promise<UpdatedTokenizedCard>;
28
- /** DELETE /v1/checkout/tokenized-card-data */
29
- deleteTokenizedCard(tokenKey: string, options?: RequestOptions): Promise<TokenizedCardResult>;
64
+ /**
65
+ * `POST /v1/checkout/tokenized-card-data`.
66
+ * @param params The tokenized card's key and the fields to update; `tokenKey` is the idempotency key.
67
+ * @returns The updated tokenized card.
68
+ * @throws {NombaError} The call failed, e.g. the token is invalid.
69
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
70
+ */
71
+ updateTokenizedCard(params: UpdateTokenizedCardParams): Promise<UpdatedTokenizedCard>;
72
+ /**
73
+ * `DELETE /v1/checkout/tokenized-card-data`.
74
+ * @param tokenKey The tokenized card's key (used as idempotency key).
75
+ * @throws {NombaError} The call failed, e.g. the token is invalid.
76
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed.
77
+ */
78
+ deleteTokenizedCard(tokenKey: string): Promise<TokenizedCardResult>;
30
79
  }
@@ -4,6 +4,11 @@
4
4
  */
5
5
  import type { DataPlansResult } from "../../../types/v1/data/data.types.js";
6
6
  export interface IDataService {
7
- /** GET /v1/bill/data-plan/{telco} - Fetch data plans for a network */
7
+ /**
8
+ * `GET /v1/bill/data-plan/{telco}`.
9
+ * @param telco The telco network to list data plans for.
10
+ * @returns The available data plans for that telco.
11
+ * @throws {NombaError} `telco` is not a recognized network, or the request failed.
12
+ */
8
13
  getDataPlans(telco: string): Promise<DataPlansResult>;
9
14
  }
@@ -2,30 +2,53 @@
2
2
  * @module nomba/interfaces/direct-debits
3
3
  * @description DirectDebits service contract
4
4
  */
5
- import type { RequestOptions } from "../../../types/common/common.types.js";
6
5
  import type { CreatedMandate, CreateMandateParams, DebitMandateParams, ListMandatesParams, MandateDebitResult, MandatePage, MandateStatus, UpdatedMandateStatus, UpdateMandateStatusParams } from "../../../types/v1/direct-debits/direct-debits.types.js";
7
6
  export interface IDirectDebitsService {
8
7
  /**
9
- * POST /v1/direct-debits.
8
+ * `POST /v1/direct-debits`.
10
9
  * ponytail: this endpoint's response envelope is `{ responseCode, responseMessage, data }`, unlike every
11
10
  * other endpoint's `{ code, description, data }` — confirmed from the spec's own example, not guessed.
11
+ * @param params The mandate to create; `merchantReference` is the idempotency key.
12
+ * @returns The created mandate.
13
+ * @throws {NombaError} The mandate params were rejected.
14
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
15
+ * check the mandate status before retrying.
16
+ */
17
+ createMandate(params: CreateMandateParams): Promise<CreatedMandate>;
18
+ /**
19
+ * `GET /v1/direct-debits/status?mandateId={mandateId}`.
20
+ * @param mandateId The mandate to look up.
21
+ * @returns The mandate's current status.
22
+ * @throws {NombaError} `mandateId` is not found, or the request failed.
12
23
  */
13
- createMandate(params: CreateMandateParams, options?: RequestOptions): Promise<CreatedMandate>;
14
- /** GET /v1/direct-debits/status?mandateId={mandateId} */
15
24
  getMandateStatus(mandateId: string): Promise<MandateStatus>;
16
25
  /**
17
- * POST /v1/direct-debits/debit-mandate. Unlike createMandate, there is no per-transaction reference
18
- * field to default the idempotency key to (mandateId is stable across every debit on that mandate, so
19
- * defaulting to it would give every recurring debit the same key). Pass your own idempotencyKey if you
20
- * need retries deduplicated; otherwise the client generates a fresh one per call.
26
+ * `POST /v1/direct-debits/debit-mandate`. No per-transaction reference field exists in params, so a
27
+ * random idempotency key is generated for error tracking. If the outcome is unknown, requery the mandate
28
+ * before retrying.
29
+ * @param params The mandate to debit and the amount.
30
+ * @returns The debit result.
31
+ * @throws {NombaError} The mandate is not active, or the debit was rejected.
32
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
33
+ * check the mandate status before retrying.
34
+ */
35
+ debitMandate(params: DebitMandateParams): Promise<MandateDebitResult>;
36
+ /**
37
+ * `GET /v1/direct-debits/mandates`.
38
+ * @param params Pagination and filter params.
39
+ * @returns A page of mandates.
40
+ * @throws {NombaError} The request failed.
21
41
  */
22
- debitMandate(params: DebitMandateParams, options?: RequestOptions): Promise<MandateDebitResult>;
23
- /** GET /v1/direct-debits/mandates */
24
42
  listMandates(params: ListMandatesParams): Promise<MandatePage>;
25
43
  /**
26
- * PUT /v1/direct-debits/update-status. Same reasoning as debitMandate: mandateId is stable across every
27
- * status change on that mandate (SUSPEND, then ACTIVE, then SUSPEND again), so it is not a safe default
28
- * idempotency key. Pass your own if you need a retry deduplicated.
44
+ * `PUT /v1/direct-debits/update-status`. No per-change reference field exists in params, so a random
45
+ * idempotency key is generated for error tracking. If the outcome is unknown, check the mandate status
46
+ * before retrying.
47
+ * @param params The mandate and the new status.
48
+ * @returns The mandate's updated status.
49
+ * @throws {NombaError} The status transition is invalid, or the request failed.
50
+ * @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
51
+ * check the mandate status before retrying.
29
52
  */
30
- updateMandateStatus(params: UpdateMandateStatusParams, options?: RequestOptions): Promise<UpdatedMandateStatus>;
53
+ updateMandateStatus(params: UpdateMandateStatusParams): Promise<UpdatedMandateStatus>;
31
54
  }