@funnelsgrove/payments 0.15.7 → 0.15.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.
@@ -10,17 +10,14 @@ var __rest = (this && this.__rest) || function (s, e) {
10
10
  }
11
11
  return t;
12
12
  };
13
- import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
14
- import { useCallback, useEffect, useMemo, useRef, useState, } from 'react';
15
- import { CheckoutProvider, PaymentElement, useCheckout, } from '@stripe/react-stripe-js/checkout';
16
- import { PaymentBrandMark, SecurityLockIcon } from './CheckoutBrandAssets.js';
17
- import { StripeCheckoutExpressCheckoutButton } from './StripeCheckoutExpressCheckoutButton.js';
18
- import { getUnsupportedCheckoutCountryMessage, normalizeSupportedCheckoutCountries, } from './checkoutCountries.js';
19
- import { isInactiveCheckoutSessionError } from '../hooks/useStripeSubscriptionCheckoutSession.js';
20
- import { getStripeWalletPaymentMethodOrder, usePlatformWalletPaymentMethods, } from './walletPlatform.js';
21
- import { queueStripeSubscriptionCheckoutStarted, trackPaidStripeSubscriptionCheckoutCompleted, trackStripeSubscriptionPaymentInfoSubmitted, } from '../services/checkoutCompletionAnalytics.service.js';
22
- import { trackCheckoutCanceled, trackCheckoutFailureShown, } from '../../../services/checkoutObservability.service.js';
23
- const defaultPaymentMethodLabels = ['Visa', 'Mastercard', 'Maestro', 'Discover'];
13
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
14
+ import { useCallback, useEffect, useMemo } from 'react';
15
+ import { CheckoutProvider } from '@stripe/react-stripe-js/checkout';
16
+ import { normalizeSupportedCheckoutCountries } from './checkoutCountries.js';
17
+ import { queueStripeSubscriptionCheckoutStarted } from '../services/checkoutCompletionAnalytics.service.js';
18
+ import { trackCheckoutCanceled } from '../../../services/checkoutObservability.service.js';
19
+ import { SharedStripeCheckoutV2CheckoutSessionForm, getFixedSupportedBillingCountry } from './SharedStripeCheckoutV2Form.internal.js';
20
+ import { sharedStripeCheckoutV2Styles } from './SharedStripeCheckoutV2.styles.js';
24
21
  const stripeCheckoutV2Appearance = {
25
22
  labels: 'above',
26
23
  inputs: 'spaced',
@@ -42,306 +39,6 @@ const stripeCheckoutV2Appearance = {
42
39
  },
43
40
  };
44
41
  const compactStripeCheckoutV2Appearance = Object.assign(Object.assign({}, stripeCheckoutV2Appearance), { variables: Object.assign(Object.assign({}, stripeCheckoutV2Appearance.variables), { borderRadius: '14px', colorPrimary: '#1687f8' }) });
45
- const isValidEmail = (value) => /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(value);
46
- const formatCountdown = (remainingSeconds) => {
47
- const normalizedSeconds = Number.isFinite(remainingSeconds)
48
- ? Math.max(0, Math.floor(remainingSeconds))
49
- : 0;
50
- const minutes = Math.floor(normalizedSeconds / 60);
51
- const seconds = normalizedSeconds % 60;
52
- return `${String(minutes).padStart(2, '0')}:${String(seconds).padStart(2, '0')}`;
53
- };
54
- const getFixedSupportedBillingCountry = (supportedCountries) => supportedCountries.length === 1 ? supportedCountries[0] : null;
55
- const checkoutCountryLabels = {
56
- US: 'United States',
57
- };
58
- const getCheckoutCountryLabel = (countryCode) => { var _a; return (_a = checkoutCountryLabels[countryCode]) !== null && _a !== void 0 ? _a : countryCode; };
59
- function getFriendlyCardErrorMessage(error) {
60
- return error instanceof Error && error.message
61
- ? error.message
62
- : 'Payment failed. Please review your card details and try again.';
63
- }
64
- function SharedStripeCheckoutV2CheckoutSessionForm({ amountCents, buttonColor, cardSubmitLabel, closeAriaLabel, countdownLabel, checkoutAnalytics, checkoutSessionId, customerEmail, customerEmailEditable = false, customerEmailLabel = 'Email', customerEmailPlaceholder = 'Enter your email', customerEmailInvalidMessage = 'Enter a valid email address.', customerName, discountAmountLabel, discountLabel, discountPercent, initialWalletAvailable, onClose, onCustomerEmailChange, onCustomerEmailCommit, onError, onInactiveCheckoutSession, onPaymentInfoSubmitted, onSuccess, paymentMethodLabels = defaultPaymentMethodLabels, promoActive, processingLabel, promoCode, promoCodeLabel, remainingSeconds, returnUrl, savedLabel, secureLabel, satisfactionLabel, satisfactionPercent, summaryLabel, supportedCountries, themeColor, title, totalLabel, totalValue, unsupportedCountryMessage, walletButtonLabel, originalPriceLabel, originalPriceValue, variant = 'standard', }) {
65
- const checkoutState = useCheckout();
66
- const walletPaymentMethods = usePlatformWalletPaymentMethods();
67
- const [selectedMethod, setSelectedMethod] = useState('wallet');
68
- const [walletAvailable, setWalletAvailable] = useState(initialWalletAvailable !== null && initialWalletAvailable !== void 0 ? initialWalletAvailable : null);
69
- const effectiveWalletAvailable = initialWalletAvailable === true && walletAvailable !== false
70
- ? true
71
- : walletAvailable;
72
- const [submitting, setSubmitting] = useState(false);
73
- const submitInFlightRef = useRef(false);
74
- const [paymentElementReady, setPaymentElementReady] = useState(false);
75
- const [paymentElementComplete, setPaymentElementComplete] = useState(false);
76
- const [error, setError] = useState(null);
77
- const [billingCountry, setBillingCountry] = useState(null);
78
- const initialCustomerEmail = (customerEmail === null || customerEmail === void 0 ? void 0 : customerEmail.trim()) || '';
79
- const [emailDraft, setEmailDraft] = useState(initialCustomerEmail);
80
- const normalizedSupportedCountries = useMemo(() => normalizeSupportedCheckoutCountries(supportedCountries), [supportedCountries]);
81
- const fixedBillingCountry = getFixedSupportedBillingCountry(normalizedSupportedCountries);
82
- const fixedBillingCountryLabel = fixedBillingCountry
83
- ? getCheckoutCountryLabel(fixedBillingCountry)
84
- : null;
85
- const cardBrandLabels = useMemo(() => paymentMethodLabels.length > 0 ? paymentMethodLabels : defaultPaymentMethodLabels, [paymentMethodLabels]);
86
- const normalizedPromoCode = promoCode.trim();
87
- const showPromo = promoActive !== null && promoActive !== void 0 ? promoActive : (discountPercent > 0 && normalizedPromoCode.length > 0);
88
- const countdownValue = formatCountdown(remainingSeconds);
89
- const resolvedCustomerEmail = customerEmailEditable
90
- ? emailDraft.trim() || initialCustomerEmail
91
- : initialCustomerEmail;
92
- const emailFieldClassName = [
93
- 'shared-checkout-v2-email-field',
94
- customerEmailEditable ? '' : 'is-disabled',
95
- ]
96
- .filter(Boolean)
97
- .join(' ');
98
- const checkoutStyle = {
99
- '--shared-checkout-v2-theme-color': themeColor,
100
- '--shared-checkout-v2-button-color': buttonColor,
101
- };
102
- const expressCheckoutSummaryLabel = (summaryLabel === null || summaryLabel === void 0 ? void 0 : summaryLabel.trim()) || discountLabel || title;
103
- const walletAriaLabel = walletPaymentMethods
104
- .map((method) => method === 'applePay' ? walletButtonLabel : 'Google Pay')
105
- .join(' / ');
106
- const showWalletMethod = effectiveWalletAvailable !== false && walletPaymentMethods.length > 0;
107
- const effectiveSelectedMethod = showWalletMethod && selectedMethod === 'wallet' ? 'wallet' : 'card';
108
- const expressCheckoutOptions = useMemo(() => {
109
- return {
110
- buttonHeight: 55,
111
- buttonTheme: {
112
- applePay: 'black',
113
- googlePay: 'black',
114
- },
115
- buttonType: {
116
- applePay: 'subscribe',
117
- googlePay: 'subscribe',
118
- },
119
- layout: {
120
- maxColumns: 1,
121
- maxRows: 2,
122
- overflow: 'auto',
123
- },
124
- paymentMethodOrder: getStripeWalletPaymentMethodOrder(walletPaymentMethods),
125
- paymentMethods: {
126
- amazonPay: 'never',
127
- applePay: walletPaymentMethods.includes('applePay') ? 'always' : 'never',
128
- googlePay: walletPaymentMethods.includes('googlePay') ? 'always' : 'never',
129
- klarna: 'never',
130
- link: 'never',
131
- paypal: 'never',
132
- },
133
- };
134
- }, [walletPaymentMethods]);
135
- const paymentElementOptions = useMemo(() => {
136
- return {
137
- fields: {
138
- billingDetails: {
139
- name: 'never',
140
- email: 'never',
141
- address: {
142
- country: fixedBillingCountry ? 'never' : 'auto',
143
- },
144
- },
145
- },
146
- layout: 'tabs',
147
- wallets: {
148
- applePay: 'never',
149
- googlePay: 'never',
150
- link: 'never',
151
- },
152
- };
153
- }, [fixedBillingCountry]);
154
- const handleInactiveCheckoutSession = () => {
155
- setError(null);
156
- onInactiveCheckoutSession === null || onInactiveCheckoutSession === void 0 ? void 0 : onInactiveCheckoutSession();
157
- };
158
- const setSharedError = (message, alreadyTracked = false, providerError) => {
159
- if (isInactiveCheckoutSessionError(message)) {
160
- handleInactiveCheckoutSession();
161
- return;
162
- }
163
- if (message && checkoutAnalytics && !alreadyTracked) {
164
- trackCheckoutFailureShown({
165
- analytics: checkoutAnalytics,
166
- checkoutSessionId,
167
- errorMessage: message,
168
- failureStage: 'card_form',
169
- paymentMethod: 'card',
170
- provider: 'stripe',
171
- providerDeclineCode: providerError === null || providerError === void 0 ? void 0 : providerError.decline_code,
172
- providerErrorCode: providerError === null || providerError === void 0 ? void 0 : providerError.code,
173
- providerErrorType: providerError === null || providerError === void 0 ? void 0 : providerError.type,
174
- });
175
- }
176
- setError(message);
177
- onError === null || onError === void 0 ? void 0 : onError(message);
178
- };
179
- const selectWalletMethod = () => {
180
- if (showWalletMethod) {
181
- setSelectedMethod('wallet');
182
- }
183
- };
184
- const selectCardMethod = () => setSelectedMethod('card');
185
- const handleWalletAvailabilityChange = (available) => {
186
- setWalletAvailable(available);
187
- if (!available && selectedMethod === 'wallet') {
188
- setSelectedMethod('card');
189
- }
190
- };
191
- const getBillingCountryError = (country) => getUnsupportedCheckoutCountryMessage({
192
- billingCountry: country,
193
- message: unsupportedCountryMessage,
194
- supportedCountries: normalizedSupportedCountries,
195
- });
196
- const handlePaymentElementChange = (event) => {
197
- var _a, _b;
198
- setPaymentElementComplete(event.complete);
199
- setBillingCountry((_b = (_a = event.value.billingDetails) === null || _a === void 0 ? void 0 : _a.address.country) !== null && _b !== void 0 ? _b : fixedBillingCountry);
200
- };
201
- const trackCheckoutSuccess = async () => {
202
- if (checkoutAnalytics) {
203
- await trackPaidStripeSubscriptionCheckoutCompleted(Object.assign({ checkoutSessionId }, checkoutAnalytics));
204
- }
205
- await (onSuccess === null || onSuccess === void 0 ? void 0 : onSuccess());
206
- };
207
- const trackPaymentInfoSubmitted = async () => {
208
- if (checkoutAnalytics) {
209
- await trackStripeSubscriptionPaymentInfoSubmitted(Object.assign({ checkoutSessionId }, checkoutAnalytics)).catch(() => 'analytics_rejected');
210
- }
211
- await (onPaymentInfoSubmitted === null || onPaymentInfoSubmitted === void 0 ? void 0 : onPaymentInfoSubmitted());
212
- };
213
- useEffect(() => {
214
- if (effectiveSelectedMethod !== 'card' || typeof window === 'undefined') {
215
- return;
216
- }
217
- const resizeTimer = window.setTimeout(() => {
218
- window.dispatchEvent(new Event('resize'));
219
- }, 0);
220
- return () => window.clearTimeout(resizeTimer);
221
- }, [effectiveSelectedMethod]);
222
- const commitCustomerEmail = async (normalizedEmail) => {
223
- if (!customerEmailEditable || !onCustomerEmailCommit) {
224
- return normalizedEmail;
225
- }
226
- const committedEmail = await onCustomerEmailCommit(normalizedEmail);
227
- const nextEmail = typeof committedEmail === 'string' && committedEmail.trim()
228
- ? committedEmail.trim()
229
- : normalizedEmail;
230
- setEmailDraft(nextEmail);
231
- onCustomerEmailChange === null || onCustomerEmailChange === void 0 ? void 0 : onCustomerEmailChange(nextEmail);
232
- return nextEmail;
233
- };
234
- const commitEmailDraftIfValid = (value) => {
235
- const normalizedEmail = value.trim();
236
- if (!customerEmailEditable || !onCustomerEmailCommit) {
237
- return;
238
- }
239
- if (!normalizedEmail || !isValidEmail(normalizedEmail)) {
240
- return;
241
- }
242
- void commitCustomerEmail(normalizedEmail).catch((commitError) => {
243
- setSharedError(getFriendlyCardErrorMessage(commitError));
244
- });
245
- };
246
- const ensureCustomerEmail = async () => {
247
- const normalizedEmail = resolvedCustomerEmail.trim();
248
- if (!normalizedEmail || !isValidEmail(normalizedEmail)) {
249
- setSharedError(customerEmailInvalidMessage);
250
- return null;
251
- }
252
- return commitCustomerEmail(normalizedEmail);
253
- };
254
- const handleSubmit = async (event) => {
255
- event.preventDefault();
256
- if (submitInFlightRef.current) {
257
- return;
258
- }
259
- const billingCountryError = getBillingCountryError(billingCountry !== null && billingCountry !== void 0 ? billingCountry : fixedBillingCountry);
260
- if (billingCountryError) {
261
- setSharedError(billingCountryError);
262
- return;
263
- }
264
- if (checkoutState.type !== 'success') {
265
- setSharedError(checkoutState.type === 'error'
266
- ? checkoutState.error.message
267
- : 'Payment form is not ready yet.');
268
- return;
269
- }
270
- if (!paymentElementReady) {
271
- setSharedError('Payment form is not ready yet.', true);
272
- return;
273
- }
274
- submitInFlightRef.current = true;
275
- setSubmitting(true);
276
- setSharedError(null);
277
- const finishSubmitting = () => {
278
- submitInFlightRef.current = false;
279
- setSubmitting(false);
280
- };
281
- try {
282
- const syncedEmail = await ensureCustomerEmail();
283
- if (!syncedEmail) {
284
- finishSubmitting();
285
- return;
286
- }
287
- if (paymentElementComplete) {
288
- await trackPaymentInfoSubmitted();
289
- }
290
- const result = await checkoutState.checkout.confirm({
291
- redirect: 'if_required',
292
- });
293
- if (result.type === 'error') {
294
- const message = result.error.message || 'Payment failed.';
295
- setSharedError(message, false, result.error);
296
- finishSubmitting();
297
- return;
298
- }
299
- if (typeof window !== 'undefined') {
300
- await trackCheckoutSuccess();
301
- window.location.assign(returnUrl);
302
- return;
303
- }
304
- finishSubmitting();
305
- }
306
- catch (submitError) {
307
- setSharedError(getFriendlyCardErrorMessage(submitError));
308
- finishSubmitting();
309
- }
310
- };
311
- const visibleError = error;
312
- return (_jsxs("div", { className: 'shared-checkout-v2-shell', "data-variant": variant, style: checkoutStyle, children: [_jsxs("header", { className: 'shared-checkout-v2-header', children: [_jsx("button", { type: 'button', className: 'shared-checkout-v2-close', onClick: onClose, "aria-label": closeAriaLabel, children: _jsx("span", { "aria-hidden": 'true' }) }), _jsx("h2", { id: 'shared-checkout-v2-title', children: title })] }), _jsxs("section", { className: 'shared-checkout-v2-summary', children: [showPromo ? (_jsxs("p", { className: 'shared-checkout-v2-countdown', children: [discountPercent, "% ", countdownLabel, " ", countdownValue, " min"] })) : null, variant === 'standard' ? (_jsxs("p", { className: 'shared-checkout-v2-satisfaction', children: [_jsx("strong", { children: satisfactionPercent }), " ", satisfactionLabel] })) : null, showPromo ? (_jsxs("div", { className: 'shared-checkout-v2-price-stack', children: [_jsxs("div", { className: 'shared-checkout-v2-price-row is-muted', children: [_jsx("span", { children: originalPriceLabel }), _jsx("span", { className: 'shared-checkout-v2-strike', children: originalPriceValue })] }), _jsxs("div", { className: 'shared-checkout-v2-price-row is-discount', children: [_jsx("strong", { children: discountLabel }), _jsx("strong", { children: discountAmountLabel })] }), _jsxs("div", { className: 'shared-checkout-v2-promo', children: [_jsx("span", { children: promoCodeLabel }), _jsx("strong", { children: normalizedPromoCode })] })] })) : null, _jsxs("div", { className: [
313
- 'shared-checkout-v2-total',
314
- showPromo ? '' : 'is-plain',
315
- ]
316
- .filter(Boolean)
317
- .join(' '), children: [_jsx("span", { children: totalLabel }), _jsxs("strong", { children: [_jsx("svg", { viewBox: '0 0 24 24', "aria-hidden": 'true', children: _jsx("path", { d: 'M20.6 13.4 12.4 21.6a2.2 2.2 0 0 1-3.1 0L2.4 14.7a2.2 2.2 0 0 1-.6-1.6V5.4a2 2 0 0 1 2-2h7.7a2.2 2.2 0 0 1 1.6.6l7.5 7.5a1.4 1.4 0 0 1 0 1.9ZM7.2 8.1a1.2 1.2 0 1 0 0-2.4 1.2 1.2 0 0 0 0 2.4Z' }) }), totalValue] })] }), showPromo ? (_jsxs("p", { className: 'shared-checkout-v2-saved', children: [_jsx("span", { "aria-hidden": 'true', children: "\uD83D\uDD25" }), savedLabel] })) : null] }), _jsxs("form", { className: 'shared-checkout-v2-payment', onSubmit: (event) => void handleSubmit(event), children: [showWalletMethod ? (_jsxs("div", { className: 'shared-checkout-v2-methods', role: 'tablist', "aria-label": 'Payment method', children: [_jsxs("button", { type: 'button', className: [
318
- 'shared-checkout-v2-method',
319
- effectiveSelectedMethod === 'wallet' ? 'is-selected' : '',
320
- ]
321
- .filter(Boolean)
322
- .join(' '), onClick: selectWalletMethod, role: 'tab', "aria-selected": effectiveSelectedMethod === 'wallet', children: [_jsxs("span", { className: 'shared-checkout-v2-tab-wallets', "aria-hidden": 'true', children: [walletPaymentMethods.includes('applePay') ? (_jsx(PaymentBrandMark, { label: 'Apple Pay', className: 'shared-checkout-v2-tab-wallet' })) : null, walletPaymentMethods.includes('googlePay') ? (_jsx(PaymentBrandMark, { label: 'Google Pay', className: 'shared-checkout-v2-tab-wallet' })) : null] }), _jsx("span", { className: 'shared-checkout-v2-sr-only', children: walletAriaLabel })] }), _jsxs("button", { type: 'button', className: [
323
- 'shared-checkout-v2-method',
324
- effectiveSelectedMethod === 'card' ? 'is-selected' : '',
325
- ]
326
- .filter(Boolean)
327
- .join(' '), onClick: selectCardMethod, role: 'tab', "aria-selected": effectiveSelectedMethod === 'card', children: [_jsx("strong", { children: "Credit card" }), _jsx("span", { className: 'shared-checkout-v2-tab-brands', "aria-hidden": 'true', children: cardBrandLabels.slice(0, 4).map((label) => (_jsx(PaymentBrandMark, { label: label, className: 'shared-checkout-v2-tab-brand' }, label))) })] })] })) : null, _jsxs("div", { hidden: effectiveSelectedMethod !== 'wallet', className: [
328
- 'shared-checkout-v2-wallet-panel',
329
- effectiveSelectedMethod === 'wallet' ? 'is-visible' : '',
330
- ]
331
- .filter(Boolean)
332
- .join(' '), children: [_jsxs("p", { className: 'shared-checkout-v2-secure-pill', children: [_jsx(SecurityLockIcon, { className: 'shared-checkout-v2-secure-pill-icon' }), secureLabel] }), _jsxs("div", { className: 'shared-checkout-v2-wallet-shell', "aria-label": walletAriaLabel, children: [_jsx(StripeCheckoutExpressCheckoutButton, { amountCents: amountCents, availabilityPaymentMethods: walletPaymentMethods, beforeConfirm: ensureCustomerEmail, checkoutAnalytics: checkoutAnalytics, checkoutSessionId: checkoutSessionId, className: 'shared-checkout-v2-express-buttons', confirmEmail: false, customerEmail: resolvedCustomerEmail, customerName: customerName, initialAvailable: initialWalletAvailable, keepInitialAvailableOnReady: initialWalletAvailable === true, onAvailabilityChange: handleWalletAvailabilityChange, onError: (message) => setSharedError(message, true), onPaymentInfoSubmitted: onPaymentInfoSubmitted, onPaymentRejected: () => setSelectedMethod('card'), onSuccess: trackCheckoutSuccess, options: expressCheckoutOptions, returnUrl: returnUrl, summaryLabel: expressCheckoutSummaryLabel, supportedCountries: normalizedSupportedCountries, unsupportedCountryMessage: unsupportedCountryMessage }), _jsx("span", { className: 'shared-checkout-v2-sr-only', children: walletAriaLabel })] })] }), _jsxs("div", { hidden: effectiveSelectedMethod !== 'card', className: [
333
- 'shared-checkout-v2-card-panel',
334
- effectiveSelectedMethod === 'card' ? 'is-visible' : '',
335
- ]
336
- .filter(Boolean)
337
- .join(' '), children: [_jsxs("div", { className: 'shared-checkout-v2-card-box', children: [_jsxs("label", { className: emailFieldClassName, children: [_jsx("span", { className: 'shared-checkout-v2-email-label', children: customerEmailLabel }), _jsx("span", { className: 'shared-checkout-v2-email-control', children: _jsx("input", { type: 'email', autoComplete: 'email', className: 'shared-checkout-v2-email-input', disabled: !customerEmailEditable, inputMode: 'email', readOnly: !customerEmailEditable, value: customerEmailEditable ? emailDraft : initialCustomerEmail, placeholder: customerEmailPlaceholder, onBlur: (event) => commitEmailDraftIfValid(event.currentTarget.value), onChange: (event) => {
338
- if (!customerEmailEditable) {
339
- return;
340
- }
341
- setEmailDraft(event.target.value);
342
- onCustomerEmailChange === null || onCustomerEmailChange === void 0 ? void 0 : onCustomerEmailChange(event.target.value);
343
- } }) })] }), _jsx(PaymentElement, { options: paymentElementOptions, onChange: handlePaymentElementChange, onReady: () => setPaymentElementReady(true) }), fixedBillingCountry && fixedBillingCountryLabel ? (_jsxs("label", { className: 'shared-checkout-v2-country-field', children: [_jsx("span", { className: 'shared-checkout-v2-country-label', children: "Country" }), _jsx("span", { className: 'shared-checkout-v2-country-control', children: _jsx("select", { "aria-label": 'Country', className: 'shared-checkout-v2-country-select', value: fixedBillingCountry, onChange: () => setBillingCountry(fixedBillingCountry), children: _jsx("option", { value: fixedBillingCountry, children: fixedBillingCountryLabel }) }) })] })) : null] }), visibleError ? _jsx("p", { className: 'shared-checkout-v2-error', children: visibleError }) : null, _jsxs("button", { type: 'submit', className: 'shared-checkout-v2-card-submit', disabled: submitting || !paymentElementReady, 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] })] })] })] }));
344
- }
345
42
  function CheckoutSessionProvider({ children, clientSecret, fixedBillingCountry, stripePromise, variant, }) {
346
43
  const providerChildren = children;
347
44
  const checkoutProviderOptions = useMemo(() => (Object.assign(Object.assign({ clientSecret }, (fixedBillingCountry
@@ -406,784 +103,3 @@ export function SharedCheckoutSpecialOfferDialog({ buttonColor, buttonLabel, des
406
103
  };
407
104
  return (_jsxs(_Fragment, { children: [_jsx("div", { className: 'shared-checkout-special-offer-overlay', style: checkoutStyle, children: _jsxs("section", { className: 'shared-checkout-special-offer-dialog', role: 'dialog', "aria-modal": 'true', "aria-labelledby": 'shared-checkout-special-offer-title', children: [_jsx(SharedCheckoutSpecialOfferGift, { discountLabel: discountLabel, imageAlt: imageAlt, imageSrc: imageSrc }), _jsx("h2", { id: 'shared-checkout-special-offer-title', children: title }), _jsx("p", { children: description }), _jsx("button", { type: 'button', className: 'shared-checkout-special-offer-button', onClick: onAccept, children: buttonLabel })] }) }), _jsx("style", { children: sharedStripeCheckoutV2Styles })] }));
408
105
  }
409
- const sharedStripeCheckoutV2Styles = `
410
- .shared-checkout-v2-overlay {
411
- position: fixed;
412
- inset: 0;
413
- z-index: 110;
414
- display: flex;
415
- align-items: stretch;
416
- justify-content: center;
417
- overflow: hidden;
418
- background: #fff;
419
- }
420
-
421
- .shared-checkout-v2-dialog {
422
- width: min(100%, 430px);
423
- height: 100svh;
424
- max-height: 100svh;
425
- overflow: hidden;
426
- background: #fff;
427
- }
428
-
429
- @media (min-width: 640px) {
430
- .shared-checkout-v2-overlay:has(.shared-checkout-v2-dialog[data-variant='compact']) {
431
- align-items: center;
432
- padding: 24px;
433
- background: rgb(0 0 0 / 48%);
434
- }
435
-
436
- .shared-checkout-v2-dialog[data-variant='compact'] {
437
- width: min(100%, 520px);
438
- height: auto;
439
- max-height: calc(100svh - 48px);
440
- border-radius: 24px;
441
- box-shadow: 0 24px 70px rgb(0 0 0 / 28%);
442
- }
443
- }
444
-
445
- .shared-checkout-v2-shell[data-variant='compact'] {
446
- height: auto;
447
- max-height: min(100svh, 760px);
448
- }
449
-
450
- .shared-checkout-v2-shell[data-variant='compact'] .shared-checkout-v2-header {
451
- min-height: 88px;
452
- padding: 0 72px;
453
- }
454
-
455
- .shared-checkout-v2-shell[data-variant='compact'] .shared-checkout-v2-header h2 {
456
- font-size: 27px;
457
- }
458
-
459
- .shared-checkout-v2-shell[data-variant='compact'] .shared-checkout-v2-close {
460
- right: 22px;
461
- left: auto;
462
- }
463
-
464
- .shared-checkout-v2-shell[data-variant='compact'] .shared-checkout-v2-summary {
465
- padding: 0 36px;
466
- }
467
-
468
- .shared-checkout-v2-shell[data-variant='compact'] .shared-checkout-v2-total {
469
- min-height: 82px;
470
- border: 1px solid #ececef;
471
- border-radius: 16px;
472
- padding: 0 22px;
473
- background: #fbfbfc;
474
- }
475
-
476
- .shared-checkout-v2-shell[data-variant='compact'] .shared-checkout-v2-total svg {
477
- display: none;
478
- }
479
-
480
- .shared-checkout-v2-shell[data-variant='compact'] .shared-checkout-v2-payment {
481
- padding-right: 36px;
482
- padding-left: 36px;
483
- }
484
-
485
- .shared-checkout-v2-shell[data-variant='compact'] .shared-checkout-v2-card-submit {
486
- border-radius: 14px;
487
- background: var(--shared-checkout-v2-button-color);
488
- text-transform: none;
489
- }
490
-
491
- .shared-checkout-v2-shell {
492
- height: 100%;
493
- max-height: 100svh;
494
- box-sizing: border-box;
495
- display: flex;
496
- flex-direction: column;
497
- overflow-y: auto;
498
- overflow-x: hidden;
499
- -webkit-overflow-scrolling: touch;
500
- background: #fff;
501
- color: #303136;
502
- font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
503
- }
504
-
505
- .shared-checkout-v2-header {
506
- position: relative;
507
- min-height: 70px;
508
- display: flex;
509
- align-items: center;
510
- justify-content: center;
511
- padding: 0 56px;
512
- background: #fff;
513
- }
514
-
515
- .shared-checkout-v2-header h2 {
516
- margin: 0;
517
- color: #020203;
518
- font-size: 24px;
519
- font-weight: 900;
520
- line-height: 1.15;
521
- letter-spacing: 0;
522
- text-align: center;
523
- }
524
-
525
- .shared-checkout-v2-close {
526
- position: absolute;
527
- left: 16px;
528
- top: 50%;
529
- width: 40px;
530
- height: 40px;
531
- border: 0;
532
- border-radius: 999px;
533
- background: #f2f2f3;
534
- color: #aaa;
535
- transform: translateY(-50%);
536
- cursor: pointer;
537
- }
538
-
539
- .shared-checkout-v2-close span,
540
- .shared-checkout-v2-close span::after {
541
- position: absolute;
542
- left: 50%;
543
- top: 50%;
544
- width: 28px;
545
- height: 4px;
546
- border-radius: 999px;
547
- background: currentColor;
548
- content: '';
549
- }
550
-
551
- .shared-checkout-v2-close span {
552
- transform: translate(-50%, -50%) rotate(45deg);
553
- }
554
-
555
- .shared-checkout-v2-close span::after {
556
- transform: translate(-50%, -50%) rotate(90deg);
557
- }
558
-
559
- .shared-checkout-v2-summary {
560
- padding: 0 17px 0;
561
- background: #fff;
562
- }
563
-
564
- .shared-checkout-v2-countdown {
565
- margin: 0;
566
- min-height: 37px;
567
- display: flex;
568
- align-items: center;
569
- justify-content: center;
570
- border-radius: 12px;
571
- background: color-mix(in srgb, var(--shared-checkout-v2-theme-color) 10%, #fff);
572
- color: var(--shared-checkout-v2-theme-color);
573
- font-size: 16px;
574
- font-weight: 900;
575
- line-height: 1.2;
576
- letter-spacing: 0;
577
- text-align: center;
578
- }
579
-
580
- .shared-checkout-v2-satisfaction {
581
- margin: 17px 0 21px;
582
- color: #2f3034;
583
- font-size: 19px;
584
- font-weight: 800;
585
- line-height: 1.15;
586
- letter-spacing: 0;
587
- text-align: center;
588
- }
589
-
590
- .shared-checkout-v2-satisfaction strong {
591
- color: var(--shared-checkout-v2-theme-color);
592
- }
593
-
594
- .shared-checkout-v2-price-stack {
595
- display: flex;
596
- flex-direction: column;
597
- gap: 8px;
598
- }
599
-
600
- .shared-checkout-v2-price-row {
601
- display: flex;
602
- align-items: center;
603
- justify-content: space-between;
604
- gap: 12px;
605
- font-size: 18px;
606
- line-height: 1.2;
607
- letter-spacing: 0;
608
- }
609
-
610
- .shared-checkout-v2-price-row.is-muted {
611
- color: #9d9d9f;
612
- font-size: 17px;
613
- font-weight: 500;
614
- }
615
-
616
- .shared-checkout-v2-strike {
617
- text-decoration-line: line-through;
618
- text-decoration-thickness: 2px;
619
- }
620
-
621
- .shared-checkout-v2-price-row.is-discount {
622
- color: #040508;
623
- font-size: 17px;
624
- font-weight: 900;
625
- }
626
-
627
- .shared-checkout-v2-price-row.is-discount strong:last-child {
628
- color: #ff2544;
629
- }
630
-
631
- .shared-checkout-v2-promo {
632
- min-height: 42px;
633
- box-sizing: border-box;
634
- display: flex;
635
- align-items: center;
636
- justify-content: space-between;
637
- gap: 12px;
638
- border-radius: 13px;
639
- background: #f0f0f0;
640
- padding: 0 14px;
641
- color: #8d8d90;
642
- font-size: 16px;
643
- font-weight: 500;
644
- line-height: 1.1;
645
- }
646
-
647
- .shared-checkout-v2-promo strong {
648
- color: #050609;
649
- font-weight: 900;
650
- }
651
-
652
- .shared-checkout-v2-total {
653
- margin-top: 20px;
654
- min-height: 76px;
655
- border-top: 1px solid #dedede;
656
- display: flex;
657
- align-items: center;
658
- justify-content: space-between;
659
- gap: 16px;
660
- color: #303136;
661
- }
662
-
663
- .shared-checkout-v2-total span {
664
- font-size: 23px;
665
- font-weight: 800;
666
- line-height: 1;
667
- }
668
-
669
- .shared-checkout-v2-total strong {
670
- display: inline-flex;
671
- align-items: center;
672
- gap: 7px;
673
- color: #303136;
674
- font-size: 25px;
675
- font-weight: 900;
676
- line-height: 1;
677
- }
678
-
679
- .shared-checkout-v2-total svg {
680
- width: 25px;
681
- height: 25px;
682
- fill: none;
683
- stroke: currentColor;
684
- stroke-width: 2;
685
- stroke-linejoin: round;
686
- }
687
-
688
- .shared-checkout-v2-total.is-plain {
689
- margin-top: 0;
690
- }
691
-
692
- .shared-checkout-v2-saved {
693
- width: fit-content;
694
- min-height: 36px;
695
- box-sizing: border-box;
696
- display: flex;
697
- align-items: center;
698
- justify-content: center;
699
- gap: 8px;
700
- margin: -8px 0 9px auto;
701
- border-radius: 12px;
702
- background: #ffdce3;
703
- padding: 0 14px;
704
- color: #ff2544;
705
- font-size: 14px;
706
- font-weight: 900;
707
- line-height: 1.1;
708
- letter-spacing: 0;
709
- }
710
-
711
- .shared-checkout-v2-payment {
712
- min-height: 0;
713
- display: flex;
714
- flex-direction: column;
715
- gap: 12px;
716
- background: #f2f2f3;
717
- padding: 9px 17px 32px;
718
- }
719
-
720
- .shared-checkout-v2-methods {
721
- display: grid;
722
- grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
723
- gap: 42px;
724
- }
725
-
726
- .shared-checkout-v2-method {
727
- min-width: 0;
728
- min-height: 74px;
729
- box-sizing: border-box;
730
- border: 2px solid #e6e7eb;
731
- border-radius: 13px;
732
- background: #fff;
733
- color: #344376;
734
- padding: 9px 8px;
735
- display: flex;
736
- flex-direction: column;
737
- align-items: center;
738
- justify-content: center;
739
- gap: 6px;
740
- cursor: pointer;
741
- }
742
-
743
- .shared-checkout-v2-method.is-selected {
744
- border: 3px solid #050505;
745
- }
746
-
747
- .shared-checkout-v2-tab-wallet {
748
- width: 58px;
749
- height: 36px;
750
- }
751
-
752
- .shared-checkout-v2-tab-wallet svg {
753
- display: block;
754
- width: 100%;
755
- height: 100%;
756
- }
757
-
758
- .shared-checkout-v2-tab-wallets {
759
- display: flex;
760
- align-items: center;
761
- justify-content: center;
762
- gap: 8px;
763
- }
764
-
765
- .shared-checkout-v2-method strong {
766
- color: #344376;
767
- font-size: 20px;
768
- font-weight: 900;
769
- line-height: 1;
770
- letter-spacing: 0;
771
- }
772
-
773
- .shared-checkout-v2-tab-brands {
774
- display: flex;
775
- align-items: center;
776
- justify-content: center;
777
- max-width: 100%;
778
- gap: 4px;
779
- }
780
-
781
- .shared-checkout-v2-tab-brand {
782
- min-width: 0;
783
- width: 24px;
784
- height: 15px;
785
- }
786
-
787
- .shared-checkout-v2-tab-brand svg {
788
- display: block;
789
- width: 100%;
790
- height: 100%;
791
- }
792
-
793
- .shared-checkout-v2-wallet-panel,
794
- .shared-checkout-v2-card-panel {
795
- display: flex;
796
- flex-direction: column;
797
- height: 0;
798
- overflow: hidden;
799
- opacity: 0;
800
- pointer-events: none;
801
- }
802
-
803
- .shared-checkout-v2-wallet-panel[hidden],
804
- .shared-checkout-v2-card-panel[hidden] {
805
- display: none;
806
- }
807
-
808
- .shared-checkout-v2-wallet-panel {
809
- align-items: center;
810
- gap: 22px;
811
- padding-top: 5px;
812
- }
813
-
814
- .shared-checkout-v2-secure-pill {
815
- width: fit-content;
816
- min-height: 47px;
817
- box-sizing: border-box;
818
- display: inline-flex;
819
- align-items: center;
820
- justify-content: center;
821
- gap: 12px;
822
- margin: 0 auto;
823
- border-radius: 12px;
824
- background: #dcffd0;
825
- padding: 0 22px;
826
- color: #207733;
827
- font-size: 18px;
828
- font-weight: 600;
829
- line-height: 1.1;
830
- letter-spacing: 0;
831
- }
832
-
833
- .shared-checkout-v2-secure-pill-icon {
834
- width: 24px;
835
- height: 24px;
836
- flex: none;
837
- color: #147232;
838
- }
839
-
840
- .shared-checkout-v2-wallet-shell {
841
- width: 100%;
842
- min-height: 124px;
843
- display: flex;
844
- flex-direction: column;
845
- justify-content: center;
846
- }
847
-
848
- .shared-checkout-v2-express-buttons {
849
- width: 100%;
850
- }
851
-
852
- .shared-checkout-v2-card-panel {
853
- position: relative;
854
- gap: 10px;
855
- margin-inline: -17px;
856
- background: #f2f2f3;
857
- padding: 16px 32px 92px;
858
- }
859
-
860
- .shared-checkout-v2-wallet-panel.is-visible,
861
- .shared-checkout-v2-card-panel.is-visible {
862
- height: auto;
863
- overflow: visible;
864
- opacity: 1;
865
- pointer-events: auto;
866
- }
867
-
868
- .shared-checkout-v2-wallet-panel:not(.is-visible),
869
- .shared-checkout-v2-card-panel:not(.is-visible) {
870
- padding-top: 0;
871
- padding-bottom: 0;
872
- }
873
-
874
- .shared-checkout-v2-email-field {
875
- box-sizing: border-box;
876
- display: flex;
877
- flex-direction: column;
878
- gap: 7px;
879
- border: 0;
880
- border-radius: 0;
881
- background: transparent;
882
- margin-bottom: 14px;
883
- padding: 0;
884
- color: #303136;
885
- font-size: 14px;
886
- font-weight: 400;
887
- line-height: 1.2;
888
- }
889
-
890
- .shared-checkout-v2-email-field.is-disabled {
891
- cursor: default;
892
- }
893
-
894
- .shared-checkout-v2-email-label {
895
- padding: 0 14px;
896
- color: #303136;
897
- font-size: 14px;
898
- font-weight: 400;
899
- line-height: 1.2;
900
- }
901
-
902
- .shared-checkout-v2-email-control {
903
- min-height: 50px;
904
- box-sizing: border-box;
905
- display: flex;
906
- align-items: center;
907
- border: 1px solid #dedede;
908
- background: #fff;
909
- box-shadow: 0 1px 2px rgb(16 24 40 / 8%);
910
- padding: 0 14px;
911
- }
912
-
913
- .shared-checkout-v2-email-input {
914
- width: 100%;
915
- min-height: 48px;
916
- box-sizing: border-box;
917
- border: 0;
918
- background: transparent;
919
- padding: 0;
920
- color: #303136;
921
- font: inherit;
922
- font-size: 18px;
923
- font-weight: 400;
924
- line-height: 1.2;
925
- outline: none;
926
- }
927
-
928
- .shared-checkout-v2-email-input:disabled {
929
- color: #74767c;
930
- opacity: 1;
931
- -webkit-text-fill-color: #74767c;
932
- }
933
-
934
- .shared-checkout-v2-email-input::placeholder {
935
- color: #8c909a;
936
- }
937
-
938
- .shared-checkout-v2-card-box {
939
- overflow: visible;
940
- border: 0;
941
- border-radius: 6px;
942
- background: transparent;
943
- box-shadow: none;
944
- }
945
-
946
- .shared-checkout-v2-country-field {
947
- box-sizing: border-box;
948
- display: flex;
949
- flex-direction: column;
950
- gap: 7px;
951
- margin: 14px 0 0;
952
- color: #303136;
953
- font-size: 14px;
954
- font-weight: 400;
955
- line-height: 1.2;
956
- }
957
-
958
- .shared-checkout-v2-country-label {
959
- padding: 0 14px;
960
- }
961
-
962
- .shared-checkout-v2-country-control {
963
- position: relative;
964
- display: block;
965
- }
966
-
967
- .shared-checkout-v2-country-control::after {
968
- position: absolute;
969
- right: 17px;
970
- top: 50%;
971
- width: 8px;
972
- height: 8px;
973
- border-right: 2px solid #6f7380;
974
- border-bottom: 2px solid #6f7380;
975
- content: '';
976
- pointer-events: none;
977
- transform: translateY(-65%) rotate(45deg);
978
- }
979
-
980
- .shared-checkout-v2-country-select {
981
- width: 100%;
982
- min-height: 50px;
983
- box-sizing: border-box;
984
- appearance: none;
985
- border: 1px solid #dedede;
986
- border-radius: 0;
987
- background: #fff;
988
- box-shadow: 0 1px 2px rgb(16 24 40 / 8%);
989
- color: #303136;
990
- font: inherit;
991
- font-size: 18px;
992
- font-weight: 400;
993
- line-height: 1.2;
994
- outline: none;
995
- padding: 0 44px 0 14px;
996
- }
997
-
998
- .shared-checkout-v2-error {
999
- margin: 0;
1000
- color: #c43737;
1001
- font-size: 13px;
1002
- font-weight: 600;
1003
- line-height: 1.35;
1004
- }
1005
-
1006
- .shared-checkout-v2-card-submit {
1007
- min-height: 60px;
1008
- border: 0;
1009
- border-radius: 11px;
1010
- background: var(--shared-checkout-v2-button-color);
1011
- color: #fff;
1012
- display: inline-flex;
1013
- align-items: center;
1014
- justify-content: center;
1015
- gap: 14px;
1016
- font-size: 22px;
1017
- font-weight: 900;
1018
- line-height: 1;
1019
- letter-spacing: 0;
1020
- cursor: pointer;
1021
- }
1022
-
1023
- .shared-checkout-v2-card-submit:disabled {
1024
- cursor: wait;
1025
- opacity: 0.72;
1026
- }
1027
-
1028
- .shared-checkout-v2-card-submit-icon {
1029
- width: 26px;
1030
- height: 26px;
1031
- }
1032
-
1033
- .shared-checkout-v2-card-brands {
1034
- min-height: 34px;
1035
- display: flex;
1036
- align-items: center;
1037
- justify-content: center;
1038
- gap: 12px;
1039
- opacity: 0.95;
1040
- }
1041
-
1042
- .shared-checkout-v2-card-brand {
1043
- width: 42px;
1044
- height: 25px;
1045
- }
1046
-
1047
- .shared-checkout-v2-secure-pill--card {
1048
- position: absolute;
1049
- left: 50%;
1050
- bottom: 16px;
1051
- transform: translateX(-50%);
1052
- white-space: nowrap;
1053
- }
1054
-
1055
- .shared-checkout-v2-sr-only {
1056
- position: absolute;
1057
- width: 1px;
1058
- height: 1px;
1059
- padding: 0;
1060
- margin: -1px;
1061
- overflow: hidden;
1062
- clip: rect(0, 0, 0, 0);
1063
- white-space: nowrap;
1064
- border: 0;
1065
- }
1066
-
1067
- .shared-checkout-special-offer-overlay {
1068
- position: fixed;
1069
- inset: 0;
1070
- z-index: 120;
1071
- display: flex;
1072
- align-items: center;
1073
- justify-content: center;
1074
- box-sizing: border-box;
1075
- padding: 22px;
1076
- background: rgb(0 0 0 / 48%);
1077
- }
1078
-
1079
- .shared-checkout-special-offer-dialog {
1080
- width: min(100%, 386px);
1081
- box-sizing: border-box;
1082
- border-radius: 14px;
1083
- background: #fff;
1084
- padding: 55px 26px 28px;
1085
- color: #303136;
1086
- text-align: center;
1087
- font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
1088
- }
1089
-
1090
- .shared-checkout-special-offer-gift {
1091
- display: block;
1092
- width: min(100%, 260px);
1093
- height: auto;
1094
- margin: 0 auto 22px;
1095
- }
1096
-
1097
- .shared-checkout-special-offer-gift--image {
1098
- position: relative;
1099
- width: min(100%, 250px);
1100
- aspect-ratio: 1;
1101
- }
1102
-
1103
- .shared-checkout-special-offer-gift-image {
1104
- display: block;
1105
- width: 100%;
1106
- height: 100%;
1107
- background-position: center;
1108
- background-repeat: no-repeat;
1109
- background-size: contain;
1110
- user-select: none;
1111
- }
1112
-
1113
- .shared-checkout-special-offer-image-discount {
1114
- position: absolute;
1115
- top: 69%;
1116
- left: 50%;
1117
- transform: translate(-50%, -50%);
1118
- color: #1f8f4d;
1119
- font-family: Inter, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
1120
- font-size: 34px;
1121
- font-weight: 900;
1122
- line-height: 1;
1123
- letter-spacing: 0;
1124
- pointer-events: none;
1125
- white-space: nowrap;
1126
- }
1127
-
1128
- .shared-checkout-special-offer-dialog h2 {
1129
- margin: 0;
1130
- color: #303136;
1131
- font-size: 36px;
1132
- font-weight: 900;
1133
- line-height: 1.1;
1134
- letter-spacing: 0;
1135
- }
1136
-
1137
- .shared-checkout-special-offer-dialog p {
1138
- margin: 26px 0 32px;
1139
- color: #77787e;
1140
- font-size: 24px;
1141
- font-weight: 500;
1142
- line-height: 1.18;
1143
- letter-spacing: 0;
1144
- }
1145
-
1146
- .shared-checkout-special-offer-button {
1147
- width: 100%;
1148
- min-height: 76px;
1149
- border: 0;
1150
- border-radius: 12px;
1151
- background: var(--shared-checkout-v2-button-color);
1152
- color: #fff;
1153
- font-size: 23px;
1154
- font-weight: 900;
1155
- line-height: 1;
1156
- letter-spacing: 0;
1157
- cursor: pointer;
1158
- }
1159
-
1160
- @media (max-width: 429px) {
1161
- .shared-checkout-v2-header {
1162
- min-height: 64px;
1163
- }
1164
-
1165
- .shared-checkout-v2-header h2 {
1166
- font-size: 24px;
1167
- }
1168
-
1169
- .shared-checkout-v2-summary {
1170
- padding-inline: 17px;
1171
- }
1172
-
1173
- .shared-checkout-v2-satisfaction {
1174
- font-size: 19px;
1175
- }
1176
-
1177
- .shared-checkout-v2-methods {
1178
- gap: 42px;
1179
- }
1180
-
1181
- .shared-checkout-v2-method strong {
1182
- font-size: 19px;
1183
- }
1184
-
1185
- .shared-checkout-v2-card-panel {
1186
- padding-inline: 32px;
1187
- }
1188
- }
1189
- `;