@funnelsgrove/payments 0.1.9 → 0.1.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.
|
@@ -31,7 +31,7 @@ function getFriendlyCardErrorMessage(error) {
|
|
|
31
31
|
? error.message
|
|
32
32
|
: 'Payment failed. Please review your card details and try again.';
|
|
33
33
|
}
|
|
34
|
-
function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel, closeAriaLabel, countdownLabel, customerEmail, customerEmailEditable = false, customerEmailLabel = 'Email', customerEmailPlaceholder = 'Enter your email', customerEmailInvalidMessage = 'Enter a valid email address.', customerName, discountAmountLabel, discountLabel, discountPercent, initialWalletAvailable,
|
|
34
|
+
function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel, closeAriaLabel, countdownLabel, customerEmail, customerEmailEditable = false, customerEmailLabel = 'Email', customerEmailPlaceholder = 'Enter your email', customerEmailInvalidMessage = 'Enter a valid email address.', customerName, discountAmountLabel, discountLabel, discountPercent, initialWalletAvailable, onClose, onCustomerEmailChange, onCustomerEmailCommit, onError, onSuccess, paymentMethodLabels = defaultPaymentMethodLabels, promoActive, processingLabel, promoCode, promoCodeLabel, remainingSeconds, returnUrl, savedLabel, secureLabel, satisfactionLabel, satisfactionPercent, summaryLabel, themeColor, title, totalLabel, totalValue, walletButtonLabel, originalPriceLabel, originalPriceValue, }) {
|
|
35
35
|
const checkoutState = useCheckout();
|
|
36
36
|
const walletPaymentMethods = usePlatformWalletPaymentMethods();
|
|
37
37
|
const [selectedMethod, setSelectedMethod] = useState('wallet');
|
|
@@ -41,16 +41,21 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
|
|
|
41
41
|
: walletAvailable;
|
|
42
42
|
const [submitting, setSubmitting] = useState(false);
|
|
43
43
|
const [error, setError] = useState(null);
|
|
44
|
-
const
|
|
45
|
-
const [
|
|
44
|
+
const initialCustomerEmail = (customerEmail === null || customerEmail === void 0 ? void 0 : customerEmail.trim()) || '';
|
|
45
|
+
const [emailDraft, setEmailDraft] = useState(initialCustomerEmail);
|
|
46
46
|
const cardBrandLabels = useMemo(() => paymentMethodLabels.length > 0 ? paymentMethodLabels : defaultPaymentMethodLabels, [paymentMethodLabels]);
|
|
47
47
|
const normalizedPromoCode = promoCode.trim();
|
|
48
48
|
const showPromo = promoActive !== null && promoActive !== void 0 ? promoActive : (discountPercent > 0 && normalizedPromoCode.length > 0);
|
|
49
49
|
const countdownValue = formatCountdown(remainingSeconds);
|
|
50
|
-
const initialCustomerEmail = (customerEmail === null || customerEmail === void 0 ? void 0 : customerEmail.trim()) || '';
|
|
51
50
|
const resolvedCustomerEmail = customerEmailEditable
|
|
52
51
|
? emailDraft.trim() || initialCustomerEmail
|
|
53
52
|
: initialCustomerEmail;
|
|
53
|
+
const emailFieldClassName = [
|
|
54
|
+
'shared-checkout-v2-email-field',
|
|
55
|
+
customerEmailEditable ? '' : 'is-disabled',
|
|
56
|
+
]
|
|
57
|
+
.filter(Boolean)
|
|
58
|
+
.join(' ');
|
|
54
59
|
const checkoutStyle = {
|
|
55
60
|
'--shared-checkout-v2-theme-color': themeColor,
|
|
56
61
|
'--shared-checkout-v2-button-color': buttonColor,
|
|
@@ -90,6 +95,15 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
|
|
|
90
95
|
}, [walletPaymentMethods]);
|
|
91
96
|
const paymentElementOptions = useMemo(() => {
|
|
92
97
|
return {
|
|
98
|
+
fields: {
|
|
99
|
+
billingDetails: {
|
|
100
|
+
name: 'never',
|
|
101
|
+
email: 'never',
|
|
102
|
+
address: {
|
|
103
|
+
country: 'auto',
|
|
104
|
+
},
|
|
105
|
+
},
|
|
106
|
+
},
|
|
93
107
|
layout: 'tabs',
|
|
94
108
|
wallets: {
|
|
95
109
|
applePay: 'never',
|
|
@@ -114,6 +128,11 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
|
|
|
114
128
|
setSelectedMethod('card');
|
|
115
129
|
}
|
|
116
130
|
};
|
|
131
|
+
useEffect(() => {
|
|
132
|
+
if (!customerEmailEditable) {
|
|
133
|
+
setEmailDraft(initialCustomerEmail);
|
|
134
|
+
}
|
|
135
|
+
}, [customerEmailEditable, initialCustomerEmail]);
|
|
117
136
|
useEffect(() => {
|
|
118
137
|
if (effectiveSelectedMethod !== 'card' || typeof window === 'undefined') {
|
|
119
138
|
return;
|
|
@@ -212,10 +231,13 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
|
|
|
212
231
|
effectiveSelectedMethod === 'card' ? 'is-visible' : '',
|
|
213
232
|
]
|
|
214
233
|
.filter(Boolean)
|
|
215
|
-
.join(' '), children: [
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
234
|
+
.join(' '), children: [_jsxs("div", { className: 'shared-checkout-v2-card-box', children: [_jsxs("label", { className: emailFieldClassName, children: [_jsx("span", { children: customerEmailLabel }), _jsx("input", { type: 'email', autoComplete: 'email', className: 'shared-checkout-v2-email-input', disabled: !customerEmailEditable, inputMode: 'email', readOnly: !customerEmailEditable, value: emailDraft, placeholder: customerEmailPlaceholder, onChange: (event) => {
|
|
235
|
+
if (!customerEmailEditable) {
|
|
236
|
+
return;
|
|
237
|
+
}
|
|
238
|
+
setEmailDraft(event.target.value);
|
|
239
|
+
onCustomerEmailChange === null || onCustomerEmailChange === void 0 ? void 0 : onCustomerEmailChange(event.target.value);
|
|
240
|
+
} })] }), _jsx(PaymentElement, { options: paymentElementOptions })] }), visibleError ? _jsx("p", { className: 'shared-checkout-v2-error', children: visibleError }) : null, _jsxs("button", { type: 'submit', className: 'shared-checkout-v2-card-submit', disabled: submitting, children: [_jsx(SecurityLockIcon, { className: 'shared-checkout-v2-card-submit-icon' }), submitting ? processingLabel : cardSubmitLabel] }), _jsx("div", { className: 'shared-checkout-v2-card-brands', "aria-hidden": 'true', children: cardBrandLabels.map((label) => (_jsx(PaymentBrandMark, { label: label, className: 'shared-checkout-v2-card-brand' }, label))) }), _jsxs("p", { className: 'shared-checkout-v2-secure-pill shared-checkout-v2-secure-pill--card', children: [_jsx(SecurityLockIcon, { className: 'shared-checkout-v2-secure-pill-icon' }), secureLabel] })] })] })] }));
|
|
219
241
|
}
|
|
220
242
|
export function SharedStripeCheckoutV2Dialog(_a) {
|
|
221
243
|
var { clientSecret, onClose, stripePromise } = _a, props = __rest(_a, ["clientSecret", "onClose", "stripePromise"]);
|
|
@@ -624,8 +646,11 @@ const sharedStripeCheckoutV2Styles = `
|
|
|
624
646
|
}
|
|
625
647
|
|
|
626
648
|
.shared-checkout-v2-card-panel {
|
|
649
|
+
position: relative;
|
|
627
650
|
gap: 10px;
|
|
628
|
-
|
|
651
|
+
margin-bottom: 42px;
|
|
652
|
+
background: #f2f2f3;
|
|
653
|
+
padding: 16px 15px 58px;
|
|
629
654
|
}
|
|
630
655
|
|
|
631
656
|
.shared-checkout-v2-wallet-panel.is-visible,
|
|
@@ -643,92 +668,57 @@ const sharedStripeCheckoutV2Styles = `
|
|
|
643
668
|
}
|
|
644
669
|
|
|
645
670
|
.shared-checkout-v2-email-field {
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
671
|
+
min-height: 64px;
|
|
672
|
+
box-sizing: border-box;
|
|
673
|
+
display: flex;
|
|
674
|
+
flex-direction: column;
|
|
675
|
+
justify-content: center;
|
|
676
|
+
border: 0;
|
|
677
|
+
border-bottom: 1px solid #dadde4;
|
|
678
|
+
border-radius: 0;
|
|
679
|
+
background: #fff;
|
|
680
|
+
padding: 8px 14px;
|
|
681
|
+
color: #647087;
|
|
682
|
+
font-size: 14px;
|
|
683
|
+
font-weight: 500;
|
|
684
|
+
line-height: 1;
|
|
685
|
+
}
|
|
686
|
+
|
|
687
|
+
.shared-checkout-v2-email-field.is-disabled {
|
|
688
|
+
cursor: default;
|
|
651
689
|
}
|
|
652
690
|
|
|
653
|
-
.shared-checkout-v2-email-input
|
|
654
|
-
.shared-checkout-v2-name-input {
|
|
691
|
+
.shared-checkout-v2-email-input {
|
|
655
692
|
width: 100%;
|
|
656
|
-
min-height:
|
|
693
|
+
min-height: 30px;
|
|
657
694
|
box-sizing: border-box;
|
|
658
|
-
border:
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
padding: 0 24px;
|
|
695
|
+
border: 0;
|
|
696
|
+
background: transparent;
|
|
697
|
+
padding: 0;
|
|
662
698
|
color: #303136;
|
|
663
699
|
font: inherit;
|
|
664
|
-
font-size:
|
|
665
|
-
font-weight:
|
|
700
|
+
font-size: 20px;
|
|
701
|
+
font-weight: 400;
|
|
702
|
+
line-height: 1.2;
|
|
666
703
|
outline: none;
|
|
667
704
|
}
|
|
668
705
|
|
|
669
|
-
.shared-checkout-v2-email-input
|
|
670
|
-
|
|
706
|
+
.shared-checkout-v2-email-input:disabled {
|
|
707
|
+
color: #74767c;
|
|
708
|
+
opacity: 1;
|
|
709
|
+
-webkit-text-fill-color: #74767c;
|
|
710
|
+
}
|
|
711
|
+
|
|
712
|
+
.shared-checkout-v2-email-input::placeholder {
|
|
671
713
|
color: #8c909a;
|
|
672
714
|
}
|
|
673
715
|
|
|
674
716
|
.shared-checkout-v2-card-box {
|
|
675
717
|
overflow: hidden;
|
|
676
|
-
border: 1px solid #
|
|
677
|
-
border-radius:
|
|
678
|
-
background: #
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
.shared-checkout-v2-card-number,
|
|
682
|
-
.shared-checkout-v2-card-half {
|
|
683
|
-
position: relative;
|
|
684
|
-
min-height: 56px;
|
|
685
|
-
box-sizing: border-box;
|
|
686
|
-
display: flex;
|
|
687
|
-
align-items: center;
|
|
688
|
-
padding: 0 24px;
|
|
689
|
-
}
|
|
690
|
-
|
|
691
|
-
.shared-checkout-v2-card-number > div,
|
|
692
|
-
.shared-checkout-v2-card-half > div {
|
|
693
|
-
position: relative;
|
|
694
|
-
z-index: 1;
|
|
695
|
-
width: 100%;
|
|
696
|
-
}
|
|
697
|
-
|
|
698
|
-
.shared-checkout-v2-card-number {
|
|
699
|
-
border-bottom: 1px solid #8f94a0;
|
|
700
|
-
}
|
|
701
|
-
|
|
702
|
-
.shared-checkout-v2-card-row {
|
|
703
|
-
display: grid;
|
|
704
|
-
grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
|
|
705
|
-
}
|
|
706
|
-
|
|
707
|
-
.shared-checkout-v2-card-half:first-child {
|
|
708
|
-
border-right: 1px solid #8f94a0;
|
|
709
|
-
}
|
|
710
|
-
|
|
711
|
-
.shared-checkout-v2-card-half--cvc {
|
|
712
|
-
justify-content: space-between;
|
|
713
|
-
gap: 10px;
|
|
714
|
-
}
|
|
715
|
-
|
|
716
|
-
.shared-checkout-v2-card-half--cvc > div {
|
|
717
|
-
flex: 1;
|
|
718
|
-
}
|
|
719
|
-
|
|
720
|
-
.shared-checkout-v2-cvc-info {
|
|
721
|
-
width: 24px;
|
|
722
|
-
height: 24px;
|
|
723
|
-
border-radius: 999px;
|
|
724
|
-
display: inline-flex;
|
|
725
|
-
align-items: center;
|
|
726
|
-
justify-content: center;
|
|
727
|
-
background: #8c909a;
|
|
728
|
-
color: #fff;
|
|
729
|
-
font-size: 16px;
|
|
730
|
-
font-weight: 900;
|
|
731
|
-
line-height: 1;
|
|
718
|
+
border: 1px solid #dadde4;
|
|
719
|
+
border-radius: 6px;
|
|
720
|
+
background: #fff;
|
|
721
|
+
box-shadow: 0 1px 2px rgb(16 24 40 / 10%);
|
|
732
722
|
}
|
|
733
723
|
|
|
734
724
|
.shared-checkout-v2-error {
|
|
@@ -780,6 +770,14 @@ const sharedStripeCheckoutV2Styles = `
|
|
|
780
770
|
height: 25px;
|
|
781
771
|
}
|
|
782
772
|
|
|
773
|
+
.shared-checkout-v2-secure-pill--card {
|
|
774
|
+
position: absolute;
|
|
775
|
+
left: 50%;
|
|
776
|
+
bottom: -33px;
|
|
777
|
+
transform: translateX(-50%);
|
|
778
|
+
white-space: nowrap;
|
|
779
|
+
}
|
|
780
|
+
|
|
783
781
|
.shared-checkout-v2-sr-only {
|
|
784
782
|
position: absolute;
|
|
785
783
|
width: 1px;
|