@reeboot/strapi-payment-plugin 0.0.1 → 0.0.3

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 (84) hide show
  1. package/README.md +378 -119
  2. package/dist/_chunks/Analytics-DSJqY9ng.mjs +355 -0
  3. package/dist/_chunks/Analytics-nBSdLT2v.js +355 -0
  4. package/dist/_chunks/App-B83DZ9NG.js +70 -0
  5. package/dist/_chunks/App-BUSTbkyy.mjs +68 -0
  6. package/dist/_chunks/Customers-BpFzfglV.js +273 -0
  7. package/dist/_chunks/Customers-C6FH7-zG.mjs +273 -0
  8. package/dist/_chunks/Dashboard-CNMTzSyc.js +180 -0
  9. package/dist/_chunks/Dashboard-Dbwl0ZBo.mjs +180 -0
  10. package/dist/_chunks/Orders-CBkT2YfP.mjs +308 -0
  11. package/dist/_chunks/Orders-OG-pwV-B.js +308 -0
  12. package/dist/_chunks/Payments-BLen1P9N.js +489 -0
  13. package/dist/_chunks/Payments-DSDJ-HWm.mjs +489 -0
  14. package/dist/_chunks/Settings-Dq1xy32B.js +357 -0
  15. package/dist/_chunks/Settings-jmGslDsB.mjs +357 -0
  16. package/dist/_chunks/en-BJocyOVu.mjs +240 -0
  17. package/dist/_chunks/en-BkVAf_R4.js +240 -0
  18. package/dist/_chunks/index-BqqrpI6D.js +66 -0
  19. package/dist/_chunks/index-DS_PYNkf.mjs +67 -0
  20. package/dist/admin/index.js +2 -63
  21. package/dist/admin/index.mjs +2 -63
  22. package/dist/admin/src/components/AnalyticsChart.d.ts +19 -0
  23. package/dist/admin/src/components/CustomerList.d.ts +21 -0
  24. package/dist/admin/src/components/OrderList.d.ts +27 -0
  25. package/dist/admin/src/components/PaymentCard.d.ts +39 -0
  26. package/dist/admin/src/components/PaymentList.d.ts +19 -0
  27. package/dist/admin/src/components/RefundModal.d.ts +15 -0
  28. package/dist/admin/src/pages/Analytics.d.ts +2 -0
  29. package/dist/admin/src/pages/Customers.d.ts +2 -0
  30. package/dist/admin/src/pages/Dashboard.d.ts +2 -0
  31. package/dist/admin/src/pages/HomePage.d.ts +1 -1
  32. package/dist/admin/src/pages/Orders.d.ts +2 -0
  33. package/dist/admin/src/pages/Payments.d.ts +2 -0
  34. package/dist/admin/src/pages/Settings.d.ts +2 -0
  35. package/dist/admin/src/pluginId.d.ts +1 -1
  36. package/dist/server/index.js +1770 -992
  37. package/dist/server/index.mjs +1773 -995
  38. package/dist/server/src/bootstrap.d.ts +5 -11
  39. package/dist/server/src/config/index.d.ts +0 -10
  40. package/dist/server/src/content-types/customer/index.d.ts +69 -0
  41. package/dist/server/src/content-types/index.d.ts +123 -39
  42. package/dist/server/src/content-types/{product.d.ts → order/index.d.ts} +26 -19
  43. package/dist/server/src/content-types/{subscription.d.ts → payment/index.d.ts} +30 -21
  44. package/dist/server/src/controllers/controller.d.ts +5 -12
  45. package/dist/server/src/controllers/index.d.ts +29 -34
  46. package/dist/server/src/controllers/stripe.d.ts +104 -0
  47. package/dist/server/src/index.d.ts +179 -139
  48. package/dist/server/src/middlewares/index.d.ts +19 -1
  49. package/dist/server/src/policies/index.d.ts +3 -1
  50. package/dist/server/src/routes/{admin-routes.d.ts → admin/index.d.ts} +4 -4
  51. package/dist/server/src/routes/content-api/index.d.ts +21 -0
  52. package/dist/server/src/routes/index.d.ts +11 -16
  53. package/dist/server/src/services/index.d.ts +2 -38
  54. package/dist/server/src/services/{stripeDriver.d.ts → stripe.d.ts} +52 -59
  55. package/dist/server/src/types/index.d.ts +179 -0
  56. package/package.json +20 -25
  57. package/dist/_chunks/App-DD7GyuRr.mjs +0 -1424
  58. package/dist/_chunks/App-KZVBFRwo.js +0 -1424
  59. package/dist/_chunks/en-B4KWt_jN.js +0 -4
  60. package/dist/_chunks/en-Byx4XI2L.mjs +0 -4
  61. package/dist/admin/src/components/Header.d.ts +0 -2
  62. package/dist/admin/src/components/NavigationMenu.d.ts +0 -2
  63. package/dist/admin/src/components/Sidebar.d.ts +0 -2
  64. package/dist/admin/src/components/TransactionDetailsModal.d.ts +0 -18
  65. package/dist/admin/src/components/TransactionList.d.ts +0 -18
  66. package/dist/admin/src/pages/ConfigurationPage.d.ts +0 -2
  67. package/dist/admin/src/pages/DashboardPage.d.ts +0 -2
  68. package/dist/admin/src/pages/ProductsPage.d.ts +0 -2
  69. package/dist/admin/src/pages/SubscriptionsPage.d.ts +0 -2
  70. package/dist/admin/src/pages/TransactionsPage.d.ts +0 -2
  71. package/dist/server/src/controllers/product.d.ts +0 -18
  72. package/dist/server/src/controllers/subscription.d.ts +0 -16
  73. package/dist/server/src/controllers/webhook.d.ts +0 -10
  74. package/dist/server/src/routes/content-api.d.ts +0 -12
  75. package/dist/server/src/routes/product.d.ts +0 -2
  76. package/dist/server/src/routes/refund-routes.d.ts +0 -13
  77. package/dist/server/src/routes/subscription.d.ts +0 -5
  78. package/dist/server/src/routes/webhook.d.ts +0 -15
  79. package/dist/server/src/services/paypalDriver.d.ts +0 -47
  80. package/dist/server/src/services/product.d.ts +0 -7
  81. package/dist/server/src/services/service.d.ts +0 -26
  82. package/dist/server/src/services/subscription.d.ts +0 -9
  83. package/dist/server/src/services/sync.d.ts +0 -13
  84. package/jest.config.js +0 -13
@@ -0,0 +1,489 @@
1
+ import { jsxs, jsx } from "react/jsx-runtime";
2
+ import { useState, useEffect } from "react";
3
+ import { Dialog, Typography, Flex, Box, Button, TextInput, Textarea, Alert, Divider, Loader, EmptyStateLayout, Card, Grid, SingleSelect, SingleSelectOption, Table, Thead, Tr, Th, Tbody, Td, Pagination, Badge } from "@strapi/design-system";
4
+ import { useIntl } from "react-intl";
5
+ import { useFetchClient } from "@strapi/strapi/admin";
6
+ import { P as PLUGIN_ID } from "./index-DS_PYNkf.mjs";
7
+ const RefundModal = ({ payment, onClose, onSuccess }) => {
8
+ const { formatMessage } = useIntl();
9
+ const { post } = useFetchClient();
10
+ const [refundAmount, setRefundAmount] = useState(payment.amount);
11
+ const [reason, setReason] = useState("");
12
+ const [loading, setLoading] = useState(false);
13
+ const [error, setError] = useState(null);
14
+ const formatCurrency = (amount, currency = "usd") => {
15
+ return new Intl.NumberFormat("en-US", {
16
+ style: "currency",
17
+ currency: currency.toUpperCase()
18
+ }).format(amount);
19
+ };
20
+ const handleSubmit = async () => {
21
+ try {
22
+ setLoading(true);
23
+ setError(null);
24
+ if (refundAmount <= 0) {
25
+ setError("Refund amount must be greater than 0");
26
+ return;
27
+ }
28
+ if (refundAmount > payment.amount) {
29
+ setError("Refund amount cannot exceed the original payment amount");
30
+ return;
31
+ }
32
+ const { data } = await post(`/${PLUGIN_ID}/admin/payments/${payment.id}/refund`, {
33
+ amount: refundAmount,
34
+ reason: reason || "Requested by customer"
35
+ });
36
+ if (data.success) {
37
+ onSuccess();
38
+ } else {
39
+ throw new Error(data.error?.message || "Failed to process refund");
40
+ }
41
+ } catch (err) {
42
+ setError(err instanceof Error ? err.message : "An error occurred");
43
+ } finally {
44
+ setLoading(false);
45
+ }
46
+ };
47
+ const handlePartialRefund = (percentage) => {
48
+ setRefundAmount(Math.round(payment.amount * percentage / 100));
49
+ };
50
+ const handleFullRefund = () => {
51
+ setRefundAmount(payment.amount);
52
+ };
53
+ return /* @__PURE__ */ jsxs(Dialog, { onClose, title: formatMessage({ id: "payment-plugin.refund.title", defaultMessage: "Process Refund" }), children: [
54
+ /* @__PURE__ */ jsx(Dialog.Header, { children: /* @__PURE__ */ jsx(Typography, { variant: "beta", children: formatMessage({ id: "payment-plugin.refund.header", defaultMessage: "Process Refund" }) }) }),
55
+ /* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, children: [
56
+ /* @__PURE__ */ jsxs(Box, { children: [
57
+ /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", fontWeight: "bold", children: formatMessage({ id: "payment-plugin.refund.paymentInfo", defaultMessage: "Payment Information" }) }),
58
+ /* @__PURE__ */ jsxs(Box, { marginTop: 2, children: [
59
+ /* @__PURE__ */ jsxs(Typography, { variant: "epsilon", children: [
60
+ formatMessage({ id: "payment-plugin.refund.customer", defaultMessage: "Customer" }),
61
+ ": ",
62
+ payment.customerEmail
63
+ ] }),
64
+ /* @__PURE__ */ jsxs(Typography, { variant: "epsilon", children: [
65
+ formatMessage({ id: "payment-plugin.refund.originalAmount", defaultMessage: "Original Amount" }),
66
+ ": ",
67
+ formatCurrency(payment.amount, payment.currency)
68
+ ] }),
69
+ /* @__PURE__ */ jsxs(Typography, { variant: "epsilon", children: [
70
+ formatMessage({ id: "payment-plugin.refund.description", defaultMessage: "Description" }),
71
+ ": ",
72
+ payment.description || "N/A"
73
+ ] })
74
+ ] })
75
+ ] }),
76
+ /* @__PURE__ */ jsxs(Box, { children: [
77
+ /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", fontWeight: "bold", marginBottom: 2, children: formatMessage({ id: "payment-plugin.refund.quickOptions", defaultMessage: "Quick Options" }) }),
78
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", children: [
79
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: handleFullRefund, children: formatMessage({ id: "payment-plugin.refund.full", defaultMessage: "Full Refund" }) }),
80
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => handlePartialRefund(50), children: formatMessage({ id: "payment-plugin.refund.half", defaultMessage: "50% Refund" }) }),
81
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => handlePartialRefund(25), children: formatMessage({ id: "payment-plugin.refund.quarter", defaultMessage: "25% Refund" }) })
82
+ ] })
83
+ ] }),
84
+ /* @__PURE__ */ jsxs(Box, { children: [
85
+ /* @__PURE__ */ jsx(
86
+ TextInput,
87
+ {
88
+ label: formatMessage({ id: "payment-plugin.refund.amount", defaultMessage: "Refund Amount" }),
89
+ placeholder: formatCurrency(payment.amount, payment.currency),
90
+ value: (refundAmount / 100).toString(),
91
+ onChange: (e) => {
92
+ const value = parseFloat(e.target.value) || 0;
93
+ setRefundAmount(Math.round(value * 100));
94
+ },
95
+ hint: formatMessage(
96
+ { id: "payment-plugin.refund.maxAmount", defaultMessage: "Maximum: {amount}" },
97
+ { amount: formatCurrency(payment.amount, payment.currency) }
98
+ )
99
+ }
100
+ ),
101
+ /* @__PURE__ */ jsxs(Typography, { variant: "epsilon", textColor: "neutral600", marginTop: 1, children: [
102
+ formatMessage({ id: "payment-plugin.refund.inCents", defaultMessage: "Amount in cents" }),
103
+ ": ",
104
+ refundAmount
105
+ ] })
106
+ ] }),
107
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
108
+ Textarea,
109
+ {
110
+ label: formatMessage({ id: "payment-plugin.refund.reason", defaultMessage: "Reason (Optional)" }),
111
+ placeholder: formatMessage({ id: "payment-plugin.refund.reasonPlaceholder", defaultMessage: "Reason for refund..." }),
112
+ value: reason,
113
+ onChange: (e) => setReason(e.target.value),
114
+ rows: 3
115
+ }
116
+ ) }),
117
+ error && /* @__PURE__ */ jsx(Alert, { severity: "danger", title: formatMessage({ id: "payment-plugin.refund.error", defaultMessage: "Error" }), children: error }),
118
+ /* @__PURE__ */ jsx(Alert, { severity: "warning", title: formatMessage({ id: "payment-plugin.refund.warning", defaultMessage: "Warning" }), children: formatMessage({
119
+ id: "payment-plugin.refund.warningMessage",
120
+ defaultMessage: "This action cannot be undone. The refund will be processed immediately."
121
+ }) })
122
+ ] }) }),
123
+ /* @__PURE__ */ jsx(Dialog.Footer, { children: /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
124
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: onClose, disabled: loading, children: formatMessage({ id: "payment-plugin.refund.cancel", defaultMessage: "Cancel" }) }),
125
+ /* @__PURE__ */ jsx(
126
+ Button,
127
+ {
128
+ variant: "danger",
129
+ onClick: handleSubmit,
130
+ disabled: loading || refundAmount <= 0 || refundAmount > payment.amount,
131
+ loading,
132
+ children: formatMessage({ id: "payment-plugin.refund.submit", defaultMessage: "Process Refund" })
133
+ }
134
+ )
135
+ ] }) })
136
+ ] });
137
+ };
138
+ const PaymentCard = ({ payment, onClose }) => {
139
+ const { formatMessage } = useIntl();
140
+ return /* @__PURE__ */ jsxs(Dialog, { onClose, title: formatMessage({ id: "payment-plugin.paymentDetails.title", defaultMessage: "Payment Details" }), children: [
141
+ /* @__PURE__ */ jsx(Dialog.Header, {}),
142
+ /* @__PURE__ */ jsx(Dialog.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 6, children: [
143
+ /* @__PURE__ */ jsx(Box, {}),
144
+ /* @__PURE__ */ jsx(Divider, {}),
145
+ /* @__PURE__ */ jsx(Box, {})
146
+ ] }) })
147
+ ] });
148
+ };
149
+ const Payments = () => {
150
+ const { formatMessage } = useIntl();
151
+ const { get } = useFetchClient();
152
+ const [payments, setPayments] = useState([]);
153
+ const [filteredPayments, setFilteredPayments] = useState([]);
154
+ const [loading, setLoading] = useState(true);
155
+ const [error, setError] = useState(null);
156
+ const [selectedPayment, setSelectedPayment] = useState(null);
157
+ const [showRefundModal, setShowRefundModal] = useState(false);
158
+ const [showPaymentCard, setShowPaymentCard] = useState(false);
159
+ const [currentPage, setCurrentPage] = useState(1);
160
+ const [pageSize, setPageSize] = useState(25);
161
+ const [totalCount, setTotalCount] = useState(0);
162
+ const [filters, setFilters] = useState({
163
+ status: "",
164
+ paymentMethod: "",
165
+ dateRange: { from: null, to: null },
166
+ search: "",
167
+ currency: ""
168
+ });
169
+ useEffect(() => {
170
+ fetchPayments();
171
+ }, [currentPage, pageSize, filters]);
172
+ useEffect(() => {
173
+ applyFilters();
174
+ }, [payments, filters]);
175
+ const fetchPayments = async () => {
176
+ try {
177
+ setLoading(true);
178
+ const queryParams = new URLSearchParams({
179
+ page: currentPage.toString(),
180
+ pageSize: pageSize.toString(),
181
+ ...filters.status && { status: filters.status }
182
+ });
183
+ const { data } = await get(`/${PLUGIN_ID}/admin/payments?${queryParams}`);
184
+ if (data.success && data.data) {
185
+ const formattedPayments = data.data.map((p) => ({
186
+ id: p.documentId,
187
+ stripePaymentId: p.stripe_payment_intent_id,
188
+ amount: p.amount,
189
+ currency: p.currency,
190
+ status: p.status,
191
+ customerEmail: p.customer?.email || "N/A",
192
+ customerName: p.customer ? `${p.customer.firstName || ""} ${p.customer.lastName || ""}`.trim() : "N/A",
193
+ paymentMethod: p.payment_method || "N/A",
194
+ createdAt: p.createdAt,
195
+ updatedAt: p.updatedAt,
196
+ orderId: p.order?.documentId
197
+ }));
198
+ setPayments(formattedPayments);
199
+ setTotalCount(data.meta.pagination.total);
200
+ }
201
+ setLoading(false);
202
+ } catch (err) {
203
+ setError("Failed to fetch payments");
204
+ setLoading(false);
205
+ }
206
+ };
207
+ const applyFilters = () => {
208
+ let filtered = [...payments];
209
+ if (filters.search) {
210
+ const searchLower = filters.search.toLowerCase();
211
+ filtered = filtered.filter(
212
+ (payment) => payment.customerEmail.toLowerCase().includes(searchLower) || payment.customerName?.toLowerCase().includes(searchLower) || payment.stripePaymentId.toLowerCase().includes(searchLower) || payment.description?.toLowerCase().includes(searchLower)
213
+ );
214
+ }
215
+ if (filters.status) {
216
+ filtered = filtered.filter((payment) => payment.status === filters.status);
217
+ }
218
+ if (filters.paymentMethod) {
219
+ filtered = filtered.filter((payment) => payment.paymentMethod === filters.paymentMethod);
220
+ }
221
+ if (filters.currency) {
222
+ filtered = filtered.filter((payment) => payment.currency === filters.currency);
223
+ }
224
+ if (filters.dateRange.from) {
225
+ filtered = filtered.filter(
226
+ (payment) => new Date(payment.createdAt) >= filters.dateRange.from
227
+ );
228
+ }
229
+ if (filters.dateRange.to) {
230
+ filtered = filtered.filter(
231
+ (payment) => new Date(payment.createdAt) <= filters.dateRange.to
232
+ );
233
+ }
234
+ setFilteredPayments(filtered);
235
+ };
236
+ const formatCurrency = (amount, currency = "usd") => {
237
+ return new Intl.NumberFormat("en-US", {
238
+ style: "currency",
239
+ currency: currency.toUpperCase()
240
+ }).format(amount);
241
+ };
242
+ const formatDate = (dateString) => {
243
+ return new Date(dateString).toLocaleDateString("en-US", {
244
+ year: "numeric",
245
+ month: "short",
246
+ day: "numeric",
247
+ hour: "2-digit",
248
+ minute: "2-digit"
249
+ });
250
+ };
251
+ const getStatusBadge = (status) => {
252
+ const statusConfig = {
253
+ succeeded: { color: "success", label: "Success" },
254
+ pending: { color: "warning", label: "Pending" },
255
+ failed: { color: "danger", label: "Failed" },
256
+ refunded: { color: "info", label: "Refunded" },
257
+ canceled: { color: "neutral", label: "Canceled" }
258
+ };
259
+ const config = statusConfig[status] || statusConfig.pending;
260
+ return /* @__PURE__ */ jsx(Badge, { size: "S", backgroundColor: config.color, children: config.label });
261
+ };
262
+ const handleRefund = (payment) => {
263
+ setSelectedPayment(payment);
264
+ setShowRefundModal(true);
265
+ };
266
+ const handleViewDetails = (payment) => {
267
+ setSelectedPayment(payment);
268
+ setShowPaymentCard(true);
269
+ };
270
+ const handleFilterChange = (key, value) => {
271
+ setFilters((prev) => ({ ...prev, [key]: value }));
272
+ setCurrentPage(1);
273
+ };
274
+ const clearFilters = () => {
275
+ setFilters({
276
+ status: "",
277
+ paymentMethod: "",
278
+ dateRange: { from: null, to: null },
279
+ search: "",
280
+ currency: ""
281
+ });
282
+ setCurrentPage(1);
283
+ };
284
+ const exportPayments = () => {
285
+ const csvContent = [
286
+ ["ID", "Stripe Payment ID", "Customer Email", "Amount", "Currency", "Status", "Payment Method", "Date"],
287
+ ...filteredPayments.map((payment) => [
288
+ payment.id,
289
+ payment.stripePaymentId,
290
+ payment.customerEmail,
291
+ (payment.amount / 100).toString(),
292
+ payment.currency,
293
+ payment.status,
294
+ payment.paymentMethod,
295
+ formatDate(payment.createdAt)
296
+ ])
297
+ ].map((row) => row.join(",")).join("\n");
298
+ const blob = new Blob([csvContent], { type: "text/csv" });
299
+ const url = window.URL.createObjectURL(blob);
300
+ const a = document.createElement("a");
301
+ a.href = url;
302
+ a.download = `payments-${(/* @__PURE__ */ new Date()).toISOString().split("T")[0]}.csv`;
303
+ a.click();
304
+ window.URL.revokeObjectURL(url);
305
+ };
306
+ const startIndex = (currentPage - 1) * pageSize;
307
+ const endIndex = startIndex + pageSize;
308
+ const paginatedPayments = filteredPayments.slice(startIndex, endIndex);
309
+ const totalPages = Math.ceil(filteredPayments.length / pageSize);
310
+ if (loading && payments.length === 0) {
311
+ return /* @__PURE__ */ jsx(Box, { paddingLeft: 10, paddingRight: 10, paddingTop: 4, paddingBottom: 10, children: /* @__PURE__ */ jsx(Flex, { justifyContent: "center", alignItems: "center", style: { minHeight: "400px" }, children: /* @__PURE__ */ jsx(Loader, {}) }) });
312
+ }
313
+ if (error) {
314
+ return /* @__PURE__ */ jsx(Box, { paddingLeft: 10, paddingRight: 10, paddingTop: 4, paddingBottom: 10, children: /* @__PURE__ */ jsx(
315
+ EmptyStateLayout,
316
+ {
317
+ title: "Error loading payments",
318
+ subtitle: error,
319
+ action: /* @__PURE__ */ jsx(Button, { onClick: fetchPayments, children: formatMessage({ id: "payment-plugin.payments.retry", defaultMessage: "Retry" }) })
320
+ }
321
+ ) });
322
+ }
323
+ return /* @__PURE__ */ jsxs(Box, { paddingLeft: 10, paddingRight: 10, paddingTop: 4, paddingBottom: 10, children: [
324
+ /* @__PURE__ */ jsx(Box, { marginBottom: 4, children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [
325
+ /* @__PURE__ */ jsxs(Box, { children: [
326
+ /* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: formatMessage({ id: "payment-plugin.payments.title", defaultMessage: "Payments" }) }),
327
+ /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage({
328
+ id: "payment-plugin.payments.subtitle",
329
+ defaultMessage: "Manage and monitor all payment transactions"
330
+ }) })
331
+ ] }),
332
+ /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
333
+ /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: exportPayments, children: formatMessage({ id: "payment-plugin.payments.export", defaultMessage: "Export" }) }),
334
+ /* @__PURE__ */ jsx(Button, { onClick: () => window.location.reload(), children: formatMessage({ id: "payment-plugin.payments.refresh", defaultMessage: "Refresh" }) })
335
+ ] })
336
+ ] }) }),
337
+ /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Grid.Root, { gap: 4, children: [
338
+ /* @__PURE__ */ jsx(Grid.Item, { col: 3, children: /* @__PURE__ */ jsx(
339
+ TextInput,
340
+ {
341
+ placeholder: formatMessage({
342
+ id: "payment-plugin.payments.search.placeholder",
343
+ defaultMessage: "Search payments..."
344
+ }),
345
+ value: filters.search,
346
+ onChange: (e) => handleFilterChange("search", e.target.value)
347
+ }
348
+ ) }),
349
+ /* @__PURE__ */ jsx(Grid.Item, { col: 2, children: /* @__PURE__ */ jsxs(
350
+ SingleSelect,
351
+ {
352
+ placeholder: formatMessage({
353
+ id: "payment-plugin.payments.status.placeholder",
354
+ defaultMessage: "All Statuses"
355
+ }),
356
+ value: filters.status,
357
+ onChange: (value) => handleFilterChange("status", value),
358
+ children: [
359
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "", children: formatMessage({ id: "payment-plugin.payments.all", defaultMessage: "All" }) }),
360
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "succeeded", children: formatMessage({ id: "payment-plugin.payments.succeeded", defaultMessage: "Succeeded" }) }),
361
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "pending", children: formatMessage({ id: "payment-plugin.payments.pending", defaultMessage: "Pending" }) }),
362
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "failed", children: formatMessage({ id: "payment-plugin.payments.failed", defaultMessage: "Failed" }) }),
363
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "refunded", children: formatMessage({ id: "payment-plugin.payments.refunded", defaultMessage: "Refunded" }) })
364
+ ]
365
+ }
366
+ ) }),
367
+ /* @__PURE__ */ jsx(Grid.Item, { col: 2, children: /* @__PURE__ */ jsxs(
368
+ SingleSelect,
369
+ {
370
+ placeholder: formatMessage({
371
+ id: "payment-plugin.payments.paymentMethod.placeholder",
372
+ defaultMessage: "All Payment Methods"
373
+ }),
374
+ value: filters.paymentMethod,
375
+ onChange: (value) => handleFilterChange("paymentMethod", value),
376
+ children: [
377
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "", children: formatMessage({ id: "payment-plugin.payments.all", defaultMessage: "All" }) }),
378
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "card", children: formatMessage({ id: "payment-plugin.payments.card", defaultMessage: "Card" }) }),
379
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "bank_transfer", children: formatMessage({ id: "payment-plugin.payments.bank_transfer", defaultMessage: "Bank Transfer" }) }),
380
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "wallet", children: formatMessage({ id: "payment-plugin.payments.wallet", defaultMessage: "Wallet" }) })
381
+ ]
382
+ }
383
+ ) }),
384
+ /* @__PURE__ */ jsx(Grid.Item, { col: 2, children: /* @__PURE__ */ jsxs(
385
+ SingleSelect,
386
+ {
387
+ placeholder: formatMessage({
388
+ id: "payment-plugin.payments.currency.placeholder",
389
+ defaultMessage: "All Currencies"
390
+ }),
391
+ value: filters.currency,
392
+ onChange: (value) => handleFilterChange("currency", value),
393
+ children: [
394
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "", children: formatMessage({ id: "payment-plugin.payments.all", defaultMessage: "All" }) }),
395
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "usd", children: "USD" }),
396
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "eur", children: "EUR" }),
397
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "gbp", children: "GBP" })
398
+ ]
399
+ }
400
+ ) }),
401
+ /* @__PURE__ */ jsx(Grid.Item, { col: 3, children: /* @__PURE__ */ jsx(Flex, { gap: 2, children: /* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: clearFilters, children: formatMessage({ id: "payment-plugin.payments.clearFilters", defaultMessage: "Clear" }) }) }) })
402
+ ] }) }) }),
403
+ /* @__PURE__ */ jsx(Box, { marginTop: 4, marginBottom: 2, children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage(
404
+ { id: "payment-plugin.payments.results", defaultMessage: "Showing {start}-{end} of {total} payments" },
405
+ {
406
+ start: startIndex + 1,
407
+ end: Math.min(endIndex, filteredPayments.length),
408
+ total: filteredPayments.length
409
+ }
410
+ ) }) }),
411
+ /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Table, { children: [
412
+ /* @__PURE__ */ jsx(Thead, { children: /* @__PURE__ */ jsxs(Tr, { children: [
413
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.payments.customer", defaultMessage: "Customer" }) }) }),
414
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.payments.amount", defaultMessage: "Amount" }) }) }),
415
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.payments.status", defaultMessage: "Status" }) }) }),
416
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.payments.method", defaultMessage: "Method" }) }) }),
417
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.payments.date", defaultMessage: "Date" }) }) }),
418
+ /* @__PURE__ */ jsx(Th, { children: /* @__PURE__ */ jsx(Typography, { variant: "epsilon", children: formatMessage({ id: "payment-plugin.payments.actions", defaultMessage: "Actions" }) }) })
419
+ ] }) }),
420
+ /* @__PURE__ */ jsx(Tbody, { children: paginatedPayments.map((payment) => /* @__PURE__ */ jsxs(Tr, { children: [
421
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Box, { children: [
422
+ /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", fontWeight: "bold", children: payment.customerName || "Unknown -" }),
423
+ /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", variant: "epsilon", children: payment.customerEmail })
424
+ ] }) }),
425
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral800", fontWeight: "bold", children: formatCurrency(payment.amount, payment.currency) }) }),
426
+ /* @__PURE__ */ jsx(Td, { children: getStatusBadge(payment.status) }),
427
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatMessage({
428
+ id: `payment-plugin.payments.${payment.paymentMethod}`,
429
+ defaultMessage: payment.paymentMethod
430
+ }) }) }),
431
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { textColor: "neutral600", children: formatDate(payment.createdAt) }) }),
432
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsxs(Flex, { gap: 1, children: [
433
+ /* @__PURE__ */ jsx(
434
+ Button,
435
+ {
436
+ onClick: () => handleViewDetails(payment),
437
+ startIcon: /* @__PURE__ */ jsx("span", { children: "👁️" }),
438
+ children: formatMessage({ id: "payment-plugin.payments.view", defaultMessage: "View details" })
439
+ }
440
+ ),
441
+ payment.status === "succeeded" && /* @__PURE__ */ jsx(
442
+ Button,
443
+ {
444
+ onClick: () => handleRefund(payment),
445
+ startIcon: /* @__PURE__ */ jsx("span", { children: "💸" }),
446
+ children: formatMessage({ id: "payment-plugin.payments.refund", defaultMessage: "Refund" })
447
+ }
448
+ )
449
+ ] }) })
450
+ ] }, payment.id)) })
451
+ ] }) }) }),
452
+ totalPages > 1 && /* @__PURE__ */ jsx(Box, { marginTop: 4, children: /* @__PURE__ */ jsx(
453
+ Pagination,
454
+ {
455
+ currentPage,
456
+ pageCount: totalPages,
457
+ onPageChange: setCurrentPage
458
+ }
459
+ ) }),
460
+ showRefundModal && selectedPayment && /* @__PURE__ */ jsx(
461
+ RefundModal,
462
+ {
463
+ payment: selectedPayment,
464
+ onClose: () => {
465
+ setShowRefundModal(false);
466
+ setSelectedPayment(null);
467
+ },
468
+ onSuccess: () => {
469
+ setShowRefundModal(false);
470
+ setSelectedPayment(null);
471
+ fetchPayments();
472
+ }
473
+ }
474
+ ),
475
+ showPaymentCard && selectedPayment && /* @__PURE__ */ jsx(
476
+ PaymentCard,
477
+ {
478
+ payment: selectedPayment,
479
+ onClose: () => {
480
+ setShowPaymentCard(false);
481
+ setSelectedPayment(null);
482
+ }
483
+ }
484
+ )
485
+ ] });
486
+ };
487
+ export {
488
+ Payments
489
+ };