@nomba/node-sdk 0.1.0 → 0.3.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 +31 -4
- 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 +20 -5
- package/dist/interfaces/v1/globals/payouts/IGlobalPayoutService.d.ts +74 -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/outcome.d.ts +24 -5
- package/dist/lib/outcome.js +24 -5
- package/dist/lib/sdk-version.generated.d.ts +1 -1
- package/dist/lib/sdk-version.generated.js +1 -1
- 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 +40 -6
- 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 +11 -2
- package/dist/services/v1/betting/betting.service.js +11 -2
- package/dist/services/v1/cable/cable.service.d.ts +12 -2
- package/dist/services/v1/cable/cable.service.js +12 -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 +21 -5
- package/dist/services/v1/globals/collections.service.js +22 -5
- package/dist/services/v1/globals/payout.service.d.ts +73 -13
- package/dist/services/v1/globals/payout.service.js +74 -15
- package/dist/services/v1/terminals/terminals.service.d.ts +5 -5
- package/dist/services/v1/terminals/terminals.service.js +7 -18
- package/dist/services/v1/virtual-accounts/virtual-accounts.service.d.ts +4 -5
- package/dist/services/v1/virtual-accounts/virtual-accounts.service.js +7 -8
- package/dist/services/v1/webhooks/webhooks.service.d.ts +3 -4
- package/dist/services/v1/webhooks/webhooks.service.js +7 -8
- 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 +9 -13
- package/package.json +1 -1
|
@@ -12,58 +12,80 @@
|
|
|
12
12
|
* @docs https://developer.nomba.com
|
|
13
13
|
* @see https://developer.nomba.com/docs/api-reference/direct-debits
|
|
14
14
|
*/
|
|
15
|
+
/** Direct debit mandates (v1): create, inspect, debit, and update recurring mandates. */
|
|
15
16
|
export class DirectDebitsService {
|
|
16
17
|
http;
|
|
17
18
|
constructor(http) {
|
|
18
19
|
this.http = http;
|
|
19
20
|
}
|
|
20
21
|
/**
|
|
21
|
-
* POST /v1/direct-debits
|
|
22
|
+
* `POST /v1/direct-debits`.
|
|
22
23
|
* ponytail: this endpoint's response envelope is `{ responseCode, responseMessage, data }`, unlike every
|
|
23
24
|
* other endpoint's `{ code, description, data }` — confirmed from the spec's own example, not guessed.
|
|
25
|
+
* @param params The mandate to create; `merchantReference` is the idempotency key.
|
|
26
|
+
* @returns The created mandate.
|
|
27
|
+
* @throws {NombaError} The mandate params were rejected.
|
|
28
|
+
* @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
|
|
29
|
+
* check the mandate status before retrying.
|
|
24
30
|
*/
|
|
25
|
-
createMandate(params
|
|
31
|
+
createMandate(params) {
|
|
26
32
|
return this.http.request("POST", "/v1/direct-debits", {
|
|
27
33
|
body: params,
|
|
28
34
|
codeField: "responseCode",
|
|
29
35
|
descriptionField: "responseMessage",
|
|
30
|
-
|
|
31
|
-
idempotencyKey: options.idempotencyKey ?? params.merchantReference,
|
|
36
|
+
idempotencyKey: params.merchantReference,
|
|
32
37
|
});
|
|
33
38
|
}
|
|
34
|
-
/**
|
|
39
|
+
/**
|
|
40
|
+
* `GET /v1/direct-debits/status?mandateId={mandateId}`.
|
|
41
|
+
* @param mandateId The mandate to look up.
|
|
42
|
+
* @returns The mandate's current status.
|
|
43
|
+
* @throws {NombaError} `mandateId` is not found, or the request failed.
|
|
44
|
+
*/
|
|
35
45
|
getMandateStatus(mandateId) {
|
|
36
46
|
return this.http.request("GET", "/v1/direct-debits/status", {
|
|
37
47
|
query: { mandateId },
|
|
38
48
|
});
|
|
39
49
|
}
|
|
40
50
|
/**
|
|
41
|
-
* POST /v1/direct-debits/debit-mandate
|
|
42
|
-
*
|
|
43
|
-
*
|
|
44
|
-
*
|
|
51
|
+
* `POST /v1/direct-debits/debit-mandate`. No per-transaction reference field exists in params, so a
|
|
52
|
+
* random idempotency key is generated for error tracking. If the outcome is unknown, requery the mandate
|
|
53
|
+
* before retrying.
|
|
54
|
+
* @param params The mandate to debit and the amount.
|
|
55
|
+
* @returns The debit result.
|
|
56
|
+
* @throws {NombaError} The mandate is not active, or the debit was rejected.
|
|
57
|
+
* @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
|
|
58
|
+
* check the mandate status before retrying.
|
|
45
59
|
*/
|
|
46
|
-
debitMandate(params
|
|
60
|
+
debitMandate(params) {
|
|
47
61
|
return this.http.request("POST", "/v1/direct-debits/debit-mandate", {
|
|
48
62
|
body: params,
|
|
49
|
-
...options,
|
|
50
63
|
});
|
|
51
64
|
}
|
|
52
|
-
/**
|
|
65
|
+
/**
|
|
66
|
+
* `GET /v1/direct-debits/mandates`.
|
|
67
|
+
* @param params Pagination and filter params.
|
|
68
|
+
* @returns A page of mandates.
|
|
69
|
+
* @throws {NombaError} The request failed.
|
|
70
|
+
*/
|
|
53
71
|
listMandates(params) {
|
|
54
72
|
return this.http.request("GET", "/v1/direct-debits/mandates", {
|
|
55
73
|
query: params,
|
|
56
74
|
});
|
|
57
75
|
}
|
|
58
76
|
/**
|
|
59
|
-
* PUT /v1/direct-debits/update-status
|
|
60
|
-
*
|
|
61
|
-
*
|
|
77
|
+
* `PUT /v1/direct-debits/update-status`. No per-change reference field exists in params, so a random
|
|
78
|
+
* idempotency key is generated for error tracking. If the outcome is unknown, check the mandate status
|
|
79
|
+
* before retrying.
|
|
80
|
+
* @param params The mandate and the new status.
|
|
81
|
+
* @returns The mandate's updated status.
|
|
82
|
+
* @throws {NombaError} The status transition is invalid, or the request failed.
|
|
83
|
+
* @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
|
|
84
|
+
* check the mandate status before retrying.
|
|
62
85
|
*/
|
|
63
|
-
updateMandateStatus(params
|
|
86
|
+
updateMandateStatus(params) {
|
|
64
87
|
return this.http.request("PUT", "/v1/direct-debits/update-status", {
|
|
65
88
|
body: params,
|
|
66
|
-
...options,
|
|
67
89
|
});
|
|
68
90
|
}
|
|
69
91
|
}
|
|
@@ -6,11 +6,21 @@
|
|
|
6
6
|
import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
|
|
7
7
|
import type { IElectricityService } from "../../../interfaces/v1/electricity/index.js";
|
|
8
8
|
import type { ElectricityProvidersResult, MeterLookupParams, MeterLookupResult } from "../../../types/v1/electricity/electricity.types.js";
|
|
9
|
+
/** Electricity bill lookup (v1): disco listing and meter lookup, no payment endpoint. */
|
|
9
10
|
export declare class ElectricityService implements IElectricityService {
|
|
10
11
|
private readonly http;
|
|
11
12
|
constructor(http: IHttpClient);
|
|
12
|
-
/**
|
|
13
|
+
/**
|
|
14
|
+
* `GET /v1/bill/electricity/discos`.
|
|
15
|
+
* @returns The electricity distribution companies (discos) available for meter lookup.
|
|
16
|
+
* @throws {NombaError} The request failed.
|
|
17
|
+
*/
|
|
13
18
|
getElectricityProviders(): Promise<ElectricityProvidersResult>;
|
|
14
|
-
/**
|
|
19
|
+
/**
|
|
20
|
+
* `GET /v1/bill/electricity/lookup`.
|
|
21
|
+
* @param params The disco and meter number to look up.
|
|
22
|
+
* @returns The meter's customer details.
|
|
23
|
+
* @throws {NombaError} The meter number is invalid or not found, or the request failed.
|
|
24
|
+
*/
|
|
15
25
|
lookupMeter(params: MeterLookupParams): Promise<MeterLookupResult>;
|
|
16
26
|
}
|
|
@@ -3,16 +3,26 @@
|
|
|
3
3
|
* @description Electricity (v1): GET /v1/bill/electricity/discos, GET /v1/bill/electricity/lookup
|
|
4
4
|
* @see https://developer.nomba.com/docs/api-reference/bills
|
|
5
5
|
*/
|
|
6
|
+
/** Electricity bill lookup (v1): disco listing and meter lookup, no payment endpoint. */
|
|
6
7
|
export class ElectricityService {
|
|
7
8
|
http;
|
|
8
9
|
constructor(http) {
|
|
9
10
|
this.http = http;
|
|
10
11
|
}
|
|
11
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* `GET /v1/bill/electricity/discos`.
|
|
14
|
+
* @returns The electricity distribution companies (discos) available for meter lookup.
|
|
15
|
+
* @throws {NombaError} The request failed.
|
|
16
|
+
*/
|
|
12
17
|
getElectricityProviders() {
|
|
13
18
|
return this.http.request("GET", "/v1/bill/electricity/discos");
|
|
14
19
|
}
|
|
15
|
-
/**
|
|
20
|
+
/**
|
|
21
|
+
* `GET /v1/bill/electricity/lookup`.
|
|
22
|
+
* @param params The disco and meter number to look up.
|
|
23
|
+
* @returns The meter's customer details.
|
|
24
|
+
* @throws {NombaError} The meter number is invalid or not found, or the request failed.
|
|
25
|
+
*/
|
|
16
26
|
lookupMeter(params) {
|
|
17
27
|
return this.http.request("GET", "/v1/bill/electricity/lookup", {
|
|
18
28
|
query: params,
|
|
@@ -14,15 +14,31 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
|
|
16
16
|
import type { IGlobalCollectionsService } from "../../../interfaces/v1/globals/collections/IGlobalCollectionsService.js";
|
|
17
|
-
import type { RequestOptions } from "../../../types/common/common.types.js";
|
|
18
17
|
import type { CollectionTransaction, InflowProvider, InflowResult, InitiateInflowParams } from "../../../types/v1/globals/collections.types.js";
|
|
18
|
+
/** Global Collections (v1): DRC mobile money inflows. */
|
|
19
19
|
export declare class GlobalCollectionsService implements IGlobalCollectionsService {
|
|
20
20
|
private readonly http;
|
|
21
21
|
constructor(http: IHttpClient);
|
|
22
|
-
/**
|
|
22
|
+
/**
|
|
23
|
+
* `GET /v1/global-collection/drc/inflow/providers`.
|
|
24
|
+
* @returns The mobile money providers available for DRC inflows.
|
|
25
|
+
* @throws {NombaError} The request failed.
|
|
26
|
+
*/
|
|
23
27
|
inflowProviders(): Promise<InflowProvider[]>;
|
|
24
|
-
/**
|
|
25
|
-
|
|
26
|
-
|
|
28
|
+
/**
|
|
29
|
+
* `POST /v1/global-collection/inflow/initiate`. Prompts the customer to approve the charge on their phone.
|
|
30
|
+
* @param params The inflow to initiate; `idempotencyKey` defaults to a generated one.
|
|
31
|
+
* @returns The initiated inflow, including its `transactionReference`.
|
|
32
|
+
* @throws {NombaError} The inflow params were rejected.
|
|
33
|
+
* @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
|
|
34
|
+
* check the transaction status before retrying.
|
|
35
|
+
*/
|
|
36
|
+
initiateInflow(params: InitiateInflowParams): Promise<InflowResult>;
|
|
37
|
+
/**
|
|
38
|
+
* `GET /v1/global-collection/transactions/{transactionId}`, with the `transactionReference` from `initiateInflow`.
|
|
39
|
+
* @param transactionId The transaction reference to look up.
|
|
40
|
+
* @returns The transaction's current state.
|
|
41
|
+
* @throws {NombaError} `transactionId` is not found, or the request failed.
|
|
42
|
+
*/
|
|
27
43
|
getTransaction(transactionId: string): Promise<CollectionTransaction>;
|
|
28
44
|
}
|
|
@@ -14,24 +14,41 @@
|
|
|
14
14
|
*/
|
|
15
15
|
import { randomUUID } from "node:crypto";
|
|
16
16
|
import { pathId } from "../../../lib/util.js";
|
|
17
|
+
/** Global Collections (v1): DRC mobile money inflows. */
|
|
17
18
|
export class GlobalCollectionsService {
|
|
18
19
|
http;
|
|
19
20
|
constructor(http) {
|
|
20
21
|
this.http = http;
|
|
21
22
|
}
|
|
22
|
-
/**
|
|
23
|
+
/**
|
|
24
|
+
* `GET /v1/global-collection/drc/inflow/providers`.
|
|
25
|
+
* @returns The mobile money providers available for DRC inflows.
|
|
26
|
+
* @throws {NombaError} The request failed.
|
|
27
|
+
*/
|
|
23
28
|
inflowProviders() {
|
|
24
29
|
return this.http.request("GET", "/v1/global-collection/drc/inflow/providers");
|
|
25
30
|
}
|
|
26
|
-
/**
|
|
27
|
-
|
|
28
|
-
|
|
31
|
+
/**
|
|
32
|
+
* `POST /v1/global-collection/inflow/initiate`. Prompts the customer to approve the charge on their phone.
|
|
33
|
+
* @param params The inflow to initiate; `idempotencyKey` defaults to a generated one.
|
|
34
|
+
* @returns The initiated inflow, including its `transactionReference`.
|
|
35
|
+
* @throws {NombaError} The inflow params were rejected.
|
|
36
|
+
* @throws {OutcomeUnknownError} The call failed in a way that does not say whether it was processed;
|
|
37
|
+
* check the transaction status before retrying.
|
|
38
|
+
*/
|
|
39
|
+
initiateInflow(params) {
|
|
40
|
+
const idempotencyKey = params.idempotencyKey || randomUUID();
|
|
29
41
|
return this.http.request("POST", "/v1/global-collection/inflow/initiate", {
|
|
30
42
|
body: { ...params, idempotencyKey },
|
|
31
43
|
idempotencyKey,
|
|
32
44
|
});
|
|
33
45
|
}
|
|
34
|
-
/**
|
|
46
|
+
/**
|
|
47
|
+
* `GET /v1/global-collection/transactions/{transactionId}`, with the `transactionReference` from `initiateInflow`.
|
|
48
|
+
* @param transactionId The transaction reference to look up.
|
|
49
|
+
* @returns The transaction's current state.
|
|
50
|
+
* @throws {NombaError} `transactionId` is not found, or the request failed.
|
|
51
|
+
*/
|
|
35
52
|
async getTransaction(transactionId) {
|
|
36
53
|
return this.http.request("GET", `/v1/global-collection/transactions/${pathId(transactionId)}`);
|
|
37
54
|
}
|
|
@@ -14,32 +14,92 @@
|
|
|
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; `idempotencyKey` defaults to a generated one.
|
|
81
|
+
* @param options Per-call overrides, including `okCodes`/`onOutcome` via `CallOptions`.
|
|
82
|
+
* @returns The settled payout result (or the type `options` maps it to).
|
|
83
|
+
* @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 instead).
|
|
86
|
+
*/
|
|
40
87
|
authorizeTransfer<R = PayoutResult>(params: AuthorizeTransferParams, options?: CallOptions<PayoutResult, R>): Promise<PayoutResult | R>;
|
|
41
|
-
/**
|
|
88
|
+
/**
|
|
89
|
+
* `POST /v1/global-payout/exchange/authorize`. Moves money between your own wallets in different currencies.
|
|
90
|
+
* @param params The exchange to authorize; `idempotencyKey` defaults to a generated one.
|
|
91
|
+
* @param options Per-call overrides, including `okCodes`/`onOutcome` via `CallOptions`.
|
|
92
|
+
* @returns The settled payout result (or the type `options` maps it to).
|
|
93
|
+
* @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 instead).
|
|
96
|
+
*/
|
|
42
97
|
authorizeExchange<R = PayoutResult>(params: AuthorizeExchangeParams, options?: CallOptions<PayoutResult, R>): Promise<PayoutResult | R>;
|
|
43
|
-
/**
|
|
98
|
+
/**
|
|
99
|
+
* `GET /v1/global-payout/transactions/{transactionId}`, with a `wtTransactionId`.
|
|
100
|
+
* @param transactionId The transaction to look up.
|
|
101
|
+
* @returns The transaction's current state.
|
|
102
|
+
* @throws {NombaError} `transactionId` is not found, or the request failed.
|
|
103
|
+
*/
|
|
44
104
|
getTransaction(transactionId: string): Promise<PayoutTransaction>;
|
|
45
105
|
}
|
|
@@ -30,66 +30,125 @@ 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; `idempotencyKey` defaults to a generated one.
|
|
119
|
+
* @param options Per-call overrides, including `okCodes`/`onOutcome` via `CallOptions`.
|
|
120
|
+
* @returns The settled payout result (or the type `options` maps it to).
|
|
121
|
+
* @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 instead).
|
|
124
|
+
*/
|
|
79
125
|
async authorizeTransfer(params, options = {}) {
|
|
80
126
|
return this.#authorize("/v1/global-payout/transfer/authorize", params, options, TRANSFER_OUTCOMES);
|
|
81
127
|
}
|
|
82
|
-
/**
|
|
128
|
+
/**
|
|
129
|
+
* `POST /v1/global-payout/exchange/authorize`. Moves money between your own wallets in different currencies.
|
|
130
|
+
* @param params The exchange to authorize; `idempotencyKey` defaults to a generated one.
|
|
131
|
+
* @param options Per-call overrides, including `okCodes`/`onOutcome` via `CallOptions`.
|
|
132
|
+
* @returns The settled payout result (or the type `options` maps it to).
|
|
133
|
+
* @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 instead).
|
|
136
|
+
*/
|
|
83
137
|
async authorizeExchange(params, options = {}) {
|
|
84
138
|
return this.#authorize("/v1/global-payout/exchange/authorize", params, options, EXCHANGE_OUTCOMES);
|
|
85
139
|
}
|
|
86
|
-
/**
|
|
140
|
+
/**
|
|
141
|
+
* `GET /v1/global-payout/transactions/{transactionId}`, with a `wtTransactionId`.
|
|
142
|
+
* @param transactionId The transaction to look up.
|
|
143
|
+
* @returns The transaction's current state.
|
|
144
|
+
* @throws {NombaError} `transactionId` is not found, or the request failed.
|
|
145
|
+
*/
|
|
87
146
|
async getTransaction(transactionId) {
|
|
88
147
|
return this.http.request("GET", `/v1/global-payout/transactions/${pathId(transactionId)}`);
|
|
89
148
|
}
|
|
90
149
|
// One key in the body (the one the API dedupes on) and the header, so OutcomeUnknownError reports it.
|
|
91
150
|
#authorize(path, params, options, table) {
|
|
92
|
-
const idempotencyKey = params.idempotencyKey ||
|
|
93
|
-
return settle(this.http, "POST", path, { body: { ...params, idempotencyKey } }, table,
|
|
151
|
+
const idempotencyKey = params.idempotencyKey || randomUUID();
|
|
152
|
+
return settle(this.http, "POST", path, { body: { ...params, idempotencyKey } }, table, idempotencyKey, options);
|
|
94
153
|
}
|
|
95
154
|
}
|
|
@@ -14,19 +14,19 @@
|
|
|
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
19
|
export declare class TerminalsService implements ITerminalsService {
|
|
20
20
|
private readonly http;
|
|
21
21
|
constructor(http: IHttpClient);
|
|
22
22
|
/** POST /v1/terminals/assign */
|
|
23
|
-
assignToParent(params: AssignTerminalParams
|
|
23
|
+
assignToParent(params: AssignTerminalParams): Promise<Terminal>;
|
|
24
24
|
/** POST /v1/terminals/assign/{subAccountId} */
|
|
25
|
-
assignToSubAccount(subAccountId: string, params: AssignTerminalParams
|
|
25
|
+
assignToSubAccount(subAccountId: string, params: AssignTerminalParams): Promise<Terminal>;
|
|
26
26
|
/** POST /v1/terminals/unassign */
|
|
27
|
-
unassignFromParent(params: AssignTerminalParams
|
|
27
|
+
unassignFromParent(params: AssignTerminalParams): Promise<Terminal>;
|
|
28
28
|
/** POST /v1/terminals/unassign/{subAccountId} */
|
|
29
|
-
unassignFromSubAccount(subAccountId: string, params: AssignTerminalParams
|
|
29
|
+
unassignFromSubAccount(subAccountId: string, params: AssignTerminalParams): Promise<Terminal>;
|
|
30
30
|
/**
|
|
31
31
|
* POST /v1/terminals/payment-request/{terminalId}. Triggers a payment prompt on the physical terminal.
|
|
32
32
|
* ponytail: the spec lists no accountId header for this endpoint, unlike every other one; sent anyway
|
|
@@ -26,32 +26,24 @@ export class TerminalsService {
|
|
|
26
26
|
this.http = http;
|
|
27
27
|
}
|
|
28
28
|
/** POST /v1/terminals/assign */
|
|
29
|
-
assignToParent(params
|
|
29
|
+
assignToParent(params) {
|
|
30
30
|
return this.http.request("POST", "/v1/terminals/assign", {
|
|
31
31
|
body: params,
|
|
32
|
-
...options,
|
|
33
32
|
});
|
|
34
33
|
}
|
|
35
34
|
/** POST /v1/terminals/assign/{subAccountId} */
|
|
36
|
-
async assignToSubAccount(subAccountId, params
|
|
37
|
-
return this.http.request("POST", `/v1/terminals/assign/${pathId(subAccountId)}`, {
|
|
38
|
-
body: params,
|
|
39
|
-
...options,
|
|
40
|
-
});
|
|
35
|
+
async assignToSubAccount(subAccountId, params) {
|
|
36
|
+
return this.http.request("POST", `/v1/terminals/assign/${pathId(subAccountId)}`, { body: params });
|
|
41
37
|
}
|
|
42
38
|
/** POST /v1/terminals/unassign */
|
|
43
|
-
unassignFromParent(params
|
|
39
|
+
unassignFromParent(params) {
|
|
44
40
|
return this.http.request("POST", "/v1/terminals/unassign", {
|
|
45
41
|
body: params,
|
|
46
|
-
...options,
|
|
47
42
|
});
|
|
48
43
|
}
|
|
49
44
|
/** POST /v1/terminals/unassign/{subAccountId} */
|
|
50
|
-
async unassignFromSubAccount(subAccountId, params
|
|
51
|
-
return this.http.request("POST", `/v1/terminals/unassign/${pathId(subAccountId)}`, {
|
|
52
|
-
body: params,
|
|
53
|
-
...options,
|
|
54
|
-
});
|
|
45
|
+
async unassignFromSubAccount(subAccountId, params) {
|
|
46
|
+
return this.http.request("POST", `/v1/terminals/unassign/${pathId(subAccountId)}`, { body: params });
|
|
55
47
|
}
|
|
56
48
|
/**
|
|
57
49
|
* POST /v1/terminals/payment-request/{terminalId}. Triggers a payment prompt on the physical terminal.
|
|
@@ -61,9 +53,6 @@ export class TerminalsService {
|
|
|
61
53
|
* re-prompt the terminal.
|
|
62
54
|
*/
|
|
63
55
|
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
|
-
});
|
|
56
|
+
return settle(this.http, "POST", `/v1/terminals/payment-request/${pathId(terminalId)}`, { body: params }, PAYMENT_REQUEST_OUTCOMES, params.merchantTxRef, options);
|
|
68
57
|
}
|
|
69
58
|
}
|
|
@@ -15,23 +15,22 @@
|
|
|
15
15
|
import type { IHttpClient } from "../../../interfaces/http/IHttpClient.js";
|
|
16
16
|
import type { IVirtualAccountsService } from "../../../interfaces/v1/virtual-accounts/IVirtualAccountsService.js";
|
|
17
17
|
import type { PageParams } from "../../../lib/util.js";
|
|
18
|
-
import type { RequestOptions } from "../../../types/common/common.types.js";
|
|
19
18
|
import type { CreatedVirtualAccount, CreateVirtualAccountParams, FilterVirtualAccountsParams, UpdateVirtualAccountParams, VirtualAccount, VirtualAccountList } from "../../../types/v1/virtual-accounts/virtual-accounts.types.js";
|
|
20
19
|
export declare class VirtualAccountsService implements IVirtualAccountsService {
|
|
21
20
|
private readonly http;
|
|
22
21
|
constructor(http: IHttpClient);
|
|
23
22
|
/** POST /v1/accounts/virtual */
|
|
24
|
-
create(params: CreateVirtualAccountParams
|
|
23
|
+
create(params: CreateVirtualAccountParams): Promise<CreatedVirtualAccount>;
|
|
25
24
|
/** POST /v1/accounts/virtual/{subAccountId}. Funds are collected in that sub account. */
|
|
26
|
-
createForSubAccount(subAccountId: string, params: CreateVirtualAccountParams
|
|
25
|
+
createForSubAccount(subAccountId: string, params: CreateVirtualAccountParams): Promise<CreatedVirtualAccount>;
|
|
27
26
|
/** GET /v1/accounts/virtual/{identifier}. `identifier` is the accountRef or the virtual account number. */
|
|
28
27
|
get(identifier: string): Promise<VirtualAccount>;
|
|
29
28
|
/** PUT /v1/accounts/virtual/{identifier}. `identifier` is the accountRef or the 10 digit account number. */
|
|
30
|
-
update(identifier: string, params: UpdateVirtualAccountParams
|
|
29
|
+
update(identifier: string, params: UpdateVirtualAccountParams): Promise<{
|
|
31
30
|
updated: boolean;
|
|
32
31
|
}>;
|
|
33
32
|
/** DELETE /v1/accounts/virtual/{identifier}. Stops the account accepting payments. */
|
|
34
|
-
expire(identifier: string
|
|
33
|
+
expire(identifier: string): Promise<{
|
|
35
34
|
expired: boolean;
|
|
36
35
|
}>;
|
|
37
36
|
/** POST /v1/accounts/virtual/list */
|
|
@@ -20,27 +20,26 @@ export class VirtualAccountsService {
|
|
|
20
20
|
this.http = http;
|
|
21
21
|
}
|
|
22
22
|
/** POST /v1/accounts/virtual */
|
|
23
|
-
create(params
|
|
23
|
+
create(params) {
|
|
24
24
|
return this.http.request("POST", "/v1/accounts/virtual", {
|
|
25
25
|
body: params,
|
|
26
|
-
...options,
|
|
27
26
|
});
|
|
28
27
|
}
|
|
29
28
|
/** POST /v1/accounts/virtual/{subAccountId}. Funds are collected in that sub account. */
|
|
30
|
-
async createForSubAccount(subAccountId, params
|
|
31
|
-
return this.http.request("POST", `/v1/accounts/virtual/${pathId(subAccountId)}`, { body: params
|
|
29
|
+
async createForSubAccount(subAccountId, params) {
|
|
30
|
+
return this.http.request("POST", `/v1/accounts/virtual/${pathId(subAccountId)}`, { body: params });
|
|
32
31
|
}
|
|
33
32
|
/** GET /v1/accounts/virtual/{identifier}. `identifier` is the accountRef or the virtual account number. */
|
|
34
33
|
async get(identifier) {
|
|
35
34
|
return this.http.request("GET", `/v1/accounts/virtual/${pathId(identifier)}`);
|
|
36
35
|
}
|
|
37
36
|
/** PUT /v1/accounts/virtual/{identifier}. `identifier` is the accountRef or the 10 digit account number. */
|
|
38
|
-
async update(identifier, params
|
|
39
|
-
return this.http.request("PUT", `/v1/accounts/virtual/${pathId(identifier)}`, { body: params
|
|
37
|
+
async update(identifier, params) {
|
|
38
|
+
return this.http.request("PUT", `/v1/accounts/virtual/${pathId(identifier)}`, { body: params });
|
|
40
39
|
}
|
|
41
40
|
/** DELETE /v1/accounts/virtual/{identifier}. Stops the account accepting payments. */
|
|
42
|
-
async expire(identifier
|
|
43
|
-
return this.http.request("DELETE", `/v1/accounts/virtual/${pathId(identifier)}
|
|
41
|
+
async expire(identifier) {
|
|
42
|
+
return this.http.request("DELETE", `/v1/accounts/virtual/${pathId(identifier)}`);
|
|
44
43
|
}
|
|
45
44
|
/** POST /v1/accounts/virtual/list */
|
|
46
45
|
list(filter = {}, page = {}) {
|