@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
|
@@ -13,11 +13,9 @@ const TABS = [
|
|
|
13
13
|
{ label: "PayPal Connection", to: `${BASE}/connection` },
|
|
14
14
|
{ label: "PayPal Settings", to: `${BASE}/paypal-settings` },
|
|
15
15
|
{ label: "Advanced Card Payments", to: `${BASE}/advanced-card-payments` },
|
|
16
|
-
{ label: "Reconciliation Status", to: `${BASE}/reconciliation-status` },
|
|
17
16
|
/* { label: "Google Pay", to: `${BASE}/google-pay` },
|
|
18
17
|
{ label: "Apple Pay", to: `${BASE}/apple-pay` },
|
|
19
18
|
{ label: "Pay Later Messaging", to: `${BASE}/pay-later-messaging` }, */
|
|
20
|
-
{ label: "Audit Logs", to: `${BASE}/audit-logs` },
|
|
21
19
|
{ label: "Additional Settings", to: `${BASE}/additional-settings` }
|
|
22
20
|
];
|
|
23
21
|
function isActive(pathname, to) {
|
|
@@ -38,7 +36,7 @@ function PayPalTabs() {
|
|
|
38
36
|
);
|
|
39
37
|
}) }) });
|
|
40
38
|
}
|
|
41
|
-
async function adminFetch$
|
|
39
|
+
async function adminFetch$2(path, opts = {}) {
|
|
42
40
|
var _a;
|
|
43
41
|
const { method = "GET", body, query } = opts;
|
|
44
42
|
let url = path;
|
|
@@ -76,12 +74,9 @@ const DEFAULT_FORM$1 = {
|
|
|
76
74
|
brandName: "PayPal",
|
|
77
75
|
landingPage: "no_preference",
|
|
78
76
|
requireInstantPayment: false,
|
|
79
|
-
useShippingAsBilling: true,
|
|
80
77
|
sendItemDetails: true,
|
|
81
|
-
skipOrderReviewPage: true,
|
|
82
78
|
invoicePrefix: "WC-",
|
|
83
79
|
creditCardStatementName: "PayPal",
|
|
84
|
-
enableLogging: true,
|
|
85
80
|
logPath: "/uploads/wc-logs/"
|
|
86
81
|
};
|
|
87
82
|
function mergeWithDefaults$1(saved) {
|
|
@@ -122,7 +117,7 @@ function AdditionalSettingsTab() {
|
|
|
122
117
|
(async () => {
|
|
123
118
|
try {
|
|
124
119
|
setLoading(true);
|
|
125
|
-
const json = await adminFetch$
|
|
120
|
+
const json = await adminFetch$2("/admin/paypal/settings");
|
|
126
121
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
127
122
|
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
128
123
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
@@ -136,7 +131,7 @@ function AdditionalSettingsTab() {
|
|
|
136
131
|
try {
|
|
137
132
|
setSaving(true);
|
|
138
133
|
setToast(null);
|
|
139
|
-
const json = await adminFetch$
|
|
134
|
+
const json = await adminFetch$2("/admin/paypal/settings", { method: "POST", body: { additional_settings: form } });
|
|
140
135
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
141
136
|
const saved = payload == null ? void 0 : payload.additional_settings;
|
|
142
137
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
|
|
@@ -157,7 +152,7 @@ function AdditionalSettingsTab() {
|
|
|
157
152
|
SectionCard$2,
|
|
158
153
|
{
|
|
159
154
|
title: "Additional Settings",
|
|
160
|
-
description: "These settings control checkout behavior
|
|
155
|
+
description: "These settings control checkout behavior and PayPal experience.",
|
|
161
156
|
right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
162
157
|
/* @__PURE__ */ 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" }),
|
|
163
158
|
loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading..." }) : null
|
|
@@ -177,36 +172,18 @@ function AdditionalSettingsTab() {
|
|
|
177
172
|
/* @__PURE__ */ 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" }),
|
|
178
173
|
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Require Instant Payment" })
|
|
179
174
|
] }) }),
|
|
180
|
-
/* @__PURE__ */ 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__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
181
|
-
/* @__PURE__ */ 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" }),
|
|
182
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Use PayPal Shipping Address as Billing" })
|
|
183
|
-
] }) }),
|
|
184
175
|
/* @__PURE__ */ 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__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
185
176
|
/* @__PURE__ */ 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" }),
|
|
186
177
|
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Send line item details to PayPal" })
|
|
187
178
|
] }) }),
|
|
188
|
-
/* @__PURE__ */ 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__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
189
|
-
/* @__PURE__ */ 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" }),
|
|
190
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Skip Order Review Page" })
|
|
191
|
-
] }) }),
|
|
192
179
|
/* @__PURE__ */ jsx(FieldRow$2, { label: "Invoice prefix", children: /* @__PURE__ */ 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-" }) }),
|
|
193
|
-
/* @__PURE__ */ jsx(FieldRow$2, { label: "Credit Card Statement Name", children: /* @__PURE__ */ 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" }) })
|
|
194
|
-
/* @__PURE__ */ jsx(FieldRow$2, { label: "Debug log", hint: /* @__PURE__ */ jsxs("span", { children: [
|
|
195
|
-
"Log PayPal events such as Webhook, Payment, Refund. ",
|
|
196
|
-
form.logPath ? /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
197
|
-
"Log location: ",
|
|
198
|
-
/* @__PURE__ */ jsx("span", { className: "font-mono", children: form.logPath })
|
|
199
|
-
] }) : null
|
|
200
|
-
] }), children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
201
|
-
/* @__PURE__ */ 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" }),
|
|
202
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable logging" })
|
|
203
|
-
] }) })
|
|
180
|
+
/* @__PURE__ */ jsx(FieldRow$2, { label: "Credit Card Statement Name", children: /* @__PURE__ */ 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" }) })
|
|
204
181
|
] })
|
|
205
182
|
}
|
|
206
183
|
)
|
|
207
184
|
] }) });
|
|
208
185
|
}
|
|
209
|
-
async function adminFetch$
|
|
186
|
+
async function adminFetch$1(path, opts = {}) {
|
|
210
187
|
var _a;
|
|
211
188
|
const { method = "GET", body, query } = opts;
|
|
212
189
|
let url = path;
|
|
@@ -239,7 +216,7 @@ async function adminFetch$3(path, opts = {}) {
|
|
|
239
216
|
return {};
|
|
240
217
|
}
|
|
241
218
|
}
|
|
242
|
-
const DEFAULT_FORM = { enabled: true, title: "Credit or Debit Card", disabledCards: [], threeDS: "when_required"
|
|
219
|
+
const DEFAULT_FORM = { enabled: true, title: "Credit or Debit Card", disabledCards: [], threeDS: "when_required" };
|
|
243
220
|
function mergeWithDefaults(saved) {
|
|
244
221
|
if (!saved) return { ...DEFAULT_FORM };
|
|
245
222
|
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
@@ -299,7 +276,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
299
276
|
(async () => {
|
|
300
277
|
try {
|
|
301
278
|
setLoading(true);
|
|
302
|
-
const json = await adminFetch$
|
|
279
|
+
const json = await adminFetch$1("/admin/paypal/settings");
|
|
303
280
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
304
281
|
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
305
282
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
@@ -312,7 +289,7 @@ function AdvancedCardPaymentsTab() {
|
|
|
312
289
|
async function onSave() {
|
|
313
290
|
try {
|
|
314
291
|
setSaving(true);
|
|
315
|
-
const json = await adminFetch$
|
|
292
|
+
const json = await adminFetch$1("/admin/paypal/settings", { method: "POST", body: { advanced_card_payments: form } });
|
|
316
293
|
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
317
294
|
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
318
295
|
if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
|
|
@@ -367,10 +344,6 @@ function AdvancedCardPaymentsTab() {
|
|
|
367
344
|
/* @__PURE__ */ jsx(FieldRow$1, { label: "Contingency for 3D Secure", hint: "Choose when 3D Secure should be triggered during card payments.", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
368
345
|
/* @__PURE__ */ 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__ */ jsx("option", { value: o.value, children: o.label }, o.value)) }),
|
|
369
346
|
((_a = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _a.hint) ? /* @__PURE__ */ 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
|
|
370
|
-
] }) }),
|
|
371
|
-
/* @__PURE__ */ jsx(FieldRow$1, { label: "Card Save Enabled", hint: "Allow customers to save a card at checkout for future use.", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
372
|
-
/* @__PURE__ */ 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" }),
|
|
373
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable card saving at checkout" })
|
|
374
347
|
] }) })
|
|
375
348
|
] })
|
|
376
349
|
}
|
|
@@ -380,95 +353,6 @@ function AdvancedCardPaymentsTab() {
|
|
|
380
353
|
function PayPalApplePayPage() {
|
|
381
354
|
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
382
355
|
}
|
|
383
|
-
async function adminFetch$2(path, opts = {}) {
|
|
384
|
-
var _a;
|
|
385
|
-
const { method = "GET", body, query } = opts;
|
|
386
|
-
let url = path;
|
|
387
|
-
if (query && Object.keys(query).length > 0) {
|
|
388
|
-
const params = new URLSearchParams(query);
|
|
389
|
-
url = `${path}?${params.toString()}`;
|
|
390
|
-
}
|
|
391
|
-
const headers = { Accept: "application/json" };
|
|
392
|
-
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
393
|
-
if (typeof window !== "undefined") {
|
|
394
|
-
const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
|
|
395
|
-
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
396
|
-
}
|
|
397
|
-
const res = await fetch(url, {
|
|
398
|
-
method,
|
|
399
|
-
headers,
|
|
400
|
-
credentials: "include",
|
|
401
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
402
|
-
});
|
|
403
|
-
const text = await res.text().catch(() => "");
|
|
404
|
-
if (!res.ok) {
|
|
405
|
-
if (res.status === 401) throw new Error("Unauthorized (401) - session may have expired. Please reload and log in again.");
|
|
406
|
-
if (res.status === 403) throw new Error("Forbidden (403) - you do not have permission to perform this action.");
|
|
407
|
-
throw new Error(text || `Request failed with status ${res.status}`);
|
|
408
|
-
}
|
|
409
|
-
if (!text) return {};
|
|
410
|
-
try {
|
|
411
|
-
return JSON.parse(text);
|
|
412
|
-
} catch {
|
|
413
|
-
return {};
|
|
414
|
-
}
|
|
415
|
-
}
|
|
416
|
-
function formatDate$1(value) {
|
|
417
|
-
if (!value) return "";
|
|
418
|
-
const parsed = new Date(value);
|
|
419
|
-
if (Number.isNaN(parsed.getTime())) return value;
|
|
420
|
-
return parsed.toLocaleString();
|
|
421
|
-
}
|
|
422
|
-
function PayPalAuditLogsPage() {
|
|
423
|
-
const [logs, setLogs] = useState([]);
|
|
424
|
-
const [loading, setLoading] = useState(false);
|
|
425
|
-
const [error, setError] = useState(null);
|
|
426
|
-
const fetchLogs = useCallback(async () => {
|
|
427
|
-
try {
|
|
428
|
-
setLoading(true);
|
|
429
|
-
setError(null);
|
|
430
|
-
const data = await adminFetch$2("/admin/paypal/audit-logs", { query: { limit: "50" } });
|
|
431
|
-
setLogs((data == null ? void 0 : data.logs) ?? []);
|
|
432
|
-
} catch (fetchError) {
|
|
433
|
-
setError(fetchError instanceof Error ? fetchError.message : "Failed to load audit logs.");
|
|
434
|
-
setLogs([]);
|
|
435
|
-
} finally {
|
|
436
|
-
setLoading(false);
|
|
437
|
-
}
|
|
438
|
-
}, []);
|
|
439
|
-
useEffect(() => {
|
|
440
|
-
fetchLogs();
|
|
441
|
-
}, [fetchLogs]);
|
|
442
|
-
return /* @__PURE__ */ jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
443
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
444
|
-
/* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Audit Logs" }),
|
|
445
|
-
/* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-ui-fg-subtle", children: "Track administrative changes and credential events for PayPal configuration." })
|
|
446
|
-
] }),
|
|
447
|
-
/* @__PURE__ */ jsx(PayPalTabs, {}),
|
|
448
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
449
|
-
/* @__PURE__ */ jsx("div", { className: "border-b border-ui-border-base p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-4", children: [
|
|
450
|
-
/* @__PURE__ */ jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: "Latest events" }),
|
|
451
|
-
/* @__PURE__ */ 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" })
|
|
452
|
-
] }) }),
|
|
453
|
-
/* @__PURE__ */ jsxs("div", { className: "p-4", children: [
|
|
454
|
-
error ? /* @__PURE__ */ jsx("div", { className: "rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error }) : null,
|
|
455
|
-
!error && logs.length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-sm text-ui-fg-subtle", children: loading ? "Loading audit logs..." : "No audit log entries found yet." }) : null,
|
|
456
|
-
logs.length > 0 ? /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full text-left text-sm", children: [
|
|
457
|
-
/* @__PURE__ */ jsx("thead", { className: "text-ui-fg-muted", children: /* @__PURE__ */ jsxs("tr", { children: [
|
|
458
|
-
/* @__PURE__ */ jsx("th", { className: "pb-2 pr-4 font-medium", children: "Timestamp" }),
|
|
459
|
-
/* @__PURE__ */ jsx("th", { className: "pb-2 pr-4 font-medium", children: "Event" }),
|
|
460
|
-
/* @__PURE__ */ jsx("th", { className: "pb-2 font-medium", children: "Details" })
|
|
461
|
-
] }) }),
|
|
462
|
-
/* @__PURE__ */ jsx("tbody", { children: logs.map((entry) => /* @__PURE__ */ jsxs("tr", { className: "border-t border-ui-border-base", children: [
|
|
463
|
-
/* @__PURE__ */ jsx("td", { className: "py-3 pr-4 text-ui-fg-base", children: formatDate$1(entry.created_at) || "—" }),
|
|
464
|
-
/* @__PURE__ */ jsx("td", { className: "py-3 pr-4 text-ui-fg-base", children: entry.event_type || "—" }),
|
|
465
|
-
/* @__PURE__ */ jsx("td", { className: "py-3 text-ui-fg-subtle", children: /* @__PURE__ */ 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) }) })
|
|
466
|
-
] }, entry.id)) })
|
|
467
|
-
] }) }) : null
|
|
468
|
-
] })
|
|
469
|
-
] })
|
|
470
|
-
] }) });
|
|
471
|
-
}
|
|
472
356
|
const config = defineRouteConfig({
|
|
473
357
|
label: "PayPal Connection",
|
|
474
358
|
hide: true
|
|
@@ -1059,126 +943,6 @@ function PayPalGooglePayPage() {
|
|
|
1059
943
|
function PayPalPayLaterMessagingPage() {
|
|
1060
944
|
return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
1061
945
|
}
|
|
1062
|
-
async function adminFetch$1(path, opts = {}) {
|
|
1063
|
-
var _a;
|
|
1064
|
-
const { method = "GET", body, query } = opts;
|
|
1065
|
-
let url = path;
|
|
1066
|
-
if (query && Object.keys(query).length > 0) {
|
|
1067
|
-
const params = new URLSearchParams(query);
|
|
1068
|
-
url = `${path}?${params.toString()}`;
|
|
1069
|
-
}
|
|
1070
|
-
const headers = { Accept: "application/json" };
|
|
1071
|
-
if (body !== void 0) headers["Content-Type"] = "application/json";
|
|
1072
|
-
if (typeof window !== "undefined") {
|
|
1073
|
-
const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
|
|
1074
|
-
if (token) headers["Authorization"] = `Bearer ${token}`;
|
|
1075
|
-
}
|
|
1076
|
-
const res = await fetch(url, {
|
|
1077
|
-
method,
|
|
1078
|
-
headers,
|
|
1079
|
-
credentials: "include",
|
|
1080
|
-
body: body !== void 0 ? JSON.stringify(body) : void 0
|
|
1081
|
-
});
|
|
1082
|
-
const text = await res.text().catch(() => "");
|
|
1083
|
-
if (!res.ok) {
|
|
1084
|
-
if (res.status === 401) throw new Error("Unauthorized (401) - session may have expired. Please reload and log in again.");
|
|
1085
|
-
if (res.status === 403) throw new Error("Forbidden (403) - you do not have permission to perform this action.");
|
|
1086
|
-
throw new Error(text || `Request failed with status ${res.status}`);
|
|
1087
|
-
}
|
|
1088
|
-
if (!text) return {};
|
|
1089
|
-
try {
|
|
1090
|
-
return JSON.parse(text);
|
|
1091
|
-
} catch {
|
|
1092
|
-
return {};
|
|
1093
|
-
}
|
|
1094
|
-
}
|
|
1095
|
-
function formatDate(value) {
|
|
1096
|
-
if (!value) return "—";
|
|
1097
|
-
const parsed = new Date(value);
|
|
1098
|
-
if (Number.isNaN(parsed.getTime())) return value;
|
|
1099
|
-
return parsed.toLocaleString();
|
|
1100
|
-
}
|
|
1101
|
-
function PayPalReconciliationStatusPage() {
|
|
1102
|
-
const [status, setStatus] = useState({});
|
|
1103
|
-
const [loading, setLoading] = useState(false);
|
|
1104
|
-
const [error, setError] = useState(null);
|
|
1105
|
-
const fetchStatus = useCallback(async () => {
|
|
1106
|
-
try {
|
|
1107
|
-
setLoading(true);
|
|
1108
|
-
setError(null);
|
|
1109
|
-
const data = await adminFetch$1("/admin/paypal/reconciliation-status");
|
|
1110
|
-
setStatus((data == null ? void 0 : data.status) ?? {});
|
|
1111
|
-
} catch (fetchError) {
|
|
1112
|
-
setError(fetchError instanceof Error ? fetchError.message : "Failed to load reconciliation status.");
|
|
1113
|
-
setStatus({});
|
|
1114
|
-
} finally {
|
|
1115
|
-
setLoading(false);
|
|
1116
|
-
}
|
|
1117
|
-
}, []);
|
|
1118
|
-
useEffect(() => {
|
|
1119
|
-
fetchStatus();
|
|
1120
|
-
}, [fetchStatus]);
|
|
1121
|
-
return /* @__PURE__ */ jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
1122
|
-
/* @__PURE__ */ jsxs("div", { children: [
|
|
1123
|
-
/* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Reconciliation Status" }),
|
|
1124
|
-
/* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-ui-fg-subtle", children: "Monitor reconciliation health and drift detection for PayPal payment sessions." })
|
|
1125
|
-
] }),
|
|
1126
|
-
/* @__PURE__ */ jsx(PayPalTabs, {}),
|
|
1127
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
1128
|
-
/* @__PURE__ */ jsx("div", { className: "border-b border-ui-border-base p-4", children: /* @__PURE__ */ jsxs("div", { className: "flex items-center justify-between gap-4", children: [
|
|
1129
|
-
/* @__PURE__ */ jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: "Latest reconciliation run" }),
|
|
1130
|
-
/* @__PURE__ */ 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" })
|
|
1131
|
-
] }) }),
|
|
1132
|
-
/* @__PURE__ */ jsxs("div", { className: "p-4", children: [
|
|
1133
|
-
error ? /* @__PURE__ */ jsx("div", { className: "rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error }) : null,
|
|
1134
|
-
!error && Object.keys(status).length === 0 ? /* @__PURE__ */ jsx("div", { className: "text-sm text-ui-fg-subtle", children: loading ? "Loading reconciliation status..." : "No reconciliation data yet." }) : null,
|
|
1135
|
-
Object.keys(status).length > 0 ? /* @__PURE__ */ jsxs("div", { className: "grid gap-4 text-sm text-ui-fg-base md:grid-cols-2", children: [
|
|
1136
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1137
|
-
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last run" }),
|
|
1138
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: formatDate(status.last_run_at) })
|
|
1139
|
-
] }),
|
|
1140
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1141
|
-
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last run status" }),
|
|
1142
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1 font-medium capitalize", children: status.last_run_status || "—" })
|
|
1143
|
-
] }),
|
|
1144
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1145
|
-
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last success" }),
|
|
1146
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: formatDate(status.last_success_at) })
|
|
1147
|
-
] }),
|
|
1148
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1149
|
-
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last failure" }),
|
|
1150
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: formatDate(status.last_failure_at) })
|
|
1151
|
-
] }),
|
|
1152
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1153
|
-
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Sessions checked" }),
|
|
1154
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.sessions_checked ?? 0 })
|
|
1155
|
-
] }),
|
|
1156
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1157
|
-
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Sessions updated" }),
|
|
1158
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.sessions_updated ?? 0 })
|
|
1159
|
-
] }),
|
|
1160
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1161
|
-
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Drift detections" }),
|
|
1162
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.drift_count ?? 0 })
|
|
1163
|
-
] }),
|
|
1164
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
|
|
1165
|
-
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last drift order" }),
|
|
1166
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.last_drift_order_id || "—" }),
|
|
1167
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: formatDate(status.last_drift_at) })
|
|
1168
|
-
] }),
|
|
1169
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3 md:col-span-2", children: [
|
|
1170
|
-
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last error" }),
|
|
1171
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.last_error || "No errors recorded." })
|
|
1172
|
-
] }),
|
|
1173
|
-
/* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3 md:col-span-2", children: [
|
|
1174
|
-
/* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Total runs" }),
|
|
1175
|
-
/* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.runs ?? 0 })
|
|
1176
|
-
] })
|
|
1177
|
-
] }) : null
|
|
1178
|
-
] })
|
|
1179
|
-
] })
|
|
1180
|
-
] }) });
|
|
1181
|
-
}
|
|
1182
946
|
async function adminFetch(path, opts = {}) {
|
|
1183
947
|
var _a;
|
|
1184
948
|
const { method = "GET", body, query } = opts;
|
|
@@ -1212,13 +976,6 @@ async function adminFetch(path, opts = {}) {
|
|
|
1212
976
|
return {};
|
|
1213
977
|
}
|
|
1214
978
|
}
|
|
1215
|
-
const DISPLAY_LOCATION_OPTIONS = [
|
|
1216
|
-
{ value: "product", label: "Product Page" },
|
|
1217
|
-
{ value: "cart", label: "Cart Page" },
|
|
1218
|
-
{ value: "express", label: "Express Checkout" },
|
|
1219
|
-
{ value: "checkout", label: "Checkout Page", disabled: true, hint: "Locked by PayPal eligibility / checkout config" },
|
|
1220
|
-
{ value: "mini_cart", label: "Mini Cart (Side Cart)" }
|
|
1221
|
-
];
|
|
1222
979
|
const DISABLE_BUTTON_OPTIONS = [
|
|
1223
980
|
{ value: "paypal", label: "PayPal" },
|
|
1224
981
|
{ value: "paylater", label: "Pay Later" },
|
|
@@ -1324,7 +1081,6 @@ function PayPalSettingsTab() {
|
|
|
1324
1081
|
enabled: true,
|
|
1325
1082
|
title: "PayPal",
|
|
1326
1083
|
description: "Pay via PayPal; you can pay with your credit card if you don't have a PayPal account",
|
|
1327
|
-
displayOn: ["product", "cart", "express", "mini_cart"],
|
|
1328
1084
|
disableButtons: [],
|
|
1329
1085
|
buttonColor: "gold",
|
|
1330
1086
|
buttonShape: "rect",
|
|
@@ -1395,7 +1151,6 @@ function PayPalSettingsTab() {
|
|
|
1395
1151
|
setSaving(false);
|
|
1396
1152
|
}
|
|
1397
1153
|
}
|
|
1398
|
-
useMemo(() => new Map(DISPLAY_LOCATION_OPTIONS.map((o) => [o.value, o])), []);
|
|
1399
1154
|
function toggleMulti(key, value) {
|
|
1400
1155
|
setForm((prev) => {
|
|
1401
1156
|
const list = prev[key] || [];
|
|
@@ -1429,7 +1184,7 @@ function PayPalSettingsTab() {
|
|
|
1429
1184
|
SectionCard,
|
|
1430
1185
|
{
|
|
1431
1186
|
title: "PayPal Settings",
|
|
1432
|
-
description: "Enable PayPal
|
|
1187
|
+
description: "Enable PayPal and configure checkout title/description.",
|
|
1433
1188
|
right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1434
1189
|
/* @__PURE__ */ jsx(
|
|
1435
1190
|
"button",
|
|
@@ -1473,60 +1228,7 @@ function PayPalSettingsTab() {
|
|
|
1473
1228
|
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",
|
|
1474
1229
|
placeholder: "Pay via PayPal..."
|
|
1475
1230
|
}
|
|
1476
|
-
) })
|
|
1477
|
-
/* @__PURE__ */ jsx(
|
|
1478
|
-
FieldRow,
|
|
1479
|
-
{
|
|
1480
|
-
label: "Display PayPal Buttons On",
|
|
1481
|
-
hint: "Choose where PayPal Smart Buttons should render.",
|
|
1482
|
-
children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
1483
|
-
/* @__PURE__ */ jsxs("div", { className: "flex flex-wrap gap-2", children: [
|
|
1484
|
-
DISPLAY_LOCATION_OPTIONS.filter((o) => form.displayOn.includes(o.value)).map((o) => /* @__PURE__ */ jsxs(
|
|
1485
|
-
Pill,
|
|
1486
|
-
{
|
|
1487
|
-
disabled: o.disabled,
|
|
1488
|
-
onRemove: o.disabled ? void 0 : () => removeMulti("displayOn", o.value),
|
|
1489
|
-
children: [
|
|
1490
|
-
o.label,
|
|
1491
|
-
o.disabled ? /* @__PURE__ */ jsx("span", { className: "ml-1 rounded bg-ui-bg-subtle px-1 py-[1px] text-[10px] text-ui-fg-subtle", children: "Locked" }) : null
|
|
1492
|
-
]
|
|
1493
|
-
},
|
|
1494
|
-
o.value
|
|
1495
|
-
)),
|
|
1496
|
-
form.displayOn.length === 0 ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "No locations selected." }) : null
|
|
1497
|
-
] }),
|
|
1498
|
-
/* @__PURE__ */ jsx("div", { className: "rounded-md border border-ui-border-base p-3", children: /* @__PURE__ */ jsx("div", { className: "grid gap-2 md:grid-cols-2", children: DISPLAY_LOCATION_OPTIONS.map((o) => {
|
|
1499
|
-
const checked = form.displayOn.includes(o.value);
|
|
1500
|
-
return /* @__PURE__ */ jsxs(
|
|
1501
|
-
"label",
|
|
1502
|
-
{
|
|
1503
|
-
className: cx(
|
|
1504
|
-
"flex items-start gap-2 rounded-md p-2",
|
|
1505
|
-
o.disabled ? "opacity-60" : "hover:bg-ui-bg-subtle"
|
|
1506
|
-
),
|
|
1507
|
-
children: [
|
|
1508
|
-
/* @__PURE__ */ jsx(
|
|
1509
|
-
"input",
|
|
1510
|
-
{
|
|
1511
|
-
type: "checkbox",
|
|
1512
|
-
disabled: o.disabled,
|
|
1513
|
-
checked,
|
|
1514
|
-
onChange: () => toggleMulti("displayOn", o.value),
|
|
1515
|
-
className: "mt-0.5 h-4 w-4 rounded border-ui-border-base"
|
|
1516
|
-
}
|
|
1517
|
-
),
|
|
1518
|
-
/* @__PURE__ */ jsxs("span", { className: "flex flex-col", children: [
|
|
1519
|
-
/* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: o.label }),
|
|
1520
|
-
o.hint ? /* @__PURE__ */ jsx("span", { className: "text-xs text-ui-fg-subtle", children: o.hint }) : null
|
|
1521
|
-
] })
|
|
1522
|
-
]
|
|
1523
|
-
},
|
|
1524
|
-
o.value
|
|
1525
|
-
);
|
|
1526
|
-
}) }) })
|
|
1527
|
-
] })
|
|
1528
|
-
}
|
|
1529
|
-
)
|
|
1231
|
+
) })
|
|
1530
1232
|
] })
|
|
1531
1233
|
}
|
|
1532
1234
|
),
|
|
@@ -1661,10 +1363,6 @@ const routeModule = {
|
|
|
1661
1363
|
Component: PayPalApplePayPage,
|
|
1662
1364
|
path: "/settings/paypal/apple-pay"
|
|
1663
1365
|
},
|
|
1664
|
-
{
|
|
1665
|
-
Component: PayPalAuditLogsPage,
|
|
1666
|
-
path: "/settings/paypal/audit-logs"
|
|
1667
|
-
},
|
|
1668
1366
|
{
|
|
1669
1367
|
Component: PayPalConnectionPage,
|
|
1670
1368
|
path: "/settings/paypal/connection"
|
|
@@ -1677,10 +1375,6 @@ const routeModule = {
|
|
|
1677
1375
|
Component: PayPalPayLaterMessagingPage,
|
|
1678
1376
|
path: "/settings/paypal/pay-later-messaging"
|
|
1679
1377
|
},
|
|
1680
|
-
{
|
|
1681
|
-
Component: PayPalReconciliationStatusPage,
|
|
1682
|
-
path: "/settings/paypal/reconciliation-status"
|
|
1683
|
-
},
|
|
1684
1378
|
{
|
|
1685
1379
|
Component: PayPalSettingsTab,
|
|
1686
1380
|
path: "/settings/paypal/paypal-settings"
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paypal-reconcile.d.ts","sourceRoot":"","sources":["../../../../src/jobs/paypal-reconcile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAchE,wBAA8B,eAAe,CAAC,SAAS,EAAE,eAAe,
|
|
1
|
+
{"version":3,"file":"paypal-reconcile.d.ts","sourceRoot":"","sources":["../../../../src/jobs/paypal-reconcile.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,2BAA2B,CAAA;AAchE,wBAA8B,eAAe,CAAC,SAAS,EAAE,eAAe,iBA6FvE;AAED,eAAO,MAAM,MAAM;;;CAGlB,CAAA"}
|
|
@@ -27,13 +27,6 @@ async function paypalReconcile(container) {
|
|
|
27
27
|
provider_id: [...provider_ids_1.PAYPAL_PROVIDER_IDS],
|
|
28
28
|
status: ["pending", "authorized"],
|
|
29
29
|
});
|
|
30
|
-
let sessionsChecked = 0;
|
|
31
|
-
let sessionsUpdated = 0;
|
|
32
|
-
let driftCount = 0;
|
|
33
|
-
let lastDriftAt = null;
|
|
34
|
-
let lastDriftOrderId = null;
|
|
35
|
-
let hadFailure = false;
|
|
36
|
-
let lastErrorMessage = null;
|
|
37
30
|
for (const session of sessions || []) {
|
|
38
31
|
const data = (session?.data || {});
|
|
39
32
|
const paypalData = (data.paypal || {});
|
|
@@ -41,7 +34,6 @@ async function paypalReconcile(container) {
|
|
|
41
34
|
if (!orderId) {
|
|
42
35
|
continue;
|
|
43
36
|
}
|
|
44
|
-
sessionsChecked += 1;
|
|
45
37
|
try {
|
|
46
38
|
const order = await paypal.getOrderDetails(orderId);
|
|
47
39
|
const status = STATUS_MAP[String(order?.status || "").toUpperCase()];
|
|
@@ -50,9 +42,6 @@ async function paypalReconcile(container) {
|
|
|
50
42
|
}
|
|
51
43
|
const previousStatus = session?.status;
|
|
52
44
|
if (previousStatus && previousStatus !== status) {
|
|
53
|
-
driftCount += 1;
|
|
54
|
-
lastDriftAt = new Date().toISOString();
|
|
55
|
-
lastDriftOrderId = orderId;
|
|
56
45
|
await paypal.recordPaymentLog("reconcile_drift", {
|
|
57
46
|
session_id: session.id,
|
|
58
47
|
order_id: orderId,
|
|
@@ -88,7 +77,6 @@ async function paypalReconcile(container) {
|
|
|
88
77
|
},
|
|
89
78
|
},
|
|
90
79
|
});
|
|
91
|
-
sessionsUpdated += 1;
|
|
92
80
|
try {
|
|
93
81
|
await paypal.recordMetric("reconcile_success");
|
|
94
82
|
}
|
|
@@ -97,8 +85,6 @@ async function paypalReconcile(container) {
|
|
|
97
85
|
}
|
|
98
86
|
}
|
|
99
87
|
catch (error) {
|
|
100
|
-
hadFailure = true;
|
|
101
|
-
lastErrorMessage = error instanceof Error ? error.message : String(error);
|
|
102
88
|
try {
|
|
103
89
|
await paypal.recordMetric("reconcile_failed");
|
|
104
90
|
}
|
|
@@ -115,28 +101,6 @@ async function paypalReconcile(container) {
|
|
|
115
101
|
console.error("[PayPal] reconcile error", error);
|
|
116
102
|
}
|
|
117
103
|
}
|
|
118
|
-
try {
|
|
119
|
-
await paypal.updateReconciliationStatus({
|
|
120
|
-
status: hadFailure ? "failed" : "success",
|
|
121
|
-
sessions_checked: sessionsChecked,
|
|
122
|
-
sessions_updated: sessionsUpdated,
|
|
123
|
-
drift_count: driftCount,
|
|
124
|
-
last_drift_at: lastDriftAt,
|
|
125
|
-
last_drift_order_id: lastDriftOrderId,
|
|
126
|
-
error_message: hadFailure ? lastErrorMessage : null,
|
|
127
|
-
});
|
|
128
|
-
}
|
|
129
|
-
catch (error) {
|
|
130
|
-
await paypal.updateReconciliationStatus({
|
|
131
|
-
status: "failed",
|
|
132
|
-
sessions_checked: sessionsChecked,
|
|
133
|
-
sessions_updated: sessionsUpdated,
|
|
134
|
-
drift_count: driftCount,
|
|
135
|
-
last_drift_at: lastDriftAt,
|
|
136
|
-
last_drift_order_id: lastDriftOrderId,
|
|
137
|
-
error_message: error?.message,
|
|
138
|
-
});
|
|
139
|
-
}
|
|
140
104
|
}
|
|
141
105
|
exports.config = {
|
|
142
106
|
name: "paypal-reconcile",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"paypal-reconcile.js","sourceRoot":"","sources":["../../../../src/jobs/paypal-reconcile.ts"],"names":[],"mappings":";;;AAcA,
|
|
1
|
+
{"version":3,"file":"paypal-reconcile.js","sourceRoot":"","sources":["../../../../src/jobs/paypal-reconcile.ts"],"names":[],"mappings":"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"}
|
|
@@ -2,20 +2,6 @@ import PayPalModuleService from "./service";
|
|
|
2
2
|
export declare const PAYPAL_MODULE = "paypal_onboarding";
|
|
3
3
|
declare const _default: import("@medusajs/types").ModuleExports<typeof PayPalModuleService> & {
|
|
4
4
|
linkable: {
|
|
5
|
-
readonly paypalAuditLog: {
|
|
6
|
-
id: {
|
|
7
|
-
serviceName: "paypal_onboarding";
|
|
8
|
-
field: "paypalAuditLog";
|
|
9
|
-
linkable: "paypal_audit_log_id";
|
|
10
|
-
primaryKey: "id";
|
|
11
|
-
};
|
|
12
|
-
toJSON: () => {
|
|
13
|
-
serviceName: "paypal_onboarding";
|
|
14
|
-
field: "paypalAuditLog";
|
|
15
|
-
linkable: "paypal_audit_log_id";
|
|
16
|
-
primaryKey: "id";
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
5
|
readonly paypalConnection: {
|
|
20
6
|
id: {
|
|
21
7
|
serviceName: "paypal_onboarding";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/paypal/index.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,MAAM,WAAW,CAAA;AAE3C,eAAO,MAAM,aAAa,sBAAsB,CAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/modules/paypal/index.ts"],"names":[],"mappings":"AACA,OAAO,mBAAmB,MAAM,WAAW,CAAA;AAE3C,eAAO,MAAM,aAAa,sBAAsB,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEhD,wBAEE"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { Migration } from "@medusajs/framework/mikro-orm/migrations";
|
|
2
|
+
export declare class Migration20261101090000 extends Migration {
|
|
3
|
+
up(): Promise<void>;
|
|
4
|
+
down(): Promise<void>;
|
|
5
|
+
}
|
|
6
|
+
//# sourceMappingURL=20261101090000_remove_paypal_reconciliation_status.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"20261101090000_remove_paypal_reconciliation_status.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/paypal/migrations/20261101090000_remove_paypal_reconciliation_status.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,0CAA0C,CAAA;AAEpE,qBAAa,uBAAwB,SAAQ,SAAS;IAC9C,EAAE,IAAI,OAAO,CAAC,IAAI,CAAC;IASnB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;CAY5B"}
|