@easypayment/medusa-paypal 0.1.3 → 0.1.4

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.
@@ -41,17 +41,11 @@ function PayPalTabs() {
41
41
  }) }) });
42
42
  }
43
43
  const DEFAULT_FORM$1 = {
44
- paymentAction: "capture",
45
- brandName: "PayPal",
46
- landingPage: "no_preference",
47
- requireInstantPayment: false,
48
- useShippingAsBilling: true,
49
- sendItemDetails: true,
50
- skipOrderReviewPage: true,
51
- invoicePrefix: "WC-",
52
- creditCardStatementName: "PayPal",
53
- enableLogging: true,
54
- logPath: "/uploads/wc-logs/"
44
+ enabled: true,
45
+ title: "Credit or Debit Card",
46
+ disabledCards: [],
47
+ threeDS: "when_required",
48
+ cardSaveEnabled: false
55
49
  };
56
50
  function mergeWithDefaults$1(saved) {
57
51
  if (!saved) return { ...DEFAULT_FORM$1 };
@@ -61,6 +55,53 @@ function mergeWithDefaults$1(saved) {
61
55
  ...Object.fromEntries(entries)
62
56
  };
63
57
  }
58
+ const CARD_BRANDS = [
59
+ { value: "visa", label: "Visa" },
60
+ { value: "mastercard", label: "Mastercard" },
61
+ { value: "amex", label: "American Express" },
62
+ { value: "discover", label: "Discover" },
63
+ { value: "diners", label: "Diners Club" },
64
+ { value: "jcb", label: "JCB" },
65
+ { value: "unionpay", label: "UnionPay" }
66
+ ];
67
+ const THREE_DS_OPTIONS = [
68
+ {
69
+ value: "when_required",
70
+ label: "3D Secure when required",
71
+ hint: "Triggers 3DS only when the card / issuer requires it."
72
+ },
73
+ {
74
+ value: "sli",
75
+ label: "3D Secure (SCA) / liability shift (recommended)",
76
+ hint: "Attempts to optimize for liability shift while remaining compliant."
77
+ },
78
+ {
79
+ value: "always",
80
+ label: "Always request 3D Secure",
81
+ hint: "Forces 3DS challenge whenever possible (may reduce conversion)."
82
+ }
83
+ ];
84
+ function cx$1(...parts) {
85
+ return parts.filter(Boolean).join(" ");
86
+ }
87
+ function Pill$1({
88
+ children,
89
+ onRemove
90
+ }) {
91
+ return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1 rounded-md border border-ui-border-base bg-ui-bg-base px-2 py-1 text-sm text-ui-fg-base", children: [
92
+ children,
93
+ onRemove ? /* @__PURE__ */ jsxRuntime.jsx(
94
+ "button",
95
+ {
96
+ type: "button",
97
+ onClick: onRemove,
98
+ className: "ml-1 rounded px-1 text-ui-fg-subtle hover:text-ui-fg-base",
99
+ "aria-label": "Remove",
100
+ children: "×"
101
+ }
102
+ ) : null
103
+ ] });
104
+ }
64
105
  function SectionCard$2({
65
106
  title,
66
107
  description,
@@ -91,10 +132,12 @@ function FieldRow$2({
91
132
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-12 md:col-span-8", children })
92
133
  ] });
93
134
  }
94
- function AdditionalSettingsTab() {
135
+ function AdvancedCardPaymentsTab() {
136
+ var _a, _b;
95
137
  const [form, setForm] = react.useState(() => ({ ...DEFAULT_FORM$1 }));
96
138
  const [loading, setLoading] = react.useState(false);
97
139
  const [saving, setSaving] = react.useState(false);
140
+ const [toast, setToast] = react.useState(null);
98
141
  const didInit = react.useRef(false);
99
142
  react.useEffect(() => {
100
143
  if (didInit.current) return;
@@ -109,7 +152,7 @@ function AdditionalSettingsTab() {
109
152
  if (!r.ok) return;
110
153
  const json = await r.json();
111
154
  const payload = (json == null ? void 0 : json.data) ?? json;
112
- const saved = payload == null ? void 0 : payload.additional_settings;
155
+ const saved = payload == null ? void 0 : payload.advanced_card_payments;
113
156
  if (saved && typeof saved === "object") {
114
157
  setForm(mergeWithDefaults$1(saved));
115
158
  }
@@ -118,11 +161,9 @@ function AdditionalSettingsTab() {
118
161
  }
119
162
  })();
120
163
  }, []);
121
- const [toast, setToast] = react.useState(null);
122
164
  async function onSave() {
123
165
  try {
124
166
  setSaving(true);
125
- setToast(null);
126
167
  const r = await fetch("/admin/paypal/settings", {
127
168
  method: "POST",
128
169
  credentials: "include",
@@ -130,29 +171,42 @@ function AdditionalSettingsTab() {
130
171
  "Content-Type": "application/json",
131
172
  "Accept": "application/json"
132
173
  },
133
- body: JSON.stringify({
134
- additional_settings: form
135
- })
174
+ body: JSON.stringify({ advanced_card_payments: form })
136
175
  });
137
176
  if (!r.ok) {
138
- const errText = await r.text().catch(() => "");
139
- throw new Error(errText || "Failed to save settings");
177
+ const t = await r.text();
178
+ setToast({ type: "error", message: "Failed to save settings. " + t });
179
+ window.setTimeout(() => setToast(null), 3500);
180
+ return;
140
181
  }
141
- const json = await r.json().catch(() => ({}));
182
+ const json = await r.json().catch(() => null);
142
183
  const payload = (json == null ? void 0 : json.data) ?? json;
143
- const saved = payload == null ? void 0 : payload.additional_settings;
184
+ const saved = payload == null ? void 0 : payload.advanced_card_payments;
144
185
  if (saved && typeof saved === "object") {
145
186
  setForm(mergeWithDefaults$1(saved));
146
187
  }
147
188
  setToast({ type: "success", message: "Settings saved" });
148
189
  window.setTimeout(() => setToast(null), 2500);
149
- } catch (e) {
150
- setToast({ type: "error", message: (e == null ? void 0 : e.message) || "Failed to save settings" });
151
- window.setTimeout(() => setToast(null), 3500);
152
190
  } finally {
153
191
  setSaving(false);
154
192
  }
155
193
  }
194
+ const disabledSet = react.useMemo(() => new Set(form.disabledCards), [form.disabledCards]);
195
+ function toggleDisabledCard(value) {
196
+ setForm((prev) => {
197
+ const exists = prev.disabledCards.includes(value);
198
+ return {
199
+ ...prev,
200
+ disabledCards: exists ? prev.disabledCards.filter((v) => v !== value) : [...prev.disabledCards, value]
201
+ };
202
+ });
203
+ }
204
+ function removeDisabledCard(value) {
205
+ setForm((prev) => ({
206
+ ...prev,
207
+ disabledCards: prev.disabledCards.filter((v) => v !== value)
208
+ }));
209
+ }
156
210
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
157
211
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-start justify-between gap-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Gateway By Easy Payment" }) }) }),
158
212
  /* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
@@ -168,8 +222,8 @@ function AdditionalSettingsTab() {
168
222
  /* @__PURE__ */ jsxRuntime.jsx(
169
223
  SectionCard$2,
170
224
  {
171
- title: "Additional Settings",
172
- description: "These settings control checkout behavior, PayPal experience, and logging.",
225
+ title: "Advanced Card Payments",
226
+ description: "Control card checkout settings, 3D Secure behavior, and card saving.",
173
227
  right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
174
228
  /* @__PURE__ */ jsxRuntime.jsx(
175
229
  "button",
@@ -184,164 +238,114 @@ function AdditionalSettingsTab() {
184
238
  loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
185
239
  ] }),
186
240
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
187
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Payment action", children: /* @__PURE__ */ jsxRuntime.jsxs(
188
- "select",
189
- {
190
- value: form.paymentAction,
191
- onChange: (e) => setForm((p) => ({ ...p, paymentAction: e.target.value })),
192
- className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive",
193
- children: [
194
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "capture", children: "Capture" }),
195
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "authorize", children: "Authorize" })
196
- ]
197
- }
198
- ) }),
199
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Brand Name", children: /* @__PURE__ */ jsxRuntime.jsx(
200
- "input",
201
- {
202
- value: form.brandName,
203
- onChange: (e) => setForm((p) => ({ ...p, brandName: e.target.value })),
204
- className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive",
205
- placeholder: "PayPal"
206
- }
207
- ) }),
208
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Landing Page", children: /* @__PURE__ */ jsxRuntime.jsxs(
209
- "select",
210
- {
211
- value: form.landingPage,
212
- onChange: (e) => setForm((p) => ({ ...p, landingPage: e.target.value })),
213
- className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive",
214
- children: [
215
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "no_preference", children: "No Preference" }),
216
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "login", children: "Login" }),
217
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "billing", children: "Billing" })
218
- ]
219
- }
220
- ) }),
221
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Instant Payments", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
241
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Enable/Disable", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
222
242
  /* @__PURE__ */ jsxRuntime.jsx(
223
243
  "input",
224
244
  {
225
245
  type: "checkbox",
226
- checked: form.requireInstantPayment,
227
- onChange: (e) => setForm((p) => ({ ...p, requireInstantPayment: e.target.checked })),
246
+ checked: form.enabled,
247
+ onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })),
228
248
  className: "h-4 w-4 rounded border-ui-border-base"
229
249
  }
230
250
  ),
231
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Require Instant Payment" })
251
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
232
252
  ] }) }),
233
- /* @__PURE__ */ jsxRuntime.jsx(
234
- FieldRow$2,
253
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Title", children: /* @__PURE__ */ jsxRuntime.jsx(
254
+ "input",
235
255
  {
236
- label: "Billing Address",
237
- hint: "If the billing address is empty and PayPal provides a shipping address, the order will use the shipping address as the billing address.",
238
- children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
239
- /* @__PURE__ */ jsxRuntime.jsx(
240
- "input",
241
- {
242
- type: "checkbox",
243
- checked: form.useShippingAsBilling,
244
- onChange: (e) => setForm((p) => ({ ...p, useShippingAsBilling: e.target.checked })),
245
- className: "h-4 w-4 rounded border-ui-border-base"
246
- }
247
- ),
248
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Use PayPal Shipping Address as Billing" })
249
- ] })
256
+ value: form.title,
257
+ onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })),
258
+ className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive",
259
+ placeholder: "Credit or Debit Card"
250
260
  }
251
- ),
261
+ ) }),
252
262
  /* @__PURE__ */ jsxRuntime.jsx(
253
263
  FieldRow$2,
254
264
  {
255
- label: "Send Item Details",
256
- hint: "Include all line item details in the payment request to PayPal so that they can be seen from the PayPal transaction details page.",
257
- children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
258
- /* @__PURE__ */ jsxRuntime.jsx(
259
- "input",
260
- {
261
- type: "checkbox",
262
- checked: form.sendItemDetails,
263
- onChange: (e) => setForm((p) => ({ ...p, sendItemDetails: e.target.checked })),
264
- className: "h-4 w-4 rounded border-ui-border-base"
265
- }
266
- ),
267
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Send line item details to PayPal" })
265
+ label: "Disable specific credit cards",
266
+ hint: "Select card brands to hide from the card form.",
267
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
268
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: form.disabledCards.length ? form.disabledCards.map((v) => {
269
+ var _a2;
270
+ const label = ((_a2 = CARD_BRANDS.find((b) => b.value === v)) == null ? void 0 : _a2.label) ?? v;
271
+ return /* @__PURE__ */ jsxRuntime.jsx(Pill$1, { onRemove: () => removeDisabledCard(v), children: label }, v);
272
+ }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "No card brands disabled." }) }),
273
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-ui-border-base p-3", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-2 md:grid-cols-2", children: CARD_BRANDS.map((b) => {
274
+ const checked = disabledSet.has(b.value);
275
+ return /* @__PURE__ */ jsxRuntime.jsxs(
276
+ "label",
277
+ {
278
+ className: cx$1(
279
+ "flex items-center gap-2 rounded-md p-2",
280
+ "hover:bg-ui-bg-subtle"
281
+ ),
282
+ children: [
283
+ /* @__PURE__ */ jsxRuntime.jsx(
284
+ "input",
285
+ {
286
+ type: "checkbox",
287
+ checked,
288
+ onChange: () => toggleDisabledCard(b.value),
289
+ className: "h-4 w-4 rounded border-ui-border-base"
290
+ }
291
+ ),
292
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: b.label })
293
+ ]
294
+ },
295
+ b.value
296
+ );
297
+ }) }) })
268
298
  ] })
269
299
  }
270
300
  ),
271
301
  /* @__PURE__ */ jsxRuntime.jsx(
272
302
  FieldRow$2,
273
303
  {
274
- label: "Order Review Page",
275
- hint: "Payments from the Product or Cart page skip the review step and go straight to the Thank You page.",
276
- children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
304
+ label: "Contingency for 3D Secure",
305
+ hint: "Choose when 3D Secure should be triggered during card payments.",
306
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
277
307
  /* @__PURE__ */ jsxRuntime.jsx(
278
- "input",
308
+ "select",
279
309
  {
280
- type: "checkbox",
281
- checked: form.skipOrderReviewPage,
282
- onChange: (e) => setForm((p) => ({ ...p, skipOrderReviewPage: e.target.checked })),
283
- className: "h-4 w-4 rounded border-ui-border-base"
310
+ value: form.threeDS,
311
+ onChange: (e) => setForm((p) => ({ ...p, threeDS: e.target.value })),
312
+ className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive",
313
+ children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value))
284
314
  }
285
315
  ),
286
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Skip Order Review Page" })
316
+ ((_a = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _a.hint) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-ui-fg-subtle", children: (_b = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _b.hint }) : null
287
317
  ] })
288
318
  }
289
319
  ),
290
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Invoice prefix", children: /* @__PURE__ */ jsxRuntime.jsx(
291
- "input",
292
- {
293
- value: form.invoicePrefix,
294
- onChange: (e) => setForm((p) => ({ ...p, invoicePrefix: e.target.value })),
295
- className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive",
296
- placeholder: "WC-"
297
- }
298
- ) }),
299
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Credit Card Statement Name", children: /* @__PURE__ */ jsxRuntime.jsx(
300
- "input",
301
- {
302
- value: form.creditCardStatementName,
303
- onChange: (e) => setForm((p) => ({ ...p, creditCardStatementName: e.target.value })),
304
- className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive",
305
- placeholder: "PayPal"
306
- }
307
- ) }),
308
- /* @__PURE__ */ jsxRuntime.jsx(
309
- FieldRow$2,
310
- {
311
- label: "Debug log",
312
- hint: /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
313
- "Log PayPal events such as Webhook, Payment, Refund.",
314
- " ",
315
- form.logPath ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
316
- "Log location: ",
317
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono", children: form.logPath })
318
- ] }) : null
319
- ] }),
320
- children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
321
- /* @__PURE__ */ jsxRuntime.jsx(
322
- "input",
323
- {
324
- type: "checkbox",
325
- checked: form.enableLogging,
326
- onChange: (e) => setForm((p) => ({ ...p, enableLogging: e.target.checked })),
327
- className: "h-4 w-4 rounded border-ui-border-base"
328
- }
329
- ),
330
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable logging" })
331
- ] })
332
- }
333
- )
320
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow$2, { label: "Card Save Enabled", hint: "Allow customers to save a card at checkout for future use.", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
321
+ /* @__PURE__ */ jsxRuntime.jsx(
322
+ "input",
323
+ {
324
+ type: "checkbox",
325
+ checked: form.cardSaveEnabled,
326
+ onChange: (e) => setForm((p) => ({ ...p, cardSaveEnabled: e.target.checked })),
327
+ className: "h-4 w-4 rounded border-ui-border-base"
328
+ }
329
+ ),
330
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable card saving at checkout" })
331
+ ] }) })
334
332
  ] })
335
333
  }
336
334
  )
337
335
  ] }) });
338
336
  }
339
337
  const DEFAULT_FORM = {
340
- enabled: true,
341
- title: "Credit or Debit Card",
342
- disabledCards: [],
343
- threeDS: "when_required",
344
- cardSaveEnabled: false
338
+ paymentAction: "capture",
339
+ brandName: "PayPal",
340
+ landingPage: "no_preference",
341
+ requireInstantPayment: false,
342
+ useShippingAsBilling: true,
343
+ sendItemDetails: true,
344
+ skipOrderReviewPage: true,
345
+ invoicePrefix: "WC-",
346
+ creditCardStatementName: "PayPal",
347
+ enableLogging: true,
348
+ logPath: "/uploads/wc-logs/"
345
349
  };
346
350
  function mergeWithDefaults(saved) {
347
351
  if (!saved) return { ...DEFAULT_FORM };
@@ -351,53 +355,6 @@ function mergeWithDefaults(saved) {
351
355
  ...Object.fromEntries(entries)
352
356
  };
353
357
  }
354
- const CARD_BRANDS = [
355
- { value: "visa", label: "Visa" },
356
- { value: "mastercard", label: "Mastercard" },
357
- { value: "amex", label: "American Express" },
358
- { value: "discover", label: "Discover" },
359
- { value: "diners", label: "Diners Club" },
360
- { value: "jcb", label: "JCB" },
361
- { value: "unionpay", label: "UnionPay" }
362
- ];
363
- const THREE_DS_OPTIONS = [
364
- {
365
- value: "when_required",
366
- label: "3D Secure when required",
367
- hint: "Triggers 3DS only when the card / issuer requires it."
368
- },
369
- {
370
- value: "sli",
371
- label: "3D Secure (SCA) / liability shift (recommended)",
372
- hint: "Attempts to optimize for liability shift while remaining compliant."
373
- },
374
- {
375
- value: "always",
376
- label: "Always request 3D Secure",
377
- hint: "Forces 3DS challenge whenever possible (may reduce conversion)."
378
- }
379
- ];
380
- function cx$1(...parts) {
381
- return parts.filter(Boolean).join(" ");
382
- }
383
- function Pill$1({
384
- children,
385
- onRemove
386
- }) {
387
- return /* @__PURE__ */ jsxRuntime.jsxs("span", { className: "inline-flex items-center gap-1 rounded-md border border-ui-border-base bg-ui-bg-base px-2 py-1 text-sm text-ui-fg-base", children: [
388
- children,
389
- onRemove ? /* @__PURE__ */ jsxRuntime.jsx(
390
- "button",
391
- {
392
- type: "button",
393
- onClick: onRemove,
394
- className: "ml-1 rounded px-1 text-ui-fg-subtle hover:text-ui-fg-base",
395
- "aria-label": "Remove",
396
- children: "×"
397
- }
398
- ) : null
399
- ] });
400
- }
401
358
  function SectionCard$1({
402
359
  title,
403
360
  description,
@@ -428,12 +385,10 @@ function FieldRow$1({
428
385
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-12 md:col-span-8", children })
429
386
  ] });
430
387
  }
431
- function AdvancedCardPaymentsTab() {
432
- var _a, _b;
388
+ function AdditionalSettingsTab() {
433
389
  const [form, setForm] = react.useState(() => ({ ...DEFAULT_FORM }));
434
390
  const [loading, setLoading] = react.useState(false);
435
391
  const [saving, setSaving] = react.useState(false);
436
- const [toast, setToast] = react.useState(null);
437
392
  const didInit = react.useRef(false);
438
393
  react.useEffect(() => {
439
394
  if (didInit.current) return;
@@ -448,7 +403,7 @@ function AdvancedCardPaymentsTab() {
448
403
  if (!r.ok) return;
449
404
  const json = await r.json();
450
405
  const payload = (json == null ? void 0 : json.data) ?? json;
451
- const saved = payload == null ? void 0 : payload.advanced_card_payments;
406
+ const saved = payload == null ? void 0 : payload.additional_settings;
452
407
  if (saved && typeof saved === "object") {
453
408
  setForm(mergeWithDefaults(saved));
454
409
  }
@@ -457,9 +412,11 @@ function AdvancedCardPaymentsTab() {
457
412
  }
458
413
  })();
459
414
  }, []);
415
+ const [toast, setToast] = react.useState(null);
460
416
  async function onSave() {
461
417
  try {
462
418
  setSaving(true);
419
+ setToast(null);
463
420
  const r = await fetch("/admin/paypal/settings", {
464
421
  method: "POST",
465
422
  credentials: "include",
@@ -467,42 +424,29 @@ function AdvancedCardPaymentsTab() {
467
424
  "Content-Type": "application/json",
468
425
  "Accept": "application/json"
469
426
  },
470
- body: JSON.stringify({ advanced_card_payments: form })
427
+ body: JSON.stringify({
428
+ additional_settings: form
429
+ })
471
430
  });
472
431
  if (!r.ok) {
473
- const t = await r.text();
474
- setToast({ type: "error", message: "Failed to save settings. " + t });
475
- window.setTimeout(() => setToast(null), 3500);
476
- return;
432
+ const errText = await r.text().catch(() => "");
433
+ throw new Error(errText || "Failed to save settings");
477
434
  }
478
- const json = await r.json().catch(() => null);
435
+ const json = await r.json().catch(() => ({}));
479
436
  const payload = (json == null ? void 0 : json.data) ?? json;
480
- const saved = payload == null ? void 0 : payload.advanced_card_payments;
437
+ const saved = payload == null ? void 0 : payload.additional_settings;
481
438
  if (saved && typeof saved === "object") {
482
439
  setForm(mergeWithDefaults(saved));
483
440
  }
484
441
  setToast({ type: "success", message: "Settings saved" });
485
442
  window.setTimeout(() => setToast(null), 2500);
443
+ } catch (e) {
444
+ setToast({ type: "error", message: (e == null ? void 0 : e.message) || "Failed to save settings" });
445
+ window.setTimeout(() => setToast(null), 3500);
486
446
  } finally {
487
447
  setSaving(false);
488
448
  }
489
449
  }
490
- const disabledSet = react.useMemo(() => new Set(form.disabledCards), [form.disabledCards]);
491
- function toggleDisabledCard(value) {
492
- setForm((prev) => {
493
- const exists = prev.disabledCards.includes(value);
494
- return {
495
- ...prev,
496
- disabledCards: exists ? prev.disabledCards.filter((v) => v !== value) : [...prev.disabledCards, value]
497
- };
498
- });
499
- }
500
- function removeDisabledCard(value) {
501
- setForm((prev) => ({
502
- ...prev,
503
- disabledCards: prev.disabledCards.filter((v) => v !== value)
504
- }));
505
- }
506
450
  return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
507
451
  /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-start justify-between gap-4", children: /* @__PURE__ */ jsxRuntime.jsx("div", { children: /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Gateway By Easy Payment" }) }) }),
508
452
  /* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
@@ -518,8 +462,8 @@ function AdvancedCardPaymentsTab() {
518
462
  /* @__PURE__ */ jsxRuntime.jsx(
519
463
  SectionCard$1,
520
464
  {
521
- title: "Advanced Card Payments",
522
- description: "Control card checkout settings, 3D Secure behavior, and card saving.",
465
+ title: "Additional Settings",
466
+ description: "These settings control checkout behavior, PayPal experience, and logging.",
523
467
  right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
524
468
  /* @__PURE__ */ jsxRuntime.jsx(
525
469
  "button",
@@ -534,105 +478,158 @@ function AdvancedCardPaymentsTab() {
534
478
  loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
535
479
  ] }),
536
480
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
537
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Enable/Disable", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
481
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Payment action", children: /* @__PURE__ */ jsxRuntime.jsxs(
482
+ "select",
483
+ {
484
+ value: form.paymentAction,
485
+ onChange: (e) => setForm((p) => ({ ...p, paymentAction: e.target.value })),
486
+ className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive",
487
+ children: [
488
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "capture", children: "Capture" }),
489
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "authorize", children: "Authorize" })
490
+ ]
491
+ }
492
+ ) }),
493
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Brand Name", children: /* @__PURE__ */ jsxRuntime.jsx(
494
+ "input",
495
+ {
496
+ value: form.brandName,
497
+ onChange: (e) => setForm((p) => ({ ...p, brandName: e.target.value })),
498
+ className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive",
499
+ placeholder: "PayPal"
500
+ }
501
+ ) }),
502
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Landing Page", children: /* @__PURE__ */ jsxRuntime.jsxs(
503
+ "select",
504
+ {
505
+ value: form.landingPage,
506
+ onChange: (e) => setForm((p) => ({ ...p, landingPage: e.target.value })),
507
+ className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive",
508
+ children: [
509
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "no_preference", children: "No Preference" }),
510
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "login", children: "Login" }),
511
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "billing", children: "Billing" })
512
+ ]
513
+ }
514
+ ) }),
515
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Instant Payments", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
538
516
  /* @__PURE__ */ jsxRuntime.jsx(
539
517
  "input",
540
518
  {
541
519
  type: "checkbox",
542
- checked: form.enabled,
543
- onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })),
520
+ checked: form.requireInstantPayment,
521
+ onChange: (e) => setForm((p) => ({ ...p, requireInstantPayment: e.target.checked })),
544
522
  className: "h-4 w-4 rounded border-ui-border-base"
545
523
  }
546
524
  ),
547
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
525
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Require Instant Payment" })
548
526
  ] }) }),
549
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Title", children: /* @__PURE__ */ jsxRuntime.jsx(
550
- "input",
527
+ /* @__PURE__ */ jsxRuntime.jsx(
528
+ FieldRow$1,
551
529
  {
552
- value: form.title,
553
- onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })),
554
- className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive",
555
- placeholder: "Credit or Debit Card"
530
+ label: "Billing Address",
531
+ hint: "If the billing address is empty and PayPal provides a shipping address, the order will use the shipping address as the billing address.",
532
+ children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
533
+ /* @__PURE__ */ jsxRuntime.jsx(
534
+ "input",
535
+ {
536
+ type: "checkbox",
537
+ checked: form.useShippingAsBilling,
538
+ onChange: (e) => setForm((p) => ({ ...p, useShippingAsBilling: e.target.checked })),
539
+ className: "h-4 w-4 rounded border-ui-border-base"
540
+ }
541
+ ),
542
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Use PayPal Shipping Address as Billing" })
543
+ ] })
556
544
  }
557
- ) }),
545
+ ),
558
546
  /* @__PURE__ */ jsxRuntime.jsx(
559
547
  FieldRow$1,
560
548
  {
561
- label: "Disable specific credit cards",
562
- hint: "Select card brands to hide from the card form.",
563
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
564
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: form.disabledCards.length ? form.disabledCards.map((v) => {
565
- var _a2;
566
- const label = ((_a2 = CARD_BRANDS.find((b) => b.value === v)) == null ? void 0 : _a2.label) ?? v;
567
- return /* @__PURE__ */ jsxRuntime.jsx(Pill$1, { onRemove: () => removeDisabledCard(v), children: label }, v);
568
- }) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "No card brands disabled." }) }),
569
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-ui-border-base p-3", children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "grid gap-2 md:grid-cols-2", children: CARD_BRANDS.map((b) => {
570
- const checked = disabledSet.has(b.value);
571
- return /* @__PURE__ */ jsxRuntime.jsxs(
572
- "label",
573
- {
574
- className: cx$1(
575
- "flex items-center gap-2 rounded-md p-2",
576
- "hover:bg-ui-bg-subtle"
577
- ),
578
- children: [
579
- /* @__PURE__ */ jsxRuntime.jsx(
580
- "input",
581
- {
582
- type: "checkbox",
583
- checked,
584
- onChange: () => toggleDisabledCard(b.value),
585
- className: "h-4 w-4 rounded border-ui-border-base"
586
- }
587
- ),
588
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: b.label })
589
- ]
590
- },
591
- b.value
592
- );
593
- }) }) })
549
+ label: "Send Item Details",
550
+ hint: "Include all line item details in the payment request to PayPal so that they can be seen from the PayPal transaction details page.",
551
+ children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
552
+ /* @__PURE__ */ jsxRuntime.jsx(
553
+ "input",
554
+ {
555
+ type: "checkbox",
556
+ checked: form.sendItemDetails,
557
+ onChange: (e) => setForm((p) => ({ ...p, sendItemDetails: e.target.checked })),
558
+ className: "h-4 w-4 rounded border-ui-border-base"
559
+ }
560
+ ),
561
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Send line item details to PayPal" })
594
562
  ] })
595
563
  }
596
564
  ),
597
565
  /* @__PURE__ */ jsxRuntime.jsx(
598
566
  FieldRow$1,
599
567
  {
600
- label: "Contingency for 3D Secure",
601
- hint: "Choose when 3D Secure should be triggered during card payments.",
602
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
568
+ label: "Order Review Page",
569
+ hint: "Payments from the Product or Cart page skip the review step and go straight to the Thank You page.",
570
+ children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
603
571
  /* @__PURE__ */ jsxRuntime.jsx(
604
- "select",
572
+ "input",
605
573
  {
606
- value: form.threeDS,
607
- onChange: (e) => setForm((p) => ({ ...p, threeDS: e.target.value })),
608
- className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive",
609
- children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value))
574
+ type: "checkbox",
575
+ checked: form.skipOrderReviewPage,
576
+ onChange: (e) => setForm((p) => ({ ...p, skipOrderReviewPage: e.target.checked })),
577
+ className: "h-4 w-4 rounded border-ui-border-base"
610
578
  }
611
579
  ),
612
- ((_a = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _a.hint) ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-xs text-ui-fg-subtle", children: (_b = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _b.hint }) : null
580
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Skip Order Review Page" })
613
581
  ] })
614
582
  }
615
583
  ),
616
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Card Save Enabled", hint: "Allow customers to save a card at checkout for future use.", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
617
- /* @__PURE__ */ jsxRuntime.jsx(
618
- "input",
619
- {
620
- type: "checkbox",
621
- checked: form.cardSaveEnabled,
622
- onChange: (e) => setForm((p) => ({ ...p, cardSaveEnabled: e.target.checked })),
623
- className: "h-4 w-4 rounded border-ui-border-base"
624
- }
625
- ),
626
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable card saving at checkout" })
627
- ] }) })
584
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Invoice prefix", children: /* @__PURE__ */ jsxRuntime.jsx(
585
+ "input",
586
+ {
587
+ value: form.invoicePrefix,
588
+ onChange: (e) => setForm((p) => ({ ...p, invoicePrefix: e.target.value })),
589
+ className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive",
590
+ placeholder: "WC-"
591
+ }
592
+ ) }),
593
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Credit Card Statement Name", children: /* @__PURE__ */ jsxRuntime.jsx(
594
+ "input",
595
+ {
596
+ value: form.creditCardStatementName,
597
+ onChange: (e) => setForm((p) => ({ ...p, creditCardStatementName: e.target.value })),
598
+ className: "w-full rounded-md border border-ui-border-base bg-ui-bg-base px-3 py-2 text-sm text-ui-fg-base outline-none focus:ring-2 focus:ring-ui-border-interactive",
599
+ placeholder: "PayPal"
600
+ }
601
+ ) }),
602
+ /* @__PURE__ */ jsxRuntime.jsx(
603
+ FieldRow$1,
604
+ {
605
+ label: "Debug log",
606
+ hint: /* @__PURE__ */ jsxRuntime.jsxs("span", { children: [
607
+ "Log PayPal events such as Webhook, Payment, Refund.",
608
+ " ",
609
+ form.logPath ? /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
610
+ "Log location: ",
611
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono", children: form.logPath })
612
+ ] }) : null
613
+ ] }),
614
+ children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
615
+ /* @__PURE__ */ jsxRuntime.jsx(
616
+ "input",
617
+ {
618
+ type: "checkbox",
619
+ checked: form.enableLogging,
620
+ onChange: (e) => setForm((p) => ({ ...p, enableLogging: e.target.checked })),
621
+ className: "h-4 w-4 rounded border-ui-border-base"
622
+ }
623
+ ),
624
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable logging" })
625
+ ] })
626
+ }
627
+ )
628
628
  ] })
629
629
  }
630
630
  )
631
631
  ] }) });
632
632
  }
633
- function PayPalApplePayPage() {
634
- return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
635
- }
636
633
  const config = adminSdk.defineRouteConfig({
637
634
  label: "PayPal Connection",
638
635
  hide: true
@@ -1217,84 +1214,8 @@ function PayPalConnectionPage() {
1217
1214
  ` })
1218
1215
  ] });
1219
1216
  }
1220
- function formatDate$2(value) {
1221
- if (!value) {
1222
- return "";
1223
- }
1224
- const parsed = new Date(value);
1225
- if (Number.isNaN(parsed.getTime())) {
1226
- return value;
1227
- }
1228
- return parsed.toLocaleString();
1229
- }
1230
- function PayPalAuditLogsPage() {
1231
- const [logs, setLogs] = react.useState([]);
1232
- const [loading, setLoading] = react.useState(false);
1233
- const [error, setError] = react.useState(null);
1234
- const fetchLogs = react.useCallback(async () => {
1235
- try {
1236
- setLoading(true);
1237
- setError(null);
1238
- const response = await fetch("/admin/paypal/audit-logs?limit=50", {
1239
- credentials: "include",
1240
- headers: {
1241
- Accept: "application/json"
1242
- }
1243
- });
1244
- if (!response.ok) {
1245
- const message = await response.text().catch(() => "");
1246
- throw new Error(message || "Failed to load audit logs.");
1247
- }
1248
- const data = await response.json().catch(() => ({}));
1249
- setLogs((data == null ? void 0 : data.logs) || []);
1250
- } catch (fetchError) {
1251
- setError((fetchError == null ? void 0 : fetchError.message) || "Failed to load audit logs.");
1252
- setLogs([]);
1253
- } finally {
1254
- setLoading(false);
1255
- }
1256
- }, []);
1257
- react.useEffect(() => {
1258
- fetchLogs();
1259
- }, [fetchLogs]);
1260
- return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
1261
- /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1262
- /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Audit Logs" }),
1263
- /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-ui-fg-subtle", children: "Track administrative changes and credential events for PayPal configuration." })
1264
- ] }),
1265
- /* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
1266
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
1267
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-b border-ui-border-base p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
1268
- /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: "Latest events" }),
1269
- /* @__PURE__ */ jsxRuntime.jsx(
1270
- "button",
1271
- {
1272
- type: "button",
1273
- onClick: fetchLogs,
1274
- className: "rounded-md border border-ui-border-base px-3 py-2 text-sm text-ui-fg-base",
1275
- disabled: loading,
1276
- children: loading ? "Refreshing..." : "Refresh"
1277
- }
1278
- )
1279
- ] }) }),
1280
- /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4", children: [
1281
- error ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error }) : null,
1282
- !error && logs.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-ui-fg-subtle", children: loading ? "Loading audit logs..." : "No audit log entries found yet." }) : null,
1283
- logs.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full text-left text-sm", children: [
1284
- /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "text-ui-fg-muted", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1285
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "pb-2 pr-4 font-medium", children: "Timestamp" }),
1286
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "pb-2 pr-4 font-medium", children: "Event" }),
1287
- /* @__PURE__ */ jsxRuntime.jsx("th", { className: "pb-2 font-medium", children: "Details" })
1288
- ] }) }),
1289
- /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: logs.map((entry) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "border-t border-ui-border-base", children: [
1290
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-3 pr-4 text-ui-fg-base", children: formatDate$2(entry.created_at) || "—" }),
1291
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-3 pr-4 text-ui-fg-base", children: entry.event_type || "—" }),
1292
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-3 text-ui-fg-subtle", children: /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre-wrap rounded-md bg-ui-bg-subtle p-2 text-xs text-ui-fg-subtle", children: JSON.stringify(entry.metadata || {}, null, 2) }) })
1293
- ] }, entry.id)) })
1294
- ] }) }) : null
1295
- ] })
1296
- ] })
1297
- ] }) });
1217
+ function PayPalApplePayPage() {
1218
+ return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
1298
1219
  }
1299
1220
  const EMPTY_FILTERS = {
1300
1221
  dispute_id: "",
@@ -1302,7 +1223,7 @@ const EMPTY_FILTERS = {
1302
1223
  order_id: "",
1303
1224
  cart_id: ""
1304
1225
  };
1305
- function formatDate$1(value) {
1226
+ function formatDate$2(value) {
1306
1227
  if (!value) {
1307
1228
  return "";
1308
1229
  }
@@ -1481,7 +1402,7 @@ function PayPalDisputesPage() {
1481
1402
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-3", children: dispute.amount ? `${dispute.amount} ${dispute.currency_code || ""}` : "-" }),
1482
1403
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-3", children: dispute.order_id || "-" }),
1483
1404
  /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-3", children: dispute.cart_id || "-" }),
1484
- /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-3 text-ui-fg-subtle", children: formatDate$1(dispute.updated_at || dispute.created_at) })
1405
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "px-4 py-3 text-ui-fg-subtle", children: formatDate$2(dispute.updated_at || dispute.created_at) })
1485
1406
  ] }, dispute.id)) })
1486
1407
  ] }) }),
1487
1408
  error ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-t border-ui-border-base px-4 py-3 text-sm text-ui-fg-error", children: error }) : null
@@ -1491,6 +1412,85 @@ function PayPalDisputesPage() {
1491
1412
  function PayPalGooglePayPage() {
1492
1413
  return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
1493
1414
  }
1415
+ function formatDate$1(value) {
1416
+ if (!value) {
1417
+ return "";
1418
+ }
1419
+ const parsed = new Date(value);
1420
+ if (Number.isNaN(parsed.getTime())) {
1421
+ return value;
1422
+ }
1423
+ return parsed.toLocaleString();
1424
+ }
1425
+ function PayPalAuditLogsPage() {
1426
+ const [logs, setLogs] = react.useState([]);
1427
+ const [loading, setLoading] = react.useState(false);
1428
+ const [error, setError] = react.useState(null);
1429
+ const fetchLogs = react.useCallback(async () => {
1430
+ try {
1431
+ setLoading(true);
1432
+ setError(null);
1433
+ const response = await fetch("/admin/paypal/audit-logs?limit=50", {
1434
+ credentials: "include",
1435
+ headers: {
1436
+ Accept: "application/json"
1437
+ }
1438
+ });
1439
+ if (!response.ok) {
1440
+ const message = await response.text().catch(() => "");
1441
+ throw new Error(message || "Failed to load audit logs.");
1442
+ }
1443
+ const data = await response.json().catch(() => ({}));
1444
+ setLogs((data == null ? void 0 : data.logs) || []);
1445
+ } catch (fetchError) {
1446
+ setError((fetchError == null ? void 0 : fetchError.message) || "Failed to load audit logs.");
1447
+ setLogs([]);
1448
+ } finally {
1449
+ setLoading(false);
1450
+ }
1451
+ }, []);
1452
+ react.useEffect(() => {
1453
+ fetchLogs();
1454
+ }, [fetchLogs]);
1455
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
1456
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
1457
+ /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl font-semibold text-ui-fg-base", children: "PayPal Audit Logs" }),
1458
+ /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-ui-fg-subtle", children: "Track administrative changes and credential events for PayPal configuration." })
1459
+ ] }),
1460
+ /* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
1461
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
1462
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "border-b border-ui-border-base p-4", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center justify-between gap-4", children: [
1463
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: "Latest events" }),
1464
+ /* @__PURE__ */ jsxRuntime.jsx(
1465
+ "button",
1466
+ {
1467
+ type: "button",
1468
+ onClick: fetchLogs,
1469
+ className: "rounded-md border border-ui-border-base px-3 py-2 text-sm text-ui-fg-base",
1470
+ disabled: loading,
1471
+ children: loading ? "Refreshing..." : "Refresh"
1472
+ }
1473
+ )
1474
+ ] }) }),
1475
+ /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-4", children: [
1476
+ error ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-red-200 bg-red-50 p-3 text-sm text-red-600", children: error }) : null,
1477
+ !error && logs.length === 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm text-ui-fg-subtle", children: loading ? "Loading audit logs..." : "No audit log entries found yet." }) : null,
1478
+ logs.length > 0 ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "overflow-x-auto", children: /* @__PURE__ */ jsxRuntime.jsxs("table", { className: "min-w-full text-left text-sm", children: [
1479
+ /* @__PURE__ */ jsxRuntime.jsx("thead", { className: "text-ui-fg-muted", children: /* @__PURE__ */ jsxRuntime.jsxs("tr", { children: [
1480
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "pb-2 pr-4 font-medium", children: "Timestamp" }),
1481
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "pb-2 pr-4 font-medium", children: "Event" }),
1482
+ /* @__PURE__ */ jsxRuntime.jsx("th", { className: "pb-2 font-medium", children: "Details" })
1483
+ ] }) }),
1484
+ /* @__PURE__ */ jsxRuntime.jsx("tbody", { children: logs.map((entry) => /* @__PURE__ */ jsxRuntime.jsxs("tr", { className: "border-t border-ui-border-base", children: [
1485
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-3 pr-4 text-ui-fg-base", children: formatDate$1(entry.created_at) || "—" }),
1486
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-3 pr-4 text-ui-fg-base", children: entry.event_type || "—" }),
1487
+ /* @__PURE__ */ jsxRuntime.jsx("td", { className: "py-3 text-ui-fg-subtle", children: /* @__PURE__ */ jsxRuntime.jsx("pre", { className: "whitespace-pre-wrap rounded-md bg-ui-bg-subtle p-2 text-xs text-ui-fg-subtle", children: JSON.stringify(entry.metadata || {}, null, 2) }) })
1488
+ ] }, entry.id)) })
1489
+ ] }) }) : null
1490
+ ] })
1491
+ ] })
1492
+ ] }) });
1493
+ }
1494
1494
  function PayPalPayLaterMessagingPage() {
1495
1495
  return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
1496
1496
  }
@@ -2048,25 +2048,21 @@ const routeModule = {
2048
2048
  Component: PayPalSettingsIndexRoute,
2049
2049
  path: "/settings/paypal"
2050
2050
  },
2051
- {
2052
- Component: AdditionalSettingsTab,
2053
- path: "/settings/paypal/additional-settings"
2054
- },
2055
2051
  {
2056
2052
  Component: AdvancedCardPaymentsTab,
2057
2053
  path: "/settings/paypal/advanced-card-payments"
2058
2054
  },
2059
2055
  {
2060
- Component: PayPalApplePayPage,
2061
- path: "/settings/paypal/apple-pay"
2056
+ Component: AdditionalSettingsTab,
2057
+ path: "/settings/paypal/additional-settings"
2062
2058
  },
2063
2059
  {
2064
2060
  Component: PayPalConnectionPage,
2065
2061
  path: "/settings/paypal/connection"
2066
2062
  },
2067
2063
  {
2068
- Component: PayPalAuditLogsPage,
2069
- path: "/settings/paypal/audit-logs"
2064
+ Component: PayPalApplePayPage,
2065
+ path: "/settings/paypal/apple-pay"
2070
2066
  },
2071
2067
  {
2072
2068
  Component: PayPalDisputesPage,
@@ -2076,6 +2072,10 @@ const routeModule = {
2076
2072
  Component: PayPalGooglePayPage,
2077
2073
  path: "/settings/paypal/google-pay"
2078
2074
  },
2075
+ {
2076
+ Component: PayPalAuditLogsPage,
2077
+ path: "/settings/paypal/audit-logs"
2078
+ },
2079
2079
  {
2080
2080
  Component: PayPalPayLaterMessagingPage,
2081
2081
  path: "/settings/paypal/pay-later-messaging"