@flopay/react 0.3.4 → 0.3.11
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 +56 -12
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -1
- package/dist/index.d.ts +9 -1
- package/dist/index.mjs +56 -12
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -3
package/dist/index.d.cts
CHANGED
|
@@ -83,6 +83,10 @@ interface FloPayCheckoutProps {
|
|
|
83
83
|
buttonsStyles?: _flopay_shared.ButtonsLayoutStyles;
|
|
84
84
|
/** Custom React content rendered inside the card button when `layout="buttons"`. */
|
|
85
85
|
cardButtonContent?: React.ReactNode;
|
|
86
|
+
/** Custom React content rendered for the buttons-layout card back button label. */
|
|
87
|
+
cardBackButtonContent?: React.ReactNode;
|
|
88
|
+
/** Custom React content rendered for the card-form title. */
|
|
89
|
+
cardTitleContent?: React.ReactNode;
|
|
86
90
|
/**
|
|
87
91
|
* Called when a payment method button is clicked.
|
|
88
92
|
* `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
|
|
@@ -138,7 +142,7 @@ interface FloPayCheckoutProps {
|
|
|
138
142
|
* />
|
|
139
143
|
* ```
|
|
140
144
|
*/
|
|
141
|
-
declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, fallbackPublishableKey, loading: loadingNode, error: errorNode, onComplete, onError, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, onButtonClick, enableAVS, avsLayout, submitLabel, className, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
|
|
145
|
+
declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, fallbackPublishableKey, loading: loadingNode, error: errorNode, onComplete, onError, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, onButtonClick, enableAVS, avsLayout, submitLabel, className, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
|
|
142
146
|
|
|
143
147
|
/**
|
|
144
148
|
* Returns the current `FloPay` instance, or `null` if the provider
|
|
@@ -380,6 +384,10 @@ interface SplitCardFormProps {
|
|
|
380
384
|
buttonsStyles?: _flopay_shared.ButtonsLayoutStyles;
|
|
381
385
|
/** Custom React content rendered inside the card button when `layout="buttons"`. */
|
|
382
386
|
cardButtonContent?: React.ReactNode;
|
|
387
|
+
/** Custom React content rendered for the buttons-layout card back button label. */
|
|
388
|
+
cardBackButtonContent?: React.ReactNode;
|
|
389
|
+
/** Custom React content rendered for the card-form title. */
|
|
390
|
+
cardTitleContent?: React.ReactNode;
|
|
383
391
|
/**
|
|
384
392
|
* Called when a payment method button is clicked.
|
|
385
393
|
* `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
|
package/dist/index.d.ts
CHANGED
|
@@ -83,6 +83,10 @@ interface FloPayCheckoutProps {
|
|
|
83
83
|
buttonsStyles?: _flopay_shared.ButtonsLayoutStyles;
|
|
84
84
|
/** Custom React content rendered inside the card button when `layout="buttons"`. */
|
|
85
85
|
cardButtonContent?: React.ReactNode;
|
|
86
|
+
/** Custom React content rendered for the buttons-layout card back button label. */
|
|
87
|
+
cardBackButtonContent?: React.ReactNode;
|
|
88
|
+
/** Custom React content rendered for the card-form title. */
|
|
89
|
+
cardTitleContent?: React.ReactNode;
|
|
86
90
|
/**
|
|
87
91
|
* Called when a payment method button is clicked.
|
|
88
92
|
* `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
|
|
@@ -138,7 +142,7 @@ interface FloPayCheckoutProps {
|
|
|
138
142
|
* />
|
|
139
143
|
* ```
|
|
140
144
|
*/
|
|
141
|
-
declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, fallbackPublishableKey, loading: loadingNode, error: errorNode, onComplete, onError, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, onButtonClick, enableAVS, avsLayout, submitLabel, className, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
|
|
145
|
+
declare function FloPayCheckout({ sessionId: sessionIdProp, createSession: createSessionParams, billingApiUrl, appearance, locale, fallbackPublishableKey, loading: loadingNode, error: errorNode, onComplete, onError, showPayPal, showApplePay, showGooglePay, layout, buttonsTheme, buttonsStyles, cardButtonContent, cardBackButtonContent, cardTitleContent, onButtonClick, enableAVS, avsLayout, submitLabel, className, children, checkoutMode: checkoutModeProp, confirmLabel, renderConfirmButton, onSessionCompleted, }: FloPayCheckoutProps): React.ReactElement;
|
|
142
146
|
|
|
143
147
|
/**
|
|
144
148
|
* Returns the current `FloPay` instance, or `null` if the provider
|
|
@@ -380,6 +384,10 @@ interface SplitCardFormProps {
|
|
|
380
384
|
buttonsStyles?: _flopay_shared.ButtonsLayoutStyles;
|
|
381
385
|
/** Custom React content rendered inside the card button when `layout="buttons"`. */
|
|
382
386
|
cardButtonContent?: React.ReactNode;
|
|
387
|
+
/** Custom React content rendered for the buttons-layout card back button label. */
|
|
388
|
+
cardBackButtonContent?: React.ReactNode;
|
|
389
|
+
/** Custom React content rendered for the card-form title. */
|
|
390
|
+
cardTitleContent?: React.ReactNode;
|
|
383
391
|
/**
|
|
384
392
|
* Called when a payment method button is clicked.
|
|
385
393
|
* `method`: `'card'` | `'paypal'` | `'apple_pay'` | `'google_pay'`
|
package/dist/index.mjs
CHANGED
|
@@ -113,10 +113,29 @@ function DefaultCardButtonContent() {
|
|
|
113
113
|
)
|
|
114
114
|
] });
|
|
115
115
|
}
|
|
116
|
+
function DefaultBackButtonContent() {
|
|
117
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: "Go back" });
|
|
118
|
+
}
|
|
119
|
+
function DefaultTitleContent() {
|
|
120
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: "Secure card checkout" });
|
|
121
|
+
}
|
|
122
|
+
function isEmptySlotContent(content) {
|
|
123
|
+
return content !== void 0 && (content === "" || content === null || content === false);
|
|
124
|
+
}
|
|
116
125
|
function CardButtonContentSlot({
|
|
117
126
|
content
|
|
118
127
|
}) {
|
|
119
|
-
return /* @__PURE__ */ jsx2(Fragment, { children: content
|
|
128
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: content === void 0 ? /* @__PURE__ */ jsx2(DefaultCardButtonContent, {}) : content });
|
|
129
|
+
}
|
|
130
|
+
function BackButtonContentSlot({
|
|
131
|
+
content
|
|
132
|
+
}) {
|
|
133
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: content === void 0 ? /* @__PURE__ */ jsx2(DefaultBackButtonContent, {}) : content });
|
|
134
|
+
}
|
|
135
|
+
function TitleContentSlot({
|
|
136
|
+
content
|
|
137
|
+
}) {
|
|
138
|
+
return /* @__PURE__ */ jsx2(Fragment, { children: content === void 0 ? /* @__PURE__ */ jsx2(DefaultTitleContent, {}) : content });
|
|
120
139
|
}
|
|
121
140
|
|
|
122
141
|
// src/elements.tsx
|
|
@@ -311,6 +330,14 @@ function ProcessingOverlay({ status, errorMessage }) {
|
|
|
311
330
|
status === "success" && "PAYMENT SUCCESSFUL",
|
|
312
331
|
status === "error" && "PAYMENT FAILED"
|
|
313
332
|
] }),
|
|
333
|
+
status === "success" && /* @__PURE__ */ jsx4("p", { style: {
|
|
334
|
+
fontSize: 13,
|
|
335
|
+
color: "#6b7280",
|
|
336
|
+
fontWeight: 400,
|
|
337
|
+
maxWidth: 260,
|
|
338
|
+
lineHeight: 1.4,
|
|
339
|
+
margin: 0
|
|
340
|
+
}, children: "You will be automatically redirected, do not close or navigate away from this window." }),
|
|
314
341
|
status === "error" && errorMessage && /* @__PURE__ */ jsx4("p", { style: {
|
|
315
342
|
fontSize: 13,
|
|
316
343
|
color: "#6b7280",
|
|
@@ -590,6 +617,8 @@ function SplitCardFormInner({
|
|
|
590
617
|
buttonsTheme,
|
|
591
618
|
buttonsStyles: buttonsStylesOverride,
|
|
592
619
|
cardButtonContent,
|
|
620
|
+
cardBackButtonContent,
|
|
621
|
+
cardTitleContent,
|
|
593
622
|
onButtonClick,
|
|
594
623
|
enableAVS = false,
|
|
595
624
|
avsLayout: avsLayoutProp = "row",
|
|
@@ -936,6 +965,8 @@ function SplitCardFormInner({
|
|
|
936
965
|
const resolvedBorder = isButtons ? bStyles.cardInputBorder ?? "#e5e7eb" : "#A4A4FF";
|
|
937
966
|
const cardBg = isButtons ? bStyles.cardFormContainer?.backgroundColor ?? "white" : "#EDEDFF";
|
|
938
967
|
const cardInputBg = isButtons ? bStyles.cardInputBackground ?? "white" : "white";
|
|
968
|
+
const hideBackButtonLabel = isEmptySlotContent(cardBackButtonContent);
|
|
969
|
+
const hideTitle = isEmptySlotContent(cardTitleContent);
|
|
939
970
|
const stripeElementStyle = isButtons && (bStyles.cardInputColor || bStyles.cardInputPlaceholderColor || bStyles.cardInputFontSize) ? {
|
|
940
971
|
style: {
|
|
941
972
|
base: {
|
|
@@ -966,7 +997,7 @@ function SplitCardFormInner({
|
|
|
966
997
|
style: {
|
|
967
998
|
display: "inline-flex",
|
|
968
999
|
alignItems: "center",
|
|
969
|
-
gap: "0.5rem",
|
|
1000
|
+
gap: hideBackButtonLabel ? 0 : "0.5rem",
|
|
970
1001
|
background: "none",
|
|
971
1002
|
border: "none",
|
|
972
1003
|
cursor: "pointer",
|
|
@@ -991,11 +1022,11 @@ function SplitCardFormInner({
|
|
|
991
1022
|
transition: "background-color 0.15s",
|
|
992
1023
|
...bStyles.backButtonIcon
|
|
993
1024
|
}, children: /* @__PURE__ */ jsx4("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx4("path", { d: "M15 18l-6-6 6-6" }) }) }),
|
|
994
|
-
|
|
1025
|
+
/* @__PURE__ */ jsx4(BackButtonContentSlot, { content: cardBackButtonContent })
|
|
995
1026
|
]
|
|
996
1027
|
}
|
|
997
1028
|
),
|
|
998
|
-
/* @__PURE__ */ jsx4("div", { style: {
|
|
1029
|
+
hideTitle ? /* @__PURE__ */ jsx4("div", { style: { flex: 1 } }) : /* @__PURE__ */ jsx4("div", { style: {
|
|
999
1030
|
flex: 1,
|
|
1000
1031
|
textAlign: "center",
|
|
1001
1032
|
fontWeight: 600,
|
|
@@ -1003,9 +1034,9 @@ function SplitCardFormInner({
|
|
|
1003
1034
|
color: "#262833",
|
|
1004
1035
|
paddingRight: 80,
|
|
1005
1036
|
...bStyles.title
|
|
1006
|
-
}, children:
|
|
1037
|
+
}, children: /* @__PURE__ */ jsx4(TitleContentSlot, { content: cardTitleContent }) })
|
|
1007
1038
|
] }),
|
|
1008
|
-
!isButtons && /* @__PURE__ */ jsx4("div", { style: { textAlign: "center", fontWeight: 600, fontSize: "1.1rem", padding: "0.5rem 0", color: "#262833" }, children:
|
|
1039
|
+
!isButtons && !hideTitle && /* @__PURE__ */ jsx4("div", { style: { textAlign: "center", fontWeight: 600, fontSize: "1.1rem", padding: "0.5rem 0", color: "#262833" }, children: /* @__PURE__ */ jsx4(TitleContentSlot, { content: cardTitleContent }) }),
|
|
1009
1040
|
/* @__PURE__ */ jsx4("div", { style: {
|
|
1010
1041
|
backgroundColor: cardInputBg,
|
|
1011
1042
|
border: `1px solid ${resolvedBorder}`,
|
|
@@ -1354,6 +1385,8 @@ function FloPayCheckout({
|
|
|
1354
1385
|
buttonsTheme,
|
|
1355
1386
|
buttonsStyles,
|
|
1356
1387
|
cardButtonContent,
|
|
1388
|
+
cardBackButtonContent,
|
|
1389
|
+
cardTitleContent,
|
|
1357
1390
|
onButtonClick,
|
|
1358
1391
|
enableAVS,
|
|
1359
1392
|
avsLayout,
|
|
@@ -1811,7 +1844,9 @@ function FloPayCheckout({
|
|
|
1811
1844
|
showGooglePay,
|
|
1812
1845
|
buttonsTheme,
|
|
1813
1846
|
buttonsStyles,
|
|
1814
|
-
cardButtonContent
|
|
1847
|
+
cardButtonContent,
|
|
1848
|
+
cardBackButtonContent,
|
|
1849
|
+
cardTitleContent
|
|
1815
1850
|
}
|
|
1816
1851
|
) });
|
|
1817
1852
|
}
|
|
@@ -1899,6 +1934,8 @@ function FloPayCheckout({
|
|
|
1899
1934
|
buttonsTheme,
|
|
1900
1935
|
buttonsStyles,
|
|
1901
1936
|
cardButtonContent,
|
|
1937
|
+
cardBackButtonContent,
|
|
1938
|
+
cardTitleContent,
|
|
1902
1939
|
onButtonClick,
|
|
1903
1940
|
enableAVS,
|
|
1904
1941
|
avsLayout,
|
|
@@ -1941,7 +1978,9 @@ function InterimButtonsView({
|
|
|
1941
1978
|
showGooglePay,
|
|
1942
1979
|
buttonsTheme,
|
|
1943
1980
|
buttonsStyles: stylesOverride,
|
|
1944
|
-
cardButtonContent
|
|
1981
|
+
cardButtonContent,
|
|
1982
|
+
cardBackButtonContent,
|
|
1983
|
+
cardTitleContent
|
|
1945
1984
|
}) {
|
|
1946
1985
|
const [showCardForm, setShowCardForm] = useState3(false);
|
|
1947
1986
|
const bStyles = useMemo3(() => {
|
|
@@ -1952,6 +1991,8 @@ function InterimButtonsView({
|
|
|
1952
1991
|
...stylesOverride,
|
|
1953
1992
|
cardButton: { ...base.cardButton, ...stylesOverride.cardButton },
|
|
1954
1993
|
cardFormContainer: { ...base.cardFormContainer, ...stylesOverride.cardFormContainer },
|
|
1994
|
+
backButton: { ...base.backButton, ...stylesOverride.backButton },
|
|
1995
|
+
backButtonIcon: { ...base.backButtonIcon, ...stylesOverride.backButtonIcon },
|
|
1955
1996
|
submitButton: { ...base.submitButton, ...stylesOverride.submitButton },
|
|
1956
1997
|
title: { ...base.title, ...stylesOverride.title }
|
|
1957
1998
|
};
|
|
@@ -1965,6 +2006,8 @@ function InterimButtonsView({
|
|
|
1965
2006
|
if (showCardForm) {
|
|
1966
2007
|
const inputBorder = bStyles.cardInputBorder ?? "#e5e7eb";
|
|
1967
2008
|
const inputBg = bStyles.cardInputBackground ?? "white";
|
|
2009
|
+
const hideBackButtonLabel = isEmptySlotContent(cardBackButtonContent);
|
|
2010
|
+
const hideTitle = isEmptySlotContent(cardTitleContent);
|
|
1968
2011
|
return /* @__PURE__ */ jsxs3("div", { style: {
|
|
1969
2012
|
backgroundColor: bStyles.cardFormContainer?.backgroundColor ?? "white",
|
|
1970
2013
|
borderRadius: "8px",
|
|
@@ -1978,10 +2021,11 @@ function InterimButtonsView({
|
|
|
1978
2021
|
{
|
|
1979
2022
|
type: "button",
|
|
1980
2023
|
onClick: () => setShowCardForm(false),
|
|
2024
|
+
"aria-label": "Back to payment methods",
|
|
1981
2025
|
style: {
|
|
1982
2026
|
display: "inline-flex",
|
|
1983
2027
|
alignItems: "center",
|
|
1984
|
-
gap: "0.5rem",
|
|
2028
|
+
gap: hideBackButtonLabel ? 0 : "0.5rem",
|
|
1985
2029
|
background: "none",
|
|
1986
2030
|
border: "none",
|
|
1987
2031
|
cursor: "pointer",
|
|
@@ -2003,11 +2047,11 @@ function InterimButtonsView({
|
|
|
2003
2047
|
backgroundColor: "#f3f4f6",
|
|
2004
2048
|
...bStyles.backButtonIcon
|
|
2005
2049
|
}, children: /* @__PURE__ */ jsx5("svg", { width: "14", height: "14", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: "2.5", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ jsx5("path", { d: "M15 18l-6-6 6-6" }) }) }),
|
|
2006
|
-
|
|
2050
|
+
/* @__PURE__ */ jsx5(BackButtonContentSlot, { content: cardBackButtonContent })
|
|
2007
2051
|
]
|
|
2008
2052
|
}
|
|
2009
2053
|
),
|
|
2010
|
-
/* @__PURE__ */ jsx5("div", { style: {
|
|
2054
|
+
hideTitle ? /* @__PURE__ */ jsx5("div", { style: { flex: 1 } }) : /* @__PURE__ */ jsx5("div", { style: {
|
|
2011
2055
|
flex: 1,
|
|
2012
2056
|
textAlign: "center",
|
|
2013
2057
|
fontWeight: 600,
|
|
@@ -2015,7 +2059,7 @@ function InterimButtonsView({
|
|
|
2015
2059
|
color: "#262833",
|
|
2016
2060
|
paddingRight: 80,
|
|
2017
2061
|
...bStyles.title
|
|
2018
|
-
}, children:
|
|
2062
|
+
}, children: /* @__PURE__ */ jsx5(TitleContentSlot, { content: cardTitleContent }) })
|
|
2019
2063
|
] }),
|
|
2020
2064
|
/* @__PURE__ */ jsx5("div", { style: { backgroundColor: inputBg, border: `1px solid ${inputBorder}`, borderTopLeftRadius: 8, borderTopRightRadius: 8, padding: 12, height: 45 }, children: /* @__PURE__ */ jsx5("div", { style: { width: "60%", height: 14, borderRadius: 4, background: "#e5e7eb", animation: "flopay-interim-pulse 1.5s ease-in-out infinite" } }) }),
|
|
2021
2065
|
/* @__PURE__ */ jsxs3("div", { style: { display: "flex" }, children: [
|