@nomba/node-sdk 0.3.0 → 0.5.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 +49 -15
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/interfaces/v1/electricity/IElectricityService.d.ts +1 -8
- package/dist/interfaces/v1/globals/collections/IGlobalCollectionsService.d.ts +3 -1
- package/dist/interfaces/v1/globals/payouts/IGlobalPayoutService.d.ts +8 -6
- package/dist/interfaces/v2/electricity/IElectricityV2Service.d.ts +9 -2
- package/dist/interfaces/v2/electricity/IElectricityV2Service.js +1 -1
- package/dist/lib/errors.d.ts +19 -0
- package/dist/lib/errors.js +23 -0
- package/dist/lib/outcome.d.ts +9 -3
- package/dist/lib/outcome.js +10 -4
- 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/services/http/http-client.service.js +5 -3
- package/dist/services/v1/betting/betting.service.d.ts +1 -0
- package/dist/services/v1/betting/betting.service.js +1 -0
- package/dist/services/v1/cable/cable.service.d.ts +1 -0
- package/dist/services/v1/cable/cable.service.js +1 -0
- package/dist/services/v1/checkout/checkout.service.js +1 -1
- package/dist/services/v1/electricity/electricity.service.d.ts +3 -10
- package/dist/services/v1/electricity/electricity.service.js +2 -13
- package/dist/services/v1/globals/collections.service.d.ts +3 -1
- package/dist/services/v1/globals/collections.service.js +10 -5
- package/dist/services/v1/globals/payout.service.d.ts +12 -8
- package/dist/services/v1/globals/payout.service.js +19 -12
- 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 +37 -9
- package/dist/services/v1/terminals/terminals.service.js +38 -10
- 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 +48 -7
- package/dist/services/v1/virtual-accounts/virtual-accounts.service.js +48 -7
- package/dist/services/v1/webhooks/webhooks.service.d.ts +28 -6
- package/dist/services/v1/webhooks/webhooks.service.js +28 -6
- package/dist/services/v2/airtime/airtime.service.js +1 -1
- package/dist/services/v2/betting/betting.service.js +1 -1
- package/dist/services/v2/cable/cable.service.js +1 -1
- package/dist/services/v2/data/data.service.js +1 -1
- package/dist/services/v2/electricity/electricity.service.d.ts +10 -3
- package/dist/services/v2/electricity/electricity.service.js +14 -3
- package/dist/services/v2/transfers/transfers.service.js +4 -4
- package/dist/types/common/common.types.d.ts +2 -1
- package/dist/types/v1/electricity/electricity.types.d.ts +0 -9
- package/dist/types/v1/globals/collections.types.d.ts +3 -3
- package/dist/types/v1/globals/payout.types.d.ts +3 -3
- package/dist/types/v2/electricity/electricity.types.d.ts +9 -0
- package/package.json +1 -1
|
@@ -77,22 +77,26 @@ export declare class GlobalPayoutService implements IGlobalPayoutService {
|
|
|
77
77
|
paymentMethods(params?: PaymentMethodsParams): Promise<PaymentMethodInfo[]>;
|
|
78
78
|
/**
|
|
79
79
|
* `POST /v1/global-payout/transfer/authorize`. Sends money cross-border.
|
|
80
|
-
* @param params The transfer to authorize
|
|
81
|
-
*
|
|
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`).
|
|
82
83
|
* @returns The settled payout result (or the type `options` maps it to).
|
|
84
|
+
* @throws {IdempotencyKeyAbsentError} `idempotencyKey` is missing or empty.
|
|
83
85
|
* @throws {NombaError} The transfer was rejected.
|
|
84
|
-
* @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed
|
|
85
|
-
* (not thrown if `options` resolves unknown outcomes
|
|
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).
|
|
86
88
|
*/
|
|
87
89
|
authorizeTransfer<R = PayoutResult>(params: AuthorizeTransferParams, options?: CallOptions<PayoutResult, R>): Promise<PayoutResult | R>;
|
|
88
90
|
/**
|
|
89
91
|
* `POST /v1/global-payout/exchange/authorize`. Moves money between your own wallets in different currencies.
|
|
90
|
-
* @param params The exchange to authorize
|
|
91
|
-
*
|
|
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`).
|
|
92
95
|
* @returns The settled payout result (or the type `options` maps it to).
|
|
96
|
+
* @throws {IdempotencyKeyAbsentError} `idempotencyKey` is missing or empty.
|
|
93
97
|
* @throws {NombaError} The exchange was rejected.
|
|
94
|
-
* @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed
|
|
95
|
-
* (not thrown if `options` resolves unknown outcomes
|
|
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).
|
|
96
100
|
*/
|
|
97
101
|
authorizeExchange<R = PayoutResult>(params: AuthorizeExchangeParams, options?: CallOptions<PayoutResult, R>): Promise<PayoutResult | R>;
|
|
98
102
|
/**
|
|
@@ -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
|
|
@@ -115,24 +115,28 @@ export class GlobalPayoutService {
|
|
|
115
115
|
}
|
|
116
116
|
/**
|
|
117
117
|
* `POST /v1/global-payout/transfer/authorize`. Sends money cross-border.
|
|
118
|
-
* @param params The transfer to authorize
|
|
119
|
-
*
|
|
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`).
|
|
120
121
|
* @returns The settled payout result (or the type `options` maps it to).
|
|
122
|
+
* @throws {IdempotencyKeyAbsentError} `idempotencyKey` is missing or empty.
|
|
121
123
|
* @throws {NombaError} The transfer was rejected.
|
|
122
|
-
* @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed
|
|
123
|
-
* (not thrown if `options` resolves unknown outcomes
|
|
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).
|
|
124
126
|
*/
|
|
125
127
|
async authorizeTransfer(params, options = {}) {
|
|
126
128
|
return this.#authorize("/v1/global-payout/transfer/authorize", params, options, TRANSFER_OUTCOMES);
|
|
127
129
|
}
|
|
128
130
|
/**
|
|
129
131
|
* `POST /v1/global-payout/exchange/authorize`. Moves money between your own wallets in different currencies.
|
|
130
|
-
* @param params The exchange to authorize
|
|
131
|
-
*
|
|
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`).
|
|
132
135
|
* @returns The settled payout result (or the type `options` maps it to).
|
|
136
|
+
* @throws {IdempotencyKeyAbsentError} `idempotencyKey` is missing or empty.
|
|
133
137
|
* @throws {NombaError} The exchange was rejected.
|
|
134
|
-
* @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed
|
|
135
|
-
* (not thrown if `options` resolves unknown outcomes
|
|
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).
|
|
136
140
|
*/
|
|
137
141
|
async authorizeExchange(params, options = {}) {
|
|
138
142
|
return this.#authorize("/v1/global-payout/exchange/authorize", params, options, EXCHANGE_OUTCOMES);
|
|
@@ -146,9 +150,12 @@ export class GlobalPayoutService {
|
|
|
146
150
|
async getTransaction(transactionId) {
|
|
147
151
|
return this.http.request("GET", `/v1/global-payout/transactions/${pathId(transactionId)}`);
|
|
148
152
|
}
|
|
149
|
-
// 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.
|
|
150
154
|
#authorize(path, params, options, table) {
|
|
151
|
-
const idempotencyKey = params
|
|
152
|
-
|
|
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);
|
|
153
160
|
}
|
|
154
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)}`);
|
|
@@ -16,23 +16,51 @@ import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
|
|
|
16
16
|
import type { ITerminalsService } from "../../../interfaces/v1/terminals/index.js";
|
|
17
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
|
-
/**
|
|
23
|
+
/**
|
|
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
|
+
*/
|
|
23
29
|
assignToParent(params: AssignTerminalParams): Promise<Terminal>;
|
|
24
|
-
/**
|
|
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
|
+
*/
|
|
25
37
|
assignToSubAccount(subAccountId: string, params: AssignTerminalParams): Promise<Terminal>;
|
|
26
|
-
/**
|
|
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
|
+
*/
|
|
27
44
|
unassignFromParent(params: AssignTerminalParams): Promise<Terminal>;
|
|
28
|
-
/**
|
|
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
|
+
*/
|
|
29
52
|
unassignFromSubAccount(subAccountId: string, params: AssignTerminalParams): Promise<Terminal>;
|
|
30
53
|
/**
|
|
31
|
-
* POST /v1/terminals/payment-request/{terminalId}
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
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,39 +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
|
+
/**
|
|
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
|
+
*/
|
|
29
35
|
assignToParent(params) {
|
|
30
36
|
return this.http.request("POST", "/v1/terminals/assign", {
|
|
31
37
|
body: params,
|
|
32
38
|
});
|
|
33
39
|
}
|
|
34
|
-
/**
|
|
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
|
+
*/
|
|
35
47
|
async assignToSubAccount(subAccountId, params) {
|
|
36
48
|
return this.http.request("POST", `/v1/terminals/assign/${pathId(subAccountId)}`, { body: params });
|
|
37
49
|
}
|
|
38
|
-
/**
|
|
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
|
+
*/
|
|
39
56
|
unassignFromParent(params) {
|
|
40
57
|
return this.http.request("POST", "/v1/terminals/unassign", {
|
|
41
58
|
body: params,
|
|
42
59
|
});
|
|
43
60
|
}
|
|
44
|
-
/**
|
|
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
|
+
*/
|
|
45
68
|
async unassignFromSubAccount(subAccountId, params) {
|
|
46
69
|
return this.http.request("POST", `/v1/terminals/unassign/${pathId(subAccountId)}`, { body: params });
|
|
47
70
|
}
|
|
48
71
|
/**
|
|
49
|
-
* POST /v1/terminals/payment-request/{terminalId}
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
*
|
|
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.
|
|
54
82
|
*/
|
|
55
83
|
async pushPaymentRequest(terminalId, params, options = {}) {
|
|
56
|
-
return settle(this.http, "POST", `/v1/terminals/payment-request/${pathId(terminalId)}`, { body: params }, PAYMENT_REQUEST_OUTCOMES, params.merchantTxRef, options);
|
|
84
|
+
return settle(this.http, "POST", `/v1/terminals/payment-request/${pathId(terminalId)}`, { body: params }, PAYMENT_REQUEST_OUTCOMES, { field: "merchantTxRef", value: params.merchantTxRef }, options);
|
|
57
85
|
}
|
|
58
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
|
}
|
|
@@ -14,18 +14,28 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { paginate } from "../../../lib/paginate.js";
|
|
16
16
|
import { pageQuery, pathId } from "../../../lib/util.js";
|
|
17
|
+
/** Transactions (v1): list and filter transactions on parent, sub, and virtual accounts. */
|
|
17
18
|
export class TransactionsService {
|
|
18
19
|
http;
|
|
19
20
|
constructor(http) {
|
|
20
21
|
this.http = http;
|
|
21
22
|
}
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* `GET /v1/transactions/bank`. Lists credit and debit transactions on the parent account.
|
|
25
|
+
* @param params Pagination options (`cursor`, `limit`).
|
|
26
|
+
* @returns One page of bank transactions.
|
|
27
|
+
* @throws {NombaError} The call failed.
|
|
28
|
+
*/
|
|
23
29
|
listBankTransactions(params = {}) {
|
|
24
30
|
return this.http.request("GET", "/v1/transactions/bank", {
|
|
25
31
|
query: pageQuery(params),
|
|
26
32
|
});
|
|
27
33
|
}
|
|
28
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* Iterates over every credit/debit transaction on the parent account, across all pages.
|
|
36
|
+
* @param params Starting pagination options.
|
|
37
|
+
* @throws {NombaError} A page request failed.
|
|
38
|
+
*/
|
|
29
39
|
iterateBankTransactions(params = {}) {
|
|
30
40
|
return paginate(async (cursor) => {
|
|
31
41
|
const page = await this.listBankTransactions(cursor ? { ...params, cursor } : params);
|
|
@@ -33,62 +43,110 @@ export class TransactionsService {
|
|
|
33
43
|
});
|
|
34
44
|
}
|
|
35
45
|
/**
|
|
36
|
-
* GET /v1/transactions/virtual
|
|
37
|
-
*
|
|
46
|
+
* `GET /v1/transactions/virtual`. Lists transactions on a virtual account.
|
|
47
|
+
* Note: The response carries a cursor, but the API docs do not name a paging parameter,
|
|
48
|
+
* so only the first page is returned.
|
|
49
|
+
* @param params The virtual account number and optional date range.
|
|
50
|
+
* @returns One page of virtual account transactions.
|
|
51
|
+
* @throws {NombaError} The call failed, e.g. `accountNumber` does not exist.
|
|
38
52
|
*/
|
|
39
53
|
listVirtualAccountTransactions({ accountNumber, ...dates }) {
|
|
40
54
|
return this.http.request("GET", "/v1/transactions/virtual", {
|
|
41
55
|
query: { virtual_account: accountNumber, ...dates },
|
|
42
56
|
});
|
|
43
57
|
}
|
|
44
|
-
/**
|
|
58
|
+
/**
|
|
59
|
+
* `GET /v1/transactions/accounts`. Lists transactions on the parent account.
|
|
60
|
+
* @param params Pagination options (`cursor`, `limit`).
|
|
61
|
+
* @returns One page of transactions.
|
|
62
|
+
* @throws {NombaError} The call failed.
|
|
63
|
+
*/
|
|
45
64
|
listParentTransactions(params = {}) {
|
|
46
65
|
return this.http.request("GET", "/v1/transactions/accounts", {
|
|
47
66
|
query: pageQuery(params),
|
|
48
67
|
});
|
|
49
68
|
}
|
|
50
|
-
/**
|
|
69
|
+
/**
|
|
70
|
+
* Iterates over every transaction on the parent account, across all pages.
|
|
71
|
+
* @param params Starting pagination options.
|
|
72
|
+
* @throws {NombaError} A page request failed.
|
|
73
|
+
*/
|
|
51
74
|
iterateParentTransactions(params = {}) {
|
|
52
75
|
return paginate(async (cursor) => {
|
|
53
76
|
const page = await this.listParentTransactions(cursor ? { ...params, cursor } : params);
|
|
54
77
|
return { results: page.results ?? [], cursor: page.cursor ?? "" };
|
|
55
78
|
});
|
|
56
79
|
}
|
|
57
|
-
/**
|
|
80
|
+
/**
|
|
81
|
+
* `GET /v1/transactions/accounts/{subAccountId}`. Lists transactions on a sub account.
|
|
82
|
+
* @param subAccountId The sub account's ID.
|
|
83
|
+
* @param params Pagination options (`cursor`, `limit`).
|
|
84
|
+
* @returns One page of transactions.
|
|
85
|
+
* @throws {NombaError} The call failed, e.g. `subAccountId` does not exist.
|
|
86
|
+
*/
|
|
58
87
|
async listSubAccountTransactions(subAccountId, params = {}) {
|
|
59
88
|
return this.http.request("GET", `/v1/transactions/accounts/${pathId(subAccountId)}`, {
|
|
60
89
|
query: pageQuery(params),
|
|
61
90
|
});
|
|
62
91
|
}
|
|
63
|
-
/**
|
|
92
|
+
/**
|
|
93
|
+
* Iterates over every transaction on a sub account, across all pages.
|
|
94
|
+
* @param subAccountId The sub account's ID.
|
|
95
|
+
* @param params Starting pagination options.
|
|
96
|
+
* @throws {NombaError} A page request failed, e.g. `subAccountId` does not exist.
|
|
97
|
+
*/
|
|
64
98
|
iterateSubAccountTransactions(subAccountId, params = {}) {
|
|
65
99
|
return paginate(async (cursor) => {
|
|
66
100
|
const page = await this.listSubAccountTransactions(subAccountId, cursor ? { ...params, cursor } : params);
|
|
67
101
|
return { results: page.results ?? [], cursor: page.cursor ?? "" };
|
|
68
102
|
});
|
|
69
103
|
}
|
|
70
|
-
/**
|
|
104
|
+
/**
|
|
105
|
+
* `POST /v1/transactions/accounts`. Filters transactions on the parent account by criteria.
|
|
106
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
107
|
+
* @param page Pagination options (`cursor`, `limit`).
|
|
108
|
+
* @returns One page of matching transactions.
|
|
109
|
+
* @throws {NombaError} The call failed.
|
|
110
|
+
*/
|
|
71
111
|
filterParentTransactions(filter = {}, page = {}) {
|
|
72
112
|
return this.http.request("POST", "/v1/transactions/accounts", {
|
|
73
113
|
body: filter,
|
|
74
114
|
query: pageQuery(page),
|
|
75
115
|
});
|
|
76
116
|
}
|
|
77
|
-
/**
|
|
117
|
+
/**
|
|
118
|
+
* Iterates over every parent account transaction matching the filter, across all pages.
|
|
119
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
120
|
+
* @param page Starting pagination options.
|
|
121
|
+
* @throws {NombaError} A page request failed.
|
|
122
|
+
*/
|
|
78
123
|
iterateFilteredParentTransactions(filter = {}, page = {}) {
|
|
79
124
|
return paginate(async (cursor) => {
|
|
80
125
|
const p = await this.filterParentTransactions(filter, cursor ? { ...page, cursor } : page);
|
|
81
126
|
return { results: p.results ?? [], cursor: p.cursor ?? "" };
|
|
82
127
|
});
|
|
83
128
|
}
|
|
84
|
-
/**
|
|
129
|
+
/**
|
|
130
|
+
* `POST /v1/transactions/accounts/{subAccountId}`. Filters transactions on a sub account by criteria.
|
|
131
|
+
* @param subAccountId The sub account's ID.
|
|
132
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
133
|
+
* @param page Pagination options (`cursor`, `limit`).
|
|
134
|
+
* @returns One page of matching transactions.
|
|
135
|
+
* @throws {NombaError} The call failed, e.g. `subAccountId` does not exist.
|
|
136
|
+
*/
|
|
85
137
|
async filterSubAccountTransactions(subAccountId, filter = {}, page = {}) {
|
|
86
138
|
return this.http.request("POST", `/v1/transactions/accounts/${pathId(subAccountId)}`, {
|
|
87
139
|
body: filter,
|
|
88
140
|
query: pageQuery(page),
|
|
89
141
|
});
|
|
90
142
|
}
|
|
91
|
-
/**
|
|
143
|
+
/**
|
|
144
|
+
* Iterates over every sub account transaction matching the filter, across all pages.
|
|
145
|
+
* @param subAccountId The sub account's ID.
|
|
146
|
+
* @param filter Filter criteria (e.g., `dateFrom`, `dateTo`, `transactionType`).
|
|
147
|
+
* @param page Starting pagination options.
|
|
148
|
+
* @throws {NombaError} A page request failed, e.g. `subAccountId` does not exist.
|
|
149
|
+
*/
|
|
92
150
|
iterateFilteredSubAccountTransactions(subAccountId, filter = {}, page = {}) {
|
|
93
151
|
return paginate(async (cursor) => {
|
|
94
152
|
const p = await this.filterSubAccountTransactions(subAccountId, filter, cursor ? { ...page, cursor } : page);
|