@djangocfg/ext-payments 1.0.19 → 1.0.21
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 +117 -145
- package/dist/api/hooks.cjs +1701 -0
- package/dist/api/hooks.d.cts +4 -0
- package/dist/api/hooks.d.ts +4 -0
- package/dist/api/hooks.js +1681 -0
- package/dist/api/index.cjs +1738 -0
- package/dist/api/index.d.cts +372 -0
- package/dist/api/index.d.ts +372 -0
- package/dist/api/index.js +1688 -0
- package/dist/api-hooks-DG8taGyN.d.cts +1172 -0
- package/dist/api-hooks-DG8taGyN.d.ts +1172 -0
- package/dist/api-hooks.cjs +1701 -0
- package/dist/api-hooks.d.cts +4 -0
- package/dist/api-hooks.d.ts +4 -0
- package/dist/api-hooks.js +1681 -0
- package/dist/config.cjs +11 -1
- package/dist/config.js +11 -1
- package/dist/hooks-DG8taGyN.d.cts +1172 -0
- package/dist/hooks-DG8taGyN.d.ts +1172 -0
- package/dist/index.cjs +15 -5
- package/dist/index.d.cts +23 -1407
- package/dist/index.d.ts +23 -1407
- package/dist/index.js +15 -5
- package/package.json +13 -3
- package/src/api/hooks.ts +16 -0
- package/src/api/index.ts +20 -1
|
@@ -0,0 +1,1172 @@
|
|
|
1
|
+
import useSWR from 'swr';
|
|
2
|
+
import { ConsolaInstance } from 'consola';
|
|
3
|
+
import { z } from 'zod';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Current payment status
|
|
7
|
+
* * `pending` - Pending
|
|
8
|
+
* * `confirming` - Confirming
|
|
9
|
+
* * `confirmed` - Confirmed
|
|
10
|
+
* * `completed` - Completed
|
|
11
|
+
* * `partially_paid` - Partially Paid
|
|
12
|
+
* * `failed` - Failed
|
|
13
|
+
* * `expired` - Expired
|
|
14
|
+
* * `cancelled` - Cancelled
|
|
15
|
+
*/
|
|
16
|
+
declare enum PaymentDetailStatus {
|
|
17
|
+
PENDING = "pending",
|
|
18
|
+
CONFIRMING = "confirming",
|
|
19
|
+
CONFIRMED = "confirmed",
|
|
20
|
+
COMPLETED = "completed",
|
|
21
|
+
PARTIALLY_PAID = "partially_paid",
|
|
22
|
+
FAILED = "failed",
|
|
23
|
+
EXPIRED = "expired",
|
|
24
|
+
CANCELLED = "cancelled"
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Current payment status
|
|
28
|
+
* * `pending` - Pending
|
|
29
|
+
* * `confirming` - Confirming
|
|
30
|
+
* * `confirmed` - Confirmed
|
|
31
|
+
* * `completed` - Completed
|
|
32
|
+
* * `partially_paid` - Partially Paid
|
|
33
|
+
* * `failed` - Failed
|
|
34
|
+
* * `expired` - Expired
|
|
35
|
+
* * `cancelled` - Cancelled
|
|
36
|
+
*/
|
|
37
|
+
declare enum PaymentListStatus {
|
|
38
|
+
PENDING = "pending",
|
|
39
|
+
CONFIRMING = "confirming",
|
|
40
|
+
CONFIRMED = "confirmed",
|
|
41
|
+
COMPLETED = "completed",
|
|
42
|
+
PARTIALLY_PAID = "partially_paid",
|
|
43
|
+
FAILED = "failed",
|
|
44
|
+
EXPIRED = "expired",
|
|
45
|
+
CANCELLED = "cancelled"
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
* Type of transaction
|
|
49
|
+
* * `deposit` - Deposit
|
|
50
|
+
* * `withdrawal` - Withdrawal
|
|
51
|
+
* * `payment` - Payment
|
|
52
|
+
* * `refund` - Refund
|
|
53
|
+
* * `fee` - Fee
|
|
54
|
+
* * `bonus` - Bonus
|
|
55
|
+
* * `adjustment` - Adjustment
|
|
56
|
+
*/
|
|
57
|
+
declare enum TransactionTransactionType {
|
|
58
|
+
DEPOSIT = "deposit",
|
|
59
|
+
WITHDRAWAL = "withdrawal",
|
|
60
|
+
PAYMENT = "payment",
|
|
61
|
+
REFUND = "refund",
|
|
62
|
+
FEE = "fee",
|
|
63
|
+
BONUS = "bonus",
|
|
64
|
+
ADJUSTMENT = "adjustment"
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Withdrawal status
|
|
68
|
+
* * `pending` - Pending
|
|
69
|
+
* * `approved` - Approved
|
|
70
|
+
* * `processing` - Processing
|
|
71
|
+
* * `completed` - Completed
|
|
72
|
+
* * `rejected` - Rejected
|
|
73
|
+
* * `cancelled` - Cancelled
|
|
74
|
+
*/
|
|
75
|
+
declare enum WithdrawalDetailStatus {
|
|
76
|
+
PENDING = "pending",
|
|
77
|
+
APPROVED = "approved",
|
|
78
|
+
PROCESSING = "processing",
|
|
79
|
+
COMPLETED = "completed",
|
|
80
|
+
REJECTED = "rejected",
|
|
81
|
+
CANCELLED = "cancelled"
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Withdrawal status
|
|
85
|
+
* * `pending` - Pending
|
|
86
|
+
* * `approved` - Approved
|
|
87
|
+
* * `processing` - Processing
|
|
88
|
+
* * `completed` - Completed
|
|
89
|
+
* * `rejected` - Rejected
|
|
90
|
+
* * `cancelled` - Cancelled
|
|
91
|
+
*/
|
|
92
|
+
declare enum WithdrawalListStatus {
|
|
93
|
+
PENDING = "pending",
|
|
94
|
+
APPROVED = "approved",
|
|
95
|
+
PROCESSING = "processing",
|
|
96
|
+
COMPLETED = "completed",
|
|
97
|
+
REJECTED = "rejected",
|
|
98
|
+
CANCELLED = "cancelled"
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
type enums_PaymentDetailStatus = PaymentDetailStatus;
|
|
102
|
+
declare const enums_PaymentDetailStatus: typeof PaymentDetailStatus;
|
|
103
|
+
type enums_PaymentListStatus = PaymentListStatus;
|
|
104
|
+
declare const enums_PaymentListStatus: typeof PaymentListStatus;
|
|
105
|
+
type enums_TransactionTransactionType = TransactionTransactionType;
|
|
106
|
+
declare const enums_TransactionTransactionType: typeof TransactionTransactionType;
|
|
107
|
+
type enums_WithdrawalDetailStatus = WithdrawalDetailStatus;
|
|
108
|
+
declare const enums_WithdrawalDetailStatus: typeof WithdrawalDetailStatus;
|
|
109
|
+
type enums_WithdrawalListStatus = WithdrawalListStatus;
|
|
110
|
+
declare const enums_WithdrawalListStatus: typeof WithdrawalListStatus;
|
|
111
|
+
declare namespace enums {
|
|
112
|
+
export { enums_PaymentDetailStatus as PaymentDetailStatus, enums_PaymentListStatus as PaymentListStatus, enums_TransactionTransactionType as TransactionTransactionType, enums_WithdrawalDetailStatus as WithdrawalDetailStatus, enums_WithdrawalListStatus as WithdrawalListStatus };
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* User balance serializer.
|
|
117
|
+
*
|
|
118
|
+
* Response model (includes read-only fields).
|
|
119
|
+
*/
|
|
120
|
+
interface Balance {
|
|
121
|
+
/** Current balance in USD */
|
|
122
|
+
balance_usd: string;
|
|
123
|
+
balance_display: string;
|
|
124
|
+
/** Total amount deposited (lifetime) */
|
|
125
|
+
total_deposited: string;
|
|
126
|
+
/** Total amount withdrawn (lifetime) */
|
|
127
|
+
total_withdrawn: string;
|
|
128
|
+
/** When the last transaction occurred */
|
|
129
|
+
last_transaction_at?: string | null;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
*
|
|
133
|
+
* Response model (includes read-only fields).
|
|
134
|
+
*/
|
|
135
|
+
interface PaginatedPaymentListList {
|
|
136
|
+
/** Total number of items across all pages */
|
|
137
|
+
count: number;
|
|
138
|
+
/** Current page number (1-based) */
|
|
139
|
+
page: number;
|
|
140
|
+
/** Total number of pages */
|
|
141
|
+
pages: number;
|
|
142
|
+
/** Number of items per page */
|
|
143
|
+
page_size: number;
|
|
144
|
+
/** Whether there is a next page */
|
|
145
|
+
has_next: boolean;
|
|
146
|
+
/** Whether there is a previous page */
|
|
147
|
+
has_previous: boolean;
|
|
148
|
+
/** Next page number (null if no next page) */
|
|
149
|
+
next_page?: number | null;
|
|
150
|
+
/** Previous page number (null if no previous page) */
|
|
151
|
+
previous_page?: number | null;
|
|
152
|
+
/** Array of items for current page */
|
|
153
|
+
results: Array<PaymentList$1>;
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Detailed payment information.
|
|
157
|
+
*
|
|
158
|
+
* Response model (includes read-only fields).
|
|
159
|
+
*/
|
|
160
|
+
interface PaymentDetail {
|
|
161
|
+
/** Unique identifier for this record */
|
|
162
|
+
id: string;
|
|
163
|
+
/** Internal payment identifier (PAY_YYYYMMDDHHMMSS_UUID) */
|
|
164
|
+
internal_payment_id: string;
|
|
165
|
+
/** Payment amount in USD */
|
|
166
|
+
amount_usd: string;
|
|
167
|
+
currency_code: string;
|
|
168
|
+
currency_name: string;
|
|
169
|
+
currency_token: string;
|
|
170
|
+
currency_network: string;
|
|
171
|
+
pay_amount?: string | null;
|
|
172
|
+
actual_amount?: string | null;
|
|
173
|
+
actual_amount_usd?: string | null;
|
|
174
|
+
/** Current payment status
|
|
175
|
+
|
|
176
|
+
* `pending` - Pending
|
|
177
|
+
* `confirming` - Confirming
|
|
178
|
+
* `confirmed` - Confirmed
|
|
179
|
+
* `completed` - Completed
|
|
180
|
+
* `partially_paid` - Partially Paid
|
|
181
|
+
* `failed` - Failed
|
|
182
|
+
* `expired` - Expired
|
|
183
|
+
* `cancelled` - Cancelled */
|
|
184
|
+
status: PaymentDetailStatus;
|
|
185
|
+
status_display: string;
|
|
186
|
+
pay_address?: string | null;
|
|
187
|
+
/** Get QR code URL. */
|
|
188
|
+
qr_code_url?: string | null;
|
|
189
|
+
payment_url?: string | null;
|
|
190
|
+
transaction_hash?: string | null;
|
|
191
|
+
/** Get blockchain explorer link. */
|
|
192
|
+
explorer_link?: string | null;
|
|
193
|
+
/** Number of blockchain confirmations */
|
|
194
|
+
confirmations_count: number;
|
|
195
|
+
expires_at?: string | null;
|
|
196
|
+
completed_at?: string | null;
|
|
197
|
+
/** When this record was created */
|
|
198
|
+
created_at: string;
|
|
199
|
+
is_completed: boolean;
|
|
200
|
+
is_failed: boolean;
|
|
201
|
+
is_expired: boolean;
|
|
202
|
+
/** Payment description */
|
|
203
|
+
description: string;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Payment list item (lighter than detail).
|
|
207
|
+
*
|
|
208
|
+
* Response model (includes read-only fields).
|
|
209
|
+
*/
|
|
210
|
+
interface PaymentList$1 {
|
|
211
|
+
/** Unique identifier for this record */
|
|
212
|
+
id: string;
|
|
213
|
+
/** Internal payment identifier (PAY_YYYYMMDDHHMMSS_UUID) */
|
|
214
|
+
internal_payment_id: string;
|
|
215
|
+
/** Payment amount in USD */
|
|
216
|
+
amount_usd: string;
|
|
217
|
+
currency_code: string;
|
|
218
|
+
currency_token: string;
|
|
219
|
+
/** Current payment status
|
|
220
|
+
|
|
221
|
+
* `pending` - Pending
|
|
222
|
+
* `confirming` - Confirming
|
|
223
|
+
* `confirmed` - Confirmed
|
|
224
|
+
* `completed` - Completed
|
|
225
|
+
* `partially_paid` - Partially Paid
|
|
226
|
+
* `failed` - Failed
|
|
227
|
+
* `expired` - Expired
|
|
228
|
+
* `cancelled` - Cancelled */
|
|
229
|
+
status: PaymentListStatus;
|
|
230
|
+
status_display: string;
|
|
231
|
+
/** When this record was created */
|
|
232
|
+
created_at: string;
|
|
233
|
+
/** When this payment was completed */
|
|
234
|
+
completed_at?: string | null;
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Serializer for creating payment.
|
|
238
|
+
*
|
|
239
|
+
* Request model (no read-only fields).
|
|
240
|
+
*/
|
|
241
|
+
interface PaymentCreateRequest$1 {
|
|
242
|
+
/** Payment amount in USD */
|
|
243
|
+
amount_usd: string;
|
|
244
|
+
/** Currency code (e.g., USDTTRC20) */
|
|
245
|
+
currency_code: string;
|
|
246
|
+
/** Optional payment description */
|
|
247
|
+
description?: string;
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* Response for payment creation.
|
|
251
|
+
*
|
|
252
|
+
* Response model (includes read-only fields).
|
|
253
|
+
*/
|
|
254
|
+
interface PaymentCreateResponse$1 {
|
|
255
|
+
success: boolean;
|
|
256
|
+
payment: PaymentDetail;
|
|
257
|
+
qr_code_url: string | null;
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
*
|
|
261
|
+
* Response model (includes read-only fields).
|
|
262
|
+
*/
|
|
263
|
+
interface PaginatedWithdrawalListList {
|
|
264
|
+
/** Total number of items across all pages */
|
|
265
|
+
count: number;
|
|
266
|
+
/** Current page number (1-based) */
|
|
267
|
+
page: number;
|
|
268
|
+
/** Total number of pages */
|
|
269
|
+
pages: number;
|
|
270
|
+
/** Number of items per page */
|
|
271
|
+
page_size: number;
|
|
272
|
+
/** Whether there is a next page */
|
|
273
|
+
has_next: boolean;
|
|
274
|
+
/** Whether there is a previous page */
|
|
275
|
+
has_previous: boolean;
|
|
276
|
+
/** Next page number (null if no next page) */
|
|
277
|
+
next_page?: number | null;
|
|
278
|
+
/** Previous page number (null if no previous page) */
|
|
279
|
+
previous_page?: number | null;
|
|
280
|
+
/** Array of items for current page */
|
|
281
|
+
results: Array<WithdrawalList>;
|
|
282
|
+
}
|
|
283
|
+
/**
|
|
284
|
+
* Detailed withdrawal information.
|
|
285
|
+
*
|
|
286
|
+
* Response model (includes read-only fields).
|
|
287
|
+
*/
|
|
288
|
+
interface WithdrawalDetail {
|
|
289
|
+
/** Unique identifier for this record */
|
|
290
|
+
id: string;
|
|
291
|
+
/** Internal withdrawal identifier (WD_YYYYMMDDHHMMSS_UUID) */
|
|
292
|
+
internal_withdrawal_id: string;
|
|
293
|
+
/** Withdrawal amount in USD (min $10) */
|
|
294
|
+
amount_usd: string;
|
|
295
|
+
currency_code: string;
|
|
296
|
+
currency_name: string;
|
|
297
|
+
currency_token: string;
|
|
298
|
+
currency_network: string;
|
|
299
|
+
/** Destination wallet address */
|
|
300
|
+
wallet_address: string;
|
|
301
|
+
/** Network transaction fee in USD */
|
|
302
|
+
network_fee_usd: string;
|
|
303
|
+
/** Service fee in USD */
|
|
304
|
+
service_fee_usd: string;
|
|
305
|
+
/** Total fee (network + service) in USD */
|
|
306
|
+
total_fee_usd: string;
|
|
307
|
+
/** Final amount to receive (amount - total_fee) */
|
|
308
|
+
final_amount_usd: string;
|
|
309
|
+
crypto_amount?: string | null;
|
|
310
|
+
/** Withdrawal status
|
|
311
|
+
|
|
312
|
+
* `pending` - Pending
|
|
313
|
+
* `approved` - Approved
|
|
314
|
+
* `processing` - Processing
|
|
315
|
+
* `completed` - Completed
|
|
316
|
+
* `rejected` - Rejected
|
|
317
|
+
* `cancelled` - Cancelled */
|
|
318
|
+
status: WithdrawalDetailStatus;
|
|
319
|
+
status_display: string;
|
|
320
|
+
transaction_hash?: string | null;
|
|
321
|
+
/** Get blockchain explorer link. */
|
|
322
|
+
explorer_link?: string | null;
|
|
323
|
+
/** Admin notes (reason for rejection, etc.) */
|
|
324
|
+
admin_notes: string;
|
|
325
|
+
/** When this record was created */
|
|
326
|
+
created_at: string;
|
|
327
|
+
approved_at?: string | null;
|
|
328
|
+
completed_at?: string | null;
|
|
329
|
+
rejected_at?: string | null;
|
|
330
|
+
cancelled_at?: string | null;
|
|
331
|
+
}
|
|
332
|
+
/**
|
|
333
|
+
* Response for withdrawal cancellation.
|
|
334
|
+
*
|
|
335
|
+
* Response model (includes read-only fields).
|
|
336
|
+
*/
|
|
337
|
+
interface WithdrawalCancelResponse$1 {
|
|
338
|
+
success: boolean;
|
|
339
|
+
withdrawal: WithdrawalDetail;
|
|
340
|
+
message: string;
|
|
341
|
+
}
|
|
342
|
+
/**
|
|
343
|
+
* Serializer for creating withdrawal request.
|
|
344
|
+
*
|
|
345
|
+
* Request model (no read-only fields).
|
|
346
|
+
*/
|
|
347
|
+
interface WithdrawalCreateRequest$1 {
|
|
348
|
+
/** Withdrawal amount in USD (min $10) */
|
|
349
|
+
amount_usd: string;
|
|
350
|
+
/** Currency code (e.g., USDTTRC20) */
|
|
351
|
+
currency_code: string;
|
|
352
|
+
/** Destination wallet address */
|
|
353
|
+
wallet_address: string;
|
|
354
|
+
}
|
|
355
|
+
/**
|
|
356
|
+
* Response for withdrawal creation.
|
|
357
|
+
*
|
|
358
|
+
* Response model (includes read-only fields).
|
|
359
|
+
*/
|
|
360
|
+
interface WithdrawalCreateResponse$1 {
|
|
361
|
+
success: boolean;
|
|
362
|
+
withdrawal: WithdrawalDetail;
|
|
363
|
+
message: string;
|
|
364
|
+
}
|
|
365
|
+
/**
|
|
366
|
+
* Withdrawal list item (lighter than detail).
|
|
367
|
+
*
|
|
368
|
+
* Response model (includes read-only fields).
|
|
369
|
+
*/
|
|
370
|
+
interface WithdrawalList {
|
|
371
|
+
/** Unique identifier for this record */
|
|
372
|
+
id: string;
|
|
373
|
+
/** Internal withdrawal identifier (WD_YYYYMMDDHHMMSS_UUID) */
|
|
374
|
+
internal_withdrawal_id: string;
|
|
375
|
+
/** Withdrawal amount in USD (min $10) */
|
|
376
|
+
amount_usd: string;
|
|
377
|
+
/** Final amount to receive (amount - total_fee) */
|
|
378
|
+
final_amount_usd: string;
|
|
379
|
+
currency_code: string;
|
|
380
|
+
currency_token: string;
|
|
381
|
+
/** Withdrawal status
|
|
382
|
+
|
|
383
|
+
* `pending` - Pending
|
|
384
|
+
* `approved` - Approved
|
|
385
|
+
* `processing` - Processing
|
|
386
|
+
* `completed` - Completed
|
|
387
|
+
* `rejected` - Rejected
|
|
388
|
+
* `cancelled` - Cancelled */
|
|
389
|
+
status: WithdrawalListStatus;
|
|
390
|
+
status_display: string;
|
|
391
|
+
/** When this record was created */
|
|
392
|
+
created_at: string;
|
|
393
|
+
/** When withdrawal was completed */
|
|
394
|
+
completed_at?: string | null;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
type models_Balance = Balance;
|
|
398
|
+
type models_PaginatedPaymentListList = PaginatedPaymentListList;
|
|
399
|
+
type models_PaginatedWithdrawalListList = PaginatedWithdrawalListList;
|
|
400
|
+
type models_PaymentDetail = PaymentDetail;
|
|
401
|
+
type models_WithdrawalDetail = WithdrawalDetail;
|
|
402
|
+
type models_WithdrawalList = WithdrawalList;
|
|
403
|
+
declare namespace models {
|
|
404
|
+
export type { models_Balance as Balance, models_PaginatedPaymentListList as PaginatedPaymentListList, models_PaginatedWithdrawalListList as PaginatedWithdrawalListList, PaymentCreateRequest$1 as PaymentCreateRequest, PaymentCreateResponse$1 as PaymentCreateResponse, models_PaymentDetail as PaymentDetail, PaymentList$1 as PaymentList, WithdrawalCancelResponse$1 as WithdrawalCancelResponse, WithdrawalCreateRequest$1 as WithdrawalCreateRequest, WithdrawalCreateResponse$1 as WithdrawalCreateResponse, models_WithdrawalDetail as WithdrawalDetail, models_WithdrawalList as WithdrawalList };
|
|
405
|
+
}
|
|
406
|
+
|
|
407
|
+
/**
|
|
408
|
+
* API endpoints for Payments.
|
|
409
|
+
*/
|
|
410
|
+
declare class ExtPaymentsPayments {
|
|
411
|
+
private client;
|
|
412
|
+
constructor(client: any);
|
|
413
|
+
/**
|
|
414
|
+
* Get user balance
|
|
415
|
+
*
|
|
416
|
+
* Get current user balance and transaction statistics
|
|
417
|
+
*/
|
|
418
|
+
balanceRetrieve(): Promise<Balance>;
|
|
419
|
+
/**
|
|
420
|
+
* Get available currencies
|
|
421
|
+
*
|
|
422
|
+
* Returns list of available currencies with token+network info, popular
|
|
423
|
+
* first
|
|
424
|
+
*/
|
|
425
|
+
currenciesList(): Promise<any>;
|
|
426
|
+
currenciesEstimateRetrieve(code: string, amount?: number): Promise<any>;
|
|
427
|
+
currenciesEstimateRetrieve(code: string, params?: {
|
|
428
|
+
amount?: number;
|
|
429
|
+
}): Promise<any>;
|
|
430
|
+
currenciesWithdrawalEstimateRetrieve(code: string, amount?: number): Promise<any>;
|
|
431
|
+
currenciesWithdrawalEstimateRetrieve(code: string, params?: {
|
|
432
|
+
amount?: number;
|
|
433
|
+
}): Promise<any>;
|
|
434
|
+
paymentsList(page?: number, page_size?: number): Promise<PaginatedPaymentListList>;
|
|
435
|
+
paymentsList(params?: {
|
|
436
|
+
page?: number;
|
|
437
|
+
page_size?: number;
|
|
438
|
+
}): Promise<PaginatedPaymentListList>;
|
|
439
|
+
/**
|
|
440
|
+
* ViewSet for payment operations. Endpoints: - GET /payments/ - List
|
|
441
|
+
* user's payments - GET /payments/{id}/ - Get payment details - POST
|
|
442
|
+
* /payments/create/ - Create new payment - GET /payments/{id}/status/ -
|
|
443
|
+
* Check payment status - POST /payments/{id}/confirm/ - Confirm payment
|
|
444
|
+
*/
|
|
445
|
+
paymentsRetrieve(id: string): Promise<PaymentDetail>;
|
|
446
|
+
/**
|
|
447
|
+
* POST /api/v1/payments/{id}/confirm/ Confirm payment (user clicked "I
|
|
448
|
+
* have paid"). Checks status with provider and creates transaction if
|
|
449
|
+
* completed.
|
|
450
|
+
*/
|
|
451
|
+
paymentsConfirmCreate(id: string): Promise<PaymentList$1>;
|
|
452
|
+
/**
|
|
453
|
+
* GET /api/v1/payments/{id}/status/?refresh=true Check payment status
|
|
454
|
+
* (with optional refresh from provider). Query params: - refresh: boolean
|
|
455
|
+
* (default: false) - Force refresh from provider
|
|
456
|
+
*/
|
|
457
|
+
paymentsStatusRetrieve(id: string): Promise<PaymentList$1[]>;
|
|
458
|
+
/**
|
|
459
|
+
* Create payment
|
|
460
|
+
*
|
|
461
|
+
* Create a new payment with specified amount and currency
|
|
462
|
+
*/
|
|
463
|
+
paymentsCreateCreate(data: PaymentCreateRequest$1): Promise<PaymentCreateResponse$1>;
|
|
464
|
+
transactionsList(limit?: number, offset?: number, type?: string): Promise<any>;
|
|
465
|
+
transactionsList(params?: {
|
|
466
|
+
limit?: number;
|
|
467
|
+
offset?: number;
|
|
468
|
+
type?: string;
|
|
469
|
+
}): Promise<any>;
|
|
470
|
+
withdrawalsList(page?: number, page_size?: number): Promise<PaginatedWithdrawalListList>;
|
|
471
|
+
withdrawalsList(params?: {
|
|
472
|
+
page?: number;
|
|
473
|
+
page_size?: number;
|
|
474
|
+
}): Promise<PaginatedWithdrawalListList>;
|
|
475
|
+
/**
|
|
476
|
+
* ViewSet for withdrawal operations. Endpoints: - GET /withdrawals/ - List
|
|
477
|
+
* user's withdrawal requests - GET /withdrawals/{id}/ - Get withdrawal
|
|
478
|
+
* details - POST /withdrawals/create/ - Create withdrawal request - POST
|
|
479
|
+
* /withdrawals/{id}/cancel/ - Cancel pending withdrawal
|
|
480
|
+
*/
|
|
481
|
+
withdrawalsRetrieve(id: string): Promise<WithdrawalDetail>;
|
|
482
|
+
/**
|
|
483
|
+
* Cancel withdrawal request
|
|
484
|
+
*
|
|
485
|
+
* Cancel a pending withdrawal request
|
|
486
|
+
*/
|
|
487
|
+
withdrawalsCancelCreate(id: string): Promise<WithdrawalCancelResponse$1>;
|
|
488
|
+
/**
|
|
489
|
+
* Create withdrawal request
|
|
490
|
+
*
|
|
491
|
+
* Create a new withdrawal request (requires admin approval)
|
|
492
|
+
*/
|
|
493
|
+
withdrawalsCreateCreate(data: WithdrawalCreateRequest$1): Promise<WithdrawalCreateResponse$1>;
|
|
494
|
+
}
|
|
495
|
+
|
|
496
|
+
/**
|
|
497
|
+
* API Logger with Consola
|
|
498
|
+
* Beautiful console logging for API requests and responses
|
|
499
|
+
*
|
|
500
|
+
* Installation:
|
|
501
|
+
* npm install consola
|
|
502
|
+
*/
|
|
503
|
+
|
|
504
|
+
/**
|
|
505
|
+
* Request log data
|
|
506
|
+
*/
|
|
507
|
+
interface RequestLog {
|
|
508
|
+
method: string;
|
|
509
|
+
url: string;
|
|
510
|
+
headers?: Record<string, string>;
|
|
511
|
+
body?: any;
|
|
512
|
+
timestamp: number;
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Response log data
|
|
516
|
+
*/
|
|
517
|
+
interface ResponseLog {
|
|
518
|
+
status: number;
|
|
519
|
+
statusText: string;
|
|
520
|
+
data?: any;
|
|
521
|
+
duration: number;
|
|
522
|
+
timestamp: number;
|
|
523
|
+
}
|
|
524
|
+
/**
|
|
525
|
+
* Error log data
|
|
526
|
+
*/
|
|
527
|
+
interface ErrorLog {
|
|
528
|
+
message: string;
|
|
529
|
+
statusCode?: number;
|
|
530
|
+
fieldErrors?: Record<string, string[]>;
|
|
531
|
+
duration: number;
|
|
532
|
+
timestamp: number;
|
|
533
|
+
}
|
|
534
|
+
/**
|
|
535
|
+
* Logger configuration
|
|
536
|
+
*/
|
|
537
|
+
interface LoggerConfig {
|
|
538
|
+
/** Enable logging */
|
|
539
|
+
enabled: boolean;
|
|
540
|
+
/** Log requests */
|
|
541
|
+
logRequests: boolean;
|
|
542
|
+
/** Log responses */
|
|
543
|
+
logResponses: boolean;
|
|
544
|
+
/** Log errors */
|
|
545
|
+
logErrors: boolean;
|
|
546
|
+
/** Log request/response bodies */
|
|
547
|
+
logBodies: boolean;
|
|
548
|
+
/** Log headers (excluding sensitive ones) */
|
|
549
|
+
logHeaders: boolean;
|
|
550
|
+
/** Custom consola instance */
|
|
551
|
+
consola?: ConsolaInstance;
|
|
552
|
+
}
|
|
553
|
+
/**
|
|
554
|
+
* API Logger class
|
|
555
|
+
*/
|
|
556
|
+
declare class APILogger {
|
|
557
|
+
private config;
|
|
558
|
+
private consola;
|
|
559
|
+
constructor(config?: Partial<LoggerConfig>);
|
|
560
|
+
/**
|
|
561
|
+
* Enable logging
|
|
562
|
+
*/
|
|
563
|
+
enable(): void;
|
|
564
|
+
/**
|
|
565
|
+
* Disable logging
|
|
566
|
+
*/
|
|
567
|
+
disable(): void;
|
|
568
|
+
/**
|
|
569
|
+
* Update configuration
|
|
570
|
+
*/
|
|
571
|
+
setConfig(config: Partial<LoggerConfig>): void;
|
|
572
|
+
/**
|
|
573
|
+
* Filter sensitive headers
|
|
574
|
+
*/
|
|
575
|
+
private filterHeaders;
|
|
576
|
+
/**
|
|
577
|
+
* Log request
|
|
578
|
+
*/
|
|
579
|
+
logRequest(request: RequestLog): void;
|
|
580
|
+
/**
|
|
581
|
+
* Log response
|
|
582
|
+
*/
|
|
583
|
+
logResponse(request: RequestLog, response: ResponseLog): void;
|
|
584
|
+
/**
|
|
585
|
+
* Log error
|
|
586
|
+
*/
|
|
587
|
+
logError(request: RequestLog, error: ErrorLog): void;
|
|
588
|
+
/**
|
|
589
|
+
* Log general info
|
|
590
|
+
*/
|
|
591
|
+
info(message: string, ...args: any[]): void;
|
|
592
|
+
/**
|
|
593
|
+
* Log warning
|
|
594
|
+
*/
|
|
595
|
+
warn(message: string, ...args: any[]): void;
|
|
596
|
+
/**
|
|
597
|
+
* Log error
|
|
598
|
+
*/
|
|
599
|
+
error(message: string, ...args: any[]): void;
|
|
600
|
+
/**
|
|
601
|
+
* Log debug
|
|
602
|
+
*/
|
|
603
|
+
debug(message: string, ...args: any[]): void;
|
|
604
|
+
/**
|
|
605
|
+
* Log success
|
|
606
|
+
*/
|
|
607
|
+
success(message: string, ...args: any[]): void;
|
|
608
|
+
/**
|
|
609
|
+
* Create a sub-logger with prefix
|
|
610
|
+
*/
|
|
611
|
+
withTag(tag: string): ConsolaInstance;
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
/**
|
|
615
|
+
* Retry Configuration and Utilities
|
|
616
|
+
*
|
|
617
|
+
* Provides automatic retry logic for failed HTTP requests using p-retry.
|
|
618
|
+
* Retries only on network errors and server errors (5xx), not client errors (4xx).
|
|
619
|
+
*/
|
|
620
|
+
/**
|
|
621
|
+
* Information about a failed retry attempt.
|
|
622
|
+
*/
|
|
623
|
+
interface FailedAttemptInfo {
|
|
624
|
+
/** The error that caused the failure */
|
|
625
|
+
error: Error;
|
|
626
|
+
/** The attempt number (1-indexed) */
|
|
627
|
+
attemptNumber: number;
|
|
628
|
+
/** Number of retries left */
|
|
629
|
+
retriesLeft: number;
|
|
630
|
+
}
|
|
631
|
+
/**
|
|
632
|
+
* Retry configuration options.
|
|
633
|
+
*
|
|
634
|
+
* Uses exponential backoff with jitter by default to avoid thundering herd.
|
|
635
|
+
*/
|
|
636
|
+
interface RetryConfig {
|
|
637
|
+
/**
|
|
638
|
+
* Maximum number of retry attempts.
|
|
639
|
+
* @default 3
|
|
640
|
+
*/
|
|
641
|
+
retries?: number;
|
|
642
|
+
/**
|
|
643
|
+
* Exponential backoff factor.
|
|
644
|
+
* @default 2
|
|
645
|
+
*/
|
|
646
|
+
factor?: number;
|
|
647
|
+
/**
|
|
648
|
+
* Minimum wait time between retries (ms).
|
|
649
|
+
* @default 1000
|
|
650
|
+
*/
|
|
651
|
+
minTimeout?: number;
|
|
652
|
+
/**
|
|
653
|
+
* Maximum wait time between retries (ms).
|
|
654
|
+
* @default 60000
|
|
655
|
+
*/
|
|
656
|
+
maxTimeout?: number;
|
|
657
|
+
/**
|
|
658
|
+
* Add randomness to wait times (jitter).
|
|
659
|
+
* Helps avoid thundering herd problem.
|
|
660
|
+
* @default true
|
|
661
|
+
*/
|
|
662
|
+
randomize?: boolean;
|
|
663
|
+
/**
|
|
664
|
+
* Callback called on each failed attempt.
|
|
665
|
+
*/
|
|
666
|
+
onFailedAttempt?: (info: FailedAttemptInfo) => void;
|
|
667
|
+
}
|
|
668
|
+
/**
|
|
669
|
+
* Default retry configuration.
|
|
670
|
+
*/
|
|
671
|
+
declare const DEFAULT_RETRY_CONFIG: Required<RetryConfig>;
|
|
672
|
+
/**
|
|
673
|
+
* Determine if an error should trigger a retry.
|
|
674
|
+
*
|
|
675
|
+
* Retries on:
|
|
676
|
+
* - Network errors (connection refused, timeout, etc.)
|
|
677
|
+
* - Server errors (5xx status codes)
|
|
678
|
+
* - Rate limiting (429 status code)
|
|
679
|
+
*
|
|
680
|
+
* Does NOT retry on:
|
|
681
|
+
* - Client errors (4xx except 429)
|
|
682
|
+
* - Authentication errors (401, 403)
|
|
683
|
+
* - Not found (404)
|
|
684
|
+
*
|
|
685
|
+
* @param error - The error to check
|
|
686
|
+
* @returns true if should retry, false otherwise
|
|
687
|
+
*/
|
|
688
|
+
declare function shouldRetry(error: any): boolean;
|
|
689
|
+
/**
|
|
690
|
+
* Wrap a function with retry logic.
|
|
691
|
+
*
|
|
692
|
+
* @param fn - Async function to retry
|
|
693
|
+
* @param config - Retry configuration
|
|
694
|
+
* @returns Result of the function
|
|
695
|
+
*
|
|
696
|
+
* @example
|
|
697
|
+
* ```typescript
|
|
698
|
+
* const result = await withRetry(
|
|
699
|
+
* async () => fetch('https://api.example.com/users'),
|
|
700
|
+
* { retries: 5, minTimeout: 2000 }
|
|
701
|
+
* );
|
|
702
|
+
* ```
|
|
703
|
+
*/
|
|
704
|
+
declare function withRetry<T>(fn: () => Promise<T>, config?: RetryConfig): Promise<T>;
|
|
705
|
+
|
|
706
|
+
/**
|
|
707
|
+
* Storage adapters for cross-platform token storage.
|
|
708
|
+
*
|
|
709
|
+
* Supports:
|
|
710
|
+
* - LocalStorage (browser)
|
|
711
|
+
* - Cookies (SSR/browser)
|
|
712
|
+
* - Memory (Node.js/Electron/testing)
|
|
713
|
+
*/
|
|
714
|
+
|
|
715
|
+
/**
|
|
716
|
+
* Storage adapter interface for cross-platform token storage.
|
|
717
|
+
*/
|
|
718
|
+
interface StorageAdapter {
|
|
719
|
+
getItem(key: string): string | null;
|
|
720
|
+
setItem(key: string, value: string): void;
|
|
721
|
+
removeItem(key: string): void;
|
|
722
|
+
}
|
|
723
|
+
/**
|
|
724
|
+
* LocalStorage adapter with safe try-catch for browser environments.
|
|
725
|
+
* Works in modern browsers with localStorage support.
|
|
726
|
+
*
|
|
727
|
+
* Note: This adapter uses window.localStorage and should only be used in browser/client environments.
|
|
728
|
+
* For server-side usage, use MemoryStorageAdapter or CookieStorageAdapter instead.
|
|
729
|
+
*/
|
|
730
|
+
declare class LocalStorageAdapter implements StorageAdapter {
|
|
731
|
+
private logger?;
|
|
732
|
+
constructor(logger?: APILogger);
|
|
733
|
+
getItem(key: string): string | null;
|
|
734
|
+
setItem(key: string, value: string): void;
|
|
735
|
+
removeItem(key: string): void;
|
|
736
|
+
}
|
|
737
|
+
/**
|
|
738
|
+
* Cookie-based storage adapter for SSR and browser environments.
|
|
739
|
+
* Useful for Next.js, Nuxt.js, and other SSR frameworks.
|
|
740
|
+
*/
|
|
741
|
+
declare class CookieStorageAdapter implements StorageAdapter {
|
|
742
|
+
private logger?;
|
|
743
|
+
constructor(logger?: APILogger);
|
|
744
|
+
getItem(key: string): string | null;
|
|
745
|
+
setItem(key: string, value: string): void;
|
|
746
|
+
removeItem(key: string): void;
|
|
747
|
+
}
|
|
748
|
+
/**
|
|
749
|
+
* In-memory storage adapter for Node.js, Electron, and testing environments.
|
|
750
|
+
* Data is stored in RAM and cleared when process exits.
|
|
751
|
+
*/
|
|
752
|
+
declare class MemoryStorageAdapter implements StorageAdapter {
|
|
753
|
+
private storage;
|
|
754
|
+
private logger?;
|
|
755
|
+
constructor(logger?: APILogger);
|
|
756
|
+
getItem(key: string): string | null;
|
|
757
|
+
setItem(key: string, value: string): void;
|
|
758
|
+
removeItem(key: string): void;
|
|
759
|
+
}
|
|
760
|
+
|
|
761
|
+
/**
|
|
762
|
+
* Zod schema for PaymentCreateRequest
|
|
763
|
+
*
|
|
764
|
+
* This schema provides runtime validation and type inference.
|
|
765
|
+
* * Serializer for creating payment.
|
|
766
|
+
* */
|
|
767
|
+
|
|
768
|
+
/**
|
|
769
|
+
* Serializer for creating payment.
|
|
770
|
+
*/
|
|
771
|
+
declare const PaymentCreateRequestSchema: z.ZodObject<{
|
|
772
|
+
amount_usd: z.ZodString;
|
|
773
|
+
currency_code: z.ZodString;
|
|
774
|
+
description: z.ZodOptional<z.ZodString>;
|
|
775
|
+
}, z.core.$strip>;
|
|
776
|
+
/**
|
|
777
|
+
* Infer TypeScript type from Zod schema
|
|
778
|
+
*/
|
|
779
|
+
type PaymentCreateRequest = z.infer<typeof PaymentCreateRequestSchema>;
|
|
780
|
+
|
|
781
|
+
/**
|
|
782
|
+
* Response for payment creation.
|
|
783
|
+
*/
|
|
784
|
+
declare const PaymentCreateResponseSchema: z.ZodObject<{
|
|
785
|
+
success: z.ZodBoolean;
|
|
786
|
+
payment: z.ZodObject<{
|
|
787
|
+
id: z.ZodString;
|
|
788
|
+
internal_payment_id: z.ZodString;
|
|
789
|
+
amount_usd: z.ZodString;
|
|
790
|
+
currency_code: z.ZodString;
|
|
791
|
+
currency_name: z.ZodString;
|
|
792
|
+
currency_token: z.ZodString;
|
|
793
|
+
currency_network: z.ZodString;
|
|
794
|
+
pay_amount: z.ZodNullable<z.ZodString>;
|
|
795
|
+
actual_amount: z.ZodNullable<z.ZodString>;
|
|
796
|
+
actual_amount_usd: z.ZodNullable<z.ZodString>;
|
|
797
|
+
status: z.ZodEnum<typeof PaymentDetailStatus>;
|
|
798
|
+
status_display: z.ZodString;
|
|
799
|
+
pay_address: z.ZodNullable<z.ZodString>;
|
|
800
|
+
qr_code_url: z.ZodNullable<z.ZodString>;
|
|
801
|
+
payment_url: z.ZodNullable<z.ZodUnion<readonly [z.ZodURL, z.ZodLiteral<"">]>>;
|
|
802
|
+
transaction_hash: z.ZodNullable<z.ZodString>;
|
|
803
|
+
explorer_link: z.ZodNullable<z.ZodString>;
|
|
804
|
+
confirmations_count: z.ZodInt;
|
|
805
|
+
expires_at: z.ZodNullable<z.ZodString>;
|
|
806
|
+
completed_at: z.ZodNullable<z.ZodString>;
|
|
807
|
+
created_at: z.ZodString;
|
|
808
|
+
is_completed: z.ZodBoolean;
|
|
809
|
+
is_failed: z.ZodBoolean;
|
|
810
|
+
is_expired: z.ZodBoolean;
|
|
811
|
+
description: z.ZodString;
|
|
812
|
+
}, z.core.$strip>;
|
|
813
|
+
qr_code_url: z.ZodNullable<z.ZodUnion<readonly [z.ZodURL, z.ZodLiteral<"">]>>;
|
|
814
|
+
}, z.core.$strip>;
|
|
815
|
+
/**
|
|
816
|
+
* Infer TypeScript type from Zod schema
|
|
817
|
+
*/
|
|
818
|
+
type PaymentCreateResponse = z.infer<typeof PaymentCreateResponseSchema>;
|
|
819
|
+
|
|
820
|
+
/**
|
|
821
|
+
* Zod schema for PaymentList
|
|
822
|
+
*
|
|
823
|
+
* This schema provides runtime validation and type inference.
|
|
824
|
+
* * Payment list item (lighter than detail).
|
|
825
|
+
* */
|
|
826
|
+
|
|
827
|
+
/**
|
|
828
|
+
* Payment list item (lighter than detail).
|
|
829
|
+
*/
|
|
830
|
+
declare const PaymentListSchema: z.ZodObject<{
|
|
831
|
+
id: z.ZodString;
|
|
832
|
+
internal_payment_id: z.ZodString;
|
|
833
|
+
amount_usd: z.ZodString;
|
|
834
|
+
currency_code: z.ZodString;
|
|
835
|
+
currency_token: z.ZodString;
|
|
836
|
+
status: z.ZodEnum<typeof PaymentListStatus>;
|
|
837
|
+
status_display: z.ZodString;
|
|
838
|
+
created_at: z.ZodString;
|
|
839
|
+
completed_at: z.ZodNullable<z.ZodString>;
|
|
840
|
+
}, z.core.$strip>;
|
|
841
|
+
/**
|
|
842
|
+
* Infer TypeScript type from Zod schema
|
|
843
|
+
*/
|
|
844
|
+
type PaymentList = z.infer<typeof PaymentListSchema>;
|
|
845
|
+
|
|
846
|
+
/**
|
|
847
|
+
* Response for withdrawal cancellation.
|
|
848
|
+
*/
|
|
849
|
+
declare const WithdrawalCancelResponseSchema: z.ZodObject<{
|
|
850
|
+
success: z.ZodBoolean;
|
|
851
|
+
withdrawal: z.ZodObject<{
|
|
852
|
+
id: z.ZodString;
|
|
853
|
+
internal_withdrawal_id: z.ZodString;
|
|
854
|
+
amount_usd: z.ZodString;
|
|
855
|
+
currency_code: z.ZodString;
|
|
856
|
+
currency_name: z.ZodString;
|
|
857
|
+
currency_token: z.ZodString;
|
|
858
|
+
currency_network: z.ZodString;
|
|
859
|
+
wallet_address: z.ZodString;
|
|
860
|
+
network_fee_usd: z.ZodString;
|
|
861
|
+
service_fee_usd: z.ZodString;
|
|
862
|
+
total_fee_usd: z.ZodString;
|
|
863
|
+
final_amount_usd: z.ZodString;
|
|
864
|
+
crypto_amount: z.ZodNullable<z.ZodString>;
|
|
865
|
+
status: z.ZodEnum<typeof WithdrawalDetailStatus>;
|
|
866
|
+
status_display: z.ZodString;
|
|
867
|
+
transaction_hash: z.ZodNullable<z.ZodString>;
|
|
868
|
+
explorer_link: z.ZodNullable<z.ZodString>;
|
|
869
|
+
admin_notes: z.ZodString;
|
|
870
|
+
created_at: z.ZodString;
|
|
871
|
+
approved_at: z.ZodNullable<z.ZodString>;
|
|
872
|
+
completed_at: z.ZodNullable<z.ZodString>;
|
|
873
|
+
rejected_at: z.ZodNullable<z.ZodString>;
|
|
874
|
+
cancelled_at: z.ZodNullable<z.ZodString>;
|
|
875
|
+
}, z.core.$strip>;
|
|
876
|
+
message: z.ZodString;
|
|
877
|
+
}, z.core.$strip>;
|
|
878
|
+
/**
|
|
879
|
+
* Infer TypeScript type from Zod schema
|
|
880
|
+
*/
|
|
881
|
+
type WithdrawalCancelResponse = z.infer<typeof WithdrawalCancelResponseSchema>;
|
|
882
|
+
|
|
883
|
+
/**
|
|
884
|
+
* Zod schema for WithdrawalCreateRequest
|
|
885
|
+
*
|
|
886
|
+
* This schema provides runtime validation and type inference.
|
|
887
|
+
* * Serializer for creating withdrawal request.
|
|
888
|
+
* */
|
|
889
|
+
|
|
890
|
+
/**
|
|
891
|
+
* Serializer for creating withdrawal request.
|
|
892
|
+
*/
|
|
893
|
+
declare const WithdrawalCreateRequestSchema: z.ZodObject<{
|
|
894
|
+
amount_usd: z.ZodString;
|
|
895
|
+
currency_code: z.ZodString;
|
|
896
|
+
wallet_address: z.ZodString;
|
|
897
|
+
}, z.core.$strip>;
|
|
898
|
+
/**
|
|
899
|
+
* Infer TypeScript type from Zod schema
|
|
900
|
+
*/
|
|
901
|
+
type WithdrawalCreateRequest = z.infer<typeof WithdrawalCreateRequestSchema>;
|
|
902
|
+
|
|
903
|
+
/**
|
|
904
|
+
* Response for withdrawal creation.
|
|
905
|
+
*/
|
|
906
|
+
declare const WithdrawalCreateResponseSchema: z.ZodObject<{
|
|
907
|
+
success: z.ZodBoolean;
|
|
908
|
+
withdrawal: z.ZodObject<{
|
|
909
|
+
id: z.ZodString;
|
|
910
|
+
internal_withdrawal_id: z.ZodString;
|
|
911
|
+
amount_usd: z.ZodString;
|
|
912
|
+
currency_code: z.ZodString;
|
|
913
|
+
currency_name: z.ZodString;
|
|
914
|
+
currency_token: z.ZodString;
|
|
915
|
+
currency_network: z.ZodString;
|
|
916
|
+
wallet_address: z.ZodString;
|
|
917
|
+
network_fee_usd: z.ZodString;
|
|
918
|
+
service_fee_usd: z.ZodString;
|
|
919
|
+
total_fee_usd: z.ZodString;
|
|
920
|
+
final_amount_usd: z.ZodString;
|
|
921
|
+
crypto_amount: z.ZodNullable<z.ZodString>;
|
|
922
|
+
status: z.ZodEnum<typeof WithdrawalDetailStatus>;
|
|
923
|
+
status_display: z.ZodString;
|
|
924
|
+
transaction_hash: z.ZodNullable<z.ZodString>;
|
|
925
|
+
explorer_link: z.ZodNullable<z.ZodString>;
|
|
926
|
+
admin_notes: z.ZodString;
|
|
927
|
+
created_at: z.ZodString;
|
|
928
|
+
approved_at: z.ZodNullable<z.ZodString>;
|
|
929
|
+
completed_at: z.ZodNullable<z.ZodString>;
|
|
930
|
+
rejected_at: z.ZodNullable<z.ZodString>;
|
|
931
|
+
cancelled_at: z.ZodNullable<z.ZodString>;
|
|
932
|
+
}, z.core.$strip>;
|
|
933
|
+
message: z.ZodString;
|
|
934
|
+
}, z.core.$strip>;
|
|
935
|
+
/**
|
|
936
|
+
* Infer TypeScript type from Zod schema
|
|
937
|
+
*/
|
|
938
|
+
type WithdrawalCreateResponse = z.infer<typeof WithdrawalCreateResponseSchema>;
|
|
939
|
+
|
|
940
|
+
/**
|
|
941
|
+
* Cmdop API - API Client with JWT Management
|
|
942
|
+
*
|
|
943
|
+
* Usage:
|
|
944
|
+
* ```typescript
|
|
945
|
+
* import { API } from './api';
|
|
946
|
+
*
|
|
947
|
+
* const api = new API('https://api.example.com');
|
|
948
|
+
*
|
|
949
|
+
* // Set JWT token
|
|
950
|
+
* api.setToken('your-jwt-token', 'refresh-token');
|
|
951
|
+
*
|
|
952
|
+
* // Use API
|
|
953
|
+
* const posts = await api.posts.list();
|
|
954
|
+
* const user = await api.users.retrieve(1);
|
|
955
|
+
*
|
|
956
|
+
* // Check authentication
|
|
957
|
+
* if (api.isAuthenticated()) {
|
|
958
|
+
* // ...
|
|
959
|
+
* }
|
|
960
|
+
*
|
|
961
|
+
* // Custom storage with logging (for Electron/Node.js)
|
|
962
|
+
* import { MemoryStorageAdapter, APILogger } from './storage';
|
|
963
|
+
* const logger = new APILogger({ enabled: true, logLevel: 'debug' });
|
|
964
|
+
* const api = new API('https://api.example.com', {
|
|
965
|
+
* storage: new MemoryStorageAdapter(logger),
|
|
966
|
+
* loggerConfig: { enabled: true, logLevel: 'debug' }
|
|
967
|
+
* });
|
|
968
|
+
*
|
|
969
|
+
* // Get OpenAPI schema
|
|
970
|
+
* const schema = api.getSchema();
|
|
971
|
+
* ```
|
|
972
|
+
*/
|
|
973
|
+
|
|
974
|
+
declare const TOKEN_KEY = "auth_token";
|
|
975
|
+
declare const REFRESH_TOKEN_KEY = "refresh_token";
|
|
976
|
+
interface APIOptions {
|
|
977
|
+
/** Custom storage adapter (defaults to LocalStorageAdapter) */
|
|
978
|
+
storage?: StorageAdapter;
|
|
979
|
+
/** Retry configuration for failed requests */
|
|
980
|
+
retryConfig?: RetryConfig;
|
|
981
|
+
/** Logger configuration */
|
|
982
|
+
loggerConfig?: Partial<LoggerConfig>;
|
|
983
|
+
}
|
|
984
|
+
declare class API {
|
|
985
|
+
private baseUrl;
|
|
986
|
+
private _client;
|
|
987
|
+
private _token;
|
|
988
|
+
private _refreshToken;
|
|
989
|
+
private storage;
|
|
990
|
+
private options?;
|
|
991
|
+
ext_payments_payments: ExtPaymentsPayments;
|
|
992
|
+
constructor(baseUrl: string, options?: APIOptions);
|
|
993
|
+
private _loadTokensFromStorage;
|
|
994
|
+
private _reinitClients;
|
|
995
|
+
private _injectAuthHeader;
|
|
996
|
+
/**
|
|
997
|
+
* Get current JWT token
|
|
998
|
+
*/
|
|
999
|
+
getToken(): string | null;
|
|
1000
|
+
/**
|
|
1001
|
+
* Get current refresh token
|
|
1002
|
+
*/
|
|
1003
|
+
getRefreshToken(): string | null;
|
|
1004
|
+
/**
|
|
1005
|
+
* Set JWT token and refresh token
|
|
1006
|
+
* @param token - JWT access token
|
|
1007
|
+
* @param refreshToken - JWT refresh token (optional)
|
|
1008
|
+
*/
|
|
1009
|
+
setToken(token: string, refreshToken?: string): void;
|
|
1010
|
+
/**
|
|
1011
|
+
* Clear all tokens
|
|
1012
|
+
*/
|
|
1013
|
+
clearTokens(): void;
|
|
1014
|
+
/**
|
|
1015
|
+
* Check if user is authenticated
|
|
1016
|
+
*/
|
|
1017
|
+
isAuthenticated(): boolean;
|
|
1018
|
+
/**
|
|
1019
|
+
* Update base URL and reinitialize clients
|
|
1020
|
+
* @param url - New base URL
|
|
1021
|
+
*/
|
|
1022
|
+
setBaseUrl(url: string): void;
|
|
1023
|
+
/**
|
|
1024
|
+
* Get current base URL
|
|
1025
|
+
*/
|
|
1026
|
+
getBaseUrl(): string;
|
|
1027
|
+
/**
|
|
1028
|
+
* Get OpenAPI schema path
|
|
1029
|
+
* @returns Path to the OpenAPI schema JSON file
|
|
1030
|
+
*
|
|
1031
|
+
* Note: The OpenAPI schema is available in the schema.json file.
|
|
1032
|
+
* You can load it dynamically using:
|
|
1033
|
+
* ```typescript
|
|
1034
|
+
* const schema = await fetch('./schema.json').then(r => r.json());
|
|
1035
|
+
* // or using fs in Node.js:
|
|
1036
|
+
* // const schema = JSON.parse(fs.readFileSync('./schema.json', 'utf-8'));
|
|
1037
|
+
* ```
|
|
1038
|
+
*/
|
|
1039
|
+
getSchemaPath(): string;
|
|
1040
|
+
}
|
|
1041
|
+
|
|
1042
|
+
/**
|
|
1043
|
+
* SWR Hooks for Payments
|
|
1044
|
+
*
|
|
1045
|
+
* React hooks powered by SWR for data fetching with automatic caching,
|
|
1046
|
+
* revalidation, and optimistic updates.
|
|
1047
|
+
*
|
|
1048
|
+
* Usage:
|
|
1049
|
+
* ```typescript
|
|
1050
|
+
* // Query hooks (GET)
|
|
1051
|
+
* const { data, error, isLoading } = useUsers({ page: 1 })
|
|
1052
|
+
*
|
|
1053
|
+
* // Mutation hooks (POST/PUT/PATCH/DELETE)
|
|
1054
|
+
* const createUser = useCreateUser()
|
|
1055
|
+
* await createUser({ name: 'John', email: 'john@example.com' })
|
|
1056
|
+
* ```
|
|
1057
|
+
*/
|
|
1058
|
+
|
|
1059
|
+
/**
|
|
1060
|
+
* Get user balance
|
|
1061
|
+
*
|
|
1062
|
+
* @method GET
|
|
1063
|
+
* @path /cfg/payments/balance/
|
|
1064
|
+
*/
|
|
1065
|
+
declare function usePaymentsBalanceRetrieve(client?: API): ReturnType<typeof useSWR<Balance>>;
|
|
1066
|
+
/**
|
|
1067
|
+
* Get available currencies
|
|
1068
|
+
*
|
|
1069
|
+
* @method GET
|
|
1070
|
+
* @path /cfg/payments/currencies/
|
|
1071
|
+
*/
|
|
1072
|
+
declare function usePaymentsCurrenciesList(client?: API): ReturnType<typeof useSWR<any>>;
|
|
1073
|
+
/**
|
|
1074
|
+
* Get currency estimate
|
|
1075
|
+
*
|
|
1076
|
+
* @method GET
|
|
1077
|
+
* @path /cfg/payments/currencies/{code}/estimate/
|
|
1078
|
+
*/
|
|
1079
|
+
declare function usePaymentsCurrenciesEstimateRetrieve(code: string, params?: {
|
|
1080
|
+
amount?: number;
|
|
1081
|
+
}, client?: API): ReturnType<typeof useSWR<any>>;
|
|
1082
|
+
/**
|
|
1083
|
+
* Get withdrawal estimate
|
|
1084
|
+
*
|
|
1085
|
+
* @method GET
|
|
1086
|
+
* @path /cfg/payments/currencies/{code}/withdrawal-estimate/
|
|
1087
|
+
*/
|
|
1088
|
+
declare function usePaymentsCurrenciesWithdrawalEstimateRetrieve(code: string, params?: {
|
|
1089
|
+
amount?: number;
|
|
1090
|
+
}, client?: API): ReturnType<typeof useSWR<any>>;
|
|
1091
|
+
/**
|
|
1092
|
+
* API operation
|
|
1093
|
+
*
|
|
1094
|
+
* @method GET
|
|
1095
|
+
* @path /cfg/payments/payments/
|
|
1096
|
+
*/
|
|
1097
|
+
declare function usePaymentsPaymentsList(params?: {
|
|
1098
|
+
page?: number;
|
|
1099
|
+
page_size?: number;
|
|
1100
|
+
}, client?: API): ReturnType<typeof useSWR<PaginatedPaymentListList>>;
|
|
1101
|
+
/**
|
|
1102
|
+
* API operation
|
|
1103
|
+
*
|
|
1104
|
+
* @method GET
|
|
1105
|
+
* @path /cfg/payments/payments/{id}/
|
|
1106
|
+
*/
|
|
1107
|
+
declare function usePaymentsPaymentsRetrieve(id: string, client?: API): ReturnType<typeof useSWR<PaymentDetail>>;
|
|
1108
|
+
/**
|
|
1109
|
+
* API operation
|
|
1110
|
+
*
|
|
1111
|
+
* @method POST
|
|
1112
|
+
* @path /cfg/payments/payments/{id}/confirm/
|
|
1113
|
+
*/
|
|
1114
|
+
declare function useCreatePaymentsPaymentsConfirmCreate(): (id: string, client?: API) => Promise<PaymentList>;
|
|
1115
|
+
/**
|
|
1116
|
+
* API operation
|
|
1117
|
+
*
|
|
1118
|
+
* @method GET
|
|
1119
|
+
* @path /cfg/payments/payments/{id}/status/
|
|
1120
|
+
*/
|
|
1121
|
+
declare function usePaymentsPaymentsStatusRetrieve(id: string, client?: API): ReturnType<typeof useSWR<PaymentList>>;
|
|
1122
|
+
/**
|
|
1123
|
+
* Create payment
|
|
1124
|
+
*
|
|
1125
|
+
* @method POST
|
|
1126
|
+
* @path /cfg/payments/payments/create/
|
|
1127
|
+
*/
|
|
1128
|
+
declare function useCreatePaymentsPaymentsCreateCreate(): (data: PaymentCreateRequest, client?: API) => Promise<PaymentCreateResponse>;
|
|
1129
|
+
/**
|
|
1130
|
+
* Get user transactions
|
|
1131
|
+
*
|
|
1132
|
+
* @method GET
|
|
1133
|
+
* @path /cfg/payments/transactions/
|
|
1134
|
+
*/
|
|
1135
|
+
declare function usePaymentsTransactionsList(params?: {
|
|
1136
|
+
limit?: number;
|
|
1137
|
+
offset?: number;
|
|
1138
|
+
type?: string;
|
|
1139
|
+
}, client?: API): ReturnType<typeof useSWR<any>>;
|
|
1140
|
+
/**
|
|
1141
|
+
* API operation
|
|
1142
|
+
*
|
|
1143
|
+
* @method GET
|
|
1144
|
+
* @path /cfg/payments/withdrawals/
|
|
1145
|
+
*/
|
|
1146
|
+
declare function usePaymentsWithdrawalsList(params?: {
|
|
1147
|
+
page?: number;
|
|
1148
|
+
page_size?: number;
|
|
1149
|
+
}, client?: API): ReturnType<typeof useSWR<PaginatedWithdrawalListList>>;
|
|
1150
|
+
/**
|
|
1151
|
+
* API operation
|
|
1152
|
+
*
|
|
1153
|
+
* @method GET
|
|
1154
|
+
* @path /cfg/payments/withdrawals/{id}/
|
|
1155
|
+
*/
|
|
1156
|
+
declare function usePaymentsWithdrawalsRetrieve(id: string, client?: API): ReturnType<typeof useSWR<WithdrawalDetail>>;
|
|
1157
|
+
/**
|
|
1158
|
+
* Cancel withdrawal request
|
|
1159
|
+
*
|
|
1160
|
+
* @method POST
|
|
1161
|
+
* @path /cfg/payments/withdrawals/{id}/cancel/
|
|
1162
|
+
*/
|
|
1163
|
+
declare function useCreatePaymentsWithdrawalsCancelCreate(): (id: string, client?: API) => Promise<WithdrawalCancelResponse>;
|
|
1164
|
+
/**
|
|
1165
|
+
* Create withdrawal request
|
|
1166
|
+
*
|
|
1167
|
+
* @method POST
|
|
1168
|
+
* @path /cfg/payments/withdrawals/create/
|
|
1169
|
+
*/
|
|
1170
|
+
declare function useCreatePaymentsWithdrawalsCreateCreate(): (data: WithdrawalCreateRequest, client?: API) => Promise<WithdrawalCreateResponse>;
|
|
1171
|
+
|
|
1172
|
+
export { API as A, useCreatePaymentsWithdrawalsCancelCreate as B, useCreatePaymentsWithdrawalsCreateCreate as C, type APIOptions as D, ExtPaymentsPayments as E, LocalStorageAdapter as F, CookieStorageAdapter as G, TOKEN_KEY as H, REFRESH_TOKEN_KEY as I, models as J, enums as K, type LoggerConfig as L, MemoryStorageAdapter as M, type RequestLog as N, type ResponseLog as O, PaymentListStatus as P, type ErrorLog as Q, type RetryConfig as R, type StorageAdapter as S, TransactionTransactionType as T, APILogger as U, type FailedAttemptInfo as V, WithdrawalListStatus as W, withRetry as X, shouldRetry as Y, DEFAULT_RETRY_CONFIG as Z, PaymentDetailStatus as a, WithdrawalDetailStatus as b, type PaymentList as c, type PaymentCreateRequest as d, type PaymentCreateResponse as e, type WithdrawalCancelResponse as f, type WithdrawalCreateRequest as g, type WithdrawalCreateResponse as h, PaymentCreateRequestSchema as i, PaymentCreateResponseSchema as j, PaymentListSchema as k, WithdrawalCancelResponseSchema as l, WithdrawalCreateRequestSchema as m, WithdrawalCreateResponseSchema as n, usePaymentsCurrenciesList as o, usePaymentsCurrenciesEstimateRetrieve as p, usePaymentsCurrenciesWithdrawalEstimateRetrieve as q, usePaymentsPaymentsList as r, usePaymentsPaymentsRetrieve as s, useCreatePaymentsPaymentsConfirmCreate as t, usePaymentsBalanceRetrieve as u, usePaymentsPaymentsStatusRetrieve as v, useCreatePaymentsPaymentsCreateCreate as w, usePaymentsTransactionsList as x, usePaymentsWithdrawalsList as y, usePaymentsWithdrawalsRetrieve as z };
|