@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
@@ -154,13 +154,9 @@ async function adminFetch(path, opts = {}) {
154
154
  }
155
155
  }
156
156
  const DEFAULT_FORM$1 = {
157
- paymentAction: "capture",
158
- brandName: "PayPal",
159
- landingPage: "no_preference",
160
- requireInstantPayment: false,
161
- sendItemDetails: true,
162
- invoicePrefix: "PP-",
163
- creditCardStatementName: "PayPal"
157
+ enabled: true,
158
+ title: "Credit or Debit Card",
159
+ threeDS: "when_required"
164
160
  };
165
161
  function mergeWithDefaults$1(saved) {
166
162
  if (!saved) return { ...DEFAULT_FORM$1 };
@@ -172,7 +168,25 @@ function mergeWithDefaults$1(saved) {
172
168
  ...Object.fromEntries(entries)
173
169
  };
174
170
  }
175
- function AdditionalSettingsTab() {
171
+ const THREE_DS_OPTIONS = [
172
+ {
173
+ value: "when_required",
174
+ label: "3D Secure when required",
175
+ hint: "Triggers 3DS only when the card / issuer requires it."
176
+ },
177
+ {
178
+ value: "sli",
179
+ label: "3D Secure (SCA) / liability shift (recommended)",
180
+ hint: "Attempts to optimize for liability shift while remaining compliant."
181
+ },
182
+ {
183
+ value: "always",
184
+ label: "Always request 3D Secure",
185
+ hint: "Forces 3DS challenge whenever possible (may reduce conversion)."
186
+ }
187
+ ];
188
+ function AdvancedCardPaymentsTab() {
189
+ var _a, _b;
176
190
  const [form, setForm] = useState(() => ({
177
191
  ...DEFAULT_FORM$1
178
192
  }));
@@ -189,7 +203,7 @@ function AdditionalSettingsTab() {
189
203
  setLoading(true);
190
204
  const json = await adminFetch("/admin/paypal/settings");
191
205
  const payload = (json == null ? void 0 : json.data) ?? json;
192
- const saved = payload == null ? void 0 : payload.additional_settings;
206
+ const saved = payload == null ? void 0 : payload.advanced_card_payments;
193
207
  if (saved && typeof saved === "object")
194
208
  setForm(mergeWithDefaults$1(saved));
195
209
  } catch {
@@ -201,21 +215,20 @@ function AdditionalSettingsTab() {
201
215
  async function onSave() {
202
216
  try {
203
217
  setSaving(true);
204
- setToast(null);
205
218
  const json = await adminFetch("/admin/paypal/settings", {
206
219
  method: "POST",
207
220
  body: {
208
- additional_settings: form
221
+ advanced_card_payments: form
209
222
  }
210
223
  });
211
224
  const payload = (json == null ? void 0 : json.data) ?? json;
212
- const saved = payload == null ? void 0 : payload.additional_settings;
225
+ const saved = payload == null ? void 0 : payload.advanced_card_payments;
213
226
  if (saved && typeof saved === "object") setForm(mergeWithDefaults$1(saved));
214
227
  setToast({ kind: "success", message: "Settings saved" });
215
228
  } catch (e) {
216
229
  setToast({
217
230
  kind: "error",
218
- message: e instanceof Error ? e.message : "Failed to save settings"
231
+ message: (e instanceof Error ? e.message : "") || "Failed to save settings."
219
232
  });
220
233
  } finally {
221
234
  setSaving(false);
@@ -228,8 +241,8 @@ function AdditionalSettingsTab() {
228
241
  /* @__PURE__ */ jsx(
229
242
  SectionCard,
230
243
  {
231
- title: "Additional Settings",
232
- description: "These settings control checkout behavior and PayPal experience.",
244
+ title: "Advanced Card Payments",
245
+ description: "Control card checkout settings and 3D Secure behavior.",
233
246
  right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
234
247
  /* @__PURE__ */ jsx(
235
248
  "button",
@@ -244,115 +257,51 @@ function AdditionalSettingsTab() {
244
257
  loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
245
258
  ] }),
246
259
  children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-ui-border-base", children: [
247
- /* @__PURE__ */ jsx(FieldRow, { label: "Payment action", htmlFor: "as-payment-action", children: /* @__PURE__ */ jsxs(
248
- "select",
249
- {
250
- id: "as-payment-action",
251
- value: form.paymentAction,
252
- onChange: (e) => setForm((p) => ({
253
- ...p,
254
- paymentAction: e.target.value
255
- })),
256
- 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",
257
- children: [
258
- /* @__PURE__ */ jsx("option", { value: "capture", children: "Capture" }),
259
- /* @__PURE__ */ jsx("option", { value: "authorize", children: "Authorize" })
260
- ]
261
- }
262
- ) }),
263
- /* @__PURE__ */ jsx(FieldRow, { label: "Brand Name", htmlFor: "as-brand-name", children: /* @__PURE__ */ jsx(
264
- "input",
265
- {
266
- id: "as-brand-name",
267
- value: form.brandName,
268
- onChange: (e) => setForm((p) => ({ ...p, brandName: e.target.value })),
269
- 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",
270
- placeholder: "PayPal"
271
- }
272
- ) }),
273
- /* @__PURE__ */ jsx(FieldRow, { label: "Landing Page", htmlFor: "as-landing-page", children: /* @__PURE__ */ jsxs(
274
- "select",
275
- {
276
- id: "as-landing-page",
277
- value: form.landingPage,
278
- onChange: (e) => setForm((p) => ({
279
- ...p,
280
- landingPage: e.target.value
281
- })),
282
- 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",
283
- children: [
284
- /* @__PURE__ */ jsx("option", { value: "no_preference", children: "No Preference" }),
285
- /* @__PURE__ */ jsx("option", { value: "login", children: "Login" }),
286
- /* @__PURE__ */ jsx("option", { value: "billing", children: "Billing" })
287
- ]
288
- }
289
- ) }),
290
- /* @__PURE__ */ jsx(FieldRow, { label: "Instant Payments", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
260
+ /* @__PURE__ */ jsx(FieldRow, { label: "Enable/Disable", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
291
261
  /* @__PURE__ */ jsx(
292
262
  "input",
293
263
  {
294
264
  type: "checkbox",
295
- checked: form.requireInstantPayment,
296
- onChange: (e) => setForm((p) => ({
297
- ...p,
298
- requireInstantPayment: e.target.checked
299
- })),
265
+ checked: form.enabled,
266
+ onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })),
300
267
  className: "h-4 w-4 rounded border-ui-border-base"
301
268
  }
302
269
  ),
303
- /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Require Instant Payment" })
270
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
304
271
  ] }) }),
272
+ /* @__PURE__ */ jsx(FieldRow, { label: "Title", htmlFor: "acp-title", children: /* @__PURE__ */ jsx(
273
+ "input",
274
+ {
275
+ id: "acp-title",
276
+ value: form.title,
277
+ onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })),
278
+ 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",
279
+ placeholder: "Credit or Debit Card"
280
+ }
281
+ ) }),
305
282
  /* @__PURE__ */ jsx(
306
283
  FieldRow,
307
284
  {
308
- label: "Send Item Details",
309
- hint: "Include all line item details in the payment request to PayPal so that they can be seen from the PayPal transaction details page.",
310
- children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
285
+ label: "Contingency for 3D Secure",
286
+ hint: "Choose when 3D Secure should be triggered during card payments.",
287
+ htmlFor: "acp-threeds",
288
+ children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
311
289
  /* @__PURE__ */ jsx(
312
- "input",
290
+ "select",
313
291
  {
314
- type: "checkbox",
315
- checked: form.sendItemDetails,
292
+ id: "acp-threeds",
293
+ value: form.threeDS,
316
294
  onChange: (e) => setForm((p) => ({
317
295
  ...p,
318
- sendItemDetails: e.target.checked
296
+ threeDS: e.target.value
319
297
  })),
320
- className: "h-4 w-4 rounded border-ui-border-base"
298
+ 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",
299
+ children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsx("option", { value: o.value, children: o.label }, o.value))
321
300
  }
322
301
  ),
323
- /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Send line item details to PayPal" })
302
+ ((_a = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _a.hint) ? /* @__PURE__ */ jsx("div", { className: "text-xs text-ui-fg-subtle", children: (_b = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _b.hint }) : null
324
303
  ] })
325
304
  }
326
- ),
327
- /* @__PURE__ */ jsx(FieldRow, { label: "Invoice prefix", htmlFor: "as-invoice-prefix", children: /* @__PURE__ */ jsx(
328
- "input",
329
- {
330
- id: "as-invoice-prefix",
331
- value: form.invoicePrefix,
332
- onChange: (e) => setForm((p) => ({ ...p, invoicePrefix: e.target.value })),
333
- 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",
334
- placeholder: "PP-"
335
- }
336
- ) }),
337
- /* @__PURE__ */ jsx(
338
- FieldRow,
339
- {
340
- label: "Credit Card Statement Name",
341
- htmlFor: "as-cc-statement",
342
- children: /* @__PURE__ */ jsx(
343
- "input",
344
- {
345
- id: "as-cc-statement",
346
- value: form.creditCardStatementName,
347
- onChange: (e) => setForm((p) => ({
348
- ...p,
349
- creditCardStatementName: e.target.value
350
- })),
351
- 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",
352
- placeholder: "PayPal"
353
- }
354
- )
355
- }
356
305
  )
357
306
  ] })
358
307
  }
@@ -360,9 +309,14 @@ function AdditionalSettingsTab() {
360
309
  ] }) });
361
310
  }
362
311
  const DEFAULT_FORM = {
363
- enabled: true,
364
- title: "Credit or Debit Card",
365
- threeDS: "when_required"
312
+ paymentAction: "capture",
313
+ brandName: "PayPal",
314
+ landingPage: "no_preference",
315
+ requireInstantPayment: false,
316
+ sendItemDetails: true,
317
+ invoicePrefix: "PP-",
318
+ creditCardStatementName: "PayPal",
319
+ debugLogging: false
366
320
  };
367
321
  function mergeWithDefaults(saved) {
368
322
  if (!saved) return { ...DEFAULT_FORM };
@@ -374,33 +328,59 @@ function mergeWithDefaults(saved) {
374
328
  ...Object.fromEntries(entries)
375
329
  };
376
330
  }
377
- const THREE_DS_OPTIONS = [
378
- {
379
- value: "when_required",
380
- label: "3D Secure when required",
381
- hint: "Triggers 3DS only when the card / issuer requires it."
382
- },
383
- {
384
- value: "sli",
385
- label: "3D Secure (SCA) / liability shift (recommended)",
386
- hint: "Attempts to optimize for liability shift while remaining compliant."
387
- },
388
- {
389
- value: "always",
390
- label: "Always request 3D Secure",
391
- hint: "Forces 3DS challenge whenever possible (may reduce conversion)."
392
- }
393
- ];
394
- function AdvancedCardPaymentsTab() {
395
- var _a, _b;
331
+ function AdditionalSettingsTab() {
396
332
  const [form, setForm] = useState(() => ({
397
333
  ...DEFAULT_FORM
398
334
  }));
399
335
  const [loading, setLoading] = useState(false);
400
336
  const [saving, setSaving] = useState(false);
337
+ const [downloading, setDownloading] = useState(false);
401
338
  const [toast, setToast] = useState(null);
402
339
  const didInit = useRef(false);
403
340
  const dismissToast = useCallback(() => setToast(null), []);
341
+ async function onDownloadLog() {
342
+ var _a;
343
+ try {
344
+ setDownloading(true);
345
+ setToast(null);
346
+ const headers = { Accept: "text/plain" };
347
+ if (typeof window !== "undefined") {
348
+ const token = (_a = window.__medusa__) == null ? void 0 : _a.token;
349
+ if (token) headers["Authorization"] = `Bearer ${token}`;
350
+ }
351
+ const res = await fetch("/admin/paypal/logs?download=1", {
352
+ headers,
353
+ credentials: "include"
354
+ });
355
+ if (!res.ok) {
356
+ if (res.status === 404) {
357
+ throw new Error(
358
+ "No log file yet. Enable logging, run a test transaction, then download."
359
+ );
360
+ }
361
+ throw new Error(`Download failed (${res.status})`);
362
+ }
363
+ const blob = await res.blob();
364
+ const dispo = res.headers.get("Content-Disposition") || "";
365
+ const match = dispo.match(/filename="?([^"]+)"?/);
366
+ const filename = (match == null ? void 0 : match[1]) || "paypal-requests.log";
367
+ const url = URL.createObjectURL(blob);
368
+ const a = document.createElement("a");
369
+ a.href = url;
370
+ a.download = filename;
371
+ document.body.appendChild(a);
372
+ a.click();
373
+ a.remove();
374
+ URL.revokeObjectURL(url);
375
+ } catch (e) {
376
+ setToast({
377
+ kind: "error",
378
+ message: e instanceof Error ? e.message : "Failed to download log"
379
+ });
380
+ } finally {
381
+ setDownloading(false);
382
+ }
383
+ }
404
384
  useEffect(() => {
405
385
  if (didInit.current) return;
406
386
  didInit.current = true;
@@ -409,7 +389,7 @@ function AdvancedCardPaymentsTab() {
409
389
  setLoading(true);
410
390
  const json = await adminFetch("/admin/paypal/settings");
411
391
  const payload = (json == null ? void 0 : json.data) ?? json;
412
- const saved = payload == null ? void 0 : payload.advanced_card_payments;
392
+ const saved = payload == null ? void 0 : payload.additional_settings;
413
393
  if (saved && typeof saved === "object")
414
394
  setForm(mergeWithDefaults(saved));
415
395
  } catch {
@@ -421,20 +401,21 @@ function AdvancedCardPaymentsTab() {
421
401
  async function onSave() {
422
402
  try {
423
403
  setSaving(true);
404
+ setToast(null);
424
405
  const json = await adminFetch("/admin/paypal/settings", {
425
406
  method: "POST",
426
407
  body: {
427
- advanced_card_payments: form
408
+ additional_settings: form
428
409
  }
429
410
  });
430
411
  const payload = (json == null ? void 0 : json.data) ?? json;
431
- const saved = payload == null ? void 0 : payload.advanced_card_payments;
412
+ const saved = payload == null ? void 0 : payload.additional_settings;
432
413
  if (saved && typeof saved === "object") setForm(mergeWithDefaults(saved));
433
414
  setToast({ kind: "success", message: "Settings saved" });
434
415
  } catch (e) {
435
416
  setToast({
436
417
  kind: "error",
437
- message: (e instanceof Error ? e.message : "") || "Failed to save settings."
418
+ message: e instanceof Error ? e.message : "Failed to save settings"
438
419
  });
439
420
  } finally {
440
421
  setSaving(false);
@@ -447,8 +428,8 @@ function AdvancedCardPaymentsTab() {
447
428
  /* @__PURE__ */ jsx(
448
429
  SectionCard,
449
430
  {
450
- title: "Advanced Card Payments",
451
- description: "Control card checkout settings and 3D Secure behavior.",
431
+ title: "Additional Settings",
432
+ description: "These settings control checkout behavior and PayPal experience.",
452
433
  right: /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
453
434
  /* @__PURE__ */ jsx(
454
435
  "button",
@@ -463,60 +444,160 @@ function AdvancedCardPaymentsTab() {
463
444
  loading ? /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
464
445
  ] }),
465
446
  children: /* @__PURE__ */ jsxs("div", { className: "divide-y divide-ui-border-base", children: [
466
- /* @__PURE__ */ jsx(FieldRow, { label: "Enable/Disable", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
447
+ /* @__PURE__ */ jsx(FieldRow, { label: "Payment action", htmlFor: "as-payment-action", children: /* @__PURE__ */ jsxs(
448
+ "select",
449
+ {
450
+ id: "as-payment-action",
451
+ value: form.paymentAction,
452
+ onChange: (e) => setForm((p) => ({
453
+ ...p,
454
+ paymentAction: e.target.value
455
+ })),
456
+ 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",
457
+ children: [
458
+ /* @__PURE__ */ jsx("option", { value: "capture", children: "Capture" }),
459
+ /* @__PURE__ */ jsx("option", { value: "authorize", children: "Authorize" })
460
+ ]
461
+ }
462
+ ) }),
463
+ /* @__PURE__ */ jsx(FieldRow, { label: "Brand Name", htmlFor: "as-brand-name", children: /* @__PURE__ */ jsx(
464
+ "input",
465
+ {
466
+ id: "as-brand-name",
467
+ value: form.brandName,
468
+ onChange: (e) => setForm((p) => ({ ...p, brandName: e.target.value })),
469
+ 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",
470
+ placeholder: "PayPal"
471
+ }
472
+ ) }),
473
+ /* @__PURE__ */ jsx(FieldRow, { label: "Landing Page", htmlFor: "as-landing-page", children: /* @__PURE__ */ jsxs(
474
+ "select",
475
+ {
476
+ id: "as-landing-page",
477
+ value: form.landingPage,
478
+ onChange: (e) => setForm((p) => ({
479
+ ...p,
480
+ landingPage: e.target.value
481
+ })),
482
+ 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",
483
+ children: [
484
+ /* @__PURE__ */ jsx("option", { value: "no_preference", children: "No Preference" }),
485
+ /* @__PURE__ */ jsx("option", { value: "login", children: "Login" }),
486
+ /* @__PURE__ */ jsx("option", { value: "billing", children: "Billing" })
487
+ ]
488
+ }
489
+ ) }),
490
+ /* @__PURE__ */ jsx(FieldRow, { label: "Instant Payments", children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
467
491
  /* @__PURE__ */ jsx(
468
492
  "input",
469
493
  {
470
494
  type: "checkbox",
471
- checked: form.enabled,
472
- onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })),
495
+ checked: form.requireInstantPayment,
496
+ onChange: (e) => setForm((p) => ({
497
+ ...p,
498
+ requireInstantPayment: e.target.checked
499
+ })),
473
500
  className: "h-4 w-4 rounded border-ui-border-base"
474
501
  }
475
502
  ),
476
- /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
503
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Require Instant Payment" })
477
504
  ] }) }),
478
- /* @__PURE__ */ jsx(FieldRow, { label: "Title", htmlFor: "acp-title", children: /* @__PURE__ */ jsx(
479
- "input",
480
- {
481
- id: "acp-title",
482
- value: form.title,
483
- onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })),
484
- 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",
485
- placeholder: "Credit or Debit Card"
486
- }
487
- ) }),
488
505
  /* @__PURE__ */ jsx(
489
506
  FieldRow,
490
507
  {
491
- label: "Contingency for 3D Secure",
492
- hint: "Choose when 3D Secure should be triggered during card payments.",
493
- htmlFor: "acp-threeds",
494
- children: /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-2", children: [
508
+ label: "Send Item Details",
509
+ hint: "Include all line item details in the payment request to PayPal so that they can be seen from the PayPal transaction details page.",
510
+ children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
495
511
  /* @__PURE__ */ jsx(
496
- "select",
512
+ "input",
497
513
  {
498
- id: "acp-threeds",
499
- value: form.threeDS,
514
+ type: "checkbox",
515
+ checked: form.sendItemDetails,
500
516
  onChange: (e) => setForm((p) => ({
501
517
  ...p,
502
- threeDS: e.target.value
518
+ sendItemDetails: e.target.checked
503
519
  })),
504
- 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",
505
- children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsx("option", { value: o.value, children: o.label }, o.value))
520
+ className: "h-4 w-4 rounded border-ui-border-base"
506
521
  }
507
522
  ),
508
- ((_a = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _a.hint) ? /* @__PURE__ */ jsx("div", { className: "text-xs text-ui-fg-subtle", children: (_b = THREE_DS_OPTIONS.find((o) => o.value === form.threeDS)) == null ? void 0 : _b.hint }) : null
523
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Send line item details to PayPal" })
509
524
  ] })
510
525
  }
526
+ ),
527
+ /* @__PURE__ */ jsx(FieldRow, { label: "Invoice prefix", htmlFor: "as-invoice-prefix", children: /* @__PURE__ */ jsx(
528
+ "input",
529
+ {
530
+ id: "as-invoice-prefix",
531
+ value: form.invoicePrefix,
532
+ onChange: (e) => setForm((p) => ({ ...p, invoicePrefix: e.target.value })),
533
+ 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",
534
+ placeholder: "PP-"
535
+ }
536
+ ) }),
537
+ /* @__PURE__ */ jsx(
538
+ FieldRow,
539
+ {
540
+ label: "Credit Card Statement Name",
541
+ htmlFor: "as-cc-statement",
542
+ children: /* @__PURE__ */ jsx(
543
+ "input",
544
+ {
545
+ id: "as-cc-statement",
546
+ value: form.creditCardStatementName,
547
+ onChange: (e) => setForm((p) => ({
548
+ ...p,
549
+ creditCardStatementName: e.target.value
550
+ })),
551
+ 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",
552
+ placeholder: "PayPal"
553
+ }
554
+ )
555
+ }
511
556
  )
512
557
  ] })
513
558
  }
559
+ ),
560
+ /* @__PURE__ */ jsx(
561
+ SectionCard,
562
+ {
563
+ title: "Integration logging (PayPal review)",
564
+ 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.",
565
+ right: /* @__PURE__ */ jsx("div", { className: "flex items-center gap-3", children: /* @__PURE__ */ jsx(
566
+ "button",
567
+ {
568
+ type: "button",
569
+ onClick: onDownloadLog,
570
+ disabled: downloading,
571
+ 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",
572
+ children: downloading ? "Preparing…" : "Download log"
573
+ }
574
+ ) }),
575
+ children: /* @__PURE__ */ jsx("div", { className: "divide-y divide-ui-border-base", children: /* @__PURE__ */ jsx(
576
+ FieldRow,
577
+ {
578
+ label: "Request/response logging",
579
+ 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.",
580
+ children: /* @__PURE__ */ jsxs("label", { className: "inline-flex items-center gap-2", children: [
581
+ /* @__PURE__ */ jsx(
582
+ "input",
583
+ {
584
+ type: "checkbox",
585
+ checked: form.debugLogging,
586
+ onChange: (e) => setForm((p) => ({
587
+ ...p,
588
+ debugLogging: e.target.checked
589
+ })),
590
+ className: "h-4 w-4 rounded border-ui-border-base"
591
+ }
592
+ ),
593
+ /* @__PURE__ */ jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable request/response log file" })
594
+ ] })
595
+ }
596
+ ) })
597
+ }
514
598
  )
515
599
  ] }) });
516
600
  }
517
- function PayPalApplePayPage() {
518
- return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
519
- }
520
601
  function PayPalGooglePayPage() {
521
602
  return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
522
603
  }
@@ -1275,6 +1356,9 @@ function PayPalConnectionPage() {
1275
1356
  ` })
1276
1357
  ] });
1277
1358
  }
1359
+ function PayPalApplePayPage() {
1360
+ return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
1361
+ }
1278
1362
  function PayPalPayLaterMessagingPage() {
1279
1363
  return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
1280
1364
  }
@@ -1501,17 +1585,13 @@ const routeModule = {
1501
1585
  Component: PayPalSettingsIndexRoute,
1502
1586
  path: "/settings/paypal"
1503
1587
  },
1504
- {
1505
- Component: AdditionalSettingsTab,
1506
- path: "/settings/paypal/additional-settings"
1507
- },
1508
1588
  {
1509
1589
  Component: AdvancedCardPaymentsTab,
1510
1590
  path: "/settings/paypal/advanced-card-payments"
1511
1591
  },
1512
1592
  {
1513
- Component: PayPalApplePayPage,
1514
- path: "/settings/paypal/apple-pay"
1593
+ Component: AdditionalSettingsTab,
1594
+ path: "/settings/paypal/additional-settings"
1515
1595
  },
1516
1596
  {
1517
1597
  Component: PayPalGooglePayPage,
@@ -1521,6 +1601,10 @@ const routeModule = {
1521
1601
  Component: PayPalConnectionPage,
1522
1602
  path: "/settings/paypal/connection"
1523
1603
  },
1604
+ {
1605
+ Component: PayPalApplePayPage,
1606
+ path: "/settings/paypal/apple-pay"
1607
+ },
1524
1608
  {
1525
1609
  Component: PayPalPayLaterMessagingPage,
1526
1610
  path: "/settings/paypal/pay-later-messaging"
@@ -0,0 +1,10 @@
1
+ import type { MedusaRequest, MedusaResponse } from "@medusajs/framework/http";
2
+ /**
3
+ * GET /admin/paypal/logs
4
+ * → { enabled, files: [{ name, size, modified }] }
5
+ *
6
+ * GET /admin/paypal/logs?file=<name>&download=1 (file optional → newest)
7
+ * → the raw log file as a text/plain attachment, for sending to PayPal.
8
+ */
9
+ export declare function GET(req: MedusaRequest, res: MedusaResponse): Promise<MedusaResponse>;
10
+ //# sourceMappingURL=route.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.d.ts","sourceRoot":"","sources":["../../../../../../../src/api/admin/paypal/logs/route.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAA;AAO7E;;;;;;GAMG;AACH,wBAAsB,GAAG,CAAC,GAAG,EAAE,aAAa,EAAE,GAAG,EAAE,cAAc,2BAiChE"}
@@ -0,0 +1,43 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.GET = GET;
7
+ const fs_1 = __importDefault(require("fs"));
8
+ const path_1 = __importDefault(require("path"));
9
+ const request_logger_1 = require("../../../../modules/paypal/utils/request-logger");
10
+ /**
11
+ * GET /admin/paypal/logs
12
+ * → { enabled, files: [{ name, size, modified }] }
13
+ *
14
+ * GET /admin/paypal/logs?file=<name>&download=1 (file optional → newest)
15
+ * → the raw log file as a text/plain attachment, for sending to PayPal.
16
+ */
17
+ async function GET(req, res) {
18
+ try {
19
+ const query = req.query;
20
+ const wantsDownload = query.download === "1" ||
21
+ query.download === "true" ||
22
+ typeof query.file === "string";
23
+ if (wantsDownload) {
24
+ const filePath = (0, request_logger_1.resolveLogFile)(query.file);
25
+ if (!filePath) {
26
+ return res.status(404).json({ message: "Log file not found" });
27
+ }
28
+ const name = path_1.default.basename(filePath);
29
+ res.setHeader("Content-Type", "text/plain; charset=utf-8");
30
+ res.setHeader("Content-Disposition", `attachment; filename="${name}"`);
31
+ return res.send(fs_1.default.readFileSync(filePath, "utf8"));
32
+ }
33
+ return res.json({
34
+ enabled: (0, request_logger_1.isRequestLoggingEnabled)(),
35
+ files: (0, request_logger_1.listLogFiles)(),
36
+ });
37
+ }
38
+ catch (e) {
39
+ console.error("[PayPal] logs GET failed:", e instanceof Error ? e.message : e);
40
+ return res.status(500).json({ message: "Failed to read PayPal logs" });
41
+ }
42
+ }
43
+ //# sourceMappingURL=route.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"route.js","sourceRoot":"","sources":["../../../../../../../src/api/admin/paypal/logs/route.ts"],"names":[],"mappings":";;;;;AAgBA,kBAiCC;AAjDD,4CAAmB;AACnB,gDAAuB;AAEvB,oFAIwD;AAExD;;;;;;GAMG;AACI,KAAK,UAAU,GAAG,CAAC,GAAkB,EAAE,GAAmB;IAC/D,IAAI,CAAC;QACH,MAAM,KAAK,GAAG,GAAG,CAAC,KAA2C,CAAA;QAC7D,MAAM,aAAa,GACjB,KAAK,CAAC,QAAQ,KAAK,GAAG;YACtB,KAAK,CAAC,QAAQ,KAAK,MAAM;YACzB,OAAO,KAAK,CAAC,IAAI,KAAK,QAAQ,CAAA;QAEhC,IAAI,aAAa,EAAE,CAAC;YAClB,MAAM,QAAQ,GAAG,IAAA,+BAAc,EAAC,KAAK,CAAC,IAAI,CAAC,CAAA;YAC3C,IAAI,CAAC,QAAQ,EAAE,CAAC;gBACd,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,oBAAoB,EAAE,CAAC,CAAA;YAChE,CAAC;YACD,MAAM,IAAI,GAAG,cAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAA;YACpC,GAAG,CAAC,SAAS,CAAC,cAAc,EAAE,2BAA2B,CAAC,CAAA;YAC1D,GAAG,CAAC,SAAS,CACX,qBAAqB,EACrB,yBAAyB,IAAI,GAAG,CACjC,CAAA;YACD,OAAO,GAAG,CAAC,IAAI,CAAC,YAAE,CAAC,YAAY,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;QACpD,CAAC;QAED,OAAO,GAAG,CAAC,IAAI,CAAC;YACd,OAAO,EAAE,IAAA,wCAAuB,GAAE;YAClC,KAAK,EAAE,IAAA,6BAAY,GAAE;SACtB,CAAC,CAAA;IACJ,CAAC;IAAC,OAAO,CAAU,EAAE,CAAC;QACpB,OAAO,CAAC,KAAK,CACX,2BAA2B,EAC3B,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,CACnC,CAAA;QACD,OAAO,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,EAAE,OAAO,EAAE,4BAA4B,EAAE,CAAC,CAAA;IACxE,CAAC;AACH,CAAC"}