@easypayment/medusa-payment-paypal 1.3.3 → 1.3.5

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.
Files changed (41) hide show
  1. package/.medusa/server/src/admin/index.js +250 -166
  2. package/.medusa/server/src/admin/index.mjs +250 -166
  3. package/.medusa/server/src/api/admin/paypal/logs/route.d.ts +10 -0
  4. package/.medusa/server/src/api/admin/paypal/logs/route.d.ts.map +1 -0
  5. package/.medusa/server/src/api/admin/paypal/logs/route.js +43 -0
  6. package/.medusa/server/src/api/admin/paypal/logs/route.js.map +1 -0
  7. package/.medusa/server/src/api/middlewares.d.ts.map +1 -1
  8. package/.medusa/server/src/api/middlewares.js +22 -4
  9. package/.medusa/server/src/api/middlewares.js.map +1 -1
  10. package/.medusa/server/src/api/utils/request-logger.d.ts +11 -0
  11. package/.medusa/server/src/api/utils/request-logger.d.ts.map +1 -0
  12. package/.medusa/server/src/api/utils/request-logger.js +69 -0
  13. package/.medusa/server/src/api/utils/request-logger.js.map +1 -0
  14. package/.medusa/server/src/modules/paypal/payment-provider/base-provider.d.ts +3 -3
  15. package/.medusa/server/src/modules/paypal/service.d.ts.map +1 -1
  16. package/.medusa/server/src/modules/paypal/service.js +19 -3
  17. package/.medusa/server/src/modules/paypal/service.js.map +1 -1
  18. package/.medusa/server/src/modules/paypal/types/config.js +1 -1
  19. package/.medusa/server/src/modules/paypal/types/config.js.map +1 -1
  20. package/.medusa/server/src/modules/paypal/utils/credential-resolver.d.ts.map +1 -1
  21. package/.medusa/server/src/modules/paypal/utils/credential-resolver.js +10 -0
  22. package/.medusa/server/src/modules/paypal/utils/credential-resolver.js.map +1 -1
  23. package/.medusa/server/src/modules/paypal/utils/paypal-fetch.d.ts.map +1 -1
  24. package/.medusa/server/src/modules/paypal/utils/paypal-fetch.js +39 -0
  25. package/.medusa/server/src/modules/paypal/utils/paypal-fetch.js.map +1 -1
  26. package/.medusa/server/src/modules/paypal/utils/request-logger.d.ts +62 -0
  27. package/.medusa/server/src/modules/paypal/utils/request-logger.d.ts.map +1 -0
  28. package/.medusa/server/src/modules/paypal/utils/request-logger.js +297 -0
  29. package/.medusa/server/src/modules/paypal/utils/request-logger.js.map +1 -0
  30. package/CHANGELOG.md +27 -0
  31. package/README.md +4 -0
  32. package/package.json +1 -1
  33. package/src/admin/routes/settings/paypal/additional-settings/page.tsx +87 -0
  34. package/src/api/admin/paypal/logs/route.ts +50 -0
  35. package/src/api/middlewares.ts +22 -4
  36. package/src/api/utils/request-logger.ts +84 -0
  37. package/src/modules/paypal/service.ts +21 -3
  38. package/src/modules/paypal/types/config.ts +1 -1
  39. package/src/modules/paypal/utils/credential-resolver.ts +9 -0
  40. package/src/modules/paypal/utils/paypal-fetch.ts +42 -0
  41. package/src/modules/paypal/utils/request-logger.ts +358 -0
@@ -155,13 +155,9 @@ async function adminFetch(path, opts = {}) {
155
155
  }
156
156
  }
157
157
  const DEFAULT_FORM$1 = {
158
- paymentAction: "capture",
159
- brandName: "PayPal",
160
- landingPage: "no_preference",
161
- requireInstantPayment: false,
162
- sendItemDetails: true,
163
- invoicePrefix: "PP-",
164
- creditCardStatementName: "PayPal"
158
+ enabled: true,
159
+ title: "Credit or Debit Card",
160
+ threeDS: "when_required"
165
161
  };
166
162
  function mergeWithDefaults$1(saved) {
167
163
  if (!saved) return { ...DEFAULT_FORM$1 };
@@ -173,7 +169,25 @@ function mergeWithDefaults$1(saved) {
173
169
  ...Object.fromEntries(entries)
174
170
  };
175
171
  }
176
- function AdditionalSettingsTab() {
172
+ const THREE_DS_OPTIONS = [
173
+ {
174
+ value: "when_required",
175
+ label: "3D Secure when required",
176
+ hint: "Triggers 3DS only when the card / issuer requires it."
177
+ },
178
+ {
179
+ value: "sli",
180
+ label: "3D Secure (SCA) / liability shift (recommended)",
181
+ hint: "Attempts to optimize for liability shift while remaining compliant."
182
+ },
183
+ {
184
+ value: "always",
185
+ label: "Always request 3D Secure",
186
+ hint: "Forces 3DS challenge whenever possible (may reduce conversion)."
187
+ }
188
+ ];
189
+ function AdvancedCardPaymentsTab() {
190
+ var _a, _b;
177
191
  const [form, setForm] = react.useState(() => ({
178
192
  ...DEFAULT_FORM$1
179
193
  }));
@@ -190,7 +204,7 @@ function AdditionalSettingsTab() {
190
204
  setLoading(true);
191
205
  const json = await adminFetch("/admin/paypal/settings");
192
206
  const payload = (json == null ? void 0 : json.data) ?? json;
193
- const saved = payload == null ? void 0 : payload.additional_settings;
207
+ const saved = payload == null ? void 0 : payload.advanced_card_payments;
194
208
  if (saved && typeof saved === "object")
195
209
  setForm(mergeWithDefaults$1(saved));
196
210
  } catch {
@@ -202,21 +216,20 @@ function AdditionalSettingsTab() {
202
216
  async function onSave() {
203
217
  try {
204
218
  setSaving(true);
205
- setToast(null);
206
219
  const json = await adminFetch("/admin/paypal/settings", {
207
220
  method: "POST",
208
221
  body: {
209
- additional_settings: form
222
+ advanced_card_payments: form
210
223
  }
211
224
  });
212
225
  const payload = (json == null ? void 0 : json.data) ?? json;
213
- const saved = payload == null ? void 0 : payload.additional_settings;
226
+ const saved = payload == null ? void 0 : payload.advanced_card_payments;
214
227
  if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
215
228
  setToast({ kind: "success", message: "Settings saved" });
216
229
  } catch (e) {
217
230
  setToast({
218
231
  kind: "error",
219
- message: e instanceof Error ? e.message : "Failed to save settings"
232
+ message: (e instanceof Error ? e.message : "") || "Failed to save settings."
220
233
  });
221
234
  } finally {
222
235
  setSaving(false);
@@ -229,8 +242,8 @@ function AdditionalSettingsTab() {
229
242
  /* @__PURE__ */ jsxRuntime.jsx(
230
243
  SectionCard,
231
244
  {
232
- title: "Additional Settings",
233
- description: "These settings control checkout behavior and PayPal experience.",
245
+ title: "Advanced Card Payments",
246
+ description: "Control card checkout settings and 3D Secure behavior.",
234
247
  right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
235
248
  /* @__PURE__ */ jsxRuntime.jsx(
236
249
  "button",
@@ -245,115 +258,51 @@ function AdditionalSettingsTab() {
245
258
  loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
246
259
  ] }),
247
260
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
248
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Payment action", htmlFor: "as-payment-action", children: /* @__PURE__ */ jsxRuntime.jsxs(
249
- "select",
250
- {
251
- id: "as-payment-action",
252
- value: form.paymentAction,
253
- onChange: (e) => setForm((p) => ({
254
- ...p,
255
- paymentAction: e.target.value
256
- })),
257
- 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",
258
- children: [
259
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "capture", children: "Capture" }),
260
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "authorize", children: "Authorize" })
261
- ]
262
- }
263
- ) }),
264
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Brand Name", htmlFor: "as-brand-name", children: /* @__PURE__ */ jsxRuntime.jsx(
265
- "input",
266
- {
267
- id: "as-brand-name",
268
- value: form.brandName,
269
- onChange: (e) => setForm((p) => ({ ...p, brandName: e.target.value })),
270
- 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",
271
- placeholder: "PayPal"
272
- }
273
- ) }),
274
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Landing Page", htmlFor: "as-landing-page", children: /* @__PURE__ */ jsxRuntime.jsxs(
275
- "select",
276
- {
277
- id: "as-landing-page",
278
- value: form.landingPage,
279
- onChange: (e) => setForm((p) => ({
280
- ...p,
281
- landingPage: e.target.value
282
- })),
283
- 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",
284
- children: [
285
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "no_preference", children: "No Preference" }),
286
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "login", children: "Login" }),
287
- /* @__PURE__ */ jsxRuntime.jsx("option", { value: "billing", children: "Billing" })
288
- ]
289
- }
290
- ) }),
291
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Instant Payments", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
261
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Enable/Disable", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
292
262
  /* @__PURE__ */ jsxRuntime.jsx(
293
263
  "input",
294
264
  {
295
265
  type: "checkbox",
296
- checked: form.requireInstantPayment,
297
- onChange: (e) => setForm((p) => ({
298
- ...p,
299
- requireInstantPayment: e.target.checked
300
- })),
266
+ checked: form.enabled,
267
+ onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })),
301
268
  className: "h-4 w-4 rounded border-ui-border-base"
302
269
  }
303
270
  ),
304
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Require Instant Payment" })
271
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
305
272
  ] }) }),
273
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Title", htmlFor: "acp-title", children: /* @__PURE__ */ jsxRuntime.jsx(
274
+ "input",
275
+ {
276
+ id: "acp-title",
277
+ value: form.title,
278
+ onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })),
279
+ 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",
280
+ placeholder: "Credit or Debit Card"
281
+ }
282
+ ) }),
306
283
  /* @__PURE__ */ jsxRuntime.jsx(
307
284
  FieldRow,
308
285
  {
309
- label: "Send Item Details",
310
- hint: "Include all line item details in the payment request to PayPal so that they can be seen from the PayPal transaction details page.",
311
- children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
286
+ label: "Contingency for 3D Secure",
287
+ hint: "Choose when 3D Secure should be triggered during card payments.",
288
+ htmlFor: "acp-threeds",
289
+ children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
312
290
  /* @__PURE__ */ jsxRuntime.jsx(
313
- "input",
291
+ "select",
314
292
  {
315
- type: "checkbox",
316
- checked: form.sendItemDetails,
293
+ id: "acp-threeds",
294
+ value: form.threeDS,
317
295
  onChange: (e) => setForm((p) => ({
318
296
  ...p,
319
- sendItemDetails: e.target.checked
297
+ threeDS: e.target.value
320
298
  })),
321
- className: "h-4 w-4 rounded border-ui-border-base"
299
+ 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",
300
+ children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value))
322
301
  }
323
302
  ),
324
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Send line item details to PayPal" })
303
+ ((_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
325
304
  ] })
326
305
  }
327
- ),
328
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Invoice prefix", htmlFor: "as-invoice-prefix", children: /* @__PURE__ */ jsxRuntime.jsx(
329
- "input",
330
- {
331
- id: "as-invoice-prefix",
332
- value: form.invoicePrefix,
333
- onChange: (e) => setForm((p) => ({ ...p, invoicePrefix: e.target.value })),
334
- 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",
335
- placeholder: "PP-"
336
- }
337
- ) }),
338
- /* @__PURE__ */ jsxRuntime.jsx(
339
- FieldRow,
340
- {
341
- label: "Credit Card Statement Name",
342
- htmlFor: "as-cc-statement",
343
- children: /* @__PURE__ */ jsxRuntime.jsx(
344
- "input",
345
- {
346
- id: "as-cc-statement",
347
- value: form.creditCardStatementName,
348
- onChange: (e) => setForm((p) => ({
349
- ...p,
350
- creditCardStatementName: e.target.value
351
- })),
352
- 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",
353
- placeholder: "PayPal"
354
- }
355
- )
356
- }
357
306
  )
358
307
  ] })
359
308
  }
@@ -361,9 +310,14 @@ function AdditionalSettingsTab() {
361
310
  ] }) });
362
311
  }
363
312
  const DEFAULT_FORM = {
364
- enabled: true,
365
- title: "Credit or Debit Card",
366
- threeDS: "when_required"
313
+ paymentAction: "capture",
314
+ brandName: "PayPal",
315
+ landingPage: "no_preference",
316
+ requireInstantPayment: false,
317
+ sendItemDetails: true,
318
+ invoicePrefix: "PP-",
319
+ creditCardStatementName: "PayPal",
320
+ debugLogging: false
367
321
  };
368
322
  function mergeWithDefaults(saved) {
369
323
  if (!saved) return { ...DEFAULT_FORM };
@@ -375,33 +329,59 @@ function mergeWithDefaults(saved) {
375
329
  ...Object.fromEntries(entries)
376
330
  };
377
331
  }
378
- const THREE_DS_OPTIONS = [
379
- {
380
- value: "when_required",
381
- label: "3D Secure when required",
382
- hint: "Triggers 3DS only when the card / issuer requires it."
383
- },
384
- {
385
- value: "sli",
386
- label: "3D Secure (SCA) / liability shift (recommended)",
387
- hint: "Attempts to optimize for liability shift while remaining compliant."
388
- },
389
- {
390
- value: "always",
391
- label: "Always request 3D Secure",
392
- hint: "Forces 3DS challenge whenever possible (may reduce conversion)."
393
- }
394
- ];
395
- function AdvancedCardPaymentsTab() {
396
- var _a, _b;
332
+ function AdditionalSettingsTab() {
397
333
  const [form, setForm] = react.useState(() => ({
398
334
  ...DEFAULT_FORM
399
335
  }));
400
336
  const [loading, setLoading] = react.useState(false);
401
337
  const [saving, setSaving] = react.useState(false);
338
+ const [downloading, setDownloading] = react.useState(false);
402
339
  const [toast, setToast] = react.useState(null);
403
340
  const didInit = react.useRef(false);
404
341
  const dismissToast = react.useCallback(() => setToast(null), []);
342
+ async function onDownloadLog() {
343
+ var _a;
344
+ try {
345
+ setDownloading(true);
346
+ setToast(null);
347
+ const headers = { Accept: "text/plain" };
348
+ if (typeof window !== "undefined") {
349
+ const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
350
+ if (token) headers["Authorization"] = `Bearer ${token}`;
351
+ }
352
+ const res = await fetch("/admin/paypal/logs?download=1", {
353
+ headers,
354
+ credentials: "include"
355
+ });
356
+ if (!res.ok) {
357
+ if (res.status === 404) {
358
+ throw new Error(
359
+ "No log file yet. Enable logging, run a test transaction, then download."
360
+ );
361
+ }
362
+ throw new Error(`Download failed (${res.status})`);
363
+ }
364
+ const blob = await res.blob();
365
+ const dispo = res.headers.get("Content-Disposition") || "";
366
+ const match = dispo.match(/filename="?([^"]+)"?/);
367
+ const filename = (match == null ? void 0 : match[1]) || "paypal-requests.log";
368
+ const url = URL.createObjectURL(blob);
369
+ const a = document.createElement("a");
370
+ a.href = url;
371
+ a.download = filename;
372
+ document.body.appendChild(a);
373
+ a.click();
374
+ a.remove();
375
+ URL.revokeObjectURL(url);
376
+ } catch (e) {
377
+ setToast({
378
+ kind: "error",
379
+ message: e instanceof Error ? e.message : "Failed to download log"
380
+ });
381
+ } finally {
382
+ setDownloading(false);
383
+ }
384
+ }
405
385
  react.useEffect(() => {
406
386
  if (didInit.current) return;
407
387
  didInit.current = true;
@@ -410,7 +390,7 @@ function AdvancedCardPaymentsTab() {
410
390
  setLoading(true);
411
391
  const json = await adminFetch("/admin/paypal/settings");
412
392
  const payload = (json == null ? void 0 : json.data) ?? json;
413
- const saved = payload == null ? void 0 : payload.advanced_card_payments;
393
+ const saved = payload == null ? void 0 : payload.additional_settings;
414
394
  if (saved && typeof saved === "object")
415
395
  setForm(mergeWithDefaults(saved));
416
396
  } catch {
@@ -422,20 +402,21 @@ function AdvancedCardPaymentsTab() {
422
402
  async function onSave() {
423
403
  try {
424
404
  setSaving(true);
405
+ setToast(null);
425
406
  const json = await adminFetch("/admin/paypal/settings", {
426
407
  method: "POST",
427
408
  body: {
428
- advanced_card_payments: form
409
+ additional_settings: form
429
410
  }
430
411
  });
431
412
  const payload = (json == null ? void 0 : json.data) ?? json;
432
- const saved = payload == null ? void 0 : payload.advanced_card_payments;
413
+ const saved = payload == null ? void 0 : payload.additional_settings;
433
414
  if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
434
415
  setToast({ kind: "success", message: "Settings saved" });
435
416
  } catch (e) {
436
417
  setToast({
437
418
  kind: "error",
438
- message: (e instanceof Error ? e.message : "") || "Failed to save settings."
419
+ message: e instanceof Error ? e.message : "Failed to save settings"
439
420
  });
440
421
  } finally {
441
422
  setSaving(false);
@@ -448,8 +429,8 @@ function AdvancedCardPaymentsTab() {
448
429
  /* @__PURE__ */ jsxRuntime.jsx(
449
430
  SectionCard,
450
431
  {
451
- title: "Advanced Card Payments",
452
- description: "Control card checkout settings and 3D Secure behavior.",
432
+ title: "Additional Settings",
433
+ description: "These settings control checkout behavior and PayPal experience.",
453
434
  right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
454
435
  /* @__PURE__ */ jsxRuntime.jsx(
455
436
  "button",
@@ -464,60 +445,160 @@ function AdvancedCardPaymentsTab() {
464
445
  loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
465
446
  ] }),
466
447
  children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
467
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Enable/Disable", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
448
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Payment action", htmlFor: "as-payment-action", children: /* @__PURE__ */ jsxRuntime.jsxs(
449
+ "select",
450
+ {
451
+ id: "as-payment-action",
452
+ value: form.paymentAction,
453
+ onChange: (e) => setForm((p) => ({
454
+ ...p,
455
+ paymentAction: e.target.value
456
+ })),
457
+ 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",
458
+ children: [
459
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "capture", children: "Capture" }),
460
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "authorize", children: "Authorize" })
461
+ ]
462
+ }
463
+ ) }),
464
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Brand Name", htmlFor: "as-brand-name", children: /* @__PURE__ */ jsxRuntime.jsx(
465
+ "input",
466
+ {
467
+ id: "as-brand-name",
468
+ value: form.brandName,
469
+ onChange: (e) => setForm((p) => ({ ...p, brandName: e.target.value })),
470
+ 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",
471
+ placeholder: "PayPal"
472
+ }
473
+ ) }),
474
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Landing Page", htmlFor: "as-landing-page", children: /* @__PURE__ */ jsxRuntime.jsxs(
475
+ "select",
476
+ {
477
+ id: "as-landing-page",
478
+ value: form.landingPage,
479
+ onChange: (e) => setForm((p) => ({
480
+ ...p,
481
+ landingPage: e.target.value
482
+ })),
483
+ 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",
484
+ children: [
485
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "no_preference", children: "No Preference" }),
486
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "login", children: "Login" }),
487
+ /* @__PURE__ */ jsxRuntime.jsx("option", { value: "billing", children: "Billing" })
488
+ ]
489
+ }
490
+ ) }),
491
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Instant Payments", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
468
492
  /* @__PURE__ */ jsxRuntime.jsx(
469
493
  "input",
470
494
  {
471
495
  type: "checkbox",
472
- checked: form.enabled,
473
- onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })),
496
+ checked: form.requireInstantPayment,
497
+ onChange: (e) => setForm((p) => ({
498
+ ...p,
499
+ requireInstantPayment: e.target.checked
500
+ })),
474
501
  className: "h-4 w-4 rounded border-ui-border-base"
475
502
  }
476
503
  ),
477
- /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
504
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Require Instant Payment" })
478
505
  ] }) }),
479
- /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Title", htmlFor: "acp-title", children: /* @__PURE__ */ jsxRuntime.jsx(
480
- "input",
481
- {
482
- id: "acp-title",
483
- value: form.title,
484
- onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })),
485
- 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",
486
- placeholder: "Credit or Debit Card"
487
- }
488
- ) }),
489
506
  /* @__PURE__ */ jsxRuntime.jsx(
490
507
  FieldRow,
491
508
  {
492
- label: "Contingency for 3D Secure",
493
- hint: "Choose when 3D Secure should be triggered during card payments.",
494
- htmlFor: "acp-threeds",
495
- children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
509
+ label: "Send Item Details",
510
+ hint: "Include all line item details in the payment request to PayPal so that they can be seen from the PayPal transaction details page.",
511
+ children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
496
512
  /* @__PURE__ */ jsxRuntime.jsx(
497
- "select",
513
+ "input",
498
514
  {
499
- id: "acp-threeds",
500
- value: form.threeDS,
515
+ type: "checkbox",
516
+ checked: form.sendItemDetails,
501
517
  onChange: (e) => setForm((p) => ({
502
518
  ...p,
503
- threeDS: e.target.value
519
+ sendItemDetails: e.target.checked
504
520
  })),
505
- 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",
506
- children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value))
521
+ className: "h-4 w-4 rounded border-ui-border-base"
507
522
  }
508
523
  ),
509
- ((_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
524
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Send line item details to PayPal" })
510
525
  ] })
511
526
  }
527
+ ),
528
+ /* @__PURE__ */ jsxRuntime.jsx(FieldRow, { label: "Invoice prefix", htmlFor: "as-invoice-prefix", children: /* @__PURE__ */ jsxRuntime.jsx(
529
+ "input",
530
+ {
531
+ id: "as-invoice-prefix",
532
+ value: form.invoicePrefix,
533
+ onChange: (e) => setForm((p) => ({ ...p, invoicePrefix: e.target.value })),
534
+ 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",
535
+ placeholder: "PP-"
536
+ }
537
+ ) }),
538
+ /* @__PURE__ */ jsxRuntime.jsx(
539
+ FieldRow,
540
+ {
541
+ label: "Credit Card Statement Name",
542
+ htmlFor: "as-cc-statement",
543
+ children: /* @__PURE__ */ jsxRuntime.jsx(
544
+ "input",
545
+ {
546
+ id: "as-cc-statement",
547
+ value: form.creditCardStatementName,
548
+ onChange: (e) => setForm((p) => ({
549
+ ...p,
550
+ creditCardStatementName: e.target.value
551
+ })),
552
+ 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",
553
+ placeholder: "PayPal"
554
+ }
555
+ )
556
+ }
512
557
  )
513
558
  ] })
514
559
  }
560
+ ),
561
+ /* @__PURE__ */ jsxRuntime.jsx(
562
+ SectionCard,
563
+ {
564
+ title: "Integration logging (PayPal review)",
565
+ description: "Write every PayPal API request/response and plugin API request/response to a log file you can download and send to PayPal for integration approval. Credentials (auth tokens, client secrets, card fields) are redacted; the BN code is kept. Keep this OFF in normal production use.",
566
+ right: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ jsxRuntime.jsx(
567
+ "button",
568
+ {
569
+ type: "button",
570
+ onClick: onDownloadLog,
571
+ disabled: downloading,
572
+ className: "transition-fg relative inline-flex w-fit items-center justify-center overflow-hidden rounded-md outline-none shadow-buttons-neutral text-ui-fg-base bg-ui-button-neutral after:transition-fg after:absolute after:inset-0 after:content-[''] after:button-neutral-gradient hover:bg-ui-button-neutral-hover hover:after:button-neutral-hover-gradient active:bg-ui-button-neutral-pressed active:after:button-neutral-pressed-gradient focus-visible:shadow-buttons-neutral-focus disabled:bg-ui-bg-disabled disabled:border-ui-border-base disabled:text-ui-fg-disabled disabled:shadow-buttons-neutral disabled:after:hidden txt-compact-small-plus px-3 py-1.5",
573
+ children: downloading ? "Preparing…" : "Download log"
574
+ }
575
+ ) }),
576
+ children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "divide-y divide-ui-border-base", children: /* @__PURE__ */ jsxRuntime.jsx(
577
+ FieldRow,
578
+ {
579
+ label: "Request/response logging",
580
+ hint: "When enabled, the plugin appends each request and response to logs/paypal-requests-YYYY-MM-DD.log (path configurable via PAYPAL_LOG_DIR). Remember to save after toggling.",
581
+ children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
582
+ /* @__PURE__ */ jsxRuntime.jsx(
583
+ "input",
584
+ {
585
+ type: "checkbox",
586
+ checked: form.debugLogging,
587
+ onChange: (e) => setForm((p) => ({
588
+ ...p,
589
+ debugLogging: e.target.checked
590
+ })),
591
+ className: "h-4 w-4 rounded border-ui-border-base"
592
+ }
593
+ ),
594
+ /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable request/response log file" })
595
+ ] })
596
+ }
597
+ ) })
598
+ }
515
599
  )
516
600
  ] }) });
517
601
  }
518
- function PayPalApplePayPage() {
519
- return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
520
- }
521
602
  function PayPalGooglePayPage() {
522
603
  return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
523
604
  }
@@ -1276,6 +1357,9 @@ function PayPalConnectionPage() {
1276
1357
  ` })
1277
1358
  ] });
1278
1359
  }
1360
+ function PayPalApplePayPage() {
1361
+ return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
1362
+ }
1279
1363
  function PayPalPayLaterMessagingPage() {
1280
1364
  return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
1281
1365
  }
@@ -1502,17 +1586,13 @@ const routeModule = {
1502
1586
  Component: PayPalSettingsIndexRoute,
1503
1587
  path: "/settings/paypal"
1504
1588
  },
1505
- {
1506
- Component: AdditionalSettingsTab,
1507
- path: "/settings/paypal/additional-settings"
1508
- },
1509
1589
  {
1510
1590
  Component: AdvancedCardPaymentsTab,
1511
1591
  path: "/settings/paypal/advanced-card-payments"
1512
1592
  },
1513
1593
  {
1514
- Component: PayPalApplePayPage,
1515
- path: "/settings/paypal/apple-pay"
1594
+ Component: AdditionalSettingsTab,
1595
+ path: "/settings/paypal/additional-settings"
1516
1596
  },
1517
1597
  {
1518
1598
  Component: PayPalGooglePayPage,
@@ -1522,6 +1602,10 @@ const routeModule = {
1522
1602
  Component: PayPalConnectionPage,
1523
1603
  path: "/settings/paypal/connection"
1524
1604
  },
1605
+ {
1606
+ Component: PayPalApplePayPage,
1607
+ path: "/settings/paypal/apple-pay"
1608
+ },
1525
1609
  {
1526
1610
  Component: PayPalPayLaterMessagingPage,
1527
1611
  path: "/settings/paypal/pay-later-messaging"