@flopay/react 0.4.4 → 0.4.5

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
@@ -2445,6 +2445,7 @@ function FloPayCheckout({
2445
2445
  avsLayout,
2446
2446
  submitLabel,
2447
2447
  className,
2448
+ initialErrorMessage = null,
2448
2449
  children,
2449
2450
  checkoutMode: checkoutModeProp,
2450
2451
  confirmLabel,
@@ -2467,7 +2468,7 @@ function FloPayCheckout({
2467
2468
  const [loadError, setLoadError] = (0, import_react8.useState)(null);
2468
2469
  const [currentMode, setCurrentMode] = (0, import_react8.useState)("full");
2469
2470
  const [confirmProcessing, setConfirmProcessing] = (0, import_react8.useState)(false);
2470
- const [modeError, setModeError] = (0, import_react8.useState)(null);
2471
+ const [modeError, setModeError] = (0, import_react8.useState)(initialErrorMessage);
2471
2472
  const [modeOverlayStatus, setModeOverlayStatus] = (0, import_react8.useState)(null);
2472
2473
  const [modeOverlayError, setModeOverlayError] = (0, import_react8.useState)(null);
2473
2474
  const [createSessionPatch, setCreateSessionPatch] = (0, import_react8.useState)(void 0);
@@ -2514,6 +2515,9 @@ function FloPayCheckout({
2514
2515
  setCreateSessionPatch(void 0);
2515
2516
  setCreateSessionPatchBaseHash(baseCreateSessionHash);
2516
2517
  }, [baseCreateSessionHash]);
2518
+ (0, import_react8.useEffect)(() => {
2519
+ setModeError(initialErrorMessage);
2520
+ }, [initialErrorMessage]);
2517
2521
  const emitDecline = (0, import_react8.useCallback)(
2518
2522
  (method, input, overrides) => {
2519
2523
  onDeclineRef.current?.(buildDeclineEvent(method, input, overrides));
@@ -2606,10 +2610,10 @@ function FloPayCheckout({
2606
2610
  }, [sessionIdProp]);
2607
2611
  (0, import_react8.useEffect)(() => {
2608
2612
  autoCheckoutAttempted.current = false;
2609
- setModeError(null);
2613
+ setModeError(initialErrorMessage);
2610
2614
  setModeOverlayError(null);
2611
2615
  setModeOverlayStatus(null);
2612
- }, [sessionIdProp, createSessionHash]);
2616
+ }, [createSessionHash, initialErrorMessage, sessionIdProp]);
2613
2617
  async function resolveInlineSession(params, cacheKey) {
2614
2618
  const api = new import_js2.PaymentAPI(resolvedBillingUrl);
2615
2619
  let sid = typeof window !== "undefined" ? window.sessionStorage.getItem(cacheKey) : null;
@@ -4454,7 +4458,7 @@ function FloPayAutomaticPaymentButton({
4454
4458
  padding: "1.5rem",
4455
4459
  zIndex: 1100
4456
4460
  },
4457
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
4461
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
4458
4462
  "div",
4459
4463
  {
4460
4464
  style: {
@@ -4470,48 +4474,21 @@ function FloPayAutomaticPaymentButton({
4470
4474
  flexDirection: "column",
4471
4475
  gap: "1rem"
4472
4476
  },
4473
- children: [
4474
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
4475
- "div",
4476
- {
4477
- style: {
4478
- display: "flex",
4479
- gap: "1rem",
4480
- alignItems: "flex-start"
4481
- },
4482
- children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
4483
- "div",
4484
- {
4485
- style: {
4486
- flex: 1,
4487
- background: "#fef2f2",
4488
- color: "#b91c1c",
4489
- border: "1px solid #fecaca",
4490
- borderRadius: "12px",
4491
- padding: "0.75rem 1rem",
4492
- fontSize: "0.9rem",
4493
- lineHeight: 1.5
4494
- },
4495
- children: fallbackSession.errorMessage
4496
- }
4497
- )
4498
- }
4499
- ),
4500
- /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
4501
- FloPayCheckout,
4502
- {
4503
- sessionId: fallbackSession.sessionId,
4504
- checkoutMode: "full",
4505
- billingApiUrl: resolvedBillingUrl,
4506
- fallbackPublishableKey,
4507
- cardTitleContent: null,
4508
- showSecurityFooter: false,
4509
- onComplete: handleFallbackComplete,
4510
- onError: handleFallbackError,
4511
- onDecline: handleFallbackDecline
4512
- }
4513
- )
4514
- ]
4477
+ children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
4478
+ FloPayCheckout,
4479
+ {
4480
+ sessionId: fallbackSession.sessionId,
4481
+ checkoutMode: "full",
4482
+ billingApiUrl: resolvedBillingUrl,
4483
+ fallbackPublishableKey,
4484
+ initialErrorMessage: fallbackSession.errorMessage,
4485
+ cardTitleContent: null,
4486
+ showSecurityFooter: false,
4487
+ onComplete: handleFallbackComplete,
4488
+ onError: handleFallbackError,
4489
+ onDecline: handleFallbackDecline
4490
+ }
4491
+ )
4515
4492
  }
4516
4493
  )
4517
4494
  }