@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.cjs CHANGED
@@ -39,9 +39,11 @@ __export(index_exports, {
39
39
  FloPayAutomaticPaymentButton: () => FloPayAutomaticPaymentButton,
40
40
  FloPayCheckout: () => FloPayCheckout,
41
41
  FloPayProvider: () => FloPayProvider,
42
+ InAppBrowserNotice: () => InAppBrowserNotice,
42
43
  PayPalButton: () => PayPalButton,
43
44
  PaymentElement: () => PaymentElement,
44
45
  SplitCardForm: () => SplitCardForm,
46
+ isInAppBrowser: () => isInAppBrowser,
45
47
  useCheckout: () => useCheckout,
46
48
  useElements: () => useElements,
47
49
  useFloPay: () => useFloPay,
@@ -151,7 +153,7 @@ function FloPayProvider({
151
153
  }
152
154
 
153
155
  // src/flopay-checkout.tsx
154
- var import_react8 = __toESM(require("react"), 1);
156
+ var import_react9 = __toESM(require("react"), 1);
155
157
  var import_js2 = require("@flopay/js");
156
158
  var import_shared7 = require("@flopay/shared");
157
159
 
@@ -285,7 +287,7 @@ var AddressElement = createElementComponent("address", "AddressElement");
285
287
  // src/split-card-form.tsx
286
288
  var import_react_stripe_js = require("@stripe/react-stripe-js");
287
289
  var import_shared4 = require("@flopay/shared");
288
- var import_react7 = require("react");
290
+ var import_react8 = require("react");
289
291
 
290
292
  // src/hooks.ts
291
293
  var import_react5 = require("react");
@@ -658,9 +660,119 @@ function wasSessionRecentlyCompleted(sessionId) {
658
660
  }
659
661
  }
660
662
 
663
+ // src/in-app-browser-notice.tsx
664
+ var import_react7 = require("react");
665
+
666
+ // src/in-app-browser.ts
667
+ function isInAppBrowser(userAgent) {
668
+ const ua = userAgent ?? (typeof navigator !== "undefined" ? navigator.userAgent : "");
669
+ if (!ua) return false;
670
+ if (/FBAN|FBAV|FB_IAB|FBIOS|Instagram|musical_ly|BytedanceWebview|TikTok/i.test(ua)) {
671
+ return true;
672
+ }
673
+ if (/Twitter|Snapchat|Pinterest|LinkedInApp|Line\/|MicroMessenger|GSA\//i.test(ua)) {
674
+ return true;
675
+ }
676
+ if (/Android.*;\s?wv\)/.test(ua)) return true;
677
+ if (/(iPhone|iPad|iPod).*AppleWebKit(?!.*Safari)/.test(ua)) return true;
678
+ return false;
679
+ }
680
+
681
+ // src/in-app-browser-notice.tsx
682
+ var import_jsx_runtime5 = require("react/jsx-runtime");
683
+ 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.";
684
+ function InAppBrowserNotice({
685
+ message,
686
+ openButtonLabel,
687
+ copiedButtonLabel,
688
+ containerStyle,
689
+ buttonStyle,
690
+ onOpenInBrowser
691
+ }) {
692
+ const [copied, setCopied] = (0, import_react7.useState)(false);
693
+ const [inAppBrowser, setInAppBrowser] = (0, import_react7.useState)(false);
694
+ (0, import_react7.useEffect)(() => {
695
+ setInAppBrowser(isInAppBrowser());
696
+ }, []);
697
+ const defaultOpenLabel = inAppBrowser ? "Copy link" : "Open in browser";
698
+ const defaultCopiedLabel = inAppBrowser ? "Link copied \u2014 open Safari/Chrome and paste" : "Link copied \u2014 paste in your browser";
699
+ const effectiveOpenLabel = openButtonLabel ?? defaultOpenLabel;
700
+ const effectiveCopiedLabel = copiedButtonLabel ?? defaultCopiedLabel;
701
+ const handleClick = (0, import_react7.useCallback)(async () => {
702
+ if (typeof window === "undefined") return;
703
+ const url = window.location.href;
704
+ let opened = false;
705
+ if (!inAppBrowser) {
706
+ try {
707
+ const win = window.open(url, "_blank");
708
+ opened = !!win;
709
+ } catch {
710
+ opened = false;
711
+ }
712
+ }
713
+ let didCopy = false;
714
+ if (!opened) {
715
+ if (typeof navigator !== "undefined" && typeof navigator.clipboard?.writeText === "function") {
716
+ try {
717
+ await navigator.clipboard.writeText(url);
718
+ didCopy = true;
719
+ setCopied(true);
720
+ } catch {
721
+ didCopy = false;
722
+ }
723
+ }
724
+ }
725
+ onOpenInBrowser?.({ opened, copied: didCopy });
726
+ }, [inAppBrowser, onOpenInBrowser]);
727
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
728
+ "div",
729
+ {
730
+ role: "status",
731
+ "data-testid": "flopay-in-app-browser-notice",
732
+ style: {
733
+ marginTop: "0.75rem",
734
+ padding: "0.75rem 0.875rem",
735
+ background: "#FFFBEB",
736
+ border: "1px solid #FDE68A",
737
+ borderRadius: 8,
738
+ color: "#92400E",
739
+ fontSize: "0.85rem",
740
+ lineHeight: 1.4,
741
+ display: "flex",
742
+ flexDirection: "column",
743
+ gap: "0.5rem",
744
+ ...containerStyle
745
+ },
746
+ children: [
747
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: message ?? DEFAULT_MESSAGE }),
748
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
749
+ "button",
750
+ {
751
+ type: "button",
752
+ onClick: handleClick,
753
+ style: {
754
+ alignSelf: "flex-start",
755
+ padding: "0.4rem 0.75rem",
756
+ background: "transparent",
757
+ border: "1px solid #92400E",
758
+ borderRadius: 6,
759
+ color: "#92400E",
760
+ fontSize: "0.85rem",
761
+ fontWeight: 600,
762
+ cursor: "pointer",
763
+ ...buttonStyle
764
+ },
765
+ children: copied ? effectiveCopiedLabel : effectiveOpenLabel
766
+ }
767
+ )
768
+ ]
769
+ }
770
+ );
771
+ }
772
+
661
773
  // src/split-card-form.tsx
662
774
  var import_shared5 = require("@flopay/shared");
663
- var import_jsx_runtime5 = require("react/jsx-runtime");
775
+ var import_jsx_runtime6 = require("react/jsx-runtime");
664
776
  var WALLET_RESUME_KEY = "flopay_wallet_resume";
665
777
  var FLOPAY_KEYFRAMES = `
666
778
  @keyframes flopay-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
@@ -702,7 +814,7 @@ function normalizeBeforeButtonClickError(method, err) {
702
814
  );
703
815
  }
704
816
  function FloPayKeyframes() {
705
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("style", { children: FLOPAY_KEYFRAMES });
817
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("style", { children: FLOPAY_KEYFRAMES });
706
818
  }
707
819
  function toCssSize(value) {
708
820
  if (typeof value === "number") return `${value}px`;
@@ -722,9 +834,9 @@ function ExpressCheckoutReadySwap({
722
834
  placeholderTestId,
723
835
  children
724
836
  }) {
725
- if (state === "unavailable") return null;
726
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { position: "relative", minHeight: 44 }, children: [
727
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
837
+ if (state === "unavailable" || state === "load_error") return null;
838
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { position: "relative", minHeight: 44 }, children: [
839
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
728
840
  "div",
729
841
  {
730
842
  "data-testid": placeholderTestId,
@@ -743,7 +855,7 @@ function ExpressCheckoutReadySwap({
743
855
  }
744
856
  }
745
857
  ),
746
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
858
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
747
859
  "div",
748
860
  {
749
861
  style: {
@@ -758,9 +870,9 @@ function ExpressCheckoutReadySwap({
758
870
  )
759
871
  ] });
760
872
  }
761
- var SplitCardForm = (0, import_react7.forwardRef)(
873
+ var SplitCardForm = (0, import_react8.forwardRef)(
762
874
  function SplitCardForm2(props, ref) {
763
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SplitCardFormInner, { ...props, innerRef: ref });
875
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SplitCardFormInner, { ...props, innerRef: ref });
764
876
  }
765
877
  );
766
878
  function PayPalButtonInner({
@@ -772,16 +884,24 @@ function PayPalButtonInner({
772
884
  isProcessing = false,
773
885
  onButtonClick,
774
886
  onDecline,
775
- runBeforeButtonClick
887
+ runBeforeButtonClick,
888
+ onLoadStateChange
776
889
  }) {
777
890
  const stripe = (0, import_react_stripe_js.useStripe)();
778
891
  const elements = (0, import_react_stripe_js.useElements)();
779
- const [loadState, setLoadState] = (0, import_react7.useState)("loading");
780
- const [submitting, setSubmitting] = (0, import_react7.useState)(false);
781
- const paypalResumeAttempted = (0, import_react7.useRef)(false);
782
- const beforeClickRef = (0, import_react7.useRef)(null);
892
+ const [loadState, setLoadState] = (0, import_react8.useState)("loading");
893
+ const onLoadStateChangeRef = (0, import_react8.useRef)(onLoadStateChange);
894
+ (0, import_react8.useEffect)(() => {
895
+ onLoadStateChangeRef.current = onLoadStateChange;
896
+ }, [onLoadStateChange]);
897
+ (0, import_react8.useEffect)(() => {
898
+ onLoadStateChangeRef.current?.(loadState);
899
+ }, [loadState]);
900
+ const [submitting, setSubmitting] = (0, import_react8.useState)(false);
901
+ const paypalResumeAttempted = (0, import_react8.useRef)(false);
902
+ const beforeClickRef = (0, import_react8.useRef)(null);
783
903
  const baseUrl = billingApiUrl.replace(/\/+$/, "");
784
- (0, import_react7.useEffect)(() => {
904
+ (0, import_react8.useEffect)(() => {
785
905
  if (!stripe || paypalResumeAttempted.current) return;
786
906
  const params = new URLSearchParams(window.location.search);
787
907
  const paymentIntentId = params.get("payment_intent");
@@ -828,7 +948,7 @@ function PayPalButtonInner({
828
948
  }
829
949
  })();
830
950
  }, [stripe, onTokenizedBody, onErrorChange, onDecline]);
831
- const handlePayPalClick = (0, import_react7.useCallback)(async (event) => {
951
+ const handlePayPalClick = (0, import_react8.useCallback)(async (event) => {
832
952
  if (isProcessing || submitting) {
833
953
  event.reject();
834
954
  return;
@@ -846,7 +966,7 @@ function PayPalButtonInner({
846
966
  onButtonClick?.("paypal");
847
967
  event.resolve();
848
968
  }, [isProcessing, onButtonClick, runBeforeButtonClick, submitting]);
849
- const handlePayPalConfirm = (0, import_react7.useCallback)(async (event) => {
969
+ const handlePayPalConfirm = (0, import_react8.useCallback)(async (event) => {
850
970
  if (!stripe || !elements) return;
851
971
  let prepared = beforeClickRef.current;
852
972
  beforeClickRef.current = null;
@@ -938,12 +1058,12 @@ function PayPalButtonInner({
938
1058
  setSubmitting(false);
939
1059
  }
940
1060
  }, [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange, onDecline, runBeforeButtonClick]);
941
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
942
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ExpressCheckoutReadySwap, { state: loadState, placeholderTestId: "flopay-paypal-placeholder", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1061
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1062
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ExpressCheckoutReadySwap, { state: loadState, placeholderTestId: "flopay-paypal-placeholder", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
943
1063
  import_react_stripe_js.ExpressCheckoutElement,
944
1064
  {
945
1065
  onReady: (event) => setLoadState(resolveExpressCheckoutLoadState(event, ["paypal"])),
946
- onLoadError: () => setLoadState("unavailable"),
1066
+ onLoadError: () => setLoadState("load_error"),
947
1067
  onClick: handlePayPalClick,
948
1068
  onConfirm: handlePayPalConfirm,
949
1069
  onCancel: () => {
@@ -964,7 +1084,7 @@ function PayPalButtonInner({
964
1084
  }
965
1085
  }
966
1086
  ) }),
967
- submitting && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ProcessingOverlay, { status: "processing" })
1087
+ submitting && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ProcessingOverlay, { status: "processing" })
968
1088
  ] });
969
1089
  }
970
1090
  function WalletButtonInner({
@@ -977,16 +1097,24 @@ function WalletButtonInner({
977
1097
  onErrorChange,
978
1098
  onButtonClick,
979
1099
  onDecline,
980
- runBeforeButtonClick
1100
+ runBeforeButtonClick,
1101
+ onLoadStateChange
981
1102
  }) {
982
1103
  const stripe = (0, import_react_stripe_js.useStripe)();
983
1104
  const elements = (0, import_react_stripe_js.useElements)();
984
- const [loadState, setLoadState] = (0, import_react7.useState)("loading");
985
- const [submitting, setSubmitting] = (0, import_react7.useState)(false);
1105
+ const [loadState, setLoadState] = (0, import_react8.useState)("loading");
1106
+ const onLoadStateChangeRef = (0, import_react8.useRef)(onLoadStateChange);
1107
+ (0, import_react8.useEffect)(() => {
1108
+ onLoadStateChangeRef.current = onLoadStateChange;
1109
+ }, [onLoadStateChange]);
1110
+ (0, import_react8.useEffect)(() => {
1111
+ onLoadStateChangeRef.current?.(loadState);
1112
+ }, [loadState]);
1113
+ const [submitting, setSubmitting] = (0, import_react8.useState)(false);
986
1114
  const baseUrl = billingApiUrl.replace(/\/+$/, "");
987
- const lastWalletMethodRef = (0, import_react7.useRef)("card");
988
- const beforeClickRef = (0, import_react7.useRef)(null);
989
- const handleWalletConfirm = (0, import_react7.useCallback)(
1115
+ const lastWalletMethodRef = (0, import_react8.useRef)("card");
1116
+ const beforeClickRef = (0, import_react8.useRef)(null);
1117
+ const handleWalletConfirm = (0, import_react8.useCallback)(
990
1118
  async (event) => {
991
1119
  if (!stripe || !elements) return;
992
1120
  const walletType = event.expressPaymentType;
@@ -1075,12 +1203,12 @@ function WalletButtonInner({
1075
1203
  },
1076
1204
  [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange, onDecline, runBeforeButtonClick]
1077
1205
  );
1078
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1079
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ExpressCheckoutReadySwap, { state: loadState, placeholderTestId: "flopay-wallet-placeholder", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1206
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
1207
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ExpressCheckoutReadySwap, { state: loadState, placeholderTestId: "flopay-wallet-placeholder", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1080
1208
  import_react_stripe_js.ExpressCheckoutElement,
1081
1209
  {
1082
1210
  onReady: (event) => setLoadState(resolveExpressCheckoutLoadState(event, ["applePay", "googlePay"])),
1083
- onLoadError: () => setLoadState("unavailable"),
1211
+ onLoadError: () => setLoadState("load_error"),
1084
1212
  onClick: async (event) => {
1085
1213
  lastWalletMethodRef.current = event.expressPaymentType === "apple_pay" ? "apple_pay" : "google_pay";
1086
1214
  const beforeClick = runBeforeButtonClick ? await runBeforeButtonClick(lastWalletMethodRef.current) : { proceed: true };
@@ -1115,7 +1243,7 @@ function WalletButtonInner({
1115
1243
  }
1116
1244
  }
1117
1245
  ) }),
1118
- submitting && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ProcessingOverlay, { status: "processing" })
1246
+ submitting && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ProcessingOverlay, { status: "processing" })
1119
1247
  ] });
1120
1248
  }
1121
1249
  function SplitCardFormInner({
@@ -1172,49 +1300,49 @@ function SplitCardFormInner({
1172
1300
  const flopay = useFloPay();
1173
1301
  const paypalFlopay = usePayPalFloPay();
1174
1302
  const elements = useElements();
1175
- const checkout = (0, import_react7.useContext)(CheckoutContext);
1303
+ const checkout = (0, import_react8.useContext)(CheckoutContext);
1176
1304
  const contextBillingUrl = useBillingApiUrl();
1177
- const [processing, setProcessing] = (0, import_react7.useState)(false);
1178
- const [error, setError] = (0, import_react7.useState)(null);
1179
- const [is3DSActive, setIs3DSActive] = (0, import_react7.useState)(false);
1180
- const [selectedCountry, setSelectedCountry] = (0, import_react7.useState)(countryProp ?? "US");
1181
- const [zipCode, setZipCode] = (0, import_react7.useState)(zipProp ?? "");
1182
- const [addressLine1, setAddressLine1] = (0, import_react7.useState)(addressLine1Prop ?? "");
1183
- const [addressLine2, setAddressLine2] = (0, import_react7.useState)(addressLine2Prop ?? "");
1184
- const [city, setCity] = (0, import_react7.useState)(cityProp ?? "");
1185
- const [stateValue, setStateValue] = (0, import_react7.useState)(stateProp ?? "");
1186
- const [accountPatch, setAccountPatch] = (0, import_react7.useState)({});
1187
- const zipCodeRef = (0, import_react7.useRef)(zipProp ?? "");
1188
- const selectedCountryRef = (0, import_react7.useRef)(countryProp ?? "US");
1189
- const addressLine1Ref = (0, import_react7.useRef)(addressLine1Prop ?? "");
1190
- const addressLine2Ref = (0, import_react7.useRef)(addressLine2Prop ?? "");
1191
- const cityRef = (0, import_react7.useRef)(cityProp ?? "");
1192
- const stateRef = (0, import_react7.useRef)(stateProp ?? "");
1193
- const avsConfig = (0, import_react7.useMemo)(() => (0, import_shared4.resolveAVSConfig)(enableAVSProp), [enableAVSProp]);
1305
+ const [processing, setProcessing] = (0, import_react8.useState)(false);
1306
+ const [error, setError] = (0, import_react8.useState)(null);
1307
+ const [is3DSActive, setIs3DSActive] = (0, import_react8.useState)(false);
1308
+ const [selectedCountry, setSelectedCountry] = (0, import_react8.useState)(countryProp ?? "US");
1309
+ const [zipCode, setZipCode] = (0, import_react8.useState)(zipProp ?? "");
1310
+ const [addressLine1, setAddressLine1] = (0, import_react8.useState)(addressLine1Prop ?? "");
1311
+ const [addressLine2, setAddressLine2] = (0, import_react8.useState)(addressLine2Prop ?? "");
1312
+ const [city, setCity] = (0, import_react8.useState)(cityProp ?? "");
1313
+ const [stateValue, setStateValue] = (0, import_react8.useState)(stateProp ?? "");
1314
+ const [accountPatch, setAccountPatch] = (0, import_react8.useState)({});
1315
+ const zipCodeRef = (0, import_react8.useRef)(zipProp ?? "");
1316
+ const selectedCountryRef = (0, import_react8.useRef)(countryProp ?? "US");
1317
+ const addressLine1Ref = (0, import_react8.useRef)(addressLine1Prop ?? "");
1318
+ const addressLine2Ref = (0, import_react8.useRef)(addressLine2Prop ?? "");
1319
+ const cityRef = (0, import_react8.useRef)(cityProp ?? "");
1320
+ const stateRef = (0, import_react8.useRef)(stateProp ?? "");
1321
+ const avsConfig = (0, import_react8.useMemo)(() => (0, import_shared4.resolveAVSConfig)(enableAVSProp), [enableAVSProp]);
1194
1322
  const enableAVS = avsConfig !== null;
1195
- const [viewState, setViewState] = (0, import_react7.useState)(initialCardOpen ? "card" : "buttons");
1323
+ const [viewState, setViewState] = (0, import_react8.useState)(initialCardOpen ? "card" : "buttons");
1196
1324
  const showCardForm = viewState === "expanding" || viewState === "card";
1197
1325
  const TRANSITION_MS = 280;
1198
- const expandToCard = (0, import_react7.useCallback)(() => {
1326
+ const expandToCard = (0, import_react8.useCallback)(() => {
1199
1327
  setViewState("expanding");
1200
1328
  setTimeout(() => setViewState("card"), TRANSITION_MS);
1201
1329
  }, []);
1202
- const collapseToButtons = (0, import_react7.useCallback)(() => {
1330
+ const collapseToButtons = (0, import_react8.useCallback)(() => {
1203
1331
  setViewState("collapsing");
1204
1332
  setTimeout(() => setViewState("buttons"), TRANSITION_MS);
1205
1333
  }, []);
1206
- (0, import_react7.useEffect)(() => {
1334
+ (0, import_react8.useEffect)(() => {
1207
1335
  if (layout === "buttons" && initialCardOpen) {
1208
1336
  setViewState("card");
1209
1337
  }
1210
1338
  }, [layout, initialCardOpen]);
1211
- const [fullName, setFullName] = (0, import_react7.useState)("");
1212
- const [formReady, setFormReady] = (0, import_react7.useState)(false);
1213
- const [overlayStatus, setOverlayStatus] = (0, import_react7.useState)(null);
1214
- const processingRef = (0, import_react7.useRef)(false);
1339
+ const [fullName, setFullName] = (0, import_react8.useState)("");
1340
+ const [formReady, setFormReady] = (0, import_react8.useState)(false);
1341
+ const [overlayStatus, setOverlayStatus] = (0, import_react8.useState)(null);
1342
+ const processingRef = (0, import_react8.useRef)(false);
1215
1343
  const resolvedBillingApiUrl = billingApiUrl || contextBillingUrl;
1216
1344
  const displayError = externalError ?? error;
1217
- const bStyles = (0, import_react7.useMemo)(() => {
1345
+ const bStyles = (0, import_react8.useMemo)(() => {
1218
1346
  const base = (0, import_shared4.resolveButtonsLayoutTheme)(buttonsTheme);
1219
1347
  if (!buttonsStylesOverride) return base;
1220
1348
  return {
@@ -1232,7 +1360,7 @@ function SplitCardFormInner({
1232
1360
  const isSubmitting = (externalProcessing ?? processing) || isInlineSessionPatchProcessing;
1233
1361
  const isSelfContained = !onTokenizedBody;
1234
1362
  const baseUrl = resolvedBillingApiUrl.replace(/\/+$/, "");
1235
- const resolvedAccount = (0, import_react7.useMemo)(() => mergeAccountPatch({
1363
+ const resolvedAccount = (0, import_react8.useMemo)(() => mergeAccountPatch({
1236
1364
  userId,
1237
1365
  email,
1238
1366
  firstName,
@@ -1240,51 +1368,62 @@ function SplitCardFormInner({
1240
1368
  country: countryProp,
1241
1369
  zip: zipProp
1242
1370
  }, accountPatch), [userId, email, firstName, lastName, countryProp, zipProp, accountPatch]);
1243
- const stripeInstance = (0, import_react7.useMemo)(() => {
1371
+ const stripeInstance = (0, import_react8.useMemo)(() => {
1244
1372
  if (!flopay) return null;
1245
1373
  return flopay.getRawProvider();
1246
1374
  }, [flopay]);
1247
- const paypalStripeInstance = (0, import_react7.useMemo)(() => {
1375
+ const paypalStripeInstance = (0, import_react8.useMemo)(() => {
1248
1376
  if (!paypalFlopay) return null;
1249
1377
  return paypalFlopay.getRawProvider();
1250
1378
  }, [paypalFlopay]);
1251
1379
  const amountInCents = totalAmount || 100;
1252
- const walletOptions = (0, import_react7.useMemo)(() => ({
1380
+ const walletOptions = (0, import_react8.useMemo)(() => ({
1253
1381
  mode: "payment",
1254
1382
  amount: amountInCents,
1255
1383
  currency: currency.toLowerCase(),
1256
1384
  paymentMethodCreation: "manual",
1257
1385
  captureMethod: "manual"
1258
1386
  }), [amountInCents, currency]);
1259
- const paypalOptions = (0, import_react7.useMemo)(() => ({
1387
+ const paypalOptions = (0, import_react8.useMemo)(() => ({
1260
1388
  mode: "payment",
1261
1389
  amount: amountInCents,
1262
1390
  currency: currency.toLowerCase(),
1263
1391
  captureMethod: "manual",
1264
1392
  setupFutureUsage: "off_session"
1265
1393
  }), [amountInCents, currency]);
1266
- const updateError = (0, import_react7.useCallback)(
1394
+ const updateError = (0, import_react8.useCallback)(
1267
1395
  (err) => {
1268
1396
  setError(err);
1269
1397
  onErrorChange?.(err);
1270
1398
  },
1271
1399
  [onErrorChange]
1272
1400
  );
1273
- const emitDecline = (0, import_react7.useCallback)(
1401
+ const emitDecline = (0, import_react8.useCallback)(
1274
1402
  (method, input, overrides) => {
1275
1403
  onDecline?.(buildDeclineEvent(method, input, overrides));
1276
1404
  },
1277
1405
  [onDecline]
1278
1406
  );
1279
1407
  const showWallets = showApplePay || showGooglePay;
1280
- const handleNameChange = (0, import_react7.useCallback)((value) => {
1408
+ const [paypalLoadState, setPaypalLoadState] = (0, import_react8.useState)("loading");
1409
+ const [walletLoadState, setWalletLoadState] = (0, import_react8.useState)("loading");
1410
+ const [inAppBrowserDetected, setInAppBrowserDetected] = (0, import_react8.useState)(false);
1411
+ (0, import_react8.useEffect)(() => {
1412
+ setInAppBrowserDetected(isInAppBrowser());
1413
+ }, []);
1414
+ const expectedPayPal = showPayPal && !!paypalStripeInstance;
1415
+ const expectedWallets = showWallets && !!stripeInstance;
1416
+ const paypalLoadFailed = expectedPayPal && (paypalLoadState === "load_error" || paypalLoadState === "unavailable");
1417
+ const walletsLoadFailed = expectedWallets && walletLoadState === "load_error";
1418
+ const showInAppBrowserNotice = (expectedPayPal || expectedWallets) && (inAppBrowserDetected || paypalLoadFailed || walletsLoadFailed);
1419
+ const handleNameChange = (0, import_react8.useCallback)((value) => {
1281
1420
  setFullName(value);
1282
1421
  onFullNameChange?.(value);
1283
1422
  const parts = value.trim().split(/\s+/);
1284
1423
  onFirstNameChange?.(parts[0] ?? "");
1285
1424
  onLastNameChange?.(parts.length > 1 ? parts.slice(1).join(" ") : "");
1286
1425
  }, [onFullNameChange, onFirstNameChange, onLastNameChange]);
1287
- const applyInlineSessionPatch = (0, import_react7.useCallback)(
1426
+ const applyInlineSessionPatch = (0, import_react8.useCallback)(
1288
1427
  (patch, method) => {
1289
1428
  if (!checkout.applyInlineSessionPatch) {
1290
1429
  return Promise.resolve({ error: null, sessionId });
@@ -1301,7 +1440,7 @@ function SplitCardFormInner({
1301
1440
  },
1302
1441
  [checkout.applyInlineSessionPatch, onError, sessionId, updateError]
1303
1442
  );
1304
- const runBeforeButtonClick = (0, import_react7.useCallback)(async (method) => {
1443
+ const runBeforeButtonClick = (0, import_react8.useCallback)(async (method) => {
1305
1444
  if (!onBeforeButtonClick) return { proceed: true };
1306
1445
  try {
1307
1446
  const result = await onBeforeButtonClick({
@@ -1337,7 +1476,7 @@ function SplitCardFormInner({
1337
1476
  return { proceed: false };
1338
1477
  }
1339
1478
  }, [applyInlineSessionPatch, checkout.inlineSessionDraft, onBeforeButtonClick, onError, sessionId, updateError]);
1340
- const processPaymentInternal = (0, import_react7.useCallback)(
1479
+ const processPaymentInternal = (0, import_react8.useCallback)(
1341
1480
  async (tokenizedBody, overrides) => {
1342
1481
  if (processingRef.current) return;
1343
1482
  processingRef.current = true;
@@ -1527,7 +1666,7 @@ function SplitCardFormInner({
1527
1666
  },
1528
1667
  [baseUrl, sessionId, resolvedAccount, fullName, chv, flopay, paypalFlopay, onComplete, onError, updateError, emitDecline]
1529
1668
  );
1530
- const dispatchTokenizedBody = (0, import_react7.useCallback)(
1669
+ const dispatchTokenizedBody = (0, import_react8.useCallback)(
1531
1670
  (tokenizedBody, overrides) => {
1532
1671
  if (onTokenizedBody) {
1533
1672
  onTokenizedBody(tokenizedBody);
@@ -1537,7 +1676,7 @@ function SplitCardFormInner({
1537
1676
  },
1538
1677
  [onTokenizedBody, processPaymentInternal]
1539
1678
  );
1540
- (0, import_react7.useImperativeHandle)(innerRef, () => ({
1679
+ (0, import_react8.useImperativeHandle)(innerRef, () => ({
1541
1680
  async handleNextAction(secret) {
1542
1681
  if (!flopay) return;
1543
1682
  setIs3DSActive(true);
@@ -1564,7 +1703,7 @@ function SplitCardFormInner({
1564
1703
  }
1565
1704
  }
1566
1705
  }), [flopay, dispatchTokenizedBody, onError, updateError, emitDecline]);
1567
- (0, import_react7.useEffect)(() => {
1706
+ (0, import_react8.useEffect)(() => {
1568
1707
  if (typeof window === "undefined") return;
1569
1708
  const stored = localStorage.getItem(WALLET_RESUME_KEY);
1570
1709
  if (!stored) return;
@@ -1582,7 +1721,7 @@ function SplitCardFormInner({
1582
1721
  localStorage.removeItem(WALLET_RESUME_KEY);
1583
1722
  }
1584
1723
  }, [sessionId, dispatchTokenizedBody]);
1585
- const handleSubmit = (0, import_react7.useCallback)(
1724
+ const handleSubmit = (0, import_react8.useCallback)(
1586
1725
  async (e) => {
1587
1726
  e.preventDefault();
1588
1727
  if (!flopay || !elements || isSubmitting || processingRef.current) return;
@@ -1724,7 +1863,7 @@ function SplitCardFormInner({
1724
1863
  );
1725
1864
  const isReady = flopay !== null && elements !== null;
1726
1865
  if (!isReady) {
1727
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." });
1866
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." });
1728
1867
  }
1729
1868
  const isButtons = layout === "buttons";
1730
1869
  const resolvedBorder = isButtons ? bStyles.cardInputBorder ?? "#e5e7eb" : "#A4A4FF";
@@ -1767,7 +1906,7 @@ function SplitCardFormInner({
1767
1906
  invalid: { color: "#ef4444" }
1768
1907
  }
1769
1908
  };
1770
- const cardFormBlock = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
1909
+ const cardFormBlock = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
1771
1910
  backgroundColor: cardBg,
1772
1911
  borderRadius: "8px",
1773
1912
  padding: isButtons ? "0" : "1rem",
@@ -1775,7 +1914,7 @@ function SplitCardFormInner({
1775
1914
  ...isButtons ? { padding: bStyles.cardFormContainer?.padding ?? "0" } : {},
1776
1915
  ...sharedInputPlaceholderVars
1777
1916
  }, children: [
1778
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("style", { children: `
1917
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("style", { children: `
1779
1918
  .flopay-shared-input::placeholder {
1780
1919
  color: var(--flopay-input-placeholder-color);
1781
1920
  opacity: 1;
@@ -1784,12 +1923,12 @@ function SplitCardFormInner({
1784
1923
  font-weight: var(--flopay-input-font-weight);
1785
1924
  }
1786
1925
  ` }),
1787
- isButtons && showCardForm && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
1926
+ isButtons && showCardForm && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
1788
1927
  display: "flex",
1789
1928
  alignItems: "center",
1790
1929
  padding: "0.75rem 0 0.625rem"
1791
1930
  }, children: [
1792
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1931
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1793
1932
  "button",
1794
1933
  {
1795
1934
  type: "button",
@@ -1811,7 +1950,7 @@ function SplitCardFormInner({
1811
1950
  },
1812
1951
  "aria-label": "Back to payment methods",
1813
1952
  children: [
1814
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: {
1953
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: {
1815
1954
  display: "inline-flex",
1816
1955
  alignItems: "center",
1817
1956
  justifyContent: "center",
@@ -1821,12 +1960,12 @@ function SplitCardFormInner({
1821
1960
  backgroundColor: "#f3f4f6",
1822
1961
  transition: "background-color 0.15s",
1823
1962
  ...bStyles.backButtonIcon
1824
- }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
1825
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
1963
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
1964
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
1826
1965
  ]
1827
1966
  }
1828
1967
  ),
1829
- hideTitle ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1968
+ hideTitle ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
1830
1969
  flex: 1,
1831
1970
  textAlign: "center",
1832
1971
  fontWeight: 600,
@@ -1834,18 +1973,18 @@ function SplitCardFormInner({
1834
1973
  color: "#262833",
1835
1974
  paddingRight: 80,
1836
1975
  ...bStyles.title
1837
- }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TitleContentSlot, { content: cardTitleContent }) })
1976
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TitleContentSlot, { content: cardTitleContent }) })
1838
1977
  ] }),
1839
- !isButtons && !hideTitle && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { textAlign: "center", fontWeight: 600, fontSize: "1.1rem", padding: "0.5rem 0", color: "#262833" }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TitleContentSlot, { content: cardTitleContent }) }),
1840
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1978
+ !isButtons && !hideTitle && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { textAlign: "center", fontWeight: 600, fontSize: "1.1rem", padding: "0.5rem 0", color: "#262833" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TitleContentSlot, { content: cardTitleContent }) }),
1979
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
1841
1980
  backgroundColor: cardInputBg,
1842
1981
  border: `1px solid ${resolvedBorder}`,
1843
1982
  borderTopLeftRadius: "8px",
1844
1983
  borderTopRightRadius: "8px",
1845
1984
  padding: "10px"
1846
- }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardNumberElement, { onReady: () => setFormReady(true), options: stripeElementStyle }) }),
1847
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex" }, children: [
1848
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1985
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CardNumberElement, { onReady: () => setFormReady(true), options: stripeElementStyle }) }),
1986
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex" }, children: [
1987
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
1849
1988
  flex: 1,
1850
1989
  backgroundColor: cardInputBg,
1851
1990
  border: `1px solid ${resolvedBorder}`,
@@ -1853,23 +1992,23 @@ function SplitCardFormInner({
1853
1992
  borderRight: "none",
1854
1993
  borderBottomLeftRadius: "8px",
1855
1994
  padding: "10px"
1856
- }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardExpiryElement, { options: stripeElementStyle }) }),
1857
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1995
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CardExpiryElement, { options: stripeElementStyle }) }),
1996
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
1858
1997
  flex: 1,
1859
1998
  backgroundColor: cardInputBg,
1860
1999
  border: `1px solid ${resolvedBorder}`,
1861
2000
  borderTop: "none",
1862
2001
  borderBottomRightRadius: "8px",
1863
2002
  padding: "10px"
1864
- }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardCvcElement, { options: stripeElementStyle }) })
2003
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CardCvcElement, { options: stripeElementStyle }) })
1865
2004
  ] }),
1866
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2005
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
1867
2006
  backgroundColor: cardInputBg,
1868
2007
  border: `1px solid ${resolvedBorder}`,
1869
2008
  borderRadius: "8px",
1870
2009
  marginTop: "0.5rem",
1871
2010
  padding: "10px"
1872
- }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2011
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1873
2012
  "input",
1874
2013
  {
1875
2014
  className: "flopay-shared-input",
@@ -1908,8 +2047,8 @@ function SplitCardFormInner({
1908
2047
  ...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
1909
2048
  });
1910
2049
  const stateOpts = (0, import_shared4.getStateOptions)(cc);
1911
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1912
- (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: inputWrapStyle(bStyles.addressLine1Input), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2050
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2051
+ (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, cc) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: inputWrapStyle(bStyles.addressLine1Input), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1913
2052
  "input",
1914
2053
  {
1915
2054
  className: "flopay-shared-input",
@@ -1926,7 +2065,7 @@ function SplitCardFormInner({
1926
2065
  style: inputFieldStyle()
1927
2066
  }
1928
2067
  ) }),
1929
- (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_2, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: inputWrapStyle(bStyles.addressLine2Input), children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2068
+ (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_2, cc) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: inputWrapStyle(bStyles.addressLine2Input), children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1930
2069
  "input",
1931
2070
  {
1932
2071
  className: "flopay-shared-input",
@@ -1942,12 +2081,12 @@ function SplitCardFormInner({
1942
2081
  style: inputFieldStyle()
1943
2082
  }
1944
2083
  ) }),
1945
- ((0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) || (0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc)) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
2084
+ ((0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) || (0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc)) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
1946
2085
  display: "flex",
1947
2086
  gap: "0",
1948
2087
  marginTop: "0.5rem"
1949
2088
  }, children: [
1950
- (0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2089
+ (0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
1951
2090
  flex: 1,
1952
2091
  backgroundColor: cardInputBg,
1953
2092
  border: `1px solid ${resolvedBorder}`,
@@ -1956,7 +2095,7 @@ function SplitCardFormInner({
1956
2095
  borderBottomLeftRadius: "8px",
1957
2096
  ...(0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc) ? { borderRight: "none", borderTopRightRadius: 0, borderBottomRightRadius: 0 } : { borderRadius: "8px" },
1958
2097
  ...isButtons && bStyles.cityInput ? bStyles.cityInput : {}
1959
- }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2098
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1960
2099
  "input",
1961
2100
  {
1962
2101
  className: "flopay-shared-input",
@@ -1973,7 +2112,7 @@ function SplitCardFormInner({
1973
2112
  style: inputFieldStyle()
1974
2113
  }
1975
2114
  ) }),
1976
- (0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2115
+ (0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
1977
2116
  flex: 1,
1978
2117
  backgroundColor: cardInputBg,
1979
2118
  border: `1px solid ${resolvedBorder}`,
@@ -1982,7 +2121,7 @@ function SplitCardFormInner({
1982
2121
  borderBottomRightRadius: "8px",
1983
2122
  ...(0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) ? { borderTopLeftRadius: 0, borderBottomLeftRadius: 0 } : { borderRadius: "8px" },
1984
2123
  ...isButtons && bStyles.stateInput ? bStyles.stateInput : {}
1985
- }, children: stateOpts ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2124
+ }, children: stateOpts ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1986
2125
  "select",
1987
2126
  {
1988
2127
  value: stateValue,
@@ -1996,11 +2135,11 @@ function SplitCardFormInner({
1996
2135
  "data-testid": "flopay-state",
1997
2136
  style: { ...inputFieldStyle(), cursor: "pointer" },
1998
2137
  children: [
1999
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: (0, import_shared4.getStateLabel)(cc) }),
2000
- stateOpts.map((s) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: s.code, children: s.name }, s.code))
2138
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: "", children: (0, import_shared4.getStateLabel)(cc) }),
2139
+ stateOpts.map((s) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("option", { value: s.code, children: s.name }, s.code))
2001
2140
  ]
2002
2141
  }
2003
- ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2142
+ ) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2004
2143
  "input",
2005
2144
  {
2006
2145
  className: "flopay-shared-input",
@@ -2018,20 +2157,20 @@ function SplitCardFormInner({
2018
2157
  }
2019
2158
  ) })
2020
2159
  ] }),
2021
- ((0, import_shared4.isAVSFieldVisible)(avsConfig.country, cc) || (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc)) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
2160
+ ((0, import_shared4.isAVSFieldVisible)(avsConfig.country, cc) || (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc)) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
2022
2161
  display: "flex",
2023
2162
  flexDirection: avsLayoutProp === "column" ? "column" : "row",
2024
2163
  gap: avsLayoutProp === "column" ? "0.5rem" : "0",
2025
2164
  marginTop: "0.5rem"
2026
2165
  }, children: [
2027
- (0, import_shared4.isAVSFieldVisible)(avsConfig.country, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2166
+ (0, import_shared4.isAVSFieldVisible)(avsConfig.country, cc) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
2028
2167
  flex: avsLayoutProp === "row" ? 1 : void 0,
2029
2168
  backgroundColor: cardInputBg,
2030
2169
  border: `1px solid ${resolvedBorder}`,
2031
2170
  padding: "10px",
2032
2171
  ...avsLayoutProp === "row" && (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc) ? { borderRadius: "0", borderTopLeftRadius: "8px", borderBottomLeftRadius: "8px", borderRight: "none" } : { borderRadius: "8px" },
2033
2172
  ...isButtons && bStyles.countrySelect ? bStyles.countrySelect : {}
2034
- }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2173
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2035
2174
  "select",
2036
2175
  {
2037
2176
  value: selectedCountry,
@@ -2046,21 +2185,21 @@ function SplitCardFormInner({
2046
2185
  autoComplete: "country",
2047
2186
  "data-testid": "flopay-country",
2048
2187
  style: { ...inputFieldStyle(), cursor: "pointer" },
2049
- children: import_shared4.COUNTRY_OPTIONS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: c.code, children: [
2188
+ children: import_shared4.COUNTRY_OPTIONS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("option", { value: c.code, children: [
2050
2189
  c.flag,
2051
2190
  " ",
2052
2191
  c.name
2053
2192
  ] }, c.code))
2054
2193
  }
2055
2194
  ) }),
2056
- (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2195
+ (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
2057
2196
  flex: avsLayoutProp === "row" ? 1 : void 0,
2058
2197
  backgroundColor: cardInputBg,
2059
2198
  border: `1px solid ${resolvedBorder}`,
2060
2199
  padding: "10px",
2061
2200
  ...avsLayoutProp === "row" && (0, import_shared4.isAVSFieldVisible)(avsConfig.country, cc) ? { borderRadius: "0", borderTopRightRadius: "8px", borderBottomRightRadius: "8px" } : { borderRadius: "8px" },
2062
2201
  ...isButtons && bStyles.zipInput ? bStyles.zipInput : {}
2063
- }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2202
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2064
2203
  "input",
2065
2204
  {
2066
2205
  className: "flopay-shared-input",
@@ -2081,7 +2220,7 @@ function SplitCardFormInner({
2081
2220
  ] })
2082
2221
  ] });
2083
2222
  })(),
2084
- displayError && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
2223
+ displayError && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
2085
2224
  margin: "0.75rem 0",
2086
2225
  padding: "0.625rem 0.875rem",
2087
2226
  background: "#FEF2F2",
@@ -2095,10 +2234,10 @@ function SplitCardFormInner({
2095
2234
  gap: "0.5rem",
2096
2235
  ...isButtons && bStyles.errorBanner ? bStyles.errorBanner : {}
2097
2236
  }, children: [
2098
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("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" }) }),
2237
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("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" }) }),
2099
2238
  displayError
2100
2239
  ] }),
2101
- children ?? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2240
+ children ?? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2102
2241
  "button",
2103
2242
  {
2104
2243
  type: "submit",
@@ -2121,7 +2260,7 @@ function SplitCardFormInner({
2121
2260
  children: isSubmitting ? "PROCESSING..." : submitLabel
2122
2261
  }
2123
2262
  ),
2124
- !isButtons && showSecurityFooter && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2263
+ !isButtons && showSecurityFooter && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
2125
2264
  backgroundColor: "#EFF9F0",
2126
2265
  borderRadius: "8px",
2127
2266
  padding: "0.75rem",
@@ -2138,11 +2277,11 @@ function SplitCardFormInner({
2138
2277
  const cardButtonSizing = cardButtonContent === void 0 ? { boxSizing: "border-box", height: DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT, padding: "0 1rem" } : { padding: "0.9rem 1rem" };
2139
2278
  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;
2140
2279
  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;
2141
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
2142
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FloPayKeyframes, {}),
2143
- overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
2144
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "grid" }, children: [
2145
- /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
2280
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
2281
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FloPayKeyframes, {}),
2282
+ overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
2283
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "grid" }, children: [
2284
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
2146
2285
  gridArea: "1 / 1",
2147
2286
  display: "flex",
2148
2287
  flexDirection: "column",
@@ -2151,7 +2290,7 @@ function SplitCardFormInner({
2151
2290
  ...!isButtonsView && !buttonsAnim ? { visibility: "hidden", position: "absolute", pointerEvents: "none", width: "100%" } : {},
2152
2291
  ...buttonsAnim ? { animation: buttonsAnim, pointerEvents: "none" } : {}
2153
2292
  }, children: [
2154
- showPayPal && paypalStripeInstance && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_stripe_js.Elements, { stripe: paypalStripeInstance, options: paypalOptions, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2293
+ showPayPal && paypalStripeInstance && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_stripe_js.Elements, { stripe: paypalStripeInstance, options: paypalOptions, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2155
2294
  PayPalButtonInner,
2156
2295
  {
2157
2296
  sessionId,
@@ -2162,10 +2301,11 @@ function SplitCardFormInner({
2162
2301
  isProcessing: isSubmitting,
2163
2302
  onButtonClick,
2164
2303
  onDecline,
2165
- runBeforeButtonClick
2304
+ runBeforeButtonClick,
2305
+ onLoadStateChange: setPaypalLoadState
2166
2306
  }
2167
2307
  ) }),
2168
- showWallets && stripeInstance ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2308
+ showWallets && stripeInstance ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2169
2309
  WalletButtonInner,
2170
2310
  {
2171
2311
  sessionId,
@@ -2177,10 +2317,12 @@ function SplitCardFormInner({
2177
2317
  onErrorChange: updateError,
2178
2318
  onButtonClick,
2179
2319
  onDecline,
2180
- runBeforeButtonClick
2320
+ runBeforeButtonClick,
2321
+ onLoadStateChange: setWalletLoadState
2181
2322
  }
2182
- ) }) : showWallets ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { height: DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT, borderRadius: 8, background: "#e5e7eb", animation: "flopay-pulse 1.5s ease-in-out infinite" } }) : null,
2183
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2323
+ ) }) : showWallets ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { height: DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT, borderRadius: 8, background: "#e5e7eb", animation: "flopay-pulse 1.5s ease-in-out infinite" } }) : null,
2324
+ showInAppBrowserNotice && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(InAppBrowserNotice, {}),
2325
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2184
2326
  "button",
2185
2327
  {
2186
2328
  type: "button",
@@ -2218,10 +2360,10 @@ function SplitCardFormInner({
2218
2360
  onMouseUp: (e) => {
2219
2361
  e.currentTarget.style.transform = "scale(1)";
2220
2362
  },
2221
- children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardButtonContentSlot, { content: cardButtonContent })
2363
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CardButtonContentSlot, { content: cardButtonContent })
2222
2364
  }
2223
2365
  ),
2224
- displayError && viewState === "buttons" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
2366
+ displayError && viewState === "buttons" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
2225
2367
  margin: "0.25rem 0",
2226
2368
  padding: "0.625rem 0.875rem",
2227
2369
  background: "#FEF2F2",
@@ -2235,11 +2377,11 @@ function SplitCardFormInner({
2235
2377
  gap: "0.5rem",
2236
2378
  ...bStyles.errorBanner ? bStyles.errorBanner : {}
2237
2379
  }, children: [
2238
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("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" }) }),
2380
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("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" }) }),
2239
2381
  displayError
2240
2382
  ] })
2241
2383
  ] }),
2242
- isCardView && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2384
+ isCardView && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
2243
2385
  gridArea: "1 / 1",
2244
2386
  ...cardAnim ? { animation: cardAnim } : {},
2245
2387
  ...viewState === "collapsing" ? { pointerEvents: "none" } : {}
@@ -2247,10 +2389,10 @@ function SplitCardFormInner({
2247
2389
  ] })
2248
2390
  ] });
2249
2391
  }
2250
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
2251
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FloPayKeyframes, {}),
2252
- overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
2253
- showWallets && stripeInstance && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2392
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
2393
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FloPayKeyframes, {}),
2394
+ overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
2395
+ showWallets && stripeInstance && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2254
2396
  WalletButtonInner,
2255
2397
  {
2256
2398
  sessionId,
@@ -2260,10 +2402,11 @@ function SplitCardFormInner({
2260
2402
  showGooglePay,
2261
2403
  onTokenizedBody: dispatchTokenizedBody,
2262
2404
  onErrorChange: updateError,
2263
- onDecline
2405
+ onDecline,
2406
+ onLoadStateChange: setWalletLoadState
2264
2407
  }
2265
2408
  ) }),
2266
- showPayPal && paypalStripeInstance && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_stripe_js.Elements, { stripe: paypalStripeInstance, options: paypalOptions, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2409
+ showPayPal && paypalStripeInstance && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_react_stripe_js.Elements, { stripe: paypalStripeInstance, options: paypalOptions, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2267
2410
  PayPalButtonInner,
2268
2411
  {
2269
2412
  sessionId,
@@ -2272,10 +2415,12 @@ function SplitCardFormInner({
2272
2415
  onTokenizedBody: dispatchTokenizedBody,
2273
2416
  onErrorChange: updateError,
2274
2417
  isProcessing: isSubmitting,
2275
- onDecline
2418
+ onDecline,
2419
+ onLoadStateChange: setPaypalLoadState
2276
2420
  }
2277
2421
  ) }),
2278
- (showWallets && stripeInstance || showPayPal && paypalStripeInstance) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
2422
+ showInAppBrowserNotice && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(InAppBrowserNotice, {}),
2423
+ (showWallets && stripeInstance || showPayPal && paypalStripeInstance) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
2279
2424
  display: "flex",
2280
2425
  alignItems: "center",
2281
2426
  gap: "0.75rem",
@@ -2283,9 +2428,9 @@ function SplitCardFormInner({
2283
2428
  color: "#999",
2284
2429
  fontSize: "0.85rem"
2285
2430
  }, children: [
2286
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } }),
2287
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "or pay with card" }),
2288
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } })
2431
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } }),
2432
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { children: "or pay with card" }),
2433
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } })
2289
2434
  ] }),
2290
2435
  cardFormBlock
2291
2436
  ] });
@@ -2726,15 +2871,31 @@ async function handleSavedPaymentRedirectResult(redirectResult, {
2726
2871
  { checkoutMethod: "paypal" }
2727
2872
  );
2728
2873
  }
2729
- const confirmParams = {
2730
- return_url: returnUrl ?? resolveSavedPaymentReturnUrl(session) ?? window.location.href
2731
- };
2732
2874
  if (redirectResult.paymentMethodId) {
2733
- confirmParams["payment_method"] = redirectResult.paymentMethodId;
2875
+ const { error: error2 } = await paypalStripe.handleNextAction({
2876
+ clientSecret: redirectResult.threeDSecureToken
2877
+ });
2878
+ if (error2) {
2879
+ throw Object.assign(
2880
+ new import_shared6.FloPayError(
2881
+ error2.message ?? "PayPal authorization failed.",
2882
+ "api_error",
2883
+ { code: error2.code }
2884
+ ),
2885
+ { checkoutMethod: "paypal" }
2886
+ );
2887
+ }
2888
+ return {
2889
+ status: "succeeded",
2890
+ checkoutMethod: "paypal"
2891
+ };
2734
2892
  }
2735
2893
  const { error } = await paypalStripe.confirmPayment({
2736
2894
  clientSecret: redirectResult.threeDSecureToken,
2737
- confirmParams,
2895
+ confirmParams: {
2896
+ return_url: returnUrl ?? resolveSavedPaymentReturnUrl(session) ?? window.location.href,
2897
+ payment_method_data: { type: "paypal" }
2898
+ },
2738
2899
  redirect: "if_required"
2739
2900
  });
2740
2901
  if (error) {
@@ -2808,7 +2969,7 @@ async function loadSavedPaymentProviders({
2808
2969
  }
2809
2970
 
2810
2971
  // src/flopay-checkout.tsx
2811
- var import_jsx_runtime6 = require("react/jsx-runtime");
2972
+ var import_jsx_runtime7 = require("react/jsx-runtime");
2812
2973
  var DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2 = 44;
2813
2974
  var PAYPAL_RESUME_STORAGE_KEY = "flopay_checkout_saved_payment_resume";
2814
2975
  var sessionInflightMap = /* @__PURE__ */ new Map();
@@ -2911,37 +3072,37 @@ function FloPayCheckout({
2911
3072
  const resolvedBillingUrl = (0, import_shared7.resolveBillingApiUrl)(billingApiUrl);
2912
3073
  const checkoutType = createSessionParams ? "embedded_checkout" : "standard_checkout";
2913
3074
  const checkoutLayout = children ? "custom_layout" : layout === "buttons" ? "buttons_layout" : "default_layout";
2914
- const [unified, setUnified] = (0, import_react8.useState)(null);
2915
- const [flopay, setFloPay] = (0, import_react8.useState)(null);
2916
- const flopayRef = (0, import_react8.useRef)(null);
2917
- const [paypalFlopay, setPaypalFloPay] = (0, import_react8.useState)(null);
2918
- const paypalFlopayRef = (0, import_react8.useRef)(null);
2919
- const [session, setSession] = (0, import_react8.useState)(null);
2920
- const [resolvedSessionId, setResolvedSessionId] = (0, import_react8.useState)(sessionIdProp ?? "");
3075
+ const [unified, setUnified] = (0, import_react9.useState)(null);
3076
+ const [flopay, setFloPay] = (0, import_react9.useState)(null);
3077
+ const flopayRef = (0, import_react9.useRef)(null);
3078
+ const [paypalFlopay, setPaypalFloPay] = (0, import_react9.useState)(null);
3079
+ const paypalFlopayRef = (0, import_react9.useRef)(null);
3080
+ const [session, setSession] = (0, import_react9.useState)(null);
3081
+ const [resolvedSessionId, setResolvedSessionId] = (0, import_react9.useState)(sessionIdProp ?? "");
2921
3082
  const activeSessionId = sessionIdProp ?? resolvedSessionId;
2922
3083
  const initSessionDependency = createSessionParams ? "" : activeSessionId;
2923
- const [isLoading, setIsLoading] = (0, import_react8.useState)(true);
2924
- const [loadError, setLoadError] = (0, import_react8.useState)(null);
2925
- const [currentMode, setCurrentMode] = (0, import_react8.useState)("full");
2926
- const [confirmProcessing, setConfirmProcessing] = (0, import_react8.useState)(false);
2927
- const [modeError, setModeError] = (0, import_react8.useState)(initialErrorMessage);
2928
- const [modeOverlayStatus, setModeOverlayStatus] = (0, import_react8.useState)(null);
2929
- const [modeOverlayError, setModeOverlayError] = (0, import_react8.useState)(null);
2930
- const [createSessionPatch, setCreateSessionPatch] = (0, import_react8.useState)(void 0);
2931
- const [createSessionPatchBaseHash, setCreateSessionPatchBaseHash] = (0, import_react8.useState)("");
2932
- const [cardBootstrapPending, setCardBootstrapPending] = (0, import_react8.useState)(false);
2933
- const autoCheckoutAttempted = (0, import_react8.useRef)(false);
2934
- const paypalResumeAttempted = (0, import_react8.useRef)(false);
2935
- const savedPaymentKeysRef = (0, import_react8.useRef)(null);
2936
- const onCompleteRef = (0, import_react8.useRef)(onComplete);
3084
+ const [isLoading, setIsLoading] = (0, import_react9.useState)(true);
3085
+ const [loadError, setLoadError] = (0, import_react9.useState)(null);
3086
+ const [currentMode, setCurrentMode] = (0, import_react9.useState)("full");
3087
+ const [confirmProcessing, setConfirmProcessing] = (0, import_react9.useState)(false);
3088
+ const [modeError, setModeError] = (0, import_react9.useState)(initialErrorMessage);
3089
+ const [modeOverlayStatus, setModeOverlayStatus] = (0, import_react9.useState)(null);
3090
+ const [modeOverlayError, setModeOverlayError] = (0, import_react9.useState)(null);
3091
+ const [createSessionPatch, setCreateSessionPatch] = (0, import_react9.useState)(void 0);
3092
+ const [createSessionPatchBaseHash, setCreateSessionPatchBaseHash] = (0, import_react9.useState)("");
3093
+ const [cardBootstrapPending, setCardBootstrapPending] = (0, import_react9.useState)(false);
3094
+ const autoCheckoutAttempted = (0, import_react9.useRef)(false);
3095
+ const paypalResumeAttempted = (0, import_react9.useRef)(false);
3096
+ const savedPaymentKeysRef = (0, import_react9.useRef)(null);
3097
+ const onCompleteRef = (0, import_react9.useRef)(onComplete);
2937
3098
  onCompleteRef.current = onComplete;
2938
- const onErrorRef = (0, import_react8.useRef)(onError);
3099
+ const onErrorRef = (0, import_react9.useRef)(onError);
2939
3100
  onErrorRef.current = onError;
2940
- const onDeclineRef = (0, import_react8.useRef)(onDecline);
3101
+ const onDeclineRef = (0, import_react9.useRef)(onDecline);
2941
3102
  onDeclineRef.current = onDecline;
2942
- const onSessionCompletedRef = (0, import_react8.useRef)(onSessionCompleted);
3103
+ const onSessionCompletedRef = (0, import_react9.useRef)(onSessionCompleted);
2943
3104
  onSessionCompletedRef.current = onSessionCompleted;
2944
- (0, import_react8.useEffect)(() => {
3105
+ (0, import_react9.useEffect)(() => {
2945
3106
  console.info("[FloPay] Checkout initialized", {
2946
3107
  sdk_version: import_shared7.SDK_VERSION,
2947
3108
  checkout_type: checkoutType,
@@ -2949,40 +3110,40 @@ function FloPayCheckout({
2949
3110
  billing_api_url: resolvedBillingUrl
2950
3111
  });
2951
3112
  }, [checkoutLayout, checkoutType, resolvedBillingUrl]);
2952
- const baseCreateSessionHash = (0, import_react8.useMemo)(
3113
+ const baseCreateSessionHash = (0, import_react9.useMemo)(
2953
3114
  () => createSessionParams ? hashCreateParams(createSessionParams) : "",
2954
3115
  [createSessionParams]
2955
3116
  );
2956
- const activeCreateSessionPatch = (0, import_react8.useMemo)(
3117
+ const activeCreateSessionPatch = (0, import_react9.useMemo)(
2957
3118
  () => createSessionPatchBaseHash === baseCreateSessionHash ? createSessionPatch : void 0,
2958
3119
  [createSessionPatch, createSessionPatchBaseHash, baseCreateSessionHash]
2959
3120
  );
2960
- const effectiveCreateSessionBase = (0, import_react8.useMemo)(
3121
+ const effectiveCreateSessionBase = (0, import_react9.useMemo)(
2961
3122
  () => createSessionParams ? mergeInlineSessionPatch(createSessionParams, activeCreateSessionPatch) : void 0,
2962
3123
  [createSessionParams, activeCreateSessionPatch]
2963
3124
  );
2964
3125
  const effectiveCreateSessionMode = checkoutModeProp ?? effectiveCreateSessionBase?.checkoutMode ?? "full";
2965
- const effectiveCreateSession = (0, import_react8.useMemo)(
3126
+ const effectiveCreateSession = (0, import_react9.useMemo)(
2966
3127
  () => effectiveCreateSessionBase ? {
2967
3128
  ...effectiveCreateSessionBase,
2968
3129
  checkoutMode: effectiveCreateSessionMode
2969
3130
  } : void 0,
2970
3131
  [effectiveCreateSessionBase, effectiveCreateSessionMode]
2971
3132
  );
2972
- (0, import_react8.useEffect)(() => {
3133
+ (0, import_react9.useEffect)(() => {
2973
3134
  setCreateSessionPatch(void 0);
2974
3135
  setCreateSessionPatchBaseHash(baseCreateSessionHash);
2975
3136
  }, [baseCreateSessionHash]);
2976
- (0, import_react8.useEffect)(() => {
3137
+ (0, import_react9.useEffect)(() => {
2977
3138
  setModeError(initialErrorMessage);
2978
3139
  }, [initialErrorMessage]);
2979
- const emitDecline = (0, import_react8.useCallback)(
3140
+ const emitDecline = (0, import_react9.useCallback)(
2980
3141
  (method, input, overrides) => {
2981
3142
  onDeclineRef.current?.(buildDeclineEvent(method, input, overrides));
2982
3143
  },
2983
3144
  []
2984
3145
  );
2985
- const runSavedPaymentFlow = (0, import_react8.useCallback)(
3146
+ const runSavedPaymentFlow = (0, import_react9.useCallback)(
2986
3147
  async (sess, options) => {
2987
3148
  setModeError(null);
2988
3149
  setModeOverlayError(null);
@@ -3089,7 +3250,7 @@ function FloPayCheckout({
3089
3250
  resolvedBillingUrl
3090
3251
  ]
3091
3252
  );
3092
- (0, import_react8.useEffect)(() => {
3253
+ (0, import_react9.useEffect)(() => {
3093
3254
  if (typeof window === "undefined" || paypalResumeAttempted.current) {
3094
3255
  return;
3095
3256
  }
@@ -3206,7 +3367,7 @@ function FloPayCheckout({
3206
3367
  }
3207
3368
  })();
3208
3369
  }, [emitDecline, locale, normalizeSavedPaymentError, resolvedBillingUrl]);
3209
- const initializedHashRef = (0, import_react8.useRef)(null);
3370
+ const initializedHashRef = (0, import_react9.useRef)(null);
3210
3371
  function hashCreateParams(params) {
3211
3372
  const key = JSON.stringify({
3212
3373
  c: params?.clientId,
@@ -3230,16 +3391,16 @@ function FloPayCheckout({
3230
3391
  }
3231
3392
  return `flopay_session_${Math.abs(h).toString(36)}`;
3232
3393
  }
3233
- const createSessionHash = (0, import_react8.useMemo)(
3394
+ const createSessionHash = (0, import_react9.useMemo)(
3234
3395
  () => effectiveCreateSession ? hashCreateParams(effectiveCreateSession) : "",
3235
3396
  [effectiveCreateSession]
3236
3397
  );
3237
- const createSessionParamsRef = (0, import_react8.useRef)(effectiveCreateSession);
3398
+ const createSessionParamsRef = (0, import_react9.useRef)(effectiveCreateSession);
3238
3399
  createSessionParamsRef.current = effectiveCreateSession;
3239
- (0, import_react8.useEffect)(() => {
3400
+ (0, import_react9.useEffect)(() => {
3240
3401
  setResolvedSessionId(sessionIdProp ?? "");
3241
3402
  }, [sessionIdProp]);
3242
- (0, import_react8.useEffect)(() => {
3403
+ (0, import_react9.useEffect)(() => {
3243
3404
  autoCheckoutAttempted.current = false;
3244
3405
  setModeError(initialErrorMessage);
3245
3406
  setModeOverlayError(null);
@@ -3282,7 +3443,7 @@ function FloPayCheckout({
3282
3443
  }
3283
3444
  return { sid: sid ?? "", result: realResult };
3284
3445
  }
3285
- const bootstrapInlineSession = (0, import_react8.useCallback)(
3446
+ const bootstrapInlineSession = (0, import_react9.useCallback)(
3286
3447
  async (patch) => {
3287
3448
  const baseParams = createSessionParamsRef.current;
3288
3449
  if (!baseParams) {
@@ -3343,7 +3504,7 @@ function FloPayCheckout({
3343
3504
  },
3344
3505
  [locale, resolvedBillingUrl]
3345
3506
  );
3346
- const handleInlineSessionPatch = (0, import_react8.useCallback)(async (patch) => {
3507
+ const handleInlineSessionPatch = (0, import_react9.useCallback)(async (patch) => {
3347
3508
  if (!hasInlineSessionPatchData(patch) || cardBootstrapPending) {
3348
3509
  return {
3349
3510
  sessionId: resolvedSessionId,
@@ -3366,7 +3527,7 @@ function FloPayCheckout({
3366
3527
  resolvedSessionId,
3367
3528
  session
3368
3529
  ]);
3369
- (0, import_react8.useEffect)(() => {
3530
+ (0, import_react9.useEffect)(() => {
3370
3531
  let cancelled = false;
3371
3532
  setLoadError(null);
3372
3533
  if (createSessionHash) {
@@ -3520,7 +3681,7 @@ function FloPayCheckout({
3520
3681
  initSessionDependency,
3521
3682
  runSavedPaymentFlow
3522
3683
  ]);
3523
- const handleConfirmCheckout = (0, import_react8.useCallback)(async () => {
3684
+ const handleConfirmCheckout = (0, import_react9.useCallback)(async () => {
3524
3685
  if (confirmProcessing || !session) return;
3525
3686
  setConfirmProcessing(true);
3526
3687
  setModeError(null);
@@ -3533,7 +3694,7 @@ function FloPayCheckout({
3533
3694
  setConfirmProcessing(false);
3534
3695
  }
3535
3696
  }, [activeSessionId, confirmProcessing, runSavedPaymentFlow, session]);
3536
- const providerOptions = (0, import_react8.useMemo)(() => {
3697
+ const providerOptions = (0, import_react9.useMemo)(() => {
3537
3698
  if (!unified || !session) return void 0;
3538
3699
  const opts = {
3539
3700
  appearance,
@@ -3552,7 +3713,7 @@ function FloPayCheckout({
3552
3713
  const shouldHandleInlineSessionPatch = Boolean(
3553
3714
  createSessionParams && !children && layout === "buttons" && onBeforeButtonClick && effectiveCreateSessionMode === "full"
3554
3715
  );
3555
- const checkoutValue = (0, import_react8.useMemo)(
3716
+ const checkoutValue = (0, import_react9.useMemo)(
3556
3717
  () => ({
3557
3718
  session,
3558
3719
  loading: isLoading,
@@ -3574,7 +3735,7 @@ function FloPayCheckout({
3574
3735
  ]
3575
3736
  );
3576
3737
  const shouldShowInterimButtons = Boolean(createSessionParams) && layout === "buttons" && (!flopay || !providerOptions);
3577
- const modeOverlay = modeOverlayStatus ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3738
+ const modeOverlay = modeOverlayStatus ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3578
3739
  ProcessingOverlay,
3579
3740
  {
3580
3741
  status: modeOverlayStatus,
@@ -3583,31 +3744,31 @@ function FloPayCheckout({
3583
3744
  ) : null;
3584
3745
  if (isLoading) {
3585
3746
  if (loadingNode) {
3586
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3747
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3587
3748
  loadingNode,
3588
3749
  modeOverlay
3589
3750
  ] });
3590
3751
  }
3591
3752
  if (layout === "buttons") {
3592
- const skeletonBar = (h) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
3753
+ const skeletonBar = (h) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
3593
3754
  height: h,
3594
3755
  borderRadius: 8,
3595
3756
  background: "#e5e7eb",
3596
3757
  animation: "flopay-loading-pulse 1.5s ease-in-out infinite"
3597
3758
  } });
3598
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3599
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
3759
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3760
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
3600
3761
  showPayPal && skeletonBar(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
3601
3762
  (showApplePay || showGooglePay) && skeletonBar(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
3602
3763
  skeletonBar(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
3603
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("style", { children: `@keyframes flopay-loading-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
3764
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("style", { children: `@keyframes flopay-loading-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
3604
3765
  ] }),
3605
3766
  modeOverlay
3606
3767
  ] });
3607
3768
  }
3608
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3609
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", justifyContent: "center", padding: 32 }, children: [
3610
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
3769
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3770
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", justifyContent: "center", padding: 32 }, children: [
3771
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
3611
3772
  width: 24,
3612
3773
  height: 24,
3613
3774
  border: "2px solid #e5e7eb",
@@ -3615,14 +3776,14 @@ function FloPayCheckout({
3615
3776
  borderRadius: "50%",
3616
3777
  animation: "spin 0.6s linear infinite"
3617
3778
  } }),
3618
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` })
3779
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` })
3619
3780
  ] }),
3620
3781
  modeOverlay
3621
3782
  ] });
3622
3783
  }
3623
3784
  if (loadError) {
3624
- if (errorNode) return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: errorNode(loadError) });
3625
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3785
+ if (errorNode) return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: errorNode(loadError) });
3786
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3626
3787
  "div",
3627
3788
  {
3628
3789
  style: {
@@ -3636,8 +3797,8 @@ function FloPayCheckout({
3636
3797
  );
3637
3798
  }
3638
3799
  if (shouldShowInterimButtons) {
3639
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3640
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3800
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3801
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3641
3802
  InterimButtonsView,
3642
3803
  {
3643
3804
  onButtonClick,
@@ -3655,12 +3816,12 @@ function FloPayCheckout({
3655
3816
  ] });
3656
3817
  }
3657
3818
  if (!flopay || !providerOptions) {
3658
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: modeOverlay });
3819
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: modeOverlay });
3659
3820
  }
3660
3821
  if (currentMode === "confirm") {
3661
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3662
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FloPayProvider, { flopay, paypalFlopay, options: providerOptions, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { className, children: [
3663
- modeError && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3822
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3823
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FloPayProvider, { flopay, paypalFlopay, options: providerOptions, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { className, children: [
3824
+ modeError && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3664
3825
  "div",
3665
3826
  {
3666
3827
  style: {
@@ -3675,7 +3836,7 @@ function FloPayCheckout({
3675
3836
  renderConfirmButton ? renderConfirmButton({
3676
3837
  onConfirm: handleConfirmCheckout,
3677
3838
  isProcessing: confirmProcessing
3678
- }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3839
+ }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3679
3840
  "button",
3680
3841
  {
3681
3842
  type: "button",
@@ -3700,9 +3861,9 @@ function FloPayCheckout({
3700
3861
  modeOverlay
3701
3862
  ] });
3702
3863
  }
3703
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3704
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(FloPayProvider, { flopay, paypalFlopay, options: providerOptions, children: children ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3705
- modeError && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3864
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3865
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(FloPayProvider, { flopay, paypalFlopay, options: providerOptions, children: children ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3866
+ modeError && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3706
3867
  "div",
3707
3868
  {
3708
3869
  style: {
@@ -3717,7 +3878,7 @@ function FloPayCheckout({
3717
3878
  children: modeError
3718
3879
  }
3719
3880
  ),
3720
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3881
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3721
3882
  SessionInjector,
3722
3883
  {
3723
3884
  sessionId: activeSessionId,
@@ -3726,7 +3887,7 @@ function FloPayCheckout({
3726
3887
  children
3727
3888
  }
3728
3889
  )
3729
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3890
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3730
3891
  SplitCardForm,
3731
3892
  {
3732
3893
  sessionId: activeSessionId,
@@ -3777,8 +3938,8 @@ function SessionInjector({
3777
3938
  session,
3778
3939
  children
3779
3940
  }) {
3780
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: import_react8.default.Children.map(children, (child) => {
3781
- if (!import_react8.default.isValidElement(child)) return child;
3941
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: import_react9.default.Children.map(children, (child) => {
3942
+ if (!import_react9.default.isValidElement(child)) return child;
3782
3943
  const existing = child.props;
3783
3944
  const injected = {};
3784
3945
  if (!existing.sessionId) injected.sessionId = sessionId;
@@ -3792,7 +3953,7 @@ function SessionInjector({
3792
3953
  injected.lastName = session.customer.lastName;
3793
3954
  }
3794
3955
  if (Object.keys(injected).length === 0) return child;
3795
- return import_react8.default.cloneElement(child, injected);
3956
+ return import_react9.default.cloneElement(child, injected);
3796
3957
  }) });
3797
3958
  }
3798
3959
  function InterimButtonsView({
@@ -3810,14 +3971,14 @@ function InterimButtonsView({
3810
3971
  cardBackButtonContent,
3811
3972
  cardTitleContent
3812
3973
  }) {
3813
- const [showCardForm, setShowCardForm] = (0, import_react8.useState)(false);
3974
+ const [showCardForm, setShowCardForm] = (0, import_react9.useState)(false);
3814
3975
  const isCardOpenControlled = typeof cardOpen === "boolean";
3815
- (0, import_react8.useEffect)(() => {
3976
+ (0, import_react9.useEffect)(() => {
3816
3977
  if (isCardOpenControlled) {
3817
3978
  setShowCardForm(cardOpen);
3818
3979
  }
3819
3980
  }, [cardOpen, isCardOpenControlled]);
3820
- const bStyles = (0, import_react8.useMemo)(() => {
3981
+ const bStyles = (0, import_react9.useMemo)(() => {
3821
3982
  const base = (0, import_shared7.resolveButtonsLayoutTheme)(buttonsTheme);
3822
3983
  if (!stylesOverride) return base;
3823
3984
  return {
@@ -3831,7 +3992,7 @@ function InterimButtonsView({
3831
3992
  title: { ...base.title, ...stylesOverride.title }
3832
3993
  };
3833
3994
  }, [buttonsTheme, stylesOverride]);
3834
- const skeleton = (h) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
3995
+ const skeleton = (h) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
3835
3996
  height: h,
3836
3997
  borderRadius: 8,
3837
3998
  background: "#e5e7eb",
@@ -3843,15 +4004,15 @@ function InterimButtonsView({
3843
4004
  const inputBg = bStyles.cardInputBackground ?? "white";
3844
4005
  const hideBackButtonLabel = isEmptySlotContent(cardBackButtonContent);
3845
4006
  const hideTitle = isEmptySlotContent(cardTitleContent);
3846
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
4007
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: {
3847
4008
  backgroundColor: bStyles.cardFormContainer?.backgroundColor ?? "white",
3848
4009
  borderRadius: "8px",
3849
4010
  animation: "flopay-interim-expand 0.35s cubic-bezier(0.4, 0, 0.2, 1) both",
3850
4011
  overflow: "hidden",
3851
4012
  ...bStyles.cardFormContainer
3852
4013
  }, children: [
3853
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", padding: "0.75rem 0 0.625rem" }, children: [
3854
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
4014
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", alignItems: "center", padding: "0.75rem 0 0.625rem" }, children: [
4015
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3855
4016
  "button",
3856
4017
  {
3857
4018
  type: "button",
@@ -3878,7 +4039,7 @@ function InterimButtonsView({
3878
4039
  ...bStyles.backButton
3879
4040
  },
3880
4041
  children: [
3881
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: {
4042
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: {
3882
4043
  display: "inline-flex",
3883
4044
  alignItems: "center",
3884
4045
  justifyContent: "center",
@@ -3887,12 +4048,12 @@ function InterimButtonsView({
3887
4048
  borderRadius: "50%",
3888
4049
  backgroundColor: "#f3f4f6",
3889
4050
  ...bStyles.backButtonIcon
3890
- }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
3891
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
4051
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
4052
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
3892
4053
  ]
3893
4054
  }
3894
4055
  ),
3895
- hideTitle ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
4056
+ hideTitle ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
3896
4057
  flex: 1,
3897
4058
  textAlign: "center",
3898
4059
  fontWeight: 600,
@@ -3900,15 +4061,15 @@ function InterimButtonsView({
3900
4061
  color: "#262833",
3901
4062
  paddingRight: 80,
3902
4063
  ...bStyles.title
3903
- }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TitleContentSlot, { content: cardTitleContent }) })
4064
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TitleContentSlot, { content: cardTitleContent }) })
3904
4065
  ] }),
3905
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTopLeftRadius: 8, borderTopRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { width: "60%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
3906
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex" }, children: [
3907
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { flex: 1, backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTop: "none", borderRight: "none", borderBottomLeftRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { width: "50%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
3908
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { flex: 1, backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTop: "none", borderBottomRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { width: "40%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) })
4066
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTopLeftRadius: 8, borderTopRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { width: "60%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
4067
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex" }, children: [
4068
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { flex: 1, backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTop: "none", borderRight: "none", borderBottomLeftRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { width: "50%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
4069
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { flex: 1, backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTop: "none", borderBottomRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { width: "40%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) })
3909
4070
  ] }),
3910
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderRadius: 8, marginTop: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { width: "45%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
3911
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
4071
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderRadius: 8, marginTop: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { width: "45%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
4072
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
3912
4073
  height: 50,
3913
4074
  borderRadius: 8,
3914
4075
  marginTop: 16,
@@ -3917,7 +4078,7 @@ function InterimButtonsView({
3917
4078
  ...bStyles.submitButton,
3918
4079
  opacity: 0.5
3919
4080
  } }),
3920
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("style", { children: `
4081
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("style", { children: `
3921
4082
  @keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
3922
4083
  @keyframes flopay-interim-expand {
3923
4084
  0% { opacity: 0; max-height: 0; transform: translateY(-12px); }
@@ -3927,10 +4088,10 @@ function InterimButtonsView({
3927
4088
  ` })
3928
4089
  ] });
3929
4090
  }
3930
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
4091
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
3931
4092
  showPayPal && skeleton(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
3932
4093
  (showApplePay || showGooglePay) && skeleton(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
3933
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
4094
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3934
4095
  "button",
3935
4096
  {
3936
4097
  type: "button",
@@ -3970,10 +4131,10 @@ function InterimButtonsView({
3970
4131
  onMouseUp: (e) => {
3971
4132
  e.currentTarget.style.transform = "scale(1)";
3972
4133
  },
3973
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CardButtonContentSlot, { content: cardButtonContent })
4134
+ children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CardButtonContentSlot, { content: cardButtonContent })
3974
4135
  }
3975
4136
  ),
3976
- errorMessage && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
4137
+ errorMessage && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: {
3977
4138
  margin: "0.25rem 0",
3978
4139
  padding: "0.625rem 0.875rem",
3979
4140
  background: "#FEF2F2",
@@ -3987,21 +4148,21 @@ function InterimButtonsView({
3987
4148
  gap: "0.5rem",
3988
4149
  ...bStyles.errorBanner
3989
4150
  }, children: [
3990
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("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" }) }),
4151
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("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" }) }),
3991
4152
  errorMessage
3992
4153
  ] }),
3993
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("style", { children: `@keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
4154
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("style", { children: `@keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
3994
4155
  ] });
3995
4156
  }
3996
4157
 
3997
4158
  // src/checkout-form.tsx
3998
4159
  var import_shared8 = require("@flopay/shared");
3999
- var import_react9 = require("react");
4000
- var import_jsx_runtime7 = require("react/jsx-runtime");
4160
+ var import_react10 = require("react");
4161
+ var import_jsx_runtime8 = require("react/jsx-runtime");
4001
4162
  var WALLET_RESUME_KEY2 = "flopay_wallet_resume";
4002
- var CheckoutForm = (0, import_react9.forwardRef)(
4163
+ var CheckoutForm = (0, import_react10.forwardRef)(
4003
4164
  function CheckoutForm2(props, ref) {
4004
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CheckoutFormInner, { ...props, innerRef: ref });
4165
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CheckoutFormInner, { ...props, innerRef: ref });
4005
4166
  }
4006
4167
  );
4007
4168
  function CheckoutFormInner({
@@ -4030,27 +4191,27 @@ function CheckoutFormInner({
4030
4191
  const paypalFlopay = usePayPalFloPay();
4031
4192
  const elements = useElements();
4032
4193
  const contextBillingUrl = useBillingApiUrl();
4033
- const [processing, setProcessing] = (0, import_react9.useState)(false);
4034
- const [error, setError] = (0, import_react9.useState)(null);
4035
- const [is3DSActive, setIs3DSActive] = (0, import_react9.useState)(false);
4194
+ const [processing, setProcessing] = (0, import_react10.useState)(false);
4195
+ const [error, setError] = (0, import_react10.useState)(null);
4196
+ const [is3DSActive, setIs3DSActive] = (0, import_react10.useState)(false);
4036
4197
  const displayError = externalError ?? error;
4037
4198
  const isSubmitting = externalProcessing ?? processing;
4038
4199
  const isSelfContained = !onTokenizedBody;
4039
4200
  const baseUrl = (billingApiUrl || contextBillingUrl).replace(/\/+$/, "");
4040
- const updateError = (0, import_react9.useCallback)(
4201
+ const updateError = (0, import_react10.useCallback)(
4041
4202
  (err) => {
4042
4203
  setError(err);
4043
4204
  onErrorChange?.(err);
4044
4205
  },
4045
4206
  [onErrorChange]
4046
4207
  );
4047
- const emitDecline = (0, import_react9.useCallback)(
4208
+ const emitDecline = (0, import_react10.useCallback)(
4048
4209
  (input, overrides) => {
4049
4210
  onDecline?.(buildDeclineEvent("card", input, overrides));
4050
4211
  },
4051
4212
  [onDecline]
4052
4213
  );
4053
- const processPaymentInternal = (0, import_react9.useCallback)(
4214
+ const processPaymentInternal = (0, import_react10.useCallback)(
4054
4215
  async (tokenizedBody, completionPaymentMethodId) => {
4055
4216
  setProcessing(true);
4056
4217
  updateError(null);
@@ -4167,7 +4328,7 @@ function CheckoutFormInner({
4167
4328
  },
4168
4329
  [baseUrl, sessionId, userId, email, firstName, lastName, chv, flopay, paypalFlopay, onComplete, onError, onDecline, updateError, emitDecline]
4169
4330
  );
4170
- const dispatchTokenizedBody = (0, import_react9.useCallback)(
4331
+ const dispatchTokenizedBody = (0, import_react10.useCallback)(
4171
4332
  (tokenizedBody) => {
4172
4333
  if (onTokenizedBody) {
4173
4334
  onTokenizedBody(tokenizedBody);
@@ -4177,7 +4338,7 @@ function CheckoutFormInner({
4177
4338
  },
4178
4339
  [onTokenizedBody, processPaymentInternal]
4179
4340
  );
4180
- (0, import_react9.useImperativeHandle)(innerRef, () => ({
4341
+ (0, import_react10.useImperativeHandle)(innerRef, () => ({
4181
4342
  async handleNextAction(secret) {
4182
4343
  if (!flopay) return;
4183
4344
  setIs3DSActive(true);
@@ -4204,7 +4365,7 @@ function CheckoutFormInner({
4204
4365
  }
4205
4366
  }
4206
4367
  }), [flopay, dispatchTokenizedBody, onError, updateError, emitDecline]);
4207
- (0, import_react9.useEffect)(() => {
4368
+ (0, import_react10.useEffect)(() => {
4208
4369
  if (typeof window === "undefined") return;
4209
4370
  const stored = localStorage.getItem(WALLET_RESUME_KEY2);
4210
4371
  if (!stored) return;
@@ -4222,7 +4383,7 @@ function CheckoutFormInner({
4222
4383
  localStorage.removeItem(WALLET_RESUME_KEY2);
4223
4384
  }
4224
4385
  }, [sessionId, dispatchTokenizedBody]);
4225
- const handleSubmit = (0, import_react9.useCallback)(
4386
+ const handleSubmit = (0, import_react10.useCallback)(
4226
4387
  async (e) => {
4227
4388
  e.preventDefault();
4228
4389
  if (!flopay || !elements || isSubmitting) return;
@@ -4312,8 +4473,8 @@ function CheckoutFormInner({
4312
4473
  [flopay, elements, isSubmitting, sessionId, email, baseUrl, isSelfContained, dispatchTokenizedBody, onError, updateError, emitDecline]
4313
4474
  );
4314
4475
  const isReady = flopay !== null && elements !== null;
4315
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
4316
- (is3DSActive || isSubmitting) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { "data-testid": "flopay-overlay", style: {
4476
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
4477
+ (is3DSActive || isSubmitting) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "data-testid": "flopay-overlay", style: {
4317
4478
  position: "absolute",
4318
4479
  inset: 0,
4319
4480
  background: "rgba(255,255,255,0.7)",
@@ -4322,12 +4483,12 @@ function CheckoutFormInner({
4322
4483
  justifyContent: "center",
4323
4484
  zIndex: 10
4324
4485
  }, children: is3DSActive ? "Verifying payment..." : "Processing..." }),
4325
- !isReady && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." }),
4326
- isReady && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
4327
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PaymentElement, { options: { layout } }),
4328
- showAddress && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AddressElement, { options: { mode: showAddress === true ? "billing" : showAddress } }),
4329
- displayError && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { role: "alert", "data-testid": "flopay-error", style: { color: "red", margin: "0.75rem 0" }, children: displayError }),
4330
- children ?? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4486
+ !isReady && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." }),
4487
+ isReady && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
4488
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PaymentElement, { options: { layout } }),
4489
+ showAddress && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AddressElement, { options: { mode: showAddress === true ? "billing" : showAddress } }),
4490
+ displayError && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { role: "alert", "data-testid": "flopay-error", style: { color: "red", margin: "0.75rem 0" }, children: displayError }),
4491
+ children ?? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4331
4492
  "button",
4332
4493
  {
4333
4494
  type: "submit",
@@ -4342,8 +4503,8 @@ function CheckoutFormInner({
4342
4503
 
4343
4504
  // src/paypal-button.tsx
4344
4505
  var import_shared9 = require("@flopay/shared");
4345
- var import_react10 = require("react");
4346
- var import_jsx_runtime8 = require("react/jsx-runtime");
4506
+ var import_react11 = require("react");
4507
+ var import_jsx_runtime9 = require("react/jsx-runtime");
4347
4508
  function PayPalButton({
4348
4509
  sessionId,
4349
4510
  billingApiUrl,
@@ -4360,11 +4521,11 @@ function PayPalButton({
4360
4521
  const flopay = useFloPay();
4361
4522
  const elements = useElements();
4362
4523
  const contextBillingUrl = useBillingApiUrl();
4363
- const [ready, setReady] = (0, import_react10.useState)(false);
4364
- const [submitting, setSubmitting] = (0, import_react10.useState)(false);
4365
- const paypalResumeAttempted = (0, import_react10.useRef)(false);
4524
+ const [ready, setReady] = (0, import_react11.useState)(false);
4525
+ const [submitting, setSubmitting] = (0, import_react11.useState)(false);
4526
+ const paypalResumeAttempted = (0, import_react11.useRef)(false);
4366
4527
  const baseUrl = (billingApiUrl || contextBillingUrl).replace(/\/+$/, "");
4367
- const processPaymentInternal = (0, import_react10.useCallback)(
4528
+ const processPaymentInternal = (0, import_react11.useCallback)(
4368
4529
  async (tokenizedBody) => {
4369
4530
  try {
4370
4531
  const response = await fetch(`${baseUrl}/v1/checkouts/sessions/process`, {
@@ -4397,7 +4558,7 @@ function PayPalButton({
4397
4558
  },
4398
4559
  [baseUrl, sessionId, userId, email, firstName, lastName, chv, onComplete, onErrorChange]
4399
4560
  );
4400
- const dispatchTokenizedBody = (0, import_react10.useCallback)(
4561
+ const dispatchTokenizedBody = (0, import_react11.useCallback)(
4401
4562
  (body) => {
4402
4563
  if (onTokenizedBody) {
4403
4564
  onTokenizedBody(body);
@@ -4407,7 +4568,7 @@ function PayPalButton({
4407
4568
  },
4408
4569
  [onTokenizedBody, processPaymentInternal]
4409
4570
  );
4410
- (0, import_react10.useEffect)(() => {
4571
+ (0, import_react11.useEffect)(() => {
4411
4572
  if (!flopay || paypalResumeAttempted.current) return;
4412
4573
  const params = new URLSearchParams(window.location.search);
4413
4574
  const paymentIntentId = params.get("payment_intent");
@@ -4455,7 +4616,7 @@ function PayPalButton({
4455
4616
  }
4456
4617
  })();
4457
4618
  }, [flopay, dispatchTokenizedBody, onErrorChange]);
4458
- const handlePayPalConfirm = (0, import_react10.useCallback)(async () => {
4619
+ const handlePayPalConfirm = (0, import_react11.useCallback)(async () => {
4459
4620
  if (!flopay || !elements) return;
4460
4621
  try {
4461
4622
  setSubmitting(true);
@@ -4488,11 +4649,11 @@ function PayPalButton({
4488
4649
  }
4489
4650
  }, [flopay, elements, sessionId, email, baseUrl, dispatchTokenizedBody, onErrorChange]);
4490
4651
  if (!flopay || !elements) {
4491
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6, animation: "pulse 1.5s infinite" } });
4652
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6, animation: "pulse 1.5s infinite" } });
4492
4653
  }
4493
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
4494
- !ready && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6 } }),
4495
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: ready ? {} : { display: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4654
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
4655
+ !ready && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6 } }),
4656
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: ready ? {} : { display: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
4496
4657
  "button",
4497
4658
  {
4498
4659
  type: "button",
@@ -4514,7 +4675,7 @@ function PayPalButton({
4514
4675
  children: submitting ? "Processing..." : "PayPal"
4515
4676
  }
4516
4677
  ) }),
4517
- (submitting || isProcessing) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
4678
+ (submitting || isProcessing) && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: {
4518
4679
  position: "fixed",
4519
4680
  inset: 0,
4520
4681
  background: "rgba(0,0,0,0.4)",
@@ -4522,7 +4683,7 @@ function PayPalButton({
4522
4683
  alignItems: "center",
4523
4684
  justifyContent: "center",
4524
4685
  zIndex: 1e3
4525
- }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
4686
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: {
4526
4687
  background: "white",
4527
4688
  borderRadius: 8,
4528
4689
  padding: "1.5rem",
@@ -4534,10 +4695,10 @@ function PayPalButton({
4534
4695
  }
4535
4696
 
4536
4697
  // src/automatic-payment-button.tsx
4537
- var import_react11 = require("react");
4698
+ var import_react12 = require("react");
4538
4699
  var import_js3 = require("@flopay/js");
4539
4700
  var import_shared10 = require("@flopay/shared");
4540
- var import_jsx_runtime9 = require("react/jsx-runtime");
4701
+ var import_jsx_runtime10 = require("react/jsx-runtime");
4541
4702
  var DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT3 = 44;
4542
4703
  var PAYPAL_RESUME_STORAGE_KEY2 = "flopay_automatic_payment_button_resume";
4543
4704
  function sleep2(ms) {
@@ -4654,11 +4815,11 @@ function FloPayAutomaticPaymentButton({
4654
4815
  style,
4655
4816
  ...buttonProps
4656
4817
  }) {
4657
- const resolvedBillingUrl = (0, import_react11.useMemo)(
4818
+ const resolvedBillingUrl = (0, import_react12.useMemo)(
4658
4819
  () => (0, import_shared10.resolveBillingApiUrl)(billingApiUrl),
4659
4820
  [billingApiUrl]
4660
4821
  );
4661
- const createSessionDraft = (0, import_react11.useMemo)(
4822
+ const createSessionDraft = (0, import_react12.useMemo)(
4662
4823
  () => resolveCreateSessionDraft({
4663
4824
  createSession,
4664
4825
  clientId,
@@ -4684,11 +4845,11 @@ function FloPayAutomaticPaymentButton({
4684
4845
  utmMetadata
4685
4846
  ]
4686
4847
  );
4687
- const [isProcessing, setIsProcessing] = (0, import_react11.useState)(false);
4688
- const [overlayStatus, setOverlayStatus] = (0, import_react11.useState)(null);
4689
- const [overlayError, setOverlayError] = (0, import_react11.useState)(null);
4690
- const [fallbackSession, setFallbackSession] = (0, import_react11.useState)(null);
4691
- const automaticPaymentToken = (0, import_react11.useMemo)(
4848
+ const [isProcessing, setIsProcessing] = (0, import_react12.useState)(false);
4849
+ const [overlayStatus, setOverlayStatus] = (0, import_react12.useState)(null);
4850
+ const [overlayError, setOverlayError] = (0, import_react12.useState)(null);
4851
+ const [fallbackSession, setFallbackSession] = (0, import_react12.useState)(null);
4852
+ const automaticPaymentToken = (0, import_react12.useMemo)(
4692
4853
  () => paymentMethodId ? {
4693
4854
  id: paymentMethodId,
4694
4855
  type: "card",
@@ -4696,31 +4857,31 @@ function FloPayAutomaticPaymentButton({
4696
4857
  } : void 0,
4697
4858
  [checkoutMethod, paymentMethodId]
4698
4859
  );
4699
- const isMountedRef = (0, import_react11.useRef)(true);
4700
- const resumeAttemptedRef = (0, import_react11.useRef)(false);
4701
- const fallbackSessionRef = (0, import_react11.useRef)(fallbackSession);
4702
- const onSuccessRef = (0, import_react11.useRef)(onSuccess);
4703
- const onErrorRef = (0, import_react11.useRef)(onError);
4704
- const onDeclineRef = (0, import_react11.useRef)(onDecline);
4705
- (0, import_react11.useEffect)(() => {
4860
+ const isMountedRef = (0, import_react12.useRef)(true);
4861
+ const resumeAttemptedRef = (0, import_react12.useRef)(false);
4862
+ const fallbackSessionRef = (0, import_react12.useRef)(fallbackSession);
4863
+ const onSuccessRef = (0, import_react12.useRef)(onSuccess);
4864
+ const onErrorRef = (0, import_react12.useRef)(onError);
4865
+ const onDeclineRef = (0, import_react12.useRef)(onDecline);
4866
+ (0, import_react12.useEffect)(() => {
4706
4867
  fallbackSessionRef.current = fallbackSession;
4707
4868
  }, [fallbackSession]);
4708
- (0, import_react11.useEffect)(() => {
4869
+ (0, import_react12.useEffect)(() => {
4709
4870
  onSuccessRef.current = onSuccess;
4710
4871
  }, [onSuccess]);
4711
- (0, import_react11.useEffect)(() => {
4872
+ (0, import_react12.useEffect)(() => {
4712
4873
  onErrorRef.current = onError;
4713
4874
  }, [onError]);
4714
- (0, import_react11.useEffect)(() => {
4875
+ (0, import_react12.useEffect)(() => {
4715
4876
  onDeclineRef.current = onDecline;
4716
4877
  }, [onDecline]);
4717
- (0, import_react11.useEffect)(() => {
4878
+ (0, import_react12.useEffect)(() => {
4718
4879
  isMountedRef.current = true;
4719
4880
  return () => {
4720
4881
  isMountedRef.current = false;
4721
4882
  };
4722
4883
  }, []);
4723
- (0, import_react11.useEffect)(() => {
4884
+ (0, import_react12.useEffect)(() => {
4724
4885
  if (!fallbackSession || typeof window === "undefined") {
4725
4886
  return;
4726
4887
  }
@@ -4734,13 +4895,13 @@ function FloPayAutomaticPaymentButton({
4734
4895
  window.removeEventListener("keydown", handleKeyDown);
4735
4896
  };
4736
4897
  }, [fallbackSession]);
4737
- const emitDecline = (0, import_react11.useCallback)((error, method = DEFAULT_SAVED_PAYMENT_DECLINE_METHOD) => {
4898
+ const emitDecline = (0, import_react12.useCallback)((error, method = DEFAULT_SAVED_PAYMENT_DECLINE_METHOD) => {
4738
4899
  onDeclineRef.current?.(buildDeclineEvent(method, error, {
4739
4900
  code: error.code,
4740
4901
  declineCode: error.declineCode
4741
4902
  }));
4742
4903
  }, []);
4743
- const showSuccess = (0, import_react11.useCallback)(async (event) => {
4904
+ const showSuccess = (0, import_react12.useCallback)(async (event) => {
4744
4905
  if (!isMountedRef.current) return;
4745
4906
  setOverlayError(null);
4746
4907
  setOverlayStatus("success");
@@ -4748,7 +4909,7 @@ function FloPayAutomaticPaymentButton({
4748
4909
  if (!isMountedRef.current) return;
4749
4910
  onSuccessRef.current?.(event);
4750
4911
  }, []);
4751
- const showError = (0, import_react11.useCallback)(async (error, options) => {
4912
+ const showError = (0, import_react12.useCallback)(async (error, options) => {
4752
4913
  if (!isMountedRef.current) return;
4753
4914
  onErrorRef.current?.(error);
4754
4915
  if (options?.emitDecline) {
@@ -4758,7 +4919,7 @@ function FloPayAutomaticPaymentButton({
4758
4919
  setOverlayStatus("error");
4759
4920
  await sleep2(PROCESSING_OVERLAY_ERROR_DELAY_MS);
4760
4921
  }, [emitDecline]);
4761
- const processResolvedSession = (0, import_react11.useCallback)(async (apiResult, resolvedSessionId, options) => {
4922
+ const processResolvedSession = (0, import_react12.useCallback)(async (apiResult, resolvedSessionId, options) => {
4762
4923
  const session = apiResult.data.session ?? null;
4763
4924
  if (!session) {
4764
4925
  throw new import_shared10.FloPayError("No session data returned", "api_error");
@@ -4925,6 +5086,14 @@ function FloPayAutomaticPaymentButton({
4925
5086
  if (floPayErr.code === "payment_intent_unexpected_state" && inResumeWindow) {
4926
5087
  return;
4927
5088
  }
5089
+ const isSilentFallbackCase = (floPayErr.code === "paypal_requires_user_interaction" || floPayErr.code === "payment_intent_unexpected_state") && shouldShowFallbackCheckout(floPayErr, fallbackSessionId) && !!fallbackSessionId && isMountedRef.current;
5090
+ if (isSilentFallbackCase) {
5091
+ setFallbackSession({
5092
+ sessionId: fallbackSessionId,
5093
+ errorMessage: ""
5094
+ });
5095
+ return;
5096
+ }
4928
5097
  await showError(floPayErr, {
4929
5098
  emitDecline: true,
4930
5099
  method: floPayErr.checkoutMethod ?? DEFAULT_SAVED_PAYMENT_DECLINE_METHOD
@@ -4945,7 +5114,7 @@ function FloPayAutomaticPaymentButton({
4945
5114
  showError,
4946
5115
  showSuccess
4947
5116
  ]);
4948
- const handleButtonClick = (0, import_react11.useCallback)(async (event) => {
5117
+ const handleButtonClick = (0, import_react12.useCallback)(async (event) => {
4949
5118
  buttonProps.onClick?.(event);
4950
5119
  if (event.defaultPrevented || disabled || isProcessing) {
4951
5120
  return;
@@ -5027,7 +5196,7 @@ function FloPayAutomaticPaymentButton({
5027
5196
  showError,
5028
5197
  showSuccess
5029
5198
  ]);
5030
- const handleFallbackComplete = (0, import_react11.useCallback)((result) => {
5199
+ const handleFallbackComplete = (0, import_react12.useCallback)((result) => {
5031
5200
  const activeFallback = fallbackSessionRef.current;
5032
5201
  setFallbackSession(null);
5033
5202
  onSuccessRef.current?.({
@@ -5037,13 +5206,13 @@ function FloPayAutomaticPaymentButton({
5037
5206
  autoCompleted: false
5038
5207
  });
5039
5208
  }, []);
5040
- const handleFallbackError = (0, import_react11.useCallback)((error) => {
5209
+ const handleFallbackError = (0, import_react12.useCallback)((error) => {
5041
5210
  onErrorRef.current?.(error);
5042
5211
  }, []);
5043
- const handleFallbackDecline = (0, import_react11.useCallback)((decline) => {
5212
+ const handleFallbackDecline = (0, import_react12.useCallback)((decline) => {
5044
5213
  onDeclineRef.current?.(decline);
5045
5214
  }, []);
5046
- (0, import_react11.useEffect)(() => {
5215
+ (0, import_react12.useEffect)(() => {
5047
5216
  if (typeof window === "undefined" || resumeAttemptedRef.current) {
5048
5217
  return;
5049
5218
  }
@@ -5174,7 +5343,7 @@ function FloPayAutomaticPaymentButton({
5174
5343
  }
5175
5344
  })();
5176
5345
  }, [locale, resolvedBillingUrl, showError, showSuccess]);
5177
- const bStyles = (0, import_react11.useMemo)(() => {
5346
+ const bStyles = (0, import_react12.useMemo)(() => {
5178
5347
  const base = (0, import_shared10.resolveButtonsLayoutTheme)(buttonsTheme);
5179
5348
  if (!stylesOverride) return base;
5180
5349
  return {
@@ -5184,8 +5353,8 @@ function FloPayAutomaticPaymentButton({
5184
5353
  };
5185
5354
  }, [buttonsTheme, stylesOverride]);
5186
5355
  const cardButtonSizing = children === void 0 ? { boxSizing: "border-box", height: DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT3, padding: "0 1rem" } : { padding: "0.9rem 1rem" };
5187
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
5188
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
5356
+ return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
5357
+ /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
5189
5358
  "button",
5190
5359
  {
5191
5360
  ...buttonProps,
@@ -5226,17 +5395,17 @@ function FloPayAutomaticPaymentButton({
5226
5395
  e.currentTarget.style.transform = "scale(1)";
5227
5396
  }
5228
5397
  },
5229
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CardButtonContentSlot, { content: children })
5398
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CardButtonContentSlot, { content: children })
5230
5399
  }
5231
5400
  ),
5232
- overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
5401
+ overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
5233
5402
  ProcessingOverlay,
5234
5403
  {
5235
5404
  status: overlayStatus,
5236
5405
  errorMessage: overlayError
5237
5406
  }
5238
5407
  ),
5239
- fallbackSession && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
5408
+ fallbackSession && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
5240
5409
  "div",
5241
5410
  {
5242
5411
  "data-testid": "flopay-automatic-payment-fallback",
@@ -5257,7 +5426,7 @@ function FloPayAutomaticPaymentButton({
5257
5426
  padding: "1.5rem",
5258
5427
  zIndex: 1100
5259
5428
  },
5260
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
5429
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
5261
5430
  "div",
5262
5431
  {
5263
5432
  style: {
@@ -5273,7 +5442,7 @@ function FloPayAutomaticPaymentButton({
5273
5442
  flexDirection: "column",
5274
5443
  gap: "1rem"
5275
5444
  },
5276
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
5445
+ children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
5277
5446
  FloPayCheckout,
5278
5447
  {
5279
5448
  sessionId: fallbackSession.sessionId,
@@ -5304,9 +5473,11 @@ function FloPayAutomaticPaymentButton({
5304
5473
  FloPayAutomaticPaymentButton,
5305
5474
  FloPayCheckout,
5306
5475
  FloPayProvider,
5476
+ InAppBrowserNotice,
5307
5477
  PayPalButton,
5308
5478
  PaymentElement,
5309
5479
  SplitCardForm,
5480
+ isInAppBrowser,
5310
5481
  useCheckout,
5311
5482
  useElements,
5312
5483
  useFloPay,