@easypayment/medusa-paypal 0.2.8 → 0.2.9
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.
- package/.medusa/server/src/admin/index.js +99 -256
- package/.medusa/server/src/admin/index.mjs +99 -256
- package/.medusa/server/src/api/store/paypal/webhook/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/paypal/webhook/route.js +1 -1
- package/.medusa/server/src/api/store/paypal/webhook/route.js.map +1 -1
- package/.medusa/server/src/jobs/paypal-webhook-retry.d.ts.map +1 -1
- package/.medusa/server/src/jobs/paypal-webhook-retry.js +1 -1
- package/.medusa/server/src/jobs/paypal-webhook-retry.js.map +1 -1
- package/.medusa/server/src/modules/paypal/index.d.ts +0 -14
- package/.medusa/server/src/modules/paypal/index.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/service.d.ts +0 -43
- package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/service.js +0 -43
- package/.medusa/server/src/modules/paypal/service.js.map +1 -1
- package/.medusa/server/src/modules/paypal/webhook-processor.d.ts +0 -13
- package/.medusa/server/src/modules/paypal/webhook-processor.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/webhook-processor.js +0 -96
- package/.medusa/server/src/modules/paypal/webhook-processor.js.map +1 -1
- package/package.json +1 -1
- package/src/admin/routes/settings/paypal/_components/Tabs.tsx +0 -1
- package/src/api/store/paypal/webhook/route.ts +1 -2
- package/src/jobs/paypal-webhook-retry.ts +1 -2
- package/src/modules/paypal/service.ts +0 -58
- package/src/modules/paypal/webhook-processor.ts +2 -114
- package/.medusa/server/src/api/admin/paypal/disputes/[id]/route.d.ts +0 -3
- package/.medusa/server/src/api/admin/paypal/disputes/[id]/route.d.ts.map +0 -1
- package/.medusa/server/src/api/admin/paypal/disputes/[id]/route.js +0 -17
- package/.medusa/server/src/api/admin/paypal/disputes/[id]/route.js.map +0 -1
- package/.medusa/server/src/api/admin/paypal/disputes/route.d.ts +0 -3
- package/.medusa/server/src/api/admin/paypal/disputes/route.d.ts.map +0 -1
- package/.medusa/server/src/api/admin/paypal/disputes/route.js +0 -27
- package/.medusa/server/src/api/admin/paypal/disputes/route.js.map +0 -1
- package/.medusa/server/src/api/admin/paypal/disputes/summary/route.d.ts +0 -3
- package/.medusa/server/src/api/admin/paypal/disputes/summary/route.d.ts.map +0 -1
- package/.medusa/server/src/api/admin/paypal/disputes/summary/route.js +0 -17
- package/.medusa/server/src/api/admin/paypal/disputes/summary/route.js.map +0 -1
- package/.medusa/server/src/api/store/paypal/disputes/route.d.ts +0 -3
- package/.medusa/server/src/api/store/paypal/disputes/route.d.ts.map +0 -1
- package/.medusa/server/src/api/store/paypal/disputes/route.js +0 -46
- package/.medusa/server/src/api/store/paypal/disputes/route.js.map +0 -1
- package/.medusa/server/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.d.ts +0 -6
- package/.medusa/server/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.d.ts.map +0 -1
- package/.medusa/server/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.js +0 -43
- package/.medusa/server/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.js.map +0 -1
- package/.medusa/server/src/modules/paypal/models/paypal_dispute.d.ts +0 -16
- package/.medusa/server/src/modules/paypal/models/paypal_dispute.d.ts.map +0 -1
- package/.medusa/server/src/modules/paypal/models/paypal_dispute.js +0 -19
- package/.medusa/server/src/modules/paypal/models/paypal_dispute.js.map +0 -1
- package/src/admin/routes/settings/paypal/disputes/page.tsx +0 -186
- package/src/api/admin/paypal/disputes/[id]/route.ts +0 -19
- package/src/api/admin/paypal/disputes/route.ts +0 -30
- package/src/api/admin/paypal/disputes/summary/route.ts +0 -18
- package/src/api/store/paypal/disputes/route.ts +0 -67
- package/src/modules/paypal/migrations/20260501090000_create_paypal_dispute.ts +0 -40
- package/src/modules/paypal/models/paypal_dispute.ts +0 -18
|
@@ -14,7 +14,6 @@ const TABS = [
|
|
|
14
14
|
{ label: "PayPal Connection", to: `${BASE}/connection` },
|
|
15
15
|
{ label: "PayPal Settings", to: `${BASE}/paypal-settings` },
|
|
16
16
|
{ label: "Advanced Card Payments", to: `${BASE}/advanced-card-payments` },
|
|
17
|
-
{ label: "Disputes", to: `${BASE}/disputes` },
|
|
18
17
|
{ label: "Reconciliation Status", to: `${BASE}/reconciliation-status` },
|
|
19
18
|
/* { label: "Google Pay", to: `${BASE}/google-pay` },
|
|
20
19
|
{ label: "Apple Pay", to: `${BASE}/apple-pay` },
|
|
@@ -40,7 +39,7 @@ function PayPalTabs() {
|
|
|
40
39
|
);
|
|
41
40
|
}) }) });
|
|
42
41
|
}
|
|
43
|
-
async function adminFetch$
|
|
42
|
+
async function adminFetch$4(path, opts = {}) {
|
|
44
43
|
var _a;
|
|
45
44
|
const { method = "GET", body, query } = opts;
|
|
46
45
|
let url = path;
|
|
@@ -124,7 +123,7 @@ function AdditionalSettingsTab() {
|
|
|
124
123
|
(async () => {
|
|
125
124
|
try {
|
|
126
125
|
setLoading(true);
|
|
127
|
-
const json = await adminFetch$
|
|
126
|
+
const json = await adminFetch$4("/admin/paypal/settings");
|
|
128
127
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
129
128
|
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
130
129
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
@@ -138,7 +137,7 @@ function AdditionalSettingsTab() {
|
|
|
138
137
|
try {
|
|
139
138
|
setSaving(true);
|
|
140
139
|
setToast(null);
|
|
141
|
-
const json = await adminFetch$
|
|
140
|
+
const json = await adminFetch$4("/admin/paypal/settings", { method: "POST", body: { additional_settings: form } });
|
|
142
141
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
143
142
|
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
144
143
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
@@ -208,7 +207,7 @@ function AdditionalSettingsTab() {
|
|
|
208
207
|
)
|
|
209
208
|
] }) });
|
|
210
209
|
}
|
|
211
|
-
async function adminFetch$
|
|
210
|
+
async function adminFetch$3(path, opts = {}) {
|
|
212
211
|
var _a;
|
|
213
212
|
const { method = "GET", body, query } = opts;
|
|
214
213
|
let url = path;
|
|
@@ -301,7 +300,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
301
300
|
(async () => {
|
|
302
301
|
try {
|
|
303
302
|
setLoading(true);
|
|
304
|
-
const json = await adminFetch$
|
|
303
|
+
const json = await adminFetch$3("/admin/paypal/settings");
|
|
305
304
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
306
305
|
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
307
306
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
@@ -314,7 +313,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
314
313
|
async function onSave() {
|
|
315
314
|
try {
|
|
316
315
|
setSaving(true);
|
|
317
|
-
const json = await adminFetch$
|
|
316
|
+
const json = await adminFetch$3("/admin/paypal/settings", { method: "POST", body: { advanced_card_payments: form } });
|
|
318
317
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
319
318
|
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
320
319
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
@@ -382,6 +381,95 @@ function AdvancedCardPaymentsTab() {
|
|
|
382
381
|
function PayPalApplePayPage() {
|
|
383
382
|
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
384
383
|
}
|
|
384
|
+
async function adminFetch$2(path, opts = {}) {
|
|
385
|
+
var _a;
|
|
386
|
+
const { method = "GET", body, query } = opts;
|
|
387
|
+
let url = path;
|
|
388
|
+
if (query && Object.keys(query).length > 0) {
|
|
389
|
+
const params = new URLSearchParams(query);
|
|
390
|
+
url = `${path}?${params.toString()}`;
|
|
391
|
+
}
|
|
392
|
+
const headers = { Accept: "application/json" };
|
|
393
|
+
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
394
|
+
if (typeof window !== "undefined") {
|
|
395
|
+
const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
|
|
396
|
+
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
397
|
+
}
|
|
398
|
+
const res = await fetch(url, {
|
|
399
|
+
method,
|
|
400
|
+
headers,
|
|
401
|
+
credentials: "include",
|
|
402
|
+
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
403
|
+
});
|
|
404
|
+
const text = await res.text().catch(() => "");
|
|
405
|
+
if (!res.ok) {
|
|
406
|
+
if (res.status === 401) throw new Error("Unauthorized (401) - session may have expired. Please reload and log in again.");
|
|
407
|
+
if (res.status === 403) throw new Error("Forbidden (403) - you do not have permission to perform this action.");
|
|
408
|
+
throw new Error(text || `Request failed with status ${res.status}`);
|
|
409
|
+
}
|
|
410
|
+
if (!text) return {};
|
|
411
|
+
try {
|
|
412
|
+
return JSON.parse(text);
|
|
413
|
+
} catch {
|
|
414
|
+
return {};
|
|
415
|
+
}
|
|
416
|
+
}
|
|
417
|
+
function formatDate$1(value) {
|
|
418
|
+
if (!value) return "";
|
|
419
|
+
const parsed = new Date(value);
|
|
420
|
+
if (Number.isNaN(parsed.getTime())) return value;
|
|
421
|
+
return parsed.toLocaleString();
|
|
422
|
+
}
|
|
423
|
+
function PayPalAuditLogsPage() {
|
|
424
|
+
const [logs, setLogs] = react.useState([]);
|
|
425
|
+
const [loading, setLoading] = react.useState(false);
|
|
426
|
+
const [error, setError] = react.useState(null);
|
|
427
|
+
const fetchLogs = react.useCallback(async () => {
|
|
428
|
+
try {
|
|
429
|
+
setLoading(true);
|
|
430
|
+
setError(null);
|
|
431
|
+
const data = await adminFetch$2("/admin/paypal/audit-logs", { query: { limit: "50" } });
|
|
432
|
+
setLogs((data == null ? void 0 : data.logs) ?? []);
|
|
433
|
+
} catch (fetchError) {
|
|
434
|
+
setError(fetchError instanceof Error ? fetchError.message : "Failed to load audit logs.");
|
|
435
|
+
setLogs([]);
|
|
436
|
+
} finally {
|
|
437
|
+
setLoading(false);
|
|
438
|
+
}
|
|
439
|
+
}, []);
|
|
440
|
+
react.useEffect(() => {
|
|
441
|
+
fetchLogs();
|
|
442
|
+
}, [fetchLogs]);
|
|
443
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
444
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
445
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Audit Logs" }),
|
|
446
|
+
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-ui-fg-subtle", children: "Track administrative changes and credential events for PayPal configuration." })
|
|
447
|
+
] }),
|
|
448
|
+
/* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
|
|
449
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
450
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-b border-ui-border-base p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
|
|
451
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: "Latest events" }),
|
|
452
|
+
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: fetchLogs, className: "rounded-md border border-ui-border-base px-3 py-2 text-sm text-ui-fg-base", disabled: loading, children: loading ? "Refreshing..." : "Refresh" })
|
|
453
|
+
] }) }),
|
|
454
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4", children: [
|
|
455
|
+
error ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error }) : null,
|
|
456
|
+
!error && logs.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-ui-fg-subtle", children: loading ? "Loading audit logs..." : "No audit log entries found yet." }) : null,
|
|
457
|
+
logs.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full text-left text-sm", children: [
|
|
458
|
+
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "text-ui-fg-muted", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
459
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "pb-2 pr-4 font-medium", children: "Timestamp" }),
|
|
460
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "pb-2 pr-4 font-medium", children: "Event" }),
|
|
461
|
+
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "pb-2 font-medium", children: "Details" })
|
|
462
|
+
] }) }),
|
|
463
|
+
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: logs.map((entry) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "border-t border-ui-border-base", children: [
|
|
464
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-3 pr-4 text-ui-fg-base", children: formatDate$1(entry.created_at) || "—" }),
|
|
465
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-3 pr-4 text-ui-fg-base", children: entry.event_type || "—" }),
|
|
466
|
+
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-3 text-ui-fg-subtle", children: /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre-wrap rounded-md bg-ui-bg-subtle p-2 text-xs text-ui-fg-subtle", children: JSON.stringify(entry.metadata || {}, null, 2) }) })
|
|
467
|
+
] }, entry.id)) })
|
|
468
|
+
] }) }) : null
|
|
469
|
+
] })
|
|
470
|
+
] })
|
|
471
|
+
] }) });
|
|
472
|
+
}
|
|
385
473
|
const config = adminSdk.defineRouteConfig({
|
|
386
474
|
label: "PayPal Connection",
|
|
387
475
|
hide: true
|
|
@@ -966,247 +1054,6 @@ function PayPalConnectionPage() {
|
|
|
966
1054
|
` })
|
|
967
1055
|
] });
|
|
968
1056
|
}
|
|
969
|
-
async function adminFetch$3(path, opts = {}) {
|
|
970
|
-
var _a;
|
|
971
|
-
const { method = "GET", body, query } = opts;
|
|
972
|
-
let url = path;
|
|
973
|
-
if (query && Object.keys(query).length > 0) {
|
|
974
|
-
const params = new URLSearchParams(query);
|
|
975
|
-
url = `${path}?${params.toString()}`;
|
|
976
|
-
}
|
|
977
|
-
const headers = { Accept: "application/json" };
|
|
978
|
-
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
979
|
-
if (typeof window !== "undefined") {
|
|
980
|
-
const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
|
|
981
|
-
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
982
|
-
}
|
|
983
|
-
const res = await fetch(url, {
|
|
984
|
-
method,
|
|
985
|
-
headers,
|
|
986
|
-
credentials: "include",
|
|
987
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
988
|
-
});
|
|
989
|
-
const text = await res.text().catch(() => "");
|
|
990
|
-
if (!res.ok) {
|
|
991
|
-
if (res.status === 401) throw new Error("Unauthorized (401) - session may have expired. Please reload and log in again.");
|
|
992
|
-
if (res.status === 403) throw new Error("Forbidden (403) - you do not have permission to perform this action.");
|
|
993
|
-
throw new Error(text || `Request failed with status ${res.status}`);
|
|
994
|
-
}
|
|
995
|
-
if (!text) return {};
|
|
996
|
-
try {
|
|
997
|
-
return JSON.parse(text);
|
|
998
|
-
} catch {
|
|
999
|
-
return {};
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
const EMPTY_FILTERS = { dispute_id: "", status: "", order_id: "", cart_id: "" };
|
|
1003
|
-
function formatDate$2(value) {
|
|
1004
|
-
if (!value) return "";
|
|
1005
|
-
const parsed = new Date(value);
|
|
1006
|
-
if (Number.isNaN(parsed.getTime())) return value;
|
|
1007
|
-
return parsed.toLocaleString();
|
|
1008
|
-
}
|
|
1009
|
-
function PayPalDisputesPage() {
|
|
1010
|
-
const [filters, setFilters] = react.useState({ ...EMPTY_FILTERS });
|
|
1011
|
-
const [disputes, setDisputes] = react.useState([]);
|
|
1012
|
-
const [loading, setLoading] = react.useState(false);
|
|
1013
|
-
const [error, setError] = react.useState(null);
|
|
1014
|
-
const queryString = react.useMemo(() => {
|
|
1015
|
-
const params = new URLSearchParams();
|
|
1016
|
-
Object.entries(filters).forEach(([key, value]) => {
|
|
1017
|
-
if (value.trim()) params.set(key, value.trim());
|
|
1018
|
-
});
|
|
1019
|
-
const qs = params.toString();
|
|
1020
|
-
return qs ? `?${qs}` : "";
|
|
1021
|
-
}, [filters]);
|
|
1022
|
-
const fetchDisputes = react.useCallback(async (source) => {
|
|
1023
|
-
try {
|
|
1024
|
-
setLoading(true);
|
|
1025
|
-
setError(null);
|
|
1026
|
-
const query = {};
|
|
1027
|
-
Object.entries(source).forEach(([key, value]) => {
|
|
1028
|
-
if (value.trim()) query[key] = value.trim();
|
|
1029
|
-
});
|
|
1030
|
-
const json = await adminFetch$3("/admin/paypal/disputes", { query });
|
|
1031
|
-
setDisputes((json == null ? void 0 : json.disputes) ?? []);
|
|
1032
|
-
} catch (fetchError) {
|
|
1033
|
-
setError(fetchError instanceof Error ? fetchError.message : "Failed to load disputes");
|
|
1034
|
-
setDisputes([]);
|
|
1035
|
-
} finally {
|
|
1036
|
-
setLoading(false);
|
|
1037
|
-
}
|
|
1038
|
-
}, []);
|
|
1039
|
-
react.useEffect(() => {
|
|
1040
|
-
fetchDisputes(EMPTY_FILTERS);
|
|
1041
|
-
}, [fetchDisputes]);
|
|
1042
|
-
const onSubmit = (event) => {
|
|
1043
|
-
event.preventDefault();
|
|
1044
|
-
fetchDisputes(filters);
|
|
1045
|
-
};
|
|
1046
|
-
const onReset = () => {
|
|
1047
|
-
setFilters({ ...EMPTY_FILTERS });
|
|
1048
|
-
fetchDisputes(EMPTY_FILTERS);
|
|
1049
|
-
};
|
|
1050
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
1051
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1052
|
-
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Disputes" }),
|
|
1053
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-ui-fg-subtle", children: "Review PayPal dispute activity tied to your Medusa orders. This view is read-only." })
|
|
1054
|
-
] }),
|
|
1055
|
-
/* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
|
|
1056
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
1057
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-b border-ui-border-base p-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: "Filters" }) }),
|
|
1058
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("form", { onSubmit, className: "flex flex-col gap-4", children: [
|
|
1059
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-4 md:grid-cols-4", children: [
|
|
1060
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex flex-col gap-1 text-sm text-ui-fg-subtle", children: [
|
|
1061
|
-
"Dispute ID",
|
|
1062
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { className: "rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base", value: filters.dispute_id, onChange: (e) => setFilters((p) => ({ ...p, dispute_id: e.target.value })), placeholder: "PP-D-123" })
|
|
1063
|
-
] }),
|
|
1064
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex flex-col gap-1 text-sm text-ui-fg-subtle", children: [
|
|
1065
|
-
"Status",
|
|
1066
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { className: "rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base", value: filters.status, onChange: (e) => setFilters((p) => ({ ...p, status: e.target.value })), placeholder: "OPEN" })
|
|
1067
|
-
] }),
|
|
1068
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex flex-col gap-1 text-sm text-ui-fg-subtle", children: [
|
|
1069
|
-
"Order ID",
|
|
1070
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { className: "rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base", value: filters.order_id, onChange: (e) => setFilters((p) => ({ ...p, order_id: e.target.value })), placeholder: "order_..." })
|
|
1071
|
-
] }),
|
|
1072
|
-
/* @__PURE__ */ jsxRuntime.jsxs("label", { className: "flex flex-col gap-1 text-sm text-ui-fg-subtle", children: [
|
|
1073
|
-
"Cart ID",
|
|
1074
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { className: "rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base", value: filters.cart_id, onChange: (e) => setFilters((p) => ({ ...p, cart_id: e.target.value })), placeholder: "cart_..." })
|
|
1075
|
-
] })
|
|
1076
|
-
] }),
|
|
1077
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-3", children: [
|
|
1078
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "submit", className: "rounded-md bg-ui-fg-base px-4 py-2 text-sm font-medium text-ui-bg-base", disabled: loading, children: loading ? "Loading..." : "Apply filters" }),
|
|
1079
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", className: "rounded-md border border-ui-border-base px-4 py-2 text-sm text-ui-fg-base", onClick: onReset, disabled: loading, children: "Reset" }),
|
|
1080
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "text-sm text-ui-fg-subtle", children: [
|
|
1081
|
-
"Showing ",
|
|
1082
|
-
disputes.length,
|
|
1083
|
-
" dispute",
|
|
1084
|
-
disputes.length === 1 ? "" : "s",
|
|
1085
|
-
queryString ? " (filtered)" : ""
|
|
1086
|
-
] })
|
|
1087
|
-
] })
|
|
1088
|
-
] }) })
|
|
1089
|
-
] }),
|
|
1090
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
1091
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-b border-ui-border-base p-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: "Dispute Records" }) }),
|
|
1092
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base text-sm", children: [
|
|
1093
|
-
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "text-left text-ui-fg-subtle", children: [
|
|
1094
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 font-medium", children: "Dispute" }),
|
|
1095
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 font-medium", children: "Status" }),
|
|
1096
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 font-medium", children: "Reason" }),
|
|
1097
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 font-medium", children: "Stage" }),
|
|
1098
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 font-medium", children: "Amount" }),
|
|
1099
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 font-medium", children: "Order" }),
|
|
1100
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 font-medium", children: "Cart" }),
|
|
1101
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 font-medium", children: "Updated" })
|
|
1102
|
-
] }) }),
|
|
1103
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-base text-ui-fg-base", children: disputes.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("tr", { children: /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-6 text-center text-ui-fg-subtle", colSpan: 8, children: loading ? "Loading disputes..." : "No disputes found." }) }) : disputes.map((dispute) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
1104
|
-
/* @__PURE__ */ jsxRuntime.jsxs("td", { className: "px-4 py-3", children: [
|
|
1105
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium text-ui-fg-base", children: dispute.dispute_id }),
|
|
1106
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-ui-fg-subtle", children: dispute.transaction_id || "No transaction" })
|
|
1107
|
-
] }),
|
|
1108
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-3", children: dispute.status || "Unknown" }),
|
|
1109
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-3", children: dispute.reason || "-" }),
|
|
1110
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-3", children: dispute.stage || "-" }),
|
|
1111
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-3", children: dispute.amount ? `${dispute.amount} ${dispute.currency_code || ""}` : "-" }),
|
|
1112
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-3", children: dispute.order_id || "-" }),
|
|
1113
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-3", children: dispute.cart_id || "-" }),
|
|
1114
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-3 text-ui-fg-subtle", children: formatDate$2(dispute.updated_at || dispute.created_at) })
|
|
1115
|
-
] }, dispute.id)) })
|
|
1116
|
-
] }) }),
|
|
1117
|
-
error ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-ui-border-base px-4 py-3 text-sm text-ui-fg-error", children: error }) : null
|
|
1118
|
-
] })
|
|
1119
|
-
] }) });
|
|
1120
|
-
}
|
|
1121
|
-
async function adminFetch$2(path, opts = {}) {
|
|
1122
|
-
var _a;
|
|
1123
|
-
const { method = "GET", body, query } = opts;
|
|
1124
|
-
let url = path;
|
|
1125
|
-
if (query && Object.keys(query).length > 0) {
|
|
1126
|
-
const params = new URLSearchParams(query);
|
|
1127
|
-
url = `${path}?${params.toString()}`;
|
|
1128
|
-
}
|
|
1129
|
-
const headers = { Accept: "application/json" };
|
|
1130
|
-
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
1131
|
-
if (typeof window !== "undefined") {
|
|
1132
|
-
const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
|
|
1133
|
-
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
1134
|
-
}
|
|
1135
|
-
const res = await fetch(url, {
|
|
1136
|
-
method,
|
|
1137
|
-
headers,
|
|
1138
|
-
credentials: "include",
|
|
1139
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
1140
|
-
});
|
|
1141
|
-
const text = await res.text().catch(() => "");
|
|
1142
|
-
if (!res.ok) {
|
|
1143
|
-
if (res.status === 401) throw new Error("Unauthorized (401) - session may have expired. Please reload and log in again.");
|
|
1144
|
-
if (res.status === 403) throw new Error("Forbidden (403) - you do not have permission to perform this action.");
|
|
1145
|
-
throw new Error(text || `Request failed with status ${res.status}`);
|
|
1146
|
-
}
|
|
1147
|
-
if (!text) return {};
|
|
1148
|
-
try {
|
|
1149
|
-
return JSON.parse(text);
|
|
1150
|
-
} catch {
|
|
1151
|
-
return {};
|
|
1152
|
-
}
|
|
1153
|
-
}
|
|
1154
|
-
function formatDate$1(value) {
|
|
1155
|
-
if (!value) return "";
|
|
1156
|
-
const parsed = new Date(value);
|
|
1157
|
-
if (Number.isNaN(parsed.getTime())) return value;
|
|
1158
|
-
return parsed.toLocaleString();
|
|
1159
|
-
}
|
|
1160
|
-
function PayPalAuditLogsPage() {
|
|
1161
|
-
const [logs, setLogs] = react.useState([]);
|
|
1162
|
-
const [loading, setLoading] = react.useState(false);
|
|
1163
|
-
const [error, setError] = react.useState(null);
|
|
1164
|
-
const fetchLogs = react.useCallback(async () => {
|
|
1165
|
-
try {
|
|
1166
|
-
setLoading(true);
|
|
1167
|
-
setError(null);
|
|
1168
|
-
const data = await adminFetch$2("/admin/paypal/audit-logs", { query: { limit: "50" } });
|
|
1169
|
-
setLogs((data == null ? void 0 : data.logs) ?? []);
|
|
1170
|
-
} catch (fetchError) {
|
|
1171
|
-
setError(fetchError instanceof Error ? fetchError.message : "Failed to load audit logs.");
|
|
1172
|
-
setLogs([]);
|
|
1173
|
-
} finally {
|
|
1174
|
-
setLoading(false);
|
|
1175
|
-
}
|
|
1176
|
-
}, []);
|
|
1177
|
-
react.useEffect(() => {
|
|
1178
|
-
fetchLogs();
|
|
1179
|
-
}, [fetchLogs]);
|
|
1180
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
1181
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1182
|
-
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Audit Logs" }),
|
|
1183
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-ui-fg-subtle", children: "Track administrative changes and credential events for PayPal configuration." })
|
|
1184
|
-
] }),
|
|
1185
|
-
/* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
|
|
1186
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
1187
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-b border-ui-border-base p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
|
|
1188
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: "Latest events" }),
|
|
1189
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: fetchLogs, className: "rounded-md border border-ui-border-base px-3 py-2 text-sm text-ui-fg-base", disabled: loading, children: loading ? "Refreshing..." : "Refresh" })
|
|
1190
|
-
] }) }),
|
|
1191
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4", children: [
|
|
1192
|
-
error ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error }) : null,
|
|
1193
|
-
!error && logs.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-ui-fg-subtle", children: loading ? "Loading audit logs..." : "No audit log entries found yet." }) : null,
|
|
1194
|
-
logs.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full text-left text-sm", children: [
|
|
1195
|
-
/* @__PURE__ */ jsxRuntime.jsx("thead", { className: "text-ui-fg-muted", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
|
|
1196
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "pb-2 pr-4 font-medium", children: "Timestamp" }),
|
|
1197
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "pb-2 pr-4 font-medium", children: "Event" }),
|
|
1198
|
-
/* @__PURE__ */ jsxRuntime.jsx("th", { className: "pb-2 font-medium", children: "Details" })
|
|
1199
|
-
] }) }),
|
|
1200
|
-
/* @__PURE__ */ jsxRuntime.jsx("tbody", { children: logs.map((entry) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "border-t border-ui-border-base", children: [
|
|
1201
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-3 pr-4 text-ui-fg-base", children: formatDate$1(entry.created_at) || "—" }),
|
|
1202
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-3 pr-4 text-ui-fg-base", children: entry.event_type || "—" }),
|
|
1203
|
-
/* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-3 text-ui-fg-subtle", children: /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre-wrap rounded-md bg-ui-bg-subtle p-2 text-xs text-ui-fg-subtle", children: JSON.stringify(entry.metadata || {}, null, 2) }) })
|
|
1204
|
-
] }, entry.id)) })
|
|
1205
|
-
] }) }) : null
|
|
1206
|
-
] })
|
|
1207
|
-
] })
|
|
1208
|
-
] }) });
|
|
1209
|
-
}
|
|
1210
1057
|
function PayPalGooglePayPage() {
|
|
1211
1058
|
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
1212
1059
|
}
|
|
@@ -1815,18 +1662,14 @@ const routeModule = {
|
|
|
1815
1662
|
Component: PayPalApplePayPage,
|
|
1816
1663
|
path: "/settings/paypal/apple-pay"
|
|
1817
1664
|
},
|
|
1818
|
-
{
|
|
1819
|
-
Component: PayPalConnectionPage,
|
|
1820
|
-
path: "/settings/paypal/connection"
|
|
1821
|
-
},
|
|
1822
|
-
{
|
|
1823
|
-
Component: PayPalDisputesPage,
|
|
1824
|
-
path: "/settings/paypal/disputes"
|
|
1825
|
-
},
|
|
1826
1665
|
{
|
|
1827
1666
|
Component: PayPalAuditLogsPage,
|
|
1828
1667
|
path: "/settings/paypal/audit-logs"
|
|
1829
1668
|
},
|
|
1669
|
+
{
|
|
1670
|
+
Component: PayPalConnectionPage,
|
|
1671
|
+
path: "/settings/paypal/connection"
|
|
1672
|
+
},
|
|
1830
1673
|
{
|
|
1831
1674
|
Component: PayPalGooglePayPage,
|
|
1832
1675
|
path: "/settings/paypal/google-pay"
|