@easypayment/medusa-paypal 0.2.9 → 0.3.0
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 +18 -248
- package/.medusa/server/src/admin/index.mjs +18 -248
- package/.medusa/server/src/jobs/paypal-reconcile.d.ts.map +1 -1
- package/.medusa/server/src/jobs/paypal-reconcile.js +0 -36
- package/.medusa/server/src/jobs/paypal-reconcile.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/migrations/20261101090000_remove_paypal_reconciliation_status.d.ts +6 -0
- package/.medusa/server/src/modules/paypal/migrations/20261101090000_remove_paypal_reconciliation_status.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20261101090000_remove_paypal_reconciliation_status.js +28 -0
- package/.medusa/server/src/modules/paypal/migrations/20261101090000_remove_paypal_reconciliation_status.js.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/20261201090000_remove_paypal_audit_log.d.ts +6 -0
- package/.medusa/server/src/modules/paypal/migrations/20261201090000_remove_paypal_audit_log.d.ts.map +1 -0
- package/.medusa/server/src/modules/paypal/migrations/{20260301090000_create_paypal_audit_log.js → 20261201090000_remove_paypal_audit_log.js} +10 -10
- package/.medusa/server/src/modules/paypal/migrations/20261201090000_remove_paypal_audit_log.js.map +1 -0
- package/.medusa/server/src/modules/paypal/service.d.ts +2 -48
- package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/service.js +2 -99
- package/.medusa/server/src/modules/paypal/service.js.map +1 -1
- package/package.json +1 -1
- package/src/admin/routes/settings/paypal/_components/Tabs.tsx +0 -2
- package/src/admin/routes/settings/paypal/additional-settings/page.tsx +218 -226
- package/src/jobs/paypal-reconcile.ts +0 -37
- package/src/modules/paypal/migrations/20261101090000_remove_paypal_reconciliation_status.ts +25 -0
- package/src/modules/paypal/migrations/{20260301090000_create_paypal_audit_log.ts → 20261201090000_remove_paypal_audit_log.ts} +8 -8
- package/src/modules/paypal/service.ts +2 -112
- package/.medusa/server/src/api/admin/paypal/audit-logs/route.d.ts +0 -3
- package/.medusa/server/src/api/admin/paypal/audit-logs/route.d.ts.map +0 -1
- package/.medusa/server/src/api/admin/paypal/audit-logs/route.js +0 -12
- package/.medusa/server/src/api/admin/paypal/audit-logs/route.js.map +0 -1
- package/.medusa/server/src/api/admin/paypal/reconciliation-status/route.d.ts +0 -3
- package/.medusa/server/src/api/admin/paypal/reconciliation-status/route.d.ts.map +0 -1
- package/.medusa/server/src/api/admin/paypal/reconciliation-status/route.js +0 -8
- package/.medusa/server/src/api/admin/paypal/reconciliation-status/route.js.map +0 -1
- package/.medusa/server/src/modules/paypal/migrations/20260301090000_create_paypal_audit_log.d.ts +0 -6
- package/.medusa/server/src/modules/paypal/migrations/20260301090000_create_paypal_audit_log.d.ts.map +0 -1
- package/.medusa/server/src/modules/paypal/migrations/20260301090000_create_paypal_audit_log.js.map +0 -1
- package/.medusa/server/src/modules/paypal/models/paypal_audit_log.d.ts +0 -7
- package/.medusa/server/src/modules/paypal/models/paypal_audit_log.d.ts.map +0 -1
- package/.medusa/server/src/modules/paypal/models/paypal_audit_log.js +0 -10
- package/.medusa/server/src/modules/paypal/models/paypal_audit_log.js.map +0 -1
- package/src/admin/routes/settings/paypal/audit-logs/page.tsx +0 -127
- package/src/admin/routes/settings/paypal/reconciliation-status/page.tsx +0 -120
- package/src/api/admin/paypal/audit-logs/route.ts +0 -13
- package/src/api/admin/paypal/reconciliation-status/route.ts +0 -7
- package/src/modules/paypal/models/paypal_audit_log.ts +0 -9
|
@@ -14,11 +14,9 @@ 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: "Reconciliation Status", to: `${BASE}/reconciliation-status` },
|
|
18
17
|
/* { label: "Google Pay", to: `${BASE}/google-pay` },
|
|
19
18
|
{ label: "Apple Pay", to: `${BASE}/apple-pay` },
|
|
20
19
|
{ label: "Pay Later Messaging", to: `${BASE}/pay-later-messaging` }, */
|
|
21
|
-
{ label: "Audit Logs", to: `${BASE}/audit-logs` },
|
|
22
20
|
{ label: "Additional Settings", to: `${BASE}/additional-settings` }
|
|
23
21
|
];
|
|
24
22
|
function isActive(pathname, to) {
|
|
@@ -39,7 +37,7 @@ function PayPalTabs() {
|
|
|
39
37
|
);
|
|
40
38
|
}) }) });
|
|
41
39
|
}
|
|
42
|
-
async function adminFetch$
|
|
40
|
+
async function adminFetch$2(path, opts = {}) {
|
|
43
41
|
var _a;
|
|
44
42
|
const { method = "GET", body, query } = opts;
|
|
45
43
|
let url = path;
|
|
@@ -82,7 +80,6 @@ const DEFAULT_FORM$1 = {
|
|
|
82
80
|
skipOrderReviewPage: true,
|
|
83
81
|
invoicePrefix: "WC-",
|
|
84
82
|
creditCardStatementName: "PayPal",
|
|
85
|
-
enableLogging: true,
|
|
86
83
|
logPath: "/uploads/wc-logs/"
|
|
87
84
|
};
|
|
88
85
|
function mergeWithDefaults$1(saved) {
|
|
@@ -123,7 +120,7 @@ function AdditionalSettingsTab() {
|
|
|
123
120
|
(async () => {
|
|
124
121
|
try {
|
|
125
122
|
setLoading(true);
|
|
126
|
-
const json = await adminFetch$
|
|
123
|
+
const json = await adminFetch$2("/admin/paypal/settings");
|
|
127
124
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
128
125
|
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
129
126
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
@@ -137,7 +134,7 @@ function AdditionalSettingsTab() {
|
|
|
137
134
|
try {
|
|
138
135
|
setSaving(true);
|
|
139
136
|
setToast(null);
|
|
140
|
-
const json = await adminFetch$
|
|
137
|
+
const json = await adminFetch$2("/admin/paypal/settings", { method: "POST", body: { additional_settings: form } });
|
|
141
138
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
142
139
|
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
143
140
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
@@ -158,7 +155,7 @@ function AdditionalSettingsTab() {
|
|
|
158
155
|
SectionCard$2,
|
|
159
156
|
{
|
|
160
157
|
title: "Additional Settings",
|
|
161
|
-
description: "These settings control checkout behavior
|
|
158
|
+
description: "These settings control checkout behavior and PayPal experience.",
|
|
162
159
|
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
163
160
|
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: onSave, disabled: saving || loading, className: "rounded-md bg-ui-button-neutral px-4 py-2 text-sm font-medium text-ui-fg-on-color shadow-sm hover:opacity-90 disabled:opacity-60", children: saving ? "Saving..." : "Save settings" }),
|
|
164
161
|
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading..." }) : null
|
|
@@ -191,23 +188,16 @@ function AdditionalSettingsTab() {
|
|
|
191
188
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Skip Order Review Page" })
|
|
192
189
|
] }) }),
|
|
193
190
|
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Invoice prefix", children: /* @__PURE__ */ jsxRuntime.jsx("input", { value: form.invoicePrefix, onChange: (e) => setForm((p) => ({ ...p, invoicePrefix: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "WC-" }) }),
|
|
194
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Credit Card Statement Name", children: /* @__PURE__ */ jsxRuntime.jsx("input", { value: form.creditCardStatementName, onChange: (e) => setForm((p) => ({ ...p, creditCardStatementName: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "PayPal" }) })
|
|
195
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Debug log", hint: /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
|
|
196
|
-
"Log PayPal events such as Webhook, Payment, Refund. ",
|
|
197
|
-
form.logPath ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
198
|
-
"Log location: ",
|
|
199
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono", children: form.logPath })
|
|
200
|
-
] }) : null
|
|
201
|
-
] }), children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
202
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.enableLogging, onChange: (e) => setForm((p) => ({ ...p, enableLogging: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
203
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable logging" })
|
|
204
|
-
] }) })
|
|
191
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Credit Card Statement Name", children: /* @__PURE__ */ jsxRuntime.jsx("input", { value: form.creditCardStatementName, onChange: (e) => setForm((p) => ({ ...p, creditCardStatementName: e.target.value })), className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive", placeholder: "PayPal" }) })
|
|
205
192
|
] })
|
|
206
193
|
}
|
|
207
194
|
)
|
|
208
195
|
] }) });
|
|
209
196
|
}
|
|
210
|
-
|
|
197
|
+
function PayPalGooglePayPage() {
|
|
198
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
199
|
+
}
|
|
200
|
+
async function adminFetch$1(path, opts = {}) {
|
|
211
201
|
var _a;
|
|
212
202
|
const { method = "GET", body, query } = opts;
|
|
213
203
|
let url = path;
|
|
@@ -300,7 +290,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
300
290
|
(async () => {
|
|
301
291
|
try {
|
|
302
292
|
setLoading(true);
|
|
303
|
-
const json = await adminFetch$
|
|
293
|
+
const json = await adminFetch$1("/admin/paypal/settings");
|
|
304
294
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
305
295
|
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
306
296
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
@@ -313,7 +303,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
313
303
|
async function onSave() {
|
|
314
304
|
try {
|
|
315
305
|
setSaving(true);
|
|
316
|
-
const json = await adminFetch$
|
|
306
|
+
const json = await adminFetch$1("/admin/paypal/settings", { method: "POST", body: { advanced_card_payments: form } });
|
|
317
307
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
318
308
|
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
319
309
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
@@ -378,98 +368,6 @@ function AdvancedCardPaymentsTab() {
|
|
|
378
368
|
)
|
|
379
369
|
] }) });
|
|
380
370
|
}
|
|
381
|
-
function PayPalApplePayPage() {
|
|
382
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
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
|
-
}
|
|
473
371
|
const config = adminSdk.defineRouteConfig({
|
|
474
372
|
label: "PayPal Connection",
|
|
475
373
|
hide: true
|
|
@@ -1054,132 +952,12 @@ function PayPalConnectionPage() {
|
|
|
1054
952
|
` })
|
|
1055
953
|
] });
|
|
1056
954
|
}
|
|
1057
|
-
function
|
|
955
|
+
function PayPalApplePayPage() {
|
|
1058
956
|
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
1059
957
|
}
|
|
1060
958
|
function PayPalPayLaterMessagingPage() {
|
|
1061
959
|
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
1062
960
|
}
|
|
1063
|
-
async function adminFetch$1(path, opts = {}) {
|
|
1064
|
-
var _a;
|
|
1065
|
-
const { method = "GET", body, query } = opts;
|
|
1066
|
-
let url = path;
|
|
1067
|
-
if (query && Object.keys(query).length > 0) {
|
|
1068
|
-
const params = new URLSearchParams(query);
|
|
1069
|
-
url = `${path}?${params.toString()}`;
|
|
1070
|
-
}
|
|
1071
|
-
const headers = { Accept: "application/json" };
|
|
1072
|
-
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
1073
|
-
if (typeof window !== "undefined") {
|
|
1074
|
-
const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
|
|
1075
|
-
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
1076
|
-
}
|
|
1077
|
-
const res = await fetch(url, {
|
|
1078
|
-
method,
|
|
1079
|
-
headers,
|
|
1080
|
-
credentials: "include",
|
|
1081
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
1082
|
-
});
|
|
1083
|
-
const text = await res.text().catch(() => "");
|
|
1084
|
-
if (!res.ok) {
|
|
1085
|
-
if (res.status === 401) throw new Error("Unauthorized (401) - session may have expired. Please reload and log in again.");
|
|
1086
|
-
if (res.status === 403) throw new Error("Forbidden (403) - you do not have permission to perform this action.");
|
|
1087
|
-
throw new Error(text || `Request failed with status ${res.status}`);
|
|
1088
|
-
}
|
|
1089
|
-
if (!text) return {};
|
|
1090
|
-
try {
|
|
1091
|
-
return JSON.parse(text);
|
|
1092
|
-
} catch {
|
|
1093
|
-
return {};
|
|
1094
|
-
}
|
|
1095
|
-
}
|
|
1096
|
-
function formatDate(value) {
|
|
1097
|
-
if (!value) return "—";
|
|
1098
|
-
const parsed = new Date(value);
|
|
1099
|
-
if (Number.isNaN(parsed.getTime())) return value;
|
|
1100
|
-
return parsed.toLocaleString();
|
|
1101
|
-
}
|
|
1102
|
-
function PayPalReconciliationStatusPage() {
|
|
1103
|
-
const [status, setStatus] = react.useState({});
|
|
1104
|
-
const [loading, setLoading] = react.useState(false);
|
|
1105
|
-
const [error, setError] = react.useState(null);
|
|
1106
|
-
const fetchStatus = react.useCallback(async () => {
|
|
1107
|
-
try {
|
|
1108
|
-
setLoading(true);
|
|
1109
|
-
setError(null);
|
|
1110
|
-
const data = await adminFetch$1("/admin/paypal/reconciliation-status");
|
|
1111
|
-
setStatus((data == null ? void 0 : data.status) ?? {});
|
|
1112
|
-
} catch (fetchError) {
|
|
1113
|
-
setError(fetchError instanceof Error ? fetchError.message : "Failed to load reconciliation status.");
|
|
1114
|
-
setStatus({});
|
|
1115
|
-
} finally {
|
|
1116
|
-
setLoading(false);
|
|
1117
|
-
}
|
|
1118
|
-
}, []);
|
|
1119
|
-
react.useEffect(() => {
|
|
1120
|
-
fetchStatus();
|
|
1121
|
-
}, [fetchStatus]);
|
|
1122
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
1123
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
1124
|
-
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Reconciliation Status" }),
|
|
1125
|
-
/* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-ui-fg-subtle", children: "Monitor reconciliation health and drift detection for PayPal payment sessions." })
|
|
1126
|
-
] }),
|
|
1127
|
-
/* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
|
|
1128
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
1129
|
-
/* @__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: [
|
|
1130
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: "Latest reconciliation run" }),
|
|
1131
|
-
/* @__PURE__ */ jsxRuntime.jsx("button", { type: "button", onClick: fetchStatus, className: "rounded-md border border-ui-border-base px-3 py-2 text-sm text-ui-fg-base", disabled: loading, children: loading ? "Refreshing..." : "Refresh" })
|
|
1132
|
-
] }) }),
|
|
1133
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4", children: [
|
|
1134
|
-
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,
|
|
1135
|
-
!error && Object.keys(status).length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-ui-fg-subtle", children: loading ? "Loading reconciliation status..." : "No reconciliation data yet." }) : null,
|
|
1136
|
-
Object.keys(status).length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid gap-4 text-sm text-ui-fg-base md:grid-cols-2", children: [
|
|
1137
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1138
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle", children: "Last run" }),
|
|
1139
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 font-medium", children: formatDate(status.last_run_at) })
|
|
1140
|
-
] }),
|
|
1141
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1142
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle", children: "Last run status" }),
|
|
1143
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 font-medium capitalize", children: status.last_run_status || "—" })
|
|
1144
|
-
] }),
|
|
1145
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1146
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle", children: "Last success" }),
|
|
1147
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 font-medium", children: formatDate(status.last_success_at) })
|
|
1148
|
-
] }),
|
|
1149
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1150
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle", children: "Last failure" }),
|
|
1151
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 font-medium", children: formatDate(status.last_failure_at) })
|
|
1152
|
-
] }),
|
|
1153
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1154
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle", children: "Sessions checked" }),
|
|
1155
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 font-medium", children: status.sessions_checked ?? 0 })
|
|
1156
|
-
] }),
|
|
1157
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1158
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle", children: "Sessions updated" }),
|
|
1159
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 font-medium", children: status.sessions_updated ?? 0 })
|
|
1160
|
-
] }),
|
|
1161
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1162
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle", children: "Drift detections" }),
|
|
1163
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 font-medium", children: status.drift_count ?? 0 })
|
|
1164
|
-
] }),
|
|
1165
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1166
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle", children: "Last drift order" }),
|
|
1167
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 font-medium", children: status.last_drift_order_id || "—" }),
|
|
1168
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: formatDate(status.last_drift_at) })
|
|
1169
|
-
] }),
|
|
1170
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3 md:col-span-2", children: [
|
|
1171
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle", children: "Last error" }),
|
|
1172
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 font-medium", children: status.last_error || "No errors recorded." })
|
|
1173
|
-
] }),
|
|
1174
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3 md:col-span-2", children: [
|
|
1175
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-ui-fg-subtle", children: "Total runs" }),
|
|
1176
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 font-medium", children: status.runs ?? 0 })
|
|
1177
|
-
] })
|
|
1178
|
-
] }) : null
|
|
1179
|
-
] })
|
|
1180
|
-
] })
|
|
1181
|
-
] }) });
|
|
1182
|
-
}
|
|
1183
961
|
async function adminFetch(path, opts = {}) {
|
|
1184
962
|
var _a;
|
|
1185
963
|
const { method = "GET", body, query } = opts;
|
|
@@ -1655,33 +1433,25 @@ const routeModule = {
|
|
|
1655
1433
|
path: "/settings/paypal/additional-settings"
|
|
1656
1434
|
},
|
|
1657
1435
|
{
|
|
1658
|
-
Component:
|
|
1659
|
-
path: "/settings/paypal/
|
|
1660
|
-
},
|
|
1661
|
-
{
|
|
1662
|
-
Component: PayPalApplePayPage,
|
|
1663
|
-
path: "/settings/paypal/apple-pay"
|
|
1436
|
+
Component: PayPalGooglePayPage,
|
|
1437
|
+
path: "/settings/paypal/google-pay"
|
|
1664
1438
|
},
|
|
1665
1439
|
{
|
|
1666
|
-
Component:
|
|
1667
|
-
path: "/settings/paypal/
|
|
1440
|
+
Component: AdvancedCardPaymentsTab,
|
|
1441
|
+
path: "/settings/paypal/advanced-card-payments"
|
|
1668
1442
|
},
|
|
1669
1443
|
{
|
|
1670
1444
|
Component: PayPalConnectionPage,
|
|
1671
1445
|
path: "/settings/paypal/connection"
|
|
1672
1446
|
},
|
|
1673
1447
|
{
|
|
1674
|
-
Component:
|
|
1675
|
-
path: "/settings/paypal/
|
|
1448
|
+
Component: PayPalApplePayPage,
|
|
1449
|
+
path: "/settings/paypal/apple-pay"
|
|
1676
1450
|
},
|
|
1677
1451
|
{
|
|
1678
1452
|
Component: PayPalPayLaterMessagingPage,
|
|
1679
1453
|
path: "/settings/paypal/pay-later-messaging"
|
|
1680
1454
|
},
|
|
1681
|
-
{
|
|
1682
|
-
Component: PayPalReconciliationStatusPage,
|
|
1683
|
-
path: "/settings/paypal/reconciliation-status"
|
|
1684
|
-
},
|
|
1685
1455
|
{
|
|
1686
1456
|
Component: PayPalSettingsTab,
|
|
1687
1457
|
path: "/settings/paypal/paypal-settings"
|