@easypayment/medusa-payment-paypal 0.9.22 → 0.9.24

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 (40) hide show
  1. package/.medusa/server/src/admin/index.js +262 -92
  2. package/.medusa/server/src/admin/index.mjs +262 -92
  3. package/.medusa/server/src/admin/routes/settings/paypal/connection/page.d.ts.map +1 -1
  4. package/.medusa/server/src/admin/routes/settings/paypal/connection/page.js +304 -146
  5. package/.medusa/server/src/admin/routes/settings/paypal/connection/page.js.map +1 -1
  6. package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.d.ts.map +1 -1
  7. package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.js +6 -8
  8. package/.medusa/server/src/api/admin/payment-collections/[id]/payment-sessions/route.js.map +1 -1
  9. package/.medusa/server/src/api/admin/paypal/environment/route.d.ts.map +1 -1
  10. package/.medusa/server/src/api/admin/paypal/environment/route.js +11 -3
  11. package/.medusa/server/src/api/admin/paypal/environment/route.js.map +1 -1
  12. package/.medusa/server/src/api/admin/paypal/onboarding-status/route.d.ts.map +1 -1
  13. package/.medusa/server/src/api/admin/paypal/onboarding-status/route.js +4 -1
  14. package/.medusa/server/src/api/admin/paypal/onboarding-status/route.js.map +1 -1
  15. package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.d.ts.map +1 -1
  16. package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.js +6 -8
  17. package/.medusa/server/src/api/store/payment-collections/[id]/payment-sessions/route.js.map +1 -1
  18. package/.medusa/server/src/api/store/paypal/capture-order/route.d.ts.map +1 -1
  19. package/.medusa/server/src/api/store/paypal/capture-order/route.js +11 -0
  20. package/.medusa/server/src/api/store/paypal/capture-order/route.js.map +1 -1
  21. package/.medusa/server/src/api/store/paypal-complete/route.d.ts.map +1 -1
  22. package/.medusa/server/src/api/store/paypal-complete/route.js +2 -4
  23. package/.medusa/server/src/api/store/paypal-complete/route.js.map +1 -1
  24. package/.medusa/server/src/modules/paypal/payment-provider/card-service.d.ts.map +1 -1
  25. package/.medusa/server/src/modules/paypal/payment-provider/card-service.js +55 -34
  26. package/.medusa/server/src/modules/paypal/payment-provider/card-service.js.map +1 -1
  27. package/.medusa/server/src/modules/paypal/utils/core-workflow.d.ts +32 -0
  28. package/.medusa/server/src/modules/paypal/utils/core-workflow.d.ts.map +1 -0
  29. package/.medusa/server/src/modules/paypal/utils/core-workflow.js +40 -0
  30. package/.medusa/server/src/modules/paypal/utils/core-workflow.js.map +1 -0
  31. package/package.json +1 -1
  32. package/src/admin/routes/settings/paypal/connection/page.tsx +330 -161
  33. package/src/api/admin/payment-collections/[id]/payment-sessions/route.ts +6 -8
  34. package/src/api/admin/paypal/environment/route.ts +10 -3
  35. package/src/api/admin/paypal/onboarding-status/route.ts +4 -1
  36. package/src/api/store/payment-collections/[id]/payment-sessions/route.ts +6 -8
  37. package/src/api/store/paypal/capture-order/route.ts +15 -0
  38. package/src/api/store/paypal-complete/route.ts +6 -4
  39. package/src/modules/paypal/payment-provider/card-service.ts +72 -38
  40. package/src/modules/paypal/utils/core-workflow.ts +46 -0
@@ -223,6 +223,9 @@ function AdditionalSettingsTab() {
223
223
  )
224
224
  ] }) });
225
225
  }
226
+ function PayPalApplePayPage() {
227
+ return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
228
+ }
226
229
  const DEFAULT_FORM = {
227
230
  enabled: true,
228
231
  title: "Credit or Debit Card",
@@ -307,12 +310,6 @@ function AdvancedCardPaymentsTab() {
307
310
  )
308
311
  ] }) });
309
312
  }
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
- }
316
313
  const config = defineRouteConfig({
317
314
  label: "PayPal Connection"
318
315
  });
@@ -362,12 +359,62 @@ function clearCachedUrl(env) {
362
359
  } catch {
363
360
  }
364
361
  }
362
+ function isPayPalOrigin(origin) {
363
+ try {
364
+ const host = new URL(origin).hostname.toLowerCase();
365
+ return host === "www.paypal.com" || host === "www.sandbox.paypal.com" || host.endsWith(".paypal.com") || host.endsWith(".paypalobjects.com");
366
+ } catch {
367
+ return false;
368
+ }
369
+ }
370
+ function extractAuth(data) {
371
+ if (!data) return {};
372
+ if (typeof data === "object") {
373
+ const obj = data;
374
+ const authCode = obj.authCode ?? obj.auth_code ?? obj.authcode ?? obj.code;
375
+ const sharedId = obj.sharedId ?? obj.shared_id ?? obj.sharedid;
376
+ if (authCode && sharedId) {
377
+ return { authCode: String(authCode), sharedId: String(sharedId) };
378
+ }
379
+ for (const key of ["data", "payload", "message", "detail", "body", "params"]) {
380
+ if (obj[key] && typeof obj[key] === "object") {
381
+ const inner = extractAuth(obj[key]);
382
+ if (inner.authCode && inner.sharedId) return inner;
383
+ }
384
+ if (typeof obj[key] === "string") {
385
+ const inner = extractAuth(obj[key]);
386
+ if (inner.authCode && inner.sharedId) return inner;
387
+ }
388
+ }
389
+ return {};
390
+ }
391
+ if (typeof data === "string") {
392
+ const s = data.trim();
393
+ if (!s) return {};
394
+ if (s.startsWith("{") || s.startsWith("[")) {
395
+ try {
396
+ return extractAuth(JSON.parse(s));
397
+ } catch {
398
+ }
399
+ }
400
+ if (/auth_?code/i.test(s) && /shared_?id/i.test(s)) {
401
+ try {
402
+ const sp = new URLSearchParams(s.replace(/^[?#]/, ""));
403
+ const authCode = sp.get("authCode") || sp.get("auth_code") || void 0;
404
+ const sharedId = sp.get("sharedId") || sp.get("shared_id") || void 0;
405
+ if (authCode && sharedId) return { authCode, sharedId };
406
+ } catch {
407
+ }
408
+ }
409
+ }
410
+ return {};
411
+ }
365
412
  function PayPalConnectionPage() {
366
413
  const [env, setEnv] = useState("live");
367
414
  const [envReady, setEnvReady] = useState(false);
368
415
  const [connState, setConnState] = useState("loading");
369
- const [partnerReady, setPartnerReady] = useState(false);
370
416
  const [error, setError] = useState(null);
417
+ const [popupBlocked, setPopupBlocked] = useState(false);
371
418
  const [finalUrl, setFinalUrl] = useState("");
372
419
  const [showManual, setShowManual] = useState(false);
373
420
  const [clientId, setClientId] = useState("");
@@ -375,11 +422,20 @@ function PayPalConnectionPage() {
375
422
  const [statusInfo, setStatusInfo] = useState(null);
376
423
  const [onboardingInProgress, setOnboardingInProgress] = useState(false);
377
424
  const initLoaderRef = useRef(null);
425
+ const paypalButtonRef = useRef(null);
378
426
  const errorLogRef = useRef(null);
379
427
  const runIdRef = useRef(0);
380
428
  const currentRunId = useRef(0);
381
429
  const envRef = useRef(env);
382
430
  envRef.current = env;
431
+ const finalUrlRef = useRef(finalUrl);
432
+ finalUrlRef.current = finalUrl;
433
+ const connStateRef = useRef(connState);
434
+ connStateRef.current = connState;
435
+ const inProgressRef = useRef(onboardingInProgress);
436
+ inProgressRef.current = onboardingInProgress;
437
+ const popupRef = useRef(null);
438
+ const pollRef = useRef(null);
383
439
  const completedRef = useRef(false);
384
440
  const ppBtnMeasureRef = useRef(null);
385
441
  const [ppBtnWidth, setPpBtnWidth] = useState(null);
@@ -390,13 +446,139 @@ function PayPalConnectionPage() {
390
446
  setConnState("error");
391
447
  setError(msg);
392
448
  }, []);
449
+ const stopPoll = useCallback(() => {
450
+ if (pollRef.current) {
451
+ clearInterval(pollRef.current);
452
+ pollRef.current = null;
453
+ }
454
+ }, []);
455
+ const openOnboardingPopup = useCallback((url) => {
456
+ const w = 450;
457
+ const h = 600;
458
+ const baseLeft = typeof window.screenX === "number" ? window.screenX : window.screenLeft || 0;
459
+ const baseTop = typeof window.screenY === "number" ? window.screenY : window.screenTop || 0;
460
+ const outerW = window.outerWidth || document.documentElement.clientWidth || 1024;
461
+ const outerH = window.outerHeight || document.documentElement.clientHeight || 768;
462
+ const left = Math.round(baseLeft + Math.max(0, (outerW - w) / 2));
463
+ const top = Math.round(baseTop + Math.max(0, (outerH - h) / 2));
464
+ const features = `popup=yes,width=${w},height=${h},left=${left},top=${top},scrollbars=yes,resizable=yes`;
465
+ let popup = null;
466
+ try {
467
+ popup = window.open(url, POPUP_NAME, features);
468
+ } catch {
469
+ popup = null;
470
+ }
471
+ if (popup) {
472
+ popupRef.current = popup;
473
+ try {
474
+ popup.focus();
475
+ } catch {
476
+ }
477
+ }
478
+ return popup;
479
+ }, []);
480
+ const completeOnboarding = useCallback(
481
+ async (authCode, sharedId) => {
482
+ var _a, _b, _c, _d, _e, _f, _g, _h;
483
+ if (!authCode || !sharedId) return;
484
+ if (completedRef.current) return;
485
+ completedRef.current = true;
486
+ stopPoll();
487
+ try {
488
+ window.onbeforeunload = null;
489
+ } catch {
490
+ }
491
+ const activeEnv = envRef.current === "sandbox" ? "sandbox" : "live";
492
+ setOnboardingInProgress(true);
493
+ setConnState("loading");
494
+ setError(null);
495
+ setPopupBlocked(false);
496
+ try {
497
+ const res = await fetch(ONBOARDING_COMPLETE_ENDPOINT, {
498
+ method: "POST",
499
+ headers: { "content-type": "application/json" },
500
+ credentials: "include",
501
+ body: JSON.stringify({ authCode, sharedId, env: activeEnv })
502
+ });
503
+ if (!res.ok) {
504
+ const txt = await res.text().catch(() => "");
505
+ throw new Error(txt || `Onboarding exchange failed (${res.status})`);
506
+ }
507
+ try {
508
+ (_a = popupRef.current) == null ? void 0 : _a.close();
509
+ } catch {
510
+ }
511
+ try {
512
+ 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;
513
+ if (typeof close1 === "function") close1();
514
+ } catch {
515
+ }
516
+ try {
517
+ 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;
518
+ if (typeof close2 === "function") close2();
519
+ } catch {
520
+ }
521
+ clearCachedUrl(activeEnv);
522
+ try {
523
+ const statusRes = await fetch(`${STATUS_ENDPOINT}?environment=${activeEnv}`, {
524
+ method: "GET",
525
+ credentials: "include"
526
+ });
527
+ const refreshedStatus = await statusRes.json().catch(() => ({}));
528
+ setStatusInfo(refreshedStatus || null);
529
+ } catch {
530
+ }
531
+ setConnState("connected");
532
+ setShowManual(false);
533
+ } catch (e) {
534
+ completedRef.current = false;
535
+ console.error(e);
536
+ setConnState("error");
537
+ setError((e == null ? void 0 : e.message) || "Exchange failed while saving credentials.");
538
+ } finally {
539
+ setOnboardingInProgress(false);
540
+ }
541
+ },
542
+ [stopPoll]
543
+ );
544
+ const startStatusPoll = useCallback(() => {
545
+ stopPoll();
546
+ let ticks = 0;
547
+ pollRef.current = setInterval(async () => {
548
+ var _a;
549
+ ticks += 1;
550
+ if (completedRef.current || ticks > 150) {
551
+ stopPoll();
552
+ return;
553
+ }
554
+ try {
555
+ const r = await fetch(`${STATUS_ENDPOINT}?environment=${envRef.current}`, {
556
+ method: "GET",
557
+ credentials: "include"
558
+ });
559
+ const st = await r.json().catch(() => ({}));
560
+ if ((st == null ? void 0 : st.status) === "connected" && (st == null ? void 0 : st.seller_client_id_present) === true) {
561
+ completedRef.current = true;
562
+ stopPoll();
563
+ try {
564
+ (_a = popupRef.current) == null ? void 0 : _a.close();
565
+ } catch {
566
+ }
567
+ clearCachedUrl(envRef.current);
568
+ setStatusInfo(st);
569
+ setConnState("connected");
570
+ setShowManual(false);
571
+ setOnboardingInProgress(false);
572
+ }
573
+ } catch {
574
+ }
575
+ }, 2e3);
576
+ }, [stopPoll]);
393
577
  const generateLinkAndReload = useCallback(
394
578
  async (targetEnv, runId) => {
395
579
  if (initLoaderRef.current) {
396
580
  const loaderText = initLoaderRef.current.querySelector("#loader-text");
397
- if (loaderText) {
398
- loaderText.textContent = "Generating onboarding session...";
399
- }
581
+ if (loaderText) loaderText.textContent = "Generating onboarding session...";
400
582
  }
401
583
  try {
402
584
  const res = await fetch(SERVICE_URL, {
@@ -450,6 +632,7 @@ function PayPalConnectionPage() {
450
632
  const run = async () => {
451
633
  setConnState("loading");
452
634
  setError(null);
635
+ setPopupBlocked(false);
453
636
  setFinalUrl("");
454
637
  try {
455
638
  const r = await fetch(`${STATUS_ENDPOINT}?environment=${env}`, {
@@ -488,13 +671,6 @@ function PayPalConnectionPage() {
488
671
  const scriptUrl = PARTNER_JS_URLS[env];
489
672
  let cancelled = false;
490
673
  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
- };
498
674
  const initPartner = (attempt = 0) => {
499
675
  var _a2, _b2;
500
676
  if (cancelled) return;
@@ -506,7 +682,6 @@ function PayPalConnectionPage() {
506
682
  } catch (e) {
507
683
  console.error("[paypal] partner.js init failed:", e);
508
684
  }
509
- markReady();
510
685
  return;
511
686
  }
512
687
  if (typeof (signup == null ? void 0 : signup.render) === "function") {
@@ -515,7 +690,6 @@ function PayPalConnectionPage() {
515
690
  } catch (e) {
516
691
  console.error("[paypal] partner.js render failed:", e);
517
692
  }
518
- markReady();
519
693
  return;
520
694
  }
521
695
  if (attempt < 40) {
@@ -526,7 +700,6 @@ function PayPalConnectionPage() {
526
700
  document.dispatchEvent(new Event("DOMContentLoaded"));
527
701
  } catch {
528
702
  }
529
- markReady();
530
703
  };
531
704
  const existingScript = document.getElementById("paypal-partner-js");
532
705
  if (existingScript) {
@@ -543,74 +716,39 @@ function PayPalConnectionPage() {
543
716
  ppScript.src = scriptUrl;
544
717
  ppScript.async = true;
545
718
  ppScript.onload = () => initPartner();
546
- ppScript.onerror = () => markReady();
547
719
  document.body.appendChild(ppScript);
548
720
  return () => {
549
721
  cancelled = true;
550
- clearTimeout(readyFallback);
551
- if (pollTimer) {
552
- clearTimeout(pollTimer);
553
- }
554
- if (ppScript.parentNode) {
555
- ppScript.parentNode.removeChild(ppScript);
556
- }
722
+ if (pollTimer) clearTimeout(pollTimer);
723
+ if (ppScript.parentNode) ppScript.parentNode.removeChild(ppScript);
557
724
  };
558
725
  }, [connState, finalUrl, env]);
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})`);
582
- }
726
+ useEffect(() => {
727
+ const onMessage = (ev) => {
728
+ let serialized = "";
583
729
  try {
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();
730
+ serialized = typeof ev.data === "string" ? ev.data : JSON.stringify(ev.data);
586
731
  } catch {
732
+ serialized = String(ev.data);
587
733
  }
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 {
734
+ const looksRelevant = isPayPalOrigin(ev.origin) || /auth_?code|shared_?id|onboard|merchantId/i.test(serialized || "");
735
+ if (looksRelevant) {
736
+ console.info(
737
+ "[PayPal onboarding] message from",
738
+ ev.origin,
739
+ "·",
740
+ (serialized || "").slice(0, 500)
741
+ );
592
742
  }
593
- clearCachedUrl(activeEnv);
594
- try {
595
- const statusRes = await fetch(`${STATUS_ENDPOINT}?environment=${activeEnv}`, {
596
- method: "GET",
597
- credentials: "include"
598
- });
599
- const refreshedStatus = await statusRes.json().catch(() => ({}));
600
- setStatusInfo(refreshedStatus || null);
601
- } catch {
743
+ if (!isPayPalOrigin(ev.origin)) return;
744
+ const { authCode, sharedId } = extractAuth(ev.data);
745
+ if (authCode && sharedId) {
746
+ completeOnboarding(authCode, sharedId);
602
747
  }
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
- }, []);
748
+ };
749
+ window.addEventListener("message", onMessage);
750
+ return () => window.removeEventListener("message", onMessage);
751
+ }, [completeOnboarding]);
614
752
  useLayoutEffect(() => {
615
753
  window.onboardingCallback = (authCode, sharedId) => {
616
754
  completeOnboarding(authCode, sharedId);
@@ -619,6 +757,32 @@ function PayPalConnectionPage() {
619
757
  window.onboardingCallback = void 0;
620
758
  };
621
759
  }, [completeOnboarding]);
760
+ useEffect(() => {
761
+ const onCaptureClick = (e) => {
762
+ const btn = paypalButtonRef.current;
763
+ if (!btn) return;
764
+ const target = e.target;
765
+ if (!target || !btn.contains(target)) return;
766
+ e.preventDefault();
767
+ e.stopImmediatePropagation();
768
+ if (connStateRef.current !== "ready" || !finalUrlRef.current || inProgressRef.current) {
769
+ return;
770
+ }
771
+ completedRef.current = false;
772
+ const popup = openOnboardingPopup(finalUrlRef.current);
773
+ if (!popup) {
774
+ setPopupBlocked(true);
775
+ return;
776
+ }
777
+ setPopupBlocked(false);
778
+ startStatusPoll();
779
+ };
780
+ document.addEventListener("click", onCaptureClick, true);
781
+ return () => document.removeEventListener("click", onCaptureClick, true);
782
+ }, [openOnboardingPopup, startStatusPoll]);
783
+ useEffect(() => {
784
+ return () => stopPoll();
785
+ }, [stopPoll]);
622
786
  useLayoutEffect(() => {
623
787
  const el = ppBtnMeasureRef.current;
624
788
  if (!el) return;
@@ -639,6 +803,9 @@ function PayPalConnectionPage() {
639
803
  else window.removeEventListener("resize", update);
640
804
  };
641
805
  }, [connState, env, finalUrl]);
806
+ const handleConnectClick = (e) => {
807
+ e.preventDefault();
808
+ };
642
809
  const handleSaveManual = async () => {
643
810
  if (!canSaveManual || onboardingInProgress) return;
644
811
  setOnboardingInProgress(true);
@@ -713,6 +880,7 @@ function PayPalConnectionPage() {
713
880
  if (next === env || onboardingInProgress) return;
714
881
  completedRef.current = false;
715
882
  clearCachedUrl();
883
+ setPopupBlocked(false);
716
884
  setConnState("loading");
717
885
  try {
718
886
  await fetch(ENVIRONMENT_ENDPOINT, {
@@ -783,6 +951,7 @@ function PayPalConnectionPage() {
783
951
  "a",
784
952
  {
785
953
  ref: (node) => {
954
+ paypalButtonRef.current = node;
786
955
  ppBtnMeasureRef.current = node;
787
956
  },
788
957
  id: "paypal-button",
@@ -790,19 +959,17 @@ function PayPalConnectionPage() {
790
959
  "data-paypal-button": "true",
791
960
  href: finalUrl || "#",
792
961
  "data-paypal-onboard-complete": "onboardingCallback",
793
- "aria-disabled": onboardingInProgress || !partnerReady,
962
+ onClick: handleConnectClick,
794
963
  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",
795
964
  style: {
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"
965
+ cursor: onboardingInProgress ? "not-allowed" : "pointer",
966
+ opacity: onboardingInProgress ? 0.6 : 1,
967
+ pointerEvents: onboardingInProgress ? "none" : "auto"
802
968
  },
803
- children: partnerReady || onboardingInProgress ? "Connect to PayPal" : "Preparing PayPal…"
969
+ children: "Connect to PayPal"
804
970
  }
805
971
  ),
972
+ 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." }),
806
973
  /* @__PURE__ */ jsx(
807
974
  "div",
808
975
  {
@@ -958,6 +1125,9 @@ function PayPalConnectionPage() {
958
1125
  ` })
959
1126
  ] });
960
1127
  }
1128
+ function PayPalGooglePayPage() {
1129
+ return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
1130
+ }
961
1131
  function PayPalPayLaterMessagingPage() {
962
1132
  return /* @__PURE__ */ jsx(Navigate, { to: "/settings/paypal/connection", replace: true });
963
1133
  }
@@ -1179,22 +1349,22 @@ const routeModule = {
1179
1349
  Component: AdditionalSettingsTab,
1180
1350
  path: "/settings/paypal/additional-settings"
1181
1351
  },
1182
- {
1183
- Component: AdvancedCardPaymentsTab,
1184
- path: "/settings/paypal/advanced-card-payments"
1185
- },
1186
1352
  {
1187
1353
  Component: PayPalApplePayPage,
1188
1354
  path: "/settings/paypal/apple-pay"
1189
1355
  },
1190
1356
  {
1191
- Component: PayPalGooglePayPage,
1192
- path: "/settings/paypal/google-pay"
1357
+ Component: AdvancedCardPaymentsTab,
1358
+ path: "/settings/paypal/advanced-card-payments"
1193
1359
  },
1194
1360
  {
1195
1361
  Component: PayPalConnectionPage,
1196
1362
  path: "/settings/paypal/connection"
1197
1363
  },
1364
+ {
1365
+ Component: PayPalGooglePayPage,
1366
+ path: "/settings/paypal/google-pay"
1367
+ },
1198
1368
  {
1199
1369
  Component: PayPalPayLaterMessagingPage,
1200
1370
  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;AA0ED,MAAM,CAAC,OAAO,UAAU,oBAAoB,4CAgvB3C"}
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;AAkID,MAAM,CAAC,OAAO,UAAU,oBAAoB,4CAi2B3C"}