@reeboot/strapi-payment-plugin 0.0.3 → 0.0.5

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