@flopay/react 0.5.5 → 0.5.6

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
@@ -810,8 +810,9 @@ function PayPalButtonInner({
810
810
  accountPatch: beforeClick.accountPatch,
811
811
  sessionId: beforeClick.sessionId
812
812
  };
813
+ onButtonClick?.("paypal");
813
814
  event.resolve();
814
- }, [isProcessing, runBeforeButtonClick, submitting]);
815
+ }, [isProcessing, onButtonClick, runBeforeButtonClick, submitting]);
815
816
  const handlePayPalConfirm = (0, import_react7.useCallback)(async (event) => {
816
817
  if (!stripe || !elements) return;
817
818
  let prepared = beforeClickRef.current;
@@ -829,7 +830,6 @@ function PayPalButtonInner({
829
830
  }
830
831
  const effectiveSessionId = prepared?.sessionId ?? sessionId;
831
832
  const effectiveEmail = prepared?.accountPatch?.email ?? email;
832
- onButtonClick?.("paypal");
833
833
  try {
834
834
  setSubmitting(true);
835
835
  onErrorChange?.(null);
@@ -904,7 +904,7 @@ function PayPalButtonInner({
904
904
  } finally {
905
905
  setSubmitting(false);
906
906
  }
907
- }, [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange, onDecline, onButtonClick, runBeforeButtonClick]);
907
+ }, [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange, onDecline, runBeforeButtonClick]);
908
908
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
909
909
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ExpressCheckoutReadySwap, { state: loadState, placeholderTestId: "flopay-paypal-placeholder", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
910
910
  import_react_stripe_js.ExpressCheckoutElement,
@@ -975,7 +975,6 @@ function WalletButtonInner({
975
975
  const method = walletType === "apple_pay" ? "apple_pay" : "google_pay";
976
976
  const effectiveSessionId = prepared?.sessionId ?? sessionId;
977
977
  const effectiveEmail = prepared?.accountPatch?.email ?? email;
978
- onButtonClick?.(walletType === "apple_pay" ? "apple_pay" : "google_pay");
979
978
  try {
980
979
  setSubmitting(true);
981
980
  onErrorChange?.(null);
@@ -1041,7 +1040,7 @@ function WalletButtonInner({
1041
1040
  setSubmitting(false);
1042
1041
  }
1043
1042
  },
1044
- [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange, onDecline, onButtonClick, runBeforeButtonClick]
1043
+ [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange, onDecline, runBeforeButtonClick]
1045
1044
  );
1046
1045
  return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(import_jsx_runtime5.Fragment, { children: [
1047
1046
  /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(ExpressCheckoutReadySwap, { state: loadState, placeholderTestId: "flopay-wallet-placeholder", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
@@ -1061,6 +1060,7 @@ function WalletButtonInner({
1061
1060
  accountPatch: beforeClick.accountPatch,
1062
1061
  sessionId: beforeClick.sessionId
1063
1062
  };
1063
+ onButtonClick?.(lastWalletMethodRef.current);
1064
1064
  event.resolve();
1065
1065
  },
1066
1066
  onConfirm: handleWalletConfirm,
@@ -2777,6 +2777,7 @@ async function loadSavedPaymentProviders({
2777
2777
  var import_jsx_runtime6 = require("react/jsx-runtime");
2778
2778
  var DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2 = 44;
2779
2779
  var PAYPAL_RESUME_STORAGE_KEY = "flopay_checkout_saved_payment_resume";
2780
+ var sessionInflightMap = /* @__PURE__ */ new Map();
2780
2781
  function sleep(ms) {
2781
2782
  return new Promise((resolve) => setTimeout(resolve, ms));
2782
2783
  }
@@ -3143,7 +3144,6 @@ function FloPayCheckout({
3143
3144
  }
3144
3145
  })();
3145
3146
  }, [emitDecline, locale, normalizeSavedPaymentError, resolvedBillingUrl]);
3146
- const inflightRef = (0, import_react8.useRef)(/* @__PURE__ */ new Map());
3147
3147
  const initializedHashRef = (0, import_react8.useRef)(null);
3148
3148
  function hashCreateParams(params) {
3149
3149
  const key = JSON.stringify({
@@ -3225,16 +3225,16 @@ function FloPayCheckout({
3225
3225
  }
3226
3226
  const mergedParams = mergeInlineSessionPatch(baseParams, patch);
3227
3227
  const cacheKey = hashCreateParams(mergedParams);
3228
- let promise = inflightRef.current.get(cacheKey);
3228
+ let promise = sessionInflightMap.get(cacheKey);
3229
3229
  if (!promise) {
3230
3230
  promise = resolveInlineSession(mergedParams, cacheKey);
3231
- inflightRef.current.set(cacheKey, promise);
3231
+ sessionInflightMap.set(cacheKey, promise);
3232
3232
  }
3233
3233
  let resolved;
3234
3234
  try {
3235
3235
  resolved = await promise;
3236
3236
  } finally {
3237
- inflightRef.current.delete(cacheKey);
3237
+ sessionInflightMap.delete(cacheKey);
3238
3238
  }
3239
3239
  initializedHashRef.current = cacheKey;
3240
3240
  try {