@flopay/react 0.2.1 → 0.3.4

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
@@ -116,13 +116,61 @@ function FloPayProvider({
116
116
  }
117
117
 
118
118
  // src/flopay-checkout.tsx
119
- var import_react6 = __toESM(require("react"), 1);
119
+ var import_react7 = __toESM(require("react"), 1);
120
120
  var import_js = require("@flopay/js");
121
121
  var import_shared5 = require("@flopay/shared");
122
122
 
123
- // src/elements.tsx
123
+ // src/card-button-content.tsx
124
124
  var import_react3 = require("react");
125
125
  var import_jsx_runtime2 = require("react/jsx-runtime");
126
+ function DefaultCardButtonContent() {
127
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
128
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
129
+ "svg",
130
+ {
131
+ width: "20",
132
+ height: "20",
133
+ viewBox: "0 0 24 24",
134
+ fill: "none",
135
+ stroke: "currentColor",
136
+ strokeWidth: "1.5",
137
+ strokeLinecap: "round",
138
+ strokeLinejoin: "round",
139
+ "aria-hidden": "true",
140
+ children: [
141
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { width: "20", height: "14", x: "2", y: "5", rx: "2" }),
142
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "2", x2: "22", y1: "10", y2: "10" })
143
+ ]
144
+ }
145
+ ),
146
+ "Credit / Debit Card",
147
+ /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
148
+ "svg",
149
+ {
150
+ width: "16",
151
+ height: "16",
152
+ viewBox: "0 0 24 24",
153
+ fill: "none",
154
+ stroke: "#9ca3af",
155
+ strokeWidth: "2",
156
+ strokeLinecap: "round",
157
+ strokeLinejoin: "round",
158
+ style: { position: "absolute", right: "1rem" },
159
+ "aria-hidden": "true",
160
+ children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M9 18l6-6-6-6" })
161
+ }
162
+ )
163
+ ] });
164
+ }
165
+ function CardButtonContentSlot({
166
+ content
167
+ }) {
168
+ return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: content ?? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DefaultCardButtonContent, {}) });
169
+ }
170
+
171
+ // src/elements.tsx
172
+ var import_react4 = require("react");
173
+ var import_jsx_runtime3 = require("react/jsx-runtime");
126
174
  function createElementComponent(elementType, displayName) {
127
175
  function ElementComponent({
128
176
  className,
@@ -135,10 +183,10 @@ function createElementComponent(elementType, displayName) {
135
183
  onBlur,
136
184
  onEscape
137
185
  }) {
138
- const containerRef = (0, import_react3.useRef)(null);
139
- const elementRef = (0, import_react3.useRef)(null);
140
- const { elements } = (0, import_react3.useContext)(FloPayContext);
141
- (0, import_react3.useEffect)(() => {
186
+ const containerRef = (0, import_react4.useRef)(null);
187
+ const elementRef = (0, import_react4.useRef)(null);
188
+ const { elements } = (0, import_react4.useContext)(FloPayContext);
189
+ (0, import_react4.useEffect)(() => {
142
190
  if (!elements || !containerRef.current) return;
143
191
  let mounted = true;
144
192
  (async () => {
@@ -168,7 +216,7 @@ function createElementComponent(elementType, displayName) {
168
216
  }
169
217
  };
170
218
  }, [elements]);
171
- return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("div", { ref: containerRef, className, id, style });
219
+ return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: containerRef, className, id, style });
172
220
  }
173
221
  ElementComponent.displayName = displayName;
174
222
  return ElementComponent;
@@ -183,30 +231,30 @@ var AddressElement = createElementComponent("address", "AddressElement");
183
231
  // src/split-card-form.tsx
184
232
  var import_react_stripe_js = require("@stripe/react-stripe-js");
185
233
  var import_shared3 = require("@flopay/shared");
186
- var import_react5 = require("react");
234
+ var import_react6 = require("react");
187
235
 
188
236
  // src/hooks.ts
189
- var import_react4 = require("react");
237
+ var import_react5 = require("react");
190
238
  var import_shared2 = require("@flopay/shared");
191
239
  function useFloPay() {
192
- const ctx = (0, import_react4.useContext)(FloPayContext);
240
+ const ctx = (0, import_react5.useContext)(FloPayContext);
193
241
  return ctx.flopay;
194
242
  }
195
243
  function useElements() {
196
- const ctx = (0, import_react4.useContext)(FloPayContext);
244
+ const ctx = (0, import_react5.useContext)(FloPayContext);
197
245
  return ctx.elements;
198
246
  }
199
247
  function useCheckout() {
200
- return (0, import_react4.useContext)(CheckoutContext);
248
+ return (0, import_react5.useContext)(CheckoutContext);
201
249
  }
202
250
  function useBillingApiUrl() {
203
- const ctx = (0, import_react4.useContext)(FloPayContext);
251
+ const ctx = (0, import_react5.useContext)(FloPayContext);
204
252
  return ctx.billingApiUrl || (0, import_shared2.resolveBillingApiUrl)();
205
253
  }
206
254
 
207
255
  // src/split-card-form.tsx
208
256
  var import_shared4 = require("@flopay/shared");
209
- var import_jsx_runtime3 = require("react/jsx-runtime");
257
+ var import_jsx_runtime4 = require("react/jsx-runtime");
210
258
  var WALLET_RESUME_KEY = "flopay_wallet_resume";
211
259
  var FLOPAY_KEYFRAMES = `
212
260
  @keyframes flopay-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
@@ -229,10 +277,10 @@ var FLOPAY_KEYFRAMES = `
229
277
  }
230
278
  `;
231
279
  function FloPayKeyframes() {
232
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: FLOPAY_KEYFRAMES });
280
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: FLOPAY_KEYFRAMES });
233
281
  }
234
282
  function ProcessingOverlay({ status, errorMessage }) {
235
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: {
283
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
236
284
  position: "fixed",
237
285
  inset: 0,
238
286
  background: "rgba(0,0,0,0.35)",
@@ -241,7 +289,7 @@ function ProcessingOverlay({ status, errorMessage }) {
241
289
  justifyContent: "center",
242
290
  zIndex: 1e3,
243
291
  backdropFilter: "blur(2px)"
244
- }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: {
292
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
245
293
  background: "white",
246
294
  borderRadius: 12,
247
295
  padding: "2rem 2.5rem",
@@ -253,8 +301,8 @@ function ProcessingOverlay({ status, errorMessage }) {
253
301
  alignItems: "center",
254
302
  gap: 16
255
303
  }, children: [
256
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { width: 48, height: 48, position: "relative" }, children: [
257
- status === "processing" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
304
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { width: 48, height: 48, position: "relative" }, children: [
305
+ status === "processing" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
258
306
  "svg",
259
307
  {
260
308
  width: "48",
@@ -264,14 +312,14 @@ function ProcessingOverlay({ status, errorMessage }) {
264
312
  xmlns: "http://www.w3.org/2000/svg",
265
313
  style: { animation: "flopay-spin 0.8s linear infinite" },
266
314
  children: [
267
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "12", cy: "12", r: "10", stroke: "#e5e7eb", strokeWidth: "3" }),
268
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M4 12a8 8 0 018-8v3a5 5 0 00-5 5H4z", fill: "#4A49FF" })
315
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "12", cy: "12", r: "10", stroke: "#e5e7eb", strokeWidth: "3" }),
316
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M4 12a8 8 0 018-8v3a5 5 0 00-5 5H4z", fill: "#4A49FF" })
269
317
  ]
270
318
  }
271
319
  ),
272
- status === "success" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { animation: "flopay-pop 0.4s cubic-bezier(0.34,1.56,0.64,1)" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { width: "48", height: "48", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
273
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "12", cy: "12", r: "11", fill: "#22c55e" }),
274
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
320
+ status === "success" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { animation: "flopay-pop 0.4s cubic-bezier(0.34,1.56,0.64,1)" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { width: "48", height: "48", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
321
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "12", cy: "12", r: "11", fill: "#22c55e" }),
322
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
275
323
  "path",
276
324
  {
277
325
  d: "M7 12.5l3 3 7-7",
@@ -283,9 +331,9 @@ function ProcessingOverlay({ status, errorMessage }) {
283
331
  }
284
332
  )
285
333
  ] }) }),
286
- status === "error" && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { animation: "flopay-shake 0.4s ease" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { width: "48", height: "48", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
287
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("circle", { cx: "12", cy: "12", r: "11", fill: "#ef4444" }),
288
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
334
+ status === "error" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { animation: "flopay-shake 0.4s ease" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { width: "48", height: "48", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
335
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "12", cy: "12", r: "11", fill: "#ef4444" }),
336
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
289
337
  "path",
290
338
  {
291
339
  d: "M8 8l8 8M16 8l-8 8",
@@ -297,7 +345,7 @@ function ProcessingOverlay({ status, errorMessage }) {
297
345
  )
298
346
  ] }) })
299
347
  ] }),
300
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("span", { style: {
348
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: {
301
349
  fontSize: 14,
302
350
  fontWeight: 600,
303
351
  letterSpacing: "0.05em",
@@ -307,7 +355,7 @@ function ProcessingOverlay({ status, errorMessage }) {
307
355
  status === "success" && "PAYMENT SUCCESSFUL",
308
356
  status === "error" && "PAYMENT FAILED"
309
357
  ] }),
310
- status === "error" && errorMessage && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("p", { style: {
358
+ status === "error" && errorMessage && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: {
311
359
  fontSize: 13,
312
360
  color: "#6b7280",
313
361
  fontWeight: 400,
@@ -315,7 +363,7 @@ function ProcessingOverlay({ status, errorMessage }) {
315
363
  lineHeight: 1.4,
316
364
  margin: 0
317
365
  }, children: errorMessage }),
318
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("style", { children: `
366
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: `
319
367
  @keyframes flopay-spin { to { transform: rotate(360deg); } }
320
368
  @keyframes flopay-pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }
321
369
  @keyframes flopay-draw { to { stroke-dashoffset: 0; } }
@@ -323,9 +371,9 @@ function ProcessingOverlay({ status, errorMessage }) {
323
371
  ` })
324
372
  ] }) });
325
373
  }
326
- var SplitCardForm = (0, import_react5.forwardRef)(
374
+ var SplitCardForm = (0, import_react6.forwardRef)(
327
375
  function SplitCardForm2(props, ref) {
328
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(SplitCardFormInner, { ...props, innerRef: ref });
376
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SplitCardFormInner, { ...props, innerRef: ref });
329
377
  }
330
378
  );
331
379
  function PayPalButtonInner({
@@ -339,11 +387,11 @@ function PayPalButtonInner({
339
387
  }) {
340
388
  const stripe = (0, import_react_stripe_js.useStripe)();
341
389
  const elements = (0, import_react_stripe_js.useElements)();
342
- const [ready, setReady] = (0, import_react5.useState)(false);
343
- const [submitting, setSubmitting] = (0, import_react5.useState)(false);
344
- const paypalResumeAttempted = (0, import_react5.useRef)(false);
390
+ const [ready, setReady] = (0, import_react6.useState)(false);
391
+ const [submitting, setSubmitting] = (0, import_react6.useState)(false);
392
+ const paypalResumeAttempted = (0, import_react6.useRef)(false);
345
393
  const baseUrl = billingApiUrl.replace(/\/+$/, "");
346
- (0, import_react5.useEffect)(() => {
394
+ (0, import_react6.useEffect)(() => {
347
395
  if (!stripe || paypalResumeAttempted.current) return;
348
396
  const params = new URLSearchParams(window.location.search);
349
397
  const paymentIntentId = params.get("payment_intent");
@@ -386,7 +434,7 @@ function PayPalButtonInner({
386
434
  }
387
435
  })();
388
436
  }, [stripe, onTokenizedBody, onErrorChange]);
389
- const handlePayPalConfirm = (0, import_react5.useCallback)(async (_event) => {
437
+ const handlePayPalConfirm = (0, import_react6.useCallback)(async (_event) => {
390
438
  if (!stripe || !elements) return;
391
439
  onButtonClick?.("paypal");
392
440
  try {
@@ -442,8 +490,8 @@ function PayPalButtonInner({
442
490
  setSubmitting(false);
443
491
  }
444
492
  }, [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange]);
445
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
446
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
493
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
494
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
447
495
  import_react_stripe_js.ExpressCheckoutElement,
448
496
  {
449
497
  onReady: () => setReady(true),
@@ -461,7 +509,7 @@ function PayPalButtonInner({
461
509
  }
462
510
  }
463
511
  ) }),
464
- submitting && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ProcessingOverlay, { status: "processing" })
512
+ submitting && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ProcessingOverlay, { status: "processing" })
465
513
  ] });
466
514
  }
467
515
  function WalletButtonInner({
@@ -476,10 +524,10 @@ function WalletButtonInner({
476
524
  }) {
477
525
  const stripe = (0, import_react_stripe_js.useStripe)();
478
526
  const elements = (0, import_react_stripe_js.useElements)();
479
- const [ready, setReady] = (0, import_react5.useState)(false);
480
- const [submitting, setSubmitting] = (0, import_react5.useState)(false);
527
+ const [ready, setReady] = (0, import_react6.useState)(false);
528
+ const [submitting, setSubmitting] = (0, import_react6.useState)(false);
481
529
  const baseUrl = billingApiUrl.replace(/\/+$/, "");
482
- const handleWalletConfirm = (0, import_react5.useCallback)(
530
+ const handleWalletConfirm = (0, import_react6.useCallback)(
483
531
  async (_event) => {
484
532
  if (!stripe || !elements) return;
485
533
  const walletType = _event.expressPaymentType;
@@ -535,8 +583,8 @@ function WalletButtonInner({
535
583
  },
536
584
  [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange]
537
585
  );
538
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(import_jsx_runtime3.Fragment, { children: [
539
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
586
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
587
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
540
588
  import_react_stripe_js.ExpressCheckoutElement,
541
589
  {
542
590
  onReady: () => setReady(true),
@@ -557,7 +605,7 @@ function WalletButtonInner({
557
605
  }
558
606
  }
559
607
  ) }),
560
- submitting && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ProcessingOverlay, { status: "processing" })
608
+ submitting && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ProcessingOverlay, { status: "processing" })
561
609
  ] });
562
610
  }
563
611
  function SplitCardFormInner({
@@ -585,7 +633,14 @@ function SplitCardFormInner({
585
633
  layout = "default",
586
634
  buttonsTheme,
587
635
  buttonsStyles: buttonsStylesOverride,
636
+ cardButtonContent,
588
637
  onButtonClick,
638
+ enableAVS = false,
639
+ avsLayout: avsLayoutProp = "row",
640
+ country: countryProp,
641
+ zip: zipProp,
642
+ onCountryChange,
643
+ onZipChange,
589
644
  totalAmount = 0,
590
645
  currency = "usd",
591
646
  innerRef
@@ -593,27 +648,31 @@ function SplitCardFormInner({
593
648
  const flopay = useFloPay();
594
649
  const elements = useElements();
595
650
  const contextBillingUrl = useBillingApiUrl();
596
- const [processing, setProcessing] = (0, import_react5.useState)(false);
597
- const [error, setError] = (0, import_react5.useState)(null);
598
- const [is3DSActive, setIs3DSActive] = (0, import_react5.useState)(false);
599
- const [viewState, setViewState] = (0, import_react5.useState)("buttons");
651
+ const [processing, setProcessing] = (0, import_react6.useState)(false);
652
+ const [error, setError] = (0, import_react6.useState)(null);
653
+ const [is3DSActive, setIs3DSActive] = (0, import_react6.useState)(false);
654
+ const [selectedCountry, setSelectedCountry] = (0, import_react6.useState)(countryProp ?? "US");
655
+ const [zipCode, setZipCode] = (0, import_react6.useState)(zipProp ?? "");
656
+ const zipCodeRef = (0, import_react6.useRef)(zipProp ?? "");
657
+ const selectedCountryRef = (0, import_react6.useRef)(countryProp ?? "US");
658
+ const [viewState, setViewState] = (0, import_react6.useState)("buttons");
600
659
  const showCardForm = viewState === "expanding" || viewState === "card";
601
660
  const TRANSITION_MS = 280;
602
- const expandToCard = (0, import_react5.useCallback)(() => {
661
+ const expandToCard = (0, import_react6.useCallback)(() => {
603
662
  setViewState("expanding");
604
663
  setTimeout(() => setViewState("card"), TRANSITION_MS);
605
664
  }, []);
606
- const collapseToButtons = (0, import_react5.useCallback)(() => {
665
+ const collapseToButtons = (0, import_react6.useCallback)(() => {
607
666
  setViewState("collapsing");
608
667
  setTimeout(() => setViewState("buttons"), TRANSITION_MS);
609
668
  }, []);
610
- const [fullName, setFullName] = (0, import_react5.useState)("");
611
- const [formReady, setFormReady] = (0, import_react5.useState)(false);
612
- const [overlayStatus, setOverlayStatus] = (0, import_react5.useState)(null);
613
- const processingRef = (0, import_react5.useRef)(false);
669
+ const [fullName, setFullName] = (0, import_react6.useState)("");
670
+ const [formReady, setFormReady] = (0, import_react6.useState)(false);
671
+ const [overlayStatus, setOverlayStatus] = (0, import_react6.useState)(null);
672
+ const processingRef = (0, import_react6.useRef)(false);
614
673
  const resolvedBillingApiUrl = billingApiUrl || contextBillingUrl;
615
674
  const displayError = externalError ?? error;
616
- const bStyles = (0, import_react5.useMemo)(() => {
675
+ const bStyles = (0, import_react6.useMemo)(() => {
617
676
  const base = (0, import_shared3.resolveButtonsLayoutTheme)(buttonsTheme);
618
677
  if (!buttonsStylesOverride) return base;
619
678
  return {
@@ -630,25 +689,25 @@ function SplitCardFormInner({
630
689
  const isSubmitting = externalProcessing ?? processing;
631
690
  const isSelfContained = !onTokenizedBody;
632
691
  const baseUrl = resolvedBillingApiUrl.replace(/\/+$/, "");
633
- const stripeInstance = (0, import_react5.useMemo)(() => {
692
+ const stripeInstance = (0, import_react6.useMemo)(() => {
634
693
  if (!flopay) return null;
635
694
  return flopay.getRawProvider();
636
695
  }, [flopay]);
637
696
  const amountInCents = totalAmount || 100;
638
- const walletOptions = (0, import_react5.useMemo)(() => ({
697
+ const walletOptions = (0, import_react6.useMemo)(() => ({
639
698
  mode: "payment",
640
699
  amount: amountInCents,
641
700
  currency: currency.toLowerCase(),
642
701
  paymentMethodCreation: "manual",
643
702
  captureMethod: "manual"
644
703
  }), [amountInCents, currency]);
645
- const paypalOptions = (0, import_react5.useMemo)(() => ({
704
+ const paypalOptions = (0, import_react6.useMemo)(() => ({
646
705
  mode: "payment",
647
706
  amount: amountInCents,
648
707
  currency: currency.toLowerCase(),
649
708
  captureMethod: "manual"
650
709
  }), [amountInCents, currency]);
651
- const updateError = (0, import_react5.useCallback)(
710
+ const updateError = (0, import_react6.useCallback)(
652
711
  (err) => {
653
712
  setError(err);
654
713
  onErrorChange?.(err);
@@ -656,13 +715,13 @@ function SplitCardFormInner({
656
715
  [onErrorChange]
657
716
  );
658
717
  const showWallets = showApplePay || showGooglePay;
659
- const handleNameChange = (0, import_react5.useCallback)((value) => {
718
+ const handleNameChange = (0, import_react6.useCallback)((value) => {
660
719
  setFullName(value);
661
720
  const parts = value.trim().split(/\s+/);
662
721
  onFirstNameChange?.(parts[0] ?? "");
663
722
  onLastNameChange?.(parts.length > 1 ? parts.slice(1).join(" ") : "");
664
723
  }, [onFirstNameChange, onLastNameChange]);
665
- const processPaymentInternal = (0, import_react5.useCallback)(
724
+ const processPaymentInternal = (0, import_react6.useCallback)(
666
725
  async (tokenizedBody) => {
667
726
  if (processingRef.current) return;
668
727
  processingRef.current = true;
@@ -683,7 +742,8 @@ function SplitCardFormInner({
683
742
  userId: userId ?? "",
684
743
  email: email ?? "",
685
744
  firstName: firstName ?? fullName.trim().split(/\s+/)[0] ?? "",
686
- lastName: lastName ?? fullName.trim().split(/\s+/).slice(1).join(" ") ?? ""
745
+ lastName: lastName ?? fullName.trim().split(/\s+/).slice(1).join(" ") ?? "",
746
+ ...enableAVS ? { zip: zipCodeRef.current, country: selectedCountryRef.current } : {}
687
747
  },
688
748
  chv
689
749
  })
@@ -780,7 +840,7 @@ function SplitCardFormInner({
780
840
  },
781
841
  [baseUrl, sessionId, userId, email, firstName, lastName, fullName, chv, flopay, onComplete, onError, updateError]
782
842
  );
783
- const dispatchTokenizedBody = (0, import_react5.useCallback)(
843
+ const dispatchTokenizedBody = (0, import_react6.useCallback)(
784
844
  (tokenizedBody) => {
785
845
  if (onTokenizedBody) {
786
846
  onTokenizedBody(tokenizedBody);
@@ -790,7 +850,7 @@ function SplitCardFormInner({
790
850
  },
791
851
  [onTokenizedBody, processPaymentInternal]
792
852
  );
793
- (0, import_react5.useImperativeHandle)(innerRef, () => ({
853
+ (0, import_react6.useImperativeHandle)(innerRef, () => ({
794
854
  async handleNextAction(secret) {
795
855
  if (!flopay) return;
796
856
  setIs3DSActive(true);
@@ -816,7 +876,7 @@ function SplitCardFormInner({
816
876
  }
817
877
  }
818
878
  }), [flopay, dispatchTokenizedBody, onError, updateError]);
819
- (0, import_react5.useEffect)(() => {
879
+ (0, import_react6.useEffect)(() => {
820
880
  if (typeof window === "undefined") return;
821
881
  const stored = localStorage.getItem(WALLET_RESUME_KEY);
822
882
  if (!stored) return;
@@ -834,7 +894,7 @@ function SplitCardFormInner({
834
894
  localStorage.removeItem(WALLET_RESUME_KEY);
835
895
  }
836
896
  }, [sessionId, dispatchTokenizedBody]);
837
- const handleSubmit = (0, import_react5.useCallback)(
897
+ const handleSubmit = (0, import_react6.useCallback)(
838
898
  async (e) => {
839
899
  e.preventDefault();
840
900
  if (!flopay || !elements || isSubmitting || processingRef.current) return;
@@ -844,13 +904,24 @@ function SplitCardFormInner({
844
904
  updateError(null);
845
905
  let handedOff = false;
846
906
  try {
907
+ if (enableAVS && !zipCodeRef.current.trim()) {
908
+ updateError((0, import_shared3.getPostalCodeLabel)(selectedCountryRef.current) + " is required");
909
+ return;
910
+ }
847
911
  const submitResult = await flopay.submitElements();
848
912
  if (submitResult.error) {
849
913
  updateError(submitResult.error.message);
850
914
  onError?.(submitResult.error);
851
915
  return;
852
916
  }
853
- const pmResult = await flopay.createPaymentMethod();
917
+ const billingDetails = enableAVS ? {
918
+ name: fullName,
919
+ address: {
920
+ country: selectedCountryRef.current,
921
+ postal_code: zipCodeRef.current
922
+ }
923
+ } : void 0;
924
+ const pmResult = await flopay.createPaymentMethod(billingDetails);
854
925
  if (pmResult.error || !pmResult.paymentMethodId) {
855
926
  updateError(pmResult.error?.message ?? "Failed to create payment method.");
856
927
  return;
@@ -903,7 +974,7 @@ function SplitCardFormInner({
903
974
  );
904
975
  const isReady = flopay !== null && elements !== null;
905
976
  if (!isReady) {
906
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." });
977
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." });
907
978
  }
908
979
  const isButtons = layout === "buttons";
909
980
  const resolvedBorder = isButtons ? bStyles.cardInputBorder ?? "#e5e7eb" : "#A4A4FF";
@@ -919,19 +990,19 @@ function SplitCardFormInner({
919
990
  invalid: { color: "#ef4444" }
920
991
  }
921
992
  } : {};
922
- const cardFormBlock = /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: {
993
+ const cardFormBlock = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
923
994
  backgroundColor: cardBg,
924
995
  borderRadius: "8px",
925
996
  padding: isButtons ? "0" : "1rem",
926
997
  ...isButtons ? bStyles.cardFormContainer : {},
927
998
  ...isButtons ? { padding: bStyles.cardFormContainer?.padding ?? "0" } : {}
928
999
  }, children: [
929
- isButtons && showCardForm && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: {
1000
+ isButtons && showCardForm && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
930
1001
  display: "flex",
931
1002
  alignItems: "center",
932
1003
  padding: "0.75rem 0 0.625rem"
933
1004
  }, children: [
934
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1005
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
935
1006
  "button",
936
1007
  {
937
1008
  type: "button",
@@ -953,7 +1024,7 @@ function SplitCardFormInner({
953
1024
  },
954
1025
  "aria-label": "Back to payment methods",
955
1026
  children: [
956
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { style: {
1027
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: {
957
1028
  display: "inline-flex",
958
1029
  alignItems: "center",
959
1030
  justifyContent: "center",
@@ -963,12 +1034,12 @@ function SplitCardFormInner({
963
1034
  backgroundColor: "#f3f4f6",
964
1035
  transition: "background-color 0.15s",
965
1036
  ...bStyles.backButtonIcon
966
- }, children: /* @__PURE__ */ (0, import_jsx_runtime3.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_runtime3.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
1037
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime4.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_runtime4.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
967
1038
  "Go back"
968
1039
  ]
969
1040
  }
970
1041
  ),
971
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: {
1042
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
972
1043
  flex: 1,
973
1044
  textAlign: "center",
974
1045
  fontWeight: 600,
@@ -978,16 +1049,16 @@ function SplitCardFormInner({
978
1049
  ...bStyles.title
979
1050
  }, children: "Secure card checkout" })
980
1051
  ] }),
981
- !isButtons && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { textAlign: "center", fontWeight: 600, fontSize: "1.1rem", padding: "0.5rem 0", color: "#262833" }, children: "Secure card checkout" }),
982
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: {
1052
+ !isButtons && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { textAlign: "center", fontWeight: 600, fontSize: "1.1rem", padding: "0.5rem 0", color: "#262833" }, children: "Secure card checkout" }),
1053
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
983
1054
  backgroundColor: cardInputBg,
984
1055
  border: `1px solid ${resolvedBorder}`,
985
1056
  borderTopLeftRadius: "8px",
986
1057
  borderTopRightRadius: "8px",
987
1058
  padding: "10px"
988
- }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CardNumberElement, { onReady: () => setFormReady(true), options: stripeElementStyle }) }),
989
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "flex" }, children: [
990
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: {
1059
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CardNumberElement, { onReady: () => setFormReady(true), options: stripeElementStyle }) }),
1060
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex" }, children: [
1061
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
991
1062
  flex: 1,
992
1063
  backgroundColor: cardInputBg,
993
1064
  border: `1px solid ${resolvedBorder}`,
@@ -995,23 +1066,23 @@ function SplitCardFormInner({
995
1066
  borderRight: "none",
996
1067
  borderBottomLeftRadius: "8px",
997
1068
  padding: "10px"
998
- }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CardExpiryElement, { options: stripeElementStyle }) }),
999
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: {
1069
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CardExpiryElement, { options: stripeElementStyle }) }),
1070
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
1000
1071
  flex: 1,
1001
1072
  backgroundColor: cardInputBg,
1002
1073
  border: `1px solid ${resolvedBorder}`,
1003
1074
  borderTop: "none",
1004
1075
  borderBottomRightRadius: "8px",
1005
1076
  padding: "10px"
1006
- }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(CardCvcElement, { options: stripeElementStyle }) })
1077
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CardCvcElement, { options: stripeElementStyle }) })
1007
1078
  ] }),
1008
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: {
1079
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
1009
1080
  backgroundColor: cardInputBg,
1010
1081
  border: `1px solid ${resolvedBorder}`,
1011
1082
  borderRadius: "8px",
1012
1083
  marginTop: "0.5rem",
1013
1084
  padding: "10px"
1014
- }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1085
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1015
1086
  "input",
1016
1087
  {
1017
1088
  placeholder: "Full Name on Card",
@@ -1032,7 +1103,84 @@ function SplitCardFormInner({
1032
1103
  }
1033
1104
  }
1034
1105
  ) }),
1035
- displayError && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
1106
+ enableAVS && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
1107
+ display: "flex",
1108
+ flexDirection: avsLayoutProp === "column" ? "column" : "row",
1109
+ gap: avsLayoutProp === "column" ? "0.5rem" : "0",
1110
+ marginTop: "0.5rem"
1111
+ }, children: [
1112
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
1113
+ flex: avsLayoutProp === "row" ? 1 : void 0,
1114
+ backgroundColor: cardInputBg,
1115
+ border: `1px solid ${resolvedBorder}`,
1116
+ padding: "10px",
1117
+ ...avsLayoutProp === "row" ? { borderRadius: "0", borderTopLeftRadius: "8px", borderBottomLeftRadius: "8px", borderRight: "none" } : { borderRadius: "8px" },
1118
+ ...isButtons && bStyles.countrySelect ? bStyles.countrySelect : {}
1119
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1120
+ "select",
1121
+ {
1122
+ value: selectedCountry,
1123
+ onChange: (e) => {
1124
+ selectedCountryRef.current = e.target.value;
1125
+ setSelectedCountry(e.target.value);
1126
+ onCountryChange?.(e.target.value);
1127
+ },
1128
+ disabled: isSubmitting,
1129
+ autoComplete: "country",
1130
+ "data-testid": "flopay-country",
1131
+ style: {
1132
+ width: "100%",
1133
+ border: "none",
1134
+ outline: "none",
1135
+ background: "transparent",
1136
+ fontSize: bStyles.cardInputFontSize ?? "16px",
1137
+ fontFamily: "Poppins, sans-serif",
1138
+ color: bStyles.cardInputColor ?? "#262833",
1139
+ cursor: "pointer",
1140
+ ...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
1141
+ },
1142
+ children: import_shared3.COUNTRY_OPTIONS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("option", { value: c.code, children: [
1143
+ c.flag,
1144
+ " ",
1145
+ c.name
1146
+ ] }, c.code))
1147
+ }
1148
+ ) }),
1149
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
1150
+ flex: avsLayoutProp === "row" ? 1 : void 0,
1151
+ backgroundColor: cardInputBg,
1152
+ border: `1px solid ${resolvedBorder}`,
1153
+ padding: "10px",
1154
+ ...avsLayoutProp === "row" ? { borderRadius: "0", borderTopRightRadius: "8px", borderBottomRightRadius: "8px" } : { borderRadius: "8px" },
1155
+ ...isButtons && bStyles.zipInput ? bStyles.zipInput : {}
1156
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1157
+ "input",
1158
+ {
1159
+ placeholder: (0, import_shared3.getPostalCodeLabel)(selectedCountry),
1160
+ autoComplete: "postal-code",
1161
+ value: zipCode,
1162
+ onChange: (e) => {
1163
+ zipCodeRef.current = e.target.value;
1164
+ setZipCode(e.target.value);
1165
+ onZipChange?.(e.target.value);
1166
+ },
1167
+ disabled: isSubmitting,
1168
+ required: true,
1169
+ "data-testid": "flopay-zip",
1170
+ style: {
1171
+ width: "100%",
1172
+ border: "none",
1173
+ outline: "none",
1174
+ background: "transparent",
1175
+ fontSize: bStyles.cardInputFontSize ?? "16px",
1176
+ fontFamily: "Poppins, sans-serif",
1177
+ color: bStyles.cardInputColor ?? "#262833",
1178
+ ...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
1179
+ }
1180
+ }
1181
+ ) })
1182
+ ] }),
1183
+ displayError && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
1036
1184
  margin: "0.75rem 0",
1037
1185
  padding: "0.625rem 0.875rem",
1038
1186
  background: "#FEF2F2",
@@ -1046,10 +1194,10 @@ function SplitCardFormInner({
1046
1194
  gap: "0.5rem",
1047
1195
  ...isButtons && bStyles.errorBanner ? bStyles.errorBanner : {}
1048
1196
  }, children: [
1049
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime3.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" }) }),
1197
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime4.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" }) }),
1050
1198
  displayError
1051
1199
  ] }),
1052
- children ?? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1200
+ children ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1053
1201
  "button",
1054
1202
  {
1055
1203
  type: "submit",
@@ -1072,7 +1220,7 @@ function SplitCardFormInner({
1072
1220
  children: isSubmitting ? "PROCESSING..." : submitLabel
1073
1221
  }
1074
1222
  ),
1075
- !isButtons && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: {
1223
+ !isButtons && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
1076
1224
  backgroundColor: "#EFF9F0",
1077
1225
  borderRadius: "8px",
1078
1226
  padding: "0.75rem",
@@ -1088,11 +1236,11 @@ function SplitCardFormInner({
1088
1236
  const isCardView = viewState === "expanding" || viewState === "card" || viewState === "collapsing";
1089
1237
  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;
1090
1238
  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;
1091
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
1092
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FloPayKeyframes, {}),
1093
- overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
1094
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: { display: "grid" }, children: [
1095
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: {
1239
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
1240
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FloPayKeyframes, {}),
1241
+ overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
1242
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid" }, children: [
1243
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
1096
1244
  gridArea: "1 / 1",
1097
1245
  display: "flex",
1098
1246
  flexDirection: "column",
@@ -1101,7 +1249,7 @@ function SplitCardFormInner({
1101
1249
  ...!isButtonsView && !buttonsAnim ? { visibility: "hidden", position: "absolute", pointerEvents: "none", width: "100%" } : {},
1102
1250
  ...buttonsAnim ? { animation: buttonsAnim, pointerEvents: "none" } : {}
1103
1251
  }, children: [
1104
- showPayPal && stripeInstance ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: paypalOptions, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1252
+ showPayPal && stripeInstance ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: paypalOptions, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1105
1253
  PayPalButtonInner,
1106
1254
  {
1107
1255
  sessionId,
@@ -1112,8 +1260,8 @@ function SplitCardFormInner({
1112
1260
  isProcessing: isSubmitting,
1113
1261
  onButtonClick
1114
1262
  }
1115
- ) }) : showPayPal ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { height: 44, borderRadius: 8, background: "#e5e7eb", animation: "flopay-pulse 1.5s ease-in-out infinite" } }) : null,
1116
- showWallets && stripeInstance ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1263
+ ) }) : showPayPal ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { height: 44, borderRadius: 8, background: "#e5e7eb", animation: "flopay-pulse 1.5s ease-in-out infinite" } }) : null,
1264
+ showWallets && stripeInstance ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1117
1265
  WalletButtonInner,
1118
1266
  {
1119
1267
  sessionId,
@@ -1125,8 +1273,8 @@ function SplitCardFormInner({
1125
1273
  onErrorChange: updateError,
1126
1274
  onButtonClick
1127
1275
  }
1128
- ) }) : showWallets ? /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { height: 44, borderRadius: 8, background: "#e5e7eb", animation: "flopay-pulse 1.5s ease-in-out infinite" } }) : null,
1129
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)(
1276
+ ) }) : showWallets ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { height: 44, borderRadius: 8, background: "#e5e7eb", animation: "flopay-pulse 1.5s ease-in-out infinite" } }) : null,
1277
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1130
1278
  "button",
1131
1279
  {
1132
1280
  type: "button",
@@ -1159,17 +1307,10 @@ function SplitCardFormInner({
1159
1307
  onMouseUp: (e) => {
1160
1308
  e.currentTarget.style.transform = "scale(1)";
1161
1309
  },
1162
- children: [
1163
- /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
1164
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { width: "20", height: "14", x: "2", y: "5", rx: "2" }),
1165
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "2", x2: "22", y1: "10", y2: "10" })
1166
- ] }),
1167
- "Credit / Debit Card",
1168
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "#9ca3af", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", style: { position: "absolute", right: "1rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M9 18l6-6-6-6" }) })
1169
- ]
1310
+ children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CardButtonContentSlot, { content: cardButtonContent })
1170
1311
  }
1171
1312
  ),
1172
- displayError && viewState === "buttons" && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
1313
+ displayError && viewState === "buttons" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
1173
1314
  margin: "0.25rem 0",
1174
1315
  padding: "0.625rem 0.875rem",
1175
1316
  background: "#FEF2F2",
@@ -1183,11 +1324,11 @@ function SplitCardFormInner({
1183
1324
  gap: "0.5rem",
1184
1325
  ...bStyles.errorBanner ? bStyles.errorBanner : {}
1185
1326
  }, children: [
1186
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime3.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" }) }),
1327
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime4.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" }) }),
1187
1328
  displayError
1188
1329
  ] })
1189
1330
  ] }),
1190
- isCardView && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: {
1331
+ isCardView && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
1191
1332
  gridArea: "1 / 1",
1192
1333
  ...cardAnim ? { animation: cardAnim } : {},
1193
1334
  ...viewState === "collapsing" ? { pointerEvents: "none" } : {}
@@ -1195,10 +1336,10 @@ function SplitCardFormInner({
1195
1336
  ] })
1196
1337
  ] });
1197
1338
  }
1198
- return /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
1199
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(FloPayKeyframes, {}),
1200
- overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
1201
- showWallets && stripeInstance && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1339
+ return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
1340
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FloPayKeyframes, {}),
1341
+ overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
1342
+ showWallets && stripeInstance && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1202
1343
  WalletButtonInner,
1203
1344
  {
1204
1345
  sessionId,
@@ -1210,7 +1351,7 @@ function SplitCardFormInner({
1210
1351
  onErrorChange: updateError
1211
1352
  }
1212
1353
  ) }),
1213
- showPayPal && stripeInstance && /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: paypalOptions, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)(
1354
+ showPayPal && stripeInstance && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: paypalOptions, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1214
1355
  PayPalButtonInner,
1215
1356
  {
1216
1357
  sessionId,
@@ -1221,7 +1362,7 @@ function SplitCardFormInner({
1221
1362
  isProcessing: isSubmitting
1222
1363
  }
1223
1364
  ) }),
1224
- (showWallets && stripeInstance || showPayPal && stripeInstance) && /* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("div", { style: {
1365
+ (showWallets && stripeInstance || showPayPal && stripeInstance) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
1225
1366
  display: "flex",
1226
1367
  alignItems: "center",
1227
1368
  gap: "0.75rem",
@@ -1229,16 +1370,16 @@ function SplitCardFormInner({
1229
1370
  color: "#999",
1230
1371
  fontSize: "0.85rem"
1231
1372
  }, children: [
1232
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } }),
1233
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("span", { children: "or pay with card" }),
1234
- /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } })
1373
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } }),
1374
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "or pay with card" }),
1375
+ /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } })
1235
1376
  ] }),
1236
1377
  cardFormBlock
1237
1378
  ] });
1238
1379
  }
1239
1380
 
1240
1381
  // src/flopay-checkout.tsx
1241
- var import_jsx_runtime4 = require("react/jsx-runtime");
1382
+ var import_jsx_runtime5 = require("react/jsx-runtime");
1242
1383
  function FloPayCheckout({
1243
1384
  sessionId: sessionIdProp,
1244
1385
  createSession: createSessionParams,
@@ -1256,7 +1397,10 @@ function FloPayCheckout({
1256
1397
  layout,
1257
1398
  buttonsTheme,
1258
1399
  buttonsStyles,
1400
+ cardButtonContent,
1259
1401
  onButtonClick,
1402
+ enableAVS,
1403
+ avsLayout,
1260
1404
  submitLabel,
1261
1405
  className,
1262
1406
  children,
@@ -1266,24 +1410,24 @@ function FloPayCheckout({
1266
1410
  onSessionCompleted
1267
1411
  }) {
1268
1412
  const resolvedBillingUrl = (0, import_shared5.resolveBillingApiUrl)(billingApiUrl);
1269
- const [unified, setUnified] = (0, import_react6.useState)(null);
1270
- const [flopay, setFloPay] = (0, import_react6.useState)(null);
1271
- const flopayRef = (0, import_react6.useRef)(null);
1272
- const [session, setSession] = (0, import_react6.useState)(null);
1273
- const [resolvedSessionId, setResolvedSessionId] = (0, import_react6.useState)(sessionIdProp ?? "");
1274
- const [isLoading, setIsLoading] = (0, import_react6.useState)(true);
1275
- const [loadError, setLoadError] = (0, import_react6.useState)(null);
1276
- const [currentMode, setCurrentMode] = (0, import_react6.useState)("full");
1277
- const [confirmProcessing, setConfirmProcessing] = (0, import_react6.useState)(false);
1278
- const [modeError, setModeError] = (0, import_react6.useState)(null);
1279
- const autoCheckoutAttempted = (0, import_react6.useRef)(false);
1280
- const onCompleteRef = (0, import_react6.useRef)(onComplete);
1413
+ const [unified, setUnified] = (0, import_react7.useState)(null);
1414
+ const [flopay, setFloPay] = (0, import_react7.useState)(null);
1415
+ const flopayRef = (0, import_react7.useRef)(null);
1416
+ const [session, setSession] = (0, import_react7.useState)(null);
1417
+ const [resolvedSessionId, setResolvedSessionId] = (0, import_react7.useState)(sessionIdProp ?? "");
1418
+ const [isLoading, setIsLoading] = (0, import_react7.useState)(true);
1419
+ const [loadError, setLoadError] = (0, import_react7.useState)(null);
1420
+ const [currentMode, setCurrentMode] = (0, import_react7.useState)("full");
1421
+ const [confirmProcessing, setConfirmProcessing] = (0, import_react7.useState)(false);
1422
+ const [modeError, setModeError] = (0, import_react7.useState)(null);
1423
+ const autoCheckoutAttempted = (0, import_react7.useRef)(false);
1424
+ const onCompleteRef = (0, import_react7.useRef)(onComplete);
1281
1425
  onCompleteRef.current = onComplete;
1282
- const onErrorRef = (0, import_react6.useRef)(onError);
1426
+ const onErrorRef = (0, import_react7.useRef)(onError);
1283
1427
  onErrorRef.current = onError;
1284
- const onSessionCompletedRef = (0, import_react6.useRef)(onSessionCompleted);
1428
+ const onSessionCompletedRef = (0, import_react7.useRef)(onSessionCompleted);
1285
1429
  onSessionCompletedRef.current = onSessionCompleted;
1286
- const processPaymentForMode = (0, import_react6.useCallback)(
1430
+ const processPaymentForMode = (0, import_react7.useCallback)(
1287
1431
  async (sess) => {
1288
1432
  const baseUrl = resolvedBillingUrl.replace(/\/+$/, "");
1289
1433
  const response = await fetch(`${baseUrl}/v1/checkouts/sessions/process`, {
@@ -1329,7 +1473,7 @@ function FloPayCheckout({
1329
1473
  },
1330
1474
  [resolvedBillingUrl, resolvedSessionId]
1331
1475
  );
1332
- const handleRedirectResult = (0, import_react6.useCallback)(
1476
+ const handleRedirectResult = (0, import_react7.useCallback)(
1333
1477
  async (redirectResult, sess, options) => {
1334
1478
  const stripe = flopayRef.current?.getRawProvider();
1335
1479
  if (!stripe) return false;
@@ -1374,8 +1518,8 @@ function FloPayCheckout({
1374
1518
  },
1375
1519
  [resolvedBillingUrl, resolvedSessionId]
1376
1520
  );
1377
- const inflightRef = (0, import_react6.useRef)(/* @__PURE__ */ new Map());
1378
- const initializedHashRef = (0, import_react6.useRef)(null);
1521
+ const inflightRef = (0, import_react7.useRef)(/* @__PURE__ */ new Map());
1522
+ const initializedHashRef = (0, import_react7.useRef)(null);
1379
1523
  function hashCreateParams(params) {
1380
1524
  const key = JSON.stringify({
1381
1525
  c: params?.clientId,
@@ -1390,7 +1534,7 @@ function FloPayCheckout({
1390
1534
  }
1391
1535
  return `flopay_session_${Math.abs(h).toString(36)}`;
1392
1536
  }
1393
- const createSessionHash = (0, import_react6.useMemo)(
1537
+ const createSessionHash = (0, import_react7.useMemo)(
1394
1538
  () => createSessionParams ? hashCreateParams(createSessionParams) : "",
1395
1539
  // eslint-disable-next-line react-hooks/exhaustive-deps
1396
1540
  [
@@ -1401,9 +1545,9 @@ function FloPayCheckout({
1401
1545
  JSON.stringify(createSessionParams?.subscriptions)
1402
1546
  ]
1403
1547
  );
1404
- const createSessionParamsRef = (0, import_react6.useRef)(createSessionParams);
1548
+ const createSessionParamsRef = (0, import_react7.useRef)(createSessionParams);
1405
1549
  createSessionParamsRef.current = createSessionParams;
1406
- (0, import_react6.useEffect)(() => {
1550
+ (0, import_react7.useEffect)(() => {
1407
1551
  let cancelled = false;
1408
1552
  setLoadError(null);
1409
1553
  if (createSessionHash) {
@@ -1608,7 +1752,7 @@ function FloPayCheckout({
1608
1752
  cancelled = true;
1609
1753
  };
1610
1754
  }, [resolvedSessionId, createSessionHash, resolvedBillingUrl, fallbackPublishableKey, locale, checkoutModeProp]);
1611
- const handleConfirmCheckout = (0, import_react6.useCallback)(async () => {
1755
+ const handleConfirmCheckout = (0, import_react7.useCallback)(async () => {
1612
1756
  if (confirmProcessing || !session) return;
1613
1757
  setConfirmProcessing(true);
1614
1758
  setModeError(null);
@@ -1633,7 +1777,7 @@ function FloPayCheckout({
1633
1777
  setConfirmProcessing(false);
1634
1778
  }
1635
1779
  }, [confirmProcessing, session, processPaymentForMode, handleRedirectResult, onError]);
1636
- const providerOptions = (0, import_react6.useMemo)(() => {
1780
+ const providerOptions = (0, import_react7.useMemo)(() => {
1637
1781
  if (!unified || !session) return void 0;
1638
1782
  const opts = {
1639
1783
  appearance,
@@ -1649,7 +1793,7 @@ function FloPayCheckout({
1649
1793
  }
1650
1794
  return opts;
1651
1795
  }, [unified, session, appearance, resolvedBillingUrl]);
1652
- const checkoutValue = (0, import_react6.useMemo)(
1796
+ const checkoutValue = (0, import_react7.useMemo)(
1653
1797
  () => ({
1654
1798
  session,
1655
1799
  loading: isLoading,
@@ -1659,23 +1803,23 @@ function FloPayCheckout({
1659
1803
  [session, isLoading, loadError, currentMode]
1660
1804
  );
1661
1805
  if (isLoading) {
1662
- if (loadingNode) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: loadingNode });
1806
+ if (loadingNode) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: loadingNode });
1663
1807
  if (layout === "buttons") {
1664
- const skeletonBar = (h) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
1808
+ const skeletonBar = (h) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1665
1809
  height: h,
1666
1810
  borderRadius: 8,
1667
1811
  background: "#e5e7eb",
1668
1812
  animation: "flopay-loading-pulse 1.5s ease-in-out infinite"
1669
1813
  } });
1670
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
1814
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
1671
1815
  showPayPal && skeletonBar(44),
1672
1816
  (showApplePay || showGooglePay) && skeletonBar(44),
1673
1817
  skeletonBar(48),
1674
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: `@keyframes flopay-loading-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
1818
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("style", { children: `@keyframes flopay-loading-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
1675
1819
  ] });
1676
1820
  }
1677
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", justifyContent: "center", padding: 32 }, children: [
1678
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
1821
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex", justifyContent: "center", padding: 32 }, children: [
1822
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1679
1823
  width: 24,
1680
1824
  height: 24,
1681
1825
  border: "2px solid #e5e7eb",
@@ -1683,12 +1827,12 @@ function FloPayCheckout({
1683
1827
  borderRadius: "50%",
1684
1828
  animation: "spin 0.6s linear infinite"
1685
1829
  } }),
1686
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` })
1830
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` })
1687
1831
  ] });
1688
1832
  }
1689
1833
  if (loadError) {
1690
- if (errorNode) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: errorNode(loadError) });
1691
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1834
+ if (errorNode) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: errorNode(loadError) });
1835
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1692
1836
  "div",
1693
1837
  {
1694
1838
  style: {
@@ -1702,7 +1846,7 @@ function FloPayCheckout({
1702
1846
  );
1703
1847
  }
1704
1848
  if ((!flopay || !providerOptions) && createSessionParams && layout === "buttons") {
1705
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1849
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1706
1850
  InterimButtonsView,
1707
1851
  {
1708
1852
  onButtonClick,
@@ -1710,14 +1854,15 @@ function FloPayCheckout({
1710
1854
  showApplePay,
1711
1855
  showGooglePay,
1712
1856
  buttonsTheme,
1713
- buttonsStyles
1857
+ buttonsStyles,
1858
+ cardButtonContent
1714
1859
  }
1715
1860
  ) });
1716
1861
  }
1717
- if (!flopay || !providerOptions) return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, {});
1862
+ if (!flopay || !providerOptions) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, {});
1718
1863
  if (currentMode === "confirm") {
1719
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FloPayProvider, { flopay, options: providerOptions, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { className, children: [
1720
- modeError && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1864
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FloPayProvider, { flopay, options: providerOptions, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className, children: [
1865
+ modeError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1721
1866
  "div",
1722
1867
  {
1723
1868
  style: {
@@ -1732,7 +1877,7 @@ function FloPayCheckout({
1732
1877
  renderConfirmButton ? renderConfirmButton({
1733
1878
  onConfirm: handleConfirmCheckout,
1734
1879
  isProcessing: confirmProcessing
1735
- }) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1880
+ }) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1736
1881
  "button",
1737
1882
  {
1738
1883
  type: "button",
@@ -1755,8 +1900,8 @@ function FloPayCheckout({
1755
1900
  )
1756
1901
  ] }) }) });
1757
1902
  }
1758
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(FloPayProvider, { flopay, options: providerOptions, children: [
1759
- modeError && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1903
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(FloPayProvider, { flopay, options: providerOptions, children: [
1904
+ modeError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1760
1905
  "div",
1761
1906
  {
1762
1907
  style: {
@@ -1771,7 +1916,7 @@ function FloPayCheckout({
1771
1916
  children: modeError
1772
1917
  }
1773
1918
  ),
1774
- children ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1919
+ children ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1775
1920
  SessionInjector,
1776
1921
  {
1777
1922
  sessionId: resolvedSessionId,
@@ -1779,7 +1924,7 @@ function FloPayCheckout({
1779
1924
  session,
1780
1925
  children
1781
1926
  }
1782
- ) : /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
1927
+ ) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1783
1928
  SplitCardForm,
1784
1929
  {
1785
1930
  sessionId: resolvedSessionId,
@@ -1797,7 +1942,12 @@ function FloPayCheckout({
1797
1942
  layout,
1798
1943
  buttonsTheme,
1799
1944
  buttonsStyles,
1945
+ cardButtonContent,
1800
1946
  onButtonClick,
1947
+ enableAVS,
1948
+ avsLayout,
1949
+ country: session?.customer?.country,
1950
+ zip: session?.customer?.zip,
1801
1951
  submitLabel,
1802
1952
  className
1803
1953
  }
@@ -1810,8 +1960,8 @@ function SessionInjector({
1810
1960
  session,
1811
1961
  children
1812
1962
  }) {
1813
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_jsx_runtime4.Fragment, { children: import_react6.default.Children.map(children, (child) => {
1814
- if (!import_react6.default.isValidElement(child)) return child;
1963
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: import_react7.default.Children.map(children, (child) => {
1964
+ if (!import_react7.default.isValidElement(child)) return child;
1815
1965
  const existing = child.props;
1816
1966
  const injected = {};
1817
1967
  if (!existing.sessionId) injected.sessionId = sessionId;
@@ -1825,7 +1975,7 @@ function SessionInjector({
1825
1975
  injected.lastName = session.customer.lastName;
1826
1976
  }
1827
1977
  if (Object.keys(injected).length === 0) return child;
1828
- return import_react6.default.cloneElement(child, injected);
1978
+ return import_react7.default.cloneElement(child, injected);
1829
1979
  }) });
1830
1980
  }
1831
1981
  function InterimButtonsView({
@@ -1834,10 +1984,11 @@ function InterimButtonsView({
1834
1984
  showApplePay,
1835
1985
  showGooglePay,
1836
1986
  buttonsTheme,
1837
- buttonsStyles: stylesOverride
1987
+ buttonsStyles: stylesOverride,
1988
+ cardButtonContent
1838
1989
  }) {
1839
- const [showCardForm, setShowCardForm] = (0, import_react6.useState)(false);
1840
- const bStyles = (0, import_react6.useMemo)(() => {
1990
+ const [showCardForm, setShowCardForm] = (0, import_react7.useState)(false);
1991
+ const bStyles = (0, import_react7.useMemo)(() => {
1841
1992
  const base = (0, import_shared5.resolveButtonsLayoutTheme)(buttonsTheme);
1842
1993
  if (!stylesOverride) return base;
1843
1994
  return {
@@ -1849,7 +2000,7 @@ function InterimButtonsView({
1849
2000
  title: { ...base.title, ...stylesOverride.title }
1850
2001
  };
1851
2002
  }, [buttonsTheme, stylesOverride]);
1852
- const skeleton = (h) => /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
2003
+ const skeleton = (h) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1853
2004
  height: h,
1854
2005
  borderRadius: 8,
1855
2006
  background: "#e5e7eb",
@@ -1858,15 +2009,15 @@ function InterimButtonsView({
1858
2009
  if (showCardForm) {
1859
2010
  const inputBorder = bStyles.cardInputBorder ?? "#e5e7eb";
1860
2011
  const inputBg = bStyles.cardInputBackground ?? "white";
1861
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
2012
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
1862
2013
  backgroundColor: bStyles.cardFormContainer?.backgroundColor ?? "white",
1863
2014
  borderRadius: "8px",
1864
2015
  animation: "flopay-interim-expand 0.35s cubic-bezier(0.4, 0, 0.2, 1) both",
1865
2016
  overflow: "hidden",
1866
2017
  ...bStyles.cardFormContainer
1867
2018
  }, children: [
1868
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", alignItems: "center", padding: "0.75rem 0 0.625rem" }, children: [
1869
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
2019
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex", alignItems: "center", padding: "0.75rem 0 0.625rem" }, children: [
2020
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
1870
2021
  "button",
1871
2022
  {
1872
2023
  type: "button",
@@ -1886,7 +2037,7 @@ function InterimButtonsView({
1886
2037
  ...bStyles.backButton
1887
2038
  },
1888
2039
  children: [
1889
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: {
2040
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: {
1890
2041
  display: "inline-flex",
1891
2042
  alignItems: "center",
1892
2043
  justifyContent: "center",
@@ -1895,12 +2046,12 @@ function InterimButtonsView({
1895
2046
  borderRadius: "50%",
1896
2047
  backgroundColor: "#f3f4f6",
1897
2048
  ...bStyles.backButtonIcon
1898
- }, children: /* @__PURE__ */ (0, import_jsx_runtime4.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_runtime4.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
2049
+ }, 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" }) }) }),
1899
2050
  "Go back"
1900
2051
  ]
1901
2052
  }
1902
2053
  ),
1903
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
2054
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1904
2055
  flex: 1,
1905
2056
  textAlign: "center",
1906
2057
  fontWeight: 600,
@@ -1910,13 +2061,13 @@ function InterimButtonsView({
1910
2061
  ...bStyles.title
1911
2062
  }, children: "Secure card checkout" })
1912
2063
  ] }),
1913
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTopLeftRadius: 8, borderTopRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { width: "60%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
1914
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex" }, children: [
1915
- /* @__PURE__ */ (0, import_jsx_runtime4.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_runtime4.jsx)("div", { style: { width: "50%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
1916
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { flex: 1, backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTop: "none", borderBottomRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { width: "40%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) })
2064
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTopLeftRadius: 8, borderTopRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { width: "60%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
2065
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex" }, children: [
2066
+ /* @__PURE__ */ (0, import_jsx_runtime5.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_runtime5.jsx)("div", { style: { width: "50%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
2067
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { flex: 1, backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTop: "none", borderBottomRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { width: "40%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) })
1917
2068
  ] }),
1918
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderRadius: 8, marginTop: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { width: "45%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
1919
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
2069
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderRadius: 8, marginTop: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { width: "45%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
2070
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
1920
2071
  height: 50,
1921
2072
  borderRadius: 8,
1922
2073
  marginTop: 16,
@@ -1925,7 +2076,7 @@ function InterimButtonsView({
1925
2076
  ...bStyles.submitButton,
1926
2077
  opacity: 0.5
1927
2078
  } }),
1928
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: `
2079
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("style", { children: `
1929
2080
  @keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
1930
2081
  @keyframes flopay-interim-expand {
1931
2082
  0% { opacity: 0; max-height: 0; transform: translateY(-12px); }
@@ -1935,10 +2086,10 @@ function InterimButtonsView({
1935
2086
  ` })
1936
2087
  ] });
1937
2088
  }
1938
- return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
2089
+ return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
1939
2090
  showPayPal && skeleton(44),
1940
2091
  (showApplePay || showGooglePay) && skeleton(44),
1941
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
2092
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
1942
2093
  "button",
1943
2094
  {
1944
2095
  type: "button",
@@ -1971,28 +2122,21 @@ function InterimButtonsView({
1971
2122
  onMouseUp: (e) => {
1972
2123
  e.currentTarget.style.transform = "scale(1)";
1973
2124
  },
1974
- children: [
1975
- /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
1976
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { width: "20", height: "14", x: "2", y: "5", rx: "2" }),
1977
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "2", x2: "22", y1: "10", y2: "10" })
1978
- ] }),
1979
- "Credit / Debit Card",
1980
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "#9ca3af", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", style: { position: "absolute", right: "1rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M9 18l6-6-6-6" }) })
1981
- ]
2125
+ children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardButtonContentSlot, { content: cardButtonContent })
1982
2126
  }
1983
2127
  ),
1984
- /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: `@keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
2128
+ /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("style", { children: `@keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
1985
2129
  ] });
1986
2130
  }
1987
2131
 
1988
2132
  // src/checkout-form.tsx
1989
2133
  var import_shared6 = require("@flopay/shared");
1990
- var import_react7 = require("react");
1991
- var import_jsx_runtime5 = require("react/jsx-runtime");
2134
+ var import_react8 = require("react");
2135
+ var import_jsx_runtime6 = require("react/jsx-runtime");
1992
2136
  var WALLET_RESUME_KEY2 = "flopay_wallet_resume";
1993
- var CheckoutForm = (0, import_react7.forwardRef)(
2137
+ var CheckoutForm = (0, import_react8.forwardRef)(
1994
2138
  function CheckoutForm2(props, ref) {
1995
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckoutFormInner, { ...props, innerRef: ref });
2139
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckoutFormInner, { ...props, innerRef: ref });
1996
2140
  }
1997
2141
  );
1998
2142
  function CheckoutFormInner({
@@ -2019,21 +2163,21 @@ function CheckoutFormInner({
2019
2163
  const flopay = useFloPay();
2020
2164
  const elements = useElements();
2021
2165
  const contextBillingUrl = useBillingApiUrl();
2022
- const [processing, setProcessing] = (0, import_react7.useState)(false);
2023
- const [error, setError] = (0, import_react7.useState)(null);
2024
- const [is3DSActive, setIs3DSActive] = (0, import_react7.useState)(false);
2166
+ const [processing, setProcessing] = (0, import_react8.useState)(false);
2167
+ const [error, setError] = (0, import_react8.useState)(null);
2168
+ const [is3DSActive, setIs3DSActive] = (0, import_react8.useState)(false);
2025
2169
  const displayError = externalError ?? error;
2026
2170
  const isSubmitting = externalProcessing ?? processing;
2027
2171
  const isSelfContained = !onTokenizedBody;
2028
2172
  const baseUrl = (billingApiUrl || contextBillingUrl).replace(/\/+$/, "");
2029
- const updateError = (0, import_react7.useCallback)(
2173
+ const updateError = (0, import_react8.useCallback)(
2030
2174
  (err) => {
2031
2175
  setError(err);
2032
2176
  onErrorChange?.(err);
2033
2177
  },
2034
2178
  [onErrorChange]
2035
2179
  );
2036
- const processPaymentInternal = (0, import_react7.useCallback)(
2180
+ const processPaymentInternal = (0, import_react8.useCallback)(
2037
2181
  async (tokenizedBody) => {
2038
2182
  setProcessing(true);
2039
2183
  updateError(null);
@@ -2121,7 +2265,7 @@ function CheckoutFormInner({
2121
2265
  },
2122
2266
  [baseUrl, sessionId, userId, email, firstName, lastName, chv, flopay, onComplete, onError, updateError]
2123
2267
  );
2124
- const dispatchTokenizedBody = (0, import_react7.useCallback)(
2268
+ const dispatchTokenizedBody = (0, import_react8.useCallback)(
2125
2269
  (tokenizedBody) => {
2126
2270
  if (onTokenizedBody) {
2127
2271
  onTokenizedBody(tokenizedBody);
@@ -2131,7 +2275,7 @@ function CheckoutFormInner({
2131
2275
  },
2132
2276
  [onTokenizedBody, processPaymentInternal]
2133
2277
  );
2134
- (0, import_react7.useImperativeHandle)(innerRef, () => ({
2278
+ (0, import_react8.useImperativeHandle)(innerRef, () => ({
2135
2279
  async handleNextAction(secret) {
2136
2280
  if (!flopay) return;
2137
2281
  setIs3DSActive(true);
@@ -2157,7 +2301,7 @@ function CheckoutFormInner({
2157
2301
  }
2158
2302
  }
2159
2303
  }), [flopay, dispatchTokenizedBody, onError, updateError]);
2160
- (0, import_react7.useEffect)(() => {
2304
+ (0, import_react8.useEffect)(() => {
2161
2305
  if (typeof window === "undefined") return;
2162
2306
  const stored = localStorage.getItem(WALLET_RESUME_KEY2);
2163
2307
  if (!stored) return;
@@ -2175,7 +2319,7 @@ function CheckoutFormInner({
2175
2319
  localStorage.removeItem(WALLET_RESUME_KEY2);
2176
2320
  }
2177
2321
  }, [sessionId, dispatchTokenizedBody]);
2178
- const handleSubmit = (0, import_react7.useCallback)(
2322
+ const handleSubmit = (0, import_react8.useCallback)(
2179
2323
  async (e) => {
2180
2324
  e.preventDefault();
2181
2325
  if (!flopay || !elements || isSubmitting) return;
@@ -2235,8 +2379,8 @@ function CheckoutFormInner({
2235
2379
  [flopay, elements, isSubmitting, sessionId, email, baseUrl, isSelfContained, dispatchTokenizedBody, onError, updateError]
2236
2380
  );
2237
2381
  const isReady = flopay !== null && elements !== null;
2238
- return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
2239
- (is3DSActive || isSubmitting) && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { "data-testid": "flopay-overlay", style: {
2382
+ return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
2383
+ (is3DSActive || isSubmitting) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { "data-testid": "flopay-overlay", style: {
2240
2384
  position: "absolute",
2241
2385
  inset: 0,
2242
2386
  background: "rgba(255,255,255,0.7)",
@@ -2245,12 +2389,12 @@ function CheckoutFormInner({
2245
2389
  justifyContent: "center",
2246
2390
  zIndex: 10
2247
2391
  }, children: is3DSActive ? "Verifying payment..." : "Processing..." }),
2248
- !isReady && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." }),
2249
- isReady && /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
2250
- /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(PaymentElement, { options: { layout } }),
2251
- showAddress && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(AddressElement, { options: { mode: showAddress === true ? "billing" : showAddress } }),
2252
- displayError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { role: "alert", "data-testid": "flopay-error", style: { color: "red", margin: "0.75rem 0" }, children: displayError }),
2253
- children ?? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
2392
+ !isReady && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." }),
2393
+ isReady && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2394
+ /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PaymentElement, { options: { layout } }),
2395
+ showAddress && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AddressElement, { options: { mode: showAddress === true ? "billing" : showAddress } }),
2396
+ displayError && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { role: "alert", "data-testid": "flopay-error", style: { color: "red", margin: "0.75rem 0" }, children: displayError }),
2397
+ children ?? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2254
2398
  "button",
2255
2399
  {
2256
2400
  type: "submit",
@@ -2265,8 +2409,8 @@ function CheckoutFormInner({
2265
2409
 
2266
2410
  // src/paypal-button.tsx
2267
2411
  var import_shared7 = require("@flopay/shared");
2268
- var import_react8 = require("react");
2269
- var import_jsx_runtime6 = require("react/jsx-runtime");
2412
+ var import_react9 = require("react");
2413
+ var import_jsx_runtime7 = require("react/jsx-runtime");
2270
2414
  function PayPalButton({
2271
2415
  sessionId,
2272
2416
  billingApiUrl,
@@ -2283,11 +2427,11 @@ function PayPalButton({
2283
2427
  const flopay = useFloPay();
2284
2428
  const elements = useElements();
2285
2429
  const contextBillingUrl = useBillingApiUrl();
2286
- const [ready, setReady] = (0, import_react8.useState)(false);
2287
- const [submitting, setSubmitting] = (0, import_react8.useState)(false);
2288
- const paypalResumeAttempted = (0, import_react8.useRef)(false);
2430
+ const [ready, setReady] = (0, import_react9.useState)(false);
2431
+ const [submitting, setSubmitting] = (0, import_react9.useState)(false);
2432
+ const paypalResumeAttempted = (0, import_react9.useRef)(false);
2289
2433
  const baseUrl = (billingApiUrl || contextBillingUrl).replace(/\/+$/, "");
2290
- const processPaymentInternal = (0, import_react8.useCallback)(
2434
+ const processPaymentInternal = (0, import_react9.useCallback)(
2291
2435
  async (tokenizedBody) => {
2292
2436
  try {
2293
2437
  const response = await fetch(`${baseUrl}/v1/checkouts/sessions/process`, {
@@ -2320,7 +2464,7 @@ function PayPalButton({
2320
2464
  },
2321
2465
  [baseUrl, sessionId, userId, email, firstName, lastName, chv, onComplete, onErrorChange]
2322
2466
  );
2323
- const dispatchTokenizedBody = (0, import_react8.useCallback)(
2467
+ const dispatchTokenizedBody = (0, import_react9.useCallback)(
2324
2468
  (body) => {
2325
2469
  if (onTokenizedBody) {
2326
2470
  onTokenizedBody(body);
@@ -2330,7 +2474,7 @@ function PayPalButton({
2330
2474
  },
2331
2475
  [onTokenizedBody, processPaymentInternal]
2332
2476
  );
2333
- (0, import_react8.useEffect)(() => {
2477
+ (0, import_react9.useEffect)(() => {
2334
2478
  if (!flopay || paypalResumeAttempted.current) return;
2335
2479
  const params = new URLSearchParams(window.location.search);
2336
2480
  const paymentIntentId = params.get("payment_intent");
@@ -2378,7 +2522,7 @@ function PayPalButton({
2378
2522
  }
2379
2523
  })();
2380
2524
  }, [flopay, dispatchTokenizedBody, onErrorChange]);
2381
- const handlePayPalConfirm = (0, import_react8.useCallback)(async () => {
2525
+ const handlePayPalConfirm = (0, import_react9.useCallback)(async () => {
2382
2526
  if (!flopay || !elements) return;
2383
2527
  try {
2384
2528
  setSubmitting(true);
@@ -2421,11 +2565,11 @@ function PayPalButton({
2421
2565
  }
2422
2566
  }, [flopay, elements, sessionId, email, baseUrl, dispatchTokenizedBody, onErrorChange]);
2423
2567
  if (!flopay || !elements) {
2424
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6, animation: "pulse 1.5s infinite" } });
2568
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6, animation: "pulse 1.5s infinite" } });
2425
2569
  }
2426
- return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
2427
- !ready && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6 } }),
2428
- /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: ready ? {} : { display: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
2570
+ return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
2571
+ !ready && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6 } }),
2572
+ /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: ready ? {} : { display: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
2429
2573
  "button",
2430
2574
  {
2431
2575
  type: "button",
@@ -2447,7 +2591,7 @@ function PayPalButton({
2447
2591
  children: submitting ? "Processing..." : "PayPal"
2448
2592
  }
2449
2593
  ) }),
2450
- (submitting || isProcessing) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
2594
+ (submitting || isProcessing) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
2451
2595
  position: "fixed",
2452
2596
  inset: 0,
2453
2597
  background: "rgba(0,0,0,0.4)",
@@ -2455,7 +2599,7 @@ function PayPalButton({
2455
2599
  alignItems: "center",
2456
2600
  justifyContent: "center",
2457
2601
  zIndex: 1e3
2458
- }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: {
2602
+ }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
2459
2603
  background: "white",
2460
2604
  borderRadius: 8,
2461
2605
  padding: "1.5rem",