@reeboot/strapi-payment-plugin 0.0.1 → 0.0.2

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