@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 +9 -9
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +9 -9
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.mjs
CHANGED
|
@@ -773,8 +773,9 @@ function PayPalButtonInner({
|
|
|
773
773
|
accountPatch: beforeClick.accountPatch,
|
|
774
774
|
sessionId: beforeClick.sessionId
|
|
775
775
|
};
|
|
776
|
+
onButtonClick?.("paypal");
|
|
776
777
|
event.resolve();
|
|
777
|
-
}, [isProcessing, runBeforeButtonClick, submitting]);
|
|
778
|
+
}, [isProcessing, onButtonClick, runBeforeButtonClick, submitting]);
|
|
778
779
|
const handlePayPalConfirm = useCallback(async (event) => {
|
|
779
780
|
if (!stripe || !elements) return;
|
|
780
781
|
let prepared = beforeClickRef.current;
|
|
@@ -792,7 +793,6 @@ function PayPalButtonInner({
|
|
|
792
793
|
}
|
|
793
794
|
const effectiveSessionId = prepared?.sessionId ?? sessionId;
|
|
794
795
|
const effectiveEmail = prepared?.accountPatch?.email ?? email;
|
|
795
|
-
onButtonClick?.("paypal");
|
|
796
796
|
try {
|
|
797
797
|
setSubmitting(true);
|
|
798
798
|
onErrorChange?.(null);
|
|
@@ -867,7 +867,7 @@ function PayPalButtonInner({
|
|
|
867
867
|
} finally {
|
|
868
868
|
setSubmitting(false);
|
|
869
869
|
}
|
|
870
|
-
}, [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange, onDecline,
|
|
870
|
+
}, [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange, onDecline, runBeforeButtonClick]);
|
|
871
871
|
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
872
872
|
/* @__PURE__ */ jsx5(ExpressCheckoutReadySwap, { state: loadState, placeholderTestId: "flopay-paypal-placeholder", children: /* @__PURE__ */ jsx5(
|
|
873
873
|
ExpressCheckoutElement,
|
|
@@ -938,7 +938,6 @@ function WalletButtonInner({
|
|
|
938
938
|
const method = walletType === "apple_pay" ? "apple_pay" : "google_pay";
|
|
939
939
|
const effectiveSessionId = prepared?.sessionId ?? sessionId;
|
|
940
940
|
const effectiveEmail = prepared?.accountPatch?.email ?? email;
|
|
941
|
-
onButtonClick?.(walletType === "apple_pay" ? "apple_pay" : "google_pay");
|
|
942
941
|
try {
|
|
943
942
|
setSubmitting(true);
|
|
944
943
|
onErrorChange?.(null);
|
|
@@ -1004,7 +1003,7 @@ function WalletButtonInner({
|
|
|
1004
1003
|
setSubmitting(false);
|
|
1005
1004
|
}
|
|
1006
1005
|
},
|
|
1007
|
-
[stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange, onDecline,
|
|
1006
|
+
[stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange, onDecline, runBeforeButtonClick]
|
|
1008
1007
|
);
|
|
1009
1008
|
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
1010
1009
|
/* @__PURE__ */ jsx5(ExpressCheckoutReadySwap, { state: loadState, placeholderTestId: "flopay-wallet-placeholder", children: /* @__PURE__ */ jsx5(
|
|
@@ -1024,6 +1023,7 @@ function WalletButtonInner({
|
|
|
1024
1023
|
accountPatch: beforeClick.accountPatch,
|
|
1025
1024
|
sessionId: beforeClick.sessionId
|
|
1026
1025
|
};
|
|
1026
|
+
onButtonClick?.(lastWalletMethodRef.current);
|
|
1027
1027
|
event.resolve();
|
|
1028
1028
|
},
|
|
1029
1029
|
onConfirm: handleWalletConfirm,
|
|
@@ -2740,6 +2740,7 @@ async function loadSavedPaymentProviders({
|
|
|
2740
2740
|
import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
2741
2741
|
var DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2 = 44;
|
|
2742
2742
|
var PAYPAL_RESUME_STORAGE_KEY = "flopay_checkout_saved_payment_resume";
|
|
2743
|
+
var sessionInflightMap = /* @__PURE__ */ new Map();
|
|
2743
2744
|
function sleep(ms) {
|
|
2744
2745
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2745
2746
|
}
|
|
@@ -3106,7 +3107,6 @@ function FloPayCheckout({
|
|
|
3106
3107
|
}
|
|
3107
3108
|
})();
|
|
3108
3109
|
}, [emitDecline, locale, normalizeSavedPaymentError, resolvedBillingUrl]);
|
|
3109
|
-
const inflightRef = useRef3(/* @__PURE__ */ new Map());
|
|
3110
3110
|
const initializedHashRef = useRef3(null);
|
|
3111
3111
|
function hashCreateParams(params) {
|
|
3112
3112
|
const key = JSON.stringify({
|
|
@@ -3188,16 +3188,16 @@ function FloPayCheckout({
|
|
|
3188
3188
|
}
|
|
3189
3189
|
const mergedParams = mergeInlineSessionPatch(baseParams, patch);
|
|
3190
3190
|
const cacheKey = hashCreateParams(mergedParams);
|
|
3191
|
-
let promise =
|
|
3191
|
+
let promise = sessionInflightMap.get(cacheKey);
|
|
3192
3192
|
if (!promise) {
|
|
3193
3193
|
promise = resolveInlineSession(mergedParams, cacheKey);
|
|
3194
|
-
|
|
3194
|
+
sessionInflightMap.set(cacheKey, promise);
|
|
3195
3195
|
}
|
|
3196
3196
|
let resolved;
|
|
3197
3197
|
try {
|
|
3198
3198
|
resolved = await promise;
|
|
3199
3199
|
} finally {
|
|
3200
|
-
|
|
3200
|
+
sessionInflightMap.delete(cacheKey);
|
|
3201
3201
|
}
|
|
3202
3202
|
initializedHashRef.current = cacheKey;
|
|
3203
3203
|
try {
|