@easypayment/medusa-paypal 0.2.0 → 0.2.2

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.
@@ -629,9 +629,6 @@ function AdvancedCardPaymentsTab() {
629
629
  )
630
630
  ] }) });
631
631
  }
632
- function PayPalApplePayPage() {
633
- return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
634
- }
635
632
  const config = defineRouteConfig({
636
633
  label: "PayPal Connection",
637
634
  hide: true
@@ -1216,13 +1213,98 @@ function PayPalConnectionPage() {
1216
1213
  ` })
1217
1214
  ] });
1218
1215
  }
1216
+ function PayPalApplePayPage() {
1217
+ return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
1218
+ }
1219
+ function formatDate$2(value) {
1220
+ if (!value) {
1221
+ return "";
1222
+ }
1223
+ const parsed = new Date(value);
1224
+ if (Number.isNaN(parsed.getTime())) {
1225
+ return value;
1226
+ }
1227
+ return parsed.toLocaleString();
1228
+ }
1229
+ function PayPalAuditLogsPage() {
1230
+ const [logs, setLogs] = useState([]);
1231
+ const [loading, setLoading] = useState(false);
1232
+ const [error, setError] = useState(null);
1233
+ const fetchLogs = useCallback(async () => {
1234
+ try {
1235
+ setLoading(true);
1236
+ setError(null);
1237
+ const response = await fetch("/admin/paypal/audit-logs?limit=50", {
1238
+ credentials: "include",
1239
+ headers: {
1240
+ Accept: "application/json"
1241
+ }
1242
+ });
1243
+ if (!response.ok) {
1244
+ const message = await response.text().catch(() => "");
1245
+ throw new Error(message || "Failed to load audit logs.");
1246
+ }
1247
+ const data = await response.json().catch(() => ({}));
1248
+ setLogs((data == null ? void 0 : data.logs) || []);
1249
+ } catch (fetchError) {
1250
+ setError((fetchError == null ? void 0 : fetchError.message) || "Failed to load audit logs.");
1251
+ setLogs([]);
1252
+ } finally {
1253
+ setLoading(false);
1254
+ }
1255
+ }, []);
1256
+ useEffect(() => {
1257
+ fetchLogs();
1258
+ }, [fetchLogs]);
1259
+ return /* @__PURE__ */ jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
1260
+ /* @__PURE__ */ jsxs("div", { children: [
1261
+ /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Audit Logs" }),
1262
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-ui-fg-subtle", children: "Track administrative changes and credential events for PayPal configuration." })
1263
+ ] }),
1264
+ /* @__PURE__ */ jsx(PayPalTabs, {}),
1265
+ /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
1266
+ /* @__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: [
1267
+ /* @__PURE__ */ jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: "Latest events" }),
1268
+ /* @__PURE__ */ jsx(
1269
+ "button",
1270
+ {
1271
+ type: "button",
1272
+ onClick: fetchLogs,
1273
+ className: "rounded-md border border-ui-border-base px-3 py-2 text-sm text-ui-fg-base",
1274
+ disabled: loading,
1275
+ children: loading ? "Refreshing..." : "Refresh"
1276
+ }
1277
+ )
1278
+ ] }) }),
1279
+ /* @__PURE__ */ jsxs("div", { className: "p-4", children: [
1280
+ error ? /* @__PURE__ */ jsx("div", { className: "rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error }) : null,
1281
+ !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,
1282
+ logs.length > 0 ? /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full text-left text-sm", children: [
1283
+ /* @__PURE__ */ jsx("thead", { className: "text-ui-fg-muted", children: /* @__PURE__ */ jsxs("tr", { children: [
1284
+ /* @__PURE__ */ jsx("th", { className: "pb-2 pr-4 font-medium", children: "Timestamp" }),
1285
+ /* @__PURE__ */ jsx("th", { className: "pb-2 pr-4 font-medium", children: "Event" }),
1286
+ /* @__PURE__ */ jsx("th", { className: "pb-2 font-medium", children: "Details" })
1287
+ ] }) }),
1288
+ /* @__PURE__ */ jsx("tbody", { children: logs.map((entry) => /* @__PURE__ */ jsxs("tr", { className: "border-t border-ui-border-base", children: [
1289
+ /* @__PURE__ */ jsx("td", { className: "py-3 pr-4 text-ui-fg-base", children: formatDate$2(entry.created_at) || "—" }),
1290
+ /* @__PURE__ */ jsx("td", { className: "py-3 pr-4 text-ui-fg-base", children: entry.event_type || "—" }),
1291
+ /* @__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) }) })
1292
+ ] }, entry.id)) })
1293
+ ] }) }) : null
1294
+ ] })
1295
+ ] })
1296
+ ] }) });
1297
+ }
1298
+ function PayPalGooglePayPage() {
1299
+ return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
1300
+ }
1219
1301
  const EMPTY_FILTERS = {
1220
1302
  dispute_id: "",
1221
1303
  status: "",
1222
1304
  order_id: "",
1223
1305
  cart_id: ""
1224
1306
  };
1225
- function formatDate$2(value) {
1307
+ function formatDate$1(value) {
1226
1308
  if (!value) {
1227
1309
  return "";
1228
1310
  }
@@ -1401,208 +1483,16 @@ function PayPalDisputesPage() {
1401
1483
  /* @__PURE__ */ jsx("td", { className: "px-4 py-3", children: dispute.amount ? `${dispute.amount} ${dispute.currency_code || ""}` : "-" }),
1402
1484
  /* @__PURE__ */ jsx("td", { className: "px-4 py-3", children: dispute.order_id || "-" }),
1403
1485
  /* @__PURE__ */ jsx("td", { className: "px-4 py-3", children: dispute.cart_id || "-" }),
1404
- /* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-ui-fg-subtle", children: formatDate$2(dispute.updated_at || dispute.created_at) })
1486
+ /* @__PURE__ */ jsx("td", { className: "px-4 py-3 text-ui-fg-subtle", children: formatDate$1(dispute.updated_at || dispute.created_at) })
1405
1487
  ] }, dispute.id)) })
1406
1488
  ] }) }),
1407
1489
  error ? /* @__PURE__ */ jsx("div", { className: "border-t border-ui-border-base px-4 py-3 text-sm text-ui-fg-error", children: error }) : null
1408
1490
  ] })
1409
1491
  ] }) });
1410
1492
  }
1411
- function formatDate$1(value) {
1412
- if (!value) {
1413
- return "";
1414
- }
1415
- const parsed = new Date(value);
1416
- if (Number.isNaN(parsed.getTime())) {
1417
- return value;
1418
- }
1419
- return parsed.toLocaleString();
1420
- }
1421
- function PayPalAuditLogsPage() {
1422
- const [logs, setLogs] = useState([]);
1423
- const [loading, setLoading] = useState(false);
1424
- const [error, setError] = useState(null);
1425
- const fetchLogs = useCallback(async () => {
1426
- try {
1427
- setLoading(true);
1428
- setError(null);
1429
- const response = await fetch("/admin/paypal/audit-logs?limit=50", {
1430
- credentials: "include",
1431
- headers: {
1432
- Accept: "application/json"
1433
- }
1434
- });
1435
- if (!response.ok) {
1436
- const message = await response.text().catch(() => "");
1437
- throw new Error(message || "Failed to load audit logs.");
1438
- }
1439
- const data = await response.json().catch(() => ({}));
1440
- setLogs((data == null ? void 0 : data.logs) || []);
1441
- } catch (fetchError) {
1442
- setError((fetchError == null ? void 0 : fetchError.message) || "Failed to load audit logs.");
1443
- setLogs([]);
1444
- } finally {
1445
- setLoading(false);
1446
- }
1447
- }, []);
1448
- useEffect(() => {
1449
- fetchLogs();
1450
- }, [fetchLogs]);
1451
- return /* @__PURE__ */ jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
1452
- /* @__PURE__ */ jsxs("div", { children: [
1453
- /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Audit Logs" }),
1454
- /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-ui-fg-subtle", children: "Track administrative changes and credential events for PayPal configuration." })
1455
- ] }),
1456
- /* @__PURE__ */ jsx(PayPalTabs, {}),
1457
- /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
1458
- /* @__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: [
1459
- /* @__PURE__ */ jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: "Latest events" }),
1460
- /* @__PURE__ */ jsx(
1461
- "button",
1462
- {
1463
- type: "button",
1464
- onClick: fetchLogs,
1465
- className: "rounded-md border border-ui-border-base px-3 py-2 text-sm text-ui-fg-base",
1466
- disabled: loading,
1467
- children: loading ? "Refreshing..." : "Refresh"
1468
- }
1469
- )
1470
- ] }) }),
1471
- /* @__PURE__ */ jsxs("div", { className: "p-4", children: [
1472
- error ? /* @__PURE__ */ jsx("div", { className: "rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error }) : null,
1473
- !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,
1474
- logs.length > 0 ? /* @__PURE__ */ jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxs("table", { className: "min-w-full text-left text-sm", children: [
1475
- /* @__PURE__ */ jsx("thead", { className: "text-ui-fg-muted", children: /* @__PURE__ */ jsxs("tr", { children: [
1476
- /* @__PURE__ */ jsx("th", { className: "pb-2 pr-4 font-medium", children: "Timestamp" }),
1477
- /* @__PURE__ */ jsx("th", { className: "pb-2 pr-4 font-medium", children: "Event" }),
1478
- /* @__PURE__ */ jsx("th", { className: "pb-2 font-medium", children: "Details" })
1479
- ] }) }),
1480
- /* @__PURE__ */ jsx("tbody", { children: logs.map((entry) => /* @__PURE__ */ jsxs("tr", { className: "border-t border-ui-border-base", children: [
1481
- /* @__PURE__ */ jsx("td", { className: "py-3 pr-4 text-ui-fg-base", children: formatDate$1(entry.created_at) || "—" }),
1482
- /* @__PURE__ */ jsx("td", { className: "py-3 pr-4 text-ui-fg-base", children: entry.event_type || "—" }),
1483
- /* @__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) }) })
1484
- ] }, entry.id)) })
1485
- ] }) }) : null
1486
- ] })
1487
- ] })
1488
- ] }) });
1489
- }
1490
- function PayPalGooglePayPage() {
1491
- return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
1492
- }
1493
1493
  function PayPalPayLaterMessagingPage() {
1494
1494
  return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
1495
1495
  }
1496
- function formatDate(value) {
1497
- if (!value) {
1498
- return "—";
1499
- }
1500
- const parsed = new Date(value);
1501
- if (Number.isNaN(parsed.getTime())) {
1502
- return value;
1503
- }
1504
- return parsed.toLocaleString();
1505
- }
1506
- function PayPalReconciliationStatusPage() {
1507
- const [status, setStatus] = useState({});
1508
- const [loading, setLoading] = useState(false);
1509
- const [error, setError] = useState(null);
1510
- const fetchStatus = useCallback(async () => {
1511
- try {
1512
- setLoading(true);
1513
- setError(null);
1514
- const response = await fetch("/admin/paypal/reconciliation-status", {
1515
- credentials: "include",
1516
- headers: {
1517
- Accept: "application/json"
1518
- }
1519
- });
1520
- if (!response.ok) {
1521
- const message = await response.text().catch(() => "");
1522
- throw new Error(message || "Failed to load reconciliation status.");
1523
- }
1524
- const data = await response.json().catch(() => ({}));
1525
- setStatus((data == null ? void 0 : data.status) || {});
1526
- } catch (fetchError) {
1527
- setError((fetchError == null ? void 0 : fetchError.message) || "Failed to load reconciliation status.");
1528
- setStatus({});
1529
- } finally {
1530
- setLoading(false);
1531
- }
1532
- }, []);
1533
- useEffect(() => {
1534
- fetchStatus();
1535
- }, [fetchStatus]);
1536
- return /* @__PURE__ */ jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
1537
- /* @__PURE__ */ jsxs("div", { children: [
1538
- /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Reconciliation Status" }),
1539
- /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-ui-fg-subtle", children: "Monitor reconciliation health and drift detection for PayPal payment sessions." })
1540
- ] }),
1541
- /* @__PURE__ */ jsx(PayPalTabs, {}),
1542
- /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
1543
- /* @__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: [
1544
- /* @__PURE__ */ jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: "Latest reconciliation run" }),
1545
- /* @__PURE__ */ jsx(
1546
- "button",
1547
- {
1548
- type: "button",
1549
- onClick: fetchStatus,
1550
- className: "rounded-md border border-ui-border-base px-3 py-2 text-sm text-ui-fg-base",
1551
- disabled: loading,
1552
- children: loading ? "Refreshing..." : "Refresh"
1553
- }
1554
- )
1555
- ] }) }),
1556
- /* @__PURE__ */ jsxs("div", { className: "p-4", children: [
1557
- error ? /* @__PURE__ */ jsx("div", { className: "rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error }) : null,
1558
- !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,
1559
- Object.keys(status).length > 0 ? /* @__PURE__ */ jsxs("div", { className: "grid gap-4 text-sm text-ui-fg-base md:grid-cols-2", children: [
1560
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
1561
- /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last run" }),
1562
- /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: formatDate(status.last_run_at) })
1563
- ] }),
1564
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
1565
- /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last run status" }),
1566
- /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium capitalize", children: status.last_run_status || "—" })
1567
- ] }),
1568
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
1569
- /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last success" }),
1570
- /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: formatDate(status.last_success_at) })
1571
- ] }),
1572
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
1573
- /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last failure" }),
1574
- /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: formatDate(status.last_failure_at) })
1575
- ] }),
1576
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
1577
- /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Sessions checked" }),
1578
- /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.sessions_checked ?? 0 })
1579
- ] }),
1580
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
1581
- /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Sessions updated" }),
1582
- /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.sessions_updated ?? 0 })
1583
- ] }),
1584
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
1585
- /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Drift detections" }),
1586
- /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.drift_count ?? 0 })
1587
- ] }),
1588
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
1589
- /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last drift order" }),
1590
- /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.last_drift_order_id || "—" }),
1591
- /* @__PURE__ */ jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: formatDate(status.last_drift_at) })
1592
- ] }),
1593
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3 md:col-span-2", children: [
1594
- /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last error" }),
1595
- /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.last_error || "No errors recorded." })
1596
- ] }),
1597
- /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3 md:col-span-2", children: [
1598
- /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Total runs" }),
1599
- /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.runs ?? 0 })
1600
- ] })
1601
- ] }) : null
1602
- ] })
1603
- ] })
1604
- ] }) });
1605
- }
1606
1496
  const DISPLAY_LOCATION_OPTIONS = [
1607
1497
  { value: "product", label: "Product Page" },
1608
1498
  { value: "cart", label: "Cart Page" },
@@ -2040,6 +1930,116 @@ function PayPalSettingsTab() {
2040
1930
  )
2041
1931
  ] }) });
2042
1932
  }
1933
+ function formatDate(value) {
1934
+ if (!value) {
1935
+ return "—";
1936
+ }
1937
+ const parsed = new Date(value);
1938
+ if (Number.isNaN(parsed.getTime())) {
1939
+ return value;
1940
+ }
1941
+ return parsed.toLocaleString();
1942
+ }
1943
+ function PayPalReconciliationStatusPage() {
1944
+ const [status, setStatus] = useState({});
1945
+ const [loading, setLoading] = useState(false);
1946
+ const [error, setError] = useState(null);
1947
+ const fetchStatus = useCallback(async () => {
1948
+ try {
1949
+ setLoading(true);
1950
+ setError(null);
1951
+ const response = await fetch("/admin/paypal/reconciliation-status", {
1952
+ credentials: "include",
1953
+ headers: {
1954
+ Accept: "application/json"
1955
+ }
1956
+ });
1957
+ if (!response.ok) {
1958
+ const message = await response.text().catch(() => "");
1959
+ throw new Error(message || "Failed to load reconciliation status.");
1960
+ }
1961
+ const data = await response.json().catch(() => ({}));
1962
+ setStatus((data == null ? void 0 : data.status) || {});
1963
+ } catch (fetchError) {
1964
+ setError((fetchError == null ? void 0 : fetchError.message) || "Failed to load reconciliation status.");
1965
+ setStatus({});
1966
+ } finally {
1967
+ setLoading(false);
1968
+ }
1969
+ }, []);
1970
+ useEffect(() => {
1971
+ fetchStatus();
1972
+ }, [fetchStatus]);
1973
+ return /* @__PURE__ */ jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
1974
+ /* @__PURE__ */ jsxs("div", { children: [
1975
+ /* @__PURE__ */ jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Reconciliation Status" }),
1976
+ /* @__PURE__ */ jsx("p", { className: "mt-1 text-sm text-ui-fg-subtle", children: "Monitor reconciliation health and drift detection for PayPal payment sessions." })
1977
+ ] }),
1978
+ /* @__PURE__ */ jsx(PayPalTabs, {}),
1979
+ /* @__PURE__ */ jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
1980
+ /* @__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: [
1981
+ /* @__PURE__ */ jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: "Latest reconciliation run" }),
1982
+ /* @__PURE__ */ jsx(
1983
+ "button",
1984
+ {
1985
+ type: "button",
1986
+ onClick: fetchStatus,
1987
+ className: "rounded-md border border-ui-border-base px-3 py-2 text-sm text-ui-fg-base",
1988
+ disabled: loading,
1989
+ children: loading ? "Refreshing..." : "Refresh"
1990
+ }
1991
+ )
1992
+ ] }) }),
1993
+ /* @__PURE__ */ jsxs("div", { className: "p-4", children: [
1994
+ error ? /* @__PURE__ */ jsx("div", { className: "rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error }) : null,
1995
+ !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,
1996
+ Object.keys(status).length > 0 ? /* @__PURE__ */ jsxs("div", { className: "grid gap-4 text-sm text-ui-fg-base md:grid-cols-2", children: [
1997
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
1998
+ /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last run" }),
1999
+ /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: formatDate(status.last_run_at) })
2000
+ ] }),
2001
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
2002
+ /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last run status" }),
2003
+ /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium capitalize", children: status.last_run_status || "—" })
2004
+ ] }),
2005
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
2006
+ /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last success" }),
2007
+ /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: formatDate(status.last_success_at) })
2008
+ ] }),
2009
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
2010
+ /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last failure" }),
2011
+ /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: formatDate(status.last_failure_at) })
2012
+ ] }),
2013
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
2014
+ /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Sessions checked" }),
2015
+ /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.sessions_checked ?? 0 })
2016
+ ] }),
2017
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
2018
+ /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Sessions updated" }),
2019
+ /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.sessions_updated ?? 0 })
2020
+ ] }),
2021
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
2022
+ /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Drift detections" }),
2023
+ /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.drift_count ?? 0 })
2024
+ ] }),
2025
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3", children: [
2026
+ /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last drift order" }),
2027
+ /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.last_drift_order_id || "—" }),
2028
+ /* @__PURE__ */ jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: formatDate(status.last_drift_at) })
2029
+ ] }),
2030
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3 md:col-span-2", children: [
2031
+ /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Last error" }),
2032
+ /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.last_error || "No errors recorded." })
2033
+ ] }),
2034
+ /* @__PURE__ */ jsxs("div", { className: "rounded-lg border border-ui-border-base bg-ui-bg-subtle p-3 md:col-span-2", children: [
2035
+ /* @__PURE__ */ jsx("div", { className: "text-ui-fg-subtle", children: "Total runs" }),
2036
+ /* @__PURE__ */ jsx("div", { className: "mt-1 font-medium", children: status.runs ?? 0 })
2037
+ ] })
2038
+ ] }) : null
2039
+ ] })
2040
+ ] })
2041
+ ] }) });
2042
+ }
2043
2043
  const widgetModule = { widgets: [] };
2044
2044
  const routeModule = {
2045
2045
  routes: [
@@ -2055,17 +2055,13 @@ const routeModule = {
2055
2055
  Component: AdvancedCardPaymentsTab,
2056
2056
  path: "/settings/paypal/advanced-card-payments"
2057
2057
  },
2058
- {
2059
- Component: PayPalApplePayPage,
2060
- path: "/settings/paypal/apple-pay"
2061
- },
2062
2058
  {
2063
2059
  Component: PayPalConnectionPage,
2064
2060
  path: "/settings/paypal/connection"
2065
2061
  },
2066
2062
  {
2067
- Component: PayPalDisputesPage,
2068
- path: "/settings/paypal/disputes"
2063
+ Component: PayPalApplePayPage,
2064
+ path: "/settings/paypal/apple-pay"
2069
2065
  },
2070
2066
  {
2071
2067
  Component: PayPalAuditLogsPage,
@@ -2076,16 +2072,20 @@ const routeModule = {
2076
2072
  path: "/settings/paypal/google-pay"
2077
2073
  },
2078
2074
  {
2079
- Component: PayPalPayLaterMessagingPage,
2080
- path: "/settings/paypal/pay-later-messaging"
2075
+ Component: PayPalDisputesPage,
2076
+ path: "/settings/paypal/disputes"
2081
2077
  },
2082
2078
  {
2083
- Component: PayPalReconciliationStatusPage,
2084
- path: "/settings/paypal/reconciliation-status"
2079
+ Component: PayPalPayLaterMessagingPage,
2080
+ path: "/settings/paypal/pay-later-messaging"
2085
2081
  },
2086
2082
  {
2087
2083
  Component: PayPalSettingsTab,
2088
2084
  path: "/settings/paypal/paypal-settings"
2085
+ },
2086
+ {
2087
+ Component: PayPalReconciliationStatusPage,
2088
+ path: "/settings/paypal/reconciliation-status"
2089
2089
  }
2090
2090
  ]
2091
2091
  };
@@ -1 +1 @@
1
- {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../../src/api/store/payment-collections/[id]/payment-sessions/route.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAiB,MAAM,0BAA0B,CAAA;AAO5F,wBAAsB,IAAI,CAAC,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,cAAc,iBAuBtE"}
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../../src/api/store/payment-collections/[id]/payment-sessions/route.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAiB,MAAM,0BAA0B,CAAA;AAc5F,wBAAsB,IAAI,CAAC,GAAG,EAAE,kBAAkB,EAAE,GAAG,EAAE,cAAc,iBAuBtE"}
@@ -3,6 +3,12 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.POST = POST;
4
4
  const core_flows_1 = require("@medusajs/core-flows");
5
5
  const http_1 = require("@medusajs/framework/http");
6
+ const defaultPaymentCollectionFields = [
7
+ "id",
8
+ "currency_code",
9
+ "amount",
10
+ "*payment_sessions",
11
+ ];
6
12
  async function POST(req, res) {
7
13
  const collectionId = req.params.id;
8
14
  const { provider_id, data } = req.body;
@@ -18,7 +24,7 @@ async function POST(req, res) {
18
24
  entity: "payment_collection",
19
25
  idOrFilter: collectionId,
20
26
  scope: req.scope,
21
- fields: req.queryConfig.fields,
27
+ fields: req.queryConfig?.fields ?? defaultPaymentCollectionFields,
22
28
  });
23
29
  res.status(200).json({
24
30
  payment_collection: paymentCollection,
@@ -1 +1 @@
1
- {"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../../src/api/store/payment-collections/[id]/payment-sessions/route.ts"],"names":[],"mappings":";;AAQA,oBAuBC;AA/BD,qDAAoE;AACpE,mDAA4F;AAOrF,KAAK,UAAU,IAAI,CAAC,GAAuB,EAAE,GAAmB;IACrE,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;IAClC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,IAAgC,CAAA;IAElE,MAAM,IAAA,0CAA6B,EAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;QACjD,KAAK,EAAE;YACL,qBAAqB,EAAE,YAAY;YACnC,WAAW;YACX,WAAW,EAAE,GAAG,CAAC,YAAY,EAAE,QAAQ;YACvC,IAAI;SACL;KACF,CAAC,CAAA;IAEF,MAAM,iBAAiB,GAAG,MAAM,IAAA,oBAAa,EAAC;QAC5C,MAAM,EAAE,oBAAoB;QAC5B,UAAU,EAAE,YAAY;QACxB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,MAAM,EAAE,GAAG,CAAC,WAAW,CAAC,MAAM;KAC/B,CAAC,CAAA;IAEF,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;QACnB,kBAAkB,EAAE,iBAAiB;KACtC,CAAC,CAAA;AACJ,CAAC"}
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../../src/api/store/payment-collections/[id]/payment-sessions/route.ts"],"names":[],"mappings":";;AAeA,oBAuBC;AAtCD,qDAAoE;AACpE,mDAA4F;AAO5F,MAAM,8BAA8B,GAAG;IACrC,IAAI;IACJ,eAAe;IACf,QAAQ;IACR,mBAAmB;CACpB,CAAA;AAEM,KAAK,UAAU,IAAI,CAAC,GAAuB,EAAE,GAAmB;IACrE,MAAM,YAAY,GAAG,GAAG,CAAC,MAAM,CAAC,EAAE,CAAA;IAClC,MAAM,EAAE,WAAW,EAAE,IAAI,EAAE,GAAG,GAAG,CAAC,IAAgC,CAAA;IAElE,MAAM,IAAA,0CAA6B,EAAC,GAAG,CAAC,KAAK,CAAC,CAAC,GAAG,CAAC;QACjD,KAAK,EAAE;YACL,qBAAqB,EAAE,YAAY;YACnC,WAAW;YACX,WAAW,EAAE,GAAG,CAAC,YAAY,EAAE,QAAQ;YACvC,IAAI;SACL;KACF,CAAC,CAAA;IAEF,MAAM,iBAAiB,GAAG,MAAM,IAAA,oBAAa,EAAC;QAC5C,MAAM,EAAE,oBAAoB;QAC5B,UAAU,EAAE,YAAY;QACxB,KAAK,EAAE,GAAG,CAAC,KAAK;QAChB,MAAM,EAAE,GAAG,CAAC,WAAW,EAAE,MAAM,IAAI,8BAA8B;KAClE,CAAC,CAAA;IAEF,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC;QACnB,kBAAkB,EAAE,iBAAiB;KACtC,CAAC,CAAA;AACJ,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"service.d.ts","sourceRoot":"","sources":["../../../../../../src/modules/paypal/payment-provider/service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,2BAA2B,CAAA;AAEnE,OAAO,KAAK,EACV,qBAAqB,EACrB,sBAAsB,EACtB,mBAAmB,EACnB,oBAAoB,EACpB,kBAAkB,EAClB,mBAAmB,EACnB,wBAAwB,EACxB,yBAAyB,EACzB,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACrB,sBAAsB,EACtB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,qBAAqB,EACrB,kBAAkB,EAClB,mBAAmB,EACnB,sBAAsB,EACtB,mBAAmB,EACpB,MAAM,2BAA2B,CAAA;AASlC,KAAK,OAAO,GAAG,EAAE,CAAA;AAWjB,cAAM,qBAAsB,SAAQ,uBAAuB,CAAC,OAAO,CAAC;IAClE,MAAM,CAAC,UAAU,SAAW;IAE5B,SAAS,CAAC,QAAQ,CAAC,QAAQ,EAAE,OAAO,CAAA;gBAExB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,OAAO;IAKzD,OAAO,CAAC,oBAAoB;YAOd,eAAe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B,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,sBAAsB,CAAC;IA+I5B,eAAe,CACnB,KAAK,EAAE,oBAAoB,GAC1B,OAAO,CAAC,qBAAqB,CAAC;IAyB3B,gBAAgB,CACpB,KAAK,EAAE,qBAAqB,GAC3B,OAAO,CAAC,sBAAsB,CAAC;IAwC5B,cAAc,CAClB,KAAK,EAAE,mBAAmB,GACzB,OAAO,CAAC,oBAAoB,CAAC;IAgL1B,aAAa,CACjB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,mBAAmB,CAAC;IAiHzB,aAAa,CACjB,KAAK,EAAE,kBAAkB,GACxB,OAAO,CAAC,mBAAmB,CAAC;IAqIzB,aAAa,CACjB,MAAM,EAAE,kBAAkB,GACzB,OAAO,CAAC,mBAAmB,CAAC;IAI/B;;;OAGG;IACG,uBAAuB,CAC3B,OAAO,EAAE,sBAAsB,CAAC,SAAS,CAAC,GACzC,OAAO,CAAC,mBAAmB,CAAC;CAGhC;AAED,eAAe,qBAAqB,CAAA;AACpC,OAAO,EAAE,qBAAqB,EAAE,CAAA"}
@@ -24,10 +24,21 @@ class PayPalPaymentProvider extends utils_1.AbstractPaymentProvider {
24
24
  }
25
25
  resolvePayPalService() {
26
26
  const container = this.container;
27
- return container.resolve("paypal_onboarding");
27
+ try {
28
+ return container.resolve("paypal_onboarding");
29
+ }
30
+ catch {
31
+ return null;
32
+ }
28
33
  }
29
34
  async resolveSettings() {
30
35
  const paypal = this.resolvePayPalService();
36
+ if (!paypal) {
37
+ return {
38
+ additionalSettings: {},
39
+ apiDetails: {},
40
+ };
41
+ }
31
42
  const settings = await paypal.getSettings().catch(() => ({}));
32
43
  const data = settings && typeof settings === "object" && "data" in settings
33
44
  ? (settings.data ?? {})
@@ -46,6 +57,9 @@ class PayPalPaymentProvider extends utils_1.AbstractPaymentProvider {
46
57
  }
47
58
  async getPayPalAccessToken() {
48
59
  const paypal = this.resolvePayPalService();
60
+ if (!paypal) {
61
+ throw new Error("PayPal module service is unavailable. Ensure the PayPal module is registered in Medusa config.");
62
+ }
49
63
  const creds = await paypal.getActiveCredentials();
50
64
  const base = creds.environment === "live"
51
65
  ? "https://api-m.paypal.com"
@@ -178,8 +192,11 @@ class PayPalPaymentProvider extends utils_1.AbstractPaymentProvider {
178
192
  return "pending";
179
193
  }
180
194
  async recordFailure(eventType, metadata) {
195
+ const paypal = this.resolvePayPalService();
196
+ if (!paypal) {
197
+ return;
198
+ }
181
199
  try {
182
- const paypal = this.resolvePayPalService();
183
200
  await paypal.recordPaymentLog(eventType, metadata);
184
201
  await paypal.recordAuditEvent(eventType, metadata);
185
202
  await paypal.recordMetric(eventType);
@@ -189,8 +206,11 @@ class PayPalPaymentProvider extends utils_1.AbstractPaymentProvider {
189
206
  }
190
207
  }
191
208
  async recordSuccess(metricName) {
209
+ const paypal = this.resolvePayPalService();
210
+ if (!paypal) {
211
+ return;
212
+ }
192
213
  try {
193
- const paypal = this.resolvePayPalService();
194
214
  await paypal.recordMetric(metricName);
195
215
  }
196
216
  catch {
@@ -198,8 +218,11 @@ class PayPalPaymentProvider extends utils_1.AbstractPaymentProvider {
198
218
  }
199
219
  }
200
220
  async recordPaymentEvent(eventType, metadata) {
221
+ const paypal = this.resolvePayPalService();
222
+ if (!paypal) {
223
+ return;
224
+ }
201
225
  try {
202
- const paypal = this.resolvePayPalService();
203
226
  await paypal.recordPaymentLog(eventType, metadata);
204
227
  }
205
228
  catch {