@flopay/react 0.3.1 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +278 -239
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -1
- package/dist/index.d.ts +5 -1
- package/dist/index.mjs +189 -150
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -116,13 +116,61 @@ function FloPayProvider({
|
|
|
116
116
|
}
|
|
117
117
|
|
|
118
118
|
// src/flopay-checkout.tsx
|
|
119
|
-
var
|
|
119
|
+
var import_react7 = __toESM(require("react"), 1);
|
|
120
120
|
var import_js = require("@flopay/js");
|
|
121
121
|
var import_shared5 = require("@flopay/shared");
|
|
122
122
|
|
|
123
|
-
// src/
|
|
123
|
+
// src/card-button-content.tsx
|
|
124
124
|
var import_react3 = require("react");
|
|
125
125
|
var import_jsx_runtime2 = require("react/jsx-runtime");
|
|
126
|
+
function DefaultCardButtonContent() {
|
|
127
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(import_jsx_runtime2.Fragment, { children: [
|
|
128
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsxs)(
|
|
129
|
+
"svg",
|
|
130
|
+
{
|
|
131
|
+
width: "20",
|
|
132
|
+
height: "20",
|
|
133
|
+
viewBox: "0 0 24 24",
|
|
134
|
+
fill: "none",
|
|
135
|
+
stroke: "currentColor",
|
|
136
|
+
strokeWidth: "1.5",
|
|
137
|
+
strokeLinecap: "round",
|
|
138
|
+
strokeLinejoin: "round",
|
|
139
|
+
"aria-hidden": "true",
|
|
140
|
+
children: [
|
|
141
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("rect", { width: "20", height: "14", x: "2", y: "5", rx: "2" }),
|
|
142
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)("line", { x1: "2", x2: "22", y1: "10", y2: "10" })
|
|
143
|
+
]
|
|
144
|
+
}
|
|
145
|
+
),
|
|
146
|
+
"Credit / Debit Card",
|
|
147
|
+
/* @__PURE__ */ (0, import_jsx_runtime2.jsx)(
|
|
148
|
+
"svg",
|
|
149
|
+
{
|
|
150
|
+
width: "16",
|
|
151
|
+
height: "16",
|
|
152
|
+
viewBox: "0 0 24 24",
|
|
153
|
+
fill: "none",
|
|
154
|
+
stroke: "#9ca3af",
|
|
155
|
+
strokeWidth: "2",
|
|
156
|
+
strokeLinecap: "round",
|
|
157
|
+
strokeLinejoin: "round",
|
|
158
|
+
style: { position: "absolute", right: "1rem" },
|
|
159
|
+
"aria-hidden": "true",
|
|
160
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime2.jsx)("path", { d: "M9 18l6-6-6-6" })
|
|
161
|
+
}
|
|
162
|
+
)
|
|
163
|
+
] });
|
|
164
|
+
}
|
|
165
|
+
function CardButtonContentSlot({
|
|
166
|
+
content
|
|
167
|
+
}) {
|
|
168
|
+
return /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(import_jsx_runtime2.Fragment, { children: content ?? /* @__PURE__ */ (0, import_jsx_runtime2.jsx)(DefaultCardButtonContent, {}) });
|
|
169
|
+
}
|
|
170
|
+
|
|
171
|
+
// src/elements.tsx
|
|
172
|
+
var import_react4 = require("react");
|
|
173
|
+
var import_jsx_runtime3 = require("react/jsx-runtime");
|
|
126
174
|
function createElementComponent(elementType, displayName) {
|
|
127
175
|
function ElementComponent({
|
|
128
176
|
className,
|
|
@@ -135,10 +183,10 @@ function createElementComponent(elementType, displayName) {
|
|
|
135
183
|
onBlur,
|
|
136
184
|
onEscape
|
|
137
185
|
}) {
|
|
138
|
-
const containerRef = (0,
|
|
139
|
-
const elementRef = (0,
|
|
140
|
-
const { elements } = (0,
|
|
141
|
-
(0,
|
|
186
|
+
const containerRef = (0, import_react4.useRef)(null);
|
|
187
|
+
const elementRef = (0, import_react4.useRef)(null);
|
|
188
|
+
const { elements } = (0, import_react4.useContext)(FloPayContext);
|
|
189
|
+
(0, import_react4.useEffect)(() => {
|
|
142
190
|
if (!elements || !containerRef.current) return;
|
|
143
191
|
let mounted = true;
|
|
144
192
|
(async () => {
|
|
@@ -168,7 +216,7 @@ function createElementComponent(elementType, displayName) {
|
|
|
168
216
|
}
|
|
169
217
|
};
|
|
170
218
|
}, [elements]);
|
|
171
|
-
return /* @__PURE__ */ (0,
|
|
219
|
+
return /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("div", { ref: containerRef, className, id, style });
|
|
172
220
|
}
|
|
173
221
|
ElementComponent.displayName = displayName;
|
|
174
222
|
return ElementComponent;
|
|
@@ -183,30 +231,30 @@ var AddressElement = createElementComponent("address", "AddressElement");
|
|
|
183
231
|
// src/split-card-form.tsx
|
|
184
232
|
var import_react_stripe_js = require("@stripe/react-stripe-js");
|
|
185
233
|
var import_shared3 = require("@flopay/shared");
|
|
186
|
-
var
|
|
234
|
+
var import_react6 = require("react");
|
|
187
235
|
|
|
188
236
|
// src/hooks.ts
|
|
189
|
-
var
|
|
237
|
+
var import_react5 = require("react");
|
|
190
238
|
var import_shared2 = require("@flopay/shared");
|
|
191
239
|
function useFloPay() {
|
|
192
|
-
const ctx = (0,
|
|
240
|
+
const ctx = (0, import_react5.useContext)(FloPayContext);
|
|
193
241
|
return ctx.flopay;
|
|
194
242
|
}
|
|
195
243
|
function useElements() {
|
|
196
|
-
const ctx = (0,
|
|
244
|
+
const ctx = (0, import_react5.useContext)(FloPayContext);
|
|
197
245
|
return ctx.elements;
|
|
198
246
|
}
|
|
199
247
|
function useCheckout() {
|
|
200
|
-
return (0,
|
|
248
|
+
return (0, import_react5.useContext)(CheckoutContext);
|
|
201
249
|
}
|
|
202
250
|
function useBillingApiUrl() {
|
|
203
|
-
const ctx = (0,
|
|
251
|
+
const ctx = (0, import_react5.useContext)(FloPayContext);
|
|
204
252
|
return ctx.billingApiUrl || (0, import_shared2.resolveBillingApiUrl)();
|
|
205
253
|
}
|
|
206
254
|
|
|
207
255
|
// src/split-card-form.tsx
|
|
208
256
|
var import_shared4 = require("@flopay/shared");
|
|
209
|
-
var
|
|
257
|
+
var import_jsx_runtime4 = require("react/jsx-runtime");
|
|
210
258
|
var WALLET_RESUME_KEY = "flopay_wallet_resume";
|
|
211
259
|
var FLOPAY_KEYFRAMES = `
|
|
212
260
|
@keyframes flopay-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
|
|
@@ -229,10 +277,10 @@ var FLOPAY_KEYFRAMES = `
|
|
|
229
277
|
}
|
|
230
278
|
`;
|
|
231
279
|
function FloPayKeyframes() {
|
|
232
|
-
return /* @__PURE__ */ (0,
|
|
280
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: FLOPAY_KEYFRAMES });
|
|
233
281
|
}
|
|
234
282
|
function ProcessingOverlay({ status, errorMessage }) {
|
|
235
|
-
return /* @__PURE__ */ (0,
|
|
283
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
|
|
236
284
|
position: "fixed",
|
|
237
285
|
inset: 0,
|
|
238
286
|
background: "rgba(0,0,0,0.35)",
|
|
@@ -241,7 +289,7 @@ function ProcessingOverlay({ status, errorMessage }) {
|
|
|
241
289
|
justifyContent: "center",
|
|
242
290
|
zIndex: 1e3,
|
|
243
291
|
backdropFilter: "blur(2px)"
|
|
244
|
-
}, children: /* @__PURE__ */ (0,
|
|
292
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
|
|
245
293
|
background: "white",
|
|
246
294
|
borderRadius: 12,
|
|
247
295
|
padding: "2rem 2.5rem",
|
|
@@ -253,8 +301,8 @@ function ProcessingOverlay({ status, errorMessage }) {
|
|
|
253
301
|
alignItems: "center",
|
|
254
302
|
gap: 16
|
|
255
303
|
}, children: [
|
|
256
|
-
/* @__PURE__ */ (0,
|
|
257
|
-
status === "processing" && /* @__PURE__ */ (0,
|
|
304
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { width: 48, height: 48, position: "relative" }, children: [
|
|
305
|
+
status === "processing" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
258
306
|
"svg",
|
|
259
307
|
{
|
|
260
308
|
width: "48",
|
|
@@ -264,14 +312,14 @@ function ProcessingOverlay({ status, errorMessage }) {
|
|
|
264
312
|
xmlns: "http://www.w3.org/2000/svg",
|
|
265
313
|
style: { animation: "flopay-spin 0.8s linear infinite" },
|
|
266
314
|
children: [
|
|
267
|
-
/* @__PURE__ */ (0,
|
|
268
|
-
/* @__PURE__ */ (0,
|
|
315
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "12", cy: "12", r: "10", stroke: "#e5e7eb", strokeWidth: "3" }),
|
|
316
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M4 12a8 8 0 018-8v3a5 5 0 00-5 5H4z", fill: "#4A49FF" })
|
|
269
317
|
]
|
|
270
318
|
}
|
|
271
319
|
),
|
|
272
|
-
status === "success" && /* @__PURE__ */ (0,
|
|
273
|
-
/* @__PURE__ */ (0,
|
|
274
|
-
/* @__PURE__ */ (0,
|
|
320
|
+
status === "success" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { animation: "flopay-pop 0.4s cubic-bezier(0.34,1.56,0.64,1)" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { width: "48", height: "48", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
321
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "12", cy: "12", r: "11", fill: "#22c55e" }),
|
|
322
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
275
323
|
"path",
|
|
276
324
|
{
|
|
277
325
|
d: "M7 12.5l3 3 7-7",
|
|
@@ -283,9 +331,9 @@ function ProcessingOverlay({ status, errorMessage }) {
|
|
|
283
331
|
}
|
|
284
332
|
)
|
|
285
333
|
] }) }),
|
|
286
|
-
status === "error" && /* @__PURE__ */ (0,
|
|
287
|
-
/* @__PURE__ */ (0,
|
|
288
|
-
/* @__PURE__ */ (0,
|
|
334
|
+
status === "error" && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { animation: "flopay-shake 0.4s ease" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { width: "48", height: "48", viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: [
|
|
335
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("circle", { cx: "12", cy: "12", r: "11", fill: "#ef4444" }),
|
|
336
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
289
337
|
"path",
|
|
290
338
|
{
|
|
291
339
|
d: "M8 8l8 8M16 8l-8 8",
|
|
@@ -297,7 +345,7 @@ function ProcessingOverlay({ status, errorMessage }) {
|
|
|
297
345
|
)
|
|
298
346
|
] }) })
|
|
299
347
|
] }),
|
|
300
|
-
/* @__PURE__ */ (0,
|
|
348
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("span", { style: {
|
|
301
349
|
fontSize: 14,
|
|
302
350
|
fontWeight: 600,
|
|
303
351
|
letterSpacing: "0.05em",
|
|
@@ -307,7 +355,7 @@ function ProcessingOverlay({ status, errorMessage }) {
|
|
|
307
355
|
status === "success" && "PAYMENT SUCCESSFUL",
|
|
308
356
|
status === "error" && "PAYMENT FAILED"
|
|
309
357
|
] }),
|
|
310
|
-
status === "error" && errorMessage && /* @__PURE__ */ (0,
|
|
358
|
+
status === "error" && errorMessage && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("p", { style: {
|
|
311
359
|
fontSize: 13,
|
|
312
360
|
color: "#6b7280",
|
|
313
361
|
fontWeight: 400,
|
|
@@ -315,7 +363,7 @@ function ProcessingOverlay({ status, errorMessage }) {
|
|
|
315
363
|
lineHeight: 1.4,
|
|
316
364
|
margin: 0
|
|
317
365
|
}, children: errorMessage }),
|
|
318
|
-
/* @__PURE__ */ (0,
|
|
366
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("style", { children: `
|
|
319
367
|
@keyframes flopay-spin { to { transform: rotate(360deg); } }
|
|
320
368
|
@keyframes flopay-pop { 0% { transform: scale(0); } 100% { transform: scale(1); } }
|
|
321
369
|
@keyframes flopay-draw { to { stroke-dashoffset: 0; } }
|
|
@@ -323,9 +371,9 @@ function ProcessingOverlay({ status, errorMessage }) {
|
|
|
323
371
|
` })
|
|
324
372
|
] }) });
|
|
325
373
|
}
|
|
326
|
-
var SplitCardForm = (0,
|
|
374
|
+
var SplitCardForm = (0, import_react6.forwardRef)(
|
|
327
375
|
function SplitCardForm2(props, ref) {
|
|
328
|
-
return /* @__PURE__ */ (0,
|
|
376
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(SplitCardFormInner, { ...props, innerRef: ref });
|
|
329
377
|
}
|
|
330
378
|
);
|
|
331
379
|
function PayPalButtonInner({
|
|
@@ -339,11 +387,11 @@ function PayPalButtonInner({
|
|
|
339
387
|
}) {
|
|
340
388
|
const stripe = (0, import_react_stripe_js.useStripe)();
|
|
341
389
|
const elements = (0, import_react_stripe_js.useElements)();
|
|
342
|
-
const [ready, setReady] = (0,
|
|
343
|
-
const [submitting, setSubmitting] = (0,
|
|
344
|
-
const paypalResumeAttempted = (0,
|
|
390
|
+
const [ready, setReady] = (0, import_react6.useState)(false);
|
|
391
|
+
const [submitting, setSubmitting] = (0, import_react6.useState)(false);
|
|
392
|
+
const paypalResumeAttempted = (0, import_react6.useRef)(false);
|
|
345
393
|
const baseUrl = billingApiUrl.replace(/\/+$/, "");
|
|
346
|
-
(0,
|
|
394
|
+
(0, import_react6.useEffect)(() => {
|
|
347
395
|
if (!stripe || paypalResumeAttempted.current) return;
|
|
348
396
|
const params = new URLSearchParams(window.location.search);
|
|
349
397
|
const paymentIntentId = params.get("payment_intent");
|
|
@@ -386,7 +434,7 @@ function PayPalButtonInner({
|
|
|
386
434
|
}
|
|
387
435
|
})();
|
|
388
436
|
}, [stripe, onTokenizedBody, onErrorChange]);
|
|
389
|
-
const handlePayPalConfirm = (0,
|
|
437
|
+
const handlePayPalConfirm = (0, import_react6.useCallback)(async (_event) => {
|
|
390
438
|
if (!stripe || !elements) return;
|
|
391
439
|
onButtonClick?.("paypal");
|
|
392
440
|
try {
|
|
@@ -442,8 +490,8 @@ function PayPalButtonInner({
|
|
|
442
490
|
setSubmitting(false);
|
|
443
491
|
}
|
|
444
492
|
}, [stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange]);
|
|
445
|
-
return /* @__PURE__ */ (0,
|
|
446
|
-
/* @__PURE__ */ (0,
|
|
493
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
494
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
447
495
|
import_react_stripe_js.ExpressCheckoutElement,
|
|
448
496
|
{
|
|
449
497
|
onReady: () => setReady(true),
|
|
@@ -461,7 +509,7 @@ function PayPalButtonInner({
|
|
|
461
509
|
}
|
|
462
510
|
}
|
|
463
511
|
) }),
|
|
464
|
-
submitting && /* @__PURE__ */ (0,
|
|
512
|
+
submitting && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ProcessingOverlay, { status: "processing" })
|
|
465
513
|
] });
|
|
466
514
|
}
|
|
467
515
|
function WalletButtonInner({
|
|
@@ -476,10 +524,10 @@ function WalletButtonInner({
|
|
|
476
524
|
}) {
|
|
477
525
|
const stripe = (0, import_react_stripe_js.useStripe)();
|
|
478
526
|
const elements = (0, import_react_stripe_js.useElements)();
|
|
479
|
-
const [ready, setReady] = (0,
|
|
480
|
-
const [submitting, setSubmitting] = (0,
|
|
527
|
+
const [ready, setReady] = (0, import_react6.useState)(false);
|
|
528
|
+
const [submitting, setSubmitting] = (0, import_react6.useState)(false);
|
|
481
529
|
const baseUrl = billingApiUrl.replace(/\/+$/, "");
|
|
482
|
-
const handleWalletConfirm = (0,
|
|
530
|
+
const handleWalletConfirm = (0, import_react6.useCallback)(
|
|
483
531
|
async (_event) => {
|
|
484
532
|
if (!stripe || !elements) return;
|
|
485
533
|
const walletType = _event.expressPaymentType;
|
|
@@ -535,8 +583,8 @@ function WalletButtonInner({
|
|
|
535
583
|
},
|
|
536
584
|
[stripe, elements, sessionId, email, baseUrl, onTokenizedBody, onErrorChange]
|
|
537
585
|
);
|
|
538
|
-
return /* @__PURE__ */ (0,
|
|
539
|
-
/* @__PURE__ */ (0,
|
|
586
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(import_jsx_runtime4.Fragment, { children: [
|
|
587
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
540
588
|
import_react_stripe_js.ExpressCheckoutElement,
|
|
541
589
|
{
|
|
542
590
|
onReady: () => setReady(true),
|
|
@@ -557,7 +605,7 @@ function WalletButtonInner({
|
|
|
557
605
|
}
|
|
558
606
|
}
|
|
559
607
|
) }),
|
|
560
|
-
submitting && /* @__PURE__ */ (0,
|
|
608
|
+
submitting && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ProcessingOverlay, { status: "processing" })
|
|
561
609
|
] });
|
|
562
610
|
}
|
|
563
611
|
function SplitCardFormInner({
|
|
@@ -585,6 +633,7 @@ function SplitCardFormInner({
|
|
|
585
633
|
layout = "default",
|
|
586
634
|
buttonsTheme,
|
|
587
635
|
buttonsStyles: buttonsStylesOverride,
|
|
636
|
+
cardButtonContent,
|
|
588
637
|
onButtonClick,
|
|
589
638
|
enableAVS = false,
|
|
590
639
|
avsLayout: avsLayoutProp = "row",
|
|
@@ -599,31 +648,31 @@ function SplitCardFormInner({
|
|
|
599
648
|
const flopay = useFloPay();
|
|
600
649
|
const elements = useElements();
|
|
601
650
|
const contextBillingUrl = useBillingApiUrl();
|
|
602
|
-
const [processing, setProcessing] = (0,
|
|
603
|
-
const [error, setError] = (0,
|
|
604
|
-
const [is3DSActive, setIs3DSActive] = (0,
|
|
605
|
-
const [selectedCountry, setSelectedCountry] = (0,
|
|
606
|
-
const [zipCode, setZipCode] = (0,
|
|
607
|
-
const zipCodeRef = (0,
|
|
608
|
-
const selectedCountryRef = (0,
|
|
609
|
-
const [viewState, setViewState] = (0,
|
|
651
|
+
const [processing, setProcessing] = (0, import_react6.useState)(false);
|
|
652
|
+
const [error, setError] = (0, import_react6.useState)(null);
|
|
653
|
+
const [is3DSActive, setIs3DSActive] = (0, import_react6.useState)(false);
|
|
654
|
+
const [selectedCountry, setSelectedCountry] = (0, import_react6.useState)(countryProp ?? "US");
|
|
655
|
+
const [zipCode, setZipCode] = (0, import_react6.useState)(zipProp ?? "");
|
|
656
|
+
const zipCodeRef = (0, import_react6.useRef)(zipProp ?? "");
|
|
657
|
+
const selectedCountryRef = (0, import_react6.useRef)(countryProp ?? "US");
|
|
658
|
+
const [viewState, setViewState] = (0, import_react6.useState)("buttons");
|
|
610
659
|
const showCardForm = viewState === "expanding" || viewState === "card";
|
|
611
660
|
const TRANSITION_MS = 280;
|
|
612
|
-
const expandToCard = (0,
|
|
661
|
+
const expandToCard = (0, import_react6.useCallback)(() => {
|
|
613
662
|
setViewState("expanding");
|
|
614
663
|
setTimeout(() => setViewState("card"), TRANSITION_MS);
|
|
615
664
|
}, []);
|
|
616
|
-
const collapseToButtons = (0,
|
|
665
|
+
const collapseToButtons = (0, import_react6.useCallback)(() => {
|
|
617
666
|
setViewState("collapsing");
|
|
618
667
|
setTimeout(() => setViewState("buttons"), TRANSITION_MS);
|
|
619
668
|
}, []);
|
|
620
|
-
const [fullName, setFullName] = (0,
|
|
621
|
-
const [formReady, setFormReady] = (0,
|
|
622
|
-
const [overlayStatus, setOverlayStatus] = (0,
|
|
623
|
-
const processingRef = (0,
|
|
669
|
+
const [fullName, setFullName] = (0, import_react6.useState)("");
|
|
670
|
+
const [formReady, setFormReady] = (0, import_react6.useState)(false);
|
|
671
|
+
const [overlayStatus, setOverlayStatus] = (0, import_react6.useState)(null);
|
|
672
|
+
const processingRef = (0, import_react6.useRef)(false);
|
|
624
673
|
const resolvedBillingApiUrl = billingApiUrl || contextBillingUrl;
|
|
625
674
|
const displayError = externalError ?? error;
|
|
626
|
-
const bStyles = (0,
|
|
675
|
+
const bStyles = (0, import_react6.useMemo)(() => {
|
|
627
676
|
const base = (0, import_shared3.resolveButtonsLayoutTheme)(buttonsTheme);
|
|
628
677
|
if (!buttonsStylesOverride) return base;
|
|
629
678
|
return {
|
|
@@ -640,25 +689,25 @@ function SplitCardFormInner({
|
|
|
640
689
|
const isSubmitting = externalProcessing ?? processing;
|
|
641
690
|
const isSelfContained = !onTokenizedBody;
|
|
642
691
|
const baseUrl = resolvedBillingApiUrl.replace(/\/+$/, "");
|
|
643
|
-
const stripeInstance = (0,
|
|
692
|
+
const stripeInstance = (0, import_react6.useMemo)(() => {
|
|
644
693
|
if (!flopay) return null;
|
|
645
694
|
return flopay.getRawProvider();
|
|
646
695
|
}, [flopay]);
|
|
647
696
|
const amountInCents = totalAmount || 100;
|
|
648
|
-
const walletOptions = (0,
|
|
697
|
+
const walletOptions = (0, import_react6.useMemo)(() => ({
|
|
649
698
|
mode: "payment",
|
|
650
699
|
amount: amountInCents,
|
|
651
700
|
currency: currency.toLowerCase(),
|
|
652
701
|
paymentMethodCreation: "manual",
|
|
653
702
|
captureMethod: "manual"
|
|
654
703
|
}), [amountInCents, currency]);
|
|
655
|
-
const paypalOptions = (0,
|
|
704
|
+
const paypalOptions = (0, import_react6.useMemo)(() => ({
|
|
656
705
|
mode: "payment",
|
|
657
706
|
amount: amountInCents,
|
|
658
707
|
currency: currency.toLowerCase(),
|
|
659
708
|
captureMethod: "manual"
|
|
660
709
|
}), [amountInCents, currency]);
|
|
661
|
-
const updateError = (0,
|
|
710
|
+
const updateError = (0, import_react6.useCallback)(
|
|
662
711
|
(err) => {
|
|
663
712
|
setError(err);
|
|
664
713
|
onErrorChange?.(err);
|
|
@@ -666,13 +715,13 @@ function SplitCardFormInner({
|
|
|
666
715
|
[onErrorChange]
|
|
667
716
|
);
|
|
668
717
|
const showWallets = showApplePay || showGooglePay;
|
|
669
|
-
const handleNameChange = (0,
|
|
718
|
+
const handleNameChange = (0, import_react6.useCallback)((value) => {
|
|
670
719
|
setFullName(value);
|
|
671
720
|
const parts = value.trim().split(/\s+/);
|
|
672
721
|
onFirstNameChange?.(parts[0] ?? "");
|
|
673
722
|
onLastNameChange?.(parts.length > 1 ? parts.slice(1).join(" ") : "");
|
|
674
723
|
}, [onFirstNameChange, onLastNameChange]);
|
|
675
|
-
const processPaymentInternal = (0,
|
|
724
|
+
const processPaymentInternal = (0, import_react6.useCallback)(
|
|
676
725
|
async (tokenizedBody) => {
|
|
677
726
|
if (processingRef.current) return;
|
|
678
727
|
processingRef.current = true;
|
|
@@ -791,7 +840,7 @@ function SplitCardFormInner({
|
|
|
791
840
|
},
|
|
792
841
|
[baseUrl, sessionId, userId, email, firstName, lastName, fullName, chv, flopay, onComplete, onError, updateError]
|
|
793
842
|
);
|
|
794
|
-
const dispatchTokenizedBody = (0,
|
|
843
|
+
const dispatchTokenizedBody = (0, import_react6.useCallback)(
|
|
795
844
|
(tokenizedBody) => {
|
|
796
845
|
if (onTokenizedBody) {
|
|
797
846
|
onTokenizedBody(tokenizedBody);
|
|
@@ -801,7 +850,7 @@ function SplitCardFormInner({
|
|
|
801
850
|
},
|
|
802
851
|
[onTokenizedBody, processPaymentInternal]
|
|
803
852
|
);
|
|
804
|
-
(0,
|
|
853
|
+
(0, import_react6.useImperativeHandle)(innerRef, () => ({
|
|
805
854
|
async handleNextAction(secret) {
|
|
806
855
|
if (!flopay) return;
|
|
807
856
|
setIs3DSActive(true);
|
|
@@ -827,7 +876,7 @@ function SplitCardFormInner({
|
|
|
827
876
|
}
|
|
828
877
|
}
|
|
829
878
|
}), [flopay, dispatchTokenizedBody, onError, updateError]);
|
|
830
|
-
(0,
|
|
879
|
+
(0, import_react6.useEffect)(() => {
|
|
831
880
|
if (typeof window === "undefined") return;
|
|
832
881
|
const stored = localStorage.getItem(WALLET_RESUME_KEY);
|
|
833
882
|
if (!stored) return;
|
|
@@ -845,7 +894,7 @@ function SplitCardFormInner({
|
|
|
845
894
|
localStorage.removeItem(WALLET_RESUME_KEY);
|
|
846
895
|
}
|
|
847
896
|
}, [sessionId, dispatchTokenizedBody]);
|
|
848
|
-
const handleSubmit = (0,
|
|
897
|
+
const handleSubmit = (0, import_react6.useCallback)(
|
|
849
898
|
async (e) => {
|
|
850
899
|
e.preventDefault();
|
|
851
900
|
if (!flopay || !elements || isSubmitting || processingRef.current) return;
|
|
@@ -925,7 +974,7 @@ function SplitCardFormInner({
|
|
|
925
974
|
);
|
|
926
975
|
const isReady = flopay !== null && elements !== null;
|
|
927
976
|
if (!isReady) {
|
|
928
|
-
return /* @__PURE__ */ (0,
|
|
977
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." });
|
|
929
978
|
}
|
|
930
979
|
const isButtons = layout === "buttons";
|
|
931
980
|
const resolvedBorder = isButtons ? bStyles.cardInputBorder ?? "#e5e7eb" : "#A4A4FF";
|
|
@@ -941,19 +990,19 @@ function SplitCardFormInner({
|
|
|
941
990
|
invalid: { color: "#ef4444" }
|
|
942
991
|
}
|
|
943
992
|
} : {};
|
|
944
|
-
const cardFormBlock = /* @__PURE__ */ (0,
|
|
993
|
+
const cardFormBlock = /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
|
|
945
994
|
backgroundColor: cardBg,
|
|
946
995
|
borderRadius: "8px",
|
|
947
996
|
padding: isButtons ? "0" : "1rem",
|
|
948
997
|
...isButtons ? bStyles.cardFormContainer : {},
|
|
949
998
|
...isButtons ? { padding: bStyles.cardFormContainer?.padding ?? "0" } : {}
|
|
950
999
|
}, children: [
|
|
951
|
-
isButtons && showCardForm && /* @__PURE__ */ (0,
|
|
1000
|
+
isButtons && showCardForm && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
|
|
952
1001
|
display: "flex",
|
|
953
1002
|
alignItems: "center",
|
|
954
1003
|
padding: "0.75rem 0 0.625rem"
|
|
955
1004
|
}, children: [
|
|
956
|
-
/* @__PURE__ */ (0,
|
|
1005
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)(
|
|
957
1006
|
"button",
|
|
958
1007
|
{
|
|
959
1008
|
type: "button",
|
|
@@ -975,7 +1024,7 @@ function SplitCardFormInner({
|
|
|
975
1024
|
},
|
|
976
1025
|
"aria-label": "Back to payment methods",
|
|
977
1026
|
children: [
|
|
978
|
-
/* @__PURE__ */ (0,
|
|
1027
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { style: {
|
|
979
1028
|
display: "inline-flex",
|
|
980
1029
|
alignItems: "center",
|
|
981
1030
|
justifyContent: "center",
|
|
@@ -985,12 +1034,12 @@ function SplitCardFormInner({
|
|
|
985
1034
|
backgroundColor: "#f3f4f6",
|
|
986
1035
|
transition: "background-color 0.15s",
|
|
987
1036
|
...bStyles.backButtonIcon
|
|
988
|
-
}, children: /* @__PURE__ */ (0,
|
|
1037
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
|
|
989
1038
|
"Go back"
|
|
990
1039
|
]
|
|
991
1040
|
}
|
|
992
1041
|
),
|
|
993
|
-
/* @__PURE__ */ (0,
|
|
1042
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
|
|
994
1043
|
flex: 1,
|
|
995
1044
|
textAlign: "center",
|
|
996
1045
|
fontWeight: 600,
|
|
@@ -1000,16 +1049,16 @@ function SplitCardFormInner({
|
|
|
1000
1049
|
...bStyles.title
|
|
1001
1050
|
}, children: "Secure card checkout" })
|
|
1002
1051
|
] }),
|
|
1003
|
-
!isButtons && /* @__PURE__ */ (0,
|
|
1004
|
-
/* @__PURE__ */ (0,
|
|
1052
|
+
!isButtons && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { textAlign: "center", fontWeight: 600, fontSize: "1.1rem", padding: "0.5rem 0", color: "#262833" }, children: "Secure card checkout" }),
|
|
1053
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
|
|
1005
1054
|
backgroundColor: cardInputBg,
|
|
1006
1055
|
border: `1px solid ${resolvedBorder}`,
|
|
1007
1056
|
borderTopLeftRadius: "8px",
|
|
1008
1057
|
borderTopRightRadius: "8px",
|
|
1009
1058
|
padding: "10px"
|
|
1010
|
-
}, children: /* @__PURE__ */ (0,
|
|
1011
|
-
/* @__PURE__ */ (0,
|
|
1012
|
-
/* @__PURE__ */ (0,
|
|
1059
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CardNumberElement, { onReady: () => setFormReady(true), options: stripeElementStyle }) }),
|
|
1060
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "flex" }, children: [
|
|
1061
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
|
|
1013
1062
|
flex: 1,
|
|
1014
1063
|
backgroundColor: cardInputBg,
|
|
1015
1064
|
border: `1px solid ${resolvedBorder}`,
|
|
@@ -1017,23 +1066,23 @@ function SplitCardFormInner({
|
|
|
1017
1066
|
borderRight: "none",
|
|
1018
1067
|
borderBottomLeftRadius: "8px",
|
|
1019
1068
|
padding: "10px"
|
|
1020
|
-
}, children: /* @__PURE__ */ (0,
|
|
1021
|
-
/* @__PURE__ */ (0,
|
|
1069
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CardExpiryElement, { options: stripeElementStyle }) }),
|
|
1070
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
|
|
1022
1071
|
flex: 1,
|
|
1023
1072
|
backgroundColor: cardInputBg,
|
|
1024
1073
|
border: `1px solid ${resolvedBorder}`,
|
|
1025
1074
|
borderTop: "none",
|
|
1026
1075
|
borderBottomRightRadius: "8px",
|
|
1027
1076
|
padding: "10px"
|
|
1028
|
-
}, children: /* @__PURE__ */ (0,
|
|
1077
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CardCvcElement, { options: stripeElementStyle }) })
|
|
1029
1078
|
] }),
|
|
1030
|
-
/* @__PURE__ */ (0,
|
|
1079
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
|
|
1031
1080
|
backgroundColor: cardInputBg,
|
|
1032
1081
|
border: `1px solid ${resolvedBorder}`,
|
|
1033
1082
|
borderRadius: "8px",
|
|
1034
1083
|
marginTop: "0.5rem",
|
|
1035
1084
|
padding: "10px"
|
|
1036
|
-
}, children: /* @__PURE__ */ (0,
|
|
1085
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1037
1086
|
"input",
|
|
1038
1087
|
{
|
|
1039
1088
|
placeholder: "Full Name on Card",
|
|
@@ -1054,20 +1103,20 @@ function SplitCardFormInner({
|
|
|
1054
1103
|
}
|
|
1055
1104
|
}
|
|
1056
1105
|
) }),
|
|
1057
|
-
enableAVS && /* @__PURE__ */ (0,
|
|
1106
|
+
enableAVS && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
|
|
1058
1107
|
display: "flex",
|
|
1059
1108
|
flexDirection: avsLayoutProp === "column" ? "column" : "row",
|
|
1060
1109
|
gap: avsLayoutProp === "column" ? "0.5rem" : "0",
|
|
1061
1110
|
marginTop: "0.5rem"
|
|
1062
1111
|
}, children: [
|
|
1063
|
-
/* @__PURE__ */ (0,
|
|
1112
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
|
|
1064
1113
|
flex: avsLayoutProp === "row" ? 1 : void 0,
|
|
1065
1114
|
backgroundColor: cardInputBg,
|
|
1066
1115
|
border: `1px solid ${resolvedBorder}`,
|
|
1067
1116
|
padding: "10px",
|
|
1068
1117
|
...avsLayoutProp === "row" ? { borderRadius: "0", borderTopLeftRadius: "8px", borderBottomLeftRadius: "8px", borderRight: "none" } : { borderRadius: "8px" },
|
|
1069
1118
|
...isButtons && bStyles.countrySelect ? bStyles.countrySelect : {}
|
|
1070
|
-
}, children: /* @__PURE__ */ (0,
|
|
1119
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1071
1120
|
"select",
|
|
1072
1121
|
{
|
|
1073
1122
|
value: selectedCountry,
|
|
@@ -1090,21 +1139,21 @@ function SplitCardFormInner({
|
|
|
1090
1139
|
cursor: "pointer",
|
|
1091
1140
|
...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
|
|
1092
1141
|
},
|
|
1093
|
-
children: import_shared3.COUNTRY_OPTIONS.map((c) => /* @__PURE__ */ (0,
|
|
1142
|
+
children: import_shared3.COUNTRY_OPTIONS.map((c) => /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("option", { value: c.code, children: [
|
|
1094
1143
|
c.flag,
|
|
1095
1144
|
" ",
|
|
1096
1145
|
c.name
|
|
1097
1146
|
] }, c.code))
|
|
1098
1147
|
}
|
|
1099
1148
|
) }),
|
|
1100
|
-
/* @__PURE__ */ (0,
|
|
1149
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
|
|
1101
1150
|
flex: avsLayoutProp === "row" ? 1 : void 0,
|
|
1102
1151
|
backgroundColor: cardInputBg,
|
|
1103
1152
|
border: `1px solid ${resolvedBorder}`,
|
|
1104
1153
|
padding: "10px",
|
|
1105
1154
|
...avsLayoutProp === "row" ? { borderRadius: "0", borderTopRightRadius: "8px", borderBottomRightRadius: "8px" } : { borderRadius: "8px" },
|
|
1106
1155
|
...isButtons && bStyles.zipInput ? bStyles.zipInput : {}
|
|
1107
|
-
}, children: /* @__PURE__ */ (0,
|
|
1156
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1108
1157
|
"input",
|
|
1109
1158
|
{
|
|
1110
1159
|
placeholder: (0, import_shared3.getPostalCodeLabel)(selectedCountry),
|
|
@@ -1131,7 +1180,7 @@ function SplitCardFormInner({
|
|
|
1131
1180
|
}
|
|
1132
1181
|
) })
|
|
1133
1182
|
] }),
|
|
1134
|
-
displayError && /* @__PURE__ */ (0,
|
|
1183
|
+
displayError && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
|
|
1135
1184
|
margin: "0.75rem 0",
|
|
1136
1185
|
padding: "0.625rem 0.875rem",
|
|
1137
1186
|
background: "#FEF2F2",
|
|
@@ -1145,10 +1194,10 @@ function SplitCardFormInner({
|
|
|
1145
1194
|
gap: "0.5rem",
|
|
1146
1195
|
...isButtons && bStyles.errorBanner ? bStyles.errorBanner : {}
|
|
1147
1196
|
}, children: [
|
|
1148
|
-
/* @__PURE__ */ (0,
|
|
1197
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z", stroke: "#DC2626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }),
|
|
1149
1198
|
displayError
|
|
1150
1199
|
] }),
|
|
1151
|
-
children ?? /* @__PURE__ */ (0,
|
|
1200
|
+
children ?? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1152
1201
|
"button",
|
|
1153
1202
|
{
|
|
1154
1203
|
type: "submit",
|
|
@@ -1171,7 +1220,7 @@ function SplitCardFormInner({
|
|
|
1171
1220
|
children: isSubmitting ? "PROCESSING..." : submitLabel
|
|
1172
1221
|
}
|
|
1173
1222
|
),
|
|
1174
|
-
!isButtons && /* @__PURE__ */ (0,
|
|
1223
|
+
!isButtons && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
|
|
1175
1224
|
backgroundColor: "#EFF9F0",
|
|
1176
1225
|
borderRadius: "8px",
|
|
1177
1226
|
padding: "0.75rem",
|
|
@@ -1187,11 +1236,11 @@ function SplitCardFormInner({
|
|
|
1187
1236
|
const isCardView = viewState === "expanding" || viewState === "card" || viewState === "collapsing";
|
|
1188
1237
|
const buttonsAnim = viewState === "expanding" ? `flopay-buttons-exit ${TRANSITION_MS}ms cubic-bezier(0.4, 0, 0.2, 1) both` : viewState === "collapsing" ? `flopay-buttons-enter ${TRANSITION_MS}ms cubic-bezier(0, 0, 0.2, 1) both` : void 0;
|
|
1189
1238
|
const cardAnim = viewState === "expanding" ? `flopay-card-enter ${TRANSITION_MS}ms cubic-bezier(0, 0, 0.2, 1) both` : viewState === "collapsing" ? `flopay-card-exit ${TRANSITION_MS}ms cubic-bezier(0.4, 0, 0.2, 1) both` : void 0;
|
|
1190
|
-
return /* @__PURE__ */ (0,
|
|
1191
|
-
/* @__PURE__ */ (0,
|
|
1192
|
-
overlayStatus && /* @__PURE__ */ (0,
|
|
1193
|
-
/* @__PURE__ */ (0,
|
|
1194
|
-
/* @__PURE__ */ (0,
|
|
1239
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
|
|
1240
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FloPayKeyframes, {}),
|
|
1241
|
+
overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
|
|
1242
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: { display: "grid" }, children: [
|
|
1243
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
|
|
1195
1244
|
gridArea: "1 / 1",
|
|
1196
1245
|
display: "flex",
|
|
1197
1246
|
flexDirection: "column",
|
|
@@ -1200,7 +1249,7 @@ function SplitCardFormInner({
|
|
|
1200
1249
|
...!isButtonsView && !buttonsAnim ? { visibility: "hidden", position: "absolute", pointerEvents: "none", width: "100%" } : {},
|
|
1201
1250
|
...buttonsAnim ? { animation: buttonsAnim, pointerEvents: "none" } : {}
|
|
1202
1251
|
}, children: [
|
|
1203
|
-
showPayPal && stripeInstance ? /* @__PURE__ */ (0,
|
|
1252
|
+
showPayPal && stripeInstance ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: paypalOptions, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1204
1253
|
PayPalButtonInner,
|
|
1205
1254
|
{
|
|
1206
1255
|
sessionId,
|
|
@@ -1211,8 +1260,8 @@ function SplitCardFormInner({
|
|
|
1211
1260
|
isProcessing: isSubmitting,
|
|
1212
1261
|
onButtonClick
|
|
1213
1262
|
}
|
|
1214
|
-
) }) : showPayPal ? /* @__PURE__ */ (0,
|
|
1215
|
-
showWallets && stripeInstance ? /* @__PURE__ */ (0,
|
|
1263
|
+
) }) : showPayPal ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { height: 44, borderRadius: 8, background: "#e5e7eb", animation: "flopay-pulse 1.5s ease-in-out infinite" } }) : null,
|
|
1264
|
+
showWallets && stripeInstance ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1216
1265
|
WalletButtonInner,
|
|
1217
1266
|
{
|
|
1218
1267
|
sessionId,
|
|
@@ -1224,8 +1273,8 @@ function SplitCardFormInner({
|
|
|
1224
1273
|
onErrorChange: updateError,
|
|
1225
1274
|
onButtonClick
|
|
1226
1275
|
}
|
|
1227
|
-
) }) : showWallets ? /* @__PURE__ */ (0,
|
|
1228
|
-
/* @__PURE__ */ (0,
|
|
1276
|
+
) }) : showWallets ? /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { height: 44, borderRadius: 8, background: "#e5e7eb", animation: "flopay-pulse 1.5s ease-in-out infinite" } }) : null,
|
|
1277
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1229
1278
|
"button",
|
|
1230
1279
|
{
|
|
1231
1280
|
type: "button",
|
|
@@ -1258,17 +1307,10 @@ function SplitCardFormInner({
|
|
|
1258
1307
|
onMouseUp: (e) => {
|
|
1259
1308
|
e.currentTarget.style.transform = "scale(1)";
|
|
1260
1309
|
},
|
|
1261
|
-
children:
|
|
1262
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsxs)("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
1263
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("rect", { width: "20", height: "14", x: "2", y: "5", rx: "2" }),
|
|
1264
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("line", { x1: "2", x2: "22", y1: "10", y2: "10" })
|
|
1265
|
-
] }),
|
|
1266
|
-
"Credit / Debit Card",
|
|
1267
|
-
/* @__PURE__ */ (0, import_jsx_runtime3.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "#9ca3af", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", style: { position: "absolute", right: "1rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime3.jsx)("path", { d: "M9 18l6-6-6-6" }) })
|
|
1268
|
-
]
|
|
1310
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(CardButtonContentSlot, { content: cardButtonContent })
|
|
1269
1311
|
}
|
|
1270
1312
|
),
|
|
1271
|
-
displayError && viewState === "buttons" && /* @__PURE__ */ (0,
|
|
1313
|
+
displayError && viewState === "buttons" && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { role: "alert", "data-testid": "flopay-error", style: {
|
|
1272
1314
|
margin: "0.25rem 0",
|
|
1273
1315
|
padding: "0.625rem 0.875rem",
|
|
1274
1316
|
background: "#FEF2F2",
|
|
@@ -1282,11 +1324,11 @@ function SplitCardFormInner({
|
|
|
1282
1324
|
gap: "0.5rem",
|
|
1283
1325
|
...bStyles.errorBanner ? bStyles.errorBanner : {}
|
|
1284
1326
|
}, children: [
|
|
1285
|
-
/* @__PURE__ */ (0,
|
|
1327
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", style: { flexShrink: 0 }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M12 9v4m0 4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z", stroke: "#DC2626", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round" }) }),
|
|
1286
1328
|
displayError
|
|
1287
1329
|
] })
|
|
1288
1330
|
] }),
|
|
1289
|
-
isCardView && /* @__PURE__ */ (0,
|
|
1331
|
+
isCardView && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: {
|
|
1290
1332
|
gridArea: "1 / 1",
|
|
1291
1333
|
...cardAnim ? { animation: cardAnim } : {},
|
|
1292
1334
|
...viewState === "collapsing" ? { pointerEvents: "none" } : {}
|
|
@@ -1294,10 +1336,10 @@ function SplitCardFormInner({
|
|
|
1294
1336
|
] })
|
|
1295
1337
|
] });
|
|
1296
1338
|
}
|
|
1297
|
-
return /* @__PURE__ */ (0,
|
|
1298
|
-
/* @__PURE__ */ (0,
|
|
1299
|
-
overlayStatus && /* @__PURE__ */ (0,
|
|
1300
|
-
showWallets && stripeInstance && /* @__PURE__ */ (0,
|
|
1339
|
+
return /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
|
|
1340
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)(FloPayKeyframes, {}),
|
|
1341
|
+
overlayStatus && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(ProcessingOverlay, { status: overlayStatus, errorMessage: displayError }),
|
|
1342
|
+
showWallets && stripeInstance && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: walletOptions, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1301
1343
|
WalletButtonInner,
|
|
1302
1344
|
{
|
|
1303
1345
|
sessionId,
|
|
@@ -1309,7 +1351,7 @@ function SplitCardFormInner({
|
|
|
1309
1351
|
onErrorChange: updateError
|
|
1310
1352
|
}
|
|
1311
1353
|
) }),
|
|
1312
|
-
showPayPal && stripeInstance && /* @__PURE__ */ (0,
|
|
1354
|
+
showPayPal && stripeInstance && /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(import_react_stripe_js.Elements, { stripe: stripeInstance, options: paypalOptions, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)(
|
|
1313
1355
|
PayPalButtonInner,
|
|
1314
1356
|
{
|
|
1315
1357
|
sessionId,
|
|
@@ -1320,7 +1362,7 @@ function SplitCardFormInner({
|
|
|
1320
1362
|
isProcessing: isSubmitting
|
|
1321
1363
|
}
|
|
1322
1364
|
) }),
|
|
1323
|
-
(showWallets && stripeInstance || showPayPal && stripeInstance) && /* @__PURE__ */ (0,
|
|
1365
|
+
(showWallets && stripeInstance || showPayPal && stripeInstance) && /* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("div", { style: {
|
|
1324
1366
|
display: "flex",
|
|
1325
1367
|
alignItems: "center",
|
|
1326
1368
|
gap: "0.75rem",
|
|
@@ -1328,16 +1370,16 @@ function SplitCardFormInner({
|
|
|
1328
1370
|
color: "#999",
|
|
1329
1371
|
fontSize: "0.85rem"
|
|
1330
1372
|
}, children: [
|
|
1331
|
-
/* @__PURE__ */ (0,
|
|
1332
|
-
/* @__PURE__ */ (0,
|
|
1333
|
-
/* @__PURE__ */ (0,
|
|
1373
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } }),
|
|
1374
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("span", { children: "or pay with card" }),
|
|
1375
|
+
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("div", { style: { flex: 1, height: 1, backgroundColor: "#ddd" } })
|
|
1334
1376
|
] }),
|
|
1335
1377
|
cardFormBlock
|
|
1336
1378
|
] });
|
|
1337
1379
|
}
|
|
1338
1380
|
|
|
1339
1381
|
// src/flopay-checkout.tsx
|
|
1340
|
-
var
|
|
1382
|
+
var import_jsx_runtime5 = require("react/jsx-runtime");
|
|
1341
1383
|
function FloPayCheckout({
|
|
1342
1384
|
sessionId: sessionIdProp,
|
|
1343
1385
|
createSession: createSessionParams,
|
|
@@ -1355,6 +1397,7 @@ function FloPayCheckout({
|
|
|
1355
1397
|
layout,
|
|
1356
1398
|
buttonsTheme,
|
|
1357
1399
|
buttonsStyles,
|
|
1400
|
+
cardButtonContent,
|
|
1358
1401
|
onButtonClick,
|
|
1359
1402
|
enableAVS,
|
|
1360
1403
|
avsLayout,
|
|
@@ -1367,24 +1410,24 @@ function FloPayCheckout({
|
|
|
1367
1410
|
onSessionCompleted
|
|
1368
1411
|
}) {
|
|
1369
1412
|
const resolvedBillingUrl = (0, import_shared5.resolveBillingApiUrl)(billingApiUrl);
|
|
1370
|
-
const [unified, setUnified] = (0,
|
|
1371
|
-
const [flopay, setFloPay] = (0,
|
|
1372
|
-
const flopayRef = (0,
|
|
1373
|
-
const [session, setSession] = (0,
|
|
1374
|
-
const [resolvedSessionId, setResolvedSessionId] = (0,
|
|
1375
|
-
const [isLoading, setIsLoading] = (0,
|
|
1376
|
-
const [loadError, setLoadError] = (0,
|
|
1377
|
-
const [currentMode, setCurrentMode] = (0,
|
|
1378
|
-
const [confirmProcessing, setConfirmProcessing] = (0,
|
|
1379
|
-
const [modeError, setModeError] = (0,
|
|
1380
|
-
const autoCheckoutAttempted = (0,
|
|
1381
|
-
const onCompleteRef = (0,
|
|
1413
|
+
const [unified, setUnified] = (0, import_react7.useState)(null);
|
|
1414
|
+
const [flopay, setFloPay] = (0, import_react7.useState)(null);
|
|
1415
|
+
const flopayRef = (0, import_react7.useRef)(null);
|
|
1416
|
+
const [session, setSession] = (0, import_react7.useState)(null);
|
|
1417
|
+
const [resolvedSessionId, setResolvedSessionId] = (0, import_react7.useState)(sessionIdProp ?? "");
|
|
1418
|
+
const [isLoading, setIsLoading] = (0, import_react7.useState)(true);
|
|
1419
|
+
const [loadError, setLoadError] = (0, import_react7.useState)(null);
|
|
1420
|
+
const [currentMode, setCurrentMode] = (0, import_react7.useState)("full");
|
|
1421
|
+
const [confirmProcessing, setConfirmProcessing] = (0, import_react7.useState)(false);
|
|
1422
|
+
const [modeError, setModeError] = (0, import_react7.useState)(null);
|
|
1423
|
+
const autoCheckoutAttempted = (0, import_react7.useRef)(false);
|
|
1424
|
+
const onCompleteRef = (0, import_react7.useRef)(onComplete);
|
|
1382
1425
|
onCompleteRef.current = onComplete;
|
|
1383
|
-
const onErrorRef = (0,
|
|
1426
|
+
const onErrorRef = (0, import_react7.useRef)(onError);
|
|
1384
1427
|
onErrorRef.current = onError;
|
|
1385
|
-
const onSessionCompletedRef = (0,
|
|
1428
|
+
const onSessionCompletedRef = (0, import_react7.useRef)(onSessionCompleted);
|
|
1386
1429
|
onSessionCompletedRef.current = onSessionCompleted;
|
|
1387
|
-
const processPaymentForMode = (0,
|
|
1430
|
+
const processPaymentForMode = (0, import_react7.useCallback)(
|
|
1388
1431
|
async (sess) => {
|
|
1389
1432
|
const baseUrl = resolvedBillingUrl.replace(/\/+$/, "");
|
|
1390
1433
|
const response = await fetch(`${baseUrl}/v1/checkouts/sessions/process`, {
|
|
@@ -1430,7 +1473,7 @@ function FloPayCheckout({
|
|
|
1430
1473
|
},
|
|
1431
1474
|
[resolvedBillingUrl, resolvedSessionId]
|
|
1432
1475
|
);
|
|
1433
|
-
const handleRedirectResult = (0,
|
|
1476
|
+
const handleRedirectResult = (0, import_react7.useCallback)(
|
|
1434
1477
|
async (redirectResult, sess, options) => {
|
|
1435
1478
|
const stripe = flopayRef.current?.getRawProvider();
|
|
1436
1479
|
if (!stripe) return false;
|
|
@@ -1475,8 +1518,8 @@ function FloPayCheckout({
|
|
|
1475
1518
|
},
|
|
1476
1519
|
[resolvedBillingUrl, resolvedSessionId]
|
|
1477
1520
|
);
|
|
1478
|
-
const inflightRef = (0,
|
|
1479
|
-
const initializedHashRef = (0,
|
|
1521
|
+
const inflightRef = (0, import_react7.useRef)(/* @__PURE__ */ new Map());
|
|
1522
|
+
const initializedHashRef = (0, import_react7.useRef)(null);
|
|
1480
1523
|
function hashCreateParams(params) {
|
|
1481
1524
|
const key = JSON.stringify({
|
|
1482
1525
|
c: params?.clientId,
|
|
@@ -1491,7 +1534,7 @@ function FloPayCheckout({
|
|
|
1491
1534
|
}
|
|
1492
1535
|
return `flopay_session_${Math.abs(h).toString(36)}`;
|
|
1493
1536
|
}
|
|
1494
|
-
const createSessionHash = (0,
|
|
1537
|
+
const createSessionHash = (0, import_react7.useMemo)(
|
|
1495
1538
|
() => createSessionParams ? hashCreateParams(createSessionParams) : "",
|
|
1496
1539
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1497
1540
|
[
|
|
@@ -1502,9 +1545,9 @@ function FloPayCheckout({
|
|
|
1502
1545
|
JSON.stringify(createSessionParams?.subscriptions)
|
|
1503
1546
|
]
|
|
1504
1547
|
);
|
|
1505
|
-
const createSessionParamsRef = (0,
|
|
1548
|
+
const createSessionParamsRef = (0, import_react7.useRef)(createSessionParams);
|
|
1506
1549
|
createSessionParamsRef.current = createSessionParams;
|
|
1507
|
-
(0,
|
|
1550
|
+
(0, import_react7.useEffect)(() => {
|
|
1508
1551
|
let cancelled = false;
|
|
1509
1552
|
setLoadError(null);
|
|
1510
1553
|
if (createSessionHash) {
|
|
@@ -1709,7 +1752,7 @@ function FloPayCheckout({
|
|
|
1709
1752
|
cancelled = true;
|
|
1710
1753
|
};
|
|
1711
1754
|
}, [resolvedSessionId, createSessionHash, resolvedBillingUrl, fallbackPublishableKey, locale, checkoutModeProp]);
|
|
1712
|
-
const handleConfirmCheckout = (0,
|
|
1755
|
+
const handleConfirmCheckout = (0, import_react7.useCallback)(async () => {
|
|
1713
1756
|
if (confirmProcessing || !session) return;
|
|
1714
1757
|
setConfirmProcessing(true);
|
|
1715
1758
|
setModeError(null);
|
|
@@ -1734,7 +1777,7 @@ function FloPayCheckout({
|
|
|
1734
1777
|
setConfirmProcessing(false);
|
|
1735
1778
|
}
|
|
1736
1779
|
}, [confirmProcessing, session, processPaymentForMode, handleRedirectResult, onError]);
|
|
1737
|
-
const providerOptions = (0,
|
|
1780
|
+
const providerOptions = (0, import_react7.useMemo)(() => {
|
|
1738
1781
|
if (!unified || !session) return void 0;
|
|
1739
1782
|
const opts = {
|
|
1740
1783
|
appearance,
|
|
@@ -1750,7 +1793,7 @@ function FloPayCheckout({
|
|
|
1750
1793
|
}
|
|
1751
1794
|
return opts;
|
|
1752
1795
|
}, [unified, session, appearance, resolvedBillingUrl]);
|
|
1753
|
-
const checkoutValue = (0,
|
|
1796
|
+
const checkoutValue = (0, import_react7.useMemo)(
|
|
1754
1797
|
() => ({
|
|
1755
1798
|
session,
|
|
1756
1799
|
loading: isLoading,
|
|
@@ -1760,23 +1803,23 @@ function FloPayCheckout({
|
|
|
1760
1803
|
[session, isLoading, loadError, currentMode]
|
|
1761
1804
|
);
|
|
1762
1805
|
if (isLoading) {
|
|
1763
|
-
if (loadingNode) return /* @__PURE__ */ (0,
|
|
1806
|
+
if (loadingNode) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: loadingNode });
|
|
1764
1807
|
if (layout === "buttons") {
|
|
1765
|
-
const skeletonBar = (h) => /* @__PURE__ */ (0,
|
|
1808
|
+
const skeletonBar = (h) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
|
|
1766
1809
|
height: h,
|
|
1767
1810
|
borderRadius: 8,
|
|
1768
1811
|
background: "#e5e7eb",
|
|
1769
1812
|
animation: "flopay-loading-pulse 1.5s ease-in-out infinite"
|
|
1770
1813
|
} });
|
|
1771
|
-
return /* @__PURE__ */ (0,
|
|
1814
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
|
|
1772
1815
|
showPayPal && skeletonBar(44),
|
|
1773
1816
|
(showApplePay || showGooglePay) && skeletonBar(44),
|
|
1774
1817
|
skeletonBar(48),
|
|
1775
|
-
/* @__PURE__ */ (0,
|
|
1818
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("style", { children: `@keyframes flopay-loading-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
|
|
1776
1819
|
] });
|
|
1777
1820
|
}
|
|
1778
|
-
return /* @__PURE__ */ (0,
|
|
1779
|
-
/* @__PURE__ */ (0,
|
|
1821
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex", justifyContent: "center", padding: 32 }, children: [
|
|
1822
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
|
|
1780
1823
|
width: 24,
|
|
1781
1824
|
height: 24,
|
|
1782
1825
|
border: "2px solid #e5e7eb",
|
|
@@ -1784,12 +1827,12 @@ function FloPayCheckout({
|
|
|
1784
1827
|
borderRadius: "50%",
|
|
1785
1828
|
animation: "spin 0.6s linear infinite"
|
|
1786
1829
|
} }),
|
|
1787
|
-
/* @__PURE__ */ (0,
|
|
1830
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("style", { children: `@keyframes spin { to { transform: rotate(360deg); } }` })
|
|
1788
1831
|
] });
|
|
1789
1832
|
}
|
|
1790
1833
|
if (loadError) {
|
|
1791
|
-
if (errorNode) return /* @__PURE__ */ (0,
|
|
1792
|
-
return /* @__PURE__ */ (0,
|
|
1834
|
+
if (errorNode) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: errorNode(loadError) });
|
|
1835
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1793
1836
|
"div",
|
|
1794
1837
|
{
|
|
1795
1838
|
style: {
|
|
@@ -1803,7 +1846,7 @@ function FloPayCheckout({
|
|
|
1803
1846
|
);
|
|
1804
1847
|
}
|
|
1805
1848
|
if ((!flopay || !providerOptions) && createSessionParams && layout === "buttons") {
|
|
1806
|
-
return /* @__PURE__ */ (0,
|
|
1849
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1807
1850
|
InterimButtonsView,
|
|
1808
1851
|
{
|
|
1809
1852
|
onButtonClick,
|
|
@@ -1811,14 +1854,15 @@ function FloPayCheckout({
|
|
|
1811
1854
|
showApplePay,
|
|
1812
1855
|
showGooglePay,
|
|
1813
1856
|
buttonsTheme,
|
|
1814
|
-
buttonsStyles
|
|
1857
|
+
buttonsStyles,
|
|
1858
|
+
cardButtonContent
|
|
1815
1859
|
}
|
|
1816
1860
|
) });
|
|
1817
1861
|
}
|
|
1818
|
-
if (!flopay || !providerOptions) return /* @__PURE__ */ (0,
|
|
1862
|
+
if (!flopay || !providerOptions) return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, {});
|
|
1819
1863
|
if (currentMode === "confirm") {
|
|
1820
|
-
return /* @__PURE__ */ (0,
|
|
1821
|
-
modeError && /* @__PURE__ */ (0,
|
|
1864
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(FloPayProvider, { flopay, options: providerOptions, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { className, children: [
|
|
1865
|
+
modeError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1822
1866
|
"div",
|
|
1823
1867
|
{
|
|
1824
1868
|
style: {
|
|
@@ -1833,7 +1877,7 @@ function FloPayCheckout({
|
|
|
1833
1877
|
renderConfirmButton ? renderConfirmButton({
|
|
1834
1878
|
onConfirm: handleConfirmCheckout,
|
|
1835
1879
|
isProcessing: confirmProcessing
|
|
1836
|
-
}) : /* @__PURE__ */ (0,
|
|
1880
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1837
1881
|
"button",
|
|
1838
1882
|
{
|
|
1839
1883
|
type: "button",
|
|
@@ -1856,8 +1900,8 @@ function FloPayCheckout({
|
|
|
1856
1900
|
)
|
|
1857
1901
|
] }) }) });
|
|
1858
1902
|
}
|
|
1859
|
-
return /* @__PURE__ */ (0,
|
|
1860
|
-
modeError && /* @__PURE__ */ (0,
|
|
1903
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CheckoutContext.Provider, { value: checkoutValue, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(FloPayProvider, { flopay, options: providerOptions, children: [
|
|
1904
|
+
modeError && /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1861
1905
|
"div",
|
|
1862
1906
|
{
|
|
1863
1907
|
style: {
|
|
@@ -1872,7 +1916,7 @@ function FloPayCheckout({
|
|
|
1872
1916
|
children: modeError
|
|
1873
1917
|
}
|
|
1874
1918
|
),
|
|
1875
|
-
children ? /* @__PURE__ */ (0,
|
|
1919
|
+
children ? /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1876
1920
|
SessionInjector,
|
|
1877
1921
|
{
|
|
1878
1922
|
sessionId: resolvedSessionId,
|
|
@@ -1880,7 +1924,7 @@ function FloPayCheckout({
|
|
|
1880
1924
|
session,
|
|
1881
1925
|
children
|
|
1882
1926
|
}
|
|
1883
|
-
) : /* @__PURE__ */ (0,
|
|
1927
|
+
) : /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
1884
1928
|
SplitCardForm,
|
|
1885
1929
|
{
|
|
1886
1930
|
sessionId: resolvedSessionId,
|
|
@@ -1898,6 +1942,7 @@ function FloPayCheckout({
|
|
|
1898
1942
|
layout,
|
|
1899
1943
|
buttonsTheme,
|
|
1900
1944
|
buttonsStyles,
|
|
1945
|
+
cardButtonContent,
|
|
1901
1946
|
onButtonClick,
|
|
1902
1947
|
enableAVS,
|
|
1903
1948
|
avsLayout,
|
|
@@ -1915,8 +1960,8 @@ function SessionInjector({
|
|
|
1915
1960
|
session,
|
|
1916
1961
|
children
|
|
1917
1962
|
}) {
|
|
1918
|
-
return /* @__PURE__ */ (0,
|
|
1919
|
-
if (!
|
|
1963
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(import_jsx_runtime5.Fragment, { children: import_react7.default.Children.map(children, (child) => {
|
|
1964
|
+
if (!import_react7.default.isValidElement(child)) return child;
|
|
1920
1965
|
const existing = child.props;
|
|
1921
1966
|
const injected = {};
|
|
1922
1967
|
if (!existing.sessionId) injected.sessionId = sessionId;
|
|
@@ -1930,7 +1975,7 @@ function SessionInjector({
|
|
|
1930
1975
|
injected.lastName = session.customer.lastName;
|
|
1931
1976
|
}
|
|
1932
1977
|
if (Object.keys(injected).length === 0) return child;
|
|
1933
|
-
return
|
|
1978
|
+
return import_react7.default.cloneElement(child, injected);
|
|
1934
1979
|
}) });
|
|
1935
1980
|
}
|
|
1936
1981
|
function InterimButtonsView({
|
|
@@ -1939,10 +1984,11 @@ function InterimButtonsView({
|
|
|
1939
1984
|
showApplePay,
|
|
1940
1985
|
showGooglePay,
|
|
1941
1986
|
buttonsTheme,
|
|
1942
|
-
buttonsStyles: stylesOverride
|
|
1987
|
+
buttonsStyles: stylesOverride,
|
|
1988
|
+
cardButtonContent
|
|
1943
1989
|
}) {
|
|
1944
|
-
const [showCardForm, setShowCardForm] = (0,
|
|
1945
|
-
const bStyles = (0,
|
|
1990
|
+
const [showCardForm, setShowCardForm] = (0, import_react7.useState)(false);
|
|
1991
|
+
const bStyles = (0, import_react7.useMemo)(() => {
|
|
1946
1992
|
const base = (0, import_shared5.resolveButtonsLayoutTheme)(buttonsTheme);
|
|
1947
1993
|
if (!stylesOverride) return base;
|
|
1948
1994
|
return {
|
|
@@ -1954,7 +2000,7 @@ function InterimButtonsView({
|
|
|
1954
2000
|
title: { ...base.title, ...stylesOverride.title }
|
|
1955
2001
|
};
|
|
1956
2002
|
}, [buttonsTheme, stylesOverride]);
|
|
1957
|
-
const skeleton = (h) => /* @__PURE__ */ (0,
|
|
2003
|
+
const skeleton = (h) => /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
|
|
1958
2004
|
height: h,
|
|
1959
2005
|
borderRadius: 8,
|
|
1960
2006
|
background: "#e5e7eb",
|
|
@@ -1963,15 +2009,15 @@ function InterimButtonsView({
|
|
|
1963
2009
|
if (showCardForm) {
|
|
1964
2010
|
const inputBorder = bStyles.cardInputBorder ?? "#e5e7eb";
|
|
1965
2011
|
const inputBg = bStyles.cardInputBackground ?? "white";
|
|
1966
|
-
return /* @__PURE__ */ (0,
|
|
2012
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: {
|
|
1967
2013
|
backgroundColor: bStyles.cardFormContainer?.backgroundColor ?? "white",
|
|
1968
2014
|
borderRadius: "8px",
|
|
1969
2015
|
animation: "flopay-interim-expand 0.35s cubic-bezier(0.4, 0, 0.2, 1) both",
|
|
1970
2016
|
overflow: "hidden",
|
|
1971
2017
|
...bStyles.cardFormContainer
|
|
1972
2018
|
}, children: [
|
|
1973
|
-
/* @__PURE__ */ (0,
|
|
1974
|
-
/* @__PURE__ */ (0,
|
|
2019
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex", alignItems: "center", padding: "0.75rem 0 0.625rem" }, children: [
|
|
2020
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)(
|
|
1975
2021
|
"button",
|
|
1976
2022
|
{
|
|
1977
2023
|
type: "button",
|
|
@@ -1991,7 +2037,7 @@ function InterimButtonsView({
|
|
|
1991
2037
|
...bStyles.backButton
|
|
1992
2038
|
},
|
|
1993
2039
|
children: [
|
|
1994
|
-
/* @__PURE__ */ (0,
|
|
2040
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("span", { style: {
|
|
1995
2041
|
display: "inline-flex",
|
|
1996
2042
|
alignItems: "center",
|
|
1997
2043
|
justifyContent: "center",
|
|
@@ -2000,12 +2046,12 @@ function InterimButtonsView({
|
|
|
2000
2046
|
borderRadius: "50%",
|
|
2001
2047
|
backgroundColor: "#f3f4f6",
|
|
2002
2048
|
...bStyles.backButtonIcon
|
|
2003
|
-
}, children: /* @__PURE__ */ (0,
|
|
2049
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("path", { d: "M15 18l-6-6 6-6" }) }) }),
|
|
2004
2050
|
"Go back"
|
|
2005
2051
|
]
|
|
2006
2052
|
}
|
|
2007
2053
|
),
|
|
2008
|
-
/* @__PURE__ */ (0,
|
|
2054
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
|
|
2009
2055
|
flex: 1,
|
|
2010
2056
|
textAlign: "center",
|
|
2011
2057
|
fontWeight: 600,
|
|
@@ -2015,13 +2061,13 @@ function InterimButtonsView({
|
|
|
2015
2061
|
...bStyles.title
|
|
2016
2062
|
}, children: "Secure card checkout" })
|
|
2017
2063
|
] }),
|
|
2018
|
-
/* @__PURE__ */ (0,
|
|
2019
|
-
/* @__PURE__ */ (0,
|
|
2020
|
-
/* @__PURE__ */ (0,
|
|
2021
|
-
/* @__PURE__ */ (0,
|
|
2064
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTopLeftRadius: 8, borderTopRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { width: "60%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
|
|
2065
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex" }, children: [
|
|
2066
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { flex: 1, backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTop: "none", borderRight: "none", borderBottomLeftRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { width: "50%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
|
|
2067
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { flex: 1, backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTop: "none", borderBottomRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { width: "40%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) })
|
|
2022
2068
|
] }),
|
|
2023
|
-
/* @__PURE__ */ (0,
|
|
2024
|
-
/* @__PURE__ */ (0,
|
|
2069
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderRadius: 8, marginTop: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: { width: "45%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
|
|
2070
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("div", { style: {
|
|
2025
2071
|
height: 50,
|
|
2026
2072
|
borderRadius: 8,
|
|
2027
2073
|
marginTop: 16,
|
|
@@ -2030,7 +2076,7 @@ function InterimButtonsView({
|
|
|
2030
2076
|
...bStyles.submitButton,
|
|
2031
2077
|
opacity: 0.5
|
|
2032
2078
|
} }),
|
|
2033
|
-
/* @__PURE__ */ (0,
|
|
2079
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("style", { children: `
|
|
2034
2080
|
@keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
|
|
2035
2081
|
@keyframes flopay-interim-expand {
|
|
2036
2082
|
0% { opacity: 0; max-height: 0; transform: translateY(-12px); }
|
|
@@ -2040,10 +2086,10 @@ function InterimButtonsView({
|
|
|
2040
2086
|
` })
|
|
2041
2087
|
] });
|
|
2042
2088
|
}
|
|
2043
|
-
return /* @__PURE__ */ (0,
|
|
2089
|
+
return /* @__PURE__ */ (0, import_jsx_runtime5.jsxs)("div", { style: { display: "flex", flexDirection: "column", gap: "0.5rem" }, children: [
|
|
2044
2090
|
showPayPal && skeleton(44),
|
|
2045
2091
|
(showApplePay || showGooglePay) && skeleton(44),
|
|
2046
|
-
/* @__PURE__ */ (0,
|
|
2092
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)(
|
|
2047
2093
|
"button",
|
|
2048
2094
|
{
|
|
2049
2095
|
type: "button",
|
|
@@ -2076,28 +2122,21 @@ function InterimButtonsView({
|
|
|
2076
2122
|
onMouseUp: (e) => {
|
|
2077
2123
|
e.currentTarget.style.transform = "scale(1)";
|
|
2078
2124
|
},
|
|
2079
|
-
children:
|
|
2080
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsxs)("svg", { width: "20", height: "20", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "1.5", strokeLinecap: "round", strokeLinejoin: "round", children: [
|
|
2081
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("rect", { width: "20", height: "14", x: "2", y: "5", rx: "2" }),
|
|
2082
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("line", { x1: "2", x2: "22", y1: "10", y2: "10" })
|
|
2083
|
-
] }),
|
|
2084
|
-
"Credit / Debit Card",
|
|
2085
|
-
/* @__PURE__ */ (0, import_jsx_runtime4.jsx)("svg", { width: "16", height: "16", viewBox: "0 0 24 24", fill: "none", stroke: "#9ca3af", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", style: { position: "absolute", right: "1rem" }, children: /* @__PURE__ */ (0, import_jsx_runtime4.jsx)("path", { d: "M9 18l6-6-6-6" }) })
|
|
2086
|
-
]
|
|
2125
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime5.jsx)(CardButtonContentSlot, { content: cardButtonContent })
|
|
2087
2126
|
}
|
|
2088
2127
|
),
|
|
2089
|
-
/* @__PURE__ */ (0,
|
|
2128
|
+
/* @__PURE__ */ (0, import_jsx_runtime5.jsx)("style", { children: `@keyframes flopay-interim-pulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }` })
|
|
2090
2129
|
] });
|
|
2091
2130
|
}
|
|
2092
2131
|
|
|
2093
2132
|
// src/checkout-form.tsx
|
|
2094
2133
|
var import_shared6 = require("@flopay/shared");
|
|
2095
|
-
var
|
|
2096
|
-
var
|
|
2134
|
+
var import_react8 = require("react");
|
|
2135
|
+
var import_jsx_runtime6 = require("react/jsx-runtime");
|
|
2097
2136
|
var WALLET_RESUME_KEY2 = "flopay_wallet_resume";
|
|
2098
|
-
var CheckoutForm = (0,
|
|
2137
|
+
var CheckoutForm = (0, import_react8.forwardRef)(
|
|
2099
2138
|
function CheckoutForm2(props, ref) {
|
|
2100
|
-
return /* @__PURE__ */ (0,
|
|
2139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(CheckoutFormInner, { ...props, innerRef: ref });
|
|
2101
2140
|
}
|
|
2102
2141
|
);
|
|
2103
2142
|
function CheckoutFormInner({
|
|
@@ -2124,21 +2163,21 @@ function CheckoutFormInner({
|
|
|
2124
2163
|
const flopay = useFloPay();
|
|
2125
2164
|
const elements = useElements();
|
|
2126
2165
|
const contextBillingUrl = useBillingApiUrl();
|
|
2127
|
-
const [processing, setProcessing] = (0,
|
|
2128
|
-
const [error, setError] = (0,
|
|
2129
|
-
const [is3DSActive, setIs3DSActive] = (0,
|
|
2166
|
+
const [processing, setProcessing] = (0, import_react8.useState)(false);
|
|
2167
|
+
const [error, setError] = (0, import_react8.useState)(null);
|
|
2168
|
+
const [is3DSActive, setIs3DSActive] = (0, import_react8.useState)(false);
|
|
2130
2169
|
const displayError = externalError ?? error;
|
|
2131
2170
|
const isSubmitting = externalProcessing ?? processing;
|
|
2132
2171
|
const isSelfContained = !onTokenizedBody;
|
|
2133
2172
|
const baseUrl = (billingApiUrl || contextBillingUrl).replace(/\/+$/, "");
|
|
2134
|
-
const updateError = (0,
|
|
2173
|
+
const updateError = (0, import_react8.useCallback)(
|
|
2135
2174
|
(err) => {
|
|
2136
2175
|
setError(err);
|
|
2137
2176
|
onErrorChange?.(err);
|
|
2138
2177
|
},
|
|
2139
2178
|
[onErrorChange]
|
|
2140
2179
|
);
|
|
2141
|
-
const processPaymentInternal = (0,
|
|
2180
|
+
const processPaymentInternal = (0, import_react8.useCallback)(
|
|
2142
2181
|
async (tokenizedBody) => {
|
|
2143
2182
|
setProcessing(true);
|
|
2144
2183
|
updateError(null);
|
|
@@ -2226,7 +2265,7 @@ function CheckoutFormInner({
|
|
|
2226
2265
|
},
|
|
2227
2266
|
[baseUrl, sessionId, userId, email, firstName, lastName, chv, flopay, onComplete, onError, updateError]
|
|
2228
2267
|
);
|
|
2229
|
-
const dispatchTokenizedBody = (0,
|
|
2268
|
+
const dispatchTokenizedBody = (0, import_react8.useCallback)(
|
|
2230
2269
|
(tokenizedBody) => {
|
|
2231
2270
|
if (onTokenizedBody) {
|
|
2232
2271
|
onTokenizedBody(tokenizedBody);
|
|
@@ -2236,7 +2275,7 @@ function CheckoutFormInner({
|
|
|
2236
2275
|
},
|
|
2237
2276
|
[onTokenizedBody, processPaymentInternal]
|
|
2238
2277
|
);
|
|
2239
|
-
(0,
|
|
2278
|
+
(0, import_react8.useImperativeHandle)(innerRef, () => ({
|
|
2240
2279
|
async handleNextAction(secret) {
|
|
2241
2280
|
if (!flopay) return;
|
|
2242
2281
|
setIs3DSActive(true);
|
|
@@ -2262,7 +2301,7 @@ function CheckoutFormInner({
|
|
|
2262
2301
|
}
|
|
2263
2302
|
}
|
|
2264
2303
|
}), [flopay, dispatchTokenizedBody, onError, updateError]);
|
|
2265
|
-
(0,
|
|
2304
|
+
(0, import_react8.useEffect)(() => {
|
|
2266
2305
|
if (typeof window === "undefined") return;
|
|
2267
2306
|
const stored = localStorage.getItem(WALLET_RESUME_KEY2);
|
|
2268
2307
|
if (!stored) return;
|
|
@@ -2280,7 +2319,7 @@ function CheckoutFormInner({
|
|
|
2280
2319
|
localStorage.removeItem(WALLET_RESUME_KEY2);
|
|
2281
2320
|
}
|
|
2282
2321
|
}, [sessionId, dispatchTokenizedBody]);
|
|
2283
|
-
const handleSubmit = (0,
|
|
2322
|
+
const handleSubmit = (0, import_react8.useCallback)(
|
|
2284
2323
|
async (e) => {
|
|
2285
2324
|
e.preventDefault();
|
|
2286
2325
|
if (!flopay || !elements || isSubmitting) return;
|
|
@@ -2340,8 +2379,8 @@ function CheckoutFormInner({
|
|
|
2340
2379
|
[flopay, elements, isSubmitting, sessionId, email, baseUrl, isSelfContained, dispatchTokenizedBody, onError, updateError]
|
|
2341
2380
|
);
|
|
2342
2381
|
const isReady = flopay !== null && elements !== null;
|
|
2343
|
-
return /* @__PURE__ */ (0,
|
|
2344
|
-
(is3DSActive || isSubmitting) && /* @__PURE__ */ (0,
|
|
2382
|
+
return /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)("form", { onSubmit: handleSubmit, className, style: { position: "relative" }, children: [
|
|
2383
|
+
(is3DSActive || isSubmitting) && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { "data-testid": "flopay-overlay", style: {
|
|
2345
2384
|
position: "absolute",
|
|
2346
2385
|
inset: 0,
|
|
2347
2386
|
background: "rgba(255,255,255,0.7)",
|
|
@@ -2350,12 +2389,12 @@ function CheckoutFormInner({
|
|
|
2350
2389
|
justifyContent: "center",
|
|
2351
2390
|
zIndex: 10
|
|
2352
2391
|
}, children: is3DSActive ? "Verifying payment..." : "Processing..." }),
|
|
2353
|
-
!isReady && /* @__PURE__ */ (0,
|
|
2354
|
-
isReady && /* @__PURE__ */ (0,
|
|
2355
|
-
/* @__PURE__ */ (0,
|
|
2356
|
-
showAddress && /* @__PURE__ */ (0,
|
|
2357
|
-
displayError && /* @__PURE__ */ (0,
|
|
2358
|
-
children ?? /* @__PURE__ */ (0,
|
|
2392
|
+
!isReady && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { "data-testid": "flopay-loading", "aria-busy": "true", children: "Loading payment form..." }),
|
|
2393
|
+
isReady && /* @__PURE__ */ (0, import_jsx_runtime6.jsxs)(import_jsx_runtime6.Fragment, { children: [
|
|
2394
|
+
/* @__PURE__ */ (0, import_jsx_runtime6.jsx)(PaymentElement, { options: { layout } }),
|
|
2395
|
+
showAddress && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(AddressElement, { options: { mode: showAddress === true ? "billing" : showAddress } }),
|
|
2396
|
+
displayError && /* @__PURE__ */ (0, import_jsx_runtime6.jsx)("div", { role: "alert", "data-testid": "flopay-error", style: { color: "red", margin: "0.75rem 0" }, children: displayError }),
|
|
2397
|
+
children ?? /* @__PURE__ */ (0, import_jsx_runtime6.jsx)(
|
|
2359
2398
|
"button",
|
|
2360
2399
|
{
|
|
2361
2400
|
type: "submit",
|
|
@@ -2370,8 +2409,8 @@ function CheckoutFormInner({
|
|
|
2370
2409
|
|
|
2371
2410
|
// src/paypal-button.tsx
|
|
2372
2411
|
var import_shared7 = require("@flopay/shared");
|
|
2373
|
-
var
|
|
2374
|
-
var
|
|
2412
|
+
var import_react9 = require("react");
|
|
2413
|
+
var import_jsx_runtime7 = require("react/jsx-runtime");
|
|
2375
2414
|
function PayPalButton({
|
|
2376
2415
|
sessionId,
|
|
2377
2416
|
billingApiUrl,
|
|
@@ -2388,11 +2427,11 @@ function PayPalButton({
|
|
|
2388
2427
|
const flopay = useFloPay();
|
|
2389
2428
|
const elements = useElements();
|
|
2390
2429
|
const contextBillingUrl = useBillingApiUrl();
|
|
2391
|
-
const [ready, setReady] = (0,
|
|
2392
|
-
const [submitting, setSubmitting] = (0,
|
|
2393
|
-
const paypalResumeAttempted = (0,
|
|
2430
|
+
const [ready, setReady] = (0, import_react9.useState)(false);
|
|
2431
|
+
const [submitting, setSubmitting] = (0, import_react9.useState)(false);
|
|
2432
|
+
const paypalResumeAttempted = (0, import_react9.useRef)(false);
|
|
2394
2433
|
const baseUrl = (billingApiUrl || contextBillingUrl).replace(/\/+$/, "");
|
|
2395
|
-
const processPaymentInternal = (0,
|
|
2434
|
+
const processPaymentInternal = (0, import_react9.useCallback)(
|
|
2396
2435
|
async (tokenizedBody) => {
|
|
2397
2436
|
try {
|
|
2398
2437
|
const response = await fetch(`${baseUrl}/v1/checkouts/sessions/process`, {
|
|
@@ -2425,7 +2464,7 @@ function PayPalButton({
|
|
|
2425
2464
|
},
|
|
2426
2465
|
[baseUrl, sessionId, userId, email, firstName, lastName, chv, onComplete, onErrorChange]
|
|
2427
2466
|
);
|
|
2428
|
-
const dispatchTokenizedBody = (0,
|
|
2467
|
+
const dispatchTokenizedBody = (0, import_react9.useCallback)(
|
|
2429
2468
|
(body) => {
|
|
2430
2469
|
if (onTokenizedBody) {
|
|
2431
2470
|
onTokenizedBody(body);
|
|
@@ -2435,7 +2474,7 @@ function PayPalButton({
|
|
|
2435
2474
|
},
|
|
2436
2475
|
[onTokenizedBody, processPaymentInternal]
|
|
2437
2476
|
);
|
|
2438
|
-
(0,
|
|
2477
|
+
(0, import_react9.useEffect)(() => {
|
|
2439
2478
|
if (!flopay || paypalResumeAttempted.current) return;
|
|
2440
2479
|
const params = new URLSearchParams(window.location.search);
|
|
2441
2480
|
const paymentIntentId = params.get("payment_intent");
|
|
@@ -2483,7 +2522,7 @@ function PayPalButton({
|
|
|
2483
2522
|
}
|
|
2484
2523
|
})();
|
|
2485
2524
|
}, [flopay, dispatchTokenizedBody, onErrorChange]);
|
|
2486
|
-
const handlePayPalConfirm = (0,
|
|
2525
|
+
const handlePayPalConfirm = (0, import_react9.useCallback)(async () => {
|
|
2487
2526
|
if (!flopay || !elements) return;
|
|
2488
2527
|
try {
|
|
2489
2528
|
setSubmitting(true);
|
|
@@ -2526,11 +2565,11 @@ function PayPalButton({
|
|
|
2526
2565
|
}
|
|
2527
2566
|
}, [flopay, elements, sessionId, email, baseUrl, dispatchTokenizedBody, onErrorChange]);
|
|
2528
2567
|
if (!flopay || !elements) {
|
|
2529
|
-
return /* @__PURE__ */ (0,
|
|
2568
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6, animation: "pulse 1.5s infinite" } });
|
|
2530
2569
|
}
|
|
2531
|
-
return /* @__PURE__ */ (0,
|
|
2532
|
-
!ready && /* @__PURE__ */ (0,
|
|
2533
|
-
/* @__PURE__ */ (0,
|
|
2570
|
+
return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_jsx_runtime7.Fragment, { children: [
|
|
2571
|
+
!ready && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: { height: 45, background: "#f0f0f0", borderRadius: 6 } }),
|
|
2572
|
+
/* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: ready ? {} : { display: "none" }, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)(
|
|
2534
2573
|
"button",
|
|
2535
2574
|
{
|
|
2536
2575
|
type: "button",
|
|
@@ -2552,7 +2591,7 @@ function PayPalButton({
|
|
|
2552
2591
|
children: submitting ? "Processing..." : "PayPal"
|
|
2553
2592
|
}
|
|
2554
2593
|
) }),
|
|
2555
|
-
(submitting || isProcessing) && /* @__PURE__ */ (0,
|
|
2594
|
+
(submitting || isProcessing) && /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
|
|
2556
2595
|
position: "fixed",
|
|
2557
2596
|
inset: 0,
|
|
2558
2597
|
background: "rgba(0,0,0,0.4)",
|
|
@@ -2560,7 +2599,7 @@ function PayPalButton({
|
|
|
2560
2599
|
alignItems: "center",
|
|
2561
2600
|
justifyContent: "center",
|
|
2562
2601
|
zIndex: 1e3
|
|
2563
|
-
}, children: /* @__PURE__ */ (0,
|
|
2602
|
+
}, children: /* @__PURE__ */ (0, import_jsx_runtime7.jsx)("div", { style: {
|
|
2564
2603
|
background: "white",
|
|
2565
2604
|
borderRadius: 8,
|
|
2566
2605
|
padding: "1.5rem",
|