@funnelsgrove/payments 0.1.8 → 0.1.10

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, nameOnCardPlaceholder = 'Name on card', 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, }) {
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 [emailDraft, setEmailDraft] = useState((customerEmail === null || customerEmail === void 0 ? void 0 : customerEmail.trim()) || '');
45
- const [nameOnCard, setNameOnCard] = useState((customerName === null || customerName === void 0 ? void 0 : customerName.trim()) || '');
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,
@@ -72,7 +77,6 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
72
77
  applePay: 'subscribe',
73
78
  googlePay: 'subscribe',
74
79
  },
75
- emailRequired: true,
76
80
  layout: {
77
81
  maxColumns: 1,
78
82
  maxRows: 2,
@@ -91,7 +95,21 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
91
95
  }, [walletPaymentMethods]);
92
96
  const paymentElementOptions = useMemo(() => {
93
97
  return {
94
- layout: 'tabs',
98
+ fields: {
99
+ billingDetails: {
100
+ name: 'never',
101
+ email: 'never',
102
+ address: {
103
+ country: 'auto',
104
+ },
105
+ },
106
+ },
107
+ layout: {
108
+ type: 'accordion',
109
+ defaultCollapsed: false,
110
+ radios: false,
111
+ spacedAccordionItems: false,
112
+ },
95
113
  wallets: {
96
114
  applePay: 'never',
97
115
  googlePay: 'never',
@@ -115,6 +133,11 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
115
133
  setSelectedMethod('card');
116
134
  }
117
135
  };
136
+ useEffect(() => {
137
+ if (!customerEmailEditable) {
138
+ setEmailDraft(initialCustomerEmail);
139
+ }
140
+ }, [customerEmailEditable, initialCustomerEmail]);
118
141
  useEffect(() => {
119
142
  if (effectiveSelectedMethod !== 'card' || typeof window === 'undefined') {
120
143
  return;
@@ -213,10 +236,13 @@ function SharedStripeCheckoutV2Form({ amountCents, buttonColor, cardSubmitLabel,
213
236
  effectiveSelectedMethod === 'card' ? 'is-visible' : '',
214
237
  ]
215
238
  .filter(Boolean)
216
- .join(' '), children: [customerEmailEditable ? (_jsxs("label", { className: 'shared-checkout-v2-email-field', children: [_jsx("span", { children: customerEmailLabel }), _jsx("input", { type: 'email', autoComplete: 'email', className: 'shared-checkout-v2-email-input', inputMode: 'email', value: emailDraft, placeholder: customerEmailPlaceholder, onChange: (event) => {
239
+ .join(' '), 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) => {
240
+ if (!customerEmailEditable) {
241
+ return;
242
+ }
217
243
  setEmailDraft(event.target.value);
218
244
  onCustomerEmailChange === null || onCustomerEmailChange === void 0 ? void 0 : onCustomerEmailChange(event.target.value);
219
- } })] })) : null, _jsx("div", { className: 'shared-checkout-v2-card-box', children: _jsx(PaymentElement, { options: paymentElementOptions }) }), _jsx("input", { type: 'text', autoComplete: 'cc-name', className: 'shared-checkout-v2-name-input', value: nameOnCard, placeholder: nameOnCardPlaceholder, onChange: (event) => setNameOnCard(event.target.value) }), 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', children: [_jsx(SecurityLockIcon, { className: 'shared-checkout-v2-secure-pill-icon' }), secureLabel] })] })] })] }));
245
+ } })] }), _jsx("div", { className: 'shared-checkout-v2-card-box', children: _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] })] })] })] }));
220
246
  }
221
247
  export function SharedStripeCheckoutV2Dialog(_a) {
222
248
  var { clientSecret, onClose, stripePromise } = _a, props = __rest(_a, ["clientSecret", "onClose", "stripePromise"]);
@@ -625,8 +651,11 @@ const sharedStripeCheckoutV2Styles = `
625
651
  }
626
652
 
627
653
  .shared-checkout-v2-card-panel {
654
+ position: relative;
628
655
  gap: 10px;
629
- padding: 2px 15px 5px;
656
+ margin-bottom: 42px;
657
+ background: #f2f2f3;
658
+ padding: 16px 15px 58px;
630
659
  }
631
660
 
632
661
  .shared-checkout-v2-wallet-panel.is-visible,
@@ -644,92 +673,56 @@ const sharedStripeCheckoutV2Styles = `
644
673
  }
645
674
 
646
675
  .shared-checkout-v2-email-field {
647
- display: grid;
648
- gap: 7px;
649
- color: #25272a;
650
- font-size: 13px;
651
- font-weight: 800;
652
- }
653
-
654
- .shared-checkout-v2-email-input,
655
- .shared-checkout-v2-name-input {
656
- width: 100%;
657
- min-height: 56px;
676
+ min-height: 64px;
658
677
  box-sizing: border-box;
659
- border: 1px solid #8f94a0;
660
- border-radius: 14px;
661
- background: #f6f7fc;
662
- padding: 0 24px;
663
- color: #303136;
664
- font: inherit;
665
- font-size: 19px;
678
+ display: flex;
679
+ flex-direction: column;
680
+ justify-content: center;
681
+ border: 1px solid #dadde4;
682
+ border-radius: 6px;
683
+ background: #fff;
684
+ padding: 8px 14px;
685
+ box-shadow: 0 1px 2px rgb(16 24 40 / 10%);
686
+ color: #647087;
687
+ font-size: 14px;
666
688
  font-weight: 500;
667
- outline: none;
668
- }
669
-
670
- .shared-checkout-v2-email-input::placeholder,
671
- .shared-checkout-v2-name-input::placeholder {
672
- color: #8c909a;
673
- }
674
-
675
- .shared-checkout-v2-card-box {
676
- overflow: hidden;
677
- border: 1px solid #8f94a0;
678
- border-radius: 14px;
679
- background: #f6f7fc;
689
+ line-height: 1;
680
690
  }
681
691
 
682
- .shared-checkout-v2-card-number,
683
- .shared-checkout-v2-card-half {
684
- position: relative;
685
- min-height: 56px;
686
- box-sizing: border-box;
687
- display: flex;
688
- align-items: center;
689
- padding: 0 24px;
692
+ .shared-checkout-v2-email-field.is-disabled {
693
+ cursor: default;
690
694
  }
691
695
 
692
- .shared-checkout-v2-card-number > div,
693
- .shared-checkout-v2-card-half > div {
694
- position: relative;
695
- z-index: 1;
696
+ .shared-checkout-v2-email-input {
696
697
  width: 100%;
698
+ min-height: 30px;
699
+ box-sizing: border-box;
700
+ border: 0;
701
+ background: transparent;
702
+ padding: 0;
703
+ color: #303136;
704
+ font: inherit;
705
+ font-size: 20px;
706
+ font-weight: 400;
707
+ line-height: 1.2;
708
+ outline: none;
697
709
  }
698
710
 
699
- .shared-checkout-v2-card-number {
700
- border-bottom: 1px solid #8f94a0;
701
- }
702
-
703
- .shared-checkout-v2-card-row {
704
- display: grid;
705
- grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
706
- }
707
-
708
- .shared-checkout-v2-card-half:first-child {
709
- border-right: 1px solid #8f94a0;
710
- }
711
-
712
- .shared-checkout-v2-card-half--cvc {
713
- justify-content: space-between;
714
- gap: 10px;
711
+ .shared-checkout-v2-email-input:disabled {
712
+ color: #74767c;
713
+ opacity: 1;
714
+ -webkit-text-fill-color: #74767c;
715
715
  }
716
716
 
717
- .shared-checkout-v2-card-half--cvc > div {
718
- flex: 1;
717
+ .shared-checkout-v2-email-input::placeholder {
718
+ color: #8c909a;
719
719
  }
720
720
 
721
- .shared-checkout-v2-cvc-info {
722
- width: 24px;
723
- height: 24px;
724
- border-radius: 999px;
725
- display: inline-flex;
726
- align-items: center;
727
- justify-content: center;
728
- background: #8c909a;
729
- color: #fff;
730
- font-size: 16px;
731
- font-weight: 900;
732
- line-height: 1;
721
+ .shared-checkout-v2-card-box {
722
+ overflow: visible;
723
+ border: 0;
724
+ border-radius: 0;
725
+ background: transparent;
733
726
  }
734
727
 
735
728
  .shared-checkout-v2-error {
@@ -781,6 +774,14 @@ const sharedStripeCheckoutV2Styles = `
781
774
  height: 25px;
782
775
  }
783
776
 
777
+ .shared-checkout-v2-secure-pill--card {
778
+ position: absolute;
779
+ left: 50%;
780
+ bottom: -33px;
781
+ transform: translateX(-50%);
782
+ white-space: nowrap;
783
+ }
784
+
784
785
  .shared-checkout-v2-sr-only {
785
786
  position: absolute;
786
787
  width: 1px;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@funnelsgrove/payments",
3
- "version": "0.1.8",
3
+ "version": "0.1.10",
4
4
  "type": "module",
5
5
  "private": false,
6
6
  "main": "./dist/index.js",