@reeboot/strapi-payment-plugin 0.0.4 → 0.0.6

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/_chunks/{Analytics-nBSdLT2v.js → Analytics-CLjtRWYA.js} +68 -51
  2. package/dist/_chunks/{Analytics-DSJqY9ng.mjs → Analytics-CQmAVKsq.mjs} +68 -51
  3. package/dist/_chunks/App-DXN62SV6.mjs +118 -0
  4. package/dist/_chunks/App-Dk7XtjNA.js +120 -0
  5. package/dist/_chunks/{Customers-BpFzfglV.js → Customers-BNDi4QBH.js} +113 -51
  6. package/dist/_chunks/{Customers-C6FH7-zG.mjs → Customers-BQzVBQDT.mjs} +114 -52
  7. package/dist/_chunks/Dashboard-CuHC-dit.mjs +311 -0
  8. package/dist/_chunks/Dashboard-UUwohHZa.js +311 -0
  9. package/dist/_chunks/{Orders-CBkT2YfP.mjs → Orders-65mNfu2i.mjs} +140 -80
  10. package/dist/_chunks/{Orders-OG-pwV-B.js → Orders-CitNCdWE.js} +139 -79
  11. package/dist/_chunks/PaymentList-B0CAzInT.mjs +137 -0
  12. package/dist/_chunks/PaymentList-Dy1BAFoD.js +136 -0
  13. package/dist/_chunks/{Payments-DSDJ-HWm.mjs → Payments-FnhoV_2B.mjs} +175 -136
  14. package/dist/_chunks/{Payments-BLen1P9N.js → Payments-TOnygGIW.js} +173 -134
  15. package/dist/_chunks/Settings-BJtDagUs.js +644 -0
  16. package/dist/_chunks/Settings-EoLSuZLe.mjs +644 -0
  17. package/dist/_chunks/{index-DS_PYNkf.mjs → index-2Zd_T7bD.mjs} +1 -1
  18. package/dist/_chunks/{index-BqqrpI6D.js → index-CHEgJ7e5.js} +1 -1
  19. package/dist/admin/index.js +1 -1
  20. package/dist/admin/index.mjs +1 -1
  21. package/dist/admin/src/components/CustomerList.d.ts +1 -13
  22. package/dist/admin/src/components/IntegrationModal.d.ts +7 -0
  23. package/dist/admin/src/components/OrderList.d.ts +1 -19
  24. package/dist/admin/src/components/PaymentCard.d.ts +2 -33
  25. package/dist/admin/src/components/PaymentList.d.ts +3 -11
  26. package/dist/admin/src/components/RefundModal.d.ts +2 -8
  27. package/dist/admin/src/types/index.d.ts +47 -0
  28. package/dist/server/index.js +241 -96
  29. package/dist/server/index.mjs +241 -96
  30. package/dist/server/src/content-types/index.d.ts +9 -2
  31. package/dist/server/src/content-types/order/index.d.ts +8 -1
  32. package/dist/server/src/content-types/payment/index.d.ts +1 -1
  33. package/dist/server/src/index.d.ts +9 -2
  34. package/dist/server/src/types/api.d.ts +31 -0
  35. package/dist/server/src/types/customer.d.ts +2 -0
  36. package/dist/server/src/types/index.d.ts +4 -179
  37. package/dist/server/src/types/order.d.ts +2 -0
  38. package/dist/server/src/types/payment.d.ts +2 -0
  39. package/package.json +8 -7
  40. package/dist/_chunks/App-B83DZ9NG.js +0 -70
  41. package/dist/_chunks/App-BUSTbkyy.mjs +0 -68
  42. package/dist/_chunks/Dashboard-CNMTzSyc.js +0 -180
  43. package/dist/_chunks/Dashboard-Dbwl0ZBo.mjs +0 -180
  44. package/dist/_chunks/Settings-Dq1xy32B.js +0 -357
  45. package/dist/_chunks/Settings-jmGslDsB.mjs +0 -357
  46. package/dist/admin/src/pages/HomePage.d.ts +0 -2
@@ -1,14 +1,16 @@
1
- import { jsxs, jsx } from "react/jsx-runtime";
1
+ import { jsx, jsxs } from "react/jsx-runtime";
2
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";
3
+ import { Modal, Typography, Flex, Box, Button, TextInput, SingleSelect, SingleSelectOption, Textarea, Alert, Grid, Divider, Table, Tbody, Tr, Td, Badge, Loader, EmptyStateLayout, Card, Pagination } from "@strapi/design-system";
4
4
  import { useIntl } from "react-intl";
5
5
  import { useFetchClient } from "@strapi/strapi/admin";
6
- import { P as PLUGIN_ID } from "./index-DS_PYNkf.mjs";
6
+ import { P as PLUGIN_ID } from "./index-2Zd_T7bD.mjs";
7
+ import { P as PaymentList } from "./PaymentList-B0CAzInT.mjs";
7
8
  const RefundModal = ({ payment, onClose, onSuccess }) => {
8
9
  const { formatMessage } = useIntl();
9
10
  const { post } = useFetchClient();
10
11
  const [refundAmount, setRefundAmount] = useState(payment.amount);
11
- const [reason, setReason] = useState("");
12
+ const [reason, setReason] = useState("requested_by_customer");
13
+ const [notes, setNotes] = useState("");
12
14
  const [loading, setLoading] = useState(false);
13
15
  const [error, setError] = useState(null);
14
16
  const formatCurrency = (amount, currency = "usd") => {
@@ -31,7 +33,10 @@ const RefundModal = ({ payment, onClose, onSuccess }) => {
31
33
  }
32
34
  const { data } = await post(`/${PLUGIN_ID}/admin/payments/${payment.id}/refund`, {
33
35
  amount: refundAmount,
34
- reason: reason || "Requested by customer"
36
+ reason,
37
+ metadata: {
38
+ admin_notes: notes
39
+ }
35
40
  });
36
41
  if (data.success) {
37
42
  onSuccess();
@@ -45,28 +50,28 @@ const RefundModal = ({ payment, onClose, onSuccess }) => {
45
50
  }
46
51
  };
47
52
  const handlePartialRefund = (percentage) => {
48
- setRefundAmount(Math.round(payment.amount * percentage / 100));
53
+ setRefundAmount(parseFloat((payment.amount * (percentage / 100)).toFixed(2)));
49
54
  };
50
55
  const handleFullRefund = () => {
51
56
  setRefundAmount(payment.amount);
52
57
  };
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: [
58
+ return /* @__PURE__ */ jsx(Modal.Root, { open: true, onOpenChange: onClose, children: /* @__PURE__ */ jsxs(Modal.Content, { children: [
59
+ /* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "neutral800", as: "h2", id: "title", children: formatMessage({ id: "payment-plugin.refund.title", defaultMessage: "Process Refund" }) }) }),
60
+ /* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 4, children: [
56
61
  /* @__PURE__ */ jsxs(Box, { children: [
57
62
  /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", fontWeight: "bold", children: formatMessage({ id: "payment-plugin.refund.paymentInfo", defaultMessage: "Payment Information" }) }),
58
63
  /* @__PURE__ */ jsxs(Box, { marginTop: 2, children: [
59
- /* @__PURE__ */ jsxs(Typography, { variant: "epsilon", children: [
64
+ /* @__PURE__ */ jsxs(Typography, { variant: "epsilon", display: "block", children: [
60
65
  formatMessage({ id: "payment-plugin.refund.customer", defaultMessage: "Customer" }),
61
66
  ": ",
62
67
  payment.customerEmail
63
68
  ] }),
64
- /* @__PURE__ */ jsxs(Typography, { variant: "epsilon", children: [
69
+ /* @__PURE__ */ jsxs(Typography, { variant: "epsilon", display: "block", children: [
65
70
  formatMessage({ id: "payment-plugin.refund.originalAmount", defaultMessage: "Original Amount" }),
66
71
  ": ",
67
72
  formatCurrency(payment.amount, payment.currency)
68
73
  ] }),
69
- /* @__PURE__ */ jsxs(Typography, { variant: "epsilon", children: [
74
+ /* @__PURE__ */ jsxs(Typography, { variant: "epsilon", display: "block", children: [
70
75
  formatMessage({ id: "payment-plugin.refund.description", defaultMessage: "Description" }),
71
76
  ": ",
72
77
  payment.description || "N/A"
@@ -74,77 +79,165 @@ const RefundModal = ({ payment, onClose, onSuccess }) => {
74
79
  ] })
75
80
  ] }),
76
81
  /* @__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" }) }),
82
+ /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", fontWeight: "bold", marginBottom: 2, display: "block", children: formatMessage({ id: "payment-plugin.refund.quickOptions", defaultMessage: "Quick Options" }) }),
78
83
  /* @__PURE__ */ jsxs(Flex, { gap: 2, wrap: "wrap", children: [
79
84
  /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: handleFullRefund, children: formatMessage({ id: "payment-plugin.refund.full", defaultMessage: "Full Refund" }) }),
80
85
  /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => handlePartialRefund(50), children: formatMessage({ id: "payment-plugin.refund.half", defaultMessage: "50% Refund" }) }),
81
86
  /* @__PURE__ */ jsx(Button, { variant: "secondary", onClick: () => handlePartialRefund(25), children: formatMessage({ id: "payment-plugin.refund.quarter", defaultMessage: "25% Refund" }) })
82
87
  ] })
83
88
  ] }),
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
89
  /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
108
- Textarea,
90
+ TextInput,
91
+ {
92
+ label: formatMessage({ id: "payment-plugin.refund.amount", defaultMessage: "Refund Amount" }),
93
+ placeholder: formatCurrency(payment.amount, payment.currency),
94
+ step: "0.01",
95
+ value: refundAmount.toString(),
96
+ onChange: (e) => {
97
+ const value = parseFloat(e.target.value) || 0;
98
+ setRefundAmount(value);
99
+ },
100
+ hint: formatMessage(
101
+ { id: "payment-plugin.refund.maxAmount", defaultMessage: "Maximum: {amount}" },
102
+ { amount: formatCurrency(payment.amount, payment.currency) }
103
+ )
104
+ }
105
+ ) }),
106
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsxs(
107
+ SingleSelect,
109
108
  {
110
- label: formatMessage({ id: "payment-plugin.refund.reason", defaultMessage: "Reason (Optional)" }),
111
- placeholder: formatMessage({ id: "payment-plugin.refund.reasonPlaceholder", defaultMessage: "Reason for refund..." }),
109
+ label: formatMessage({ id: "payment-plugin.refund.reason", defaultMessage: "Reason" }),
112
110
  value: reason,
113
- onChange: (e) => setReason(e.target.value),
111
+ onChange: (value) => setReason(value),
112
+ children: [
113
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "requested_by_customer", children: formatMessage({ id: "payment-plugin.refund.reason.requested", defaultMessage: "Requested by customer" }) }),
114
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "duplicate", children: formatMessage({ id: "payment-plugin.refund.reason.duplicate", defaultMessage: "Duplicate" }) }),
115
+ /* @__PURE__ */ jsx(SingleSelectOption, { value: "fraudulent", children: formatMessage({ id: "payment-plugin.refund.reason.fraudulent", defaultMessage: "Fraudulent" }) })
116
+ ]
117
+ }
118
+ ) }),
119
+ /* @__PURE__ */ jsx(Box, { children: /* @__PURE__ */ jsx(
120
+ Textarea,
121
+ {
122
+ label: formatMessage({ id: "payment-plugin.refund.notes", defaultMessage: "Internal Notes (Optional)" }),
123
+ placeholder: formatMessage({ id: "payment-plugin.refund.notesPlaceholder", defaultMessage: "Additional details about this refund..." }),
124
+ value: notes,
125
+ onChange: (e) => setNotes(e.target.value),
114
126
  rows: 3
115
127
  }
116
128
  ) }),
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({
129
+ error && /* @__PURE__ */ jsx(Alert, { variant: "danger", title: formatMessage({ id: "payment-plugin.refund.error", defaultMessage: "Error" }), children: error }),
130
+ /* @__PURE__ */ jsx(Alert, { variant: "warning", title: formatMessage({ id: "payment-plugin.refund.warning", defaultMessage: "Warning" }), children: formatMessage({
119
131
  id: "payment-plugin.refund.warningMessage",
120
132
  defaultMessage: "This action cannot be undone. The refund will be processed immediately."
121
133
  }) })
122
134
  ] }) }),
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" }) }),
135
+ /* @__PURE__ */ jsxs(Modal.Footer, { children: [
136
+ /* @__PURE__ */ jsx(Button, { variant: "tertiary", onClick: onClose, disabled: loading, children: formatMessage({ id: "payment-plugin.refund.cancel", defaultMessage: "Cancel" }) }),
125
137
  /* @__PURE__ */ jsx(
126
138
  Button,
127
139
  {
128
- variant: "danger",
140
+ variant: "danger-light",
129
141
  onClick: handleSubmit,
130
142
  disabled: loading || refundAmount <= 0 || refundAmount > payment.amount,
131
143
  loading,
132
144
  children: formatMessage({ id: "payment-plugin.refund.submit", defaultMessage: "Process Refund" })
133
145
  }
134
146
  )
135
- ] }) })
136
- ] });
147
+ ] })
148
+ ] }) });
137
149
  };
138
150
  const PaymentCard = ({ payment, onClose }) => {
139
151
  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, {}),
152
+ console.log("Payment:", payment);
153
+ const formatCurrency = (amount, currency = "usd") => {
154
+ return new Intl.NumberFormat("en-US", {
155
+ style: "currency",
156
+ currency: currency.toUpperCase()
157
+ }).format(amount);
158
+ };
159
+ const formatDate = (dateString) => {
160
+ return new Date(dateString).toLocaleString("en-US", {
161
+ year: "numeric",
162
+ month: "long",
163
+ day: "numeric",
164
+ hour: "2-digit",
165
+ minute: "2-digit",
166
+ second: "2-digit"
167
+ });
168
+ };
169
+ const getStatusBadge = (status) => {
170
+ const statusConfig = {
171
+ succeeded: { color: "success", label: "Success" },
172
+ pending: { color: "warning", label: "Pending" },
173
+ failed: { color: "danger", label: "Failed" },
174
+ refunded: { color: "info", label: "Refunded" },
175
+ canceled: { color: "neutral", label: "Canceled" }
176
+ };
177
+ const config = statusConfig[status] || statusConfig.pending;
178
+ return /* @__PURE__ */ jsx(Badge, { size: "M", backgroundColor: config.color, children: config.label });
179
+ };
180
+ return /* @__PURE__ */ jsx(Modal.Root, { open: true, onOpenChange: onClose, children: /* @__PURE__ */ jsxs(Modal.Content, { children: [
181
+ /* @__PURE__ */ jsx(Modal.Header, { children: /* @__PURE__ */ jsx(Typography, { fontWeight: "bold", textColor: "neutral800", as: "h2", id: "title", children: formatMessage({ id: "payment-plugin.paymentDetails.title", defaultMessage: "Payment Details" }) }) }),
182
+ /* @__PURE__ */ jsx(Modal.Body, { children: /* @__PURE__ */ jsxs(Flex, { direction: "column", gap: 6, children: [
183
+ /* @__PURE__ */ jsxs(Box, { children: [
184
+ /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", fontWeight: "bold", marginBottom: 3, children: formatMessage({ id: "payment-plugin.paymentDetails.basicInfo", defaultMessage: "Basic Information" }) }),
185
+ /* @__PURE__ */ jsxs(Grid.Root, { gap: 4, children: [
186
+ /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
187
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", textTransform: "uppercase", children: formatMessage({ id: "payment-plugin.paymentDetails.customer", defaultMessage: "Customer" }) }),
188
+ /* @__PURE__ */ jsx(Typography, { variant: "epsilon", fontWeight: "bold", display: "block", children: payment.customerName || "Unknown" }),
189
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", children: payment.customerEmail })
190
+ ] }) }),
191
+ /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
192
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", textTransform: "uppercase", children: formatMessage({ id: "payment-plugin.paymentDetails.amount", defaultMessage: "Amount" }) }),
193
+ /* @__PURE__ */ jsx(Typography, { variant: "delta", fontWeight: "bold", display: "block", children: formatCurrency(payment.amount, payment.currency) })
194
+ ] }) }),
195
+ /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
196
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", textTransform: "uppercase", children: formatMessage({ id: "payment-plugin.paymentDetails.status", defaultMessage: "Status" }) }),
197
+ /* @__PURE__ */ jsx(Box, { marginTop: 1, children: getStatusBadge(payment.payment_status) })
198
+ ] }) }),
199
+ /* @__PURE__ */ jsx(Grid.Item, { col: 6, s: 12, children: /* @__PURE__ */ jsxs(Box, { children: [
200
+ /* @__PURE__ */ jsx(Typography, { variant: "pi", textColor: "neutral600", textTransform: "uppercase", children: formatMessage({ id: "payment-plugin.paymentDetails.paymentMethod", defaultMessage: "Payment Method" }) }),
201
+ /* @__PURE__ */ jsx(Typography, { variant: "epsilon", display: "block", children: formatMessage({
202
+ id: `payment-plugin.paymentDetails.${payment.payment_method}`,
203
+ defaultMessage: payment.payment_method
204
+ }) })
205
+ ] }) })
206
+ ] })
207
+ ] }),
144
208
  /* @__PURE__ */ jsx(Divider, {}),
145
- /* @__PURE__ */ jsx(Box, {})
146
- ] }) })
147
- ] });
209
+ /* @__PURE__ */ jsxs(Box, { children: [
210
+ /* @__PURE__ */ jsx(Typography, { variant: "epsilon", textColor: "neutral600", fontWeight: "bold", marginBottom: 3, children: formatMessage({ id: "payment-plugin.paymentDetails.transaction", defaultMessage: "Transaction Details" }) }),
211
+ /* @__PURE__ */ jsx(Table, { children: /* @__PURE__ */ jsxs(Tbody, { children: [
212
+ /* @__PURE__ */ jsxs(Tr, { children: [
213
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", children: formatMessage({ id: "payment-plugin.paymentDetails.stripeId", defaultMessage: "Stripe Payment ID" }) }) }),
214
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "pi", fontFamily: "monospace", children: payment.stripe_payment_intent_id }) })
215
+ ] }),
216
+ /* @__PURE__ */ jsxs(Tr, { children: [
217
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", children: formatMessage({ id: "payment-plugin.paymentDetails.createdAt", defaultMessage: "Created At" }) }) }),
218
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "pi", children: formatDate(payment.createdAt) }) })
219
+ ] }),
220
+ payment.orderId && /* @__PURE__ */ jsxs(Tr, { children: [
221
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "pi", fontWeight: "bold", children: formatMessage({ id: "payment-plugin.paymentDetails.orderId", defaultMessage: "Order ID" }) }) }),
222
+ /* @__PURE__ */ jsx(Td, { children: /* @__PURE__ */ jsx(Typography, { variant: "pi", fontFamily: "monospace", children: payment.orderId }) })
223
+ ] })
224
+ ] }) })
225
+ ] })
226
+ ] }) }),
227
+ /* @__PURE__ */ jsxs(Modal.Footer, { children: [
228
+ /* @__PURE__ */ jsx(Button, { onClick: onClose, variant: "tertiary", children: "Close" }),
229
+ /* @__PURE__ */ jsx(
230
+ Button,
231
+ {
232
+ onClick: () => {
233
+ navigator.clipboard.writeText(payment.stripe_payment_intent_id || "");
234
+ alert("Copied to clipboard");
235
+ },
236
+ children: "Copy Stripe ID"
237
+ }
238
+ )
239
+ ] })
240
+ ] }) });
148
241
  };
149
242
  const Payments = () => {
150
243
  const { formatMessage } = useIntl();
@@ -156,11 +249,12 @@ const Payments = () => {
156
249
  const [selectedPayment, setSelectedPayment] = useState(null);
157
250
  const [showRefundModal, setShowRefundModal] = useState(false);
158
251
  const [showPaymentCard, setShowPaymentCard] = useState(false);
252
+ console.log("payments:", payments);
159
253
  const [currentPage, setCurrentPage] = useState(1);
160
254
  const [pageSize, setPageSize] = useState(25);
161
255
  const [totalCount, setTotalCount] = useState(0);
162
256
  const [filters, setFilters] = useState({
163
- status: "",
257
+ payment_status: "",
164
258
  paymentMethod: "",
165
259
  dateRange: { from: null, to: null },
166
260
  search: "",
@@ -178,21 +272,15 @@ const Payments = () => {
178
272
  const queryParams = new URLSearchParams({
179
273
  page: currentPage.toString(),
180
274
  pageSize: pageSize.toString(),
181
- ...filters.status && { status: filters.status }
275
+ ...filters.payment_status && { payment_status: filters.payment_status }
182
276
  });
183
277
  const { data } = await get(`/${PLUGIN_ID}/admin/payments?${queryParams}`);
184
278
  if (data.success && data.data) {
185
279
  const formattedPayments = data.data.map((p) => ({
280
+ ...p,
186
281
  id: p.documentId,
187
- stripePaymentId: p.stripe_payment_intent_id,
188
- amount: p.amount,
189
- currency: p.currency,
190
- status: p.status,
191
282
  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,
283
+ customerName: p.customer ? `${p.customer.first_name || ""} ${p.customer.last_name || ""}`.trim() : "N/A",
196
284
  orderId: p.order?.documentId
197
285
  }));
198
286
  setPayments(formattedPayments);
@@ -209,14 +297,14 @@ const Payments = () => {
209
297
  if (filters.search) {
210
298
  const searchLower = filters.search.toLowerCase();
211
299
  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)
300
+ (payment) => payment.customerEmail.toLowerCase().includes(searchLower) || payment.customerName?.toLowerCase().includes(searchLower) || payment.stripe_payment_intent_id && payment.stripe_payment_intent_id.toLowerCase().includes(searchLower) || payment.description?.toLowerCase().includes(searchLower)
213
301
  );
214
302
  }
215
- if (filters.status) {
216
- filtered = filtered.filter((payment) => payment.status === filters.status);
303
+ if (filters.payment_status) {
304
+ filtered = filtered.filter((payment) => payment.payment_status === filters.payment_status);
217
305
  }
218
306
  if (filters.paymentMethod) {
219
- filtered = filtered.filter((payment) => payment.paymentMethod === filters.paymentMethod);
307
+ filtered = filtered.filter((payment) => payment.payment_method === filters.paymentMethod);
220
308
  }
221
309
  if (filters.currency) {
222
310
  filtered = filtered.filter((payment) => payment.currency === filters.currency);
@@ -233,12 +321,6 @@ const Payments = () => {
233
321
  }
234
322
  setFilteredPayments(filtered);
235
323
  };
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
324
  const formatDate = (dateString) => {
243
325
  return new Date(dateString).toLocaleDateString("en-US", {
244
326
  year: "numeric",
@@ -248,17 +330,6 @@ const Payments = () => {
248
330
  minute: "2-digit"
249
331
  });
250
332
  };
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
333
  const handleRefund = (payment) => {
263
334
  setSelectedPayment(payment);
264
335
  setShowRefundModal(true);
@@ -273,7 +344,7 @@ const Payments = () => {
273
344
  };
274
345
  const clearFilters = () => {
275
346
  setFilters({
276
- status: "",
347
+ payment_status: "",
277
348
  paymentMethod: "",
278
349
  dateRange: { from: null, to: null },
279
350
  search: "",
@@ -286,12 +357,12 @@ const Payments = () => {
286
357
  ["ID", "Stripe Payment ID", "Customer Email", "Amount", "Currency", "Status", "Payment Method", "Date"],
287
358
  ...filteredPayments.map((payment) => [
288
359
  payment.id,
289
- payment.stripePaymentId,
290
- payment.customerEmail,
291
- (payment.amount / 100).toString(),
360
+ payment.stripe_payment_intent_id || "",
361
+ payment.customerEmail || "",
362
+ payment.amount.toString(),
292
363
  payment.currency,
293
- payment.status,
294
- payment.paymentMethod,
364
+ payment.payment_status,
365
+ payment.payment_method || "",
295
366
  formatDate(payment.createdAt)
296
367
  ])
297
368
  ].map((row) => row.join(",")).join("\n");
@@ -320,7 +391,7 @@ const Payments = () => {
320
391
  }
321
392
  ) });
322
393
  }
323
- return /* @__PURE__ */ jsxs(Box, { paddingLeft: 10, paddingRight: 10, paddingTop: 4, paddingBottom: 10, children: [
394
+ return /* @__PURE__ */ jsxs(Box, { children: [
324
395
  /* @__PURE__ */ jsx(Box, { marginBottom: 4, children: /* @__PURE__ */ jsxs(Flex, { justifyContent: "space-between", alignItems: "center", children: [
325
396
  /* @__PURE__ */ jsxs(Box, { children: [
326
397
  /* @__PURE__ */ jsx(Typography, { variant: "alpha", tag: "h1", children: formatMessage({ id: "payment-plugin.payments.title", defaultMessage: "Payments" }) }),
@@ -331,7 +402,7 @@ const Payments = () => {
331
402
  ] }),
332
403
  /* @__PURE__ */ jsxs(Flex, { gap: 2, children: [
333
404
  /* @__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" }) })
405
+ /* @__PURE__ */ jsx(Button, { onClick: () => fetchPayments(), children: formatMessage({ id: "payment-plugin.payments.refresh", defaultMessage: "Refresh" }) })
335
406
  ] })
336
407
  ] }) }),
337
408
  /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(Box, { padding: 4, children: /* @__PURE__ */ jsxs(Grid.Root, { gap: 4, children: [
@@ -353,8 +424,8 @@ const Payments = () => {
353
424
  id: "payment-plugin.payments.status.placeholder",
354
425
  defaultMessage: "All Statuses"
355
426
  }),
356
- value: filters.status,
357
- onChange: (value) => handleFilterChange("status", value),
427
+ value: filters.payment_status,
428
+ onChange: (value) => handleFilterChange("payment_status", value),
358
429
  children: [
359
430
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "", children: formatMessage({ id: "payment-plugin.payments.all", defaultMessage: "All" }) }),
360
431
  /* @__PURE__ */ jsx(SingleSelectOption, { value: "succeeded", children: formatMessage({ id: "payment-plugin.payments.succeeded", defaultMessage: "Succeeded" }) }),
@@ -408,47 +479,15 @@ const Payments = () => {
408
479
  total: filteredPayments.length
409
480
  }
410
481
  ) }) }),
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
- ] }) }) }),
482
+ /* @__PURE__ */ jsx(Card, { children: /* @__PURE__ */ jsx(
483
+ PaymentList,
484
+ {
485
+ payments: paginatedPayments,
486
+ onPaymentClick: (payment) => handleViewDetails(payment),
487
+ onRefund: (payment) => handleRefund(payment),
488
+ onViewDetails: (payment) => handleViewDetails(payment)
489
+ }
490
+ ) }),
452
491
  totalPages > 1 && /* @__PURE__ */ jsx(Box, { marginTop: 4, children: /* @__PURE__ */ jsx(
453
492
  Pagination,
454
493
  {