@flopay/react 0.4.11 → 0.5.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/dist/index.cjs +291 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -7
- package/dist/index.d.ts +25 -7
- package/dist/index.mjs +300 -94
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FloPay, FloPayElements } from '@flopay/js';
|
|
3
3
|
import * as _flopay_shared from '@flopay/shared';
|
|
4
|
-
import { FloPayAppearance, InlineSessionDraft, FloPayError, PaymentResult, DeclineEvent, CheckoutButtonMethod, BeforeButtonClickEvent, InlineSessionPatch, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody, CheckoutItem, CheckoutSubscription, ButtonsLayoutTheme, ButtonsLayoutStyles } from '@flopay/shared';
|
|
4
|
+
import { FloPayAppearance, InlineSessionDraft, FloPayError, PaymentResult, DeclineEvent, CheckoutButtonMethod, BeforeButtonClickEvent, InlineSessionPatch, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody, AVSFieldConfig, CheckoutItem, CheckoutSubscription, ButtonsLayoutTheme, ButtonsLayoutStyles } from '@flopay/shared';
|
|
5
5
|
export { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, InlineSessionDraft, InlineSessionPatch } from '@flopay/shared';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
|
|
@@ -111,10 +111,12 @@ interface FloPayCheckoutProps {
|
|
|
111
111
|
*/
|
|
112
112
|
onBeforeButtonClick?: (event: BeforeButtonClickEvent) => void | false | Promise<void | false | InlineSessionPatch> | InlineSessionPatch;
|
|
113
113
|
/**
|
|
114
|
-
* Enable AVS (Address Verification).
|
|
115
|
-
*
|
|
114
|
+
* Enable AVS (Address Verification).
|
|
115
|
+
* - `true` — show country + postal code (backward compatible default)
|
|
116
|
+
* - `AVSFieldConfig` — granular per-field control, optionally scoped to country codes
|
|
117
|
+
* - `false` / omitted — AVS disabled
|
|
116
118
|
*/
|
|
117
|
-
enableAVS?: boolean;
|
|
119
|
+
enableAVS?: boolean | _flopay_shared.AVSFieldConfig;
|
|
118
120
|
/** Layout for AVS fields: 'row' (side-by-side, default) or 'column' (stacked). */
|
|
119
121
|
avsLayout?: 'row' | 'column';
|
|
120
122
|
/** Label for the submit button. */
|
|
@@ -442,20 +444,36 @@ interface SplitCardFormProps {
|
|
|
442
444
|
*/
|
|
443
445
|
onBeforeButtonClick?: (event: BeforeButtonClickEvent) => MaybePromise<void | false | InlineSessionPatch>;
|
|
444
446
|
/**
|
|
445
|
-
* Enable AVS (Address Verification).
|
|
446
|
-
*
|
|
447
|
+
* Enable AVS (Address Verification).
|
|
448
|
+
* - `true` — show country + postal code (backward compatible default)
|
|
449
|
+
* - `AVSFieldConfig` — granular per-field control, optionally scoped to country codes
|
|
450
|
+
* - `false` / omitted — AVS disabled
|
|
447
451
|
*/
|
|
448
|
-
enableAVS?: boolean;
|
|
452
|
+
enableAVS?: boolean | AVSFieldConfig;
|
|
449
453
|
/** Layout for AVS fields: 'row' (side-by-side, default) or 'column' (stacked). */
|
|
450
454
|
avsLayout?: 'row' | 'column';
|
|
451
455
|
/** Pre-filled country code (ISO 3166-1 alpha-2) for AVS. */
|
|
452
456
|
country?: string;
|
|
453
457
|
/** Pre-filled ZIP/postal code for AVS. */
|
|
454
458
|
zip?: string;
|
|
459
|
+
/** Pre-filled street address (line 1) for AVS. Typically from a partner GeoIP / profile lookup. */
|
|
460
|
+
addressLine1?: string;
|
|
461
|
+
/** Pre-filled apt/suite/unit (line 2) for AVS. */
|
|
462
|
+
addressLine2?: string;
|
|
463
|
+
/** Pre-filled city for AVS. Typically from a partner GeoIP / profile lookup. */
|
|
464
|
+
city?: string;
|
|
465
|
+
/** Pre-filled state/province for AVS. Typically from a partner GeoIP / profile lookup. */
|
|
466
|
+
state?: string;
|
|
455
467
|
/** Callback when AVS country changes. */
|
|
456
468
|
onCountryChange?: (country: string) => void;
|
|
457
469
|
/** Callback when AVS ZIP/postal code changes. */
|
|
458
470
|
onZipChange?: (zip: string) => void;
|
|
471
|
+
/** Whether AVS was enabled (sent to backend for analytics). */
|
|
472
|
+
avsCheck?: boolean;
|
|
473
|
+
/** Checkout type: 'standard_checkout' or 'embedded_checkout'. */
|
|
474
|
+
checkoutType?: string;
|
|
475
|
+
/** Checkout layout: 'default_layout', 'buttons_layout', or 'custom_layout'. */
|
|
476
|
+
checkoutLayout?: string;
|
|
459
477
|
/** Total amount in cents (smallest currency unit). Used for wallet/PayPal Elements config. */
|
|
460
478
|
totalAmount?: number;
|
|
461
479
|
/** Currency code (used for PayPal Elements config). */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { FloPay, FloPayElements } from '@flopay/js';
|
|
3
3
|
import * as _flopay_shared from '@flopay/shared';
|
|
4
|
-
import { FloPayAppearance, InlineSessionDraft, FloPayError, PaymentResult, DeclineEvent, CheckoutButtonMethod, BeforeButtonClickEvent, InlineSessionPatch, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody, CheckoutItem, CheckoutSubscription, ButtonsLayoutTheme, ButtonsLayoutStyles } from '@flopay/shared';
|
|
4
|
+
import { FloPayAppearance, InlineSessionDraft, FloPayError, PaymentResult, DeclineEvent, CheckoutButtonMethod, BeforeButtonClickEvent, InlineSessionPatch, CheckoutMode, CheckoutSession, ElementOptions, ElementChangeEvent, TokenizedBody, AVSFieldConfig, CheckoutItem, CheckoutSubscription, ButtonsLayoutTheme, ButtonsLayoutStyles } from '@flopay/shared';
|
|
5
5
|
export { BeforeButtonClickEvent, CheckoutButtonMethod, DeclineEvent, InlineSessionDraft, InlineSessionPatch } from '@flopay/shared';
|
|
6
6
|
import * as react_jsx_runtime from 'react/jsx-runtime';
|
|
7
7
|
|
|
@@ -111,10 +111,12 @@ interface FloPayCheckoutProps {
|
|
|
111
111
|
*/
|
|
112
112
|
onBeforeButtonClick?: (event: BeforeButtonClickEvent) => void | false | Promise<void | false | InlineSessionPatch> | InlineSessionPatch;
|
|
113
113
|
/**
|
|
114
|
-
* Enable AVS (Address Verification).
|
|
115
|
-
*
|
|
114
|
+
* Enable AVS (Address Verification).
|
|
115
|
+
* - `true` — show country + postal code (backward compatible default)
|
|
116
|
+
* - `AVSFieldConfig` — granular per-field control, optionally scoped to country codes
|
|
117
|
+
* - `false` / omitted — AVS disabled
|
|
116
118
|
*/
|
|
117
|
-
enableAVS?: boolean;
|
|
119
|
+
enableAVS?: boolean | _flopay_shared.AVSFieldConfig;
|
|
118
120
|
/** Layout for AVS fields: 'row' (side-by-side, default) or 'column' (stacked). */
|
|
119
121
|
avsLayout?: 'row' | 'column';
|
|
120
122
|
/** Label for the submit button. */
|
|
@@ -442,20 +444,36 @@ interface SplitCardFormProps {
|
|
|
442
444
|
*/
|
|
443
445
|
onBeforeButtonClick?: (event: BeforeButtonClickEvent) => MaybePromise<void | false | InlineSessionPatch>;
|
|
444
446
|
/**
|
|
445
|
-
* Enable AVS (Address Verification).
|
|
446
|
-
*
|
|
447
|
+
* Enable AVS (Address Verification).
|
|
448
|
+
* - `true` — show country + postal code (backward compatible default)
|
|
449
|
+
* - `AVSFieldConfig` — granular per-field control, optionally scoped to country codes
|
|
450
|
+
* - `false` / omitted — AVS disabled
|
|
447
451
|
*/
|
|
448
|
-
enableAVS?: boolean;
|
|
452
|
+
enableAVS?: boolean | AVSFieldConfig;
|
|
449
453
|
/** Layout for AVS fields: 'row' (side-by-side, default) or 'column' (stacked). */
|
|
450
454
|
avsLayout?: 'row' | 'column';
|
|
451
455
|
/** Pre-filled country code (ISO 3166-1 alpha-2) for AVS. */
|
|
452
456
|
country?: string;
|
|
453
457
|
/** Pre-filled ZIP/postal code for AVS. */
|
|
454
458
|
zip?: string;
|
|
459
|
+
/** Pre-filled street address (line 1) for AVS. Typically from a partner GeoIP / profile lookup. */
|
|
460
|
+
addressLine1?: string;
|
|
461
|
+
/** Pre-filled apt/suite/unit (line 2) for AVS. */
|
|
462
|
+
addressLine2?: string;
|
|
463
|
+
/** Pre-filled city for AVS. Typically from a partner GeoIP / profile lookup. */
|
|
464
|
+
city?: string;
|
|
465
|
+
/** Pre-filled state/province for AVS. Typically from a partner GeoIP / profile lookup. */
|
|
466
|
+
state?: string;
|
|
455
467
|
/** Callback when AVS country changes. */
|
|
456
468
|
onCountryChange?: (country: string) => void;
|
|
457
469
|
/** Callback when AVS ZIP/postal code changes. */
|
|
458
470
|
onZipChange?: (zip: string) => void;
|
|
471
|
+
/** Whether AVS was enabled (sent to backend for analytics). */
|
|
472
|
+
avsCheck?: boolean;
|
|
473
|
+
/** Checkout type: 'standard_checkout' or 'embedded_checkout'. */
|
|
474
|
+
checkoutType?: string;
|
|
475
|
+
/** Checkout layout: 'default_layout', 'buttons_layout', or 'custom_layout'. */
|
|
476
|
+
checkoutLayout?: string;
|
|
459
477
|
/** Total amount in cents (smallest currency unit). Used for wallet/PayPal Elements config. */
|
|
460
478
|
totalAmount?: number;
|
|
461
479
|
/** Currency code (used for PayPal Elements config). */
|
package/dist/index.mjs
CHANGED
|
@@ -238,7 +238,15 @@ import {
|
|
|
238
238
|
useElements as useStripeElements,
|
|
239
239
|
useStripe as useStripeRaw
|
|
240
240
|
} from "@stripe/react-stripe-js";
|
|
241
|
-
import {
|
|
241
|
+
import {
|
|
242
|
+
resolveButtonsLayoutTheme,
|
|
243
|
+
getPostalCodeLabel,
|
|
244
|
+
getStateLabel,
|
|
245
|
+
getStateOptions,
|
|
246
|
+
COUNTRY_OPTIONS,
|
|
247
|
+
resolveAVSConfig,
|
|
248
|
+
isAVSFieldVisible
|
|
249
|
+
} from "@flopay/shared";
|
|
242
250
|
import { forwardRef, useCallback, useContext as useContext3, useEffect as useEffect3, useImperativeHandle, useMemo as useMemo2, useRef as useRef2, useState as useState2 } from "react";
|
|
243
251
|
|
|
244
252
|
// src/hooks.ts
|
|
@@ -1010,12 +1018,19 @@ function SplitCardFormInner({
|
|
|
1010
1018
|
showSecurityFooter = true,
|
|
1011
1019
|
onButtonClick,
|
|
1012
1020
|
onBeforeButtonClick,
|
|
1013
|
-
enableAVS
|
|
1021
|
+
enableAVS: enableAVSProp,
|
|
1014
1022
|
avsLayout: avsLayoutProp = "row",
|
|
1015
1023
|
country: countryProp,
|
|
1016
1024
|
zip: zipProp,
|
|
1025
|
+
addressLine1: addressLine1Prop,
|
|
1026
|
+
addressLine2: addressLine2Prop,
|
|
1027
|
+
city: cityProp,
|
|
1028
|
+
state: stateProp,
|
|
1017
1029
|
onCountryChange,
|
|
1018
1030
|
onZipChange,
|
|
1031
|
+
avsCheck: avsCheckProp,
|
|
1032
|
+
checkoutType: checkoutTypeProp,
|
|
1033
|
+
checkoutLayout: checkoutLayoutProp,
|
|
1019
1034
|
totalAmount = 0,
|
|
1020
1035
|
currency = "usd",
|
|
1021
1036
|
initialCardOpen = false,
|
|
@@ -1031,9 +1046,19 @@ function SplitCardFormInner({
|
|
|
1031
1046
|
const [is3DSActive, setIs3DSActive] = useState2(false);
|
|
1032
1047
|
const [selectedCountry, setSelectedCountry] = useState2(countryProp ?? "US");
|
|
1033
1048
|
const [zipCode, setZipCode] = useState2(zipProp ?? "");
|
|
1049
|
+
const [addressLine1, setAddressLine1] = useState2(addressLine1Prop ?? "");
|
|
1050
|
+
const [addressLine2, setAddressLine2] = useState2(addressLine2Prop ?? "");
|
|
1051
|
+
const [city, setCity] = useState2(cityProp ?? "");
|
|
1052
|
+
const [stateValue, setStateValue] = useState2(stateProp ?? "");
|
|
1034
1053
|
const [accountPatch, setAccountPatch] = useState2({});
|
|
1035
1054
|
const zipCodeRef = useRef2(zipProp ?? "");
|
|
1036
1055
|
const selectedCountryRef = useRef2(countryProp ?? "US");
|
|
1056
|
+
const addressLine1Ref = useRef2(addressLine1Prop ?? "");
|
|
1057
|
+
const addressLine2Ref = useRef2(addressLine2Prop ?? "");
|
|
1058
|
+
const cityRef = useRef2(cityProp ?? "");
|
|
1059
|
+
const stateRef = useRef2(stateProp ?? "");
|
|
1060
|
+
const avsConfig = useMemo2(() => resolveAVSConfig(enableAVSProp), [enableAVSProp]);
|
|
1061
|
+
const enableAVS = avsConfig !== null;
|
|
1037
1062
|
const [viewState, setViewState] = useState2(initialCardOpen ? "card" : "buttons");
|
|
1038
1063
|
const showCardForm = viewState === "expanding" || viewState === "card";
|
|
1039
1064
|
const TRANSITION_MS = 280;
|
|
@@ -1205,9 +1230,33 @@ function SplitCardFormInner({
|
|
|
1205
1230
|
email: effectiveAccount.email ?? "",
|
|
1206
1231
|
firstName: effectiveAccount.firstName ?? fullName.trim().split(/\s+/)[0] ?? "",
|
|
1207
1232
|
lastName: effectiveAccount.lastName ?? fullName.trim().split(/\s+/).slice(1).join(" ") ?? "",
|
|
1208
|
-
...
|
|
1233
|
+
...avsConfig ? (() => {
|
|
1234
|
+
const c = selectedCountryRef.current;
|
|
1235
|
+
return {
|
|
1236
|
+
country: c,
|
|
1237
|
+
...isAVSFieldVisible(avsConfig.postal_code, c) && zipCodeRef.current ? { zip: zipCodeRef.current } : {},
|
|
1238
|
+
...isAVSFieldVisible(avsConfig.city, c) && cityRef.current ? { city: cityRef.current } : {},
|
|
1239
|
+
...isAVSFieldVisible(avsConfig.state, c) && stateRef.current ? { state: stateRef.current } : {},
|
|
1240
|
+
...isAVSFieldVisible(avsConfig.address_line_1, c) && addressLine1Ref.current ? { addressLine1: addressLine1Ref.current } : {},
|
|
1241
|
+
...isAVSFieldVisible(avsConfig.address_line_2, c) && addressLine2Ref.current ? { addressLine2: addressLine2Ref.current } : {}
|
|
1242
|
+
};
|
|
1243
|
+
})() : {}
|
|
1209
1244
|
},
|
|
1210
|
-
chv
|
|
1245
|
+
chv,
|
|
1246
|
+
// Checkout analytics metadata
|
|
1247
|
+
avsCheck: avsCheckProp ?? false,
|
|
1248
|
+
checkoutType: checkoutTypeProp,
|
|
1249
|
+
checkoutLayout: checkoutLayoutProp,
|
|
1250
|
+
// Resolved exposure: which fields were actually shown for the active country.
|
|
1251
|
+
// Country-scoped rules (e.g. ['US', 'CA']) are flattened to booleans here.
|
|
1252
|
+
avsConfig: avsConfig ? {
|
|
1253
|
+
country: isAVSFieldVisible(avsConfig.country, selectedCountryRef.current),
|
|
1254
|
+
postal_code: isAVSFieldVisible(avsConfig.postal_code, selectedCountryRef.current),
|
|
1255
|
+
address_line_1: isAVSFieldVisible(avsConfig.address_line_1, selectedCountryRef.current),
|
|
1256
|
+
address_line_2: isAVSFieldVisible(avsConfig.address_line_2, selectedCountryRef.current),
|
|
1257
|
+
city: isAVSFieldVisible(avsConfig.city, selectedCountryRef.current),
|
|
1258
|
+
state: isAVSFieldVisible(avsConfig.state, selectedCountryRef.current)
|
|
1259
|
+
} : void 0
|
|
1211
1260
|
})
|
|
1212
1261
|
});
|
|
1213
1262
|
if (response.ok) {
|
|
@@ -1231,14 +1280,19 @@ function SplitCardFormInner({
|
|
|
1231
1280
|
}
|
|
1232
1281
|
setIs3DSActive(true);
|
|
1233
1282
|
try {
|
|
1234
|
-
const retryBillingAddress = {
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1283
|
+
const retryBillingAddress = {};
|
|
1284
|
+
const retryCC = selectedCountryRef.current;
|
|
1285
|
+
const retryCountry = enableAVS ? retryCC : effectiveAccount.country;
|
|
1286
|
+
if (retryCountry) retryBillingAddress["country"] = retryCountry;
|
|
1287
|
+
if (avsConfig && isAVSFieldVisible(avsConfig.postal_code, retryCC) && zipCodeRef.current.trim()) {
|
|
1288
|
+
retryBillingAddress["postal_code"] = zipCodeRef.current.trim();
|
|
1289
|
+
} else if (!avsConfig && effectiveAccount.zip) {
|
|
1290
|
+
retryBillingAddress["postal_code"] = effectiveAccount.zip;
|
|
1291
|
+
}
|
|
1292
|
+
if (avsConfig && isAVSFieldVisible(avsConfig.address_line_1, retryCC) && addressLine1Ref.current.trim()) retryBillingAddress["line1"] = addressLine1Ref.current.trim();
|
|
1293
|
+
if (avsConfig && isAVSFieldVisible(avsConfig.address_line_2, retryCC) && addressLine2Ref.current.trim()) retryBillingAddress["line2"] = addressLine2Ref.current.trim();
|
|
1294
|
+
if (avsConfig && isAVSFieldVisible(avsConfig.city, retryCC) && cityRef.current.trim()) retryBillingAddress["city"] = cityRef.current.trim();
|
|
1295
|
+
if (avsConfig && isAVSFieldVisible(avsConfig.state, retryCC) && stateRef.current.trim()) retryBillingAddress["state"] = stateRef.current.trim();
|
|
1242
1296
|
const result = await flopay.confirmPayment({
|
|
1243
1297
|
clientSecret: secret,
|
|
1244
1298
|
returnUrl: window.location.href,
|
|
@@ -1396,9 +1450,24 @@ function SplitCardFormInner({
|
|
|
1396
1450
|
updateError(null);
|
|
1397
1451
|
let handedOff = false;
|
|
1398
1452
|
try {
|
|
1399
|
-
if (
|
|
1400
|
-
|
|
1401
|
-
|
|
1453
|
+
if (avsConfig) {
|
|
1454
|
+
const country = selectedCountryRef.current;
|
|
1455
|
+
if (isAVSFieldVisible(avsConfig.postal_code, country) && !zipCodeRef.current.trim()) {
|
|
1456
|
+
updateError(getPostalCodeLabel(country) + " is required");
|
|
1457
|
+
return;
|
|
1458
|
+
}
|
|
1459
|
+
if (isAVSFieldVisible(avsConfig.address_line_1, country) && !addressLine1Ref.current.trim()) {
|
|
1460
|
+
updateError("Street address is required");
|
|
1461
|
+
return;
|
|
1462
|
+
}
|
|
1463
|
+
if (isAVSFieldVisible(avsConfig.city, country) && !cityRef.current.trim()) {
|
|
1464
|
+
updateError("City is required");
|
|
1465
|
+
return;
|
|
1466
|
+
}
|
|
1467
|
+
if (isAVSFieldVisible(avsConfig.state, country) && !stateRef.current.trim()) {
|
|
1468
|
+
updateError(getStateLabel(country) + " is required");
|
|
1469
|
+
return;
|
|
1470
|
+
}
|
|
1402
1471
|
}
|
|
1403
1472
|
const submitResult = await flopay.submitElements();
|
|
1404
1473
|
if (submitResult.error) {
|
|
@@ -1406,14 +1475,19 @@ function SplitCardFormInner({
|
|
|
1406
1475
|
onError?.(submitResult.error);
|
|
1407
1476
|
return;
|
|
1408
1477
|
}
|
|
1409
|
-
const billingAddress = {
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1478
|
+
const billingAddress = {};
|
|
1479
|
+
const cc = selectedCountryRef.current;
|
|
1480
|
+
const avsCountry = enableAVS ? cc : resolvedAccount.country;
|
|
1481
|
+
if (avsCountry) billingAddress["country"] = avsCountry;
|
|
1482
|
+
if (avsConfig && isAVSFieldVisible(avsConfig.postal_code, cc) && zipCodeRef.current.trim()) {
|
|
1483
|
+
billingAddress["postal_code"] = zipCodeRef.current.trim();
|
|
1484
|
+
} else if (!avsConfig && resolvedAccount.zip) {
|
|
1485
|
+
billingAddress["postal_code"] = resolvedAccount.zip;
|
|
1486
|
+
}
|
|
1487
|
+
if (avsConfig && isAVSFieldVisible(avsConfig.address_line_1, cc) && addressLine1Ref.current.trim()) billingAddress["line1"] = addressLine1Ref.current.trim();
|
|
1488
|
+
if (avsConfig && isAVSFieldVisible(avsConfig.address_line_2, cc) && addressLine2Ref.current.trim()) billingAddress["line2"] = addressLine2Ref.current.trim();
|
|
1489
|
+
if (avsConfig && isAVSFieldVisible(avsConfig.city, cc) && cityRef.current.trim()) billingAddress["city"] = cityRef.current.trim();
|
|
1490
|
+
if (avsConfig && isAVSFieldVisible(avsConfig.state, cc) && stateRef.current.trim()) billingAddress["state"] = stateRef.current.trim();
|
|
1417
1491
|
const billingDetails = {
|
|
1418
1492
|
...resolvedAccount.email ? { email: resolvedAccount.email } : {},
|
|
1419
1493
|
...fullName.trim() ? { name: fullName.trim() } : {},
|
|
@@ -1640,80 +1714,198 @@ function SplitCardFormInner({
|
|
|
1640
1714
|
}
|
|
1641
1715
|
}
|
|
1642
1716
|
) }),
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
gap: avsLayoutProp === "column" ? "0.5rem" : "0",
|
|
1647
|
-
marginTop: "0.5rem"
|
|
1648
|
-
}, children: [
|
|
1649
|
-
/* @__PURE__ */ jsx5("div", { style: {
|
|
1650
|
-
flex: avsLayoutProp === "row" ? 1 : void 0,
|
|
1717
|
+
avsConfig && (() => {
|
|
1718
|
+
const cc = selectedCountry;
|
|
1719
|
+
const inputWrapStyle = (extraStyle) => ({
|
|
1651
1720
|
backgroundColor: cardInputBg,
|
|
1652
1721
|
border: `1px solid ${resolvedBorder}`,
|
|
1722
|
+
borderRadius: "8px",
|
|
1723
|
+
marginTop: "0.5rem",
|
|
1653
1724
|
padding: "10px",
|
|
1654
|
-
...
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
"
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
"
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
" ",
|
|
1680
|
-
|
|
1681
|
-
] }, c.code))
|
|
1682
|
-
}
|
|
1683
|
-
) }),
|
|
1684
|
-
/* @__PURE__ */ jsx5("div", { style: {
|
|
1685
|
-
flex: avsLayoutProp === "row" ? 1 : void 0,
|
|
1686
|
-
backgroundColor: cardInputBg,
|
|
1687
|
-
border: `1px solid ${resolvedBorder}`,
|
|
1688
|
-
padding: "10px",
|
|
1689
|
-
...avsLayoutProp === "row" ? { borderRadius: "0", borderTopRightRadius: "8px", borderBottomRightRadius: "8px" } : { borderRadius: "8px" },
|
|
1690
|
-
...isButtons && bStyles.zipInput ? bStyles.zipInput : {}
|
|
1691
|
-
}, children: /* @__PURE__ */ jsx5(
|
|
1692
|
-
"input",
|
|
1693
|
-
{
|
|
1694
|
-
className: "flopay-shared-input",
|
|
1695
|
-
placeholder: getPostalCodeLabel(selectedCountry),
|
|
1696
|
-
autoComplete: "postal-code",
|
|
1697
|
-
value: zipCode,
|
|
1698
|
-
onChange: (e) => {
|
|
1699
|
-
zipCodeRef.current = e.target.value;
|
|
1700
|
-
setZipCode(e.target.value);
|
|
1701
|
-
onZipChange?.(e.target.value);
|
|
1702
|
-
},
|
|
1703
|
-
disabled: isSubmitting,
|
|
1704
|
-
required: true,
|
|
1705
|
-
"data-testid": "flopay-zip",
|
|
1706
|
-
style: {
|
|
1707
|
-
width: "100%",
|
|
1708
|
-
border: "none",
|
|
1709
|
-
outline: "none",
|
|
1710
|
-
background: "transparent",
|
|
1711
|
-
...sharedInputTypography,
|
|
1712
|
-
...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
|
|
1725
|
+
...isButtons && extraStyle ? extraStyle : {}
|
|
1726
|
+
});
|
|
1727
|
+
const inputFieldStyle = () => ({
|
|
1728
|
+
width: "100%",
|
|
1729
|
+
border: "none",
|
|
1730
|
+
outline: "none",
|
|
1731
|
+
background: "transparent",
|
|
1732
|
+
...sharedInputTypography,
|
|
1733
|
+
...isButtons && bStyles.nameInput ? bStyles.nameInput : {}
|
|
1734
|
+
});
|
|
1735
|
+
const stateOpts = getStateOptions(cc);
|
|
1736
|
+
return /* @__PURE__ */ jsxs3(Fragment2, { children: [
|
|
1737
|
+
isAVSFieldVisible(avsConfig.address_line_1, cc) && /* @__PURE__ */ jsx5("div", { style: inputWrapStyle(bStyles.addressLine1Input), children: /* @__PURE__ */ jsx5(
|
|
1738
|
+
"input",
|
|
1739
|
+
{
|
|
1740
|
+
className: "flopay-shared-input",
|
|
1741
|
+
placeholder: "Street Address (e.g. 123 Main St)",
|
|
1742
|
+
autoComplete: "address-line1",
|
|
1743
|
+
value: addressLine1,
|
|
1744
|
+
onChange: (e) => {
|
|
1745
|
+
addressLine1Ref.current = e.target.value;
|
|
1746
|
+
setAddressLine1(e.target.value);
|
|
1747
|
+
},
|
|
1748
|
+
disabled: isSubmitting,
|
|
1749
|
+
required: true,
|
|
1750
|
+
"data-testid": "flopay-address-line1",
|
|
1751
|
+
style: inputFieldStyle()
|
|
1713
1752
|
}
|
|
1714
|
-
}
|
|
1715
|
-
|
|
1716
|
-
|
|
1753
|
+
) }),
|
|
1754
|
+
isAVSFieldVisible(avsConfig.address_line_2, cc) && /* @__PURE__ */ jsx5("div", { style: inputWrapStyle(bStyles.addressLine2Input), children: /* @__PURE__ */ jsx5(
|
|
1755
|
+
"input",
|
|
1756
|
+
{
|
|
1757
|
+
className: "flopay-shared-input",
|
|
1758
|
+
placeholder: "Apt, Suite, Unit (optional)",
|
|
1759
|
+
autoComplete: "address-line2",
|
|
1760
|
+
value: addressLine2,
|
|
1761
|
+
onChange: (e) => {
|
|
1762
|
+
addressLine2Ref.current = e.target.value;
|
|
1763
|
+
setAddressLine2(e.target.value);
|
|
1764
|
+
},
|
|
1765
|
+
disabled: isSubmitting,
|
|
1766
|
+
"data-testid": "flopay-address-line2",
|
|
1767
|
+
style: inputFieldStyle()
|
|
1768
|
+
}
|
|
1769
|
+
) }),
|
|
1770
|
+
(isAVSFieldVisible(avsConfig.city, cc) || isAVSFieldVisible(avsConfig.state, cc)) && /* @__PURE__ */ jsxs3("div", { style: {
|
|
1771
|
+
display: "flex",
|
|
1772
|
+
gap: "0",
|
|
1773
|
+
marginTop: "0.5rem"
|
|
1774
|
+
}, children: [
|
|
1775
|
+
isAVSFieldVisible(avsConfig.city, cc) && /* @__PURE__ */ jsx5("div", { style: {
|
|
1776
|
+
flex: 1,
|
|
1777
|
+
backgroundColor: cardInputBg,
|
|
1778
|
+
border: `1px solid ${resolvedBorder}`,
|
|
1779
|
+
padding: "10px",
|
|
1780
|
+
borderTopLeftRadius: "8px",
|
|
1781
|
+
borderBottomLeftRadius: "8px",
|
|
1782
|
+
...isAVSFieldVisible(avsConfig.state, cc) ? { borderRight: "none", borderTopRightRadius: 0, borderBottomRightRadius: 0 } : { borderRadius: "8px" },
|
|
1783
|
+
...isButtons && bStyles.cityInput ? bStyles.cityInput : {}
|
|
1784
|
+
}, children: /* @__PURE__ */ jsx5(
|
|
1785
|
+
"input",
|
|
1786
|
+
{
|
|
1787
|
+
className: "flopay-shared-input",
|
|
1788
|
+
placeholder: "City",
|
|
1789
|
+
autoComplete: "address-level2",
|
|
1790
|
+
value: city,
|
|
1791
|
+
onChange: (e) => {
|
|
1792
|
+
cityRef.current = e.target.value;
|
|
1793
|
+
setCity(e.target.value);
|
|
1794
|
+
},
|
|
1795
|
+
disabled: isSubmitting,
|
|
1796
|
+
required: true,
|
|
1797
|
+
"data-testid": "flopay-city",
|
|
1798
|
+
style: inputFieldStyle()
|
|
1799
|
+
}
|
|
1800
|
+
) }),
|
|
1801
|
+
isAVSFieldVisible(avsConfig.state, cc) && /* @__PURE__ */ jsx5("div", { style: {
|
|
1802
|
+
flex: 1,
|
|
1803
|
+
backgroundColor: cardInputBg,
|
|
1804
|
+
border: `1px solid ${resolvedBorder}`,
|
|
1805
|
+
padding: "10px",
|
|
1806
|
+
borderTopRightRadius: "8px",
|
|
1807
|
+
borderBottomRightRadius: "8px",
|
|
1808
|
+
...isAVSFieldVisible(avsConfig.city, cc) ? { borderTopLeftRadius: 0, borderBottomLeftRadius: 0 } : { borderRadius: "8px" },
|
|
1809
|
+
...isButtons && bStyles.stateInput ? bStyles.stateInput : {}
|
|
1810
|
+
}, children: stateOpts ? /* @__PURE__ */ jsxs3(
|
|
1811
|
+
"select",
|
|
1812
|
+
{
|
|
1813
|
+
value: stateValue,
|
|
1814
|
+
onChange: (e) => {
|
|
1815
|
+
stateRef.current = e.target.value;
|
|
1816
|
+
setStateValue(e.target.value);
|
|
1817
|
+
},
|
|
1818
|
+
disabled: isSubmitting,
|
|
1819
|
+
autoComplete: "address-level1",
|
|
1820
|
+
required: true,
|
|
1821
|
+
"data-testid": "flopay-state",
|
|
1822
|
+
style: { ...inputFieldStyle(), cursor: "pointer" },
|
|
1823
|
+
children: [
|
|
1824
|
+
/* @__PURE__ */ jsx5("option", { value: "", children: getStateLabel(cc) }),
|
|
1825
|
+
stateOpts.map((s) => /* @__PURE__ */ jsx5("option", { value: s.code, children: s.name }, s.code))
|
|
1826
|
+
]
|
|
1827
|
+
}
|
|
1828
|
+
) : /* @__PURE__ */ jsx5(
|
|
1829
|
+
"input",
|
|
1830
|
+
{
|
|
1831
|
+
className: "flopay-shared-input",
|
|
1832
|
+
placeholder: getStateLabel(cc),
|
|
1833
|
+
autoComplete: "address-level1",
|
|
1834
|
+
value: stateValue,
|
|
1835
|
+
onChange: (e) => {
|
|
1836
|
+
stateRef.current = e.target.value;
|
|
1837
|
+
setStateValue(e.target.value);
|
|
1838
|
+
},
|
|
1839
|
+
disabled: isSubmitting,
|
|
1840
|
+
required: true,
|
|
1841
|
+
"data-testid": "flopay-state",
|
|
1842
|
+
style: inputFieldStyle()
|
|
1843
|
+
}
|
|
1844
|
+
) })
|
|
1845
|
+
] }),
|
|
1846
|
+
(isAVSFieldVisible(avsConfig.country, cc) || isAVSFieldVisible(avsConfig.postal_code, cc)) && /* @__PURE__ */ jsxs3("div", { style: {
|
|
1847
|
+
display: "flex",
|
|
1848
|
+
flexDirection: avsLayoutProp === "column" ? "column" : "row",
|
|
1849
|
+
gap: avsLayoutProp === "column" ? "0.5rem" : "0",
|
|
1850
|
+
marginTop: "0.5rem"
|
|
1851
|
+
}, children: [
|
|
1852
|
+
isAVSFieldVisible(avsConfig.country, cc) && /* @__PURE__ */ jsx5("div", { style: {
|
|
1853
|
+
flex: avsLayoutProp === "row" ? 1 : void 0,
|
|
1854
|
+
backgroundColor: cardInputBg,
|
|
1855
|
+
border: `1px solid ${resolvedBorder}`,
|
|
1856
|
+
padding: "10px",
|
|
1857
|
+
...avsLayoutProp === "row" && isAVSFieldVisible(avsConfig.postal_code, cc) ? { borderRadius: "0", borderTopLeftRadius: "8px", borderBottomLeftRadius: "8px", borderRight: "none" } : { borderRadius: "8px" },
|
|
1858
|
+
...isButtons && bStyles.countrySelect ? bStyles.countrySelect : {}
|
|
1859
|
+
}, children: /* @__PURE__ */ jsx5(
|
|
1860
|
+
"select",
|
|
1861
|
+
{
|
|
1862
|
+
value: selectedCountry,
|
|
1863
|
+
onChange: (e) => {
|
|
1864
|
+
selectedCountryRef.current = e.target.value;
|
|
1865
|
+
setSelectedCountry(e.target.value);
|
|
1866
|
+
onCountryChange?.(e.target.value);
|
|
1867
|
+
stateRef.current = "";
|
|
1868
|
+
setStateValue("");
|
|
1869
|
+
},
|
|
1870
|
+
disabled: isSubmitting,
|
|
1871
|
+
autoComplete: "country",
|
|
1872
|
+
"data-testid": "flopay-country",
|
|
1873
|
+
style: { ...inputFieldStyle(), cursor: "pointer" },
|
|
1874
|
+
children: COUNTRY_OPTIONS.map((c) => /* @__PURE__ */ jsxs3("option", { value: c.code, children: [
|
|
1875
|
+
c.flag,
|
|
1876
|
+
" ",
|
|
1877
|
+
c.name
|
|
1878
|
+
] }, c.code))
|
|
1879
|
+
}
|
|
1880
|
+
) }),
|
|
1881
|
+
isAVSFieldVisible(avsConfig.postal_code, cc) && /* @__PURE__ */ jsx5("div", { style: {
|
|
1882
|
+
flex: avsLayoutProp === "row" ? 1 : void 0,
|
|
1883
|
+
backgroundColor: cardInputBg,
|
|
1884
|
+
border: `1px solid ${resolvedBorder}`,
|
|
1885
|
+
padding: "10px",
|
|
1886
|
+
...avsLayoutProp === "row" && isAVSFieldVisible(avsConfig.country, cc) ? { borderRadius: "0", borderTopRightRadius: "8px", borderBottomRightRadius: "8px" } : { borderRadius: "8px" },
|
|
1887
|
+
...isButtons && bStyles.zipInput ? bStyles.zipInput : {}
|
|
1888
|
+
}, children: /* @__PURE__ */ jsx5(
|
|
1889
|
+
"input",
|
|
1890
|
+
{
|
|
1891
|
+
className: "flopay-shared-input",
|
|
1892
|
+
placeholder: getPostalCodeLabel(selectedCountry),
|
|
1893
|
+
autoComplete: "postal-code",
|
|
1894
|
+
value: zipCode,
|
|
1895
|
+
onChange: (e) => {
|
|
1896
|
+
zipCodeRef.current = e.target.value;
|
|
1897
|
+
setZipCode(e.target.value);
|
|
1898
|
+
onZipChange?.(e.target.value);
|
|
1899
|
+
},
|
|
1900
|
+
disabled: isSubmitting,
|
|
1901
|
+
required: true,
|
|
1902
|
+
"data-testid": "flopay-zip",
|
|
1903
|
+
style: inputFieldStyle()
|
|
1904
|
+
}
|
|
1905
|
+
) })
|
|
1906
|
+
] })
|
|
1907
|
+
] });
|
|
1908
|
+
})(),
|
|
1717
1909
|
displayError && /* @__PURE__ */ jsxs3("div", { role: "alert", "data-testid": "flopay-error", style: {
|
|
1718
1910
|
margin: "0.75rem 0",
|
|
1719
1911
|
padding: "0.625rem 0.875rem",
|
|
@@ -2857,7 +3049,14 @@ function FloPayCheckout({
|
|
|
2857
3049
|
}
|
|
2858
3050
|
}
|
|
2859
3051
|
if (!sid) {
|
|
2860
|
-
|
|
3052
|
+
const paramsWithAnalytics = {
|
|
3053
|
+
...params,
|
|
3054
|
+
avsCheck: !!enableAVS,
|
|
3055
|
+
avsConfig: typeof enableAVS === "object" ? enableAVS : void 0,
|
|
3056
|
+
checkoutType: "embedded_checkout",
|
|
3057
|
+
checkoutLayout: children ? "custom_layout" : layout === "buttons" ? "buttons_layout" : "default_layout"
|
|
3058
|
+
};
|
|
3059
|
+
realResult = await api.createAndFetchSession(paramsWithAnalytics);
|
|
2861
3060
|
sid = realResult.data.session?.id ?? "";
|
|
2862
3061
|
if (sid && typeof window !== "undefined") {
|
|
2863
3062
|
window.sessionStorage.setItem(cacheKey, sid);
|
|
@@ -3339,8 +3538,15 @@ function FloPayCheckout({
|
|
|
3339
3538
|
enableAVS,
|
|
3340
3539
|
avsLayout,
|
|
3341
3540
|
country: session?.customer?.country,
|
|
3541
|
+
city: session?.customer?.city,
|
|
3542
|
+
state: session?.customer?.state,
|
|
3543
|
+
addressLine1: session?.customer?.line1,
|
|
3544
|
+
addressLine2: session?.customer?.line2,
|
|
3342
3545
|
onCountryChange,
|
|
3343
3546
|
onZipChange,
|
|
3547
|
+
avsCheck: !!enableAVS,
|
|
3548
|
+
checkoutType: createSessionParams ? "embedded_checkout" : "standard_checkout",
|
|
3549
|
+
checkoutLayout: children ? "custom_layout" : layout === "buttons" ? "buttons_layout" : "default_layout",
|
|
3344
3550
|
submitLabel,
|
|
3345
3551
|
className
|
|
3346
3552
|
}
|