@flopay/react 1.4.0 → 1.4.1
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/README.md +7 -0
- package/dist/index.cjs +691 -710
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +377 -397
- package/dist/index.mjs.map +1 -1
- package/dist/payment-logos/alipay.svg +1 -0
- package/dist/payment-logos/bancontact.svg +1 -0
- package/dist/payment-logos/blik.svg +1 -0
- package/dist/payment-logos/eps.svg +1 -0
- package/dist/payment-logos/giropay.svg +1 -0
- package/dist/payment-logos/ideal.svg +1 -0
- package/dist/payment-logos/klarna.svg +1 -0
- package/dist/payment-logos/p24.svg +1 -0
- package/dist/payment-logos/sepa_debit.svg +1 -0
- package/dist/payment-logos/wechat_pay.svg +1 -0
- package/package.json +4 -3
package/dist/index.cjs
CHANGED
|
@@ -246,7 +246,7 @@ function FloPayProvider({
|
|
|
246
246
|
}
|
|
247
247
|
|
|
248
248
|
// src/flopay-checkout.tsx
|
|
249
|
-
var
|
|
249
|
+
var import_react11 = __toESM(require("react"), 1);
|
|
250
250
|
var import_js4 = require("@flopay/js");
|
|
251
251
|
var import_shared8 = require("@flopay/shared");
|
|
252
252
|
|
|
@@ -456,42 +456,100 @@ function VaultCardFields({
|
|
|
456
456
|
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { ref: containerRef, "data-testid": "flopay-vault-card-fields", style: containerStyle });
|
|
457
457
|
}
|
|
458
458
|
|
|
459
|
+
// src/error-banner.tsx
|
|
460
|
+
var import_react6 = require("react");
|
|
461
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
462
|
+
function ErrorBanner({
|
|
463
|
+
children,
|
|
464
|
+
margin,
|
|
465
|
+
icon = true,
|
|
466
|
+
styleOverride
|
|
467
|
+
}) {
|
|
468
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
469
|
+
"div",
|
|
470
|
+
{
|
|
471
|
+
role: "alert",
|
|
472
|
+
"data-testid": "flopay-error",
|
|
473
|
+
style: {
|
|
474
|
+
margin,
|
|
475
|
+
padding: "0.625rem 0.875rem",
|
|
476
|
+
background: "#FEF2F2",
|
|
477
|
+
border: "1px solid #FECACA",
|
|
478
|
+
borderRadius: "8px",
|
|
479
|
+
color: "#991B1B",
|
|
480
|
+
fontSize: "0.85rem",
|
|
481
|
+
fontWeight: 600,
|
|
482
|
+
...icon ? { display: "flex", alignItems: "center", gap: "0.5rem" } : {},
|
|
483
|
+
...styleOverride ?? {}
|
|
484
|
+
},
|
|
485
|
+
children: [
|
|
486
|
+
icon && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
487
|
+
"path",
|
|
488
|
+
{
|
|
489
|
+
d: "M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z",
|
|
490
|
+
stroke: "#DC2626",
|
|
491
|
+
strokeWidth: "2",
|
|
492
|
+
strokeLinecap: "round",
|
|
493
|
+
strokeLinejoin: "round"
|
|
494
|
+
}
|
|
495
|
+
) }),
|
|
496
|
+
children
|
|
497
|
+
]
|
|
498
|
+
}
|
|
499
|
+
);
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// src/payment-logos.generated.ts
|
|
503
|
+
var import_meta = {};
|
|
504
|
+
var PAYMENT_METHOD_LOGO_URLS = {
|
|
505
|
+
"alipay": new URL("./payment-logos/alipay.svg", import_meta.url).href,
|
|
506
|
+
"bancontact": new URL("./payment-logos/bancontact.svg", import_meta.url).href,
|
|
507
|
+
"blik": new URL("./payment-logos/blik.svg", import_meta.url).href,
|
|
508
|
+
"eps": new URL("./payment-logos/eps.svg", import_meta.url).href,
|
|
509
|
+
"giropay": new URL("./payment-logos/giropay.svg", import_meta.url).href,
|
|
510
|
+
"ideal": new URL("./payment-logos/ideal.svg", import_meta.url).href,
|
|
511
|
+
"klarna": new URL("./payment-logos/klarna.svg", import_meta.url).href,
|
|
512
|
+
"p24": new URL("./payment-logos/p24.svg", import_meta.url).href,
|
|
513
|
+
"sepa_debit": new URL("./payment-logos/sepa_debit.svg", import_meta.url).href,
|
|
514
|
+
"wechat_pay": new URL("./payment-logos/wechat_pay.svg", import_meta.url).href
|
|
515
|
+
};
|
|
516
|
+
|
|
459
517
|
// src/split-card-form.tsx
|
|
460
|
-
var
|
|
518
|
+
var import_react10 = __toESM(require("react"), 1);
|
|
461
519
|
|
|
462
520
|
// src/hooks.ts
|
|
463
|
-
var
|
|
521
|
+
var import_react7 = require("react");
|
|
464
522
|
var import_shared2 = require("@flopay/shared");
|
|
465
523
|
function useFloPay() {
|
|
466
|
-
const ctx = (0,
|
|
524
|
+
const ctx = (0, import_react7.useContext)(FloPayContext);
|
|
467
525
|
return ctx.flopay;
|
|
468
526
|
}
|
|
469
527
|
function usePayPalFloPay() {
|
|
470
|
-
const ctx = (0,
|
|
528
|
+
const ctx = (0, import_react7.useContext)(FloPayContext);
|
|
471
529
|
return ctx.paypalFlopay ?? null;
|
|
472
530
|
}
|
|
473
531
|
function useElements() {
|
|
474
|
-
const ctx = (0,
|
|
532
|
+
const ctx = (0, import_react7.useContext)(FloPayContext);
|
|
475
533
|
return ctx.elements;
|
|
476
534
|
}
|
|
477
535
|
function useCheckout() {
|
|
478
|
-
return (0,
|
|
536
|
+
return (0, import_react7.useContext)(CheckoutContext);
|
|
479
537
|
}
|
|
480
538
|
function useBillingApiUrl() {
|
|
481
|
-
const ctx = (0,
|
|
539
|
+
const ctx = (0, import_react7.useContext)(FloPayContext);
|
|
482
540
|
return ctx.billingApiUrl || (0, import_shared2.resolveBillingApiUrl)();
|
|
483
541
|
}
|
|
484
542
|
|
|
485
543
|
// src/processing-overlay.tsx
|
|
486
|
-
var
|
|
487
|
-
var
|
|
544
|
+
var import_react8 = require("react");
|
|
545
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
488
546
|
var PROCESSING_OVERLAY_SUCCESS_DELAY_MS = 1200;
|
|
489
547
|
var PROCESSING_OVERLAY_ERROR_DELAY_MS = 1500;
|
|
490
548
|
function ProcessingOverlay({
|
|
491
549
|
status,
|
|
492
550
|
errorMessage
|
|
493
551
|
}) {
|
|
494
|
-
return /* @__PURE__ */ (0,
|
|
552
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
495
553
|
"div",
|
|
496
554
|
{
|
|
497
555
|
"data-testid": "flopay-processing-overlay",
|
|
@@ -508,7 +566,7 @@ function ProcessingOverlay({
|
|
|
508
566
|
zIndex: 1e3,
|
|
509
567
|
backdropFilter: "blur(2px)"
|
|
510
568
|
},
|
|
511
|
-
children: /* @__PURE__ */ (0,
|
|
569
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
512
570
|
"div",
|
|
513
571
|
{
|
|
514
572
|
style: {
|
|
@@ -524,8 +582,8 @@ function ProcessingOverlay({
|
|
|
524
582
|
gap: 16
|
|
525
583
|
},
|
|
526
584
|
children: [
|
|
527
|
-
/* @__PURE__ */ (0,
|
|
528
|
-
status === "processing" && /* @__PURE__ */ (0,
|
|
585
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("div", { style: { width: 48, height: 48, position: "relative" }, children: [
|
|
586
|
+
status === "processing" && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
529
587
|
"svg",
|
|
530
588
|
{
|
|
531
589
|
width: "48",
|
|
@@ -535,14 +593,14 @@ function ProcessingOverlay({
|
|
|
535
593
|
xmlns: "http://www.w3.org/2000/svg",
|
|
536
594
|
style: { animation: "flopay-spin 0.8s linear infinite" },
|
|
537
595
|
children: [
|
|
538
|
-
/* @__PURE__ */ (0,
|
|
539
|
-
/* @__PURE__ */ (0,
|
|
596
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("circle", { cx: "12", cy: "12", r: "10", stroke: "#e5e7eb", strokeWidth: "3" }),
|
|
597
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("path", { d: "M4 12a8 8 0 018-8v3a5 5 0 00-5 5H4z", fill: "#4A49FF" })
|
|
540
598
|
]
|
|
541
599
|
}
|
|
542
600
|
),
|
|
543
|
-
status === "success" && /* @__PURE__ */ (0,
|
|
544
|
-
/* @__PURE__ */ (0,
|
|
545
|
-
/* @__PURE__ */ (0,
|
|
601
|
+
status === "success" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { animation: "flopay-pop 0.4s cubic-bezier(0.34,1.56,0.64,1)" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("svg", { width: "48", height: "48", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
602
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("circle", { cx: "12", cy: "12", r: "11", fill: "#22c55e" }),
|
|
603
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
546
604
|
"path",
|
|
547
605
|
{
|
|
548
606
|
d: "M7 12.5l3 3 7-7",
|
|
@@ -558,9 +616,9 @@ function ProcessingOverlay({
|
|
|
558
616
|
}
|
|
559
617
|
)
|
|
560
618
|
] }) }),
|
|
561
|
-
status === "error" && /* @__PURE__ */ (0,
|
|
562
|
-
/* @__PURE__ */ (0,
|
|
563
|
-
/* @__PURE__ */ (0,
|
|
619
|
+
status === "error" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { style: { animation: "flopay-shake 0.4s ease" }, children: /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("svg", { width: "48", height: "48", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
620
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("circle", { cx: "12", cy: "12", r: "11", fill: "#ef4444" }),
|
|
621
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
564
622
|
"path",
|
|
565
623
|
{
|
|
566
624
|
d: "M8 8l8 8M16 8l-8 8",
|
|
@@ -576,7 +634,7 @@ function ProcessingOverlay({
|
|
|
576
634
|
)
|
|
577
635
|
] }) })
|
|
578
636
|
] }),
|
|
579
|
-
/* @__PURE__ */ (0,
|
|
637
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(
|
|
580
638
|
"span",
|
|
581
639
|
{
|
|
582
640
|
style: {
|
|
@@ -592,7 +650,7 @@ function ProcessingOverlay({
|
|
|
592
650
|
]
|
|
593
651
|
}
|
|
594
652
|
),
|
|
595
|
-
status === "success" && /* @__PURE__ */ (0,
|
|
653
|
+
status === "success" && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
596
654
|
"p",
|
|
597
655
|
{
|
|
598
656
|
style: {
|
|
@@ -606,7 +664,7 @@ function ProcessingOverlay({
|
|
|
606
664
|
children: "You will be automatically redirected, do not close or navigate away from this window."
|
|
607
665
|
}
|
|
608
666
|
),
|
|
609
|
-
status === "error" && errorMessage && /* @__PURE__ */ (0,
|
|
667
|
+
status === "error" && errorMessage && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
610
668
|
"p",
|
|
611
669
|
{
|
|
612
670
|
style: {
|
|
@@ -620,7 +678,7 @@ function ProcessingOverlay({
|
|
|
620
678
|
children: errorMessage
|
|
621
679
|
}
|
|
622
680
|
),
|
|
623
|
-
/* @__PURE__ */ (0,
|
|
681
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)("style", { children: `
|
|
624
682
|
@keyframes flopay-spin { to { transform: rotate(360deg); } }
|
|
625
683
|
@keyframes flopay-pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }
|
|
626
684
|
@keyframes flopay-draw { to { stroke-dashoffset: 0; } }
|
|
@@ -782,6 +840,14 @@ async function buildFloPayApiErrorFromResponse(response, fallbackMessage) {
|
|
|
782
840
|
const payload = await response.json().catch(() => null);
|
|
783
841
|
return buildFloPayApiError(payload, fallbackMessage);
|
|
784
842
|
}
|
|
843
|
+
function intentRequestHeaders(nonce) {
|
|
844
|
+
const headers = { "Content-Type": "application/json" };
|
|
845
|
+
if (nonce) headers["x-checkout-session-token"] = nonce;
|
|
846
|
+
return headers;
|
|
847
|
+
}
|
|
848
|
+
function isSuccessfulPaymentIntentStatus(status) {
|
|
849
|
+
return status === "succeeded" || status === "requires_capture" || status === "processing";
|
|
850
|
+
}
|
|
785
851
|
function mapPayPalIntentStatusToPaymentResult(status) {
|
|
786
852
|
if (status === "succeeded") {
|
|
787
853
|
return "succeeded";
|
|
@@ -894,7 +960,7 @@ function isInAppBrowser(userAgent) {
|
|
|
894
960
|
}
|
|
895
961
|
|
|
896
962
|
// src/direct-paypal-button.tsx
|
|
897
|
-
var
|
|
963
|
+
var import_react9 = require("react");
|
|
898
964
|
var import_paypal_js = require("@paypal/paypal-js");
|
|
899
965
|
var import_js = require("@flopay/js");
|
|
900
966
|
var import_shared4 = require("@flopay/shared");
|
|
@@ -949,7 +1015,7 @@ function isPopupBlockedError(err) {
|
|
|
949
1015
|
}
|
|
950
1016
|
|
|
951
1017
|
// src/direct-paypal-button.tsx
|
|
952
|
-
var
|
|
1018
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
953
1019
|
var DEFAULT_BUTTON_HEIGHT = 45;
|
|
954
1020
|
var DIRECT_PAYPAL_RECOVERY_MESSAGE = "We couldn't open PayPal. Try again or choose another payment method.";
|
|
955
1021
|
var DIRECT_PAYPAL_RECOVERY_ACTION_STYLE = {
|
|
@@ -993,7 +1059,7 @@ function DirectPayPalButtonImplementation({
|
|
|
993
1059
|
debug = false
|
|
994
1060
|
}) {
|
|
995
1061
|
const flopay = useFloPay();
|
|
996
|
-
const standaloneTelemetry = (0,
|
|
1062
|
+
const standaloneTelemetry = (0, import_react9.useMemo)(() => {
|
|
997
1063
|
if (flopay) return null;
|
|
998
1064
|
const reporter = createTelemetryBridge({
|
|
999
1065
|
billingApiUrl,
|
|
@@ -1011,13 +1077,13 @@ function DirectPayPalButtonImplementation({
|
|
|
1011
1077
|
telemetryContext?.checkoutMode,
|
|
1012
1078
|
telemetryContext?.layout
|
|
1013
1079
|
]);
|
|
1014
|
-
const floPayTelemetry = (0,
|
|
1015
|
-
(0,
|
|
1080
|
+
const floPayTelemetry = (0, import_react9.useMemo)(() => getFloPayTelemetryBridge(flopay), [flopay]);
|
|
1081
|
+
(0, import_react9.useEffect)(() => () => {
|
|
1016
1082
|
if (!standaloneTelemetry) return;
|
|
1017
1083
|
void standaloneTelemetry.flush().catch(() => {
|
|
1018
1084
|
}).finally(() => standaloneTelemetry.destroy());
|
|
1019
1085
|
}, [standaloneTelemetry]);
|
|
1020
|
-
const telemetrySource = (0,
|
|
1086
|
+
const telemetrySource = (0, import_react9.useMemo)(() => ({
|
|
1021
1087
|
error: (input) => {
|
|
1022
1088
|
if (floPayTelemetry) floPayTelemetry.error(input);
|
|
1023
1089
|
else standaloneTelemetry?.error(input);
|
|
@@ -1037,100 +1103,100 @@ function DirectPayPalButtonImplementation({
|
|
|
1037
1103
|
startTiming: () => floPayTelemetry?.now() ?? standaloneTelemetry?.now() ?? 0,
|
|
1038
1104
|
elapsed: (startedAt) => floPayTelemetry?.elapsed(startedAt) ?? Math.max(0, (standaloneTelemetry?.now() ?? startedAt) - startedAt)
|
|
1039
1105
|
}), [floPayTelemetry, standaloneTelemetry]);
|
|
1040
|
-
const containerRef = (0,
|
|
1041
|
-
const providerStartedAt = (0,
|
|
1042
|
-
const focusTargetRef = (0,
|
|
1043
|
-
const pendingProviderFocusRef = (0,
|
|
1044
|
-
const [ready, setReady] = (0,
|
|
1045
|
-
const [renderGeneration, setRenderGeneration] = (0,
|
|
1046
|
-
const activeRenderGenerationRef = (0,
|
|
1047
|
-
const [showRetryFocusTarget, setShowRetryFocusTarget] = (0,
|
|
1048
|
-
const [failed, setFailed] = (0,
|
|
1049
|
-
const [submitting, setSubmitting] = (0,
|
|
1050
|
-
const baseUrl = (0,
|
|
1051
|
-
const [debugLines, setDebugLines] = (0,
|
|
1106
|
+
const containerRef = (0, import_react9.useRef)(null);
|
|
1107
|
+
const providerStartedAt = (0, import_react9.useRef)(0);
|
|
1108
|
+
const focusTargetRef = (0, import_react9.useRef)(null);
|
|
1109
|
+
const pendingProviderFocusRef = (0, import_react9.useRef)(false);
|
|
1110
|
+
const [ready, setReady] = (0, import_react9.useState)(false);
|
|
1111
|
+
const [renderGeneration, setRenderGeneration] = (0, import_react9.useState)(0);
|
|
1112
|
+
const activeRenderGenerationRef = (0, import_react9.useRef)(0);
|
|
1113
|
+
const [showRetryFocusTarget, setShowRetryFocusTarget] = (0, import_react9.useState)(false);
|
|
1114
|
+
const [failed, setFailed] = (0, import_react9.useState)(false);
|
|
1115
|
+
const [submitting, setSubmitting] = (0, import_react9.useState)(false);
|
|
1116
|
+
const baseUrl = (0, import_react9.useMemo)(() => billingApiUrl.replace(/\/+$/, ""), [billingApiUrl]);
|
|
1117
|
+
const [debugLines, setDebugLines] = (0, import_react9.useState)([]);
|
|
1052
1118
|
const appendDebug = (line) => {
|
|
1053
1119
|
if (!debug) return;
|
|
1054
1120
|
setDebugLines((prev) => [...prev, `${(/* @__PURE__ */ new Date()).toISOString().slice(11, 23)} ${line}`]);
|
|
1055
1121
|
};
|
|
1056
|
-
const onTokenizedBodyRef = (0,
|
|
1057
|
-
const onCompleteRef = (0,
|
|
1058
|
-
const onErrorChangeRef = (0,
|
|
1059
|
-
const onDeclineRef = (0,
|
|
1060
|
-
const onTechnicalFailureRef = (0,
|
|
1061
|
-
const onButtonClickRef = (0,
|
|
1062
|
-
const onLoadStateChangeRef = (0,
|
|
1063
|
-
const runBeforeButtonClickRef = (0,
|
|
1064
|
-
const sessionRef = (0,
|
|
1065
|
-
const emailRef = (0,
|
|
1066
|
-
const nonceRef = (0,
|
|
1067
|
-
const beforeClickRef = (0,
|
|
1068
|
-
const attemptGenerationRef = (0,
|
|
1069
|
-
const attemptRef = (0,
|
|
1070
|
-
const invalidatedAttemptGenerationRef = (0,
|
|
1071
|
-
const attemptContextBySurfaceRef = (0,
|
|
1072
|
-
const approvalContextByTokenRef = (0,
|
|
1073
|
-
(0,
|
|
1122
|
+
const onTokenizedBodyRef = (0, import_react9.useRef)(onTokenizedBody);
|
|
1123
|
+
const onCompleteRef = (0, import_react9.useRef)(onComplete);
|
|
1124
|
+
const onErrorChangeRef = (0, import_react9.useRef)(onErrorChange);
|
|
1125
|
+
const onDeclineRef = (0, import_react9.useRef)(onDecline);
|
|
1126
|
+
const onTechnicalFailureRef = (0, import_react9.useRef)(onTechnicalFailure);
|
|
1127
|
+
const onButtonClickRef = (0, import_react9.useRef)(onButtonClick);
|
|
1128
|
+
const onLoadStateChangeRef = (0, import_react9.useRef)(onLoadStateChange);
|
|
1129
|
+
const runBeforeButtonClickRef = (0, import_react9.useRef)(runBeforeButtonClick);
|
|
1130
|
+
const sessionRef = (0, import_react9.useRef)(session);
|
|
1131
|
+
const emailRef = (0, import_react9.useRef)(email);
|
|
1132
|
+
const nonceRef = (0, import_react9.useRef)(nonce);
|
|
1133
|
+
const beforeClickRef = (0, import_react9.useRef)(null);
|
|
1134
|
+
const attemptGenerationRef = (0, import_react9.useRef)(0);
|
|
1135
|
+
const attemptRef = (0, import_react9.useRef)(null);
|
|
1136
|
+
const invalidatedAttemptGenerationRef = (0, import_react9.useRef)(null);
|
|
1137
|
+
const attemptContextBySurfaceRef = (0, import_react9.useRef)(/* @__PURE__ */ new Map());
|
|
1138
|
+
const approvalContextByTokenRef = (0, import_react9.useRef)(/* @__PURE__ */ new Map());
|
|
1139
|
+
(0, import_react9.useEffect)(() => {
|
|
1074
1140
|
onTokenizedBodyRef.current = onTokenizedBody;
|
|
1075
1141
|
}, [onTokenizedBody]);
|
|
1076
|
-
(0,
|
|
1142
|
+
(0, import_react9.useEffect)(() => {
|
|
1077
1143
|
onCompleteRef.current = onComplete;
|
|
1078
1144
|
}, [onComplete]);
|
|
1079
|
-
(0,
|
|
1145
|
+
(0, import_react9.useEffect)(() => {
|
|
1080
1146
|
onErrorChangeRef.current = onErrorChange;
|
|
1081
1147
|
}, [onErrorChange]);
|
|
1082
|
-
(0,
|
|
1148
|
+
(0, import_react9.useEffect)(() => {
|
|
1083
1149
|
onDeclineRef.current = onDecline;
|
|
1084
1150
|
}, [onDecline]);
|
|
1085
|
-
(0,
|
|
1151
|
+
(0, import_react9.useEffect)(() => {
|
|
1086
1152
|
onTechnicalFailureRef.current = onTechnicalFailure;
|
|
1087
1153
|
}, [onTechnicalFailure]);
|
|
1088
|
-
(0,
|
|
1154
|
+
(0, import_react9.useEffect)(() => {
|
|
1089
1155
|
onButtonClickRef.current = onButtonClick;
|
|
1090
1156
|
}, [onButtonClick]);
|
|
1091
|
-
(0,
|
|
1157
|
+
(0, import_react9.useEffect)(() => {
|
|
1092
1158
|
onLoadStateChangeRef.current = onLoadStateChange;
|
|
1093
1159
|
}, [onLoadStateChange]);
|
|
1094
|
-
(0,
|
|
1160
|
+
(0, import_react9.useEffect)(() => {
|
|
1095
1161
|
runBeforeButtonClickRef.current = runBeforeButtonClick;
|
|
1096
1162
|
}, [runBeforeButtonClick]);
|
|
1097
|
-
(0,
|
|
1163
|
+
(0, import_react9.useEffect)(() => {
|
|
1098
1164
|
sessionRef.current = session;
|
|
1099
1165
|
}, [session]);
|
|
1100
|
-
(0,
|
|
1166
|
+
(0, import_react9.useEffect)(() => {
|
|
1101
1167
|
emailRef.current = email;
|
|
1102
1168
|
}, [email]);
|
|
1103
|
-
(0,
|
|
1169
|
+
(0, import_react9.useEffect)(() => {
|
|
1104
1170
|
nonceRef.current = nonce;
|
|
1105
1171
|
}, [nonce]);
|
|
1106
|
-
(0,
|
|
1172
|
+
(0, import_react9.useEffect)(() => {
|
|
1107
1173
|
activeRenderGenerationRef.current = renderGeneration;
|
|
1108
1174
|
}, [renderGeneration]);
|
|
1109
|
-
(0,
|
|
1175
|
+
(0, import_react9.useEffect)(() => {
|
|
1110
1176
|
if (showRetryFocusTarget) focusTargetRef.current?.focus();
|
|
1111
1177
|
}, [showRetryFocusTarget, renderGeneration]);
|
|
1112
|
-
const focusRetryTarget = (0,
|
|
1178
|
+
const focusRetryTarget = (0, import_react9.useCallback)(() => {
|
|
1113
1179
|
window.setTimeout(() => {
|
|
1114
1180
|
focusTargetRef.current?.focus();
|
|
1115
1181
|
}, 0);
|
|
1116
1182
|
}, []);
|
|
1117
|
-
const remountPayPalButtons = (0,
|
|
1183
|
+
const remountPayPalButtons = (0, import_react9.useCallback)(() => {
|
|
1118
1184
|
setReady(false);
|
|
1119
1185
|
setRenderGeneration((current) => current + 1);
|
|
1120
1186
|
}, []);
|
|
1121
|
-
const focusPayPalSurface = (0,
|
|
1187
|
+
const focusPayPalSurface = (0, import_react9.useCallback)(() => {
|
|
1122
1188
|
setShowRetryFocusTarget(false);
|
|
1123
1189
|
const target = containerRef.current?.querySelector(
|
|
1124
1190
|
'iframe, button, [tabindex]:not([tabindex="-1"])'
|
|
1125
1191
|
);
|
|
1126
1192
|
(target ?? containerRef.current)?.focus?.();
|
|
1127
1193
|
}, []);
|
|
1128
|
-
(0,
|
|
1194
|
+
(0, import_react9.useEffect)(() => {
|
|
1129
1195
|
if (!ready || !pendingProviderFocusRef.current) return;
|
|
1130
1196
|
pendingProviderFocusRef.current = false;
|
|
1131
1197
|
focusPayPalSurface();
|
|
1132
1198
|
}, [focusPayPalSurface, ready, renderGeneration]);
|
|
1133
|
-
const notifyTechnicalFailure = (0,
|
|
1199
|
+
const notifyTechnicalFailure = (0, import_react9.useCallback)((err, options) => {
|
|
1134
1200
|
const handler = onTechnicalFailureRef.current;
|
|
1135
1201
|
if (handler) {
|
|
1136
1202
|
handler("paypal", err, options);
|
|
@@ -1208,7 +1274,7 @@ function DirectPayPalButtonImplementation({
|
|
|
1208
1274
|
}
|
|
1209
1275
|
return token;
|
|
1210
1276
|
};
|
|
1211
|
-
(0,
|
|
1277
|
+
(0, import_react9.useEffect)(() => {
|
|
1212
1278
|
const handleVisibilityChange = () => {
|
|
1213
1279
|
if (document.visibilityState === "visible") {
|
|
1214
1280
|
scheduleMissingCallbackRecovery();
|
|
@@ -1226,11 +1292,11 @@ function DirectPayPalButtonImplementation({
|
|
|
1226
1292
|
clearAttemptTimer();
|
|
1227
1293
|
};
|
|
1228
1294
|
}, []);
|
|
1229
|
-
(0,
|
|
1295
|
+
(0, import_react9.useEffect)(() => {
|
|
1230
1296
|
invokeMerchantCallback(() => onLoadStateChangeRef.current?.(ready && !failed));
|
|
1231
1297
|
}, [ready, failed]);
|
|
1232
1298
|
const normalizedEnv = (0, import_shared4.normalizeGatewayEnvironment)(environment);
|
|
1233
|
-
(0,
|
|
1299
|
+
(0, import_react9.useEffect)(() => {
|
|
1234
1300
|
const maskedClient = clientId ? `${clientId.slice(0, 6)}\u2026(len ${clientId.length})` : "(empty)";
|
|
1235
1301
|
const ua = typeof navigator !== "undefined" ? navigator.userAgent : "(no navigator)";
|
|
1236
1302
|
appendDebug(`mount clientId=${maskedClient} env=${environment ?? "(unset)"}\u2192${normalizedEnv ?? "live"} ccy=${currency} sub=${isSubscription}`);
|
|
@@ -1513,9 +1579,8 @@ function DirectPayPalButtonImplementation({
|
|
|
1513
1579
|
const prepared = beforeClickRef.current;
|
|
1514
1580
|
const effectiveSessionId = prepared?.sessionId ?? sessionId;
|
|
1515
1581
|
const effectiveEmail = prepared?.accountPatch?.email ?? emailRef.current;
|
|
1516
|
-
const intentHeaders = { "Content-Type": "application/json" };
|
|
1517
1582
|
const currentNonce = prepared?.nonce ?? nonceRef.current;
|
|
1518
|
-
|
|
1583
|
+
const intentHeaders = intentRequestHeaders(currentNonce);
|
|
1519
1584
|
telemetrySource.log({
|
|
1520
1585
|
name: "payment.intent.started",
|
|
1521
1586
|
stage: "processing",
|
|
@@ -1844,7 +1909,7 @@ function DirectPayPalButtonImplementation({
|
|
|
1844
1909
|
}
|
|
1845
1910
|
};
|
|
1846
1911
|
}, [baseUrl, clientId, currency, environment, isSubscription, sessionId, existingOrderId, renderGeneration, telemetrySource]);
|
|
1847
|
-
const debugPanel = debug ? /* @__PURE__ */ (0,
|
|
1912
|
+
const debugPanel = debug ? /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(
|
|
1848
1913
|
"pre",
|
|
1849
1914
|
{
|
|
1850
1915
|
"data-testid": "flopay-direct-paypal-debug",
|
|
@@ -1869,17 +1934,17 @@ ${debugLines.join("\n")}`
|
|
|
1869
1934
|
}
|
|
1870
1935
|
) : null;
|
|
1871
1936
|
if (failed) {
|
|
1872
|
-
return debug ? /* @__PURE__ */ (0,
|
|
1937
|
+
return debug ? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { children: debugPanel }) : null;
|
|
1873
1938
|
}
|
|
1874
1939
|
return (
|
|
1875
1940
|
// Single wrapper so the parent flex container sees exactly one flex item
|
|
1876
1941
|
// (otherwise the fragment's placeholder + container become two siblings
|
|
1877
1942
|
// and any spacing-sensitive layout has to reason about both). The wrapper
|
|
1878
1943
|
// intentionally has no margin/padding so the parent owns all spacing.
|
|
1879
|
-
/* @__PURE__ */ (0,
|
|
1944
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { children: [
|
|
1880
1945
|
debugPanel,
|
|
1881
|
-
/* @__PURE__ */ (0,
|
|
1882
|
-
!ready && /* @__PURE__ */ (0,
|
|
1946
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsxs)("div", { style: { position: "relative", minHeight: DEFAULT_BUTTON_HEIGHT }, children: [
|
|
1947
|
+
!ready && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1883
1948
|
"div",
|
|
1884
1949
|
{
|
|
1885
1950
|
"data-testid": "flopay-direct-paypal-placeholder",
|
|
@@ -1893,7 +1958,7 @@ ${debugLines.join("\n")}`
|
|
|
1893
1958
|
}
|
|
1894
1959
|
}
|
|
1895
1960
|
),
|
|
1896
|
-
/* @__PURE__ */ (0,
|
|
1961
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1897
1962
|
"div",
|
|
1898
1963
|
{
|
|
1899
1964
|
ref: containerRef,
|
|
@@ -1910,7 +1975,7 @@ ${debugLines.join("\n")}`
|
|
|
1910
1975
|
renderGeneration
|
|
1911
1976
|
)
|
|
1912
1977
|
] }),
|
|
1913
|
-
showRetryFocusTarget && /* @__PURE__ */ (0,
|
|
1978
|
+
showRetryFocusTarget && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
1914
1979
|
"button",
|
|
1915
1980
|
{
|
|
1916
1981
|
ref: focusTargetRef,
|
|
@@ -1925,15 +1990,15 @@ ${debugLines.join("\n")}`
|
|
|
1925
1990
|
);
|
|
1926
1991
|
}
|
|
1927
1992
|
function DirectPayPalButton(props) {
|
|
1928
|
-
return /* @__PURE__ */ (0,
|
|
1993
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DirectPayPalButtonImplementation, { ...props });
|
|
1929
1994
|
}
|
|
1930
1995
|
function InstrumentedDirectPayPalButton(props) {
|
|
1931
|
-
return /* @__PURE__ */ (0,
|
|
1996
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(DirectPayPalButtonImplementation, { ...props });
|
|
1932
1997
|
}
|
|
1933
1998
|
|
|
1934
1999
|
// src/split-card-form.tsx
|
|
1935
2000
|
var import_shared6 = require("@flopay/shared");
|
|
1936
|
-
var
|
|
2001
|
+
var import_jsx_runtime8 = require("react/jsx-runtime");
|
|
1937
2002
|
var STRIPE_RESUME_KEY = "flopay_stripe_resume";
|
|
1938
2003
|
var LEGACY_WALLET_RESUME_KEY = "flopay_wallet_resume";
|
|
1939
2004
|
var PAYPAL_RESUME_KEY = "flopay_paypal_resume";
|
|
@@ -2048,17 +2113,17 @@ function buildExternalMethodRecoveryMessage(method, popupBlocked) {
|
|
|
2048
2113
|
return popupBlocked ? `${base} Allow pop-ups for this site, then try again.` : base;
|
|
2049
2114
|
}
|
|
2050
2115
|
function useExternalAttemptReconciliation(onMissingTerminal) {
|
|
2051
|
-
const generationRef = (0,
|
|
2052
|
-
const invalidatedGenerationRef = (0,
|
|
2053
|
-
const attemptRef = (0,
|
|
2054
|
-
const clearAttemptTimer = (0,
|
|
2116
|
+
const generationRef = (0, import_react10.useRef)(0);
|
|
2117
|
+
const invalidatedGenerationRef = (0, import_react10.useRef)(null);
|
|
2118
|
+
const attemptRef = (0, import_react10.useRef)(null);
|
|
2119
|
+
const clearAttemptTimer = (0, import_react10.useCallback)((targetAttempt = attemptRef.current) => {
|
|
2055
2120
|
const attempt = targetAttempt;
|
|
2056
2121
|
if (attempt?.timer) {
|
|
2057
2122
|
clearTimeout(attempt.timer);
|
|
2058
2123
|
attempt.timer = null;
|
|
2059
2124
|
}
|
|
2060
2125
|
}, []);
|
|
2061
|
-
const armAttemptTimer = (0,
|
|
2126
|
+
const armAttemptTimer = (0, import_react10.useCallback)((attempt, delayMs) => {
|
|
2062
2127
|
if (typeof document !== "undefined" && document.visibilityState !== "visible") return;
|
|
2063
2128
|
clearAttemptTimer(attempt);
|
|
2064
2129
|
attempt.timer = setTimeout(() => {
|
|
@@ -2073,11 +2138,11 @@ function useExternalAttemptReconciliation(onMissingTerminal) {
|
|
|
2073
2138
|
);
|
|
2074
2139
|
}, delayMs);
|
|
2075
2140
|
}, [clearAttemptTimer, onMissingTerminal]);
|
|
2076
|
-
const armRecoveryTimer = (0,
|
|
2141
|
+
const armRecoveryTimer = (0, import_react10.useCallback)((attempt) => {
|
|
2077
2142
|
if (!attempt.yieldedControl) return;
|
|
2078
2143
|
armAttemptTimer(attempt, EXTERNAL_METHOD_CALLBACK_GRACE_MS);
|
|
2079
2144
|
}, [armAttemptTimer]);
|
|
2080
|
-
const startAttempt = (0,
|
|
2145
|
+
const startAttempt = (0, import_react10.useCallback)((method) => {
|
|
2081
2146
|
clearAttemptTimer();
|
|
2082
2147
|
const generation = generationRef.current + 1;
|
|
2083
2148
|
generationRef.current = generation;
|
|
@@ -2086,7 +2151,7 @@ function useExternalAttemptReconciliation(onMissingTerminal) {
|
|
|
2086
2151
|
attemptRef.current = attempt;
|
|
2087
2152
|
return generation;
|
|
2088
2153
|
}, [clearAttemptTimer]);
|
|
2089
|
-
const finishAttempt = (0,
|
|
2154
|
+
const finishAttempt = (0, import_react10.useCallback)((generation) => {
|
|
2090
2155
|
const attempt = attemptRef.current;
|
|
2091
2156
|
if (typeof generation === "number" && attempt?.generation !== generation) return false;
|
|
2092
2157
|
clearAttemptTimer(attempt);
|
|
@@ -2096,7 +2161,7 @@ function useExternalAttemptReconciliation(onMissingTerminal) {
|
|
|
2096
2161
|
}
|
|
2097
2162
|
return true;
|
|
2098
2163
|
}, [clearAttemptTimer]);
|
|
2099
|
-
const invalidateAttempt = (0,
|
|
2164
|
+
const invalidateAttempt = (0, import_react10.useCallback)((generation) => {
|
|
2100
2165
|
const attempt = attemptRef.current;
|
|
2101
2166
|
const targetGeneration = generation ?? attempt?.generation ?? generationRef.current;
|
|
2102
2167
|
if (!generation || attempt?.generation === generation) {
|
|
@@ -2105,26 +2170,26 @@ function useExternalAttemptReconciliation(onMissingTerminal) {
|
|
|
2105
2170
|
}
|
|
2106
2171
|
invalidatedGenerationRef.current = targetGeneration;
|
|
2107
2172
|
}, [clearAttemptTimer]);
|
|
2108
|
-
const isAttemptInvalidated = (0,
|
|
2173
|
+
const isAttemptInvalidated = (0, import_react10.useCallback)(
|
|
2109
2174
|
(generation) => invalidatedGenerationRef.current === (generation ?? generationRef.current),
|
|
2110
2175
|
[]
|
|
2111
2176
|
);
|
|
2112
|
-
const isAttemptCurrent = (0,
|
|
2177
|
+
const isAttemptCurrent = (0, import_react10.useCallback)(
|
|
2113
2178
|
(generation) => attemptRef.current?.generation === generation && invalidatedGenerationRef.current !== generation,
|
|
2114
2179
|
[]
|
|
2115
2180
|
);
|
|
2116
|
-
const scheduleRecoveryIfReturned = (0,
|
|
2181
|
+
const scheduleRecoveryIfReturned = (0, import_react10.useCallback)(() => {
|
|
2117
2182
|
const attempt = attemptRef.current;
|
|
2118
2183
|
if (!attempt) return;
|
|
2119
2184
|
armRecoveryTimer(attempt);
|
|
2120
2185
|
}, [armRecoveryTimer]);
|
|
2121
|
-
const markAttemptYieldedControl = (0,
|
|
2186
|
+
const markAttemptYieldedControl = (0, import_react10.useCallback)(() => {
|
|
2122
2187
|
const attempt = attemptRef.current;
|
|
2123
2188
|
if (!attempt) return;
|
|
2124
2189
|
attempt.yieldedControl = true;
|
|
2125
2190
|
clearAttemptTimer(attempt);
|
|
2126
2191
|
}, [clearAttemptTimer]);
|
|
2127
|
-
(0,
|
|
2192
|
+
(0, import_react10.useEffect)(() => {
|
|
2128
2193
|
const handleVisibilityChange = () => {
|
|
2129
2194
|
if (document.visibilityState === "visible") {
|
|
2130
2195
|
scheduleRecoveryIfReturned();
|
|
@@ -2166,7 +2231,7 @@ function normalizeBeforeButtonClickError(method, err) {
|
|
|
2166
2231
|
);
|
|
2167
2232
|
}
|
|
2168
2233
|
function FloPayKeyframes() {
|
|
2169
|
-
return /* @__PURE__ */ (0,
|
|
2234
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("style", { children: FLOPAY_KEYFRAMES });
|
|
2170
2235
|
}
|
|
2171
2236
|
function toCssSize(value) {
|
|
2172
2237
|
if (typeof value === "number") return `${value}px`;
|
|
@@ -2188,8 +2253,8 @@ function ExpressCheckoutReadySwap({
|
|
|
2188
2253
|
children
|
|
2189
2254
|
}) {
|
|
2190
2255
|
if (state === "unavailable" || state === "load_error") return null;
|
|
2191
|
-
return /* @__PURE__ */ (0,
|
|
2192
|
-
/* @__PURE__ */ (0,
|
|
2256
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { position: "relative", minHeight: 44 }, children: [
|
|
2257
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2193
2258
|
"div",
|
|
2194
2259
|
{
|
|
2195
2260
|
"data-testid": placeholderTestId,
|
|
@@ -2208,7 +2273,7 @@ function ExpressCheckoutReadySwap({
|
|
|
2208
2273
|
}
|
|
2209
2274
|
}
|
|
2210
2275
|
),
|
|
2211
|
-
/* @__PURE__ */ (0,
|
|
2276
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2212
2277
|
"div",
|
|
2213
2278
|
{
|
|
2214
2279
|
style: {
|
|
@@ -2226,9 +2291,9 @@ function ExpressCheckoutReadySwap({
|
|
|
2226
2291
|
function isExpressCheckoutRowVisible(state) {
|
|
2227
2292
|
return state !== "unavailable" && state !== "load_error";
|
|
2228
2293
|
}
|
|
2229
|
-
var SplitCardForm = (0,
|
|
2294
|
+
var SplitCardForm = (0, import_react10.forwardRef)(
|
|
2230
2295
|
function SplitCardForm2(props, ref) {
|
|
2231
|
-
return /* @__PURE__ */ (0,
|
|
2296
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(SplitCardFormInner, { ...props, innerRef: ref });
|
|
2232
2297
|
}
|
|
2233
2298
|
);
|
|
2234
2299
|
function PayPalButtonInner({
|
|
@@ -2249,18 +2314,18 @@ function PayPalButtonInner({
|
|
|
2249
2314
|
const flopay = useFloPay();
|
|
2250
2315
|
const stripe = (0, import_react_stripe_js.useStripe)();
|
|
2251
2316
|
const elements = (0, import_react_stripe_js.useElements)();
|
|
2252
|
-
const [loadState, setLoadState] = (0,
|
|
2253
|
-
(0,
|
|
2317
|
+
const [loadState, setLoadState] = (0, import_react10.useState)("loading");
|
|
2318
|
+
(0, import_react10.useEffect)(() => {
|
|
2254
2319
|
onLoadStateChange?.(loadState);
|
|
2255
2320
|
}, [loadState, onLoadStateChange]);
|
|
2256
|
-
const [submitting, setSubmitting] = (0,
|
|
2257
|
-
const paypalResumeAttempted = (0,
|
|
2258
|
-
const focusTargetRef = (0,
|
|
2259
|
-
const recoveryActionRef = (0,
|
|
2260
|
-
const [surfaceKey, setSurfaceKey] = (0,
|
|
2261
|
-
const [showRecoveryAction, setShowRecoveryAction] = (0,
|
|
2262
|
-
const pendingProviderFocusRef = (0,
|
|
2263
|
-
const attemptContextBySurfaceRef = (0,
|
|
2321
|
+
const [submitting, setSubmitting] = (0, import_react10.useState)(false);
|
|
2322
|
+
const paypalResumeAttempted = (0, import_react10.useRef)(false);
|
|
2323
|
+
const focusTargetRef = (0, import_react10.useRef)(null);
|
|
2324
|
+
const recoveryActionRef = (0, import_react10.useRef)(null);
|
|
2325
|
+
const [surfaceKey, setSurfaceKey] = (0, import_react10.useState)(0);
|
|
2326
|
+
const [showRecoveryAction, setShowRecoveryAction] = (0, import_react10.useState)(false);
|
|
2327
|
+
const pendingProviderFocusRef = (0, import_react10.useRef)(false);
|
|
2328
|
+
const attemptContextBySurfaceRef = (0, import_react10.useRef)(/* @__PURE__ */ new Map());
|
|
2264
2329
|
const baseUrl = billingApiUrl.replace(/\/+$/, "");
|
|
2265
2330
|
const {
|
|
2266
2331
|
startAttempt,
|
|
@@ -2276,35 +2341,35 @@ function PayPalButtonInner({
|
|
|
2276
2341
|
setShowRecoveryAction(true);
|
|
2277
2342
|
setSurfaceKey((key) => key + 1);
|
|
2278
2343
|
});
|
|
2279
|
-
(0,
|
|
2344
|
+
(0, import_react10.useEffect)(() => {
|
|
2280
2345
|
if (showRecoveryAction) recoveryActionRef.current?.focus();
|
|
2281
2346
|
}, [showRecoveryAction, surfaceKey]);
|
|
2282
|
-
const resetSurface = (0,
|
|
2347
|
+
const resetSurface = (0, import_react10.useCallback)(() => {
|
|
2283
2348
|
setSurfaceKey((key) => key + 1);
|
|
2284
2349
|
}, []);
|
|
2285
|
-
const recoverTechnicalFailure = (0,
|
|
2350
|
+
const recoverTechnicalFailure = (0, import_react10.useCallback)((err, code, generation) => {
|
|
2286
2351
|
invalidateAttempt(generation);
|
|
2287
2352
|
onTechnicalFailure?.("paypal", err, { code, popupBlocked: isPopupBlockedError(err) });
|
|
2288
2353
|
setShowRecoveryAction(true);
|
|
2289
2354
|
resetSurface();
|
|
2290
2355
|
}, [invalidateAttempt, onTechnicalFailure, resetSurface]);
|
|
2291
|
-
const focusProviderSurface = (0,
|
|
2356
|
+
const focusProviderSurface = (0, import_react10.useCallback)(() => {
|
|
2292
2357
|
window.setTimeout(() => {
|
|
2293
2358
|
const target = focusTargetRef.current?.querySelector("iframe");
|
|
2294
2359
|
(target ?? focusTargetRef.current)?.focus();
|
|
2295
2360
|
}, 0);
|
|
2296
2361
|
}, []);
|
|
2297
|
-
(0,
|
|
2362
|
+
(0, import_react10.useEffect)(() => {
|
|
2298
2363
|
if (!pendingProviderFocusRef.current) return;
|
|
2299
2364
|
pendingProviderFocusRef.current = false;
|
|
2300
2365
|
focusProviderSurface();
|
|
2301
2366
|
}, [focusProviderSurface, surfaceKey]);
|
|
2302
|
-
const handleRecoveryActionClick = (0,
|
|
2367
|
+
const handleRecoveryActionClick = (0, import_react10.useCallback)(() => {
|
|
2303
2368
|
setShowRecoveryAction(false);
|
|
2304
2369
|
onErrorChange?.(null);
|
|
2305
2370
|
focusProviderSurface();
|
|
2306
2371
|
}, [focusProviderSurface, onErrorChange]);
|
|
2307
|
-
(0,
|
|
2372
|
+
(0, import_react10.useEffect)(() => {
|
|
2308
2373
|
if (!stripe || paypalResumeAttempted.current) return;
|
|
2309
2374
|
const params = new URLSearchParams(window.location.search);
|
|
2310
2375
|
const paymentIntentId = params.get("payment_intent");
|
|
@@ -2370,7 +2435,7 @@ function PayPalButtonInner({
|
|
|
2370
2435
|
}
|
|
2371
2436
|
})();
|
|
2372
2437
|
}, [stripe, onTokenizedBody, onErrorChange, onDecline]);
|
|
2373
|
-
const handlePayPalClick = (0,
|
|
2438
|
+
const handlePayPalClick = (0, import_react10.useCallback)(async (event) => {
|
|
2374
2439
|
if (isProcessing || submitting) {
|
|
2375
2440
|
event.reject();
|
|
2376
2441
|
return;
|
|
@@ -2392,7 +2457,7 @@ function PayPalButtonInner({
|
|
|
2392
2457
|
onButtonClick?.("paypal");
|
|
2393
2458
|
event.resolve();
|
|
2394
2459
|
}, [attemptContextBySurfaceRef, isProcessing, onButtonClick, runBeforeButtonClick, startAttempt, submitting, surfaceKey]);
|
|
2395
|
-
const handlePayPalConfirm = (0,
|
|
2460
|
+
const handlePayPalConfirm = (0, import_react10.useCallback)(async (event) => {
|
|
2396
2461
|
if (!stripe || !elements) return;
|
|
2397
2462
|
const attemptContext = attemptContextBySurfaceRef.current.get(surfaceKey);
|
|
2398
2463
|
if (attemptContext && !isAttemptCurrent(attemptContext.generation)) {
|
|
@@ -2432,8 +2497,7 @@ function PayPalButtonInner({
|
|
|
2432
2497
|
event.paymentFailed({ reason: "fail" });
|
|
2433
2498
|
return;
|
|
2434
2499
|
}
|
|
2435
|
-
const intentHeaders =
|
|
2436
|
-
if (effectiveNonce) intentHeaders["x-checkout-session-token"] = effectiveNonce;
|
|
2500
|
+
const intentHeaders = intentRequestHeaders(effectiveNonce);
|
|
2437
2501
|
const intentResponse = await fetch(`${baseUrl}/v1/checkouts/payments/intents`, {
|
|
2438
2502
|
method: "POST",
|
|
2439
2503
|
headers: intentHeaders,
|
|
@@ -2524,14 +2588,14 @@ function PayPalButtonInner({
|
|
|
2524
2588
|
setSubmitting(false);
|
|
2525
2589
|
}
|
|
2526
2590
|
}, [stripe, elements, sessionId, nonce, email, baseUrl, onTokenizedBody, onErrorChange, onDecline, runBeforeButtonClick, recoverTechnicalFailure, finishAttempt, isAttemptCurrent, isAttemptInvalidated, surfaceKey]);
|
|
2527
|
-
return /* @__PURE__ */ (0,
|
|
2528
|
-
/* @__PURE__ */ (0,
|
|
2591
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
2592
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2529
2593
|
ExpressCheckoutReadySwap,
|
|
2530
2594
|
{
|
|
2531
2595
|
state: loadState,
|
|
2532
2596
|
placeholderTestId: "flopay-paypal-placeholder",
|
|
2533
2597
|
borderRadius: placeholderBorderRadius,
|
|
2534
|
-
children: /* @__PURE__ */ (0,
|
|
2598
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2535
2599
|
"div",
|
|
2536
2600
|
{
|
|
2537
2601
|
ref: focusTargetRef,
|
|
@@ -2540,7 +2604,7 @@ function PayPalButtonInner({
|
|
|
2540
2604
|
"aria-label": "PayPal payment method",
|
|
2541
2605
|
style: { borderRadius: 8, outlineOffset: 4 },
|
|
2542
2606
|
children: [
|
|
2543
|
-
showRecoveryAction && /* @__PURE__ */ (0,
|
|
2607
|
+
showRecoveryAction && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2544
2608
|
"button",
|
|
2545
2609
|
{
|
|
2546
2610
|
ref: recoveryActionRef,
|
|
@@ -2551,7 +2615,7 @@ function PayPalButtonInner({
|
|
|
2551
2615
|
children: "Try PayPal again"
|
|
2552
2616
|
}
|
|
2553
2617
|
),
|
|
2554
|
-
/* @__PURE__ */ (0,
|
|
2618
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2555
2619
|
import_react_stripe_js.ExpressCheckoutElement,
|
|
2556
2620
|
{
|
|
2557
2621
|
onReady: (event) => setLoadState(resolveExpressCheckoutLoadState(event, ["paypal"])),
|
|
@@ -2591,7 +2655,7 @@ function PayPalButtonInner({
|
|
|
2591
2655
|
)
|
|
2592
2656
|
}
|
|
2593
2657
|
),
|
|
2594
|
-
submitting && /* @__PURE__ */ (0,
|
|
2658
|
+
submitting && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ProcessingOverlay, { status: "processing" })
|
|
2595
2659
|
] });
|
|
2596
2660
|
}
|
|
2597
2661
|
function WalletButtonInner({
|
|
@@ -2612,21 +2676,21 @@ function WalletButtonInner({
|
|
|
2612
2676
|
const flopay = useFloPay();
|
|
2613
2677
|
const stripe = (0, import_react_stripe_js.useStripe)();
|
|
2614
2678
|
const elements = (0, import_react_stripe_js.useElements)();
|
|
2615
|
-
const [loadState, setLoadState] = (0,
|
|
2616
|
-
(0,
|
|
2679
|
+
const [loadState, setLoadState] = (0, import_react10.useState)("loading");
|
|
2680
|
+
(0, import_react10.useEffect)(() => {
|
|
2617
2681
|
onLoadStateChange?.(loadState);
|
|
2618
2682
|
}, [loadState, onLoadStateChange]);
|
|
2619
|
-
const [submitting, setSubmitting] = (0,
|
|
2683
|
+
const [submitting, setSubmitting] = (0, import_react10.useState)(false);
|
|
2620
2684
|
const baseUrl = billingApiUrl.replace(/\/+$/, "");
|
|
2621
|
-
const focusTargetRef = (0,
|
|
2622
|
-
const recoveryActionRef = (0,
|
|
2623
|
-
const [surfaceKey, setSurfaceKey] = (0,
|
|
2624
|
-
const [showRecoveryAction, setShowRecoveryAction] = (0,
|
|
2625
|
-
const [recoveryActionMethod, setRecoveryActionMethod] = (0,
|
|
2626
|
-
const pendingProviderFocusRef = (0,
|
|
2627
|
-
const lastWalletProviderMethodRef = (0,
|
|
2628
|
-
const lastWalletMethodRef = (0,
|
|
2629
|
-
const attemptContextBySurfaceRef = (0,
|
|
2685
|
+
const focusTargetRef = (0, import_react10.useRef)(null);
|
|
2686
|
+
const recoveryActionRef = (0, import_react10.useRef)(null);
|
|
2687
|
+
const [surfaceKey, setSurfaceKey] = (0, import_react10.useState)(0);
|
|
2688
|
+
const [showRecoveryAction, setShowRecoveryAction] = (0, import_react10.useState)(false);
|
|
2689
|
+
const [recoveryActionMethod, setRecoveryActionMethod] = (0, import_react10.useState)("google_pay");
|
|
2690
|
+
const pendingProviderFocusRef = (0, import_react10.useRef)(false);
|
|
2691
|
+
const lastWalletProviderMethodRef = (0, import_react10.useRef)("google_pay");
|
|
2692
|
+
const lastWalletMethodRef = (0, import_react10.useRef)("google_pay");
|
|
2693
|
+
const attemptContextBySurfaceRef = (0, import_react10.useRef)(/* @__PURE__ */ new Map());
|
|
2630
2694
|
const {
|
|
2631
2695
|
startAttempt,
|
|
2632
2696
|
finishAttempt,
|
|
@@ -2642,36 +2706,36 @@ function WalletButtonInner({
|
|
|
2642
2706
|
setShowRecoveryAction(true);
|
|
2643
2707
|
setSurfaceKey((key) => key + 1);
|
|
2644
2708
|
});
|
|
2645
|
-
(0,
|
|
2709
|
+
(0, import_react10.useEffect)(() => {
|
|
2646
2710
|
if (showRecoveryAction) recoveryActionRef.current?.focus();
|
|
2647
2711
|
}, [showRecoveryAction, surfaceKey]);
|
|
2648
|
-
const resetSurface = (0,
|
|
2712
|
+
const resetSurface = (0, import_react10.useCallback)(() => {
|
|
2649
2713
|
setSurfaceKey((key) => key + 1);
|
|
2650
2714
|
}, []);
|
|
2651
|
-
const recoverTechnicalFailure = (0,
|
|
2715
|
+
const recoverTechnicalFailure = (0, import_react10.useCallback)((method, err, code, generation) => {
|
|
2652
2716
|
invalidateAttempt(generation);
|
|
2653
2717
|
onTechnicalFailure?.(method, err, { code, popupBlocked: isPopupBlockedError(err) });
|
|
2654
2718
|
setRecoveryActionMethod(method);
|
|
2655
2719
|
setShowRecoveryAction(true);
|
|
2656
2720
|
resetSurface();
|
|
2657
2721
|
}, [invalidateAttempt, onTechnicalFailure, resetSurface]);
|
|
2658
|
-
const focusProviderSurface = (0,
|
|
2722
|
+
const focusProviderSurface = (0, import_react10.useCallback)(() => {
|
|
2659
2723
|
window.setTimeout(() => {
|
|
2660
2724
|
const target = focusTargetRef.current?.querySelector("iframe");
|
|
2661
2725
|
(target ?? focusTargetRef.current)?.focus();
|
|
2662
2726
|
}, 0);
|
|
2663
2727
|
}, []);
|
|
2664
|
-
(0,
|
|
2728
|
+
(0, import_react10.useEffect)(() => {
|
|
2665
2729
|
if (!pendingProviderFocusRef.current) return;
|
|
2666
2730
|
pendingProviderFocusRef.current = false;
|
|
2667
2731
|
focusProviderSurface();
|
|
2668
2732
|
}, [focusProviderSurface, surfaceKey]);
|
|
2669
|
-
const handleRecoveryActionClick = (0,
|
|
2733
|
+
const handleRecoveryActionClick = (0, import_react10.useCallback)(() => {
|
|
2670
2734
|
setShowRecoveryAction(false);
|
|
2671
2735
|
onErrorChange?.(null);
|
|
2672
2736
|
focusProviderSurface();
|
|
2673
2737
|
}, [focusProviderSurface, onErrorChange]);
|
|
2674
|
-
const handleWalletConfirm = (0,
|
|
2738
|
+
const handleWalletConfirm = (0, import_react10.useCallback)(
|
|
2675
2739
|
async (event) => {
|
|
2676
2740
|
if (!stripe || !elements) return;
|
|
2677
2741
|
const attemptContext = attemptContextBySurfaceRef.current.get(surfaceKey);
|
|
@@ -2718,8 +2782,7 @@ function WalletButtonInner({
|
|
|
2718
2782
|
if (!effectiveSessionId || !effectiveEmail) {
|
|
2719
2783
|
throw new Error("Missing sessionId or email for wallet payment");
|
|
2720
2784
|
}
|
|
2721
|
-
const intentHeaders =
|
|
2722
|
-
if (effectiveNonce) intentHeaders["x-checkout-session-token"] = effectiveNonce;
|
|
2785
|
+
const intentHeaders = intentRequestHeaders(effectiveNonce);
|
|
2723
2786
|
const intentResponse = await fetch(`${baseUrl}/v1/checkouts/payments/intents`, {
|
|
2724
2787
|
method: "POST",
|
|
2725
2788
|
headers: intentHeaders,
|
|
@@ -2774,7 +2837,7 @@ function WalletButtonInner({
|
|
|
2774
2837
|
},
|
|
2775
2838
|
[stripe, elements, sessionId, nonce, email, baseUrl, onTokenizedBody, onErrorChange, onDecline, runBeforeButtonClick, recoverTechnicalFailure, finishAttempt, isAttemptCurrent, isAttemptInvalidated, surfaceKey]
|
|
2776
2839
|
);
|
|
2777
|
-
const expressMethodMap = (0,
|
|
2840
|
+
const expressMethodMap = (0, import_react10.useMemo)(() => {
|
|
2778
2841
|
const allKeys = ["applePay", "googlePay", "paypal", "link", "amazonPay", "klarna"];
|
|
2779
2842
|
const alwaysCapable = /* @__PURE__ */ new Set(["applePay", "googlePay"]);
|
|
2780
2843
|
const enabledKeys = new Set(expressMethods.map(import_shared5.stripeExpressMethodToOptionKey));
|
|
@@ -2788,18 +2851,18 @@ function WalletButtonInner({
|
|
|
2788
2851
|
}
|
|
2789
2852
|
return out;
|
|
2790
2853
|
}, [expressMethods]);
|
|
2791
|
-
const availableMethodKeys = (0,
|
|
2854
|
+
const availableMethodKeys = (0, import_react10.useMemo)(
|
|
2792
2855
|
() => expressMethods.map(import_shared5.stripeExpressMethodToOptionKey),
|
|
2793
2856
|
[expressMethods]
|
|
2794
2857
|
);
|
|
2795
|
-
return /* @__PURE__ */ (0,
|
|
2796
|
-
/* @__PURE__ */ (0,
|
|
2858
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
2859
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2797
2860
|
ExpressCheckoutReadySwap,
|
|
2798
2861
|
{
|
|
2799
2862
|
state: loadState,
|
|
2800
2863
|
placeholderTestId: "flopay-wallet-placeholder",
|
|
2801
2864
|
borderRadius: placeholderBorderRadius,
|
|
2802
|
-
children: /* @__PURE__ */ (0,
|
|
2865
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2803
2866
|
"div",
|
|
2804
2867
|
{
|
|
2805
2868
|
ref: focusTargetRef,
|
|
@@ -2808,7 +2871,7 @@ function WalletButtonInner({
|
|
|
2808
2871
|
"aria-label": "Wallet payment methods",
|
|
2809
2872
|
style: { borderRadius: 8, outlineOffset: 4 },
|
|
2810
2873
|
children: [
|
|
2811
|
-
showRecoveryAction && /* @__PURE__ */ (0,
|
|
2874
|
+
showRecoveryAction && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2812
2875
|
"button",
|
|
2813
2876
|
{
|
|
2814
2877
|
ref: recoveryActionRef,
|
|
@@ -2823,7 +2886,7 @@ function WalletButtonInner({
|
|
|
2823
2886
|
]
|
|
2824
2887
|
}
|
|
2825
2888
|
),
|
|
2826
|
-
/* @__PURE__ */ (0,
|
|
2889
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2827
2890
|
import_react_stripe_js.ExpressCheckoutElement,
|
|
2828
2891
|
{
|
|
2829
2892
|
onReady: (event) => {
|
|
@@ -2887,7 +2950,7 @@ function WalletButtonInner({
|
|
|
2887
2950
|
)
|
|
2888
2951
|
}
|
|
2889
2952
|
),
|
|
2890
|
-
submitting && /* @__PURE__ */ (0,
|
|
2953
|
+
submitting && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ProcessingOverlay, { status: "processing" })
|
|
2891
2954
|
] });
|
|
2892
2955
|
}
|
|
2893
2956
|
function StripeMethodButton({
|
|
@@ -2905,10 +2968,11 @@ function StripeMethodButton({
|
|
|
2905
2968
|
fontFamily
|
|
2906
2969
|
}) {
|
|
2907
2970
|
const brand = (0, import_shared5.resolveStripeMethodBrandVariant)(method, themeId);
|
|
2971
|
+
const vendoredLogoUrl = PAYMENT_METHOD_LOGO_URLS[method];
|
|
2908
2972
|
const resolvedBackground = brand?.backgroundColor ?? backgroundColor ?? "#ffffff";
|
|
2909
2973
|
const resolvedBorder = brand?.borderColor ?? borderColor ?? "#d1d5db";
|
|
2910
2974
|
const resolvedTextColor = brand?.textColor ?? textColor ?? "#262833";
|
|
2911
|
-
return /* @__PURE__ */ (0,
|
|
2975
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2912
2976
|
"button",
|
|
2913
2977
|
{
|
|
2914
2978
|
type: "button",
|
|
@@ -2955,9 +3019,9 @@ function StripeMethodButton({
|
|
|
2955
3019
|
// Pulse-skeleton parity with the wallet ECE: no spinner, just the
|
|
2956
3020
|
// status text on top of the pulsing background. Keeps the loading
|
|
2957
3021
|
// affordance shape-equivalent across both kinds of tile.
|
|
2958
|
-
/* @__PURE__ */ (0,
|
|
2959
|
-
) : /* @__PURE__ */ (0,
|
|
2960
|
-
/* @__PURE__ */ (0,
|
|
3022
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: { margin: "0 auto" }, children: `Connecting to ${(0, import_shared5.getStripeMethodDisplayName)(method)}\u2026` })
|
|
3023
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
3024
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
2961
3025
|
"span",
|
|
2962
3026
|
{
|
|
2963
3027
|
style: {
|
|
@@ -2970,15 +3034,36 @@ function StripeMethodButton({
|
|
|
2970
3034
|
gap: (0, import_shared5.hasVendoredStripeMethodLogo)(method) ? 8 : 0
|
|
2971
3035
|
},
|
|
2972
3036
|
children: [
|
|
2973
|
-
|
|
3037
|
+
vendoredLogoUrl ? (
|
|
3038
|
+
// Vendored brand logo — an <img> asset (not inline SVG) so its
|
|
3039
|
+
// bytes ship as a sibling file, out of the JS bundle. 3:2 box
|
|
3040
|
+
// matching the datatrans logos' 120×80 viewBox; each ships its own
|
|
3041
|
+
// white rounded-rect background so it stays legible on any tile.
|
|
3042
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3043
|
+
"img",
|
|
3044
|
+
{
|
|
3045
|
+
src: vendoredLogoUrl,
|
|
3046
|
+
alt: "",
|
|
3047
|
+
"aria-hidden": "true",
|
|
3048
|
+
loading: "lazy",
|
|
3049
|
+
decoding: "async",
|
|
3050
|
+
width: 30,
|
|
3051
|
+
height: 20,
|
|
3052
|
+
style: {
|
|
3053
|
+
width: 30,
|
|
3054
|
+
height: 20,
|
|
3055
|
+
flexShrink: 0,
|
|
3056
|
+
borderRadius: 3,
|
|
3057
|
+
objectFit: "contain",
|
|
3058
|
+
display: "inline-flex"
|
|
3059
|
+
}
|
|
3060
|
+
}
|
|
3061
|
+
)
|
|
3062
|
+
) : brand?.logoSvg ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2974
3063
|
"span",
|
|
2975
3064
|
{
|
|
2976
3065
|
"aria-hidden": "true",
|
|
2977
3066
|
style: {
|
|
2978
|
-
// 3:2 box matching the vendored datatrans logos' 120×80
|
|
2979
|
-
// viewBox. Each logo ships with its own white rounded-rect
|
|
2980
|
-
// background baked in, so the mark stays legible on any
|
|
2981
|
-
// brand-coloured tile without an extra chip wrapper here.
|
|
2982
3067
|
width: 30,
|
|
2983
3068
|
height: 20,
|
|
2984
3069
|
flexShrink: 0,
|
|
@@ -2988,12 +3073,12 @@ function StripeMethodButton({
|
|
|
2988
3073
|
},
|
|
2989
3074
|
dangerouslySetInnerHTML: { __html: brand.logoSvg }
|
|
2990
3075
|
}
|
|
2991
|
-
),
|
|
2992
|
-
/* @__PURE__ */ (0,
|
|
3076
|
+
) : null,
|
|
3077
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: (0, import_shared5.getStripeMethodDisplayName)(method) })
|
|
2993
3078
|
]
|
|
2994
3079
|
}
|
|
2995
3080
|
),
|
|
2996
|
-
hasNextStep && /* @__PURE__ */ (0,
|
|
3081
|
+
hasNextStep && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
2997
3082
|
"svg",
|
|
2998
3083
|
{
|
|
2999
3084
|
width: "14",
|
|
@@ -3013,7 +3098,7 @@ function StripeMethodButton({
|
|
|
3013
3098
|
opacity: 0.7
|
|
3014
3099
|
},
|
|
3015
3100
|
"aria-hidden": "true",
|
|
3016
|
-
children: /* @__PURE__ */ (0,
|
|
3101
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("path", { d: "M9 18l6-6-6-6" })
|
|
3017
3102
|
}
|
|
3018
3103
|
)
|
|
3019
3104
|
] })
|
|
@@ -3042,12 +3127,12 @@ function StripeMethodInlineForm({
|
|
|
3042
3127
|
const flopay = useFloPay();
|
|
3043
3128
|
const stripe = (0, import_react_stripe_js.useStripe)();
|
|
3044
3129
|
const elements = (0, import_react_stripe_js.useElements)();
|
|
3045
|
-
const [submitting, setSubmitting] = (0,
|
|
3046
|
-
const submittingRef = (0,
|
|
3047
|
-
const [isMethodComplete, setIsMethodComplete] = (0,
|
|
3048
|
-
const [loadState, setLoadState] = (0,
|
|
3130
|
+
const [submitting, setSubmitting] = (0, import_react10.useState)(false);
|
|
3131
|
+
const submittingRef = (0, import_react10.useRef)(false);
|
|
3132
|
+
const [isMethodComplete, setIsMethodComplete] = (0, import_react10.useState)(false);
|
|
3133
|
+
const [loadState, setLoadState] = (0, import_react10.useState)("loading");
|
|
3049
3134
|
const baseUrl = billingApiUrl.replace(/\/+$/, "");
|
|
3050
|
-
const handlePay = (0,
|
|
3135
|
+
const handlePay = (0, import_react10.useCallback)(async () => {
|
|
3051
3136
|
if (!stripe || !elements || isProcessing || submittingRef.current || !isMethodComplete) return;
|
|
3052
3137
|
submittingRef.current = true;
|
|
3053
3138
|
setSubmitting(true);
|
|
@@ -3077,8 +3162,7 @@ function StripeMethodInlineForm({
|
|
|
3077
3162
|
if (!effectiveSessionId || !effectiveEmail) {
|
|
3078
3163
|
throw new Error("Missing sessionId or email for payment.");
|
|
3079
3164
|
}
|
|
3080
|
-
const intentHeaders =
|
|
3081
|
-
if (effectiveNonce) intentHeaders["x-checkout-session-token"] = effectiveNonce;
|
|
3165
|
+
const intentHeaders = intentRequestHeaders(effectiveNonce);
|
|
3082
3166
|
const intentResponse = await fetch(`${baseUrl}/v1/checkouts/payments/intents`, {
|
|
3083
3167
|
method: "POST",
|
|
3084
3168
|
headers: intentHeaders,
|
|
@@ -3132,9 +3216,8 @@ function StripeMethodInlineForm({
|
|
|
3132
3216
|
onDecline?.(buildDeclineEvent("card", message, { code: confirmError.code }));
|
|
3133
3217
|
return;
|
|
3134
3218
|
}
|
|
3135
|
-
const SUCCESSFUL_PI_STATUSES = /* @__PURE__ */ new Set(["succeeded", "requires_capture", "processing"]);
|
|
3136
3219
|
const piStatus = paymentIntent?.status;
|
|
3137
|
-
if (!
|
|
3220
|
+
if (!isSuccessfulPaymentIntentStatus(piStatus)) {
|
|
3138
3221
|
if (typeof window !== "undefined") {
|
|
3139
3222
|
try {
|
|
3140
3223
|
localStorage.removeItem(STRIPE_RESUME_KEY);
|
|
@@ -3187,8 +3270,8 @@ function StripeMethodInlineForm({
|
|
|
3187
3270
|
onDecline
|
|
3188
3271
|
]);
|
|
3189
3272
|
void onCancel;
|
|
3190
|
-
return /* @__PURE__ */ (0,
|
|
3191
|
-
/* @__PURE__ */ (0,
|
|
3273
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { "data-testid": `flopay-stripe-method-form-${method}`, style: { display: "flex", flexDirection: "column" }, children: [
|
|
3274
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3192
3275
|
import_react_stripe_js.PaymentElement,
|
|
3193
3276
|
{
|
|
3194
3277
|
onReady: () => setLoadState("ready"),
|
|
@@ -3217,7 +3300,7 @@ function StripeMethodInlineForm({
|
|
|
3217
3300
|
}
|
|
3218
3301
|
}
|
|
3219
3302
|
),
|
|
3220
|
-
/* @__PURE__ */ (0,
|
|
3303
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3221
3304
|
"button",
|
|
3222
3305
|
{
|
|
3223
3306
|
type: "button",
|
|
@@ -3244,22 +3327,7 @@ function StripeMethodInlineForm({
|
|
|
3244
3327
|
children: submitting ? "Processing\u2026" : `Pay with ${(0, import_shared5.getStripeMethodDisplayName)(method)}`
|
|
3245
3328
|
}
|
|
3246
3329
|
),
|
|
3247
|
-
errorText && /* @__PURE__ */ (0,
|
|
3248
|
-
margin: "0.75rem 0 0",
|
|
3249
|
-
padding: "0.625rem 0.875rem",
|
|
3250
|
-
background: "#FEF2F2",
|
|
3251
|
-
border: "1px solid #FECACA",
|
|
3252
|
-
borderRadius: "8px",
|
|
3253
|
-
color: "#991B1B",
|
|
3254
|
-
fontSize: "0.85rem",
|
|
3255
|
-
fontWeight: 600,
|
|
3256
|
-
display: "flex",
|
|
3257
|
-
alignItems: "center",
|
|
3258
|
-
gap: "0.5rem"
|
|
3259
|
-
}, children: [
|
|
3260
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z", stroke: "#DC2626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }),
|
|
3261
|
-
errorText
|
|
3262
|
-
] })
|
|
3330
|
+
errorText && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ErrorBanner, { margin: "0.75rem 0 0", children: errorText })
|
|
3263
3331
|
] });
|
|
3264
3332
|
}
|
|
3265
3333
|
function StripePaymentElementInner({
|
|
@@ -3287,17 +3355,17 @@ function StripePaymentElementInner({
|
|
|
3287
3355
|
expandedApmMethod
|
|
3288
3356
|
}) {
|
|
3289
3357
|
const baseUrl = billingApiUrl.replace(/\/+$/, "");
|
|
3290
|
-
const [expandedMethod, setExpandedMethod] = (0,
|
|
3291
|
-
const [submittingMethod, setSubmittingMethod] = (0,
|
|
3292
|
-
const submittingRef = (0,
|
|
3293
|
-
(0,
|
|
3358
|
+
const [expandedMethod, setExpandedMethod] = (0, import_react10.useState)(null);
|
|
3359
|
+
const [submittingMethod, setSubmittingMethod] = (0, import_react10.useState)(null);
|
|
3360
|
+
const submittingRef = (0, import_react10.useRef)(false);
|
|
3361
|
+
(0, import_react10.useEffect)(() => {
|
|
3294
3362
|
if (paymentElementMethods.length > 0 && stripeInstance) {
|
|
3295
3363
|
onLoadStateChange?.("ready");
|
|
3296
3364
|
} else if (!stripeInstance) {
|
|
3297
3365
|
onLoadStateChange?.("loading");
|
|
3298
3366
|
}
|
|
3299
3367
|
}, [paymentElementMethods.length, stripeInstance, onLoadStateChange]);
|
|
3300
|
-
const handleAutoConfirm = (0,
|
|
3368
|
+
const handleAutoConfirm = (0, import_react10.useCallback)(async (method) => {
|
|
3301
3369
|
if (!stripeInstance) return;
|
|
3302
3370
|
if (submittingRef.current || isProcessing) return;
|
|
3303
3371
|
submittingRef.current = true;
|
|
@@ -3317,8 +3385,7 @@ function StripePaymentElementInner({
|
|
|
3317
3385
|
if (!effectiveSessionId || !effectiveEmail) {
|
|
3318
3386
|
throw new Error("Missing sessionId or email for payment.");
|
|
3319
3387
|
}
|
|
3320
|
-
const intentHeaders =
|
|
3321
|
-
if (effectiveNonce) intentHeaders["x-checkout-session-token"] = effectiveNonce;
|
|
3388
|
+
const intentHeaders = intentRequestHeaders(effectiveNonce);
|
|
3322
3389
|
const intentResponse = await fetch(`${baseUrl}/v1/checkouts/payments/intents`, {
|
|
3323
3390
|
method: "POST",
|
|
3324
3391
|
headers: intentHeaders,
|
|
@@ -3384,9 +3451,8 @@ function StripePaymentElementInner({
|
|
|
3384
3451
|
onDecline?.(buildDeclineEvent("card", message, { code: confirmError.code }));
|
|
3385
3452
|
return;
|
|
3386
3453
|
}
|
|
3387
|
-
const SUCCESSFUL_PI_STATUSES = /* @__PURE__ */ new Set(["succeeded", "requires_capture", "processing"]);
|
|
3388
3454
|
const piStatus = paymentIntent?.status;
|
|
3389
|
-
if (!
|
|
3455
|
+
if (!isSuccessfulPaymentIntentStatus(piStatus)) {
|
|
3390
3456
|
if (typeof window !== "undefined") {
|
|
3391
3457
|
try {
|
|
3392
3458
|
localStorage.removeItem(STRIPE_RESUME_KEY);
|
|
@@ -3436,9 +3502,9 @@ function StripePaymentElementInner({
|
|
|
3436
3502
|
onErrorChange,
|
|
3437
3503
|
onDecline
|
|
3438
3504
|
]);
|
|
3439
|
-
const [localExpandedMethod, setLocalExpandedMethod] = (0,
|
|
3505
|
+
const [localExpandedMethod, setLocalExpandedMethod] = (0, import_react10.useState)(null);
|
|
3440
3506
|
const activeExpandedMethod = onExpandApm ? expandedApmMethod ?? null : localExpandedMethod;
|
|
3441
|
-
const handleMethodClick = (0,
|
|
3507
|
+
const handleMethodClick = (0, import_react10.useCallback)((method) => {
|
|
3442
3508
|
if (submittingRef.current || isProcessing) return;
|
|
3443
3509
|
if (activeExpandedMethod && activeExpandedMethod !== method) return;
|
|
3444
3510
|
if ((0, import_shared5.needsStripeMethodExplicitConfirm)(method)) {
|
|
@@ -3451,14 +3517,14 @@ function StripePaymentElementInner({
|
|
|
3451
3517
|
void handleAutoConfirm(method);
|
|
3452
3518
|
}
|
|
3453
3519
|
}, [activeExpandedMethod, isProcessing, handleAutoConfirm, onExpandApm]);
|
|
3454
|
-
const localInlineElementsOptions = (0,
|
|
3520
|
+
const localInlineElementsOptions = (0, import_react10.useMemo)(() => {
|
|
3455
3521
|
if (!localExpandedMethod) return null;
|
|
3456
3522
|
return {
|
|
3457
3523
|
...paymentElementBaseOptions,
|
|
3458
3524
|
paymentMethodTypes: [localExpandedMethod]
|
|
3459
3525
|
};
|
|
3460
3526
|
}, [localExpandedMethod, paymentElementBaseOptions]);
|
|
3461
|
-
return /* @__PURE__ */ (0,
|
|
3527
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3462
3528
|
"div",
|
|
3463
3529
|
{
|
|
3464
3530
|
"data-testid": "flopay-stripe-payment-element-region",
|
|
@@ -3467,8 +3533,8 @@ function StripePaymentElementInner({
|
|
|
3467
3533
|
const isExpanded = expandedApmMethod === method;
|
|
3468
3534
|
const isSubmittingThis = submittingMethod === method;
|
|
3469
3535
|
const otherInProgress = submittingMethod !== null && submittingMethod !== method || expandedApmMethod !== null && expandedApmMethod !== void 0 && expandedApmMethod !== method;
|
|
3470
|
-
return /* @__PURE__ */ (0,
|
|
3471
|
-
/* @__PURE__ */ (0,
|
|
3536
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_react10.default.Fragment, { children: [
|
|
3537
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3472
3538
|
StripeMethodButton,
|
|
3473
3539
|
{
|
|
3474
3540
|
method,
|
|
@@ -3485,12 +3551,12 @@ function StripePaymentElementInner({
|
|
|
3485
3551
|
fontFamily: buttonAppearance?.fontFamily
|
|
3486
3552
|
}
|
|
3487
3553
|
),
|
|
3488
|
-
!onExpandApm && localExpandedMethod === method && localInlineElementsOptions && stripeInstance && /* @__PURE__ */ (0,
|
|
3554
|
+
!onExpandApm && localExpandedMethod === method && localInlineElementsOptions && stripeInstance && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3489
3555
|
import_react_stripe_js.Elements,
|
|
3490
3556
|
{
|
|
3491
3557
|
stripe: stripeInstance,
|
|
3492
3558
|
options: localInlineElementsOptions,
|
|
3493
|
-
children: /* @__PURE__ */ (0,
|
|
3559
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
3494
3560
|
StripeMethodInlineForm,
|
|
3495
3561
|
{
|
|
3496
3562
|
method,
|
|
@@ -3584,41 +3650,41 @@ function SplitCardFormInner({
|
|
|
3584
3650
|
const flopay = useFloPay();
|
|
3585
3651
|
const paypalFlopay = usePayPalFloPay();
|
|
3586
3652
|
const elements = useElements();
|
|
3587
|
-
const checkout = (0,
|
|
3653
|
+
const checkout = (0, import_react10.useContext)(CheckoutContext);
|
|
3588
3654
|
const contextBillingUrl = useBillingApiUrl();
|
|
3589
|
-
const [processing, setProcessing] = (0,
|
|
3590
|
-
const [error, setError] = (0,
|
|
3591
|
-
const [is3DSActive, setIs3DSActive] = (0,
|
|
3592
|
-
const [selectedCountry, setSelectedCountry] = (0,
|
|
3593
|
-
const [zipCode, setZipCode] = (0,
|
|
3594
|
-
const [addressLine1, setAddressLine1] = (0,
|
|
3595
|
-
const [addressLine2, setAddressLine2] = (0,
|
|
3596
|
-
const [city, setCity] = (0,
|
|
3597
|
-
const [stateValue, setStateValue] = (0,
|
|
3598
|
-
const [accountPatch, setAccountPatch] = (0,
|
|
3599
|
-
const zipCodeRef = (0,
|
|
3600
|
-
const selectedCountryRef = (0,
|
|
3601
|
-
const addressLine1Ref = (0,
|
|
3602
|
-
const addressLine2Ref = (0,
|
|
3603
|
-
const cityRef = (0,
|
|
3604
|
-
const stateRef = (0,
|
|
3605
|
-
const avsConfig = (0,
|
|
3655
|
+
const [processing, setProcessing] = (0, import_react10.useState)(false);
|
|
3656
|
+
const [error, setError] = (0, import_react10.useState)(null);
|
|
3657
|
+
const [is3DSActive, setIs3DSActive] = (0, import_react10.useState)(false);
|
|
3658
|
+
const [selectedCountry, setSelectedCountry] = (0, import_react10.useState)(countryProp ?? "US");
|
|
3659
|
+
const [zipCode, setZipCode] = (0, import_react10.useState)(zipProp ?? "");
|
|
3660
|
+
const [addressLine1, setAddressLine1] = (0, import_react10.useState)(addressLine1Prop ?? "");
|
|
3661
|
+
const [addressLine2, setAddressLine2] = (0, import_react10.useState)(addressLine2Prop ?? "");
|
|
3662
|
+
const [city, setCity] = (0, import_react10.useState)(cityProp ?? "");
|
|
3663
|
+
const [stateValue, setStateValue] = (0, import_react10.useState)(stateProp ?? "");
|
|
3664
|
+
const [accountPatch, setAccountPatch] = (0, import_react10.useState)({});
|
|
3665
|
+
const zipCodeRef = (0, import_react10.useRef)(zipProp ?? "");
|
|
3666
|
+
const selectedCountryRef = (0, import_react10.useRef)(countryProp ?? "US");
|
|
3667
|
+
const addressLine1Ref = (0, import_react10.useRef)(addressLine1Prop ?? "");
|
|
3668
|
+
const addressLine2Ref = (0, import_react10.useRef)(addressLine2Prop ?? "");
|
|
3669
|
+
const cityRef = (0, import_react10.useRef)(cityProp ?? "");
|
|
3670
|
+
const stateRef = (0, import_react10.useRef)(stateProp ?? "");
|
|
3671
|
+
const avsConfig = (0, import_react10.useMemo)(() => (0, import_shared5.resolveAVSConfig)(enableAVSProp), [enableAVSProp]);
|
|
3606
3672
|
const enableAVS = avsConfig !== null;
|
|
3607
3673
|
const vaultBlockReady = Boolean(session?.vault?.html);
|
|
3608
3674
|
const vaultGatewayAdvertised = Boolean(session?.gateways?.pcivault);
|
|
3609
3675
|
const vaultActive = Boolean(
|
|
3610
3676
|
showStripe && (vaultBlockReady || vaultGatewayAdvertised) && flopay && sessionId
|
|
3611
3677
|
);
|
|
3612
|
-
const cardCapture = (0,
|
|
3678
|
+
const cardCapture = (0, import_react10.useMemo)(() => {
|
|
3613
3679
|
if (!flopay || !vaultActive || !sessionId) return null;
|
|
3614
3680
|
return flopay.cardCapture({ sessionId });
|
|
3615
3681
|
}, [flopay, vaultActive, sessionId]);
|
|
3616
|
-
const postalCodeState = (0,
|
|
3682
|
+
const postalCodeState = (0, import_react10.useMemo)(() => {
|
|
3617
3683
|
const cc = selectedCountry;
|
|
3618
3684
|
const visible = avsConfig ? (0, import_shared5.isAVSFieldVisible)(avsConfig.postal_code, cc) : false;
|
|
3619
3685
|
return computePostalCodeState(cc, zipCode, visible);
|
|
3620
3686
|
}, [avsConfig, selectedCountry, zipCode]);
|
|
3621
|
-
const { avsInvalid, invalidAvsFields } = (0,
|
|
3687
|
+
const { avsInvalid, invalidAvsFields } = (0, import_react10.useMemo)(() => {
|
|
3622
3688
|
const none = { line1: false, city: false, state: false, zip: false };
|
|
3623
3689
|
if (!vaultActive || !avsConfig) return { avsInvalid: false, invalidAvsFields: none };
|
|
3624
3690
|
const cc = selectedCountry;
|
|
@@ -3634,53 +3700,53 @@ function SplitCardFormInner({
|
|
|
3634
3700
|
const avsInvalid2 = invalidAvsFields2.line1 || invalidAvsFields2.city || invalidAvsFields2.state || invalidAvsFields2.zip;
|
|
3635
3701
|
return { avsInvalid: avsInvalid2, invalidAvsFields: invalidAvsFields2 };
|
|
3636
3702
|
}, [vaultActive, avsConfig, selectedCountry, addressLine1, city, stateValue, postalCodeState]);
|
|
3637
|
-
const [hasAttemptedSubmit, setHasAttemptedSubmit] = (0,
|
|
3638
|
-
const [zipTouched, setZipTouched] = (0,
|
|
3639
|
-
const [vaultMount, setVaultMount] = (0,
|
|
3703
|
+
const [hasAttemptedSubmit, setHasAttemptedSubmit] = (0, import_react10.useState)(false);
|
|
3704
|
+
const [zipTouched, setZipTouched] = (0, import_react10.useState)(false);
|
|
3705
|
+
const [vaultMount, setVaultMount] = (0, import_react10.useState)(
|
|
3640
3706
|
() => toVaultMount(session?.vault)
|
|
3641
3707
|
);
|
|
3642
|
-
const [viewState, setViewState] = (0,
|
|
3643
|
-
const [expandedApmMethod, setExpandedApmMethod] = (0,
|
|
3708
|
+
const [viewState, setViewState] = (0, import_react10.useState)(initialCardOpen ? "card" : "buttons");
|
|
3709
|
+
const [expandedApmMethod, setExpandedApmMethod] = (0, import_react10.useState)(null);
|
|
3644
3710
|
const showCardForm = viewState === "expanding" || viewState === "card";
|
|
3645
3711
|
const TRANSITION_MS = 280;
|
|
3646
|
-
const expandToCard = (0,
|
|
3712
|
+
const expandToCard = (0, import_react10.useCallback)(() => {
|
|
3647
3713
|
setViewState("expanding");
|
|
3648
3714
|
setTimeout(() => setViewState("card"), TRANSITION_MS);
|
|
3649
3715
|
}, []);
|
|
3650
|
-
const collapseToButtons = (0,
|
|
3716
|
+
const collapseToButtons = (0, import_react10.useCallback)(() => {
|
|
3651
3717
|
setViewState("collapsing");
|
|
3652
3718
|
setTimeout(() => setViewState("buttons"), TRANSITION_MS);
|
|
3653
3719
|
}, []);
|
|
3654
|
-
const expandToApm = (0,
|
|
3720
|
+
const expandToApm = (0, import_react10.useCallback)((method) => {
|
|
3655
3721
|
setExpandedApmMethod(method);
|
|
3656
3722
|
setViewState("apm-expanding");
|
|
3657
3723
|
setTimeout(() => setViewState("apm-form"), TRANSITION_MS);
|
|
3658
3724
|
}, []);
|
|
3659
|
-
const collapseFromApm = (0,
|
|
3725
|
+
const collapseFromApm = (0, import_react10.useCallback)(() => {
|
|
3660
3726
|
setViewState("apm-collapsing");
|
|
3661
3727
|
setTimeout(() => {
|
|
3662
3728
|
setViewState("buttons");
|
|
3663
3729
|
setExpandedApmMethod(null);
|
|
3664
3730
|
}, TRANSITION_MS);
|
|
3665
3731
|
}, []);
|
|
3666
|
-
(0,
|
|
3732
|
+
(0, import_react10.useEffect)(() => {
|
|
3667
3733
|
if (layout === "buttons" && initialCardOpen) {
|
|
3668
3734
|
setViewState("card");
|
|
3669
3735
|
}
|
|
3670
3736
|
}, [layout, initialCardOpen]);
|
|
3671
|
-
const [fullName, setFullName] = (0,
|
|
3672
|
-
const [formReady, setFormReady] = (0,
|
|
3673
|
-
const [overlayStatus, setOverlayStatus] = (0,
|
|
3674
|
-
const processingRef = (0,
|
|
3675
|
-
const [paypalDirectRetry, setPaypalDirectRetry] = (0,
|
|
3676
|
-
const paypalDirectRetryRef = (0,
|
|
3677
|
-
(0,
|
|
3737
|
+
const [fullName, setFullName] = (0, import_react10.useState)("");
|
|
3738
|
+
const [formReady, setFormReady] = (0, import_react10.useState)(false);
|
|
3739
|
+
const [overlayStatus, setOverlayStatus] = (0, import_react10.useState)(null);
|
|
3740
|
+
const processingRef = (0, import_react10.useRef)(false);
|
|
3741
|
+
const [paypalDirectRetry, setPaypalDirectRetry] = (0, import_react10.useState)(null);
|
|
3742
|
+
const paypalDirectRetryRef = (0, import_react10.useRef)(paypalDirectRetry);
|
|
3743
|
+
(0, import_react10.useEffect)(() => {
|
|
3678
3744
|
paypalDirectRetryRef.current = paypalDirectRetry;
|
|
3679
3745
|
}, [paypalDirectRetry]);
|
|
3680
3746
|
const resolvedBillingApiUrl = billingApiUrl || contextBillingUrl;
|
|
3681
3747
|
const displayError = externalError ?? error;
|
|
3682
|
-
const themeBundle = (0,
|
|
3683
|
-
const bStyles = (0,
|
|
3748
|
+
const themeBundle = (0, import_react10.useMemo)(() => (0, import_shared6.resolveTheme)(theme), [theme]);
|
|
3749
|
+
const bStyles = (0, import_react10.useMemo)(() => {
|
|
3684
3750
|
const base = themeBundle?.buttonsLayout ?? (0, import_shared5.resolveButtonsLayoutTheme)(buttonsTheme);
|
|
3685
3751
|
if (!buttonsStylesOverride) return base;
|
|
3686
3752
|
return {
|
|
@@ -3695,7 +3761,7 @@ function SplitCardFormInner({
|
|
|
3695
3761
|
};
|
|
3696
3762
|
}, [themeBundle, buttonsTheme, buttonsStylesOverride]);
|
|
3697
3763
|
const appearance = appearanceOverride ?? themeBundle?.appearance;
|
|
3698
|
-
const vaultThemeColors = (0,
|
|
3764
|
+
const vaultThemeColors = (0, import_react10.useMemo)(() => {
|
|
3699
3765
|
const vars = appearance?.variables;
|
|
3700
3766
|
const asString = (value) => typeof value === "string" && value ? value : void 0;
|
|
3701
3767
|
const submitButtonStyle = bStyles.submitButton;
|
|
@@ -3724,7 +3790,7 @@ function SplitCardFormInner({
|
|
|
3724
3790
|
const isSubmitting = (externalProcessing ?? processing) || isInlineSessionPatchProcessing;
|
|
3725
3791
|
const isSelfContained = !onTokenizedBody;
|
|
3726
3792
|
const baseUrl = resolvedBillingApiUrl.replace(/\/+$/, "");
|
|
3727
|
-
const resolvedAccount = (0,
|
|
3793
|
+
const resolvedAccount = (0, import_react10.useMemo)(() => mergeAccountPatch({
|
|
3728
3794
|
userId,
|
|
3729
3795
|
email,
|
|
3730
3796
|
firstName,
|
|
@@ -3732,17 +3798,17 @@ function SplitCardFormInner({
|
|
|
3732
3798
|
country: countryProp,
|
|
3733
3799
|
zip: zipProp
|
|
3734
3800
|
}, accountPatch), [userId, email, firstName, lastName, countryProp, zipProp, accountPatch]);
|
|
3735
|
-
const stripeInstance = (0,
|
|
3801
|
+
const stripeInstance = (0, import_react10.useMemo)(() => {
|
|
3736
3802
|
if (!flopay) return null;
|
|
3737
3803
|
return flopay.getRawProvider();
|
|
3738
3804
|
}, [flopay]);
|
|
3739
|
-
const paypalStripeInstance = (0,
|
|
3805
|
+
const paypalStripeInstance = (0, import_react10.useMemo)(() => {
|
|
3740
3806
|
if (!paypalFlopay) return null;
|
|
3741
3807
|
return paypalFlopay.getRawProvider();
|
|
3742
3808
|
}, [paypalFlopay]);
|
|
3743
3809
|
const amountInCents = totalAmount || 100;
|
|
3744
3810
|
const stripeAppearanceProp = appearance ? { appearance } : null;
|
|
3745
|
-
const paymentElementAppearance = (0,
|
|
3811
|
+
const paymentElementAppearance = (0, import_react10.useMemo)(() => {
|
|
3746
3812
|
const base = appearance ?? {};
|
|
3747
3813
|
const baseRules = base.rules ?? {};
|
|
3748
3814
|
return {
|
|
@@ -3762,7 +3828,7 @@ function SplitCardFormInner({
|
|
|
3762
3828
|
}
|
|
3763
3829
|
};
|
|
3764
3830
|
}, [appearance]);
|
|
3765
|
-
const walletOptions = (0,
|
|
3831
|
+
const walletOptions = (0, import_react10.useMemo)(() => {
|
|
3766
3832
|
const modeOptions = resolveWalletElementsMode(totalAmount);
|
|
3767
3833
|
return {
|
|
3768
3834
|
...modeOptions,
|
|
@@ -3773,7 +3839,7 @@ function SplitCardFormInner({
|
|
|
3773
3839
|
...stripeAppearanceProp
|
|
3774
3840
|
};
|
|
3775
3841
|
}, [totalAmount, currency, stripeAppearanceProp]);
|
|
3776
|
-
const paypalOptions = (0,
|
|
3842
|
+
const paypalOptions = (0, import_react10.useMemo)(() => ({
|
|
3777
3843
|
mode: "payment",
|
|
3778
3844
|
amount: amountInCents,
|
|
3779
3845
|
currency: currency.toLowerCase(),
|
|
@@ -3781,29 +3847,29 @@ function SplitCardFormInner({
|
|
|
3781
3847
|
setupFutureUsage: "off_session",
|
|
3782
3848
|
...stripeAppearanceProp
|
|
3783
3849
|
}), [amountInCents, currency, stripeAppearanceProp]);
|
|
3784
|
-
const updateError = (0,
|
|
3850
|
+
const updateError = (0, import_react10.useCallback)(
|
|
3785
3851
|
(err) => {
|
|
3786
3852
|
setError(err);
|
|
3787
3853
|
onErrorChange?.(err);
|
|
3788
3854
|
},
|
|
3789
3855
|
[onErrorChange]
|
|
3790
3856
|
);
|
|
3791
|
-
(0,
|
|
3857
|
+
(0, import_react10.useEffect)(() => {
|
|
3792
3858
|
if (!vaultActive || !cardCapture) return;
|
|
3793
3859
|
cardCapture.setCardFieldOrder?.(cardFieldOrder ?? null, avsConfig == null);
|
|
3794
3860
|
}, [vaultActive, cardCapture, cardFieldOrder, avsConfig]);
|
|
3795
|
-
(0,
|
|
3861
|
+
(0, import_react10.useEffect)(() => {
|
|
3796
3862
|
if (viewState === "expanding" || viewState === "collapsing" || viewState === "apm-expanding" || viewState === "apm-collapsing") {
|
|
3797
3863
|
updateError(null);
|
|
3798
3864
|
}
|
|
3799
3865
|
}, [viewState, updateError]);
|
|
3800
|
-
const emitDecline = (0,
|
|
3866
|
+
const emitDecline = (0, import_react10.useCallback)(
|
|
3801
3867
|
(method, input, overrides) => {
|
|
3802
3868
|
onDecline?.(buildDeclineEvent(method, input, overrides));
|
|
3803
3869
|
},
|
|
3804
3870
|
[onDecline]
|
|
3805
3871
|
);
|
|
3806
|
-
const recoverExternalMethodTechnicalFailure = (0,
|
|
3872
|
+
const recoverExternalMethodTechnicalFailure = (0, import_react10.useCallback)(
|
|
3807
3873
|
(method, err, options) => {
|
|
3808
3874
|
const popupBlocked = options?.popupBlocked ?? isPopupBlockedError(err);
|
|
3809
3875
|
const message = buildExternalMethodRecoveryMessage(method, popupBlocked);
|
|
@@ -3827,7 +3893,7 @@ function SplitCardFormInner({
|
|
|
3827
3893
|
},
|
|
3828
3894
|
[layout, onError, updateError]
|
|
3829
3895
|
);
|
|
3830
|
-
(0,
|
|
3896
|
+
(0, import_react10.useEffect)(() => {
|
|
3831
3897
|
if (!vaultActive || !sessionId) {
|
|
3832
3898
|
setVaultMount(null);
|
|
3833
3899
|
return;
|
|
@@ -3865,7 +3931,7 @@ function SplitCardFormInner({
|
|
|
3865
3931
|
nonce,
|
|
3866
3932
|
updateError
|
|
3867
3933
|
]);
|
|
3868
|
-
const vaultOutcomeRef = (0,
|
|
3934
|
+
const vaultOutcomeRef = (0, import_react10.useRef)({
|
|
3869
3935
|
onComplete,
|
|
3870
3936
|
onError,
|
|
3871
3937
|
updateError,
|
|
@@ -3891,8 +3957,8 @@ function SplitCardFormInner({
|
|
|
3891
3957
|
nonce,
|
|
3892
3958
|
baseUrl
|
|
3893
3959
|
};
|
|
3894
|
-
const vaultCompletedRef = (0,
|
|
3895
|
-
const buildVaultAccountSnapshot = (0,
|
|
3960
|
+
const vaultCompletedRef = (0, import_react10.useRef)(false);
|
|
3961
|
+
const buildVaultAccountSnapshot = (0, import_react10.useCallback)(() => {
|
|
3896
3962
|
const { resolvedAccount: resolvedAccount2, avsConfig: avsConfig2, fullName: fullName2, avsCheckProp: avsCheckProp2 } = vaultOutcomeRef.current;
|
|
3897
3963
|
const cc = selectedCountryRef.current || resolvedAccount2.country || "US";
|
|
3898
3964
|
const stateVisible = avsConfig2 ? (0, import_shared5.isAVSFieldVisible)(avsConfig2.state, cc) : false;
|
|
@@ -3928,11 +3994,11 @@ function SplitCardFormInner({
|
|
|
3928
3994
|
} : {}
|
|
3929
3995
|
};
|
|
3930
3996
|
}, []);
|
|
3931
|
-
(0,
|
|
3997
|
+
(0, import_react10.useEffect)(() => {
|
|
3932
3998
|
if (!vaultActive || !cardCapture) return;
|
|
3933
3999
|
cardCapture.setSubmitGate?.(avsInvalid);
|
|
3934
4000
|
}, [vaultActive, cardCapture, avsInvalid]);
|
|
3935
|
-
(0,
|
|
4001
|
+
(0, import_react10.useEffect)(() => {
|
|
3936
4002
|
if (!vaultActive || !cardCapture) return;
|
|
3937
4003
|
vaultCompletedRef.current = false;
|
|
3938
4004
|
let cancelled = false;
|
|
@@ -3993,18 +4059,18 @@ function SplitCardFormInner({
|
|
|
3993
4059
|
const hasEnabledMethodsPayload = Array.isArray(enabledPaymentMethods);
|
|
3994
4060
|
const hasEnabledMethods = hasEnabledMethodsPayload && enabledPaymentMethods.length > 0;
|
|
3995
4061
|
const paypalEnabled = hasEnabledMethodsPayload && enabledPaymentMethods.includes("paypal");
|
|
3996
|
-
const { expressMethods, paymentElementMethods } = (0,
|
|
4062
|
+
const { expressMethods, paymentElementMethods } = (0, import_react10.useMemo)(
|
|
3997
4063
|
() => (0, import_shared5.partitionStripeMethods)(enabledPaymentMethods, {
|
|
3998
4064
|
excludePaypal: directPaypalConfigured
|
|
3999
4065
|
}),
|
|
4000
4066
|
[enabledPaymentMethods, directPaypalConfigured]
|
|
4001
4067
|
);
|
|
4002
4068
|
const paypalRenderedSeparately = directPaypalConfigured || !!paypalFlopay;
|
|
4003
|
-
const expressMethodsForWalletRow = (0,
|
|
4069
|
+
const expressMethodsForWalletRow = (0, import_react10.useMemo)(
|
|
4004
4070
|
() => paypalRenderedSeparately ? expressMethods.filter((m) => m !== "paypal") : expressMethods,
|
|
4005
4071
|
[expressMethods, paypalRenderedSeparately]
|
|
4006
4072
|
);
|
|
4007
|
-
const legacyExpressMethods = (0,
|
|
4073
|
+
const legacyExpressMethods = (0, import_react10.useMemo)(() => {
|
|
4008
4074
|
const out = [];
|
|
4009
4075
|
if (showApplePay) out.push("apple_pay");
|
|
4010
4076
|
if (showGooglePay) out.push("google_pay");
|
|
@@ -4013,7 +4079,7 @@ function SplitCardFormInner({
|
|
|
4013
4079
|
const walletExpressMethods = hasEnabledMethodsPayload ? expressMethodsForWalletRow : legacyExpressMethods;
|
|
4014
4080
|
const showWallets = showStripe && walletExpressMethods.length > 0;
|
|
4015
4081
|
const apmCountry = enableAVS ? selectedCountry : countryProp;
|
|
4016
|
-
const paymentElementMethodsForCurrency = (0,
|
|
4082
|
+
const paymentElementMethodsForCurrency = (0, import_react10.useMemo)(() => {
|
|
4017
4083
|
const target = apmCountry?.trim().toUpperCase();
|
|
4018
4084
|
if (!target) return paymentElementMethods;
|
|
4019
4085
|
if (!enabledPaymentMethodCountries) {
|
|
@@ -4024,19 +4090,19 @@ function SplitCardFormInner({
|
|
|
4024
4090
|
return !allowed || allowed.length === 0 || allowed.includes(target);
|
|
4025
4091
|
});
|
|
4026
4092
|
}, [paymentElementMethods, apmCountry, enabledPaymentMethodCountries]);
|
|
4027
|
-
const paymentElementBaseOptions = (0,
|
|
4093
|
+
const paymentElementBaseOptions = (0, import_react10.useMemo)(() => ({
|
|
4028
4094
|
mode: "payment",
|
|
4029
4095
|
amount: amountInCents,
|
|
4030
4096
|
currency: currency.toLowerCase(),
|
|
4031
4097
|
paymentMethodCreation: "manual",
|
|
4032
4098
|
appearance: paymentElementAppearance
|
|
4033
4099
|
}), [amountInCents, currency, paymentElementAppearance]);
|
|
4034
|
-
const [paypalLoadState, setPaypalLoadState] = (0,
|
|
4035
|
-
const [walletLoadState, setWalletLoadState] = (0,
|
|
4036
|
-
const [paymentElementLoadState, setPaymentElementLoadState] = (0,
|
|
4037
|
-
const [directPaypalReady, setDirectPaypalReady] = (0,
|
|
4038
|
-
const [inAppBrowserDetected, setInAppBrowserDetected] = (0,
|
|
4039
|
-
(0,
|
|
4100
|
+
const [paypalLoadState, setPaypalLoadState] = (0, import_react10.useState)("loading");
|
|
4101
|
+
const [walletLoadState, setWalletLoadState] = (0, import_react10.useState)("loading");
|
|
4102
|
+
const [paymentElementLoadState, setPaymentElementLoadState] = (0, import_react10.useState)("loading");
|
|
4103
|
+
const [directPaypalReady, setDirectPaypalReady] = (0, import_react10.useState)(false);
|
|
4104
|
+
const [inAppBrowserDetected, setInAppBrowserDetected] = (0, import_react10.useState)();
|
|
4105
|
+
(0, import_react10.useEffect)(() => {
|
|
4040
4106
|
setInAppBrowserDetected(isInAppBrowser());
|
|
4041
4107
|
}, []);
|
|
4042
4108
|
const shouldShowPayPal = showPayPal && (directPaypalConfigured || (hasEnabledMethodsPayload ? paypalEnabled : inAppBrowserDetected === false));
|
|
@@ -4048,8 +4114,8 @@ function SplitCardFormInner({
|
|
|
4048
4114
|
const shouldDisplayPayPalRow = shouldRenderDirectPayPal ? directPaypalReady : shouldRenderStripePayPal && isExpressCheckoutRowVisible(paypalLoadState);
|
|
4049
4115
|
const shouldDisplayWalletRow = shouldRenderWallets && isExpressCheckoutRowVisible(walletLoadState);
|
|
4050
4116
|
const shouldDisplayPaymentElementRow = shouldRenderPaymentElement && paymentElementLoadState !== "load_error";
|
|
4051
|
-
const validationFiredRef = (0,
|
|
4052
|
-
(0,
|
|
4117
|
+
const validationFiredRef = (0, import_react10.useRef)(false);
|
|
4118
|
+
(0, import_react10.useEffect)(() => {
|
|
4053
4119
|
if (validationFiredRef.current) return;
|
|
4054
4120
|
if (!showStripe && !showPayPal) {
|
|
4055
4121
|
validationFiredRef.current = true;
|
|
@@ -4069,8 +4135,8 @@ function SplitCardFormInner({
|
|
|
4069
4135
|
updateError(err.message);
|
|
4070
4136
|
}
|
|
4071
4137
|
}, [showStripe, showPayPal, directPaypalConfigured, paypalStripeInstance, onError, updateError]);
|
|
4072
|
-
const deprecationLoggedRef = (0,
|
|
4073
|
-
(0,
|
|
4138
|
+
const deprecationLoggedRef = (0, import_react10.useRef)(false);
|
|
4139
|
+
(0, import_react10.useEffect)(() => {
|
|
4074
4140
|
if (deprecationLoggedRef.current) return;
|
|
4075
4141
|
if (!hasEnabledMethods) return;
|
|
4076
4142
|
const stale = [];
|
|
@@ -4082,14 +4148,14 @@ function SplitCardFormInner({
|
|
|
4082
4148
|
`[FloPay] ${stale.join(" / ")} ${stale.length === 1 ? "is" : "are"} deprecated: the Apple Pay / Google Pay surface is now driven by \`gateways.stripe.enabledPaymentMethods\` on the session response. Remove the legacy prop(s) to silence this warning.`
|
|
4083
4149
|
);
|
|
4084
4150
|
}, [hasEnabledMethods, showApplePay, showGooglePay]);
|
|
4085
|
-
const handleNameChange = (0,
|
|
4151
|
+
const handleNameChange = (0, import_react10.useCallback)((value) => {
|
|
4086
4152
|
setFullName(value);
|
|
4087
4153
|
onFullNameChange?.(value);
|
|
4088
4154
|
const parts = value.trim().split(/\s+/);
|
|
4089
4155
|
onFirstNameChange?.(parts[0] ?? "");
|
|
4090
4156
|
onLastNameChange?.(parts.length > 1 ? parts.slice(1).join(" ") : "");
|
|
4091
4157
|
}, [onFullNameChange, onFirstNameChange, onLastNameChange]);
|
|
4092
|
-
const applyInlineSessionPatch = (0,
|
|
4158
|
+
const applyInlineSessionPatch = (0, import_react10.useCallback)(
|
|
4093
4159
|
(patch, method) => {
|
|
4094
4160
|
if (!checkout.applyInlineSessionPatch) {
|
|
4095
4161
|
return Promise.resolve({ error: null, sessionId, nonce });
|
|
@@ -4111,7 +4177,7 @@ function SplitCardFormInner({
|
|
|
4111
4177
|
},
|
|
4112
4178
|
[checkout.applyInlineSessionPatch, nonce, onError, sessionId, updateError]
|
|
4113
4179
|
);
|
|
4114
|
-
const runBeforeButtonClick = (0,
|
|
4180
|
+
const runBeforeButtonClick = (0, import_react10.useCallback)(async (method) => {
|
|
4115
4181
|
if (!onBeforeButtonClick) return { proceed: true };
|
|
4116
4182
|
try {
|
|
4117
4183
|
const result = await onBeforeButtonClick({
|
|
@@ -4148,7 +4214,7 @@ function SplitCardFormInner({
|
|
|
4148
4214
|
return { proceed: false };
|
|
4149
4215
|
}
|
|
4150
4216
|
}, [applyInlineSessionPatch, checkout.inlineSessionDraft, onBeforeButtonClick, onError, sessionId, updateError]);
|
|
4151
|
-
const processPaymentInternal = (0,
|
|
4217
|
+
const processPaymentInternal = (0, import_react10.useCallback)(
|
|
4152
4218
|
async (tokenizedBody, overrides) => {
|
|
4153
4219
|
if (processingRef.current) return;
|
|
4154
4220
|
processingRef.current = true;
|
|
@@ -4359,7 +4425,7 @@ function SplitCardFormInner({
|
|
|
4359
4425
|
},
|
|
4360
4426
|
[baseUrl, sessionId, nonce, resolvedAccount, fullName, chv, flopay, paypalFlopay, onComplete, onError, updateError, emitDecline]
|
|
4361
4427
|
);
|
|
4362
|
-
const dispatchTokenizedBody = (0,
|
|
4428
|
+
const dispatchTokenizedBody = (0, import_react10.useCallback)(
|
|
4363
4429
|
(tokenizedBody, overrides) => {
|
|
4364
4430
|
if (onTokenizedBody) {
|
|
4365
4431
|
onTokenizedBody(tokenizedBody);
|
|
@@ -4369,7 +4435,7 @@ function SplitCardFormInner({
|
|
|
4369
4435
|
},
|
|
4370
4436
|
[onTokenizedBody, processPaymentInternal]
|
|
4371
4437
|
);
|
|
4372
|
-
(0,
|
|
4438
|
+
(0, import_react10.useImperativeHandle)(innerRef, () => ({
|
|
4373
4439
|
async handleNextAction(secret) {
|
|
4374
4440
|
if (!flopay) return;
|
|
4375
4441
|
setIs3DSActive(true);
|
|
@@ -4396,8 +4462,8 @@ function SplitCardFormInner({
|
|
|
4396
4462
|
}
|
|
4397
4463
|
}
|
|
4398
4464
|
}), [flopay, dispatchTokenizedBody, onError, updateError, emitDecline]);
|
|
4399
|
-
const stripeResumeAttemptedRef = (0,
|
|
4400
|
-
(0,
|
|
4465
|
+
const stripeResumeAttemptedRef = (0, import_react10.useRef)(false);
|
|
4466
|
+
(0, import_react10.useEffect)(() => {
|
|
4401
4467
|
if (typeof window === "undefined" || stripeResumeAttemptedRef.current) return;
|
|
4402
4468
|
const params = new URLSearchParams(window.location.search);
|
|
4403
4469
|
const paymentIntentId = params.get("payment_intent");
|
|
@@ -4458,7 +4524,7 @@ function SplitCardFormInner({
|
|
|
4458
4524
|
return;
|
|
4459
4525
|
}
|
|
4460
4526
|
const piStatus = paymentIntent?.status;
|
|
4461
|
-
const successful = piStatus
|
|
4527
|
+
const successful = isSuccessfulPaymentIntentStatus(piStatus);
|
|
4462
4528
|
if (!paymentIntent || !successful) {
|
|
4463
4529
|
const message = piStatus === "canceled" ? "Payment was canceled." : "Payment was not completed. Please try again.";
|
|
4464
4530
|
updateError(message);
|
|
@@ -4475,7 +4541,7 @@ function SplitCardFormInner({
|
|
|
4475
4541
|
}, persistedOverrides);
|
|
4476
4542
|
})();
|
|
4477
4543
|
}, [sessionId, dispatchTokenizedBody, flopay, updateError, emitDecline]);
|
|
4478
|
-
const handleSubmit = (0,
|
|
4544
|
+
const handleSubmit = (0, import_react10.useCallback)(
|
|
4479
4545
|
async (e) => {
|
|
4480
4546
|
e.preventDefault();
|
|
4481
4547
|
if (!flopay || !elements || isSubmitting || processingRef.current) return;
|
|
@@ -4558,8 +4624,7 @@ function SplitCardFormInner({
|
|
|
4558
4624
|
updateError(pmResult.error?.message ?? "Failed to create payment method.");
|
|
4559
4625
|
return;
|
|
4560
4626
|
}
|
|
4561
|
-
const intentHeaders =
|
|
4562
|
-
if (nonce) intentHeaders["x-checkout-session-token"] = nonce;
|
|
4627
|
+
const intentHeaders = intentRequestHeaders(nonce);
|
|
4563
4628
|
const intentResponse = await fetch(`${baseUrl}/v1/checkouts/payments/intents`, {
|
|
4564
4629
|
method: "POST",
|
|
4565
4630
|
headers: intentHeaders,
|
|
@@ -4635,7 +4700,7 @@ function SplitCardFormInner({
|
|
|
4635
4700
|
);
|
|
4636
4701
|
const isReady = flopay !== null && (vaultActive || elements !== null);
|
|
4637
4702
|
if (!isReady) {
|
|
4638
|
-
return /* @__PURE__ */ (0,
|
|
4703
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." });
|
|
4639
4704
|
}
|
|
4640
4705
|
const isButtons = layout === "buttons";
|
|
4641
4706
|
const appearanceVars = appearance?.variables;
|
|
@@ -4694,7 +4759,7 @@ function SplitCardFormInner({
|
|
|
4694
4759
|
const containerOverrides = bStyles.cardFormContainer ?? {};
|
|
4695
4760
|
const containerPadding = containerOverrides.padding ?? (isButtons ? "0" : "1rem");
|
|
4696
4761
|
const containerRadius = containerOverrides.borderRadius ?? resolvedBorderRadius;
|
|
4697
|
-
const vaultCardFieldsNode = cardCapture && vaultMount ? /* @__PURE__ */ (0,
|
|
4762
|
+
const vaultCardFieldsNode = cardCapture && vaultMount ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4698
4763
|
VaultCardFields,
|
|
4699
4764
|
{
|
|
4700
4765
|
capture: cardCapture,
|
|
@@ -4732,7 +4797,7 @@ function SplitCardFormInner({
|
|
|
4732
4797
|
if (message) setOverlayStatus(null);
|
|
4733
4798
|
}
|
|
4734
4799
|
}
|
|
4735
|
-
) : /* @__PURE__ */ (0,
|
|
4800
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4736
4801
|
"div",
|
|
4737
4802
|
{
|
|
4738
4803
|
"data-testid": "flopay-vault-loading",
|
|
@@ -4747,7 +4812,7 @@ function SplitCardFormInner({
|
|
|
4747
4812
|
children: "Loading secure card form\u2026"
|
|
4748
4813
|
}
|
|
4749
4814
|
);
|
|
4750
|
-
const cardFormBlock = /* @__PURE__ */ (0,
|
|
4815
|
+
const cardFormBlock = /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: {
|
|
4751
4816
|
backgroundColor: cardBg,
|
|
4752
4817
|
borderRadius: containerRadius,
|
|
4753
4818
|
...containerOverrides,
|
|
@@ -4760,7 +4825,7 @@ function SplitCardFormInner({
|
|
|
4760
4825
|
display: "flex",
|
|
4761
4826
|
flexDirection: "column"
|
|
4762
4827
|
}, children: [
|
|
4763
|
-
/* @__PURE__ */ (0,
|
|
4828
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("style", { children: `
|
|
4764
4829
|
.flopay-shared-input::placeholder {
|
|
4765
4830
|
color: var(--flopay-input-placeholder-color);
|
|
4766
4831
|
opacity: 1;
|
|
@@ -4769,14 +4834,14 @@ function SplitCardFormInner({
|
|
|
4769
4834
|
font-weight: var(--flopay-input-font-weight);
|
|
4770
4835
|
}
|
|
4771
4836
|
` }),
|
|
4772
|
-
isButtons && showCardForm && /* @__PURE__ */ (0,
|
|
4837
|
+
isButtons && showCardForm && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: {
|
|
4773
4838
|
display: "flex",
|
|
4774
4839
|
alignItems: "center",
|
|
4775
4840
|
padding: "0.75rem 0 0.625rem",
|
|
4776
4841
|
// Keep the header on top when AVS is ordered above the card on vault.
|
|
4777
4842
|
order: vaultActive ? -2 : 0
|
|
4778
4843
|
}, children: [
|
|
4779
|
-
/* @__PURE__ */ (0,
|
|
4844
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4780
4845
|
"button",
|
|
4781
4846
|
{
|
|
4782
4847
|
type: "button",
|
|
@@ -4798,7 +4863,7 @@ function SplitCardFormInner({
|
|
|
4798
4863
|
},
|
|
4799
4864
|
"aria-label": "Back to payment methods",
|
|
4800
4865
|
children: [
|
|
4801
|
-
/* @__PURE__ */ (0,
|
|
4866
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: {
|
|
4802
4867
|
display: "inline-flex",
|
|
4803
4868
|
alignItems: "center",
|
|
4804
4869
|
justifyContent: "center",
|
|
@@ -4808,12 +4873,12 @@ function SplitCardFormInner({
|
|
|
4808
4873
|
backgroundColor: "#f3f4f6",
|
|
4809
4874
|
transition: "background-color 0.15s",
|
|
4810
4875
|
...bStyles.backButtonIcon
|
|
4811
|
-
}, children: /* @__PURE__ */ (0,
|
|
4812
|
-
/* @__PURE__ */ (0,
|
|
4876
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.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_runtime8.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
|
|
4877
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
|
|
4813
4878
|
]
|
|
4814
4879
|
}
|
|
4815
4880
|
),
|
|
4816
|
-
hideTitle ? /* @__PURE__ */ (0,
|
|
4881
|
+
hideTitle ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
4817
4882
|
flex: 1,
|
|
4818
4883
|
textAlign: "center",
|
|
4819
4884
|
fontWeight: 600,
|
|
@@ -4821,9 +4886,9 @@ function SplitCardFormInner({
|
|
|
4821
4886
|
color: "#262833",
|
|
4822
4887
|
paddingRight: 80,
|
|
4823
4888
|
...bStyles.title
|
|
4824
|
-
}, children: /* @__PURE__ */ (0,
|
|
4889
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TitleContentSlot, { content: cardTitleContent }) })
|
|
4825
4890
|
] }),
|
|
4826
|
-
!isButtons && !hideTitle && /* @__PURE__ */ (0,
|
|
4891
|
+
!isButtons && !hideTitle && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
4827
4892
|
textAlign: "center",
|
|
4828
4893
|
fontWeight: 600,
|
|
4829
4894
|
fontSize: "1.1rem",
|
|
@@ -4833,17 +4898,17 @@ function SplitCardFormInner({
|
|
|
4833
4898
|
// (-2) and AVS block (-1) are ordered below it but above the card form.
|
|
4834
4899
|
order: vaultActive ? -3 : 0,
|
|
4835
4900
|
...bStyles.title
|
|
4836
|
-
}, children: /* @__PURE__ */ (0,
|
|
4837
|
-
!vaultActive && /* @__PURE__ */ (0,
|
|
4838
|
-
/* @__PURE__ */ (0,
|
|
4901
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(TitleContentSlot, { content: cardTitleContent }) }),
|
|
4902
|
+
!vaultActive && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
4903
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
4839
4904
|
backgroundColor: cardInputBg,
|
|
4840
4905
|
border: `1px solid ${resolvedBorder}`,
|
|
4841
4906
|
borderTopLeftRadius: resolvedBorderRadius,
|
|
4842
4907
|
borderTopRightRadius: resolvedBorderRadius,
|
|
4843
4908
|
padding: "10px"
|
|
4844
|
-
}, children: /* @__PURE__ */ (0,
|
|
4845
|
-
/* @__PURE__ */ (0,
|
|
4846
|
-
/* @__PURE__ */ (0,
|
|
4909
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CardNumberElement, { onReady: () => setFormReady(true), options: stripeElementStyle }) }),
|
|
4910
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { display: "flex" }, children: [
|
|
4911
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
4847
4912
|
flex: 1,
|
|
4848
4913
|
backgroundColor: cardInputBg,
|
|
4849
4914
|
// Longhand only — mixing `border` shorthand with per-side
|
|
@@ -4855,8 +4920,8 @@ function SplitCardFormInner({
|
|
|
4855
4920
|
borderLeft: `1px solid ${resolvedBorder}`,
|
|
4856
4921
|
borderBottomLeftRadius: resolvedBorderRadius,
|
|
4857
4922
|
padding: "10px"
|
|
4858
|
-
}, children: /* @__PURE__ */ (0,
|
|
4859
|
-
/* @__PURE__ */ (0,
|
|
4923
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CardExpiryElement, { options: stripeElementStyle }) }),
|
|
4924
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
4860
4925
|
flex: 1,
|
|
4861
4926
|
backgroundColor: cardInputBg,
|
|
4862
4927
|
borderTop: "none",
|
|
@@ -4865,16 +4930,16 @@ function SplitCardFormInner({
|
|
|
4865
4930
|
borderLeft: `1px solid ${resolvedBorder}`,
|
|
4866
4931
|
borderBottomRightRadius: resolvedBorderRadius,
|
|
4867
4932
|
padding: "10px"
|
|
4868
|
-
}, children: /* @__PURE__ */ (0,
|
|
4933
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CardCvcElement, { options: stripeElementStyle }) })
|
|
4869
4934
|
] })
|
|
4870
4935
|
] }),
|
|
4871
|
-
!vaultActive && /* @__PURE__ */ (0,
|
|
4936
|
+
!vaultActive && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
4872
4937
|
backgroundColor: cardInputBg,
|
|
4873
4938
|
border: `1px solid ${resolvedBorder}`,
|
|
4874
4939
|
borderRadius: resolvedBorderRadius,
|
|
4875
4940
|
marginTop: "0.5rem",
|
|
4876
4941
|
padding: "10px"
|
|
4877
|
-
}, children: /* @__PURE__ */ (0,
|
|
4942
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4878
4943
|
"input",
|
|
4879
4944
|
{
|
|
4880
4945
|
className: "flopay-shared-input",
|
|
@@ -4896,7 +4961,7 @@ function SplitCardFormInner({
|
|
|
4896
4961
|
}
|
|
4897
4962
|
}
|
|
4898
4963
|
) }),
|
|
4899
|
-
avsConfig && /* @__PURE__ */ (0,
|
|
4964
|
+
avsConfig && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { order: vaultActive ? -1 : 0 }, "data-testid": "flopay-avs-fields", children: (() => {
|
|
4900
4965
|
const cc = selectedCountry;
|
|
4901
4966
|
const inputWrapStyle = (invalid = false) => ({
|
|
4902
4967
|
backgroundColor: cardInputBg,
|
|
@@ -4913,8 +4978,8 @@ function SplitCardFormInner({
|
|
|
4913
4978
|
...sharedInputTypography
|
|
4914
4979
|
});
|
|
4915
4980
|
const stateOpts = (0, import_shared5.getStateOptions)(cc);
|
|
4916
|
-
return /* @__PURE__ */ (0,
|
|
4917
|
-
(0, import_shared5.isAVSFieldVisible)(avsConfig.address_line_1, cc) && /* @__PURE__ */ (0,
|
|
4981
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
4982
|
+
(0, import_shared5.isAVSFieldVisible)(avsConfig.address_line_1, cc) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: inputWrapStyle(invalidAvsFields.line1), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4918
4983
|
"input",
|
|
4919
4984
|
{
|
|
4920
4985
|
className: "flopay-shared-input",
|
|
@@ -4933,7 +4998,7 @@ function SplitCardFormInner({
|
|
|
4933
4998
|
style: inputFieldStyle()
|
|
4934
4999
|
}
|
|
4935
5000
|
) }),
|
|
4936
|
-
(0, import_shared5.isAVSFieldVisible)(avsConfig.address_line_2, cc) && /* @__PURE__ */ (0,
|
|
5001
|
+
(0, import_shared5.isAVSFieldVisible)(avsConfig.address_line_2, cc) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: inputWrapStyle(), children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4937
5002
|
"input",
|
|
4938
5003
|
{
|
|
4939
5004
|
className: "flopay-shared-input",
|
|
@@ -4951,12 +5016,12 @@ function SplitCardFormInner({
|
|
|
4951
5016
|
style: inputFieldStyle()
|
|
4952
5017
|
}
|
|
4953
5018
|
) }),
|
|
4954
|
-
((0, import_shared5.isAVSFieldVisible)(avsConfig.city, cc) || (0, import_shared5.isAVSFieldVisible)(avsConfig.state, cc)) && /* @__PURE__ */ (0,
|
|
5019
|
+
((0, import_shared5.isAVSFieldVisible)(avsConfig.city, cc) || (0, import_shared5.isAVSFieldVisible)(avsConfig.state, cc)) && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: {
|
|
4955
5020
|
display: "flex",
|
|
4956
5021
|
gap: "0",
|
|
4957
5022
|
marginTop: "0.5rem"
|
|
4958
5023
|
}, children: [
|
|
4959
|
-
(0, import_shared5.isAVSFieldVisible)(avsConfig.city, cc) && /* @__PURE__ */ (0,
|
|
5024
|
+
(0, import_shared5.isAVSFieldVisible)(avsConfig.city, cc) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
4960
5025
|
flex: 1,
|
|
4961
5026
|
backgroundColor: cardInputBg,
|
|
4962
5027
|
borderTop: `1px solid ${avsBorderColor(invalidAvsFields.city)}`,
|
|
@@ -4967,7 +5032,7 @@ function SplitCardFormInner({
|
|
|
4967
5032
|
borderTopLeftRadius: resolvedBorderRadius,
|
|
4968
5033
|
borderBottomLeftRadius: resolvedBorderRadius,
|
|
4969
5034
|
...(0, import_shared5.isAVSFieldVisible)(avsConfig.state, cc) ? { borderRight: "none", borderTopRightRadius: 0, borderBottomRightRadius: 0 } : { borderRadius: resolvedBorderRadius }
|
|
4970
|
-
}, children: /* @__PURE__ */ (0,
|
|
5035
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
4971
5036
|
"input",
|
|
4972
5037
|
{
|
|
4973
5038
|
className: "flopay-shared-input",
|
|
@@ -4986,7 +5051,7 @@ function SplitCardFormInner({
|
|
|
4986
5051
|
style: inputFieldStyle()
|
|
4987
5052
|
}
|
|
4988
5053
|
) }),
|
|
4989
|
-
(0, import_shared5.isAVSFieldVisible)(avsConfig.state, cc) && /* @__PURE__ */ (0,
|
|
5054
|
+
(0, import_shared5.isAVSFieldVisible)(avsConfig.state, cc) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
4990
5055
|
flex: 1,
|
|
4991
5056
|
backgroundColor: cardInputBg,
|
|
4992
5057
|
border: `1px solid ${avsBorderColor(invalidAvsFields.state)}`,
|
|
@@ -4994,7 +5059,7 @@ function SplitCardFormInner({
|
|
|
4994
5059
|
borderTopRightRadius: resolvedBorderRadius,
|
|
4995
5060
|
borderBottomRightRadius: resolvedBorderRadius,
|
|
4996
5061
|
...(0, import_shared5.isAVSFieldVisible)(avsConfig.city, cc) ? { borderTopLeftRadius: 0, borderBottomLeftRadius: 0 } : { borderRadius: resolvedBorderRadius }
|
|
4997
|
-
}, children: stateOpts ? /* @__PURE__ */ (0,
|
|
5062
|
+
}, children: stateOpts ? /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
4998
5063
|
"select",
|
|
4999
5064
|
{
|
|
5000
5065
|
id: "flopay-billing-state",
|
|
@@ -5010,11 +5075,11 @@ function SplitCardFormInner({
|
|
|
5010
5075
|
"data-testid": "flopay-state",
|
|
5011
5076
|
style: { ...inputFieldStyle(), cursor: "pointer" },
|
|
5012
5077
|
children: [
|
|
5013
|
-
/* @__PURE__ */ (0,
|
|
5014
|
-
stateOpts.map((s) => /* @__PURE__ */ (0,
|
|
5078
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: "", children: (0, import_shared5.getStateLabel)(cc) }),
|
|
5079
|
+
stateOpts.map((s) => /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("option", { value: s.code, children: s.name }, s.code))
|
|
5015
5080
|
]
|
|
5016
5081
|
}
|
|
5017
|
-
) : /* @__PURE__ */ (0,
|
|
5082
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5018
5083
|
"input",
|
|
5019
5084
|
{
|
|
5020
5085
|
className: "flopay-shared-input",
|
|
@@ -5034,13 +5099,13 @@ function SplitCardFormInner({
|
|
|
5034
5099
|
}
|
|
5035
5100
|
) })
|
|
5036
5101
|
] }),
|
|
5037
|
-
((0, import_shared5.isAVSFieldVisible)(avsConfig.country, cc) || (0, import_shared5.isAVSFieldVisible)(avsConfig.postal_code, cc)) && /* @__PURE__ */ (0,
|
|
5102
|
+
((0, import_shared5.isAVSFieldVisible)(avsConfig.country, cc) || (0, import_shared5.isAVSFieldVisible)(avsConfig.postal_code, cc)) && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: {
|
|
5038
5103
|
display: "flex",
|
|
5039
5104
|
flexDirection: avsLayoutProp === "column" ? "column" : "row",
|
|
5040
5105
|
gap: avsLayoutProp === "column" ? "0.5rem" : "0",
|
|
5041
5106
|
marginTop: "0.5rem"
|
|
5042
5107
|
}, children: [
|
|
5043
|
-
(0, import_shared5.isAVSFieldVisible)(avsConfig.country, cc) && /* @__PURE__ */ (0,
|
|
5108
|
+
(0, import_shared5.isAVSFieldVisible)(avsConfig.country, cc) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
5044
5109
|
flex: avsLayoutProp === "row" ? 1 : void 0,
|
|
5045
5110
|
backgroundColor: cardInputBg,
|
|
5046
5111
|
borderTop: `1px solid ${resolvedBorder}`,
|
|
@@ -5049,7 +5114,7 @@ function SplitCardFormInner({
|
|
|
5049
5114
|
borderLeft: `1px solid ${resolvedBorder}`,
|
|
5050
5115
|
padding: "10px",
|
|
5051
5116
|
...avsLayoutProp === "row" && (0, import_shared5.isAVSFieldVisible)(avsConfig.postal_code, cc) ? { borderRadius: "0", borderTopLeftRadius: resolvedBorderRadius, borderBottomLeftRadius: resolvedBorderRadius, borderRight: "none" } : { borderRadius: resolvedBorderRadius }
|
|
5052
|
-
}, children: /* @__PURE__ */ (0,
|
|
5117
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5053
5118
|
"select",
|
|
5054
5119
|
{
|
|
5055
5120
|
id: "flopay-billing-country",
|
|
@@ -5066,20 +5131,20 @@ function SplitCardFormInner({
|
|
|
5066
5131
|
autoComplete: "billing country",
|
|
5067
5132
|
"data-testid": "flopay-country",
|
|
5068
5133
|
style: { ...inputFieldStyle(), cursor: "pointer" },
|
|
5069
|
-
children: import_shared5.COUNTRY_OPTIONS.map((c) => /* @__PURE__ */ (0,
|
|
5134
|
+
children: import_shared5.COUNTRY_OPTIONS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("option", { value: c.code, children: [
|
|
5070
5135
|
c.flag,
|
|
5071
5136
|
" ",
|
|
5072
5137
|
c.name
|
|
5073
5138
|
] }, c.code))
|
|
5074
5139
|
}
|
|
5075
5140
|
) }),
|
|
5076
|
-
(0, import_shared5.isAVSFieldVisible)(avsConfig.postal_code, cc) && /* @__PURE__ */ (0,
|
|
5141
|
+
(0, import_shared5.isAVSFieldVisible)(avsConfig.postal_code, cc) && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
5077
5142
|
flex: avsLayoutProp === "row" ? 1 : void 0,
|
|
5078
5143
|
backgroundColor: cardInputBg,
|
|
5079
5144
|
border: `1px solid ${zipBorderColor}`,
|
|
5080
5145
|
padding: "10px",
|
|
5081
5146
|
...avsLayoutProp === "row" && (0, import_shared5.isAVSFieldVisible)(avsConfig.country, cc) ? { borderRadius: "0", borderTopRightRadius: resolvedBorderRadius, borderBottomRightRadius: resolvedBorderRadius } : { borderRadius: resolvedBorderRadius }
|
|
5082
|
-
}, children: /* @__PURE__ */ (0,
|
|
5147
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5083
5148
|
"input",
|
|
5084
5149
|
{
|
|
5085
5150
|
className: "flopay-shared-input",
|
|
@@ -5103,7 +5168,7 @@ function SplitCardFormInner({
|
|
|
5103
5168
|
}
|
|
5104
5169
|
) })
|
|
5105
5170
|
] }),
|
|
5106
|
-
showPostcodeError && /* @__PURE__ */ (0,
|
|
5171
|
+
showPostcodeError && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5107
5172
|
"div",
|
|
5108
5173
|
{
|
|
5109
5174
|
id: "flopay-billing-postal-code-error",
|
|
@@ -5120,26 +5185,10 @@ function SplitCardFormInner({
|
|
|
5120
5185
|
)
|
|
5121
5186
|
] });
|
|
5122
5187
|
})() }),
|
|
5123
|
-
vaultActive && cardPreFormSlot && /* @__PURE__ */ (0,
|
|
5188
|
+
vaultActive && cardPreFormSlot && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { order: -2, width: "100%" }, children: cardPreFormSlot }),
|
|
5124
5189
|
vaultActive && vaultCardFieldsNode,
|
|
5125
|
-
displayError && /* @__PURE__ */ (0,
|
|
5126
|
-
|
|
5127
|
-
padding: "0.625rem 0.875rem",
|
|
5128
|
-
background: "#FEF2F2",
|
|
5129
|
-
border: "1px solid #FECACA",
|
|
5130
|
-
borderRadius: "8px",
|
|
5131
|
-
color: "#991B1B",
|
|
5132
|
-
fontSize: "0.85rem",
|
|
5133
|
-
fontWeight: 600,
|
|
5134
|
-
display: "flex",
|
|
5135
|
-
alignItems: "center",
|
|
5136
|
-
gap: "0.5rem",
|
|
5137
|
-
...bStyles.errorBanner ? bStyles.errorBanner : {}
|
|
5138
|
-
}, children: [
|
|
5139
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z", stroke: "#DC2626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }),
|
|
5140
|
-
displayError
|
|
5141
|
-
] }),
|
|
5142
|
-
!vaultActive && (children ?? /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
5190
|
+
displayError && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ErrorBanner, { margin: "0.75rem 0", styleOverride: bStyles.errorBanner, children: displayError }),
|
|
5191
|
+
!vaultActive && (children ?? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5143
5192
|
"button",
|
|
5144
5193
|
{
|
|
5145
5194
|
type: "submit",
|
|
@@ -5184,9 +5233,9 @@ function SplitCardFormInner({
|
|
|
5184
5233
|
const renderDirectPaypalGateDebug = (testId) => {
|
|
5185
5234
|
if (!debug) return null;
|
|
5186
5235
|
if (!showPayPal || !directPaypalConfigured) {
|
|
5187
|
-
return /* @__PURE__ */ (0,
|
|
5236
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("pre", { "data-testid": testId, style: gateDebugStyle, children: "FloPay/DirectPayPal-debug - not enabled" });
|
|
5188
5237
|
}
|
|
5189
|
-
return /* @__PURE__ */ (0,
|
|
5238
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("pre", { "data-testid": testId, style: gateDebugStyle, children: [
|
|
5190
5239
|
"FloPay/DirectPayPal-debug (parent gate)",
|
|
5191
5240
|
` showPayPal=${showPayPal}`,
|
|
5192
5241
|
` directPaypalConfigured=${directPaypalConfigured}`,
|
|
@@ -5199,9 +5248,9 @@ function SplitCardFormInner({
|
|
|
5199
5248
|
const renderStripeGateDebug = (testId) => {
|
|
5200
5249
|
if (!debug) return null;
|
|
5201
5250
|
if (!showStripe || !stripeInstance) {
|
|
5202
|
-
return /* @__PURE__ */ (0,
|
|
5251
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("pre", { "data-testid": testId, style: gateDebugStyle, children: "FloPay/Stripe-debug - not enabled" });
|
|
5203
5252
|
}
|
|
5204
|
-
return /* @__PURE__ */ (0,
|
|
5253
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("pre", { "data-testid": testId, style: gateDebugStyle, children: [
|
|
5205
5254
|
"FloPay/Stripe-debug (parent gate)",
|
|
5206
5255
|
` showStripe=${showStripe}`,
|
|
5207
5256
|
` currency=${currency}`,
|
|
@@ -5230,11 +5279,11 @@ function SplitCardFormInner({
|
|
|
5230
5279
|
const cardButtonSizing = cardButtonContent === void 0 ? { boxSizing: "border-box", height: DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT, padding: "0 1rem" } : { padding: "0.9rem 1rem" };
|
|
5231
5280
|
const buttonsAnim = viewState === "expanding" || viewState === "apm-expanding" ? `flopay-buttons-exit ${TRANSITION_MS}ms cubic-bezier(0.4, 0, 0.2, 1) both` : viewState === "collapsing" || viewState === "apm-collapsing" ? `flopay-buttons-enter ${TRANSITION_MS}ms cubic-bezier(0, 0, 0.2, 1) both` : void 0;
|
|
5232
5281
|
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;
|
|
5233
|
-
return /* @__PURE__ */ (0,
|
|
5234
|
-
/* @__PURE__ */ (0,
|
|
5235
|
-
overlayStatus && /* @__PURE__ */ (0,
|
|
5236
|
-
/* @__PURE__ */ (0,
|
|
5237
|
-
/* @__PURE__ */ (0,
|
|
5282
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
|
|
5283
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloPayKeyframes, {}),
|
|
5284
|
+
overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
|
|
5285
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { display: "grid" }, children: [
|
|
5286
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
5238
5287
|
"div",
|
|
5239
5288
|
{
|
|
5240
5289
|
"data-testid": "flopay-buttons-panel",
|
|
@@ -5251,8 +5300,8 @@ function SplitCardFormInner({
|
|
|
5251
5300
|
children: [
|
|
5252
5301
|
renderDirectPaypalGateDebug("flopay-direct-paypal-gate-debug"),
|
|
5253
5302
|
renderStripeGateDebug("flopay-stripe-gate-debug"),
|
|
5254
|
-
shouldRenderDirectPayPal && directPaypal && /* @__PURE__ */ (0,
|
|
5255
|
-
paypalDirectRetry && /* @__PURE__ */ (0,
|
|
5303
|
+
shouldRenderDirectPayPal && directPaypal && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
5304
|
+
paypalDirectRetry && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5256
5305
|
"div",
|
|
5257
5306
|
{
|
|
5258
5307
|
"data-testid": "flopay-paypal-direct-retry-notice",
|
|
@@ -5268,7 +5317,7 @@ function SplitCardFormInner({
|
|
|
5268
5317
|
children: "Please confirm your PayPal payment to complete checkout."
|
|
5269
5318
|
}
|
|
5270
5319
|
),
|
|
5271
|
-
/* @__PURE__ */ (0,
|
|
5320
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5272
5321
|
DirectPayPalButton,
|
|
5273
5322
|
{
|
|
5274
5323
|
sessionId,
|
|
@@ -5295,7 +5344,7 @@ function SplitCardFormInner({
|
|
|
5295
5344
|
paypalDirectRetry?.orderId ?? "fresh"
|
|
5296
5345
|
)
|
|
5297
5346
|
] }),
|
|
5298
|
-
shouldRenderStripePayPal && /* @__PURE__ */ (0,
|
|
5347
|
+
shouldRenderStripePayPal && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_stripe_js.Elements, { stripe: paypalStripeInstance, options: paypalOptions, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5299
5348
|
PayPalButtonInner,
|
|
5300
5349
|
{
|
|
5301
5350
|
sessionId,
|
|
@@ -5313,7 +5362,7 @@ function SplitCardFormInner({
|
|
|
5313
5362
|
placeholderBorderRadius: buttonBorderRadius
|
|
5314
5363
|
}
|
|
5315
5364
|
) }),
|
|
5316
|
-
shouldRenderWallets ? /* @__PURE__ */ (0,
|
|
5365
|
+
shouldRenderWallets ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5317
5366
|
WalletButtonInner,
|
|
5318
5367
|
{
|
|
5319
5368
|
sessionId,
|
|
@@ -5330,8 +5379,8 @@ function SplitCardFormInner({
|
|
|
5330
5379
|
onLoadStateChange: setWalletLoadState,
|
|
5331
5380
|
placeholderBorderRadius: buttonBorderRadius
|
|
5332
5381
|
}
|
|
5333
|
-
) }) : shouldShowWallets ? /* @__PURE__ */ (0,
|
|
5334
|
-
shouldRenderPaymentElement && /* @__PURE__ */ (0,
|
|
5382
|
+
) }) : shouldShowWallets ? /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { height: DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT, borderRadius: buttonBorderRadius, background: "#e5e7eb", animation: "flopay-pulse 1.5s ease-in-out infinite" } }) : null,
|
|
5383
|
+
shouldRenderPaymentElement && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5335
5384
|
StripePaymentElementInner,
|
|
5336
5385
|
{
|
|
5337
5386
|
sessionId,
|
|
@@ -5363,7 +5412,7 @@ function SplitCardFormInner({
|
|
|
5363
5412
|
}
|
|
5364
5413
|
}
|
|
5365
5414
|
),
|
|
5366
|
-
showStripe && /* @__PURE__ */ (0,
|
|
5415
|
+
showStripe && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5367
5416
|
"button",
|
|
5368
5417
|
{
|
|
5369
5418
|
type: "button",
|
|
@@ -5419,50 +5468,34 @@ function SplitCardFormInner({
|
|
|
5419
5468
|
onMouseUp: (e) => {
|
|
5420
5469
|
e.currentTarget.style.transform = "scale(1)";
|
|
5421
5470
|
},
|
|
5422
|
-
children: /* @__PURE__ */ (0,
|
|
5471
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(CardButtonContentSlot, { content: cardButtonContent })
|
|
5423
5472
|
}
|
|
5424
5473
|
),
|
|
5425
|
-
displayError && viewState === "buttons" && /* @__PURE__ */ (0,
|
|
5426
|
-
margin: "0.25rem 0",
|
|
5427
|
-
padding: "0.625rem 0.875rem",
|
|
5428
|
-
background: "#FEF2F2",
|
|
5429
|
-
border: "1px solid #FECACA",
|
|
5430
|
-
borderRadius: "8px",
|
|
5431
|
-
color: "#991B1B",
|
|
5432
|
-
fontSize: "0.85rem",
|
|
5433
|
-
fontWeight: 600,
|
|
5434
|
-
display: "flex",
|
|
5435
|
-
alignItems: "center",
|
|
5436
|
-
gap: "0.5rem",
|
|
5437
|
-
...bStyles.errorBanner ? bStyles.errorBanner : {}
|
|
5438
|
-
}, children: [
|
|
5439
|
-
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("path", { d: "M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z", stroke: "#DC2626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }),
|
|
5440
|
-
displayError
|
|
5441
|
-
] })
|
|
5474
|
+
displayError && viewState === "buttons" && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ErrorBanner, { margin: "0.25rem 0", styleOverride: bStyles.errorBanner, children: displayError })
|
|
5442
5475
|
]
|
|
5443
5476
|
}
|
|
5444
5477
|
),
|
|
5445
|
-
showStripe && isCardView && /* @__PURE__ */ (0,
|
|
5478
|
+
showStripe && isCardView && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
5446
5479
|
gridArea: "1 / 1",
|
|
5447
5480
|
...cardAnim ? { animation: cardAnim } : {},
|
|
5448
5481
|
...viewState === "collapsing" ? { pointerEvents: "none" } : {}
|
|
5449
5482
|
}, children: cardFormBlock }),
|
|
5450
|
-
showStripe && isApmView && expandedApmMethod && apmInlineOptions && stripeInstance && /* @__PURE__ */ (0,
|
|
5483
|
+
showStripe && isApmView && expandedApmMethod && apmInlineOptions && stripeInstance && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
5451
5484
|
gridArea: "1 / 1",
|
|
5452
5485
|
...apmAnim ? { animation: apmAnim } : {},
|
|
5453
5486
|
...viewState === "apm-collapsing" ? { pointerEvents: "none" } : {}
|
|
5454
|
-
}, children: /* @__PURE__ */ (0,
|
|
5487
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: {
|
|
5455
5488
|
backgroundColor: cardBg,
|
|
5456
5489
|
borderRadius: containerRadius,
|
|
5457
5490
|
...containerOverrides,
|
|
5458
5491
|
padding: containerPadding
|
|
5459
5492
|
}, children: [
|
|
5460
|
-
/* @__PURE__ */ (0,
|
|
5493
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: {
|
|
5461
5494
|
display: "flex",
|
|
5462
5495
|
alignItems: "center",
|
|
5463
5496
|
padding: "0.75rem 0 0.625rem"
|
|
5464
5497
|
}, children: [
|
|
5465
|
-
/* @__PURE__ */ (0,
|
|
5498
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
5466
5499
|
"button",
|
|
5467
5500
|
{
|
|
5468
5501
|
type: "button",
|
|
@@ -5485,7 +5518,7 @@ function SplitCardFormInner({
|
|
|
5485
5518
|
},
|
|
5486
5519
|
"aria-label": "Back to payment methods",
|
|
5487
5520
|
children: [
|
|
5488
|
-
/* @__PURE__ */ (0,
|
|
5521
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: {
|
|
5489
5522
|
display: "inline-flex",
|
|
5490
5523
|
alignItems: "center",
|
|
5491
5524
|
justifyContent: "center",
|
|
@@ -5495,12 +5528,12 @@ function SplitCardFormInner({
|
|
|
5495
5528
|
backgroundColor: "#f3f4f6",
|
|
5496
5529
|
transition: "background-color 0.15s",
|
|
5497
5530
|
...bStyles.backButtonIcon
|
|
5498
|
-
}, children: /* @__PURE__ */ (0,
|
|
5499
|
-
/* @__PURE__ */ (0,
|
|
5531
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.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_runtime8.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
|
|
5532
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
|
|
5500
5533
|
]
|
|
5501
5534
|
}
|
|
5502
5535
|
),
|
|
5503
|
-
/* @__PURE__ */ (0,
|
|
5536
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
5504
5537
|
flex: 1,
|
|
5505
5538
|
textAlign: "center",
|
|
5506
5539
|
fontWeight: 600,
|
|
@@ -5510,12 +5543,12 @@ function SplitCardFormInner({
|
|
|
5510
5543
|
...bStyles.title
|
|
5511
5544
|
}, children: `Pay with ${(0, import_shared5.getStripeMethodDisplayName)(expandedApmMethod)}` })
|
|
5512
5545
|
] }),
|
|
5513
|
-
/* @__PURE__ */ (0,
|
|
5546
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5514
5547
|
import_react_stripe_js.Elements,
|
|
5515
5548
|
{
|
|
5516
5549
|
stripe: stripeInstance,
|
|
5517
5550
|
options: apmInlineOptions,
|
|
5518
|
-
children: /* @__PURE__ */ (0,
|
|
5551
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5519
5552
|
StripeMethodInlineForm,
|
|
5520
5553
|
{
|
|
5521
5554
|
method: expandedApmMethod,
|
|
@@ -5545,24 +5578,24 @@ function SplitCardFormInner({
|
|
|
5545
5578
|
] });
|
|
5546
5579
|
}
|
|
5547
5580
|
if (isApmView && expandedApmMethod && apmInlineOptions && stripeInstance && showStripe) {
|
|
5548
|
-
return /* @__PURE__ */ (0,
|
|
5549
|
-
/* @__PURE__ */ (0,
|
|
5550
|
-
overlayStatus && /* @__PURE__ */ (0,
|
|
5551
|
-
/* @__PURE__ */ (0,
|
|
5581
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
|
|
5582
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloPayKeyframes, {}),
|
|
5583
|
+
overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
|
|
5584
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
5552
5585
|
...apmAnim ? { animation: apmAnim } : {},
|
|
5553
5586
|
...viewState === "apm-collapsing" ? { pointerEvents: "none" } : {}
|
|
5554
|
-
}, children: /* @__PURE__ */ (0,
|
|
5587
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: {
|
|
5555
5588
|
backgroundColor: cardBg,
|
|
5556
5589
|
borderRadius: containerRadius,
|
|
5557
5590
|
...containerOverrides,
|
|
5558
5591
|
padding: containerPadding
|
|
5559
5592
|
}, children: [
|
|
5560
|
-
/* @__PURE__ */ (0,
|
|
5593
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: {
|
|
5561
5594
|
display: "flex",
|
|
5562
5595
|
alignItems: "center",
|
|
5563
5596
|
padding: "0.75rem 0 0.625rem"
|
|
5564
5597
|
}, children: [
|
|
5565
|
-
/* @__PURE__ */ (0,
|
|
5598
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(
|
|
5566
5599
|
"button",
|
|
5567
5600
|
{
|
|
5568
5601
|
type: "button",
|
|
@@ -5585,7 +5618,7 @@ function SplitCardFormInner({
|
|
|
5585
5618
|
},
|
|
5586
5619
|
"aria-label": "Back to payment methods",
|
|
5587
5620
|
children: [
|
|
5588
|
-
/* @__PURE__ */ (0,
|
|
5621
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { style: {
|
|
5589
5622
|
display: "inline-flex",
|
|
5590
5623
|
alignItems: "center",
|
|
5591
5624
|
justifyContent: "center",
|
|
@@ -5595,12 +5628,12 @@ function SplitCardFormInner({
|
|
|
5595
5628
|
backgroundColor: "#f3f4f6",
|
|
5596
5629
|
transition: "background-color 0.15s",
|
|
5597
5630
|
...bStyles.backButtonIcon
|
|
5598
|
-
}, children: /* @__PURE__ */ (0,
|
|
5599
|
-
/* @__PURE__ */ (0,
|
|
5631
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime8.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_runtime8.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
|
|
5632
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
|
|
5600
5633
|
]
|
|
5601
5634
|
}
|
|
5602
5635
|
),
|
|
5603
|
-
/* @__PURE__ */ (0,
|
|
5636
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: {
|
|
5604
5637
|
flex: 1,
|
|
5605
5638
|
textAlign: "center",
|
|
5606
5639
|
fontWeight: 600,
|
|
@@ -5610,12 +5643,12 @@ function SplitCardFormInner({
|
|
|
5610
5643
|
...bStyles.title
|
|
5611
5644
|
}, children: `Pay with ${(0, import_shared5.getStripeMethodDisplayName)(expandedApmMethod)}` })
|
|
5612
5645
|
] }),
|
|
5613
|
-
/* @__PURE__ */ (0,
|
|
5646
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5614
5647
|
import_react_stripe_js.Elements,
|
|
5615
5648
|
{
|
|
5616
5649
|
stripe: stripeInstance,
|
|
5617
5650
|
options: apmInlineOptions,
|
|
5618
|
-
children: /* @__PURE__ */ (0,
|
|
5651
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5619
5652
|
StripeMethodInlineForm,
|
|
5620
5653
|
{
|
|
5621
5654
|
method: expandedApmMethod,
|
|
@@ -5643,14 +5676,14 @@ function SplitCardFormInner({
|
|
|
5643
5676
|
] }) })
|
|
5644
5677
|
] });
|
|
5645
5678
|
}
|
|
5646
|
-
return /* @__PURE__ */ (0,
|
|
5647
|
-
/* @__PURE__ */ (0,
|
|
5648
|
-
overlayStatus && /* @__PURE__ */ (0,
|
|
5649
|
-
/* @__PURE__ */ (0,
|
|
5679
|
+
return /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
|
|
5680
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(FloPayKeyframes, {}),
|
|
5681
|
+
overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
|
|
5682
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
|
|
5650
5683
|
renderDirectPaypalGateDebug("flopay-direct-paypal-gate-debug-default"),
|
|
5651
5684
|
renderStripeGateDebug("flopay-stripe-gate-debug-default"),
|
|
5652
|
-
shouldRenderDirectPayPal && directPaypal && /* @__PURE__ */ (0,
|
|
5653
|
-
paypalDirectRetry && /* @__PURE__ */ (0,
|
|
5685
|
+
shouldRenderDirectPayPal && directPaypal && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)(import_jsx_runtime8.Fragment, { children: [
|
|
5686
|
+
paypalDirectRetry && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5654
5687
|
"div",
|
|
5655
5688
|
{
|
|
5656
5689
|
"data-testid": "flopay-paypal-direct-retry-notice-default",
|
|
@@ -5666,7 +5699,7 @@ function SplitCardFormInner({
|
|
|
5666
5699
|
children: "Please confirm your PayPal payment to complete checkout."
|
|
5667
5700
|
}
|
|
5668
5701
|
),
|
|
5669
|
-
/* @__PURE__ */ (0,
|
|
5702
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5670
5703
|
DirectPayPalButton,
|
|
5671
5704
|
{
|
|
5672
5705
|
sessionId,
|
|
@@ -5693,7 +5726,7 @@ function SplitCardFormInner({
|
|
|
5693
5726
|
paypalDirectRetry?.orderId ?? "fresh"
|
|
5694
5727
|
)
|
|
5695
5728
|
] }),
|
|
5696
|
-
shouldRenderStripePayPal && /* @__PURE__ */ (0,
|
|
5729
|
+
shouldRenderStripePayPal && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_stripe_js.Elements, { stripe: paypalStripeInstance, options: paypalOptions, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5697
5730
|
PayPalButtonInner,
|
|
5698
5731
|
{
|
|
5699
5732
|
sessionId,
|
|
@@ -5711,7 +5744,7 @@ function SplitCardFormInner({
|
|
|
5711
5744
|
placeholderBorderRadius: buttonBorderRadius
|
|
5712
5745
|
}
|
|
5713
5746
|
) }),
|
|
5714
|
-
shouldRenderWallets && /* @__PURE__ */ (0,
|
|
5747
|
+
shouldRenderWallets && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5715
5748
|
WalletButtonInner,
|
|
5716
5749
|
{
|
|
5717
5750
|
sessionId,
|
|
@@ -5729,7 +5762,7 @@ function SplitCardFormInner({
|
|
|
5729
5762
|
placeholderBorderRadius: buttonBorderRadius
|
|
5730
5763
|
}
|
|
5731
5764
|
) }),
|
|
5732
|
-
shouldRenderPaymentElement && /* @__PURE__ */ (0,
|
|
5765
|
+
shouldRenderPaymentElement && /* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
5733
5766
|
StripePaymentElementInner,
|
|
5734
5767
|
{
|
|
5735
5768
|
sessionId,
|
|
@@ -5762,7 +5795,7 @@ function SplitCardFormInner({
|
|
|
5762
5795
|
}
|
|
5763
5796
|
)
|
|
5764
5797
|
] }),
|
|
5765
|
-
showStripe && (shouldDisplayWalletRow || shouldDisplayPayPalRow || shouldDisplayPaymentElementRow) && /* @__PURE__ */ (0,
|
|
5798
|
+
showStripe && (shouldDisplayWalletRow || shouldDisplayPayPalRow || shouldDisplayPaymentElementRow) && /* @__PURE__ */ (0, import_jsx_runtime8.jsxs)("div", { style: {
|
|
5766
5799
|
display: "flex",
|
|
5767
5800
|
alignItems: "center",
|
|
5768
5801
|
gap: "0.75rem",
|
|
@@ -5770,9 +5803,9 @@ function SplitCardFormInner({
|
|
|
5770
5803
|
color: "#999",
|
|
5771
5804
|
fontSize: "0.85rem"
|
|
5772
5805
|
}, children: [
|
|
5773
|
-
/* @__PURE__ */ (0,
|
|
5774
|
-
/* @__PURE__ */ (0,
|
|
5775
|
-
/* @__PURE__ */ (0,
|
|
5806
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } }),
|
|
5807
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("span", { children: "or pay with card" }),
|
|
5808
|
+
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } })
|
|
5776
5809
|
] }),
|
|
5777
5810
|
showStripe && cardFormBlock
|
|
5778
5811
|
] });
|
|
@@ -5802,6 +5835,9 @@ async function confirmResumeIntent(stripe, clientSecret, data, isSetupIntent) {
|
|
|
5802
5835
|
const { paymentIntent, error } = await stripe.confirmCardPayment(clientSecret, data);
|
|
5803
5836
|
return { error, intent: paymentIntent ?? null };
|
|
5804
5837
|
}
|
|
5838
|
+
function withCheckoutMethod(error, checkoutMethod) {
|
|
5839
|
+
return Object.assign(error, { checkoutMethod });
|
|
5840
|
+
}
|
|
5805
5841
|
function getRedirectResultFromCheckoutProcessError(error) {
|
|
5806
5842
|
if (!error?.type || !error.threeDSecureToken) {
|
|
5807
5843
|
return null;
|
|
@@ -6023,7 +6059,7 @@ function checkoutProcessErrorToFloPayError(error, fallbackMessage = "Payment fai
|
|
|
6023
6059
|
const checkoutMethod = options?.checkoutMethod ?? error?.checkoutMethod ?? (error?.type === "paypal_redirect_required" ? "paypal" : "card");
|
|
6024
6060
|
const rawMessage = error?.message ?? fallbackMessage;
|
|
6025
6061
|
const message = applyFriendlyMessageOverride(rawMessage) ?? rawMessage;
|
|
6026
|
-
return
|
|
6062
|
+
return withCheckoutMethod(
|
|
6027
6063
|
new import_shared7.FloPayError(
|
|
6028
6064
|
message,
|
|
6029
6065
|
"api_error",
|
|
@@ -6031,7 +6067,7 @@ function checkoutProcessErrorToFloPayError(error, fallbackMessage = "Payment fai
|
|
|
6031
6067
|
code: error?.gatewayErrorCode
|
|
6032
6068
|
}
|
|
6033
6069
|
),
|
|
6034
|
-
|
|
6070
|
+
checkoutMethod
|
|
6035
6071
|
);
|
|
6036
6072
|
}
|
|
6037
6073
|
function resolveSavedPaymentReturnUrl(session) {
|
|
@@ -6203,13 +6239,13 @@ async function processSavedPaymentForMode({
|
|
|
6203
6239
|
if (recoveredRedirect) {
|
|
6204
6240
|
return recoveredRedirect;
|
|
6205
6241
|
}
|
|
6206
|
-
throw
|
|
6242
|
+
throw withCheckoutMethod(
|
|
6207
6243
|
new import_shared7.FloPayError(
|
|
6208
6244
|
"Your card requires authentication. Please enter your payment details below.",
|
|
6209
6245
|
"api_error",
|
|
6210
6246
|
{ code: "authentication_required" }
|
|
6211
6247
|
),
|
|
6212
|
-
|
|
6248
|
+
"card"
|
|
6213
6249
|
);
|
|
6214
6250
|
}
|
|
6215
6251
|
throw new import_shared7.FloPayError(
|
|
@@ -6237,13 +6273,13 @@ async function handleSavedPaymentRedirectResult(redirectResult, {
|
|
|
6237
6273
|
}
|
|
6238
6274
|
if (redirectResult.type === "3ds_required") {
|
|
6239
6275
|
if (!attempt3DS || !redirectResult.threeDSecureToken) {
|
|
6240
|
-
throw
|
|
6276
|
+
throw withCheckoutMethod(
|
|
6241
6277
|
new import_shared7.FloPayError(
|
|
6242
6278
|
"Your card requires authentication. Please enter your payment details below.",
|
|
6243
6279
|
"api_error",
|
|
6244
6280
|
{ code: "authentication_required" }
|
|
6245
6281
|
),
|
|
6246
|
-
|
|
6282
|
+
"card"
|
|
6247
6283
|
);
|
|
6248
6284
|
}
|
|
6249
6285
|
const isSetupIntent = (0, import_shared7.isSetupIntentClientSecret)(redirectResult.threeDSecureToken);
|
|
@@ -6252,13 +6288,13 @@ async function handleSavedPaymentRedirectResult(redirectResult, {
|
|
|
6252
6288
|
const retrieved = await retrieveResumeIntent(stripe, redirectResult.threeDSecureToken, isSetupIntent);
|
|
6253
6289
|
if (retrieved) {
|
|
6254
6290
|
if (retrieved.error) {
|
|
6255
|
-
throw
|
|
6291
|
+
throw withCheckoutMethod(
|
|
6256
6292
|
new import_shared7.FloPayError(
|
|
6257
6293
|
retrieved.error.message ?? `Failed to retrieve 3DS ${isSetupIntent ? "setup" : "payment"} status.`,
|
|
6258
6294
|
"api_error",
|
|
6259
6295
|
{ code: retrieved.error.code }
|
|
6260
6296
|
),
|
|
6261
|
-
|
|
6297
|
+
"card"
|
|
6262
6298
|
);
|
|
6263
6299
|
}
|
|
6264
6300
|
const existingIntent = retrieved.intent;
|
|
@@ -6281,13 +6317,13 @@ async function handleSavedPaymentRedirectResult(redirectResult, {
|
|
|
6281
6317
|
) : null;
|
|
6282
6318
|
if (confirmed) {
|
|
6283
6319
|
if (confirmed.error) {
|
|
6284
|
-
throw
|
|
6320
|
+
throw withCheckoutMethod(
|
|
6285
6321
|
new import_shared7.FloPayError(
|
|
6286
6322
|
confirmed.error.message ?? "3DS authentication failed.",
|
|
6287
6323
|
"api_error",
|
|
6288
6324
|
{ code: confirmed.error.code }
|
|
6289
6325
|
),
|
|
6290
|
-
|
|
6326
|
+
"card"
|
|
6291
6327
|
);
|
|
6292
6328
|
}
|
|
6293
6329
|
paymentIntent = confirmed.intent;
|
|
@@ -6296,13 +6332,13 @@ async function handleSavedPaymentRedirectResult(redirectResult, {
|
|
|
6296
6332
|
clientSecret: redirectResult.threeDSecureToken
|
|
6297
6333
|
});
|
|
6298
6334
|
if (nextAction.error) {
|
|
6299
|
-
throw
|
|
6335
|
+
throw withCheckoutMethod(
|
|
6300
6336
|
new import_shared7.FloPayError(
|
|
6301
6337
|
nextAction.error.message ?? "3DS authentication failed.",
|
|
6302
6338
|
"api_error",
|
|
6303
6339
|
{ code: nextAction.error.code }
|
|
6304
6340
|
),
|
|
6305
|
-
|
|
6341
|
+
"card"
|
|
6306
6342
|
);
|
|
6307
6343
|
}
|
|
6308
6344
|
paymentIntent = (isSetupIntent ? nextAction.setupIntent : nextAction.paymentIntent) ?? null;
|
|
@@ -6338,17 +6374,17 @@ async function handleSavedPaymentRedirectResult(redirectResult, {
|
|
|
6338
6374
|
telemetry
|
|
6339
6375
|
});
|
|
6340
6376
|
}
|
|
6341
|
-
throw
|
|
6377
|
+
throw withCheckoutMethod(
|
|
6342
6378
|
new import_shared7.FloPayError("3DS authentication did not complete successfully.", "api_error"),
|
|
6343
|
-
|
|
6379
|
+
"card"
|
|
6344
6380
|
);
|
|
6345
6381
|
}
|
|
6346
6382
|
if (redirectResult.type === "paypal_redirect_required") {
|
|
6347
6383
|
const paypalStripe = (paypalFlopay ?? flopay)?.getRawProvider();
|
|
6348
6384
|
if (!paypalStripe) {
|
|
6349
|
-
throw
|
|
6385
|
+
throw withCheckoutMethod(
|
|
6350
6386
|
new import_shared7.FloPayError("PayPal is not available.", "api_error"),
|
|
6351
|
-
|
|
6387
|
+
"paypal"
|
|
6352
6388
|
);
|
|
6353
6389
|
}
|
|
6354
6390
|
if (redirectResult.paymentMethodId) {
|
|
@@ -6356,13 +6392,13 @@ async function handleSavedPaymentRedirectResult(redirectResult, {
|
|
|
6356
6392
|
clientSecret: redirectResult.threeDSecureToken
|
|
6357
6393
|
});
|
|
6358
6394
|
if (error2) {
|
|
6359
|
-
throw
|
|
6395
|
+
throw withCheckoutMethod(
|
|
6360
6396
|
new import_shared7.FloPayError(
|
|
6361
6397
|
error2.message ?? "PayPal authorization failed.",
|
|
6362
6398
|
"api_error",
|
|
6363
6399
|
{ code: error2.code }
|
|
6364
6400
|
),
|
|
6365
|
-
|
|
6401
|
+
"paypal"
|
|
6366
6402
|
);
|
|
6367
6403
|
}
|
|
6368
6404
|
return {
|
|
@@ -6379,13 +6415,13 @@ async function handleSavedPaymentRedirectResult(redirectResult, {
|
|
|
6379
6415
|
redirect: "if_required"
|
|
6380
6416
|
});
|
|
6381
6417
|
if (error) {
|
|
6382
|
-
throw
|
|
6418
|
+
throw withCheckoutMethod(
|
|
6383
6419
|
new import_shared7.FloPayError(
|
|
6384
6420
|
error.message ?? "PayPal authorization failed.",
|
|
6385
6421
|
"api_error",
|
|
6386
6422
|
{ code: error.code }
|
|
6387
6423
|
),
|
|
6388
|
-
|
|
6424
|
+
"paypal"
|
|
6389
6425
|
);
|
|
6390
6426
|
}
|
|
6391
6427
|
return {
|
|
@@ -6470,7 +6506,7 @@ async function loadSavedPaymentProviders({
|
|
|
6470
6506
|
}
|
|
6471
6507
|
|
|
6472
6508
|
// src/flopay-checkout.tsx
|
|
6473
|
-
var
|
|
6509
|
+
var import_jsx_runtime9 = require("react/jsx-runtime");
|
|
6474
6510
|
var DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2 = 44;
|
|
6475
6511
|
var PAYPAL_RESUME_STORAGE_KEY = "flopay_checkout_saved_payment_resume";
|
|
6476
6512
|
var sessionInflightMap = /* @__PURE__ */ new Map();
|
|
@@ -6648,51 +6684,51 @@ function FloPayCheckout({
|
|
|
6648
6684
|
onSessionCompleted
|
|
6649
6685
|
}) {
|
|
6650
6686
|
const resolvedBillingUrl = (0, import_shared8.resolveBillingApiUrl)(billingApiUrl);
|
|
6651
|
-
const themeBundle = (0,
|
|
6687
|
+
const themeBundle = (0, import_react11.useMemo)(() => (0, import_shared8.resolveTheme)(theme), [theme]);
|
|
6652
6688
|
const appearance = appearanceOverride ?? themeBundle?.appearance;
|
|
6653
6689
|
const checkoutType = createSessionParams ? "embedded_checkout" : "standard_checkout";
|
|
6654
6690
|
const checkoutLayout = children ? "custom_layout" : layout === "buttons" ? "buttons_layout" : "default_layout";
|
|
6655
|
-
const [unified, setUnified] = (0,
|
|
6656
|
-
const [flopay, setFloPay] = (0,
|
|
6657
|
-
const flopayRef = (0,
|
|
6658
|
-
const [paypalFlopay, setPaypalFloPay] = (0,
|
|
6659
|
-
const paypalFlopayRef = (0,
|
|
6660
|
-
const [session, setSession] = (0,
|
|
6661
|
-
const [resolvedSessionId, setResolvedSessionId] = (0,
|
|
6691
|
+
const [unified, setUnified] = (0, import_react11.useState)(null);
|
|
6692
|
+
const [flopay, setFloPay] = (0, import_react11.useState)(null);
|
|
6693
|
+
const flopayRef = (0, import_react11.useRef)(null);
|
|
6694
|
+
const [paypalFlopay, setPaypalFloPay] = (0, import_react11.useState)(null);
|
|
6695
|
+
const paypalFlopayRef = (0, import_react11.useRef)(null);
|
|
6696
|
+
const [session, setSession] = (0, import_react11.useState)(null);
|
|
6697
|
+
const [resolvedSessionId, setResolvedSessionId] = (0, import_react11.useState)(sessionIdProp ?? "");
|
|
6662
6698
|
const activeSessionId = sessionIdProp ?? resolvedSessionId;
|
|
6663
6699
|
const initSessionDependency = createSessionParams ? "" : activeSessionId;
|
|
6664
|
-
const [isLoading, setIsLoading] = (0,
|
|
6665
|
-
const [loadError, setLoadError] = (0,
|
|
6666
|
-
const [currentMode, setCurrentMode] = (0,
|
|
6667
|
-
const [confirmProcessing, setConfirmProcessing] = (0,
|
|
6668
|
-
const [modeError, setModeError] = (0,
|
|
6669
|
-
const [modeOverlayStatus, setModeOverlayStatus] = (0,
|
|
6670
|
-
const [modeOverlayError, setModeOverlayError] = (0,
|
|
6671
|
-
const [createSessionPatch, setCreateSessionPatch] = (0,
|
|
6672
|
-
const [createSessionPatchBaseHash, setCreateSessionPatchBaseHash] = (0,
|
|
6673
|
-
const [cardBootstrapPending, setCardBootstrapPending] = (0,
|
|
6674
|
-
const autoCheckoutAttempted = (0,
|
|
6675
|
-
const paypalResumeAttempted = (0,
|
|
6676
|
-
const savedPaymentKeysRef = (0,
|
|
6677
|
-
const telemetryCheckoutContext = (0,
|
|
6700
|
+
const [isLoading, setIsLoading] = (0, import_react11.useState)(true);
|
|
6701
|
+
const [loadError, setLoadError] = (0, import_react11.useState)(null);
|
|
6702
|
+
const [currentMode, setCurrentMode] = (0, import_react11.useState)("full");
|
|
6703
|
+
const [confirmProcessing, setConfirmProcessing] = (0, import_react11.useState)(false);
|
|
6704
|
+
const [modeError, setModeError] = (0, import_react11.useState)(initialErrorMessage);
|
|
6705
|
+
const [modeOverlayStatus, setModeOverlayStatus] = (0, import_react11.useState)(null);
|
|
6706
|
+
const [modeOverlayError, setModeOverlayError] = (0, import_react11.useState)(null);
|
|
6707
|
+
const [createSessionPatch, setCreateSessionPatch] = (0, import_react11.useState)(void 0);
|
|
6708
|
+
const [createSessionPatchBaseHash, setCreateSessionPatchBaseHash] = (0, import_react11.useState)("");
|
|
6709
|
+
const [cardBootstrapPending, setCardBootstrapPending] = (0, import_react11.useState)(false);
|
|
6710
|
+
const autoCheckoutAttempted = (0, import_react11.useRef)(false);
|
|
6711
|
+
const paypalResumeAttempted = (0, import_react11.useRef)(false);
|
|
6712
|
+
const savedPaymentKeysRef = (0, import_react11.useRef)(null);
|
|
6713
|
+
const telemetryCheckoutContext = (0, import_react11.useMemo)(() => ({
|
|
6678
6714
|
checkoutMode: checkoutModeProp ?? currentMode,
|
|
6679
6715
|
layout: children ? "unknown" : layout === "buttons" ? "buttons" : "embedded"
|
|
6680
6716
|
}), [checkoutModeProp, children, currentMode, layout]);
|
|
6681
|
-
const onCompleteRef = (0,
|
|
6717
|
+
const onCompleteRef = (0, import_react11.useRef)(onComplete);
|
|
6682
6718
|
onCompleteRef.current = onComplete;
|
|
6683
|
-
const onErrorRef = (0,
|
|
6719
|
+
const onErrorRef = (0, import_react11.useRef)(onError);
|
|
6684
6720
|
onErrorRef.current = onError;
|
|
6685
|
-
const onDeclineRef = (0,
|
|
6721
|
+
const onDeclineRef = (0, import_react11.useRef)(onDecline);
|
|
6686
6722
|
onDeclineRef.current = onDecline;
|
|
6687
|
-
(0,
|
|
6723
|
+
(0, import_react11.useEffect)(() => {
|
|
6688
6724
|
getFloPayTelemetryBridge(flopay)?.setCheckoutContext(telemetryCheckoutContext);
|
|
6689
6725
|
if (paypalFlopay && paypalFlopay !== flopay) {
|
|
6690
6726
|
getFloPayTelemetryBridge(paypalFlopay)?.setCheckoutContext(telemetryCheckoutContext);
|
|
6691
6727
|
}
|
|
6692
6728
|
}, [flopay, paypalFlopay, telemetryCheckoutContext]);
|
|
6693
|
-
const onSessionCompletedRef = (0,
|
|
6729
|
+
const onSessionCompletedRef = (0, import_react11.useRef)(onSessionCompleted);
|
|
6694
6730
|
onSessionCompletedRef.current = onSessionCompleted;
|
|
6695
|
-
(0,
|
|
6731
|
+
(0, import_react11.useEffect)(() => {
|
|
6696
6732
|
console.info("[FloPay] Checkout initialized", {
|
|
6697
6733
|
sdk_version: import_shared8.SDK_VERSION,
|
|
6698
6734
|
checkout_type: checkoutType,
|
|
@@ -6700,34 +6736,34 @@ function FloPayCheckout({
|
|
|
6700
6736
|
billing_api_url: resolvedBillingUrl
|
|
6701
6737
|
});
|
|
6702
6738
|
}, [checkoutLayout, checkoutType, resolvedBillingUrl]);
|
|
6703
|
-
const baseCreateSessionHash = (0,
|
|
6739
|
+
const baseCreateSessionHash = (0, import_react11.useMemo)(
|
|
6704
6740
|
() => createSessionParams ? hashCreateParams(createSessionParams) : "",
|
|
6705
6741
|
[createSessionParams]
|
|
6706
6742
|
);
|
|
6707
|
-
const activeCreateSessionPatch = (0,
|
|
6743
|
+
const activeCreateSessionPatch = (0, import_react11.useMemo)(
|
|
6708
6744
|
() => createSessionPatchBaseHash === baseCreateSessionHash ? createSessionPatch : void 0,
|
|
6709
6745
|
[createSessionPatch, createSessionPatchBaseHash, baseCreateSessionHash]
|
|
6710
6746
|
);
|
|
6711
|
-
const effectiveCreateSessionBase = (0,
|
|
6747
|
+
const effectiveCreateSessionBase = (0, import_react11.useMemo)(
|
|
6712
6748
|
() => createSessionParams ? mergeInlineSessionPatch(createSessionParams, activeCreateSessionPatch) : void 0,
|
|
6713
6749
|
[createSessionParams, activeCreateSessionPatch]
|
|
6714
6750
|
);
|
|
6715
6751
|
const effectiveCreateSessionMode = checkoutModeProp ?? effectiveCreateSessionBase?.checkoutMode ?? "full";
|
|
6716
|
-
const effectiveCreateSession = (0,
|
|
6752
|
+
const effectiveCreateSession = (0, import_react11.useMemo)(
|
|
6717
6753
|
() => effectiveCreateSessionBase ? {
|
|
6718
6754
|
...effectiveCreateSessionBase,
|
|
6719
6755
|
checkoutMode: effectiveCreateSessionMode
|
|
6720
6756
|
} : void 0,
|
|
6721
6757
|
[effectiveCreateSessionBase, effectiveCreateSessionMode]
|
|
6722
6758
|
);
|
|
6723
|
-
(0,
|
|
6759
|
+
(0, import_react11.useEffect)(() => {
|
|
6724
6760
|
setCreateSessionPatch(void 0);
|
|
6725
6761
|
setCreateSessionPatchBaseHash(baseCreateSessionHash);
|
|
6726
6762
|
}, [baseCreateSessionHash]);
|
|
6727
|
-
(0,
|
|
6763
|
+
(0, import_react11.useEffect)(() => {
|
|
6728
6764
|
setModeError(initialErrorMessage);
|
|
6729
6765
|
}, [initialErrorMessage]);
|
|
6730
|
-
const emitDecline = (0,
|
|
6766
|
+
const emitDecline = (0, import_react11.useCallback)(
|
|
6731
6767
|
(method, input, overrides) => {
|
|
6732
6768
|
invokeMerchantCallback(() => {
|
|
6733
6769
|
onDeclineRef.current?.(buildDeclineEvent(method, input, overrides));
|
|
@@ -6735,7 +6771,7 @@ function FloPayCheckout({
|
|
|
6735
6771
|
},
|
|
6736
6772
|
[invokeMerchantCallback]
|
|
6737
6773
|
);
|
|
6738
|
-
const runSavedPaymentFlow = (0,
|
|
6774
|
+
const runSavedPaymentFlow = (0, import_react11.useCallback)(
|
|
6739
6775
|
async (sess, options) => {
|
|
6740
6776
|
setModeError(null);
|
|
6741
6777
|
setModeOverlayError(null);
|
|
@@ -7001,7 +7037,7 @@ function FloPayCheckout({
|
|
|
7001
7037
|
telemetryCheckoutContext
|
|
7002
7038
|
]
|
|
7003
7039
|
);
|
|
7004
|
-
(0,
|
|
7040
|
+
(0, import_react11.useEffect)(() => {
|
|
7005
7041
|
if (typeof window === "undefined" || paypalResumeAttempted.current) {
|
|
7006
7042
|
return;
|
|
7007
7043
|
}
|
|
@@ -7204,7 +7240,7 @@ function FloPayCheckout({
|
|
|
7204
7240
|
}
|
|
7205
7241
|
})();
|
|
7206
7242
|
}, [emitDecline, invokeMerchantCallback, locale, normalizeSavedPaymentError, resolvedBillingUrl, telemetry]);
|
|
7207
|
-
const initializedHashRef = (0,
|
|
7243
|
+
const initializedHashRef = (0, import_react11.useRef)(null);
|
|
7208
7244
|
function hashCreateParams(params) {
|
|
7209
7245
|
const key = JSON.stringify({
|
|
7210
7246
|
c: params?.clientId,
|
|
@@ -7237,16 +7273,16 @@ function FloPayCheckout({
|
|
|
7237
7273
|
}
|
|
7238
7274
|
return `flopay_session_${Math.abs(h).toString(36)}`;
|
|
7239
7275
|
}
|
|
7240
|
-
const createSessionHash = (0,
|
|
7276
|
+
const createSessionHash = (0, import_react11.useMemo)(
|
|
7241
7277
|
() => effectiveCreateSession ? hashCreateParams(effectiveCreateSession) : "",
|
|
7242
7278
|
[effectiveCreateSession]
|
|
7243
7279
|
);
|
|
7244
|
-
const createSessionParamsRef = (0,
|
|
7280
|
+
const createSessionParamsRef = (0, import_react11.useRef)(effectiveCreateSession);
|
|
7245
7281
|
createSessionParamsRef.current = effectiveCreateSession;
|
|
7246
|
-
(0,
|
|
7282
|
+
(0, import_react11.useEffect)(() => {
|
|
7247
7283
|
setResolvedSessionId(sessionIdProp ?? "");
|
|
7248
7284
|
}, [sessionIdProp]);
|
|
7249
|
-
(0,
|
|
7285
|
+
(0, import_react11.useEffect)(() => {
|
|
7250
7286
|
autoCheckoutAttempted.current = false;
|
|
7251
7287
|
setModeError(initialErrorMessage);
|
|
7252
7288
|
setModeOverlayError(null);
|
|
@@ -7353,7 +7389,7 @@ function FloPayCheckout({
|
|
|
7353
7389
|
finishStandaloneTelemetry(reporter);
|
|
7354
7390
|
}
|
|
7355
7391
|
}
|
|
7356
|
-
const bootstrapInlineSession = (0,
|
|
7392
|
+
const bootstrapInlineSession = (0, import_react11.useCallback)(
|
|
7357
7393
|
async (patch) => {
|
|
7358
7394
|
const baseParams = createSessionParamsRef.current;
|
|
7359
7395
|
if (!baseParams) {
|
|
@@ -7415,7 +7451,7 @@ function FloPayCheckout({
|
|
|
7415
7451
|
},
|
|
7416
7452
|
[locale, resolvedBillingUrl, telemetry, telemetryCheckoutContext]
|
|
7417
7453
|
);
|
|
7418
|
-
const handleInlineSessionPatch = (0,
|
|
7454
|
+
const handleInlineSessionPatch = (0, import_react11.useCallback)(async (patch) => {
|
|
7419
7455
|
if (!hasInlineSessionPatchData(patch) || cardBootstrapPending) {
|
|
7420
7456
|
return {
|
|
7421
7457
|
sessionId: resolvedSessionId,
|
|
@@ -7438,7 +7474,7 @@ function FloPayCheckout({
|
|
|
7438
7474
|
resolvedSessionId,
|
|
7439
7475
|
session
|
|
7440
7476
|
]);
|
|
7441
|
-
(0,
|
|
7477
|
+
(0, import_react11.useEffect)(() => {
|
|
7442
7478
|
let cancelled = false;
|
|
7443
7479
|
setLoadError(null);
|
|
7444
7480
|
if (createSessionHash) {
|
|
@@ -7629,7 +7665,7 @@ function FloPayCheckout({
|
|
|
7629
7665
|
nonceProp,
|
|
7630
7666
|
runSavedPaymentFlow
|
|
7631
7667
|
]);
|
|
7632
|
-
const handleConfirmCheckout = (0,
|
|
7668
|
+
const handleConfirmCheckout = (0, import_react11.useCallback)(async () => {
|
|
7633
7669
|
if (confirmProcessing || !session) return;
|
|
7634
7670
|
setConfirmProcessing(true);
|
|
7635
7671
|
setModeError(null);
|
|
@@ -7644,7 +7680,7 @@ function FloPayCheckout({
|
|
|
7644
7680
|
}, [activeSessionId, confirmProcessing, runSavedPaymentFlow, session]);
|
|
7645
7681
|
const directPaypalConfig = resolveDirectPaypalConfig(unified);
|
|
7646
7682
|
const isPaypalOnlySession = isPayPalOnlyUnified(unified);
|
|
7647
|
-
const providerOptions = (0,
|
|
7683
|
+
const providerOptions = (0, import_react11.useMemo)(() => {
|
|
7648
7684
|
if (!unified || !session || !unified.data.stripe?.publishableKey) return void 0;
|
|
7649
7685
|
const opts = {
|
|
7650
7686
|
appearance,
|
|
@@ -7663,7 +7699,7 @@ function FloPayCheckout({
|
|
|
7663
7699
|
const shouldHandleInlineSessionPatch = Boolean(
|
|
7664
7700
|
createSessionParams && !children && layout === "buttons" && onBeforeButtonClick && effectiveCreateSessionMode === "full"
|
|
7665
7701
|
);
|
|
7666
|
-
const checkoutValue = (0,
|
|
7702
|
+
const checkoutValue = (0, import_react11.useMemo)(
|
|
7667
7703
|
() => ({
|
|
7668
7704
|
session,
|
|
7669
7705
|
loading: isLoading,
|
|
@@ -7685,7 +7721,7 @@ function FloPayCheckout({
|
|
|
7685
7721
|
]
|
|
7686
7722
|
);
|
|
7687
7723
|
const shouldShowInterimButtons = Boolean(createSessionParams) && layout === "buttons" && !isPaypalOnlySession && (!flopay || !providerOptions);
|
|
7688
|
-
const modeOverlay = modeOverlayStatus ? /* @__PURE__ */ (0,
|
|
7724
|
+
const modeOverlay = modeOverlayStatus ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7689
7725
|
ProcessingOverlay,
|
|
7690
7726
|
{
|
|
7691
7727
|
status: modeOverlayStatus,
|
|
@@ -7694,32 +7730,32 @@ function FloPayCheckout({
|
|
|
7694
7730
|
) : null;
|
|
7695
7731
|
if (isLoading) {
|
|
7696
7732
|
if (loadingNode) {
|
|
7697
|
-
return /* @__PURE__ */ (0,
|
|
7733
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
7698
7734
|
loadingNode,
|
|
7699
7735
|
modeOverlay
|
|
7700
7736
|
] });
|
|
7701
7737
|
}
|
|
7702
7738
|
if (layout === "buttons") {
|
|
7703
7739
|
const bundleRadius = themeBundle?.buttonsLayout?.cardButton?.borderRadius ?? themeBundle?.appearance.variables?.borderRadius ?? 8;
|
|
7704
|
-
const skeletonBar = (h) => /* @__PURE__ */ (0,
|
|
7740
|
+
const skeletonBar = (h) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: {
|
|
7705
7741
|
height: h,
|
|
7706
7742
|
borderRadius: bundleRadius,
|
|
7707
7743
|
background: "#e5e7eb",
|
|
7708
7744
|
animation: "flopay-loading-pulse 1.5s ease-in-out infinite"
|
|
7709
7745
|
} });
|
|
7710
|
-
return /* @__PURE__ */ (0,
|
|
7711
|
-
/* @__PURE__ */ (0,
|
|
7746
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
7747
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
|
|
7712
7748
|
showPayPal && skeletonBar(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
|
|
7713
7749
|
showStripe && (showApplePay || showGooglePay) && skeletonBar(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
|
|
7714
7750
|
showStripe && skeletonBar(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
|
|
7715
|
-
/* @__PURE__ */ (0,
|
|
7751
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("style", { children: `@keyframes flopay-loading-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
|
|
7716
7752
|
] }),
|
|
7717
7753
|
modeOverlay
|
|
7718
7754
|
] });
|
|
7719
7755
|
}
|
|
7720
|
-
return /* @__PURE__ */ (0,
|
|
7721
|
-
/* @__PURE__ */ (0,
|
|
7722
|
-
/* @__PURE__ */ (0,
|
|
7756
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
7757
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { display: "flex", justifyContent: "center", padding: 32 }, children: [
|
|
7758
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: {
|
|
7723
7759
|
width: 24,
|
|
7724
7760
|
height: 24,
|
|
7725
7761
|
border: "2px solid #e5e7eb",
|
|
@@ -7727,16 +7763,16 @@ function FloPayCheckout({
|
|
|
7727
7763
|
borderRadius: "50%",
|
|
7728
7764
|
animation: "spin 0.6s linear infinite"
|
|
7729
7765
|
} }),
|
|
7730
|
-
/* @__PURE__ */ (0,
|
|
7766
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` })
|
|
7731
7767
|
] }),
|
|
7732
7768
|
modeOverlay
|
|
7733
7769
|
] });
|
|
7734
7770
|
}
|
|
7735
7771
|
if (loadError) {
|
|
7736
7772
|
if (errorNode) {
|
|
7737
|
-
return /* @__PURE__ */ (0,
|
|
7773
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: errorNode(loadError) });
|
|
7738
7774
|
}
|
|
7739
|
-
return /* @__PURE__ */ (0,
|
|
7775
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7740
7776
|
"div",
|
|
7741
7777
|
{
|
|
7742
7778
|
role: "alert",
|
|
@@ -7752,8 +7788,8 @@ function FloPayCheckout({
|
|
|
7752
7788
|
) });
|
|
7753
7789
|
}
|
|
7754
7790
|
if (shouldShowInterimButtons) {
|
|
7755
|
-
return /* @__PURE__ */ (0,
|
|
7756
|
-
/* @__PURE__ */ (0,
|
|
7791
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
7792
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7757
7793
|
InterimButtonsView,
|
|
7758
7794
|
{
|
|
7759
7795
|
onButtonClick,
|
|
@@ -7773,26 +7809,10 @@ function FloPayCheckout({
|
|
|
7773
7809
|
] });
|
|
7774
7810
|
}
|
|
7775
7811
|
if (isPaypalOnlySession && session && directPaypalConfig) {
|
|
7776
|
-
return /* @__PURE__ */ (0,
|
|
7777
|
-
/* @__PURE__ */ (0,
|
|
7778
|
-
modeError && /* @__PURE__ */ (0,
|
|
7779
|
-
|
|
7780
|
-
{
|
|
7781
|
-
role: "alert",
|
|
7782
|
-
"data-testid": "flopay-error",
|
|
7783
|
-
style: {
|
|
7784
|
-
padding: "0.625rem 0.875rem",
|
|
7785
|
-
background: "#FEF2F2",
|
|
7786
|
-
border: "1px solid #FECACA",
|
|
7787
|
-
borderRadius: "8px",
|
|
7788
|
-
color: "#991B1B",
|
|
7789
|
-
fontSize: "0.85rem",
|
|
7790
|
-
fontWeight: 600
|
|
7791
|
-
},
|
|
7792
|
-
children: modeError
|
|
7793
|
-
}
|
|
7794
|
-
),
|
|
7795
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)(
|
|
7812
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
7813
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className, style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
|
|
7814
|
+
modeError && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(ErrorBanner, { icon: false, children: modeError }),
|
|
7815
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7796
7816
|
InstrumentedDirectPayPalButton,
|
|
7797
7817
|
{
|
|
7798
7818
|
sessionId: activeSessionId,
|
|
@@ -7818,12 +7838,12 @@ function FloPayCheckout({
|
|
|
7818
7838
|
] });
|
|
7819
7839
|
}
|
|
7820
7840
|
if (!flopay || !providerOptions) {
|
|
7821
|
-
return /* @__PURE__ */ (0,
|
|
7841
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: modeOverlay });
|
|
7822
7842
|
}
|
|
7823
7843
|
if (currentMode === "confirm") {
|
|
7824
|
-
return /* @__PURE__ */ (0,
|
|
7825
|
-
/* @__PURE__ */ (0,
|
|
7826
|
-
modeError && /* @__PURE__ */ (0,
|
|
7844
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
7845
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FloPayProvider, { flopay, paypalFlopay, options: providerOptions, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { className, children: [
|
|
7846
|
+
modeError && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7827
7847
|
"div",
|
|
7828
7848
|
{
|
|
7829
7849
|
style: {
|
|
@@ -7838,7 +7858,7 @@ function FloPayCheckout({
|
|
|
7838
7858
|
renderConfirmButton ? renderConfirmButton({
|
|
7839
7859
|
onConfirm: handleConfirmCheckout,
|
|
7840
7860
|
isProcessing: confirmProcessing
|
|
7841
|
-
}) : /* @__PURE__ */ (0,
|
|
7861
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7842
7862
|
"button",
|
|
7843
7863
|
{
|
|
7844
7864
|
type: "button",
|
|
@@ -7863,9 +7883,9 @@ function FloPayCheckout({
|
|
|
7863
7883
|
modeOverlay
|
|
7864
7884
|
] });
|
|
7865
7885
|
}
|
|
7866
|
-
return /* @__PURE__ */ (0,
|
|
7867
|
-
/* @__PURE__ */ (0,
|
|
7868
|
-
modeError && /* @__PURE__ */ (0,
|
|
7886
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
7887
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(FloPayProvider, { flopay, paypalFlopay, options: providerOptions, children: children ? /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(import_jsx_runtime9.Fragment, { children: [
|
|
7888
|
+
modeError && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7869
7889
|
"div",
|
|
7870
7890
|
{
|
|
7871
7891
|
style: {
|
|
@@ -7880,7 +7900,7 @@ function FloPayCheckout({
|
|
|
7880
7900
|
children: modeError
|
|
7881
7901
|
}
|
|
7882
7902
|
),
|
|
7883
|
-
/* @__PURE__ */ (0,
|
|
7903
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7884
7904
|
SessionInjector,
|
|
7885
7905
|
{
|
|
7886
7906
|
sessionId: activeSessionId,
|
|
@@ -7890,7 +7910,7 @@ function FloPayCheckout({
|
|
|
7890
7910
|
children
|
|
7891
7911
|
}
|
|
7892
7912
|
)
|
|
7893
|
-
] }) : /* @__PURE__ */ (0,
|
|
7913
|
+
] }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
7894
7914
|
SplitCardForm,
|
|
7895
7915
|
{
|
|
7896
7916
|
sessionId: activeSessionId,
|
|
@@ -7953,8 +7973,8 @@ function SessionInjector({
|
|
|
7953
7973
|
session,
|
|
7954
7974
|
children
|
|
7955
7975
|
}) {
|
|
7956
|
-
return /* @__PURE__ */ (0,
|
|
7957
|
-
if (!
|
|
7976
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(import_jsx_runtime9.Fragment, { children: import_react11.default.Children.map(children, (child) => {
|
|
7977
|
+
if (!import_react11.default.isValidElement(child)) return child;
|
|
7958
7978
|
const existing = child.props;
|
|
7959
7979
|
const injected = {};
|
|
7960
7980
|
if (!existing.sessionId) injected.sessionId = sessionId;
|
|
@@ -7969,15 +7989,11 @@ function SessionInjector({
|
|
|
7969
7989
|
injected.lastName = session.customer.lastName;
|
|
7970
7990
|
}
|
|
7971
7991
|
if (Object.keys(injected).length === 0) return child;
|
|
7972
|
-
return
|
|
7992
|
+
return import_react11.default.cloneElement(child, injected);
|
|
7973
7993
|
}) });
|
|
7974
7994
|
}
|
|
7975
7995
|
function InterimButtonsView({
|
|
7976
7996
|
onButtonClick,
|
|
7977
|
-
onCardButtonClick,
|
|
7978
|
-
cardLoading = false,
|
|
7979
|
-
cardOpen,
|
|
7980
|
-
errorMessage,
|
|
7981
7997
|
showPayPal,
|
|
7982
7998
|
showStripe = true,
|
|
7983
7999
|
showApplePay,
|
|
@@ -7989,15 +8005,9 @@ function InterimButtonsView({
|
|
|
7989
8005
|
cardBackButtonContent,
|
|
7990
8006
|
cardTitleContent
|
|
7991
8007
|
}) {
|
|
7992
|
-
const [showCardForm, setShowCardForm] = (0,
|
|
7993
|
-
const
|
|
7994
|
-
(0,
|
|
7995
|
-
if (isCardOpenControlled) {
|
|
7996
|
-
setShowCardForm(cardOpen);
|
|
7997
|
-
}
|
|
7998
|
-
}, [cardOpen, isCardOpenControlled]);
|
|
7999
|
-
const themeBundle = (0, import_react10.useMemo)(() => (0, import_shared8.resolveTheme)(theme), [theme]);
|
|
8000
|
-
const bStyles = (0, import_react10.useMemo)(() => {
|
|
8008
|
+
const [showCardForm, setShowCardForm] = (0, import_react11.useState)(false);
|
|
8009
|
+
const themeBundle = (0, import_react11.useMemo)(() => (0, import_shared8.resolveTheme)(theme), [theme]);
|
|
8010
|
+
const bStyles = (0, import_react11.useMemo)(() => {
|
|
8001
8011
|
const base = themeBundle?.buttonsLayout ?? (0, import_shared8.resolveButtonsLayoutTheme)(buttonsTheme);
|
|
8002
8012
|
if (!stylesOverride) return base;
|
|
8003
8013
|
return {
|
|
@@ -8012,7 +8022,7 @@ function InterimButtonsView({
|
|
|
8012
8022
|
};
|
|
8013
8023
|
}, [themeBundle, buttonsTheme, stylesOverride]);
|
|
8014
8024
|
const skeletonRadius = themeBundle?.buttonsLayout?.cardButton?.borderRadius ?? themeBundle?.appearance.variables?.borderRadius ?? 8;
|
|
8015
|
-
const skeleton = (h) => /* @__PURE__ */ (0,
|
|
8025
|
+
const skeleton = (h) => /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: {
|
|
8016
8026
|
height: h,
|
|
8017
8027
|
borderRadius: skeletonRadius,
|
|
8018
8028
|
background: "#e5e7eb",
|
|
@@ -8024,25 +8034,20 @@ function InterimButtonsView({
|
|
|
8024
8034
|
const inputBg = bStyles.cardInputBackground ?? "white";
|
|
8025
8035
|
const hideBackButtonLabel = isEmptySlotContent(cardBackButtonContent);
|
|
8026
8036
|
const hideTitle = isEmptySlotContent(cardTitleContent);
|
|
8027
|
-
return /* @__PURE__ */ (0,
|
|
8037
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: {
|
|
8028
8038
|
backgroundColor: bStyles.cardFormContainer?.backgroundColor ?? "white",
|
|
8029
8039
|
borderRadius: "8px",
|
|
8030
8040
|
animation: "flopay-interim-expand 0.35s cubic-bezier(0.4, 0, 0.2, 1) both",
|
|
8031
8041
|
overflow: "hidden",
|
|
8032
8042
|
...bStyles.cardFormContainer
|
|
8033
8043
|
}, children: [
|
|
8034
|
-
/* @__PURE__ */ (0,
|
|
8035
|
-
/* @__PURE__ */ (0,
|
|
8044
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { display: "flex", alignItems: "center", padding: "0.75rem 0 0.625rem" }, children: [
|
|
8045
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)(
|
|
8036
8046
|
"button",
|
|
8037
8047
|
{
|
|
8038
8048
|
type: "button",
|
|
8039
|
-
onClick: () =>
|
|
8040
|
-
if (!isCardOpenControlled) {
|
|
8041
|
-
setShowCardForm(false);
|
|
8042
|
-
}
|
|
8043
|
-
},
|
|
8049
|
+
onClick: () => setShowCardForm(false),
|
|
8044
8050
|
"aria-label": "Back to payment methods",
|
|
8045
|
-
disabled: isCardOpenControlled || cardLoading,
|
|
8046
8051
|
style: {
|
|
8047
8052
|
display: "inline-flex",
|
|
8048
8053
|
alignItems: "center",
|
|
@@ -8054,12 +8059,12 @@ function InterimButtonsView({
|
|
|
8054
8059
|
fontWeight: 500,
|
|
8055
8060
|
padding: 0,
|
|
8056
8061
|
flexShrink: 0,
|
|
8057
|
-
opacity:
|
|
8058
|
-
cursor:
|
|
8062
|
+
opacity: 1,
|
|
8063
|
+
cursor: "pointer",
|
|
8059
8064
|
...bStyles.backButton
|
|
8060
8065
|
},
|
|
8061
8066
|
children: [
|
|
8062
|
-
/* @__PURE__ */ (0,
|
|
8067
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("span", { style: {
|
|
8063
8068
|
display: "inline-flex",
|
|
8064
8069
|
alignItems: "center",
|
|
8065
8070
|
justifyContent: "center",
|
|
@@ -8068,12 +8073,12 @@ function InterimButtonsView({
|
|
|
8068
8073
|
borderRadius: "50%",
|
|
8069
8074
|
backgroundColor: "#f3f4f6",
|
|
8070
8075
|
...bStyles.backButtonIcon
|
|
8071
|
-
}, children: /* @__PURE__ */ (0,
|
|
8072
|
-
/* @__PURE__ */ (0,
|
|
8076
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime9.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_runtime9.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
|
|
8077
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)(BackButtonContentSlot, { content: cardBackButtonContent })
|
|
8073
8078
|
]
|
|
8074
8079
|
}
|
|
8075
8080
|
),
|
|
8076
|
-
hideTitle ? /* @__PURE__ */ (0,
|
|
8081
|
+
hideTitle ? /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { flex: 1 } }) : /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: {
|
|
8077
8082
|
flex: 1,
|
|
8078
8083
|
textAlign: "center",
|
|
8079
8084
|
fontWeight: 600,
|
|
@@ -8081,11 +8086,11 @@ function InterimButtonsView({
|
|
|
8081
8086
|
color: "#262833",
|
|
8082
8087
|
paddingRight: 80,
|
|
8083
8088
|
...bStyles.title
|
|
8084
|
-
}, children: /* @__PURE__ */ (0,
|
|
8089
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(TitleContentSlot, { content: cardTitleContent }) })
|
|
8085
8090
|
] }),
|
|
8086
|
-
/* @__PURE__ */ (0,
|
|
8087
|
-
/* @__PURE__ */ (0,
|
|
8088
|
-
/* @__PURE__ */ (0,
|
|
8091
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTopLeftRadius: 8, borderTopRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { width: "60%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
|
|
8092
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { display: "flex" }, children: [
|
|
8093
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: {
|
|
8089
8094
|
flex: 1,
|
|
8090
8095
|
backgroundColor: inputBg,
|
|
8091
8096
|
borderTop: "none",
|
|
@@ -8095,8 +8100,8 @@ function InterimButtonsView({
|
|
|
8095
8100
|
borderBottomLeftRadius: 8,
|
|
8096
8101
|
padding: 12,
|
|
8097
8102
|
height: 45
|
|
8098
|
-
}, children: /* @__PURE__ */ (0,
|
|
8099
|
-
/* @__PURE__ */ (0,
|
|
8103
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { width: "50%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
|
|
8104
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: {
|
|
8100
8105
|
flex: 1,
|
|
8101
8106
|
backgroundColor: inputBg,
|
|
8102
8107
|
borderTop: "none",
|
|
@@ -8106,10 +8111,10 @@ function InterimButtonsView({
|
|
|
8106
8111
|
borderBottomRightRadius: 8,
|
|
8107
8112
|
padding: 12,
|
|
8108
8113
|
height: 45
|
|
8109
|
-
}, children: /* @__PURE__ */ (0,
|
|
8114
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { width: "40%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) })
|
|
8110
8115
|
] }),
|
|
8111
|
-
/* @__PURE__ */ (0,
|
|
8112
|
-
/* @__PURE__ */ (0,
|
|
8116
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderRadius: 8, marginTop: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: { width: "45%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
|
|
8117
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("div", { style: {
|
|
8113
8118
|
height: 50,
|
|
8114
8119
|
borderRadius: 8,
|
|
8115
8120
|
marginTop: 16,
|
|
@@ -8118,7 +8123,7 @@ function InterimButtonsView({
|
|
|
8118
8123
|
...bStyles.submitButton,
|
|
8119
8124
|
opacity: 0.5
|
|
8120
8125
|
} }),
|
|
8121
|
-
/* @__PURE__ */ (0,
|
|
8126
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("style", { children: `
|
|
8122
8127
|
@keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
|
|
8123
8128
|
@keyframes flopay-interim-expand {
|
|
8124
8129
|
0% { opacity: 0; max-height: 0; transform: translateY(-12px); }
|
|
@@ -8128,23 +8133,17 @@ function InterimButtonsView({
|
|
|
8128
8133
|
` })
|
|
8129
8134
|
] });
|
|
8130
8135
|
}
|
|
8131
|
-
return /* @__PURE__ */ (0,
|
|
8136
|
+
return /* @__PURE__ */ (0, import_jsx_runtime9.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
|
|
8132
8137
|
showPayPal && skeleton(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
|
|
8133
8138
|
showStripe && (showApplePay || showGooglePay) && skeleton(DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT2),
|
|
8134
|
-
showStripe && /* @__PURE__ */ (0,
|
|
8139
|
+
showStripe && /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(
|
|
8135
8140
|
"button",
|
|
8136
8141
|
{
|
|
8137
8142
|
type: "button",
|
|
8138
|
-
onClick:
|
|
8139
|
-
if (cardLoading) return;
|
|
8140
|
-
if (onCardButtonClick) {
|
|
8141
|
-
await onCardButtonClick();
|
|
8142
|
-
return;
|
|
8143
|
-
}
|
|
8143
|
+
onClick: () => {
|
|
8144
8144
|
onButtonClick?.("card");
|
|
8145
8145
|
setShowCardForm(true);
|
|
8146
8146
|
},
|
|
8147
|
-
disabled: cardLoading,
|
|
8148
8147
|
style: {
|
|
8149
8148
|
width: "100%",
|
|
8150
8149
|
...cardButtonSizing,
|
|
@@ -8154,7 +8153,7 @@ function InterimButtonsView({
|
|
|
8154
8153
|
borderRadius: "8px",
|
|
8155
8154
|
fontSize: bStyles.cardButtonFontSize ?? "0.95rem",
|
|
8156
8155
|
fontWeight: 600,
|
|
8157
|
-
cursor:
|
|
8156
|
+
cursor: "pointer",
|
|
8158
8157
|
display: "flex",
|
|
8159
8158
|
alignItems: "center",
|
|
8160
8159
|
justifyContent: "center",
|
|
@@ -8162,7 +8161,7 @@ function InterimButtonsView({
|
|
|
8162
8161
|
boxShadow: "0 1px 2px rgba(0,0,0,0.04)",
|
|
8163
8162
|
transition: "transform 0.1s",
|
|
8164
8163
|
position: "relative",
|
|
8165
|
-
opacity:
|
|
8164
|
+
opacity: 1,
|
|
8166
8165
|
...bStyles.cardButton
|
|
8167
8166
|
},
|
|
8168
8167
|
onMouseDown: (e) => {
|
|
@@ -8171,39 +8170,22 @@ function InterimButtonsView({
|
|
|
8171
8170
|
onMouseUp: (e) => {
|
|
8172
8171
|
e.currentTarget.style.transform = "scale(1)";
|
|
8173
8172
|
},
|
|
8174
|
-
children: /* @__PURE__ */ (0,
|
|
8173
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime9.jsx)(CardButtonContentSlot, { content: cardButtonContent })
|
|
8175
8174
|
}
|
|
8176
8175
|
),
|
|
8177
|
-
|
|
8178
|
-
margin: "0.25rem 0",
|
|
8179
|
-
padding: "0.625rem 0.875rem",
|
|
8180
|
-
background: "#FEF2F2",
|
|
8181
|
-
border: "1px solid #FECACA",
|
|
8182
|
-
borderRadius: "8px",
|
|
8183
|
-
color: "#991B1B",
|
|
8184
|
-
fontSize: "0.85rem",
|
|
8185
|
-
fontWeight: 600,
|
|
8186
|
-
display: "flex",
|
|
8187
|
-
alignItems: "center",
|
|
8188
|
-
gap: "0.5rem",
|
|
8189
|
-
...bStyles.errorBanner
|
|
8190
|
-
}, children: [
|
|
8191
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime8.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" }) }),
|
|
8192
|
-
errorMessage
|
|
8193
|
-
] }),
|
|
8194
|
-
/* @__PURE__ */ (0, import_jsx_runtime8.jsx)("style", { children: `@keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
|
|
8176
|
+
/* @__PURE__ */ (0, import_jsx_runtime9.jsx)("style", { children: `@keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
|
|
8195
8177
|
] });
|
|
8196
8178
|
}
|
|
8197
8179
|
|
|
8198
8180
|
// src/checkout-form.tsx
|
|
8199
8181
|
var import_js5 = require("@flopay/js");
|
|
8200
8182
|
var import_shared9 = require("@flopay/shared");
|
|
8201
|
-
var
|
|
8202
|
-
var
|
|
8183
|
+
var import_react12 = require("react");
|
|
8184
|
+
var import_jsx_runtime10 = require("react/jsx-runtime");
|
|
8203
8185
|
var WALLET_RESUME_KEY = "flopay_wallet_resume";
|
|
8204
|
-
var CheckoutForm = (0,
|
|
8186
|
+
var CheckoutForm = (0, import_react12.forwardRef)(
|
|
8205
8187
|
function CheckoutForm2(props, ref) {
|
|
8206
|
-
return /* @__PURE__ */ (0,
|
|
8188
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(CheckoutFormInner, { ...props, innerRef: ref });
|
|
8207
8189
|
}
|
|
8208
8190
|
);
|
|
8209
8191
|
function CheckoutFormInner({
|
|
@@ -8233,27 +8215,27 @@ function CheckoutFormInner({
|
|
|
8233
8215
|
const paypalFlopay = usePayPalFloPay();
|
|
8234
8216
|
const elements = useElements();
|
|
8235
8217
|
const contextBillingUrl = useBillingApiUrl();
|
|
8236
|
-
const [processing, setProcessing] = (0,
|
|
8237
|
-
const [error, setError] = (0,
|
|
8238
|
-
const [is3DSActive, setIs3DSActive] = (0,
|
|
8218
|
+
const [processing, setProcessing] = (0, import_react12.useState)(false);
|
|
8219
|
+
const [error, setError] = (0, import_react12.useState)(null);
|
|
8220
|
+
const [is3DSActive, setIs3DSActive] = (0, import_react12.useState)(false);
|
|
8239
8221
|
const displayError = externalError ?? error;
|
|
8240
8222
|
const isSubmitting = externalProcessing ?? processing;
|
|
8241
8223
|
const isSelfContained = !onTokenizedBody;
|
|
8242
8224
|
const baseUrl = (billingApiUrl || contextBillingUrl).replace(/\/+$/, "");
|
|
8243
|
-
const updateError = (0,
|
|
8225
|
+
const updateError = (0, import_react12.useCallback)(
|
|
8244
8226
|
(err) => {
|
|
8245
8227
|
setError(err);
|
|
8246
8228
|
onErrorChange?.(err);
|
|
8247
8229
|
},
|
|
8248
8230
|
[onErrorChange]
|
|
8249
8231
|
);
|
|
8250
|
-
const emitDecline = (0,
|
|
8232
|
+
const emitDecline = (0, import_react12.useCallback)(
|
|
8251
8233
|
(input, overrides) => {
|
|
8252
8234
|
onDecline?.(buildDeclineEvent("card", input, overrides));
|
|
8253
8235
|
},
|
|
8254
8236
|
[onDecline]
|
|
8255
8237
|
);
|
|
8256
|
-
const processPaymentInternal = (0,
|
|
8238
|
+
const processPaymentInternal = (0, import_react12.useCallback)(
|
|
8257
8239
|
async (tokenizedBody, completionPaymentMethodId) => {
|
|
8258
8240
|
setProcessing(true);
|
|
8259
8241
|
updateError(null);
|
|
@@ -8365,7 +8347,7 @@ function CheckoutFormInner({
|
|
|
8365
8347
|
},
|
|
8366
8348
|
[baseUrl, sessionId, nonce, userId, email, firstName, lastName, chv, flopay, paypalFlopay, onComplete, onError, onDecline, updateError, emitDecline]
|
|
8367
8349
|
);
|
|
8368
|
-
const dispatchTokenizedBody = (0,
|
|
8350
|
+
const dispatchTokenizedBody = (0, import_react12.useCallback)(
|
|
8369
8351
|
(tokenizedBody) => {
|
|
8370
8352
|
if (onTokenizedBody) {
|
|
8371
8353
|
onTokenizedBody(tokenizedBody);
|
|
@@ -8375,7 +8357,7 @@ function CheckoutFormInner({
|
|
|
8375
8357
|
},
|
|
8376
8358
|
[onTokenizedBody, processPaymentInternal]
|
|
8377
8359
|
);
|
|
8378
|
-
(0,
|
|
8360
|
+
(0, import_react12.useImperativeHandle)(innerRef, () => ({
|
|
8379
8361
|
async handleNextAction(secret) {
|
|
8380
8362
|
if (!flopay) return;
|
|
8381
8363
|
setIs3DSActive(true);
|
|
@@ -8402,7 +8384,7 @@ function CheckoutFormInner({
|
|
|
8402
8384
|
}
|
|
8403
8385
|
}
|
|
8404
8386
|
}), [flopay, dispatchTokenizedBody, onError, updateError, emitDecline]);
|
|
8405
|
-
(0,
|
|
8387
|
+
(0, import_react12.useEffect)(() => {
|
|
8406
8388
|
if (typeof window === "undefined") return;
|
|
8407
8389
|
const stored = localStorage.getItem(WALLET_RESUME_KEY);
|
|
8408
8390
|
if (!stored) return;
|
|
@@ -8420,7 +8402,7 @@ function CheckoutFormInner({
|
|
|
8420
8402
|
localStorage.removeItem(WALLET_RESUME_KEY);
|
|
8421
8403
|
}
|
|
8422
8404
|
}, [sessionId, dispatchTokenizedBody]);
|
|
8423
|
-
const handleSubmit = (0,
|
|
8405
|
+
const handleSubmit = (0, import_react12.useCallback)(
|
|
8424
8406
|
async (e) => {
|
|
8425
8407
|
e.preventDefault();
|
|
8426
8408
|
if (!flopay || !elements || isSubmitting) return;
|
|
@@ -8446,8 +8428,7 @@ function CheckoutFormInner({
|
|
|
8446
8428
|
if (!sessionId || !email) {
|
|
8447
8429
|
throw new import_shared9.FloPayError("Missing sessionId or email", "validation_error");
|
|
8448
8430
|
}
|
|
8449
|
-
const intentHeaders =
|
|
8450
|
-
if (nonce) intentHeaders["x-checkout-session-token"] = nonce;
|
|
8431
|
+
const intentHeaders = intentRequestHeaders(nonce);
|
|
8451
8432
|
const intentResponse = await fetch(`${baseUrl}/v1/checkouts/payments/intents`, {
|
|
8452
8433
|
method: "POST",
|
|
8453
8434
|
headers: intentHeaders,
|
|
@@ -8512,8 +8493,8 @@ function CheckoutFormInner({
|
|
|
8512
8493
|
[flopay, elements, isSubmitting, sessionId, nonce, email, firstName, lastName, baseUrl, isSelfContained, dispatchTokenizedBody, onError, updateError, emitDecline]
|
|
8513
8494
|
);
|
|
8514
8495
|
const isReady = flopay !== null && elements !== null;
|
|
8515
|
-
return /* @__PURE__ */ (0,
|
|
8516
|
-
(is3DSActive || isSubmitting) && /* @__PURE__ */ (0,
|
|
8496
|
+
return /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
|
|
8497
|
+
(is3DSActive || isSubmitting) && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { "data-testid": "flopay-overlay", style: {
|
|
8517
8498
|
position: "absolute",
|
|
8518
8499
|
inset: 0,
|
|
8519
8500
|
background: "rgba(255,255,255,0.7)",
|
|
@@ -8522,12 +8503,12 @@ function CheckoutFormInner({
|
|
|
8522
8503
|
justifyContent: "center",
|
|
8523
8504
|
zIndex: 10
|
|
8524
8505
|
}, children: is3DSActive ? "Verifying payment..." : "Processing..." }),
|
|
8525
|
-
!isReady && /* @__PURE__ */ (0,
|
|
8526
|
-
isReady && /* @__PURE__ */ (0,
|
|
8527
|
-
/* @__PURE__ */ (0,
|
|
8528
|
-
showAddress && /* @__PURE__ */ (0,
|
|
8529
|
-
displayError && /* @__PURE__ */ (0,
|
|
8530
|
-
children ?? /* @__PURE__ */ (0,
|
|
8506
|
+
!isReady && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." }),
|
|
8507
|
+
isReady && /* @__PURE__ */ (0, import_jsx_runtime10.jsxs)(import_jsx_runtime10.Fragment, { children: [
|
|
8508
|
+
/* @__PURE__ */ (0, import_jsx_runtime10.jsx)(PaymentElement, { options: { layout } }),
|
|
8509
|
+
showAddress && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(AddressElement, { options: { mode: showAddress === true ? "billing" : showAddress } }),
|
|
8510
|
+
displayError && /* @__PURE__ */ (0, import_jsx_runtime10.jsx)("div", { role: "alert", "data-testid": "flopay-error", style: { color: "red", margin: "0.75rem 0" }, children: displayError }),
|
|
8511
|
+
children ?? /* @__PURE__ */ (0, import_jsx_runtime10.jsx)(
|
|
8531
8512
|
"button",
|
|
8532
8513
|
{
|
|
8533
8514
|
type: "submit",
|
|
@@ -8543,8 +8524,8 @@ function CheckoutFormInner({
|
|
|
8543
8524
|
// src/paypal-button.tsx
|
|
8544
8525
|
var import_js6 = require("@flopay/js");
|
|
8545
8526
|
var import_shared10 = require("@flopay/shared");
|
|
8546
|
-
var
|
|
8547
|
-
var
|
|
8527
|
+
var import_react13 = require("react");
|
|
8528
|
+
var import_jsx_runtime11 = require("react/jsx-runtime");
|
|
8548
8529
|
function PayPalButton({
|
|
8549
8530
|
sessionId,
|
|
8550
8531
|
nonce,
|
|
@@ -8562,11 +8543,11 @@ function PayPalButton({
|
|
|
8562
8543
|
const flopay = useFloPay();
|
|
8563
8544
|
const elements = useElements();
|
|
8564
8545
|
const contextBillingUrl = useBillingApiUrl();
|
|
8565
|
-
const [ready, setReady] = (0,
|
|
8566
|
-
const [submitting, setSubmitting] = (0,
|
|
8567
|
-
const paypalResumeAttempted = (0,
|
|
8546
|
+
const [ready, setReady] = (0, import_react13.useState)(false);
|
|
8547
|
+
const [submitting, setSubmitting] = (0, import_react13.useState)(false);
|
|
8548
|
+
const paypalResumeAttempted = (0, import_react13.useRef)(false);
|
|
8568
8549
|
const baseUrl = (billingApiUrl || contextBillingUrl).replace(/\/+$/, "");
|
|
8569
|
-
const processPaymentInternal = (0,
|
|
8550
|
+
const processPaymentInternal = (0, import_react13.useCallback)(
|
|
8570
8551
|
async (tokenizedBody) => {
|
|
8571
8552
|
try {
|
|
8572
8553
|
const api = new import_js6.PaymentAPI(baseUrl);
|
|
@@ -8594,7 +8575,7 @@ function PayPalButton({
|
|
|
8594
8575
|
},
|
|
8595
8576
|
[baseUrl, sessionId, nonce, userId, email, firstName, lastName, chv, onComplete, onErrorChange]
|
|
8596
8577
|
);
|
|
8597
|
-
const dispatchTokenizedBody = (0,
|
|
8578
|
+
const dispatchTokenizedBody = (0, import_react13.useCallback)(
|
|
8598
8579
|
(body) => {
|
|
8599
8580
|
if (onTokenizedBody) {
|
|
8600
8581
|
onTokenizedBody(body);
|
|
@@ -8604,7 +8585,7 @@ function PayPalButton({
|
|
|
8604
8585
|
},
|
|
8605
8586
|
[onTokenizedBody, processPaymentInternal]
|
|
8606
8587
|
);
|
|
8607
|
-
(0,
|
|
8588
|
+
(0, import_react13.useEffect)(() => {
|
|
8608
8589
|
if (!flopay || paypalResumeAttempted.current) return;
|
|
8609
8590
|
const params = new URLSearchParams(window.location.search);
|
|
8610
8591
|
const paymentIntentId = params.get("payment_intent");
|
|
@@ -8652,7 +8633,7 @@ function PayPalButton({
|
|
|
8652
8633
|
}
|
|
8653
8634
|
})();
|
|
8654
8635
|
}, [flopay, dispatchTokenizedBody, onErrorChange]);
|
|
8655
|
-
const handlePayPalConfirm = (0,
|
|
8636
|
+
const handlePayPalConfirm = (0, import_react13.useCallback)(async () => {
|
|
8656
8637
|
if (!flopay || !elements) return;
|
|
8657
8638
|
try {
|
|
8658
8639
|
setSubmitting(true);
|
|
@@ -8686,11 +8667,11 @@ function PayPalButton({
|
|
|
8686
8667
|
}
|
|
8687
8668
|
}, [flopay, elements, sessionId, nonce, email, baseUrl, dispatchTokenizedBody, onErrorChange]);
|
|
8688
8669
|
if (!flopay || !elements) {
|
|
8689
|
-
return /* @__PURE__ */ (0,
|
|
8670
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6, animation: "pulse 1.5s infinite" } });
|
|
8690
8671
|
}
|
|
8691
|
-
return /* @__PURE__ */ (0,
|
|
8692
|
-
!ready && /* @__PURE__ */ (0,
|
|
8693
|
-
/* @__PURE__ */ (0,
|
|
8672
|
+
return /* @__PURE__ */ (0, import_jsx_runtime11.jsxs)(import_jsx_runtime11.Fragment, { children: [
|
|
8673
|
+
!ready && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6 } }),
|
|
8674
|
+
/* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: ready ? {} : { display: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)(
|
|
8694
8675
|
"button",
|
|
8695
8676
|
{
|
|
8696
8677
|
type: "button",
|
|
@@ -8712,7 +8693,7 @@ function PayPalButton({
|
|
|
8712
8693
|
children: submitting ? "Processing..." : "PayPal"
|
|
8713
8694
|
}
|
|
8714
8695
|
) }),
|
|
8715
|
-
(submitting || isProcessing) && /* @__PURE__ */ (0,
|
|
8696
|
+
(submitting || isProcessing) && /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: {
|
|
8716
8697
|
position: "fixed",
|
|
8717
8698
|
inset: 0,
|
|
8718
8699
|
background: "rgba(0,0,0,0.4)",
|
|
@@ -8720,7 +8701,7 @@ function PayPalButton({
|
|
|
8720
8701
|
alignItems: "center",
|
|
8721
8702
|
justifyContent: "center",
|
|
8722
8703
|
zIndex: 1e3
|
|
8723
|
-
}, children: /* @__PURE__ */ (0,
|
|
8704
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime11.jsx)("div", { style: {
|
|
8724
8705
|
background: "white",
|
|
8725
8706
|
borderRadius: 8,
|
|
8726
8707
|
padding: "1.5rem",
|
|
@@ -8732,10 +8713,10 @@ function PayPalButton({
|
|
|
8732
8713
|
}
|
|
8733
8714
|
|
|
8734
8715
|
// src/automatic-payment-button.tsx
|
|
8735
|
-
var
|
|
8716
|
+
var import_react14 = require("react");
|
|
8736
8717
|
var import_js7 = require("@flopay/js");
|
|
8737
8718
|
var import_shared11 = require("@flopay/shared");
|
|
8738
|
-
var
|
|
8719
|
+
var import_jsx_runtime12 = require("react/jsx-runtime");
|
|
8739
8720
|
var DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT3 = 44;
|
|
8740
8721
|
function sleep2(ms) {
|
|
8741
8722
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
@@ -8815,11 +8796,11 @@ function FloPayAutomaticPaymentButton({
|
|
|
8815
8796
|
style,
|
|
8816
8797
|
...buttonProps
|
|
8817
8798
|
}) {
|
|
8818
|
-
const resolvedBillingUrl = (0,
|
|
8799
|
+
const resolvedBillingUrl = (0, import_react14.useMemo)(
|
|
8819
8800
|
() => (0, import_shared11.resolveBillingApiUrl)(billingApiUrl),
|
|
8820
8801
|
[billingApiUrl]
|
|
8821
8802
|
);
|
|
8822
|
-
const createSessionDraft = (0,
|
|
8803
|
+
const createSessionDraft = (0, import_react14.useMemo)(
|
|
8823
8804
|
() => resolveCreateSessionDraft({
|
|
8824
8805
|
createSession,
|
|
8825
8806
|
clientId,
|
|
@@ -8847,36 +8828,36 @@ function FloPayAutomaticPaymentButton({
|
|
|
8847
8828
|
utmMetadata
|
|
8848
8829
|
]
|
|
8849
8830
|
);
|
|
8850
|
-
const [isProcessing, setIsProcessing] = (0,
|
|
8851
|
-
const [overlayStatus, setOverlayStatus] = (0,
|
|
8852
|
-
const [overlayError, setOverlayError] = (0,
|
|
8853
|
-
const [fallbackSession, setFallbackSession] = (0,
|
|
8854
|
-
const isMountedRef = (0,
|
|
8855
|
-
const threeDsAbortRef = (0,
|
|
8856
|
-
const fallbackSessionRef = (0,
|
|
8857
|
-
const onSuccessRef = (0,
|
|
8858
|
-
const onErrorRef = (0,
|
|
8859
|
-
const onDeclineRef = (0,
|
|
8860
|
-
(0,
|
|
8831
|
+
const [isProcessing, setIsProcessing] = (0, import_react14.useState)(false);
|
|
8832
|
+
const [overlayStatus, setOverlayStatus] = (0, import_react14.useState)(null);
|
|
8833
|
+
const [overlayError, setOverlayError] = (0, import_react14.useState)(null);
|
|
8834
|
+
const [fallbackSession, setFallbackSession] = (0, import_react14.useState)(null);
|
|
8835
|
+
const isMountedRef = (0, import_react14.useRef)(true);
|
|
8836
|
+
const threeDsAbortRef = (0, import_react14.useRef)(null);
|
|
8837
|
+
const fallbackSessionRef = (0, import_react14.useRef)(fallbackSession);
|
|
8838
|
+
const onSuccessRef = (0, import_react14.useRef)(onSuccess);
|
|
8839
|
+
const onErrorRef = (0, import_react14.useRef)(onError);
|
|
8840
|
+
const onDeclineRef = (0, import_react14.useRef)(onDecline);
|
|
8841
|
+
(0, import_react14.useEffect)(() => {
|
|
8861
8842
|
fallbackSessionRef.current = fallbackSession;
|
|
8862
8843
|
}, [fallbackSession]);
|
|
8863
|
-
(0,
|
|
8844
|
+
(0, import_react14.useEffect)(() => {
|
|
8864
8845
|
onSuccessRef.current = onSuccess;
|
|
8865
8846
|
}, [onSuccess]);
|
|
8866
|
-
(0,
|
|
8847
|
+
(0, import_react14.useEffect)(() => {
|
|
8867
8848
|
onErrorRef.current = onError;
|
|
8868
8849
|
}, [onError]);
|
|
8869
|
-
(0,
|
|
8850
|
+
(0, import_react14.useEffect)(() => {
|
|
8870
8851
|
onDeclineRef.current = onDecline;
|
|
8871
8852
|
}, [onDecline]);
|
|
8872
|
-
(0,
|
|
8853
|
+
(0, import_react14.useEffect)(() => {
|
|
8873
8854
|
isMountedRef.current = true;
|
|
8874
8855
|
return () => {
|
|
8875
8856
|
isMountedRef.current = false;
|
|
8876
8857
|
threeDsAbortRef.current?.abort();
|
|
8877
8858
|
};
|
|
8878
8859
|
}, []);
|
|
8879
|
-
(0,
|
|
8860
|
+
(0, import_react14.useEffect)(() => {
|
|
8880
8861
|
if (typeof window === "undefined") {
|
|
8881
8862
|
return;
|
|
8882
8863
|
}
|
|
@@ -8890,13 +8871,13 @@ function FloPayAutomaticPaymentButton({
|
|
|
8890
8871
|
window.removeEventListener("keydown", handleKeyDown);
|
|
8891
8872
|
};
|
|
8892
8873
|
}, []);
|
|
8893
|
-
const emitDecline = (0,
|
|
8874
|
+
const emitDecline = (0, import_react14.useCallback)((error, method = DEFAULT_SAVED_PAYMENT_DECLINE_METHOD) => {
|
|
8894
8875
|
onDeclineRef.current?.(buildDeclineEvent(method, error, {
|
|
8895
8876
|
code: error.code,
|
|
8896
8877
|
declineCode: error.declineCode
|
|
8897
8878
|
}));
|
|
8898
8879
|
}, []);
|
|
8899
|
-
const showSuccess = (0,
|
|
8880
|
+
const showSuccess = (0, import_react14.useCallback)(async (event) => {
|
|
8900
8881
|
if (!isMountedRef.current) return;
|
|
8901
8882
|
setOverlayError(null);
|
|
8902
8883
|
setOverlayStatus("success");
|
|
@@ -8904,7 +8885,7 @@ function FloPayAutomaticPaymentButton({
|
|
|
8904
8885
|
if (!isMountedRef.current) return;
|
|
8905
8886
|
onSuccessRef.current?.(event);
|
|
8906
8887
|
}, []);
|
|
8907
|
-
const showError = (0,
|
|
8888
|
+
const showError = (0, import_react14.useCallback)(async (error, options) => {
|
|
8908
8889
|
if (!isMountedRef.current) return;
|
|
8909
8890
|
onErrorRef.current?.(error);
|
|
8910
8891
|
if (options?.emitDecline) {
|
|
@@ -8914,7 +8895,7 @@ function FloPayAutomaticPaymentButton({
|
|
|
8914
8895
|
setOverlayStatus("error");
|
|
8915
8896
|
await sleep2(PROCESSING_OVERLAY_ERROR_DELAY_MS);
|
|
8916
8897
|
}, [emitDecline]);
|
|
8917
|
-
const processResolvedSession = (0,
|
|
8898
|
+
const processResolvedSession = (0, import_react14.useCallback)(async (apiResult, resolvedSessionId, options) => {
|
|
8918
8899
|
const session = apiResult.data.session ?? null;
|
|
8919
8900
|
if (!session) {
|
|
8920
8901
|
throw new import_shared11.FloPayError("No session data returned", "api_error");
|
|
@@ -9070,7 +9051,7 @@ function FloPayAutomaticPaymentButton({
|
|
|
9070
9051
|
showError,
|
|
9071
9052
|
showSuccess
|
|
9072
9053
|
]);
|
|
9073
|
-
const handleButtonClick = (0,
|
|
9054
|
+
const handleButtonClick = (0, import_react14.useCallback)(async (event) => {
|
|
9074
9055
|
buttonProps.onClick?.(event);
|
|
9075
9056
|
if (event.defaultPrevented || disabled || isProcessing) {
|
|
9076
9057
|
return;
|
|
@@ -9152,7 +9133,7 @@ function FloPayAutomaticPaymentButton({
|
|
|
9152
9133
|
showError,
|
|
9153
9134
|
showSuccess
|
|
9154
9135
|
]);
|
|
9155
|
-
const handleFallbackComplete = (0,
|
|
9136
|
+
const handleFallbackComplete = (0, import_react14.useCallback)((result) => {
|
|
9156
9137
|
const activeFallback = fallbackSessionRef.current;
|
|
9157
9138
|
setFallbackSession(null);
|
|
9158
9139
|
onSuccessRef.current?.({
|
|
@@ -9162,14 +9143,14 @@ function FloPayAutomaticPaymentButton({
|
|
|
9162
9143
|
autoCompleted: false
|
|
9163
9144
|
});
|
|
9164
9145
|
}, []);
|
|
9165
|
-
const handleFallbackError = (0,
|
|
9146
|
+
const handleFallbackError = (0, import_react14.useCallback)((error) => {
|
|
9166
9147
|
onErrorRef.current?.(error);
|
|
9167
9148
|
}, []);
|
|
9168
|
-
const handleFallbackDecline = (0,
|
|
9149
|
+
const handleFallbackDecline = (0, import_react14.useCallback)((decline) => {
|
|
9169
9150
|
onDeclineRef.current?.(decline);
|
|
9170
9151
|
}, []);
|
|
9171
|
-
const themeBundle = (0,
|
|
9172
|
-
const bStyles = (0,
|
|
9152
|
+
const themeBundle = (0, import_react14.useMemo)(() => (0, import_shared11.resolveTheme)(theme), [theme]);
|
|
9153
|
+
const bStyles = (0, import_react14.useMemo)(() => {
|
|
9173
9154
|
const base = themeBundle?.buttonsLayout ?? (0, import_shared11.resolveButtonsLayoutTheme)(buttonsTheme);
|
|
9174
9155
|
if (!stylesOverride) return base;
|
|
9175
9156
|
return {
|
|
@@ -9178,7 +9159,7 @@ function FloPayAutomaticPaymentButton({
|
|
|
9178
9159
|
cardButton: { ...base.cardButton, ...stylesOverride.cardButton }
|
|
9179
9160
|
};
|
|
9180
9161
|
}, [themeBundle, buttonsTheme, stylesOverride]);
|
|
9181
|
-
const resolvedAppearance = (0,
|
|
9162
|
+
const resolvedAppearance = (0, import_react14.useMemo)(() => {
|
|
9182
9163
|
const bundleAppearance = themeBundle?.appearance;
|
|
9183
9164
|
if (!appearance) return bundleAppearance;
|
|
9184
9165
|
if (!bundleAppearance) return appearance;
|
|
@@ -9196,8 +9177,8 @@ function FloPayAutomaticPaymentButton({
|
|
|
9196
9177
|
const resolvedPrimaryHoverColor = resolvedAppearanceVars?.colorPrimaryHover ?? darkenHex(resolvedPrimaryColor, 0.12);
|
|
9197
9178
|
const resolvedButtonBorderRadius = resolvedAppearanceVars?.borderRadius ?? "8px";
|
|
9198
9179
|
const cardButtonSizing = children === void 0 ? { boxSizing: "border-box", height: DEFAULT_BUTTONS_LAYOUT_BUTTON_HEIGHT3, padding: "0 1rem" } : { padding: "0.9rem 1rem" };
|
|
9199
|
-
return /* @__PURE__ */ (0,
|
|
9200
|
-
/* @__PURE__ */ (0,
|
|
9180
|
+
return /* @__PURE__ */ (0, import_jsx_runtime12.jsxs)(import_jsx_runtime12.Fragment, { children: [
|
|
9181
|
+
/* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
9201
9182
|
"button",
|
|
9202
9183
|
{
|
|
9203
9184
|
...buttonProps,
|
|
@@ -9261,17 +9242,17 @@ function FloPayAutomaticPaymentButton({
|
|
|
9261
9242
|
e.currentTarget.style.transform = "scale(1)";
|
|
9262
9243
|
}
|
|
9263
9244
|
},
|
|
9264
|
-
children: /* @__PURE__ */ (0,
|
|
9245
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(CardButtonContentSlot, { content: children })
|
|
9265
9246
|
}
|
|
9266
9247
|
),
|
|
9267
|
-
overlayStatus && /* @__PURE__ */ (0,
|
|
9248
|
+
overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
9268
9249
|
ProcessingOverlay,
|
|
9269
9250
|
{
|
|
9270
9251
|
status: overlayStatus,
|
|
9271
9252
|
errorMessage: overlayError
|
|
9272
9253
|
}
|
|
9273
9254
|
),
|
|
9274
|
-
fallbackSession && /* @__PURE__ */ (0,
|
|
9255
|
+
fallbackSession && /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
9275
9256
|
"div",
|
|
9276
9257
|
{
|
|
9277
9258
|
"data-testid": "flopay-automatic-payment-fallback",
|
|
@@ -9292,7 +9273,7 @@ function FloPayAutomaticPaymentButton({
|
|
|
9292
9273
|
padding: "1.5rem",
|
|
9293
9274
|
zIndex: 1100
|
|
9294
9275
|
},
|
|
9295
|
-
children: /* @__PURE__ */ (0,
|
|
9276
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
9296
9277
|
"div",
|
|
9297
9278
|
{
|
|
9298
9279
|
style: {
|
|
@@ -9308,7 +9289,7 @@ function FloPayAutomaticPaymentButton({
|
|
|
9308
9289
|
flexDirection: "column",
|
|
9309
9290
|
gap: "1rem"
|
|
9310
9291
|
},
|
|
9311
|
-
children: /* @__PURE__ */ (0,
|
|
9292
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime12.jsx)(
|
|
9312
9293
|
FloPayCheckout,
|
|
9313
9294
|
{
|
|
9314
9295
|
sessionId: fallbackSession.sessionId,
|