@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.
- package/README.md +77 -16
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/interfaces/v1/accounts/IAccountsService.d.ts +46 -8
- package/dist/interfaces/v1/betting/IBettingService.d.ts +11 -2
- package/dist/interfaces/v1/cable/ICableService.d.ts +12 -2
- package/dist/interfaces/v1/charge/IChargeService.d.ts +80 -19
- package/dist/interfaces/v1/checkout/ICheckoutService.d.ts +64 -15
- package/dist/interfaces/v1/data/IDataService.d.ts +6 -1
- package/dist/interfaces/v1/direct-debits/IDirectDebitsService.d.ts +37 -14
- package/dist/interfaces/v1/electricity/IElectricityService.d.ts +11 -2
- package/dist/interfaces/v1/globals/collections/IGlobalCollectionsService.d.ts +22 -5
- package/dist/interfaces/v1/globals/payouts/IGlobalPayoutService.d.ts +76 -13
- package/dist/interfaces/v1/requery/IRequeryService.d.ts +19 -5
- package/dist/interfaces/v1/terminals/ITerminalsService.d.ts +43 -10
- package/dist/interfaces/v1/transactions/ITransactionsService.d.ts +71 -12
- package/dist/interfaces/v1/virtual-accounts/IVirtualAccountsService.d.ts +50 -12
- package/dist/interfaces/v1/webhooks/IWebhooksService.d.ts +29 -10
- package/dist/interfaces/v2/airtime/IAirtimeV2Service.d.ts +21 -2
- package/dist/interfaces/v2/betting/IBettingV2Service.d.ts +21 -2
- package/dist/interfaces/v2/cable/ICableV2Service.d.ts +21 -2
- package/dist/interfaces/v2/data/IDataV2Service.d.ts +21 -2
- package/dist/interfaces/v2/electricity/IElectricityV2Service.d.ts +22 -2
- package/dist/interfaces/v2/transfers/ITransfersService.d.ts +57 -6
- package/dist/lib/errors.d.ts +19 -0
- package/dist/lib/errors.js +23 -0
- package/dist/lib/outcome.d.ts +30 -5
- package/dist/lib/outcome.js +31 -6
- package/dist/lib/sdk-version.generated.d.ts +1 -1
- package/dist/lib/sdk-version.generated.js +1 -1
- package/dist/lib/util.d.ts +0 -1
- package/dist/lib/util.js +0 -6
- package/dist/nomba.d.ts +38 -5
- package/dist/nomba.js +38 -5
- package/dist/services/http/http-client.service.d.ts +40 -6
- package/dist/services/http/http-client.service.js +44 -9
- package/dist/services/v1/accounts/accounts.service.d.ts +46 -8
- package/dist/services/v1/accounts/accounts.service.js +46 -8
- package/dist/services/v1/betting/betting.service.d.ts +12 -2
- package/dist/services/v1/betting/betting.service.js +12 -2
- package/dist/services/v1/cable/cable.service.d.ts +13 -2
- package/dist/services/v1/cable/cable.service.js +13 -2
- package/dist/services/v1/charge/charge.service.d.ts +80 -19
- package/dist/services/v1/charge/charge.service.js +88 -26
- package/dist/services/v1/checkout/checkout.service.d.ts +63 -15
- package/dist/services/v1/checkout/checkout.service.js +70 -24
- package/dist/services/v1/data/data.service.d.ts +7 -1
- package/dist/services/v1/data/data.service.js +7 -1
- package/dist/services/v1/direct-debits/direct-debits.service.d.ts +38 -14
- package/dist/services/v1/direct-debits/direct-debits.service.js +39 -17
- package/dist/services/v1/electricity/electricity.service.d.ts +12 -2
- package/dist/services/v1/electricity/electricity.service.js +12 -2
- package/dist/services/v1/globals/collections.service.d.ts +23 -5
- package/dist/services/v1/globals/collections.service.js +29 -7
- package/dist/services/v1/globals/payout.service.d.ts +77 -13
- package/dist/services/v1/globals/payout.service.js +83 -17
- package/dist/services/v1/requery/requery.service.d.ts +23 -5
- package/dist/services/v1/requery/requery.service.js +23 -5
- package/dist/services/v1/terminals/terminals.service.d.ts +42 -14
- package/dist/services/v1/terminals/terminals.service.js +44 -27
- package/dist/services/v1/transactions/transactions.service.d.ts +70 -12
- package/dist/services/v1/transactions/transactions.service.js +70 -12
- package/dist/services/v1/virtual-accounts/virtual-accounts.service.d.ts +52 -12
- package/dist/services/v1/virtual-accounts/virtual-accounts.service.js +55 -15
- package/dist/services/v1/webhooks/webhooks.service.d.ts +31 -10
- package/dist/services/v1/webhooks/webhooks.service.js +35 -14
- package/dist/services/v2/airtime/airtime.service.d.ts +26 -2
- package/dist/services/v2/airtime/airtime.service.js +27 -7
- package/dist/services/v2/betting/betting.service.d.ts +27 -3
- package/dist/services/v2/betting/betting.service.js +28 -8
- package/dist/services/v2/cable/cable.service.d.ts +27 -3
- package/dist/services/v2/cable/cable.service.js +28 -8
- package/dist/services/v2/data/data.service.d.ts +26 -2
- package/dist/services/v2/data/data.service.js +27 -7
- package/dist/services/v2/electricity/electricity.service.d.ts +28 -3
- package/dist/services/v2/electricity/electricity.service.js +29 -8
- package/dist/services/v2/transfers/transfers.service.d.ts +51 -6
- package/dist/services/v2/transfers/transfers.service.js +55 -25
- package/dist/types/common/common.types.d.ts +10 -13
- package/dist/types/v1/globals/collections.types.d.ts +3 -3
- package/dist/types/v1/globals/payout.types.d.ts +3 -3
- package/package.json +1 -1
|
@@ -14,32 +14,96 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
|
|
16
16
|
import type { IGlobalPayoutService } from "../../../interfaces/v1/globals/payouts/IGlobalPayoutService.js";
|
|
17
|
-
import type { CallOptions
|
|
17
|
+
import type { CallOptions } from "../../../types/common/common.types.js";
|
|
18
18
|
import type { AuthorizeExchangeParams, AuthorizeTransferParams, Conversion, ConvertMoneyParams, ExchangeRate, ExchangeRatesParams, InstitutionProvider, InstitutionProvidersParams, PaymentMethodInfo, PaymentMethodsParams, PayoutAccount, PayoutResult, PayoutTransaction } from "../../../types/v1/globals/payout.types.js";
|
|
19
|
+
/** Global Payout (v1): cross-border transfers, currency exchange, and multi-currency wallets. */
|
|
19
20
|
export declare class GlobalPayoutService implements IGlobalPayoutService {
|
|
20
21
|
#private;
|
|
21
22
|
private readonly http;
|
|
22
23
|
constructor(http: IHttpClient);
|
|
23
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* `GET /v1/global-payout/accounts`.
|
|
26
|
+
* @returns Every currency wallet, with its balance.
|
|
27
|
+
* @throws {NombaError} The request failed.
|
|
28
|
+
*/
|
|
24
29
|
listAccounts(): Promise<PayoutAccount[]>;
|
|
25
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* `GET /v1/global-payout/accounts/{accountId}`.
|
|
32
|
+
* @param accountId The wallet to look up.
|
|
33
|
+
* @returns The wallet's details and balance.
|
|
34
|
+
* @throws {NombaError} `accountId` is not one of your wallets (404), or the request failed.
|
|
35
|
+
*/
|
|
26
36
|
getAccount(accountId: string): Promise<PayoutAccount>;
|
|
27
|
-
/**
|
|
37
|
+
/**
|
|
38
|
+
* `GET /v1/sandbox/global-payout/accounts`.
|
|
39
|
+
* @returns Canned test wallet data.
|
|
40
|
+
* @throws {NombaError} The request failed.
|
|
41
|
+
*/
|
|
28
42
|
listSandboxAccounts(): Promise<PayoutAccount[]>;
|
|
29
|
-
/**
|
|
43
|
+
/**
|
|
44
|
+
* `GET /v1/sandbox/global-payout/accounts/{accountId}`. Canned test data; any id is echoed back.
|
|
45
|
+
* @param accountId The wallet id to echo back in the canned response.
|
|
46
|
+
* @returns Canned test wallet data for that id.
|
|
47
|
+
* @throws {NombaError} The request failed.
|
|
48
|
+
*/
|
|
30
49
|
getSandboxAccount(accountId: string): Promise<PayoutAccount>;
|
|
31
|
-
/**
|
|
50
|
+
/**
|
|
51
|
+
* `GET /v1/global-payout/exchange-rates`.
|
|
52
|
+
* @param params The currency pair to get a rate for.
|
|
53
|
+
* @returns The matching exchange rates.
|
|
54
|
+
* @throws {NombaError} The request failed.
|
|
55
|
+
*/
|
|
32
56
|
exchangeRates(params: ExchangeRatesParams): Promise<ExchangeRate[]>;
|
|
33
|
-
/**
|
|
34
|
-
|
|
35
|
-
|
|
57
|
+
/**
|
|
58
|
+
* `POST /v1/global-payout/money/convert`. A calculation only; no money moves.
|
|
59
|
+
* @param params The amount and currency pair to convert.
|
|
60
|
+
* @returns The converted amount and rate used.
|
|
61
|
+
* @throws {NombaError} The request failed.
|
|
62
|
+
*/
|
|
63
|
+
convert(params: ConvertMoneyParams): Promise<Conversion>;
|
|
64
|
+
/**
|
|
65
|
+
* `GET /v1/global-payout/bank/providers`.
|
|
66
|
+
* @param params Filters, e.g. by country or currency.
|
|
67
|
+
* @returns The receiving institutions available for payout.
|
|
68
|
+
* @throws {NombaError} The request failed.
|
|
69
|
+
*/
|
|
36
70
|
institutionProviders(params?: InstitutionProvidersParams): Promise<InstitutionProvider[]>;
|
|
37
|
-
/**
|
|
71
|
+
/**
|
|
72
|
+
* `GET /v1/global-payout/payment-methods`.
|
|
73
|
+
* @param params Filters, e.g. by country or currency.
|
|
74
|
+
* @returns The payment methods available for payout.
|
|
75
|
+
* @throws {NombaError} The request failed.
|
|
76
|
+
*/
|
|
38
77
|
paymentMethods(params?: PaymentMethodsParams): Promise<PaymentMethodInfo[]>;
|
|
39
|
-
/**
|
|
78
|
+
/**
|
|
79
|
+
* `POST /v1/global-payout/transfer/authorize`. Sends money cross-border.
|
|
80
|
+
* @param params The transfer to authorize. Must include `idempotencyKey` — the SDK never generates
|
|
81
|
+
* one for you to prevent double disbursement.
|
|
82
|
+
* @param options Per-call overrides including outcome closures (`onSuccess`, `onPending`, `onFailed`).
|
|
83
|
+
* @returns The settled payout result (or the type `options` maps it to).
|
|
84
|
+
* @throws {IdempotencyKeyAbsentError} `idempotencyKey` is missing or empty.
|
|
85
|
+
* @throws {NombaError} The transfer was rejected.
|
|
86
|
+
* @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
|
|
87
|
+
* check the transaction status before retrying (not thrown if `options` resolves unknown outcomes).
|
|
88
|
+
*/
|
|
40
89
|
authorizeTransfer<R = PayoutResult>(params: AuthorizeTransferParams, options?: CallOptions<PayoutResult, R>): Promise<PayoutResult | R>;
|
|
41
|
-
/**
|
|
90
|
+
/**
|
|
91
|
+
* `POST /v1/global-payout/exchange/authorize`. Moves money between your own wallets in different currencies.
|
|
92
|
+
* @param params The exchange to authorize. Must include `idempotencyKey` — the SDK never generates
|
|
93
|
+
* one for you to prevent double disbursement.
|
|
94
|
+
* @param options Per-call overrides including outcome closures (`onSuccess`, `onPending`, `onFailed`).
|
|
95
|
+
* @returns The settled payout result (or the type `options` maps it to).
|
|
96
|
+
* @throws {IdempotencyKeyAbsentError} `idempotencyKey` is missing or empty.
|
|
97
|
+
* @throws {NombaError} The exchange was rejected.
|
|
98
|
+
* @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
|
|
99
|
+
* check the transaction status before retrying (not thrown if `options` resolves unknown outcomes).
|
|
100
|
+
*/
|
|
42
101
|
authorizeExchange<R = PayoutResult>(params: AuthorizeExchangeParams, options?: CallOptions<PayoutResult, R>): Promise<PayoutResult | R>;
|
|
43
|
-
/**
|
|
102
|
+
/**
|
|
103
|
+
* `GET /v1/global-payout/transactions/{transactionId}`, with a `wtTransactionId`.
|
|
104
|
+
* @param transactionId The transaction to look up.
|
|
105
|
+
* @returns The transaction's current state.
|
|
106
|
+
* @throws {NombaError} `transactionId` is not found, or the request failed.
|
|
107
|
+
*/
|
|
44
108
|
getTransaction(transactionId: string): Promise<PayoutTransaction>;
|
|
45
109
|
}
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
* @docs https://developer.nomba.com
|
|
13
13
|
* @see https://developer.nomba.com/docs/products/global-payout/introduction
|
|
14
14
|
*/
|
|
15
|
-
import {
|
|
15
|
+
import { IdempotencyKeyAbsentError } from "../../../lib/errors.js";
|
|
16
16
|
import { REJECTED, settle } from "../../../lib/outcome.js";
|
|
17
17
|
import { pathId } from "../../../lib/util.js";
|
|
18
18
|
// authorize-transfer documents data.status PROCESSING, PENDING, COMPLETED and FAILED. The docs never say FAILED is
|
|
@@ -30,66 +30,132 @@ const TRANSFER_OUTCOMES = {
|
|
|
30
30
|
const EXCHANGE_OUTCOMES = {
|
|
31
31
|
codes: { "00": "success", ...REJECTED },
|
|
32
32
|
};
|
|
33
|
+
/** Global Payout (v1): cross-border transfers, currency exchange, and multi-currency wallets. */
|
|
33
34
|
export class GlobalPayoutService {
|
|
34
35
|
http;
|
|
35
36
|
constructor(http) {
|
|
36
37
|
this.http = http;
|
|
37
38
|
}
|
|
38
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* `GET /v1/global-payout/accounts`.
|
|
41
|
+
* @returns Every currency wallet, with its balance.
|
|
42
|
+
* @throws {NombaError} The request failed.
|
|
43
|
+
*/
|
|
39
44
|
listAccounts() {
|
|
40
45
|
return this.http.request("GET", "/v1/global-payout/accounts");
|
|
41
46
|
}
|
|
42
|
-
/**
|
|
47
|
+
/**
|
|
48
|
+
* `GET /v1/global-payout/accounts/{accountId}`.
|
|
49
|
+
* @param accountId The wallet to look up.
|
|
50
|
+
* @returns The wallet's details and balance.
|
|
51
|
+
* @throws {NombaError} `accountId` is not one of your wallets (404), or the request failed.
|
|
52
|
+
*/
|
|
43
53
|
async getAccount(accountId) {
|
|
44
54
|
return this.http.request("GET", `/v1/global-payout/accounts/${pathId(accountId)}`);
|
|
45
55
|
}
|
|
46
|
-
/**
|
|
56
|
+
/**
|
|
57
|
+
* `GET /v1/sandbox/global-payout/accounts`.
|
|
58
|
+
* @returns Canned test wallet data.
|
|
59
|
+
* @throws {NombaError} The request failed.
|
|
60
|
+
*/
|
|
47
61
|
listSandboxAccounts() {
|
|
48
62
|
return this.http.request("GET", "/v1/sandbox/global-payout/accounts");
|
|
49
63
|
}
|
|
50
|
-
/**
|
|
64
|
+
/**
|
|
65
|
+
* `GET /v1/sandbox/global-payout/accounts/{accountId}`. Canned test data; any id is echoed back.
|
|
66
|
+
* @param accountId The wallet id to echo back in the canned response.
|
|
67
|
+
* @returns Canned test wallet data for that id.
|
|
68
|
+
* @throws {NombaError} The request failed.
|
|
69
|
+
*/
|
|
51
70
|
async getSandboxAccount(accountId) {
|
|
52
71
|
return this.http.request("GET", `/v1/sandbox/global-payout/accounts/${pathId(accountId)}`);
|
|
53
72
|
}
|
|
54
|
-
/**
|
|
73
|
+
/**
|
|
74
|
+
* `GET /v1/global-payout/exchange-rates`.
|
|
75
|
+
* @param params The currency pair to get a rate for.
|
|
76
|
+
* @returns The matching exchange rates.
|
|
77
|
+
* @throws {NombaError} The request failed.
|
|
78
|
+
*/
|
|
55
79
|
async exchangeRates(params) {
|
|
56
80
|
const data = await this.http.request("GET", "/v1/global-payout/exchange-rates", { query: params });
|
|
57
81
|
return data.rates;
|
|
58
82
|
}
|
|
59
|
-
/**
|
|
60
|
-
|
|
83
|
+
/**
|
|
84
|
+
* `POST /v1/global-payout/money/convert`. A calculation only; no money moves.
|
|
85
|
+
* @param params The amount and currency pair to convert.
|
|
86
|
+
* @returns The converted amount and rate used.
|
|
87
|
+
* @throws {NombaError} The request failed.
|
|
88
|
+
*/
|
|
89
|
+
convert(params) {
|
|
61
90
|
return this.http.request("POST", "/v1/global-payout/money/convert", {
|
|
62
91
|
body: params,
|
|
63
|
-
...options,
|
|
64
92
|
});
|
|
65
93
|
}
|
|
66
|
-
/**
|
|
94
|
+
/**
|
|
95
|
+
* `GET /v1/global-payout/bank/providers`.
|
|
96
|
+
* @param params Filters, e.g. by country or currency.
|
|
97
|
+
* @returns The receiving institutions available for payout.
|
|
98
|
+
* @throws {NombaError} The request failed.
|
|
99
|
+
*/
|
|
67
100
|
institutionProviders(params = {}) {
|
|
68
101
|
return this.http.request("GET", "/v1/global-payout/bank/providers", {
|
|
69
102
|
query: params,
|
|
70
103
|
});
|
|
71
104
|
}
|
|
72
|
-
/**
|
|
105
|
+
/**
|
|
106
|
+
* `GET /v1/global-payout/payment-methods`.
|
|
107
|
+
* @param params Filters, e.g. by country or currency.
|
|
108
|
+
* @returns The payment methods available for payout.
|
|
109
|
+
* @throws {NombaError} The request failed.
|
|
110
|
+
*/
|
|
73
111
|
paymentMethods(params = {}) {
|
|
74
112
|
return this.http.request("GET", "/v1/global-payout/payment-methods", {
|
|
75
113
|
query: params,
|
|
76
114
|
});
|
|
77
115
|
}
|
|
78
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* `POST /v1/global-payout/transfer/authorize`. Sends money cross-border.
|
|
118
|
+
* @param params The transfer to authorize. Must include `idempotencyKey` — the SDK never generates
|
|
119
|
+
* one for you to prevent double disbursement.
|
|
120
|
+
* @param options Per-call overrides including outcome closures (`onSuccess`, `onPending`, `onFailed`).
|
|
121
|
+
* @returns The settled payout result (or the type `options` maps it to).
|
|
122
|
+
* @throws {IdempotencyKeyAbsentError} `idempotencyKey` is missing or empty.
|
|
123
|
+
* @throws {NombaError} The transfer was rejected.
|
|
124
|
+
* @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
|
|
125
|
+
* check the transaction status before retrying (not thrown if `options` resolves unknown outcomes).
|
|
126
|
+
*/
|
|
79
127
|
async authorizeTransfer(params, options = {}) {
|
|
80
128
|
return this.#authorize("/v1/global-payout/transfer/authorize", params, options, TRANSFER_OUTCOMES);
|
|
81
129
|
}
|
|
82
|
-
/**
|
|
130
|
+
/**
|
|
131
|
+
* `POST /v1/global-payout/exchange/authorize`. Moves money between your own wallets in different currencies.
|
|
132
|
+
* @param params The exchange to authorize. Must include `idempotencyKey` — the SDK never generates
|
|
133
|
+
* one for you to prevent double disbursement.
|
|
134
|
+
* @param options Per-call overrides including outcome closures (`onSuccess`, `onPending`, `onFailed`).
|
|
135
|
+
* @returns The settled payout result (or the type `options` maps it to).
|
|
136
|
+
* @throws {IdempotencyKeyAbsentError} `idempotencyKey` is missing or empty.
|
|
137
|
+
* @throws {NombaError} The exchange was rejected.
|
|
138
|
+
* @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
|
|
139
|
+
* check the transaction status before retrying (not thrown if `options` resolves unknown outcomes).
|
|
140
|
+
*/
|
|
83
141
|
async authorizeExchange(params, options = {}) {
|
|
84
142
|
return this.#authorize("/v1/global-payout/exchange/authorize", params, options, EXCHANGE_OUTCOMES);
|
|
85
143
|
}
|
|
86
|
-
/**
|
|
144
|
+
/**
|
|
145
|
+
* `GET /v1/global-payout/transactions/{transactionId}`, with a `wtTransactionId`.
|
|
146
|
+
* @param transactionId The transaction to look up.
|
|
147
|
+
* @returns The transaction's current state.
|
|
148
|
+
* @throws {NombaError} `transactionId` is not found, or the request failed.
|
|
149
|
+
*/
|
|
87
150
|
async getTransaction(transactionId) {
|
|
88
151
|
return this.http.request("GET", `/v1/global-payout/transactions/${pathId(transactionId)}`);
|
|
89
152
|
}
|
|
90
|
-
// One key in the body (the one the API dedupes on)
|
|
153
|
+
// One key in the body (the one the API dedupes on), required to prevent double disbursement; OutcomeUnknownError reports it.
|
|
91
154
|
#authorize(path, params, options, table) {
|
|
92
|
-
const idempotencyKey = params
|
|
93
|
-
|
|
155
|
+
const { idempotencyKey } = params;
|
|
156
|
+
if (!idempotencyKey?.trim()) {
|
|
157
|
+
throw new IdempotencyKeyAbsentError("idempotencyKey", path);
|
|
158
|
+
}
|
|
159
|
+
return settle(this.http, "POST", path, { body: params }, table, { field: "idempotencyKey", value: idempotencyKey }, options);
|
|
94
160
|
}
|
|
95
161
|
}
|
|
@@ -15,17 +15,35 @@
|
|
|
15
15
|
import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
|
|
16
16
|
import type { IRequeryService } from "../../../interfaces/v1/requery/IRequeryService.js";
|
|
17
17
|
import type { Transaction, TransactionLookup } from "../../../types/v1/requery/requery.types.js";
|
|
18
|
+
/** Requery (v1): look up a single transaction's current status. */
|
|
18
19
|
export declare class RequeryService implements IRequeryService {
|
|
19
20
|
private readonly http;
|
|
20
21
|
constructor(http: IHttpClient);
|
|
21
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* `GET /v1/transactions/accounts/single`. Looks up a transaction on the parent account by
|
|
24
|
+
* reference or ID.
|
|
25
|
+
* @param lookup The transaction identifier (e.g., `transactionId` or `merchantTxRef`).
|
|
26
|
+
* @returns The transaction's current details and status.
|
|
27
|
+
* @throws {NombaError} The transaction was not found, or the call failed.
|
|
28
|
+
*/
|
|
22
29
|
fetchParentTransaction(lookup: TransactionLookup): Promise<Transaction>;
|
|
23
|
-
/**
|
|
30
|
+
/**
|
|
31
|
+
* `GET /v1/transactions/accounts/{subAccountId}/single`. Looks up a transaction on a sub account
|
|
32
|
+
* by reference or ID.
|
|
33
|
+
* @param subAccountId The sub account's ID.
|
|
34
|
+
* @param lookup The transaction identifier (e.g., `transactionId` or `merchantTxRef`).
|
|
35
|
+
* @returns The transaction's current details and status.
|
|
36
|
+
* @throws {NombaError} The transaction was not found, `subAccountId` does not exist, or the call failed.
|
|
37
|
+
*/
|
|
24
38
|
fetchSubAccountTransaction(subAccountId: string, lookup: TransactionLookup): Promise<Transaction>;
|
|
25
39
|
/**
|
|
26
|
-
* GET /v1/transactions/requery/{sessionId}
|
|
27
|
-
*
|
|
28
|
-
*
|
|
40
|
+
* `GET /v1/transactions/requery/{sessionId}`. Looks up a bank transfer by its session ID.
|
|
41
|
+
* Use this for transfers made through both parent and sub accounts. Note: Nomba-to-Nomba
|
|
42
|
+
* wallet transfers do not return a `sessionId`; use `fetchParentTransaction` or
|
|
43
|
+
* `fetchSubAccountTransaction` for those instead.
|
|
44
|
+
* @param sessionId The transfer's session ID from the original response.
|
|
45
|
+
* @returns The transaction's current details and status.
|
|
46
|
+
* @throws {NombaError} The session was not found, or the call failed.
|
|
29
47
|
*/
|
|
30
48
|
requeryBySession(sessionId: string): Promise<Transaction>;
|
|
31
49
|
}
|
|
@@ -13,27 +13,45 @@
|
|
|
13
13
|
* @see https://developer.nomba.com/docs/api-reference/requery
|
|
14
14
|
*/
|
|
15
15
|
import { pathId } from "../../../lib/util.js";
|
|
16
|
+
/** Requery (v1): look up a single transaction's current status. */
|
|
16
17
|
export class RequeryService {
|
|
17
18
|
http;
|
|
18
19
|
constructor(http) {
|
|
19
20
|
this.http = http;
|
|
20
21
|
}
|
|
21
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* `GET /v1/transactions/accounts/single`. Looks up a transaction on the parent account by
|
|
24
|
+
* reference or ID.
|
|
25
|
+
* @param lookup The transaction identifier (e.g., `transactionId` or `merchantTxRef`).
|
|
26
|
+
* @returns The transaction's current details and status.
|
|
27
|
+
* @throws {NombaError} The transaction was not found, or the call failed.
|
|
28
|
+
*/
|
|
22
29
|
fetchParentTransaction(lookup) {
|
|
23
30
|
return this.http.request("GET", "/v1/transactions/accounts/single", {
|
|
24
31
|
query: lookup,
|
|
25
32
|
});
|
|
26
33
|
}
|
|
27
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* `GET /v1/transactions/accounts/{subAccountId}/single`. Looks up a transaction on a sub account
|
|
36
|
+
* by reference or ID.
|
|
37
|
+
* @param subAccountId The sub account's ID.
|
|
38
|
+
* @param lookup The transaction identifier (e.g., `transactionId` or `merchantTxRef`).
|
|
39
|
+
* @returns The transaction's current details and status.
|
|
40
|
+
* @throws {NombaError} The transaction was not found, `subAccountId` does not exist, or the call failed.
|
|
41
|
+
*/
|
|
28
42
|
async fetchSubAccountTransaction(subAccountId, lookup) {
|
|
29
43
|
return this.http.request("GET", `/v1/transactions/accounts/${pathId(subAccountId)}/single`, {
|
|
30
44
|
query: lookup,
|
|
31
45
|
});
|
|
32
46
|
}
|
|
33
47
|
/**
|
|
34
|
-
* GET /v1/transactions/requery/{sessionId}
|
|
35
|
-
*
|
|
36
|
-
*
|
|
48
|
+
* `GET /v1/transactions/requery/{sessionId}`. Looks up a bank transfer by its session ID.
|
|
49
|
+
* Use this for transfers made through both parent and sub accounts. Note: Nomba-to-Nomba
|
|
50
|
+
* wallet transfers do not return a `sessionId`; use `fetchParentTransaction` or
|
|
51
|
+
* `fetchSubAccountTransaction` for those instead.
|
|
52
|
+
* @param sessionId The transfer's session ID from the original response.
|
|
53
|
+
* @returns The transaction's current details and status.
|
|
54
|
+
* @throws {NombaError} The session was not found, or the call failed.
|
|
37
55
|
*/
|
|
38
56
|
async requeryBySession(sessionId) {
|
|
39
57
|
return this.http.request("GET", `/v1/transactions/requery/${pathId(sessionId)}`);
|
|
@@ -14,25 +14,53 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
|
|
16
16
|
import type { ITerminalsService } from "../../../interfaces/v1/terminals/index.js";
|
|
17
|
-
import type { CallOptions
|
|
17
|
+
import type { CallOptions } from "../../../types/common/common.types.js";
|
|
18
18
|
import type { AssignTerminalParams, PushPaymentRequestParams, Terminal, TerminalPayment } from "../../../types/v1/terminals/terminals.types.js";
|
|
19
|
+
/** Terminals (v1): assign, unassign, and push payment requests to physical POS terminals. */
|
|
19
20
|
export declare class TerminalsService implements ITerminalsService {
|
|
20
21
|
private readonly http;
|
|
21
22
|
constructor(http: IHttpClient);
|
|
22
|
-
/** POST /v1/terminals/assign */
|
|
23
|
-
assignToParent(params: AssignTerminalParams, options?: RequestOptions): Promise<Terminal>;
|
|
24
|
-
/** POST /v1/terminals/assign/{subAccountId} */
|
|
25
|
-
assignToSubAccount(subAccountId: string, params: AssignTerminalParams, options?: RequestOptions): Promise<Terminal>;
|
|
26
|
-
/** POST /v1/terminals/unassign */
|
|
27
|
-
unassignFromParent(params: AssignTerminalParams, options?: RequestOptions): Promise<Terminal>;
|
|
28
|
-
/** POST /v1/terminals/unassign/{subAccountId} */
|
|
29
|
-
unassignFromSubAccount(subAccountId: string, params: AssignTerminalParams, options?: RequestOptions): Promise<Terminal>;
|
|
30
23
|
/**
|
|
31
|
-
* POST /v1/terminals/
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
|
|
24
|
+
* `POST /v1/terminals/assign`. Assigns a terminal to the parent account.
|
|
25
|
+
* @param params The terminal ID to assign.
|
|
26
|
+
* @returns The assigned terminal's details.
|
|
27
|
+
* @throws {NombaError} The call failed, e.g. the terminal does not exist or is already assigned.
|
|
28
|
+
*/
|
|
29
|
+
assignToParent(params: AssignTerminalParams): Promise<Terminal>;
|
|
30
|
+
/**
|
|
31
|
+
* `POST /v1/terminals/assign/{subAccountId}`. Assigns a terminal to a sub account.
|
|
32
|
+
* @param subAccountId The sub account to assign the terminal to.
|
|
33
|
+
* @param params The terminal ID to assign.
|
|
34
|
+
* @returns The assigned terminal's details.
|
|
35
|
+
* @throws {NombaError} The call failed, e.g. the terminal or sub account does not exist.
|
|
36
|
+
*/
|
|
37
|
+
assignToSubAccount(subAccountId: string, params: AssignTerminalParams): Promise<Terminal>;
|
|
38
|
+
/**
|
|
39
|
+
* `POST /v1/terminals/unassign`. Unassigns a terminal from the parent account.
|
|
40
|
+
* @param params The terminal ID to unassign.
|
|
41
|
+
* @returns The unassigned terminal's details.
|
|
42
|
+
* @throws {NombaError} The call failed, e.g. the terminal is not assigned to this account.
|
|
43
|
+
*/
|
|
44
|
+
unassignFromParent(params: AssignTerminalParams): Promise<Terminal>;
|
|
45
|
+
/**
|
|
46
|
+
* `POST /v1/terminals/unassign/{subAccountId}`. Unassigns a terminal from a sub account.
|
|
47
|
+
* @param subAccountId The sub account to unassign the terminal from.
|
|
48
|
+
* @param params The terminal ID to unassign.
|
|
49
|
+
* @returns The unassigned terminal's details.
|
|
50
|
+
* @throws {NombaError} The call failed, e.g. the terminal is not assigned to this sub account.
|
|
51
|
+
*/
|
|
52
|
+
unassignFromSubAccount(subAccountId: string, params: AssignTerminalParams): Promise<Terminal>;
|
|
53
|
+
/**
|
|
54
|
+
* `POST /v1/terminals/payment-request/{terminalId}`. Triggers a payment prompt on the physical terminal.
|
|
55
|
+
* The customer taps or swipes their card, and the outcome is reported via webhook or requery.
|
|
56
|
+
* @param terminalId The terminal's ID to prompt for payment.
|
|
57
|
+
* @param params The amount and `merchantTxRef` (used as idempotency key).
|
|
58
|
+
* @param options Outcome closures (`onSuccess`, `onPending`, `onFailed`); without them, success resolves
|
|
59
|
+
* the result and pending/failure throws.
|
|
60
|
+
* @returns The payment result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
|
|
61
|
+
* @throws {NombaError} The request was rejected (4xx).
|
|
62
|
+
* @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
|
|
63
|
+
* @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
|
|
36
64
|
*/
|
|
37
65
|
pushPaymentRequest<R = TerminalPayment>(terminalId: string, params: PushPaymentRequestParams, options?: CallOptions<TerminalPayment, R>): Promise<TerminalPayment | R>;
|
|
38
66
|
}
|
|
@@ -20,50 +20,67 @@ const PAYMENT_REQUEST_OUTCOMES = {
|
|
|
20
20
|
codes: { "00": "success", ...REJECTED },
|
|
21
21
|
statuses: { completed: "success", pending: "pending", failed: "pending" },
|
|
22
22
|
};
|
|
23
|
+
/** Terminals (v1): assign, unassign, and push payment requests to physical POS terminals. */
|
|
23
24
|
export class TerminalsService {
|
|
24
25
|
http;
|
|
25
26
|
constructor(http) {
|
|
26
27
|
this.http = http;
|
|
27
28
|
}
|
|
28
|
-
/**
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* `POST /v1/terminals/assign`. Assigns a terminal to the parent account.
|
|
31
|
+
* @param params The terminal ID to assign.
|
|
32
|
+
* @returns The assigned terminal's details.
|
|
33
|
+
* @throws {NombaError} The call failed, e.g. the terminal does not exist or is already assigned.
|
|
34
|
+
*/
|
|
35
|
+
assignToParent(params) {
|
|
30
36
|
return this.http.request("POST", "/v1/terminals/assign", {
|
|
31
37
|
body: params,
|
|
32
|
-
...options,
|
|
33
38
|
});
|
|
34
39
|
}
|
|
35
|
-
/**
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
/**
|
|
41
|
+
* `POST /v1/terminals/assign/{subAccountId}`. Assigns a terminal to a sub account.
|
|
42
|
+
* @param subAccountId The sub account to assign the terminal to.
|
|
43
|
+
* @param params The terminal ID to assign.
|
|
44
|
+
* @returns The assigned terminal's details.
|
|
45
|
+
* @throws {NombaError} The call failed, e.g. the terminal or sub account does not exist.
|
|
46
|
+
*/
|
|
47
|
+
async assignToSubAccount(subAccountId, params) {
|
|
48
|
+
return this.http.request("POST", `/v1/terminals/assign/${pathId(subAccountId)}`, { body: params });
|
|
41
49
|
}
|
|
42
|
-
/**
|
|
43
|
-
|
|
50
|
+
/**
|
|
51
|
+
* `POST /v1/terminals/unassign`. Unassigns a terminal from the parent account.
|
|
52
|
+
* @param params The terminal ID to unassign.
|
|
53
|
+
* @returns The unassigned terminal's details.
|
|
54
|
+
* @throws {NombaError} The call failed, e.g. the terminal is not assigned to this account.
|
|
55
|
+
*/
|
|
56
|
+
unassignFromParent(params) {
|
|
44
57
|
return this.http.request("POST", "/v1/terminals/unassign", {
|
|
45
58
|
body: params,
|
|
46
|
-
...options,
|
|
47
59
|
});
|
|
48
60
|
}
|
|
49
|
-
/**
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
61
|
+
/**
|
|
62
|
+
* `POST /v1/terminals/unassign/{subAccountId}`. Unassigns a terminal from a sub account.
|
|
63
|
+
* @param subAccountId The sub account to unassign the terminal from.
|
|
64
|
+
* @param params The terminal ID to unassign.
|
|
65
|
+
* @returns The unassigned terminal's details.
|
|
66
|
+
* @throws {NombaError} The call failed, e.g. the terminal is not assigned to this sub account.
|
|
67
|
+
*/
|
|
68
|
+
async unassignFromSubAccount(subAccountId, params) {
|
|
69
|
+
return this.http.request("POST", `/v1/terminals/unassign/${pathId(subAccountId)}`, { body: params });
|
|
55
70
|
}
|
|
56
71
|
/**
|
|
57
|
-
* POST /v1/terminals/payment-request/{terminalId}
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
72
|
+
* `POST /v1/terminals/payment-request/{terminalId}`. Triggers a payment prompt on the physical terminal.
|
|
73
|
+
* The customer taps or swipes their card, and the outcome is reported via webhook or requery.
|
|
74
|
+
* @param terminalId The terminal's ID to prompt for payment.
|
|
75
|
+
* @param params The amount and `merchantTxRef` (used as idempotency key).
|
|
76
|
+
* @param options Outcome closures (`onSuccess`, `onPending`, `onFailed`); without them, success resolves
|
|
77
|
+
* the result and pending/failure throws.
|
|
78
|
+
* @returns The payment result, or whatever `options.onSuccess`/`onPending`/`onFailed` returns.
|
|
79
|
+
* @throws {NombaError} The request was rejected (4xx).
|
|
80
|
+
* @throws {OutcomeUnknownError} The outcome could not be confirmed as success or failure.
|
|
81
|
+
* @throws {UnconfirmedOutcomeError} The result is pending and no `onPending` handler was given.
|
|
62
82
|
*/
|
|
63
83
|
async pushPaymentRequest(terminalId, params, options = {}) {
|
|
64
|
-
return settle(this.http, "POST", `/v1/terminals/payment-request/${pathId(terminalId)}`, { body: params }, PAYMENT_REQUEST_OUTCOMES, {
|
|
65
|
-
...options,
|
|
66
|
-
idempotencyKey: options.idempotencyKey ?? params.merchantTxRef,
|
|
67
|
-
});
|
|
84
|
+
return settle(this.http, "POST", `/v1/terminals/payment-request/${pathId(terminalId)}`, { body: params }, PAYMENT_REQUEST_OUTCOMES, { field: "merchantTxRef", value: params.merchantTxRef }, options);
|
|
68
85
|
}
|
|
69
86
|
}
|
|
@@ -17,32 +17,90 @@ import type { ITransactionsService } from "../../../interfaces/v1/transactions/I
|
|
|
17
17
|
import type { Page } from "../../../lib/util.js";
|
|
18
18
|
import type { Transaction } from "../../../types/v1/requery/requery.types.js";
|
|
19
19
|
import type { BankTransaction, BankTransactionList, FilterTransactionsParams, TransactionList, TransactionListParams, VirtualAccountTransaction, VirtualAccountTransactionParams } from "../../../types/v1/transactions/transactions.types.js";
|
|
20
|
+
/** Transactions (v1): list and filter transactions on parent, sub, and virtual accounts. */
|
|
20
21
|
export declare class TransactionsService implements ITransactionsService {
|
|
21
22
|
private readonly http;
|
|
22
23
|
constructor(http: IHttpClient);
|
|
23
|
-
/**
|
|
24
|
+
/**
|
|
25
|
+
* `GET /v1/transactions/bank`. Lists credit and debit transactions on the parent account.
|
|
26
|
+
* @param params Pagination options (`cursor`, `limit`).
|
|
27
|
+
* @returns One page of bank transactions.
|
|
28
|
+
* @throws {NombaError} The call failed.
|
|
29
|
+
*/
|
|
24
30
|
listBankTransactions(params?: TransactionListParams): Promise<BankTransactionList>;
|
|
25
|
-
/**
|
|
31
|
+
/**
|
|
32
|
+
* Iterates over every credit/debit transaction on the parent account, across all pages.
|
|
33
|
+
* @param params Starting pagination options.
|
|
34
|
+
* @throws {NombaError} A page request failed.
|
|
35
|
+
*/
|
|
26
36
|
iterateBankTransactions(params?: TransactionListParams): AsyncGenerator<BankTransaction>;
|
|
27
37
|
/**
|
|
28
|
-
* GET /v1/transactions/virtual
|
|
29
|
-
*
|
|
38
|
+
* `GET /v1/transactions/virtual`. Lists transactions on a virtual account.
|
|
39
|
+
* Note: The response carries a cursor, but the API docs do not name a paging parameter,
|
|
40
|
+
* so only the first page is returned.
|
|
41
|
+
* @param params The virtual account number and optional date range.
|
|
42
|
+
* @returns One page of virtual account transactions.
|
|
43
|
+
* @throws {NombaError} The call failed, e.g. `accountNumber` does not exist.
|
|
30
44
|
*/
|
|
31
45
|
listVirtualAccountTransactions({ accountNumber, ...dates }: VirtualAccountTransactionParams): Promise<Page<VirtualAccountTransaction>>;
|
|
32
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* `GET /v1/transactions/accounts`. Lists transactions on the parent account.
|
|
48
|
+
* @param params Pagination options (`cursor`, `limit`).
|
|
49
|
+
* @returns One page of transactions.
|
|
50
|
+
* @throws {NombaError} The call failed.
|
|
51
|
+
*/
|
|
33
52
|
listParentTransactions(params?: TransactionListParams): Promise<TransactionList>;
|
|
34
|
-
/**
|
|
53
|
+
/**
|
|
54
|
+
* Iterates over every transaction on the parent account, across all pages.
|
|
55
|
+
* @param params Starting pagination options.
|
|
56
|
+
* @throws {NombaError} A page request failed.
|
|
57
|
+
*/
|
|
35
58
|
iterateParentTransactions(params?: TransactionListParams): AsyncGenerator<Transaction>;
|
|
36
|
-
/**
|
|
59
|
+
/**
|
|
60
|
+
* `GET /v1/transactions/accounts/{subAccountId}`. Lists transactions on a sub account.
|
|
61
|
+
* @param subAccountId The sub account's ID.
|
|
62
|
+
* @param params Pagination options (`cursor`, `limit`).
|
|
63
|
+
* @returns One page of transactions.
|
|
64
|
+
* @throws {NombaError} The call failed, e.g. `subAccountId` does not exist.
|
|
65
|
+
*/
|
|
37
66
|
listSubAccountTransactions(subAccountId: string, params?: TransactionListParams): Promise<TransactionList>;
|
|
38
|
-
/**
|
|
67
|
+
/**
|
|
68
|
+
* Iterates over every transaction on a sub account, across all pages.
|
|
69
|
+
* @param subAccountId The sub account's ID.
|
|
70
|
+
* @param params Starting pagination options.
|
|
71
|
+
* @throws {NombaError} A page request failed, e.g. `subAccountId` does not exist.
|
|
72
|
+
*/
|
|
39
73
|
iterateSubAccountTransactions(subAccountId: string, params?: TransactionListParams): AsyncGenerator<Transaction>;
|
|
40
|
-
/**
|
|
74
|
+
/**
|
|
75
|
+
* `POST /v1/transactions/accounts`. Filters transactions on the parent account by criteria.
|
|
76
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
77
|
+
* @param page Pagination options (`cursor`, `limit`).
|
|
78
|
+
* @returns One page of matching transactions.
|
|
79
|
+
* @throws {NombaError} The call failed.
|
|
80
|
+
*/
|
|
41
81
|
filterParentTransactions(filter?: FilterTransactionsParams, page?: TransactionListParams): Promise<TransactionList>;
|
|
42
|
-
/**
|
|
82
|
+
/**
|
|
83
|
+
* Iterates over every parent account transaction matching the filter, across all pages.
|
|
84
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
85
|
+
* @param page Starting pagination options.
|
|
86
|
+
* @throws {NombaError} A page request failed.
|
|
87
|
+
*/
|
|
43
88
|
iterateFilteredParentTransactions(filter?: FilterTransactionsParams, page?: TransactionListParams): AsyncGenerator<Transaction>;
|
|
44
|
-
/**
|
|
89
|
+
/**
|
|
90
|
+
* `POST /v1/transactions/accounts/{subAccountId}`. Filters transactions on a sub account by criteria.
|
|
91
|
+
* @param subAccountId The sub account's ID.
|
|
92
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
93
|
+
* @param page Pagination options (`cursor`, `limit`).
|
|
94
|
+
* @returns One page of matching transactions.
|
|
95
|
+
* @throws {NombaError} The call failed, e.g. `subAccountId` does not exist.
|
|
96
|
+
*/
|
|
45
97
|
filterSubAccountTransactions(subAccountId: string, filter?: FilterTransactionsParams, page?: TransactionListParams): Promise<TransactionList>;
|
|
46
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* Iterates over every sub account transaction matching the filter, across all pages.
|
|
100
|
+
* @param subAccountId The sub account's ID.
|
|
101
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
102
|
+
* @param page Starting pagination options.
|
|
103
|
+
* @throws {NombaError} A page request failed, e.g. `subAccountId` does not exist.
|
|
104
|
+
*/
|
|
47
105
|
iterateFilteredSubAccountTransactions(subAccountId: string, filter?: FilterTransactionsParams, page?: TransactionListParams): AsyncGenerator<Transaction>;
|
|
48
106
|
}
|