@easypayment/medusa-payment-paypal 0.9.20 → 0.9.22

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.
@@ -223,9 +223,6 @@ function AdditionalSettingsTab() {
223
223
  )
224
224
  ] }) });
225
225
  }
226
- function PayPalApplePayPage() {
227
- return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
228
- }
229
226
  const DEFAULT_FORM = {
230
227
  enabled: true,
231
228
  title: "Credit or Debit Card",
@@ -310,6 +307,12 @@ function AdvancedCardPaymentsTab() {
310
307
  )
311
308
  ] }) });
312
309
  }
310
+ function PayPalApplePayPage() {
311
+ return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
312
+ }
313
+ function PayPalGooglePayPage() {
314
+ return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
315
+ }
313
316
  const config = defineRouteConfig({
314
317
  label: "PayPal Connection"
315
318
  });
@@ -318,9 +321,9 @@ const PARTNER_JS_URLS = {
318
321
  live: "https://www.paypal.com/webapps/merchantboarding/js/lib/lightbox/partner.js"
319
322
  };
320
323
  const SERVICE_URL = "/admin/paypal/onboarding-link";
321
- const POPUP_NAME = "PPMiniBrowser";
324
+ const POPUP_NAME = "PPFrame";
322
325
  const CACHE_PREFIX = "pp_onboard_cache";
323
- const CACHE_EXPIRY = 10 * 60 * 1e3;
326
+ const CACHE_EXPIRY = 6 * 60 * 60 * 1e3;
324
327
  const ONBOARDING_COMPLETE_ENDPOINT = "/admin/paypal/onboard-complete";
325
328
  const STATUS_ENDPOINT = "/admin/paypal/status";
326
329
  const SAVE_CREDENTIALS_ENDPOINT = "/admin/paypal/save-credentials";
@@ -343,7 +346,9 @@ function readCachedUrl(env) {
343
346
  function writeCachedUrl(env, url) {
344
347
  try {
345
348
  localStorage.setItem(cacheKeyFor(env), JSON.stringify({ url, ts: Date.now() }));
349
+ return readCachedUrl(env) === url;
346
350
  } catch {
351
+ return false;
347
352
  }
348
353
  }
349
354
  function clearCachedUrl(env) {
@@ -357,58 +362,12 @@ function clearCachedUrl(env) {
357
362
  } catch {
358
363
  }
359
364
  }
360
- function isPayPalOrigin(origin) {
361
- try {
362
- const host = new URL(origin).hostname.toLowerCase();
363
- return host === "www.paypal.com" || host === "www.sandbox.paypal.com" || host.endsWith(".paypal.com") || host.endsWith(".paypalobjects.com");
364
- } catch {
365
- return false;
366
- }
367
- }
368
- function extractAuth(data) {
369
- if (!data) return {};
370
- if (typeof data === "object") {
371
- const obj = data;
372
- const authCode = obj.authCode ?? obj.auth_code ?? obj.authcode;
373
- const sharedId = obj.sharedId ?? obj.shared_id ?? obj.sharedid;
374
- if (authCode && sharedId) {
375
- return { authCode: String(authCode), sharedId: String(sharedId) };
376
- }
377
- for (const key of ["data", "payload", "message", "detail", "body"]) {
378
- if (obj[key] && typeof obj[key] === "object") {
379
- const inner = extractAuth(obj[key]);
380
- if (inner.authCode && inner.sharedId) return inner;
381
- }
382
- }
383
- return {};
384
- }
385
- if (typeof data === "string") {
386
- const s = data.trim();
387
- if (!s) return {};
388
- if (s.startsWith("{")) {
389
- try {
390
- return extractAuth(JSON.parse(s));
391
- } catch {
392
- }
393
- }
394
- if (/auth_?code/i.test(s) && /shared_?id/i.test(s)) {
395
- try {
396
- const sp = new URLSearchParams(s.replace(/^[?#]/, ""));
397
- const authCode = sp.get("authCode") || sp.get("auth_code") || void 0;
398
- const sharedId = sp.get("sharedId") || sp.get("shared_id") || void 0;
399
- if (authCode && sharedId) return { authCode, sharedId };
400
- } catch {
401
- }
402
- }
403
- }
404
- return {};
405
- }
406
365
  function PayPalConnectionPage() {
407
366
  const [env, setEnv] = useState("live");
408
367
  const [envReady, setEnvReady] = useState(false);
409
368
  const [connState, setConnState] = useState("loading");
369
+ const [partnerReady, setPartnerReady] = useState(false);
410
370
  const [error, setError] = useState(null);
411
- const [popupBlocked, setPopupBlocked] = useState(false);
412
371
  const [finalUrl, setFinalUrl] = useState("");
413
372
  const [showManual, setShowManual] = useState(false);
414
373
  const [clientId, setClientId] = useState("");
@@ -416,22 +375,12 @@ function PayPalConnectionPage() {
416
375
  const [statusInfo, setStatusInfo] = useState(null);
417
376
  const [onboardingInProgress, setOnboardingInProgress] = useState(false);
418
377
  const initLoaderRef = useRef(null);
419
- const paypalButtonRef = useRef(null);
420
378
  const errorLogRef = useRef(null);
421
379
  const runIdRef = useRef(0);
422
380
  const currentRunId = useRef(0);
423
- const finalUrlRef = useRef(finalUrl);
424
- finalUrlRef.current = finalUrl;
425
- const connStateRef = useRef(connState);
426
- connStateRef.current = connState;
427
- const inProgressRef = useRef(onboardingInProgress);
428
- inProgressRef.current = onboardingInProgress;
429
381
  const envRef = useRef(env);
430
382
  envRef.current = env;
431
- const popupRef = useRef(null);
432
- const popupPollRef = useRef(null);
433
383
  const completedRef = useRef(false);
434
- const partnerBoundRef = useRef(false);
435
384
  const ppBtnMeasureRef = useRef(null);
436
385
  const [ppBtnWidth, setPpBtnWidth] = useState(null);
437
386
  const canSaveManual = useMemo(() => {
@@ -441,131 +390,23 @@ function PayPalConnectionPage() {
441
390
  setConnState("error");
442
391
  setError(msg);
443
392
  }, []);
444
- const stopPopupPoll = useCallback(() => {
445
- if (popupPollRef.current) {
446
- clearInterval(popupPollRef.current);
447
- popupPollRef.current = null;
448
- }
449
- }, []);
450
- const openOnboardingPopup = useCallback(
451
- (url) => {
452
- const w = 450;
453
- const h = 600;
454
- const baseLeft = typeof window.screenX === "number" ? window.screenX : window.screenLeft || 0;
455
- const baseTop = typeof window.screenY === "number" ? window.screenY : window.screenTop || 0;
456
- const outerW = window.outerWidth || document.documentElement.clientWidth || 1024;
457
- const outerH = window.outerHeight || document.documentElement.clientHeight || 768;
458
- const left = Math.round(baseLeft + Math.max(0, (outerW - w) / 2));
459
- const top = Math.round(baseTop + Math.max(0, (outerH - h) / 2));
460
- const features = `popup=yes,width=${w},height=${h},left=${left},top=${top},scrollbars=yes,resizable=yes`;
461
- let popup = null;
462
- try {
463
- popup = window.open(url, POPUP_NAME, features);
464
- } catch {
465
- popup = null;
466
- }
467
- if (popup) {
468
- popupRef.current = popup;
469
- try {
470
- popup.focus();
471
- } catch {
393
+ const generateLinkAndReload = useCallback(
394
+ async (targetEnv, runId) => {
395
+ if (initLoaderRef.current) {
396
+ const loaderText = initLoaderRef.current.querySelector("#loader-text");
397
+ if (loaderText) {
398
+ loaderText.textContent = "Generating onboarding session...";
472
399
  }
473
- stopPopupPoll();
474
- popupPollRef.current = setInterval(() => {
475
- if (!popupRef.current || popupRef.current.closed) {
476
- stopPopupPoll();
477
- }
478
- }, 1e3);
479
400
  }
480
- return popup;
481
- },
482
- [stopPopupPoll]
483
- );
484
- const completeOnboarding = useCallback(
485
- async (authCode, sharedId) => {
486
- var _a, _b, _c, _d, _e, _f, _g, _h;
487
- if (!authCode || !sharedId) return;
488
- if (completedRef.current) return;
489
- completedRef.current = true;
490
401
  try {
491
- window.onbeforeunload = null;
492
- } catch {
493
- }
494
- const activeEnv = envRef.current === "sandbox" ? "sandbox" : "live";
495
- setOnboardingInProgress(true);
496
- setConnState("loading");
497
- setError(null);
498
- setPopupBlocked(false);
499
- try {
500
- const res = await fetch(ONBOARDING_COMPLETE_ENDPOINT, {
402
+ const res = await fetch(SERVICE_URL, {
501
403
  method: "POST",
502
404
  headers: { "content-type": "application/json" },
503
405
  credentials: "include",
504
- body: JSON.stringify({ authCode, sharedId, env: activeEnv })
406
+ body: JSON.stringify({ products: ["PPCP"], environment: targetEnv })
505
407
  });
506
- if (!res.ok) {
507
- const txt = await res.text().catch(() => "");
508
- throw new Error(txt || `Onboarding exchange failed (${res.status})`);
509
- }
510
- try {
511
- (_a = popupRef.current) == null ? void 0 : _a.close();
512
- } catch {
513
- }
514
- stopPopupPoll();
515
- try {
516
- const close1 = (_e = (_d = (_c = (_b = window.PAYPAL) == null ? void 0 : _b.apps) == null ? void 0 : _c.Signup) == null ? void 0 : _d.MiniBrowser) == null ? void 0 : _e.closeFlow;
517
- if (typeof close1 === "function") close1();
518
- } catch {
519
- }
520
- try {
521
- const close2 = ((_h = (_g = (_f = window.PAYPAL) == null ? void 0 : _f.apps) == null ? void 0 : _g.Signup) == null ? void 0 : _h.miniBrowser) && window.PAYPAL.apps.Signup.miniBrowser.closeFlow;
522
- if (typeof close2 === "function") close2();
523
- } catch {
524
- }
525
- clearCachedUrl(activeEnv);
526
- try {
527
- const statusRes = await fetch(
528
- `${STATUS_ENDPOINT}?environment=${activeEnv}`,
529
- { method: "GET", credentials: "include" }
530
- );
531
- const refreshedStatus = await statusRes.json().catch(() => ({}));
532
- setStatusInfo(refreshedStatus || null);
533
- } catch {
534
- }
535
- setConnState("connected");
536
- setShowManual(false);
537
- } catch (e) {
538
- completedRef.current = false;
539
- console.error(e);
540
- setConnState("error");
541
- setError((e == null ? void 0 : e.message) || "Exchange failed while saving credentials.");
542
- } finally {
543
- setOnboardingInProgress(false);
544
- }
545
- },
546
- [stopPopupPoll]
547
- );
548
- const fetchFreshLink = useCallback(
549
- (runId, targetEnv) => {
550
- if (initLoaderRef.current) {
551
- const loaderText = initLoaderRef.current.querySelector("#loader-text");
552
- if (loaderText)
553
- loaderText.textContent = "Generating onboarding session...";
554
- }
555
- fetch(SERVICE_URL, {
556
- method: "POST",
557
- headers: { "content-type": "application/json" },
558
- credentials: "include",
559
- body: JSON.stringify({
560
- products: ["PPCP"],
561
- // Generate the link for the explicitly selected environment so it can
562
- // never depend on a racing POST /environment having landed yet.
563
- environment: targetEnv
564
- })
565
- }).then((r) => {
566
- if (!r.ok) throw new Error(`Service returned ${r.status}`);
567
- return r.json();
568
- }).then((data) => {
408
+ if (!res.ok) throw new Error(`Service returned ${res.status}`);
409
+ const data = await res.json();
569
410
  if (runId !== currentRunId.current) return;
570
411
  const href = data == null ? void 0 : data.onboarding_url;
571
412
  if (!href) {
@@ -573,13 +414,17 @@ function PayPalConnectionPage() {
573
414
  return;
574
415
  }
575
416
  const url = href + (href.includes("?") ? "&" : "?") + "displayMode=minibrowser";
576
- writeCachedUrl(targetEnv, url);
417
+ const persisted = writeCachedUrl(targetEnv, url);
418
+ if (persisted) {
419
+ window.location.reload();
420
+ return;
421
+ }
577
422
  setFinalUrl(url);
578
423
  setConnState("ready");
579
- }).catch(() => {
424
+ } catch {
580
425
  if (runId !== currentRunId.current) return;
581
426
  showError("Unable to connect to service.");
582
- });
427
+ }
583
428
  },
584
429
  [showError]
585
430
  );
@@ -596,12 +441,60 @@ function PayPalConnectionPage() {
596
441
  alive = false;
597
442
  };
598
443
  }, []);
444
+ useEffect(() => {
445
+ if (!envReady) return;
446
+ currentRunId.current = ++runIdRef.current;
447
+ const runId = currentRunId.current;
448
+ let cancelled = false;
449
+ completedRef.current = false;
450
+ const run = async () => {
451
+ setConnState("loading");
452
+ setError(null);
453
+ setFinalUrl("");
454
+ try {
455
+ const r = await fetch(`${STATUS_ENDPOINT}?environment=${env}`, {
456
+ method: "GET",
457
+ credentials: "include"
458
+ });
459
+ const st = await r.json().catch(() => ({}));
460
+ if (cancelled || runId !== currentRunId.current) return;
461
+ setStatusInfo(st);
462
+ const isConnected = (st == null ? void 0 : st.status) === "connected" && (st == null ? void 0 : st.seller_client_id_present) === true;
463
+ if (isConnected) {
464
+ setConnState("connected");
465
+ setShowManual(false);
466
+ return;
467
+ }
468
+ } catch (e) {
469
+ console.error(e);
470
+ }
471
+ if (cancelled || runId !== currentRunId.current) return;
472
+ const cached = readCachedUrl(env);
473
+ if (cached) {
474
+ setFinalUrl(cached);
475
+ setConnState("ready");
476
+ return;
477
+ }
478
+ await generateLinkAndReload(env, runId);
479
+ };
480
+ run();
481
+ return () => {
482
+ cancelled = true;
483
+ };
484
+ }, [env, envReady, generateLinkAndReload]);
599
485
  useEffect(() => {
600
486
  var _a, _b, _c;
601
487
  if (connState !== "ready" || !finalUrl) return;
602
488
  const scriptUrl = PARTNER_JS_URLS[env];
603
489
  let cancelled = false;
604
490
  let pollTimer;
491
+ setPartnerReady(false);
492
+ const readyFallback = setTimeout(() => {
493
+ if (!cancelled) setPartnerReady(true);
494
+ }, 6e3);
495
+ const markReady = () => {
496
+ if (!cancelled) setPartnerReady(true);
497
+ };
605
498
  const initPartner = (attempt = 0) => {
606
499
  var _a2, _b2;
607
500
  if (cancelled) return;
@@ -610,19 +503,19 @@ function PayPalConnectionPage() {
610
503
  if (target == null ? void 0 : target.init) {
611
504
  try {
612
505
  target.init();
613
- partnerBoundRef.current = true;
614
506
  } catch (e) {
615
507
  console.error("[paypal] partner.js init failed:", e);
616
508
  }
509
+ markReady();
617
510
  return;
618
511
  }
619
512
  if (typeof (signup == null ? void 0 : signup.render) === "function") {
620
513
  try {
621
514
  signup.render();
622
- partnerBoundRef.current = true;
623
515
  } catch (e) {
624
516
  console.error("[paypal] partner.js render failed:", e);
625
517
  }
518
+ markReady();
626
519
  return;
627
520
  }
628
521
  if (attempt < 40) {
@@ -633,8 +526,8 @@ function PayPalConnectionPage() {
633
526
  document.dispatchEvent(new Event("DOMContentLoaded"));
634
527
  } catch {
635
528
  }
529
+ markReady();
636
530
  };
637
- partnerBoundRef.current = false;
638
531
  const existingScript = document.getElementById("paypal-partner-js");
639
532
  if (existingScript) {
640
533
  (_a = existingScript.parentNode) == null ? void 0 : _a.removeChild(existingScript);
@@ -650,9 +543,11 @@ function PayPalConnectionPage() {
650
543
  ppScript.src = scriptUrl;
651
544
  ppScript.async = true;
652
545
  ppScript.onload = () => initPartner();
546
+ ppScript.onerror = () => markReady();
653
547
  document.body.appendChild(ppScript);
654
548
  return () => {
655
549
  cancelled = true;
550
+ clearTimeout(readyFallback);
656
551
  if (pollTimer) {
657
552
  clearTimeout(pollTimer);
658
553
  }
@@ -661,59 +556,61 @@ function PayPalConnectionPage() {
661
556
  }
662
557
  };
663
558
  }, [connState, finalUrl, env]);
664
- useEffect(() => {
665
- const onMessage = (ev) => {
666
- if (!isPayPalOrigin(ev.origin)) return;
667
- const { authCode, sharedId } = extractAuth(ev.data);
668
- if (authCode && sharedId) {
669
- completeOnboarding(authCode, sharedId);
559
+ const completeOnboarding = useCallback(async (authCode, sharedId) => {
560
+ var _a, _b, _c, _d, _e, _f, _g;
561
+ if (!authCode || !sharedId) return;
562
+ if (completedRef.current) return;
563
+ completedRef.current = true;
564
+ try {
565
+ window.onbeforeunload = null;
566
+ } catch {
567
+ }
568
+ const activeEnv = envRef.current === "sandbox" ? "sandbox" : "live";
569
+ setOnboardingInProgress(true);
570
+ setConnState("loading");
571
+ setError(null);
572
+ try {
573
+ const res = await fetch(ONBOARDING_COMPLETE_ENDPOINT, {
574
+ method: "POST",
575
+ headers: { "content-type": "application/json" },
576
+ credentials: "include",
577
+ body: JSON.stringify({ authCode, sharedId, env: activeEnv })
578
+ });
579
+ if (!res.ok) {
580
+ const txt = await res.text().catch(() => "");
581
+ throw new Error(txt || `Onboarding exchange failed (${res.status})`);
670
582
  }
671
- };
672
- window.addEventListener("message", onMessage);
673
- return () => window.removeEventListener("message", onMessage);
674
- }, [completeOnboarding]);
675
- useEffect(() => {
676
- if (!envReady) return;
677
- currentRunId.current = ++runIdRef.current;
678
- const runId = currentRunId.current;
679
- let cancelled = false;
680
- completedRef.current = false;
681
- const run = async () => {
682
- setConnState("loading");
683
- setError(null);
684
- setPopupBlocked(false);
685
- setFinalUrl("");
686
583
  try {
687
- const r = await fetch(`${STATUS_ENDPOINT}?environment=${env}`, {
584
+ const close1 = (_d = (_c = (_b = (_a = window.PAYPAL) == null ? void 0 : _a.apps) == null ? void 0 : _b.Signup) == null ? void 0 : _c.MiniBrowser) == null ? void 0 : _d.closeFlow;
585
+ if (typeof close1 === "function") close1();
586
+ } catch {
587
+ }
588
+ try {
589
+ const close2 = ((_g = (_f = (_e = window.PAYPAL) == null ? void 0 : _e.apps) == null ? void 0 : _f.Signup) == null ? void 0 : _g.miniBrowser) && window.PAYPAL.apps.Signup.miniBrowser.closeFlow;
590
+ if (typeof close2 === "function") close2();
591
+ } catch {
592
+ }
593
+ clearCachedUrl(activeEnv);
594
+ try {
595
+ const statusRes = await fetch(`${STATUS_ENDPOINT}?environment=${activeEnv}`, {
688
596
  method: "GET",
689
597
  credentials: "include"
690
598
  });
691
- const st = await r.json().catch(() => ({}));
692
- if (cancelled || runId !== currentRunId.current) return;
693
- setStatusInfo(st);
694
- const isConnected = (st == null ? void 0 : st.status) === "connected" && (st == null ? void 0 : st.seller_client_id_present) === true;
695
- if (isConnected) {
696
- setConnState("connected");
697
- setShowManual(false);
698
- return;
699
- }
700
- } catch (e) {
701
- console.error(e);
702
- }
703
- if (cancelled || runId !== currentRunId.current) return;
704
- const cached = readCachedUrl(env);
705
- if (cached) {
706
- setFinalUrl(cached);
707
- setConnState("ready");
708
- } else {
709
- fetchFreshLink(runId, env);
599
+ const refreshedStatus = await statusRes.json().catch(() => ({}));
600
+ setStatusInfo(refreshedStatus || null);
601
+ } catch {
710
602
  }
711
- };
712
- run();
713
- return () => {
714
- cancelled = true;
715
- };
716
- }, [env, envReady, fetchFreshLink]);
603
+ setConnState("connected");
604
+ setShowManual(false);
605
+ } catch (e) {
606
+ completedRef.current = false;
607
+ console.error(e);
608
+ setConnState("error");
609
+ setError((e == null ? void 0 : e.message) || "Exchange failed while saving credentials.");
610
+ } finally {
611
+ setOnboardingInProgress(false);
612
+ }
613
+ }, []);
717
614
  useLayoutEffect(() => {
718
615
  window.onboardingCallback = (authCode, sharedId) => {
719
616
  completeOnboarding(authCode, sharedId);
@@ -722,11 +619,6 @@ function PayPalConnectionPage() {
722
619
  window.onboardingCallback = void 0;
723
620
  };
724
621
  }, [completeOnboarding]);
725
- useEffect(() => {
726
- return () => {
727
- stopPopupPoll();
728
- };
729
- }, [stopPopupPoll]);
730
622
  useLayoutEffect(() => {
731
623
  const el = ppBtnMeasureRef.current;
732
624
  if (!el) return;
@@ -747,18 +639,6 @@ function PayPalConnectionPage() {
747
639
  else window.removeEventListener("resize", update);
748
640
  };
749
641
  }, [connState, env, finalUrl]);
750
- const handleConnectClick = (e) => {
751
- e.preventDefault();
752
- if (connStateRef.current !== "ready" || !finalUrlRef.current || inProgressRef.current) {
753
- return;
754
- }
755
- if (partnerBoundRef.current) {
756
- return;
757
- }
758
- completedRef.current = false;
759
- const popup = openOnboardingPopup(finalUrlRef.current);
760
- setPopupBlocked(!popup);
761
- };
762
642
  const handleSaveManual = async () => {
763
643
  if (!canSaveManual || onboardingInProgress) return;
764
644
  setOnboardingInProgress(true);
@@ -819,8 +699,7 @@ function PayPalConnectionPage() {
819
699
  clearCachedUrl(env);
820
700
  completedRef.current = false;
821
701
  currentRunId.current = ++runIdRef.current;
822
- const runId = currentRunId.current;
823
- fetchFreshLink(runId, env);
702
+ await generateLinkAndReload(env, currentRunId.current);
824
703
  } catch (e) {
825
704
  console.error(e);
826
705
  setConnState("error");
@@ -831,10 +710,10 @@ function PayPalConnectionPage() {
831
710
  };
832
711
  const handleEnvChange = async (e) => {
833
712
  const next = e.target.value;
713
+ if (next === env || onboardingInProgress) return;
834
714
  completedRef.current = false;
835
- setPopupBlocked(false);
836
715
  clearCachedUrl();
837
- setEnv(next);
716
+ setConnState("loading");
838
717
  try {
839
718
  await fetch(ENVIRONMENT_ENDPOINT, {
840
719
  method: "POST",
@@ -844,6 +723,7 @@ function PayPalConnectionPage() {
844
723
  });
845
724
  } catch {
846
725
  }
726
+ setEnv(next);
847
727
  };
848
728
  return /* @__PURE__ */ jsxs("div", { className: "p-6", children: [
849
729
  /* @__PURE__ */ jsxs("div", { className: "flex flex-col gap-6", children: [
@@ -903,7 +783,6 @@ function PayPalConnectionPage() {
903
783
  "a",
904
784
  {
905
785
  ref: (node) => {
906
- paypalButtonRef.current = node;
907
786
  ppBtnMeasureRef.current = node;
908
787
  },
909
788
  id: "paypal-button",
@@ -911,17 +790,19 @@ function PayPalConnectionPage() {
911
790
  "data-paypal-button": "true",
912
791
  href: finalUrl || "#",
913
792
  "data-paypal-onboard-complete": "onboardingCallback",
914
- onClick: handleConnectClick,
793
+ "aria-disabled": onboardingInProgress || !partnerReady,
915
794
  className: "transition-fg relative inline-flex w-fit items-center justify-center overflow-hidden rounded-md outline-none no-underline 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",
916
795
  style: {
917
- cursor: onboardingInProgress ? "not-allowed" : "pointer",
918
- opacity: onboardingInProgress ? 0.6 : 1,
919
- pointerEvents: onboardingInProgress ? "none" : "auto"
796
+ cursor: onboardingInProgress || !partnerReady ? "not-allowed" : "pointer",
797
+ opacity: onboardingInProgress || !partnerReady ? 0.6 : 1,
798
+ // Keep the anchor mounted (partner.js must find it to bind)
799
+ // but un-clickable until partner.js has taken over the
800
+ // click — so it can never open a tab via the native href.
801
+ pointerEvents: onboardingInProgress || !partnerReady ? "none" : "auto"
920
802
  },
921
- children: "Connect to PayPal"
803
+ children: partnerReady || onboardingInProgress ? "Connect to PayPal" : "Preparing PayPal…"
922
804
  }
923
805
  ),
924
- popupBlocked && /* @__PURE__ */ jsx("div", { className: "mt-3 text-left text-xs bg-amber-50 text-amber-700 p-3 border border-amber-200 rounded", children: "Your browser blocked the PayPal popup. Please allow popups for this site, then click “Connect to PayPal” again." }),
925
806
  /* @__PURE__ */ jsx(
926
807
  "div",
927
808
  {
@@ -1077,9 +958,6 @@ function PayPalConnectionPage() {
1077
958
  ` })
1078
959
  ] });
1079
960
  }
1080
- function PayPalGooglePayPage() {
1081
- return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
1082
- }
1083
961
  function PayPalPayLaterMessagingPage() {
1084
962
  return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
1085
963
  }
@@ -1301,22 +1179,22 @@ const routeModule = {
1301
1179
  Component: AdditionalSettingsTab,
1302
1180
  path: "/settings/paypal/additional-settings"
1303
1181
  },
1304
- {
1305
- Component: PayPalApplePayPage,
1306
- path: "/settings/paypal/apple-pay"
1307
- },
1308
1182
  {
1309
1183
  Component: AdvancedCardPaymentsTab,
1310
1184
  path: "/settings/paypal/advanced-card-payments"
1311
1185
  },
1312
1186
  {
1313
- Component: PayPalConnectionPage,
1314
- path: "/settings/paypal/connection"
1187
+ Component: PayPalApplePayPage,
1188
+ path: "/settings/paypal/apple-pay"
1315
1189
  },
1316
1190
  {
1317
1191
  Component: PayPalGooglePayPage,
1318
1192
  path: "/settings/paypal/google-pay"
1319
1193
  },
1194
+ {
1195
+ Component: PayPalConnectionPage,
1196
+ path: "/settings/paypal/connection"
1197
+ },
1320
1198
  {
1321
1199
  Component: PayPalPayLaterMessagingPage,
1322
1200
  path: "/settings/paypal/pay-later-messaging"
@@ -1 +1 @@
1
- {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../../../../../../src/admin/routes/settings/paypal/connection/page.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,MAAM,2CAEjB,CAAA;AAQF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,CAAC,EAAE;YACP,IAAI,CAAC,EAAE;gBACL,MAAM,CAAC,EAAE;oBACP,WAAW,CAAC,EAAE;wBAAE,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;wBAAC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;qBAAE,CAAA;oBAC3D,WAAW,CAAC,EAAE;wBAAE,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;wBAAC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;qBAAE,CAAA;oBAC3D,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;iBACpB,CAAA;aACF,CAAA;SACF,CAAA;QACD,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;KAClE;CACF;AAmID,MAAM,CAAC,OAAO,UAAU,oBAAoB,4CA02B3C"}
1
+ {"version":3,"file":"page.d.ts","sourceRoot":"","sources":["../../../../../../../../src/admin/routes/settings/paypal/connection/page.tsx"],"names":[],"mappings":"AAWA,eAAO,MAAM,MAAM,2CAEjB,CAAA;AAQF,OAAO,CAAC,MAAM,CAAC;IACb,UAAU,MAAM;QACd,MAAM,CAAC,EAAE;YACP,IAAI,CAAC,EAAE;gBACL,MAAM,CAAC,EAAE;oBACP,WAAW,CAAC,EAAE;wBAAE,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;wBAAC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;qBAAE,CAAA;oBAC3D,WAAW,CAAC,EAAE;wBAAE,IAAI,CAAC,EAAE,MAAM,IAAI,CAAC;wBAAC,SAAS,CAAC,EAAE,MAAM,IAAI,CAAA;qBAAE,CAAA;oBAC3D,MAAM,CAAC,EAAE,MAAM,IAAI,CAAA;iBACpB,CAAA;aACF,CAAA;SACF,CAAA;QACD,kBAAkB,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,IAAI,CAAA;KAClE;CACF;AA0ED,MAAM,CAAC,OAAO,UAAU,oBAAoB,4CAgvB3C"}