@djangocfg/ext-payments 1.0.13 → 1.0.17
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/dist/config.cjs +5 -8
- package/dist/config.js +5 -8
- package/dist/hooks.cjs +1 -1
- package/dist/hooks.js +1 -1
- package/dist/index.cjs +1085 -1107
- package/dist/index.d.cts +480 -41
- package/dist/index.d.ts +480 -41
- package/dist/index.js +1037 -1093
- package/package.json +13 -16
- package/src/api/generated/ext_payments/CLAUDE.md +7 -3
- package/src/api/generated/ext_payments/_utils/fetchers/ext_payments__payments.ts +237 -5
- package/src/api/generated/ext_payments/_utils/hooks/ext_payments__payments.ts +71 -3
- package/src/api/generated/ext_payments/_utils/schemas/PaginatedWithdrawalListList.schema.ts +24 -0
- package/src/api/generated/ext_payments/_utils/schemas/PaymentCreateRequest.schema.ts +21 -0
- package/src/api/generated/ext_payments/_utils/schemas/WithdrawalCreateRequest.schema.ts +21 -0
- package/src/api/generated/ext_payments/_utils/schemas/WithdrawalDetail.schema.ts +42 -0
- package/src/api/generated/ext_payments/_utils/schemas/WithdrawalList.schema.ts +29 -0
- package/src/api/generated/ext_payments/_utils/schemas/index.ts +5 -0
- package/src/api/generated/ext_payments/enums.ts +36 -0
- package/src/api/generated/ext_payments/ext_payments__payments/client.ts +58 -5
- package/src/api/generated/ext_payments/ext_payments__payments/models.ts +141 -0
- package/src/api/generated/ext_payments/schema.json +579 -3
- package/src/components/ActivityItem.tsx +118 -0
- package/src/components/ActivityList.tsx +93 -0
- package/src/components/AddFundsSheet.tsx +258 -0
- package/src/components/BalanceHero.tsx +102 -0
- package/src/components/PaymentSheet.tsx +290 -0
- package/src/components/ResponsiveSheet.tsx +151 -0
- package/src/components/WithdrawSheet.tsx +329 -0
- package/src/components/index.ts +18 -0
- package/src/contexts/WalletContext.tsx +355 -0
- package/src/contexts/index.ts +12 -45
- package/src/index.ts +6 -18
- package/src/contexts/BalancesContext.tsx +0 -63
- package/src/contexts/CurrenciesContext.tsx +0 -64
- package/src/contexts/OverviewContext.tsx +0 -173
- package/src/contexts/PaymentsContext.tsx +0 -122
- package/src/contexts/PaymentsExtensionProvider.tsx +0 -56
- package/src/contexts/README.md +0 -201
- package/src/contexts/RootPaymentsContext.tsx +0 -66
- package/src/contexts/types.ts +0 -40
- package/src/hooks/index.ts +0 -20
- package/src/layouts/PaymentsLayout/PaymentsLayout.tsx +0 -90
- package/src/layouts/PaymentsLayout/components/CreatePaymentDialog.tsx +0 -274
- package/src/layouts/PaymentsLayout/components/PaymentDetailsDialog.tsx +0 -287
- package/src/layouts/PaymentsLayout/components/index.ts +0 -2
- package/src/layouts/PaymentsLayout/events.ts +0 -47
- package/src/layouts/PaymentsLayout/index.ts +0 -16
- package/src/layouts/PaymentsLayout/types.ts +0 -6
- package/src/layouts/PaymentsLayout/views/overview/components/BalanceCard.tsx +0 -121
- package/src/layouts/PaymentsLayout/views/overview/components/RecentPayments.tsx +0 -139
- package/src/layouts/PaymentsLayout/views/overview/components/index.ts +0 -2
- package/src/layouts/PaymentsLayout/views/overview/index.tsx +0 -21
- package/src/layouts/PaymentsLayout/views/payments/components/PaymentsList.tsx +0 -279
- package/src/layouts/PaymentsLayout/views/payments/components/index.ts +0 -1
- package/src/layouts/PaymentsLayout/views/payments/index.tsx +0 -18
- package/src/layouts/PaymentsLayout/views/transactions/components/TransactionsList.tsx +0 -260
- package/src/layouts/PaymentsLayout/views/transactions/components/index.ts +0 -1
- package/src/layouts/PaymentsLayout/views/transactions/index.tsx +0 -18
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@djangocfg/ext-payments",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "Payments system extension for DjangoCFG",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"django",
|
|
@@ -37,11 +37,6 @@
|
|
|
37
37
|
"import": "./dist/index.js",
|
|
38
38
|
"require": "./dist/index.cjs"
|
|
39
39
|
},
|
|
40
|
-
"./hooks": {
|
|
41
|
-
"types": "./dist/hooks.d.ts",
|
|
42
|
-
"import": "./dist/hooks.js",
|
|
43
|
-
"require": "./dist/hooks.cjs"
|
|
44
|
-
},
|
|
45
40
|
"./config": {
|
|
46
41
|
"types": "./dist/config.d.ts",
|
|
47
42
|
"import": "./dist/config.js",
|
|
@@ -59,24 +54,26 @@
|
|
|
59
54
|
"check": "tsc --noEmit"
|
|
60
55
|
},
|
|
61
56
|
"peerDependencies": {
|
|
62
|
-
"@djangocfg/api": "^2.1.
|
|
63
|
-
"@djangocfg/ext-base": "^1.0.
|
|
64
|
-
"@djangocfg/ui-core": "^2.1.
|
|
65
|
-
"@djangocfg/ui-nextjs": "^2.1.
|
|
57
|
+
"@djangocfg/api": "^2.1.108",
|
|
58
|
+
"@djangocfg/ext-base": "^1.0.12",
|
|
59
|
+
"@djangocfg/ui-core": "^2.1.108",
|
|
60
|
+
"@djangocfg/ui-nextjs": "^2.1.108",
|
|
66
61
|
"consola": "^3.4.2",
|
|
67
62
|
"lucide-react": "^0.545.0",
|
|
68
63
|
"next": "^16",
|
|
69
64
|
"p-retry": "^7.0.0",
|
|
70
65
|
"react": "^19",
|
|
71
66
|
"swr": "^2.3.7",
|
|
72
|
-
"zod": "^4.
|
|
73
|
-
"moment": "^2.30.1"
|
|
67
|
+
"zod": "^4.3.4",
|
|
68
|
+
"moment": "^2.30.1",
|
|
69
|
+
"react-hook-form": "^7.69.0",
|
|
70
|
+
"@hookform/resolvers": "^5.2.2"
|
|
74
71
|
},
|
|
75
72
|
"devDependencies": {
|
|
76
|
-
"@djangocfg/api": "^2.1.
|
|
77
|
-
"@djangocfg/ext-base": "^1.0.
|
|
78
|
-
"@djangocfg/typescript-config": "^2.1.
|
|
79
|
-
"@djangocfg/ui-nextjs": "^2.1.
|
|
73
|
+
"@djangocfg/api": "^2.1.108",
|
|
74
|
+
"@djangocfg/ext-base": "^1.0.12",
|
|
75
|
+
"@djangocfg/typescript-config": "^2.1.108",
|
|
76
|
+
"@djangocfg/ui-nextjs": "^2.1.108",
|
|
80
77
|
"@types/node": "^24.7.2",
|
|
81
78
|
"@types/react": "^19.0.0",
|
|
82
79
|
"consola": "^3.4.2",
|
|
@@ -11,12 +11,12 @@ python manage.py generate_client --groups ext_payments --typescript
|
|
|
11
11
|
| | |
|
|
12
12
|
|---|---|
|
|
13
13
|
| Version | 3.0.3 |
|
|
14
|
-
| Operations |
|
|
15
|
-
| Schemas |
|
|
14
|
+
| Operations | 12 |
|
|
15
|
+
| Schemas | 11 |
|
|
16
16
|
|
|
17
17
|
## Resources
|
|
18
18
|
|
|
19
|
-
- **payments** (
|
|
19
|
+
- **payments** (12 ops)
|
|
20
20
|
|
|
21
21
|
## Operations
|
|
22
22
|
|
|
@@ -29,6 +29,10 @@ python manage.py generate_client --groups ext_payments --typescript
|
|
|
29
29
|
- `GET` /cfg/payments/payments/{id}/ → `cfg_payments_payments_retrieve`
|
|
30
30
|
- `GET` /cfg/payments/payments/{id}/status/ → `cfg_payments_payments_status_retrieve`
|
|
31
31
|
- `GET` /cfg/payments/transactions/ → `cfg_payments_transactions_list`
|
|
32
|
+
- `POST` /cfg/payments/withdrawals/{id}/cancel/ → `cfg_payments_withdrawals_cancel_create`
|
|
33
|
+
- `POST` /cfg/payments/withdrawals/create/ → `cfg_payments_withdrawals_create_create`
|
|
34
|
+
- `GET` /cfg/payments/withdrawals/ → `cfg_payments_withdrawals_list`
|
|
35
|
+
- `GET` /cfg/payments/withdrawals/{id}/ → `cfg_payments_withdrawals_retrieve`
|
|
32
36
|
|
|
33
37
|
## Usage
|
|
34
38
|
|
|
@@ -33,8 +33,12 @@
|
|
|
33
33
|
import { consola } from 'consola'
|
|
34
34
|
import { BalanceSchema, type Balance } from '../schemas/Balance.schema'
|
|
35
35
|
import { PaginatedPaymentListListSchema, type PaginatedPaymentListList } from '../schemas/PaginatedPaymentListList.schema'
|
|
36
|
+
import { PaginatedWithdrawalListListSchema, type PaginatedWithdrawalListList } from '../schemas/PaginatedWithdrawalListList.schema'
|
|
37
|
+
import { PaymentCreateRequestSchema, type PaymentCreateRequest } from '../schemas/PaymentCreateRequest.schema'
|
|
36
38
|
import { PaymentDetailSchema, type PaymentDetail } from '../schemas/PaymentDetail.schema'
|
|
37
39
|
import { PaymentListSchema, type PaymentList } from '../schemas/PaymentList.schema'
|
|
40
|
+
import { WithdrawalCreateRequestSchema, type WithdrawalCreateRequest } from '../schemas/WithdrawalCreateRequest.schema'
|
|
41
|
+
import { WithdrawalDetailSchema, type WithdrawalDetail } from '../schemas/WithdrawalDetail.schema'
|
|
38
42
|
import { getAPIInstance } from '../../api-instance'
|
|
39
43
|
|
|
40
44
|
/**
|
|
@@ -337,17 +341,17 @@ export async function getPaymentsPaymentsStatusRetrieve( id: string, client?:
|
|
|
337
341
|
|
|
338
342
|
|
|
339
343
|
/**
|
|
340
|
-
*
|
|
344
|
+
* Create payment
|
|
341
345
|
*
|
|
342
346
|
* @method POST
|
|
343
347
|
* @path /cfg/payments/payments/create/
|
|
344
348
|
*/
|
|
345
|
-
export async function createPaymentsPaymentsCreateCreate( client?: any
|
|
346
|
-
): Promise<
|
|
349
|
+
export async function createPaymentsPaymentsCreateCreate( data: PaymentCreateRequest, client?: any
|
|
350
|
+
): Promise<PaymentDetail> {
|
|
347
351
|
const api = client || getAPIInstance()
|
|
348
|
-
const response = await api.ext_payments_payments.paymentsCreateCreate()
|
|
352
|
+
const response = await api.ext_payments_payments.paymentsCreateCreate(data)
|
|
349
353
|
try {
|
|
350
|
-
return
|
|
354
|
+
return PaymentDetailSchema.parse(response)
|
|
351
355
|
} catch (error) {
|
|
352
356
|
// Zod validation error - log detailed information
|
|
353
357
|
consola.error('❌ Zod Validation Failed');
|
|
@@ -407,3 +411,231 @@ export async function getPaymentsTransactionsList( params?: { limit?: number; o
|
|
|
407
411
|
}
|
|
408
412
|
|
|
409
413
|
|
|
414
|
+
/**
|
|
415
|
+
* API operation
|
|
416
|
+
*
|
|
417
|
+
* @method GET
|
|
418
|
+
* @path /cfg/payments/withdrawals/
|
|
419
|
+
*/
|
|
420
|
+
export async function getPaymentsWithdrawalsList( params?: { page?: number; page_size?: number }, client?: any
|
|
421
|
+
): Promise<PaginatedWithdrawalListList> {
|
|
422
|
+
const api = client || getAPIInstance()
|
|
423
|
+
const response = await api.ext_payments_payments.withdrawalsList(params?.page, params?.page_size)
|
|
424
|
+
try {
|
|
425
|
+
return PaginatedWithdrawalListListSchema.parse(response)
|
|
426
|
+
} catch (error) {
|
|
427
|
+
// Zod validation error - log detailed information
|
|
428
|
+
consola.error('❌ Zod Validation Failed');
|
|
429
|
+
consola.box(`getPaymentsWithdrawalsList\nPath: /cfg/payments/withdrawals/\nMethod: GET`);
|
|
430
|
+
|
|
431
|
+
if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
|
|
432
|
+
consola.error('Validation Issues:');
|
|
433
|
+
(error as any).issues.forEach((issue: any, index: number) => {
|
|
434
|
+
consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
|
|
435
|
+
consola.error(` ├─ Message: ${issue.message}`);
|
|
436
|
+
if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
|
|
437
|
+
if (issue.received) consola.error(` └─ Received: ${issue.received}`);
|
|
438
|
+
});
|
|
439
|
+
}
|
|
440
|
+
|
|
441
|
+
consola.error('Response data:', response);
|
|
442
|
+
|
|
443
|
+
// Dispatch browser CustomEvent (only if window is defined)
|
|
444
|
+
if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
|
|
445
|
+
try {
|
|
446
|
+
const event = new CustomEvent('zod-validation-error', {
|
|
447
|
+
detail: {
|
|
448
|
+
operation: 'getPaymentsWithdrawalsList',
|
|
449
|
+
path: '/cfg/payments/withdrawals/',
|
|
450
|
+
method: 'GET',
|
|
451
|
+
error: error,
|
|
452
|
+
response: response,
|
|
453
|
+
timestamp: new Date(),
|
|
454
|
+
},
|
|
455
|
+
bubbles: true,
|
|
456
|
+
cancelable: false,
|
|
457
|
+
});
|
|
458
|
+
window.dispatchEvent(event);
|
|
459
|
+
} catch (eventError) {
|
|
460
|
+
// Silently fail - event dispatch should never crash the app
|
|
461
|
+
consola.warn('Failed to dispatch validation error event:', eventError);
|
|
462
|
+
}
|
|
463
|
+
}
|
|
464
|
+
|
|
465
|
+
// Re-throw the error
|
|
466
|
+
throw error;
|
|
467
|
+
}
|
|
468
|
+
}
|
|
469
|
+
|
|
470
|
+
|
|
471
|
+
/**
|
|
472
|
+
* API operation
|
|
473
|
+
*
|
|
474
|
+
* @method GET
|
|
475
|
+
* @path /cfg/payments/withdrawals/{id}/
|
|
476
|
+
*/
|
|
477
|
+
export async function getPaymentsWithdrawalsRetrieve( id: string, client?: any
|
|
478
|
+
): Promise<WithdrawalDetail> {
|
|
479
|
+
const api = client || getAPIInstance()
|
|
480
|
+
const response = await api.ext_payments_payments.withdrawalsRetrieve(id)
|
|
481
|
+
try {
|
|
482
|
+
return WithdrawalDetailSchema.parse(response)
|
|
483
|
+
} catch (error) {
|
|
484
|
+
// Zod validation error - log detailed information
|
|
485
|
+
consola.error('❌ Zod Validation Failed');
|
|
486
|
+
consola.box(`getPaymentsWithdrawalsRetrieve\nPath: /cfg/payments/withdrawals/{id}/\nMethod: GET`);
|
|
487
|
+
|
|
488
|
+
if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
|
|
489
|
+
consola.error('Validation Issues:');
|
|
490
|
+
(error as any).issues.forEach((issue: any, index: number) => {
|
|
491
|
+
consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
|
|
492
|
+
consola.error(` ├─ Message: ${issue.message}`);
|
|
493
|
+
if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
|
|
494
|
+
if (issue.received) consola.error(` └─ Received: ${issue.received}`);
|
|
495
|
+
});
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
consola.error('Response data:', response);
|
|
499
|
+
|
|
500
|
+
// Dispatch browser CustomEvent (only if window is defined)
|
|
501
|
+
if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
|
|
502
|
+
try {
|
|
503
|
+
const event = new CustomEvent('zod-validation-error', {
|
|
504
|
+
detail: {
|
|
505
|
+
operation: 'getPaymentsWithdrawalsRetrieve',
|
|
506
|
+
path: '/cfg/payments/withdrawals/{id}/',
|
|
507
|
+
method: 'GET',
|
|
508
|
+
error: error,
|
|
509
|
+
response: response,
|
|
510
|
+
timestamp: new Date(),
|
|
511
|
+
},
|
|
512
|
+
bubbles: true,
|
|
513
|
+
cancelable: false,
|
|
514
|
+
});
|
|
515
|
+
window.dispatchEvent(event);
|
|
516
|
+
} catch (eventError) {
|
|
517
|
+
// Silently fail - event dispatch should never crash the app
|
|
518
|
+
consola.warn('Failed to dispatch validation error event:', eventError);
|
|
519
|
+
}
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
// Re-throw the error
|
|
523
|
+
throw error;
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
|
|
528
|
+
/**
|
|
529
|
+
* Cancel withdrawal request
|
|
530
|
+
*
|
|
531
|
+
* @method POST
|
|
532
|
+
* @path /cfg/payments/withdrawals/{id}/cancel/
|
|
533
|
+
*/
|
|
534
|
+
export async function createPaymentsWithdrawalsCancelCreate( id: string, client?: any
|
|
535
|
+
): Promise<WithdrawalDetail> {
|
|
536
|
+
const api = client || getAPIInstance()
|
|
537
|
+
const response = await api.ext_payments_payments.withdrawalsCancelCreate(id)
|
|
538
|
+
try {
|
|
539
|
+
return WithdrawalDetailSchema.parse(response)
|
|
540
|
+
} catch (error) {
|
|
541
|
+
// Zod validation error - log detailed information
|
|
542
|
+
consola.error('❌ Zod Validation Failed');
|
|
543
|
+
consola.box(`createPaymentsWithdrawalsCancelCreate\nPath: /cfg/payments/withdrawals/{id}/cancel/\nMethod: POST`);
|
|
544
|
+
|
|
545
|
+
if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
|
|
546
|
+
consola.error('Validation Issues:');
|
|
547
|
+
(error as any).issues.forEach((issue: any, index: number) => {
|
|
548
|
+
consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
|
|
549
|
+
consola.error(` ├─ Message: ${issue.message}`);
|
|
550
|
+
if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
|
|
551
|
+
if (issue.received) consola.error(` └─ Received: ${issue.received}`);
|
|
552
|
+
});
|
|
553
|
+
}
|
|
554
|
+
|
|
555
|
+
consola.error('Response data:', response);
|
|
556
|
+
|
|
557
|
+
// Dispatch browser CustomEvent (only if window is defined)
|
|
558
|
+
if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
|
|
559
|
+
try {
|
|
560
|
+
const event = new CustomEvent('zod-validation-error', {
|
|
561
|
+
detail: {
|
|
562
|
+
operation: 'createPaymentsWithdrawalsCancelCreate',
|
|
563
|
+
path: '/cfg/payments/withdrawals/{id}/cancel/',
|
|
564
|
+
method: 'POST',
|
|
565
|
+
error: error,
|
|
566
|
+
response: response,
|
|
567
|
+
timestamp: new Date(),
|
|
568
|
+
},
|
|
569
|
+
bubbles: true,
|
|
570
|
+
cancelable: false,
|
|
571
|
+
});
|
|
572
|
+
window.dispatchEvent(event);
|
|
573
|
+
} catch (eventError) {
|
|
574
|
+
// Silently fail - event dispatch should never crash the app
|
|
575
|
+
consola.warn('Failed to dispatch validation error event:', eventError);
|
|
576
|
+
}
|
|
577
|
+
}
|
|
578
|
+
|
|
579
|
+
// Re-throw the error
|
|
580
|
+
throw error;
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
|
|
585
|
+
/**
|
|
586
|
+
* Create withdrawal request
|
|
587
|
+
*
|
|
588
|
+
* @method POST
|
|
589
|
+
* @path /cfg/payments/withdrawals/create/
|
|
590
|
+
*/
|
|
591
|
+
export async function createPaymentsWithdrawalsCreateCreate( data: WithdrawalCreateRequest, client?: any
|
|
592
|
+
): Promise<WithdrawalDetail> {
|
|
593
|
+
const api = client || getAPIInstance()
|
|
594
|
+
const response = await api.ext_payments_payments.withdrawalsCreateCreate(data)
|
|
595
|
+
try {
|
|
596
|
+
return WithdrawalDetailSchema.parse(response)
|
|
597
|
+
} catch (error) {
|
|
598
|
+
// Zod validation error - log detailed information
|
|
599
|
+
consola.error('❌ Zod Validation Failed');
|
|
600
|
+
consola.box(`createPaymentsWithdrawalsCreateCreate\nPath: /cfg/payments/withdrawals/create/\nMethod: POST`);
|
|
601
|
+
|
|
602
|
+
if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
|
|
603
|
+
consola.error('Validation Issues:');
|
|
604
|
+
(error as any).issues.forEach((issue: any, index: number) => {
|
|
605
|
+
consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
|
|
606
|
+
consola.error(` ├─ Message: ${issue.message}`);
|
|
607
|
+
if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
|
|
608
|
+
if (issue.received) consola.error(` └─ Received: ${issue.received}`);
|
|
609
|
+
});
|
|
610
|
+
}
|
|
611
|
+
|
|
612
|
+
consola.error('Response data:', response);
|
|
613
|
+
|
|
614
|
+
// Dispatch browser CustomEvent (only if window is defined)
|
|
615
|
+
if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
|
|
616
|
+
try {
|
|
617
|
+
const event = new CustomEvent('zod-validation-error', {
|
|
618
|
+
detail: {
|
|
619
|
+
operation: 'createPaymentsWithdrawalsCreateCreate',
|
|
620
|
+
path: '/cfg/payments/withdrawals/create/',
|
|
621
|
+
method: 'POST',
|
|
622
|
+
error: error,
|
|
623
|
+
response: response,
|
|
624
|
+
timestamp: new Date(),
|
|
625
|
+
},
|
|
626
|
+
bubbles: true,
|
|
627
|
+
cancelable: false,
|
|
628
|
+
});
|
|
629
|
+
window.dispatchEvent(event);
|
|
630
|
+
} catch (eventError) {
|
|
631
|
+
// Silently fail - event dispatch should never crash the app
|
|
632
|
+
consola.warn('Failed to dispatch validation error event:', eventError);
|
|
633
|
+
}
|
|
634
|
+
}
|
|
635
|
+
|
|
636
|
+
// Re-throw the error
|
|
637
|
+
throw error;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
|
|
641
|
+
|
|
@@ -23,8 +23,12 @@ import * as Fetchers from '../fetchers/ext_payments__payments'
|
|
|
23
23
|
import type { API } from '../../index'
|
|
24
24
|
import type { Balance } from '../schemas/Balance.schema'
|
|
25
25
|
import type { PaginatedPaymentListList } from '../schemas/PaginatedPaymentListList.schema'
|
|
26
|
+
import type { PaginatedWithdrawalListList } from '../schemas/PaginatedWithdrawalListList.schema'
|
|
27
|
+
import type { PaymentCreateRequest } from '../schemas/PaymentCreateRequest.schema'
|
|
26
28
|
import type { PaymentDetail } from '../schemas/PaymentDetail.schema'
|
|
27
29
|
import type { PaymentList } from '../schemas/PaymentList.schema'
|
|
30
|
+
import type { WithdrawalCreateRequest } from '../schemas/WithdrawalCreateRequest.schema'
|
|
31
|
+
import type { WithdrawalDetail } from '../schemas/WithdrawalDetail.schema'
|
|
28
32
|
|
|
29
33
|
/**
|
|
30
34
|
* Get user balance
|
|
@@ -115,7 +119,7 @@ export function usePaymentsPaymentsStatusRetrieve(id: string, client?: API): Ret
|
|
|
115
119
|
|
|
116
120
|
|
|
117
121
|
/**
|
|
118
|
-
*
|
|
122
|
+
* Create payment
|
|
119
123
|
*
|
|
120
124
|
* @method POST
|
|
121
125
|
* @path /cfg/payments/payments/create/
|
|
@@ -123,8 +127,8 @@ export function usePaymentsPaymentsStatusRetrieve(id: string, client?: API): Ret
|
|
|
123
127
|
export function useCreatePaymentsPaymentsCreateCreate() {
|
|
124
128
|
const { mutate } = useSWRConfig()
|
|
125
129
|
|
|
126
|
-
return async (client?: API): Promise<
|
|
127
|
-
const result = await Fetchers.createPaymentsPaymentsCreateCreate(client)
|
|
130
|
+
return async (data: PaymentCreateRequest, client?: API): Promise<PaymentDetail> => {
|
|
131
|
+
const result = await Fetchers.createPaymentsPaymentsCreateCreate(data, client)
|
|
128
132
|
// Revalidate related queries
|
|
129
133
|
mutate('cfg-payments-payments')
|
|
130
134
|
return result
|
|
@@ -146,3 +150,67 @@ export function usePaymentsTransactionsList(params?: { limit?: number; offset?:
|
|
|
146
150
|
}
|
|
147
151
|
|
|
148
152
|
|
|
153
|
+
/**
|
|
154
|
+
* API operation
|
|
155
|
+
*
|
|
156
|
+
* @method GET
|
|
157
|
+
* @path /cfg/payments/withdrawals/
|
|
158
|
+
*/
|
|
159
|
+
export function usePaymentsWithdrawalsList(params?: { page?: number; page_size?: number }, client?: API): ReturnType<typeof useSWR<PaginatedWithdrawalListList>> {
|
|
160
|
+
return useSWR<PaginatedWithdrawalListList>(
|
|
161
|
+
params ? ['cfg-payments-withdrawals', params] : 'cfg-payments-withdrawals',
|
|
162
|
+
() => Fetchers.getPaymentsWithdrawalsList(params, client)
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
/**
|
|
168
|
+
* API operation
|
|
169
|
+
*
|
|
170
|
+
* @method GET
|
|
171
|
+
* @path /cfg/payments/withdrawals/{id}/
|
|
172
|
+
*/
|
|
173
|
+
export function usePaymentsWithdrawalsRetrieve(id: string, client?: API): ReturnType<typeof useSWR<WithdrawalDetail>> {
|
|
174
|
+
return useSWR<WithdrawalDetail>(
|
|
175
|
+
['cfg-payments-withdrawal', id],
|
|
176
|
+
() => Fetchers.getPaymentsWithdrawalsRetrieve(id, client)
|
|
177
|
+
)
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
|
|
181
|
+
/**
|
|
182
|
+
* Cancel withdrawal request
|
|
183
|
+
*
|
|
184
|
+
* @method POST
|
|
185
|
+
* @path /cfg/payments/withdrawals/{id}/cancel/
|
|
186
|
+
*/
|
|
187
|
+
export function useCreatePaymentsWithdrawalsCancelCreate() {
|
|
188
|
+
const { mutate } = useSWRConfig()
|
|
189
|
+
|
|
190
|
+
return async (id: string, client?: API): Promise<WithdrawalDetail> => {
|
|
191
|
+
const result = await Fetchers.createPaymentsWithdrawalsCancelCreate(id, client)
|
|
192
|
+
// Revalidate related queries
|
|
193
|
+
mutate('cfg-payments-withdrawals-cancel')
|
|
194
|
+
return result
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
|
|
199
|
+
/**
|
|
200
|
+
* Create withdrawal request
|
|
201
|
+
*
|
|
202
|
+
* @method POST
|
|
203
|
+
* @path /cfg/payments/withdrawals/create/
|
|
204
|
+
*/
|
|
205
|
+
export function useCreatePaymentsWithdrawalsCreateCreate() {
|
|
206
|
+
const { mutate } = useSWRConfig()
|
|
207
|
+
|
|
208
|
+
return async (data: WithdrawalCreateRequest, client?: API): Promise<WithdrawalDetail> => {
|
|
209
|
+
const result = await Fetchers.createPaymentsWithdrawalsCreateCreate(data, client)
|
|
210
|
+
// Revalidate related queries
|
|
211
|
+
mutate('cfg-payments-withdrawals')
|
|
212
|
+
return result
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema for PaginatedWithdrawalListList
|
|
3
|
+
*
|
|
4
|
+
* This schema provides runtime validation and type inference.
|
|
5
|
+
* */
|
|
6
|
+
import { z } from 'zod'
|
|
7
|
+
import { WithdrawalListSchema } from './WithdrawalList.schema'
|
|
8
|
+
|
|
9
|
+
export const PaginatedWithdrawalListListSchema = z.object({
|
|
10
|
+
count: z.int(),
|
|
11
|
+
page: z.int(),
|
|
12
|
+
pages: z.int(),
|
|
13
|
+
page_size: z.int(),
|
|
14
|
+
has_next: z.boolean(),
|
|
15
|
+
has_previous: z.boolean(),
|
|
16
|
+
next_page: z.int().nullable().optional(),
|
|
17
|
+
previous_page: z.int().nullable().optional(),
|
|
18
|
+
results: z.array(WithdrawalListSchema),
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
/**
|
|
22
|
+
* Infer TypeScript type from Zod schema
|
|
23
|
+
*/
|
|
24
|
+
export type PaginatedWithdrawalListList = z.infer<typeof PaginatedWithdrawalListListSchema>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema for PaymentCreateRequest
|
|
3
|
+
*
|
|
4
|
+
* This schema provides runtime validation and type inference.
|
|
5
|
+
* * Serializer for creating payment.
|
|
6
|
+
* */
|
|
7
|
+
import { z } from 'zod'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Serializer for creating payment.
|
|
11
|
+
*/
|
|
12
|
+
export const PaymentCreateRequestSchema = z.object({
|
|
13
|
+
amount_usd: z.string(),
|
|
14
|
+
currency_code: z.string().min(1).max(20),
|
|
15
|
+
description: z.string().max(500).optional(),
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Infer TypeScript type from Zod schema
|
|
20
|
+
*/
|
|
21
|
+
export type PaymentCreateRequest = z.infer<typeof PaymentCreateRequestSchema>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema for WithdrawalCreateRequest
|
|
3
|
+
*
|
|
4
|
+
* This schema provides runtime validation and type inference.
|
|
5
|
+
* * Serializer for creating withdrawal request.
|
|
6
|
+
* */
|
|
7
|
+
import { z } from 'zod'
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Serializer for creating withdrawal request.
|
|
11
|
+
*/
|
|
12
|
+
export const WithdrawalCreateRequestSchema = z.object({
|
|
13
|
+
amount_usd: z.string(),
|
|
14
|
+
currency_code: z.string().min(1).max(20),
|
|
15
|
+
wallet_address: z.string().min(1).max(255),
|
|
16
|
+
})
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Infer TypeScript type from Zod schema
|
|
20
|
+
*/
|
|
21
|
+
export type WithdrawalCreateRequest = z.infer<typeof WithdrawalCreateRequestSchema>
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema for WithdrawalDetail
|
|
3
|
+
*
|
|
4
|
+
* This schema provides runtime validation and type inference.
|
|
5
|
+
* * Detailed withdrawal information.
|
|
6
|
+
* */
|
|
7
|
+
import { z } from 'zod'
|
|
8
|
+
import * as Enums from '../../enums'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Detailed withdrawal information.
|
|
12
|
+
*/
|
|
13
|
+
export const WithdrawalDetailSchema = z.object({
|
|
14
|
+
id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
15
|
+
internal_withdrawal_id: z.string(),
|
|
16
|
+
amount_usd: z.string(),
|
|
17
|
+
currency_code: z.string(),
|
|
18
|
+
currency_name: z.string(),
|
|
19
|
+
currency_token: z.string(),
|
|
20
|
+
currency_network: z.string(),
|
|
21
|
+
wallet_address: z.string(),
|
|
22
|
+
network_fee_usd: z.string(),
|
|
23
|
+
service_fee_usd: z.string(),
|
|
24
|
+
total_fee_usd: z.string(),
|
|
25
|
+
final_amount_usd: z.string(),
|
|
26
|
+
crypto_amount: z.string().nullable(),
|
|
27
|
+
status: z.nativeEnum(Enums.WithdrawalDetailStatus),
|
|
28
|
+
status_display: z.string(),
|
|
29
|
+
transaction_hash: z.string().nullable(),
|
|
30
|
+
explorer_link: z.string().nullable(),
|
|
31
|
+
admin_notes: z.string(),
|
|
32
|
+
created_at: z.iso.datetime(),
|
|
33
|
+
approved_at: z.iso.datetime().nullable(),
|
|
34
|
+
completed_at: z.iso.datetime().nullable(),
|
|
35
|
+
rejected_at: z.iso.datetime().nullable(),
|
|
36
|
+
cancelled_at: z.iso.datetime().nullable(),
|
|
37
|
+
})
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Infer TypeScript type from Zod schema
|
|
41
|
+
*/
|
|
42
|
+
export type WithdrawalDetail = z.infer<typeof WithdrawalDetailSchema>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Zod schema for WithdrawalList
|
|
3
|
+
*
|
|
4
|
+
* This schema provides runtime validation and type inference.
|
|
5
|
+
* * Withdrawal list item (lighter than detail).
|
|
6
|
+
* */
|
|
7
|
+
import { z } from 'zod'
|
|
8
|
+
import * as Enums from '../../enums'
|
|
9
|
+
|
|
10
|
+
/**
|
|
11
|
+
* Withdrawal list item (lighter than detail).
|
|
12
|
+
*/
|
|
13
|
+
export const WithdrawalListSchema = z.object({
|
|
14
|
+
id: z.string().regex(/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i),
|
|
15
|
+
internal_withdrawal_id: z.string(),
|
|
16
|
+
amount_usd: z.string(),
|
|
17
|
+
final_amount_usd: z.string(),
|
|
18
|
+
currency_code: z.string(),
|
|
19
|
+
currency_token: z.string(),
|
|
20
|
+
status: z.nativeEnum(Enums.WithdrawalListStatus),
|
|
21
|
+
status_display: z.string(),
|
|
22
|
+
created_at: z.iso.datetime(),
|
|
23
|
+
completed_at: z.iso.datetime().nullable(),
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Infer TypeScript type from Zod schema
|
|
28
|
+
*/
|
|
29
|
+
export type WithdrawalList = z.infer<typeof WithdrawalListSchema>
|
|
@@ -20,6 +20,11 @@
|
|
|
20
20
|
export * from './Balance.schema'
|
|
21
21
|
export * from './Currency.schema'
|
|
22
22
|
export * from './PaginatedPaymentListList.schema'
|
|
23
|
+
export * from './PaginatedWithdrawalListList.schema'
|
|
24
|
+
export * from './PaymentCreateRequest.schema'
|
|
23
25
|
export * from './PaymentDetail.schema'
|
|
24
26
|
export * from './PaymentList.schema'
|
|
25
27
|
export * from './Transaction.schema'
|
|
28
|
+
export * from './WithdrawalCreateRequest.schema'
|
|
29
|
+
export * from './WithdrawalDetail.schema'
|
|
30
|
+
export * from './WithdrawalList.schema'
|
|
@@ -63,3 +63,39 @@ export enum TransactionTransactionType {
|
|
|
63
63
|
ADJUSTMENT = "adjustment",
|
|
64
64
|
}
|
|
65
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
|
+
export enum WithdrawalDetailStatus {
|
|
76
|
+
PENDING = "pending",
|
|
77
|
+
APPROVED = "approved",
|
|
78
|
+
PROCESSING = "processing",
|
|
79
|
+
COMPLETED = "completed",
|
|
80
|
+
REJECTED = "rejected",
|
|
81
|
+
CANCELLED = "cancelled",
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* Withdrawal status
|
|
86
|
+
* * `pending` - Pending
|
|
87
|
+
* * `approved` - Approved
|
|
88
|
+
* * `processing` - Processing
|
|
89
|
+
* * `completed` - Completed
|
|
90
|
+
* * `rejected` - Rejected
|
|
91
|
+
* * `cancelled` - Cancelled
|
|
92
|
+
*/
|
|
93
|
+
export enum WithdrawalListStatus {
|
|
94
|
+
PENDING = "pending",
|
|
95
|
+
APPROVED = "approved",
|
|
96
|
+
PROCESSING = "processing",
|
|
97
|
+
COMPLETED = "completed",
|
|
98
|
+
REJECTED = "rejected",
|
|
99
|
+
CANCELLED = "cancelled",
|
|
100
|
+
}
|
|
101
|
+
|