@easypayment/medusa-paypal 0.2.9 → 0.3.1
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 +11 -317
- package/.medusa/server/src/admin/index.mjs +11 -317
- 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 +202 -226
- package/src/admin/routes/settings/paypal/advanced-card-payments/page.tsx +220 -227
- package/src/admin/routes/settings/paypal/paypal-settings/page.tsx +519 -599
- 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;
|
|
@@ -77,12 +75,9 @@ const DEFAULT_FORM$1 = {
|
|
|
77
75
|
brandName: "PayPal",
|
|
78
76
|
landingPage: "no_preference",
|
|
79
77
|
requireInstantPayment: false,
|
|
80
|
-
useShippingAsBilling: true,
|
|
81
78
|
sendItemDetails: true,
|
|
82
|
-
skipOrderReviewPage: true,
|
|
83
79
|
invoicePrefix: "WC-",
|
|
84
80
|
creditCardStatementName: "PayPal",
|
|
85
|
-
enableLogging: true,
|
|
86
81
|
logPath: "/uploads/wc-logs/"
|
|
87
82
|
};
|
|
88
83
|
function mergeWithDefaults$1(saved) {
|
|
@@ -123,7 +118,7 @@ function AdditionalSettingsTab() {
|
|
|
123
118
|
(async () => {
|
|
124
119
|
try {
|
|
125
120
|
setLoading(true);
|
|
126
|
-
const json = await adminFetch$
|
|
121
|
+
const json = await adminFetch$2("/admin/paypal/settings");
|
|
127
122
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
128
123
|
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
129
124
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
@@ -137,7 +132,7 @@ function AdditionalSettingsTab() {
|
|
|
137
132
|
try {
|
|
138
133
|
setSaving(true);
|
|
139
134
|
setToast(null);
|
|
140
|
-
const json = await adminFetch$
|
|
135
|
+
const json = await adminFetch$2("/admin/paypal/settings", { method: "POST", body: { additional_settings: form } });
|
|
141
136
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
142
137
|
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
143
138
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
@@ -158,7 +153,7 @@ function AdditionalSettingsTab() {
|
|
|
158
153
|
SectionCard$2,
|
|
159
154
|
{
|
|
160
155
|
title: "Additional Settings",
|
|
161
|
-
description: "These settings control checkout behavior
|
|
156
|
+
description: "These settings control checkout behavior and PayPal experience.",
|
|
162
157
|
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
163
158
|
/* @__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
159
|
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading..." }) : null
|
|
@@ -178,36 +173,18 @@ function AdditionalSettingsTab() {
|
|
|
178
173
|
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.requireInstantPayment, onChange: (e) => setForm((p) => ({ ...p, requireInstantPayment: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
179
174
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Require Instant Payment" })
|
|
180
175
|
] }) }),
|
|
181
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Billing Address", hint: "If the billing address is empty and PayPal provides a shipping address, the order will use the shipping address as the billing address.", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
182
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.useShippingAsBilling, onChange: (e) => setForm((p) => ({ ...p, useShippingAsBilling: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
183
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Use PayPal Shipping Address as Billing" })
|
|
184
|
-
] }) }),
|
|
185
176
|
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Send Item Details", hint: "Include all line item details in the payment request to PayPal so that they can be seen from the PayPal transaction details page.", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
186
177
|
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.sendItemDetails, onChange: (e) => setForm((p) => ({ ...p, sendItemDetails: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
187
178
|
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Send line item details to PayPal" })
|
|
188
179
|
] }) }),
|
|
189
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Order Review Page", hint: "Payments from the Product or Cart page skip the review step and go straight to the Thank You page.", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
190
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.skipOrderReviewPage, onChange: (e) => setForm((p) => ({ ...p, skipOrderReviewPage: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
191
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Skip Order Review Page" })
|
|
192
|
-
] }) }),
|
|
193
180
|
/* @__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
|
-
] }) })
|
|
181
|
+
/* @__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
182
|
] })
|
|
206
183
|
}
|
|
207
184
|
)
|
|
208
185
|
] }) });
|
|
209
186
|
}
|
|
210
|
-
async function adminFetch$
|
|
187
|
+
async function adminFetch$1(path, opts = {}) {
|
|
211
188
|
var _a;
|
|
212
189
|
const { method = "GET", body, query } = opts;
|
|
213
190
|
let url = path;
|
|
@@ -240,7 +217,7 @@ async function adminFetch$3(path, opts = {}) {
|
|
|
240
217
|
return {};
|
|
241
218
|
}
|
|
242
219
|
}
|
|
243
|
-
const DEFAULT_FORM = { enabled: true, title: "Credit or Debit Card", disabledCards: [], threeDS: "when_required"
|
|
220
|
+
const DEFAULT_FORM = { enabled: true, title: "Credit or Debit Card", disabledCards: [], threeDS: "when_required" };
|
|
244
221
|
function mergeWithDefaults(saved) {
|
|
245
222
|
if (!saved) return { ...DEFAULT_FORM };
|
|
246
223
|
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
@@ -300,7 +277,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
300
277
|
(async () => {
|
|
301
278
|
try {
|
|
302
279
|
setLoading(true);
|
|
303
|
-
const json = await adminFetch$
|
|
280
|
+
const json = await adminFetch$1("/admin/paypal/settings");
|
|
304
281
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
305
282
|
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
306
283
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
@@ -313,7 +290,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
313
290
|
async function onSave() {
|
|
314
291
|
try {
|
|
315
292
|
setSaving(true);
|
|
316
|
-
const json = await adminFetch$
|
|
293
|
+
const json = await adminFetch$1("/admin/paypal/settings", { method: "POST", body: { advanced_card_payments: form } });
|
|
317
294
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
318
295
|
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
319
296
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
@@ -368,10 +345,6 @@ function AdvancedCardPaymentsTab() {
|
|
|
368
345
|
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Contingency for 3D Secure", hint: "Choose when 3D Secure should be triggered during card payments.", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
369
346
|
/* @__PURE__ */ jsxRuntime.jsx("select", { value: form.threeDS, onChange: (e) => setForm((p) => ({ ...p, threeDS: 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", children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value)) }),
|
|
370
347
|
((_a = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _a.hint) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-ui-fg-subtle", children: (_b = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _b.hint }) : null
|
|
371
|
-
] }) }),
|
|
372
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Card Save Enabled", hint: "Allow customers to save a card at checkout for future use.", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
373
|
-
/* @__PURE__ */ jsxRuntime.jsx("input", { type: "checkbox", checked: form.cardSaveEnabled, onChange: (e) => setForm((p) => ({ ...p, cardSaveEnabled: e.target.checked })), className: "h-4 w-4 rounded border-ui-border-base" }),
|
|
374
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable card saving at checkout" })
|
|
375
348
|
] }) })
|
|
376
349
|
] })
|
|
377
350
|
}
|
|
@@ -381,95 +354,6 @@ function AdvancedCardPaymentsTab() {
|
|
|
381
354
|
function PayPalApplePayPage() {
|
|
382
355
|
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
383
356
|
}
|
|
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
357
|
const config = adminSdk.defineRouteConfig({
|
|
474
358
|
label: "PayPal Connection",
|
|
475
359
|
hide: true
|
|
@@ -1060,126 +944,6 @@ function PayPalGooglePayPage() {
|
|
|
1060
944
|
function PayPalPayLaterMessagingPage() {
|
|
1061
945
|
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
1062
946
|
}
|
|
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
947
|
async function adminFetch(path, opts = {}) {
|
|
1184
948
|
var _a;
|
|
1185
949
|
const { method = "GET", body, query } = opts;
|
|
@@ -1213,13 +977,6 @@ async function adminFetch(path, opts = {}) {
|
|
|
1213
977
|
return {};
|
|
1214
978
|
}
|
|
1215
979
|
}
|
|
1216
|
-
const DISPLAY_LOCATION_OPTIONS = [
|
|
1217
|
-
{ value: "product", label: "Product Page" },
|
|
1218
|
-
{ value: "cart", label: "Cart Page" },
|
|
1219
|
-
{ value: "express", label: "Express Checkout" },
|
|
1220
|
-
{ value: "checkout", label: "Checkout Page", disabled: true, hint: "Locked by PayPal eligibility / checkout config" },
|
|
1221
|
-
{ value: "mini_cart", label: "Mini Cart (Side Cart)" }
|
|
1222
|
-
];
|
|
1223
980
|
const DISABLE_BUTTON_OPTIONS = [
|
|
1224
981
|
{ value: "paypal", label: "PayPal" },
|
|
1225
982
|
{ value: "paylater", label: "Pay Later" },
|
|
@@ -1325,7 +1082,6 @@ function PayPalSettingsTab() {
|
|
|
1325
1082
|
enabled: true,
|
|
1326
1083
|
title: "PayPal",
|
|
1327
1084
|
description: "Pay via PayPal; you can pay with your credit card if you don't have a PayPal account",
|
|
1328
|
-
displayOn: ["product", "cart", "express", "mini_cart"],
|
|
1329
1085
|
disableButtons: [],
|
|
1330
1086
|
buttonColor: "gold",
|
|
1331
1087
|
buttonShape: "rect",
|
|
@@ -1396,7 +1152,6 @@ function PayPalSettingsTab() {
|
|
|
1396
1152
|
setSaving(false);
|
|
1397
1153
|
}
|
|
1398
1154
|
}
|
|
1399
|
-
react.useMemo(() => new Map(DISPLAY_LOCATION_OPTIONS.map((o) => [o.value, o])), []);
|
|
1400
1155
|
function toggleMulti(key, value) {
|
|
1401
1156
|
setForm((prev) => {
|
|
1402
1157
|
const list = prev[key] || [];
|
|
@@ -1430,7 +1185,7 @@ function PayPalSettingsTab() {
|
|
|
1430
1185
|
SectionCard,
|
|
1431
1186
|
{
|
|
1432
1187
|
title: "PayPal Settings",
|
|
1433
|
-
description: "Enable PayPal
|
|
1188
|
+
description: "Enable PayPal and configure checkout title/description.",
|
|
1434
1189
|
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1435
1190
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1436
1191
|
"button",
|
|
@@ -1474,60 +1229,7 @@ function PayPalSettingsTab() {
|
|
|
1474
1229
|
className: "min-h-[84px] w-full resize-y 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",
|
|
1475
1230
|
placeholder: "Pay via PayPal..."
|
|
1476
1231
|
}
|
|
1477
|
-
) })
|
|
1478
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1479
|
-
FieldRow,
|
|
1480
|
-
{
|
|
1481
|
-
label: "Display PayPal Buttons On",
|
|
1482
|
-
hint: "Choose where PayPal Smart Buttons should render.",
|
|
1483
|
-
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
1484
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
1485
|
-
DISPLAY_LOCATION_OPTIONS.filter((o) => form.displayOn.includes(o.value)).map((o) => /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1486
|
-
Pill,
|
|
1487
|
-
{
|
|
1488
|
-
disabled: o.disabled,
|
|
1489
|
-
onRemove: o.disabled ? void 0 : () => removeMulti("displayOn", o.value),
|
|
1490
|
-
children: [
|
|
1491
|
-
o.label,
|
|
1492
|
-
o.disabled ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "ml-1 rounded bg-ui-bg-subtle px-1 py-[1px] text-[10px] text-ui-fg-subtle", children: "Locked" }) : null
|
|
1493
|
-
]
|
|
1494
|
-
},
|
|
1495
|
-
o.value
|
|
1496
|
-
)),
|
|
1497
|
-
form.displayOn.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "No locations selected." }) : null
|
|
1498
|
-
] }),
|
|
1499
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-ui-border-base p-3", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-2 md:grid-cols-2", children: DISPLAY_LOCATION_OPTIONS.map((o) => {
|
|
1500
|
-
const checked = form.displayOn.includes(o.value);
|
|
1501
|
-
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1502
|
-
"label",
|
|
1503
|
-
{
|
|
1504
|
-
className: cx(
|
|
1505
|
-
"flex items-start gap-2 rounded-md p-2",
|
|
1506
|
-
o.disabled ? "opacity-60" : "hover:bg-ui-bg-subtle"
|
|
1507
|
-
),
|
|
1508
|
-
children: [
|
|
1509
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1510
|
-
"input",
|
|
1511
|
-
{
|
|
1512
|
-
type: "checkbox",
|
|
1513
|
-
disabled: o.disabled,
|
|
1514
|
-
checked,
|
|
1515
|
-
onChange: () => toggleMulti("displayOn", o.value),
|
|
1516
|
-
className: "mt-0.5 h-4 w-4 rounded border-ui-border-base"
|
|
1517
|
-
}
|
|
1518
|
-
),
|
|
1519
|
-
/* @__PURE__ */ jsxRuntime.jsxs("span", { className: "flex flex-col", children: [
|
|
1520
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: o.label }),
|
|
1521
|
-
o.hint ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-xs text-ui-fg-subtle", children: o.hint }) : null
|
|
1522
|
-
] })
|
|
1523
|
-
]
|
|
1524
|
-
},
|
|
1525
|
-
o.value
|
|
1526
|
-
);
|
|
1527
|
-
}) }) })
|
|
1528
|
-
] })
|
|
1529
|
-
}
|
|
1530
|
-
)
|
|
1232
|
+
) })
|
|
1531
1233
|
] })
|
|
1532
1234
|
}
|
|
1533
1235
|
),
|
|
@@ -1662,10 +1364,6 @@ const routeModule = {
|
|
|
1662
1364
|
Component: PayPalApplePayPage,
|
|
1663
1365
|
path: "/settings/paypal/apple-pay"
|
|
1664
1366
|
},
|
|
1665
|
-
{
|
|
1666
|
-
Component: PayPalAuditLogsPage,
|
|
1667
|
-
path: "/settings/paypal/audit-logs"
|
|
1668
|
-
},
|
|
1669
1367
|
{
|
|
1670
1368
|
Component: PayPalConnectionPage,
|
|
1671
1369
|
path: "/settings/paypal/connection"
|
|
@@ -1678,10 +1376,6 @@ const routeModule = {
|
|
|
1678
1376
|
Component: PayPalPayLaterMessagingPage,
|
|
1679
1377
|
path: "/settings/paypal/pay-later-messaging"
|
|
1680
1378
|
},
|
|
1681
|
-
{
|
|
1682
|
-
Component: PayPalReconciliationStatusPage,
|
|
1683
|
-
path: "/settings/paypal/reconciliation-status"
|
|
1684
|
-
},
|
|
1685
1379
|
{
|
|
1686
1380
|
Component: PayPalSettingsTab,
|
|
1687
1381
|
path: "/settings/paypal/paypal-settings"
|