@flopay/react 0.5.0 → 0.5.2
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 +34 -13
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.mjs +36 -14
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs
CHANGED
|
@@ -1060,6 +1060,10 @@ function SplitCardFormInner({
|
|
|
1060
1060
|
avsLayout: avsLayoutProp = "row",
|
|
1061
1061
|
country: countryProp,
|
|
1062
1062
|
zip: zipProp,
|
|
1063
|
+
addressLine1: addressLine1Prop,
|
|
1064
|
+
addressLine2: addressLine2Prop,
|
|
1065
|
+
city: cityProp,
|
|
1066
|
+
state: stateProp,
|
|
1063
1067
|
onCountryChange,
|
|
1064
1068
|
onZipChange,
|
|
1065
1069
|
avsCheck: avsCheckProp,
|
|
@@ -1080,17 +1084,17 @@ function SplitCardFormInner({
|
|
|
1080
1084
|
const [is3DSActive, setIs3DSActive] = (0, import_react7.useState)(false);
|
|
1081
1085
|
const [selectedCountry, setSelectedCountry] = (0, import_react7.useState)(countryProp ?? "US");
|
|
1082
1086
|
const [zipCode, setZipCode] = (0, import_react7.useState)(zipProp ?? "");
|
|
1083
|
-
const [addressLine1, setAddressLine1] = (0, import_react7.useState)("");
|
|
1084
|
-
const [addressLine2, setAddressLine2] = (0, import_react7.useState)("");
|
|
1085
|
-
const [city, setCity] = (0, import_react7.useState)("");
|
|
1086
|
-
const [stateValue, setStateValue] = (0, import_react7.useState)("");
|
|
1087
|
+
const [addressLine1, setAddressLine1] = (0, import_react7.useState)(addressLine1Prop ?? "");
|
|
1088
|
+
const [addressLine2, setAddressLine2] = (0, import_react7.useState)(addressLine2Prop ?? "");
|
|
1089
|
+
const [city, setCity] = (0, import_react7.useState)(cityProp ?? "");
|
|
1090
|
+
const [stateValue, setStateValue] = (0, import_react7.useState)(stateProp ?? "");
|
|
1087
1091
|
const [accountPatch, setAccountPatch] = (0, import_react7.useState)({});
|
|
1088
1092
|
const zipCodeRef = (0, import_react7.useRef)(zipProp ?? "");
|
|
1089
1093
|
const selectedCountryRef = (0, import_react7.useRef)(countryProp ?? "US");
|
|
1090
|
-
const addressLine1Ref = (0, import_react7.useRef)("");
|
|
1091
|
-
const addressLine2Ref = (0, import_react7.useRef)("");
|
|
1092
|
-
const cityRef = (0, import_react7.useRef)("");
|
|
1093
|
-
const stateRef = (0, import_react7.useRef)("");
|
|
1094
|
+
const addressLine1Ref = (0, import_react7.useRef)(addressLine1Prop ?? "");
|
|
1095
|
+
const addressLine2Ref = (0, import_react7.useRef)(addressLine2Prop ?? "");
|
|
1096
|
+
const cityRef = (0, import_react7.useRef)(cityProp ?? "");
|
|
1097
|
+
const stateRef = (0, import_react7.useRef)(stateProp ?? "");
|
|
1094
1098
|
const avsConfig = (0, import_react7.useMemo)(() => (0, import_shared4.resolveAVSConfig)(enableAVSProp), [enableAVSProp]);
|
|
1095
1099
|
const enableAVS = avsConfig !== null;
|
|
1096
1100
|
const [viewState, setViewState] = (0, import_react7.useState)(initialCardOpen ? "card" : "buttons");
|
|
@@ -1266,12 +1270,17 @@ function SplitCardFormInner({
|
|
|
1266
1270
|
lastName: effectiveAccount.lastName ?? fullName.trim().split(/\s+/).slice(1).join(" ") ?? "",
|
|
1267
1271
|
...avsConfig ? (() => {
|
|
1268
1272
|
const c = selectedCountryRef.current;
|
|
1273
|
+
const stateVisible = (0, import_shared4.isAVSFieldVisible)(avsConfig.state, c);
|
|
1274
|
+
const line1Visible = (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, c);
|
|
1275
|
+
const zipVisible = (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, c);
|
|
1276
|
+
const derivedState = line1Visible && !stateVisible && zipVisible ? (0, import_shared4.getStateFromPostalCode)(c, zipCodeRef.current ?? "") : null;
|
|
1277
|
+
const stateValue2 = stateVisible ? stateRef.current : derivedState;
|
|
1269
1278
|
return {
|
|
1270
1279
|
country: c,
|
|
1271
|
-
...
|
|
1280
|
+
...zipVisible && zipCodeRef.current ? { zip: zipCodeRef.current } : {},
|
|
1272
1281
|
...(0, import_shared4.isAVSFieldVisible)(avsConfig.city, c) && cityRef.current ? { city: cityRef.current } : {},
|
|
1273
|
-
...
|
|
1274
|
-
...
|
|
1282
|
+
...stateValue2 ? { state: stateValue2 } : {},
|
|
1283
|
+
...line1Visible && addressLine1Ref.current ? { addressLine1: addressLine1Ref.current } : {},
|
|
1275
1284
|
...(0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_2, c) && addressLine2Ref.current ? { addressLine2: addressLine2Ref.current } : {}
|
|
1276
1285
|
};
|
|
1277
1286
|
})() : {}
|
|
@@ -1326,7 +1335,12 @@ function SplitCardFormInner({
|
|
|
1326
1335
|
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, retryCC) && addressLine1Ref.current.trim()) retryBillingAddress["line1"] = addressLine1Ref.current.trim();
|
|
1327
1336
|
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_2, retryCC) && addressLine2Ref.current.trim()) retryBillingAddress["line2"] = addressLine2Ref.current.trim();
|
|
1328
1337
|
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.city, retryCC) && cityRef.current.trim()) retryBillingAddress["city"] = cityRef.current.trim();
|
|
1329
|
-
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.state, retryCC) && stateRef.current.trim())
|
|
1338
|
+
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.state, retryCC) && stateRef.current.trim()) {
|
|
1339
|
+
retryBillingAddress["state"] = stateRef.current.trim();
|
|
1340
|
+
} else if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, retryCC) && !(0, import_shared4.isAVSFieldVisible)(avsConfig.state, retryCC) && (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, retryCC)) {
|
|
1341
|
+
const derivedRetryState = (0, import_shared4.getStateFromPostalCode)(retryCC, zipCodeRef.current.trim());
|
|
1342
|
+
if (derivedRetryState) retryBillingAddress["state"] = derivedRetryState;
|
|
1343
|
+
}
|
|
1330
1344
|
const result = await flopay.confirmPayment({
|
|
1331
1345
|
clientSecret: secret,
|
|
1332
1346
|
returnUrl: window.location.href,
|
|
@@ -1521,7 +1535,12 @@ function SplitCardFormInner({
|
|
|
1521
1535
|
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, cc) && addressLine1Ref.current.trim()) billingAddress["line1"] = addressLine1Ref.current.trim();
|
|
1522
1536
|
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_2, cc) && addressLine2Ref.current.trim()) billingAddress["line2"] = addressLine2Ref.current.trim();
|
|
1523
1537
|
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.city, cc) && cityRef.current.trim()) billingAddress["city"] = cityRef.current.trim();
|
|
1524
|
-
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc) && stateRef.current.trim())
|
|
1538
|
+
if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc) && stateRef.current.trim()) {
|
|
1539
|
+
billingAddress["state"] = stateRef.current.trim();
|
|
1540
|
+
} else if (avsConfig && (0, import_shared4.isAVSFieldVisible)(avsConfig.address_line_1, cc) && !(0, import_shared4.isAVSFieldVisible)(avsConfig.state, cc) && (0, import_shared4.isAVSFieldVisible)(avsConfig.postal_code, cc)) {
|
|
1541
|
+
const derivedSubmitState = (0, import_shared4.getStateFromPostalCode)(cc, zipCodeRef.current.trim());
|
|
1542
|
+
if (derivedSubmitState) billingAddress["state"] = derivedSubmitState;
|
|
1543
|
+
}
|
|
1525
1544
|
const billingDetails = {
|
|
1526
1545
|
...resolvedAccount.email ? { email: resolvedAccount.email } : {},
|
|
1527
1546
|
...fullName.trim() ? { name: fullName.trim() } : {},
|
|
@@ -3572,6 +3591,8 @@ function FloPayCheckout({
|
|
|
3572
3591
|
enableAVS,
|
|
3573
3592
|
avsLayout,
|
|
3574
3593
|
country: session?.customer?.country,
|
|
3594
|
+
city: session?.customer?.city,
|
|
3595
|
+
state: session?.customer?.state,
|
|
3575
3596
|
onCountryChange,
|
|
3576
3597
|
onZipChange,
|
|
3577
3598
|
avsCheck: !!enableAVS,
|