order-management 0.0.102 → 0.0.103

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.
@@ -2229,19 +2229,27 @@ const getStatusBadgeClass$7 = (status) => {
2229
2229
  if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2230
2230
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
2231
2231
  };
2232
- const PaymentsPage = () => {
2232
+ const RefundsPage = () => {
2233
2233
  const navigate = reactRouterDom.useNavigate();
2234
2234
  const [items, setItems] = react.useState([]);
2235
- const [statusFilter, setStatusFilter] = react.useState("all");
2236
2235
  const [orderIdSearch, setOrderIdSearch] = react.useState("");
2237
2236
  const debouncedOrderId = useDebounce$3(orderIdSearch, 300);
2237
+ const [paymentStatusFilter, setPaymentStatusFilter] = react.useState("all");
2238
+ const [providerSearch, setProviderSearch] = react.useState("");
2239
+ const debouncedProvider = useDebounce$3(providerSearch, 300);
2240
+ const [currencySearch, setCurrencySearch] = react.useState("");
2241
+ const debouncedCurrency = useDebounce$3(currencySearch, 300);
2242
+ const [dateFrom, setDateFrom] = react.useState("");
2243
+ const [dateTo, setDateTo] = react.useState("");
2244
+ const [amountMin, setAmountMin] = react.useState("");
2245
+ const [amountMax, setAmountMax] = react.useState("");
2238
2246
  const [isLoading, setIsLoading] = react.useState(true);
2239
2247
  const [isFetchingMore, setIsFetchingMore] = react.useState(false);
2240
2248
  const [error, setError] = react.useState(null);
2241
2249
  const [offset, setOffset] = react.useState(0);
2242
2250
  const [count, setCount] = react.useState(0);
2243
2251
  const limit = 50;
2244
- const loadTransactions = react.useCallback(
2252
+ const loadRefunds = react.useCallback(
2245
2253
  async (nextOffset, replace) => {
2246
2254
  try {
2247
2255
  if (replace) setIsLoading(true);
@@ -2250,18 +2258,25 @@ const PaymentsPage = () => {
2250
2258
  const params = new URLSearchParams();
2251
2259
  params.set("limit", String(limit));
2252
2260
  params.set("offset", String(nextOffset));
2253
- if (statusFilter !== "all") params.set("status", statusFilter);
2254
2261
  if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
2255
- const response = await fetch(
2256
- `/admin/payment-transactions?${params.toString()}`,
2257
- { credentials: "include" }
2258
- );
2262
+ if (paymentStatusFilter !== "all") params.set("payment_status", paymentStatusFilter);
2263
+ if (debouncedProvider.trim()) params.set("provider_id", debouncedProvider.trim());
2264
+ if (debouncedCurrency.trim()) params.set("currency_code", debouncedCurrency.trim());
2265
+ if (dateFrom.trim()) params.set("date_from", dateFrom.trim());
2266
+ if (dateTo.trim()) params.set("date_to", dateTo.trim());
2267
+ const min = amountMin.trim() ? Number(amountMin) : void 0;
2268
+ const max = amountMax.trim() ? Number(amountMax) : void 0;
2269
+ if (min != null && !Number.isNaN(min)) params.set("amount_min", String(min));
2270
+ if (max != null && !Number.isNaN(max)) params.set("amount_max", String(max));
2271
+ const response = await fetch(`/admin/refunds?${params.toString()}`, {
2272
+ credentials: "include"
2273
+ });
2259
2274
  if (!response.ok) {
2260
2275
  const text = await response.text();
2261
- throw new Error(text || "Failed to load payment transactions");
2276
+ throw new Error(text || "Failed to load refunds");
2262
2277
  }
2263
2278
  const payload = await response.json();
2264
- const list = payload.transactions ?? [];
2279
+ const list = payload.refunds ?? [];
2265
2280
  setCount(payload.count ?? 0);
2266
2281
  setOffset(nextOffset + list.length);
2267
2282
  setItems((prev) => replace ? list : [...prev, ...list]);
@@ -2272,46 +2287,75 @@ const PaymentsPage = () => {
2272
2287
  setIsFetchingMore(false);
2273
2288
  }
2274
2289
  },
2275
- [statusFilter, debouncedOrderId]
2290
+ [
2291
+ debouncedOrderId,
2292
+ paymentStatusFilter,
2293
+ debouncedProvider,
2294
+ debouncedCurrency,
2295
+ dateFrom,
2296
+ dateTo,
2297
+ amountMin,
2298
+ amountMax
2299
+ ]
2276
2300
  );
2277
2301
  react.useEffect(() => {
2278
- void loadTransactions(0, true);
2279
- }, [loadTransactions]);
2302
+ void loadRefunds(0, true);
2303
+ }, [loadRefunds]);
2280
2304
  const hasMore = react.useMemo(() => offset < count, [offset, count]);
2281
- const displayStatus = (t) => {
2282
- const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
2283
- return s2 !== "" ? s2 : "—";
2305
+ const displayAmount = (r) => {
2306
+ const code = (r.currency_code ?? "USD").toUpperCase();
2307
+ return `${code} ${Number(r.amount)}`;
2284
2308
  };
2285
- const displayAmount = (t) => {
2286
- const code = (t.currency_code ?? "USD").toUpperCase();
2287
- return `${code} ${Number(t.amount)}`;
2309
+ const displayStatus = (r) => {
2310
+ const s2 = r.payment_status ?? "";
2311
+ return s2 !== "" ? s2 : "—";
2288
2312
  };
2289
2313
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
2290
2314
  /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
2291
2315
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
2292
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Payments" }),
2293
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
2316
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Refunds" }),
2317
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Refund records — amount, order, payment status" })
2294
2318
  ] }),
2295
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
2319
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadRefunds(0, true), children: "Refresh" })
2296
2320
  ] }),
2297
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
2321
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
2298
2322
  /* @__PURE__ */ jsxRuntime.jsx(
2299
2323
  ui.Input,
2300
2324
  {
2301
- placeholder: "Search by Order ID",
2325
+ placeholder: "Order ID",
2302
2326
  value: orderIdSearch,
2303
2327
  onChange: (e) => setOrderIdSearch(e.target.value),
2304
- className: "md:max-w-sm",
2305
- "aria-label": "Search by order ID"
2328
+ className: "md:max-w-[180px]",
2329
+ "aria-label": "Filter by order ID"
2306
2330
  }
2307
2331
  ),
2308
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs(
2332
+ /* @__PURE__ */ jsxRuntime.jsx(
2333
+ ui.Input,
2334
+ {
2335
+ placeholder: "Provider",
2336
+ value: providerSearch,
2337
+ onChange: (e) => setProviderSearch(e.target.value),
2338
+ className: "md:max-w-[140px]",
2339
+ "aria-label": "Filter by provider"
2340
+ }
2341
+ ),
2342
+ /* @__PURE__ */ jsxRuntime.jsx(
2343
+ ui.Input,
2344
+ {
2345
+ placeholder: "Currency",
2346
+ value: currencySearch,
2347
+ onChange: (e) => setCurrencySearch(e.target.value),
2348
+ className: "md:max-w-[100px]",
2349
+ "aria-label": "Filter by currency"
2350
+ }
2351
+ ),
2352
+ /* @__PURE__ */ jsxRuntime.jsxs(
2309
2353
  "select",
2310
2354
  {
2311
- value: statusFilter,
2312
- onChange: (e) => setStatusFilter(e.target.value),
2313
- className: "h-9 rounded-md border border-ui-border-base bg-transparent px-3 text-sm text-ui-fg-base outline-none transition focus:ring-2 focus:ring-ui-fg-interactive md:max-w-xs",
2314
- "aria-label": "Filter by status",
2355
+ value: paymentStatusFilter,
2356
+ onChange: (e) => setPaymentStatusFilter(e.target.value),
2357
+ className: "h-9 rounded-md border border-ui-border-base bg-transparent px-3 text-sm text-ui-fg-base outline-none transition focus:ring-2 focus:ring-ui-fg-interactive md:max-w-[160px]",
2358
+ "aria-label": "Filter by payment status",
2315
2359
  children: [
2316
2360
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All statuses" }),
2317
2361
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "pending", children: "Pending" }),
@@ -2322,52 +2366,103 @@ const PaymentsPage = () => {
2322
2366
  /* @__PURE__ */ jsxRuntime.jsx("option", { value: "captured", children: "Captured" })
2323
2367
  ]
2324
2368
  }
2325
- ) })
2326
- ] }),
2369
+ ),
2370
+ /* @__PURE__ */ jsxRuntime.jsx(
2371
+ ui.Input,
2372
+ {
2373
+ type: "date",
2374
+ placeholder: "From",
2375
+ value: dateFrom,
2376
+ onChange: (e) => setDateFrom(e.target.value),
2377
+ className: "md:max-w-[140px]",
2378
+ "aria-label": "Date from"
2379
+ }
2380
+ ),
2381
+ /* @__PURE__ */ jsxRuntime.jsx(
2382
+ ui.Input,
2383
+ {
2384
+ type: "date",
2385
+ placeholder: "To",
2386
+ value: dateTo,
2387
+ onChange: (e) => setDateTo(e.target.value),
2388
+ className: "md:max-w-[140px]",
2389
+ "aria-label": "Date to"
2390
+ }
2391
+ ),
2392
+ /* @__PURE__ */ jsxRuntime.jsx(
2393
+ ui.Input,
2394
+ {
2395
+ placeholder: "Amount min",
2396
+ value: amountMin,
2397
+ onChange: (e) => setAmountMin(e.target.value),
2398
+ type: "number",
2399
+ min: 0,
2400
+ className: "md:max-w-[100px]",
2401
+ "aria-label": "Refund amount minimum"
2402
+ }
2403
+ ),
2404
+ /* @__PURE__ */ jsxRuntime.jsx(
2405
+ ui.Input,
2406
+ {
2407
+ placeholder: "Amount max",
2408
+ value: amountMax,
2409
+ onChange: (e) => setAmountMax(e.target.value),
2410
+ type: "number",
2411
+ min: 0,
2412
+ className: "md:max-w-[100px]",
2413
+ "aria-label": "Refund amount maximum"
2414
+ }
2415
+ )
2416
+ ] }) }),
2327
2417
  error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
2328
2418
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
2329
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
2419
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => loadRefunds(0, true), children: "Try again" }) })
2330
2420
  ] }) : null,
2331
- isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading payments…" }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
2332
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
2333
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
2334
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
2421
+ isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading refunds…" }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
2422
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No refunds yet" }),
2423
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Refund records will appear here." })
2424
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full overflow-x-auto rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full table-fixed divide-y divide-ui-border-base", style: { minWidth: 0 }, children: [
2335
2425
  /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
2336
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
2337
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
2338
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
2339
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
2340
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
2341
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
2342
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
2426
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Refund ID" }),
2427
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
2428
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment ID" }),
2429
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
2430
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[6%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Currency" }),
2431
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
2432
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment Status" }),
2433
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[14%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Note" }),
2434
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
2435
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
2343
2436
  ] }) }),
2344
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxRuntime.jsxs(
2437
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((r) => /* @__PURE__ */ jsxRuntime.jsxs(
2345
2438
  "tr",
2346
2439
  {
2347
- className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
2348
- onClick: () => navigate(`/payments/${t.payment_session_id}`),
2440
+ className: "cursor-pointer hover:bg-ui-bg-subtle/60",
2441
+ onClick: () => navigate(`/refunds/${r.refund_id}`),
2349
2442
  children: [
2350
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
2351
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
2352
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
2353
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
2443
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 font-mono text-sm text-ui-fg-base", title: r.refund_id, children: r.refund_id }),
2444
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 font-medium text-ui-fg-base", title: r.order_id ?? void 0, children: r.order_id ?? "—" }),
2445
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 font-mono text-sm text-ui-fg-subtle", title: r.payment_id, children: r.payment_id }),
2446
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", children: displayAmount(r) }),
2447
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle uppercase", children: r.currency_code || "—" }),
2448
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.provider_id || void 0, children: r.provider_id || "—" }),
2449
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsxRuntime.jsx(
2354
2450
  ui.Badge,
2355
2451
  {
2356
2452
  size: "2xsmall",
2357
- className: `uppercase ${getStatusBadgeClass$7(displayStatus(t))}`,
2358
- children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
2453
+ className: `uppercase ${getStatusBadgeClass$7(displayStatus(r))}`,
2454
+ children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
2359
2455
  }
2360
2456
  ) }),
2361
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
2362
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
2363
- year: "numeric",
2457
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.note ?? void 0, children: r.note ?? "—" }),
2458
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle text-xs", children: new Date(r.created_at).toLocaleDateString("en-US", {
2364
2459
  month: "short",
2365
2460
  day: "numeric",
2366
2461
  hour: "numeric",
2367
2462
  minute: "2-digit",
2368
2463
  hour12: true
2369
2464
  }) }),
2370
- /* @__PURE__ */ jsxRuntime.jsxs("td", { className: "px-4 py-4", children: [
2465
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-1", children: [
2371
2466
  /* @__PURE__ */ jsxRuntime.jsx(
2372
2467
  ui.Button,
2373
2468
  {
@@ -2375,27 +2470,27 @@ const PaymentsPage = () => {
2375
2470
  size: "small",
2376
2471
  onClick: (e) => {
2377
2472
  e.stopPropagation();
2378
- navigate(`/payments/${t.payment_session_id}`);
2473
+ navigate(`/refunds/${r.refund_id}`);
2379
2474
  },
2380
- children: "View details"
2475
+ children: "Details"
2381
2476
  }
2382
2477
  ),
2383
- t.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
2478
+ r.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
2384
2479
  ui.Button,
2385
2480
  {
2386
2481
  variant: "transparent",
2387
2482
  size: "small",
2388
2483
  onClick: (e) => {
2389
2484
  e.stopPropagation();
2390
- navigate(`/orders/${t.order_id}`);
2485
+ navigate(`/orders/${r.order_id}`);
2391
2486
  },
2392
2487
  children: "Order"
2393
2488
  }
2394
2489
  ) : null
2395
- ] })
2490
+ ] }) })
2396
2491
  ]
2397
2492
  },
2398
- t.payment_session_id
2493
+ r.refund_id
2399
2494
  )) })
2400
2495
  ] }) }),
2401
2496
  hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2403,15 +2498,15 @@ const PaymentsPage = () => {
2403
2498
  {
2404
2499
  variant: "secondary",
2405
2500
  isLoading: isFetchingMore,
2406
- onClick: () => loadTransactions(offset, false),
2501
+ onClick: () => loadRefunds(offset, false),
2407
2502
  children: "Load more"
2408
2503
  }
2409
2504
  ) }) : null
2410
2505
  ] }) });
2411
2506
  };
2412
2507
  const config$8 = adminSdk.defineRouteConfig({
2413
- label: "Payments",
2414
- icon: icons.CreditCard
2508
+ label: "Refunds",
2509
+ icon: icons.Receipt
2415
2510
  });
2416
2511
  const useDebounce$2 = (value, delay) => {
2417
2512
  const [debouncedValue, setDebouncedValue] = react.useState(value);
@@ -2429,27 +2524,19 @@ const getStatusBadgeClass$6 = (status) => {
2429
2524
  if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
2430
2525
  return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
2431
2526
  };
2432
- const RefundsPage = () => {
2527
+ const PaymentsPage = () => {
2433
2528
  const navigate = reactRouterDom.useNavigate();
2434
2529
  const [items, setItems] = react.useState([]);
2530
+ const [statusFilter, setStatusFilter] = react.useState("all");
2435
2531
  const [orderIdSearch, setOrderIdSearch] = react.useState("");
2436
2532
  const debouncedOrderId = useDebounce$2(orderIdSearch, 300);
2437
- const [paymentStatusFilter, setPaymentStatusFilter] = react.useState("all");
2438
- const [providerSearch, setProviderSearch] = react.useState("");
2439
- const debouncedProvider = useDebounce$2(providerSearch, 300);
2440
- const [currencySearch, setCurrencySearch] = react.useState("");
2441
- const debouncedCurrency = useDebounce$2(currencySearch, 300);
2442
- const [dateFrom, setDateFrom] = react.useState("");
2443
- const [dateTo, setDateTo] = react.useState("");
2444
- const [amountMin, setAmountMin] = react.useState("");
2445
- const [amountMax, setAmountMax] = react.useState("");
2446
2533
  const [isLoading, setIsLoading] = react.useState(true);
2447
2534
  const [isFetchingMore, setIsFetchingMore] = react.useState(false);
2448
2535
  const [error, setError] = react.useState(null);
2449
2536
  const [offset, setOffset] = react.useState(0);
2450
2537
  const [count, setCount] = react.useState(0);
2451
2538
  const limit = 50;
2452
- const loadRefunds = react.useCallback(
2539
+ const loadTransactions = react.useCallback(
2453
2540
  async (nextOffset, replace) => {
2454
2541
  try {
2455
2542
  if (replace) setIsLoading(true);
@@ -2458,25 +2545,18 @@ const RefundsPage = () => {
2458
2545
  const params = new URLSearchParams();
2459
2546
  params.set("limit", String(limit));
2460
2547
  params.set("offset", String(nextOffset));
2548
+ if (statusFilter !== "all") params.set("status", statusFilter);
2461
2549
  if (debouncedOrderId.trim()) params.set("order_id", debouncedOrderId.trim());
2462
- if (paymentStatusFilter !== "all") params.set("payment_status", paymentStatusFilter);
2463
- if (debouncedProvider.trim()) params.set("provider_id", debouncedProvider.trim());
2464
- if (debouncedCurrency.trim()) params.set("currency_code", debouncedCurrency.trim());
2465
- if (dateFrom.trim()) params.set("date_from", dateFrom.trim());
2466
- if (dateTo.trim()) params.set("date_to", dateTo.trim());
2467
- const min = amountMin.trim() ? Number(amountMin) : void 0;
2468
- const max = amountMax.trim() ? Number(amountMax) : void 0;
2469
- if (min != null && !Number.isNaN(min)) params.set("amount_min", String(min));
2470
- if (max != null && !Number.isNaN(max)) params.set("amount_max", String(max));
2471
- const response = await fetch(`/admin/refunds?${params.toString()}`, {
2472
- credentials: "include"
2473
- });
2550
+ const response = await fetch(
2551
+ `/admin/payment-transactions?${params.toString()}`,
2552
+ { credentials: "include" }
2553
+ );
2474
2554
  if (!response.ok) {
2475
2555
  const text = await response.text();
2476
- throw new Error(text || "Failed to load refunds");
2556
+ throw new Error(text || "Failed to load payment transactions");
2477
2557
  }
2478
2558
  const payload = await response.json();
2479
- const list = payload.refunds ?? [];
2559
+ const list = payload.transactions ?? [];
2480
2560
  setCount(payload.count ?? 0);
2481
2561
  setOffset(nextOffset + list.length);
2482
2562
  setItems((prev) => replace ? list : [...prev, ...list]);
@@ -2487,182 +2567,102 @@ const RefundsPage = () => {
2487
2567
  setIsFetchingMore(false);
2488
2568
  }
2489
2569
  },
2490
- [
2491
- debouncedOrderId,
2492
- paymentStatusFilter,
2493
- debouncedProvider,
2494
- debouncedCurrency,
2495
- dateFrom,
2496
- dateTo,
2497
- amountMin,
2498
- amountMax
2499
- ]
2570
+ [statusFilter, debouncedOrderId]
2500
2571
  );
2501
2572
  react.useEffect(() => {
2502
- void loadRefunds(0, true);
2503
- }, [loadRefunds]);
2573
+ void loadTransactions(0, true);
2574
+ }, [loadTransactions]);
2504
2575
  const hasMore = react.useMemo(() => offset < count, [offset, count]);
2505
- const displayAmount = (r) => {
2506
- const code = (r.currency_code ?? "USD").toUpperCase();
2507
- return `${code} ${Number(r.amount)}`;
2508
- };
2509
- const displayStatus = (r) => {
2510
- const s2 = r.payment_status ?? "";
2576
+ const displayStatus = (t) => {
2577
+ const s2 = t.payment_id != null && t.payment_status != null && t.payment_status !== "" ? t.payment_status : t.session_status ?? "";
2511
2578
  return s2 !== "" ? s2 : "—";
2512
2579
  };
2580
+ const displayAmount = (t) => {
2581
+ const code = (t.currency_code ?? "USD").toUpperCase();
2582
+ return `${code} ${Number(t.amount)}`;
2583
+ };
2513
2584
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-7xl flex-col gap-6 p-6", children: [
2514
2585
  /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
2515
2586
  /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
2516
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Refunds" }),
2517
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "Refund records — amount, order, payment status" })
2587
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Payments" }),
2588
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: "All payment attempts — completed, pending, failed, requires action" })
2518
2589
  ] }),
2519
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadRefunds(0, true), children: "Refresh" })
2590
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", onClick: () => loadTransactions(0, true), children: "Refresh" })
2520
2591
  ] }),
2521
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-center gap-3", children: [
2592
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: [
2522
2593
  /* @__PURE__ */ jsxRuntime.jsx(
2523
2594
  ui.Input,
2524
2595
  {
2525
- placeholder: "Order ID",
2596
+ placeholder: "Search by Order ID",
2526
2597
  value: orderIdSearch,
2527
2598
  onChange: (e) => setOrderIdSearch(e.target.value),
2528
- className: "md:max-w-[180px]",
2529
- "aria-label": "Filter by order ID"
2530
- }
2531
- ),
2532
- /* @__PURE__ */ jsxRuntime.jsx(
2533
- ui.Input,
2534
- {
2535
- placeholder: "Provider",
2536
- value: providerSearch,
2537
- onChange: (e) => setProviderSearch(e.target.value),
2538
- className: "md:max-w-[140px]",
2539
- "aria-label": "Filter by provider"
2540
- }
2541
- ),
2542
- /* @__PURE__ */ jsxRuntime.jsx(
2543
- ui.Input,
2544
- {
2545
- placeholder: "Currency",
2546
- value: currencySearch,
2547
- onChange: (e) => setCurrencySearch(e.target.value),
2548
- className: "md:max-w-[100px]",
2549
- "aria-label": "Filter by currency"
2599
+ className: "md:max-w-sm",
2600
+ "aria-label": "Search by order ID"
2550
2601
  }
2551
2602
  ),
2552
- /* @__PURE__ */ jsxRuntime.jsxs(
2603
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-3", children: /* @__PURE__ */ jsxRuntime.jsxs(
2553
2604
  "select",
2554
2605
  {
2555
- value: paymentStatusFilter,
2556
- onChange: (e) => setPaymentStatusFilter(e.target.value),
2557
- className: "h-9 rounded-md border border-ui-border-base bg-transparent px-3 text-sm text-ui-fg-base outline-none transition focus:ring-2 focus:ring-ui-fg-interactive md:max-w-[160px]",
2558
- "aria-label": "Filter by payment status",
2559
- children: [
2560
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All statuses" }),
2561
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "pending", children: "Pending" }),
2562
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "requires_more", children: "Requires more" }),
2563
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "error", children: "Error" }),
2564
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "canceled", children: "Canceled" }),
2565
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "authorized", children: "Authorized" }),
2566
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "captured", children: "Captured" })
2567
- ]
2568
- }
2569
- ),
2570
- /* @__PURE__ */ jsxRuntime.jsx(
2571
- ui.Input,
2572
- {
2573
- type: "date",
2574
- placeholder: "From",
2575
- value: dateFrom,
2576
- onChange: (e) => setDateFrom(e.target.value),
2577
- className: "md:max-w-[140px]",
2578
- "aria-label": "Date from"
2579
- }
2580
- ),
2581
- /* @__PURE__ */ jsxRuntime.jsx(
2582
- ui.Input,
2583
- {
2584
- type: "date",
2585
- placeholder: "To",
2586
- value: dateTo,
2587
- onChange: (e) => setDateTo(e.target.value),
2588
- className: "md:max-w-[140px]",
2589
- "aria-label": "Date to"
2590
- }
2591
- ),
2592
- /* @__PURE__ */ jsxRuntime.jsx(
2593
- ui.Input,
2594
- {
2595
- placeholder: "Amount min",
2596
- value: amountMin,
2597
- onChange: (e) => setAmountMin(e.target.value),
2598
- type: "number",
2599
- min: 0,
2600
- className: "md:max-w-[100px]",
2601
- "aria-label": "Refund amount minimum"
2602
- }
2603
- ),
2604
- /* @__PURE__ */ jsxRuntime.jsx(
2605
- ui.Input,
2606
- {
2607
- placeholder: "Amount max",
2608
- value: amountMax,
2609
- onChange: (e) => setAmountMax(e.target.value),
2610
- type: "number",
2611
- min: 0,
2612
- className: "md:max-w-[100px]",
2613
- "aria-label": "Refund amount maximum"
2606
+ value: statusFilter,
2607
+ onChange: (e) => setStatusFilter(e.target.value),
2608
+ className: "h-9 rounded-md border border-ui-border-base bg-transparent px-3 text-sm text-ui-fg-base outline-none transition focus:ring-2 focus:ring-ui-fg-interactive md:max-w-xs",
2609
+ "aria-label": "Filter by status",
2610
+ children: [
2611
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "all", children: "All statuses" }),
2612
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "pending", children: "Pending" }),
2613
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "requires_more", children: "Requires more" }),
2614
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "error", children: "Error" }),
2615
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "canceled", children: "Canceled" }),
2616
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "authorized", children: "Authorized" }),
2617
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "captured", children: "Captured" })
2618
+ ]
2614
2619
  }
2615
- )
2616
- ] }) }),
2620
+ ) })
2621
+ ] }),
2617
2622
  error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
2618
2623
  /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
2619
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => loadRefunds(0, true), children: "Try again" }) })
2624
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-4 flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", onClick: () => loadTransactions(0, true), children: "Try again" }) })
2620
2625
  ] }) : null,
2621
- isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading refunds…" }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
2622
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No refunds yet" }),
2623
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Refund records will appear here." })
2624
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full overflow-x-auto rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "w-full table-fixed divide-y divide-ui-border-base", style: { minWidth: 0 }, children: [
2626
+ isLoading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading payments…" }) }) : items.length === 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-dashed border-ui-border-strong p-10 text-center", children: [
2627
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", className: "text-xl", children: "No payment transactions yet" }),
2628
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "mt-2 text-ui-fg-subtle", children: "Payment attempts will appear here." })
2629
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-hidden rounded-xl border border-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full divide-y divide-ui-border-base", children: [
2625
2630
  /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "bg-ui-bg-subtle", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
2626
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Refund ID" }),
2627
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
2628
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment ID" }),
2629
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
2630
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[6%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Currency" }),
2631
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
2632
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[10%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Payment Status" }),
2633
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[14%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Note" }),
2634
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[11%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
2635
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "w-[8%] min-w-0 px-3 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
2631
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Order ID" }),
2632
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Amount" }),
2633
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Provider" }),
2634
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Status" }),
2635
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Finalized" }),
2636
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Created" }),
2637
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "px-4 py-3 text-left text-xs font-semibold uppercase tracking-wide text-ui-fg-muted", children: "Actions" })
2636
2638
  ] }) }),
2637
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((r) => /* @__PURE__ */ jsxRuntime.jsxs(
2639
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { className: "divide-y divide-ui-border-subtle", children: items.map((t) => /* @__PURE__ */ jsxRuntime.jsxs(
2638
2640
  "tr",
2639
2641
  {
2640
- className: "cursor-pointer hover:bg-ui-bg-subtle/60",
2641
- onClick: () => navigate(`/refunds/${r.refund_id}`),
2642
+ className: "hover:bg-ui-bg-subtle/60 cursor-pointer",
2643
+ onClick: () => navigate(`/payments/${t.payment_session_id}`),
2642
2644
  children: [
2643
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 font-mono text-sm text-ui-fg-base", title: r.refund_id, children: r.refund_id }),
2644
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 font-medium text-ui-fg-base", title: r.order_id ?? void 0, children: r.order_id ?? "—" }),
2645
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 font-mono text-sm text-ui-fg-subtle", title: r.payment_id, children: r.payment_id }),
2646
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", children: displayAmount(r) }),
2647
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle uppercase", children: r.currency_code || "—" }),
2648
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.provider_id || void 0, children: r.provider_id || "—" }),
2649
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsxRuntime.jsx(
2645
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 font-medium text-ui-fg-base", children: t.order_id ?? "—" }),
2646
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: displayAmount(t) }),
2647
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.provider_id }),
2648
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4", children: /* @__PURE__ */ jsxRuntime.jsx(
2650
2649
  ui.Badge,
2651
2650
  {
2652
2651
  size: "2xsmall",
2653
- className: `uppercase ${getStatusBadgeClass$6(displayStatus(r))}`,
2654
- children: displayStatus(r) !== "—" ? displayStatus(r).replace(/_/g, " ") : "—"
2652
+ className: `uppercase ${getStatusBadgeClass$6(displayStatus(t))}`,
2653
+ children: displayStatus(t) !== "—" ? displayStatus(t).replace(/_/g, " ") : "—"
2655
2654
  }
2656
2655
  ) }),
2657
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle", title: r.note ?? void 0, children: r.note ?? "—" }),
2658
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 truncate px-3 py-3 text-ui-fg-subtle text-xs", children: new Date(r.created_at).toLocaleDateString("en-US", {
2656
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: t.payment_id != null ? "Yes" : "No" }),
2657
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-4 text-ui-fg-subtle", children: new Date(t.created_at).toLocaleDateString("en-US", {
2658
+ year: "numeric",
2659
2659
  month: "short",
2660
2660
  day: "numeric",
2661
2661
  hour: "numeric",
2662
2662
  minute: "2-digit",
2663
2663
  hour12: true
2664
2664
  }) }),
2665
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "min-w-0 px-3 py-3", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-1", children: [
2665
+ /* @__PURE__ */ jsxRuntime.jsxs("td", { className: "px-4 py-4", children: [
2666
2666
  /* @__PURE__ */ jsxRuntime.jsx(
2667
2667
  ui.Button,
2668
2668
  {
@@ -2670,27 +2670,27 @@ const RefundsPage = () => {
2670
2670
  size: "small",
2671
2671
  onClick: (e) => {
2672
2672
  e.stopPropagation();
2673
- navigate(`/refunds/${r.refund_id}`);
2673
+ navigate(`/payments/${t.payment_session_id}`);
2674
2674
  },
2675
- children: "Details"
2675
+ children: "View details"
2676
2676
  }
2677
2677
  ),
2678
- r.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
2678
+ t.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
2679
2679
  ui.Button,
2680
2680
  {
2681
2681
  variant: "transparent",
2682
2682
  size: "small",
2683
2683
  onClick: (e) => {
2684
2684
  e.stopPropagation();
2685
- navigate(`/orders/${r.order_id}`);
2685
+ navigate(`/orders/${t.order_id}`);
2686
2686
  },
2687
2687
  children: "Order"
2688
2688
  }
2689
2689
  ) : null
2690
- ] }) })
2690
+ ] })
2691
2691
  ]
2692
2692
  },
2693
- r.refund_id
2693
+ t.payment_session_id
2694
2694
  )) })
2695
2695
  ] }) }),
2696
2696
  hasMore ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx(
@@ -2698,15 +2698,15 @@ const RefundsPage = () => {
2698
2698
  {
2699
2699
  variant: "secondary",
2700
2700
  isLoading: isFetchingMore,
2701
- onClick: () => loadRefunds(offset, false),
2701
+ onClick: () => loadTransactions(offset, false),
2702
2702
  children: "Load more"
2703
2703
  }
2704
2704
  ) }) : null
2705
2705
  ] }) });
2706
2706
  };
2707
2707
  const config$7 = adminSdk.defineRouteConfig({
2708
- label: "Refunds",
2709
- icon: icons.Receipt
2708
+ label: "Payments",
2709
+ icon: icons.CreditCard
2710
2710
  });
2711
2711
  const useDebounce$1 = (value, delay) => {
2712
2712
  const [debouncedValue, setDebouncedValue] = react.useState(value);
@@ -3838,207 +3838,89 @@ const DetailContent = ({ audit }) => {
3838
3838
  " ",
3839
3839
  guidance.headline
3840
3840
  ] }),
3841
- /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
3842
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-ui-fg-base", children: "If it needs to come back:" }),
3843
- " ",
3844
- guidance.recreate
3845
- ] }),
3846
- /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
3847
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-ui-fg-base", children: "Need the details?" }),
3848
- " Use “View full record” above to see or copy everything that was stored. Sensitive values stay hidden."
3849
- ] })
3850
- ] }),
3851
- guidance.adminSection || related.length ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-2", children: [
3852
- guidance.adminSection ? /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", onClick: () => navigate(guidance.adminSection.path), children: guidance.adminSection.label }) : null,
3853
- related.map((link) => /* @__PURE__ */ jsxRuntime.jsxs(
3854
- ui.Button,
3855
- {
3856
- variant: "transparent",
3857
- size: "small",
3858
- onClick: () => navigate(link.path),
3859
- title: `Opens ${link.label.toLowerCase()} ${link.id} if it still exists`,
3860
- children: [
3861
- "Open related ",
3862
- link.label.toLowerCase(),
3863
- /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronRightMini, {})
3864
- ]
3865
- },
3866
- link.path
3867
- ))
3868
- ] }) : null,
3869
- related.length ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-ui-fg-muted", children: "Related records open only if they haven’t been deleted too." }) : null
3870
- ] }) })
3871
- ] });
3872
- };
3873
- const Section = ({
3874
- title,
3875
- description,
3876
- actions,
3877
- children
3878
- }) => /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "flex flex-col gap-4 rounded-lg border border-ui-border-base p-5", children: [
3879
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-start justify-between gap-2", children: [
3880
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-0.5", children: [
3881
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", children: title }),
3882
- description ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: description }) : null
3883
- ] }),
3884
- actions
3885
- ] }),
3886
- children
3887
- ] });
3888
- const Field = ({ label, children }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [
3889
- /* @__PURE__ */ jsxRuntime.jsx("dt", { className: "text-xs font-medium uppercase tracking-wide text-ui-fg-muted", children: label }),
3890
- /* @__PURE__ */ jsxRuntime.jsx("dd", { className: "min-w-0", children })
3891
- ] });
3892
- const DetailSkeleton = () => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", "aria-busy": "true", children: [
3893
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
3894
- /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-5 w-24 rounded-full" }),
3895
- /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-8 w-64" }),
3896
- /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-4 w-48" })
3897
- ] }),
3898
- /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-14 w-full" }),
3899
- Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 rounded-lg border border-ui-border-base p-5", children: [
3900
- /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-5 w-40" }),
3901
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: Array.from({ length: 4 }).map((__, j) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
3902
- /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-3 w-20" }),
3903
- /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-4 w-36" })
3904
- ] }, j)) })
3905
- ] }, i))
3906
- ] });
3907
- const DetailError = ({
3908
- notFound,
3909
- message,
3910
- onRetry,
3911
- onBack
3912
- }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-2 rounded-lg border border-ui-border-base px-6 py-12 text-center", children: [
3913
- /* @__PURE__ */ jsxRuntime.jsx(icons.ExclamationCircle, { className: ui.clx(notFound ? "text-ui-fg-muted" : "text-ui-fg-error") }),
3914
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", children: notFound ? "Audit entry not found" : "Unable to load this deleted record" }),
3915
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "max-w-md text-ui-fg-subtle", children: notFound ? "This audit entry doesn’t exist. The link may be incorrect." : "We couldn’t retrieve the audit entry right now. Check your connection and try again." }),
3916
- !notFound ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "max-w-md font-mono text-ui-fg-muted", children: message }) : null,
3917
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 flex gap-2", children: [
3918
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", onClick: onBack, children: "Back to Deleted Records" }),
3919
- !notFound ? /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", size: "small", onClick: onRetry, children: "Try again" }) : null
3920
- ] })
3921
- ] });
3922
- const config$4 = adminSdk.defineRouteConfig({});
3923
- const getStatusBadgeClass$3 = (status) => {
3924
- const s2 = status.toLowerCase();
3925
- if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
3926
- if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
3927
- if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
3928
- if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
3929
- return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
3930
- };
3931
- const PaymentDetailPage = () => {
3932
- const navigate = reactRouterDom.useNavigate();
3933
- const params = reactRouterDom.useParams();
3934
- const id = params?.id?.trim();
3935
- const [detail, setDetail] = react.useState(null);
3936
- const [loading, setLoading] = react.useState(!!id);
3937
- const [error, setError] = react.useState(null);
3938
- react.useEffect(() => {
3939
- if (!id) {
3940
- setLoading(false);
3941
- return;
3942
- }
3943
- let cancelled = false;
3944
- setLoading(true);
3945
- setError(null);
3946
- fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
3947
- if (!res.ok) throw new Error(res.statusText || "Failed to load");
3948
- return res.json();
3949
- }).then((data) => {
3950
- if (!cancelled) setDetail(data);
3951
- }).catch((e) => {
3952
- if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
3953
- }).finally(() => {
3954
- if (!cancelled) setLoading(false);
3955
- });
3956
- return () => {
3957
- cancelled = true;
3958
- };
3959
- }, [id]);
3960
- const displayStatus = detail ? (detail.payment_id != null && detail.payment_status != null && detail.payment_status !== "" ? detail.payment_status : detail.session_status ?? "") || "—" : "";
3961
- const sessionStatusRaw = detail?.session_status ?? "—";
3962
- const paymentStatusRaw = detail?.payment_id != null ? detail?.payment_status ?? "—" : "—";
3963
- const displayAmount = detail ? `${(detail.currency_code ?? "USD").toUpperCase()} ${Number(detail.amount)}` : "";
3964
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-4xl flex-col gap-6 p-6", children: [
3965
- /* @__PURE__ */ jsxRuntime.jsx("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
3966
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/payments"), children: "← Payments" }),
3967
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Payment session" }),
3968
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: id ?? "—" })
3969
- ] }) }),
3970
- error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
3971
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
3972
- /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/payments"), children: "Back to list" })
3973
- ] }) : loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading…" }) }) : detail ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
3974
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl border border-ui-border-base p-6 flex flex-col gap-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
3975
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3976
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Order ID" }),
3977
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: detail.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
3978
- ui.Button,
3979
- {
3980
- variant: "transparent",
3981
- size: "small",
3982
- onClick: () => navigate(`/orders/${detail.order_id}`),
3983
- children: detail.order_id
3984
- }
3985
- ) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "—" }) })
3986
- ] }),
3987
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3988
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
3989
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: displayAmount })
3990
- ] }),
3991
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3992
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
3993
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.provider_id })
3994
- ] }),
3995
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
3996
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
3997
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
3998
- ui.Badge,
3999
- {
4000
- size: "2xsmall",
4001
- className: `uppercase ${getStatusBadgeClass$3(displayStatus)}`,
4002
- children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
4003
- }
4004
- ) })
4005
- ] }),
4006
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4007
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Session status (DB)" }),
4008
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: sessionStatusRaw })
4009
- ] }),
4010
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4011
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Payment status (DB)" }),
4012
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: paymentStatusRaw })
4013
- ] }),
4014
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4015
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Finalized" }),
4016
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.payment_id != null ? "Yes" : "No" })
3841
+ /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
3842
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-ui-fg-base", children: "If it needs to come back:" }),
3843
+ " ",
3844
+ guidance.recreate
4017
3845
  ] }),
4018
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4019
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created" }),
4020
- /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.created_at).toLocaleDateString("en-US", {
4021
- year: "numeric",
4022
- month: "short",
4023
- day: "numeric",
4024
- hour: "numeric",
4025
- minute: "2-digit",
4026
- hour12: true
4027
- }) })
3846
+ /* @__PURE__ */ jsxRuntime.jsxs("li", { children: [
3847
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-medium text-ui-fg-base", children: "Need the details?" }),
3848
+ " Use “View full record” above to see or copy everything that was stored. Sensitive values stay hidden."
4028
3849
  ] })
4029
- ] }) }),
4030
- Object.keys(detail.data ?? {}).length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4031
- /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Provider data" }),
4032
- /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.data, null, 2) })
4033
- ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl border border-ui-border-base p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No provider data for this session." }) })
4034
- ] }) : null
4035
- ] }) });
3850
+ ] }),
3851
+ guidance.adminSection || related.length ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap gap-2", children: [
3852
+ guidance.adminSection ? /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", onClick: () => navigate(guidance.adminSection.path), children: guidance.adminSection.label }) : null,
3853
+ related.map((link) => /* @__PURE__ */ jsxRuntime.jsxs(
3854
+ ui.Button,
3855
+ {
3856
+ variant: "transparent",
3857
+ size: "small",
3858
+ onClick: () => navigate(link.path),
3859
+ title: `Opens ${link.label.toLowerCase()} ${link.id} if it still exists`,
3860
+ children: [
3861
+ "Open related ",
3862
+ link.label.toLowerCase(),
3863
+ /* @__PURE__ */ jsxRuntime.jsx(icons.ChevronRightMini, {})
3864
+ ]
3865
+ },
3866
+ link.path
3867
+ ))
3868
+ ] }) : null,
3869
+ related.length ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "text-ui-fg-muted", children: "Related records open only if they haven’t been deleted too." }) : null
3870
+ ] }) })
3871
+ ] });
4036
3872
  };
4037
- const config$3 = adminSdk.defineRouteConfig({
4038
- label: "Payment details",
4039
- icon: icons.CreditCard
4040
- });
4041
- const getStatusBadgeClass$2 = (status) => {
3873
+ const Section = ({
3874
+ title,
3875
+ description,
3876
+ actions,
3877
+ children
3878
+ }) => /* @__PURE__ */ jsxRuntime.jsxs("section", { className: "flex flex-col gap-4 rounded-lg border border-ui-border-base p-5", children: [
3879
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-wrap items-start justify-between gap-2", children: [
3880
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-0.5", children: [
3881
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", children: title }),
3882
+ description ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: description }) : null
3883
+ ] }),
3884
+ actions
3885
+ ] }),
3886
+ children
3887
+ ] });
3888
+ const Field = ({ label, children }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex min-w-0 flex-col gap-1", children: [
3889
+ /* @__PURE__ */ jsxRuntime.jsx("dt", { className: "text-xs font-medium uppercase tracking-wide text-ui-fg-muted", children: label }),
3890
+ /* @__PURE__ */ jsxRuntime.jsx("dd", { className: "min-w-0", children })
3891
+ ] });
3892
+ const DetailSkeleton = () => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", "aria-busy": "true", children: [
3893
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-3", children: [
3894
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-5 w-24 rounded-full" }),
3895
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-8 w-64" }),
3896
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-4 w-48" })
3897
+ ] }),
3898
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-14 w-full" }),
3899
+ Array.from({ length: 3 }).map((_, i) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-4 rounded-lg border border-ui-border-base p-5", children: [
3900
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-5 w-40" }),
3901
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: Array.from({ length: 4 }).map((__, j) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1.5", children: [
3902
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-3 w-20" }),
3903
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Skeleton, { className: "h-4 w-36" })
3904
+ ] }, j)) })
3905
+ ] }, i))
3906
+ ] });
3907
+ const DetailError = ({
3908
+ notFound,
3909
+ message,
3910
+ onRetry,
3911
+ onBack
3912
+ }) => /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col items-center gap-2 rounded-lg border border-ui-border-base px-6 py-12 text-center", children: [
3913
+ /* @__PURE__ */ jsxRuntime.jsx(icons.ExclamationCircle, { className: ui.clx(notFound ? "text-ui-fg-muted" : "text-ui-fg-error") }),
3914
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h3", children: notFound ? "Audit entry not found" : "Unable to load this deleted record" }),
3915
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "max-w-md text-ui-fg-subtle", children: notFound ? "This audit entry doesn’t exist. The link may be incorrect." : "We couldn’t retrieve the audit entry right now. Check your connection and try again." }),
3916
+ !notFound ? /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "xsmall", className: "max-w-md font-mono text-ui-fg-muted", children: message }) : null,
3917
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-2 flex gap-2", children: [
3918
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", size: "small", onClick: onBack, children: "Back to Deleted Records" }),
3919
+ !notFound ? /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "primary", size: "small", onClick: onRetry, children: "Try again" }) : null
3920
+ ] })
3921
+ ] });
3922
+ const config$4 = adminSdk.defineRouteConfig({});
3923
+ const getStatusBadgeClass$3 = (status) => {
4042
3924
  const s2 = status.toLowerCase();
4043
3925
  if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
4044
3926
  if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
@@ -4148,7 +4030,7 @@ const RefundDetailPage = () => {
4148
4030
  ui.Badge,
4149
4031
  {
4150
4032
  size: "2xsmall",
4151
- className: `uppercase ${getStatusBadgeClass$2(paymentStatus)}`,
4033
+ className: `uppercase ${getStatusBadgeClass$3(paymentStatus)}`,
4152
4034
  children: paymentStatus !== "—" ? paymentStatus.replace(/_/g, " ") : "—"
4153
4035
  }
4154
4036
  ) })
@@ -4225,10 +4107,128 @@ const RefundDetailPage = () => {
4225
4107
  ] }) : null
4226
4108
  ] }) });
4227
4109
  };
4228
- const config$2 = adminSdk.defineRouteConfig({
4110
+ const config$3 = adminSdk.defineRouteConfig({
4229
4111
  label: "Refund details",
4230
4112
  icon: icons.Receipt
4231
4113
  });
4114
+ const getStatusBadgeClass$2 = (status) => {
4115
+ const s2 = status.toLowerCase();
4116
+ if (s2 === "captured" || s2 === "completed") return "bg-ui-tag-green-bg text-ui-tag-green-text";
4117
+ if (s2 === "authorized") return "bg-ui-tag-blue-bg text-ui-tag-blue-text";
4118
+ if (s2 === "error" || s2 === "canceled" || s2 === "cancelled") return "bg-ui-tag-red-bg text-ui-tag-red-text";
4119
+ if (s2 === "pending" || s2 === "requires_more") return "bg-ui-tag-orange-bg text-ui-tag-orange-text";
4120
+ return "bg-ui-tag-purple-bg text-ui-tag-purple-text";
4121
+ };
4122
+ const PaymentDetailPage = () => {
4123
+ const navigate = reactRouterDom.useNavigate();
4124
+ const params = reactRouterDom.useParams();
4125
+ const id = params?.id?.trim();
4126
+ const [detail, setDetail] = react.useState(null);
4127
+ const [loading, setLoading] = react.useState(!!id);
4128
+ const [error, setError] = react.useState(null);
4129
+ react.useEffect(() => {
4130
+ if (!id) {
4131
+ setLoading(false);
4132
+ return;
4133
+ }
4134
+ let cancelled = false;
4135
+ setLoading(true);
4136
+ setError(null);
4137
+ fetch(`/admin/payment-transactions/${id}`, { credentials: "include" }).then((res) => {
4138
+ if (!res.ok) throw new Error(res.statusText || "Failed to load");
4139
+ return res.json();
4140
+ }).then((data) => {
4141
+ if (!cancelled) setDetail(data);
4142
+ }).catch((e) => {
4143
+ if (!cancelled) setError(e instanceof Error ? e.message : "Failed to load");
4144
+ }).finally(() => {
4145
+ if (!cancelled) setLoading(false);
4146
+ });
4147
+ return () => {
4148
+ cancelled = true;
4149
+ };
4150
+ }, [id]);
4151
+ const displayStatus = detail ? (detail.payment_id != null && detail.payment_status != null && detail.payment_status !== "" ? detail.payment_status : detail.session_status ?? "") || "—" : "";
4152
+ const sessionStatusRaw = detail?.session_status ?? "—";
4153
+ const paymentStatusRaw = detail?.payment_id != null ? detail?.payment_status ?? "—" : "—";
4154
+ const displayAmount = detail ? `${(detail.currency_code ?? "USD").toUpperCase()} ${Number(detail.amount)}` : "";
4155
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "w-full p-6", children: /* @__PURE__ */ jsxRuntime.jsxs(ui.Container, { className: "mx-auto flex w-full max-w-4xl flex-col gap-6 p-6", children: [
4156
+ /* @__PURE__ */ jsxRuntime.jsx("header", { className: "flex flex-col gap-3 md:flex-row md:items-center md:justify-between", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
4157
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "transparent", size: "small", onClick: () => navigate("/payments"), children: "← Payments" }),
4158
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h1", children: "Payment session" }),
4159
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-subtle", children: id ?? "—" })
4160
+ ] }) }),
4161
+ error ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-lg border border-ui-border-strong p-6 text-center", children: [
4162
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { weight: "plus", className: "text-ui-fg-error", children: error }),
4163
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { variant: "secondary", className: "mt-4", onClick: () => navigate("/payments"), children: "Back to list" })
4164
+ ] }) : loading ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center py-16", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "Loading…" }) }) : detail ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
4165
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl border border-ui-border-base p-6 flex flex-col gap-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: [
4166
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4167
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Order ID" }),
4168
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: detail.order_id ? /* @__PURE__ */ jsxRuntime.jsx(
4169
+ ui.Button,
4170
+ {
4171
+ variant: "transparent",
4172
+ size: "small",
4173
+ onClick: () => navigate(`/orders/${detail.order_id}`),
4174
+ children: detail.order_id
4175
+ }
4176
+ ) : /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { children: "—" }) })
4177
+ ] }),
4178
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4179
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Amount" }),
4180
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: displayAmount })
4181
+ ] }),
4182
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4183
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Provider" }),
4184
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.provider_id })
4185
+ ] }),
4186
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4187
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Status" }),
4188
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
4189
+ ui.Badge,
4190
+ {
4191
+ size: "2xsmall",
4192
+ className: `uppercase ${getStatusBadgeClass$2(displayStatus)}`,
4193
+ children: displayStatus !== "—" ? displayStatus.replace(/_/g, " ") : "—"
4194
+ }
4195
+ ) })
4196
+ ] }),
4197
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4198
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Session status (DB)" }),
4199
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: sessionStatusRaw })
4200
+ ] }),
4201
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4202
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Payment status (DB)" }),
4203
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: paymentStatusRaw })
4204
+ ] }),
4205
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4206
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Finalized" }),
4207
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: detail.payment_id != null ? "Yes" : "No" })
4208
+ ] }),
4209
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
4210
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "Created" }),
4211
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { className: "mt-1 block", children: new Date(detail.created_at).toLocaleDateString("en-US", {
4212
+ year: "numeric",
4213
+ month: "short",
4214
+ day: "numeric",
4215
+ hour: "numeric",
4216
+ minute: "2-digit",
4217
+ hour12: true
4218
+ }) })
4219
+ ] })
4220
+ ] }) }),
4221
+ Object.keys(detail.data ?? {}).length > 0 ? /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base p-6", children: [
4222
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Heading, { level: "h2", className: "text-lg mb-4", children: "Provider data" }),
4223
+ /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "text-xs bg-ui-bg-subtle p-4 rounded-lg overflow-auto max-h-96", children: JSON.stringify(detail.data, null, 2) })
4224
+ ] }) : /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-xl border border-ui-border-base p-6", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Text, { size: "small", className: "text-ui-fg-muted", children: "No provider data for this session." }) })
4225
+ ] }) : null
4226
+ ] }) });
4227
+ };
4228
+ const config$2 = adminSdk.defineRouteConfig({
4229
+ label: "Payment details",
4230
+ icon: icons.CreditCard
4231
+ });
4232
4232
  const getStatusBadgeClass$1 = (status) => {
4233
4233
  const statusLower = status.toLowerCase();
4234
4234
  if (statusLower === "requested") {
@@ -4810,13 +4810,13 @@ const routeModule = {
4810
4810
  handle: { label: config$9.label, translationNs: config$9.translationNs }
4811
4811
  },
4812
4812
  {
4813
- Component: PaymentsPage,
4814
- path: "/payments",
4813
+ Component: RefundsPage,
4814
+ path: "/refunds",
4815
4815
  handle: { label: config$8.label, translationNs: config$8.translationNs }
4816
4816
  },
4817
4817
  {
4818
- Component: RefundsPage,
4819
- path: "/refunds",
4818
+ Component: PaymentsPage,
4819
+ path: "/payments",
4820
4820
  handle: { label: config$7.label, translationNs: config$7.translationNs }
4821
4821
  },
4822
4822
  {
@@ -4835,13 +4835,13 @@ const routeModule = {
4835
4835
  handle: { label: config$4.label, translationNs: config$4.translationNs }
4836
4836
  },
4837
4837
  {
4838
- Component: PaymentDetailPage,
4839
- path: "/payments/:id",
4838
+ Component: RefundDetailPage,
4839
+ path: "/refunds/:id",
4840
4840
  handle: { label: config$3.label, translationNs: config$3.translationNs }
4841
4841
  },
4842
4842
  {
4843
- Component: RefundDetailPage,
4844
- path: "/refunds/:id",
4843
+ Component: PaymentDetailPage,
4844
+ path: "/payments/:id",
4845
4845
  handle: { label: config$2.label, translationNs: config$2.translationNs }
4846
4846
  },
4847
4847
  {
@@ -4867,16 +4867,16 @@ const menuItemModule = {
4867
4867
  translationNs: void 0
4868
4868
  },
4869
4869
  {
4870
- label: config$8.label,
4871
- icon: config$8.icon,
4870
+ label: config$7.label,
4871
+ icon: config$7.icon,
4872
4872
  path: "/payments",
4873
4873
  nested: void 0,
4874
4874
  rank: void 0,
4875
4875
  translationNs: void 0
4876
4876
  },
4877
4877
  {
4878
- label: config$7.label,
4879
- icon: config$7.icon,
4878
+ label: config$8.label,
4879
+ icon: config$8.icon,
4880
4880
  path: "/refunds",
4881
4881
  nested: void 0,
4882
4882
  rank: void 0,
@@ -4899,16 +4899,16 @@ const menuItemModule = {
4899
4899
  translationNs: void 0
4900
4900
  },
4901
4901
  {
4902
- label: config$3.label,
4903
- icon: config$3.icon,
4902
+ label: config$2.label,
4903
+ icon: config$2.icon,
4904
4904
  path: "/payments/:id",
4905
4905
  nested: void 0,
4906
4906
  rank: void 0,
4907
4907
  translationNs: void 0
4908
4908
  },
4909
4909
  {
4910
- label: config$2.label,
4911
- icon: config$2.icon,
4910
+ label: config$3.label,
4911
+ icon: config$3.icon,
4912
4912
  path: "/refunds/:id",
4913
4913
  nested: void 0,
4914
4914
  rank: void 0,