@flopay/react 0.5.12 → 0.5.14

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/dist/index.mjs CHANGED
@@ -100,7 +100,7 @@ function FloPayProvider({
100
100
  }
101
101
 
102
102
  // src/flopay-checkout.tsx
103
- import React6, { useCallback as useCallback2, useEffect as useEffect4, useMemo as useMemo3, useRef as useRef3, useState as useState3 } from "react";
103
+ import React7, { useCallback as useCallback3, useEffect as useEffect5, useMemo as useMemo3, useRef as useRef3, useState as useState4 } from "react";
104
104
  import { PaymentAPI as PaymentAPI2 } from "@flopay/js";
105
105
  import { SDK_VERSION, FloPayError as FloPayError4, resolveBillingApiUrl as resolveBillingApiUrl3, buildCheckoutDisplayData, resolveButtonsLayoutTheme as resolveButtonsLayoutTheme2 } from "@flopay/shared";
106
106
 
@@ -248,7 +248,7 @@ import {
248
248
  isAVSFieldVisible,
249
249
  getStateFromPostalCode
250
250
  } from "@flopay/shared";
251
- import { forwardRef, useCallback, useContext as useContext3, useEffect as useEffect3, useImperativeHandle, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
251
+ import { forwardRef, useCallback as useCallback2, useContext as useContext3, useEffect as useEffect4, useImperativeHandle, useMemo as useMemo2, useRef as useRef2, useState as useState3 } from "react";
252
252
 
253
253
  // src/hooks.ts
254
254
  import { useContext as useContext2 } from "react";
@@ -621,9 +621,119 @@ function wasSessionRecentlyCompleted(sessionId) {
621
621
  }
622
622
  }
623
623
 
624
+ // src/in-app-browser-notice.tsx
625
+ import { useCallback, useEffect as useEffect3, useState as useState2 } from "react";
626
+
627
+ // src/in-app-browser.ts
628
+ function isInAppBrowser(userAgent) {
629
+ const ua = userAgent ?? (typeof navigator !== "undefined" ? navigator.userAgent : "");
630
+ if (!ua) return false;
631
+ if (/FBAN|FBAV|FB_IAB|FBIOS|Instagram|musical_ly|BytedanceWebview|TikTok/i.test(ua)) {
632
+ return true;
633
+ }
634
+ if (/Twitter|Snapchat|Pinterest|LinkedInApp|Line\/|MicroMessenger|GSA\//i.test(ua)) {
635
+ return true;
636
+ }
637
+ if (/Android.*;\s?wv\)/.test(ua)) return true;
638
+ if (/(iPhone|iPad|iPod).*AppleWebKit(?!.*Safari)/.test(ua)) return true;
639
+ return false;
640
+ }
641
+
642
+ // src/in-app-browser-notice.tsx
643
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
644
+ var DEFAULT_MESSAGE = "PayPal and some digital wallets aren't supported in this browser. Open this page in your device's browser to use them.";
645
+ function InAppBrowserNotice({
646
+ message,
647
+ openButtonLabel,
648
+ copiedButtonLabel,
649
+ containerStyle,
650
+ buttonStyle,
651
+ onOpenInBrowser
652
+ }) {
653
+ const [copied, setCopied] = useState2(false);
654
+ const [inAppBrowser, setInAppBrowser] = useState2(false);
655
+ useEffect3(() => {
656
+ setInAppBrowser(isInAppBrowser());
657
+ }, []);
658
+ const defaultOpenLabel = inAppBrowser ? "Copy link" : "Open in browser";
659
+ const defaultCopiedLabel = inAppBrowser ? "Link copied \u2014 open Safari/Chrome and paste" : "Link copied \u2014 paste in your browser";
660
+ const effectiveOpenLabel = openButtonLabel ?? defaultOpenLabel;
661
+ const effectiveCopiedLabel = copiedButtonLabel ?? defaultCopiedLabel;
662
+ const handleClick = useCallback(async () => {
663
+ if (typeof window === "undefined") return;
664
+ const url = window.location.href;
665
+ let opened = false;
666
+ if (!inAppBrowser) {
667
+ try {
668
+ const win = window.open(url, "_blank");
669
+ opened = !!win;
670
+ } catch {
671
+ opened = false;
672
+ }
673
+ }
674
+ let didCopy = false;
675
+ if (!opened) {
676
+ if (typeof navigator !== "undefined" && typeof navigator.clipboard?.writeText === "function") {
677
+ try {
678
+ await navigator.clipboard.writeText(url);
679
+ didCopy = true;
680
+ setCopied(true);
681
+ } catch {
682
+ didCopy = false;
683
+ }
684
+ }
685
+ }
686
+ onOpenInBrowser?.({ opened, copied: didCopy });
687
+ }, [inAppBrowser, onOpenInBrowser]);
688
+ return /* @__PURE__ */ jsxs3(
689
+ "div",
690
+ {
691
+ role: "status",
692
+ "data-testid": "flopay-in-app-browser-notice",
693
+ style: {
694
+ marginTop: "0.75rem",
695
+ padding: "0.75rem 0.875rem",
696
+ background: "#FFFBEB",
697
+ border: "1px solid #FDE68A",
698
+ borderRadius: 8,
699
+ color: "#92400E",
700
+ fontSize: "0.85rem",
701
+ lineHeight: 1.4,
702
+ display: "flex",
703
+ flexDirection: "column",
704
+ gap: "0.5rem",
705
+ ...containerStyle
706
+ },
707
+ children: [
708
+ /* @__PURE__ */ jsx5("span", { children: message ?? DEFAULT_MESSAGE }),
709
+ /* @__PURE__ */ jsx5(
710
+ "button",
711
+ {
712
+ type: "button",
713
+ onClick: handleClick,
714
+ style: {
715
+ alignSelf: "flex-start",
716
+ padding: "0.4rem 0.75rem",
717
+ background: "transparent",
718
+ border: "1px solid #92400E",
719
+ borderRadius: 6,
720
+ color: "#92400E",
721
+ fontSize: "0.85rem",
722
+ fontWeight: 600,
723
+ cursor: "pointer",
724
+ ...buttonStyle
725
+ },
726
+ children: copied ? effectiveCopiedLabel : effectiveOpenLabel
727
+ }
728
+ )
729
+ ]
730
+ }
731
+ );
732
+ }
733
+
624
734
  // src/split-card-form.tsx
625
735
  import { FloPayError as FloPayError2 } from "@flopay/shared";
626
- import { Fragment as Fragment2, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
736
+ import { Fragment as Fragment2, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
627
737
  var WALLET_RESUME_KEY = "flopay_wallet_resume";
628
738
  var FLOPAY_KEYFRAMES = `
629
739
  @keyframes flopay-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
@@ -665,7 +775,7 @@ function normalizeBeforeButtonClickError(method, err) {
665
775
  );
666
776
  }
667
777
  function FloPayKeyframes() {
668
- return /* @__PURE__ */ jsx5("style", { children: FLOPAY_KEYFRAMES });
778
+ return /* @__PURE__ */ jsx6("style", { children: FLOPAY_KEYFRAMES });
669
779
  }
670
780
  function toCssSize(value) {
671
781
  if (typeof value === "number") return `${value}px`;
@@ -685,9 +795,9 @@ function ExpressCheckoutReadySwap({
685
795
  placeholderTestId,
686
796
  children
687
797
  }) {
688
- if (state === "unavailable") return null;
689
- return /* @__PURE__ */ jsxs3("div", { style: { position: "relative", minHeight: 44 }, children: [
690
- /* @__PURE__ */ jsx5(
798
+ if (state === "unavailable" || state === "load_error") return null;
799
+ return /* @__PURE__ */ jsxs4("div", { style: { position: "relative", minHeight: 44 }, children: [
800
+ /* @__PURE__ */ jsx6(
691
801
  "div",
692
802
  {
693
803
  "data-testid": placeholderTestId,
@@ -706,7 +816,7 @@ function ExpressCheckoutReadySwap({
706
816
  }
707
817
  }
708
818
  ),
709
- /* @__PURE__ */ jsx5(
819
+ /* @__PURE__ */ jsx6(
710
820
  "div",
711
821
  {
712
822
  style: {
@@ -723,7 +833,7 @@ function ExpressCheckoutReadySwap({
723
833
  }
724
834
  var SplitCardForm = forwardRef(
725
835
  function SplitCardForm2(props, ref) {
726
- return /* @__PURE__ */ jsx5(SplitCardFormInner, { ...props, innerRef: ref });
836
+ return /* @__PURE__ */ jsx6(SplitCardFormInner, { ...props, innerRef: ref });
727
837
  }
728
838
  );
729
839
  function PayPalButtonInner({
@@ -735,16 +845,24 @@ function PayPalButtonInner({
735
845
  isProcessing = false,
736
846
  onButtonClick,
737
847
  onDecline,
738
- runBeforeButtonClick
848
+ runBeforeButtonClick,
849
+ onLoadStateChange
739
850
  }) {
740
851
  const stripe = useStripeRaw();
741
852
  const elements = useStripeElements();
742
- const [loadState, setLoadState] = useState2("loading");
743
- const [submitting, setSubmitting] = useState2(false);
853
+ const [loadState, setLoadState] = useState3("loading");
854
+ const onLoadStateChangeRef = useRef2(onLoadStateChange);
855
+ useEffect4(() => {
856
+ onLoadStateChangeRef.current = onLoadStateChange;
857
+ }, [onLoadStateChange]);
858
+ useEffect4(() => {
859
+ onLoadStateChangeRef.current?.(loadState);
860
+ }, [loadState]);
861
+ const [submitting, setSubmitting] = useState3(false);
744
862
  const paypalResumeAttempted = useRef2(false);
745
863
  const beforeClickRef = useRef2(null);
746
864
  const baseUrl = billingApiUrl.replace(/\/+$/, "");
747
- useEffect3(() => {
865
+ useEffect4(() => {
748
866
  if (!stripe || paypalResumeAttempted.current) return;
749
867
  const params = new URLSearchParams(window.location.search);
750
868
  const paymentIntentId = params.get("payment_intent");
@@ -791,7 +909,7 @@ function PayPalButtonInner({
791
909
  }
792
910
  })();
793
911
  }, [stripe, onTokenizedBody, onErrorChange, onDecline]);
794
- const handlePayPalClick = useCallback(async (event) => {
912
+ const handlePayPalClick = useCallback2(async (event) => {
795
913
  if (isProcessing || submitting) {
796
914
  event.reject();
797
915
  return;
@@ -809,7 +927,7 @@ function PayPalButtonInner({
809
927
  onButtonClick?.("paypal");
810
928
  event.resolve();
811
929
  }, [isProcessing, onButtonClick, runBeforeButtonClick, submitting]);
812
- const handlePayPalConfirm = useCallback(async (event) => {
930
+ const handlePayPalConfirm = useCallback2(async (event) => {
813
931
  if (!stripe || !elements) return;
814
932
  let prepared = beforeClickRef.current;
815
933
  beforeClickRef.current = null;
@@ -901,12 +1019,12 @@ function PayPalButtonInner({
901
1019
  setSubmitting(false);
902
1020
  }
903
1021
  }, [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange, onDecline, runBeforeButtonClick]);
904
- return /* @__PURE__ */ jsxs3(Fragment2, { children: [
905
- /* @__PURE__ */ jsx5(ExpressCheckoutReadySwap, { state: loadState, placeholderTestId: "flopay-paypal-placeholder", children: /* @__PURE__ */ jsx5(
1022
+ return /* @__PURE__ */ jsxs4(Fragment2, { children: [
1023
+ /* @__PURE__ */ jsx6(ExpressCheckoutReadySwap, { state: loadState, placeholderTestId: "flopay-paypal-placeholder", children: /* @__PURE__ */ jsx6(
906
1024
  ExpressCheckoutElement,
907
1025
  {
908
1026
  onReady: (event) => setLoadState(resolveExpressCheckoutLoadState(event, ["paypal"])),
909
- onLoadError: () => setLoadState("unavailable"),
1027
+ onLoadError: () => setLoadState("load_error"),
910
1028
  onClick: handlePayPalClick,
911
1029
  onConfirm: handlePayPalConfirm,
912
1030
  onCancel: () => {
@@ -927,7 +1045,7 @@ function PayPalButtonInner({
927
1045
  }
928
1046
  }
929
1047
  ) }),
930
- submitting && /* @__PURE__ */ jsx5(ProcessingOverlay, { status: "processing" })
1048
+ submitting && /* @__PURE__ */ jsx6(ProcessingOverlay, { status: "processing" })
931
1049
  ] });
932
1050
  }
933
1051
  function WalletButtonInner({
@@ -940,16 +1058,24 @@ function WalletButtonInner({
940
1058
  onErrorChange,
941
1059
  onButtonClick,
942
1060
  onDecline,
943
- runBeforeButtonClick
1061
+ runBeforeButtonClick,
1062
+ onLoadStateChange
944
1063
  }) {
945
1064
  const stripe = useStripeRaw();
946
1065
  const elements = useStripeElements();
947
- const [loadState, setLoadState] = useState2("loading");
948
- const [submitting, setSubmitting] = useState2(false);
1066
+ const [loadState, setLoadState] = useState3("loading");
1067
+ const onLoadStateChangeRef = useRef2(onLoadStateChange);
1068
+ useEffect4(() => {
1069
+ onLoadStateChangeRef.current = onLoadStateChange;
1070
+ }, [onLoadStateChange]);
1071
+ useEffect4(() => {
1072
+ onLoadStateChangeRef.current?.(loadState);
1073
+ }, [loadState]);
1074
+ const [submitting, setSubmitting] = useState3(false);
949
1075
  const baseUrl = billingApiUrl.replace(/\/+$/, "");
950
1076
  const lastWalletMethodRef = useRef2("card");
951
1077
  const beforeClickRef = useRef2(null);
952
- const handleWalletConfirm = useCallback(
1078
+ const handleWalletConfirm = useCallback2(
953
1079
  async (event) => {
954
1080
  if (!stripe || !elements) return;
955
1081
  const walletType = event.expressPaymentType;
@@ -1038,12 +1164,12 @@ function WalletButtonInner({
1038
1164
  },
1039
1165
  [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange, onDecline, runBeforeButtonClick]
1040
1166
  );
1041
- return /* @__PURE__ */ jsxs3(Fragment2, { children: [
1042
- /* @__PURE__ */ jsx5(ExpressCheckoutReadySwap, { state: loadState, placeholderTestId: "flopay-wallet-placeholder", children: /* @__PURE__ */ jsx5(
1167
+ return /* @__PURE__ */ jsxs4(Fragment2, { children: [
1168
+ /* @__PURE__ */ jsx6(ExpressCheckoutReadySwap, { state: loadState, placeholderTestId: "flopay-wallet-placeholder", children: /* @__PURE__ */ jsx6(
1043
1169
  ExpressCheckoutElement,
1044
1170
  {
1045
1171
  onReady: (event) => setLoadState(resolveExpressCheckoutLoadState(event, ["applePay", "googlePay"])),
1046
- onLoadError: () => setLoadState("unavailable"),
1172
+ onLoadError: () => setLoadState("load_error"),
1047
1173
  onClick: async (event) => {
1048
1174
  lastWalletMethodRef.current = event.expressPaymentType === "apple_pay" ? "apple_pay" : "google_pay";
1049
1175
  const beforeClick = runBeforeButtonClick ? await runBeforeButtonClick(lastWalletMethodRef.current) : { proceed: true };
@@ -1078,7 +1204,7 @@ function WalletButtonInner({
1078
1204
  }
1079
1205
  }
1080
1206
  ) }),
1081
- submitting && /* @__PURE__ */ jsx5(ProcessingOverlay, { status: "processing" })
1207
+ submitting && /* @__PURE__ */ jsx6(ProcessingOverlay, { status: "processing" })
1082
1208
  ] });
1083
1209
  }
1084
1210
  function SplitCardFormInner({
@@ -1137,16 +1263,16 @@ function SplitCardFormInner({
1137
1263
  const elements = useElements();
1138
1264
  const checkout = useContext3(CheckoutContext);
1139
1265
  const contextBillingUrl = useBillingApiUrl();
1140
- const [processing, setProcessing] = useState2(false);
1141
- const [error, setError] = useState2(null);
1142
- const [is3DSActive, setIs3DSActive] = useState2(false);
1143
- const [selectedCountry, setSelectedCountry] = useState2(countryProp ?? "US");
1144
- const [zipCode, setZipCode] = useState2(zipProp ?? "");
1145
- const [addressLine1, setAddressLine1] = useState2(addressLine1Prop ?? "");
1146
- const [addressLine2, setAddressLine2] = useState2(addressLine2Prop ?? "");
1147
- const [city, setCity] = useState2(cityProp ?? "");
1148
- const [stateValue, setStateValue] = useState2(stateProp ?? "");
1149
- const [accountPatch, setAccountPatch] = useState2({});
1266
+ const [processing, setProcessing] = useState3(false);
1267
+ const [error, setError] = useState3(null);
1268
+ const [is3DSActive, setIs3DSActive] = useState3(false);
1269
+ const [selectedCountry, setSelectedCountry] = useState3(countryProp ?? "US");
1270
+ const [zipCode, setZipCode] = useState3(zipProp ?? "");
1271
+ const [addressLine1, setAddressLine1] = useState3(addressLine1Prop ?? "");
1272
+ const [addressLine2, setAddressLine2] = useState3(addressLine2Prop ?? "");
1273
+ const [city, setCity] = useState3(cityProp ?? "");
1274
+ const [stateValue, setStateValue] = useState3(stateProp ?? "");
1275
+ const [accountPatch, setAccountPatch] = useState3({});
1150
1276
  const zipCodeRef = useRef2(zipProp ?? "");
1151
1277
  const selectedCountryRef = useRef2(countryProp ?? "US");
1152
1278
  const addressLine1Ref = useRef2(addressLine1Prop ?? "");
@@ -1155,25 +1281,25 @@ function SplitCardFormInner({
1155
1281
  const stateRef = useRef2(stateProp ?? "");
1156
1282
  const avsConfig = useMemo2(() => resolveAVSConfig(enableAVSProp), [enableAVSProp]);
1157
1283
  const enableAVS = avsConfig !== null;
1158
- const [viewState, setViewState] = useState2(initialCardOpen ? "card" : "buttons");
1284
+ const [viewState, setViewState] = useState3(initialCardOpen ? "card" : "buttons");
1159
1285
  const showCardForm = viewState === "expanding" || viewState === "card";
1160
1286
  const TRANSITION_MS = 280;
1161
- const expandToCard = useCallback(() => {
1287
+ const expandToCard = useCallback2(() => {
1162
1288
  setViewState("expanding");
1163
1289
  setTimeout(() => setViewState("card"), TRANSITION_MS);
1164
1290
  }, []);
1165
- const collapseToButtons = useCallback(() => {
1291
+ const collapseToButtons = useCallback2(() => {
1166
1292
  setViewState("collapsing");
1167
1293
  setTimeout(() => setViewState("buttons"), TRANSITION_MS);
1168
1294
  }, []);
1169
- useEffect3(() => {
1295
+ useEffect4(() => {
1170
1296
  if (layout === "buttons" && initialCardOpen) {
1171
1297
  setViewState("card");
1172
1298
  }
1173
1299
  }, [layout, initialCardOpen]);
1174
- const [fullName, setFullName] = useState2("");
1175
- const [formReady, setFormReady] = useState2(false);
1176
- const [overlayStatus, setOverlayStatus] = useState2(null);
1300
+ const [fullName, setFullName] = useState3("");
1301
+ const [formReady, setFormReady] = useState3(false);
1302
+ const [overlayStatus, setOverlayStatus] = useState3(null);
1177
1303
  const processingRef = useRef2(false);
1178
1304
  const resolvedBillingApiUrl = billingApiUrl || contextBillingUrl;
1179
1305
  const displayError = externalError ?? error;
@@ -1226,28 +1352,39 @@ function SplitCardFormInner({
1226
1352
  captureMethod: "manual",
1227
1353
  setupFutureUsage: "off_session"
1228
1354
  }), [amountInCents, currency]);
1229
- const updateError = useCallback(
1355
+ const updateError = useCallback2(
1230
1356
  (err) => {
1231
1357
  setError(err);
1232
1358
  onErrorChange?.(err);
1233
1359
  },
1234
1360
  [onErrorChange]
1235
1361
  );
1236
- const emitDecline = useCallback(
1362
+ const emitDecline = useCallback2(
1237
1363
  (method, input, overrides) => {
1238
1364
  onDecline?.(buildDeclineEvent(method, input, overrides));
1239
1365
  },
1240
1366
  [onDecline]
1241
1367
  );
1242
1368
  const showWallets = showApplePay || showGooglePay;
1243
- const handleNameChange = useCallback((value) => {
1369
+ const [paypalLoadState, setPaypalLoadState] = useState3("loading");
1370
+ const [walletLoadState, setWalletLoadState] = useState3("loading");
1371
+ const [inAppBrowserDetected, setInAppBrowserDetected] = useState3(false);
1372
+ useEffect4(() => {
1373
+ setInAppBrowserDetected(isInAppBrowser());
1374
+ }, []);
1375
+ const expectedPayPal = showPayPal && !!paypalStripeInstance;
1376
+ const expectedWallets = showWallets && !!stripeInstance;
1377
+ const paypalLoadFailed = expectedPayPal && (paypalLoadState === "load_error" || paypalLoadState === "unavailable");
1378
+ const walletsLoadFailed = expectedWallets && walletLoadState === "load_error";
1379
+ const showInAppBrowserNotice = (expectedPayPal || expectedWallets) && (inAppBrowserDetected || paypalLoadFailed || walletsLoadFailed);
1380
+ const handleNameChange = useCallback2((value) => {
1244
1381
  setFullName(value);
1245
1382
  onFullNameChange?.(value);
1246
1383
  const parts = value.trim().split(/\s+/);
1247
1384
  onFirstNameChange?.(parts[0] ?? "");
1248
1385
  onLastNameChange?.(parts.length > 1 ? parts.slice(1).join(" ") : "");
1249
1386
  }, [onFullNameChange, onFirstNameChange, onLastNameChange]);
1250
- const applyInlineSessionPatch = useCallback(
1387
+ const applyInlineSessionPatch = useCallback2(
1251
1388
  (patch, method) => {
1252
1389
  if (!checkout.applyInlineSessionPatch) {
1253
1390
  return Promise.resolve({ error: null, sessionId });
@@ -1264,7 +1401,7 @@ function SplitCardFormInner({
1264
1401
  },
1265
1402
  [checkout.applyInlineSessionPatch, onError, sessionId, updateError]
1266
1403
  );
1267
- const runBeforeButtonClick = useCallback(async (method) => {
1404
+ const runBeforeButtonClick = useCallback2(async (method) => {
1268
1405
  if (!onBeforeButtonClick) return { proceed: true };
1269
1406
  try {
1270
1407
  const result = await onBeforeButtonClick({
@@ -1300,7 +1437,7 @@ function SplitCardFormInner({
1300
1437
  return { proceed: false };
1301
1438
  }
1302
1439
  }, [applyInlineSessionPatch, checkout.inlineSessionDraft, onBeforeButtonClick, onError, sessionId, updateError]);
1303
- const processPaymentInternal = useCallback(
1440
+ const processPaymentInternal = useCallback2(
1304
1441
  async (tokenizedBody, overrides) => {
1305
1442
  if (processingRef.current) return;
1306
1443
  processingRef.current = true;
@@ -1490,7 +1627,7 @@ function SplitCardFormInner({
1490
1627
  },
1491
1628
  [baseUrl, sessionId, resolvedAccount, fullName, chv, flopay, paypalFlopay, onComplete, onError, updateError, emitDecline]
1492
1629
  );
1493
- const dispatchTokenizedBody = useCallback(
1630
+ const dispatchTokenizedBody = useCallback2(
1494
1631
  (tokenizedBody, overrides) => {
1495
1632
  if (onTokenizedBody) {
1496
1633
  onTokenizedBody(tokenizedBody);
@@ -1527,7 +1664,7 @@ function SplitCardFormInner({
1527
1664
  }
1528
1665
  }
1529
1666
  }), [flopay, dispatchTokenizedBody, onError, updateError, emitDecline]);
1530
- useEffect3(() => {
1667
+ useEffect4(() => {
1531
1668
  if (typeof window === "undefined") return;
1532
1669
  const stored = localStorage.getItem(WALLET_RESUME_KEY);
1533
1670
  if (!stored) return;
@@ -1545,7 +1682,7 @@ function SplitCardFormInner({
1545
1682
  localStorage.removeItem(WALLET_RESUME_KEY);
1546
1683
  }
1547
1684
  }, [sessionId, dispatchTokenizedBody]);
1548
- const handleSubmit = useCallback(
1685
+ const handleSubmit = useCallback2(
1549
1686
  async (e) => {
1550
1687
  e.preventDefault();
1551
1688
  if (!flopay || !elements || isSubmitting || processingRef.current) return;
@@ -1687,7 +1824,7 @@ function SplitCardFormInner({
1687
1824
  );
1688
1825
  const isReady = flopay !== null && elements !== null;
1689
1826
  if (!isReady) {
1690
- return /* @__PURE__ */ jsx5("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." });
1827
+ return /* @__PURE__ */ jsx6("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." });
1691
1828
  }
1692
1829
  const isButtons = layout === "buttons";
1693
1830
  const resolvedBorder = isButtons ? bStyles.cardInputBorder ?? "#e5e7eb" : "#A4A4FF";
@@ -1730,7 +1867,7 @@ function SplitCardFormInner({
1730
1867
  invalid: { color: "#ef4444" }
1731
1868
  }
1732
1869
  };
1733
- const cardFormBlock = /* @__PURE__ */ jsxs3("div", { style: {
1870
+ const cardFormBlock = /* @__PURE__ */ jsxs4("div", { style: {
1734
1871
  backgroundColor: cardBg,
1735
1872
  borderRadius: "8px",
1736
1873
  padding: isButtons ? "0" : "1rem",
@@ -1738,7 +1875,7 @@ function SplitCardFormInner({
1738
1875
  ...isButtons ? { padding: bStyles.cardFormContainer?.padding ?? "0" } : {},
1739
1876
  ...sharedInputPlaceholderVars
1740
1877
  }, children: [
1741
- /* @__PURE__ */ jsx5("style", { children: `
1878
+ /* @__PURE__ */ jsx6("style", { children: `
1742
1879
  .flopay-shared-input::placeholder {
1743
1880
  color: var(--flopay-input-placeholder-color);
1744
1881
  opacity: 1;
@@ -1747,12 +1884,12 @@ function SplitCardFormInner({
1747
1884
  font-weight: var(--flopay-input-font-weight);
1748
1885
  }
1749
1886
  ` }),
1750
- isButtons && showCardForm && /* @__PURE__ */ jsxs3("div", { style: {
1887
+ isButtons && showCardForm && /* @__PURE__ */ jsxs4("div", { style: {
1751
1888
  display: "flex",
1752
1889
  alignItems: "center",
1753
1890
  padding: "0.75rem 0 0.625rem"
1754
1891
  }, children: [
1755
- /* @__PURE__ */ jsxs3(
1892
+ /* @__PURE__ */ jsxs4(
1756
1893
  "button",
1757
1894
  {
1758
1895
  type: "button",
@@ -1774,7 +1911,7 @@ function SplitCardFormInner({
1774
1911
  },
1775
1912
  "aria-label": "Back to payment methods",
1776
1913
  children: [
1777
- /* @__PURE__ */ jsx5("span", { style: {
1914
+ /* @__PURE__ */ jsx6("span", { style: {
1778
1915
  display: "inline-flex",
1779
1916
  alignItems: "center",
1780
1917
  justifyContent: "center",
@@ -1784,12 +1921,12 @@ function SplitCardFormInner({
1784
1921
  backgroundColor: "#f3f4f6",
1785
1922
  transition: "background-color 0.15s",
1786
1923
  ...bStyles.backButtonIcon
1787
- }, children: /* @__PURE__ */ jsx5("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx5("path", { d: "M15 18l-6-6 6-6" }) }) }),
1788
- /* @__PURE__ */ jsx5(BackButtonContentSlot, { content: cardBackButtonContent })
1924
+ }, children: /* @__PURE__ */ jsx6("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx6("path", { d: "M15 18l-6-6 6-6" }) }) }),
1925
+ /* @__PURE__ */ jsx6(BackButtonContentSlot, { content: cardBackButtonContent })
1789
1926
  ]
1790
1927
  }
1791
1928
  ),
1792
- hideTitle ? /* @__PURE__ */ jsx5("div", { style: { flex: 1 } }) : /* @__PURE__ */ jsx5("div", { style: {
1929
+ hideTitle ? /* @__PURE__ */ jsx6("div", { style: { flex: 1 } }) : /* @__PURE__ */ jsx6("div", { style: {
1793
1930
  flex: 1,
1794
1931
  textAlign: "center",
1795
1932
  fontWeight: 600,
@@ -1797,18 +1934,18 @@ function SplitCardFormInner({
1797
1934
  color: "#262833",
1798
1935
  paddingRight: 80,
1799
1936
  ...bStyles.title
1800
- }, children: /* @__PURE__ */ jsx5(TitleContentSlot, { content: cardTitleContent }) })
1937
+ }, children: /* @__PURE__ */ jsx6(TitleContentSlot, { content: cardTitleContent }) })
1801
1938
  ] }),
1802
- !isButtons && !hideTitle && /* @__PURE__ */ jsx5("div", { style: { textAlign: "center", fontWeight: 600, fontSize: "1.1rem", padding: "0.5rem 0", color: "#262833" }, children: /* @__PURE__ */ jsx5(TitleContentSlot, { content: cardTitleContent }) }),
1803
- /* @__PURE__ */ jsx5("div", { style: {
1939
+ !isButtons && !hideTitle && /* @__PURE__ */ jsx6("div", { style: { textAlign: "center", fontWeight: 600, fontSize: "1.1rem", padding: "0.5rem 0", color: "#262833" }, children: /* @__PURE__ */ jsx6(TitleContentSlot, { content: cardTitleContent }) }),
1940
+ /* @__PURE__ */ jsx6("div", { style: {
1804
1941
  backgroundColor: cardInputBg,
1805
1942
  border: `1px solid ${resolvedBorder}`,
1806
1943
  borderTopLeftRadius: "8px",
1807
1944
  borderTopRightRadius: "8px",
1808
1945
  padding: "10px"
1809
- }, children: /* @__PURE__ */ jsx5(CardNumberElement, { onReady: () => setFormReady(true), options: stripeElementStyle }) }),
1810
- /* @__PURE__ */ jsxs3("div", { style: { display: "flex" }, children: [
1811
- /* @__PURE__ */ jsx5("div", { style: {
1946
+ }, children: /* @__PURE__ */ jsx6(CardNumberElement, { onReady: () => setFormReady(true), options: stripeElementStyle }) }),
1947
+ /* @__PURE__ */ jsxs4("div", { style: { display: "flex" }, children: [
1948
+ /* @__PURE__ */ jsx6("div", { style: {
1812
1949
  flex: 1,
1813
1950
  backgroundColor: cardInputBg,
1814
1951
  border: `1px solid ${resolvedBorder}`,
@@ -1816,23 +1953,23 @@ function SplitCardFormInner({
1816
1953
  borderRight: "none",
1817
1954
  borderBottomLeftRadius: "8px",
1818
1955
  padding: "10px"
1819
- }, children: /* @__PURE__ */ jsx5(CardExpiryElement, { options: stripeElementStyle }) }),
1820
- /* @__PURE__ */ jsx5("div", { style: {
1956
+ }, children: /* @__PURE__ */ jsx6(CardExpiryElement, { options: stripeElementStyle }) }),
1957
+ /* @__PURE__ */ jsx6("div", { style: {
1821
1958
  flex: 1,
1822
1959
  backgroundColor: cardInputBg,
1823
1960
  border: `1px solid ${resolvedBorder}`,
1824
1961
  borderTop: "none",
1825
1962
  borderBottomRightRadius: "8px",
1826
1963
  padding: "10px"
1827
- }, children: /* @__PURE__ */ jsx5(CardCvcElement, { options: stripeElementStyle }) })
1964
+ }, children: /* @__PURE__ */ jsx6(CardCvcElement, { options: stripeElementStyle }) })
1828
1965
  ] }),
1829
- /* @__PURE__ */ jsx5("div", { style: {
1966
+ /* @__PURE__ */ jsx6("div", { style: {
1830
1967
  backgroundColor: cardInputBg,
1831
1968
  border: `1px solid ${resolvedBorder}`,
1832
1969
  borderRadius: "8px",
1833
1970
  marginTop: "0.5rem",
1834
1971
  padding: "10px"
1835
- }, children: /* @__PURE__ */ jsx5(
1972
+ }, children: /* @__PURE__ */ jsx6(
1836
1973
  "input",
1837
1974
  {
1838
1975
  className: "flopay-shared-input",
@@ -1871,8 +2008,8 @@ function SplitCardFormInner({
1871
2008
  ...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
1872
2009
  });
1873
2010
  const stateOpts = getStateOptions(cc);
1874
- return /* @__PURE__ */ jsxs3(Fragment2, { children: [
1875
- isAVSFieldVisible(avsConfig.address_line_1, cc) && /* @__PURE__ */ jsx5("div", { style: inputWrapStyle(bStyles.addressLine1Input), children: /* @__PURE__ */ jsx5(
2011
+ return /* @__PURE__ */ jsxs4(Fragment2, { children: [
2012
+ isAVSFieldVisible(avsConfig.address_line_1, cc) && /* @__PURE__ */ jsx6("div", { style: inputWrapStyle(bStyles.addressLine1Input), children: /* @__PURE__ */ jsx6(
1876
2013
  "input",
1877
2014
  {
1878
2015
  className: "flopay-shared-input",
@@ -1889,7 +2026,7 @@ function SplitCardFormInner({
1889
2026
  style: inputFieldStyle()
1890
2027
  }
1891
2028
  ) }),
1892
- isAVSFieldVisible(avsConfig.address_line_2, cc) && /* @__PURE__ */ jsx5("div", { style: inputWrapStyle(bStyles.addressLine2Input), children: /* @__PURE__ */ jsx5(
2029
+ isAVSFieldVisible(avsConfig.address_line_2, cc) && /* @__PURE__ */ jsx6("div", { style: inputWrapStyle(bStyles.addressLine2Input), children: /* @__PURE__ */ jsx6(
1893
2030
  "input",
1894
2031
  {
1895
2032
  className: "flopay-shared-input",
@@ -1905,12 +2042,12 @@ function SplitCardFormInner({
1905
2042
  style: inputFieldStyle()
1906
2043
  }
1907
2044
  ) }),
1908
- (isAVSFieldVisible(avsConfig.city, cc) || isAVSFieldVisible(avsConfig.state, cc)) && /* @__PURE__ */ jsxs3("div", { style: {
2045
+ (isAVSFieldVisible(avsConfig.city, cc) || isAVSFieldVisible(avsConfig.state, cc)) && /* @__PURE__ */ jsxs4("div", { style: {
1909
2046
  display: "flex",
1910
2047
  gap: "0",
1911
2048
  marginTop: "0.5rem"
1912
2049
  }, children: [
1913
- isAVSFieldVisible(avsConfig.city, cc) && /* @__PURE__ */ jsx5("div", { style: {
2050
+ isAVSFieldVisible(avsConfig.city, cc) && /* @__PURE__ */ jsx6("div", { style: {
1914
2051
  flex: 1,
1915
2052
  backgroundColor: cardInputBg,
1916
2053
  border: `1px solid ${resolvedBorder}`,
@@ -1919,7 +2056,7 @@ function SplitCardFormInner({
1919
2056
  borderBottomLeftRadius: "8px",
1920
2057
  ...isAVSFieldVisible(avsConfig.state, cc) ? { borderRight: "none", borderTopRightRadius: 0, borderBottomRightRadius: 0 } : { borderRadius: "8px" },
1921
2058
  ...isButtons && bStyles.cityInput ? bStyles.cityInput : {}
1922
- }, children: /* @__PURE__ */ jsx5(
2059
+ }, children: /* @__PURE__ */ jsx6(
1923
2060
  "input",
1924
2061
  {
1925
2062
  className: "flopay-shared-input",
@@ -1936,7 +2073,7 @@ function SplitCardFormInner({
1936
2073
  style: inputFieldStyle()
1937
2074
  }
1938
2075
  ) }),
1939
- isAVSFieldVisible(avsConfig.state, cc) && /* @__PURE__ */ jsx5("div", { style: {
2076
+ isAVSFieldVisible(avsConfig.state, cc) && /* @__PURE__ */ jsx6("div", { style: {
1940
2077
  flex: 1,
1941
2078
  backgroundColor: cardInputBg,
1942
2079
  border: `1px solid ${resolvedBorder}`,
@@ -1945,7 +2082,7 @@ function SplitCardFormInner({
1945
2082
  borderBottomRightRadius: "8px",
1946
2083
  ...isAVSFieldVisible(avsConfig.city, cc) ? { borderTopLeftRadius: 0, borderBottomLeftRadius: 0 } : { borderRadius: "8px" },
1947
2084
  ...isButtons && bStyles.stateInput ? bStyles.stateInput : {}
1948
- }, children: stateOpts ? /* @__PURE__ */ jsxs3(
2085
+ }, children: stateOpts ? /* @__PURE__ */ jsxs4(
1949
2086
  "select",
1950
2087
  {
1951
2088
  value: stateValue,
@@ -1959,11 +2096,11 @@ function SplitCardFormInner({
1959
2096
  "data-testid": "flopay-state",
1960
2097
  style: { ...inputFieldStyle(), cursor: "pointer" },
1961
2098
  children: [
1962
- /* @__PURE__ */ jsx5("option", { value: "", children: getStateLabel(cc) }),
1963
- stateOpts.map((s) => /* @__PURE__ */ jsx5("option", { value: s.code, children: s.name }, s.code))
2099
+ /* @__PURE__ */ jsx6("option", { value: "", children: getStateLabel(cc) }),
2100
+ stateOpts.map((s) => /* @__PURE__ */ jsx6("option", { value: s.code, children: s.name }, s.code))
1964
2101
  ]
1965
2102
  }
1966
- ) : /* @__PURE__ */ jsx5(
2103
+ ) : /* @__PURE__ */ jsx6(
1967
2104
  "input",
1968
2105
  {
1969
2106
  className: "flopay-shared-input",
@@ -1981,20 +2118,20 @@ function SplitCardFormInner({
1981
2118
  }
1982
2119
  ) })
1983
2120
  ] }),
1984
- (isAVSFieldVisible(avsConfig.country, cc) || isAVSFieldVisible(avsConfig.postal_code, cc)) && /* @__PURE__ */ jsxs3("div", { style: {
2121
+ (isAVSFieldVisible(avsConfig.country, cc) || isAVSFieldVisible(avsConfig.postal_code, cc)) && /* @__PURE__ */ jsxs4("div", { style: {
1985
2122
  display: "flex",
1986
2123
  flexDirection: avsLayoutProp === "column" ? "column" : "row",
1987
2124
  gap: avsLayoutProp === "column" ? "0.5rem" : "0",
1988
2125
  marginTop: "0.5rem"
1989
2126
  }, children: [
1990
- isAVSFieldVisible(avsConfig.country, cc) && /* @__PURE__ */ jsx5("div", { style: {
2127
+ isAVSFieldVisible(avsConfig.country, cc) && /* @__PURE__ */ jsx6("div", { style: {
1991
2128
  flex: avsLayoutProp === "row" ? 1 : void 0,
1992
2129
  backgroundColor: cardInputBg,
1993
2130
  border: `1px solid ${resolvedBorder}`,
1994
2131
  padding: "10px",
1995
2132
  ...avsLayoutProp === "row" && isAVSFieldVisible(avsConfig.postal_code, cc) ? { borderRadius: "0", borderTopLeftRadius: "8px", borderBottomLeftRadius: "8px", borderRight: "none" } : { borderRadius: "8px" },
1996
2133
  ...isButtons && bStyles.countrySelect ? bStyles.countrySelect : {}
1997
- }, children: /* @__PURE__ */ jsx5(
2134
+ }, children: /* @__PURE__ */ jsx6(
1998
2135
  "select",
1999
2136
  {
2000
2137
  value: selectedCountry,
@@ -2009,21 +2146,21 @@ function SplitCardFormInner({
2009
2146
  autoComplete: "country",
2010
2147
  "data-testid": "flopay-country",
2011
2148
  style: { ...inputFieldStyle(), cursor: "pointer" },
2012
- children: COUNTRY_OPTIONS.map((c) => /* @__PURE__ */ jsxs3("option", { value: c.code, children: [
2149
+ children: COUNTRY_OPTIONS.map((c) => /* @__PURE__ */ jsxs4("option", { value: c.code, children: [
2013
2150
  c.flag,
2014
2151
  " ",
2015
2152
  c.name
2016
2153
  ] }, c.code))
2017
2154
  }
2018
2155
  ) }),
2019
- isAVSFieldVisible(avsConfig.postal_code, cc) && /* @__PURE__ */ jsx5("div", { style: {
2156
+ isAVSFieldVisible(avsConfig.postal_code, cc) && /* @__PURE__ */ jsx6("div", { style: {
2020
2157
  flex: avsLayoutProp === "row" ? 1 : void 0,
2021
2158
  backgroundColor: cardInputBg,
2022
2159
  border: `1px solid ${resolvedBorder}`,
2023
2160
  padding: "10px",
2024
2161
  ...avsLayoutProp === "row" && isAVSFieldVisible(avsConfig.country, cc) ? { borderRadius: "0", borderTopRightRadius: "8px", borderBottomRightRadius: "8px" } : { borderRadius: "8px" },
2025
2162
  ...isButtons && bStyles.zipInput ? bStyles.zipInput : {}
2026
- }, children: /* @__PURE__ */ jsx5(
2163
+ }, children: /* @__PURE__ */ jsx6(
2027
2164
  "input",
2028
2165
  {
2029
2166
  className: "flopay-shared-input",
@@ -2044,7 +2181,7 @@ function SplitCardFormInner({
2044
2181
  ] })
2045
2182
  ] });
2046
2183
  })(),
2047
- displayError && /* @__PURE__ */ jsxs3("div", { role: "alert", "data-testid": "flopay-error", style: {
2184
+ displayError && /* @__PURE__ */ jsxs4("div", { role: "alert", "data-testid": "flopay-error", style: {
2048
2185
  margin: "0.75rem 0",
2049
2186
  padding: "0.625rem 0.875rem",
2050
2187
  background: "#FEF2F2",
@@ -2058,10 +2195,10 @@ function SplitCardFormInner({
2058
2195
  gap: "0.5rem",
2059
2196
  ...isButtons && bStyles.errorBanner ? bStyles.errorBanner : {}
2060
2197
  }, children: [
2061
- /* @__PURE__ */ jsx5("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx5("path", { d: "M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z", stroke: "#DC2626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }),
2198
+ /* @__PURE__ */ jsx6("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx6("path", { d: "M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z", stroke: "#DC2626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }),
2062
2199
  displayError
2063
2200
  ] }),
2064
- children ?? /* @__PURE__ */ jsx5(
2201
+ children ?? /* @__PURE__ */ jsx6(
2065
2202
  "button",
2066
2203
  {
2067
2204
  type: "submit",
@@ -2084,7 +2221,7 @@ function SplitCardFormInner({
2084
2221
  children: isSubmitting ? "PROCESSING..." : submitLabel
2085
2222
  }
2086
2223
  ),
2087
- !isButtons && showSecurityFooter && /* @__PURE__ */ jsx5("div", { style: {
2224
+ !isButtons && showSecurityFooter && /* @__PURE__ */ jsx6("div", { style: {
2088
2225
  backgroundColor: "#EFF9F0",
2089
2226
  borderRadius: "8px",
2090
2227
  padding: "0.75rem",
@@ -2101,11 +2238,11 @@ function SplitCardFormInner({
2101
2238
  const cardButtonSizing = cardButtonContent === void 0 ? { boxSizing: "border-box", height: DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT, padding: "0 1rem" } : { padding: "0.9rem 1rem" };
2102
2239
  const buttonsAnim = viewState === "expanding" ? `flopay-buttons-exit ${TRANSITION_MS}ms cubic-bezier(0.4, 0, 0.2, 1) both` : viewState === "collapsing" ? `flopay-buttons-enter ${TRANSITION_MS}ms cubic-bezier(0, 0, 0.2, 1) both` : void 0;
2103
2240
  const cardAnim = viewState === "expanding" ? `flopay-card-enter ${TRANSITION_MS}ms cubic-bezier(0, 0, 0.2, 1) both` : viewState === "collapsing" ? `flopay-card-exit ${TRANSITION_MS}ms cubic-bezier(0.4, 0, 0.2, 1) both` : void 0;
2104
- return /* @__PURE__ */ jsxs3("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
2105
- /* @__PURE__ */ jsx5(FloPayKeyframes, {}),
2106
- overlayStatus && /* @__PURE__ */ jsx5(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
2107
- /* @__PURE__ */ jsxs3("div", { style: { display: "grid" }, children: [
2108
- /* @__PURE__ */ jsxs3("div", { style: {
2241
+ return /* @__PURE__ */ jsxs4("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
2242
+ /* @__PURE__ */ jsx6(FloPayKeyframes, {}),
2243
+ overlayStatus && /* @__PURE__ */ jsx6(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
2244
+ /* @__PURE__ */ jsxs4("div", { style: { display: "grid" }, children: [
2245
+ /* @__PURE__ */ jsxs4("div", { style: {
2109
2246
  gridArea: "1 / 1",
2110
2247
  display: "flex",
2111
2248
  flexDirection: "column",
@@ -2114,7 +2251,7 @@ function SplitCardFormInner({
2114
2251
  ...!isButtonsView && !buttonsAnim ? { visibility: "hidden", position: "absolute", pointerEvents: "none", width: "100%" } : {},
2115
2252
  ...buttonsAnim ? { animation: buttonsAnim, pointerEvents: "none" } : {}
2116
2253
  }, children: [
2117
- showPayPal && paypalStripeInstance && /* @__PURE__ */ jsx5(StripeElements, { stripe: paypalStripeInstance, options: paypalOptions, children: /* @__PURE__ */ jsx5(
2254
+ showPayPal && paypalStripeInstance && /* @__PURE__ */ jsx6(StripeElements, { stripe: paypalStripeInstance, options: paypalOptions, children: /* @__PURE__ */ jsx6(
2118
2255
  PayPalButtonInner,
2119
2256
  {
2120
2257
  sessionId,
@@ -2125,10 +2262,11 @@ function SplitCardFormInner({
2125
2262
  isProcessing: isSubmitting,
2126
2263
  onButtonClick,
2127
2264
  onDecline,
2128
- runBeforeButtonClick
2265
+ runBeforeButtonClick,
2266
+ onLoadStateChange: setPaypalLoadState
2129
2267
  }
2130
2268
  ) }),
2131
- showWallets && stripeInstance ? /* @__PURE__ */ jsx5(StripeElements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ jsx5(
2269
+ showWallets && stripeInstance ? /* @__PURE__ */ jsx6(StripeElements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ jsx6(
2132
2270
  WalletButtonInner,
2133
2271
  {
2134
2272
  sessionId,
@@ -2140,10 +2278,12 @@ function SplitCardFormInner({
2140
2278
  onErrorChange: updateError,
2141
2279
  onButtonClick,
2142
2280
  onDecline,
2143
- runBeforeButtonClick
2281
+ runBeforeButtonClick,
2282
+ onLoadStateChange: setWalletLoadState
2144
2283
  }
2145
- ) }) : showWallets ? /* @__PURE__ */ jsx5("div", { style: { height: DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT, borderRadius: 8, background: "#e5e7eb", animation: "flopay-pulse 1.5s ease-in-out infinite" } }) : null,
2146
- /* @__PURE__ */ jsx5(
2284
+ ) }) : showWallets ? /* @__PURE__ */ jsx6("div", { style: { height: DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT, borderRadius: 8, background: "#e5e7eb", animation: "flopay-pulse 1.5s ease-in-out infinite" } }) : null,
2285
+ showInAppBrowserNotice && /* @__PURE__ */ jsx6(InAppBrowserNotice, {}),
2286
+ /* @__PURE__ */ jsx6(
2147
2287
  "button",
2148
2288
  {
2149
2289
  type: "button",
@@ -2181,10 +2321,10 @@ function SplitCardFormInner({
2181
2321
  onMouseUp: (e) => {
2182
2322
  e.currentTarget.style.transform = "scale(1)";
2183
2323
  },
2184
- children: /* @__PURE__ */ jsx5(CardButtonContentSlot, { content: cardButtonContent })
2324
+ children: /* @__PURE__ */ jsx6(CardButtonContentSlot, { content: cardButtonContent })
2185
2325
  }
2186
2326
  ),
2187
- displayError && viewState === "buttons" && /* @__PURE__ */ jsxs3("div", { role: "alert", "data-testid": "flopay-error", style: {
2327
+ displayError && viewState === "buttons" && /* @__PURE__ */ jsxs4("div", { role: "alert", "data-testid": "flopay-error", style: {
2188
2328
  margin: "0.25rem 0",
2189
2329
  padding: "0.625rem 0.875rem",
2190
2330
  background: "#FEF2F2",
@@ -2198,11 +2338,11 @@ function SplitCardFormInner({
2198
2338
  gap: "0.5rem",
2199
2339
  ...bStyles.errorBanner ? bStyles.errorBanner : {}
2200
2340
  }, children: [
2201
- /* @__PURE__ */ jsx5("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx5("path", { d: "M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z", stroke: "#DC2626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }),
2341
+ /* @__PURE__ */ jsx6("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx6("path", { d: "M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z", stroke: "#DC2626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }),
2202
2342
  displayError
2203
2343
  ] })
2204
2344
  ] }),
2205
- isCardView && /* @__PURE__ */ jsx5("div", { style: {
2345
+ isCardView && /* @__PURE__ */ jsx6("div", { style: {
2206
2346
  gridArea: "1 / 1",
2207
2347
  ...cardAnim ? { animation: cardAnim } : {},
2208
2348
  ...viewState === "collapsing" ? { pointerEvents: "none" } : {}
@@ -2210,10 +2350,10 @@ function SplitCardFormInner({
2210
2350
  ] })
2211
2351
  ] });
2212
2352
  }
2213
- return /* @__PURE__ */ jsxs3("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
2214
- /* @__PURE__ */ jsx5(FloPayKeyframes, {}),
2215
- overlayStatus && /* @__PURE__ */ jsx5(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
2216
- showWallets && stripeInstance && /* @__PURE__ */ jsx5(StripeElements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ jsx5(
2353
+ return /* @__PURE__ */ jsxs4("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
2354
+ /* @__PURE__ */ jsx6(FloPayKeyframes, {}),
2355
+ overlayStatus && /* @__PURE__ */ jsx6(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
2356
+ showWallets && stripeInstance && /* @__PURE__ */ jsx6(StripeElements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ jsx6(
2217
2357
  WalletButtonInner,
2218
2358
  {
2219
2359
  sessionId,
@@ -2223,10 +2363,11 @@ function SplitCardFormInner({
2223
2363
  showGooglePay,
2224
2364
  onTokenizedBody: dispatchTokenizedBody,
2225
2365
  onErrorChange: updateError,
2226
- onDecline
2366
+ onDecline,
2367
+ onLoadStateChange: setWalletLoadState
2227
2368
  }
2228
2369
  ) }),
2229
- showPayPal && paypalStripeInstance && /* @__PURE__ */ jsx5(StripeElements, { stripe: paypalStripeInstance, options: paypalOptions, children: /* @__PURE__ */ jsx5(
2370
+ showPayPal && paypalStripeInstance && /* @__PURE__ */ jsx6(StripeElements, { stripe: paypalStripeInstance, options: paypalOptions, children: /* @__PURE__ */ jsx6(
2230
2371
  PayPalButtonInner,
2231
2372
  {
2232
2373
  sessionId,
@@ -2235,10 +2376,12 @@ function SplitCardFormInner({
2235
2376
  onTokenizedBody: dispatchTokenizedBody,
2236
2377
  onErrorChange: updateError,
2237
2378
  isProcessing: isSubmitting,
2238
- onDecline
2379
+ onDecline,
2380
+ onLoadStateChange: setPaypalLoadState
2239
2381
  }
2240
2382
  ) }),
2241
- (showWallets && stripeInstance || showPayPal && paypalStripeInstance) && /* @__PURE__ */ jsxs3("div", { style: {
2383
+ showInAppBrowserNotice && /* @__PURE__ */ jsx6(InAppBrowserNotice, {}),
2384
+ (showWallets && stripeInstance || showPayPal && paypalStripeInstance) && /* @__PURE__ */ jsxs4("div", { style: {
2242
2385
  display: "flex",
2243
2386
  alignItems: "center",
2244
2387
  gap: "0.75rem",
@@ -2246,9 +2389,9 @@ function SplitCardFormInner({
2246
2389
  color: "#999",
2247
2390
  fontSize: "0.85rem"
2248
2391
  }, children: [
2249
- /* @__PURE__ */ jsx5("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } }),
2250
- /* @__PURE__ */ jsx5("span", { children: "or pay with card" }),
2251
- /* @__PURE__ */ jsx5("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } })
2392
+ /* @__PURE__ */ jsx6("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } }),
2393
+ /* @__PURE__ */ jsx6("span", { children: "or pay with card" }),
2394
+ /* @__PURE__ */ jsx6("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } })
2252
2395
  ] }),
2253
2396
  cardFormBlock
2254
2397
  ] });
@@ -2689,15 +2832,31 @@ async function handleSavedPaymentRedirectResult(redirectResult, {
2689
2832
  { checkoutMethod: "paypal" }
2690
2833
  );
2691
2834
  }
2692
- const confirmParams = {
2693
- return_url: returnUrl ?? resolveSavedPaymentReturnUrl(session) ?? window.location.href
2694
- };
2695
2835
  if (redirectResult.paymentMethodId) {
2696
- confirmParams["payment_method"] = redirectResult.paymentMethodId;
2836
+ const { error: error2 } = await paypalStripe.handleNextAction({
2837
+ clientSecret: redirectResult.threeDSecureToken
2838
+ });
2839
+ if (error2) {
2840
+ throw Object.assign(
2841
+ new FloPayError3(
2842
+ error2.message ?? "PayPal authorization failed.",
2843
+ "api_error",
2844
+ { code: error2.code }
2845
+ ),
2846
+ { checkoutMethod: "paypal" }
2847
+ );
2848
+ }
2849
+ return {
2850
+ status: "succeeded",
2851
+ checkoutMethod: "paypal"
2852
+ };
2697
2853
  }
2698
2854
  const { error } = await paypalStripe.confirmPayment({
2699
2855
  clientSecret: redirectResult.threeDSecureToken,
2700
- confirmParams,
2856
+ confirmParams: {
2857
+ return_url: returnUrl ?? resolveSavedPaymentReturnUrl(session) ?? window.location.href,
2858
+ payment_method_data: { type: "paypal" }
2859
+ },
2701
2860
  redirect: "if_required"
2702
2861
  });
2703
2862
  if (error) {
@@ -2771,7 +2930,7 @@ async function loadSavedPaymentProviders({
2771
2930
  }
2772
2931
 
2773
2932
  // src/flopay-checkout.tsx
2774
- import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
2933
+ import { Fragment as Fragment3, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
2775
2934
  var DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2 = 44;
2776
2935
  var PAYPAL_RESUME_STORAGE_KEY = "flopay_checkout_saved_payment_resume";
2777
2936
  var sessionInflightMap = /* @__PURE__ */ new Map();
@@ -2874,25 +3033,25 @@ function FloPayCheckout({
2874
3033
  const resolvedBillingUrl = resolveBillingApiUrl3(billingApiUrl);
2875
3034
  const checkoutType = createSessionParams ? "embedded_checkout" : "standard_checkout";
2876
3035
  const checkoutLayout = children ? "custom_layout" : layout === "buttons" ? "buttons_layout" : "default_layout";
2877
- const [unified, setUnified] = useState3(null);
2878
- const [flopay, setFloPay] = useState3(null);
3036
+ const [unified, setUnified] = useState4(null);
3037
+ const [flopay, setFloPay] = useState4(null);
2879
3038
  const flopayRef = useRef3(null);
2880
- const [paypalFlopay, setPaypalFloPay] = useState3(null);
3039
+ const [paypalFlopay, setPaypalFloPay] = useState4(null);
2881
3040
  const paypalFlopayRef = useRef3(null);
2882
- const [session, setSession] = useState3(null);
2883
- const [resolvedSessionId, setResolvedSessionId] = useState3(sessionIdProp ?? "");
3041
+ const [session, setSession] = useState4(null);
3042
+ const [resolvedSessionId, setResolvedSessionId] = useState4(sessionIdProp ?? "");
2884
3043
  const activeSessionId = sessionIdProp ?? resolvedSessionId;
2885
3044
  const initSessionDependency = createSessionParams ? "" : activeSessionId;
2886
- const [isLoading, setIsLoading] = useState3(true);
2887
- const [loadError, setLoadError] = useState3(null);
2888
- const [currentMode, setCurrentMode] = useState3("full");
2889
- const [confirmProcessing, setConfirmProcessing] = useState3(false);
2890
- const [modeError, setModeError] = useState3(initialErrorMessage);
2891
- const [modeOverlayStatus, setModeOverlayStatus] = useState3(null);
2892
- const [modeOverlayError, setModeOverlayError] = useState3(null);
2893
- const [createSessionPatch, setCreateSessionPatch] = useState3(void 0);
2894
- const [createSessionPatchBaseHash, setCreateSessionPatchBaseHash] = useState3("");
2895
- const [cardBootstrapPending, setCardBootstrapPending] = useState3(false);
3045
+ const [isLoading, setIsLoading] = useState4(true);
3046
+ const [loadError, setLoadError] = useState4(null);
3047
+ const [currentMode, setCurrentMode] = useState4("full");
3048
+ const [confirmProcessing, setConfirmProcessing] = useState4(false);
3049
+ const [modeError, setModeError] = useState4(initialErrorMessage);
3050
+ const [modeOverlayStatus, setModeOverlayStatus] = useState4(null);
3051
+ const [modeOverlayError, setModeOverlayError] = useState4(null);
3052
+ const [createSessionPatch, setCreateSessionPatch] = useState4(void 0);
3053
+ const [createSessionPatchBaseHash, setCreateSessionPatchBaseHash] = useState4("");
3054
+ const [cardBootstrapPending, setCardBootstrapPending] = useState4(false);
2896
3055
  const autoCheckoutAttempted = useRef3(false);
2897
3056
  const paypalResumeAttempted = useRef3(false);
2898
3057
  const savedPaymentKeysRef = useRef3(null);
@@ -2904,7 +3063,7 @@ function FloPayCheckout({
2904
3063
  onDeclineRef.current = onDecline;
2905
3064
  const onSessionCompletedRef = useRef3(onSessionCompleted);
2906
3065
  onSessionCompletedRef.current = onSessionCompleted;
2907
- useEffect4(() => {
3066
+ useEffect5(() => {
2908
3067
  console.info("[FloPay] Checkout initialized", {
2909
3068
  sdk_version: SDK_VERSION,
2910
3069
  checkout_type: checkoutType,
@@ -2932,20 +3091,20 @@ function FloPayCheckout({
2932
3091
  } : void 0,
2933
3092
  [effectiveCreateSessionBase, effectiveCreateSessionMode]
2934
3093
  );
2935
- useEffect4(() => {
3094
+ useEffect5(() => {
2936
3095
  setCreateSessionPatch(void 0);
2937
3096
  setCreateSessionPatchBaseHash(baseCreateSessionHash);
2938
3097
  }, [baseCreateSessionHash]);
2939
- useEffect4(() => {
3098
+ useEffect5(() => {
2940
3099
  setModeError(initialErrorMessage);
2941
3100
  }, [initialErrorMessage]);
2942
- const emitDecline = useCallback2(
3101
+ const emitDecline = useCallback3(
2943
3102
  (method, input, overrides) => {
2944
3103
  onDeclineRef.current?.(buildDeclineEvent(method, input, overrides));
2945
3104
  },
2946
3105
  []
2947
3106
  );
2948
- const runSavedPaymentFlow = useCallback2(
3107
+ const runSavedPaymentFlow = useCallback3(
2949
3108
  async (sess, options) => {
2950
3109
  setModeError(null);
2951
3110
  setModeOverlayError(null);
@@ -3052,7 +3211,7 @@ function FloPayCheckout({
3052
3211
  resolvedBillingUrl
3053
3212
  ]
3054
3213
  );
3055
- useEffect4(() => {
3214
+ useEffect5(() => {
3056
3215
  if (typeof window === "undefined" || paypalResumeAttempted.current) {
3057
3216
  return;
3058
3217
  }
@@ -3199,10 +3358,10 @@ function FloPayCheckout({
3199
3358
  );
3200
3359
  const createSessionParamsRef = useRef3(effectiveCreateSession);
3201
3360
  createSessionParamsRef.current = effectiveCreateSession;
3202
- useEffect4(() => {
3361
+ useEffect5(() => {
3203
3362
  setResolvedSessionId(sessionIdProp ?? "");
3204
3363
  }, [sessionIdProp]);
3205
- useEffect4(() => {
3364
+ useEffect5(() => {
3206
3365
  autoCheckoutAttempted.current = false;
3207
3366
  setModeError(initialErrorMessage);
3208
3367
  setModeOverlayError(null);
@@ -3245,7 +3404,7 @@ function FloPayCheckout({
3245
3404
  }
3246
3405
  return { sid: sid ?? "", result: realResult };
3247
3406
  }
3248
- const bootstrapInlineSession = useCallback2(
3407
+ const bootstrapInlineSession = useCallback3(
3249
3408
  async (patch) => {
3250
3409
  const baseParams = createSessionParamsRef.current;
3251
3410
  if (!baseParams) {
@@ -3306,7 +3465,7 @@ function FloPayCheckout({
3306
3465
  },
3307
3466
  [locale, resolvedBillingUrl]
3308
3467
  );
3309
- const handleInlineSessionPatch = useCallback2(async (patch) => {
3468
+ const handleInlineSessionPatch = useCallback3(async (patch) => {
3310
3469
  if (!hasInlineSessionPatchData(patch) || cardBootstrapPending) {
3311
3470
  return {
3312
3471
  sessionId: resolvedSessionId,
@@ -3329,7 +3488,7 @@ function FloPayCheckout({
3329
3488
  resolvedSessionId,
3330
3489
  session
3331
3490
  ]);
3332
- useEffect4(() => {
3491
+ useEffect5(() => {
3333
3492
  let cancelled = false;
3334
3493
  setLoadError(null);
3335
3494
  if (createSessionHash) {
@@ -3483,7 +3642,7 @@ function FloPayCheckout({
3483
3642
  initSessionDependency,
3484
3643
  runSavedPaymentFlow
3485
3644
  ]);
3486
- const handleConfirmCheckout = useCallback2(async () => {
3645
+ const handleConfirmCheckout = useCallback3(async () => {
3487
3646
  if (confirmProcessing || !session) return;
3488
3647
  setConfirmProcessing(true);
3489
3648
  setModeError(null);
@@ -3537,7 +3696,7 @@ function FloPayCheckout({
3537
3696
  ]
3538
3697
  );
3539
3698
  const shouldShowInterimButtons = Boolean(createSessionParams) && layout === "buttons" && (!flopay || !providerOptions);
3540
- const modeOverlay = modeOverlayStatus ? /* @__PURE__ */ jsx6(
3699
+ const modeOverlay = modeOverlayStatus ? /* @__PURE__ */ jsx7(
3541
3700
  ProcessingOverlay,
3542
3701
  {
3543
3702
  status: modeOverlayStatus,
@@ -3546,31 +3705,31 @@ function FloPayCheckout({
3546
3705
  ) : null;
3547
3706
  if (isLoading) {
3548
3707
  if (loadingNode) {
3549
- return /* @__PURE__ */ jsxs4(Fragment3, { children: [
3708
+ return /* @__PURE__ */ jsxs5(Fragment3, { children: [
3550
3709
  loadingNode,
3551
3710
  modeOverlay
3552
3711
  ] });
3553
3712
  }
3554
3713
  if (layout === "buttons") {
3555
- const skeletonBar = (h) => /* @__PURE__ */ jsx6("div", { style: {
3714
+ const skeletonBar = (h) => /* @__PURE__ */ jsx7("div", { style: {
3556
3715
  height: h,
3557
3716
  borderRadius: 8,
3558
3717
  background: "#e5e7eb",
3559
3718
  animation: "flopay-loading-pulse 1.5s ease-in-out infinite"
3560
3719
  } });
3561
- return /* @__PURE__ */ jsxs4(Fragment3, { children: [
3562
- /* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
3720
+ return /* @__PURE__ */ jsxs5(Fragment3, { children: [
3721
+ /* @__PURE__ */ jsxs5("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
3563
3722
  showPayPal && skeletonBar(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
3564
3723
  (showApplePay || showGooglePay) && skeletonBar(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
3565
3724
  skeletonBar(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
3566
- /* @__PURE__ */ jsx6("style", { children: `@keyframes flopay-loading-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
3725
+ /* @__PURE__ */ jsx7("style", { children: `@keyframes flopay-loading-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
3567
3726
  ] }),
3568
3727
  modeOverlay
3569
3728
  ] });
3570
3729
  }
3571
- return /* @__PURE__ */ jsxs4(Fragment3, { children: [
3572
- /* @__PURE__ */ jsxs4("div", { style: { display: "flex", justifyContent: "center", padding: 32 }, children: [
3573
- /* @__PURE__ */ jsx6("div", { style: {
3730
+ return /* @__PURE__ */ jsxs5(Fragment3, { children: [
3731
+ /* @__PURE__ */ jsxs5("div", { style: { display: "flex", justifyContent: "center", padding: 32 }, children: [
3732
+ /* @__PURE__ */ jsx7("div", { style: {
3574
3733
  width: 24,
3575
3734
  height: 24,
3576
3735
  border: "2px solid #e5e7eb",
@@ -3578,14 +3737,14 @@ function FloPayCheckout({
3578
3737
  borderRadius: "50%",
3579
3738
  animation: "spin 0.6s linear infinite"
3580
3739
  } }),
3581
- /* @__PURE__ */ jsx6("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` })
3740
+ /* @__PURE__ */ jsx7("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` })
3582
3741
  ] }),
3583
3742
  modeOverlay
3584
3743
  ] });
3585
3744
  }
3586
3745
  if (loadError) {
3587
- if (errorNode) return /* @__PURE__ */ jsx6(Fragment3, { children: errorNode(loadError) });
3588
- return /* @__PURE__ */ jsx6(
3746
+ if (errorNode) return /* @__PURE__ */ jsx7(Fragment3, { children: errorNode(loadError) });
3747
+ return /* @__PURE__ */ jsx7(
3589
3748
  "div",
3590
3749
  {
3591
3750
  style: {
@@ -3599,8 +3758,8 @@ function FloPayCheckout({
3599
3758
  );
3600
3759
  }
3601
3760
  if (shouldShowInterimButtons) {
3602
- return /* @__PURE__ */ jsxs4(Fragment3, { children: [
3603
- /* @__PURE__ */ jsx6(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ jsx6(
3761
+ return /* @__PURE__ */ jsxs5(Fragment3, { children: [
3762
+ /* @__PURE__ */ jsx7(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ jsx7(
3604
3763
  InterimButtonsView,
3605
3764
  {
3606
3765
  onButtonClick,
@@ -3618,12 +3777,12 @@ function FloPayCheckout({
3618
3777
  ] });
3619
3778
  }
3620
3779
  if (!flopay || !providerOptions) {
3621
- return /* @__PURE__ */ jsx6(Fragment3, { children: modeOverlay });
3780
+ return /* @__PURE__ */ jsx7(Fragment3, { children: modeOverlay });
3622
3781
  }
3623
3782
  if (currentMode === "confirm") {
3624
- return /* @__PURE__ */ jsxs4(Fragment3, { children: [
3625
- /* @__PURE__ */ jsx6(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ jsx6(FloPayProvider, { flopay, paypalFlopay, options: providerOptions, children: /* @__PURE__ */ jsxs4("div", { className, children: [
3626
- modeError && /* @__PURE__ */ jsx6(
3783
+ return /* @__PURE__ */ jsxs5(Fragment3, { children: [
3784
+ /* @__PURE__ */ jsx7(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ jsx7(FloPayProvider, { flopay, paypalFlopay, options: providerOptions, children: /* @__PURE__ */ jsxs5("div", { className, children: [
3785
+ modeError && /* @__PURE__ */ jsx7(
3627
3786
  "div",
3628
3787
  {
3629
3788
  style: {
@@ -3638,7 +3797,7 @@ function FloPayCheckout({
3638
3797
  renderConfirmButton ? renderConfirmButton({
3639
3798
  onConfirm: handleConfirmCheckout,
3640
3799
  isProcessing: confirmProcessing
3641
- }) : /* @__PURE__ */ jsx6(
3800
+ }) : /* @__PURE__ */ jsx7(
3642
3801
  "button",
3643
3802
  {
3644
3803
  type: "button",
@@ -3663,9 +3822,9 @@ function FloPayCheckout({
3663
3822
  modeOverlay
3664
3823
  ] });
3665
3824
  }
3666
- return /* @__PURE__ */ jsxs4(Fragment3, { children: [
3667
- /* @__PURE__ */ jsx6(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ jsx6(FloPayProvider, { flopay, paypalFlopay, options: providerOptions, children: children ? /* @__PURE__ */ jsxs4(Fragment3, { children: [
3668
- modeError && /* @__PURE__ */ jsx6(
3825
+ return /* @__PURE__ */ jsxs5(Fragment3, { children: [
3826
+ /* @__PURE__ */ jsx7(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ jsx7(FloPayProvider, { flopay, paypalFlopay, options: providerOptions, children: children ? /* @__PURE__ */ jsxs5(Fragment3, { children: [
3827
+ modeError && /* @__PURE__ */ jsx7(
3669
3828
  "div",
3670
3829
  {
3671
3830
  style: {
@@ -3680,7 +3839,7 @@ function FloPayCheckout({
3680
3839
  children: modeError
3681
3840
  }
3682
3841
  ),
3683
- /* @__PURE__ */ jsx6(
3842
+ /* @__PURE__ */ jsx7(
3684
3843
  SessionInjector,
3685
3844
  {
3686
3845
  sessionId: activeSessionId,
@@ -3689,7 +3848,7 @@ function FloPayCheckout({
3689
3848
  children
3690
3849
  }
3691
3850
  )
3692
- ] }) : /* @__PURE__ */ jsx6(
3851
+ ] }) : /* @__PURE__ */ jsx7(
3693
3852
  SplitCardForm,
3694
3853
  {
3695
3854
  sessionId: activeSessionId,
@@ -3740,8 +3899,8 @@ function SessionInjector({
3740
3899
  session,
3741
3900
  children
3742
3901
  }) {
3743
- return /* @__PURE__ */ jsx6(Fragment3, { children: React6.Children.map(children, (child) => {
3744
- if (!React6.isValidElement(child)) return child;
3902
+ return /* @__PURE__ */ jsx7(Fragment3, { children: React7.Children.map(children, (child) => {
3903
+ if (!React7.isValidElement(child)) return child;
3745
3904
  const existing = child.props;
3746
3905
  const injected = {};
3747
3906
  if (!existing.sessionId) injected.sessionId = sessionId;
@@ -3755,7 +3914,7 @@ function SessionInjector({
3755
3914
  injected.lastName = session.customer.lastName;
3756
3915
  }
3757
3916
  if (Object.keys(injected).length === 0) return child;
3758
- return React6.cloneElement(child, injected);
3917
+ return React7.cloneElement(child, injected);
3759
3918
  }) });
3760
3919
  }
3761
3920
  function InterimButtonsView({
@@ -3773,9 +3932,9 @@ function InterimButtonsView({
3773
3932
  cardBackButtonContent,
3774
3933
  cardTitleContent
3775
3934
  }) {
3776
- const [showCardForm, setShowCardForm] = useState3(false);
3935
+ const [showCardForm, setShowCardForm] = useState4(false);
3777
3936
  const isCardOpenControlled = typeof cardOpen === "boolean";
3778
- useEffect4(() => {
3937
+ useEffect5(() => {
3779
3938
  if (isCardOpenControlled) {
3780
3939
  setShowCardForm(cardOpen);
3781
3940
  }
@@ -3794,7 +3953,7 @@ function InterimButtonsView({
3794
3953
  title: { ...base.title, ...stylesOverride.title }
3795
3954
  };
3796
3955
  }, [buttonsTheme, stylesOverride]);
3797
- const skeleton = (h) => /* @__PURE__ */ jsx6("div", { style: {
3956
+ const skeleton = (h) => /* @__PURE__ */ jsx7("div", { style: {
3798
3957
  height: h,
3799
3958
  borderRadius: 8,
3800
3959
  background: "#e5e7eb",
@@ -3806,15 +3965,15 @@ function InterimButtonsView({
3806
3965
  const inputBg = bStyles.cardInputBackground ?? "white";
3807
3966
  const hideBackButtonLabel = isEmptySlotContent(cardBackButtonContent);
3808
3967
  const hideTitle = isEmptySlotContent(cardTitleContent);
3809
- return /* @__PURE__ */ jsxs4("div", { style: {
3968
+ return /* @__PURE__ */ jsxs5("div", { style: {
3810
3969
  backgroundColor: bStyles.cardFormContainer?.backgroundColor ?? "white",
3811
3970
  borderRadius: "8px",
3812
3971
  animation: "flopay-interim-expand 0.35s cubic-bezier(0.4, 0, 0.2, 1) both",
3813
3972
  overflow: "hidden",
3814
3973
  ...bStyles.cardFormContainer
3815
3974
  }, children: [
3816
- /* @__PURE__ */ jsxs4("div", { style: { display: "flex", alignItems: "center", padding: "0.75rem 0 0.625rem" }, children: [
3817
- /* @__PURE__ */ jsxs4(
3975
+ /* @__PURE__ */ jsxs5("div", { style: { display: "flex", alignItems: "center", padding: "0.75rem 0 0.625rem" }, children: [
3976
+ /* @__PURE__ */ jsxs5(
3818
3977
  "button",
3819
3978
  {
3820
3979
  type: "button",
@@ -3841,7 +4000,7 @@ function InterimButtonsView({
3841
4000
  ...bStyles.backButton
3842
4001
  },
3843
4002
  children: [
3844
- /* @__PURE__ */ jsx6("span", { style: {
4003
+ /* @__PURE__ */ jsx7("span", { style: {
3845
4004
  display: "inline-flex",
3846
4005
  alignItems: "center",
3847
4006
  justifyContent: "center",
@@ -3850,12 +4009,12 @@ function InterimButtonsView({
3850
4009
  borderRadius: "50%",
3851
4010
  backgroundColor: "#f3f4f6",
3852
4011
  ...bStyles.backButtonIcon
3853
- }, children: /* @__PURE__ */ jsx6("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx6("path", { d: "M15 18l-6-6 6-6" }) }) }),
3854
- /* @__PURE__ */ jsx6(BackButtonContentSlot, { content: cardBackButtonContent })
4012
+ }, children: /* @__PURE__ */ jsx7("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx7("path", { d: "M15 18l-6-6 6-6" }) }) }),
4013
+ /* @__PURE__ */ jsx7(BackButtonContentSlot, { content: cardBackButtonContent })
3855
4014
  ]
3856
4015
  }
3857
4016
  ),
3858
- hideTitle ? /* @__PURE__ */ jsx6("div", { style: { flex: 1 } }) : /* @__PURE__ */ jsx6("div", { style: {
4017
+ hideTitle ? /* @__PURE__ */ jsx7("div", { style: { flex: 1 } }) : /* @__PURE__ */ jsx7("div", { style: {
3859
4018
  flex: 1,
3860
4019
  textAlign: "center",
3861
4020
  fontWeight: 600,
@@ -3863,15 +4022,15 @@ function InterimButtonsView({
3863
4022
  color: "#262833",
3864
4023
  paddingRight: 80,
3865
4024
  ...bStyles.title
3866
- }, children: /* @__PURE__ */ jsx6(TitleContentSlot, { content: cardTitleContent }) })
4025
+ }, children: /* @__PURE__ */ jsx7(TitleContentSlot, { content: cardTitleContent }) })
3867
4026
  ] }),
3868
- /* @__PURE__ */ jsx6("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTopLeftRadius: 8, borderTopRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ jsx6("div", { style: { width: "60%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
3869
- /* @__PURE__ */ jsxs4("div", { style: { display: "flex" }, children: [
3870
- /* @__PURE__ */ jsx6("div", { style: { flex: 1, backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTop: "none", borderRight: "none", borderBottomLeftRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ jsx6("div", { style: { width: "50%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
3871
- /* @__PURE__ */ jsx6("div", { style: { flex: 1, backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTop: "none", borderBottomRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ jsx6("div", { style: { width: "40%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) })
4027
+ /* @__PURE__ */ jsx7("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTopLeftRadius: 8, borderTopRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ jsx7("div", { style: { width: "60%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
4028
+ /* @__PURE__ */ jsxs5("div", { style: { display: "flex" }, children: [
4029
+ /* @__PURE__ */ jsx7("div", { style: { flex: 1, backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTop: "none", borderRight: "none", borderBottomLeftRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ jsx7("div", { style: { width: "50%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
4030
+ /* @__PURE__ */ jsx7("div", { style: { flex: 1, backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTop: "none", borderBottomRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ jsx7("div", { style: { width: "40%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) })
3872
4031
  ] }),
3873
- /* @__PURE__ */ jsx6("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderRadius: 8, marginTop: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ jsx6("div", { style: { width: "45%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
3874
- /* @__PURE__ */ jsx6("div", { style: {
4032
+ /* @__PURE__ */ jsx7("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderRadius: 8, marginTop: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ jsx7("div", { style: { width: "45%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
4033
+ /* @__PURE__ */ jsx7("div", { style: {
3875
4034
  height: 50,
3876
4035
  borderRadius: 8,
3877
4036
  marginTop: 16,
@@ -3880,7 +4039,7 @@ function InterimButtonsView({
3880
4039
  ...bStyles.submitButton,
3881
4040
  opacity: 0.5
3882
4041
  } }),
3883
- /* @__PURE__ */ jsx6("style", { children: `
4042
+ /* @__PURE__ */ jsx7("style", { children: `
3884
4043
  @keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
3885
4044
  @keyframes flopay-interim-expand {
3886
4045
  0% { opacity: 0; max-height: 0; transform: translateY(-12px); }
@@ -3890,10 +4049,10 @@ function InterimButtonsView({
3890
4049
  ` })
3891
4050
  ] });
3892
4051
  }
3893
- return /* @__PURE__ */ jsxs4("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
4052
+ return /* @__PURE__ */ jsxs5("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
3894
4053
  showPayPal && skeleton(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
3895
4054
  (showApplePay || showGooglePay) && skeleton(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
3896
- /* @__PURE__ */ jsx6(
4055
+ /* @__PURE__ */ jsx7(
3897
4056
  "button",
3898
4057
  {
3899
4058
  type: "button",
@@ -3933,10 +4092,10 @@ function InterimButtonsView({
3933
4092
  onMouseUp: (e) => {
3934
4093
  e.currentTarget.style.transform = "scale(1)";
3935
4094
  },
3936
- children: /* @__PURE__ */ jsx6(CardButtonContentSlot, { content: cardButtonContent })
4095
+ children: /* @__PURE__ */ jsx7(CardButtonContentSlot, { content: cardButtonContent })
3937
4096
  }
3938
4097
  ),
3939
- errorMessage && /* @__PURE__ */ jsxs4("div", { style: {
4098
+ errorMessage && /* @__PURE__ */ jsxs5("div", { style: {
3940
4099
  margin: "0.25rem 0",
3941
4100
  padding: "0.625rem 0.875rem",
3942
4101
  background: "#FEF2F2",
@@ -3950,21 +4109,21 @@ function InterimButtonsView({
3950
4109
  gap: "0.5rem",
3951
4110
  ...bStyles.errorBanner
3952
4111
  }, children: [
3953
- /* @__PURE__ */ jsx6("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx6("path", { d: "M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z", stroke: "#DC2626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }),
4112
+ /* @__PURE__ */ jsx7("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ jsx7("path", { d: "M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z", stroke: "#DC2626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }),
3954
4113
  errorMessage
3955
4114
  ] }),
3956
- /* @__PURE__ */ jsx6("style", { children: `@keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
4115
+ /* @__PURE__ */ jsx7("style", { children: `@keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
3957
4116
  ] });
3958
4117
  }
3959
4118
 
3960
4119
  // src/checkout-form.tsx
3961
4120
  import { FloPayError as FloPayError5 } from "@flopay/shared";
3962
- import { forwardRef as forwardRef2, useCallback as useCallback3, useEffect as useEffect5, useImperativeHandle as useImperativeHandle2, useState as useState4 } from "react";
3963
- import { Fragment as Fragment4, jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
4121
+ import { forwardRef as forwardRef2, useCallback as useCallback4, useEffect as useEffect6, useImperativeHandle as useImperativeHandle2, useState as useState5 } from "react";
4122
+ import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
3964
4123
  var WALLET_RESUME_KEY2 = "flopay_wallet_resume";
3965
4124
  var CheckoutForm = forwardRef2(
3966
4125
  function CheckoutForm2(props, ref) {
3967
- return /* @__PURE__ */ jsx7(CheckoutFormInner, { ...props, innerRef: ref });
4126
+ return /* @__PURE__ */ jsx8(CheckoutFormInner, { ...props, innerRef: ref });
3968
4127
  }
3969
4128
  );
3970
4129
  function CheckoutFormInner({
@@ -3993,27 +4152,27 @@ function CheckoutFormInner({
3993
4152
  const paypalFlopay = usePayPalFloPay();
3994
4153
  const elements = useElements();
3995
4154
  const contextBillingUrl = useBillingApiUrl();
3996
- const [processing, setProcessing] = useState4(false);
3997
- const [error, setError] = useState4(null);
3998
- const [is3DSActive, setIs3DSActive] = useState4(false);
4155
+ const [processing, setProcessing] = useState5(false);
4156
+ const [error, setError] = useState5(null);
4157
+ const [is3DSActive, setIs3DSActive] = useState5(false);
3999
4158
  const displayError = externalError ?? error;
4000
4159
  const isSubmitting = externalProcessing ?? processing;
4001
4160
  const isSelfContained = !onTokenizedBody;
4002
4161
  const baseUrl = (billingApiUrl || contextBillingUrl).replace(/\/+$/, "");
4003
- const updateError = useCallback3(
4162
+ const updateError = useCallback4(
4004
4163
  (err) => {
4005
4164
  setError(err);
4006
4165
  onErrorChange?.(err);
4007
4166
  },
4008
4167
  [onErrorChange]
4009
4168
  );
4010
- const emitDecline = useCallback3(
4169
+ const emitDecline = useCallback4(
4011
4170
  (input, overrides) => {
4012
4171
  onDecline?.(buildDeclineEvent("card", input, overrides));
4013
4172
  },
4014
4173
  [onDecline]
4015
4174
  );
4016
- const processPaymentInternal = useCallback3(
4175
+ const processPaymentInternal = useCallback4(
4017
4176
  async (tokenizedBody, completionPaymentMethodId) => {
4018
4177
  setProcessing(true);
4019
4178
  updateError(null);
@@ -4130,7 +4289,7 @@ function CheckoutFormInner({
4130
4289
  },
4131
4290
  [baseUrl, sessionId, userId, email, firstName, lastName, chv, flopay, paypalFlopay, onComplete, onError, onDecline, updateError, emitDecline]
4132
4291
  );
4133
- const dispatchTokenizedBody = useCallback3(
4292
+ const dispatchTokenizedBody = useCallback4(
4134
4293
  (tokenizedBody) => {
4135
4294
  if (onTokenizedBody) {
4136
4295
  onTokenizedBody(tokenizedBody);
@@ -4167,7 +4326,7 @@ function CheckoutFormInner({
4167
4326
  }
4168
4327
  }
4169
4328
  }), [flopay, dispatchTokenizedBody, onError, updateError, emitDecline]);
4170
- useEffect5(() => {
4329
+ useEffect6(() => {
4171
4330
  if (typeof window === "undefined") return;
4172
4331
  const stored = localStorage.getItem(WALLET_RESUME_KEY2);
4173
4332
  if (!stored) return;
@@ -4185,7 +4344,7 @@ function CheckoutFormInner({
4185
4344
  localStorage.removeItem(WALLET_RESUME_KEY2);
4186
4345
  }
4187
4346
  }, [sessionId, dispatchTokenizedBody]);
4188
- const handleSubmit = useCallback3(
4347
+ const handleSubmit = useCallback4(
4189
4348
  async (e) => {
4190
4349
  e.preventDefault();
4191
4350
  if (!flopay || !elements || isSubmitting) return;
@@ -4275,8 +4434,8 @@ function CheckoutFormInner({
4275
4434
  [flopay, elements, isSubmitting, sessionId, email, baseUrl, isSelfContained, dispatchTokenizedBody, onError, updateError, emitDecline]
4276
4435
  );
4277
4436
  const isReady = flopay !== null && elements !== null;
4278
- return /* @__PURE__ */ jsxs5("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
4279
- (is3DSActive || isSubmitting) && /* @__PURE__ */ jsx7("div", { "data-testid": "flopay-overlay", style: {
4437
+ return /* @__PURE__ */ jsxs6("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
4438
+ (is3DSActive || isSubmitting) && /* @__PURE__ */ jsx8("div", { "data-testid": "flopay-overlay", style: {
4280
4439
  position: "absolute",
4281
4440
  inset: 0,
4282
4441
  background: "rgba(255,255,255,0.7)",
@@ -4285,12 +4444,12 @@ function CheckoutFormInner({
4285
4444
  justifyContent: "center",
4286
4445
  zIndex: 10
4287
4446
  }, children: is3DSActive ? "Verifying payment..." : "Processing..." }),
4288
- !isReady && /* @__PURE__ */ jsx7("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." }),
4289
- isReady && /* @__PURE__ */ jsxs5(Fragment4, { children: [
4290
- /* @__PURE__ */ jsx7(PaymentElement, { options: { layout } }),
4291
- showAddress && /* @__PURE__ */ jsx7(AddressElement, { options: { mode: showAddress === true ? "billing" : showAddress } }),
4292
- displayError && /* @__PURE__ */ jsx7("div", { role: "alert", "data-testid": "flopay-error", style: { color: "red", margin: "0.75rem 0" }, children: displayError }),
4293
- children ?? /* @__PURE__ */ jsx7(
4447
+ !isReady && /* @__PURE__ */ jsx8("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." }),
4448
+ isReady && /* @__PURE__ */ jsxs6(Fragment4, { children: [
4449
+ /* @__PURE__ */ jsx8(PaymentElement, { options: { layout } }),
4450
+ showAddress && /* @__PURE__ */ jsx8(AddressElement, { options: { mode: showAddress === true ? "billing" : showAddress } }),
4451
+ displayError && /* @__PURE__ */ jsx8("div", { role: "alert", "data-testid": "flopay-error", style: { color: "red", margin: "0.75rem 0" }, children: displayError }),
4452
+ children ?? /* @__PURE__ */ jsx8(
4294
4453
  "button",
4295
4454
  {
4296
4455
  type: "submit",
@@ -4305,8 +4464,8 @@ function CheckoutFormInner({
4305
4464
 
4306
4465
  // src/paypal-button.tsx
4307
4466
  import { FloPayError as FloPayError6 } from "@flopay/shared";
4308
- import { useCallback as useCallback4, useEffect as useEffect6, useRef as useRef4, useState as useState5 } from "react";
4309
- import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
4467
+ import { useCallback as useCallback5, useEffect as useEffect7, useRef as useRef4, useState as useState6 } from "react";
4468
+ import { Fragment as Fragment5, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
4310
4469
  function PayPalButton({
4311
4470
  sessionId,
4312
4471
  billingApiUrl,
@@ -4323,11 +4482,11 @@ function PayPalButton({
4323
4482
  const flopay = useFloPay();
4324
4483
  const elements = useElements();
4325
4484
  const contextBillingUrl = useBillingApiUrl();
4326
- const [ready, setReady] = useState5(false);
4327
- const [submitting, setSubmitting] = useState5(false);
4485
+ const [ready, setReady] = useState6(false);
4486
+ const [submitting, setSubmitting] = useState6(false);
4328
4487
  const paypalResumeAttempted = useRef4(false);
4329
4488
  const baseUrl = (billingApiUrl || contextBillingUrl).replace(/\/+$/, "");
4330
- const processPaymentInternal = useCallback4(
4489
+ const processPaymentInternal = useCallback5(
4331
4490
  async (tokenizedBody) => {
4332
4491
  try {
4333
4492
  const response = await fetch(`${baseUrl}/v1/checkouts/sessions/process`, {
@@ -4360,7 +4519,7 @@ function PayPalButton({
4360
4519
  },
4361
4520
  [baseUrl, sessionId, userId, email, firstName, lastName, chv, onComplete, onErrorChange]
4362
4521
  );
4363
- const dispatchTokenizedBody = useCallback4(
4522
+ const dispatchTokenizedBody = useCallback5(
4364
4523
  (body) => {
4365
4524
  if (onTokenizedBody) {
4366
4525
  onTokenizedBody(body);
@@ -4370,7 +4529,7 @@ function PayPalButton({
4370
4529
  },
4371
4530
  [onTokenizedBody, processPaymentInternal]
4372
4531
  );
4373
- useEffect6(() => {
4532
+ useEffect7(() => {
4374
4533
  if (!flopay || paypalResumeAttempted.current) return;
4375
4534
  const params = new URLSearchParams(window.location.search);
4376
4535
  const paymentIntentId = params.get("payment_intent");
@@ -4418,7 +4577,7 @@ function PayPalButton({
4418
4577
  }
4419
4578
  })();
4420
4579
  }, [flopay, dispatchTokenizedBody, onErrorChange]);
4421
- const handlePayPalConfirm = useCallback4(async () => {
4580
+ const handlePayPalConfirm = useCallback5(async () => {
4422
4581
  if (!flopay || !elements) return;
4423
4582
  try {
4424
4583
  setSubmitting(true);
@@ -4451,11 +4610,11 @@ function PayPalButton({
4451
4610
  }
4452
4611
  }, [flopay, elements, sessionId, email, baseUrl, dispatchTokenizedBody, onErrorChange]);
4453
4612
  if (!flopay || !elements) {
4454
- return /* @__PURE__ */ jsx8("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6, animation: "pulse 1.5s infinite" } });
4613
+ return /* @__PURE__ */ jsx9("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6, animation: "pulse 1.5s infinite" } });
4455
4614
  }
4456
- return /* @__PURE__ */ jsxs6(Fragment5, { children: [
4457
- !ready && /* @__PURE__ */ jsx8("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6 } }),
4458
- /* @__PURE__ */ jsx8("div", { style: ready ? {} : { display: "none" }, children: /* @__PURE__ */ jsx8(
4615
+ return /* @__PURE__ */ jsxs7(Fragment5, { children: [
4616
+ !ready && /* @__PURE__ */ jsx9("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6 } }),
4617
+ /* @__PURE__ */ jsx9("div", { style: ready ? {} : { display: "none" }, children: /* @__PURE__ */ jsx9(
4459
4618
  "button",
4460
4619
  {
4461
4620
  type: "button",
@@ -4477,7 +4636,7 @@ function PayPalButton({
4477
4636
  children: submitting ? "Processing..." : "PayPal"
4478
4637
  }
4479
4638
  ) }),
4480
- (submitting || isProcessing) && /* @__PURE__ */ jsx8("div", { style: {
4639
+ (submitting || isProcessing) && /* @__PURE__ */ jsx9("div", { style: {
4481
4640
  position: "fixed",
4482
4641
  inset: 0,
4483
4642
  background: "rgba(0,0,0,0.4)",
@@ -4485,7 +4644,7 @@ function PayPalButton({
4485
4644
  alignItems: "center",
4486
4645
  justifyContent: "center",
4487
4646
  zIndex: 1e3
4488
- }, children: /* @__PURE__ */ jsx8("div", { style: {
4647
+ }, children: /* @__PURE__ */ jsx9("div", { style: {
4489
4648
  background: "white",
4490
4649
  borderRadius: 8,
4491
4650
  padding: "1.5rem",
@@ -4497,10 +4656,10 @@ function PayPalButton({
4497
4656
  }
4498
4657
 
4499
4658
  // src/automatic-payment-button.tsx
4500
- import { useCallback as useCallback5, useEffect as useEffect7, useMemo as useMemo4, useRef as useRef5, useState as useState6 } from "react";
4659
+ import { useCallback as useCallback6, useEffect as useEffect8, useMemo as useMemo4, useRef as useRef5, useState as useState7 } from "react";
4501
4660
  import { PaymentAPI as PaymentAPI3 } from "@flopay/js";
4502
4661
  import { FloPayError as FloPayError7, resolveBillingApiUrl as resolveBillingApiUrl4, resolveButtonsLayoutTheme as resolveButtonsLayoutTheme3 } from "@flopay/shared";
4503
- import { Fragment as Fragment6, jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
4662
+ import { Fragment as Fragment6, jsx as jsx10, jsxs as jsxs8 } from "react/jsx-runtime";
4504
4663
  var DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT3 = 44;
4505
4664
  var PAYPAL_RESUME_STORAGE_KEY2 = "flopay_automatic_payment_button_resume";
4506
4665
  function sleep2(ms) {
@@ -4647,10 +4806,10 @@ function FloPayAutomaticPaymentButton({
4647
4806
  utmMetadata
4648
4807
  ]
4649
4808
  );
4650
- const [isProcessing, setIsProcessing] = useState6(false);
4651
- const [overlayStatus, setOverlayStatus] = useState6(null);
4652
- const [overlayError, setOverlayError] = useState6(null);
4653
- const [fallbackSession, setFallbackSession] = useState6(null);
4809
+ const [isProcessing, setIsProcessing] = useState7(false);
4810
+ const [overlayStatus, setOverlayStatus] = useState7(null);
4811
+ const [overlayError, setOverlayError] = useState7(null);
4812
+ const [fallbackSession, setFallbackSession] = useState7(null);
4654
4813
  const automaticPaymentToken = useMemo4(
4655
4814
  () => paymentMethodId ? {
4656
4815
  id: paymentMethodId,
@@ -4665,25 +4824,25 @@ function FloPayAutomaticPaymentButton({
4665
4824
  const onSuccessRef = useRef5(onSuccess);
4666
4825
  const onErrorRef = useRef5(onError);
4667
4826
  const onDeclineRef = useRef5(onDecline);
4668
- useEffect7(() => {
4827
+ useEffect8(() => {
4669
4828
  fallbackSessionRef.current = fallbackSession;
4670
4829
  }, [fallbackSession]);
4671
- useEffect7(() => {
4830
+ useEffect8(() => {
4672
4831
  onSuccessRef.current = onSuccess;
4673
4832
  }, [onSuccess]);
4674
- useEffect7(() => {
4833
+ useEffect8(() => {
4675
4834
  onErrorRef.current = onError;
4676
4835
  }, [onError]);
4677
- useEffect7(() => {
4836
+ useEffect8(() => {
4678
4837
  onDeclineRef.current = onDecline;
4679
4838
  }, [onDecline]);
4680
- useEffect7(() => {
4839
+ useEffect8(() => {
4681
4840
  isMountedRef.current = true;
4682
4841
  return () => {
4683
4842
  isMountedRef.current = false;
4684
4843
  };
4685
4844
  }, []);
4686
- useEffect7(() => {
4845
+ useEffect8(() => {
4687
4846
  if (!fallbackSession || typeof window === "undefined") {
4688
4847
  return;
4689
4848
  }
@@ -4697,13 +4856,13 @@ function FloPayAutomaticPaymentButton({
4697
4856
  window.removeEventListener("keydown", handleKeyDown);
4698
4857
  };
4699
4858
  }, [fallbackSession]);
4700
- const emitDecline = useCallback5((error, method = DEFAULT_SAVED_PAYMENT_DECLINE_METHOD) => {
4859
+ const emitDecline = useCallback6((error, method = DEFAULT_SAVED_PAYMENT_DECLINE_METHOD) => {
4701
4860
  onDeclineRef.current?.(buildDeclineEvent(method, error, {
4702
4861
  code: error.code,
4703
4862
  declineCode: error.declineCode
4704
4863
  }));
4705
4864
  }, []);
4706
- const showSuccess = useCallback5(async (event) => {
4865
+ const showSuccess = useCallback6(async (event) => {
4707
4866
  if (!isMountedRef.current) return;
4708
4867
  setOverlayError(null);
4709
4868
  setOverlayStatus("success");
@@ -4711,7 +4870,7 @@ function FloPayAutomaticPaymentButton({
4711
4870
  if (!isMountedRef.current) return;
4712
4871
  onSuccessRef.current?.(event);
4713
4872
  }, []);
4714
- const showError = useCallback5(async (error, options) => {
4873
+ const showError = useCallback6(async (error, options) => {
4715
4874
  if (!isMountedRef.current) return;
4716
4875
  onErrorRef.current?.(error);
4717
4876
  if (options?.emitDecline) {
@@ -4721,7 +4880,7 @@ function FloPayAutomaticPaymentButton({
4721
4880
  setOverlayStatus("error");
4722
4881
  await sleep2(PROCESSING_OVERLAY_ERROR_DELAY_MS);
4723
4882
  }, [emitDecline]);
4724
- const processResolvedSession = useCallback5(async (apiResult, resolvedSessionId, options) => {
4883
+ const processResolvedSession = useCallback6(async (apiResult, resolvedSessionId, options) => {
4725
4884
  const session = apiResult.data.session ?? null;
4726
4885
  if (!session) {
4727
4886
  throw new FloPayError7("No session data returned", "api_error");
@@ -4888,6 +5047,14 @@ function FloPayAutomaticPaymentButton({
4888
5047
  if (floPayErr.code === "payment_intent_unexpected_state" && inResumeWindow) {
4889
5048
  return;
4890
5049
  }
5050
+ const isSilentFallbackCase = (floPayErr.code === "paypal_requires_user_interaction" || floPayErr.code === "payment_intent_unexpected_state") && shouldShowFallbackCheckout(floPayErr, fallbackSessionId) && !!fallbackSessionId && isMountedRef.current;
5051
+ if (isSilentFallbackCase) {
5052
+ setFallbackSession({
5053
+ sessionId: fallbackSessionId,
5054
+ errorMessage: ""
5055
+ });
5056
+ return;
5057
+ }
4891
5058
  await showError(floPayErr, {
4892
5059
  emitDecline: true,
4893
5060
  method: floPayErr.checkoutMethod ?? DEFAULT_SAVED_PAYMENT_DECLINE_METHOD
@@ -4908,7 +5075,7 @@ function FloPayAutomaticPaymentButton({
4908
5075
  showError,
4909
5076
  showSuccess
4910
5077
  ]);
4911
- const handleButtonClick = useCallback5(async (event) => {
5078
+ const handleButtonClick = useCallback6(async (event) => {
4912
5079
  buttonProps.onClick?.(event);
4913
5080
  if (event.defaultPrevented || disabled || isProcessing) {
4914
5081
  return;
@@ -4990,7 +5157,7 @@ function FloPayAutomaticPaymentButton({
4990
5157
  showError,
4991
5158
  showSuccess
4992
5159
  ]);
4993
- const handleFallbackComplete = useCallback5((result) => {
5160
+ const handleFallbackComplete = useCallback6((result) => {
4994
5161
  const activeFallback = fallbackSessionRef.current;
4995
5162
  setFallbackSession(null);
4996
5163
  onSuccessRef.current?.({
@@ -5000,13 +5167,13 @@ function FloPayAutomaticPaymentButton({
5000
5167
  autoCompleted: false
5001
5168
  });
5002
5169
  }, []);
5003
- const handleFallbackError = useCallback5((error) => {
5170
+ const handleFallbackError = useCallback6((error) => {
5004
5171
  onErrorRef.current?.(error);
5005
5172
  }, []);
5006
- const handleFallbackDecline = useCallback5((decline) => {
5173
+ const handleFallbackDecline = useCallback6((decline) => {
5007
5174
  onDeclineRef.current?.(decline);
5008
5175
  }, []);
5009
- useEffect7(() => {
5176
+ useEffect8(() => {
5010
5177
  if (typeof window === "undefined" || resumeAttemptedRef.current) {
5011
5178
  return;
5012
5179
  }
@@ -5147,8 +5314,8 @@ function FloPayAutomaticPaymentButton({
5147
5314
  };
5148
5315
  }, [buttonsTheme, stylesOverride]);
5149
5316
  const cardButtonSizing = children === void 0 ? { boxSizing: "border-box", height: DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT3, padding: "0 1rem" } : { padding: "0.9rem 1rem" };
5150
- return /* @__PURE__ */ jsxs7(Fragment6, { children: [
5151
- /* @__PURE__ */ jsx9(
5317
+ return /* @__PURE__ */ jsxs8(Fragment6, { children: [
5318
+ /* @__PURE__ */ jsx10(
5152
5319
  "button",
5153
5320
  {
5154
5321
  ...buttonProps,
@@ -5189,17 +5356,17 @@ function FloPayAutomaticPaymentButton({
5189
5356
  e.currentTarget.style.transform = "scale(1)";
5190
5357
  }
5191
5358
  },
5192
- children: /* @__PURE__ */ jsx9(CardButtonContentSlot, { content: children })
5359
+ children: /* @__PURE__ */ jsx10(CardButtonContentSlot, { content: children })
5193
5360
  }
5194
5361
  ),
5195
- overlayStatus && /* @__PURE__ */ jsx9(
5362
+ overlayStatus && /* @__PURE__ */ jsx10(
5196
5363
  ProcessingOverlay,
5197
5364
  {
5198
5365
  status: overlayStatus,
5199
5366
  errorMessage: overlayError
5200
5367
  }
5201
5368
  ),
5202
- fallbackSession && /* @__PURE__ */ jsx9(
5369
+ fallbackSession && /* @__PURE__ */ jsx10(
5203
5370
  "div",
5204
5371
  {
5205
5372
  "data-testid": "flopay-automatic-payment-fallback",
@@ -5220,7 +5387,7 @@ function FloPayAutomaticPaymentButton({
5220
5387
  padding: "1.5rem",
5221
5388
  zIndex: 1100
5222
5389
  },
5223
- children: /* @__PURE__ */ jsx9(
5390
+ children: /* @__PURE__ */ jsx10(
5224
5391
  "div",
5225
5392
  {
5226
5393
  style: {
@@ -5236,7 +5403,7 @@ function FloPayAutomaticPaymentButton({
5236
5403
  flexDirection: "column",
5237
5404
  gap: "1rem"
5238
5405
  },
5239
- children: /* @__PURE__ */ jsx9(
5406
+ children: /* @__PURE__ */ jsx10(
5240
5407
  FloPayCheckout,
5241
5408
  {
5242
5409
  sessionId: fallbackSession.sessionId,
@@ -5266,9 +5433,11 @@ export {
5266
5433
  FloPayAutomaticPaymentButton,
5267
5434
  FloPayCheckout,
5268
5435
  FloPayProvider,
5436
+ InAppBrowserNotice,
5269
5437
  PayPalButton,
5270
5438
  PaymentElement,
5271
5439
  SplitCardForm,
5440
+ isInAppBrowser,
5272
5441
  useCheckout,
5273
5442
  useElements,
5274
5443
  useFloPay,