@djangocfg/ext-payments 1.0.14 → 1.0.19

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.
Files changed (76) hide show
  1. package/dist/config.cjs +5 -8
  2. package/dist/config.js +5 -8
  3. package/dist/index.cjs +1906 -1043
  4. package/dist/index.d.cts +644 -59
  5. package/dist/index.d.ts +644 -59
  6. package/dist/index.js +1886 -1040
  7. package/package.json +13 -16
  8. package/src/WalletPage.tsx +100 -0
  9. package/src/api/generated/ext_payments/CLAUDE.md +10 -4
  10. package/src/api/generated/ext_payments/_utils/fetchers/ext_payments__payments.ts +268 -5
  11. package/src/api/generated/ext_payments/_utils/hooks/ext_payments__payments.ts +102 -3
  12. package/src/api/generated/ext_payments/_utils/schemas/Balance.schema.ts +1 -1
  13. package/src/api/generated/ext_payments/_utils/schemas/PaginatedWithdrawalListList.schema.ts +24 -0
  14. package/src/api/generated/ext_payments/_utils/schemas/PaymentCreateRequest.schema.ts +21 -0
  15. package/src/api/generated/ext_payments/_utils/schemas/PaymentCreateResponse.schema.ts +22 -0
  16. package/src/api/generated/ext_payments/_utils/schemas/PaymentDetail.schema.ts +3 -3
  17. package/src/api/generated/ext_payments/_utils/schemas/PaymentList.schema.ts +2 -2
  18. package/src/api/generated/ext_payments/_utils/schemas/Transaction.schema.ts +1 -1
  19. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalCancelResponse.schema.ts +22 -0
  20. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalCreateRequest.schema.ts +21 -0
  21. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalCreateResponse.schema.ts +22 -0
  22. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalDetail.schema.ts +42 -0
  23. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalList.schema.ts +29 -0
  24. package/src/api/generated/ext_payments/_utils/schemas/index.ts +8 -0
  25. package/src/api/generated/ext_payments/client.ts +1 -1
  26. package/src/api/generated/ext_payments/enums.ts +36 -0
  27. package/src/api/generated/ext_payments/ext_payments__payments/client.ts +104 -6
  28. package/src/api/generated/ext_payments/ext_payments__payments/models.ts +168 -8
  29. package/src/api/generated/ext_payments/index.ts +1 -1
  30. package/src/api/generated/ext_payments/schema.json +752 -42
  31. package/src/components/ActivityItem.tsx +118 -0
  32. package/src/components/ActivityList.tsx +93 -0
  33. package/src/components/AddFundsSheet.tsx +342 -0
  34. package/src/components/BalanceHero.tsx +102 -0
  35. package/src/components/CurrencyCombobox.tsx +49 -0
  36. package/src/components/PaymentSheet.tsx +352 -0
  37. package/src/components/WithdrawSheet.tsx +355 -0
  38. package/src/components/WithdrawalSheet.tsx +332 -0
  39. package/src/components/index.ts +11 -0
  40. package/src/config.ts +1 -0
  41. package/src/contexts/WalletContext.tsx +356 -0
  42. package/src/contexts/index.ts +13 -42
  43. package/src/contexts/types.ts +43 -37
  44. package/src/hooks/index.ts +3 -20
  45. package/src/hooks/useCurrencyOptions.ts +79 -0
  46. package/src/hooks/useEstimate.ts +113 -0
  47. package/src/hooks/useWithdrawalEstimate.ts +117 -0
  48. package/src/index.ts +9 -18
  49. package/src/types/index.ts +78 -0
  50. package/src/utils/errors.ts +36 -0
  51. package/src/utils/format.ts +65 -0
  52. package/src/utils/index.ts +3 -0
  53. package/src/contexts/BalancesContext.tsx +0 -63
  54. package/src/contexts/CurrenciesContext.tsx +0 -64
  55. package/src/contexts/OverviewContext.tsx +0 -173
  56. package/src/contexts/PaymentsContext.tsx +0 -122
  57. package/src/contexts/PaymentsExtensionProvider.tsx +0 -56
  58. package/src/contexts/README.md +0 -201
  59. package/src/contexts/RootPaymentsContext.tsx +0 -66
  60. package/src/layouts/PaymentsLayout/PaymentsLayout.tsx +0 -90
  61. package/src/layouts/PaymentsLayout/components/CreatePaymentDialog.tsx +0 -274
  62. package/src/layouts/PaymentsLayout/components/PaymentDetailsDialog.tsx +0 -287
  63. package/src/layouts/PaymentsLayout/components/index.ts +0 -2
  64. package/src/layouts/PaymentsLayout/events.ts +0 -47
  65. package/src/layouts/PaymentsLayout/index.ts +0 -16
  66. package/src/layouts/PaymentsLayout/types.ts +0 -6
  67. package/src/layouts/PaymentsLayout/views/overview/components/BalanceCard.tsx +0 -121
  68. package/src/layouts/PaymentsLayout/views/overview/components/RecentPayments.tsx +0 -139
  69. package/src/layouts/PaymentsLayout/views/overview/components/index.ts +0 -2
  70. package/src/layouts/PaymentsLayout/views/overview/index.tsx +0 -21
  71. package/src/layouts/PaymentsLayout/views/payments/components/PaymentsList.tsx +0 -279
  72. package/src/layouts/PaymentsLayout/views/payments/components/index.ts +0 -1
  73. package/src/layouts/PaymentsLayout/views/payments/index.tsx +0 -18
  74. package/src/layouts/PaymentsLayout/views/transactions/components/TransactionsList.tsx +0 -260
  75. package/src/layouts/PaymentsLayout/views/transactions/components/index.ts +0 -1
  76. 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.14",
3
+ "version": "1.0.19",
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.107",
63
- "@djangocfg/ext-base": "^1.0.9",
64
- "@djangocfg/ui-core": "^2.1.107",
65
- "@djangocfg/ui-nextjs": "^2.1.107",
57
+ "@djangocfg/api": "^2.1.109",
58
+ "@djangocfg/ext-base": "^1.0.14",
59
+ "@djangocfg/ui-core": "^2.1.109",
60
+ "@djangocfg/ui-nextjs": "^2.1.109",
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.1.13",
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.107",
77
- "@djangocfg/ext-base": "^1.0.9",
78
- "@djangocfg/typescript-config": "^2.1.107",
79
- "@djangocfg/ui-nextjs": "^2.1.107",
73
+ "@djangocfg/api": "^2.1.109",
74
+ "@djangocfg/ext-base": "^1.0.14",
75
+ "@djangocfg/typescript-config": "^2.1.109",
76
+ "@djangocfg/ui-nextjs": "^2.1.109",
80
77
  "@types/node": "^24.7.2",
81
78
  "@types/react": "^19.0.0",
82
79
  "consola": "^3.4.2",
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Wallet Page Component (Apple-style)
3
+ *
4
+ * Single page with balance hero + activity list
5
+ */
6
+
7
+ 'use client';
8
+
9
+ import { useState, useCallback } from 'react';
10
+
11
+ import { WalletProvider, type ActivityItem } from './contexts/WalletContext';
12
+ import type { PaymentDetail } from './contexts/types';
13
+ import {
14
+ BalanceHero,
15
+ ActivityList,
16
+ AddFundsSheet,
17
+ WithdrawSheet,
18
+ WithdrawalSheet,
19
+ PaymentSheet,
20
+ } from './components';
21
+
22
+ export const WalletContent = () => {
23
+ const [addFundsOpen, setAddFundsOpen] = useState(false);
24
+ const [withdrawOpen, setWithdrawOpen] = useState(false);
25
+ const [selectedPaymentId, setSelectedPaymentId] = useState<string | null>(null);
26
+ const [paymentSheetOpen, setPaymentSheetOpen] = useState(false);
27
+ const [selectedWithdrawalId, setSelectedWithdrawalId] = useState<string | null>(null);
28
+ const [withdrawalSheetOpen, setWithdrawalSheetOpen] = useState(false);
29
+
30
+ // Handle activity item click
31
+ const handleActivityClick = useCallback((item: ActivityItem) => {
32
+ if (item.payment) {
33
+ setSelectedPaymentId(item.payment.id);
34
+ setPaymentSheetOpen(true);
35
+ } else if (item.withdrawal) {
36
+ setSelectedWithdrawalId(item.withdrawal.id);
37
+ setWithdrawalSheetOpen(true);
38
+ }
39
+ }, []);
40
+
41
+ // Handle successful payment creation
42
+ const handlePaymentCreated = useCallback((payment: PaymentDetail) => {
43
+ setSelectedPaymentId(payment.id);
44
+ setPaymentSheetOpen(true);
45
+ }, []);
46
+
47
+ return (
48
+ <div className="min-h-screen">
49
+ {/* Balance Hero */}
50
+ <BalanceHero
51
+ onAddFunds={() => setAddFundsOpen(true)}
52
+ onWithdraw={() => setWithdrawOpen(true)}
53
+ className="bg-muted/30 border-b"
54
+ />
55
+
56
+ {/* Activity List */}
57
+ <ActivityList
58
+ onItemClick={handleActivityClick}
59
+ limit={20}
60
+ className="max-w-2xl mx-auto pb-12"
61
+ />
62
+
63
+ {/* Add Funds Sheet */}
64
+ <AddFundsSheet
65
+ open={addFundsOpen}
66
+ onOpenChange={setAddFundsOpen}
67
+ onSuccess={handlePaymentCreated}
68
+ />
69
+
70
+ {/* Withdraw Sheet */}
71
+ <WithdrawSheet
72
+ open={withdrawOpen}
73
+ onOpenChange={setWithdrawOpen}
74
+ />
75
+
76
+ {/* Payment Details Sheet */}
77
+ <PaymentSheet
78
+ paymentId={selectedPaymentId}
79
+ open={paymentSheetOpen}
80
+ onOpenChange={setPaymentSheetOpen}
81
+ onCreateNew={() => setAddFundsOpen(true)}
82
+ />
83
+
84
+ {/* Withdrawal Details Sheet */}
85
+ <WithdrawalSheet
86
+ withdrawalId={selectedWithdrawalId}
87
+ open={withdrawalSheetOpen}
88
+ onOpenChange={setWithdrawalSheetOpen}
89
+ />
90
+ </div>
91
+ );
92
+ }
93
+
94
+ export function WalletPage() {
95
+ return (
96
+ <WalletProvider>
97
+ <WalletContent />
98
+ </WalletProvider>
99
+ );
100
+ }
@@ -1,4 +1,4 @@
1
- # Django CFG API - Typescript Client
1
+ # Cmdop API - Typescript Client
2
2
 
3
3
  Auto-generated. **Do not edit manually.**
4
4
 
@@ -11,24 +11,30 @@ python manage.py generate_client --groups ext_payments --typescript
11
11
  | | |
12
12
  |---|---|
13
13
  | Version | 3.0.3 |
14
- | Operations | 8 |
15
- | Schemas | 6 |
14
+ | Operations | 14 |
15
+ | Schemas | 14 |
16
16
 
17
17
  ## Resources
18
18
 
19
- - **payments** (8 ops)
19
+ - **payments** (14 ops)
20
20
 
21
21
  ## Operations
22
22
 
23
23
  **payments:**
24
24
  - `GET` /cfg/payments/balance/ → `cfg_payments_balance_retrieve`
25
+ - `GET` /cfg/payments/currencies/{code}/estimate/ → `cfg_payments_currencies_estimate_retrieve`
25
26
  - `GET` /cfg/payments/currencies/ → `cfg_payments_currencies_list`
27
+ - `GET` /cfg/payments/currencies/{code}/withdrawal-estimate/ → `cfg_payments_currencies_withdrawal_estimate_retrieve`
26
28
  - `POST` /cfg/payments/payments/{id}/confirm/ → `cfg_payments_payments_confirm_create`
27
29
  - `POST` /cfg/payments/payments/create/ → `cfg_payments_payments_create_create`
28
30
  - `GET` /cfg/payments/payments/ → `cfg_payments_payments_list`
29
31
  - `GET` /cfg/payments/payments/{id}/ → `cfg_payments_payments_retrieve`
30
32
  - `GET` /cfg/payments/payments/{id}/status/ → `cfg_payments_payments_status_retrieve`
31
33
  - `GET` /cfg/payments/transactions/ → `cfg_payments_transactions_list`
34
+ - `POST` /cfg/payments/withdrawals/{id}/cancel/ → `cfg_payments_withdrawals_cancel_create`
35
+ - `POST` /cfg/payments/withdrawals/create/ → `cfg_payments_withdrawals_create_create`
36
+ - `GET` /cfg/payments/withdrawals/ → `cfg_payments_withdrawals_list`
37
+ - `GET` /cfg/payments/withdrawals/{id}/ → `cfg_payments_withdrawals_retrieve`
32
38
 
33
39
  ## Usage
34
40
 
@@ -33,8 +33,15 @@
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'
38
+ import { PaymentCreateResponseSchema, type PaymentCreateResponse } from '../schemas/PaymentCreateResponse.schema'
36
39
  import { PaymentDetailSchema, type PaymentDetail } from '../schemas/PaymentDetail.schema'
37
40
  import { PaymentListSchema, type PaymentList } from '../schemas/PaymentList.schema'
41
+ import { WithdrawalCancelResponseSchema, type WithdrawalCancelResponse } from '../schemas/WithdrawalCancelResponse.schema'
42
+ import { WithdrawalCreateRequestSchema, type WithdrawalCreateRequest } from '../schemas/WithdrawalCreateRequest.schema'
43
+ import { WithdrawalCreateResponseSchema, type WithdrawalCreateResponse } from '../schemas/WithdrawalCreateResponse.schema'
44
+ import { WithdrawalDetailSchema, type WithdrawalDetail } from '../schemas/WithdrawalDetail.schema'
38
45
  import { getAPIInstance } from '../../api-instance'
39
46
 
40
47
  /**
@@ -108,6 +115,34 @@ export async function getPaymentsCurrenciesList( client?: any
108
115
  }
109
116
 
110
117
 
118
+ /**
119
+ * Get currency estimate
120
+ *
121
+ * @method GET
122
+ * @path /cfg/payments/currencies/{code}/estimate/
123
+ */
124
+ export async function getPaymentsCurrenciesEstimateRetrieve( code: string, params?: { amount?: number }, client?: any
125
+ ): Promise<any> {
126
+ const api = client || getAPIInstance()
127
+ const response = await api.ext_payments_payments.currenciesEstimateRetrieve(code, params?.amount)
128
+ return response
129
+ }
130
+
131
+
132
+ /**
133
+ * Get withdrawal estimate
134
+ *
135
+ * @method GET
136
+ * @path /cfg/payments/currencies/{code}/withdrawal-estimate/
137
+ */
138
+ export async function getPaymentsCurrenciesWithdrawalEstimateRetrieve( code: string, params?: { amount?: number }, client?: any
139
+ ): Promise<any> {
140
+ const api = client || getAPIInstance()
141
+ const response = await api.ext_payments_payments.currenciesWithdrawalEstimateRetrieve(code, params?.amount)
142
+ return response
143
+ }
144
+
145
+
111
146
  /**
112
147
  * API operation
113
148
  *
@@ -337,17 +372,17 @@ export async function getPaymentsPaymentsStatusRetrieve( id: string, client?:
337
372
 
338
373
 
339
374
  /**
340
- * API operation
375
+ * Create payment
341
376
  *
342
377
  * @method POST
343
378
  * @path /cfg/payments/payments/create/
344
379
  */
345
- export async function createPaymentsPaymentsCreateCreate( client?: any
346
- ): Promise<PaymentList> {
380
+ export async function createPaymentsPaymentsCreateCreate( data: PaymentCreateRequest, client?: any
381
+ ): Promise<PaymentCreateResponse> {
347
382
  const api = client || getAPIInstance()
348
- const response = await api.ext_payments_payments.paymentsCreateCreate()
383
+ const response = await api.ext_payments_payments.paymentsCreateCreate(data)
349
384
  try {
350
- return PaymentListSchema.parse(response)
385
+ return PaymentCreateResponseSchema.parse(response)
351
386
  } catch (error) {
352
387
  // Zod validation error - log detailed information
353
388
  consola.error('❌ Zod Validation Failed');
@@ -407,3 +442,231 @@ export async function getPaymentsTransactionsList( params?: { limit?: number; o
407
442
  }
408
443
 
409
444
 
445
+ /**
446
+ * API operation
447
+ *
448
+ * @method GET
449
+ * @path /cfg/payments/withdrawals/
450
+ */
451
+ export async function getPaymentsWithdrawalsList( params?: { page?: number; page_size?: number }, client?: any
452
+ ): Promise<PaginatedWithdrawalListList> {
453
+ const api = client || getAPIInstance()
454
+ const response = await api.ext_payments_payments.withdrawalsList(params?.page, params?.page_size)
455
+ try {
456
+ return PaginatedWithdrawalListListSchema.parse(response)
457
+ } catch (error) {
458
+ // Zod validation error - log detailed information
459
+ consola.error('❌ Zod Validation Failed');
460
+ consola.box(`getPaymentsWithdrawalsList\nPath: /cfg/payments/withdrawals/\nMethod: GET`);
461
+
462
+ if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
463
+ consola.error('Validation Issues:');
464
+ (error as any).issues.forEach((issue: any, index: number) => {
465
+ consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
466
+ consola.error(` ├─ Message: ${issue.message}`);
467
+ if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
468
+ if (issue.received) consola.error(` └─ Received: ${issue.received}`);
469
+ });
470
+ }
471
+
472
+ consola.error('Response data:', response);
473
+
474
+ // Dispatch browser CustomEvent (only if window is defined)
475
+ if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
476
+ try {
477
+ const event = new CustomEvent('zod-validation-error', {
478
+ detail: {
479
+ operation: 'getPaymentsWithdrawalsList',
480
+ path: '/cfg/payments/withdrawals/',
481
+ method: 'GET',
482
+ error: error,
483
+ response: response,
484
+ timestamp: new Date(),
485
+ },
486
+ bubbles: true,
487
+ cancelable: false,
488
+ });
489
+ window.dispatchEvent(event);
490
+ } catch (eventError) {
491
+ // Silently fail - event dispatch should never crash the app
492
+ consola.warn('Failed to dispatch validation error event:', eventError);
493
+ }
494
+ }
495
+
496
+ // Re-throw the error
497
+ throw error;
498
+ }
499
+ }
500
+
501
+
502
+ /**
503
+ * API operation
504
+ *
505
+ * @method GET
506
+ * @path /cfg/payments/withdrawals/{id}/
507
+ */
508
+ export async function getPaymentsWithdrawalsRetrieve( id: string, client?: any
509
+ ): Promise<WithdrawalDetail> {
510
+ const api = client || getAPIInstance()
511
+ const response = await api.ext_payments_payments.withdrawalsRetrieve(id)
512
+ try {
513
+ return WithdrawalDetailSchema.parse(response)
514
+ } catch (error) {
515
+ // Zod validation error - log detailed information
516
+ consola.error('❌ Zod Validation Failed');
517
+ consola.box(`getPaymentsWithdrawalsRetrieve\nPath: /cfg/payments/withdrawals/{id}/\nMethod: GET`);
518
+
519
+ if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
520
+ consola.error('Validation Issues:');
521
+ (error as any).issues.forEach((issue: any, index: number) => {
522
+ consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
523
+ consola.error(` ├─ Message: ${issue.message}`);
524
+ if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
525
+ if (issue.received) consola.error(` └─ Received: ${issue.received}`);
526
+ });
527
+ }
528
+
529
+ consola.error('Response data:', response);
530
+
531
+ // Dispatch browser CustomEvent (only if window is defined)
532
+ if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
533
+ try {
534
+ const event = new CustomEvent('zod-validation-error', {
535
+ detail: {
536
+ operation: 'getPaymentsWithdrawalsRetrieve',
537
+ path: '/cfg/payments/withdrawals/{id}/',
538
+ method: 'GET',
539
+ error: error,
540
+ response: response,
541
+ timestamp: new Date(),
542
+ },
543
+ bubbles: true,
544
+ cancelable: false,
545
+ });
546
+ window.dispatchEvent(event);
547
+ } catch (eventError) {
548
+ // Silently fail - event dispatch should never crash the app
549
+ consola.warn('Failed to dispatch validation error event:', eventError);
550
+ }
551
+ }
552
+
553
+ // Re-throw the error
554
+ throw error;
555
+ }
556
+ }
557
+
558
+
559
+ /**
560
+ * Cancel withdrawal request
561
+ *
562
+ * @method POST
563
+ * @path /cfg/payments/withdrawals/{id}/cancel/
564
+ */
565
+ export async function createPaymentsWithdrawalsCancelCreate( id: string, client?: any
566
+ ): Promise<WithdrawalCancelResponse> {
567
+ const api = client || getAPIInstance()
568
+ const response = await api.ext_payments_payments.withdrawalsCancelCreate(id)
569
+ try {
570
+ return WithdrawalCancelResponseSchema.parse(response)
571
+ } catch (error) {
572
+ // Zod validation error - log detailed information
573
+ consola.error('❌ Zod Validation Failed');
574
+ consola.box(`createPaymentsWithdrawalsCancelCreate\nPath: /cfg/payments/withdrawals/{id}/cancel/\nMethod: POST`);
575
+
576
+ if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
577
+ consola.error('Validation Issues:');
578
+ (error as any).issues.forEach((issue: any, index: number) => {
579
+ consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
580
+ consola.error(` ├─ Message: ${issue.message}`);
581
+ if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
582
+ if (issue.received) consola.error(` └─ Received: ${issue.received}`);
583
+ });
584
+ }
585
+
586
+ consola.error('Response data:', response);
587
+
588
+ // Dispatch browser CustomEvent (only if window is defined)
589
+ if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
590
+ try {
591
+ const event = new CustomEvent('zod-validation-error', {
592
+ detail: {
593
+ operation: 'createPaymentsWithdrawalsCancelCreate',
594
+ path: '/cfg/payments/withdrawals/{id}/cancel/',
595
+ method: 'POST',
596
+ error: error,
597
+ response: response,
598
+ timestamp: new Date(),
599
+ },
600
+ bubbles: true,
601
+ cancelable: false,
602
+ });
603
+ window.dispatchEvent(event);
604
+ } catch (eventError) {
605
+ // Silently fail - event dispatch should never crash the app
606
+ consola.warn('Failed to dispatch validation error event:', eventError);
607
+ }
608
+ }
609
+
610
+ // Re-throw the error
611
+ throw error;
612
+ }
613
+ }
614
+
615
+
616
+ /**
617
+ * Create withdrawal request
618
+ *
619
+ * @method POST
620
+ * @path /cfg/payments/withdrawals/create/
621
+ */
622
+ export async function createPaymentsWithdrawalsCreateCreate( data: WithdrawalCreateRequest, client?: any
623
+ ): Promise<WithdrawalCreateResponse> {
624
+ const api = client || getAPIInstance()
625
+ const response = await api.ext_payments_payments.withdrawalsCreateCreate(data)
626
+ try {
627
+ return WithdrawalCreateResponseSchema.parse(response)
628
+ } catch (error) {
629
+ // Zod validation error - log detailed information
630
+ consola.error('❌ Zod Validation Failed');
631
+ consola.box(`createPaymentsWithdrawalsCreateCreate\nPath: /cfg/payments/withdrawals/create/\nMethod: POST`);
632
+
633
+ if (error instanceof Error && 'issues' in error && Array.isArray((error as any).issues)) {
634
+ consola.error('Validation Issues:');
635
+ (error as any).issues.forEach((issue: any, index: number) => {
636
+ consola.error(` ${index + 1}. ${issue.path.join('.') || 'root'}`);
637
+ consola.error(` ├─ Message: ${issue.message}`);
638
+ if (issue.expected) consola.error(` ├─ Expected: ${issue.expected}`);
639
+ if (issue.received) consola.error(` └─ Received: ${issue.received}`);
640
+ });
641
+ }
642
+
643
+ consola.error('Response data:', response);
644
+
645
+ // Dispatch browser CustomEvent (only if window is defined)
646
+ if (typeof window !== 'undefined' && error instanceof Error && 'issues' in error) {
647
+ try {
648
+ const event = new CustomEvent('zod-validation-error', {
649
+ detail: {
650
+ operation: 'createPaymentsWithdrawalsCreateCreate',
651
+ path: '/cfg/payments/withdrawals/create/',
652
+ method: 'POST',
653
+ error: error,
654
+ response: response,
655
+ timestamp: new Date(),
656
+ },
657
+ bubbles: true,
658
+ cancelable: false,
659
+ });
660
+ window.dispatchEvent(event);
661
+ } catch (eventError) {
662
+ // Silently fail - event dispatch should never crash the app
663
+ consola.warn('Failed to dispatch validation error event:', eventError);
664
+ }
665
+ }
666
+
667
+ // Re-throw the error
668
+ throw error;
669
+ }
670
+ }
671
+
672
+
@@ -23,8 +23,15 @@ 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'
28
+ import type { PaymentCreateResponse } from '../schemas/PaymentCreateResponse.schema'
26
29
  import type { PaymentDetail } from '../schemas/PaymentDetail.schema'
27
30
  import type { PaymentList } from '../schemas/PaymentList.schema'
31
+ import type { WithdrawalCancelResponse } from '../schemas/WithdrawalCancelResponse.schema'
32
+ import type { WithdrawalCreateRequest } from '../schemas/WithdrawalCreateRequest.schema'
33
+ import type { WithdrawalCreateResponse } from '../schemas/WithdrawalCreateResponse.schema'
34
+ import type { WithdrawalDetail } from '../schemas/WithdrawalDetail.schema'
28
35
 
29
36
  /**
30
37
  * Get user balance
@@ -54,6 +61,34 @@ export function usePaymentsCurrenciesList(client?: API): ReturnType<typeof useSW
54
61
  }
55
62
 
56
63
 
64
+ /**
65
+ * Get currency estimate
66
+ *
67
+ * @method GET
68
+ * @path /cfg/payments/currencies/{code}/estimate/
69
+ */
70
+ export function usePaymentsCurrenciesEstimateRetrieve(code: string, params?: { amount?: number }, client?: API): ReturnType<typeof useSWR<any>> {
71
+ return useSWR<any>(
72
+ ['cfg-payments-currencies-estimate', code],
73
+ () => Fetchers.getPaymentsCurrenciesEstimateRetrieve(code, params, client)
74
+ )
75
+ }
76
+
77
+
78
+ /**
79
+ * Get withdrawal estimate
80
+ *
81
+ * @method GET
82
+ * @path /cfg/payments/currencies/{code}/withdrawal-estimate/
83
+ */
84
+ export function usePaymentsCurrenciesWithdrawalEstimateRetrieve(code: string, params?: { amount?: number }, client?: API): ReturnType<typeof useSWR<any>> {
85
+ return useSWR<any>(
86
+ ['cfg-payments-currencies-withdrawal-estimate', code],
87
+ () => Fetchers.getPaymentsCurrenciesWithdrawalEstimateRetrieve(code, params, client)
88
+ )
89
+ }
90
+
91
+
57
92
  /**
58
93
  * API operation
59
94
  *
@@ -115,7 +150,7 @@ export function usePaymentsPaymentsStatusRetrieve(id: string, client?: API): Ret
115
150
 
116
151
 
117
152
  /**
118
- * API operation
153
+ * Create payment
119
154
  *
120
155
  * @method POST
121
156
  * @path /cfg/payments/payments/create/
@@ -123,8 +158,8 @@ export function usePaymentsPaymentsStatusRetrieve(id: string, client?: API): Ret
123
158
  export function useCreatePaymentsPaymentsCreateCreate() {
124
159
  const { mutate } = useSWRConfig()
125
160
 
126
- return async (client?: API): Promise<PaymentList> => {
127
- const result = await Fetchers.createPaymentsPaymentsCreateCreate(client)
161
+ return async (data: PaymentCreateRequest, client?: API): Promise<PaymentCreateResponse> => {
162
+ const result = await Fetchers.createPaymentsPaymentsCreateCreate(data, client)
128
163
  // Revalidate related queries
129
164
  mutate('cfg-payments-payments')
130
165
  return result
@@ -146,3 +181,67 @@ export function usePaymentsTransactionsList(params?: { limit?: number; offset?:
146
181
  }
147
182
 
148
183
 
184
+ /**
185
+ * API operation
186
+ *
187
+ * @method GET
188
+ * @path /cfg/payments/withdrawals/
189
+ */
190
+ export function usePaymentsWithdrawalsList(params?: { page?: number; page_size?: number }, client?: API): ReturnType<typeof useSWR<PaginatedWithdrawalListList>> {
191
+ return useSWR<PaginatedWithdrawalListList>(
192
+ params ? ['cfg-payments-withdrawals', params] : 'cfg-payments-withdrawals',
193
+ () => Fetchers.getPaymentsWithdrawalsList(params, client)
194
+ )
195
+ }
196
+
197
+
198
+ /**
199
+ * API operation
200
+ *
201
+ * @method GET
202
+ * @path /cfg/payments/withdrawals/{id}/
203
+ */
204
+ export function usePaymentsWithdrawalsRetrieve(id: string, client?: API): ReturnType<typeof useSWR<WithdrawalDetail>> {
205
+ return useSWR<WithdrawalDetail>(
206
+ ['cfg-payments-withdrawal', id],
207
+ () => Fetchers.getPaymentsWithdrawalsRetrieve(id, client)
208
+ )
209
+ }
210
+
211
+
212
+ /**
213
+ * Cancel withdrawal request
214
+ *
215
+ * @method POST
216
+ * @path /cfg/payments/withdrawals/{id}/cancel/
217
+ */
218
+ export function useCreatePaymentsWithdrawalsCancelCreate() {
219
+ const { mutate } = useSWRConfig()
220
+
221
+ return async (id: string, client?: API): Promise<WithdrawalCancelResponse> => {
222
+ const result = await Fetchers.createPaymentsWithdrawalsCancelCreate(id, client)
223
+ // Revalidate related queries
224
+ mutate('cfg-payments-withdrawals-cancel')
225
+ return result
226
+ }
227
+ }
228
+
229
+
230
+ /**
231
+ * Create withdrawal request
232
+ *
233
+ * @method POST
234
+ * @path /cfg/payments/withdrawals/create/
235
+ */
236
+ export function useCreatePaymentsWithdrawalsCreateCreate() {
237
+ const { mutate } = useSWRConfig()
238
+
239
+ return async (data: WithdrawalCreateRequest, client?: API): Promise<WithdrawalCreateResponse> => {
240
+ const result = await Fetchers.createPaymentsWithdrawalsCreateCreate(data, client)
241
+ // Revalidate related queries
242
+ mutate('cfg-payments-withdrawals')
243
+ return result
244
+ }
245
+ }
246
+
247
+
@@ -14,7 +14,7 @@ export const BalanceSchema = z.object({
14
14
  balance_display: z.string(),
15
15
  total_deposited: z.string(),
16
16
  total_withdrawn: z.string(),
17
- last_transaction_at: z.iso.datetime().nullable(),
17
+ last_transaction_at: z.string().datetime({ offset: true }).nullable(),
18
18
  })
19
19
 
20
20
  /**
@@ -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>