@flopay/react 0.5.17 → 0.5.19

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,11 +39,9 @@ __export(index_exports, {
39
39
  FloPayAutomaticPaymentButton: () => FloPayAutomaticPaymentButton,
40
40
  FloPayCheckout: () => FloPayCheckout,
41
41
  FloPayProvider: () => FloPayProvider,
42
- InAppBrowserNotice: () => InAppBrowserNotice,
43
42
  PayPalButton: () => PayPalButton,
44
43
  PaymentElement: () => PaymentElement,
45
44
  SplitCardForm: () => SplitCardForm,
46
- isInAppBrowser: () => isInAppBrowser,
47
45
  useCheckout: () => useCheckout,
48
46
  useElements: () => useElements,
49
47
  useFloPay: () => useFloPay,
@@ -153,8 +151,8 @@ function FloPayProvider({
153
151
  }
154
152
 
155
153
  // src/flopay-checkout.tsx
156
- var import_react9 = __toESM(require("react"), 1);
157
- var import_js2 = require("@flopay/js");
154
+ var import_react8 = __toESM(require("react"), 1);
155
+ var import_js3 = require("@flopay/js");
158
156
  var import_shared7 = require("@flopay/shared");
159
157
 
160
158
  // src/card-button-content.tsx
@@ -287,7 +285,8 @@ var AddressElement = createElementComponent("address", "AddressElement");
287
285
  // src/split-card-form.tsx
288
286
  var import_react_stripe_js = require("@stripe/react-stripe-js");
289
287
  var import_shared4 = require("@flopay/shared");
290
- var import_react8 = require("react");
288
+ var import_js = require("@flopay/js");
289
+ var import_react7 = require("react");
291
290
 
292
291
  // src/hooks.ts
293
292
  var import_react5 = require("react");
@@ -660,9 +659,6 @@ function wasSessionRecentlyCompleted(sessionId) {
660
659
  }
661
660
  }
662
661
 
663
- // src/in-app-browser-notice.tsx
664
- var import_react7 = require("react");
665
-
666
662
  // src/in-app-browser.ts
667
663
  function isInAppBrowser(userAgent) {
668
664
  const ua = userAgent ?? (typeof navigator !== "undefined" ? navigator.userAgent : "");
@@ -678,101 +674,9 @@ function isInAppBrowser(userAgent) {
678
674
  return false;
679
675
  }
680
676
 
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
-
773
677
  // src/split-card-form.tsx
774
678
  var import_shared5 = require("@flopay/shared");
775
- var import_jsx_runtime6 = require("react/jsx-runtime");
679
+ var import_jsx_runtime5 = require("react/jsx-runtime");
776
680
  var WALLET_RESUME_KEY = "flopay_wallet_resume";
777
681
  var FLOPAY_KEYFRAMES = `
778
682
  @keyframes flopay-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
@@ -814,7 +718,7 @@ function normalizeBeforeButtonClickError(method, err) {
814
718
  );
815
719
  }
816
720
  function FloPayKeyframes() {
817
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("style", { children: FLOPAY_KEYFRAMES });
721
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("style", { children: FLOPAY_KEYFRAMES });
818
722
  }
819
723
  function toCssSize(value) {
820
724
  if (typeof value === "number") return `${value}px`;
@@ -835,8 +739,8 @@ function ExpressCheckoutReadySwap({
835
739
  children
836
740
  }) {
837
741
  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)(
742
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { position: "relative", minHeight: 44 }, children: [
743
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
840
744
  "div",
841
745
  {
842
746
  "data-testid": placeholderTestId,
@@ -855,7 +759,7 @@ function ExpressCheckoutReadySwap({
855
759
  }
856
760
  }
857
761
  ),
858
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
762
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
859
763
  "div",
860
764
  {
861
765
  style: {
@@ -870,9 +774,12 @@ function ExpressCheckoutReadySwap({
870
774
  )
871
775
  ] });
872
776
  }
873
- var SplitCardForm = (0, import_react8.forwardRef)(
777
+ function isExpressCheckoutRowVisible(state) {
778
+ return state !== "unavailable" && state !== "load_error";
779
+ }
780
+ var SplitCardForm = (0, import_react7.forwardRef)(
874
781
  function SplitCardForm2(props, ref) {
875
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(SplitCardFormInner, { ...props, innerRef: ref });
782
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(SplitCardFormInner, { ...props, innerRef: ref });
876
783
  }
877
784
  );
878
785
  function PayPalButtonInner({
@@ -889,19 +796,15 @@ function PayPalButtonInner({
889
796
  }) {
890
797
  const stripe = (0, import_react_stripe_js.useStripe)();
891
798
  const elements = (0, import_react_stripe_js.useElements)();
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);
799
+ const [loadState, setLoadState] = (0, import_react7.useState)("loading");
800
+ (0, import_react7.useEffect)(() => {
801
+ onLoadStateChange?.(loadState);
802
+ }, [loadState, onLoadStateChange]);
803
+ const [submitting, setSubmitting] = (0, import_react7.useState)(false);
804
+ const paypalResumeAttempted = (0, import_react7.useRef)(false);
805
+ const beforeClickRef = (0, import_react7.useRef)(null);
903
806
  const baseUrl = billingApiUrl.replace(/\/+$/, "");
904
- (0, import_react8.useEffect)(() => {
807
+ (0, import_react7.useEffect)(() => {
905
808
  if (!stripe || paypalResumeAttempted.current) return;
906
809
  const params = new URLSearchParams(window.location.search);
907
810
  const paymentIntentId = params.get("payment_intent");
@@ -948,7 +851,7 @@ function PayPalButtonInner({
948
851
  }
949
852
  })();
950
853
  }, [stripe, onTokenizedBody, onErrorChange, onDecline]);
951
- const handlePayPalClick = (0, import_react8.useCallback)(async (event) => {
854
+ const handlePayPalClick = (0, import_react7.useCallback)(async (event) => {
952
855
  if (isProcessing || submitting) {
953
856
  event.reject();
954
857
  return;
@@ -966,7 +869,7 @@ function PayPalButtonInner({
966
869
  onButtonClick?.("paypal");
967
870
  event.resolve();
968
871
  }, [isProcessing, onButtonClick, runBeforeButtonClick, submitting]);
969
- const handlePayPalConfirm = (0, import_react8.useCallback)(async (event) => {
872
+ const handlePayPalConfirm = (0, import_react7.useCallback)(async (event) => {
970
873
  if (!stripe || !elements) return;
971
874
  let prepared = beforeClickRef.current;
972
875
  beforeClickRef.current = null;
@@ -1058,8 +961,8 @@ function PayPalButtonInner({
1058
961
  setSubmitting(false);
1059
962
  }
1060
963
  }, [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange, onDecline, runBeforeButtonClick]);
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)(
964
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
965
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ExpressCheckoutReadySwap, { state: loadState, placeholderTestId: "flopay-paypal-placeholder", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1063
966
  import_react_stripe_js.ExpressCheckoutElement,
1064
967
  {
1065
968
  onReady: (event) => setLoadState(resolveExpressCheckoutLoadState(event, ["paypal"])),
@@ -1084,7 +987,7 @@ function PayPalButtonInner({
1084
987
  }
1085
988
  }
1086
989
  ) }),
1087
- submitting && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ProcessingOverlay, { status: "processing" })
990
+ submitting && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ProcessingOverlay, { status: "processing" })
1088
991
  ] });
1089
992
  }
1090
993
  function WalletButtonInner({
@@ -1102,19 +1005,15 @@ function WalletButtonInner({
1102
1005
  }) {
1103
1006
  const stripe = (0, import_react_stripe_js.useStripe)();
1104
1007
  const elements = (0, import_react_stripe_js.useElements)();
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);
1008
+ const [loadState, setLoadState] = (0, import_react7.useState)("loading");
1009
+ (0, import_react7.useEffect)(() => {
1010
+ onLoadStateChange?.(loadState);
1011
+ }, [loadState, onLoadStateChange]);
1012
+ const [submitting, setSubmitting] = (0, import_react7.useState)(false);
1114
1013
  const baseUrl = billingApiUrl.replace(/\/+$/, "");
1115
- const lastWalletMethodRef = (0, import_react8.useRef)("card");
1116
- const beforeClickRef = (0, import_react8.useRef)(null);
1117
- const handleWalletConfirm = (0, import_react8.useCallback)(
1014
+ const lastWalletMethodRef = (0, import_react7.useRef)("card");
1015
+ const beforeClickRef = (0, import_react7.useRef)(null);
1016
+ const handleWalletConfirm = (0, import_react7.useCallback)(
1118
1017
  async (event) => {
1119
1018
  if (!stripe || !elements) return;
1120
1019
  const walletType = event.expressPaymentType;
@@ -1203,8 +1102,8 @@ function WalletButtonInner({
1203
1102
  },
1204
1103
  [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange, onDecline, runBeforeButtonClick]
1205
1104
  );
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)(
1105
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1106
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ExpressCheckoutReadySwap, { state: loadState, placeholderTestId: "flopay-wallet-placeholder", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1208
1107
  import_react_stripe_js.ExpressCheckoutElement,
1209
1108
  {
1210
1109
  onReady: (event) => setLoadState(resolveExpressCheckoutLoadState(event, ["applePay", "googlePay"])),
@@ -1243,7 +1142,7 @@ function WalletButtonInner({
1243
1142
  }
1244
1143
  }
1245
1144
  ) }),
1246
- submitting && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(ProcessingOverlay, { status: "processing" })
1145
+ submitting && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ProcessingOverlay, { status: "processing" })
1247
1146
  ] });
1248
1147
  }
1249
1148
  function SplitCardFormInner({
@@ -1300,49 +1199,49 @@ function SplitCardFormInner({
1300
1199
  const flopay = useFloPay();
1301
1200
  const paypalFlopay = usePayPalFloPay();
1302
1201
  const elements = useElements();
1303
- const checkout = (0, import_react8.useContext)(CheckoutContext);
1202
+ const checkout = (0, import_react7.useContext)(CheckoutContext);
1304
1203
  const contextBillingUrl = useBillingApiUrl();
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]);
1204
+ const [processing, setProcessing] = (0, import_react7.useState)(false);
1205
+ const [error, setError] = (0, import_react7.useState)(null);
1206
+ const [is3DSActive, setIs3DSActive] = (0, import_react7.useState)(false);
1207
+ const [selectedCountry, setSelectedCountry] = (0, import_react7.useState)(countryProp ?? "US");
1208
+ const [zipCode, setZipCode] = (0, import_react7.useState)(zipProp ?? "");
1209
+ const [addressLine1, setAddressLine1] = (0, import_react7.useState)(addressLine1Prop ?? "");
1210
+ const [addressLine2, setAddressLine2] = (0, import_react7.useState)(addressLine2Prop ?? "");
1211
+ const [city, setCity] = (0, import_react7.useState)(cityProp ?? "");
1212
+ const [stateValue, setStateValue] = (0, import_react7.useState)(stateProp ?? "");
1213
+ const [accountPatch, setAccountPatch] = (0, import_react7.useState)({});
1214
+ const zipCodeRef = (0, import_react7.useRef)(zipProp ?? "");
1215
+ const selectedCountryRef = (0, import_react7.useRef)(countryProp ?? "US");
1216
+ const addressLine1Ref = (0, import_react7.useRef)(addressLine1Prop ?? "");
1217
+ const addressLine2Ref = (0, import_react7.useRef)(addressLine2Prop ?? "");
1218
+ const cityRef = (0, import_react7.useRef)(cityProp ?? "");
1219
+ const stateRef = (0, import_react7.useRef)(stateProp ?? "");
1220
+ const avsConfig = (0, import_react7.useMemo)(() => (0, import_shared4.resolveAVSConfig)(enableAVSProp), [enableAVSProp]);
1322
1221
  const enableAVS = avsConfig !== null;
1323
- const [viewState, setViewState] = (0, import_react8.useState)(initialCardOpen ? "card" : "buttons");
1222
+ const [viewState, setViewState] = (0, import_react7.useState)(initialCardOpen ? "card" : "buttons");
1324
1223
  const showCardForm = viewState === "expanding" || viewState === "card";
1325
1224
  const TRANSITION_MS = 280;
1326
- const expandToCard = (0, import_react8.useCallback)(() => {
1225
+ const expandToCard = (0, import_react7.useCallback)(() => {
1327
1226
  setViewState("expanding");
1328
1227
  setTimeout(() => setViewState("card"), TRANSITION_MS);
1329
1228
  }, []);
1330
- const collapseToButtons = (0, import_react8.useCallback)(() => {
1229
+ const collapseToButtons = (0, import_react7.useCallback)(() => {
1331
1230
  setViewState("collapsing");
1332
1231
  setTimeout(() => setViewState("buttons"), TRANSITION_MS);
1333
1232
  }, []);
1334
- (0, import_react8.useEffect)(() => {
1233
+ (0, import_react7.useEffect)(() => {
1335
1234
  if (layout === "buttons" && initialCardOpen) {
1336
1235
  setViewState("card");
1337
1236
  }
1338
1237
  }, [layout, initialCardOpen]);
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);
1238
+ const [fullName, setFullName] = (0, import_react7.useState)("");
1239
+ const [formReady, setFormReady] = (0, import_react7.useState)(false);
1240
+ const [overlayStatus, setOverlayStatus] = (0, import_react7.useState)(null);
1241
+ const processingRef = (0, import_react7.useRef)(false);
1343
1242
  const resolvedBillingApiUrl = billingApiUrl || contextBillingUrl;
1344
1243
  const displayError = externalError ?? error;
1345
- const bStyles = (0, import_react8.useMemo)(() => {
1244
+ const bStyles = (0, import_react7.useMemo)(() => {
1346
1245
  const base = (0, import_shared4.resolveButtonsLayoutTheme)(buttonsTheme);
1347
1246
  if (!buttonsStylesOverride) return base;
1348
1247
  return {
@@ -1360,7 +1259,7 @@ function SplitCardFormInner({
1360
1259
  const isSubmitting = (externalProcessing ?? processing) || isInlineSessionPatchProcessing;
1361
1260
  const isSelfContained = !onTokenizedBody;
1362
1261
  const baseUrl = resolvedBillingApiUrl.replace(/\/+$/, "");
1363
- const resolvedAccount = (0, import_react8.useMemo)(() => mergeAccountPatch({
1262
+ const resolvedAccount = (0, import_react7.useMemo)(() => mergeAccountPatch({
1364
1263
  userId,
1365
1264
  email,
1366
1265
  firstName,
@@ -1368,62 +1267,63 @@ function SplitCardFormInner({
1368
1267
  country: countryProp,
1369
1268
  zip: zipProp
1370
1269
  }, accountPatch), [userId, email, firstName, lastName, countryProp, zipProp, accountPatch]);
1371
- const stripeInstance = (0, import_react8.useMemo)(() => {
1270
+ const stripeInstance = (0, import_react7.useMemo)(() => {
1372
1271
  if (!flopay) return null;
1373
1272
  return flopay.getRawProvider();
1374
1273
  }, [flopay]);
1375
- const paypalStripeInstance = (0, import_react8.useMemo)(() => {
1274
+ const paypalStripeInstance = (0, import_react7.useMemo)(() => {
1376
1275
  if (!paypalFlopay) return null;
1377
1276
  return paypalFlopay.getRawProvider();
1378
1277
  }, [paypalFlopay]);
1379
1278
  const amountInCents = totalAmount || 100;
1380
- const walletOptions = (0, import_react8.useMemo)(() => ({
1279
+ const walletOptions = (0, import_react7.useMemo)(() => ({
1381
1280
  mode: "payment",
1382
1281
  amount: amountInCents,
1383
1282
  currency: currency.toLowerCase(),
1384
1283
  paymentMethodCreation: "manual",
1385
1284
  captureMethod: "manual"
1386
1285
  }), [amountInCents, currency]);
1387
- const paypalOptions = (0, import_react8.useMemo)(() => ({
1286
+ const paypalOptions = (0, import_react7.useMemo)(() => ({
1388
1287
  mode: "payment",
1389
1288
  amount: amountInCents,
1390
1289
  currency: currency.toLowerCase(),
1391
1290
  captureMethod: "manual",
1392
1291
  setupFutureUsage: "off_session"
1393
1292
  }), [amountInCents, currency]);
1394
- const updateError = (0, import_react8.useCallback)(
1293
+ const updateError = (0, import_react7.useCallback)(
1395
1294
  (err) => {
1396
1295
  setError(err);
1397
1296
  onErrorChange?.(err);
1398
1297
  },
1399
1298
  [onErrorChange]
1400
1299
  );
1401
- const emitDecline = (0, import_react8.useCallback)(
1300
+ const emitDecline = (0, import_react7.useCallback)(
1402
1301
  (method, input, overrides) => {
1403
1302
  onDecline?.(buildDeclineEvent(method, input, overrides));
1404
1303
  },
1405
1304
  [onDecline]
1406
1305
  );
1407
1306
  const showWallets = showApplePay || showGooglePay;
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)(() => {
1307
+ const [paypalLoadState, setPaypalLoadState] = (0, import_react7.useState)("loading");
1308
+ const [walletLoadState, setWalletLoadState] = (0, import_react7.useState)("loading");
1309
+ const [inAppBrowserDetected, setInAppBrowserDetected] = (0, import_react7.useState)();
1310
+ (0, import_react7.useEffect)(() => {
1412
1311
  setInAppBrowserDetected(isInAppBrowser());
1413
1312
  }, []);
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) => {
1313
+ const shouldShowPayPal = showPayPal && inAppBrowserDetected === false;
1314
+ const shouldShowWallets = showWallets && inAppBrowserDetected === false;
1315
+ const shouldRenderPayPal = shouldShowPayPal && !!paypalStripeInstance;
1316
+ const shouldRenderWallets = shouldShowWallets && !!stripeInstance;
1317
+ const shouldDisplayPayPalRow = shouldRenderPayPal && isExpressCheckoutRowVisible(paypalLoadState);
1318
+ const shouldDisplayWalletRow = shouldRenderWallets && isExpressCheckoutRowVisible(walletLoadState);
1319
+ const handleNameChange = (0, import_react7.useCallback)((value) => {
1420
1320
  setFullName(value);
1421
1321
  onFullNameChange?.(value);
1422
1322
  const parts = value.trim().split(/\s+/);
1423
1323
  onFirstNameChange?.(parts[0] ?? "");
1424
1324
  onLastNameChange?.(parts.length > 1 ? parts.slice(1).join(" ") : "");
1425
1325
  }, [onFullNameChange, onFirstNameChange, onLastNameChange]);
1426
- const applyInlineSessionPatch = (0, import_react8.useCallback)(
1326
+ const applyInlineSessionPatch = (0, import_react7.useCallback)(
1427
1327
  (patch, method) => {
1428
1328
  if (!checkout.applyInlineSessionPatch) {
1429
1329
  return Promise.resolve({ error: null, sessionId });
@@ -1440,7 +1340,7 @@ function SplitCardFormInner({
1440
1340
  },
1441
1341
  [checkout.applyInlineSessionPatch, onError, sessionId, updateError]
1442
1342
  );
1443
- const runBeforeButtonClick = (0, import_react8.useCallback)(async (method) => {
1343
+ const runBeforeButtonClick = (0, import_react7.useCallback)(async (method) => {
1444
1344
  if (!onBeforeButtonClick) return { proceed: true };
1445
1345
  try {
1446
1346
  const result = await onBeforeButtonClick({
@@ -1476,7 +1376,7 @@ function SplitCardFormInner({
1476
1376
  return { proceed: false };
1477
1377
  }
1478
1378
  }, [applyInlineSessionPatch, checkout.inlineSessionDraft, onBeforeButtonClick, onError, sessionId, updateError]);
1479
- const processPaymentInternal = (0, import_react8.useCallback)(
1379
+ const processPaymentInternal = (0, import_react7.useCallback)(
1480
1380
  async (tokenizedBody, overrides) => {
1481
1381
  if (processingRef.current) return;
1482
1382
  processingRef.current = true;
@@ -1488,53 +1388,47 @@ function SplitCardFormInner({
1488
1388
  const resolvedCompletionPaymentMethodId = overrides?.completionPaymentMethodId ?? resolveTokenizedPaymentMethodId(tokenizedBody);
1489
1389
  const requestTokenizedBody = tokenizedBody.originalPaymentMethodId ? { ...tokenizedBody, originalPaymentMethodId: void 0 } : tokenizedBody;
1490
1390
  try {
1491
- const response = await fetch(`${baseUrl}/v1/checkouts/sessions/process`, {
1492
- method: "POST",
1493
- headers: {
1494
- "Content-Type": "application/json",
1495
- "x-user-id": effectiveAccount.userId ?? ""
1391
+ const api = new import_js.PaymentAPI(baseUrl);
1392
+ const response = await api.processPayment(effectiveAccount.userId ?? "", {
1393
+ sessionId: effectiveSessionId,
1394
+ tokenizedData: requestTokenizedBody,
1395
+ accountData: {
1396
+ userId: effectiveAccount.userId ?? "",
1397
+ email: effectiveAccount.email ?? "",
1398
+ firstName: effectiveAccount.firstName ?? fullName.trim().split(/\s+/)[0] ?? "",
1399
+ lastName: effectiveAccount.lastName ?? fullName.trim().split(/\s+/).slice(1).join(" ") ?? "",
1400
+ ...avsConfig ? (() => {
1401
+ const c = selectedCountryRef.current;
1402
+ const stateVisible = (0, import_shared4.isAVSFieldVisible)(avsConfig.state, c);
1403
+ const line1Visible = (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, c);
1404
+ const zipVisible = (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, c);
1405
+ const derivedState = line1Visible && !stateVisible && zipVisible ? (0, import_shared4.getStateFromPostalCode)(c, zipCodeRef.current ?? "") : null;
1406
+ const stateValue2 = stateVisible ? stateRef.current : derivedState;
1407
+ return {
1408
+ country: c,
1409
+ ...zipVisible && zipCodeRef.current ? { zip: zipCodeRef.current } : {},
1410
+ ...(0, import_shared4.isAVSFieldVisible)(avsConfig.city, c) && cityRef.current ? { city: cityRef.current } : {},
1411
+ ...stateValue2 ? { state: stateValue2 } : {},
1412
+ ...line1Visible && addressLine1Ref.current ? { addressLine1: addressLine1Ref.current } : {},
1413
+ ...(0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_2, c) && addressLine2Ref.current ? { addressLine2: addressLine2Ref.current } : {}
1414
+ };
1415
+ })() : {}
1496
1416
  },
1497
- body: JSON.stringify({
1498
- sessionId: effectiveSessionId,
1499
- tokenizedData: requestTokenizedBody,
1500
- accountData: {
1501
- userId: effectiveAccount.userId ?? "",
1502
- email: effectiveAccount.email ?? "",
1503
- firstName: effectiveAccount.firstName ?? fullName.trim().split(/\s+/)[0] ?? "",
1504
- lastName: effectiveAccount.lastName ?? fullName.trim().split(/\s+/).slice(1).join(" ") ?? "",
1505
- ...avsConfig ? (() => {
1506
- const c = selectedCountryRef.current;
1507
- const stateVisible = (0, import_shared4.isAVSFieldVisible)(avsConfig.state, c);
1508
- const line1Visible = (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, c);
1509
- const zipVisible = (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, c);
1510
- const derivedState = line1Visible && !stateVisible && zipVisible ? (0, import_shared4.getStateFromPostalCode)(c, zipCodeRef.current ?? "") : null;
1511
- const stateValue2 = stateVisible ? stateRef.current : derivedState;
1512
- return {
1513
- country: c,
1514
- ...zipVisible && zipCodeRef.current ? { zip: zipCodeRef.current } : {},
1515
- ...(0, import_shared4.isAVSFieldVisible)(avsConfig.city, c) && cityRef.current ? { city: cityRef.current } : {},
1516
- ...stateValue2 ? { state: stateValue2 } : {},
1517
- ...line1Visible && addressLine1Ref.current ? { addressLine1: addressLine1Ref.current } : {},
1518
- ...(0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_2, c) && addressLine2Ref.current ? { addressLine2: addressLine2Ref.current } : {}
1519
- };
1520
- })() : {}
1521
- },
1522
- chv,
1523
- // Checkout analytics metadata
1524
- avsCheck: avsCheckProp ?? false,
1525
- checkoutType: checkoutTypeProp,
1526
- checkoutLayout: checkoutLayoutProp,
1527
- // Resolved exposure: which fields were actually shown for the active country.
1528
- // Country-scoped rules (e.g. ['US', 'CA']) are flattened to booleans here.
1529
- avsConfig: avsConfig ? {
1530
- country: (0, import_shared4.isAVSFieldVisible)(avsConfig.country, selectedCountryRef.current),
1531
- postal_code: (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, selectedCountryRef.current),
1532
- address_line_1: (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, selectedCountryRef.current),
1533
- address_line_2: (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_2, selectedCountryRef.current),
1534
- city: (0, import_shared4.isAVSFieldVisible)(avsConfig.city, selectedCountryRef.current),
1535
- state: (0, import_shared4.isAVSFieldVisible)(avsConfig.state, selectedCountryRef.current)
1536
- } : void 0
1537
- })
1417
+ chv,
1418
+ // Checkout analytics metadata
1419
+ avsCheck: avsCheckProp ?? false,
1420
+ checkoutType: checkoutTypeProp,
1421
+ checkoutLayout: checkoutLayoutProp,
1422
+ // Resolved exposure: which fields were actually shown for the active country.
1423
+ // Country-scoped rules (e.g. ['US', 'CA']) are flattened to booleans here.
1424
+ avsConfig: avsConfig ? {
1425
+ country: (0, import_shared4.isAVSFieldVisible)(avsConfig.country, selectedCountryRef.current),
1426
+ postal_code: (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, selectedCountryRef.current),
1427
+ address_line_1: (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, selectedCountryRef.current),
1428
+ address_line_2: (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_2, selectedCountryRef.current),
1429
+ city: (0, import_shared4.isAVSFieldVisible)(avsConfig.city, selectedCountryRef.current),
1430
+ state: (0, import_shared4.isAVSFieldVisible)(avsConfig.state, selectedCountryRef.current)
1431
+ } : void 0
1538
1432
  });
1539
1433
  if (response.ok) {
1540
1434
  markSessionRecentlyCompleted(effectiveSessionId);
@@ -1666,7 +1560,7 @@ function SplitCardFormInner({
1666
1560
  },
1667
1561
  [baseUrl, sessionId, resolvedAccount, fullName, chv, flopay, paypalFlopay, onComplete, onError, updateError, emitDecline]
1668
1562
  );
1669
- const dispatchTokenizedBody = (0, import_react8.useCallback)(
1563
+ const dispatchTokenizedBody = (0, import_react7.useCallback)(
1670
1564
  (tokenizedBody, overrides) => {
1671
1565
  if (onTokenizedBody) {
1672
1566
  onTokenizedBody(tokenizedBody);
@@ -1676,7 +1570,7 @@ function SplitCardFormInner({
1676
1570
  },
1677
1571
  [onTokenizedBody, processPaymentInternal]
1678
1572
  );
1679
- (0, import_react8.useImperativeHandle)(innerRef, () => ({
1573
+ (0, import_react7.useImperativeHandle)(innerRef, () => ({
1680
1574
  async handleNextAction(secret) {
1681
1575
  if (!flopay) return;
1682
1576
  setIs3DSActive(true);
@@ -1703,7 +1597,7 @@ function SplitCardFormInner({
1703
1597
  }
1704
1598
  }
1705
1599
  }), [flopay, dispatchTokenizedBody, onError, updateError, emitDecline]);
1706
- (0, import_react8.useEffect)(() => {
1600
+ (0, import_react7.useEffect)(() => {
1707
1601
  if (typeof window === "undefined") return;
1708
1602
  const stored = localStorage.getItem(WALLET_RESUME_KEY);
1709
1603
  if (!stored) return;
@@ -1721,7 +1615,7 @@ function SplitCardFormInner({
1721
1615
  localStorage.removeItem(WALLET_RESUME_KEY);
1722
1616
  }
1723
1617
  }, [sessionId, dispatchTokenizedBody]);
1724
- const handleSubmit = (0, import_react8.useCallback)(
1618
+ const handleSubmit = (0, import_react7.useCallback)(
1725
1619
  async (e) => {
1726
1620
  e.preventDefault();
1727
1621
  if (!flopay || !elements || isSubmitting || processingRef.current) return;
@@ -1863,7 +1757,7 @@ function SplitCardFormInner({
1863
1757
  );
1864
1758
  const isReady = flopay !== null && elements !== null;
1865
1759
  if (!isReady) {
1866
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." });
1760
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." });
1867
1761
  }
1868
1762
  const isButtons = layout === "buttons";
1869
1763
  const resolvedBorder = isButtons ? bStyles.cardInputBorder ?? "#e5e7eb" : "#A4A4FF";
@@ -1906,7 +1800,7 @@ function SplitCardFormInner({
1906
1800
  invalid: { color: "#ef4444" }
1907
1801
  }
1908
1802
  };
1909
- const cardFormBlock = /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
1803
+ const cardFormBlock = /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
1910
1804
  backgroundColor: cardBg,
1911
1805
  borderRadius: "8px",
1912
1806
  padding: isButtons ? "0" : "1rem",
@@ -1914,7 +1808,7 @@ function SplitCardFormInner({
1914
1808
  ...isButtons ? { padding: bStyles.cardFormContainer?.padding ?? "0" } : {},
1915
1809
  ...sharedInputPlaceholderVars
1916
1810
  }, children: [
1917
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("style", { children: `
1811
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("style", { children: `
1918
1812
  .flopay-shared-input::placeholder {
1919
1813
  color: var(--flopay-input-placeholder-color);
1920
1814
  opacity: 1;
@@ -1923,12 +1817,12 @@ function SplitCardFormInner({
1923
1817
  font-weight: var(--flopay-input-font-weight);
1924
1818
  }
1925
1819
  ` }),
1926
- isButtons && showCardForm && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
1820
+ isButtons && showCardForm && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
1927
1821
  display: "flex",
1928
1822
  alignItems: "center",
1929
1823
  padding: "0.75rem 0 0.625rem"
1930
1824
  }, children: [
1931
- /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
1825
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1932
1826
  "button",
1933
1827
  {
1934
1828
  type: "button",
@@ -1950,7 +1844,7 @@ function SplitCardFormInner({
1950
1844
  },
1951
1845
  "aria-label": "Back to payment methods",
1952
1846
  children: [
1953
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: {
1847
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: {
1954
1848
  display: "inline-flex",
1955
1849
  alignItems: "center",
1956
1850
  justifyContent: "center",
@@ -1960,12 +1854,12 @@ function SplitCardFormInner({
1960
1854
  backgroundColor: "#f3f4f6",
1961
1855
  transition: "background-color 0.15s",
1962
1856
  ...bStyles.backButtonIcon
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 })
1857
+ }, 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" }) }) }),
1858
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
1965
1859
  ]
1966
1860
  }
1967
1861
  ),
1968
- hideTitle ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
1862
+ hideTitle ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1969
1863
  flex: 1,
1970
1864
  textAlign: "center",
1971
1865
  fontWeight: 600,
@@ -1973,18 +1867,18 @@ function SplitCardFormInner({
1973
1867
  color: "#262833",
1974
1868
  paddingRight: 80,
1975
1869
  ...bStyles.title
1976
- }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TitleContentSlot, { content: cardTitleContent }) })
1870
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(TitleContentSlot, { content: cardTitleContent }) })
1977
1871
  ] }),
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: {
1872
+ !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 }) }),
1873
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1980
1874
  backgroundColor: cardInputBg,
1981
1875
  border: `1px solid ${resolvedBorder}`,
1982
1876
  borderTopLeftRadius: "8px",
1983
1877
  borderTopRightRadius: "8px",
1984
1878
  padding: "10px"
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: {
1879
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardNumberElement, { onReady: () => setFormReady(true), options: stripeElementStyle }) }),
1880
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex" }, children: [
1881
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1988
1882
  flex: 1,
1989
1883
  backgroundColor: cardInputBg,
1990
1884
  border: `1px solid ${resolvedBorder}`,
@@ -1992,23 +1886,23 @@ function SplitCardFormInner({
1992
1886
  borderRight: "none",
1993
1887
  borderBottomLeftRadius: "8px",
1994
1888
  padding: "10px"
1995
- }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CardExpiryElement, { options: stripeElementStyle }) }),
1996
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
1889
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardExpiryElement, { options: stripeElementStyle }) }),
1890
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1997
1891
  flex: 1,
1998
1892
  backgroundColor: cardInputBg,
1999
1893
  border: `1px solid ${resolvedBorder}`,
2000
1894
  borderTop: "none",
2001
1895
  borderBottomRightRadius: "8px",
2002
1896
  padding: "10px"
2003
- }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CardCvcElement, { options: stripeElementStyle }) })
1897
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardCvcElement, { options: stripeElementStyle }) })
2004
1898
  ] }),
2005
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
1899
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2006
1900
  backgroundColor: cardInputBg,
2007
1901
  border: `1px solid ${resolvedBorder}`,
2008
1902
  borderRadius: "8px",
2009
1903
  marginTop: "0.5rem",
2010
1904
  padding: "10px"
2011
- }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1905
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2012
1906
  "input",
2013
1907
  {
2014
1908
  className: "flopay-shared-input",
@@ -2047,8 +1941,8 @@ function SplitCardFormInner({
2047
1941
  ...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
2048
1942
  });
2049
1943
  const stateOpts = (0, import_shared4.getStateOptions)(cc);
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)(
1944
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1945
+ (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)(
2052
1946
  "input",
2053
1947
  {
2054
1948
  className: "flopay-shared-input",
@@ -2065,7 +1959,7 @@ function SplitCardFormInner({
2065
1959
  style: inputFieldStyle()
2066
1960
  }
2067
1961
  ) }),
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)(
1962
+ (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)(
2069
1963
  "input",
2070
1964
  {
2071
1965
  className: "flopay-shared-input",
@@ -2081,12 +1975,12 @@ function SplitCardFormInner({
2081
1975
  style: inputFieldStyle()
2082
1976
  }
2083
1977
  ) }),
2084
- ((0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) || (0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc)) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
1978
+ ((0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) || (0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc)) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
2085
1979
  display: "flex",
2086
1980
  gap: "0",
2087
1981
  marginTop: "0.5rem"
2088
1982
  }, children: [
2089
- (0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
1983
+ (0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2090
1984
  flex: 1,
2091
1985
  backgroundColor: cardInputBg,
2092
1986
  border: `1px solid ${resolvedBorder}`,
@@ -2095,7 +1989,7 @@ function SplitCardFormInner({
2095
1989
  borderBottomLeftRadius: "8px",
2096
1990
  ...(0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc) ? { borderRight: "none", borderTopRightRadius: 0, borderBottomRightRadius: 0 } : { borderRadius: "8px" },
2097
1991
  ...isButtons && bStyles.cityInput ? bStyles.cityInput : {}
2098
- }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
1992
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2099
1993
  "input",
2100
1994
  {
2101
1995
  className: "flopay-shared-input",
@@ -2112,7 +2006,7 @@ function SplitCardFormInner({
2112
2006
  style: inputFieldStyle()
2113
2007
  }
2114
2008
  ) }),
2115
- (0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
2009
+ (0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2116
2010
  flex: 1,
2117
2011
  backgroundColor: cardInputBg,
2118
2012
  border: `1px solid ${resolvedBorder}`,
@@ -2121,7 +2015,7 @@ function SplitCardFormInner({
2121
2015
  borderBottomRightRadius: "8px",
2122
2016
  ...(0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) ? { borderTopLeftRadius: 0, borderBottomLeftRadius: 0 } : { borderRadius: "8px" },
2123
2017
  ...isButtons && bStyles.stateInput ? bStyles.stateInput : {}
2124
- }, children: stateOpts ? /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
2018
+ }, children: stateOpts ? /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
2125
2019
  "select",
2126
2020
  {
2127
2021
  value: stateValue,
@@ -2135,11 +2029,11 @@ function SplitCardFormInner({
2135
2029
  "data-testid": "flopay-state",
2136
2030
  style: { ...inputFieldStyle(), cursor: "pointer" },
2137
2031
  children: [
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))
2032
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: "", children: (0, import_shared4.getStateLabel)(cc) }),
2033
+ stateOpts.map((s) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("option", { value: s.code, children: s.name }, s.code))
2140
2034
  ]
2141
2035
  }
2142
- ) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2036
+ ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2143
2037
  "input",
2144
2038
  {
2145
2039
  className: "flopay-shared-input",
@@ -2157,20 +2051,20 @@ function SplitCardFormInner({
2157
2051
  }
2158
2052
  ) })
2159
2053
  ] }),
2160
- ((0, import_shared4.isAVSFieldVisible)(avsConfig.country, cc) || (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc)) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
2054
+ ((0, import_shared4.isAVSFieldVisible)(avsConfig.country, cc) || (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc)) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
2161
2055
  display: "flex",
2162
2056
  flexDirection: avsLayoutProp === "column" ? "column" : "row",
2163
2057
  gap: avsLayoutProp === "column" ? "0.5rem" : "0",
2164
2058
  marginTop: "0.5rem"
2165
2059
  }, children: [
2166
- (0, import_shared4.isAVSFieldVisible)(avsConfig.country, cc) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
2060
+ (0, import_shared4.isAVSFieldVisible)(avsConfig.country, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2167
2061
  flex: avsLayoutProp === "row" ? 1 : void 0,
2168
2062
  backgroundColor: cardInputBg,
2169
2063
  border: `1px solid ${resolvedBorder}`,
2170
2064
  padding: "10px",
2171
2065
  ...avsLayoutProp === "row" && (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc) ? { borderRadius: "0", borderTopLeftRadius: "8px", borderBottomLeftRadius: "8px", borderRight: "none" } : { borderRadius: "8px" },
2172
2066
  ...isButtons && bStyles.countrySelect ? bStyles.countrySelect : {}
2173
- }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2067
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2174
2068
  "select",
2175
2069
  {
2176
2070
  value: selectedCountry,
@@ -2185,21 +2079,21 @@ function SplitCardFormInner({
2185
2079
  autoComplete: "country",
2186
2080
  "data-testid": "flopay-country",
2187
2081
  style: { ...inputFieldStyle(), cursor: "pointer" },
2188
- children: import_shared4.COUNTRY_OPTIONS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("option", { value: c.code, children: [
2082
+ children: import_shared4.COUNTRY_OPTIONS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("option", { value: c.code, children: [
2189
2083
  c.flag,
2190
2084
  " ",
2191
2085
  c.name
2192
2086
  ] }, c.code))
2193
2087
  }
2194
2088
  ) }),
2195
- (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
2089
+ (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2196
2090
  flex: avsLayoutProp === "row" ? 1 : void 0,
2197
2091
  backgroundColor: cardInputBg,
2198
2092
  border: `1px solid ${resolvedBorder}`,
2199
2093
  padding: "10px",
2200
2094
  ...avsLayoutProp === "row" && (0, import_shared4.isAVSFieldVisible)(avsConfig.country, cc) ? { borderRadius: "0", borderTopRightRadius: "8px", borderBottomRightRadius: "8px" } : { borderRadius: "8px" },
2201
2095
  ...isButtons && bStyles.zipInput ? bStyles.zipInput : {}
2202
- }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2096
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2203
2097
  "input",
2204
2098
  {
2205
2099
  className: "flopay-shared-input",
@@ -2220,7 +2114,7 @@ function SplitCardFormInner({
2220
2114
  ] })
2221
2115
  ] });
2222
2116
  })(),
2223
- displayError && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
2117
+ displayError && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
2224
2118
  margin: "0.75rem 0",
2225
2119
  padding: "0.625rem 0.875rem",
2226
2120
  background: "#FEF2F2",
@@ -2234,10 +2128,10 @@ function SplitCardFormInner({
2234
2128
  gap: "0.5rem",
2235
2129
  ...isButtons && bStyles.errorBanner ? bStyles.errorBanner : {}
2236
2130
  }, children: [
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" }) }),
2131
+ /* @__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" }) }),
2238
2132
  displayError
2239
2133
  ] }),
2240
- children ?? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2134
+ children ?? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2241
2135
  "button",
2242
2136
  {
2243
2137
  type: "submit",
@@ -2260,7 +2154,7 @@ function SplitCardFormInner({
2260
2154
  children: isSubmitting ? "PROCESSING..." : submitLabel
2261
2155
  }
2262
2156
  ),
2263
- !isButtons && showSecurityFooter && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
2157
+ !isButtons && showSecurityFooter && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2264
2158
  backgroundColor: "#EFF9F0",
2265
2159
  borderRadius: "8px",
2266
2160
  padding: "0.75rem",
@@ -2277,11 +2171,11 @@ function SplitCardFormInner({
2277
2171
  const cardButtonSizing = cardButtonContent === void 0 ? { boxSizing: "border-box", height: DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT, padding: "0 1rem" } : { padding: "0.9rem 1rem" };
2278
2172
  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;
2279
2173
  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;
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: {
2174
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
2175
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FloPayKeyframes, {}),
2176
+ overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
2177
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "grid" }, children: [
2178
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
2285
2179
  gridArea: "1 / 1",
2286
2180
  display: "flex",
2287
2181
  flexDirection: "column",
@@ -2290,7 +2184,7 @@ function SplitCardFormInner({
2290
2184
  ...!isButtonsView && !buttonsAnim ? { visibility: "hidden", position: "absolute", pointerEvents: "none", width: "100%" } : {},
2291
2185
  ...buttonsAnim ? { animation: buttonsAnim, pointerEvents: "none" } : {}
2292
2186
  }, children: [
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)(
2187
+ shouldRenderPayPal && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_stripe_js.Elements, { stripe: paypalStripeInstance, options: paypalOptions, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2294
2188
  PayPalButtonInner,
2295
2189
  {
2296
2190
  sessionId,
@@ -2305,7 +2199,7 @@ function SplitCardFormInner({
2305
2199
  onLoadStateChange: setPaypalLoadState
2306
2200
  }
2307
2201
  ) }),
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)(
2202
+ shouldRenderWallets ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2309
2203
  WalletButtonInner,
2310
2204
  {
2311
2205
  sessionId,
@@ -2320,9 +2214,8 @@ function SplitCardFormInner({
2320
2214
  runBeforeButtonClick,
2321
2215
  onLoadStateChange: setWalletLoadState
2322
2216
  }
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)(
2217
+ ) }) : shouldShowWallets ? /* @__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,
2218
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2326
2219
  "button",
2327
2220
  {
2328
2221
  type: "button",
@@ -2360,10 +2253,10 @@ function SplitCardFormInner({
2360
2253
  onMouseUp: (e) => {
2361
2254
  e.currentTarget.style.transform = "scale(1)";
2362
2255
  },
2363
- children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CardButtonContentSlot, { content: cardButtonContent })
2256
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardButtonContentSlot, { content: cardButtonContent })
2364
2257
  }
2365
2258
  ),
2366
- displayError && viewState === "buttons" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
2259
+ displayError && viewState === "buttons" && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
2367
2260
  margin: "0.25rem 0",
2368
2261
  padding: "0.625rem 0.875rem",
2369
2262
  background: "#FEF2F2",
@@ -2377,11 +2270,11 @@ function SplitCardFormInner({
2377
2270
  gap: "0.5rem",
2378
2271
  ...bStyles.errorBanner ? bStyles.errorBanner : {}
2379
2272
  }, children: [
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" }) }),
2273
+ /* @__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" }) }),
2381
2274
  displayError
2382
2275
  ] })
2383
2276
  ] }),
2384
- isCardView && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
2277
+ isCardView && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
2385
2278
  gridArea: "1 / 1",
2386
2279
  ...cardAnim ? { animation: cardAnim } : {},
2387
2280
  ...viewState === "collapsing" ? { pointerEvents: "none" } : {}
@@ -2389,10 +2282,10 @@ function SplitCardFormInner({
2389
2282
  ] })
2390
2283
  ] });
2391
2284
  }
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)(
2285
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
2286
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FloPayKeyframes, {}),
2287
+ overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
2288
+ shouldRenderWallets && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2396
2289
  WalletButtonInner,
2397
2290
  {
2398
2291
  sessionId,
@@ -2406,7 +2299,7 @@ function SplitCardFormInner({
2406
2299
  onLoadStateChange: setWalletLoadState
2407
2300
  }
2408
2301
  ) }),
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)(
2302
+ shouldRenderPayPal && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_react_stripe_js.Elements, { stripe: paypalStripeInstance, options: paypalOptions, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2410
2303
  PayPalButtonInner,
2411
2304
  {
2412
2305
  sessionId,
@@ -2419,8 +2312,7 @@ function SplitCardFormInner({
2419
2312
  onLoadStateChange: setPaypalLoadState
2420
2313
  }
2421
2314
  ) }),
2422
- showInAppBrowserNotice && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(InAppBrowserNotice, {}),
2423
- (showWallets && stripeInstance || showPayPal && paypalStripeInstance) && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
2315
+ (shouldDisplayWalletRow || shouldDisplayPayPalRow) && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
2424
2316
  display: "flex",
2425
2317
  alignItems: "center",
2426
2318
  gap: "0.75rem",
@@ -2428,16 +2320,16 @@ function SplitCardFormInner({
2428
2320
  color: "#999",
2429
2321
  fontSize: "0.85rem"
2430
2322
  }, children: [
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" } })
2323
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } }),
2324
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { children: "or pay with card" }),
2325
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } })
2434
2326
  ] }),
2435
2327
  cardFormBlock
2436
2328
  ] });
2437
2329
  }
2438
2330
 
2439
2331
  // src/saved-payment-flow.ts
2440
- var import_js = require("@flopay/js");
2332
+ var import_js2 = require("@flopay/js");
2441
2333
  var import_shared6 = require("@flopay/shared");
2442
2334
  var DEFAULT_SAVED_PAYMENT_DECLINE_METHOD = "card";
2443
2335
  function getRedirectResultFromCheckoutProcessError(error) {
@@ -2545,7 +2437,7 @@ async function recover3DSRedirectResult({
2545
2437
  return null;
2546
2438
  }
2547
2439
  try {
2548
- const api = new import_js.PaymentAPI(billingApiUrl);
2440
+ const api = new import_js2.PaymentAPI(billingApiUrl);
2549
2441
  const unified = await api.getUnifiedCheckoutSession(sessionId);
2550
2442
  const refreshedToken = unified.provider === "stripe" ? unified.data.stripe?.clientSecret : void 0;
2551
2443
  if (isStripePaymentIntentClientSecret(refreshedToken)) {
@@ -2573,25 +2465,19 @@ async function processSavedPaymentForMode({
2573
2465
  const lastName = session.customer?.lastName ?? session.accountData?.lastName ?? "";
2574
2466
  const country = session.customer?.country ?? session.accountData?.country ?? void 0;
2575
2467
  const zip = session.customer?.zip ?? session.accountData?.zip ?? void 0;
2576
- const response = await retryOnceOnFetchFailure(() => fetch(`${baseUrl}/v1/checkouts/sessions/process`, {
2577
- method: "POST",
2578
- headers: {
2579
- "Content-Type": "application/json",
2580
- "x-user-id": customerId
2468
+ const api = new import_js2.PaymentAPI(baseUrl);
2469
+ const response = await retryOnceOnFetchFailure(() => api.processPayment(customerId, {
2470
+ sessionId: resolvedSessionId,
2471
+ tokenizedData,
2472
+ accountData: {
2473
+ userId: customerId,
2474
+ email: customerEmail,
2475
+ firstName,
2476
+ lastName,
2477
+ country,
2478
+ zip
2581
2479
  },
2582
- body: JSON.stringify({
2583
- sessionId: resolvedSessionId,
2584
- tokenizedData,
2585
- accountData: {
2586
- userId: customerId,
2587
- email: customerEmail,
2588
- firstName,
2589
- lastName,
2590
- country,
2591
- zip
2592
- },
2593
- returnUrl: returnUrl ?? resolveSavedPaymentReturnUrl(session)
2594
- })
2480
+ returnUrl: returnUrl ?? resolveSavedPaymentReturnUrl(session)
2595
2481
  }));
2596
2482
  if (response.ok) {
2597
2483
  return {
@@ -2664,7 +2550,7 @@ async function processSavedPaymentWithIntent({
2664
2550
  { checkoutMethod: "card" }
2665
2551
  );
2666
2552
  }
2667
- const api = new import_js.PaymentAPI(billingApiUrl);
2553
+ const api = new import_js2.PaymentAPI(billingApiUrl);
2668
2554
  const intentResponse = await retryOnceOnFetchFailure(() => api.createPaymentIntent(
2669
2555
  sessionId,
2670
2556
  customerEmail,
@@ -2950,11 +2836,11 @@ async function loadSavedPaymentProviders({
2950
2836
  }) {
2951
2837
  const needsSeparatePaypal = Boolean(paypalPublishableKey) && paypalPublishableKey !== publishableKey;
2952
2838
  const [instance, paypalInstanceOrError] = await Promise.all([
2953
- (0, import_js.loadFloPay)(publishableKey, {
2839
+ (0, import_js2.loadFloPay)(publishableKey, {
2954
2840
  billingApiUrl,
2955
2841
  locale
2956
2842
  }),
2957
- needsSeparatePaypal ? (0, import_js.loadFloPay)(paypalPublishableKey, {
2843
+ needsSeparatePaypal ? (0, import_js2.loadFloPay)(paypalPublishableKey, {
2958
2844
  billingApiUrl,
2959
2845
  locale
2960
2846
  }).catch((err) => {
@@ -2969,7 +2855,7 @@ async function loadSavedPaymentProviders({
2969
2855
  }
2970
2856
 
2971
2857
  // src/flopay-checkout.tsx
2972
- var import_jsx_runtime7 = require("react/jsx-runtime");
2858
+ var import_jsx_runtime6 = require("react/jsx-runtime");
2973
2859
  var DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2 = 44;
2974
2860
  var PAYPAL_RESUME_STORAGE_KEY = "flopay_checkout_saved_payment_resume";
2975
2861
  var sessionInflightMap = /* @__PURE__ */ new Map();
@@ -3072,37 +2958,37 @@ function FloPayCheckout({
3072
2958
  const resolvedBillingUrl = (0, import_shared7.resolveBillingApiUrl)(billingApiUrl);
3073
2959
  const checkoutType = createSessionParams ? "embedded_checkout" : "standard_checkout";
3074
2960
  const checkoutLayout = children ? "custom_layout" : layout === "buttons" ? "buttons_layout" : "default_layout";
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 ?? "");
2961
+ const [unified, setUnified] = (0, import_react8.useState)(null);
2962
+ const [flopay, setFloPay] = (0, import_react8.useState)(null);
2963
+ const flopayRef = (0, import_react8.useRef)(null);
2964
+ const [paypalFlopay, setPaypalFloPay] = (0, import_react8.useState)(null);
2965
+ const paypalFlopayRef = (0, import_react8.useRef)(null);
2966
+ const [session, setSession] = (0, import_react8.useState)(null);
2967
+ const [resolvedSessionId, setResolvedSessionId] = (0, import_react8.useState)(sessionIdProp ?? "");
3082
2968
  const activeSessionId = sessionIdProp ?? resolvedSessionId;
3083
2969
  const initSessionDependency = createSessionParams ? "" : activeSessionId;
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);
2970
+ const [isLoading, setIsLoading] = (0, import_react8.useState)(true);
2971
+ const [loadError, setLoadError] = (0, import_react8.useState)(null);
2972
+ const [currentMode, setCurrentMode] = (0, import_react8.useState)("full");
2973
+ const [confirmProcessing, setConfirmProcessing] = (0, import_react8.useState)(false);
2974
+ const [modeError, setModeError] = (0, import_react8.useState)(initialErrorMessage);
2975
+ const [modeOverlayStatus, setModeOverlayStatus] = (0, import_react8.useState)(null);
2976
+ const [modeOverlayError, setModeOverlayError] = (0, import_react8.useState)(null);
2977
+ const [createSessionPatch, setCreateSessionPatch] = (0, import_react8.useState)(void 0);
2978
+ const [createSessionPatchBaseHash, setCreateSessionPatchBaseHash] = (0, import_react8.useState)("");
2979
+ const [cardBootstrapPending, setCardBootstrapPending] = (0, import_react8.useState)(false);
2980
+ const autoCheckoutAttempted = (0, import_react8.useRef)(false);
2981
+ const paypalResumeAttempted = (0, import_react8.useRef)(false);
2982
+ const savedPaymentKeysRef = (0, import_react8.useRef)(null);
2983
+ const onCompleteRef = (0, import_react8.useRef)(onComplete);
3098
2984
  onCompleteRef.current = onComplete;
3099
- const onErrorRef = (0, import_react9.useRef)(onError);
2985
+ const onErrorRef = (0, import_react8.useRef)(onError);
3100
2986
  onErrorRef.current = onError;
3101
- const onDeclineRef = (0, import_react9.useRef)(onDecline);
2987
+ const onDeclineRef = (0, import_react8.useRef)(onDecline);
3102
2988
  onDeclineRef.current = onDecline;
3103
- const onSessionCompletedRef = (0, import_react9.useRef)(onSessionCompleted);
2989
+ const onSessionCompletedRef = (0, import_react8.useRef)(onSessionCompleted);
3104
2990
  onSessionCompletedRef.current = onSessionCompleted;
3105
- (0, import_react9.useEffect)(() => {
2991
+ (0, import_react8.useEffect)(() => {
3106
2992
  console.info("[FloPay] Checkout initialized", {
3107
2993
  sdk_version: import_shared7.SDK_VERSION,
3108
2994
  checkout_type: checkoutType,
@@ -3110,40 +2996,40 @@ function FloPayCheckout({
3110
2996
  billing_api_url: resolvedBillingUrl
3111
2997
  });
3112
2998
  }, [checkoutLayout, checkoutType, resolvedBillingUrl]);
3113
- const baseCreateSessionHash = (0, import_react9.useMemo)(
2999
+ const baseCreateSessionHash = (0, import_react8.useMemo)(
3114
3000
  () => createSessionParams ? hashCreateParams(createSessionParams) : "",
3115
3001
  [createSessionParams]
3116
3002
  );
3117
- const activeCreateSessionPatch = (0, import_react9.useMemo)(
3003
+ const activeCreateSessionPatch = (0, import_react8.useMemo)(
3118
3004
  () => createSessionPatchBaseHash === baseCreateSessionHash ? createSessionPatch : void 0,
3119
3005
  [createSessionPatch, createSessionPatchBaseHash, baseCreateSessionHash]
3120
3006
  );
3121
- const effectiveCreateSessionBase = (0, import_react9.useMemo)(
3007
+ const effectiveCreateSessionBase = (0, import_react8.useMemo)(
3122
3008
  () => createSessionParams ? mergeInlineSessionPatch(createSessionParams, activeCreateSessionPatch) : void 0,
3123
3009
  [createSessionParams, activeCreateSessionPatch]
3124
3010
  );
3125
3011
  const effectiveCreateSessionMode = checkoutModeProp ?? effectiveCreateSessionBase?.checkoutMode ?? "full";
3126
- const effectiveCreateSession = (0, import_react9.useMemo)(
3012
+ const effectiveCreateSession = (0, import_react8.useMemo)(
3127
3013
  () => effectiveCreateSessionBase ? {
3128
3014
  ...effectiveCreateSessionBase,
3129
3015
  checkoutMode: effectiveCreateSessionMode
3130
3016
  } : void 0,
3131
3017
  [effectiveCreateSessionBase, effectiveCreateSessionMode]
3132
3018
  );
3133
- (0, import_react9.useEffect)(() => {
3019
+ (0, import_react8.useEffect)(() => {
3134
3020
  setCreateSessionPatch(void 0);
3135
3021
  setCreateSessionPatchBaseHash(baseCreateSessionHash);
3136
3022
  }, [baseCreateSessionHash]);
3137
- (0, import_react9.useEffect)(() => {
3023
+ (0, import_react8.useEffect)(() => {
3138
3024
  setModeError(initialErrorMessage);
3139
3025
  }, [initialErrorMessage]);
3140
- const emitDecline = (0, import_react9.useCallback)(
3026
+ const emitDecline = (0, import_react8.useCallback)(
3141
3027
  (method, input, overrides) => {
3142
3028
  onDeclineRef.current?.(buildDeclineEvent(method, input, overrides));
3143
3029
  },
3144
3030
  []
3145
3031
  );
3146
- const runSavedPaymentFlow = (0, import_react9.useCallback)(
3032
+ const runSavedPaymentFlow = (0, import_react8.useCallback)(
3147
3033
  async (sess, options) => {
3148
3034
  setModeError(null);
3149
3035
  setModeOverlayError(null);
@@ -3171,6 +3057,17 @@ function FloPayCheckout({
3171
3057
  if (redirectResult.type === "paypal_redirect_required") {
3172
3058
  clearPayPalResumeState();
3173
3059
  }
3060
+ } else if (options?.initialAutoProcessingPending) {
3061
+ const api = new import_js3.PaymentAPI(resolvedBillingUrl);
3062
+ const completed = await api.waitForCheckoutSessionCompletion(options.initialAutoProcessingPending.sessionId, {
3063
+ initialDelayMs: options.initialAutoProcessingPending.retryAfterMs
3064
+ });
3065
+ if (completed.data.session?.status !== "complete") {
3066
+ throw new import_shared7.FloPayError("Automatic payment failed. Please try again.", "api_error", {
3067
+ code: completed.data.session?.status === "expired" ? "checkout_session_expired" : "checkout_processing_timeout"
3068
+ });
3069
+ }
3070
+ paymentResult = { status: "succeeded" };
3174
3071
  } else if (options?.initialAutoProcessingError) {
3175
3072
  throw checkoutProcessErrorToFloPayError(
3176
3073
  options.initialAutoProcessingError,
@@ -3250,7 +3147,7 @@ function FloPayCheckout({
3250
3147
  resolvedBillingUrl
3251
3148
  ]
3252
3149
  );
3253
- (0, import_react9.useEffect)(() => {
3150
+ (0, import_react8.useEffect)(() => {
3254
3151
  if (typeof window === "undefined" || paypalResumeAttempted.current) {
3255
3152
  return;
3256
3153
  }
@@ -3313,7 +3210,7 @@ function FloPayCheckout({
3313
3210
  const paymentMethodId = typeof paymentIntent.payment_method === "string" ? paymentIntent.payment_method : paymentIntent.payment_method?.id;
3314
3211
  let finalResultStatus = resultStatus;
3315
3212
  if (resumeState.sessionId) {
3316
- const resumeApi = new import_js2.PaymentAPI(resolvedBillingUrl);
3213
+ const resumeApi = new import_js3.PaymentAPI(resolvedBillingUrl);
3317
3214
  const resumeSessionResult = await resumeApi.getUnifiedCheckoutSession(resumeState.sessionId);
3318
3215
  const resumeSession = resumeSessionResult.data.session;
3319
3216
  if (resumeSession && resumeSession.status !== "complete") {
@@ -3367,7 +3264,7 @@ function FloPayCheckout({
3367
3264
  }
3368
3265
  })();
3369
3266
  }, [emitDecline, locale, normalizeSavedPaymentError, resolvedBillingUrl]);
3370
- const initializedHashRef = (0, import_react9.useRef)(null);
3267
+ const initializedHashRef = (0, import_react8.useRef)(null);
3371
3268
  function hashCreateParams(params) {
3372
3269
  const key = JSON.stringify({
3373
3270
  c: params?.clientId,
@@ -3391,23 +3288,23 @@ function FloPayCheckout({
3391
3288
  }
3392
3289
  return `flopay_session_${Math.abs(h).toString(36)}`;
3393
3290
  }
3394
- const createSessionHash = (0, import_react9.useMemo)(
3291
+ const createSessionHash = (0, import_react8.useMemo)(
3395
3292
  () => effectiveCreateSession ? hashCreateParams(effectiveCreateSession) : "",
3396
3293
  [effectiveCreateSession]
3397
3294
  );
3398
- const createSessionParamsRef = (0, import_react9.useRef)(effectiveCreateSession);
3295
+ const createSessionParamsRef = (0, import_react8.useRef)(effectiveCreateSession);
3399
3296
  createSessionParamsRef.current = effectiveCreateSession;
3400
- (0, import_react9.useEffect)(() => {
3297
+ (0, import_react8.useEffect)(() => {
3401
3298
  setResolvedSessionId(sessionIdProp ?? "");
3402
3299
  }, [sessionIdProp]);
3403
- (0, import_react9.useEffect)(() => {
3300
+ (0, import_react8.useEffect)(() => {
3404
3301
  autoCheckoutAttempted.current = false;
3405
3302
  setModeError(initialErrorMessage);
3406
3303
  setModeOverlayError(null);
3407
3304
  setModeOverlayStatus(null);
3408
3305
  }, [createSessionHash, initialErrorMessage, sessionIdProp]);
3409
3306
  async function resolveInlineSession(params, cacheKey) {
3410
- const api = new import_js2.PaymentAPI(resolvedBillingUrl);
3307
+ const api = new import_js3.PaymentAPI(resolvedBillingUrl);
3411
3308
  let sid = typeof window !== "undefined" ? window.sessionStorage.getItem(cacheKey) : null;
3412
3309
  let realResult = null;
3413
3310
  if (sid) {
@@ -3443,7 +3340,7 @@ function FloPayCheckout({
3443
3340
  }
3444
3341
  return { sid: sid ?? "", result: realResult };
3445
3342
  }
3446
- const bootstrapInlineSession = (0, import_react9.useCallback)(
3343
+ const bootstrapInlineSession = (0, import_react8.useCallback)(
3447
3344
  async (patch) => {
3448
3345
  const baseParams = createSessionParamsRef.current;
3449
3346
  if (!baseParams) {
@@ -3504,7 +3401,7 @@ function FloPayCheckout({
3504
3401
  },
3505
3402
  [locale, resolvedBillingUrl]
3506
3403
  );
3507
- const handleInlineSessionPatch = (0, import_react9.useCallback)(async (patch) => {
3404
+ const handleInlineSessionPatch = (0, import_react8.useCallback)(async (patch) => {
3508
3405
  if (!hasInlineSessionPatchData(patch) || cardBootstrapPending) {
3509
3406
  return {
3510
3407
  sessionId: resolvedSessionId,
@@ -3527,7 +3424,7 @@ function FloPayCheckout({
3527
3424
  resolvedSessionId,
3528
3425
  session
3529
3426
  ]);
3530
- (0, import_react9.useEffect)(() => {
3427
+ (0, import_react8.useEffect)(() => {
3531
3428
  let cancelled = false;
3532
3429
  setLoadError(null);
3533
3430
  if (createSessionHash) {
@@ -3559,6 +3456,7 @@ function FloPayCheckout({
3559
3456
  fallbackToFull: true,
3560
3457
  fromCreateSession: true,
3561
3458
  initialAutoProcessingError: resolved.result.autoProcessingError,
3459
+ initialAutoProcessingPending: resolved.result.autoProcessingPending,
3562
3460
  autoProcessingAttempted: resolved.result.autoProcessingAttempted,
3563
3461
  sessionId: resolved.sid || resolvedSession.id
3564
3462
  });
@@ -3597,7 +3495,7 @@ function FloPayCheckout({
3597
3495
  setIsLoading(true);
3598
3496
  async function init() {
3599
3497
  try {
3600
- const api = new import_js2.PaymentAPI(resolvedBillingUrl);
3498
+ const api = new import_js3.PaymentAPI(resolvedBillingUrl);
3601
3499
  const result = await api.getUnifiedCheckoutSession(activeSessionId);
3602
3500
  if (cancelled) return;
3603
3501
  setUnified(result);
@@ -3686,7 +3584,7 @@ function FloPayCheckout({
3686
3584
  initSessionDependency,
3687
3585
  runSavedPaymentFlow
3688
3586
  ]);
3689
- const handleConfirmCheckout = (0, import_react9.useCallback)(async () => {
3587
+ const handleConfirmCheckout = (0, import_react8.useCallback)(async () => {
3690
3588
  if (confirmProcessing || !session) return;
3691
3589
  setConfirmProcessing(true);
3692
3590
  setModeError(null);
@@ -3699,7 +3597,7 @@ function FloPayCheckout({
3699
3597
  setConfirmProcessing(false);
3700
3598
  }
3701
3599
  }, [activeSessionId, confirmProcessing, runSavedPaymentFlow, session]);
3702
- const providerOptions = (0, import_react9.useMemo)(() => {
3600
+ const providerOptions = (0, import_react8.useMemo)(() => {
3703
3601
  if (!unified || !session) return void 0;
3704
3602
  const opts = {
3705
3603
  appearance,
@@ -3718,7 +3616,7 @@ function FloPayCheckout({
3718
3616
  const shouldHandleInlineSessionPatch = Boolean(
3719
3617
  createSessionParams && !children && layout === "buttons" && onBeforeButtonClick && effectiveCreateSessionMode === "full"
3720
3618
  );
3721
- const checkoutValue = (0, import_react9.useMemo)(
3619
+ const checkoutValue = (0, import_react8.useMemo)(
3722
3620
  () => ({
3723
3621
  session,
3724
3622
  loading: isLoading,
@@ -3740,7 +3638,7 @@ function FloPayCheckout({
3740
3638
  ]
3741
3639
  );
3742
3640
  const shouldShowInterimButtons = Boolean(createSessionParams) && layout === "buttons" && (!flopay || !providerOptions);
3743
- const modeOverlay = modeOverlayStatus ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3641
+ const modeOverlay = modeOverlayStatus ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3744
3642
  ProcessingOverlay,
3745
3643
  {
3746
3644
  status: modeOverlayStatus,
@@ -3749,31 +3647,31 @@ function FloPayCheckout({
3749
3647
  ) : null;
3750
3648
  if (isLoading) {
3751
3649
  if (loadingNode) {
3752
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3650
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3753
3651
  loadingNode,
3754
3652
  modeOverlay
3755
3653
  ] });
3756
3654
  }
3757
3655
  if (layout === "buttons") {
3758
- const skeletonBar = (h) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
3656
+ const skeletonBar = (h) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
3759
3657
  height: h,
3760
3658
  borderRadius: 8,
3761
3659
  background: "#e5e7eb",
3762
3660
  animation: "flopay-loading-pulse 1.5s ease-in-out infinite"
3763
3661
  } });
3764
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3765
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
3662
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3663
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
3766
3664
  showPayPal && skeletonBar(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
3767
3665
  (showApplePay || showGooglePay) && skeletonBar(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
3768
3666
  skeletonBar(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
3769
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("style", { children: `@keyframes flopay-loading-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
3667
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("style", { children: `@keyframes flopay-loading-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
3770
3668
  ] }),
3771
3669
  modeOverlay
3772
3670
  ] });
3773
3671
  }
3774
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3775
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", justifyContent: "center", padding: 32 }, children: [
3776
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
3672
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3673
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", justifyContent: "center", padding: 32 }, children: [
3674
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
3777
3675
  width: 24,
3778
3676
  height: 24,
3779
3677
  border: "2px solid #e5e7eb",
@@ -3781,16 +3679,16 @@ function FloPayCheckout({
3781
3679
  borderRadius: "50%",
3782
3680
  animation: "spin 0.6s linear infinite"
3783
3681
  } }),
3784
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` })
3682
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` })
3785
3683
  ] }),
3786
3684
  modeOverlay
3787
3685
  ] });
3788
3686
  }
3789
3687
  if (loadError) {
3790
3688
  if (errorNode) {
3791
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: errorNode(loadError) });
3689
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: errorNode(loadError) });
3792
3690
  }
3793
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3691
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3794
3692
  "div",
3795
3693
  {
3796
3694
  style: {
@@ -3804,8 +3702,8 @@ function FloPayCheckout({
3804
3702
  ) });
3805
3703
  }
3806
3704
  if (shouldShowInterimButtons) {
3807
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3808
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3705
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3706
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3809
3707
  InterimButtonsView,
3810
3708
  {
3811
3709
  onButtonClick,
@@ -3823,12 +3721,12 @@ function FloPayCheckout({
3823
3721
  ] });
3824
3722
  }
3825
3723
  if (!flopay || !providerOptions) {
3826
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: modeOverlay });
3724
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: modeOverlay });
3827
3725
  }
3828
3726
  if (currentMode === "confirm") {
3829
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3830
- /* @__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: [
3831
- modeError && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3727
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3728
+ /* @__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: [
3729
+ modeError && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3832
3730
  "div",
3833
3731
  {
3834
3732
  style: {
@@ -3843,7 +3741,7 @@ function FloPayCheckout({
3843
3741
  renderConfirmButton ? renderConfirmButton({
3844
3742
  onConfirm: handleConfirmCheckout,
3845
3743
  isProcessing: confirmProcessing
3846
- }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3744
+ }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3847
3745
  "button",
3848
3746
  {
3849
3747
  type: "button",
@@ -3868,9 +3766,9 @@ function FloPayCheckout({
3868
3766
  modeOverlay
3869
3767
  ] });
3870
3768
  }
3871
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
3872
- /* @__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: [
3873
- modeError && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3769
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
3770
+ /* @__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: [
3771
+ modeError && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3874
3772
  "div",
3875
3773
  {
3876
3774
  style: {
@@ -3885,7 +3783,7 @@ function FloPayCheckout({
3885
3783
  children: modeError
3886
3784
  }
3887
3785
  ),
3888
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3786
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3889
3787
  SessionInjector,
3890
3788
  {
3891
3789
  sessionId: activeSessionId,
@@ -3894,7 +3792,7 @@ function FloPayCheckout({
3894
3792
  children
3895
3793
  }
3896
3794
  )
3897
- ] }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3795
+ ] }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
3898
3796
  SplitCardForm,
3899
3797
  {
3900
3798
  sessionId: activeSessionId,
@@ -3945,8 +3843,8 @@ function SessionInjector({
3945
3843
  session,
3946
3844
  children
3947
3845
  }) {
3948
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(import_jsx_runtime7.Fragment, { children: import_react9.default.Children.map(children, (child) => {
3949
- if (!import_react9.default.isValidElement(child)) return child;
3846
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(import_jsx_runtime6.Fragment, { children: import_react8.default.Children.map(children, (child) => {
3847
+ if (!import_react8.default.isValidElement(child)) return child;
3950
3848
  const existing = child.props;
3951
3849
  const injected = {};
3952
3850
  if (!existing.sessionId) injected.sessionId = sessionId;
@@ -3960,7 +3858,7 @@ function SessionInjector({
3960
3858
  injected.lastName = session.customer.lastName;
3961
3859
  }
3962
3860
  if (Object.keys(injected).length === 0) return child;
3963
- return import_react9.default.cloneElement(child, injected);
3861
+ return import_react8.default.cloneElement(child, injected);
3964
3862
  }) });
3965
3863
  }
3966
3864
  function InterimButtonsView({
@@ -3978,14 +3876,14 @@ function InterimButtonsView({
3978
3876
  cardBackButtonContent,
3979
3877
  cardTitleContent
3980
3878
  }) {
3981
- const [showCardForm, setShowCardForm] = (0, import_react9.useState)(false);
3879
+ const [showCardForm, setShowCardForm] = (0, import_react8.useState)(false);
3982
3880
  const isCardOpenControlled = typeof cardOpen === "boolean";
3983
- (0, import_react9.useEffect)(() => {
3881
+ (0, import_react8.useEffect)(() => {
3984
3882
  if (isCardOpenControlled) {
3985
3883
  setShowCardForm(cardOpen);
3986
3884
  }
3987
3885
  }, [cardOpen, isCardOpenControlled]);
3988
- const bStyles = (0, import_react9.useMemo)(() => {
3886
+ const bStyles = (0, import_react8.useMemo)(() => {
3989
3887
  const base = (0, import_shared7.resolveButtonsLayoutTheme)(buttonsTheme);
3990
3888
  if (!stylesOverride) return base;
3991
3889
  return {
@@ -3999,7 +3897,7 @@ function InterimButtonsView({
3999
3897
  title: { ...base.title, ...stylesOverride.title }
4000
3898
  };
4001
3899
  }, [buttonsTheme, stylesOverride]);
4002
- const skeleton = (h) => /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
3900
+ const skeleton = (h) => /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
4003
3901
  height: h,
4004
3902
  borderRadius: 8,
4005
3903
  background: "#e5e7eb",
@@ -4011,15 +3909,15 @@ function InterimButtonsView({
4011
3909
  const inputBg = bStyles.cardInputBackground ?? "white";
4012
3910
  const hideBackButtonLabel = isEmptySlotContent(cardBackButtonContent);
4013
3911
  const hideTitle = isEmptySlotContent(cardTitleContent);
4014
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: {
3912
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
4015
3913
  backgroundColor: bStyles.cardFormContainer?.backgroundColor ?? "white",
4016
3914
  borderRadius: "8px",
4017
3915
  animation: "flopay-interim-expand 0.35s cubic-bezier(0.4, 0, 0.2, 1) both",
4018
3916
  overflow: "hidden",
4019
3917
  ...bStyles.cardFormContainer
4020
3918
  }, children: [
4021
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", alignItems: "center", padding: "0.75rem 0 0.625rem" }, children: [
4022
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
3919
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", alignItems: "center", padding: "0.75rem 0 0.625rem" }, children: [
3920
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
4023
3921
  "button",
4024
3922
  {
4025
3923
  type: "button",
@@ -4046,7 +3944,7 @@ function InterimButtonsView({
4046
3944
  ...bStyles.backButton
4047
3945
  },
4048
3946
  children: [
4049
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("span", { style: {
3947
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("span", { style: {
4050
3948
  display: "inline-flex",
4051
3949
  alignItems: "center",
4052
3950
  justifyContent: "center",
@@ -4055,12 +3953,12 @@ function InterimButtonsView({
4055
3953
  borderRadius: "50%",
4056
3954
  backgroundColor: "#f3f4f6",
4057
3955
  ...bStyles.backButtonIcon
4058
- }, 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" }) }) }),
4059
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
3956
+ }, 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" }) }) }),
3957
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
4060
3958
  ]
4061
3959
  }
4062
3960
  ),
4063
- hideTitle ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
3961
+ hideTitle ? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
4064
3962
  flex: 1,
4065
3963
  textAlign: "center",
4066
3964
  fontWeight: 600,
@@ -4068,15 +3966,15 @@ function InterimButtonsView({
4068
3966
  color: "#262833",
4069
3967
  paddingRight: 80,
4070
3968
  ...bStyles.title
4071
- }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(TitleContentSlot, { content: cardTitleContent }) })
3969
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(TitleContentSlot, { content: cardTitleContent }) })
4072
3970
  ] }),
4073
- /* @__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" } }) }),
4074
- /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex" }, children: [
4075
- /* @__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" } }) }),
4076
- /* @__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" } }) })
3971
+ /* @__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" } }) }),
3972
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex" }, children: [
3973
+ /* @__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" } }) }),
3974
+ /* @__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" } }) })
4077
3975
  ] }),
4078
- /* @__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" } }) }),
4079
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
3976
+ /* @__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" } }) }),
3977
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
4080
3978
  height: 50,
4081
3979
  borderRadius: 8,
4082
3980
  marginTop: 16,
@@ -4085,7 +3983,7 @@ function InterimButtonsView({
4085
3983
  ...bStyles.submitButton,
4086
3984
  opacity: 0.5
4087
3985
  } }),
4088
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("style", { children: `
3986
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("style", { children: `
4089
3987
  @keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
4090
3988
  @keyframes flopay-interim-expand {
4091
3989
  0% { opacity: 0; max-height: 0; transform: translateY(-12px); }
@@ -4095,10 +3993,10 @@ function InterimButtonsView({
4095
3993
  ` })
4096
3994
  ] });
4097
3995
  }
4098
- return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
3996
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
4099
3997
  showPayPal && skeleton(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
4100
3998
  (showApplePay || showGooglePay) && skeleton(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
4101
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
3999
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
4102
4000
  "button",
4103
4001
  {
4104
4002
  type: "button",
@@ -4138,10 +4036,10 @@ function InterimButtonsView({
4138
4036
  onMouseUp: (e) => {
4139
4037
  e.currentTarget.style.transform = "scale(1)";
4140
4038
  },
4141
- children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CardButtonContentSlot, { content: cardButtonContent })
4039
+ children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CardButtonContentSlot, { content: cardButtonContent })
4142
4040
  }
4143
4041
  ),
4144
- errorMessage && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: {
4042
+ errorMessage && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: {
4145
4043
  margin: "0.25rem 0",
4146
4044
  padding: "0.625rem 0.875rem",
4147
4045
  background: "#FEF2F2",
@@ -4155,21 +4053,22 @@ function InterimButtonsView({
4155
4053
  gap: "0.5rem",
4156
4054
  ...bStyles.errorBanner
4157
4055
  }, children: [
4158
- /* @__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" }) }),
4056
+ /* @__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" }) }),
4159
4057
  errorMessage
4160
4058
  ] }),
4161
- /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("style", { children: `@keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
4059
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("style", { children: `@keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
4162
4060
  ] });
4163
4061
  }
4164
4062
 
4165
4063
  // src/checkout-form.tsx
4064
+ var import_js4 = require("@flopay/js");
4166
4065
  var import_shared8 = require("@flopay/shared");
4167
- var import_react10 = require("react");
4168
- var import_jsx_runtime8 = require("react/jsx-runtime");
4066
+ var import_react9 = require("react");
4067
+ var import_jsx_runtime7 = require("react/jsx-runtime");
4169
4068
  var WALLET_RESUME_KEY2 = "flopay_wallet_resume";
4170
- var CheckoutForm = (0, import_react10.forwardRef)(
4069
+ var CheckoutForm = (0, import_react9.forwardRef)(
4171
4070
  function CheckoutForm2(props, ref) {
4172
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CheckoutFormInner, { ...props, innerRef: ref });
4071
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(CheckoutFormInner, { ...props, innerRef: ref });
4173
4072
  }
4174
4073
  );
4175
4074
  function CheckoutFormInner({
@@ -4198,50 +4097,44 @@ function CheckoutFormInner({
4198
4097
  const paypalFlopay = usePayPalFloPay();
4199
4098
  const elements = useElements();
4200
4099
  const contextBillingUrl = useBillingApiUrl();
4201
- const [processing, setProcessing] = (0, import_react10.useState)(false);
4202
- const [error, setError] = (0, import_react10.useState)(null);
4203
- const [is3DSActive, setIs3DSActive] = (0, import_react10.useState)(false);
4100
+ const [processing, setProcessing] = (0, import_react9.useState)(false);
4101
+ const [error, setError] = (0, import_react9.useState)(null);
4102
+ const [is3DSActive, setIs3DSActive] = (0, import_react9.useState)(false);
4204
4103
  const displayError = externalError ?? error;
4205
4104
  const isSubmitting = externalProcessing ?? processing;
4206
4105
  const isSelfContained = !onTokenizedBody;
4207
4106
  const baseUrl = (billingApiUrl || contextBillingUrl).replace(/\/+$/, "");
4208
- const updateError = (0, import_react10.useCallback)(
4107
+ const updateError = (0, import_react9.useCallback)(
4209
4108
  (err) => {
4210
4109
  setError(err);
4211
4110
  onErrorChange?.(err);
4212
4111
  },
4213
4112
  [onErrorChange]
4214
4113
  );
4215
- const emitDecline = (0, import_react10.useCallback)(
4114
+ const emitDecline = (0, import_react9.useCallback)(
4216
4115
  (input, overrides) => {
4217
4116
  onDecline?.(buildDeclineEvent("card", input, overrides));
4218
4117
  },
4219
4118
  [onDecline]
4220
4119
  );
4221
- const processPaymentInternal = (0, import_react10.useCallback)(
4120
+ const processPaymentInternal = (0, import_react9.useCallback)(
4222
4121
  async (tokenizedBody, completionPaymentMethodId) => {
4223
4122
  setProcessing(true);
4224
4123
  updateError(null);
4225
4124
  const resolvedCompletionPaymentMethodId = completionPaymentMethodId ?? resolveTokenizedPaymentMethodId(tokenizedBody);
4226
4125
  const requestTokenizedBody = tokenizedBody.originalPaymentMethodId ? { ...tokenizedBody, originalPaymentMethodId: void 0 } : tokenizedBody;
4227
4126
  try {
4228
- const response = await fetch(`${baseUrl}/v1/checkouts/sessions/process`, {
4229
- method: "POST",
4230
- headers: {
4231
- "Content-Type": "application/json",
4232
- "x-user-id": userId ?? ""
4127
+ const api = new import_js4.PaymentAPI(baseUrl);
4128
+ const response = await api.processPayment(userId ?? "", {
4129
+ sessionId,
4130
+ tokenizedData: requestTokenizedBody,
4131
+ accountData: {
4132
+ userId: userId ?? "",
4133
+ email: email ?? "",
4134
+ firstName: firstName ?? "",
4135
+ lastName: lastName ?? ""
4233
4136
  },
4234
- body: JSON.stringify({
4235
- sessionId,
4236
- tokenizedData: requestTokenizedBody,
4237
- accountData: {
4238
- userId: userId ?? "",
4239
- email: email ?? "",
4240
- firstName: firstName ?? "",
4241
- lastName: lastName ?? ""
4242
- },
4243
- chv
4244
- })
4137
+ chv
4245
4138
  });
4246
4139
  if (response.ok) {
4247
4140
  onComplete?.({
@@ -4335,7 +4228,7 @@ function CheckoutFormInner({
4335
4228
  },
4336
4229
  [baseUrl, sessionId, userId, email, firstName, lastName, chv, flopay, paypalFlopay, onComplete, onError, onDecline, updateError, emitDecline]
4337
4230
  );
4338
- const dispatchTokenizedBody = (0, import_react10.useCallback)(
4231
+ const dispatchTokenizedBody = (0, import_react9.useCallback)(
4339
4232
  (tokenizedBody) => {
4340
4233
  if (onTokenizedBody) {
4341
4234
  onTokenizedBody(tokenizedBody);
@@ -4345,7 +4238,7 @@ function CheckoutFormInner({
4345
4238
  },
4346
4239
  [onTokenizedBody, processPaymentInternal]
4347
4240
  );
4348
- (0, import_react10.useImperativeHandle)(innerRef, () => ({
4241
+ (0, import_react9.useImperativeHandle)(innerRef, () => ({
4349
4242
  async handleNextAction(secret) {
4350
4243
  if (!flopay) return;
4351
4244
  setIs3DSActive(true);
@@ -4372,7 +4265,7 @@ function CheckoutFormInner({
4372
4265
  }
4373
4266
  }
4374
4267
  }), [flopay, dispatchTokenizedBody, onError, updateError, emitDecline]);
4375
- (0, import_react10.useEffect)(() => {
4268
+ (0, import_react9.useEffect)(() => {
4376
4269
  if (typeof window === "undefined") return;
4377
4270
  const stored = localStorage.getItem(WALLET_RESUME_KEY2);
4378
4271
  if (!stored) return;
@@ -4390,7 +4283,7 @@ function CheckoutFormInner({
4390
4283
  localStorage.removeItem(WALLET_RESUME_KEY2);
4391
4284
  }
4392
4285
  }, [sessionId, dispatchTokenizedBody]);
4393
- const handleSubmit = (0, import_react10.useCallback)(
4286
+ const handleSubmit = (0, import_react9.useCallback)(
4394
4287
  async (e) => {
4395
4288
  e.preventDefault();
4396
4289
  if (!flopay || !elements || isSubmitting) return;
@@ -4480,8 +4373,8 @@ function CheckoutFormInner({
4480
4373
  [flopay, elements, isSubmitting, sessionId, email, baseUrl, isSelfContained, dispatchTokenizedBody, onError, updateError, emitDecline]
4481
4374
  );
4482
4375
  const isReady = flopay !== null && elements !== null;
4483
- return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
4484
- (is3DSActive || isSubmitting) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "data-testid": "flopay-overlay", style: {
4376
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
4377
+ (is3DSActive || isSubmitting) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { "data-testid": "flopay-overlay", style: {
4485
4378
  position: "absolute",
4486
4379
  inset: 0,
4487
4380
  background: "rgba(255,255,255,0.7)",
@@ -4490,12 +4383,12 @@ function CheckoutFormInner({
4490
4383
  justifyContent: "center",
4491
4384
  zIndex: 10
4492
4385
  }, children: is3DSActive ? "Verifying payment..." : "Processing..." }),
4493
- !isReady && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." }),
4494
- isReady && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
4495
- /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(PaymentElement, { options: { layout } }),
4496
- showAddress && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(AddressElement, { options: { mode: showAddress === true ? "billing" : showAddress } }),
4497
- displayError && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { role: "alert", "data-testid": "flopay-error", style: { color: "red", margin: "0.75rem 0" }, children: displayError }),
4498
- children ?? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4386
+ !isReady && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." }),
4387
+ isReady && /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
4388
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(PaymentElement, { options: { layout } }),
4389
+ showAddress && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(AddressElement, { options: { mode: showAddress === true ? "billing" : showAddress } }),
4390
+ displayError && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { role: "alert", "data-testid": "flopay-error", style: { color: "red", margin: "0.75rem 0" }, children: displayError }),
4391
+ children ?? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
4499
4392
  "button",
4500
4393
  {
4501
4394
  type: "submit",
@@ -4509,9 +4402,10 @@ function CheckoutFormInner({
4509
4402
  }
4510
4403
 
4511
4404
  // src/paypal-button.tsx
4405
+ var import_js5 = require("@flopay/js");
4512
4406
  var import_shared9 = require("@flopay/shared");
4513
- var import_react11 = require("react");
4514
- var import_jsx_runtime9 = require("react/jsx-runtime");
4407
+ var import_react10 = require("react");
4408
+ var import_jsx_runtime8 = require("react/jsx-runtime");
4515
4409
  function PayPalButton({
4516
4410
  sessionId,
4517
4411
  billingApiUrl,
@@ -4528,30 +4422,24 @@ function PayPalButton({
4528
4422
  const flopay = useFloPay();
4529
4423
  const elements = useElements();
4530
4424
  const contextBillingUrl = useBillingApiUrl();
4531
- const [ready, setReady] = (0, import_react11.useState)(false);
4532
- const [submitting, setSubmitting] = (0, import_react11.useState)(false);
4533
- const paypalResumeAttempted = (0, import_react11.useRef)(false);
4425
+ const [ready, setReady] = (0, import_react10.useState)(false);
4426
+ const [submitting, setSubmitting] = (0, import_react10.useState)(false);
4427
+ const paypalResumeAttempted = (0, import_react10.useRef)(false);
4534
4428
  const baseUrl = (billingApiUrl || contextBillingUrl).replace(/\/+$/, "");
4535
- const processPaymentInternal = (0, import_react11.useCallback)(
4429
+ const processPaymentInternal = (0, import_react10.useCallback)(
4536
4430
  async (tokenizedBody) => {
4537
4431
  try {
4538
- const response = await fetch(`${baseUrl}/v1/checkouts/sessions/process`, {
4539
- method: "POST",
4540
- headers: {
4541
- "Content-Type": "application/json",
4542
- "x-user-id": userId ?? ""
4432
+ const api = new import_js5.PaymentAPI(baseUrl);
4433
+ const response = await api.processPayment(userId ?? "", {
4434
+ sessionId,
4435
+ tokenizedData: tokenizedBody,
4436
+ accountData: {
4437
+ userId: userId ?? "",
4438
+ email: email ?? "",
4439
+ firstName: firstName ?? "",
4440
+ lastName: lastName ?? ""
4543
4441
  },
4544
- body: JSON.stringify({
4545
- sessionId,
4546
- tokenizedData: tokenizedBody,
4547
- accountData: {
4548
- userId: userId ?? "",
4549
- email: email ?? "",
4550
- firstName: firstName ?? "",
4551
- lastName: lastName ?? ""
4552
- },
4553
- chv
4554
- })
4442
+ chv
4555
4443
  });
4556
4444
  if (response.ok) {
4557
4445
  onComplete?.();
@@ -4565,7 +4453,7 @@ function PayPalButton({
4565
4453
  },
4566
4454
  [baseUrl, sessionId, userId, email, firstName, lastName, chv, onComplete, onErrorChange]
4567
4455
  );
4568
- const dispatchTokenizedBody = (0, import_react11.useCallback)(
4456
+ const dispatchTokenizedBody = (0, import_react10.useCallback)(
4569
4457
  (body) => {
4570
4458
  if (onTokenizedBody) {
4571
4459
  onTokenizedBody(body);
@@ -4575,7 +4463,7 @@ function PayPalButton({
4575
4463
  },
4576
4464
  [onTokenizedBody, processPaymentInternal]
4577
4465
  );
4578
- (0, import_react11.useEffect)(() => {
4466
+ (0, import_react10.useEffect)(() => {
4579
4467
  if (!flopay || paypalResumeAttempted.current) return;
4580
4468
  const params = new URLSearchParams(window.location.search);
4581
4469
  const paymentIntentId = params.get("payment_intent");
@@ -4623,7 +4511,7 @@ function PayPalButton({
4623
4511
  }
4624
4512
  })();
4625
4513
  }, [flopay, dispatchTokenizedBody, onErrorChange]);
4626
- const handlePayPalConfirm = (0, import_react11.useCallback)(async () => {
4514
+ const handlePayPalConfirm = (0, import_react10.useCallback)(async () => {
4627
4515
  if (!flopay || !elements) return;
4628
4516
  try {
4629
4517
  setSubmitting(true);
@@ -4656,11 +4544,11 @@ function PayPalButton({
4656
4544
  }
4657
4545
  }, [flopay, elements, sessionId, email, baseUrl, dispatchTokenizedBody, onErrorChange]);
4658
4546
  if (!flopay || !elements) {
4659
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6, animation: "pulse 1.5s infinite" } });
4547
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6, animation: "pulse 1.5s infinite" } });
4660
4548
  }
4661
- return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
4662
- !ready && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6 } }),
4663
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: ready ? {} : { display: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
4549
+ return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
4550
+ !ready && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6 } }),
4551
+ /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: ready ? {} : { display: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
4664
4552
  "button",
4665
4553
  {
4666
4554
  type: "button",
@@ -4682,7 +4570,7 @@ function PayPalButton({
4682
4570
  children: submitting ? "Processing..." : "PayPal"
4683
4571
  }
4684
4572
  ) }),
4685
- (submitting || isProcessing) && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: {
4573
+ (submitting || isProcessing) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
4686
4574
  position: "fixed",
4687
4575
  inset: 0,
4688
4576
  background: "rgba(0,0,0,0.4)",
@@ -4690,7 +4578,7 @@ function PayPalButton({
4690
4578
  alignItems: "center",
4691
4579
  justifyContent: "center",
4692
4580
  zIndex: 1e3
4693
- }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: {
4581
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
4694
4582
  background: "white",
4695
4583
  borderRadius: 8,
4696
4584
  padding: "1.5rem",
@@ -4702,10 +4590,10 @@ function PayPalButton({
4702
4590
  }
4703
4591
 
4704
4592
  // src/automatic-payment-button.tsx
4705
- var import_react12 = require("react");
4706
- var import_js3 = require("@flopay/js");
4593
+ var import_react11 = require("react");
4594
+ var import_js6 = require("@flopay/js");
4707
4595
  var import_shared10 = require("@flopay/shared");
4708
- var import_jsx_runtime10 = require("react/jsx-runtime");
4596
+ var import_jsx_runtime9 = require("react/jsx-runtime");
4709
4597
  var DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT3 = 44;
4710
4598
  var PAYPAL_RESUME_STORAGE_KEY2 = "flopay_automatic_payment_button_resume";
4711
4599
  function sleep2(ms) {
@@ -4822,11 +4710,11 @@ function FloPayAutomaticPaymentButton({
4822
4710
  style,
4823
4711
  ...buttonProps
4824
4712
  }) {
4825
- const resolvedBillingUrl = (0, import_react12.useMemo)(
4713
+ const resolvedBillingUrl = (0, import_react11.useMemo)(
4826
4714
  () => (0, import_shared10.resolveBillingApiUrl)(billingApiUrl),
4827
4715
  [billingApiUrl]
4828
4716
  );
4829
- const createSessionDraft = (0, import_react12.useMemo)(
4717
+ const createSessionDraft = (0, import_react11.useMemo)(
4830
4718
  () => resolveCreateSessionDraft({
4831
4719
  createSession,
4832
4720
  clientId,
@@ -4852,11 +4740,11 @@ function FloPayAutomaticPaymentButton({
4852
4740
  utmMetadata
4853
4741
  ]
4854
4742
  );
4855
- const [isProcessing, setIsProcessing] = (0, import_react12.useState)(false);
4856
- const [overlayStatus, setOverlayStatus] = (0, import_react12.useState)(null);
4857
- const [overlayError, setOverlayError] = (0, import_react12.useState)(null);
4858
- const [fallbackSession, setFallbackSession] = (0, import_react12.useState)(null);
4859
- const automaticPaymentToken = (0, import_react12.useMemo)(
4743
+ const [isProcessing, setIsProcessing] = (0, import_react11.useState)(false);
4744
+ const [overlayStatus, setOverlayStatus] = (0, import_react11.useState)(null);
4745
+ const [overlayError, setOverlayError] = (0, import_react11.useState)(null);
4746
+ const [fallbackSession, setFallbackSession] = (0, import_react11.useState)(null);
4747
+ const automaticPaymentToken = (0, import_react11.useMemo)(
4860
4748
  () => paymentMethodId ? {
4861
4749
  id: paymentMethodId,
4862
4750
  type: "card",
@@ -4864,31 +4752,31 @@ function FloPayAutomaticPaymentButton({
4864
4752
  } : void 0,
4865
4753
  [checkoutMethod, paymentMethodId]
4866
4754
  );
4867
- const isMountedRef = (0, import_react12.useRef)(true);
4868
- const resumeAttemptedRef = (0, import_react12.useRef)(false);
4869
- const fallbackSessionRef = (0, import_react12.useRef)(fallbackSession);
4870
- const onSuccessRef = (0, import_react12.useRef)(onSuccess);
4871
- const onErrorRef = (0, import_react12.useRef)(onError);
4872
- const onDeclineRef = (0, import_react12.useRef)(onDecline);
4873
- (0, import_react12.useEffect)(() => {
4755
+ const isMountedRef = (0, import_react11.useRef)(true);
4756
+ const resumeAttemptedRef = (0, import_react11.useRef)(false);
4757
+ const fallbackSessionRef = (0, import_react11.useRef)(fallbackSession);
4758
+ const onSuccessRef = (0, import_react11.useRef)(onSuccess);
4759
+ const onErrorRef = (0, import_react11.useRef)(onError);
4760
+ const onDeclineRef = (0, import_react11.useRef)(onDecline);
4761
+ (0, import_react11.useEffect)(() => {
4874
4762
  fallbackSessionRef.current = fallbackSession;
4875
4763
  }, [fallbackSession]);
4876
- (0, import_react12.useEffect)(() => {
4764
+ (0, import_react11.useEffect)(() => {
4877
4765
  onSuccessRef.current = onSuccess;
4878
4766
  }, [onSuccess]);
4879
- (0, import_react12.useEffect)(() => {
4767
+ (0, import_react11.useEffect)(() => {
4880
4768
  onErrorRef.current = onError;
4881
4769
  }, [onError]);
4882
- (0, import_react12.useEffect)(() => {
4770
+ (0, import_react11.useEffect)(() => {
4883
4771
  onDeclineRef.current = onDecline;
4884
4772
  }, [onDecline]);
4885
- (0, import_react12.useEffect)(() => {
4773
+ (0, import_react11.useEffect)(() => {
4886
4774
  isMountedRef.current = true;
4887
4775
  return () => {
4888
4776
  isMountedRef.current = false;
4889
4777
  };
4890
4778
  }, []);
4891
- (0, import_react12.useEffect)(() => {
4779
+ (0, import_react11.useEffect)(() => {
4892
4780
  if (!fallbackSession || typeof window === "undefined") {
4893
4781
  return;
4894
4782
  }
@@ -4902,13 +4790,13 @@ function FloPayAutomaticPaymentButton({
4902
4790
  window.removeEventListener("keydown", handleKeyDown);
4903
4791
  };
4904
4792
  }, [fallbackSession]);
4905
- const emitDecline = (0, import_react12.useCallback)((error, method = DEFAULT_SAVED_PAYMENT_DECLINE_METHOD) => {
4793
+ const emitDecline = (0, import_react11.useCallback)((error, method = DEFAULT_SAVED_PAYMENT_DECLINE_METHOD) => {
4906
4794
  onDeclineRef.current?.(buildDeclineEvent(method, error, {
4907
4795
  code: error.code,
4908
4796
  declineCode: error.declineCode
4909
4797
  }));
4910
4798
  }, []);
4911
- const showSuccess = (0, import_react12.useCallback)(async (event) => {
4799
+ const showSuccess = (0, import_react11.useCallback)(async (event) => {
4912
4800
  if (!isMountedRef.current) return;
4913
4801
  setOverlayError(null);
4914
4802
  setOverlayStatus("success");
@@ -4916,7 +4804,7 @@ function FloPayAutomaticPaymentButton({
4916
4804
  if (!isMountedRef.current) return;
4917
4805
  onSuccessRef.current?.(event);
4918
4806
  }, []);
4919
- const showError = (0, import_react12.useCallback)(async (error, options) => {
4807
+ const showError = (0, import_react11.useCallback)(async (error, options) => {
4920
4808
  if (!isMountedRef.current) return;
4921
4809
  onErrorRef.current?.(error);
4922
4810
  if (options?.emitDecline) {
@@ -4926,7 +4814,7 @@ function FloPayAutomaticPaymentButton({
4926
4814
  setOverlayStatus("error");
4927
4815
  await sleep2(PROCESSING_OVERLAY_ERROR_DELAY_MS);
4928
4816
  }, [emitDecline]);
4929
- const processResolvedSession = (0, import_react12.useCallback)(async (apiResult, resolvedSessionId, options) => {
4817
+ const processResolvedSession = (0, import_react11.useCallback)(async (apiResult, resolvedSessionId, options) => {
4930
4818
  const session = apiResult.data.session ?? null;
4931
4819
  if (!session) {
4932
4820
  throw new import_shared10.FloPayError("No session data returned", "api_error");
@@ -4950,6 +4838,29 @@ function FloPayAutomaticPaymentButton({
4950
4838
  const redirectResult = getRedirectResultFromCheckoutProcessError(apiResult.autoProcessingError);
4951
4839
  const shouldTreatCreateSessionFlowAsServerAutoAttempt = options?.fromCreateSession && (apiResult.autoProcessingAttempted === true || !!apiResult.autoProcessingError || !!redirectResult);
4952
4840
  const shouldRetryPayPalClientSide = checkoutMethod === "paypal" && automaticPaymentToken?.isPaypal === true && options?.fromCreateSession === true;
4841
+ if (apiResult.autoProcessingPending) {
4842
+ const api = new import_js6.PaymentAPI(resolvedBillingUrl);
4843
+ const completed = await api.waitForCheckoutSessionCompletion(apiResult.autoProcessingPending.sessionId, {
4844
+ initialDelayMs: apiResult.autoProcessingPending.retryAfterMs
4845
+ });
4846
+ const completedSession = completed.data.session;
4847
+ if (!completedSession || completedSession.status !== "complete") {
4848
+ throw new import_shared10.FloPayError("Automatic payment failed. Please try again.", "api_error", {
4849
+ code: completedSession?.status === "expired" ? "checkout_session_expired" : "checkout_processing_timeout"
4850
+ });
4851
+ }
4852
+ await showSuccess({
4853
+ result: {
4854
+ status: "succeeded",
4855
+ paymentMethodId: paymentMethodId ?? void 0,
4856
+ checkoutMethod
4857
+ },
4858
+ session: completedSession,
4859
+ sessionId: completedSession.id || resolvedSessionId,
4860
+ autoCompleted: false
4861
+ });
4862
+ return;
4863
+ }
4953
4864
  if (redirectResult) {
4954
4865
  const {
4955
4866
  publishableKey,
@@ -5126,7 +5037,7 @@ function FloPayAutomaticPaymentButton({
5126
5037
  showError,
5127
5038
  showSuccess
5128
5039
  ]);
5129
- const handleButtonClick = (0, import_react12.useCallback)(async (event) => {
5040
+ const handleButtonClick = (0, import_react11.useCallback)(async (event) => {
5130
5041
  buttonProps.onClick?.(event);
5131
5042
  if (event.defaultPrevented || disabled || isProcessing) {
5132
5043
  return;
@@ -5160,7 +5071,7 @@ function FloPayAutomaticPaymentButton({
5160
5071
  setOverlayError(null);
5161
5072
  setOverlayStatus("processing");
5162
5073
  try {
5163
- const api = new import_js3.PaymentAPI(resolvedBillingUrl);
5074
+ const api = new import_js6.PaymentAPI(resolvedBillingUrl);
5164
5075
  if (sessionId) {
5165
5076
  const result = await api.getUnifiedCheckoutSession(sessionId);
5166
5077
  await processResolvedSession(result, sessionId);
@@ -5208,7 +5119,7 @@ function FloPayAutomaticPaymentButton({
5208
5119
  showError,
5209
5120
  showSuccess
5210
5121
  ]);
5211
- const handleFallbackComplete = (0, import_react12.useCallback)((result) => {
5122
+ const handleFallbackComplete = (0, import_react11.useCallback)((result) => {
5212
5123
  const activeFallback = fallbackSessionRef.current;
5213
5124
  setFallbackSession(null);
5214
5125
  onSuccessRef.current?.({
@@ -5218,13 +5129,13 @@ function FloPayAutomaticPaymentButton({
5218
5129
  autoCompleted: false
5219
5130
  });
5220
5131
  }, []);
5221
- const handleFallbackError = (0, import_react12.useCallback)((error) => {
5132
+ const handleFallbackError = (0, import_react11.useCallback)((error) => {
5222
5133
  onErrorRef.current?.(error);
5223
5134
  }, []);
5224
- const handleFallbackDecline = (0, import_react12.useCallback)((decline) => {
5135
+ const handleFallbackDecline = (0, import_react11.useCallback)((decline) => {
5225
5136
  onDeclineRef.current?.(decline);
5226
5137
  }, []);
5227
- (0, import_react12.useEffect)(() => {
5138
+ (0, import_react11.useEffect)(() => {
5228
5139
  if (typeof window === "undefined" || resumeAttemptedRef.current) {
5229
5140
  return;
5230
5141
  }
@@ -5290,7 +5201,7 @@ function FloPayAutomaticPaymentButton({
5290
5201
  { checkoutMethod: "paypal" }
5291
5202
  );
5292
5203
  }
5293
- const api = new import_js3.PaymentAPI(resolvedBillingUrl);
5204
+ const api = new import_js6.PaymentAPI(resolvedBillingUrl);
5294
5205
  const sessionResult = await api.getUnifiedCheckoutSession(resumeState.sessionId);
5295
5206
  let resumeSession = sessionResult.data.session;
5296
5207
  if (!resumeSession) {
@@ -5355,7 +5266,7 @@ function FloPayAutomaticPaymentButton({
5355
5266
  }
5356
5267
  })();
5357
5268
  }, [locale, resolvedBillingUrl, showError, showSuccess]);
5358
- const bStyles = (0, import_react12.useMemo)(() => {
5269
+ const bStyles = (0, import_react11.useMemo)(() => {
5359
5270
  const base = (0, import_shared10.resolveButtonsLayoutTheme)(buttonsTheme);
5360
5271
  if (!stylesOverride) return base;
5361
5272
  return {
@@ -5365,8 +5276,8 @@ function FloPayAutomaticPaymentButton({
5365
5276
  };
5366
5277
  }, [buttonsTheme, stylesOverride]);
5367
5278
  const cardButtonSizing = children === void 0 ? { boxSizing: "border-box", height: DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT3, padding: "0 1rem" } : { padding: "0.9rem 1rem" };
5368
- return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
5369
- /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
5279
+ return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
5280
+ /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
5370
5281
  "button",
5371
5282
  {
5372
5283
  ...buttonProps,
@@ -5407,17 +5318,17 @@ function FloPayAutomaticPaymentButton({
5407
5318
  e.currentTarget.style.transform = "scale(1)";
5408
5319
  }
5409
5320
  },
5410
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CardButtonContentSlot, { content: children })
5321
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CardButtonContentSlot, { content: children })
5411
5322
  }
5412
5323
  ),
5413
- overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
5324
+ overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
5414
5325
  ProcessingOverlay,
5415
5326
  {
5416
5327
  status: overlayStatus,
5417
5328
  errorMessage: overlayError
5418
5329
  }
5419
5330
  ),
5420
- fallbackSession && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
5331
+ fallbackSession && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
5421
5332
  "div",
5422
5333
  {
5423
5334
  "data-testid": "flopay-automatic-payment-fallback",
@@ -5438,7 +5349,7 @@ function FloPayAutomaticPaymentButton({
5438
5349
  padding: "1.5rem",
5439
5350
  zIndex: 1100
5440
5351
  },
5441
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
5352
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
5442
5353
  "div",
5443
5354
  {
5444
5355
  style: {
@@ -5454,7 +5365,7 @@ function FloPayAutomaticPaymentButton({
5454
5365
  flexDirection: "column",
5455
5366
  gap: "1rem"
5456
5367
  },
5457
- children: /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
5368
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
5458
5369
  FloPayCheckout,
5459
5370
  {
5460
5371
  sessionId: fallbackSession.sessionId,
@@ -5485,11 +5396,9 @@ function FloPayAutomaticPaymentButton({
5485
5396
  FloPayAutomaticPaymentButton,
5486
5397
  FloPayCheckout,
5487
5398
  FloPayProvider,
5488
- InAppBrowserNotice,
5489
5399
  PayPalButton,
5490
5400
  PaymentElement,
5491
5401
  SplitCardForm,
5492
- isInAppBrowser,
5493
5402
  useCheckout,
5494
5403
  useElements,
5495
5404
  useFloPay,