@djangocfg/ext-payments 1.0.17 → 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 (46) hide show
  1. package/dist/config.cjs +1 -1
  2. package/dist/config.js +1 -1
  3. package/dist/index.cjs +1175 -290
  4. package/dist/index.d.cts +226 -80
  5. package/dist/index.d.ts +226 -80
  6. package/dist/index.js +1157 -255
  7. package/package.json +9 -9
  8. package/src/WalletPage.tsx +100 -0
  9. package/src/api/generated/ext_payments/CLAUDE.md +6 -4
  10. package/src/api/generated/ext_payments/_utils/fetchers/ext_payments__payments.ts +37 -6
  11. package/src/api/generated/ext_payments/_utils/hooks/ext_payments__payments.ts +34 -3
  12. package/src/api/generated/ext_payments/_utils/schemas/Balance.schema.ts +1 -1
  13. package/src/api/generated/ext_payments/_utils/schemas/PaymentCreateResponse.schema.ts +22 -0
  14. package/src/api/generated/ext_payments/_utils/schemas/PaymentDetail.schema.ts +3 -3
  15. package/src/api/generated/ext_payments/_utils/schemas/PaymentList.schema.ts +2 -2
  16. package/src/api/generated/ext_payments/_utils/schemas/Transaction.schema.ts +1 -1
  17. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalCancelResponse.schema.ts +22 -0
  18. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalCreateResponse.schema.ts +22 -0
  19. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalDetail.schema.ts +5 -5
  20. package/src/api/generated/ext_payments/_utils/schemas/WithdrawalList.schema.ts +2 -2
  21. package/src/api/generated/ext_payments/_utils/schemas/index.ts +3 -0
  22. package/src/api/generated/ext_payments/client.ts +1 -1
  23. package/src/api/generated/ext_payments/ext_payments__payments/client.ts +49 -4
  24. package/src/api/generated/ext_payments/ext_payments__payments/models.ts +33 -14
  25. package/src/api/generated/ext_payments/index.ts +1 -1
  26. package/src/api/generated/ext_payments/schema.json +167 -33
  27. package/src/components/AddFundsSheet.tsx +157 -73
  28. package/src/components/CurrencyCombobox.tsx +49 -0
  29. package/src/components/PaymentSheet.tsx +94 -32
  30. package/src/components/WithdrawSheet.tsx +121 -95
  31. package/src/components/WithdrawalSheet.tsx +332 -0
  32. package/src/components/index.ts +1 -8
  33. package/src/config.ts +1 -0
  34. package/src/contexts/WalletContext.tsx +10 -9
  35. package/src/contexts/index.ts +5 -1
  36. package/src/contexts/types.ts +46 -0
  37. package/src/hooks/index.ts +3 -0
  38. package/src/hooks/useCurrencyOptions.ts +79 -0
  39. package/src/hooks/useEstimate.ts +113 -0
  40. package/src/hooks/useWithdrawalEstimate.ts +117 -0
  41. package/src/index.ts +3 -0
  42. package/src/types/index.ts +78 -0
  43. package/src/utils/errors.ts +36 -0
  44. package/src/utils/format.ts +65 -0
  45. package/src/utils/index.ts +3 -0
  46. package/src/components/ResponsiveSheet.tsx +0 -151
@@ -59,11 +59,8 @@ export interface PaymentDetail {
59
59
  currency_name: string;
60
60
  currency_token: string;
61
61
  currency_network: string;
62
- /** Amount to pay in cryptocurrency */
63
62
  pay_amount?: string | null;
64
- /** Actual amount received in cryptocurrency */
65
63
  actual_amount?: string | null;
66
- /** Actual amount received in USD */
67
64
  actual_amount_usd?: string | null;
68
65
  /** Current payment status
69
66
 
@@ -77,21 +74,16 @@ export interface PaymentDetail {
77
74
  * `cancelled` - Cancelled */
78
75
  status: Enums.PaymentDetailStatus;
79
76
  status_display: string;
80
- /** Cryptocurrency payment address */
81
77
  pay_address?: string | null;
82
78
  /** Get QR code URL. */
83
79
  qr_code_url?: string | null;
84
- /** Payment page URL (if provided by provider) */
85
80
  payment_url?: string | null;
86
- /** Blockchain transaction hash */
87
81
  transaction_hash?: string | null;
88
82
  /** Get blockchain explorer link. */
89
83
  explorer_link?: string | null;
90
84
  /** Number of blockchain confirmations */
91
85
  confirmations_count: number;
92
- /** When this payment expires (typically 30 minutes) */
93
86
  expires_at?: string | null;
94
- /** When this payment was completed */
95
87
  completed_at?: string | null;
96
88
  /** When this record was created */
97
89
  created_at: string;
@@ -148,6 +140,17 @@ export interface PaymentCreateRequest {
148
140
  description?: string;
149
141
  }
150
142
 
143
+ /**
144
+ * Response for payment creation.
145
+ *
146
+ * Response model (includes read-only fields).
147
+ */
148
+ export interface PaymentCreateResponse {
149
+ success: boolean;
150
+ payment: PaymentDetail;
151
+ qr_code_url: string | null;
152
+ }
153
+
151
154
  /**
152
155
  *
153
156
  * Response model (includes read-only fields).
@@ -199,7 +202,6 @@ export interface WithdrawalDetail {
199
202
  total_fee_usd: string;
200
203
  /** Final amount to receive (amount - total_fee) */
201
204
  final_amount_usd: string;
202
- /** Amount in cryptocurrency (calculated at processing time) */
203
205
  crypto_amount?: string | null;
204
206
  /** Withdrawal status
205
207
 
@@ -211,7 +213,6 @@ export interface WithdrawalDetail {
211
213
  * `cancelled` - Cancelled */
212
214
  status: Enums.WithdrawalDetailStatus;
213
215
  status_display: string;
214
- /** Blockchain transaction hash (after sending) */
215
216
  transaction_hash?: string | null;
216
217
  /** Get blockchain explorer link. */
217
218
  explorer_link?: string | null;
@@ -219,16 +220,23 @@ export interface WithdrawalDetail {
219
220
  admin_notes: string;
220
221
  /** When this record was created */
221
222
  created_at: string;
222
- /** When approved by admin */
223
223
  approved_at?: string | null;
224
- /** When withdrawal was completed */
225
224
  completed_at?: string | null;
226
- /** When rejected by admin */
227
225
  rejected_at?: string | null;
228
- /** When cancelled by user */
229
226
  cancelled_at?: string | null;
230
227
  }
231
228
 
229
+ /**
230
+ * Response for withdrawal cancellation.
231
+ *
232
+ * Response model (includes read-only fields).
233
+ */
234
+ export interface WithdrawalCancelResponse {
235
+ success: boolean;
236
+ withdrawal: WithdrawalDetail;
237
+ message: string;
238
+ }
239
+
232
240
  /**
233
241
  * Serializer for creating withdrawal request.
234
242
  *
@@ -243,6 +251,17 @@ export interface WithdrawalCreateRequest {
243
251
  wallet_address: string;
244
252
  }
245
253
 
254
+ /**
255
+ * Response for withdrawal creation.
256
+ *
257
+ * Response model (includes read-only fields).
258
+ */
259
+ export interface WithdrawalCreateResponse {
260
+ success: boolean;
261
+ withdrawal: WithdrawalDetail;
262
+ message: string;
263
+ }
264
+
246
265
  /**
247
266
  * Withdrawal list item (lighter than detail).
248
267
  *
@@ -1,6 +1,6 @@
1
1
  // Auto-generated by DjangoCFG - see CLAUDE.md
2
2
  /**
3
- * Django CFG API - API Client with JWT Management
3
+ * Cmdop API - API Client with JWT Management
4
4
  *
5
5
  * Usage:
6
6
  * ```typescript
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "openapi": "3.0.3",
3
3
  "info": {
4
- "title": "Django CFG API",
4
+ "title": "Cmdop API",
5
5
  "version": "1.0.0",
6
6
  "description": "Complete API documentation for Django CFG Demo Project",
7
7
  "x-django-metadata": {
@@ -45,7 +45,7 @@
45
45
  "/cfg/payments/currencies/": {
46
46
  "get": {
47
47
  "operationId": "cfg_payments_currencies_list",
48
- "description": "Returns list of available currencies with token+network info",
48
+ "description": "Returns list of available currencies with token+network info, popular first",
49
49
  "summary": "Get available currencies",
50
50
  "tags": [
51
51
  "payments"
@@ -73,6 +73,92 @@
73
73
  "x-async-capable": false
74
74
  }
75
75
  },
76
+ "/cfg/payments/currencies/{code}/estimate/": {
77
+ "get": {
78
+ "operationId": "cfg_payments_currencies_estimate_retrieve",
79
+ "description": "Get estimated crypto amount for a given USD amount, including min amount",
80
+ "summary": "Get currency estimate",
81
+ "parameters": [
82
+ {
83
+ "in": "query",
84
+ "name": "amount",
85
+ "schema": {
86
+ "type": "number",
87
+ "format": "double"
88
+ },
89
+ "description": "Amount in USD (default: 1)"
90
+ },
91
+ {
92
+ "in": "path",
93
+ "name": "code",
94
+ "schema": {
95
+ "type": "string"
96
+ },
97
+ "required": true
98
+ }
99
+ ],
100
+ "tags": [
101
+ "payments"
102
+ ],
103
+ "security": [
104
+ {
105
+ "jwtAuthWithLastLogin": []
106
+ }
107
+ ],
108
+ "responses": {
109
+ "200": {
110
+ "description": "Estimate response"
111
+ },
112
+ "400": {
113
+ "description": "Invalid currency"
114
+ }
115
+ },
116
+ "x-async-capable": false
117
+ }
118
+ },
119
+ "/cfg/payments/currencies/{code}/withdrawal-estimate/": {
120
+ "get": {
121
+ "operationId": "cfg_payments_currencies_withdrawal_estimate_retrieve",
122
+ "description": "Get estimated crypto amount for withdrawal with fee breakdown",
123
+ "summary": "Get withdrawal estimate",
124
+ "parameters": [
125
+ {
126
+ "in": "query",
127
+ "name": "amount",
128
+ "schema": {
129
+ "type": "number",
130
+ "format": "double"
131
+ },
132
+ "description": "Amount to withdraw in USD (default: 10)"
133
+ },
134
+ {
135
+ "in": "path",
136
+ "name": "code",
137
+ "schema": {
138
+ "type": "string"
139
+ },
140
+ "required": true
141
+ }
142
+ ],
143
+ "tags": [
144
+ "payments"
145
+ ],
146
+ "security": [
147
+ {
148
+ "jwtAuthWithLastLogin": []
149
+ }
150
+ ],
151
+ "responses": {
152
+ "200": {
153
+ "description": "Withdrawal estimate response"
154
+ },
155
+ "400": {
156
+ "description": "Invalid currency or amount"
157
+ }
158
+ },
159
+ "x-async-capable": false
160
+ }
161
+ },
76
162
  "/cfg/payments/payments/": {
77
163
  "get": {
78
164
  "operationId": "cfg_payments_payments_list",
@@ -269,7 +355,7 @@
269
355
  "content": {
270
356
  "application/json": {
271
357
  "schema": {
272
- "$ref": "#/components/schemas/PaymentDetail"
358
+ "$ref": "#/components/schemas/PaymentCreateResponse"
273
359
  }
274
360
  }
275
361
  },
@@ -451,7 +537,7 @@
451
537
  "content": {
452
538
  "application/json": {
453
539
  "schema": {
454
- "$ref": "#/components/schemas/WithdrawalDetail"
540
+ "$ref": "#/components/schemas/WithdrawalCancelResponse"
455
541
  }
456
542
  }
457
543
  },
@@ -502,7 +588,7 @@
502
588
  "content": {
503
589
  "application/json": {
504
590
  "schema": {
505
- "$ref": "#/components/schemas/WithdrawalDetail"
591
+ "$ref": "#/components/schemas/WithdrawalCreateResponse"
506
592
  }
507
593
  }
508
594
  },
@@ -786,6 +872,28 @@
786
872
  "currency_code"
787
873
  ]
788
874
  },
875
+ "PaymentCreateResponse": {
876
+ "type": "object",
877
+ "description": "Response for payment creation.",
878
+ "properties": {
879
+ "success": {
880
+ "type": "boolean"
881
+ },
882
+ "payment": {
883
+ "$ref": "#/components/schemas/PaymentDetail"
884
+ },
885
+ "qr_code_url": {
886
+ "type": "string",
887
+ "format": "uri",
888
+ "nullable": true
889
+ }
890
+ },
891
+ "required": [
892
+ "payment",
893
+ "qr_code_url",
894
+ "success"
895
+ ]
896
+ },
789
897
  "PaymentDetail": {
790
898
  "type": "object",
791
899
  "description": "Detailed payment information.",
@@ -829,24 +937,21 @@
829
937
  "format": "decimal",
830
938
  "pattern": "^-?\\d{0,12}(?:\\.\\d{0,8})?$",
831
939
  "readOnly": true,
832
- "nullable": true,
833
- "description": "Amount to pay in cryptocurrency"
940
+ "nullable": true
834
941
  },
835
942
  "actual_amount": {
836
943
  "type": "string",
837
944
  "format": "decimal",
838
945
  "pattern": "^-?\\d{0,12}(?:\\.\\d{0,8})?$",
839
946
  "readOnly": true,
840
- "nullable": true,
841
- "description": "Actual amount received in cryptocurrency"
947
+ "nullable": true
842
948
  },
843
949
  "actual_amount_usd": {
844
950
  "type": "string",
845
951
  "format": "decimal",
846
952
  "pattern": "^-?\\d{0,8}(?:\\.\\d{0,2})?$",
847
953
  "readOnly": true,
848
- "nullable": true,
849
- "description": "Actual amount received in USD"
954
+ "nullable": true
850
955
  },
851
956
  "status": {
852
957
  "enum": [
@@ -871,8 +976,7 @@
871
976
  "pay_address": {
872
977
  "type": "string",
873
978
  "readOnly": true,
874
- "nullable": true,
875
- "description": "Cryptocurrency payment address"
979
+ "nullable": true
876
980
  },
877
981
  "qr_code_url": {
878
982
  "type": "string",
@@ -884,14 +988,12 @@
884
988
  "type": "string",
885
989
  "format": "uri",
886
990
  "readOnly": true,
887
- "nullable": true,
888
- "description": "Payment page URL (if provided by provider)"
991
+ "nullable": true
889
992
  },
890
993
  "transaction_hash": {
891
994
  "type": "string",
892
995
  "readOnly": true,
893
- "nullable": true,
894
- "description": "Blockchain transaction hash"
996
+ "nullable": true
895
997
  },
896
998
  "explorer_link": {
897
999
  "type": "string",
@@ -908,15 +1010,13 @@
908
1010
  "type": "string",
909
1011
  "format": "date-time",
910
1012
  "readOnly": true,
911
- "nullable": true,
912
- "description": "When this payment expires (typically 30 minutes)"
1013
+ "nullable": true
913
1014
  },
914
1015
  "completed_at": {
915
1016
  "type": "string",
916
1017
  "format": "date-time",
917
1018
  "readOnly": true,
918
- "nullable": true,
919
- "description": "When this payment was completed"
1019
+ "nullable": true
920
1020
  },
921
1021
  "created_at": {
922
1022
  "type": "string",
@@ -1123,6 +1223,26 @@
1123
1223
  "type_display"
1124
1224
  ]
1125
1225
  },
1226
+ "WithdrawalCancelResponse": {
1227
+ "type": "object",
1228
+ "description": "Response for withdrawal cancellation.",
1229
+ "properties": {
1230
+ "success": {
1231
+ "type": "boolean"
1232
+ },
1233
+ "withdrawal": {
1234
+ "$ref": "#/components/schemas/WithdrawalDetail"
1235
+ },
1236
+ "message": {
1237
+ "type": "string"
1238
+ }
1239
+ },
1240
+ "required": [
1241
+ "message",
1242
+ "success",
1243
+ "withdrawal"
1244
+ ]
1245
+ },
1126
1246
  "WithdrawalCreateRequest": {
1127
1247
  "type": "object",
1128
1248
  "description": "Serializer for creating withdrawal request.",
@@ -1152,6 +1272,26 @@
1152
1272
  "wallet_address"
1153
1273
  ]
1154
1274
  },
1275
+ "WithdrawalCreateResponse": {
1276
+ "type": "object",
1277
+ "description": "Response for withdrawal creation.",
1278
+ "properties": {
1279
+ "success": {
1280
+ "type": "boolean"
1281
+ },
1282
+ "withdrawal": {
1283
+ "$ref": "#/components/schemas/WithdrawalDetail"
1284
+ },
1285
+ "message": {
1286
+ "type": "string"
1287
+ }
1288
+ },
1289
+ "required": [
1290
+ "message",
1291
+ "success",
1292
+ "withdrawal"
1293
+ ]
1294
+ },
1155
1295
  "WithdrawalDetail": {
1156
1296
  "type": "object",
1157
1297
  "description": "Detailed withdrawal information.",
@@ -1228,8 +1368,7 @@
1228
1368
  "format": "decimal",
1229
1369
  "pattern": "^-?\\d{0,12}(?:\\.\\d{0,8})?$",
1230
1370
  "readOnly": true,
1231
- "nullable": true,
1232
- "description": "Amount in cryptocurrency (calculated at processing time)"
1371
+ "nullable": true
1233
1372
  },
1234
1373
  "status": {
1235
1374
  "enum": [
@@ -1252,8 +1391,7 @@
1252
1391
  "transaction_hash": {
1253
1392
  "type": "string",
1254
1393
  "readOnly": true,
1255
- "nullable": true,
1256
- "description": "Blockchain transaction hash (after sending)"
1394
+ "nullable": true
1257
1395
  },
1258
1396
  "explorer_link": {
1259
1397
  "type": "string",
@@ -1276,29 +1414,25 @@
1276
1414
  "type": "string",
1277
1415
  "format": "date-time",
1278
1416
  "readOnly": true,
1279
- "nullable": true,
1280
- "description": "When approved by admin"
1417
+ "nullable": true
1281
1418
  },
1282
1419
  "completed_at": {
1283
1420
  "type": "string",
1284
1421
  "format": "date-time",
1285
1422
  "readOnly": true,
1286
- "nullable": true,
1287
- "description": "When withdrawal was completed"
1423
+ "nullable": true
1288
1424
  },
1289
1425
  "rejected_at": {
1290
1426
  "type": "string",
1291
1427
  "format": "date-time",
1292
1428
  "readOnly": true,
1293
- "nullable": true,
1294
- "description": "When rejected by admin"
1429
+ "nullable": true
1295
1430
  },
1296
1431
  "cancelled_at": {
1297
1432
  "type": "string",
1298
1433
  "format": "date-time",
1299
1434
  "readOnly": true,
1300
- "nullable": true,
1301
- "description": "When cancelled by user"
1435
+ "nullable": true
1302
1436
  }
1303
1437
  },
1304
1438
  "required": [