@lukadriel/wave-sdk 0.0.0-stage → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +30 -0
- package/LICENSE +201 -0
- package/NOTICE +2 -0
- package/README.md +523 -2
- package/dist/client/wave-client-options.d.ts +29 -0
- package/dist/client/wave-client-options.d.ts.map +1 -0
- package/dist/client/wave-client-options.js +58 -0
- package/dist/client/wave-client-options.js.map +1 -0
- package/dist/client/wave-client.d.ts +47 -0
- package/dist/client/wave-client.d.ts.map +1 -0
- package/dist/client/wave-client.js +66 -0
- package/dist/client/wave-client.js.map +1 -0
- package/dist/core/auth/authentication.d.ts +8 -0
- package/dist/core/auth/authentication.d.ts.map +1 -0
- package/dist/core/auth/authentication.js +10 -0
- package/dist/core/auth/authentication.js.map +1 -0
- package/dist/core/auth/request-signer.d.ts +26 -0
- package/dist/core/auth/request-signer.d.ts.map +1 -0
- package/dist/core/auth/request-signer.js +39 -0
- package/dist/core/auth/request-signer.js.map +1 -0
- package/dist/core/errors/error-parser.d.ts +25 -0
- package/dist/core/errors/error-parser.d.ts.map +1 -0
- package/dist/core/errors/error-parser.js +198 -0
- package/dist/core/errors/error-parser.js.map +1 -0
- package/dist/core/errors/redact.d.ts +11 -0
- package/dist/core/errors/redact.d.ts.map +1 -0
- package/dist/core/errors/redact.js +20 -0
- package/dist/core/errors/redact.js.map +1 -0
- package/dist/core/errors/wave-api-error.d.ts +116 -0
- package/dist/core/errors/wave-api-error.d.ts.map +1 -0
- package/dist/core/errors/wave-api-error.js +114 -0
- package/dist/core/errors/wave-api-error.js.map +1 -0
- package/dist/core/errors/wave-error.d.ts +27 -0
- package/dist/core/errors/wave-error.d.ts.map +1 -0
- package/dist/core/errors/wave-error.js +22 -0
- package/dist/core/errors/wave-error.js.map +1 -0
- package/dist/core/errors/wave-network-error.d.ts +24 -0
- package/dist/core/errors/wave-network-error.d.ts.map +1 -0
- package/dist/core/errors/wave-network-error.js +24 -0
- package/dist/core/errors/wave-network-error.js.map +1 -0
- package/dist/core/errors/wave-webhook-verification-error.d.ts +18 -0
- package/dist/core/errors/wave-webhook-verification-error.d.ts.map +1 -0
- package/dist/core/errors/wave-webhook-verification-error.js +17 -0
- package/dist/core/errors/wave-webhook-verification-error.js.map +1 -0
- package/dist/core/http/fetch-transport.d.ts +23 -0
- package/dist/core/http/fetch-transport.d.ts.map +1 -0
- package/dist/core/http/fetch-transport.js +34 -0
- package/dist/core/http/fetch-transport.js.map +1 -0
- package/dist/core/http/http-client.d.ts +57 -0
- package/dist/core/http/http-client.d.ts.map +1 -0
- package/dist/core/http/http-client.js +254 -0
- package/dist/core/http/http-client.js.map +1 -0
- package/dist/core/http/http-request.d.ts +35 -0
- package/dist/core/http/http-request.d.ts.map +1 -0
- package/dist/core/http/http-request.js +2 -0
- package/dist/core/http/http-request.js.map +1 -0
- package/dist/core/http/http-response.d.ts +26 -0
- package/dist/core/http/http-response.d.ts.map +1 -0
- package/dist/core/http/http-response.js +23 -0
- package/dist/core/http/http-response.js.map +1 -0
- package/dist/core/http/query.d.ts +14 -0
- package/dist/core/http/query.d.ts.map +1 -0
- package/dist/core/http/query.js +23 -0
- package/dist/core/http/query.js.map +1 -0
- package/dist/core/http/transport.d.ts +44 -0
- package/dist/core/http/transport.d.ts.map +1 -0
- package/dist/core/http/transport.js +2 -0
- package/dist/core/http/transport.js.map +1 -0
- package/dist/core/idempotency/idempotency.d.ts +16 -0
- package/dist/core/idempotency/idempotency.d.ts.map +1 -0
- package/dist/core/idempotency/idempotency.js +27 -0
- package/dist/core/idempotency/idempotency.js.map +1 -0
- package/dist/core/retry/backoff.d.ts +18 -0
- package/dist/core/retry/backoff.d.ts.map +1 -0
- package/dist/core/retry/backoff.js +46 -0
- package/dist/core/retry/backoff.js.map +1 -0
- package/dist/core/retry/retry-policy.d.ts +43 -0
- package/dist/core/retry/retry-policy.d.ts.map +1 -0
- package/dist/core/retry/retry-policy.js +90 -0
- package/dist/core/retry/retry-policy.js.map +1 -0
- package/dist/core/types/common.d.ts +59 -0
- package/dist/core/types/common.d.ts.map +1 -0
- package/dist/core/types/common.js +2 -0
- package/dist/core/types/common.js.map +1 -0
- package/dist/core/types/configuration.d.ts +82 -0
- package/dist/core/types/configuration.d.ts.map +1 -0
- package/dist/core/types/configuration.js +2 -0
- package/dist/core/types/configuration.js.map +1 -0
- package/dist/core/types/json.d.ts +15 -0
- package/dist/core/types/json.d.ts.map +1 -0
- package/dist/core/types/json.js +2 -0
- package/dist/core/types/json.js.map +1 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +24 -0
- package/dist/index.js.map +1 -0
- package/dist/resources/aggregated-merchants/aggregated-merchant-types.d.ts +82 -0
- package/dist/resources/aggregated-merchants/aggregated-merchant-types.d.ts.map +1 -0
- package/dist/resources/aggregated-merchants/aggregated-merchant-types.js +2 -0
- package/dist/resources/aggregated-merchants/aggregated-merchant-types.js.map +1 -0
- package/dist/resources/aggregated-merchants/aggregated-merchants.d.ts +67 -0
- package/dist/resources/aggregated-merchants/aggregated-merchants.d.ts.map +1 -0
- package/dist/resources/aggregated-merchants/aggregated-merchants.js +111 -0
- package/dist/resources/aggregated-merchants/aggregated-merchants.js.map +1 -0
- package/dist/resources/balance/balance-types.d.ts +18 -0
- package/dist/resources/balance/balance-types.d.ts.map +1 -0
- package/dist/resources/balance/balance-types.js +2 -0
- package/dist/resources/balance/balance-types.js.map +1 -0
- package/dist/resources/balance/balance.d.ts +20 -0
- package/dist/resources/balance/balance.d.ts.map +1 -0
- package/dist/resources/balance/balance.js +28 -0
- package/dist/resources/balance/balance.js.map +1 -0
- package/dist/resources/checkout/checkout-types.d.ts +96 -0
- package/dist/resources/checkout/checkout-types.d.ts.map +1 -0
- package/dist/resources/checkout/checkout-types.js +2 -0
- package/dist/resources/checkout/checkout-types.js.map +1 -0
- package/dist/resources/checkout/checkout.d.ts +66 -0
- package/dist/resources/checkout/checkout.d.ts.map +1 -0
- package/dist/resources/checkout/checkout.js +95 -0
- package/dist/resources/checkout/checkout.js.map +1 -0
- package/dist/resources/payout-batches/payout-batches.d.ts +31 -0
- package/dist/resources/payout-batches/payout-batches.d.ts.map +1 -0
- package/dist/resources/payout-batches/payout-batches.js +36 -0
- package/dist/resources/payout-batches/payout-batches.js.map +1 -0
- package/dist/resources/payouts/payout-types.d.ts +158 -0
- package/dist/resources/payouts/payout-types.d.ts.map +1 -0
- package/dist/resources/payouts/payout-types.js +2 -0
- package/dist/resources/payouts/payout-types.js.map +1 -0
- package/dist/resources/payouts/payouts.d.ts +63 -0
- package/dist/resources/payouts/payouts.d.ts.map +1 -0
- package/dist/resources/payouts/payouts.js +80 -0
- package/dist/resources/payouts/payouts.js.map +1 -0
- package/dist/resources/reconciliation/reconciliation-types.d.ts +86 -0
- package/dist/resources/reconciliation/reconciliation-types.d.ts.map +1 -0
- package/dist/resources/reconciliation/reconciliation-types.js +2 -0
- package/dist/resources/reconciliation/reconciliation-types.js.map +1 -0
- package/dist/resources/reconciliation/reconciliation.d.ts +41 -0
- package/dist/resources/reconciliation/reconciliation.d.ts.map +1 -0
- package/dist/resources/reconciliation/reconciliation.js +81 -0
- package/dist/resources/reconciliation/reconciliation.js.map +1 -0
- package/dist/resources/webhooks/webhook-types.d.ts +159 -0
- package/dist/resources/webhooks/webhook-types.d.ts.map +1 -0
- package/dist/resources/webhooks/webhook-types.js +36 -0
- package/dist/resources/webhooks/webhook-types.js.map +1 -0
- package/dist/resources/webhooks/webhook-verifier.d.ts +104 -0
- package/dist/resources/webhooks/webhook-verifier.d.ts.map +1 -0
- package/dist/resources/webhooks/webhook-verifier.js +188 -0
- package/dist/resources/webhooks/webhook-verifier.js.map +1 -0
- package/package.json +70 -4
- package/src/client/wave-client-options.ts +91 -0
- package/src/client/wave-client.ts +70 -0
- package/src/core/auth/authentication.ts +9 -0
- package/src/core/auth/request-signer.ts +42 -0
- package/src/core/errors/error-parser.ts +258 -0
- package/src/core/errors/redact.ts +20 -0
- package/src/core/errors/wave-api-error.ts +148 -0
- package/src/core/errors/wave-error.ts +32 -0
- package/src/core/errors/wave-network-error.ts +24 -0
- package/src/core/errors/wave-webhook-verification-error.ts +28 -0
- package/src/core/http/fetch-transport.ts +48 -0
- package/src/core/http/http-client.ts +352 -0
- package/src/core/http/http-request.ts +37 -0
- package/src/core/http/http-response.ts +37 -0
- package/src/core/http/query.ts +31 -0
- package/src/core/http/transport.ts +45 -0
- package/src/core/idempotency/idempotency.ts +31 -0
- package/src/core/retry/backoff.ts +61 -0
- package/src/core/retry/retry-policy.ts +106 -0
- package/src/core/types/common.ts +65 -0
- package/src/core/types/configuration.ts +85 -0
- package/src/core/types/json.ts +16 -0
- package/src/index.ts +146 -0
- package/src/resources/aggregated-merchants/aggregated-merchant-types.ts +87 -0
- package/src/resources/aggregated-merchants/aggregated-merchants.ts +171 -0
- package/src/resources/balance/balance-types.ts +19 -0
- package/src/resources/balance/balance.ts +39 -0
- package/src/resources/checkout/checkout-types.ts +102 -0
- package/src/resources/checkout/checkout.ts +144 -0
- package/src/resources/payout-batches/payout-batches.ts +58 -0
- package/src/resources/payouts/payout-types.ts +171 -0
- package/src/resources/payouts/payouts.ts +120 -0
- package/src/resources/reconciliation/reconciliation-types.ts +102 -0
- package/src/resources/reconciliation/reconciliation.ts +116 -0
- package/src/resources/webhooks/webhook-types.ts +222 -0
- package/src/resources/webhooks/webhook-verifier.ts +297 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
import type { Amount, CurrencyCode, PhoneNumber, Timestamp } from '../../core/types/common.js';
|
|
2
|
+
/**
|
|
3
|
+
* Documented payout states.
|
|
4
|
+
*
|
|
5
|
+
* - `processing`: submitted, execution in progress.
|
|
6
|
+
* - `succeeded`: money reached the recipient.
|
|
7
|
+
* - `failed`: execution failed; inspect `payout_error`.
|
|
8
|
+
* - `reversed`: the payout was reversed.
|
|
9
|
+
*/
|
|
10
|
+
export type PayoutStatus = 'processing' | 'succeeded' | 'failed' | 'reversed';
|
|
11
|
+
/**
|
|
12
|
+
* Failure details attached to an individual payout.
|
|
13
|
+
*
|
|
14
|
+
* Wave uses this both for failed payouts and for payouts that fail inside a batch.
|
|
15
|
+
*/
|
|
16
|
+
export interface PayoutError {
|
|
17
|
+
/** Machine-readable error code; see the Payout API error list. */
|
|
18
|
+
readonly error_code: string;
|
|
19
|
+
/** Human-readable description, when provided. */
|
|
20
|
+
readonly error_message?: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Request body for `POST /v1/payout`.
|
|
24
|
+
*/
|
|
25
|
+
export interface CreatePayoutRequest {
|
|
26
|
+
/** Currency of the payout; the business wallet and recipient must be in the same country. */
|
|
27
|
+
readonly currency: CurrencyCode;
|
|
28
|
+
/** Amount paid to the recipient, net of fees. Payout amounts must be whole numbers. */
|
|
29
|
+
readonly receive_amount: Amount;
|
|
30
|
+
/** Recipient phone number in E.164 format. */
|
|
31
|
+
readonly mobile: PhoneNumber;
|
|
32
|
+
/** Recipient name, up to 255 characters; may be used for verification. */
|
|
33
|
+
readonly name?: string;
|
|
34
|
+
/** Recipient national ID, up to 255 characters. */
|
|
35
|
+
readonly national_id?: string;
|
|
36
|
+
/** Payment reason shown to the customer, up to 40 characters. */
|
|
37
|
+
readonly payment_reason?: string;
|
|
38
|
+
/** Caller correlation string, up to 255 characters. */
|
|
39
|
+
readonly client_reference?: string;
|
|
40
|
+
/** Aggregated merchant identity; only available to permitted aggregators. */
|
|
41
|
+
readonly aggregated_merchant_id?: string;
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A payout object returned by the Payout API.
|
|
45
|
+
*/
|
|
46
|
+
export interface Payout {
|
|
47
|
+
/** Unique payout identifier, up to 20 characters. */
|
|
48
|
+
readonly id: string;
|
|
49
|
+
/** Payout currency. */
|
|
50
|
+
readonly currency: CurrencyCode;
|
|
51
|
+
/** Amount paid to the recipient, net of fees. */
|
|
52
|
+
readonly receive_amount: Amount;
|
|
53
|
+
/** Fee charged for the payout. */
|
|
54
|
+
readonly fee: Amount;
|
|
55
|
+
/** Recipient phone number in E.164 format. */
|
|
56
|
+
readonly mobile: PhoneNumber;
|
|
57
|
+
/** Current payout state. */
|
|
58
|
+
readonly status: PayoutStatus;
|
|
59
|
+
/** When the payout request was recorded (not when the money moved). */
|
|
60
|
+
readonly timestamp: Timestamp;
|
|
61
|
+
/** Recipient name, when provided. */
|
|
62
|
+
readonly name?: string;
|
|
63
|
+
/** Recipient national ID, when provided. */
|
|
64
|
+
readonly national_id?: string;
|
|
65
|
+
/** Caller correlation string, when provided. */
|
|
66
|
+
readonly client_reference?: string;
|
|
67
|
+
/** Payment reason, when provided. */
|
|
68
|
+
readonly payment_reason?: string;
|
|
69
|
+
/** Aggregated merchant identity used for this payout, when applicable. */
|
|
70
|
+
readonly aggregated_merchant_id?: string;
|
|
71
|
+
/** Failure details; only populated when `status` is `failed`. */
|
|
72
|
+
readonly payout_error?: PayoutError;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Query parameters for `GET /v1/payouts/search`.
|
|
76
|
+
*
|
|
77
|
+
* The Payout API currently documents search by client reference only.
|
|
78
|
+
*/
|
|
79
|
+
export interface SearchPayoutsQuery {
|
|
80
|
+
/** Caller correlation string to search for. */
|
|
81
|
+
readonly client_reference: string;
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Response body of `GET /v1/payouts/search`.
|
|
85
|
+
*/
|
|
86
|
+
export interface SearchPayoutsResponse {
|
|
87
|
+
/** Matching payouts; empty when nothing matches. */
|
|
88
|
+
readonly result: readonly Payout[];
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Request body for `POST /v1/payout-batch`.
|
|
92
|
+
*/
|
|
93
|
+
export interface CreatePayoutBatchRequest {
|
|
94
|
+
/** Payouts to send; each item uses the single-payout request shape. */
|
|
95
|
+
readonly payouts: readonly CreatePayoutRequest[];
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Response body of `POST /v1/payout-batch`.
|
|
99
|
+
*/
|
|
100
|
+
export interface CreatePayoutBatchResponse {
|
|
101
|
+
/** Batch identifier used to poll the retrieve endpoint. */
|
|
102
|
+
readonly id: string;
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Documented payout batch states.
|
|
106
|
+
*
|
|
107
|
+
* Batches have no success/failure status of their own; inspect each payout's `payout_error`.
|
|
108
|
+
*/
|
|
109
|
+
export type PayoutBatchStatus = 'processing' | 'complete';
|
|
110
|
+
/**
|
|
111
|
+
* A payout batch returned by `GET /v1/payout-batch/:id`.
|
|
112
|
+
*/
|
|
113
|
+
export interface PayoutBatch {
|
|
114
|
+
/** Batch identifier. */
|
|
115
|
+
readonly id: string;
|
|
116
|
+
/** Batch state. */
|
|
117
|
+
readonly status: PayoutBatchStatus;
|
|
118
|
+
/** Payouts in the batch, each with the single-payout response shape. */
|
|
119
|
+
readonly payouts: readonly Payout[];
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Outcome of comparing a provided name with Wave's records.
|
|
123
|
+
*/
|
|
124
|
+
export type NameMatch = 'MATCH' | 'NO_MATCH' | 'NAME_NOT_KNOWN';
|
|
125
|
+
/**
|
|
126
|
+
* Outcome of comparing a provided national ID with Wave's records.
|
|
127
|
+
*/
|
|
128
|
+
export type NationalIdMatch = 'MATCH' | 'NO_MATCH' | 'ID_NOT_KNOWN';
|
|
129
|
+
/**
|
|
130
|
+
* Request body for the restricted `POST /v1/verify_recipient/` endpoint.
|
|
131
|
+
*
|
|
132
|
+
* This endpoint is disabled by default and enabled case by case for businesses with a documented
|
|
133
|
+
* compliance justification; it returns HTTP 403 without access.
|
|
134
|
+
*/
|
|
135
|
+
export interface VerifyRecipientRequest {
|
|
136
|
+
/** Recipient phone number in E.164 format. */
|
|
137
|
+
readonly mobile: PhoneNumber;
|
|
138
|
+
/** Name to compare with Wave's records. */
|
|
139
|
+
readonly name?: string;
|
|
140
|
+
/** National ID to compare with Wave's records. */
|
|
141
|
+
readonly national_id?: string;
|
|
142
|
+
/** Hypothetical amount, used to check balance and inflow limits. */
|
|
143
|
+
readonly amount?: Amount;
|
|
144
|
+
/** Currency of the hypothetical amount. */
|
|
145
|
+
readonly currency?: CurrencyCode;
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Response body of `POST /v1/verify_recipient/`.
|
|
149
|
+
*/
|
|
150
|
+
export interface RecipientVerification {
|
|
151
|
+
/** Whether the payout is likely to succeed; `null` when amount and currency were not provided. */
|
|
152
|
+
readonly within_limits: boolean | null;
|
|
153
|
+
/** Name comparison result; `null` when no name was provided. */
|
|
154
|
+
readonly name_match: NameMatch | null;
|
|
155
|
+
/** National ID comparison result; only included when ID verification is enabled. */
|
|
156
|
+
readonly national_id_match?: NationalIdMatch | null;
|
|
157
|
+
}
|
|
158
|
+
//# sourceMappingURL=payout-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payout-types.d.ts","sourceRoot":"","sources":["../../../src/resources/payouts/payout-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAE/F;;;;;;;GAOG;AACH,MAAM,MAAM,YAAY,GAAG,YAAY,GAAG,WAAW,GAAG,QAAQ,GAAG,UAAU,CAAC;AAE9E;;;;GAIG;AACH,MAAM,WAAW,WAAW;IAC1B,kEAAkE;IAClE,QAAQ,CAAC,UAAU,EAAE,MAAM,CAAC;IAC5B,iDAAiD;IACjD,QAAQ,CAAC,aAAa,CAAC,EAAE,MAAM,CAAC;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,6FAA6F;IAC7F,QAAQ,CAAC,QAAQ,EAAE,YAAY,CAAC;IAChC,uFAAuF;IACvF,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,8CAA8C;IAC9C,QAAQ,CAAC,MAAM,EAAE,WAA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EG;AACH,MAAM,WAAW,qBAAqB;IACpC,kGAAkG;IAClG,QAAQ,CAAC,aAAa,EAAE,OAAO,GAAG,IAAI,CAAC;IACvC,gEAAgE;IAChE,QAAQ,CAAC,UAAU,EAAE,SAAS,GAAG,IAAI,CAAC;IACtC,oFAAoF;IACpF,QAAQ,CAAC,iBAAiB,CAAC,EAAE,eAAe,GAAG,IAAI,CAAC;CACrD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payout-types.js","sourceRoot":"","sources":["../../../src/resources/payouts/payout-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Amount, CurrencyCode, PhoneNumber, Timestamp } from '../../core/types/common.js';\n\n/**\n * Documented payout states.\n *\n * - `processing`: submitted, execution in progress.\n * - `succeeded`: money reached the recipient.\n * - `failed`: execution failed; inspect `payout_error`.\n * - `reversed`: the payout was reversed.\n */\nexport type PayoutStatus = 'processing' | 'succeeded' | 'failed' | 'reversed';\n\n/**\n * Failure details attached to an individual payout.\n *\n * Wave uses this both for failed payouts and for payouts that fail inside a batch.\n */\nexport interface PayoutError {\n /** Machine-readable error code; see the Payout API error list. */\n readonly error_code: string;\n /** Human-readable description, when provided. */\n readonly error_message?: string;\n}\n\n/**\n * Request body for `POST /v1/payout`.\n */\nexport interface CreatePayoutRequest {\n /** Currency of the payout; the business wallet and recipient must be in the same country. */\n readonly currency: CurrencyCode;\n /** Amount paid to the recipient, net of fees. Payout amounts must be whole numbers. */\n readonly receive_amount: Amount;\n /** Recipient phone number in E.164 format. */\n readonly mobile: PhoneNumber;\n /** Recipient name, up to 255 characters; may be used for verification. */\n readonly name?: string;\n /** Recipient national ID, up to 255 characters. */\n readonly national_id?: string;\n /** Payment reason shown to the customer, up to 40 characters. */\n readonly payment_reason?: string;\n /** Caller correlation string, up to 255 characters. */\n readonly client_reference?: string;\n /** Aggregated merchant identity; only available to permitted aggregators. */\n readonly aggregated_merchant_id?: string;\n}\n\n/**\n * A payout object returned by the Payout API.\n */\nexport interface Payout {\n /** Unique payout identifier, up to 20 characters. */\n readonly id: string;\n /** Payout currency. */\n readonly currency: CurrencyCode;\n /** Amount paid to the recipient, net of fees. */\n readonly receive_amount: Amount;\n /** Fee charged for the payout. */\n readonly fee: Amount;\n /** Recipient phone number in E.164 format. */\n readonly mobile: PhoneNumber;\n /** Current payout state. */\n readonly status: PayoutStatus;\n /** When the payout request was recorded (not when the money moved). */\n readonly timestamp: Timestamp;\n /** Recipient name, when provided. */\n readonly name?: string;\n /** Recipient national ID, when provided. */\n readonly national_id?: string;\n /** Caller correlation string, when provided. */\n readonly client_reference?: string;\n /** Payment reason, when provided. */\n readonly payment_reason?: string;\n /** Aggregated merchant identity used for this payout, when applicable. */\n readonly aggregated_merchant_id?: string;\n /** Failure details; only populated when `status` is `failed`. */\n readonly payout_error?: PayoutError;\n}\n\n/**\n * Query parameters for `GET /v1/payouts/search`.\n *\n * The Payout API currently documents search by client reference only.\n */\nexport interface SearchPayoutsQuery {\n /** Caller correlation string to search for. */\n readonly client_reference: string;\n}\n\n/**\n * Response body of `GET /v1/payouts/search`.\n */\nexport interface SearchPayoutsResponse {\n /** Matching payouts; empty when nothing matches. */\n readonly result: readonly Payout[];\n}\n\n/**\n * Request body for `POST /v1/payout-batch`.\n */\nexport interface CreatePayoutBatchRequest {\n /** Payouts to send; each item uses the single-payout request shape. */\n readonly payouts: readonly CreatePayoutRequest[];\n}\n\n/**\n * Response body of `POST /v1/payout-batch`.\n */\nexport interface CreatePayoutBatchResponse {\n /** Batch identifier used to poll the retrieve endpoint. */\n readonly id: string;\n}\n\n/**\n * Documented payout batch states.\n *\n * Batches have no success/failure status of their own; inspect each payout's `payout_error`.\n */\nexport type PayoutBatchStatus = 'processing' | 'complete';\n\n/**\n * A payout batch returned by `GET /v1/payout-batch/:id`.\n */\nexport interface PayoutBatch {\n /** Batch identifier. */\n readonly id: string;\n /** Batch state. */\n readonly status: PayoutBatchStatus;\n /** Payouts in the batch, each with the single-payout response shape. */\n readonly payouts: readonly Payout[];\n}\n\n/**\n * Outcome of comparing a provided name with Wave's records.\n */\nexport type NameMatch = 'MATCH' | 'NO_MATCH' | 'NAME_NOT_KNOWN';\n\n/**\n * Outcome of comparing a provided national ID with Wave's records.\n */\nexport type NationalIdMatch = 'MATCH' | 'NO_MATCH' | 'ID_NOT_KNOWN';\n\n/**\n * Request body for the restricted `POST /v1/verify_recipient/` endpoint.\n *\n * This endpoint is disabled by default and enabled case by case for businesses with a documented\n * compliance justification; it returns HTTP 403 without access.\n */\nexport interface VerifyRecipientRequest {\n /** Recipient phone number in E.164 format. */\n readonly mobile: PhoneNumber;\n /** Name to compare with Wave's records. */\n readonly name?: string;\n /** National ID to compare with Wave's records. */\n readonly national_id?: string;\n /** Hypothetical amount, used to check balance and inflow limits. */\n readonly amount?: Amount;\n /** Currency of the hypothetical amount. */\n readonly currency?: CurrencyCode;\n}\n\n/**\n * Response body of `POST /v1/verify_recipient/`.\n */\nexport interface RecipientVerification {\n /** Whether the payout is likely to succeed; `null` when amount and currency were not provided. */\n readonly within_limits: boolean | null;\n /** Name comparison result; `null` when no name was provided. */\n readonly name_match: NameMatch | null;\n /** National ID comparison result; only included when ID verification is enabled. */\n readonly national_id_match?: NationalIdMatch | null;\n}\n"]}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import type { HttpClient } from '../../core/http/http-client.js';
|
|
2
|
+
import type { RequestOptions } from '../../core/types/configuration.js';
|
|
3
|
+
import type { CreatePayoutRequest, Payout, RecipientVerification, SearchPayoutsQuery, SearchPayoutsResponse, VerifyRecipientRequest } from './payout-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Payout API operations.
|
|
6
|
+
*/
|
|
7
|
+
export declare class PayoutsResource {
|
|
8
|
+
#private;
|
|
9
|
+
/** @param http - Shared HTTP pipeline. */
|
|
10
|
+
constructor(http: HttpClient);
|
|
11
|
+
/**
|
|
12
|
+
* Sends a payout synchronously.
|
|
13
|
+
*
|
|
14
|
+
* A generated `Idempotency-Key` is reused for every retry of this call, so a transport failure
|
|
15
|
+
* cannot create a duplicate payout.
|
|
16
|
+
*
|
|
17
|
+
* A payout can fail in two documented ways: an HTTP error response, or a `Payout` whose
|
|
18
|
+
* `payout_error` field is populated.
|
|
19
|
+
*
|
|
20
|
+
* @param request - Payout details.
|
|
21
|
+
* @param options - Per-request overrides.
|
|
22
|
+
* @returns The created payout.
|
|
23
|
+
*/
|
|
24
|
+
create(request: CreatePayoutRequest, options?: RequestOptions): Promise<Payout>;
|
|
25
|
+
/**
|
|
26
|
+
* Retrieves a single payout by identifier.
|
|
27
|
+
*
|
|
28
|
+
* @param payoutId - Payout identifier starting with `pt-`.
|
|
29
|
+
* @param options - Per-request overrides.
|
|
30
|
+
* @returns The payout.
|
|
31
|
+
*/
|
|
32
|
+
retrieve(payoutId: string, options?: RequestOptions): Promise<Payout>;
|
|
33
|
+
/**
|
|
34
|
+
* Searches payouts by client reference.
|
|
35
|
+
*
|
|
36
|
+
* @param query - Search criteria; only `client_reference` is documented.
|
|
37
|
+
* @param options - Per-request overrides.
|
|
38
|
+
* @returns Matching payouts; the array is empty when nothing matches.
|
|
39
|
+
*/
|
|
40
|
+
search(query: SearchPayoutsQuery, options?: RequestOptions): Promise<SearchPayoutsResponse>;
|
|
41
|
+
/**
|
|
42
|
+
* Reverses a previously executed payout, including fees.
|
|
43
|
+
*
|
|
44
|
+
* Wave allows reversal within three days of creation. The endpoint is idempotent: reversing an
|
|
45
|
+
* already reversed payout succeeds without creating another transaction.
|
|
46
|
+
*
|
|
47
|
+
* @param payoutId - Payout identifier starting with `pt-`.
|
|
48
|
+
* @param options - Per-request overrides.
|
|
49
|
+
*/
|
|
50
|
+
reverse(payoutId: string, options?: RequestOptions): Promise<void>;
|
|
51
|
+
/**
|
|
52
|
+
* Verifies payout recipient details before sending money.
|
|
53
|
+
*
|
|
54
|
+
* This endpoint is restricted: it is disabled by default and returns HTTP 403 unless Wave has
|
|
55
|
+
* enabled it for your business. Payouts to unregistered numbers still succeed without it.
|
|
56
|
+
*
|
|
57
|
+
* @param request - Recipient details to check.
|
|
58
|
+
* @param options - Per-request overrides.
|
|
59
|
+
* @returns The documented verification result.
|
|
60
|
+
*/
|
|
61
|
+
verifyRecipient(request: VerifyRecipientRequest, options?: RequestOptions): Promise<RecipientVerification>;
|
|
62
|
+
}
|
|
63
|
+
//# sourceMappingURL=payouts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payouts.d.ts","sourceRoot":"","sources":["../../../src/resources/payouts/payouts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AACjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EACV,mBAAmB,EACnB,MAAM,EACN,qBAAqB,EACrB,kBAAkB,EAClB,qBAAqB,EACrB,sBAAsB,EACvB,MAAM,mBAAmB,CAAC;AAO3B;;GAEG;AACH,qBAAa,eAAe;;IAG1B,0CAA0C;gBAC9B,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,OAAO,EAAE,mBAAmB,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAQnF;;;;;;OAMG;IACH,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,MAAM,CAAC;IAQzE;;;;;;OAMG;IACH,MAAM,CAAC,KAAK,EAAE,kBAAkB,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,qBAAqB,CAAC;IAY/F;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;IAQtE;;;;;;;;;OASG;IACH,eAAe,CACb,OAAO,EAAE,sBAAsB,EAC/B,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,qBAAqB,CAAC;CAOlC"}
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
const CREATE_PAYOUT = { idempotent: true, requiresIdempotencyKey: true };
|
|
2
|
+
const GET_PAYOUT = { idempotent: true, requiresIdempotencyKey: false };
|
|
3
|
+
const REVERSE_PAYOUT = { idempotent: true, requiresIdempotencyKey: true };
|
|
4
|
+
const VERIFY_RECIPIENT = { idempotent: true, requiresIdempotencyKey: false };
|
|
5
|
+
/**
|
|
6
|
+
* Payout API operations.
|
|
7
|
+
*/
|
|
8
|
+
export class PayoutsResource {
|
|
9
|
+
#http;
|
|
10
|
+
/** @param http - Shared HTTP pipeline. */
|
|
11
|
+
constructor(http) {
|
|
12
|
+
this.#http = http;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Sends a payout synchronously.
|
|
16
|
+
*
|
|
17
|
+
* A generated `Idempotency-Key` is reused for every retry of this call, so a transport failure
|
|
18
|
+
* cannot create a duplicate payout.
|
|
19
|
+
*
|
|
20
|
+
* A payout can fail in two documented ways: an HTTP error response, or a `Payout` whose
|
|
21
|
+
* `payout_error` field is populated.
|
|
22
|
+
*
|
|
23
|
+
* @param request - Payout details.
|
|
24
|
+
* @param options - Per-request overrides.
|
|
25
|
+
* @returns The created payout.
|
|
26
|
+
*/
|
|
27
|
+
create(request, options = {}) {
|
|
28
|
+
return this.#http.request(CREATE_PAYOUT, { method: 'POST', path: '/v1/payout', body: request }, options);
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Retrieves a single payout by identifier.
|
|
32
|
+
*
|
|
33
|
+
* @param payoutId - Payout identifier starting with `pt-`.
|
|
34
|
+
* @param options - Per-request overrides.
|
|
35
|
+
* @returns The payout.
|
|
36
|
+
*/
|
|
37
|
+
retrieve(payoutId, options = {}) {
|
|
38
|
+
return this.#http.request(GET_PAYOUT, { method: 'GET', path: `/v1/payout/${encodeURIComponent(payoutId)}` }, options);
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Searches payouts by client reference.
|
|
42
|
+
*
|
|
43
|
+
* @param query - Search criteria; only `client_reference` is documented.
|
|
44
|
+
* @param options - Per-request overrides.
|
|
45
|
+
* @returns Matching payouts; the array is empty when nothing matches.
|
|
46
|
+
*/
|
|
47
|
+
search(query, options = {}) {
|
|
48
|
+
return this.#http.request(GET_PAYOUT, {
|
|
49
|
+
method: 'GET',
|
|
50
|
+
path: '/v1/payouts/search',
|
|
51
|
+
query: { client_reference: query.client_reference },
|
|
52
|
+
}, options);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Reverses a previously executed payout, including fees.
|
|
56
|
+
*
|
|
57
|
+
* Wave allows reversal within three days of creation. The endpoint is idempotent: reversing an
|
|
58
|
+
* already reversed payout succeeds without creating another transaction.
|
|
59
|
+
*
|
|
60
|
+
* @param payoutId - Payout identifier starting with `pt-`.
|
|
61
|
+
* @param options - Per-request overrides.
|
|
62
|
+
*/
|
|
63
|
+
reverse(payoutId, options = {}) {
|
|
64
|
+
return this.#http.requestVoid(REVERSE_PAYOUT, { method: 'POST', path: `/v1/payout/${encodeURIComponent(payoutId)}/reverse` }, options);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Verifies payout recipient details before sending money.
|
|
68
|
+
*
|
|
69
|
+
* This endpoint is restricted: it is disabled by default and returns HTTP 403 unless Wave has
|
|
70
|
+
* enabled it for your business. Payouts to unregistered numbers still succeed without it.
|
|
71
|
+
*
|
|
72
|
+
* @param request - Recipient details to check.
|
|
73
|
+
* @param options - Per-request overrides.
|
|
74
|
+
* @returns The documented verification result.
|
|
75
|
+
*/
|
|
76
|
+
verifyRecipient(request, options = {}) {
|
|
77
|
+
return this.#http.request(VERIFY_RECIPIENT, { method: 'POST', path: '/v1/verify_recipient/', body: request }, options);
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
//# sourceMappingURL=payouts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payouts.js","sourceRoot":"","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AK,CAAC,gBAAgB,EAAE;SACpD,EACD,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;;;;OAQG;IACH,OAAO,CAAC,QAAgB,EAAE,UAA0B,EAAE;QACpD,OAAO,IAAI,CAAC,KAAK,CAAC,WAAW,CAC3B,cAAc,EACd,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,cAAc,kBAAkB,CAAC,QAAQ,CAAC,UAAU,EAAE,EAC9E,OAAO,CACR,CAAC;IACJ,CAAC;IAED;;;;;;;;;OASG;IACH,eAAe,CACb,OAA+B,EAC/B,UAA0B,EAAE;QAE5B,OAAO,IAAI,CAAC,KAAK,CAAC,OAAO,CACvB,gBAAgB,EAChB,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,uBAAuB,EAAE,IAAI,EAAE,OAAO,EAAE,EAChE,OAAO,CACR,CAAC;IACJ,CAAC;CACF","sourcesContent":["import type { HttpClient } from '../../core/http/http-client.js';\nimport type { RequestOptions } from '../../core/types/configuration.js';\nimport type {\n CreatePayoutRequest,\n Payout,\n RecipientVerification,\n SearchPayoutsQuery,\n SearchPayoutsResponse,\n VerifyRecipientRequest,\n} from './payout-types.js';\n\nconst CREATE_PAYOUT = { idempotent: true, requiresIdempotencyKey: true } as const;\nconst GET_PAYOUT = { idempotent: true, requiresIdempotencyKey: false } as const;\nconst REVERSE_PAYOUT = { idempotent: true, requiresIdempotencyKey: true } as const;\nconst VERIFY_RECIPIENT = { idempotent: true, requiresIdempotencyKey: false } as const;\n\n/**\n * Payout API operations.\n */\nexport class PayoutsResource {\n readonly #http: HttpClient;\n\n /** @param http - Shared HTTP pipeline. */\n constructor(http: HttpClient) {\n this.#http = http;\n }\n\n /**\n * Sends a payout synchronously.\n *\n * A generated `Idempotency-Key` is reused for every retry of this call, so a transport failure\n * cannot create a duplicate payout.\n *\n * A payout can fail in two documented ways: an HTTP error response, or a `Payout` whose\n * `payout_error` field is populated.\n *\n * @param request - Payout details.\n * @param options - Per-request overrides.\n * @returns The created payout.\n */\n create(request: CreatePayoutRequest, options: RequestOptions = {}): Promise<Payout> {\n return this.#http.request<Payout>(\n CREATE_PAYOUT,\n { method: 'POST', path: '/v1/payout', body: request },\n options,\n );\n }\n\n /**\n * Retrieves a single payout by identifier.\n *\n * @param payoutId - Payout identifier starting with `pt-`.\n * @param options - Per-request overrides.\n * @returns The payout.\n */\n retrieve(payoutId: string, options: RequestOptions = {}): Promise<Payout> {\n return this.#http.request<Payout>(\n GET_PAYOUT,\n { method: 'GET', path: `/v1/payout/${encodeURIComponent(payoutId)}` },\n options,\n );\n }\n\n /**\n * Searches payouts by client reference.\n *\n * @param query - Search criteria; only `client_reference` is documented.\n * @param options - Per-request overrides.\n * @returns Matching payouts; the array is empty when nothing matches.\n */\n search(query: SearchPayoutsQuery, options: RequestOptions = {}): Promise<SearchPayoutsResponse> {\n return this.#http.request<SearchPayoutsResponse>(\n GET_PAYOUT,\n {\n method: 'GET',\n path: '/v1/payouts/search',\n query: { client_reference: query.client_reference },\n },\n options,\n );\n }\n\n /**\n * Reverses a previously executed payout, including fees.\n *\n * Wave allows reversal within three days of creation. The endpoint is idempotent: reversing an\n * already reversed payout succeeds without creating another transaction.\n *\n * @param payoutId - Payout identifier starting with `pt-`.\n * @param options - Per-request overrides.\n */\n reverse(payoutId: string, options: RequestOptions = {}): Promise<void> {\n return this.#http.requestVoid(\n REVERSE_PAYOUT,\n { method: 'POST', path: `/v1/payout/${encodeURIComponent(payoutId)}/reverse` },\n options,\n );\n }\n\n /**\n * Verifies payout recipient details before sending money.\n *\n * This endpoint is restricted: it is disabled by default and returns HTTP 403 unless Wave has\n * enabled it for your business. Payouts to unregistered numbers still succeed without it.\n *\n * @param request - Recipient details to check.\n * @param options - Per-request overrides.\n * @returns The documented verification result.\n */\n verifyRecipient(\n request: VerifyRecipientRequest,\n options: RequestOptions = {},\n ): Promise<RecipientVerification> {\n return this.#http.request<RecipientVerification>(\n VERIFY_RECIPIENT,\n { method: 'POST', path: '/v1/verify_recipient/', body: request },\n options,\n );\n }\n}\n"]}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { Amount, CurrencyCode, PageInfo, Timestamp } from '../../core/types/common.js';
|
|
2
|
+
import type { JsonObject } from '../../core/types/json.js';
|
|
3
|
+
/**
|
|
4
|
+
* Documented transaction types.
|
|
5
|
+
*/
|
|
6
|
+
export type TransactionType = 'merchant_payment' | 'merchant_payment_refund' | 'api_checkout' | 'api_checkout_refund' | 'api_payout' | 'api_payout_reversal' | 'bulk_payment' | 'bulk_payment_reversal' | 'b2b_payment' | 'b2b_payment_reversal' | 'merchant_sweep' | 'remittance' | 'remittance_reversal';
|
|
7
|
+
/**
|
|
8
|
+
* A wallet transaction returned by `GET /v1/transactions`.
|
|
9
|
+
*/
|
|
10
|
+
export interface Transaction {
|
|
11
|
+
/** Execution time of the transaction. */
|
|
12
|
+
readonly timestamp: Timestamp;
|
|
13
|
+
/** Unique transaction identifier, up to 20 characters. */
|
|
14
|
+
readonly transaction_id: string;
|
|
15
|
+
/** Transaction type; may be empty. */
|
|
16
|
+
readonly transaction_type?: TransactionType | '';
|
|
17
|
+
/** Amount difference applied to the wallet. */
|
|
18
|
+
readonly amount: Amount;
|
|
19
|
+
/** Fee charged for the transaction. */
|
|
20
|
+
readonly fee: Amount;
|
|
21
|
+
/** Wallet balance after the transaction, when provided. */
|
|
22
|
+
readonly balance?: Amount;
|
|
23
|
+
/** Currency of the transaction amount. */
|
|
24
|
+
readonly currency: CurrencyCode;
|
|
25
|
+
/** Whether this is a reversal or refund of a previous transaction. */
|
|
26
|
+
readonly is_reversal?: boolean;
|
|
27
|
+
/** Name of the counterparty, when provided. */
|
|
28
|
+
readonly counterparty_name?: string;
|
|
29
|
+
/** Mobile number of the counterparty, when provided. */
|
|
30
|
+
readonly counterparty_mobile?: string;
|
|
31
|
+
/** Counterparty identifier for B2B payments, when provided. */
|
|
32
|
+
readonly counterparty_id?: string;
|
|
33
|
+
/** Business user involved in the transaction, when provided. */
|
|
34
|
+
readonly business_user_name?: string;
|
|
35
|
+
/** Mobile number of the business user, when provided. */
|
|
36
|
+
readonly business_user_mobile?: string;
|
|
37
|
+
/** Employee identifier of the business user, when provided. */
|
|
38
|
+
readonly employee_id?: string;
|
|
39
|
+
/** Caller correlation string, when provided. */
|
|
40
|
+
readonly client_reference?: string;
|
|
41
|
+
/** Payment reason, when provided. */
|
|
42
|
+
readonly payment_reason?: string;
|
|
43
|
+
/** Linked Checkout API session identifier, when applicable. */
|
|
44
|
+
readonly checkout_api_session_id?: string;
|
|
45
|
+
/** Bulk payment batch identifier, when applicable. */
|
|
46
|
+
readonly batch_id?: string;
|
|
47
|
+
/** Aggregated merchant identifier, when applicable. */
|
|
48
|
+
readonly aggregated_merchant_id?: string;
|
|
49
|
+
/** Aggregated merchant name, when applicable. */
|
|
50
|
+
readonly aggregated_merchant_name?: string;
|
|
51
|
+
/** Custom key-value fields related to the payment, when provided. */
|
|
52
|
+
readonly custom_fields?: JsonObject;
|
|
53
|
+
/** Subaccount identifier that owns the transaction, when applicable. */
|
|
54
|
+
readonly submerchant_id?: string;
|
|
55
|
+
/** Subaccount name that owns the transaction, when applicable. */
|
|
56
|
+
readonly submerchant_name?: string;
|
|
57
|
+
/** Government tax applied to the transaction (Senegal only). */
|
|
58
|
+
readonly government_tax_amount?: string;
|
|
59
|
+
/** Government tax covered by Wave (Senegal only). */
|
|
60
|
+
readonly government_tax_paid_by_wave?: string;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Response body of `GET /v1/transactions`.
|
|
64
|
+
*/
|
|
65
|
+
export interface TransactionPage {
|
|
66
|
+
/** Cursor pagination state. */
|
|
67
|
+
readonly page_info: PageInfo;
|
|
68
|
+
/** Day the transactions belong to, in `YYYY-MM-DD` form. */
|
|
69
|
+
readonly date: string;
|
|
70
|
+
/** Transactions for the day, oldest first. */
|
|
71
|
+
readonly items: readonly Transaction[];
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Query parameters for `GET /v1/transactions`.
|
|
75
|
+
*/
|
|
76
|
+
export interface ListTransactionsQuery {
|
|
77
|
+
/** Day to fetch, in `YYYY-MM-DD` form; defaults to the current day. */
|
|
78
|
+
readonly date?: string;
|
|
79
|
+
/** Opaque cursor, normally the previous page's `page_info.end_cursor`. */
|
|
80
|
+
readonly after?: string;
|
|
81
|
+
/** Include transactions from readable subaccounts. */
|
|
82
|
+
readonly include_subaccounts?: boolean;
|
|
83
|
+
/** Maximum number of items to retrieve, when the server honours it. */
|
|
84
|
+
readonly first?: number;
|
|
85
|
+
}
|
|
86
|
+
//# sourceMappingURL=reconciliation-types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconciliation-types.d.ts","sourceRoot":"","sources":["../../../src/resources/reconciliation/reconciliation-types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,4BAA4B,CAAC;AAC5F,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AAE3D;;GAEG;AACH,MAAM,MAAM,eAAe,GACvB,kBAAkB,GAClB,yBAAyB,GACzB,cAAc,GACd,qBAAqB,GACrB,YAAY,GACZ,qBAAqB,GACrB,cAAc,GACd,uBAAuB,GACvB,aAAa,GACb,sBAAsB,GACtB,gBAAgB,GAChB,YAAY,GACZ,qBAAqB,CAAC;AAE1B;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,yCAAyC;IACzC,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,0DAA0D;IAC1D,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAChC,sCAAsC;IACtC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,eAAe,GAAG,EAAE,CAAC;IACjD,+CAA+C;IAC/C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,uCAAuC;IACvC,QAAQ,CAAC,GAAG,EAAE,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B,CAAC,EAAE,MAAM,CAAC;IACxC,qDAAqD;IACrD,QAAQ,CAAC,2BAA2B,CAAC,EAAE,MAAM,CAAC;CAC/C;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,+BAA+B;IAC/B,QAAQ,CAAC,SAAS,EAAE,QAAQ,CAAC;IAC7B,4DAA4D;IAC5D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,8CAA8C;IAC9C,QAAQ,CAAC,KAAK,EAAE,SAAS,WAAW,EAAE,CAAC;CACxC;AAED;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC,uEAAuE;IACvE,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;IACvB,0EAA0E;IAC1E,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,sDAAsD;IACtD,QAAQ,CAAC,mBAAmB,CAAC,EAAE,OAAO,CAAC;IACvC,uEAAuE;IACvE,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;CACzB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconciliation-types.js","sourceRoot":"","sources":["../../../src/resources/reconciliation/reconciliation-types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Amount, CurrencyCode, PageInfo, Timestamp } from '../../core/types/common.js';\nimport type { JsonObject } from '../../core/types/json.js';\n\n/**\n * Documented transaction types.\n */\nexport type TransactionType =\n | 'merchant_payment'\n | 'merchant_payment_refund'\n | 'api_checkout'\n | 'api_checkout_refund'\n | 'api_payout'\n | 'api_payout_reversal'\n | 'bulk_payment'\n | 'bulk_payment_reversal'\n | 'b2b_payment'\n | 'b2b_payment_reversal'\n | 'merchant_sweep'\n | 'remittance'\n | 'remittance_reversal';\n\n/**\n * A wallet transaction returned by `GET /v1/transactions`.\n */\nexport interface Transaction {\n /** Execution time of the transaction. */\n readonly timestamp: Timestamp;\n /** Unique transaction identifier, up to 20 characters. */\n readonly transaction_id: string;\n /** Transaction type; may be empty. */\n readonly transaction_type?: TransactionType | '';\n /** Amount difference applied to the wallet. */\n readonly amount: Amount;\n /** Fee charged for the transaction. */\n readonly fee: Amount;\n /** Wallet balance after the transaction, when provided. */\n readonly balance?: Amount;\n /** Currency of the transaction amount. */\n readonly currency: CurrencyCode;\n /** Whether this is a reversal or refund of a previous transaction. */\n readonly is_reversal?: boolean;\n /** Name of the counterparty, when provided. */\n readonly counterparty_name?: string;\n /** Mobile number of the counterparty, when provided. */\n readonly counterparty_mobile?: string;\n /** Counterparty identifier for B2B payments, when provided. */\n readonly counterparty_id?: string;\n /** Business user involved in the transaction, when provided. */\n readonly business_user_name?: string;\n /** Mobile number of the business user, when provided. */\n readonly business_user_mobile?: string;\n /** Employee identifier of the business user, when provided. */\n readonly employee_id?: string;\n /** Caller correlation string, when provided. */\n readonly client_reference?: string;\n /** Payment reason, when provided. */\n readonly payment_reason?: string;\n /** Linked Checkout API session identifier, when applicable. */\n readonly checkout_api_session_id?: string;\n /** Bulk payment batch identifier, when applicable. */\n readonly batch_id?: string;\n /** Aggregated merchant identifier, when applicable. */\n readonly aggregated_merchant_id?: string;\n /** Aggregated merchant name, when applicable. */\n readonly aggregated_merchant_name?: string;\n /** Custom key-value fields related to the payment, when provided. */\n readonly custom_fields?: JsonObject;\n /** Subaccount identifier that owns the transaction, when applicable. */\n readonly submerchant_id?: string;\n /** Subaccount name that owns the transaction, when applicable. */\n readonly submerchant_name?: string;\n /** Government tax applied to the transaction (Senegal only). */\n readonly government_tax_amount?: string;\n /** Government tax covered by Wave (Senegal only). */\n readonly government_tax_paid_by_wave?: string;\n}\n\n/**\n * Response body of `GET /v1/transactions`.\n */\nexport interface TransactionPage {\n /** Cursor pagination state. */\n readonly page_info: PageInfo;\n /** Day the transactions belong to, in `YYYY-MM-DD` form. */\n readonly date: string;\n /** Transactions for the day, oldest first. */\n readonly items: readonly Transaction[];\n}\n\n/**\n * Query parameters for `GET /v1/transactions`.\n */\nexport interface ListTransactionsQuery {\n /** Day to fetch, in `YYYY-MM-DD` form; defaults to the current day. */\n readonly date?: string;\n /** Opaque cursor, normally the previous page's `page_info.end_cursor`. */\n readonly after?: string;\n /** Include transactions from readable subaccounts. */\n readonly include_subaccounts?: boolean;\n /** Maximum number of items to retrieve, when the server honours it. */\n readonly first?: number;\n}\n"]}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { HttpClient } from '../../core/http/http-client.js';
|
|
2
|
+
import type { RequestOptions } from '../../core/types/configuration.js';
|
|
3
|
+
import type { ListTransactionsQuery, Transaction, TransactionPage } from './reconciliation-types.js';
|
|
4
|
+
/**
|
|
5
|
+
* Balance & Reconciliation API operations.
|
|
6
|
+
*/
|
|
7
|
+
export declare class ReconciliationResource {
|
|
8
|
+
#private;
|
|
9
|
+
/** @param http - Shared HTTP pipeline. */
|
|
10
|
+
constructor(http: HttpClient);
|
|
11
|
+
/**
|
|
12
|
+
* Retrieves one day of wallet transactions, oldest first.
|
|
13
|
+
*
|
|
14
|
+
* Responses paginate when a day has more than 1000 entries; pass
|
|
15
|
+
* `page_info.end_cursor` as `after` to continue. Use {@link iterateTransactions} to walk all
|
|
16
|
+
* pages.
|
|
17
|
+
*
|
|
18
|
+
* @param query - Day, cursor and subaccount options.
|
|
19
|
+
* @param options - Per-request overrides.
|
|
20
|
+
* @returns One page of transactions.
|
|
21
|
+
*/
|
|
22
|
+
listTransactions(query?: ListTransactionsQuery, options?: RequestOptions): Promise<TransactionPage>;
|
|
23
|
+
/**
|
|
24
|
+
* Iterates every transaction for the requested day, following pagination cursors.
|
|
25
|
+
*
|
|
26
|
+
* @param query - Day and subaccount options; `after` is managed automatically.
|
|
27
|
+
* @param options - Per-request overrides applied to every page request.
|
|
28
|
+
* @yields Each transaction in order.
|
|
29
|
+
*/
|
|
30
|
+
iterateTransactions(query?: ListTransactionsQuery, options?: RequestOptions): AsyncGenerator<Transaction, void, undefined>;
|
|
31
|
+
/**
|
|
32
|
+
* Refunds a payment received, including fees.
|
|
33
|
+
*
|
|
34
|
+
* Wave documents the endpoint as idempotent and returns an empty body on success.
|
|
35
|
+
*
|
|
36
|
+
* @param transactionId - Transaction identifier to refund.
|
|
37
|
+
* @param options - Per-request overrides.
|
|
38
|
+
*/
|
|
39
|
+
refund(transactionId: string, options?: RequestOptions): Promise<void>;
|
|
40
|
+
}
|
|
41
|
+
//# sourceMappingURL=reconciliation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconciliation.d.ts","sourceRoot":"","sources":["../../../src/resources/reconciliation/reconciliation.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,gCAAgC,CAAC;AAEjE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,mCAAmC,CAAC;AACxE,OAAO,KAAK,EACV,qBAAqB,EACrB,WAAW,EACX,eAAe,EAChB,MAAM,2BAA2B,CAAC;AAKnC;;GAEG;AACH,qBAAa,sBAAsB;;IAGjC,0CAA0C;gBAC9B,IAAI,EAAE,UAAU;IAI5B;;;;;;;;;;OAUG;IACH,gBAAgB,CACd,KAAK,GAAE,qBAA0B,EACjC,OAAO,GAAE,cAAmB,GAC3B,OAAO,CAAC,eAAe,CAAC;IAQ3B;;;;;;OAMG;IACI,mBAAmB,CACxB,KAAK,GAAE,qBAA0B,EACjC,OAAO,GAAE,cAAmB,GAC3B,cAAc,CAAC,WAAW,EAAE,IAAI,EAAE,SAAS,CAAC;IAyB/C;;;;;;;OAOG;IACH,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,GAAE,cAAmB,GAAG,OAAO,CAAC,IAAI,CAAC;CAU3E"}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
const LIST_TRANSACTIONS = { idempotent: true, requiresIdempotencyKey: false };
|
|
2
|
+
const REFUND_TRANSACTION = { idempotent: true, requiresIdempotencyKey: true };
|
|
3
|
+
/**
|
|
4
|
+
* Balance & Reconciliation API operations.
|
|
5
|
+
*/
|
|
6
|
+
export class ReconciliationResource {
|
|
7
|
+
#http;
|
|
8
|
+
/** @param http - Shared HTTP pipeline. */
|
|
9
|
+
constructor(http) {
|
|
10
|
+
this.#http = http;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Retrieves one day of wallet transactions, oldest first.
|
|
14
|
+
*
|
|
15
|
+
* Responses paginate when a day has more than 1000 entries; pass
|
|
16
|
+
* `page_info.end_cursor` as `after` to continue. Use {@link iterateTransactions} to walk all
|
|
17
|
+
* pages.
|
|
18
|
+
*
|
|
19
|
+
* @param query - Day, cursor and subaccount options.
|
|
20
|
+
* @param options - Per-request overrides.
|
|
21
|
+
* @returns One page of transactions.
|
|
22
|
+
*/
|
|
23
|
+
listTransactions(query = {}, options = {}) {
|
|
24
|
+
return this.#http.request(LIST_TRANSACTIONS, { method: 'GET', path: '/v1/transactions', query: toQuery(query) }, options);
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Iterates every transaction for the requested day, following pagination cursors.
|
|
28
|
+
*
|
|
29
|
+
* @param query - Day and subaccount options; `after` is managed automatically.
|
|
30
|
+
* @param options - Per-request overrides applied to every page request.
|
|
31
|
+
* @yields Each transaction in order.
|
|
32
|
+
*/
|
|
33
|
+
async *iterateTransactions(query = {}, options = {}) {
|
|
34
|
+
let after = query.after;
|
|
35
|
+
for (;;) {
|
|
36
|
+
const page = await this.listTransactions({ ...query, ...(after === undefined ? {} : { after }) }, options);
|
|
37
|
+
for (const transaction of page.items) {
|
|
38
|
+
yield transaction;
|
|
39
|
+
}
|
|
40
|
+
if (!page.page_info.has_next_page) {
|
|
41
|
+
return;
|
|
42
|
+
}
|
|
43
|
+
const nextCursor = page.page_info.end_cursor;
|
|
44
|
+
if (nextCursor === null || nextCursor === after) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
after = nextCursor;
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Refunds a payment received, including fees.
|
|
52
|
+
*
|
|
53
|
+
* Wave documents the endpoint as idempotent and returns an empty body on success.
|
|
54
|
+
*
|
|
55
|
+
* @param transactionId - Transaction identifier to refund.
|
|
56
|
+
* @param options - Per-request overrides.
|
|
57
|
+
*/
|
|
58
|
+
refund(transactionId, options = {}) {
|
|
59
|
+
return this.#http.requestVoid(REFUND_TRANSACTION, {
|
|
60
|
+
method: 'POST',
|
|
61
|
+
path: `/v1/transactions/${encodeURIComponent(transactionId)}/refund`,
|
|
62
|
+
}, options);
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
function toQuery(query) {
|
|
66
|
+
const result = {};
|
|
67
|
+
if (query.date !== undefined) {
|
|
68
|
+
result['date'] = query.date;
|
|
69
|
+
}
|
|
70
|
+
if (query.after !== undefined) {
|
|
71
|
+
result['after'] = query.after;
|
|
72
|
+
}
|
|
73
|
+
if (query.include_subaccounts !== undefined) {
|
|
74
|
+
result['include_subaccounts'] = query.include_subaccounts;
|
|
75
|
+
}
|
|
76
|
+
if (query.first !== undefined) {
|
|
77
|
+
result['first'] = query.first;
|
|
78
|
+
}
|
|
79
|
+
return result;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=reconciliation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"reconciliation.js","sourceRoot":"","sources":["../../../src/resources/reconciliation/reconciliation.ts"],"names":[],"mappings":"AASA,MAAM,iBAAiB,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,sBAAsB,EAAE,KAAK,EAAW,CAAC;AACvF,MAAM,kBAAkB,GAAG,EAAE,UAAU,EAAE,IAAI,EAAE,sBAAsB,EAAE,IAAI,EAAW,CAAC;AAEvF;;GAEG;AACH,MAAM,OAAO,sBAAsB;IACxB,KAAK,CAAa;IAE3B,0CAA0C;IAC1C,YAAY,IAAgB;QAC1B,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC;IACpB,CAAC;IAED;;;;;;;;;;OAUG;IACH,gBAAgB,CACd,QAA+B,EAAE,EACjC,UAA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3C,MAAM,MAAM,GAAwC,EAAE,CAAC;IACvD,IAAI,KAAK,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC7B,MAAM,CAAC,MAAM,CAAC,GAAG,KAAK,CAAC,IAAI,CAAC;IAC9B,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;IAChC,CAAC;IACD,IAAI,KAAK,CAAC,mBAAmB,KAAK,SAAS,EAAE,CAAC;QAC5C,MAAM,CAAC,qBAAqB,CAAC,GAAG,KAAK,CAAC,mBAAmB,CAAC;IAC5D,CAAC;IACD,IAAI,KAAK,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAC9B,MAAM,CAAC,OAAO,CAAC,GAAG,KAAK,CAAC,KAAK,CAAC;IAChC,CAAC;IACD,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["import type { HttpClient } from '../../core/http/http-client.js';\nimport type { QueryParameterValue } from '../../core/http/query.js';\nimport type { RequestOptions } from '../../core/types/configuration.js';\nimport type {\n ListTransactionsQuery,\n Transaction,\n TransactionPage,\n} from './reconciliation-types.js';\n\nconst LIST_TRANSACTIONS = { idempotent: true, requiresIdempotencyKey: false } as const;\nconst REFUND_TRANSACTION = { idempotent: true, requiresIdempotencyKey: true } as const;\n\n/**\n * Balance & Reconciliation API operations.\n */\nexport class ReconciliationResource {\n readonly #http: HttpClient;\n\n /** @param http - Shared HTTP pipeline. */\n constructor(http: HttpClient) {\n this.#http = http;\n }\n\n /**\n * Retrieves one day of wallet transactions, oldest first.\n *\n * Responses paginate when a day has more than 1000 entries; pass\n * `page_info.end_cursor` as `after` to continue. Use {@link iterateTransactions} to walk all\n * pages.\n *\n * @param query - Day, cursor and subaccount options.\n * @param options - Per-request overrides.\n * @returns One page of transactions.\n */\n listTransactions(\n query: ListTransactionsQuery = {},\n options: RequestOptions = {},\n ): Promise<TransactionPage> {\n return this.#http.request<TransactionPage>(\n LIST_TRANSACTIONS,\n { method: 'GET', path: '/v1/transactions', query: toQuery(query) },\n options,\n );\n }\n\n /**\n * Iterates every transaction for the requested day, following pagination cursors.\n *\n * @param query - Day and subaccount options; `after` is managed automatically.\n * @param options - Per-request overrides applied to every page request.\n * @yields Each transaction in order.\n */\n async *iterateTransactions(\n query: ListTransactionsQuery = {},\n options: RequestOptions = {},\n ): AsyncGenerator<Transaction, void, undefined> {\n let after = query.after;\n\n for (;;) {\n const page = await this.listTransactions(\n { ...query, ...(after === undefined ? {} : { after }) },\n options,\n );\n\n for (const transaction of page.items) {\n yield transaction;\n }\n\n if (!page.page_info.has_next_page) {\n return;\n }\n\n const nextCursor = page.page_info.end_cursor;\n if (nextCursor === null || nextCursor === after) {\n return;\n }\n after = nextCursor;\n }\n }\n\n /**\n * Refunds a payment received, including fees.\n *\n * Wave documents the endpoint as idempotent and returns an empty body on success.\n *\n * @param transactionId - Transaction identifier to refund.\n * @param options - Per-request overrides.\n */\n refund(transactionId: string, options: RequestOptions = {}): Promise<void> {\n return this.#http.requestVoid(\n REFUND_TRANSACTION,\n {\n method: 'POST',\n path: `/v1/transactions/${encodeURIComponent(transactionId)}/refund`,\n },\n options,\n );\n }\n}\n\nfunction toQuery(query: ListTransactionsQuery): Readonly<Record<string, QueryParameterValue>> {\n const result: Record<string, QueryParameterValue> = {};\n if (query.date !== undefined) {\n result['date'] = query.date;\n }\n if (query.after !== undefined) {\n result['after'] = query.after;\n }\n if (query.include_subaccounts !== undefined) {\n result['include_subaccounts'] = query.include_subaccounts;\n }\n if (query.first !== undefined) {\n result['first'] = query.first;\n }\n return result;\n}\n"]}
|