@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
@@ -0,0 +1,644 @@
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 icons = require("@strapi/icons");
9
+ const index = require("./index-CHEgJ7e5.js");
10
+ const IntegrationModal = ({ onClose, publishableKey }) => {
11
+ const [copied, setCopied] = React.useState(null);
12
+ const copyToClipboard = (text, type) => {
13
+ navigator.clipboard.writeText(text);
14
+ setCopied(type);
15
+ setTimeout(() => setCopied(null), 2e3);
16
+ };
17
+ const installSnippet = `
18
+ # Install required dependencies in your frontend app
19
+ npm install @stripe/stripe-js @stripe/react-stripe-js
20
+ `.trim();
21
+ const stripeInitCode = `
22
+ import { loadStripe } from '@stripe/stripe-js';
23
+
24
+ // Initialize Stripe with your Publishable Key
25
+ const stripePromise = loadStripe('${publishableKey || "YOUR_PUBLISHABLE_KEY"}');
26
+
27
+ export default stripePromise;
28
+ `.trim();
29
+ const checkoutSnippet = `
30
+ const handlePayment = async (amount) => {
31
+ // 1. Create a Payment Intent on your Strapi backend
32
+ // Replace YOUR_STRAPI_URL and YOUR_JWT_TOKEN
33
+ const STRAPI_URL = 'http://localhost:1337';
34
+
35
+ const response = await fetch(\`\${STRAPI_URL}/api/payment-plugin/payments/create-intent\`, {
36
+ method: 'POST',
37
+ headers: {
38
+ 'Content-Type': 'application/json',
39
+ 'Authorization': 'Bearer YOUR_JWT_TOKEN' // Required for Strapi Content API
40
+ },
41
+ body: JSON.stringify({
42
+ amount: amount, // Amount in cents (e.g., 2500 for $25.00)
43
+ currency: 'usd',
44
+ orderId: 'ORDER_123'
45
+ })
46
+ });
47
+
48
+ const { data, success } = await response.json();
49
+ if (!success) throw new Error('Failed to create PaymentIntent');
50
+
51
+ return data.clientSecret;
52
+ };
53
+ `.trim();
54
+ const elementSnippet = `
55
+ import React, { useState } from 'react';
56
+ import { Elements, PaymentElement, useStripe, useElements } from '@stripe/react-stripe-js';
57
+ import stripePromise from './stripe-init'; // From Step 1
58
+
59
+ const CheckoutForm = ({ clientSecret }) => {
60
+ const stripe = useStripe();
61
+ const elements = useElements();
62
+ const [isProcessing, setIsProcessing] = useState(false);
63
+
64
+ const handleSubmit = async (event) => {
65
+ event.preventDefault();
66
+ if (!stripe || !elements) return;
67
+
68
+ setIsProcessing(true);
69
+ const result = await stripe.confirmPayment({
70
+ elements,
71
+ confirmParams: {
72
+ return_url: window.location.origin + "/payment-success",
73
+ },
74
+ });
75
+
76
+ if (result.error) {
77
+ alert(result.error.message);
78
+ }
79
+ setIsProcessing(false);
80
+ };
81
+
82
+ return (
83
+ <form onSubmit={handleSubmit}>
84
+ <PaymentElement />
85
+ <button disabled={!stripe || isProcessing} style={{ marginTop: '1rem' }}>
86
+ {isProcessing ? 'Processing...' : 'Pay Now'}
87
+ </button>
88
+ </form>
89
+ );
90
+ };
91
+ `.trim();
92
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Root, { open: true, onOpenChange: onClose, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Modal.Content, { children: [
93
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Header, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", textColor: "neutral800", as: "h2", id: "title", children: "Frontend Integration Guide" }) }),
94
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Body, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 4, children: [
95
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", marginBottom: 4, display: "block", children: "Follow these 4 steps to integrate Stripe payments into your React/Next.js frontend." }),
96
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tabs.Root, { defaultValue: "setup", children: [
97
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Tabs.List, { children: [
98
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Trigger, { value: "setup", children: "1. Setup" }),
99
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Trigger, { value: "backend", children: "2. Backend" }),
100
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Trigger, { value: "frontend", children: "3. Frontend" }),
101
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Trigger, { value: "perms", children: "4. Permissions" })
102
+ ] }),
103
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { marginTop: 4, children: [
104
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "setup", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 4, background: "neutral100", borderRadius: "4px", children: [
105
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", display: "block", marginBottom: 2, children: "INSTALL DEPENDENCIES" }),
106
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { style: { marginBottom: "1rem", fontSize: "0.75rem", overflowX: "auto", padding: "10px", background: "#27272a", color: "#f8fafc", borderRadius: "4px" }, children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: installSnippet }) }),
107
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 2, children: [
108
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: "INITIALIZE STRIPE" }),
109
+ /* @__PURE__ */ jsxRuntime.jsx(
110
+ designSystem.Button,
111
+ {
112
+ variant: "ghost",
113
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Duplicate, {}),
114
+ onClick: () => copyToClipboard(stripeInitCode, "init"),
115
+ children: copied === "init" ? "Copied!" : "Copy"
116
+ }
117
+ )
118
+ ] }),
119
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { style: { margin: 0, fontSize: "0.75rem", overflowX: "auto", padding: "10px", background: "#27272a", color: "#f8fafc", borderRadius: "4px" }, children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: stripeInitCode }) })
120
+ ] }) }),
121
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "backend", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 4, background: "neutral100", borderRadius: "4px", children: [
122
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 2, children: [
123
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: "GET CLIENT SECRET" }),
124
+ /* @__PURE__ */ jsxRuntime.jsx(
125
+ designSystem.Button,
126
+ {
127
+ variant: "ghost",
128
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Duplicate, {}),
129
+ onClick: () => copyToClipboard(checkoutSnippet, "backend"),
130
+ children: copied === "backend" ? "Copied!" : "Copy"
131
+ }
132
+ )
133
+ ] }),
134
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { style: { margin: 0, fontSize: "0.75rem", overflowX: "auto", padding: "10px", background: "#27272a", color: "#f8fafc", borderRadius: "4px" }, children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: checkoutSnippet }) })
135
+ ] }) }),
136
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "frontend", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 4, background: "neutral100", borderRadius: "4px", children: [
137
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 2, children: [
138
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "sigma", textColor: "neutral600", children: "REACT CHECKOUT FORM" }),
139
+ /* @__PURE__ */ jsxRuntime.jsx(
140
+ designSystem.Button,
141
+ {
142
+ variant: "ghost",
143
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Duplicate, {}),
144
+ onClick: () => copyToClipboard(elementSnippet, "frontend"),
145
+ children: copied === "frontend" ? "Copied!" : "Copy"
146
+ }
147
+ )
148
+ ] }),
149
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { style: { margin: 0, fontSize: "0.75rem", overflowX: "auto", padding: "10px", background: "#27272a", color: "#f8fafc", borderRadius: "4px" }, children: /* @__PURE__ */ jsxRuntime.jsx("code", { children: elementSnippet }) })
150
+ ] }) }),
151
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Tabs.Content, { value: "perms", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 6, background: "neutral100", borderRadius: "4px", children: [
152
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", marginBottom: 2, display: "block", tag: "h3", children: "Crucial: API Permissions" }),
153
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", marginBottom: 4, display: "block", children: "By default, Strapi blocks all public access to the Content API. You must enable permissions for your frontend to interact with the plugin:" }),
154
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { paddingLeft: 4, children: [
155
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", display: "block", marginBottom: 1, children: [
156
+ "1. Go to ",
157
+ /* @__PURE__ */ jsxRuntime.jsx("b", { children: "Settings" }),
158
+ " > ",
159
+ /* @__PURE__ */ jsxRuntime.jsx("b", { children: "Users & Permissions Plugin" }),
160
+ " > ",
161
+ /* @__PURE__ */ jsxRuntime.jsx("b", { children: "Roles" })
162
+ ] }),
163
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", display: "block", marginBottom: 1, children: [
164
+ "2. Edit the ",
165
+ /* @__PURE__ */ jsxRuntime.jsx("b", { children: "Authenticated" }),
166
+ " or ",
167
+ /* @__PURE__ */ jsxRuntime.jsx("b", { children: "Public" }),
168
+ " role"
169
+ ] }),
170
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", display: "block", marginBottom: 1, children: [
171
+ "3. Find the ",
172
+ /* @__PURE__ */ jsxRuntime.jsx("b", { children: "Payment-plugin" }),
173
+ " section"
174
+ ] }),
175
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", display: "block", marginBottom: 1, children: [
176
+ "4. Enable ",
177
+ /* @__PURE__ */ jsxRuntime.jsx("b", { children: "createPaymentIntent" }),
178
+ " and ",
179
+ /* @__PURE__ */ jsxRuntime.jsx("b", { children: "confirmPayment" })
180
+ ] }),
181
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Typography, { variant: "pi", display: "block", marginBottom: 1, children: [
182
+ "5. Click ",
183
+ /* @__PURE__ */ jsxRuntime.jsx("b", { children: "Save" }),
184
+ " at the top right"
185
+ ] })
186
+ ] })
187
+ ] }) })
188
+ ] })
189
+ ] })
190
+ ] }) }),
191
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Modal.Footer, { children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { onClick: onClose, variant: "tertiary", children: "Close" }) })
192
+ ] }) });
193
+ };
194
+ const Settings = () => {
195
+ const { formatMessage } = reactIntl.useIntl();
196
+ const { get, put } = admin.useFetchClient();
197
+ const [settings, setSettings] = React.useState(null);
198
+ const [loading, setLoading] = React.useState(true);
199
+ const [saving, setSaving] = React.useState(false);
200
+ const [error, setError] = React.useState(null);
201
+ const [success, setSuccess] = React.useState(null);
202
+ const [hasChanges, setHasChanges] = React.useState(false);
203
+ const [showIntegrationModal, setShowIntegrationModal] = React.useState(false);
204
+ const [showSecretKey, setShowSecretKey] = React.useState(false);
205
+ const [showWebhookSecret, setShowWebhookSecret] = React.useState(false);
206
+ React.useEffect(() => {
207
+ fetchSettings();
208
+ }, []);
209
+ const fetchSettings = async () => {
210
+ try {
211
+ setLoading(true);
212
+ const { data } = await get(`/${index.PLUGIN_ID}/admin/config`);
213
+ if (data.success && data.data) {
214
+ const backendConfig = data.data;
215
+ const initialSettings = {
216
+ stripe: {
217
+ publishableKey: backendConfig.stripe?.publishableKey || "",
218
+ secretKey: backendConfig.stripe?.secretKey || "",
219
+ webhookSecret: backendConfig.stripe?.webhookSecret || "",
220
+ apiVersion: backendConfig.stripe?.apiVersion || "2023-10-16",
221
+ enabled: backendConfig.stripe?.enabled ?? true
222
+ },
223
+ payments: {
224
+ defaultCurrency: backendConfig.payment?.defaultCurrency || "usd",
225
+ supportedCurrencies: backendConfig.payment?.supportedCurrencies || ["usd"],
226
+ enableRefunds: backendConfig.payment?.enableRefunds ?? true,
227
+ enablePartialRefunds: backendConfig.payment?.enablePartialRefunds ?? true,
228
+ refundWindow: backendConfig.payment?.refundWindow || 30,
229
+ captureMethod: backendConfig.payment?.captureMethod || "automatic",
230
+ confirmationMethod: backendConfig.payment?.confirmationMethod || "automatic"
231
+ },
232
+ webhooks: {
233
+ enabled: true,
234
+ endpoints: {
235
+ paymentSucceeded: "",
236
+ paymentFailed: "",
237
+ refundCreated: "",
238
+ invoiceCreated: ""
239
+ },
240
+ retries: 3,
241
+ timeout: 30
242
+ },
243
+ ui: {
244
+ showPaymentStatus: true,
245
+ showCustomerInfo: true,
246
+ enableNotifications: true,
247
+ theme: "auto",
248
+ compactView: false
249
+ },
250
+ security: {
251
+ enableIpFiltering: false,
252
+ allowedIps: [],
253
+ requireAuthentication: true,
254
+ enableAuditLog: true,
255
+ sessionTimeout: 60
256
+ }
257
+ };
258
+ setSettings(initialSettings);
259
+ }
260
+ setLoading(false);
261
+ } catch (err) {
262
+ setError("Failed to fetch settings");
263
+ setLoading(false);
264
+ }
265
+ };
266
+ const handleSettingChange = (section, key, value) => {
267
+ if (!settings) return;
268
+ setSettings((prev) => ({
269
+ ...prev,
270
+ [section]: {
271
+ ...prev[section],
272
+ [key]: value
273
+ }
274
+ }));
275
+ setHasChanges(true);
276
+ setSuccess(null);
277
+ };
278
+ const saveSettings = async () => {
279
+ try {
280
+ setSaving(true);
281
+ setError(null);
282
+ if (!settings) return;
283
+ const payload = {
284
+ stripe: settings.stripe,
285
+ payment: settings.payments,
286
+ logging: {
287
+ enableWebhookLogging: true
288
+ }
289
+ };
290
+ await put(`/${index.PLUGIN_ID}/admin/config`, payload);
291
+ setHasChanges(false);
292
+ setSuccess("Settings saved successfully");
293
+ setTimeout(() => setSuccess(null), 3e3);
294
+ } catch (err) {
295
+ setError("Failed to save settings");
296
+ } finally {
297
+ setSaving(false);
298
+ }
299
+ };
300
+ const resetSettings = () => {
301
+ if (confirm("Are you sure you want to reset all settings to default? This action cannot be undone.")) {
302
+ fetchSettings();
303
+ setHasChanges(false);
304
+ }
305
+ };
306
+ const testConnection = async () => {
307
+ try {
308
+ setSaving(true);
309
+ const { data } = await get(`/${index.PLUGIN_ID}/admin/config`);
310
+ if (data.success) {
311
+ alert("Connection to backend successful!");
312
+ } else {
313
+ throw new Error("Failed to connect");
314
+ }
315
+ } catch (err) {
316
+ alert("Connection test failed. Please check your API keys and server logs.");
317
+ } finally {
318
+ setSaving(false);
319
+ }
320
+ };
321
+ if (loading) {
322
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Flex, { justifyContent: "center", alignItems: "center", style: { minHeight: "400px" }, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", children: formatMessage({ id: "payment-plugin.settings.loading", defaultMessage: "Loading settings..." }) }) }) });
323
+ }
324
+ if (!settings) {
325
+ return /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Alert, { variant: "danger", children: formatMessage({ id: "payment-plugin.settings.error", defaultMessage: "Failed to load settings" }) }) });
326
+ }
327
+ return /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
328
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginBottom: 4, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", children: [
329
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
330
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "alpha", tag: "h1", children: formatMessage({ id: "payment-plugin.settings.title", defaultMessage: "Payment Settings" }) }),
331
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "epsilon", textColor: "neutral600", children: formatMessage({
332
+ id: "payment-plugin.settings.subtitle",
333
+ defaultMessage: "Configure your payment plugin settings"
334
+ }) })
335
+ ] }),
336
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, children: [
337
+ hasChanges && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginRight: 2, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "warning600", children: "Unsaved changes" }) }),
338
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Button, { variant: "secondary", onClick: resetSettings, children: formatMessage({ id: "payment-plugin.settings.reset", defaultMessage: "Reset" }) }),
339
+ /* @__PURE__ */ jsxRuntime.jsx(
340
+ designSystem.Button,
341
+ {
342
+ variant: "secondary",
343
+ onClick: testConnection,
344
+ disabled: saving,
345
+ children: formatMessage({ id: "payment-plugin.settings.testConnection", defaultMessage: "Test Connection" })
346
+ }
347
+ ),
348
+ /* @__PURE__ */ jsxRuntime.jsx(
349
+ designSystem.Button,
350
+ {
351
+ onClick: saveSettings,
352
+ disabled: !hasChanges || saving,
353
+ loading: saving,
354
+ children: formatMessage({ id: "payment-plugin.settings.save", defaultMessage: "Save Settings" })
355
+ }
356
+ ),
357
+ /* @__PURE__ */ jsxRuntime.jsx(
358
+ designSystem.Button,
359
+ {
360
+ variant: "tertiary",
361
+ startIcon: /* @__PURE__ */ jsxRuntime.jsx(icons.Code, {}),
362
+ onClick: () => setShowIntegrationModal(true),
363
+ children: formatMessage({ id: "payment-plugin.settings.integration", defaultMessage: "Integration Guide" })
364
+ }
365
+ )
366
+ ] })
367
+ ] }) }),
368
+ error && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginBottom: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Alert, { variant: "danger", onClose: () => setError(null), children: error }) }),
369
+ success && /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { marginBottom: 4, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Alert, { variant: "success", onClose: () => setSuccess(null), children: success }) }),
370
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 6, children: [
371
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 5, children: [
372
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { justifyContent: "space-between", alignItems: "center", marginBottom: 4, children: [
373
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", children: [
374
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { color: "primary600", children: /* @__PURE__ */ jsxRuntime.jsx(icons.Key, { width: "1.5rem", height: "1.5rem" }) }),
375
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", tag: "h2", children: formatMessage({ id: "payment-plugin.settings.stripe", defaultMessage: "Stripe API Configuration" }) })
376
+ ] }),
377
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Badge, { variant: settings.stripe.enabled ? "success" : "neutral", children: settings.stripe.enabled ? "Stripe Active" : "Stripe Disabled" })
378
+ ] }),
379
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 4, children: [
380
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
381
+ designSystem.TextInput,
382
+ {
383
+ label: formatMessage({ id: "payment-plugin.settings.publishableKey", defaultMessage: "Publishable Key" }),
384
+ placeholder: "pk_test_...",
385
+ value: settings.stripe.publishableKey,
386
+ onChange: (e) => handleSettingChange("stripe", "publishableKey", e.target.value),
387
+ endAction: /* @__PURE__ */ jsxRuntime.jsx(
388
+ designSystem.Button,
389
+ {
390
+ variant: "ghost",
391
+ onClick: () => {
392
+ navigator.clipboard.writeText(settings.stripe.publishableKey);
393
+ alert("Copied to clipboard");
394
+ },
395
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Duplicate, { width: "1rem", height: "1rem" })
396
+ }
397
+ )
398
+ }
399
+ ) }),
400
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
401
+ designSystem.TextInput,
402
+ {
403
+ label: formatMessage({ id: "payment-plugin.settings.secretKey", defaultMessage: "Secret Key" }),
404
+ placeholder: "sk_test_...",
405
+ value: settings.stripe.secretKey,
406
+ onChange: (e) => handleSettingChange("stripe", "secretKey", e.target.value),
407
+ type: showSecretKey ? "text" : "password",
408
+ endAction: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
409
+ /* @__PURE__ */ jsxRuntime.jsx(
410
+ designSystem.Button,
411
+ {
412
+ variant: "ghost",
413
+ onClick: () => setShowSecretKey(!showSecretKey),
414
+ children: showSecretKey ? /* @__PURE__ */ jsxRuntime.jsx(icons.EyeStriked, { width: "1rem", height: "1rem" }) : /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, { width: "1rem", height: "1rem" })
415
+ }
416
+ ),
417
+ /* @__PURE__ */ jsxRuntime.jsx(
418
+ designSystem.Button,
419
+ {
420
+ variant: "ghost",
421
+ onClick: () => {
422
+ navigator.clipboard.writeText(settings.stripe.secretKey);
423
+ alert("Copied to clipboard");
424
+ },
425
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Duplicate, { width: "1rem", height: "1rem" })
426
+ }
427
+ )
428
+ ] })
429
+ }
430
+ ) }),
431
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, children: /* @__PURE__ */ jsxRuntime.jsx(
432
+ designSystem.TextInput,
433
+ {
434
+ label: formatMessage({ id: "payment-plugin.settings.webhookSecret", defaultMessage: "Webhook Secret" }),
435
+ placeholder: "whsec_...",
436
+ value: settings.stripe.webhookSecret,
437
+ onChange: (e) => handleSettingChange("stripe", "webhookSecret", e.target.value),
438
+ type: showWebhookSecret ? "text" : "password",
439
+ endAction: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { children: [
440
+ /* @__PURE__ */ jsxRuntime.jsx(
441
+ designSystem.Button,
442
+ {
443
+ variant: "ghost",
444
+ onClick: () => setShowWebhookSecret(!showWebhookSecret),
445
+ children: showWebhookSecret ? /* @__PURE__ */ jsxRuntime.jsx(icons.EyeStriked, { width: "1rem", height: "1rem" }) : /* @__PURE__ */ jsxRuntime.jsx(icons.Eye, { width: "1rem", height: "1rem" })
446
+ }
447
+ ),
448
+ /* @__PURE__ */ jsxRuntime.jsx(
449
+ designSystem.Button,
450
+ {
451
+ variant: "ghost",
452
+ onClick: () => {
453
+ navigator.clipboard.writeText(settings.stripe.webhookSecret);
454
+ alert("Copied to clipboard");
455
+ },
456
+ children: /* @__PURE__ */ jsxRuntime.jsx(icons.Duplicate, { width: "1rem", height: "1rem" })
457
+ }
458
+ )
459
+ ] })
460
+ }
461
+ ) }),
462
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, children: /* @__PURE__ */ jsxRuntime.jsxs(
463
+ designSystem.SingleSelect,
464
+ {
465
+ label: formatMessage({ id: "payment-plugin.settings.apiVersion", defaultMessage: "API Version" }),
466
+ value: settings.stripe.apiVersion,
467
+ onChange: (value) => handleSettingChange("stripe", "apiVersion", value),
468
+ children: [
469
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "2024-06-20", children: "2024-06-20 (Latest)" }),
470
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "2023-10-16", children: "2023-10-16" }),
471
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "2023-08-15", children: "2023-08-15" })
472
+ ]
473
+ }
474
+ ) }),
475
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Box, { padding: 3, background: "neutral100", borderRadius: "4px", children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", gap: 4, children: [
476
+ /* @__PURE__ */ jsxRuntime.jsx(
477
+ designSystem.Switch,
478
+ {
479
+ label: formatMessage({ id: "payment-plugin.settings.enabled", defaultMessage: "Enable Stripe Payments" }),
480
+ selected: settings.stripe.enabled,
481
+ onChange: () => handleSettingChange("stripe", "enabled", !settings.stripe.enabled)
482
+ }
483
+ ),
484
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
485
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: formatMessage({ id: "payment-plugin.settings.enabled", defaultMessage: "Payment Gateway Status" }) }),
486
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: settings.stripe.enabled ? "Your plugin is currently accepting payments through Stripe." : "Stripe payments are disabled. Customers will not be able to checkout." })
487
+ ] })
488
+ ] }) }) })
489
+ ] })
490
+ ] }) }) }),
491
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 5, children: [
492
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { gap: 2, alignItems: "center", marginBottom: 4, children: [
493
+ /* @__PURE__ */ jsxRuntime.jsx(icons.Globe, { width: "1.25rem", height: "1.25rem" }),
494
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", tag: "h2", children: formatMessage({ id: "payment-plugin.settings.payments", defaultMessage: "Default Rules" }) })
495
+ ] }),
496
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 4, children: [
497
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(
498
+ designSystem.SingleSelect,
499
+ {
500
+ label: formatMessage({ id: "payment-plugin.settings.defaultCurrency", defaultMessage: "Default Currency" }),
501
+ value: settings.payments.defaultCurrency,
502
+ onChange: (value) => handleSettingChange("payments", "defaultCurrency", value),
503
+ children: [
504
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "usd", children: "USD" }),
505
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "eur", children: "EUR" }),
506
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "gbp", children: "GBP" }),
507
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "cad", children: "CAD" }),
508
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "aud", children: "AUD" })
509
+ ]
510
+ }
511
+ ) }),
512
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(
513
+ designSystem.SingleSelect,
514
+ {
515
+ label: formatMessage({ id: "payment-plugin.settings.captureMethod", defaultMessage: "Capture Method" }),
516
+ value: settings.payments.captureMethod,
517
+ onChange: (value) => handleSettingChange("payments", "captureMethod", value),
518
+ children: [
519
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "automatic", children: "Automatic (Direct capture)" }),
520
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.SingleSelectOption, { value: "manual", children: "Manual (Authorize only)" })
521
+ ]
522
+ }
523
+ ) }),
524
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, children: /* @__PURE__ */ jsxRuntime.jsx(
525
+ designSystem.TextInput,
526
+ {
527
+ label: formatMessage({ id: "payment-plugin.settings.refundWindow", defaultMessage: "Max Refund Window (Days)" }),
528
+ type: "number",
529
+ value: settings.payments.refundWindow.toString(),
530
+ onChange: (e) => handleSettingChange("payments", "refundWindow", parseInt(e.target.value) || 0)
531
+ }
532
+ ) })
533
+ ] })
534
+ ] }) }) }),
535
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 6, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 5, children: [
536
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", tag: "h2", marginBottom: 4, children: formatMessage({ id: "payment-plugin.settings.security", defaultMessage: "Security Settings" }) }),
537
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 4, children: [
538
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", gap: 4, children: [
539
+ /* @__PURE__ */ jsxRuntime.jsx(
540
+ designSystem.Switch,
541
+ {
542
+ label: formatMessage({ id: "payment-plugin.settings.requireAuth", defaultMessage: "Require Authentication" }),
543
+ selected: settings.security.requireAuthentication,
544
+ onChange: () => handleSettingChange("security", "requireAuthentication", !settings.security.requireAuthentication)
545
+ }
546
+ ),
547
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
548
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: formatMessage({ id: "payment-plugin.settings.requireAuth", defaultMessage: "Public Access Restriction" }) }),
549
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: settings.security.requireAuthentication ? "Only authenticated users can initiate payments." : "Public users can initiate payments without login." })
550
+ ] })
551
+ ] }) }),
552
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", gap: 4, children: [
553
+ /* @__PURE__ */ jsxRuntime.jsx(
554
+ designSystem.Switch,
555
+ {
556
+ label: formatMessage({ id: "payment-plugin.settings.auditLog", defaultMessage: "Enable Audit Log" }),
557
+ selected: settings.security.enableAuditLog,
558
+ onChange: () => handleSettingChange("security", "enableAuditLog", !settings.security.enableAuditLog)
559
+ }
560
+ ),
561
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { children: [
562
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: formatMessage({ id: "payment-plugin.settings.auditLog", defaultMessage: "Activity Logging" }) }),
563
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: "Detailed logs of all transaction attempts and configuration changes." })
564
+ ] })
565
+ ] }) }),
566
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, marginTop: 2, children: /* @__PURE__ */ jsxRuntime.jsx(
567
+ designSystem.TextInput,
568
+ {
569
+ label: formatMessage({ id: "payment-plugin.settings.sessionTimeout", defaultMessage: "Checkout Session Timeout (Minutes)" }),
570
+ type: "number",
571
+ value: settings.security.sessionTimeout.toString(),
572
+ onChange: (e) => handleSettingChange("security", "sessionTimeout", parseInt(e.target.value) || 60)
573
+ }
574
+ ) })
575
+ ] })
576
+ ] }) }) }),
577
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 12, children: /* @__PURE__ */ jsxRuntime.jsx(designSystem.Card, { children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Box, { padding: 5, children: [
578
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "beta", tag: "h2", marginBottom: 4, children: formatMessage({ id: "payment-plugin.settings.ui", defaultMessage: "Admin Interface Customization" }) }),
579
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Grid.Root, { gap: 4, children: [
580
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
581
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", gap: 2, children: [
582
+ /* @__PURE__ */ jsxRuntime.jsx(
583
+ designSystem.Switch,
584
+ {
585
+ checked: settings.ui.showPaymentStatus,
586
+ onChange: (checked) => handleSettingChange("ui", "showPaymentStatus", checked)
587
+ }
588
+ ),
589
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: formatMessage({ id: "payment-plugin.settings.showStatus", defaultMessage: "Payment Status" }) })
590
+ ] }),
591
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: "Show status badges in lists" })
592
+ ] }) }),
593
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
594
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", gap: 2, children: [
595
+ /* @__PURE__ */ jsxRuntime.jsx(
596
+ designSystem.Switch,
597
+ {
598
+ checked: settings.ui.showCustomerInfo,
599
+ onChange: (checked) => handleSettingChange("ui", "showCustomerInfo", checked)
600
+ }
601
+ ),
602
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: formatMessage({ id: "payment-plugin.settings.showCustomerInfo", defaultMessage: "Customer Data" }) })
603
+ ] }),
604
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: "Display sensitive customer info" })
605
+ ] }) }),
606
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
607
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", gap: 2, children: [
608
+ /* @__PURE__ */ jsxRuntime.jsx(
609
+ designSystem.Switch,
610
+ {
611
+ checked: settings.ui.enableNotifications,
612
+ onChange: (checked) => handleSettingChange("ui", "enableNotifications", checked)
613
+ }
614
+ ),
615
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: formatMessage({ id: "payment-plugin.settings.notifications", defaultMessage: "Notifications" }) })
616
+ ] }),
617
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: "Browser alerts for success" })
618
+ ] }) }),
619
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Grid.Item, { col: 3, children: /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { direction: "column", gap: 2, children: [
620
+ /* @__PURE__ */ jsxRuntime.jsxs(designSystem.Flex, { alignItems: "center", gap: 2, children: [
621
+ /* @__PURE__ */ jsxRuntime.jsx(
622
+ designSystem.Switch,
623
+ {
624
+ checked: settings.ui.compactView,
625
+ onChange: (checked) => handleSettingChange("ui", "compactView", checked)
626
+ }
627
+ ),
628
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { fontWeight: "bold", children: formatMessage({ id: "payment-plugin.settings.compactView", defaultMessage: "Compact Mode" }) })
629
+ ] }),
630
+ /* @__PURE__ */ jsxRuntime.jsx(designSystem.Typography, { variant: "pi", textColor: "neutral600", children: "Dense layout for tables" })
631
+ ] }) })
632
+ ] })
633
+ ] }) }) })
634
+ ] }),
635
+ showIntegrationModal && /* @__PURE__ */ jsxRuntime.jsx(
636
+ IntegrationModal,
637
+ {
638
+ publishableKey: settings.stripe.publishableKey,
639
+ onClose: () => setShowIntegrationModal(false)
640
+ }
641
+ )
642
+ ] });
643
+ };
644
+ exports.Settings = Settings;