@easypayment/medusa-paypal 0.2.1 → 0.2.3
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.
- package/.medusa/server/src/admin/index.js +655 -655
- package/.medusa/server/src/admin/index.mjs +655 -655
- package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.d.ts.map +1 -1
- package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.js +18 -8
- package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.js.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/service.d.ts.map +1 -1
- package/.medusa/server/src/modules/paypal/payment-provider/service.js +19 -2
- package/.medusa/server/src/modules/paypal/payment-provider/service.js.map +1 -1
- package/package.json +1 -1
- package/src/api/store/payment-collections/[id]/payment-sessions/route.ts +24 -8
- package/src/modules/paypal/payment-provider/service.ts +19 -2
|
@@ -336,395 +336,98 @@ function AdditionalSettingsTab() {
|
|
|
336
336
|
)
|
|
337
337
|
] }) });
|
|
338
338
|
}
|
|
339
|
-
const
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
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)."
|
|
339
|
+
const config = adminSdk.defineRouteConfig({
|
|
340
|
+
label: "PayPal Connection",
|
|
341
|
+
hide: true
|
|
342
|
+
});
|
|
343
|
+
if (typeof window !== "undefined") {
|
|
344
|
+
const preloadHref = "https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js";
|
|
345
|
+
const existingPreload = document.head.querySelector(
|
|
346
|
+
`link[rel="preload"][href="${preloadHref}"]`
|
|
347
|
+
);
|
|
348
|
+
if (!existingPreload) {
|
|
349
|
+
const preloadLink = document.createElement("link");
|
|
350
|
+
preloadLink.rel = "preload";
|
|
351
|
+
preloadLink.href = preloadHref;
|
|
352
|
+
preloadLink.as = "script";
|
|
353
|
+
document.head.appendChild(preloadLink);
|
|
354
|
+
}
|
|
355
|
+
const existingScript = document.getElementById(
|
|
356
|
+
"paypal-partner-js"
|
|
357
|
+
);
|
|
358
|
+
if (!existingScript) {
|
|
359
|
+
const ppScript = document.createElement("script");
|
|
360
|
+
ppScript.id = "paypal-partner-js";
|
|
361
|
+
ppScript.src = preloadHref;
|
|
362
|
+
ppScript.async = true;
|
|
363
|
+
document.head.appendChild(ppScript);
|
|
378
364
|
}
|
|
379
|
-
];
|
|
380
|
-
function cx$1(...parts) {
|
|
381
|
-
return parts.filter(Boolean).join(" ");
|
|
382
365
|
}
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
366
|
+
const SERVICE_URL = "/admin/paypal/onboarding-link";
|
|
367
|
+
const CACHE_KEY = "pp_onboard_cache";
|
|
368
|
+
const RELOAD_KEY = "pp_onboard_reloaded_once";
|
|
369
|
+
const CACHE_EXPIRY = 10 * 60 * 1e3;
|
|
370
|
+
const ONBOARDING_COMPLETE_ENDPOINT = "/admin/paypal/onboard-complete";
|
|
371
|
+
const STATUS_ENDPOINT = "/admin/paypal/status";
|
|
372
|
+
const SAVE_CREDENTIALS_ENDPOINT = "/admin/paypal/save-credentials";
|
|
373
|
+
const DISCONNECT_ENDPOINT = "/admin/paypal/disconnect";
|
|
374
|
+
let cachedUrl = null;
|
|
375
|
+
if (typeof window !== "undefined") {
|
|
376
|
+
try {
|
|
377
|
+
const cached = localStorage.getItem(CACHE_KEY);
|
|
378
|
+
if (cached) {
|
|
379
|
+
const data = JSON.parse(cached);
|
|
380
|
+
if ((/* @__PURE__ */ new Date()).getTime() - data.ts < CACHE_EXPIRY) {
|
|
381
|
+
cachedUrl = data.url;
|
|
397
382
|
}
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
title,
|
|
403
|
-
description,
|
|
404
|
-
right,
|
|
405
|
-
children
|
|
406
|
-
}) {
|
|
407
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
408
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-4 border-b border-ui-border-base p-4", children: [
|
|
409
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
410
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: title }),
|
|
411
|
-
description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-sm text-ui-fg-subtle", children: description }) : null
|
|
412
|
-
] }),
|
|
413
|
-
right
|
|
414
|
-
] }),
|
|
415
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children })
|
|
416
|
-
] });
|
|
417
|
-
}
|
|
418
|
-
function FieldRow$1({
|
|
419
|
-
label,
|
|
420
|
-
hint,
|
|
421
|
-
children
|
|
422
|
-
}) {
|
|
423
|
-
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-12 items-start gap-4 py-3", children: [
|
|
424
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "col-span-12 md:col-span-4", children: [
|
|
425
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium text-ui-fg-base", children: label }),
|
|
426
|
-
hint ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: hint }) : null
|
|
427
|
-
] }),
|
|
428
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-12 md:col-span-8", children })
|
|
429
|
-
] });
|
|
383
|
+
}
|
|
384
|
+
} catch (e) {
|
|
385
|
+
console.error("Cache read error:", e);
|
|
386
|
+
}
|
|
430
387
|
}
|
|
431
|
-
function
|
|
432
|
-
|
|
433
|
-
const [form, setForm] = react.useState(() => ({ ...DEFAULT_FORM }));
|
|
434
|
-
const [loading, setLoading] = react.useState(false);
|
|
435
|
-
const [saving, setSaving] = react.useState(false);
|
|
436
|
-
const [toast, setToast] = react.useState(null);
|
|
437
|
-
const didInit = react.useRef(false);
|
|
388
|
+
function PayPalConnectionPage() {
|
|
389
|
+
const [env, setEnv] = react.useState("sandbox");
|
|
438
390
|
react.useEffect(() => {
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
const r = await fetch("/admin/paypal/settings", {
|
|
445
|
-
credentials: "include",
|
|
446
|
-
headers: { "Accept": "application/json" }
|
|
447
|
-
});
|
|
448
|
-
if (!r.ok) return;
|
|
449
|
-
const json = await r.json();
|
|
450
|
-
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
451
|
-
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
452
|
-
if (saved && typeof saved === "object") {
|
|
453
|
-
setForm(mergeWithDefaults(saved));
|
|
454
|
-
}
|
|
455
|
-
} finally {
|
|
456
|
-
setLoading(false);
|
|
457
|
-
}
|
|
458
|
-
})();
|
|
391
|
+
fetch("/admin/paypal/environment", { method: "GET" }).then((r) => r.json()).then((d) => {
|
|
392
|
+
const v = (d == null ? void 0 : d.environment) === "live" ? "live" : "sandbox";
|
|
393
|
+
setEnv(v);
|
|
394
|
+
}).catch(() => {
|
|
395
|
+
});
|
|
459
396
|
}, []);
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
}
|
|
484
|
-
setToast({ type: "success", message: "Settings saved" });
|
|
485
|
-
window.setTimeout(() => setToast(null), 2500);
|
|
486
|
-
} finally {
|
|
487
|
-
setSaving(false);
|
|
397
|
+
const [connState, setConnState] = react.useState("loading");
|
|
398
|
+
const [error, setError] = react.useState(null);
|
|
399
|
+
const [finalUrl, setFinalUrl] = react.useState("");
|
|
400
|
+
const [showManual, setShowManual] = react.useState(false);
|
|
401
|
+
const [clientId, setClientId] = react.useState("");
|
|
402
|
+
const [secret, setSecret] = react.useState("");
|
|
403
|
+
const [merchantId, setMerchantId] = react.useState("");
|
|
404
|
+
const [statusInfo, setStatusInfo] = react.useState(null);
|
|
405
|
+
const [onboardingInProgress, setOnboardingInProgress] = react.useState(false);
|
|
406
|
+
const initLoaderRef = react.useRef(null);
|
|
407
|
+
const paypalButtonRef = react.useRef(null);
|
|
408
|
+
const errorLogRef = react.useRef(null);
|
|
409
|
+
const runIdRef = react.useRef(0);
|
|
410
|
+
const currentRunId = react.useRef(0);
|
|
411
|
+
const ppBtnMeasureRef = react.useRef(null);
|
|
412
|
+
const [ppBtnWidth, setPpBtnWidth] = react.useState(null);
|
|
413
|
+
const canSaveManual = react.useMemo(() => {
|
|
414
|
+
return clientId.trim().length > 0 && secret.trim().length > 0;
|
|
415
|
+
}, [clientId, secret]);
|
|
416
|
+
const maskValue = react.useCallback((value, visibleChars = 4) => {
|
|
417
|
+
if (!value) return "";
|
|
418
|
+
if (value.length <= visibleChars) {
|
|
419
|
+
return "•".repeat(value.length);
|
|
488
420
|
}
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
}
|
|
500
|
-
function removeDisabledCard(value) {
|
|
501
|
-
setForm((prev) => ({
|
|
502
|
-
...prev,
|
|
503
|
-
disabledCards: prev.disabledCards.filter((v) => v !== value)
|
|
504
|
-
}));
|
|
505
|
-
}
|
|
506
|
-
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
507
|
-
/* @__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
|
-
/* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
|
|
509
|
-
toast ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
510
|
-
"div",
|
|
511
|
-
{
|
|
512
|
-
className: "fixed right-6 top-6 z-50 rounded-md border border-ui-border-base bg-ui-bg-base px-4 py-3 text-sm shadow-lg",
|
|
513
|
-
role: "status",
|
|
514
|
-
"aria-live": "polite",
|
|
515
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: toast.type === "success" ? "text-ui-fg-base" : "text-ui-fg-error", children: toast.message })
|
|
516
|
-
}
|
|
517
|
-
) : null,
|
|
518
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
519
|
-
SectionCard$1,
|
|
520
|
-
{
|
|
521
|
-
title: "Advanced Card Payments",
|
|
522
|
-
description: "Control card checkout settings, 3D Secure behavior, and card saving.",
|
|
523
|
-
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
524
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
525
|
-
"button",
|
|
526
|
-
{
|
|
527
|
-
type: "button",
|
|
528
|
-
onClick: onSave,
|
|
529
|
-
disabled: saving || loading,
|
|
530
|
-
className: "rounded-md bg-ui-button-neutral px-4 py-2 text-sm font-medium text-ui-fg-on-color shadow-sm hover:opacity-90 disabled:opacity-60",
|
|
531
|
-
children: saving ? "Saving..." : "Save settings"
|
|
532
|
-
}
|
|
533
|
-
),
|
|
534
|
-
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
|
|
535
|
-
] }),
|
|
536
|
-
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: [
|
|
538
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
539
|
-
"input",
|
|
540
|
-
{
|
|
541
|
-
type: "checkbox",
|
|
542
|
-
checked: form.enabled,
|
|
543
|
-
onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })),
|
|
544
|
-
className: "h-4 w-4 rounded border-ui-border-base"
|
|
545
|
-
}
|
|
546
|
-
),
|
|
547
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
|
|
548
|
-
] }) }),
|
|
549
|
-
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Title", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
550
|
-
"input",
|
|
551
|
-
{
|
|
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"
|
|
556
|
-
}
|
|
557
|
-
) }),
|
|
558
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
559
|
-
FieldRow$1,
|
|
560
|
-
{
|
|
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
|
-
}) }) })
|
|
594
|
-
] })
|
|
595
|
-
}
|
|
596
|
-
),
|
|
597
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
598
|
-
FieldRow$1,
|
|
599
|
-
{
|
|
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: [
|
|
603
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
604
|
-
"select",
|
|
605
|
-
{
|
|
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))
|
|
610
|
-
}
|
|
611
|
-
),
|
|
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
|
|
613
|
-
] })
|
|
614
|
-
}
|
|
615
|
-
),
|
|
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
|
-
] }) })
|
|
628
|
-
] })
|
|
629
|
-
}
|
|
630
|
-
)
|
|
631
|
-
] }) });
|
|
632
|
-
}
|
|
633
|
-
function PayPalApplePayPage() {
|
|
634
|
-
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
635
|
-
}
|
|
636
|
-
const config = adminSdk.defineRouteConfig({
|
|
637
|
-
label: "PayPal Connection",
|
|
638
|
-
hide: true
|
|
639
|
-
});
|
|
640
|
-
if (typeof window !== "undefined") {
|
|
641
|
-
const preloadHref = "https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js";
|
|
642
|
-
const existingPreload = document.head.querySelector(
|
|
643
|
-
`link[rel="preload"][href="${preloadHref}"]`
|
|
644
|
-
);
|
|
645
|
-
if (!existingPreload) {
|
|
646
|
-
const preloadLink = document.createElement("link");
|
|
647
|
-
preloadLink.rel = "preload";
|
|
648
|
-
preloadLink.href = preloadHref;
|
|
649
|
-
preloadLink.as = "script";
|
|
650
|
-
document.head.appendChild(preloadLink);
|
|
651
|
-
}
|
|
652
|
-
const existingScript = document.getElementById(
|
|
653
|
-
"paypal-partner-js"
|
|
654
|
-
);
|
|
655
|
-
if (!existingScript) {
|
|
656
|
-
const ppScript = document.createElement("script");
|
|
657
|
-
ppScript.id = "paypal-partner-js";
|
|
658
|
-
ppScript.src = preloadHref;
|
|
659
|
-
ppScript.async = true;
|
|
660
|
-
document.head.appendChild(ppScript);
|
|
661
|
-
}
|
|
662
|
-
}
|
|
663
|
-
const SERVICE_URL = "/admin/paypal/onboarding-link";
|
|
664
|
-
const CACHE_KEY = "pp_onboard_cache";
|
|
665
|
-
const RELOAD_KEY = "pp_onboard_reloaded_once";
|
|
666
|
-
const CACHE_EXPIRY = 10 * 60 * 1e3;
|
|
667
|
-
const ONBOARDING_COMPLETE_ENDPOINT = "/admin/paypal/onboard-complete";
|
|
668
|
-
const STATUS_ENDPOINT = "/admin/paypal/status";
|
|
669
|
-
const SAVE_CREDENTIALS_ENDPOINT = "/admin/paypal/save-credentials";
|
|
670
|
-
const DISCONNECT_ENDPOINT = "/admin/paypal/disconnect";
|
|
671
|
-
let cachedUrl = null;
|
|
672
|
-
if (typeof window !== "undefined") {
|
|
673
|
-
try {
|
|
674
|
-
const cached = localStorage.getItem(CACHE_KEY);
|
|
675
|
-
if (cached) {
|
|
676
|
-
const data = JSON.parse(cached);
|
|
677
|
-
if ((/* @__PURE__ */ new Date()).getTime() - data.ts < CACHE_EXPIRY) {
|
|
678
|
-
cachedUrl = data.url;
|
|
679
|
-
}
|
|
680
|
-
}
|
|
681
|
-
} catch (e) {
|
|
682
|
-
console.error("Cache read error:", e);
|
|
683
|
-
}
|
|
684
|
-
}
|
|
685
|
-
function PayPalConnectionPage() {
|
|
686
|
-
const [env, setEnv] = react.useState("sandbox");
|
|
687
|
-
react.useEffect(() => {
|
|
688
|
-
fetch("/admin/paypal/environment", { method: "GET" }).then((r) => r.json()).then((d) => {
|
|
689
|
-
const v = (d == null ? void 0 : d.environment) === "live" ? "live" : "sandbox";
|
|
690
|
-
setEnv(v);
|
|
691
|
-
}).catch(() => {
|
|
692
|
-
});
|
|
693
|
-
}, []);
|
|
694
|
-
const [connState, setConnState] = react.useState("loading");
|
|
695
|
-
const [error, setError] = react.useState(null);
|
|
696
|
-
const [finalUrl, setFinalUrl] = react.useState("");
|
|
697
|
-
const [showManual, setShowManual] = react.useState(false);
|
|
698
|
-
const [clientId, setClientId] = react.useState("");
|
|
699
|
-
const [secret, setSecret] = react.useState("");
|
|
700
|
-
const [merchantId, setMerchantId] = react.useState("");
|
|
701
|
-
const [statusInfo, setStatusInfo] = react.useState(null);
|
|
702
|
-
const [onboardingInProgress, setOnboardingInProgress] = react.useState(false);
|
|
703
|
-
const initLoaderRef = react.useRef(null);
|
|
704
|
-
const paypalButtonRef = react.useRef(null);
|
|
705
|
-
const errorLogRef = react.useRef(null);
|
|
706
|
-
const runIdRef = react.useRef(0);
|
|
707
|
-
const currentRunId = react.useRef(0);
|
|
708
|
-
const ppBtnMeasureRef = react.useRef(null);
|
|
709
|
-
const [ppBtnWidth, setPpBtnWidth] = react.useState(null);
|
|
710
|
-
const canSaveManual = react.useMemo(() => {
|
|
711
|
-
return clientId.trim().length > 0 && secret.trim().length > 0;
|
|
712
|
-
}, [clientId, secret]);
|
|
713
|
-
const maskValue = react.useCallback((value, visibleChars = 4) => {
|
|
714
|
-
if (!value) return "";
|
|
715
|
-
if (value.length <= visibleChars) {
|
|
716
|
-
return "•".repeat(value.length);
|
|
717
|
-
}
|
|
718
|
-
return `${"•".repeat(Math.max(0, value.length - visibleChars))}${value.slice(
|
|
719
|
-
-visibleChars
|
|
720
|
-
)}`;
|
|
721
|
-
}, []);
|
|
722
|
-
const fetchFreshLink = react.useCallback(
|
|
723
|
-
(runId) => {
|
|
724
|
-
if (initLoaderRef.current) {
|
|
725
|
-
const loaderText = initLoaderRef.current.querySelector("#loader-text");
|
|
726
|
-
if (loaderText)
|
|
727
|
-
loaderText.textContent = "Generating onboarding session...";
|
|
421
|
+
return `${"•".repeat(Math.max(0, value.length - visibleChars))}${value.slice(
|
|
422
|
+
-visibleChars
|
|
423
|
+
)}`;
|
|
424
|
+
}, []);
|
|
425
|
+
const fetchFreshLink = react.useCallback(
|
|
426
|
+
(runId) => {
|
|
427
|
+
if (initLoaderRef.current) {
|
|
428
|
+
const loaderText = initLoaderRef.current.querySelector("#loader-text");
|
|
429
|
+
if (loaderText)
|
|
430
|
+
loaderText.textContent = "Generating onboarding session...";
|
|
728
431
|
}
|
|
729
432
|
fetch(SERVICE_URL, {
|
|
730
433
|
method: "POST",
|
|
@@ -924,298 +627,592 @@ function PayPalConnectionPage() {
|
|
|
924
627
|
const txt = await res.text().catch(() => "");
|
|
925
628
|
throw new Error(txt || `Save credentials failed (${res.status})`);
|
|
926
629
|
}
|
|
927
|
-
setConnState("connected");
|
|
928
|
-
setStatusInfo({
|
|
929
|
-
seller_client_id_masked: maskValue(clientId.trim()),
|
|
930
|
-
seller_client_secret_masked: "••••••••"
|
|
931
|
-
});
|
|
932
|
-
setShowManual(false);
|
|
630
|
+
setConnState("connected");
|
|
631
|
+
setStatusInfo({
|
|
632
|
+
seller_client_id_masked: maskValue(clientId.trim()),
|
|
633
|
+
seller_client_secret_masked: "••••••••"
|
|
634
|
+
});
|
|
635
|
+
setShowManual(false);
|
|
636
|
+
try {
|
|
637
|
+
localStorage.removeItem(CACHE_KEY);
|
|
638
|
+
localStorage.removeItem(RELOAD_KEY);
|
|
639
|
+
} catch {
|
|
640
|
+
}
|
|
641
|
+
} catch (e) {
|
|
642
|
+
console.error(e);
|
|
643
|
+
setConnState("error");
|
|
644
|
+
setError((e == null ? void 0 : e.message) || "Failed to save credentials.");
|
|
645
|
+
} finally {
|
|
646
|
+
setOnboardingInProgress(false);
|
|
647
|
+
}
|
|
648
|
+
};
|
|
649
|
+
const handleDisconnect = async () => {
|
|
650
|
+
if (onboardingInProgress) return;
|
|
651
|
+
if (!window.confirm("Disconnect PayPal for this environment?")) return;
|
|
652
|
+
setOnboardingInProgress(true);
|
|
653
|
+
setConnState("loading");
|
|
654
|
+
setError(null);
|
|
655
|
+
setFinalUrl("");
|
|
656
|
+
setShowManual(false);
|
|
657
|
+
try {
|
|
658
|
+
const res = await fetch(DISCONNECT_ENDPOINT, {
|
|
659
|
+
method: "POST",
|
|
660
|
+
headers: { "content-type": "application/json" },
|
|
661
|
+
body: JSON.stringify({ environment: env })
|
|
662
|
+
});
|
|
663
|
+
if (!res.ok) {
|
|
664
|
+
const t = await res.text().catch(() => "");
|
|
665
|
+
throw new Error(t || `Disconnect failed (${res.status})`);
|
|
666
|
+
}
|
|
667
|
+
try {
|
|
668
|
+
localStorage.removeItem(CACHE_KEY);
|
|
669
|
+
localStorage.removeItem(RELOAD_KEY);
|
|
670
|
+
} catch {
|
|
671
|
+
}
|
|
672
|
+
currentRunId.current = ++runIdRef.current;
|
|
673
|
+
const runId = currentRunId.current;
|
|
674
|
+
fetchFreshLink(runId);
|
|
675
|
+
} catch (e) {
|
|
676
|
+
console.error(e);
|
|
677
|
+
setConnState("error");
|
|
678
|
+
setError((e == null ? void 0 : e.message) || "Failed to disconnect.");
|
|
679
|
+
} finally {
|
|
680
|
+
setOnboardingInProgress(false);
|
|
681
|
+
}
|
|
682
|
+
};
|
|
683
|
+
const handleEnvChange = async (e) => {
|
|
684
|
+
const next = e.target.value;
|
|
685
|
+
setEnv(next);
|
|
686
|
+
cachedUrl = null;
|
|
687
|
+
try {
|
|
688
|
+
await fetch("/admin/paypal/environment", {
|
|
689
|
+
method: "POST",
|
|
690
|
+
headers: { "content-type": "application/json" },
|
|
691
|
+
body: JSON.stringify({ environment: next })
|
|
692
|
+
});
|
|
693
|
+
} catch {
|
|
694
|
+
}
|
|
695
|
+
try {
|
|
696
|
+
localStorage.removeItem(CACHE_KEY);
|
|
697
|
+
localStorage.removeItem(RELOAD_KEY);
|
|
698
|
+
} catch {
|
|
699
|
+
}
|
|
700
|
+
};
|
|
701
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "p-6", children: [
|
|
702
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
703
|
+
/* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-xl font-semibold", children: "PayPal Gateway By Easy Payment" }),
|
|
704
|
+
/* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
|
|
705
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "rounded-md border border-ui-border-base p-4 shadow-sm", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-1 gap-y-6 md:grid-cols-[260px_1fr] md:items-start", children: [
|
|
706
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium pt-2", children: "Environment" }),
|
|
707
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-xl", children: /* @__PURE__ */ jsxRuntime.jsxs(
|
|
708
|
+
"select",
|
|
709
|
+
{
|
|
710
|
+
value: env,
|
|
711
|
+
onChange: handleEnvChange,
|
|
712
|
+
disabled: onboardingInProgress,
|
|
713
|
+
className: "w-full rounded-md border border-ui-border-base bg-transparent px-3 py-2 text-sm",
|
|
714
|
+
children: [
|
|
715
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "sandbox", children: "Sandbox (Test Mode)" }),
|
|
716
|
+
/* @__PURE__ */ jsxRuntime.jsx("option", { value: "live", children: "Live (Production)" })
|
|
717
|
+
]
|
|
718
|
+
}
|
|
719
|
+
) }),
|
|
720
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium pt-2", children: env === "sandbox" ? "Connect to PayPal Sandbox" : "Connect to PayPal Live" }),
|
|
721
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "max-w-xl", children: connState === "connected" ? /* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
722
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "text-sm text-green-600 bg-green-50 p-3 rounded border border-green-200", children: [
|
|
723
|
+
"✅ Successfully connected to PayPal!",
|
|
724
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
725
|
+
"a",
|
|
726
|
+
{
|
|
727
|
+
"data-paypal-button": "true",
|
|
728
|
+
"data-paypal-onboard-complete": "onboardingCallback",
|
|
729
|
+
href: "#",
|
|
730
|
+
style: { display: "none" },
|
|
731
|
+
children: "PayPal"
|
|
732
|
+
}
|
|
733
|
+
)
|
|
734
|
+
] }),
|
|
735
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-3 rounded-md border border-ui-border-base bg-ui-bg-subtle p-3 text-xs text-ui-fg-subtle", children: [
|
|
736
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "font-medium text-ui-fg-base", children: "Connected PayPal account" }),
|
|
737
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-1", children: [
|
|
738
|
+
"Email:",
|
|
739
|
+
" ",
|
|
740
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-ui-fg-base", children: (statusInfo == null ? void 0 : statusInfo.seller_email) || "Unavailable" })
|
|
741
|
+
] })
|
|
742
|
+
] }),
|
|
743
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
744
|
+
"button",
|
|
745
|
+
{
|
|
746
|
+
type: "button",
|
|
747
|
+
onClick: handleDisconnect,
|
|
748
|
+
disabled: onboardingInProgress,
|
|
749
|
+
className: "rounded-md border border-ui-border-base px-3 py-2 text-sm font-medium hover:bg-ui-bg-subtle disabled:opacity-50 disabled:cursor-not-allowed",
|
|
750
|
+
children: "Disconnect"
|
|
751
|
+
}
|
|
752
|
+
) })
|
|
753
|
+
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
754
|
+
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
755
|
+
"div",
|
|
756
|
+
{
|
|
757
|
+
ref: initLoaderRef,
|
|
758
|
+
id: "init-loader",
|
|
759
|
+
className: `status-msg mb-4 ${connState !== "loading" ? "hidden" : "block"}`,
|
|
760
|
+
children: [
|
|
761
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "loader inline-block align-middle mr-2" }),
|
|
762
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { id: "loader-text", className: "text-sm", children: onboardingInProgress ? "Configuring connection to PayPal…" : "Checking connection..." })
|
|
763
|
+
]
|
|
764
|
+
}
|
|
765
|
+
),
|
|
766
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: `${connState === "ready" ? "block" : "hidden"}`, children: [
|
|
767
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
768
|
+
"a",
|
|
769
|
+
{
|
|
770
|
+
ref: (node) => {
|
|
771
|
+
paypalButtonRef.current = node;
|
|
772
|
+
ppBtnMeasureRef.current = node;
|
|
773
|
+
},
|
|
774
|
+
id: "paypal-button",
|
|
775
|
+
"data-paypal-button": "true",
|
|
776
|
+
href: finalUrl || "#",
|
|
777
|
+
"data-paypal-onboard-complete": "onboardingCallback",
|
|
778
|
+
onClick: handleConnectClick,
|
|
779
|
+
className: "btn-paypal",
|
|
780
|
+
style: {
|
|
781
|
+
borderRadius: "50px",
|
|
782
|
+
textDecoration: "none",
|
|
783
|
+
display: "inline-block",
|
|
784
|
+
fontWeight: "bold",
|
|
785
|
+
border: "none",
|
|
786
|
+
cursor: onboardingInProgress ? "not-allowed" : "pointer",
|
|
787
|
+
opacity: onboardingInProgress ? 0.6 : 1,
|
|
788
|
+
pointerEvents: onboardingInProgress ? "none" : "auto"
|
|
789
|
+
},
|
|
790
|
+
children: "Connect to PayPal"
|
|
791
|
+
}
|
|
792
|
+
),
|
|
793
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
794
|
+
"div",
|
|
795
|
+
{
|
|
796
|
+
className: "mt-2",
|
|
797
|
+
style: {
|
|
798
|
+
width: ppBtnWidth ? `${ppBtnWidth}px` : "auto",
|
|
799
|
+
marginTop: "20px",
|
|
800
|
+
marginBottom: "10px"
|
|
801
|
+
},
|
|
802
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] text-ui-fg-muted leading-none", children: "OR" }) })
|
|
803
|
+
}
|
|
804
|
+
),
|
|
805
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
806
|
+
"button",
|
|
807
|
+
{
|
|
808
|
+
type: "button",
|
|
809
|
+
onClick: () => setShowManual(!showManual),
|
|
810
|
+
disabled: onboardingInProgress,
|
|
811
|
+
className: "text-sm text-ui-fg-interactive underline whitespace-nowrap disabled:opacity-50 disabled:cursor-not-allowed",
|
|
812
|
+
children: "Click here to insert credentials manually"
|
|
813
|
+
}
|
|
814
|
+
) })
|
|
815
|
+
] }),
|
|
816
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `${connState === "ready" ? "hidden" : "block"} mt-3`, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
817
|
+
"button",
|
|
818
|
+
{
|
|
819
|
+
type: "button",
|
|
820
|
+
onClick: () => setShowManual(!showManual),
|
|
821
|
+
disabled: onboardingInProgress,
|
|
822
|
+
className: "text-sm text-ui-fg-interactive underline whitespace-nowrap disabled:opacity-50 disabled:cursor-not-allowed",
|
|
823
|
+
children: "Click here to insert credentials manually"
|
|
824
|
+
}
|
|
825
|
+
) }),
|
|
826
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
827
|
+
"div",
|
|
828
|
+
{
|
|
829
|
+
ref: errorLogRef,
|
|
830
|
+
id: "error-log",
|
|
831
|
+
className: `mt-4 text-left text-xs bg-red-50 text-red-600 p-3 border border-red-200 rounded ${connState === "error" && error ? "block" : "hidden"}`,
|
|
832
|
+
children: error
|
|
833
|
+
}
|
|
834
|
+
)
|
|
835
|
+
] }) }),
|
|
836
|
+
showManual && /* @__PURE__ */ jsxRuntime.jsx("div", { className: "md:col-span-2", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "ml-[260px] max-w-xl mt-4 grid grid-cols-1 gap-3 md:grid-cols-2", children: [
|
|
837
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
838
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Client ID" }),
|
|
839
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
840
|
+
"input",
|
|
841
|
+
{
|
|
842
|
+
type: "text",
|
|
843
|
+
value: clientId,
|
|
844
|
+
onChange: (e) => setClientId(e.target.value),
|
|
845
|
+
disabled: onboardingInProgress,
|
|
846
|
+
className: "rounded-md border border-ui-border-base bg-transparent px-3 py-2 text-sm disabled:opacity-50",
|
|
847
|
+
placeholder: env === "sandbox" ? "Sandbox Client ID" : "Live Client ID"
|
|
848
|
+
}
|
|
849
|
+
)
|
|
850
|
+
] }),
|
|
851
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1", children: [
|
|
852
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Client Secret" }),
|
|
853
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
854
|
+
"input",
|
|
855
|
+
{
|
|
856
|
+
type: "password",
|
|
857
|
+
value: secret,
|
|
858
|
+
onChange: (e) => setSecret(e.target.value),
|
|
859
|
+
disabled: onboardingInProgress,
|
|
860
|
+
className: "rounded-md border border-ui-border-base bg-transparent px-3 py-2 text-sm disabled:opacity-50",
|
|
861
|
+
placeholder: env === "sandbox" ? "Sandbox Secret" : "Live Secret"
|
|
862
|
+
}
|
|
863
|
+
)
|
|
864
|
+
] }),
|
|
865
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:col-span-2", children: [
|
|
866
|
+
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Merchant ID (optional)" }),
|
|
867
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
868
|
+
"input",
|
|
869
|
+
{
|
|
870
|
+
type: "text",
|
|
871
|
+
value: merchantId,
|
|
872
|
+
onChange: (e) => setMerchantId(e.target.value),
|
|
873
|
+
disabled: onboardingInProgress,
|
|
874
|
+
className: "rounded-md border border-ui-border-base bg-transparent px-3 py-2 text-sm disabled:opacity-50",
|
|
875
|
+
placeholder: "Merchant ID"
|
|
876
|
+
}
|
|
877
|
+
)
|
|
878
|
+
] }),
|
|
879
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:col-span-2 flex items-center gap-2 mt-2", children: [
|
|
880
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
881
|
+
"button",
|
|
882
|
+
{
|
|
883
|
+
type: "button",
|
|
884
|
+
className: "rounded-md border border-ui-border-base px-3 py-2 text-sm font-medium hover:bg-ui-bg-subtle disabled:opacity-50 disabled:cursor-not-allowed",
|
|
885
|
+
onClick: () => setShowManual(false),
|
|
886
|
+
disabled: onboardingInProgress,
|
|
887
|
+
children: "Cancel"
|
|
888
|
+
}
|
|
889
|
+
),
|
|
890
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
891
|
+
"button",
|
|
892
|
+
{
|
|
893
|
+
type: "button",
|
|
894
|
+
className: "rounded-md border border-ui-border-base px-3 py-2 text-sm font-medium bg-ui-bg-base hover:bg-ui-bg-subtle disabled:opacity-50 disabled:cursor-not-allowed",
|
|
895
|
+
disabled: !canSaveManual || onboardingInProgress,
|
|
896
|
+
onClick: handleSaveManual,
|
|
897
|
+
children: "Save credentials"
|
|
898
|
+
}
|
|
899
|
+
)
|
|
900
|
+
] })
|
|
901
|
+
] }) })
|
|
902
|
+
] }) })
|
|
903
|
+
] }),
|
|
904
|
+
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
905
|
+
.loader {
|
|
906
|
+
border: 3px solid #f3f3f3;
|
|
907
|
+
border-top: 3px solid #0070ba;
|
|
908
|
+
border-radius: 50%;
|
|
909
|
+
width: 18px;
|
|
910
|
+
height: 18px;
|
|
911
|
+
animation: spin 1s linear infinite;
|
|
912
|
+
display: inline-block;
|
|
913
|
+
vertical-align: middle;
|
|
914
|
+
margin-right: 8px;
|
|
915
|
+
}
|
|
916
|
+
@keyframes spin {
|
|
917
|
+
0% { transform: rotate(0deg); }
|
|
918
|
+
100% { transform: rotate(360deg); }
|
|
919
|
+
}
|
|
920
|
+
` })
|
|
921
|
+
] });
|
|
922
|
+
}
|
|
923
|
+
const DEFAULT_FORM = {
|
|
924
|
+
enabled: true,
|
|
925
|
+
title: "Credit or Debit Card",
|
|
926
|
+
disabledCards: [],
|
|
927
|
+
threeDS: "when_required",
|
|
928
|
+
cardSaveEnabled: false
|
|
929
|
+
};
|
|
930
|
+
function mergeWithDefaults(saved) {
|
|
931
|
+
if (!saved) return { ...DEFAULT_FORM };
|
|
932
|
+
const entries = Object.entries(saved).filter(([, value]) => value !== void 0);
|
|
933
|
+
return {
|
|
934
|
+
...DEFAULT_FORM,
|
|
935
|
+
...Object.fromEntries(entries)
|
|
936
|
+
};
|
|
937
|
+
}
|
|
938
|
+
const CARD_BRANDS = [
|
|
939
|
+
{ value: "visa", label: "Visa" },
|
|
940
|
+
{ value: "mastercard", label: "Mastercard" },
|
|
941
|
+
{ value: "amex", label: "American Express" },
|
|
942
|
+
{ value: "discover", label: "Discover" },
|
|
943
|
+
{ value: "diners", label: "Diners Club" },
|
|
944
|
+
{ value: "jcb", label: "JCB" },
|
|
945
|
+
{ value: "unionpay", label: "UnionPay" }
|
|
946
|
+
];
|
|
947
|
+
const THREE_DS_OPTIONS = [
|
|
948
|
+
{
|
|
949
|
+
value: "when_required",
|
|
950
|
+
label: "3D Secure when required",
|
|
951
|
+
hint: "Triggers 3DS only when the card / issuer requires it."
|
|
952
|
+
},
|
|
953
|
+
{
|
|
954
|
+
value: "sli",
|
|
955
|
+
label: "3D Secure (SCA) / liability shift (recommended)",
|
|
956
|
+
hint: "Attempts to optimize for liability shift while remaining compliant."
|
|
957
|
+
},
|
|
958
|
+
{
|
|
959
|
+
value: "always",
|
|
960
|
+
label: "Always request 3D Secure",
|
|
961
|
+
hint: "Forces 3DS challenge whenever possible (may reduce conversion)."
|
|
962
|
+
}
|
|
963
|
+
];
|
|
964
|
+
function cx$1(...parts) {
|
|
965
|
+
return parts.filter(Boolean).join(" ");
|
|
966
|
+
}
|
|
967
|
+
function Pill$1({
|
|
968
|
+
children,
|
|
969
|
+
onRemove
|
|
970
|
+
}) {
|
|
971
|
+
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: [
|
|
972
|
+
children,
|
|
973
|
+
onRemove ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
974
|
+
"button",
|
|
975
|
+
{
|
|
976
|
+
type: "button",
|
|
977
|
+
onClick: onRemove,
|
|
978
|
+
className: "ml-1 rounded px-1 text-ui-fg-subtle hover:text-ui-fg-base",
|
|
979
|
+
"aria-label": "Remove",
|
|
980
|
+
children: "×"
|
|
981
|
+
}
|
|
982
|
+
) : null
|
|
983
|
+
] });
|
|
984
|
+
}
|
|
985
|
+
function SectionCard$1({
|
|
986
|
+
title,
|
|
987
|
+
description,
|
|
988
|
+
right,
|
|
989
|
+
children
|
|
990
|
+
}) {
|
|
991
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "rounded-xl border border-ui-border-base bg-ui-bg-base shadow-sm", children: [
|
|
992
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-start justify-between gap-4 border-b border-ui-border-base p-4", children: [
|
|
993
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { children: [
|
|
994
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-base font-semibold text-ui-fg-base", children: title }),
|
|
995
|
+
description ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-sm text-ui-fg-subtle", children: description }) : null
|
|
996
|
+
] }),
|
|
997
|
+
right
|
|
998
|
+
] }),
|
|
999
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-4", children })
|
|
1000
|
+
] });
|
|
1001
|
+
}
|
|
1002
|
+
function FieldRow$1({
|
|
1003
|
+
label,
|
|
1004
|
+
hint,
|
|
1005
|
+
children
|
|
1006
|
+
}) {
|
|
1007
|
+
return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "grid grid-cols-12 items-start gap-4 py-3", children: [
|
|
1008
|
+
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "col-span-12 md:col-span-4", children: [
|
|
1009
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "text-sm font-medium text-ui-fg-base", children: label }),
|
|
1010
|
+
hint ? /* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-1 text-xs text-ui-fg-subtle", children: hint }) : null
|
|
1011
|
+
] }),
|
|
1012
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "col-span-12 md:col-span-8", children })
|
|
1013
|
+
] });
|
|
1014
|
+
}
|
|
1015
|
+
function AdvancedCardPaymentsTab() {
|
|
1016
|
+
var _a, _b;
|
|
1017
|
+
const [form, setForm] = react.useState(() => ({ ...DEFAULT_FORM }));
|
|
1018
|
+
const [loading, setLoading] = react.useState(false);
|
|
1019
|
+
const [saving, setSaving] = react.useState(false);
|
|
1020
|
+
const [toast, setToast] = react.useState(null);
|
|
1021
|
+
const didInit = react.useRef(false);
|
|
1022
|
+
react.useEffect(() => {
|
|
1023
|
+
if (didInit.current) return;
|
|
1024
|
+
didInit.current = true;
|
|
1025
|
+
(async () => {
|
|
933
1026
|
try {
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
1027
|
+
setLoading(true);
|
|
1028
|
+
const r = await fetch("/admin/paypal/settings", {
|
|
1029
|
+
credentials: "include",
|
|
1030
|
+
headers: { "Accept": "application/json" }
|
|
1031
|
+
});
|
|
1032
|
+
if (!r.ok) return;
|
|
1033
|
+
const json = await r.json();
|
|
1034
|
+
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
1035
|
+
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
1036
|
+
if (saved && typeof saved === "object") {
|
|
1037
|
+
setForm(mergeWithDefaults(saved));
|
|
1038
|
+
}
|
|
1039
|
+
} finally {
|
|
1040
|
+
setLoading(false);
|
|
937
1041
|
}
|
|
938
|
-
}
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
setError((e == null ? void 0 : e.message) || "Failed to save credentials.");
|
|
942
|
-
} finally {
|
|
943
|
-
setOnboardingInProgress(false);
|
|
944
|
-
}
|
|
945
|
-
};
|
|
946
|
-
const handleDisconnect = async () => {
|
|
947
|
-
if (onboardingInProgress) return;
|
|
948
|
-
if (!window.confirm("Disconnect PayPal for this environment?")) return;
|
|
949
|
-
setOnboardingInProgress(true);
|
|
950
|
-
setConnState("loading");
|
|
951
|
-
setError(null);
|
|
952
|
-
setFinalUrl("");
|
|
953
|
-
setShowManual(false);
|
|
1042
|
+
})();
|
|
1043
|
+
}, []);
|
|
1044
|
+
async function onSave() {
|
|
954
1045
|
try {
|
|
955
|
-
|
|
1046
|
+
setSaving(true);
|
|
1047
|
+
const r = await fetch("/admin/paypal/settings", {
|
|
956
1048
|
method: "POST",
|
|
957
|
-
|
|
958
|
-
|
|
1049
|
+
credentials: "include",
|
|
1050
|
+
headers: {
|
|
1051
|
+
"Content-Type": "application/json",
|
|
1052
|
+
"Accept": "application/json"
|
|
1053
|
+
},
|
|
1054
|
+
body: JSON.stringify({ advanced_card_payments: form })
|
|
959
1055
|
});
|
|
960
|
-
if (!
|
|
961
|
-
const t = await
|
|
962
|
-
|
|
1056
|
+
if (!r.ok) {
|
|
1057
|
+
const t = await r.text();
|
|
1058
|
+
setToast({ type: "error", message: "Failed to save settings. " + t });
|
|
1059
|
+
window.setTimeout(() => setToast(null), 3500);
|
|
1060
|
+
return;
|
|
963
1061
|
}
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
1062
|
+
const json = await r.json().catch(() => null);
|
|
1063
|
+
const payload = (json == null ? void 0 : json.data) ?? json;
|
|
1064
|
+
const saved = payload == null ? void 0 : payload.advanced_card_payments;
|
|
1065
|
+
if (saved && typeof saved === "object") {
|
|
1066
|
+
setForm(mergeWithDefaults(saved));
|
|
968
1067
|
}
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
fetchFreshLink(runId);
|
|
972
|
-
} catch (e) {
|
|
973
|
-
console.error(e);
|
|
974
|
-
setConnState("error");
|
|
975
|
-
setError((e == null ? void 0 : e.message) || "Failed to disconnect.");
|
|
1068
|
+
setToast({ type: "success", message: "Settings saved" });
|
|
1069
|
+
window.setTimeout(() => setToast(null), 2500);
|
|
976
1070
|
} finally {
|
|
977
|
-
|
|
978
|
-
}
|
|
979
|
-
};
|
|
980
|
-
const handleEnvChange = async (e) => {
|
|
981
|
-
const next = e.target.value;
|
|
982
|
-
setEnv(next);
|
|
983
|
-
cachedUrl = null;
|
|
984
|
-
try {
|
|
985
|
-
await fetch("/admin/paypal/environment", {
|
|
986
|
-
method: "POST",
|
|
987
|
-
headers: { "content-type": "application/json" },
|
|
988
|
-
body: JSON.stringify({ environment: next })
|
|
989
|
-
});
|
|
990
|
-
} catch {
|
|
991
|
-
}
|
|
992
|
-
try {
|
|
993
|
-
localStorage.removeItem(CACHE_KEY);
|
|
994
|
-
localStorage.removeItem(RELOAD_KEY);
|
|
995
|
-
} catch {
|
|
1071
|
+
setSaving(false);
|
|
996
1072
|
}
|
|
997
|
-
}
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1033
|
-
|
|
1034
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "mt-1", children: [
|
|
1035
|
-
"Email:",
|
|
1036
|
-
" ",
|
|
1037
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "font-mono text-ui-fg-base", children: (statusInfo == null ? void 0 : statusInfo.seller_email) || "Unavailable" })
|
|
1038
|
-
] })
|
|
1039
|
-
] }),
|
|
1040
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "mt-3 flex items-center gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1041
|
-
"button",
|
|
1042
|
-
{
|
|
1043
|
-
type: "button",
|
|
1044
|
-
onClick: handleDisconnect,
|
|
1045
|
-
disabled: onboardingInProgress,
|
|
1046
|
-
className: "rounded-md border border-ui-border-base px-3 py-2 text-sm font-medium hover:bg-ui-bg-subtle disabled:opacity-50 disabled:cursor-not-allowed",
|
|
1047
|
-
children: "Disconnect"
|
|
1048
|
-
}
|
|
1049
|
-
) })
|
|
1050
|
-
] }) : /* @__PURE__ */ jsxRuntime.jsxs(jsxRuntime.Fragment, { children: [
|
|
1051
|
-
/* @__PURE__ */ jsxRuntime.jsxs(
|
|
1052
|
-
"div",
|
|
1073
|
+
}
|
|
1074
|
+
const disabledSet = react.useMemo(() => new Set(form.disabledCards), [form.disabledCards]);
|
|
1075
|
+
function toggleDisabledCard(value) {
|
|
1076
|
+
setForm((prev) => {
|
|
1077
|
+
const exists = prev.disabledCards.includes(value);
|
|
1078
|
+
return {
|
|
1079
|
+
...prev,
|
|
1080
|
+
disabledCards: exists ? prev.disabledCards.filter((v) => v !== value) : [...prev.disabledCards, value]
|
|
1081
|
+
};
|
|
1082
|
+
});
|
|
1083
|
+
}
|
|
1084
|
+
function removeDisabledCard(value) {
|
|
1085
|
+
setForm((prev) => ({
|
|
1086
|
+
...prev,
|
|
1087
|
+
disabledCards: prev.disabledCards.filter((v) => v !== value)
|
|
1088
|
+
}));
|
|
1089
|
+
}
|
|
1090
|
+
return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "p-6", children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-6", children: [
|
|
1091
|
+
/* @__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" }) }) }),
|
|
1092
|
+
/* @__PURE__ */ jsxRuntime.jsx(PayPalTabs, {}),
|
|
1093
|
+
toast ? /* @__PURE__ */ jsxRuntime.jsx(
|
|
1094
|
+
"div",
|
|
1095
|
+
{
|
|
1096
|
+
className: "fixed right-6 top-6 z-50 rounded-md border border-ui-border-base bg-ui-bg-base px-4 py-3 text-sm shadow-lg",
|
|
1097
|
+
role: "status",
|
|
1098
|
+
"aria-live": "polite",
|
|
1099
|
+
children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: toast.type === "success" ? "text-ui-fg-base" : "text-ui-fg-error", children: toast.message })
|
|
1100
|
+
}
|
|
1101
|
+
) : null,
|
|
1102
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1103
|
+
SectionCard$1,
|
|
1104
|
+
{
|
|
1105
|
+
title: "Advanced Card Payments",
|
|
1106
|
+
description: "Control card checkout settings, 3D Secure behavior, and card saving.",
|
|
1107
|
+
right: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex items-center gap-3", children: [
|
|
1108
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1109
|
+
"button",
|
|
1053
1110
|
{
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
/* @__PURE__ */ jsxRuntime.jsx("span", { id: "loader-text", className: "text-sm", children: onboardingInProgress ? "Configuring connection to PayPal…" : "Checking connection..." })
|
|
1060
|
-
]
|
|
1111
|
+
type: "button",
|
|
1112
|
+
onClick: onSave,
|
|
1113
|
+
disabled: saving || loading,
|
|
1114
|
+
className: "rounded-md bg-ui-button-neutral px-4 py-2 text-sm font-medium text-ui-fg-on-color shadow-sm hover:opacity-90 disabled:opacity-60",
|
|
1115
|
+
children: saving ? "Saving..." : "Save settings"
|
|
1061
1116
|
}
|
|
1062
1117
|
),
|
|
1063
|
-
/* @__PURE__ */ jsxRuntime.
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
ref: (node) => {
|
|
1068
|
-
paypalButtonRef.current = node;
|
|
1069
|
-
ppBtnMeasureRef.current = node;
|
|
1070
|
-
},
|
|
1071
|
-
id: "paypal-button",
|
|
1072
|
-
"data-paypal-button": "true",
|
|
1073
|
-
href: finalUrl || "#",
|
|
1074
|
-
"data-paypal-onboard-complete": "onboardingCallback",
|
|
1075
|
-
onClick: handleConnectClick,
|
|
1076
|
-
className: "btn-paypal",
|
|
1077
|
-
style: {
|
|
1078
|
-
borderRadius: "50px",
|
|
1079
|
-
textDecoration: "none",
|
|
1080
|
-
display: "inline-block",
|
|
1081
|
-
fontWeight: "bold",
|
|
1082
|
-
border: "none",
|
|
1083
|
-
cursor: onboardingInProgress ? "not-allowed" : "pointer",
|
|
1084
|
-
opacity: onboardingInProgress ? 0.6 : 1,
|
|
1085
|
-
pointerEvents: onboardingInProgress ? "none" : "auto"
|
|
1086
|
-
},
|
|
1087
|
-
children: "Connect to PayPal"
|
|
1088
|
-
}
|
|
1089
|
-
),
|
|
1118
|
+
loading ? /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "Loading…" }) : null
|
|
1119
|
+
] }),
|
|
1120
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "divide-y divide-ui-border-base", children: [
|
|
1121
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Enable/Disable", children: /* @__PURE__ */ jsxRuntime.jsxs("label", { className: "inline-flex items-center gap-2", children: [
|
|
1090
1122
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1091
|
-
"
|
|
1123
|
+
"input",
|
|
1092
1124
|
{
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
marginBottom: "10px"
|
|
1098
|
-
},
|
|
1099
|
-
children: /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex justify-center", children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-[11px] text-ui-fg-muted leading-none", children: "OR" }) })
|
|
1125
|
+
type: "checkbox",
|
|
1126
|
+
checked: form.enabled,
|
|
1127
|
+
onChange: (e) => setForm((p) => ({ ...p, enabled: e.target.checked })),
|
|
1128
|
+
className: "h-4 w-4 rounded border-ui-border-base"
|
|
1100
1129
|
}
|
|
1101
1130
|
),
|
|
1102
|
-
/* @__PURE__ */ jsxRuntime.jsx("
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
onClick: () => setShowManual(!showManual),
|
|
1107
|
-
disabled: onboardingInProgress,
|
|
1108
|
-
className: "text-sm text-ui-fg-interactive underline whitespace-nowrap disabled:opacity-50 disabled:cursor-not-allowed",
|
|
1109
|
-
children: "Click here to insert credentials manually"
|
|
1110
|
-
}
|
|
1111
|
-
) })
|
|
1112
|
-
] }),
|
|
1113
|
-
/* @__PURE__ */ jsxRuntime.jsx("div", { className: `${connState === "ready" ? "hidden" : "block"} mt-3`, children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1114
|
-
"button",
|
|
1131
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable Advanced Credit/Debit Card" })
|
|
1132
|
+
] }) }),
|
|
1133
|
+
/* @__PURE__ */ jsxRuntime.jsx(FieldRow$1, { label: "Title", children: /* @__PURE__ */ jsxRuntime.jsx(
|
|
1134
|
+
"input",
|
|
1115
1135
|
{
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
children: "Click here to insert credentials manually"
|
|
1136
|
+
value: form.title,
|
|
1137
|
+
onChange: (e) => setForm((p) => ({ ...p, title: e.target.value })),
|
|
1138
|
+
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",
|
|
1139
|
+
placeholder: "Credit or Debit Card"
|
|
1121
1140
|
}
|
|
1122
1141
|
) }),
|
|
1123
1142
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1124
|
-
|
|
1143
|
+
FieldRow$1,
|
|
1125
1144
|
{
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1145
|
+
label: "Disable specific credit cards",
|
|
1146
|
+
hint: "Select card brands to hide from the card form.",
|
|
1147
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
1148
|
+
/* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-wrap gap-2", children: form.disabledCards.length ? form.disabledCards.map((v) => {
|
|
1149
|
+
var _a2;
|
|
1150
|
+
const label = ((_a2 = CARD_BRANDS.find((b) => b.value === v)) == null ? void 0 : _a2.label) ?? v;
|
|
1151
|
+
return /* @__PURE__ */ jsxRuntime.jsx(Pill$1, { onRemove: () => removeDisabledCard(v), children: label }, v);
|
|
1152
|
+
}) : /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-subtle", children: "No card brands disabled." }) }),
|
|
1153
|
+
/* @__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) => {
|
|
1154
|
+
const checked = disabledSet.has(b.value);
|
|
1155
|
+
return /* @__PURE__ */ jsxRuntime.jsxs(
|
|
1156
|
+
"label",
|
|
1157
|
+
{
|
|
1158
|
+
className: cx$1(
|
|
1159
|
+
"flex items-center gap-2 rounded-md p-2",
|
|
1160
|
+
"hover:bg-ui-bg-subtle"
|
|
1161
|
+
),
|
|
1162
|
+
children: [
|
|
1163
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1164
|
+
"input",
|
|
1165
|
+
{
|
|
1166
|
+
type: "checkbox",
|
|
1167
|
+
checked,
|
|
1168
|
+
onChange: () => toggleDisabledCard(b.value),
|
|
1169
|
+
className: "h-4 w-4 rounded border-ui-border-base"
|
|
1170
|
+
}
|
|
1171
|
+
),
|
|
1172
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: b.label })
|
|
1173
|
+
]
|
|
1174
|
+
},
|
|
1175
|
+
b.value
|
|
1176
|
+
);
|
|
1177
|
+
}) }) })
|
|
1178
|
+
] })
|
|
1130
1179
|
}
|
|
1131
|
-
)
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
"
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
{
|
|
1153
|
-
type: "password",
|
|
1154
|
-
value: secret,
|
|
1155
|
-
onChange: (e) => setSecret(e.target.value),
|
|
1156
|
-
disabled: onboardingInProgress,
|
|
1157
|
-
className: "rounded-md border border-ui-border-base bg-transparent px-3 py-2 text-sm disabled:opacity-50",
|
|
1158
|
-
placeholder: env === "sandbox" ? "Sandbox Secret" : "Live Secret"
|
|
1159
|
-
}
|
|
1160
|
-
)
|
|
1161
|
-
] }),
|
|
1162
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-1 md:col-span-2", children: [
|
|
1163
|
-
/* @__PURE__ */ jsxRuntime.jsx("label", { className: "text-sm font-medium", children: "Merchant ID (optional)" }),
|
|
1180
|
+
),
|
|
1181
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1182
|
+
FieldRow$1,
|
|
1183
|
+
{
|
|
1184
|
+
label: "Contingency for 3D Secure",
|
|
1185
|
+
hint: "Choose when 3D Secure should be triggered during card payments.",
|
|
1186
|
+
children: /* @__PURE__ */ jsxRuntime.jsxs("div", { className: "flex flex-col gap-2", children: [
|
|
1187
|
+
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1188
|
+
"select",
|
|
1189
|
+
{
|
|
1190
|
+
value: form.threeDS,
|
|
1191
|
+
onChange: (e) => setForm((p) => ({ ...p, threeDS: e.target.value })),
|
|
1192
|
+
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",
|
|
1193
|
+
children: THREE_DS_OPTIONS.map((o) => /* @__PURE__ */ jsxRuntime.jsx("option", { value: o.value, children: o.label }, o.value))
|
|
1194
|
+
}
|
|
1195
|
+
),
|
|
1196
|
+
((_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
|
|
1197
|
+
] })
|
|
1198
|
+
}
|
|
1199
|
+
),
|
|
1200
|
+
/* @__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: [
|
|
1164
1201
|
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1165
1202
|
"input",
|
|
1166
1203
|
{
|
|
1167
|
-
type: "
|
|
1168
|
-
|
|
1169
|
-
onChange: (e) =>
|
|
1170
|
-
|
|
1171
|
-
className: "rounded-md border border-ui-border-base bg-transparent px-3 py-2 text-sm disabled:opacity-50",
|
|
1172
|
-
placeholder: "Merchant ID"
|
|
1173
|
-
}
|
|
1174
|
-
)
|
|
1175
|
-
] }),
|
|
1176
|
-
/* @__PURE__ */ jsxRuntime.jsxs("div", { className: "md:col-span-2 flex items-center gap-2 mt-2", children: [
|
|
1177
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1178
|
-
"button",
|
|
1179
|
-
{
|
|
1180
|
-
type: "button",
|
|
1181
|
-
className: "rounded-md border border-ui-border-base px-3 py-2 text-sm font-medium hover:bg-ui-bg-subtle disabled:opacity-50 disabled:cursor-not-allowed",
|
|
1182
|
-
onClick: () => setShowManual(false),
|
|
1183
|
-
disabled: onboardingInProgress,
|
|
1184
|
-
children: "Cancel"
|
|
1204
|
+
type: "checkbox",
|
|
1205
|
+
checked: form.cardSaveEnabled,
|
|
1206
|
+
onChange: (e) => setForm((p) => ({ ...p, cardSaveEnabled: e.target.checked })),
|
|
1207
|
+
className: "h-4 w-4 rounded border-ui-border-base"
|
|
1185
1208
|
}
|
|
1186
1209
|
),
|
|
1187
|
-
/* @__PURE__ */ jsxRuntime.jsx(
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
onClick: handleSaveManual,
|
|
1194
|
-
children: "Save credentials"
|
|
1195
|
-
}
|
|
1196
|
-
)
|
|
1197
|
-
] })
|
|
1198
|
-
] }) })
|
|
1199
|
-
] }) })
|
|
1200
|
-
] }),
|
|
1201
|
-
/* @__PURE__ */ jsxRuntime.jsx("style", { children: `
|
|
1202
|
-
.loader {
|
|
1203
|
-
border: 3px solid #f3f3f3;
|
|
1204
|
-
border-top: 3px solid #0070ba;
|
|
1205
|
-
border-radius: 50%;
|
|
1206
|
-
width: 18px;
|
|
1207
|
-
height: 18px;
|
|
1208
|
-
animation: spin 1s linear infinite;
|
|
1209
|
-
display: inline-block;
|
|
1210
|
-
vertical-align: middle;
|
|
1211
|
-
margin-right: 8px;
|
|
1212
|
-
}
|
|
1213
|
-
@keyframes spin {
|
|
1214
|
-
0% { transform: rotate(0deg); }
|
|
1215
|
-
100% { transform: rotate(360deg); }
|
|
1216
|
-
}
|
|
1217
|
-
` })
|
|
1218
|
-
] });
|
|
1210
|
+
/* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-sm text-ui-fg-base", children: "Enable card saving at checkout" })
|
|
1211
|
+
] }) })
|
|
1212
|
+
] })
|
|
1213
|
+
}
|
|
1214
|
+
)
|
|
1215
|
+
] }) });
|
|
1219
1216
|
}
|
|
1220
1217
|
function formatDate$2(value) {
|
|
1221
1218
|
if (!value) {
|
|
@@ -1296,6 +1293,9 @@ function PayPalAuditLogsPage() {
|
|
|
1296
1293
|
] })
|
|
1297
1294
|
] }) });
|
|
1298
1295
|
}
|
|
1296
|
+
function PayPalApplePayPage() {
|
|
1297
|
+
return /* @__PURE__ */ jsxRuntime.jsx(reactRouterDom.Navigate, { to: "/settings/paypal/connection", replace: true });
|
|
1298
|
+
}
|
|
1299
1299
|
const EMPTY_FILTERS = {
|
|
1300
1300
|
dispute_id: "",
|
|
1301
1301
|
status: "",
|
|
@@ -2052,22 +2052,22 @@ const routeModule = {
|
|
|
2052
2052
|
Component: AdditionalSettingsTab,
|
|
2053
2053
|
path: "/settings/paypal/additional-settings"
|
|
2054
2054
|
},
|
|
2055
|
-
{
|
|
2056
|
-
Component: AdvancedCardPaymentsTab,
|
|
2057
|
-
path: "/settings/paypal/advanced-card-payments"
|
|
2058
|
-
},
|
|
2059
|
-
{
|
|
2060
|
-
Component: PayPalApplePayPage,
|
|
2061
|
-
path: "/settings/paypal/apple-pay"
|
|
2062
|
-
},
|
|
2063
2055
|
{
|
|
2064
2056
|
Component: PayPalConnectionPage,
|
|
2065
2057
|
path: "/settings/paypal/connection"
|
|
2066
2058
|
},
|
|
2059
|
+
{
|
|
2060
|
+
Component: AdvancedCardPaymentsTab,
|
|
2061
|
+
path: "/settings/paypal/advanced-card-payments"
|
|
2062
|
+
},
|
|
2067
2063
|
{
|
|
2068
2064
|
Component: PayPalAuditLogsPage,
|
|
2069
2065
|
path: "/settings/paypal/audit-logs"
|
|
2070
2066
|
},
|
|
2067
|
+
{
|
|
2068
|
+
Component: PayPalApplePayPage,
|
|
2069
|
+
path: "/settings/paypal/apple-pay"
|
|
2070
|
+
},
|
|
2071
2071
|
{
|
|
2072
2072
|
Component: PayPalDisputesPage,
|
|
2073
2073
|
path: "/settings/paypal/disputes"
|