@edx/frontend-app-alacarte-checkout 1.58.0 → 1.60.0
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/checkoutPage/CheckoutPage.js +4 -4
- package/dist/checkoutPage/CheckoutPage.js.map +1 -1
- package/dist/components/AutoDismissAlert/AutoDismissAlert.d.ts +11 -1
- package/dist/components/AutoDismissAlert/AutoDismissAlert.js +22 -3
- package/dist/components/AutoDismissAlert/AutoDismissAlert.js.map +1 -1
- package/dist/components/CartSummary/CartSummary.js +1 -1
- package/dist/components/CartSummary/CartSummary.js.map +1 -1
- package/dist/components/CartSummary/student-icon.svg +1 -1
- package/dist/components/CartSummary/world-icon.svg +1 -1
- package/dist/components/Checkout/Checkout.js +13 -2
- package/dist/components/Checkout/Checkout.js.map +1 -1
- package/dist/components/ExpressCheckout/ExpressCheckout.js +1 -1
- package/dist/components/ExpressCheckout/ExpressCheckout.js.map +1 -1
- package/dist/components/PromoCode/PromoCode.js +1 -1
- package/dist/components/PromoCode/PromoCode.js.map +1 -1
- package/dist/constants.d.ts +3 -3
- package/dist/constants.js +5 -3
- package/dist/constants.js.map +1 -1
- package/dist/styles/components/expressCheckout.scss +21 -0
- package/dist/styles/components/paymentFields.scss +6 -4
- package/package.json +1 -1
|
@@ -16,13 +16,13 @@ const CheckoutPage = () => {
|
|
|
16
16
|
const disableComplianceCheck = config.DISABLE_COMPLIANCE_CHECK === true;
|
|
17
17
|
const restrictCompliance = config.RESTRICT_COMPLIANCE === true;
|
|
18
18
|
const skipSubscriptionCourseRuns = config.SKIP_SUBSCRIPTION_COURSE_RUNS === true;
|
|
19
|
-
const edxSessionUrl = `${isDevelopment ?
|
|
20
|
-
const geolocationUrl = `${isDevelopment ?
|
|
19
|
+
const edxSessionUrl = `${isDevelopment ? config.COURSES_BASE_URL : LMS_BASE_URL}/api/edx-session`;
|
|
20
|
+
const geolocationUrl = `${isDevelopment ? config.COURSES_BASE_URL : LMS_BASE_URL}/api/geolocation/lookup`;
|
|
21
21
|
const complianceCheckUrl = disableComplianceCheck
|
|
22
22
|
? undefined
|
|
23
|
-
: `${isDevelopment ?
|
|
23
|
+
: `${isDevelopment ? config.COURSES_BASE_URL : LMS_BASE_URL}/api/compliance-check`;
|
|
24
24
|
if (!stripePublishableKey || !apiUrl || !edxSessionUrl) {
|
|
25
|
-
return (_jsx(PageWrapper, { children: _jsxs(Alert, { variant: "danger", children: ["We're having trouble loading the checkout. Please refresh the page or try again in a few moments. If the problem persists,", ' ', _jsx("a", { href:
|
|
25
|
+
return (_jsx(PageWrapper, { children: _jsxs(Alert, { variant: "danger", children: ["We're having trouble loading the checkout. Please refresh the page or try again in a few moments. If the problem persists,", ' ', _jsx("a", { href: `${getAppConfig(appId).CONTACT_US_URL}`, children: "contact support" }), "."] }) }));
|
|
26
26
|
}
|
|
27
27
|
return (_jsx(PageWrapper, { children: _jsx(CheckoutGate, { stripePublishableKey: stripePublishableKey, paypalClientId: paypalClientId, apiUrl: apiUrl, edxSessionUrl: edxSessionUrl, geolocationUrl: geolocationUrl, complianceCheckUrl: complianceCheckUrl, disableComplianceCheck: disableComplianceCheck, restrictCompliance: restrictCompliance, skipSubscriptionCourseRuns: skipSubscriptionCourseRuns, learnerDashboardUrl: `${LMS_BASE_URL}/dashboard`, homeUrl: LMS_BASE_URL || '/', onComplete: (_subscriptionBiId) => {
|
|
28
28
|
console.log(_subscriptionBiId);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"CheckoutPage.js","sourceRoot":"","sources":["../../src/checkoutPage/CheckoutPage.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACpD,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,MAAM,wBAAwB,CAAC;AACrE,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,YAAY,MAAM,yCAAyC,CAAC;AAEnE,MAAM,W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EAChE,YAAG,IAAI,EAAE,GAAG,YAAY,CAAC,KAAK,CAAC,CAAC,cAAwB,EAAE,gCAEtD,SAEE,GACI,CACf,CAAC;IACJ,CAAC;IAED,OAAO,CACL,KAAC,WAAW,cACV,KAAC,YAAY,IACX,oBAAoB,EAAE,oBAAoB,EAC1C,cAAc,EAAE,cAAc,EAC9B,MAAM,EAAE,MAAM,EACd,aAAa,EAAE,aAAa,EAC5B,cAAc,EAAE,cAAc,EAC9B,kBAAkB,EAAE,kBAAkB,EACtC,sBAAsB,EAAE,sBAAsB,EAC9C,kBAAkB,EAAE,kBAAkB,EACtC,0BAA0B,EAAE,0BAA0B,EACtD,mBAAmB,EAAE,GAAG,YAAY,YAAY,EAChD,OAAO,EAAE,YAAY,IAAI,GAAG,EAC5B,UAAU,EAAE,CAAC,iBAAiB,EAAE,EAAE;gBAChC,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,CAAC;gBAC/B,kFAAkF;gBAClF,kBAAkB;YACpB,CAAC,GACD,GACU,CACf,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,YAAY,CAAC","sourcesContent":["import React from 'react';\nimport { Alert, Container } from '@openedx/paragon';\nimport { getAppConfig, getSiteConfig } from '@openedx/frontend-base';\nimport { appId } from '@src/constants';\nimport CheckoutGate from '../components/CheckoutGate/CheckoutGate';\n\nconst PageWrapper: React.FC<{ children: React.ReactNode }> = ({ children }) => (\n <Container>{children}</Container>\n);\n\nconst CheckoutPage: React.FC = () => {\n const config = getAppConfig(appId);\n const siteConfig = getSiteConfig();\n const LMS_BASE_URL = siteConfig.lmsBaseUrl.replace(/\\/$/, '');\n const stripePublishableKey = config.STRIPE_PUBLIC_KEY as string;\n // Optional — the PayPal express button stays disabled without it.\n const paypalClientId = (config.PAYPAL_CLIENT_ID as string | undefined) || undefined;\n const apiUrl = config.VIAX_API_URL as string;\n const isDevelopment = siteConfig.environment === 'development';\n const disableComplianceCheck = config.DISABLE_COMPLIANCE_CHECK === true;\n const restrictCompliance = config.RESTRICT_COMPLIANCE === true;\n const skipSubscriptionCourseRuns = config.SKIP_SUBSCRIPTION_COURSE_RUNS === true;\n const edxSessionUrl = `${isDevelopment ? config.COURSES_BASE_URL : LMS_BASE_URL}/api/edx-session`;\n const geolocationUrl = `${isDevelopment ? config.COURSES_BASE_URL : LMS_BASE_URL}/api/geolocation/lookup`;\n const complianceCheckUrl = disableComplianceCheck\n ? undefined\n : `${isDevelopment ? config.COURSES_BASE_URL : LMS_BASE_URL}/api/compliance-check`;\n\n if (!stripePublishableKey || !apiUrl || !edxSessionUrl) {\n return (\n <PageWrapper>\n <Alert variant=\"danger\">\n We're having trouble loading the checkout. Please refresh the\n page or try again in a few moments. If the problem persists,{' '}\n <a href={`${getAppConfig(appId).CONTACT_US_URL as string}`}>\n contact support\n </a>\n .\n </Alert>\n </PageWrapper>\n );\n }\n\n return (\n <PageWrapper>\n <CheckoutGate\n stripePublishableKey={stripePublishableKey}\n paypalClientId={paypalClientId}\n apiUrl={apiUrl}\n edxSessionUrl={edxSessionUrl}\n geolocationUrl={geolocationUrl}\n complianceCheckUrl={complianceCheckUrl}\n disableComplianceCheck={disableComplianceCheck}\n restrictCompliance={restrictCompliance}\n skipSubscriptionCourseRuns={skipSubscriptionCourseRuns}\n learnerDashboardUrl={`${LMS_BASE_URL}/dashboard`}\n homeUrl={LMS_BASE_URL || '/'}\n onComplete={(_subscriptionBiId) => {\n console.log(_subscriptionBiId);\n // window.location.href = `/checkout/confirmation?sub=${_subscriptionBiId ?? ''}`;\n // Success screen.\n }}\n />\n </PageWrapper>\n );\n};\n\nexport default CheckoutPage;\n"]}
|
|
@@ -7,6 +7,16 @@ export interface AutoDismissAlertProps extends Omit<AlertProps, 'show' | 'transi
|
|
|
7
7
|
onClose: () => void;
|
|
8
8
|
/** Milliseconds the alert stays on screen before dismissing itself. */
|
|
9
9
|
delay?: number;
|
|
10
|
+
/**
|
|
11
|
+
* Move focus to the alert when it mounts, so screen readers read it rather
|
|
12
|
+
* than whatever control the learner's action left focused.
|
|
13
|
+
*/
|
|
14
|
+
focusOnMount?: boolean;
|
|
15
|
+
/**
|
|
16
|
+
* Called after the alert closes while it held focus, so focus can go back
|
|
17
|
+
* to a sensible control instead of dropping to <body>.
|
|
18
|
+
*/
|
|
19
|
+
returnFocus?: () => void;
|
|
10
20
|
}
|
|
11
|
-
declare const AutoDismissAlert: ({ onClose, delay, ...props }: AutoDismissAlertProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
declare const AutoDismissAlert: ({ onClose, delay, focusOnMount, returnFocus, ...props }: AutoDismissAlertProps) => import("react/jsx-runtime").JSX.Element;
|
|
12
22
|
export default AutoDismissAlert;
|
|
@@ -10,24 +10,43 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
10
10
|
return t;
|
|
11
11
|
};
|
|
12
12
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { useEffect, useState } from 'react';
|
|
13
|
+
import { useEffect, useRef, useState } from 'react';
|
|
14
14
|
import { Alert } from '@openedx/paragon';
|
|
15
15
|
export const AUTO_DISMISS_DELAY_MS = 5000;
|
|
16
16
|
// Paragon's Alert has no autohide (only Toast does, and Toast renders in a
|
|
17
17
|
// fixed corner portal). Same rule as Toast: the timer pauses while the learner
|
|
18
18
|
// hovers or focuses the alert, so it never vanishes mid-read.
|
|
19
19
|
const AutoDismissAlert = (_a) => {
|
|
20
|
-
var { onClose, delay = AUTO_DISMISS_DELAY_MS } = _a, props = __rest(_a, ["onClose", "delay"]);
|
|
20
|
+
var { onClose, delay = AUTO_DISMISS_DELAY_MS, focusOnMount = false, returnFocus } = _a, props = __rest(_a, ["onClose", "delay", "focusOnMount", "returnFocus"]);
|
|
21
21
|
const [show, setShow] = useState(true);
|
|
22
22
|
const [hovered, setHovered] = useState(false);
|
|
23
23
|
const [focused, setFocused] = useState(false);
|
|
24
|
+
const alertRef = useRef(null);
|
|
25
|
+
const hadFocusOnCloseRef = useRef(false);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
var _a;
|
|
28
|
+
if (focusOnMount)
|
|
29
|
+
(_a = alertRef.current) === null || _a === void 0 ? void 0 : _a.focus();
|
|
30
|
+
// Mount only: a later prop change must not pull focus back.
|
|
31
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
32
|
+
}, []);
|
|
24
33
|
useEffect(() => {
|
|
25
34
|
if (!show || hovered || focused)
|
|
26
35
|
return undefined;
|
|
27
36
|
const timer = window.setTimeout(() => setShow(false), delay);
|
|
28
37
|
return () => window.clearTimeout(timer);
|
|
29
38
|
}, [show, hovered, focused, delay]);
|
|
30
|
-
return (_jsx(Alert, Object.assign({}, props, {
|
|
39
|
+
return (_jsx(Alert, Object.assign({}, props, { ref: alertRef,
|
|
40
|
+
// Focus target only, never a tab stop.
|
|
41
|
+
tabIndex: focusOnMount ? -1 : undefined, show: show, transition: true, onClose: () => {
|
|
42
|
+
var _a;
|
|
43
|
+
hadFocusOnCloseRef.current = !!((_a = alertRef.current) === null || _a === void 0 ? void 0 : _a.contains(document.activeElement));
|
|
44
|
+
setShow(false);
|
|
45
|
+
}, onExited: () => {
|
|
46
|
+
onClose();
|
|
47
|
+
if (hadFocusOnCloseRef.current)
|
|
48
|
+
returnFocus === null || returnFocus === void 0 ? void 0 : returnFocus();
|
|
49
|
+
}, onMouseEnter: () => setHovered(true), onMouseLeave: () => setHovered(false), onFocus: () => setFocused(true), onBlur: (event) => {
|
|
31
50
|
if (!event.currentTarget.contains(event.relatedTarget))
|
|
32
51
|
setFocused(false);
|
|
33
52
|
} })));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AutoDismissAlert.js","sourceRoot":"","sources":["../../../src/components/AutoDismissAlert/AutoDismissAlert.tsx"],"names":[],"mappings":";;;;;;;;;;;;AAAA,OAAc,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"AutoDismissAlert.js","sourceRoot":"","sources":["../../../src/components/Auto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YAAY,CAAC,KAAK,CAAC,CAAC;IAC1C,CAAC,EAAE,CAAC,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,CAAC,CAAC,CAAC;IAEpC,OAAO,CACL,KAAC,KAAK,oBACA,KAAK,IACT,GAAG,EAAE,QAAQ;QACb,uCAAuC;QACvC,QAAQ,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,EACvC,IAAI,EAAE,IAAI,EACV,UAAU,QACV,OAAO,EAAE,GAAG,EAAE;;YACZ,kBAAkB,CAAC,OAAO,GAAG,CAAC,CAAC,CAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,CAAA,CAAC;YAClF,OAAO,CAAC,KAAK,CAAC,CAAC;QACjB,CAAC,EAIC,QAAQ,EAAE,GAAG,EAAE;YACb,OAAO,EAAE,CAAC;YACV,IAAI,kBAAkB,CAAC,OAAO;gBAAE,WAAW,aAAX,WAAW,uBAAX,WAAW,EAAI,CAAC;QAClD,CAAC,EAEH,YAAY,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EACpC,YAAY,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EACrC,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAC/B,MAAM,EAAE,CAAC,KAAoC,EAAE,EAAE;YAC/C,IAAI,CAAC,KAAK,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,aAA4B,CAAC;gBAAE,UAAU,CAAC,KAAK,CAAC,CAAC;QAC3F,CAAC,IACD,CACH,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,gBAAgB,CAAC","sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { Alert } from '@openedx/paragon';\n\nexport const AUTO_DISMISS_DELAY_MS = 5000;\n\ntype AlertProps = React.ComponentProps<typeof Alert>;\n\nexport interface AutoDismissAlertProps extends Omit<AlertProps, 'show' | 'transition' | 'onClose'> {\n /** Called once the alert has faded out, whether the learner or the timer dismissed it. */\n onClose: () => void,\n /** Milliseconds the alert stays on screen before dismissing itself. */\n delay?: number,\n /**\n * Move focus to the alert when it mounts, so screen readers read it rather\n * than whatever control the learner's action left focused.\n */\n focusOnMount?: boolean,\n /**\n * Called after the alert closes while it held focus, so focus can go back\n * to a sensible control instead of dropping to <body>.\n */\n returnFocus?: () => void,\n}\n\n// Paragon's Alert has no autohide (only Toast does, and Toast renders in a\n// fixed corner portal). Same rule as Toast: the timer pauses while the learner\n// hovers or focuses the alert, so it never vanishes mid-read.\nconst AutoDismissAlert = ({\n onClose,\n delay = AUTO_DISMISS_DELAY_MS,\n focusOnMount = false,\n returnFocus,\n ...props\n}: AutoDismissAlertProps) => {\n const [show, setShow] = useState(true);\n const [hovered, setHovered] = useState(false);\n const [focused, setFocused] = useState(false);\n const alertRef = useRef<HTMLDivElement>(null);\n const hadFocusOnCloseRef = useRef(false);\n\n useEffect(() => {\n if (focusOnMount) alertRef.current?.focus();\n // Mount only: a later prop change must not pull focus back.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, []);\n\n useEffect(() => {\n if (!show || hovered || focused) return undefined;\n const timer = window.setTimeout(() => setShow(false), delay);\n return () => window.clearTimeout(timer);\n }, [show, hovered, focused, delay]);\n\n return (\n <Alert\n {...props}\n ref={alertRef}\n // Focus target only, never a tab stop.\n tabIndex={focusOnMount ? -1 : undefined}\n show={show}\n transition\n onClose={() => {\n hadFocusOnCloseRef.current = !!alertRef.current?.contains(document.activeElement);\n setShow(false);\n }}\n // onExited isn't in Paragon's AlertProps, but it reaches the Fade\n // transition, which calls it once the alert has unmounted.\n {...{\n onExited: () => {\n onClose();\n if (hadFocusOnCloseRef.current) returnFocus?.();\n },\n }}\n onMouseEnter={() => setHovered(true)}\n onMouseLeave={() => setHovered(false)}\n onFocus={() => setFocused(true)}\n onBlur={(event: React.FocusEvent<HTMLElement>) => {\n if (!event.currentTarget.contains(event.relatedTarget as Node | null)) setFocused(false);\n }}\n />\n );\n};\n\nexport default AutoDismissAlert;\n"]}
|
|
@@ -53,7 +53,7 @@ const CartSummary = ({ productTitle, productBlurb, learnerCount: learnerCountPro
|
|
|
53
53
|
}))] })] }), _jsx(Card.Divider, {}), _jsxs(Card.Section, { className: "p-0 py-3", children: [course ? (_jsx(CourseEnrollmentCard, { course: course, variant: "summary" })) : programDetail ? (_jsx(ProgramEnrollmentCard, { program: programDetail, programName: lineName !== null && lineName !== void 0 ? lineName : '', ownedCourses: ownedCourses })) : lineName ? (_jsx("p", { className: "font-weight-bold mb-0 text-primary-500", children: lineName })) : (_jsxs("div", { className: "d-flex align-items-start", children: [_jsx(EdxUnlimitedLogo, { ariaLabel: "edX Plus" }), _jsxs("div", { children: [_jsx("p", { className: "font-weight-bold mb-0 text-primary-500", children: title }), _jsx("p", { className: "small mb-0 text-gray-900", children: blurb })] })] })), !programDetail && ownedCourseNames && (_jsx("p", { className: "cart-summary__already-yours small text-gray-700 mb-0 mt-2", "data-testid": "already-yours", children: formatMessage(messages.alreadyYours, { names: ownedCourseNames }) }))] }), _jsx(Card.Divider, {}), _jsxs(Card.Section, { className: "cart-summary__subtotal-row d-flex justify-content-between align-items-center p-0 pt-3", children: [_jsx("span", { className: "cart-summary__subtotal text-gray-900", children: formatMessage(messages.subtotal) }), _jsx("span", { className: "cart-summary__subtotal text-gray-900", children: subtotalText })] }), discount && (_jsxs(Card.Section, { className: "d-flex justify-content-between align-items-center p-0", "data-testid": "discount-row", children: [_jsx("span", { className: "text-success font-weight-bold", children: formatMessage(messages.discountApplied) }), _jsx("span", { className: "text-success font-weight-bold", children: formatMessage(messages.discountAmount, {
|
|
54
54
|
amount: discount.amount.toFixed(2),
|
|
55
55
|
currency: discount.currency,
|
|
56
|
-
}) })] })), _jsx(Card.Section, { className: "p-0", children: _jsxs("div", { className: "d-flex justify-content-between align-items-center", "aria-live": "polite", "aria-atomic": "true", "data-testid": "todays-total", children: [_jsx("span", { className: "cart-summary__total-label text-gray-900", children: formatMessage(messages.todaysTotal) }), _jsx("span", { className: "cart-summary__total-value mb-0 text-gray-900", children: totalText })] }) })] }), promoCode ? _jsx(PromoCode, Object.assign({}, promoCode)) : null, _jsxs("div", { className: "cart-summary__stats d-none d-lg-flex", children: [_jsxs("div", { className: "cart-summary__stat d-flex align-items-center mr-4", children: [_jsx("img", { src: learnersIcon, alt: "", width: 50, height: 50, className: "mr-2" }), _jsxs("div", { children: [_jsx("p", { className: "cart-summary__stat-count font-weight-bold text-gray-
|
|
56
|
+
}) })] })), _jsx(Card.Section, { className: "p-0", children: _jsxs("div", { className: "d-flex justify-content-between align-items-center", "aria-live": "polite", "aria-atomic": "true", "data-testid": "todays-total", children: [_jsx("span", { className: "cart-summary__total-label text-gray-900", children: formatMessage(messages.todaysTotal) }), _jsx("span", { className: "cart-summary__total-value mb-0 text-gray-900", children: totalText })] }) })] }), promoCode ? _jsx(PromoCode, Object.assign({}, promoCode)) : null, _jsxs("div", { className: "cart-summary__stats d-none d-lg-flex", children: [_jsxs("div", { className: "cart-summary__stat d-flex align-items-center mr-4", children: [_jsx("img", { src: learnersIcon, alt: "", width: 50, height: 50, className: "mr-2" }), _jsxs("div", { children: [_jsx("p", { className: "cart-summary__stat-count font-weight-bold text-gray-600 mb-0", children: formatMessage(messages.learnersCount) }), _jsx("p", { className: "cart-summary__stat-label text-gray-600 mb-0", children: formatMessage(messages.learnersLabel) })] })] }), _jsxs("div", { className: "cart-summary__stat d-flex align-items-center", children: [_jsx("img", { src: institutionsIcon, alt: "", width: 50, height: 50, className: "mr-2" }), _jsxs("div", { children: [_jsx("p", { className: "cart-summary__stat-count font-weight-bold text-gray-600 mb-0", children: formatMessage(messages.institutionsCount) }), _jsx("p", { className: "cart-summary__stat-label text-gray-600 mb-0", children: formatMessage(messages.institutionsLabel) })] })] })] })] }));
|
|
57
57
|
};
|
|
58
58
|
export default CartSummary;
|
|
59
59
|
//# sourceMappingURL=C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,IACA,IACF,EACN,eAAK,SAAS,EAAC,8CAA8C,aAC3D,cAAK,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAC,EAAE,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAC,MAAM,GAAG,EAC7E,0BACE,YAAG,SAAS,EAAC,8DAA8D,YACxE,aAAa,CAAC,QAAQ,CAAC,iBAAiB,CAAC,GACxC,EACJ,YAAG,SAAS,EAAC,6CAA6C,YACvD,aAAa,CAAC,QAAQ,CAAC,iBAAiB,CAAC,GACxC,IACA,IACF,IACF,IACA,CACT,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import React from 'react';\nimport { Badge, Card, Icon, Skeleton } from '@openedx/paragon';\nimport { Group } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport { EdxUnlimitedLogo } from '../BrandMarks/BrandMarks';\nimport CourseEnrollmentCard from '../CourseEnrollmentCard/CourseEnrollmentCard';\nimport ProgramEnrollmentCard from '../ProgramEnrollmentCard/ProgramEnrollmentCard';\nimport PromoCode from '../PromoCode/PromoCode';\nimport type { PromoCodeProps } from '../PromoCode/PromoCode';\nimport type { CourseDetail } from '../../types';\nimport type { AlacarteLine, ProgramDetail } from '../../types/alacarte';\nimport messages from './Messages';\nimport learnersIcon from './world-icon.svg';\nimport institutionsIcon from './student-icon.svg';\n\nexport type BillingCycle = 'monthly' | 'annual';\n\nexport interface CartSummaryProps {\n productTitle?: string,\n productBlurb?: string,\n /** Promotional monthly price amount e.g. \"39\" */\n monthlyAmount?: string,\n /** Regular monthly price after the promo period e.g. \"59\" */\n monthlyRegularAmount?: string,\n /** Length of the promotional period in months */\n promoMonths?: number,\n /** Annual price amount e.g. \"299\" */\n annualAmount?: string,\n currency?: string,\n defaultCycle?: BillingCycle,\n monthlyRenewalLabel?: string,\n annualRenewalLabel?: string,\n /** Called when the learner switches monthly ↔ annual. */\n onCycleChange?: (cycle: BillingCycle) => void,\n learnerCount?: number,\n /** When set, shows the course enrollment preview card below the summary card. */\n course?: CourseDetail | null,\n /** À la carte checkout line — when present, drives the subtotal/total and\n * the product name shown, in place of the generic edX Plus placeholder. */\n alacarteLine?: AlacarteLine | null,\n /** Program catalog detail (filterTwouProgram) — when present, drives the\n * \"Courses included in this program\" list. */\n programDetail?: ProgramDetail | null,\n /** Fallback program name — used when there is no alacarteLine to provide it\n * (e.g. already-owned overlay). */\n programName?: string | null,\n /** Coupon input — when set, wires PromoCode to tCheckoutUpdate. */\n promoCode?: PromoCodeProps | null,\n}\n\nconst CartSummary = ({\n productTitle,\n productBlurb,\n learnerCount: learnerCountProp,\n course = null,\n alacarteLine = null,\n programDetail = null,\n programName: programNameProp = null,\n promoCode = null,\n}: CartSummaryProps) => {\n const { formatMessage } = useIntl();\n const title = productTitle ?? formatMessage(messages.productTitle);\n const blurb = productBlurb ?? formatMessage(messages.productBlurb);\n\n // Prefer the product's own enrollment count (course or program catalog field).\n const isProgramLine = alacarteLine?.kind === 'program';\n const subscriberCount = course?.tEnrollmentCount\n ?? programDetail?.tEnrollmentCount\n ?? learnerCountProp\n ?? null;\n\n // No fallback amount — an unresolved à la carte line means we don't know\n // the price yet, so the row is left blank rather than showing a made-up\n // number that could be mistaken for the real one.\n // Program subtotal is price less owned-course deduction (before coupon/discount).\n const deductionAmount = isProgramLine && alacarteLine.kind === 'program'\n ? (alacarteLine.deduction?.amount ?? 0)\n : 0;\n const subtotalAmount = alacarteLine?.price\n ? Math.max(0, alacarteLine.price.amount - deductionAmount)\n : null;\n const subtotalText = subtotalAmount != null && alacarteLine?.price\n ? formatMessage(messages.subtotalAmount, {\n amount: subtotalAmount.toFixed(2), currency: alacarteLine.price.currency,\n })\n : '';\n const totalText = alacarteLine?.amountDue\n ? formatMessage(messages.todaysTotalValue, {\n amount: alacarteLine.amountDue.amount.toFixed(2), currency: alacarteLine.amountDue.currency,\n })\n : '';\n\n const lineName = alacarteLine\n ? (alacarteLine.kind === 'course' ? alacarteLine.courseName : alacarteLine.programName)\n : programNameProp;\n\n const ownedCourses = isProgramLine && alacarteLine.kind === 'program'\n ? (alacarteLine.ownedCourses ?? [])\n : [];\n const ownedCourseNames = ownedCourses\n .map((c) => c.name)\n .filter(Boolean)\n .join(', ');\n const discount = alacarteLine?.discount ?? null;\n\n return (\n <aside className=\"cart-summary\" aria-labelledby=\"cart-summary-heading\">\n <Card className=\"cart-summary__card p-3\">\n <Card.Section className=\"d-flex justify-content-between align-items-center p-0 pb-3\">\n <h2 id=\"cart-summary-heading\" className=\"cart-summary__heading font-weight-bold text-gray-900 mb-0\">\n {formatMessage(messages.summaryHeading)}\n </h2>\n <Badge\n variant=\"light\"\n className=\"d-flex align-items-center px-2 py-1\"\n >\n <Icon\n src={Group}\n className=\"mr-1\"\n style={{ width: '1rem', height: '1rem' }}\n />\n {subscriberCount == null ? (\n <span\n className=\"cart-summary__count-skeleton\"\n aria-busy=\"true\"\n aria-label={formatMessage(messages.loadingSubscribers)}\n data-testid=\"subscriber-count-skeleton\"\n >\n <Skeleton width={96} height={12} />\n </span>\n ) : (\n formatMessage(messages.learnersSubscribed, {\n count: subscriberCount.toLocaleString(),\n })\n )}\n </Badge>\n </Card.Section>\n\n <Card.Divider />\n\n <Card.Section className=\"p-0 py-3\">\n {course ? (\n <CourseEnrollmentCard course={course} variant=\"summary\" />\n ) : programDetail ? (\n <ProgramEnrollmentCard\n program={programDetail}\n programName={lineName ?? ''}\n ownedCourses={ownedCourses}\n />\n ) : lineName ? (\n <p className=\"font-weight-bold mb-0 text-primary-500\">{lineName}</p>\n ) : (\n <div className=\"d-flex align-items-start\">\n <EdxUnlimitedLogo ariaLabel=\"edX Plus\" />\n <div>\n <p className=\"font-weight-bold mb-0 text-primary-500\">{title}</p>\n <p className=\"small mb-0 text-gray-900\">{blurb}</p>\n </div>\n </div>\n )}\n {/* Fallback when catalog detail hasn't loaded yet — once it has,\n owned courses are listed under \"Previously purchased\" in the card. */}\n {!programDetail && ownedCourseNames && (\n <p\n className=\"cart-summary__already-yours small text-gray-700 mb-0 mt-2\"\n data-testid=\"already-yours\"\n >\n {formatMessage(messages.alreadyYours, { names: ownedCourseNames })}\n </p>\n )}\n </Card.Section>\n\n <Card.Divider />\n\n <Card.Section className=\"cart-summary__subtotal-row d-flex justify-content-between align-items-center p-0 pt-3\">\n <span className=\"cart-summary__subtotal text-gray-900\">\n {formatMessage(messages.subtotal)}\n </span>\n <span className=\"cart-summary__subtotal text-gray-900\">\n {subtotalText}\n </span>\n </Card.Section>\n\n {discount && (\n <Card.Section\n className=\"d-flex justify-content-between align-items-center p-0\"\n data-testid=\"discount-row\"\n >\n <span className=\"text-success font-weight-bold\">\n {formatMessage(messages.discountApplied)}\n </span>\n <span className=\"text-success font-weight-bold\">\n {formatMessage(messages.discountAmount, {\n amount: discount.amount.toFixed(2),\n currency: discount.currency,\n })}\n </span>\n </Card.Section>\n )}\n\n <Card.Section className=\"p-0\">\n {/* Announces the new total when a coupon is applied or removed. */}\n <div\n className=\"d-flex justify-content-between align-items-center\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n data-testid=\"todays-total\"\n >\n <span className=\"cart-summary__total-label text-gray-900\">\n {formatMessage(messages.todaysTotal)}\n </span>\n <span className=\"cart-summary__total-value mb-0 text-gray-900\">\n {totalText}\n </span>\n </div>\n </Card.Section>\n </Card>\n\n {promoCode ? <PromoCode {...promoCode} /> : null}\n\n {/* Stats row */}\n <div className=\"cart-summary__stats d-none d-lg-flex\">\n <div className=\"cart-summary__stat d-flex align-items-center mr-4\">\n <img src={learnersIcon} alt=\"\" width={50} height={50} className=\"mr-2\" />\n <div>\n <p className=\"cart-summary__stat-count font-weight-bold text-gray-500 mb-0\">\n {formatMessage(messages.learnersCount)}\n </p>\n <p className=\"cart-summary__stat-label text-gray-500 mb-0\">\n {formatMessage(messages.learnersLabel)}\n </p>\n </div>\n </div>\n <div className=\"cart-summary__stat d-flex align-items-center\">\n <img src={institutionsIcon} alt=\"\" width={50} height={50} className=\"mr-2\" />\n <div>\n <p className=\"cart-summary__stat-count font-weight-bold text-gray-500 mb-0\">\n {formatMessage(messages.institutionsCount)}\n </p>\n <p className=\"cart-summary__stat-label text-gray-500 mb-0\">\n {formatMessage(messages.institutionsLabel)}\n </p>\n </div>\n </div>\n </div>\n </aside>\n );\n};\n\nexport default CartSummary;\n"]}
|
|
1
|
+
{"version":3,"file":"CartSummary.js","sourceRoot":"","sources":["../../../src/components/CartSummary/CartSummary.tsx"],"names":[],"mappings":";AACA,OAAO,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC/D,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAC;AAC/C,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,oBAAoB,MAAM,8CAA8C,CAAC;AAChF,OAAO,qBAAqB,MAAM,gDAAgD,CAAC;AACnF,OAAO,SAAS,MAAM,wBAAwB,CAAC;AAI/C,OAAO,QAAQ,MAAM,YAAY,CAAC;AAClC,OAAO,YAAY,MAAM,kBAAkB,CAAC;AAC5C,OAAO,gBAAgB,MAAM,oBAAoB,CAAC;AAqClD,MAAM,WAAW,GAAG,CAAC,EACnB,YAAY,EACZ,YAAY,EACZ,YAAY,EAAE,gBAAgB,EAC9B,MAAM,GAAG,IAAI,EACb,YAAY,GAAG,IAAI,EACnB,aAAa,GAAG,IAAI,EACpB,WAAW,EAAE,eAAe,GAAG,IAAI,EACnC,SAAS,GAAG,IAAI,GACC,EAAE,EAAE;;IACrB,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpC,MAAM,KAAK,GAAG,YAAY,aAAZ,YAAY,cAAZ,YAAY,GAAI,aAAa,CAAC,QAAQ,CAAC,YAAY,CAAC,CAAC;IACnE,MAAM,KAAK,GAAG,YAAY,aAAZ,YAA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AAS,EAAC,MAAM,GAAG,EACzE,0BACE,YAAG,SAAS,EAAC,8DAA8D,YACxE,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,GACpC,EACJ,YAAG,SAAS,EAAC,6CAA6C,YACvD,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,GACpC,IACA,IACF,EACN,eAAK,SAAS,EAAC,8CAA8C,aAC3D,cAAK,GAAG,EAAE,gBAAgB,EAAE,GAAG,EAAC,EAAE,EAAC,KAAK,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,SAAS,EAAC,MAAM,GAAG,EAC7E,0BACE,YAAG,SAAS,EAAC,8DAA8D,YACxE,aAAa,CAAC,QAAQ,CAAC,iBAAiB,CAAC,GACxC,EACJ,YAAG,SAAS,EAAC,6CAA6C,YACvD,aAAa,CAAC,QAAQ,CAAC,iBAAiB,CAAC,GACxC,IACA,IACF,IACF,IACA,CACT,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC","sourcesContent":["import React from 'react';\nimport { Badge, Card, Icon, Skeleton } from '@openedx/paragon';\nimport { Group } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport { EdxUnlimitedLogo } from '../BrandMarks/BrandMarks';\nimport CourseEnrollmentCard from '../CourseEnrollmentCard/CourseEnrollmentCard';\nimport ProgramEnrollmentCard from '../ProgramEnrollmentCard/ProgramEnrollmentCard';\nimport PromoCode from '../PromoCode/PromoCode';\nimport type { PromoCodeProps } from '../PromoCode/PromoCode';\nimport type { CourseDetail } from '../../types';\nimport type { AlacarteLine, ProgramDetail } from '../../types/alacarte';\nimport messages from './Messages';\nimport learnersIcon from './world-icon.svg';\nimport institutionsIcon from './student-icon.svg';\n\nexport type BillingCycle = 'monthly' | 'annual';\n\nexport interface CartSummaryProps {\n productTitle?: string,\n productBlurb?: string,\n /** Promotional monthly price amount e.g. \"39\" */\n monthlyAmount?: string,\n /** Regular monthly price after the promo period e.g. \"59\" */\n monthlyRegularAmount?: string,\n /** Length of the promotional period in months */\n promoMonths?: number,\n /** Annual price amount e.g. \"299\" */\n annualAmount?: string,\n currency?: string,\n defaultCycle?: BillingCycle,\n monthlyRenewalLabel?: string,\n annualRenewalLabel?: string,\n /** Called when the learner switches monthly ↔ annual. */\n onCycleChange?: (cycle: BillingCycle) => void,\n learnerCount?: number,\n /** When set, shows the course enrollment preview card below the summary card. */\n course?: CourseDetail | null,\n /** À la carte checkout line — when present, drives the subtotal/total and\n * the product name shown, in place of the generic edX Plus placeholder. */\n alacarteLine?: AlacarteLine | null,\n /** Program catalog detail (filterTwouProgram) — when present, drives the\n * \"Courses included in this program\" list. */\n programDetail?: ProgramDetail | null,\n /** Fallback program name — used when there is no alacarteLine to provide it\n * (e.g. already-owned overlay). */\n programName?: string | null,\n /** Coupon input — when set, wires PromoCode to tCheckoutUpdate. */\n promoCode?: PromoCodeProps | null,\n}\n\nconst CartSummary = ({\n productTitle,\n productBlurb,\n learnerCount: learnerCountProp,\n course = null,\n alacarteLine = null,\n programDetail = null,\n programName: programNameProp = null,\n promoCode = null,\n}: CartSummaryProps) => {\n const { formatMessage } = useIntl();\n const title = productTitle ?? formatMessage(messages.productTitle);\n const blurb = productBlurb ?? formatMessage(messages.productBlurb);\n\n // Prefer the product's own enrollment count (course or program catalog field).\n const isProgramLine = alacarteLine?.kind === 'program';\n const subscriberCount = course?.tEnrollmentCount\n ?? programDetail?.tEnrollmentCount\n ?? learnerCountProp\n ?? null;\n\n // No fallback amount — an unresolved à la carte line means we don't know\n // the price yet, so the row is left blank rather than showing a made-up\n // number that could be mistaken for the real one.\n // Program subtotal is price less owned-course deduction (before coupon/discount).\n const deductionAmount = isProgramLine && alacarteLine.kind === 'program'\n ? (alacarteLine.deduction?.amount ?? 0)\n : 0;\n const subtotalAmount = alacarteLine?.price\n ? Math.max(0, alacarteLine.price.amount - deductionAmount)\n : null;\n const subtotalText = subtotalAmount != null && alacarteLine?.price\n ? formatMessage(messages.subtotalAmount, {\n amount: subtotalAmount.toFixed(2), currency: alacarteLine.price.currency,\n })\n : '';\n const totalText = alacarteLine?.amountDue\n ? formatMessage(messages.todaysTotalValue, {\n amount: alacarteLine.amountDue.amount.toFixed(2), currency: alacarteLine.amountDue.currency,\n })\n : '';\n\n const lineName = alacarteLine\n ? (alacarteLine.kind === 'course' ? alacarteLine.courseName : alacarteLine.programName)\n : programNameProp;\n\n const ownedCourses = isProgramLine && alacarteLine.kind === 'program'\n ? (alacarteLine.ownedCourses ?? [])\n : [];\n const ownedCourseNames = ownedCourses\n .map((c) => c.name)\n .filter(Boolean)\n .join(', ');\n const discount = alacarteLine?.discount ?? null;\n\n return (\n <aside className=\"cart-summary\" aria-labelledby=\"cart-summary-heading\">\n <Card className=\"cart-summary__card p-3\">\n <Card.Section className=\"d-flex justify-content-between align-items-center p-0 pb-3\">\n <h2 id=\"cart-summary-heading\" className=\"cart-summary__heading font-weight-bold text-gray-900 mb-0\">\n {formatMessage(messages.summaryHeading)}\n </h2>\n <Badge\n variant=\"light\"\n className=\"d-flex align-items-center px-2 py-1\"\n >\n <Icon\n src={Group}\n className=\"mr-1\"\n style={{ width: '1rem', height: '1rem' }}\n />\n {subscriberCount == null ? (\n <span\n className=\"cart-summary__count-skeleton\"\n aria-busy=\"true\"\n aria-label={formatMessage(messages.loadingSubscribers)}\n data-testid=\"subscriber-count-skeleton\"\n >\n <Skeleton width={96} height={12} />\n </span>\n ) : (\n formatMessage(messages.learnersSubscribed, {\n count: subscriberCount.toLocaleString(),\n })\n )}\n </Badge>\n </Card.Section>\n\n <Card.Divider />\n\n <Card.Section className=\"p-0 py-3\">\n {course ? (\n <CourseEnrollmentCard course={course} variant=\"summary\" />\n ) : programDetail ? (\n <ProgramEnrollmentCard\n program={programDetail}\n programName={lineName ?? ''}\n ownedCourses={ownedCourses}\n />\n ) : lineName ? (\n <p className=\"font-weight-bold mb-0 text-primary-500\">{lineName}</p>\n ) : (\n <div className=\"d-flex align-items-start\">\n <EdxUnlimitedLogo ariaLabel=\"edX Plus\" />\n <div>\n <p className=\"font-weight-bold mb-0 text-primary-500\">{title}</p>\n <p className=\"small mb-0 text-gray-900\">{blurb}</p>\n </div>\n </div>\n )}\n {/* Fallback when catalog detail hasn't loaded yet — once it has,\n owned courses are listed under \"Previously purchased\" in the card. */}\n {!programDetail && ownedCourseNames && (\n <p\n className=\"cart-summary__already-yours small text-gray-700 mb-0 mt-2\"\n data-testid=\"already-yours\"\n >\n {formatMessage(messages.alreadyYours, { names: ownedCourseNames })}\n </p>\n )}\n </Card.Section>\n\n <Card.Divider />\n\n <Card.Section className=\"cart-summary__subtotal-row d-flex justify-content-between align-items-center p-0 pt-3\">\n <span className=\"cart-summary__subtotal text-gray-900\">\n {formatMessage(messages.subtotal)}\n </span>\n <span className=\"cart-summary__subtotal text-gray-900\">\n {subtotalText}\n </span>\n </Card.Section>\n\n {discount && (\n <Card.Section\n className=\"d-flex justify-content-between align-items-center p-0\"\n data-testid=\"discount-row\"\n >\n <span className=\"text-success font-weight-bold\">\n {formatMessage(messages.discountApplied)}\n </span>\n <span className=\"text-success font-weight-bold\">\n {formatMessage(messages.discountAmount, {\n amount: discount.amount.toFixed(2),\n currency: discount.currency,\n })}\n </span>\n </Card.Section>\n )}\n\n <Card.Section className=\"p-0\">\n {/* Announces the new total when a coupon is applied or removed. */}\n <div\n className=\"d-flex justify-content-between align-items-center\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n data-testid=\"todays-total\"\n >\n <span className=\"cart-summary__total-label text-gray-900\">\n {formatMessage(messages.todaysTotal)}\n </span>\n <span className=\"cart-summary__total-value mb-0 text-gray-900\">\n {totalText}\n </span>\n </div>\n </Card.Section>\n </Card>\n\n {promoCode ? <PromoCode {...promoCode} /> : null}\n\n {/* Stats row */}\n <div className=\"cart-summary__stats d-none d-lg-flex\">\n <div className=\"cart-summary__stat d-flex align-items-center mr-4\">\n <img src={learnersIcon} alt=\"\" width={50} height={50} className=\"mr-2\" />\n <div>\n <p className=\"cart-summary__stat-count font-weight-bold text-gray-600 mb-0\">\n {formatMessage(messages.learnersCount)}\n </p>\n <p className=\"cart-summary__stat-label text-gray-600 mb-0\">\n {formatMessage(messages.learnersLabel)}\n </p>\n </div>\n </div>\n <div className=\"cart-summary__stat d-flex align-items-center\">\n <img src={institutionsIcon} alt=\"\" width={50} height={50} className=\"mr-2\" />\n <div>\n <p className=\"cart-summary__stat-count font-weight-bold text-gray-600 mb-0\">\n {formatMessage(messages.institutionsCount)}\n </p>\n <p className=\"cart-summary__stat-label text-gray-600 mb-0\">\n {formatMessage(messages.institutionsLabel)}\n </p>\n </div>\n </div>\n </div>\n </aside>\n );\n};\n\nexport default CartSummary;\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
<svg width="46" height="38" viewBox="0 0 46 38" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path d="M22.9167 0L0 12.5L8.33333 17.0417V29.5417L22.9167 37.5L37.5 29.5417V17.0417L41.6667 14.7708V29.1667H45.8333V12.5L22.9167 0ZM37.125 12.5L22.9167 20.25L8.70833 12.5L22.9167 4.75L37.125 12.5ZM33.3333 27.0625L22.9167 32.75L12.5 27.0625V19.3125L22.9167 25L33.3333 19.3125V27.0625Z" fill="#
|
|
2
|
+
<path d="M22.9167 0L0 12.5L8.33333 17.0417V29.5417L22.9167 37.5L37.5 29.5417V17.0417L41.6667 14.7708V29.1667H45.8333V12.5L22.9167 0ZM37.125 12.5L22.9167 20.25L8.70833 12.5L22.9167 4.75L37.125 12.5ZM33.3333 27.0625L22.9167 32.75L12.5 27.0625V19.3125L22.9167 25L33.3333 19.3125V27.0625Z" fill="#707070"/>
|
|
3
3
|
</svg>
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
<svg width="42" height="42" viewBox="0 0 42 42" fill="none" xmlns="http://www.w3.org/2000/svg">
|
|
2
|
-
<path d="M20.8333 0C9.33333 0 0 9.33333 0 20.8333C0 32.3333 9.33333 41.6667 20.8333 41.6667C32.3333 41.6667 41.6667 32.3333 41.6667 20.8333C41.6667 9.33333 32.3333 0 20.8333 0ZM4.16667 20.8333C4.16667 19.5625 4.33333 18.3125 4.60417 17.125L14.5625 27.0833V29.1667C14.5625 31.4583 16.4375 33.3333 18.7292 33.3333V37.3542C10.5417 36.3125 4.16667 29.3125 4.16667 20.8333ZM33.1042 32.0833C32.5625 30.3958 31.0208 29.1667 29.1458 29.1667H27.0625V22.9167C27.0625 21.7708 26.125 20.8333 24.9792 20.8333H12.4792V16.6667H16.6458C17.7917 16.6667 18.7292 15.7292 18.7292 14.5833V10.4167H22.8958C25.1875 10.4167 27.0625 8.54167 27.0625 6.25V5.39583C33.1667 7.85417 37.5 13.8542 37.5 20.8333C37.5 25.1667 35.8125 29.125 33.1042 32.0833Z" fill="#
|
|
2
|
+
<path d="M20.8333 0C9.33333 0 0 9.33333 0 20.8333C0 32.3333 9.33333 41.6667 20.8333 41.6667C32.3333 41.6667 41.6667 32.3333 41.6667 20.8333C41.6667 9.33333 32.3333 0 20.8333 0ZM4.16667 20.8333C4.16667 19.5625 4.33333 18.3125 4.60417 17.125L14.5625 27.0833V29.1667C14.5625 31.4583 16.4375 33.3333 18.7292 33.3333V37.3542C10.5417 36.3125 4.16667 29.3125 4.16667 20.8333ZM33.1042 32.0833C32.5625 30.3958 31.0208 29.1667 29.1458 29.1667H27.0625V22.9167C27.0625 21.7708 26.125 20.8333 24.9792 20.8333H12.4792V16.6667H16.6458C17.7917 16.6667 18.7292 15.7292 18.7292 14.5833V10.4167H22.8958C25.1875 10.4167 27.0625 8.54167 27.0625 6.25V5.39583C33.1667 7.85417 37.5 13.8542 37.5 20.8333C37.5 25.1667 35.8125 29.125 33.1042 32.0833Z" fill="#707070"/>
|
|
3
3
|
</svg>
|
|
@@ -101,6 +101,12 @@ const Checkout = (_a) => {
|
|
|
101
101
|
setAdvertisedOffer({ code: appliedCouponCode, percent: discountPercent });
|
|
102
102
|
}
|
|
103
103
|
}, [appliedCouponCode, isCouponDiscount, discountPercent]);
|
|
104
|
+
// A coupon alert closed with focus inside it: go back to the coupon control
|
|
105
|
+
// (Remove when a coupon is applied, otherwise the field).
|
|
106
|
+
const focusCouponControl = useCallback(() => {
|
|
107
|
+
var _a, _b;
|
|
108
|
+
(_b = ((_a = document.getElementById('promoCodeRemove')) !== null && _a !== void 0 ? _a : document.getElementById('promoCode'))) === null || _b === void 0 ? void 0 : _b.focus();
|
|
109
|
+
}, []);
|
|
104
110
|
// No query params and no active cart — nothing to check out, send the
|
|
105
111
|
// learner home rather than showing a placeholder.
|
|
106
112
|
useEffect(() => {
|
|
@@ -256,7 +262,12 @@ const Checkout = (_a) => {
|
|
|
256
262
|
amount: alacarte.line.amountDue.amount.toFixed(2),
|
|
257
263
|
currency: alacarte.line.amountDue.currency,
|
|
258
264
|
}) })), showForm && (_jsxs(_Fragment, { children: [_jsx(PaymentValidationAlert, { fields: invalidPaymentFields, country: c.billing.country, focusRequest: validationRequest, onFieldSelect: focusPaymentField, className: "mb-3" }), c.phase === 'failed' && (_jsx(Alert, { variant: "danger", icon: ErrorIcon, className: "mb-3", children: failedMessage
|
|
259
|
-
|| formatMessage(messages.paymentProcessingDescription) })), appliedCouponCode && appliedDiscount && dismissedCouponAlert !== appliedCouponCode && (_jsxs(AutoDismissAlert, { variant: "success", icon: CheckCircle, dismissible: true, closeLabel: formatMessage(messages.dismiss), onClose: () => setDismissedCouponAlert(appliedCouponCode), className: "coupon-applied-alert", "data-testid": "coupon-applied-alert", role: "status",
|
|
265
|
+
|| formatMessage(messages.paymentProcessingDescription) })), appliedCouponCode && appliedDiscount && dismissedCouponAlert !== appliedCouponCode && (_jsxs(AutoDismissAlert, { variant: "success", icon: CheckCircle, dismissible: true, closeLabel: formatMessage(messages.dismiss), onClose: () => setDismissedCouponAlert(appliedCouponCode), className: "coupon-applied-alert", "data-testid": "coupon-applied-alert", role: "status",
|
|
266
|
+
// Mounts from the coupon request's onSuccess, before
|
|
267
|
+
// couponApplying settles — so only the learner's own
|
|
268
|
+
// Apply takes focus here (not a coupon applied on load),
|
|
269
|
+
// and screen readers read the alert, not Remove.
|
|
270
|
+
focusOnMount: alacarte.couponApplying, returnFocus: focusCouponControl, children: [_jsx("span", { "aria-hidden": "true", children: "\uD83C\uDF89 " }), formatMessage(messages.couponAppliedAlert, {
|
|
260
271
|
code: appliedCouponCode,
|
|
261
272
|
percent: appliedDiscount.percent,
|
|
262
273
|
})] }, appliedCouponCode)), alacarte.removedCouponCode && (() => {
|
|
@@ -265,7 +276,7 @@ const Checkout = (_a) => {
|
|
|
265
276
|
// Bold the interpolated code without baking markup into the
|
|
266
277
|
// translation string — find it in the formatted sentence.
|
|
267
278
|
const codeIndex = removedText.indexOf(removedCode);
|
|
268
|
-
return (_jsx(AutoDismissAlert, { variant: "success", icon: CheckCircle, dismissible: true, closeLabel: formatMessage(messages.dismiss), onClose: alacarte.clearRemovedCouponCode, className: "coupon-removed-alert", "data-testid": "coupon-removed-alert", role: "status", children: codeIndex === -1 ? removedText : (_jsxs(_Fragment, { children: [removedText.slice(0, codeIndex), _jsx("strong", { children: removedCode }), removedText.slice(codeIndex + removedCode.length)] })) }, removedCode));
|
|
279
|
+
return (_jsx(AutoDismissAlert, { variant: "success", icon: CheckCircle, dismissible: true, closeLabel: formatMessage(messages.dismiss), onClose: alacarte.clearRemovedCouponCode, className: "coupon-removed-alert", "data-testid": "coupon-removed-alert", role: "status", focusOnMount: alacarte.couponApplying, returnFocus: focusCouponControl, children: codeIndex === -1 ? removedText : (_jsxs(_Fragment, { children: [removedText.slice(0, codeIndex), _jsx("strong", { children: removedCode }), removedText.slice(codeIndex + removedCode.length)] })) }, removedCode));
|
|
269
280
|
})()] }))] }) }), _jsx(Col, { xs: 12, className: "payment__summary", children: _jsx("div", { ref: lockedInertRef, "data-testid": "checkout-summary-region", children: c.phase === 'success' ? (_jsx(EnrollmentSummary, { course: c.course, onStartCourse: handleStartCourse })) : (_jsx(CartSummary, { defaultCycle: selectedCycle, onCycleChange: c.processingSubscription ? undefined : c.setCycle, course: courseForSummary, alacarteLine: alacarte.line, programDetail: alacarteProgramDetail, programName: alacarte.ownedProductName, promoCode: isAlacarteReady ? {
|
|
270
281
|
value: promoCodeValue,
|
|
271
282
|
// Keep a coupon error up while the learner edits the code;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../../../src/components/Checkout/Checkout.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,WAAW,MAAM,8BAA8B,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,kGAAkG;AAClG,oFAAoF;AACpF,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,iBAAiB,MAAM,wCAAwC,CAAC;AACvE,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,4FAA4F;AAC5F,OAAO,iBAAiB,MAAM,wCAAwC,CAAC;AACvE,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAC9D,OAAO,oBAAoB,MAAM,8CAA8C,CAAC;AAChF,OAAO,mBAAmB,MAAM,4CAA4C,CAAC;AAC7E,OAAO,iBAAiB,MAAM,wCAAwC,CAAC;AACvE,OAAO,sBAAsB,MAAM,kDAAkD,CAAC;AACtF,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,kBAAkB,MAAM,0CAA0C,CAAC,CAAC,kDAAkD;AAC7H,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,E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CAAC,CAAC,SAAS,EAC1E,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,EAC1E,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,GACxE,CACH,EAEA,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,CACxB,KAAC,aAAa,IACZ,gBAAgB,EAAE,CAAA,MAAA,CAAC,CAAC,mBAAmB,0CAAE,IAAI,KAAI,EAAE,EACnD,SAAS,EAAE,CAAA,MAAA,CAAC,CAAC,mBAAmB,0CAAE,SAAS,KAAI,EAAE,EACjD,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,iBAAiB,GAC/B,CACH,EAEA,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,CACxB,KAAC,aAAa,IAAC,MAAM,EAAE,CAAC,CAAC,WAAW,GAAI,CACzC,IACG,GACF,IACF,GACF,IACF,IACL,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import React, { useCallback, useEffect, useState } from 'react';\nimport { Alert, Button, Col, Row } from '@openedx/paragon';\nimport { CheckCircle, Error as ErrorIcon } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport useCheckout from '../../data/hooks/useCheckout';\nimport type { UseCheckoutOptions } from '../../data/hooks/useCheckout';\nimport { useAlacarteCheckout } from '../../data/hooks/useAlacarteCheckout';\n// Billing-country gate disabled: every country can check out; embargo is enforced by the backend.\n// import { ALLOWED_CHECKOUT_COUNTRIES, GATE_CHECK_COUNTRY } from '../../constants';\nimport CartSummary from '../CartSummary/CartSummary';\nimport EnrollmentSummary from '../EnrollmentSummary/EnrollmentSummary';\nimport PaymentForm from '../PaymentForm/PaymentForm';\n// import CountryUnavailableModal from '../CountryUnavailableModal/CountryUnavailableModal';\nimport OrderBlockedModal from '../OrderBlockedModal/OrderBlockedModal';\nimport AlacarteNotice from '../AlacarteNotice/AlacarteNotice';\nimport AlacarteConfirmation from '../AlacarteConfirmation/AlacarteConfirmation';\nimport PaymentTimeoutAlert from '../PaymentTimeoutAlert/PaymentTimeoutAlert';\nimport PriceChangedAlert from '../PriceChangedAlert/PriceChangedAlert';\nimport PaymentValidationAlert from '../PaymentValidationAlert/PaymentValidationAlert';\nimport AutoDismissAlert from '../AutoDismissAlert/AutoDismissAlert';\nimport AlacarteDebugPanel from '../AlacarteDebugPanel/AlacarteDebugPanel'; // TEMPORARY — remove alongside AlacarteDebugPanel\nimport { getTrialDateRange } from '@src/utils';\nimport { getLearnerFacingCheckoutMessage } from '../../utils/checkoutErrors';\nimport { appliedDiscountPercent } from '../../utils/discount';\nimport { useInert } from '../../utils/inert';\nimport { getInvalidPaymentFields, isCardFieldKey } from '../../utils/paymentValidation';\nimport type { PaymentFieldKey } from '../../utils/paymentValidation';\nimport { confirmPaymentWithMethodId, getLearnerFacingStripeMessage } from '../../utils/stripeCard';\nimport { SuccessScreen, BlockedScreen, ProcessingScreen } from '../StatusScreens/StatusScreens';\nimport type { BillingCycle, CourseDetail } from '../../types';\nimport type { ProgramDetail } from '../../types/alacarte';\nimport messages from './Messages';\n\n// TEMPORARY — redirect-home-on-noActiveCheckout disabled per request; shows a\n// banner instead so the case is visible while the flow is being verified.\n// Flip back to true to restore the redirect.\nconst REDIRECT_ON_NO_ACTIVE_CHECKOUT = false;\n\nexport type CheckoutProps = UseCheckoutOptions & {\n /** Homepage URL for the country-unavailable modal CTA. */\n homeUrl?: string,\n /** Endpoint used to look up the representative IP for a selected country. */\n geolocationUrl?: string,\n /** Learner dashboard / order history URL for confirmation CTAs. */\n orderHistoryUrl?: string,\n /** PayPal JS SDK client id — enables the express PayPal button. */\n paypalClientId?: string,\n};\n\nconst Checkout = ({\n homeUrl = '/',\n orderHistoryUrl,\n paypalClientId,\n ...props\n}: CheckoutProps) => {\n const { formatMessage } = useIntl();\n const alacarte = useAlacarteCheckout({\n apiUrl: props.apiUrl,\n edxSessionUrl: props.edxSessionUrl,\n skipSubscriptionCourseRuns: props.skipSubscriptionCourseRuns,\n });\n const c = useCheckout(props);\n const [promoCodeValue, setPromoCodeValue] = useState('');\n const [dismissedCouponAlert, setDismissedCouponAlert] = useState<string | null>(null);\n // 0 hides the validation alert; each failed Pay now bumps it, which moves\n // focus to the alert.\n const [validationRequest, setValidationRequest] = useState(0);\n const [dismissedPriceChange, setDismissedPriceChange] = useState(false);\n // Last code we successfully priced — drives the \"Save {percent}% with code\n // {code}\" hint on the empty field while a coupon is not yet applied.\n const [advertisedOffer, setAdvertisedOffer] = useState<{ code: string, percent: number } | null>(null);\n const isAlacarteReady = (alacarte.phase === 'ready' || alacarte.phase === 'alreadyOwned') && !!alacarte.checkout;\n const appliedCouponCode = alacarte.checkout?.couponCode?.trim()\n ? alacarte.checkout.couponCode.trim()\n : null;\n const discountPercent = appliedDiscountPercent(alacarte.line);\n // Only treat the line discount as a removable coupon when the backend says\n // so (or a coupon code is present). Automatic offers show only in CartSummary's\n // discount row and must not drive PromoCode's applied/remove UI.\n const isCouponDiscount = !!alacarte.line?.discount\n && alacarte.line.discountSource !== 'automatic'\n && (alacarte.line.discountSource === 'coupon' || !!appliedCouponCode);\n const appliedDiscount = isCouponDiscount && discountPercent != null\n ? {\n percent: discountPercent,\n amount: alacarte.line!.discount!.amount,\n currency: alacarte.line!.discount!.currency,\n }\n : null;\n\n // Keep the coupon field in sync when a code is applied via URL or API.\n // Don't overwrite the field with empty when only an automatic offer applies.\n useEffect(() => {\n if (alacarte.checkout?.couponCode) {\n setPromoCodeValue(alacarte.checkout.couponCode);\n }\n }, [alacarte.checkout?.couponCode]);\n\n useEffect(() => {\n if (appliedCouponCode && isCouponDiscount && discountPercent != null) {\n setAdvertisedOffer({ code: appliedCouponCode, percent: discountPercent });\n }\n }, [appliedCouponCode, isCouponDiscount, discountPercent]);\n\n // No query params and no active cart — nothing to check out, send the\n // learner home rather than showing a placeholder.\n useEffect(() => {\n if (REDIRECT_ON_NO_ACTIVE_CHECKOUT && alacarte.phase === 'noActiveCheckout') {\n window.location.href = homeUrl;\n }\n }, [alacarte.phase, homeUrl]);\n\n // Express checkout (Apple Pay / Google Pay): runs the full place-order flow\n // using a wallet-provided PaymentMethod id instead of the mounted card element.\n const handleExpressPayment = useCallback(async (paymentMethodId: string, walletCountry?: string) => {\n if (!c.stripe) throw new Error('Stripe not loaded');\n const stripeInstance = c.stripe;\n const country = (c.billing.country || walletCountry || c.userCountry || '').trim().toUpperCase();\n if (!country) {\n throw new Error('Please select a country before using Apple Pay or Google Pay.');\n }\n\n await alacarte.placeOrderAsync({\n billing: {\n ...c.billing,\n country,\n },\n confirmCardPayment: async (clientSecret: string) => {\n await confirmPaymentWithMethodId({\n stripe: stripeInstance,\n clientSecret,\n paymentMethodId,\n });\n },\n });\n }, [alacarte, c.billing, c.userCountry, c.stripe]);\n\n // Express checkout (PayPal): tCheckoutPlaceOrder(PAYPAL) when the PayPal\n // button is clicked; approve/cancel go straight to the à la carte hook.\n // The card form isn't validated — PayPal collects the payer's details.\n const handlePaypalCreateOrder = useCallback(() => alacarte.startPaypalOrder({\n billing: {\n ...c.billing,\n country: c.billing.country || c.userCountry || '',\n },\n }), [alacarte, c.billing, c.userCountry]);\n\n const showProcessing\n = c.returningFromStripe\n && c.processingSubscription\n && c.phase !== 'success'\n && c.phase !== 'blocked'\n && c.phase !== 'failed';\n const showForm\n = !showProcessing\n && (c.phase === 'init'\n || c.phase === 'ready'\n || c.phase === 'failed'\n || c.phase === 'processing');\n const failedMessage = getLearnerFacingCheckoutMessage(c.lastComment);\n\n const { displayStart, displayEnd } = getTrialDateRange();\n\n // const isBillingCountryBlocked = GATE_CHECK_COUNTRY\n // && !!c.billing.country\n // && !ALLOWED_CHECKOUT_COUNTRIES.includes(c.billing.country);\n\n const selectedCycle: BillingCycle = c.selectedCycle;\n\n // Prefer the à la carte course's own detail (skills/badge/image, richer than\n // the subscription flow's ?course_run_key= lookup) when we selected a course.\n // When already-owned the line may be null, so fall back to the selector kind.\n const isCourseProduct = alacarte.line?.kind === 'course' || alacarte.selector?.kind === 'course';\n const isProgramProduct = alacarte.line?.kind === 'program' || alacarte.selector?.kind === 'program';\n\n const alacarteCourseDetail: CourseDetail | null\n = isCourseProduct && alacarte.productDetail && 'maId' in alacarte.productDetail\n ? alacarte.productDetail\n : null;\n const courseForSummary = alacarteCourseDetail ?? c.course;\n\n const alacarteProgramDetail: ProgramDetail | null\n = isProgramProduct && alacarte.productDetail && 'tCourses' in alacarte.productDetail\n ? alacarte.productDetail\n : null;\n\n const handleStartCourse = () => {\n const alacarteCourseUrl = alacarteCourseDetail?.tUrlCourse\n || (alacarte.productDetail && 'tUrlCourse' in alacarte.productDetail\n ? alacarte.productDetail.tUrlCourse\n : null);\n if (alacarteCourseUrl) {\n window.location.href = alacarteCourseUrl;\n } else if (c.course?.tUrlCourse) {\n window.location.href = c.course.tUrlCourse;\n } else {\n window.location.href = homeUrl || '/';\n }\n };\n\n const courseLabel = c.course\n ? [c.course.tBrandText, c.course.maName].filter(Boolean).join(': ')\n : null;\n\n const isAlreadyOwned = alacarte.isAlreadyOwned;\n const { paymentTimedOut } = alacarte;\n // Grey out and block the form + summary; only the alerts above stay usable.\n const isLocked = isAlreadyOwned || paymentTimedOut;\n // The overlay only blocks the pointer — inert takes the locked content out\n // of the tab order too.\n const lockedInertRef = useInert<HTMLDivElement>(isLocked);\n\n // Live while shown, so the links drop off as the learner fixes each field.\n const invalidPaymentFields = validationRequest > 0\n ? getInvalidPaymentFields(c.cardFieldStates, c.billing)\n : [];\n const handleValidationResult = (invalidFields: PaymentFieldKey[]) => {\n setValidationRequest((n) => (invalidFields.length > 0 ? n + 1 : 0));\n };\n const focusPaymentField = (field: PaymentFieldKey) => {\n if (isCardFieldKey(field)) {\n c.focusCardField(field);\n } else {\n // Billing controls use the field key as their id (Form.Group controlId).\n document.getElementById(field)?.focus();\n }\n };\n\n if (showProcessing) {\n return <ProcessingScreen />;\n }\n\n // TEMPORARY — flip to true to dump à la carte hook state while validating\n // against the real backend. Remove AlacarteDebugPanel once the flow is solid.\n const SHOW_ALACARTE_DEBUG = false;\n const alacarteDebug = SHOW_ALACARTE_DEBUG\n ? <AlacarteDebugPanel data={alacarte} />\n : null;\n\n // Confirmation: show once the order is ready (or failed to load). While\n // tPlacedOrder is still polling, keep the checkout form so Pay now can show\n // \"Processing...\" instead of a full-page loader.\n if (alacarte.placedOrder || alacarte.placedOrderError) {\n const confirmationTitle = alacarte.line?.kind === 'program'\n ? alacarte.line.programName\n : alacarte.line?.kind === 'course'\n ? alacarte.line.courseName\n : null;\n\n return (\n <>\n {alacarteDebug}\n <Row className=\"checkout__container alacarte-confirmation__container bg-light-200\">\n <Col xs={12}>\n <AlacarteConfirmation\n order={alacarte.placedOrder}\n awaiting={false}\n error={alacarte.placedOrderError}\n onContinue={handleStartCourse}\n productDetail={alacarte.productDetail}\n productTitle={confirmationTitle}\n ownedCourses={\n alacarte.line?.kind === 'program'\n ? (alacarte.line.ownedCourses ?? null)\n : null\n }\n orderHistoryUrl={orderHistoryUrl ?? null}\n placedAt={alacarte.placedOrderPlacedAt}\n />\n </Col>\n </Row>\n </>\n );\n }\n\n if (alacarte.phase === 'loading') {\n return (\n <>\n {alacarteDebug}\n <ProcessingScreen />\n </>\n );\n }\n if (alacarte.phase === 'noActiveCheckout' && REDIRECT_ON_NO_ACTIVE_CHECKOUT) {\n // Redirects home via the effect above — show a spinner rather than a\n // notice while that happens.\n return (\n <>\n {alacarteDebug}\n <ProcessingScreen />\n </>\n );\n }\n if (alacarte.phase === 'noActiveCheckout') {\n return (\n <>\n {alacarteDebug}\n <AlacarteNotice messageId={alacarte.noticeMessageId!} />\n </>\n );\n }\n // Product unavailable / not found / not purchasable — banner only, no checkout form.\n if (alacarte.phase === 'notPurchasable' || alacarte.phase === 'error') {\n return (\n <>\n {alacarteDebug}\n <Row className=\"checkout__container bg-light-200\">\n <Col xs={12}>\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n data-testid=\"alacarte-error-banner\"\n >\n {alacarte.error || 'Something went wrong with checkout.'}\n </Alert>\n </Col>\n </Row>\n </>\n );\n }\n\n // Price differs from what the learner viewed before checkout (ALC-159).\n const showPriceChangedAlert = !!alacarte.priceChanged && !dismissedPriceChange && !isLocked;\n const priceChangedKind = isProgramProduct ? 'program' : 'course';\n\n return (\n <>\n {alacarteDebug}\n <Row className=\"checkout__container bg-light-200\">\n {/* <CountryUnavailableModal\n isOpen={isBillingCountryBlocked}\n homeUrl={homeUrl}\n /> */}\n {alacarte.sanctionsBlocked && (\n <OrderBlockedModal\n isOpen\n referenceCode={alacarte.sanctionsBlocked.referenceCode}\n homeUrl={homeUrl}\n />\n )}\n <Col xs={12} className={isLocked ? 'checkout__locked-overlay' : ''}>\n {/* DOM order is the tab order on every breakpoint: alerts, then the\n summary and coupon, then payment. From lg up, the grid in\n checkout.scss moves the summary to the right column. */}\n <Row className=\"checkout__layout\">\n <Col xs={12} className=\"checkout__header\">\n <div>\n <h1 className=\"font-weight-bold text-primary-900 mb-lg-4\">\n Checkout\n </h1>\n\n {paymentTimedOut && (\n <PaymentTimeoutAlert className=\"checkout__overlay-alert mb-3\" />\n )}\n\n {isAlreadyOwned && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n className=\"checkout__overlay-alert mb-3\"\n data-testid=\"already-owned-alert\"\n >\n <p className=\"mb-3\">\n {formatMessage(\n alacarte.selector?.kind === 'program'\n ? messages.alreadyPaidProgram\n : messages.alreadyPaidCourse,\n )}\n </p>\n <div className=\"d-flex align-items-center justify-content-end gap-3 flex-wrap\">\n {orderHistoryUrl && (\n <a href={orderHistoryUrl} className=\"checkout__order-history text-gray-900 font-weight-bold\">\n {formatMessage(messages.viewOrderHistory)}\n </a>\n )}\n <Button variant=\"brand\" className=\"rounded-pill\" onClick={handleStartCourse}>\n {formatMessage(messages.goToCourse)}\n </Button>\n </div>\n </Alert>\n )}\n\n {c.error && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n dismissible\n onClose={c.clearError}\n >\n {c.error}\n </Alert>\n )}\n\n {alacarte.placeOrderError && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n dismissible\n onClose={alacarte.clearPlaceOrderError}\n className=\"mb-3\"\n >\n {alacarte.placeOrderError}\n </Alert>\n )}\n\n {alacarte.paymentDecline?.message && !alacarte.placeOrderError && !paymentTimedOut && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n className=\"mb-3\"\n data-testid=\"payment-decline-alert\"\n >\n {getLearnerFacingStripeMessage({\n message: alacarte.paymentDecline.message,\n code: alacarte.paymentDecline.code ?? undefined,\n })}\n </Alert>\n )}\n {/* paymentInterrupted alert shown when payment is interrupted but not declined, no place order error, and payment has not timed out */}\n {alacarte.paymentInterrupted && !alacarte.paymentDecline && !alacarte.placeOrderError && !paymentTimedOut && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n dismissible\n onClose={alacarte.clearPaymentInterrupted}\n className=\"mb-3\"\n data-testid=\"payment-interrupted-alert\"\n >\n {formatMessage(messages.paymentInterruptedAlert)}\n </Alert>\n )}\n {/* walletPaymentCancelled alert shown when the Apple Pay / Google Pay sheet is closed without paying */}\n {alacarte.walletPaymentCancelled && !alacarte.paymentInterrupted\n && !alacarte.paymentDecline && !alacarte.placeOrderError && !paymentTimedOut && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n dismissible\n onClose={alacarte.clearWalletPaymentCancelled}\n className=\"mb-3\"\n data-testid=\"wallet-payment-cancelled-alert\"\n >\n {formatMessage(messages.walletPaymentCancelledAlert)}\n </Alert>\n )}\n\n {alacarte.couponError && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n dismissible\n onClose={alacarte.clearCouponError}\n className=\"mb-3\"\n data-testid=\"coupon-error-alert\"\n >\n {alacarte.couponError}\n </Alert>\n )}\n\n {showPriceChangedAlert && (\n <PriceChangedAlert\n kind={priceChangedKind}\n onDismiss={() => setDismissedPriceChange(true)}\n className=\"mb-3\"\n />\n )}\n\n {!alacarte.priceAccepted && !alacarte.priceChanged && isAlacarteReady && alacarte.line?.amountDue && (\n <Alert variant=\"info\" className=\"mb-3\" data-testid=\"price-accept-notice\">\n {formatMessage(messages.priceChangedNotice, {\n amount: alacarte.line.amountDue.amount.toFixed(2),\n currency: alacarte.line.amountDue.currency,\n })}\n </Alert>\n )}\n\n {showForm && (\n <>\n <PaymentValidationAlert\n fields={invalidPaymentFields}\n country={c.billing.country}\n focusRequest={validationRequest}\n onFieldSelect={focusPaymentField}\n className=\"mb-3\"\n />\n {c.phase === 'failed' && (\n <Alert variant=\"danger\" icon={ErrorIcon} className=\"mb-3\">\n {failedMessage\n || formatMessage(messages.paymentProcessingDescription)}\n </Alert>\n )}\n {appliedCouponCode && appliedDiscount && dismissedCouponAlert !== appliedCouponCode && (\n <AutoDismissAlert\n key={appliedCouponCode}\n variant=\"success\"\n icon={CheckCircle}\n dismissible\n closeLabel={formatMessage(messages.dismiss)}\n onClose={() => setDismissedCouponAlert(appliedCouponCode)}\n className=\"coupon-applied-alert\"\n data-testid=\"coupon-applied-alert\"\n role=\"status\"\n >\n <span aria-hidden=\"true\">🎉 </span>\n {formatMessage(messages.couponAppliedAlert, {\n code: appliedCouponCode,\n percent: appliedDiscount.percent,\n })}\n </AutoDismissAlert>\n )}\n {alacarte.removedCouponCode && (() => {\n const removedCode = alacarte.removedCouponCode;\n const removedText = formatMessage(\n messages.couponRemovedAlert,\n { code: removedCode },\n );\n // Bold the interpolated code without baking markup into the\n // translation string — find it in the formatted sentence.\n const codeIndex = removedText.indexOf(removedCode);\n return (\n <AutoDismissAlert\n key={removedCode}\n variant=\"success\"\n icon={CheckCircle}\n dismissible\n closeLabel={formatMessage(messages.dismiss)}\n onClose={alacarte.clearRemovedCouponCode}\n className=\"coupon-removed-alert\"\n data-testid=\"coupon-removed-alert\"\n role=\"status\"\n >\n {codeIndex === -1 ? removedText : (\n <>\n {removedText.slice(0, codeIndex)}\n <strong>{removedCode}</strong>\n {removedText.slice(codeIndex + removedCode.length)}\n </>\n )}\n </AutoDismissAlert>\n );\n })()}\n </>\n )}\n </div>\n </Col>\n\n {/* ── Summary — swaps to EnrollmentSummary on success ── */}\n <Col xs={12} className=\"payment__summary\">\n <div ref={lockedInertRef} data-testid=\"checkout-summary-region\">\n {c.phase === 'success' ? (\n <EnrollmentSummary\n course={c.course}\n onStartCourse={handleStartCourse}\n />\n ) : (\n <CartSummary\n defaultCycle={selectedCycle}\n onCycleChange={c.processingSubscription ? undefined : c.setCycle}\n course={courseForSummary}\n alacarteLine={alacarte.line}\n programDetail={alacarteProgramDetail}\n programName={alacarte.ownedProductName}\n promoCode={isAlacarteReady ? {\n value: promoCodeValue,\n // Keep a coupon error up while the learner edits the code;\n // applyCoupon clears it on the next Apply.\n onChange: setPromoCodeValue,\n onApply: () => alacarte.applyCoupon(promoCodeValue),\n onRemove: () => {\n alacarte.removeCoupon();\n setPromoCodeValue('');\n setAdvertisedOffer(null);\n // The applied alert auto-dismisses, so re-applying the\n // same code must be able to show it again.\n setDismissedCouponAlert(null);\n },\n appliedCode: appliedCouponCode,\n discount: appliedDiscount,\n offer: !appliedCouponCode ? advertisedOffer : null,\n error: alacarte.couponError,\n isApplying: alacarte.couponApplying,\n disabled: alacarte.placingOrder,\n } : null}\n />\n )}\n </div>\n </Col>\n\n {/* ── Payment ── */}\n <Col xs={12} className=\"payment__options\">\n <div ref={lockedInertRef} data-testid=\"checkout-payment-region\">\n {showForm && (\n <PaymentForm\n billing={c.billing}\n setField={c.setField}\n numberMountRef={c.numberMountRef}\n expiryMountRef={c.expiryMountRef}\n cvcMountRef={c.cvcMountRef}\n cardError={c.cardError}\n cardFieldStates={c.cardFieldStates}\n stripeReady={c.stripeReady}\n sessionReady={c.sessionReady}\n submitting={\n isAlacarteReady\n ? (alacarte.placingOrder || alacarte.awaitingPlacedOrder)\n : c.processingSubscription\n }\n onPlaceOrder={\n isAlacarteReady\n ? () => {\n alacarte.placeOrder({\n billing: {\n ...c.billing,\n // Country is required on tCheckoutPlaceOrder (two-letter ISO).\n // Prefer the form selection; fall back to gate geolocation.\n country: c.billing.country || c.userCountry || '',\n },\n confirmCardPayment: c.confirmCardPayment,\n });\n }\n : c.placeOrder\n }\n onValidationError={handleValidationResult}\n trialEnd={selectedCycle === 'monthly' ? displayEnd : undefined}\n priceToShow={null}\n cycleToShow={selectedCycle === 'monthly' ? 'monthly' : 'annual'}\n userCountry={c.userCountry}\n geolocationUrl={props.geolocationUrl}\n alacarteLine={alacarte.line}\n stripe={c.stripe}\n expressCountry={c.billing.country || c.userCountry || 'US'}\n onExpressPayment={isAlacarteReady ? handleExpressPayment : undefined}\n onExpressClick={isAlacarteReady ? alacarte.clearPaymentAlerts : undefined}\n onExpressCancel={isAlacarteReady ? alacarte.markWalletPaymentCancelled : undefined}\n paypalClientId={paypalClientId}\n onPaypalCreateOrder={isAlacarteReady ? handlePaypalCreateOrder : undefined}\n onPaypalApprove={isAlacarteReady ? alacarte.approvePaypalOrder : undefined}\n onPaypalCancel={isAlacarteReady ? alacarte.cancelPaypalOrder : undefined}\n />\n )}\n\n {c.phase === 'success' && (\n <SuccessScreen\n subscriptionBiId={c.subscriptionDetails?.biId || ''}\n cardLast4={c.subscriptionDetails?.cardLast4 || ''}\n purchaseDate={displayStart}\n courseLabel={courseLabel}\n onFindCourse={handleStartCourse}\n />\n )}\n\n {c.phase === 'blocked' && (\n <BlockedScreen detail={c.lastComment} />\n )}\n </div>\n </Col>\n </Row>\n </Col>\n </Row>\n </>\n );\n};\n\nexport default Checkout;\n"]}
|
|
1
|
+
{"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../../../src/components/Checkout/Checkout.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,EA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C9B,mBAAmB,EAAE,eAAe,CAAC,CAAC,CAAC,uBAAuB,CAAC,CAAC,CAAC,SAAS,EAC1E,eAAe,EAAE,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,EAC1E,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,GACxE,CACH,EAEA,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,CACxB,KAAC,aAAa,IACZ,gBAAgB,EAAE,CAAA,MAAA,CAAC,CAAC,mBAAmB,0CAAE,IAAI,KAAI,EAAE,EACnD,SAAS,EAAE,CAAA,MAAA,CAAC,CAAC,mBAAmB,0CAAE,SAAS,KAAI,EAAE,EACjD,YAAY,EAAE,YAAY,EAC1B,WAAW,EAAE,WAAW,EACxB,YAAY,EAAE,iBAAiB,GAC/B,CACH,EAEA,CAAC,CAAC,KAAK,KAAK,SAAS,IAAI,CACxB,KAAC,aAAa,IAAC,MAAM,EAAE,CAAC,CAAC,WAAW,GAAI,CACzC,IACG,GACF,IACF,GACF,IACF,IACL,CACJ,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,QAAQ,CAAC","sourcesContent":["import React, { useCallback, useEffect, useState } from 'react';\nimport { Alert, Button, Col, Row } from '@openedx/paragon';\nimport { CheckCircle, Error as ErrorIcon } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport useCheckout from '../../data/hooks/useCheckout';\nimport type { UseCheckoutOptions } from '../../data/hooks/useCheckout';\nimport { useAlacarteCheckout } from '../../data/hooks/useAlacarteCheckout';\n// Billing-country gate disabled: every country can check out; embargo is enforced by the backend.\n// import { ALLOWED_CHECKOUT_COUNTRIES, GATE_CHECK_COUNTRY } from '../../constants';\nimport CartSummary from '../CartSummary/CartSummary';\nimport EnrollmentSummary from '../EnrollmentSummary/EnrollmentSummary';\nimport PaymentForm from '../PaymentForm/PaymentForm';\n// import CountryUnavailableModal from '../CountryUnavailableModal/CountryUnavailableModal';\nimport OrderBlockedModal from '../OrderBlockedModal/OrderBlockedModal';\nimport AlacarteNotice from '../AlacarteNotice/AlacarteNotice';\nimport AlacarteConfirmation from '../AlacarteConfirmation/AlacarteConfirmation';\nimport PaymentTimeoutAlert from '../PaymentTimeoutAlert/PaymentTimeoutAlert';\nimport PriceChangedAlert from '../PriceChangedAlert/PriceChangedAlert';\nimport PaymentValidationAlert from '../PaymentValidationAlert/PaymentValidationAlert';\nimport AutoDismissAlert from '../AutoDismissAlert/AutoDismissAlert';\nimport AlacarteDebugPanel from '../AlacarteDebugPanel/AlacarteDebugPanel'; // TEMPORARY — remove alongside AlacarteDebugPanel\nimport { getTrialDateRange } from '@src/utils';\nimport { getLearnerFacingCheckoutMessage } from '../../utils/checkoutErrors';\nimport { appliedDiscountPercent } from '../../utils/discount';\nimport { useInert } from '../../utils/inert';\nimport { getInvalidPaymentFields, isCardFieldKey } from '../../utils/paymentValidation';\nimport type { PaymentFieldKey } from '../../utils/paymentValidation';\nimport { confirmPaymentWithMethodId, getLearnerFacingStripeMessage } from '../../utils/stripeCard';\nimport { SuccessScreen, BlockedScreen, ProcessingScreen } from '../StatusScreens/StatusScreens';\nimport type { BillingCycle, CourseDetail } from '../../types';\nimport type { ProgramDetail } from '../../types/alacarte';\nimport messages from './Messages';\n\n// TEMPORARY — redirect-home-on-noActiveCheckout disabled per request; shows a\n// banner instead so the case is visible while the flow is being verified.\n// Flip back to true to restore the redirect.\nconst REDIRECT_ON_NO_ACTIVE_CHECKOUT = false;\n\nexport type CheckoutProps = UseCheckoutOptions & {\n /** Homepage URL for the country-unavailable modal CTA. */\n homeUrl?: string,\n /** Endpoint used to look up the representative IP for a selected country. */\n geolocationUrl?: string,\n /** Learner dashboard / order history URL for confirmation CTAs. */\n orderHistoryUrl?: string,\n /** PayPal JS SDK client id — enables the express PayPal button. */\n paypalClientId?: string,\n};\n\nconst Checkout = ({\n homeUrl = '/',\n orderHistoryUrl,\n paypalClientId,\n ...props\n}: CheckoutProps) => {\n const { formatMessage } = useIntl();\n const alacarte = useAlacarteCheckout({\n apiUrl: props.apiUrl,\n edxSessionUrl: props.edxSessionUrl,\n skipSubscriptionCourseRuns: props.skipSubscriptionCourseRuns,\n });\n const c = useCheckout(props);\n const [promoCodeValue, setPromoCodeValue] = useState('');\n const [dismissedCouponAlert, setDismissedCouponAlert] = useState<string | null>(null);\n // 0 hides the validation alert; each failed Pay now bumps it, which moves\n // focus to the alert.\n const [validationRequest, setValidationRequest] = useState(0);\n const [dismissedPriceChange, setDismissedPriceChange] = useState(false);\n // Last code we successfully priced — drives the \"Save {percent}% with code\n // {code}\" hint on the empty field while a coupon is not yet applied.\n const [advertisedOffer, setAdvertisedOffer] = useState<{ code: string, percent: number } | null>(null);\n const isAlacarteReady = (alacarte.phase === 'ready' || alacarte.phase === 'alreadyOwned') && !!alacarte.checkout;\n const appliedCouponCode = alacarte.checkout?.couponCode?.trim()\n ? alacarte.checkout.couponCode.trim()\n : null;\n const discountPercent = appliedDiscountPercent(alacarte.line);\n // Only treat the line discount as a removable coupon when the backend says\n // so (or a coupon code is present). Automatic offers show only in CartSummary's\n // discount row and must not drive PromoCode's applied/remove UI.\n const isCouponDiscount = !!alacarte.line?.discount\n && alacarte.line.discountSource !== 'automatic'\n && (alacarte.line.discountSource === 'coupon' || !!appliedCouponCode);\n const appliedDiscount = isCouponDiscount && discountPercent != null\n ? {\n percent: discountPercent,\n amount: alacarte.line!.discount!.amount,\n currency: alacarte.line!.discount!.currency,\n }\n : null;\n\n // Keep the coupon field in sync when a code is applied via URL or API.\n // Don't overwrite the field with empty when only an automatic offer applies.\n useEffect(() => {\n if (alacarte.checkout?.couponCode) {\n setPromoCodeValue(alacarte.checkout.couponCode);\n }\n }, [alacarte.checkout?.couponCode]);\n\n useEffect(() => {\n if (appliedCouponCode && isCouponDiscount && discountPercent != null) {\n setAdvertisedOffer({ code: appliedCouponCode, percent: discountPercent });\n }\n }, [appliedCouponCode, isCouponDiscount, discountPercent]);\n\n // A coupon alert closed with focus inside it: go back to the coupon control\n // (Remove when a coupon is applied, otherwise the field).\n const focusCouponControl = useCallback(() => {\n (document.getElementById('promoCodeRemove') ?? document.getElementById('promoCode'))?.focus();\n }, []);\n\n // No query params and no active cart — nothing to check out, send the\n // learner home rather than showing a placeholder.\n useEffect(() => {\n if (REDIRECT_ON_NO_ACTIVE_CHECKOUT && alacarte.phase === 'noActiveCheckout') {\n window.location.href = homeUrl;\n }\n }, [alacarte.phase, homeUrl]);\n\n // Express checkout (Apple Pay / Google Pay): runs the full place-order flow\n // using a wallet-provided PaymentMethod id instead of the mounted card element.\n const handleExpressPayment = useCallback(async (paymentMethodId: string, walletCountry?: string) => {\n if (!c.stripe) throw new Error('Stripe not loaded');\n const stripeInstance = c.stripe;\n const country = (c.billing.country || walletCountry || c.userCountry || '').trim().toUpperCase();\n if (!country) {\n throw new Error('Please select a country before using Apple Pay or Google Pay.');\n }\n\n await alacarte.placeOrderAsync({\n billing: {\n ...c.billing,\n country,\n },\n confirmCardPayment: async (clientSecret: string) => {\n await confirmPaymentWithMethodId({\n stripe: stripeInstance,\n clientSecret,\n paymentMethodId,\n });\n },\n });\n }, [alacarte, c.billing, c.userCountry, c.stripe]);\n\n // Express checkout (PayPal): tCheckoutPlaceOrder(PAYPAL) when the PayPal\n // button is clicked; approve/cancel go straight to the à la carte hook.\n // The card form isn't validated — PayPal collects the payer's details.\n const handlePaypalCreateOrder = useCallback(() => alacarte.startPaypalOrder({\n billing: {\n ...c.billing,\n country: c.billing.country || c.userCountry || '',\n },\n }), [alacarte, c.billing, c.userCountry]);\n\n const showProcessing\n = c.returningFromStripe\n && c.processingSubscription\n && c.phase !== 'success'\n && c.phase !== 'blocked'\n && c.phase !== 'failed';\n const showForm\n = !showProcessing\n && (c.phase === 'init'\n || c.phase === 'ready'\n || c.phase === 'failed'\n || c.phase === 'processing');\n const failedMessage = getLearnerFacingCheckoutMessage(c.lastComment);\n\n const { displayStart, displayEnd } = getTrialDateRange();\n\n // const isBillingCountryBlocked = GATE_CHECK_COUNTRY\n // && !!c.billing.country\n // && !ALLOWED_CHECKOUT_COUNTRIES.includes(c.billing.country);\n\n const selectedCycle: BillingCycle = c.selectedCycle;\n\n // Prefer the à la carte course's own detail (skills/badge/image, richer than\n // the subscription flow's ?course_run_key= lookup) when we selected a course.\n // When already-owned the line may be null, so fall back to the selector kind.\n const isCourseProduct = alacarte.line?.kind === 'course' || alacarte.selector?.kind === 'course';\n const isProgramProduct = alacarte.line?.kind === 'program' || alacarte.selector?.kind === 'program';\n\n const alacarteCourseDetail: CourseDetail | null\n = isCourseProduct && alacarte.productDetail && 'maId' in alacarte.productDetail\n ? alacarte.productDetail\n : null;\n const courseForSummary = alacarteCourseDetail ?? c.course;\n\n const alacarteProgramDetail: ProgramDetail | null\n = isProgramProduct && alacarte.productDetail && 'tCourses' in alacarte.productDetail\n ? alacarte.productDetail\n : null;\n\n const handleStartCourse = () => {\n const alacarteCourseUrl = alacarteCourseDetail?.tUrlCourse\n || (alacarte.productDetail && 'tUrlCourse' in alacarte.productDetail\n ? alacarte.productDetail.tUrlCourse\n : null);\n if (alacarteCourseUrl) {\n window.location.href = alacarteCourseUrl;\n } else if (c.course?.tUrlCourse) {\n window.location.href = c.course.tUrlCourse;\n } else {\n window.location.href = homeUrl || '/';\n }\n };\n\n const courseLabel = c.course\n ? [c.course.tBrandText, c.course.maName].filter(Boolean).join(': ')\n : null;\n\n const isAlreadyOwned = alacarte.isAlreadyOwned;\n const { paymentTimedOut } = alacarte;\n // Grey out and block the form + summary; only the alerts above stay usable.\n const isLocked = isAlreadyOwned || paymentTimedOut;\n // The overlay only blocks the pointer — inert takes the locked content out\n // of the tab order too.\n const lockedInertRef = useInert<HTMLDivElement>(isLocked);\n\n // Live while shown, so the links drop off as the learner fixes each field.\n const invalidPaymentFields = validationRequest > 0\n ? getInvalidPaymentFields(c.cardFieldStates, c.billing)\n : [];\n const handleValidationResult = (invalidFields: PaymentFieldKey[]) => {\n setValidationRequest((n) => (invalidFields.length > 0 ? n + 1 : 0));\n };\n const focusPaymentField = (field: PaymentFieldKey) => {\n if (isCardFieldKey(field)) {\n c.focusCardField(field);\n } else {\n // Billing controls use the field key as their id (Form.Group controlId).\n document.getElementById(field)?.focus();\n }\n };\n\n if (showProcessing) {\n return <ProcessingScreen />;\n }\n\n // TEMPORARY — flip to true to dump à la carte hook state while validating\n // against the real backend. Remove AlacarteDebugPanel once the flow is solid.\n const SHOW_ALACARTE_DEBUG = false;\n const alacarteDebug = SHOW_ALACARTE_DEBUG\n ? <AlacarteDebugPanel data={alacarte} />\n : null;\n\n // Confirmation: show once the order is ready (or failed to load). While\n // tPlacedOrder is still polling, keep the checkout form so Pay now can show\n // \"Processing...\" instead of a full-page loader.\n if (alacarte.placedOrder || alacarte.placedOrderError) {\n const confirmationTitle = alacarte.line?.kind === 'program'\n ? alacarte.line.programName\n : alacarte.line?.kind === 'course'\n ? alacarte.line.courseName\n : null;\n\n return (\n <>\n {alacarteDebug}\n <Row className=\"checkout__container alacarte-confirmation__container bg-light-200\">\n <Col xs={12}>\n <AlacarteConfirmation\n order={alacarte.placedOrder}\n awaiting={false}\n error={alacarte.placedOrderError}\n onContinue={handleStartCourse}\n productDetail={alacarte.productDetail}\n productTitle={confirmationTitle}\n ownedCourses={\n alacarte.line?.kind === 'program'\n ? (alacarte.line.ownedCourses ?? null)\n : null\n }\n orderHistoryUrl={orderHistoryUrl ?? null}\n placedAt={alacarte.placedOrderPlacedAt}\n />\n </Col>\n </Row>\n </>\n );\n }\n\n if (alacarte.phase === 'loading') {\n return (\n <>\n {alacarteDebug}\n <ProcessingScreen />\n </>\n );\n }\n if (alacarte.phase === 'noActiveCheckout' && REDIRECT_ON_NO_ACTIVE_CHECKOUT) {\n // Redirects home via the effect above — show a spinner rather than a\n // notice while that happens.\n return (\n <>\n {alacarteDebug}\n <ProcessingScreen />\n </>\n );\n }\n if (alacarte.phase === 'noActiveCheckout') {\n return (\n <>\n {alacarteDebug}\n <AlacarteNotice messageId={alacarte.noticeMessageId!} />\n </>\n );\n }\n // Product unavailable / not found / not purchasable — banner only, no checkout form.\n if (alacarte.phase === 'notPurchasable' || alacarte.phase === 'error') {\n return (\n <>\n {alacarteDebug}\n <Row className=\"checkout__container bg-light-200\">\n <Col xs={12}>\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n data-testid=\"alacarte-error-banner\"\n >\n {alacarte.error || 'Something went wrong with checkout.'}\n </Alert>\n </Col>\n </Row>\n </>\n );\n }\n\n // Price differs from what the learner viewed before checkout (ALC-159).\n const showPriceChangedAlert = !!alacarte.priceChanged && !dismissedPriceChange && !isLocked;\n const priceChangedKind = isProgramProduct ? 'program' : 'course';\n\n return (\n <>\n {alacarteDebug}\n <Row className=\"checkout__container bg-light-200\">\n {/* <CountryUnavailableModal\n isOpen={isBillingCountryBlocked}\n homeUrl={homeUrl}\n /> */}\n {alacarte.sanctionsBlocked && (\n <OrderBlockedModal\n isOpen\n referenceCode={alacarte.sanctionsBlocked.referenceCode}\n homeUrl={homeUrl}\n />\n )}\n <Col xs={12} className={isLocked ? 'checkout__locked-overlay' : ''}>\n {/* DOM order is the tab order on every breakpoint: alerts, then the\n summary and coupon, then payment. From lg up, the grid in\n checkout.scss moves the summary to the right column. */}\n <Row className=\"checkout__layout\">\n <Col xs={12} className=\"checkout__header\">\n <div>\n <h1 className=\"font-weight-bold text-primary-900 mb-lg-4\">\n Checkout\n </h1>\n\n {paymentTimedOut && (\n <PaymentTimeoutAlert className=\"checkout__overlay-alert mb-3\" />\n )}\n\n {isAlreadyOwned && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n className=\"checkout__overlay-alert mb-3\"\n data-testid=\"already-owned-alert\"\n >\n <p className=\"mb-3\">\n {formatMessage(\n alacarte.selector?.kind === 'program'\n ? messages.alreadyPaidProgram\n : messages.alreadyPaidCourse,\n )}\n </p>\n <div className=\"d-flex align-items-center justify-content-end gap-3 flex-wrap\">\n {orderHistoryUrl && (\n <a href={orderHistoryUrl} className=\"checkout__order-history text-gray-900 font-weight-bold\">\n {formatMessage(messages.viewOrderHistory)}\n </a>\n )}\n <Button variant=\"brand\" className=\"rounded-pill\" onClick={handleStartCourse}>\n {formatMessage(messages.goToCourse)}\n </Button>\n </div>\n </Alert>\n )}\n\n {c.error && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n dismissible\n onClose={c.clearError}\n >\n {c.error}\n </Alert>\n )}\n\n {alacarte.placeOrderError && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n dismissible\n onClose={alacarte.clearPlaceOrderError}\n className=\"mb-3\"\n >\n {alacarte.placeOrderError}\n </Alert>\n )}\n\n {alacarte.paymentDecline?.message && !alacarte.placeOrderError && !paymentTimedOut && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n className=\"mb-3\"\n data-testid=\"payment-decline-alert\"\n >\n {getLearnerFacingStripeMessage({\n message: alacarte.paymentDecline.message,\n code: alacarte.paymentDecline.code ?? undefined,\n })}\n </Alert>\n )}\n {/* paymentInterrupted alert shown when payment is interrupted but not declined, no place order error, and payment has not timed out */}\n {alacarte.paymentInterrupted && !alacarte.paymentDecline && !alacarte.placeOrderError && !paymentTimedOut && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n dismissible\n onClose={alacarte.clearPaymentInterrupted}\n className=\"mb-3\"\n data-testid=\"payment-interrupted-alert\"\n >\n {formatMessage(messages.paymentInterruptedAlert)}\n </Alert>\n )}\n {/* walletPaymentCancelled alert shown when the Apple Pay / Google Pay sheet is closed without paying */}\n {alacarte.walletPaymentCancelled && !alacarte.paymentInterrupted\n && !alacarte.paymentDecline && !alacarte.placeOrderError && !paymentTimedOut && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n dismissible\n onClose={alacarte.clearWalletPaymentCancelled}\n className=\"mb-3\"\n data-testid=\"wallet-payment-cancelled-alert\"\n >\n {formatMessage(messages.walletPaymentCancelledAlert)}\n </Alert>\n )}\n\n {alacarte.couponError && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n dismissible\n onClose={alacarte.clearCouponError}\n className=\"mb-3\"\n data-testid=\"coupon-error-alert\"\n >\n {alacarte.couponError}\n </Alert>\n )}\n\n {showPriceChangedAlert && (\n <PriceChangedAlert\n kind={priceChangedKind}\n onDismiss={() => setDismissedPriceChange(true)}\n className=\"mb-3\"\n />\n )}\n\n {!alacarte.priceAccepted && !alacarte.priceChanged && isAlacarteReady && alacarte.line?.amountDue && (\n <Alert variant=\"info\" className=\"mb-3\" data-testid=\"price-accept-notice\">\n {formatMessage(messages.priceChangedNotice, {\n amount: alacarte.line.amountDue.amount.toFixed(2),\n currency: alacarte.line.amountDue.currency,\n })}\n </Alert>\n )}\n\n {showForm && (\n <>\n <PaymentValidationAlert\n fields={invalidPaymentFields}\n country={c.billing.country}\n focusRequest={validationRequest}\n onFieldSelect={focusPaymentField}\n className=\"mb-3\"\n />\n {c.phase === 'failed' && (\n <Alert variant=\"danger\" icon={ErrorIcon} className=\"mb-3\">\n {failedMessage\n || formatMessage(messages.paymentProcessingDescription)}\n </Alert>\n )}\n {appliedCouponCode && appliedDiscount && dismissedCouponAlert !== appliedCouponCode && (\n <AutoDismissAlert\n key={appliedCouponCode}\n variant=\"success\"\n icon={CheckCircle}\n dismissible\n closeLabel={formatMessage(messages.dismiss)}\n onClose={() => setDismissedCouponAlert(appliedCouponCode)}\n className=\"coupon-applied-alert\"\n data-testid=\"coupon-applied-alert\"\n role=\"status\"\n // Mounts from the coupon request's onSuccess, before\n // couponApplying settles — so only the learner's own\n // Apply takes focus here (not a coupon applied on load),\n // and screen readers read the alert, not Remove.\n focusOnMount={alacarte.couponApplying}\n returnFocus={focusCouponControl}\n >\n <span aria-hidden=\"true\">🎉 </span>\n {formatMessage(messages.couponAppliedAlert, {\n code: appliedCouponCode,\n percent: appliedDiscount.percent,\n })}\n </AutoDismissAlert>\n )}\n {alacarte.removedCouponCode && (() => {\n const removedCode = alacarte.removedCouponCode;\n const removedText = formatMessage(\n messages.couponRemovedAlert,\n { code: removedCode },\n );\n // Bold the interpolated code without baking markup into the\n // translation string — find it in the formatted sentence.\n const codeIndex = removedText.indexOf(removedCode);\n return (\n <AutoDismissAlert\n key={removedCode}\n variant=\"success\"\n icon={CheckCircle}\n dismissible\n closeLabel={formatMessage(messages.dismiss)}\n onClose={alacarte.clearRemovedCouponCode}\n className=\"coupon-removed-alert\"\n data-testid=\"coupon-removed-alert\"\n role=\"status\"\n focusOnMount={alacarte.couponApplying}\n returnFocus={focusCouponControl}\n >\n {codeIndex === -1 ? removedText : (\n <>\n {removedText.slice(0, codeIndex)}\n <strong>{removedCode}</strong>\n {removedText.slice(codeIndex + removedCode.length)}\n </>\n )}\n </AutoDismissAlert>\n );\n })()}\n </>\n )}\n </div>\n </Col>\n\n {/* ── Summary — swaps to EnrollmentSummary on success ── */}\n <Col xs={12} className=\"payment__summary\">\n <div ref={lockedInertRef} data-testid=\"checkout-summary-region\">\n {c.phase === 'success' ? (\n <EnrollmentSummary\n course={c.course}\n onStartCourse={handleStartCourse}\n />\n ) : (\n <CartSummary\n defaultCycle={selectedCycle}\n onCycleChange={c.processingSubscription ? undefined : c.setCycle}\n course={courseForSummary}\n alacarteLine={alacarte.line}\n programDetail={alacarteProgramDetail}\n programName={alacarte.ownedProductName}\n promoCode={isAlacarteReady ? {\n value: promoCodeValue,\n // Keep a coupon error up while the learner edits the code;\n // applyCoupon clears it on the next Apply.\n onChange: setPromoCodeValue,\n onApply: () => alacarte.applyCoupon(promoCodeValue),\n onRemove: () => {\n alacarte.removeCoupon();\n setPromoCodeValue('');\n setAdvertisedOffer(null);\n // The applied alert auto-dismisses, so re-applying the\n // same code must be able to show it again.\n setDismissedCouponAlert(null);\n },\n appliedCode: appliedCouponCode,\n discount: appliedDiscount,\n offer: !appliedCouponCode ? advertisedOffer : null,\n error: alacarte.couponError,\n isApplying: alacarte.couponApplying,\n disabled: alacarte.placingOrder,\n } : null}\n />\n )}\n </div>\n </Col>\n\n {/* ── Payment ── */}\n <Col xs={12} className=\"payment__options\">\n <div ref={lockedInertRef} data-testid=\"checkout-payment-region\">\n {showForm && (\n <PaymentForm\n billing={c.billing}\n setField={c.setField}\n numberMountRef={c.numberMountRef}\n expiryMountRef={c.expiryMountRef}\n cvcMountRef={c.cvcMountRef}\n cardError={c.cardError}\n cardFieldStates={c.cardFieldStates}\n stripeReady={c.stripeReady}\n sessionReady={c.sessionReady}\n submitting={\n isAlacarteReady\n ? (alacarte.placingOrder || alacarte.awaitingPlacedOrder)\n : c.processingSubscription\n }\n onPlaceOrder={\n isAlacarteReady\n ? () => {\n alacarte.placeOrder({\n billing: {\n ...c.billing,\n // Country is required on tCheckoutPlaceOrder (two-letter ISO).\n // Prefer the form selection; fall back to gate geolocation.\n country: c.billing.country || c.userCountry || '',\n },\n confirmCardPayment: c.confirmCardPayment,\n });\n }\n : c.placeOrder\n }\n onValidationError={handleValidationResult}\n trialEnd={selectedCycle === 'monthly' ? displayEnd : undefined}\n priceToShow={null}\n cycleToShow={selectedCycle === 'monthly' ? 'monthly' : 'annual'}\n userCountry={c.userCountry}\n geolocationUrl={props.geolocationUrl}\n alacarteLine={alacarte.line}\n stripe={c.stripe}\n expressCountry={c.billing.country || c.userCountry || 'US'}\n onExpressPayment={isAlacarteReady ? handleExpressPayment : undefined}\n onExpressClick={isAlacarteReady ? alacarte.clearPaymentAlerts : undefined}\n onExpressCancel={isAlacarteReady ? alacarte.markWalletPaymentCancelled : undefined}\n paypalClientId={paypalClientId}\n onPaypalCreateOrder={isAlacarteReady ? handlePaypalCreateOrder : undefined}\n onPaypalApprove={isAlacarteReady ? alacarte.approvePaypalOrder : undefined}\n onPaypalCancel={isAlacarteReady ? alacarte.cancelPaypalOrder : undefined}\n />\n )}\n\n {c.phase === 'success' && (\n <SuccessScreen\n subscriptionBiId={c.subscriptionDetails?.biId || ''}\n cardLast4={c.subscriptionDetails?.cardLast4 || ''}\n purchaseDate={displayStart}\n courseLabel={courseLabel}\n onFindCourse={handleStartCourse}\n />\n )}\n\n {c.phase === 'blocked' && (\n <BlockedScreen detail={c.lastComment} />\n )}\n </div>\n </Col>\n </Row>\n </Col>\n </Row>\n </>\n );\n};\n\nexport default Checkout;\n"]}
|
|
@@ -394,7 +394,7 @@ const ExpressCheckout = ({ stripe, totalAmountCents, currency, onPaymentAuthoriz
|
|
|
394
394
|
return `${base} express-checkout__wallet--unavailable`;
|
|
395
395
|
return base;
|
|
396
396
|
};
|
|
397
|
-
return (_jsxs("div", { className: `express-checkout${showSkeleton ? ' express-checkout--loading' : ''}`, role: "group", "aria-labelledby": "express-checkout-heading", "aria-busy": showSkeleton, children: [_jsx("h3", { id: "express-checkout-heading", className: "express-checkout__heading", children: formatMessage(messages.heading) }), _jsxs("div", { className:
|
|
397
|
+
return (_jsxs("div", { className: `express-checkout${showSkeleton ? ' express-checkout--loading' : ''}`, role: "group", "aria-labelledby": "express-checkout-heading", "aria-busy": showSkeleton, children: [_jsx("h3", { id: "express-checkout-heading", className: "express-checkout__heading", children: formatMessage(messages.heading) }), _jsxs("div", { className: `express-checkout__buttons express-checkout__buttons--cols-${columnCount}`, style: { gridTemplateColumns: `repeat(${columnCount}, minmax(0, 1fr))` }, children: [_jsxs("div", { ref: paypalSlotRef, className: `express-checkout__paypal${paypalDisabled ? ' express-checkout__slot--disabled' : ''}`, children: [_jsx("div", { ref: paypalMountRef, className: paypalRendered ? undefined : 'express-checkout__paypal-mount--pending', "data-testid": "paypal-slot" }), !paypalRendered && (_jsx("button", { type: "button", disabled: true, "aria-label": formatMessage(messages.paypal), className: "express-checkout__button express-checkout__button--paypal", children: _jsx(PayPalWordmark, {}) }))] }), _jsx("div", { ref: appleMountRef, className: walletClassName(appleReady, appleVisible), "aria-hidden": appleReady && !appleVisible, "data-testid": "apple-pay-slot" }), _jsx("div", { ref: googleMountRef, className: walletClassName(googleReady, googleVisible), "aria-hidden": googleReady && !googleVisible, "data-testid": "google-pay-slot" })] }), walletError && (_jsx("p", { className: "express-checkout__error", role: "alert", children: walletError })), showSkeleton && (_jsx(Skeleton, { containerClassName: "express-checkout__skeleton", height: "100%", borderRadius: 8, inline: true }))] }));
|
|
398
398
|
};
|
|
399
399
|
export default ExpressCheckout;
|
|
400
400
|
//# sourceMappingURL=ExpressCheckout.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ExpressCheckout.js","sourceRoot":"","sources":["../../../src/components/ExpressCheckout/ExpressCheckout.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAU5C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAqClC,uFAAuF;AACvF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AAErC;;;;;;;GAOG;AACH,MAAM,eAAe,GAAmC,CAAC,EACvD,MAAM,EACN,gBAAgB,EAChB,QAAQ,EACR,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,QAAQ,EACR,cAAc,GACf,EAAE,EAAE;IACH,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpC,MAAM,aAAa,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IAC1D,MAAM,cAAc,GAAG,MAAM,CAAwB,IAAI,CAAC,CAAC;IAC3D,MAAM,gBAAgB,GAAG,MAAM,CAA4B,IAAI,CAAC,CAAC;IACjE,MAAM,iBAAiB,GAAG,MAAM,CAA4B,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AAI,EAAC,OAAO,YAChD,WAAW,GACV,CACL,EAEA,YAAY,IAAI,CACf,KAAC,QAAQ,IAAC,kBAAkB,EAAC,4BAA4B,EAAC,MAAM,EAAC,MAAM,EAAC,YAAY,EAAE,CAAC,EAAE,MAAM,SAAG,CACnG,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { useIntl } from '@openedx/frontend-base';\nimport { Skeleton } from '@openedx/paragon';\nimport type {\n ExpressCheckoutAvailablePaymentMethodsChangeEvent,\n ExpressCheckoutClickEvent,\n ExpressCheckoutConfirmEvent,\n ExpressCheckoutReadyEvent,\n StripeElementsLike,\n StripeElementLike,\n StripeLike,\n} from '../../types';\nimport { PayPalWordmark } from '../BrandMarks/BrandMarks';\nimport { useInert } from '../../utils/inert';\nimport { loadPaypal } from '../../utils/paypal';\nimport messages from './Messages';\n\nexport interface ExpressCheckoutProps {\n /** Stripe.js instance — null until loaded. */\n stripe: StripeLike | null,\n /** Total amount in the smallest currency unit (cents). */\n totalAmountCents: number | null,\n /** ISO 4217 currency code, e.g. 'USD'. */\n currency: string | null,\n /** Two-letter country code (kept for API stability). */\n country: string,\n /**\n * Called when the user authorises a wallet payment (Apple Pay / Google Pay).\n * Receives the Stripe PaymentMethod id and the billing country from the wallet.\n * Must resolve on success or reject on failure.\n */\n onPaymentAuthorized: (paymentMethodId: string, walletCountry?: string) => Promise<void>,\n /** Called when the learner clicks Apple Pay / Google Pay, before the sheet opens. */\n onWalletClick?: () => void,\n /** Called when the learner closes the Apple Pay / Google Pay sheet without paying. */\n onWalletCancel?: () => void,\n /** PayPal JS SDK client id — PayPal stays disabled without it. */\n paypalClientId?: string | null,\n /** PayPal `createOrder`: places the order with PayPal and resolves its id. */\n onPaypalCreateOrder?: () => Promise<string>,\n /** PayPal `onApprove`: captures the approved PayPal order. */\n onPaypalApprove?: (paypalOrderId: string) => Promise<void>,\n /** PayPal `onCancel` / `onError`: abandons the unapproved PayPal order. */\n onPaypalCancel?: (paypalOrderId: string) => Promise<void>,\n /** Disables the Apple Pay / Google Pay slots. */\n disabled?: boolean,\n /** Disables the PayPal slot — PayPal doesn't need Stripe, so it has its own flag. */\n paypalDisabled?: boolean,\n}\n\ntype WalletSlot = 'apple' | 'google';\n\n// Shows the block anyway if an SDK never settles (blocked script, Stripe never loads).\nexport const SKELETON_MAX_MS = 10000;\n\n/**\n * Express checkout: PayPal (local) | Apple Pay | Google Pay.\n *\n * Apple and Google each get their own Express Checkout Element (one wallet per\n * mount) so we can lay them out in equal columns. A single ECE with both wallets\n * stacks / overflows in this narrow column. `always` keeps the Shopify-like\n * show-even-without-a-saved-card behaviour.\n */\nconst ExpressCheckout: React.FC<ExpressCheckoutProps> = ({\n stripe,\n totalAmountCents,\n currency,\n onPaymentAuthorized,\n onWalletClick,\n onWalletCancel,\n paypalClientId,\n onPaypalCreateOrder,\n onPaypalApprove,\n onPaypalCancel,\n disabled,\n paypalDisabled,\n}) => {\n const { formatMessage } = useIntl();\n const appleMountRef = useRef<HTMLDivElement | null>(null);\n const googleMountRef = useRef<HTMLDivElement | null>(null);\n const appleElementsRef = useRef<StripeElementsLike | null>(null);\n const googleElementsRef = useRef<StripeElementsLike | null>(null);\n const appleElementRef = useRef<StripeElementLike | null>(null);\n const googleElementRef = useRef<StripeElementLike | null>(null);\n const onPaymentAuthorizedRef = useRef(onPaymentAuthorized);\n const onWalletClickRef = useRef(onWalletClick);\n const onWalletCancelRef = useRef(onWalletCancel);\n const paypalMountRef = useRef<HTMLDivElement | null>(null);\n // The disabled class only blocks the pointer — inert drops the slot's\n // iframe from the tab order too.\n const paypalSlotRef = useInert<HTMLDivElement>(!!paypalDisabled);\n const paypalHandlersRef = useRef({ onPaypalCreateOrder, onPaypalApprove, onPaypalCancel });\n // PayPal order created but not yet approved — cancelled if the buttons error out.\n const openPaypalOrderRef = useRef<string | null>(null);\n\n const [appleReady, setAppleReady] = useState(false);\n const [googleReady, setGoogleReady] = useState(false);\n const [appleVisible, setAppleVisible] = useState(false);\n const [googleVisible, setGoogleVisible] = useState(false);\n const [walletError, setWalletError] = useState<string | null>(null);\n const [paypalRendered, setPaypalRendered] = useState(false);\n // PayPal finished: rendered, ineligible, failed, or never possible (no client id).\n const [paypalSettled, setPaypalSettled] = useState(false);\n // Latched so later remounts (currency / amount change) don't bring the skeleton back.\n const [loaded, setLoaded] = useState(false);\n\n // Stripe wallets require a positive charge. Use an explicit > 0 check —\n // `!!totalAmountCents` treats a $0 (free) total as \"no amount\" and would\n // also break remounts after a coupon brings the total to zero.\n const canCharge = totalAmountCents != null && totalAmountCents > 0 && !!currency;\n const paypalEnabled = !!paypalClientId && canCharge && !!onPaypalCreateOrder && !!onPaypalApprove;\n // Keep slots in the grid until ready so Stripe measures a full column width.\n const showAppleSlot = !appleReady || appleVisible;\n const showGoogleSlot = !googleReady || googleVisible;\n const columnCount = 1 + (showAppleSlot ? 1 : 0) + (showGoogleSlot ? 1 : 0);\n const allSettled = paypalSettled && appleReady && googleReady;\n const showSkeleton = !loaded && !allSettled;\n\n useEffect(() => {\n if (allSettled) setLoaded(true);\n }, [allSettled]);\n\n useEffect(() => {\n const timer = setTimeout(() => setLoaded(true), SKELETON_MAX_MS);\n return () => clearTimeout(timer);\n }, []);\n\n useEffect(() => {\n onPaymentAuthorizedRef.current = onPaymentAuthorized;\n }, [onPaymentAuthorized]);\n\n useEffect(() => {\n onWalletClickRef.current = onWalletClick;\n }, [onWalletClick]);\n\n useEffect(() => {\n onWalletCancelRef.current = onWalletCancel;\n }, [onWalletCancel]);\n\n // Wallet hosts keep object refs for remounts, so toggle inert here instead.\n useEffect(() => {\n appleMountRef.current?.toggleAttribute('inert', !!disabled);\n googleMountRef.current?.toggleAttribute('inert', !!disabled);\n }, [disabled]);\n\n useEffect(() => {\n paypalHandlersRef.current = { onPaypalCreateOrder, onPaypalApprove, onPaypalCancel };\n }, [onPaypalCreateOrder, onPaypalApprove, onPaypalCancel]);\n\n // PayPal buttons: tCheckoutPlaceOrder(PAYPAL) on click, capture on approve,\n // cancel when the learner closes the PayPal window.\n useEffect(() => {\n const mountNode = paypalMountRef.current;\n if (!paypalEnabled || !paypalClientId || !currency || !mountNode) {\n console.log('[ExpressCheckout] PayPal disabled', {\n hasClientId: !!paypalClientId,\n canCharge,\n hasCreateOrder: !!onPaypalCreateOrder,\n hasApprove: !!onPaypalApprove,\n });\n setPaypalRendered(false);\n // Without a client id PayPal can never render — don't wait for it.\n // Same for a $0 total: express PayPal is not applicable.\n setPaypalSettled(!paypalClientId || !canCharge);\n return undefined;\n }\n\n let cancelled = false;\n const cancelOpenOrder = async () => {\n const orderId = openPaypalOrderRef.current;\n openPaypalOrderRef.current = null;\n if (orderId) await paypalHandlersRef.current.onPaypalCancel?.(orderId);\n };\n\n loadPaypal(paypalClientId, currency)\n .then(async (paypal) => {\n if (cancelled) return;\n const buttons = paypal.Buttons({\n fundingSource: paypal.FUNDING.PAYPAL,\n style: {\n layout: 'horizontal',\n color: 'gold',\n shape: 'rect',\n label: 'paypal',\n height: 48,\n // Matches the Stripe wallets' `borderRadius: '12px'` appearance.\n borderRadius: 12,\n tagline: false,\n },\n createOrder: async () => {\n setWalletError(null);\n const orderId = await paypalHandlersRef.current.onPaypalCreateOrder!();\n openPaypalOrderRef.current = orderId;\n return orderId;\n },\n onApprove: async ({ orderID }) => {\n openPaypalOrderRef.current = null;\n try {\n await paypalHandlersRef.current.onPaypalApprove!(orderID);\n } catch (err) {\n // The checkout page already shows the capture error.\n console.warn('[ExpressCheckout] PayPal capture failed', err);\n }\n },\n onCancel: async () => {\n await cancelOpenOrder();\n },\n onError: (err) => {\n console.warn('[ExpressCheckout] PayPal error', err);\n // createOrder failures are already shown by the checkout page.\n if (openPaypalOrderRef.current) {\n setWalletError(formatMessage(messages.paypalError));\n cancelOpenOrder().catch(() => {});\n }\n },\n });\n if (!buttons.isEligible()) {\n console.warn('[ExpressCheckout] PayPal buttons not eligible', { currency });\n if (!cancelled) setPaypalSettled(true);\n return;\n }\n await buttons.render(mountNode);\n if (!cancelled) {\n setPaypalRendered(true);\n setPaypalSettled(true);\n }\n })\n .catch((err) => {\n console.warn('[ExpressCheckout] PayPal SDK unavailable', err);\n if (!cancelled) {\n setPaypalRendered(false);\n setPaypalSettled(true);\n }\n });\n\n return () => {\n cancelled = true;\n mountNode.innerHTML = '';\n setPaypalRendered(false);\n setPaypalSettled(false);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [paypalEnabled, paypalClientId, currency]);\n\n useEffect(() => {\n if (\n !stripe\n || !canCharge\n || totalAmountCents == null\n || !currency\n || !appleMountRef.current\n || !googleMountRef.current\n ) {\n console.log('[ExpressCheckout] skip mount', {\n hasStripe: !!stripe,\n totalAmountCents,\n currency,\n canCharge,\n hasAppleMount: !!appleMountRef.current,\n hasGoogleMount: !!googleMountRef.current,\n });\n setAppleReady(false);\n setGoogleReady(false);\n setAppleVisible(false);\n setGoogleVisible(false);\n setWalletError(null);\n return undefined;\n }\n\n console.log('[ExpressCheckout] mounting wallet slots', { totalAmountCents, currency });\n setAppleReady(false);\n setGoogleReady(false);\n setAppleVisible(false);\n setGoogleVisible(false);\n\n const sharedElementsOpts = {\n mode: 'payment' as const,\n amount: totalAmountCents,\n currency: currency.toLowerCase(),\n paymentMethodCreation: 'manual' as const,\n appearance: {\n variables: { borderRadius: '12px' },\n },\n };\n\n const bindWallet = (\n slot: WalletSlot,\n elements: StripeElementsLike,\n expressElement: StripeElementLike,\n mountNode: HTMLDivElement,\n setReady: (v: boolean) => void,\n setVisible: (v: boolean) => void,\n ) => {\n // Availability comes from `availablepaymentmethodschange`: it fires on initial\n // render and again if it changes later (iOS checks Apple Pay asynchronously,\n // so a one-shot read on `ready` could hide the button for good).\n let availabilityReported = false;\n expressElement.on(\n 'availablepaymentmethodschange',\n (event: ExpressCheckoutAvailablePaymentMethodsChangeEvent) => {\n const methods = event.paymentMethods;\n const visible = !!(slot === 'apple' ? methods?.applePay : methods?.googlePay)?.available;\n console.log(`[ExpressCheckout] available payment methods (${slot})`, {\n visible,\n raw: methods ?? null,\n });\n availabilityReported = true;\n setVisible(visible);\n setReady(true);\n },\n );\n\n // Fallback for the deprecated `ready` payload, only while the change event\n // hasn't reported. A negative answer here may be stale, so it's ignored.\n expressElement.on('ready', (event: ExpressCheckoutReadyEvent) => {\n const methods = event.availablePaymentMethods;\n const visible = slot === 'apple' ? !!methods?.applePay : !!methods?.googlePay;\n console.log(`[ExpressCheckout] ready (${slot})`, { visible, raw: methods ?? null });\n if (availabilityReported || !visible) return;\n setVisible(true);\n setReady(true);\n });\n\n // A wallet that fails to load counts as unavailable, so it can't hold the skeleton.\n expressElement.on('loaderror', (event: unknown) => {\n console.warn(`[ExpressCheckout] load error (${slot})`, event);\n setVisible(false);\n setReady(true);\n });\n\n // A new wallet attempt is starting — clear the last attempt's errors.\n // Once a click handler is registered Stripe waits for resolve() (1s\n // limit) before opening the sheet, so resolve with the create options.\n expressElement.on('click', (event: ExpressCheckoutClickEvent) => {\n setWalletError(null);\n onWalletClickRef.current?.();\n event.resolve({ emailRequired: true, billingAddressRequired: true });\n });\n\n // The learner dismissed the wallet sheet without paying.\n expressElement.on('cancel', () => {\n onWalletCancelRef.current?.();\n });\n\n expressElement.on('confirm', async (event: ExpressCheckoutConfirmEvent) => {\n setWalletError(null);\n if (!elements.submit) {\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n const walletLabel = formatMessage(\n slot === 'apple' ? messages.applePay : messages.googlePay,\n );\n\n let paymentMethodId: string;\n let walletCountry: string | undefined;\n try {\n const { error: submitError } = await elements.submit();\n if (submitError) {\n setWalletError(submitError.message || formatMessage(messages.walletUnavailable, {\n wallet: walletLabel,\n }));\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n const { paymentMethod, error } = await stripe.createPaymentMethod({ elements });\n if (error || !paymentMethod?.id) {\n setWalletError(error?.message || formatMessage(messages.walletUnavailable, {\n wallet: walletLabel,\n }));\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n paymentMethodId = paymentMethod.id;\n walletCountry = event.billingDetails?.address?.country\n || paymentMethod.billing_details?.address?.country;\n } catch (err) {\n console.warn(`[ExpressCheckout] wallet setup failed (${slot})`, err);\n setWalletError(formatMessage(messages.walletUnavailable, { wallet: walletLabel }));\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n try {\n await onPaymentAuthorizedRef.current(paymentMethodId, walletCountry);\n } catch (err) {\n // The wallet worked; the payment itself failed (e.g. card declined).\n // The checkout page already shows that error, so don't blame the wallet.\n console.warn(`[ExpressCheckout] payment failed (${slot})`, err);\n event.paymentFailed({ reason: 'fail' });\n }\n });\n\n expressElement.mount(mountNode);\n };\n\n const appleElements = stripe.elements(sharedElementsOpts);\n const googleElements = stripe.elements(sharedElementsOpts);\n appleElementsRef.current = appleElements;\n googleElementsRef.current = googleElements;\n\n const appleElement = appleElements.create('expressCheckout', {\n buttonHeight: 48,\n emailRequired: true,\n billingAddressRequired: true,\n paymentMethodOrder: ['applePay'],\n buttonType: { applePay: 'plain' },\n buttonTheme: { applePay: 'black' },\n paymentMethods: {\n applePay: 'always',\n googlePay: 'never',\n link: 'never',\n paypal: 'never',\n amazonPay: 'never',\n klarna: 'never',\n },\n layout: { maxColumns: 1, maxRows: 0, overflow: 'never' },\n });\n appleElementRef.current = appleElement;\n\n const googleElement = googleElements.create('expressCheckout', {\n buttonHeight: 48,\n emailRequired: true,\n billingAddressRequired: true,\n paymentMethodOrder: ['googlePay'],\n buttonType: { googlePay: 'plain' },\n buttonTheme: { googlePay: 'black' },\n paymentMethods: {\n applePay: 'never',\n googlePay: 'always',\n link: 'never',\n paypal: 'never',\n amazonPay: 'never',\n klarna: 'never',\n },\n layout: { maxColumns: 1, maxRows: 0, overflow: 'never' },\n });\n googleElementRef.current = googleElement;\n\n bindWallet(\n 'apple',\n appleElements,\n appleElement,\n appleMountRef.current,\n setAppleReady,\n setAppleVisible,\n );\n bindWallet(\n 'google',\n googleElements,\n googleElement,\n googleMountRef.current,\n setGoogleReady,\n setGoogleVisible,\n );\n\n return () => {\n try {\n appleElement.unmount?.();\n appleElement.destroy?.();\n googleElement.unmount?.();\n googleElement.destroy?.();\n } catch {\n // Elements may already be gone.\n }\n appleElementRef.current = null;\n googleElementRef.current = null;\n appleElementsRef.current = null;\n googleElementsRef.current = null;\n setAppleReady(false);\n setGoogleReady(false);\n setAppleVisible(false);\n setGoogleVisible(false);\n };\n // Remount when the chargeable total changes (e.g. coupon apply). Calling\n // elements.update() alone can leave ECE wallets stuck unavailable after the\n // amount changes; a fresh mount re-runs availability cleanly.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [stripe, currency, totalAmountCents, canCharge]);\n\n const walletClassName = (ready: boolean, visible: boolean) => {\n const base = `express-checkout__wallet${disabled ? ' express-checkout__slot--disabled' : ''}`;\n if (!ready) return `${base} express-checkout__wallet--pending`;\n if (!visible) return `${base} express-checkout__wallet--unavailable`;\n return base;\n };\n\n return (\n <div\n className={`express-checkout${showSkeleton ? ' express-checkout--loading' : ''}`}\n role=\"group\"\n aria-labelledby=\"express-checkout-heading\"\n aria-busy={showSkeleton}\n >\n <h3 id=\"express-checkout-heading\" className=\"express-checkout__heading\">\n {formatMessage(messages.heading)}\n </h3>\n <div\n className=\"express-checkout__buttons\"\n style={{ gridTemplateColumns: `repeat(${columnCount}, minmax(0, 1fr))` }}\n >\n <div\n ref={paypalSlotRef}\n className={`express-checkout__paypal${paypalDisabled ? ' express-checkout__slot--disabled' : ''}`}\n >\n {/* PayPal SDK renders its button here; the wordmark stands in until it does. */}\n <div\n ref={paypalMountRef}\n className={paypalRendered ? undefined : 'express-checkout__paypal-mount--pending'}\n aria-label={formatMessage(messages.paypal)}\n />\n {!paypalRendered && (\n <button\n type=\"button\"\n disabled\n aria-label={formatMessage(messages.paypal)}\n className=\"express-checkout__button express-checkout__button--paypal\"\n >\n <PayPalWordmark />\n </button>\n )}\n </div>\n\n {/* Always in the DOM so remounts can find the nodes; CSS hides unavailable. */}\n <div\n ref={appleMountRef}\n className={walletClassName(appleReady, appleVisible)}\n aria-hidden={appleReady && !appleVisible}\n aria-label={formatMessage(messages.applePay)}\n />\n <div\n ref={googleMountRef}\n className={walletClassName(googleReady, googleVisible)}\n aria-hidden={googleReady && !googleVisible}\n aria-label={formatMessage(messages.googlePay)}\n />\n </div>\n {walletError && (\n <p className=\"express-checkout__error\" role=\"alert\">\n {walletError}\n </p>\n )}\n {/* One skeleton over the whole block; the slots stay mounted underneath so the SDKs can load. */}\n {showSkeleton && (\n <Skeleton containerClassName=\"express-checkout__skeleton\" height=\"100%\" borderRadius={8} inline />\n )}\n </div>\n );\n};\n\nexport default ExpressCheckout;\n"]}
|
|
1
|
+
{"version":3,"file":"ExpressCheckout.js","sourceRoot":"","sources":["../../../src/components/ExpressCheckout/ExpressCheckout.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAU5C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAqClC,uFAAuF;AACvF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AAErC;;;;;;;GAOG;AACH,MAAM,eAAe,GAAmC,CAAC,EACvD,MAAM,EACN,gBAAgB,EAChB,QAAQ,EACR,mBAAmB,EACnB,aAAa,EACb,cAAc,EACd,cAAc,EACd,mBAAmB,EACnB,eAAe,EACf,cAAc,EACd,QAAQ,EACR,cAAc,GACf,EAAE,EAAE;IACH,MAAM,EAAE,aAAa,EAAE,GAAG,OA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,CAAC,WAAW,EAAE,aAAa,CAAC,iBACzC,WAAW,IAAI,CAAC,aAAa,iBAC9B,iBAAiB,GAC7B,IACE,EACL,WAAW,IAAI,CACd,YAAG,SAAS,EAAC,yBAAyB,EAAC,IAAI,EAAC,OAAO,YAChD,WAAW,GACV,CACL,EAEA,YAAY,IAAI,CACf,KAAC,QAAQ,IAAC,kBAAkB,EAAC,4BAA4B,EAAC,MAAM,EAAC,MAAM,EAAC,YAAY,EAAE,CAAC,EAAE,MAAM,SAAG,CACnG,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { useIntl } from '@openedx/frontend-base';\nimport { Skeleton } from '@openedx/paragon';\nimport type {\n ExpressCheckoutAvailablePaymentMethodsChangeEvent,\n ExpressCheckoutClickEvent,\n ExpressCheckoutConfirmEvent,\n ExpressCheckoutReadyEvent,\n StripeElementsLike,\n StripeElementLike,\n StripeLike,\n} from '../../types';\nimport { PayPalWordmark } from '../BrandMarks/BrandMarks';\nimport { useInert } from '../../utils/inert';\nimport { loadPaypal } from '../../utils/paypal';\nimport messages from './Messages';\n\nexport interface ExpressCheckoutProps {\n /** Stripe.js instance — null until loaded. */\n stripe: StripeLike | null,\n /** Total amount in the smallest currency unit (cents). */\n totalAmountCents: number | null,\n /** ISO 4217 currency code, e.g. 'USD'. */\n currency: string | null,\n /** Two-letter country code (kept for API stability). */\n country: string,\n /**\n * Called when the user authorises a wallet payment (Apple Pay / Google Pay).\n * Receives the Stripe PaymentMethod id and the billing country from the wallet.\n * Must resolve on success or reject on failure.\n */\n onPaymentAuthorized: (paymentMethodId: string, walletCountry?: string) => Promise<void>,\n /** Called when the learner clicks Apple Pay / Google Pay, before the sheet opens. */\n onWalletClick?: () => void,\n /** Called when the learner closes the Apple Pay / Google Pay sheet without paying. */\n onWalletCancel?: () => void,\n /** PayPal JS SDK client id — PayPal stays disabled without it. */\n paypalClientId?: string | null,\n /** PayPal `createOrder`: places the order with PayPal and resolves its id. */\n onPaypalCreateOrder?: () => Promise<string>,\n /** PayPal `onApprove`: captures the approved PayPal order. */\n onPaypalApprove?: (paypalOrderId: string) => Promise<void>,\n /** PayPal `onCancel` / `onError`: abandons the unapproved PayPal order. */\n onPaypalCancel?: (paypalOrderId: string) => Promise<void>,\n /** Disables the Apple Pay / Google Pay slots. */\n disabled?: boolean,\n /** Disables the PayPal slot — PayPal doesn't need Stripe, so it has its own flag. */\n paypalDisabled?: boolean,\n}\n\ntype WalletSlot = 'apple' | 'google';\n\n// Shows the block anyway if an SDK never settles (blocked script, Stripe never loads).\nexport const SKELETON_MAX_MS = 10000;\n\n/**\n * Express checkout: PayPal (local) | Apple Pay | Google Pay.\n *\n * Apple and Google each get their own Express Checkout Element (one wallet per\n * mount) so we can lay them out in equal columns. A single ECE with both wallets\n * stacks / overflows in this narrow column. `always` keeps the Shopify-like\n * show-even-without-a-saved-card behaviour.\n */\nconst ExpressCheckout: React.FC<ExpressCheckoutProps> = ({\n stripe,\n totalAmountCents,\n currency,\n onPaymentAuthorized,\n onWalletClick,\n onWalletCancel,\n paypalClientId,\n onPaypalCreateOrder,\n onPaypalApprove,\n onPaypalCancel,\n disabled,\n paypalDisabled,\n}) => {\n const { formatMessage } = useIntl();\n const appleMountRef = useRef<HTMLDivElement | null>(null);\n const googleMountRef = useRef<HTMLDivElement | null>(null);\n const appleElementsRef = useRef<StripeElementsLike | null>(null);\n const googleElementsRef = useRef<StripeElementsLike | null>(null);\n const appleElementRef = useRef<StripeElementLike | null>(null);\n const googleElementRef = useRef<StripeElementLike | null>(null);\n const onPaymentAuthorizedRef = useRef(onPaymentAuthorized);\n const onWalletClickRef = useRef(onWalletClick);\n const onWalletCancelRef = useRef(onWalletCancel);\n const paypalMountRef = useRef<HTMLDivElement | null>(null);\n // The disabled class only blocks the pointer — inert drops the slot's\n // iframe from the tab order too.\n const paypalSlotRef = useInert<HTMLDivElement>(!!paypalDisabled);\n const paypalHandlersRef = useRef({ onPaypalCreateOrder, onPaypalApprove, onPaypalCancel });\n // PayPal order created but not yet approved — cancelled if the buttons error out.\n const openPaypalOrderRef = useRef<string | null>(null);\n\n const [appleReady, setAppleReady] = useState(false);\n const [googleReady, setGoogleReady] = useState(false);\n const [appleVisible, setAppleVisible] = useState(false);\n const [googleVisible, setGoogleVisible] = useState(false);\n const [walletError, setWalletError] = useState<string | null>(null);\n const [paypalRendered, setPaypalRendered] = useState(false);\n // PayPal finished: rendered, ineligible, failed, or never possible (no client id).\n const [paypalSettled, setPaypalSettled] = useState(false);\n // Latched so later remounts (currency / amount change) don't bring the skeleton back.\n const [loaded, setLoaded] = useState(false);\n\n // Stripe wallets require a positive charge. Use an explicit > 0 check —\n // `!!totalAmountCents` treats a $0 (free) total as \"no amount\" and would\n // also break remounts after a coupon brings the total to zero.\n const canCharge = totalAmountCents != null && totalAmountCents > 0 && !!currency;\n const paypalEnabled = !!paypalClientId && canCharge && !!onPaypalCreateOrder && !!onPaypalApprove;\n // Keep slots in the grid until ready so Stripe measures a full column width.\n const showAppleSlot = !appleReady || appleVisible;\n const showGoogleSlot = !googleReady || googleVisible;\n const columnCount = 1 + (showAppleSlot ? 1 : 0) + (showGoogleSlot ? 1 : 0);\n const allSettled = paypalSettled && appleReady && googleReady;\n const showSkeleton = !loaded && !allSettled;\n\n useEffect(() => {\n if (allSettled) setLoaded(true);\n }, [allSettled]);\n\n useEffect(() => {\n const timer = setTimeout(() => setLoaded(true), SKELETON_MAX_MS);\n return () => clearTimeout(timer);\n }, []);\n\n useEffect(() => {\n onPaymentAuthorizedRef.current = onPaymentAuthorized;\n }, [onPaymentAuthorized]);\n\n useEffect(() => {\n onWalletClickRef.current = onWalletClick;\n }, [onWalletClick]);\n\n useEffect(() => {\n onWalletCancelRef.current = onWalletCancel;\n }, [onWalletCancel]);\n\n // Wallet hosts keep object refs for remounts, so toggle inert here instead.\n useEffect(() => {\n appleMountRef.current?.toggleAttribute('inert', !!disabled);\n googleMountRef.current?.toggleAttribute('inert', !!disabled);\n }, [disabled]);\n\n useEffect(() => {\n paypalHandlersRef.current = { onPaypalCreateOrder, onPaypalApprove, onPaypalCancel };\n }, [onPaypalCreateOrder, onPaypalApprove, onPaypalCancel]);\n\n // PayPal buttons: tCheckoutPlaceOrder(PAYPAL) on click, capture on approve,\n // cancel when the learner closes the PayPal window.\n useEffect(() => {\n const mountNode = paypalMountRef.current;\n if (!paypalEnabled || !paypalClientId || !currency || !mountNode) {\n console.log('[ExpressCheckout] PayPal disabled', {\n hasClientId: !!paypalClientId,\n canCharge,\n hasCreateOrder: !!onPaypalCreateOrder,\n hasApprove: !!onPaypalApprove,\n });\n setPaypalRendered(false);\n // Without a client id PayPal can never render — don't wait for it.\n // Same for a $0 total: express PayPal is not applicable.\n setPaypalSettled(!paypalClientId || !canCharge);\n return undefined;\n }\n\n let cancelled = false;\n const cancelOpenOrder = async () => {\n const orderId = openPaypalOrderRef.current;\n openPaypalOrderRef.current = null;\n if (orderId) await paypalHandlersRef.current.onPaypalCancel?.(orderId);\n };\n\n loadPaypal(paypalClientId, currency)\n .then(async (paypal) => {\n if (cancelled) return;\n const buttons = paypal.Buttons({\n fundingSource: paypal.FUNDING.PAYPAL,\n style: {\n layout: 'horizontal',\n color: 'gold',\n shape: 'rect',\n label: 'paypal',\n height: 48,\n // Matches the Stripe wallets' `borderRadius: '12px'` appearance.\n borderRadius: 12,\n tagline: false,\n },\n createOrder: async () => {\n setWalletError(null);\n const orderId = await paypalHandlersRef.current.onPaypalCreateOrder!();\n openPaypalOrderRef.current = orderId;\n return orderId;\n },\n onApprove: async ({ orderID }) => {\n openPaypalOrderRef.current = null;\n try {\n await paypalHandlersRef.current.onPaypalApprove!(orderID);\n } catch (err) {\n // The checkout page already shows the capture error.\n console.warn('[ExpressCheckout] PayPal capture failed', err);\n }\n },\n onCancel: async () => {\n await cancelOpenOrder();\n },\n onError: (err) => {\n console.warn('[ExpressCheckout] PayPal error', err);\n // createOrder failures are already shown by the checkout page.\n if (openPaypalOrderRef.current) {\n setWalletError(formatMessage(messages.paypalError));\n cancelOpenOrder().catch(() => {});\n }\n },\n });\n if (!buttons.isEligible()) {\n console.warn('[ExpressCheckout] PayPal buttons not eligible', { currency });\n if (!cancelled) setPaypalSettled(true);\n return;\n }\n await buttons.render(mountNode);\n if (!cancelled) {\n setPaypalRendered(true);\n setPaypalSettled(true);\n }\n })\n .catch((err) => {\n console.warn('[ExpressCheckout] PayPal SDK unavailable', err);\n if (!cancelled) {\n setPaypalRendered(false);\n setPaypalSettled(true);\n }\n });\n\n return () => {\n cancelled = true;\n mountNode.innerHTML = '';\n setPaypalRendered(false);\n setPaypalSettled(false);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [paypalEnabled, paypalClientId, currency]);\n\n useEffect(() => {\n if (\n !stripe\n || !canCharge\n || totalAmountCents == null\n || !currency\n || !appleMountRef.current\n || !googleMountRef.current\n ) {\n console.log('[ExpressCheckout] skip mount', {\n hasStripe: !!stripe,\n totalAmountCents,\n currency,\n canCharge,\n hasAppleMount: !!appleMountRef.current,\n hasGoogleMount: !!googleMountRef.current,\n });\n setAppleReady(false);\n setGoogleReady(false);\n setAppleVisible(false);\n setGoogleVisible(false);\n setWalletError(null);\n return undefined;\n }\n\n console.log('[ExpressCheckout] mounting wallet slots', { totalAmountCents, currency });\n setAppleReady(false);\n setGoogleReady(false);\n setAppleVisible(false);\n setGoogleVisible(false);\n\n const sharedElementsOpts = {\n mode: 'payment' as const,\n amount: totalAmountCents,\n currency: currency.toLowerCase(),\n paymentMethodCreation: 'manual' as const,\n appearance: {\n variables: { borderRadius: '12px' },\n },\n };\n\n const bindWallet = (\n slot: WalletSlot,\n elements: StripeElementsLike,\n expressElement: StripeElementLike,\n mountNode: HTMLDivElement,\n setReady: (v: boolean) => void,\n setVisible: (v: boolean) => void,\n ) => {\n // Availability comes from `availablepaymentmethodschange`: it fires on initial\n // render and again if it changes later (iOS checks Apple Pay asynchronously,\n // so a one-shot read on `ready` could hide the button for good).\n let availabilityReported = false;\n expressElement.on(\n 'availablepaymentmethodschange',\n (event: ExpressCheckoutAvailablePaymentMethodsChangeEvent) => {\n const methods = event.paymentMethods;\n const visible = !!(slot === 'apple' ? methods?.applePay : methods?.googlePay)?.available;\n console.log(`[ExpressCheckout] available payment methods (${slot})`, {\n visible,\n raw: methods ?? null,\n });\n availabilityReported = true;\n setVisible(visible);\n setReady(true);\n },\n );\n\n // Fallback for the deprecated `ready` payload, only while the change event\n // hasn't reported. A negative answer here may be stale, so it's ignored.\n expressElement.on('ready', (event: ExpressCheckoutReadyEvent) => {\n const methods = event.availablePaymentMethods;\n const visible = slot === 'apple' ? !!methods?.applePay : !!methods?.googlePay;\n console.log(`[ExpressCheckout] ready (${slot})`, { visible, raw: methods ?? null });\n if (availabilityReported || !visible) return;\n setVisible(true);\n setReady(true);\n });\n\n // A wallet that fails to load counts as unavailable, so it can't hold the skeleton.\n expressElement.on('loaderror', (event: unknown) => {\n console.warn(`[ExpressCheckout] load error (${slot})`, event);\n setVisible(false);\n setReady(true);\n });\n\n // A new wallet attempt is starting — clear the last attempt's errors.\n // Once a click handler is registered Stripe waits for resolve() (1s\n // limit) before opening the sheet, so resolve with the create options.\n expressElement.on('click', (event: ExpressCheckoutClickEvent) => {\n setWalletError(null);\n onWalletClickRef.current?.();\n event.resolve({ emailRequired: true, billingAddressRequired: true });\n });\n\n // The learner dismissed the wallet sheet without paying.\n expressElement.on('cancel', () => {\n onWalletCancelRef.current?.();\n });\n\n expressElement.on('confirm', async (event: ExpressCheckoutConfirmEvent) => {\n setWalletError(null);\n if (!elements.submit) {\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n const walletLabel = formatMessage(\n slot === 'apple' ? messages.applePay : messages.googlePay,\n );\n\n let paymentMethodId: string;\n let walletCountry: string | undefined;\n try {\n const { error: submitError } = await elements.submit();\n if (submitError) {\n setWalletError(submitError.message || formatMessage(messages.walletUnavailable, {\n wallet: walletLabel,\n }));\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n const { paymentMethod, error } = await stripe.createPaymentMethod({ elements });\n if (error || !paymentMethod?.id) {\n setWalletError(error?.message || formatMessage(messages.walletUnavailable, {\n wallet: walletLabel,\n }));\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n paymentMethodId = paymentMethod.id;\n walletCountry = event.billingDetails?.address?.country\n || paymentMethod.billing_details?.address?.country;\n } catch (err) {\n console.warn(`[ExpressCheckout] wallet setup failed (${slot})`, err);\n setWalletError(formatMessage(messages.walletUnavailable, { wallet: walletLabel }));\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n try {\n await onPaymentAuthorizedRef.current(paymentMethodId, walletCountry);\n } catch (err) {\n // The wallet worked; the payment itself failed (e.g. card declined).\n // The checkout page already shows that error, so don't blame the wallet.\n console.warn(`[ExpressCheckout] payment failed (${slot})`, err);\n event.paymentFailed({ reason: 'fail' });\n }\n });\n\n expressElement.mount(mountNode);\n };\n\n const appleElements = stripe.elements(sharedElementsOpts);\n const googleElements = stripe.elements(sharedElementsOpts);\n appleElementsRef.current = appleElements;\n googleElementsRef.current = googleElements;\n\n const appleElement = appleElements.create('expressCheckout', {\n buttonHeight: 48,\n emailRequired: true,\n billingAddressRequired: true,\n paymentMethodOrder: ['applePay'],\n buttonType: { applePay: 'plain' },\n buttonTheme: { applePay: 'black' },\n paymentMethods: {\n applePay: 'always',\n googlePay: 'never',\n link: 'never',\n paypal: 'never',\n amazonPay: 'never',\n klarna: 'never',\n },\n layout: { maxColumns: 1, maxRows: 0, overflow: 'never' },\n });\n appleElementRef.current = appleElement;\n\n const googleElement = googleElements.create('expressCheckout', {\n buttonHeight: 48,\n emailRequired: true,\n billingAddressRequired: true,\n paymentMethodOrder: ['googlePay'],\n buttonType: { googlePay: 'plain' },\n buttonTheme: { googlePay: 'black' },\n paymentMethods: {\n applePay: 'never',\n googlePay: 'always',\n link: 'never',\n paypal: 'never',\n amazonPay: 'never',\n klarna: 'never',\n },\n layout: { maxColumns: 1, maxRows: 0, overflow: 'never' },\n });\n googleElementRef.current = googleElement;\n\n bindWallet(\n 'apple',\n appleElements,\n appleElement,\n appleMountRef.current,\n setAppleReady,\n setAppleVisible,\n );\n bindWallet(\n 'google',\n googleElements,\n googleElement,\n googleMountRef.current,\n setGoogleReady,\n setGoogleVisible,\n );\n\n return () => {\n try {\n appleElement.unmount?.();\n appleElement.destroy?.();\n googleElement.unmount?.();\n googleElement.destroy?.();\n } catch {\n // Elements may already be gone.\n }\n appleElementRef.current = null;\n googleElementRef.current = null;\n appleElementsRef.current = null;\n googleElementsRef.current = null;\n setAppleReady(false);\n setGoogleReady(false);\n setAppleVisible(false);\n setGoogleVisible(false);\n };\n // Remount when the chargeable total changes (e.g. coupon apply). Calling\n // elements.update() alone can leave ECE wallets stuck unavailable after the\n // amount changes; a fresh mount re-runs availability cleanly.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [stripe, currency, totalAmountCents, canCharge]);\n\n const walletClassName = (ready: boolean, visible: boolean) => {\n const base = `express-checkout__wallet${disabled ? ' express-checkout__slot--disabled' : ''}`;\n if (!ready) return `${base} express-checkout__wallet--pending`;\n if (!visible) return `${base} express-checkout__wallet--unavailable`;\n return base;\n };\n\n return (\n <div\n className={`express-checkout${showSkeleton ? ' express-checkout--loading' : ''}`}\n role=\"group\"\n aria-labelledby=\"express-checkout-heading\"\n aria-busy={showSkeleton}\n >\n <h3 id=\"express-checkout-heading\" className=\"express-checkout__heading\">\n {formatMessage(messages.heading)}\n </h3>\n <div\n className={`express-checkout__buttons express-checkout__buttons--cols-${columnCount}`}\n style={{ gridTemplateColumns: `repeat(${columnCount}, minmax(0, 1fr))` }}\n >\n <div\n ref={paypalSlotRef}\n className={`express-checkout__paypal${paypalDisabled ? ' express-checkout__slot--disabled' : ''}`}\n >\n {/* PayPal SDK renders its button here; the wordmark stands in until it does. */}\n <div\n ref={paypalMountRef}\n className={paypalRendered ? undefined : 'express-checkout__paypal-mount--pending'}\n data-testid=\"paypal-slot\"\n />\n {!paypalRendered && (\n <button\n type=\"button\"\n disabled\n aria-label={formatMessage(messages.paypal)}\n className=\"express-checkout__button express-checkout__button--paypal\"\n >\n <PayPalWordmark />\n </button>\n )}\n </div>\n\n {/* Always in the DOM so remounts can find the nodes; CSS hides unavailable.\n No aria-label on the slots: a labelled div is exposed as a group, so\n screen readers would announce a group around each wallet's own button. */}\n <div\n ref={appleMountRef}\n className={walletClassName(appleReady, appleVisible)}\n aria-hidden={appleReady && !appleVisible}\n data-testid=\"apple-pay-slot\"\n />\n <div\n ref={googleMountRef}\n className={walletClassName(googleReady, googleVisible)}\n aria-hidden={googleReady && !googleVisible}\n data-testid=\"google-pay-slot\"\n />\n </div>\n {walletError && (\n <p className=\"express-checkout__error\" role=\"alert\">\n {walletError}\n </p>\n )}\n {/* One skeleton over the whole block; the slots stay mounted underneath so the SDKs can load. */}\n {showSkeleton && (\n <Skeleton containerClassName=\"express-checkout__skeleton\" height=\"100%\" borderRadius={8} inline />\n )}\n </div>\n );\n};\n\nexport default ExpressCheckout;\n"]}
|
|
@@ -60,7 +60,7 @@ const PromoCode = ({ value, onChange, onApply, onRemove, appliedCode = null, dis
|
|
|
60
60
|
return (_jsxs("div", { className: "promo-code", ref: rootRef, children: [hasAppliedState && discount ? (_jsx(PromoBanner, { testId: "promo-applied-banner", children: formatMessage(messages.discountAppliedBanner, { percent: discount.percent }) })) : null, appliedCode && !discount ? (_jsx(PromoBanner, { testId: "promo-applied-banner", children: formatMessage(messages.couponApplied, { code: appliedCode }) })) : null, showOffer && offer ? (_jsx(PromoBanner, { testId: "promo-offer-banner", children: formatMessage(messages.saveWithCode, { percent: offer.percent, code: offer.code }) })) : null, hasAppliedState ? (_jsxs("div", { className: "promo-code__applied", children: [appliedCode && discount ? (_jsxs("p", { className: "promo-code__celebration", children: [_jsx("span", { "aria-hidden": "true", children: "\uD83C\uDF89" }), formatMessage(messages.couponApplied, { code: appliedCode })] })) : null, discount ? (_jsxs(_Fragment, { children: [_jsx("hr", { className: "promo-code__divider" }), _jsxs("div", { className: "promo-code__discount-row", "data-testid": "promo-discount-row", children: [_jsxs("span", { className: "promo-code__discount-label", children: [formatMessage(messages.discountApplied, { percent: discount.percent }), _jsx(Icon, { src: Check, className: "promo-code__check", "aria-hidden": "true" })] }), _jsx("span", { className: "promo-code__amount", children: formatMessage(messages.discountAmount, {
|
|
61
61
|
amount: discount.amount.toFixed(2),
|
|
62
62
|
currency: discount.currency,
|
|
63
|
-
}) })] }), onRemove ? (_jsx("button", { ref: removeRef, type: "button", className: "promo-code__remove", onClick: handleRemove, disabled: disabled || isApplying, "aria-label": removeLabel, children: formatMessage(messages.remove) })) : null] })) : onRemove && (_jsx("button", { ref: removeRef, type: "button", className: "promo-code__remove", onClick: handleRemove, disabled: disabled || isApplying, "aria-label": removeLabel, children: formatMessage(messages.remove) }))] })) : (_jsxs("form", { className: "promo-code__form", onSubmit: handleSubmit, children: [_jsxs("div", { className: `promo-code__field${focused || value ? ' promo-code__field--active' : ''}${error ? ' promo-code__field--error' : ''}`, children: [_jsx("label", { htmlFor: "promoCode", className: "promo-code__label", children: formatMessage(messages.placeholder) }), _jsx("input", { ref: inputRef, id: "promoCode", type: "text", className: "promo-code__input", value: value, onChange: (e) => onChange(e.target.value), onFocus: () => setFocused(true), onBlur: () => setFocused(false), disabled: disabled || isApplying, "aria-invalid": !!error, "aria-describedby": error ? 'promoCode-error' : undefined })] }), _jsx("button", { type: "submit", disabled: !canApply, className: "promo-code__apply", children: isApplying
|
|
63
|
+
}) })] }), onRemove ? (_jsx("button", { ref: removeRef, id: "promoCodeRemove", type: "button", className: "promo-code__remove", onClick: handleRemove, disabled: disabled || isApplying, "aria-label": removeLabel, children: formatMessage(messages.remove) })) : null] })) : onRemove && (_jsx("button", { ref: removeRef, id: "promoCodeRemove", type: "button", className: "promo-code__remove", onClick: handleRemove, disabled: disabled || isApplying, "aria-label": removeLabel, children: formatMessage(messages.remove) }))] })) : (_jsxs("form", { className: "promo-code__form", onSubmit: handleSubmit, children: [_jsxs("div", { className: `promo-code__field${focused || value ? ' promo-code__field--active' : ''}${error ? ' promo-code__field--error' : ''}`, children: [_jsx("label", { htmlFor: "promoCode", className: "promo-code__label", children: formatMessage(messages.placeholder) }), _jsx("input", { ref: inputRef, id: "promoCode", type: "text", className: "promo-code__input", value: value, onChange: (e) => onChange(e.target.value), onFocus: () => setFocused(true), onBlur: () => setFocused(false), disabled: disabled || isApplying, "aria-invalid": !!error, "aria-describedby": error ? 'promoCode-error' : undefined })] }), _jsx("button", { type: "submit", disabled: !canApply, className: "promo-code__apply", children: isApplying
|
|
64
64
|
? formatMessage(messages.applying)
|
|
65
65
|
: formatMessage(messages.apply) })] })), error && (_jsxs("div", { id: "promoCode-error", className: "promo-code__error", role: "alert", children: [_jsx("span", { className: "promo-code__error-icon", "aria-hidden": "true" }), error] }))] }));
|
|
66
66
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PromoCode.js","sourceRoot":"","sources":["../../../src/components/PromoCode/PromoCode.tsx"],"names":[],"mappings":";AAAA,OAAc,EACZ,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,GACnC,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,QAAQ,MAAM,YAAY,CAAC;AA+BlC,2EAA2E;AAC3E,mEAAmE;AACnE,qEAAqE;AACrE,MAAM,WAAW,GAAG,CAAC,EACnB,MAAM,EACN,QAAQ,GAIT,EAAE,EAAE;IACH,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,SAAS,GAAG,KAAK,EAAE,CAAC;IA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C,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import React, {\n useEffect, useId, useRef, useState,\n} from 'react';\nimport { Icon } from '@openedx/paragon';\nimport { Check, InfoOutline } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport messages from './Messages';\n\nexport interface PromoDiscount {\n /** Whole-number percent off, e.g. 15. */\n percent: number,\n amount: number,\n currency: string,\n}\n\n/** A known offer advertised before the learner applies it. */\nexport interface PromoOffer {\n code: string,\n percent: number,\n}\n\nexport interface PromoCodeProps {\n value: string,\n onChange: (value: string) => void,\n onApply: () => void,\n /** Clears an applied coupon (sends empty string to the API). */\n onRemove?: () => void,\n appliedCode?: string | null,\n /** Applied coupon's discount. Drives the applied banner and amount row. */\n discount?: PromoDiscount | null,\n /** Shown on the empty field when we already know a code and its percent. */\n offer?: PromoOffer | null,\n error?: string | null,\n isApplying?: boolean,\n disabled?: boolean,\n}\n\n// Info icon: details open visually on click / Enter / Space only, never on\n// hover or focus. Screen readers get the same text as the button's\n// description on focus instead, so it stays out of the reading flow.\nconst PromoBanner = ({\n testId,\n children,\n}: {\n testId: string,\n children: React.ReactNode,\n}) => {\n const { formatMessage } = useIntl();\n const [detailsOpen, setDetailsOpen] = useState(false);\n const detailsId = useId();\n return (\n <>\n <div className=\"promo-code__banner\" data-testid={testId}>\n <h3 className=\"promo-code__banner-text\">{children}</h3>\n <button\n type=\"button\"\n className=\"promo-code__banner-toggle\"\n aria-label={formatMessage(messages.detailsToggle)}\n aria-describedby={detailsId}\n onClick={() => setDetailsOpen((open) => !open)}\n >\n <Icon src={InfoOutline} className=\"promo-code__banner-icon\" />\n </button>\n </div>\n <p id={detailsId} className=\"promo-code__details\" hidden={!detailsOpen} aria-hidden=\"true\">\n {formatMessage(messages.details)}\n </p>\n </>\n );\n};\n\nconst PromoCode = ({\n value,\n onChange,\n onApply,\n onRemove,\n appliedCode = null,\n discount = null,\n offer = null,\n error = null,\n isApplying = false,\n disabled = false,\n}: PromoCodeProps) => {\n const { formatMessage } = useIntl();\n const [focused, setFocused] = useState(false);\n const trimmed = value.trim();\n const canApply = !disabled && !isApplying && trimmed.length > 0;\n const offerMatchesField = !trimmed\n || (!!offer && trimmed.toLowerCase() === offer.code.toLowerCase());\n // A discount on the line without a coupon code means the backend omitted the\n // code string but the coupon is still active — show the applied state.\n const hasAppliedState = !!appliedCode || !!discount;\n const showOffer = !hasAppliedState && !!offer && offerMatchesField;\n // Without a code the visible \"Remove discount\" already names the button.\n const removeLabel = appliedCode\n ? formatMessage(messages.removeDiscountLabel, { code: appliedCode })\n : undefined;\n\n const rootRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const removeRef = useRef<HTMLButtonElement>(null);\n // Apply and Remove are disabled mid-request and then swapped for each\n // other, which drops focus to <body>. Once the request settles, hand focus\n // to whichever control is now on screen so Tab carries on from here.\n const restoreFocusRef = useRef(false);\n\n useEffect(() => {\n if (isApplying || !restoreFocusRef.current) return;\n restoreFocusRef.current = false;\n const active = document.activeElement;\n // Leave focus alone if the learner has already moved elsewhere.\n if (active && active !== document.body && !rootRef.current?.contains(active)) return;\n (hasAppliedState ? removeRef.current : inputRef.current)?.focus();\n }, [isApplying, hasAppliedState]);\n\n const handleSubmit = (event: React.FormEvent) => {\n event.preventDefault();\n if (!canApply) return;\n restoreFocusRef.current = true;\n onApply();\n };\n\n const handleRemove = () => {\n restoreFocusRef.current = true;\n onRemove?.();\n };\n\n return (\n <div className=\"promo-code\" ref={rootRef}>\n {hasAppliedState && discount ? (\n <PromoBanner testId=\"promo-applied-banner\">\n {formatMessage(messages.discountAppliedBanner, { percent: discount.percent })}\n </PromoBanner>\n ) : null}\n {appliedCode && !discount ? (\n <PromoBanner testId=\"promo-applied-banner\">\n {formatMessage(messages.couponApplied, { code: appliedCode })}\n </PromoBanner>\n ) : null}\n {showOffer && offer ? (\n <PromoBanner testId=\"promo-offer-banner\">\n {formatMessage(messages.saveWithCode, { percent: offer.percent, code: offer.code })}\n </PromoBanner>\n ) : null}\n\n {hasAppliedState ? (\n <div className=\"promo-code__applied\">\n {appliedCode && discount ? (\n <p className=\"promo-code__celebration\">\n <span aria-hidden=\"true\">🎉</span>\n {formatMessage(messages.couponApplied, { code: appliedCode })}\n </p>\n ) : null}\n {discount ? (\n <>\n <hr className=\"promo-code__divider\" />\n {/* Reading order: discount and amount first, then Remove. */}\n <div className=\"promo-code__discount-row\" data-testid=\"promo-discount-row\">\n <span className=\"promo-code__discount-label\">\n {formatMessage(messages.discountApplied, { percent: discount.percent })}\n <Icon src={Check} className=\"promo-code__check\" aria-hidden=\"true\" />\n </span>\n <span className=\"promo-code__amount\">\n {formatMessage(messages.discountAmount, {\n amount: discount.amount.toFixed(2),\n currency: discount.currency,\n })}\n </span>\n </div>\n {onRemove ? (\n <button\n ref={removeRef}\n type=\"button\"\n className=\"promo-code__remove\"\n onClick={handleRemove}\n disabled={disabled || isApplying}\n aria-label={removeLabel}\n >\n {formatMessage(messages.remove)}\n </button>\n ) : null}\n </>\n ) : onRemove && (\n <button\n ref={removeRef}\n type=\"button\"\n className=\"promo-code__remove\"\n onClick={handleRemove}\n disabled={disabled || isApplying}\n aria-label={removeLabel}\n >\n {formatMessage(messages.remove)}\n </button>\n )}\n </div>\n ) : (\n <form className=\"promo-code__form\" onSubmit={handleSubmit}>\n <div className={`promo-code__field${focused || value ? ' promo-code__field--active' : ''}${error ? ' promo-code__field--error' : ''}`}>\n <label htmlFor=\"promoCode\" className=\"promo-code__label\">\n {formatMessage(messages.placeholder)}\n </label>\n <input\n ref={inputRef}\n id=\"promoCode\"\n type=\"text\"\n className=\"promo-code__input\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n disabled={disabled || isApplying}\n aria-invalid={!!error}\n aria-describedby={error ? 'promoCode-error' : undefined}\n />\n </div>\n <button\n type=\"submit\"\n disabled={!canApply}\n className=\"promo-code__apply\"\n >\n {isApplying\n ? formatMessage(messages.applying)\n : formatMessage(messages.apply)}\n </button>\n </form>\n )}\n {error && (\n <div id=\"promoCode-error\" className=\"promo-code__error\" role=\"alert\">\n <span className=\"promo-code__error-icon\" aria-hidden=\"true\" />\n {error}\n </div>\n )}\n </div>\n );\n};\n\nexport default PromoCode;\n"]}
|
|
1
|
+
{"version":3,"file":"PromoCode.js","sourceRoot":"","sources":["../../../src/components/PromoCode/PromoCode.tsx"],"names":[],"mappings":";AAAA,OAAc,EACZ,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,QAAQ,GACnC,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,KAAK,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,QAAQ,MAAM,YAAY,CAAC;AA+BlC,2EAA2E;AAC3E,mEAAmE;AACnE,qEAAqE;AACrE,MAAM,WAAW,GAAG,CAAC,EACnB,MAAM,EACN,QAAQ,GAIT,EAAE,EAAE;IACH,MAAM,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,CAAC;IACpC,MAAM,CAAC,WAAW,EAAE,cAAc,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACtD,MAAM,SAAS,GAAG,KAAK,EAAE,CAAC;IAC1B,OAAO,CACL,8BACE,eAAK,SAAS,EAAC,oBAAoB,iBAAc,MAAM,aACrD,aAAI,SAAS,EAAC,yBAAyB,YAAE,QAAQ,GAAM,EACvD,iBACE,IAAI,EAAC,QAAQ,EACb,SAAS,EAAC,2BAA2B,gBACzB,aAAa,CAAC,QAAQ,CAAC,aAAa,CAAC,sBAC/B,SAAS,EAC3B,OAAO,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,YAE9C,KAAC,IAAI,IAAC,GAAG,EAAE,WAAW,EAAE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gBACE,GAAG,EAAE,QAAQ,EACb,EAAE,EAAC,WAAW,EACd,IAAI,EAAC,MAAM,EACX,SAAS,EAAC,mBAAmB,EAC7B,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,EACzC,OAAO,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,EAC/B,MAAM,EAAE,GAAG,EAAE,CAAC,UAAU,CAAC,KAAK,CAAC,EAC/B,QAAQ,EAAE,QAAQ,IAAI,UAAU,kBAClB,CAAC,CAAC,KAAK,sBACH,KAAK,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,SAAS,GACvD,IACE,EACN,iBACE,IAAI,EAAC,QAAQ,EACb,QAAQ,EAAE,CAAC,QAAQ,EACnB,SAAS,EAAC,mBAAmB,YAE5B,UAAU;4BACT,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC;4BAClC,CAAC,CAAC,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,GAC1B,IACJ,CACR,EACA,KAAK,IAAI,CACR,eAAK,EAAE,EAAC,iBAAiB,EAAC,SAAS,EAAC,mBAAmB,EAAC,IAAI,EAAC,OAAO,aAClE,eAAM,SAAS,EAAC,wBAAwB,iBAAa,MAAM,GAAG,EAC7D,KAAK,IACF,CACP,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC","sourcesContent":["import React, {\n useEffect, useId, useRef, useState,\n} from 'react';\nimport { Icon } from '@openedx/paragon';\nimport { Check, InfoOutline } from '@openedx/paragon/icons';\nimport { useIntl } from '@openedx/frontend-base';\nimport messages from './Messages';\n\nexport interface PromoDiscount {\n /** Whole-number percent off, e.g. 15. */\n percent: number,\n amount: number,\n currency: string,\n}\n\n/** A known offer advertised before the learner applies it. */\nexport interface PromoOffer {\n code: string,\n percent: number,\n}\n\nexport interface PromoCodeProps {\n value: string,\n onChange: (value: string) => void,\n onApply: () => void,\n /** Clears an applied coupon (sends empty string to the API). */\n onRemove?: () => void,\n appliedCode?: string | null,\n /** Applied coupon's discount. Drives the applied banner and amount row. */\n discount?: PromoDiscount | null,\n /** Shown on the empty field when we already know a code and its percent. */\n offer?: PromoOffer | null,\n error?: string | null,\n isApplying?: boolean,\n disabled?: boolean,\n}\n\n// Info icon: details open visually on click / Enter / Space only, never on\n// hover or focus. Screen readers get the same text as the button's\n// description on focus instead, so it stays out of the reading flow.\nconst PromoBanner = ({\n testId,\n children,\n}: {\n testId: string,\n children: React.ReactNode,\n}) => {\n const { formatMessage } = useIntl();\n const [detailsOpen, setDetailsOpen] = useState(false);\n const detailsId = useId();\n return (\n <>\n <div className=\"promo-code__banner\" data-testid={testId}>\n <h3 className=\"promo-code__banner-text\">{children}</h3>\n <button\n type=\"button\"\n className=\"promo-code__banner-toggle\"\n aria-label={formatMessage(messages.detailsToggle)}\n aria-describedby={detailsId}\n onClick={() => setDetailsOpen((open) => !open)}\n >\n <Icon src={InfoOutline} className=\"promo-code__banner-icon\" />\n </button>\n </div>\n <p id={detailsId} className=\"promo-code__details\" hidden={!detailsOpen} aria-hidden=\"true\">\n {formatMessage(messages.details)}\n </p>\n </>\n );\n};\n\nconst PromoCode = ({\n value,\n onChange,\n onApply,\n onRemove,\n appliedCode = null,\n discount = null,\n offer = null,\n error = null,\n isApplying = false,\n disabled = false,\n}: PromoCodeProps) => {\n const { formatMessage } = useIntl();\n const [focused, setFocused] = useState(false);\n const trimmed = value.trim();\n const canApply = !disabled && !isApplying && trimmed.length > 0;\n const offerMatchesField = !trimmed\n || (!!offer && trimmed.toLowerCase() === offer.code.toLowerCase());\n // A discount on the line without a coupon code means the backend omitted the\n // code string but the coupon is still active — show the applied state.\n const hasAppliedState = !!appliedCode || !!discount;\n const showOffer = !hasAppliedState && !!offer && offerMatchesField;\n // Without a code the visible \"Remove discount\" already names the button.\n const removeLabel = appliedCode\n ? formatMessage(messages.removeDiscountLabel, { code: appliedCode })\n : undefined;\n\n const rootRef = useRef<HTMLDivElement>(null);\n const inputRef = useRef<HTMLInputElement>(null);\n const removeRef = useRef<HTMLButtonElement>(null);\n // Apply and Remove are disabled mid-request and then swapped for each\n // other, which drops focus to <body>. Once the request settles, hand focus\n // to whichever control is now on screen so Tab carries on from here.\n const restoreFocusRef = useRef(false);\n\n useEffect(() => {\n if (isApplying || !restoreFocusRef.current) return;\n restoreFocusRef.current = false;\n const active = document.activeElement;\n // Leave focus alone if the learner has already moved elsewhere.\n if (active && active !== document.body && !rootRef.current?.contains(active)) return;\n (hasAppliedState ? removeRef.current : inputRef.current)?.focus();\n }, [isApplying, hasAppliedState]);\n\n const handleSubmit = (event: React.FormEvent) => {\n event.preventDefault();\n if (!canApply) return;\n restoreFocusRef.current = true;\n onApply();\n };\n\n const handleRemove = () => {\n restoreFocusRef.current = true;\n onRemove?.();\n };\n\n return (\n <div className=\"promo-code\" ref={rootRef}>\n {hasAppliedState && discount ? (\n <PromoBanner testId=\"promo-applied-banner\">\n {formatMessage(messages.discountAppliedBanner, { percent: discount.percent })}\n </PromoBanner>\n ) : null}\n {appliedCode && !discount ? (\n <PromoBanner testId=\"promo-applied-banner\">\n {formatMessage(messages.couponApplied, { code: appliedCode })}\n </PromoBanner>\n ) : null}\n {showOffer && offer ? (\n <PromoBanner testId=\"promo-offer-banner\">\n {formatMessage(messages.saveWithCode, { percent: offer.percent, code: offer.code })}\n </PromoBanner>\n ) : null}\n\n {hasAppliedState ? (\n <div className=\"promo-code__applied\">\n {appliedCode && discount ? (\n <p className=\"promo-code__celebration\">\n <span aria-hidden=\"true\">🎉</span>\n {formatMessage(messages.couponApplied, { code: appliedCode })}\n </p>\n ) : null}\n {discount ? (\n <>\n <hr className=\"promo-code__divider\" />\n {/* Reading order: discount and amount first, then Remove. */}\n <div className=\"promo-code__discount-row\" data-testid=\"promo-discount-row\">\n <span className=\"promo-code__discount-label\">\n {formatMessage(messages.discountApplied, { percent: discount.percent })}\n <Icon src={Check} className=\"promo-code__check\" aria-hidden=\"true\" />\n </span>\n <span className=\"promo-code__amount\">\n {formatMessage(messages.discountAmount, {\n amount: discount.amount.toFixed(2),\n currency: discount.currency,\n })}\n </span>\n </div>\n {onRemove ? (\n <button\n ref={removeRef}\n id=\"promoCodeRemove\"\n type=\"button\"\n className=\"promo-code__remove\"\n onClick={handleRemove}\n disabled={disabled || isApplying}\n aria-label={removeLabel}\n >\n {formatMessage(messages.remove)}\n </button>\n ) : null}\n </>\n ) : onRemove && (\n <button\n ref={removeRef}\n id=\"promoCodeRemove\"\n type=\"button\"\n className=\"promo-code__remove\"\n onClick={handleRemove}\n disabled={disabled || isApplying}\n aria-label={removeLabel}\n >\n {formatMessage(messages.remove)}\n </button>\n )}\n </div>\n ) : (\n <form className=\"promo-code__form\" onSubmit={handleSubmit}>\n <div className={`promo-code__field${focused || value ? ' promo-code__field--active' : ''}${error ? ' promo-code__field--error' : ''}`}>\n <label htmlFor=\"promoCode\" className=\"promo-code__label\">\n {formatMessage(messages.placeholder)}\n </label>\n <input\n ref={inputRef}\n id=\"promoCode\"\n type=\"text\"\n className=\"promo-code__input\"\n value={value}\n onChange={(e) => onChange(e.target.value)}\n onFocus={() => setFocused(true)}\n onBlur={() => setFocused(false)}\n disabled={disabled || isApplying}\n aria-invalid={!!error}\n aria-describedby={error ? 'promoCode-error' : undefined}\n />\n </div>\n <button\n type=\"submit\"\n disabled={!canApply}\n className=\"promo-code__apply\"\n >\n {isApplying\n ? formatMessage(messages.applying)\n : formatMessage(messages.apply)}\n </button>\n </form>\n )}\n {error && (\n <div id=\"promoCode-error\" className=\"promo-code__error\" role=\"alert\">\n <span className=\"promo-code__error-icon\" aria-hidden=\"true\" />\n {error}\n </div>\n )}\n </div>\n );\n};\n\nexport default PromoCode;\n"]}
|
package/dist/constants.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import type { CSSProperties } from 'react';
|
|
2
2
|
export declare const appId = "org.openedx.frontend.app.aca.checkout";
|
|
3
3
|
export declare const acaCheckoutRole = "org.openedx.frontend.role.aca.checkout";
|
|
4
|
-
export declare const LEARNER_HELP_CENTER_URL
|
|
4
|
+
export declare const LEARNER_HELP_CENTER_URL: string;
|
|
5
5
|
export declare const BILLING_SUPPORT_EMAIL = "billing@edx.org";
|
|
6
|
-
export declare const REFUND_POLICY_URL
|
|
7
|
-
export declare const FAQ_URL
|
|
6
|
+
export declare const REFUND_POLICY_URL: string;
|
|
7
|
+
export declare const FAQ_URL: string;
|
|
8
8
|
export declare const STATUS: {
|
|
9
9
|
readonly IN_CART: "IN_CART";
|
|
10
10
|
readonly CONFIRM: "CONFIRM";
|
package/dist/constants.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
+
var _a, _b, _c, _d, _e, _f;
|
|
2
|
+
import { getAppConfig } from '@openedx/frontend-base';
|
|
1
3
|
export const appId = 'org.openedx.frontend.app.aca.checkout';
|
|
2
4
|
export const acaCheckoutRole = 'org.openedx.frontend.role.aca.checkout';
|
|
3
|
-
export const LEARNER_HELP_CENTER_URL =
|
|
5
|
+
export const LEARNER_HELP_CENTER_URL = `${(_b = (_a = getAppConfig(appId)) === null || _a === void 0 ? void 0 : _a.SUPPORT_URL) !== null && _b !== void 0 ? _b : ''}`;
|
|
4
6
|
export const BILLING_SUPPORT_EMAIL = 'billing@edx.org';
|
|
5
|
-
export const REFUND_POLICY_URL =
|
|
6
|
-
export const FAQ_URL =
|
|
7
|
+
export const REFUND_POLICY_URL = `${(_d = (_c = getAppConfig(appId)) === null || _c === void 0 ? void 0 : _c.REFUND_POLICY_URL) !== null && _d !== void 0 ? _d : ''}`;
|
|
8
|
+
export const FAQ_URL = `${(_f = (_e = getAppConfig(appId)) === null || _e === void 0 ? void 0 : _e.FAQ_URL) !== null && _f !== void 0 ? _f : ''}`;
|
|
7
9
|
// --- Cart BI state machine ---------------------------------------------------
|
|
8
10
|
export const STATUS = {
|
|
9
11
|
IN_CART: 'IN_CART',
|
package/dist/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,KAAK,GAAG,uCAAuC,CAAC;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG,wCAAwC,CAAC;AAExE,MAAM,CAAC,MAAM,uBAAuB,GAAG,yBAAyB,CAAC;AACjE,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AACvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,mCAAmC,CAAC;AACrE,MAAM,CAAC,MAAM,OAAO,GAAG,2DAA2D,CAAC;AAEnF,gFAAgF;AAChF,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,gBAAgB,EAAE,kBAAkB;IACpC,eAAe,EAAE,iBAAiB;IAClC,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,iBAAiB,EAAE,mBAAmB;IACtC,4BAA4B,EAAE,8BAA8B;IAC5D,WAAW,EAAE,aAAa;IAC1B,oBAAoB,EAAE,sBAAsB;CACpC,CAAC;AAMX,MAAM,CAAC,MAAM,eAAe,GAAa;IACvC,MAAM,CAAC,oBAAoB;IAC3B,MAAM,CAAC,cAAc;IACrB,MAAM,CAAC,WAAW;CACnB,CAAC;AAEF,MAAM,CAAC,MAAM,aAAa,GAA2B;IACnD,OAAO,EAAE,cAAc;IACvB,OAAO,EAAE,iBAAiB;IAC1B,gBAAgB,EAAE,qBAAqB;IACvC,eAAe,EAAE,6CAA6C;IAC9D,cAAc,EAAE,eAAe;IAC/B,cAAc,EAAE,+BAA+B;IAC/C,4BAA4B,EAAE,4BAA4B;IAC1D,iBAAiB,EAAE,6BAA6B;IAChD,WAAW,EAAE,gBAAgB;IAC7B,oBAAoB,EAAE,sBAAsB;CAC7C,CAAC;AAEF,MAAM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AAa,CAAC;CACtB,CAAC;AAEF,gFAAgF;AAChF,oEAAoE;AACpE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,kBAAkB,GAAkB;IAC/C,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,UAAU;IACrB,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,QAAQ;IACpB,aAAa,EAAE,QAAQ;CACxB,CAAC;AACF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE;QACL,IAAI,EAAE;YACJ,UAAU,EAAE,8BAA8B;YAC1C,QAAQ,EAAE,MAAM;YAChB,UAAU,EAAE,KAAK;YACjB,iFAAiF;YACjF,UAAU,EAAE,MAAM;YAClB,KAAK,EAAE,SAAS;YAChB,eAAe,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;SACtC;KACF;CACF,CAAC;AACF,uEAAuE;AACvE,MAAM,CAAC,MAAM,uBAAuB,mCAC/B,mBAAmB,KACtB,WAAW,EAAE,IAAI,GAClB,CAAC","sourcesContent":["import type { CSSProperties } from 'react';\n\nexport const appId = 'org.openedx.frontend.app.aca.checkout';\nexport const acaCheckoutRole = 'org.openedx.frontend.role.aca.checkout';\n\nexport const LEARNER_HELP_CENTER_URL = 'https://support.edx.org';\nexport const BILLING_SUPPORT_EMAIL = 'billing@edx.org';\nexport const REFUND_POLICY_URL = 'https://www.edx.org/refund-policy';\nexport const FAQ_URL = 'https://support.edx.org/hc/en-us/categories/200357087-FAQ';\n\n// --- Cart BI state machine ---------------------------------------------------\nexport const STATUS = {\n IN_CART: 'IN_CART',\n CONFIRM: 'CONFIRM',\n SANCTION_STARTED: 'SANCTION_STARTED',\n SANCTION_PASSED: 'SANCTION_PASSED',\n SANCTION_BLOCK: 'SANCTION_BLOCK',\n STRIPE_STARTED: 'STRIPE_STARTED',\n STRIPE_SUBSCRIBED: 'STRIPE_SUBSCRIBED',\n STRIPE_CONFIRMATION_REQUIRED: 'STRIPE_CONFIRMATION_REQUIRED',\n STRIPE_FAIL: 'STRIPE_FAIL',\n SUBSCRIPTION_CREATED: 'SUBSCRIPTION_CREATED',\n} as const;\n\nexport type Status = typeof STATUS[keyof typeof STATUS];\n\nexport type Phase = 'init' | 'ready' | 'processing' | 'threeds' | 'success' | 'blocked' | 'failed';\n\nexport const TERMINAL_STATES: Status[] = [\n STATUS.SUBSCRIPTION_CREATED,\n STATUS.SANCTION_BLOCK,\n STATUS.STRIPE_FAIL,\n];\n\nexport const STATUS_LABELS: Record<string, string> = {\n IN_CART: 'Cart created',\n CONFIRM: 'Order confirmed',\n SANCTION_STARTED: 'Checking sanctions…',\n SANCTION_PASSED: 'Sanctions passed — setting up your account…',\n SANCTION_BLOCK: 'Order blocked',\n STRIPE_STARTED: 'Setting up your subscription…',\n STRIPE_CONFIRMATION_REQUIRED: 'Card verification required',\n STRIPE_SUBSCRIBED: 'Card verified — finalizing…',\n STRIPE_FAIL: 'Payment failed',\n SUBSCRIPTION_CREATED: 'Subscription created',\n};\n\nexport const isTerminalStatus = (status: Status | null | undefined): boolean =>\n TERMINAL_STATES.includes(status as Status);\n\n/** UI phase derived from the raw bpStatus code + cart readiness. */\nexport function phaseFor(status: Status | null, ready: boolean): Phase {\n if (status === STATUS.SUBSCRIPTION_CREATED) return 'success';\n if (status === STATUS.SANCTION_BLOCK) return 'blocked';\n if (status === STATUS.STRIPE_FAIL) return 'failed';\n if (status && status !== STATUS.IN_CART) return 'processing';\n return ready ? 'ready' : 'init';\n}\n\n// --- Dev defaults (match the local test harness) -----------------------------\nexport const DEFAULTS = {\n apiUrl: '/api/graphql',\n confirmIntentUrl: '/api/stripe/confirm-pi',\n customerUid: '019d2bde-f769-743d-88f9-8bf0d1a7a002',\n salableUid: '019d2ce7-05bc-7dd6-b141-e32df9ac86c1',\n // Monthly Subscription template uid (not Annual)\n billingPlanUid: '019d2ce7-05bf-733c-ba56-0fcafafeb69b',\n};\n\nexport const LS_KEYS = { biId: 'twou.cartBiId', uid: 'twou.cartUid' };\n\n// ─── Checkout gate feature flags (dev controls) ───────────────────────────────\n// Set to false during development to bypass the country gate check.\n// Should be true in production. Subscriber access is enforced outside this app.\n\n/** When false, the country check is skipped — all countries can access checkout. */\nexport const GATE_CHECK_COUNTRY = true;\n\n/**\n * ISO 3166-1 alpha-2 country codes that are permitted to complete checkout.\n * Add or remove codes here to open or restrict access by country.\n */\nexport const ALLOWED_CHECKOUT_COUNTRIES: readonly string[] = ['GB', 'AU', 'CA', 'US', 'IN'];\n\n/**\n * ISO 3166-1 alpha-2 country codes that require the extra billing-consent checkbox.\n * Add or remove codes here to control which selected billing countries show it.\n */\nexport const COUNTRIES_REQUIRING_EXTRA_CONFIRM: readonly string[] = ['GB', 'CA'];\n\n/**\n * ISO 3166-1 alpha-2 codes (plus XK, Kosovo) offered in the billing country dropdown.\n * Display names are localized at runtime with Intl.DisplayNames (see utils/countries).\n * Sanctioned countries stay listed: the backend embargo check blocks them.\n */\nexport const BILLING_COUNTRY_CODES: readonly string[] = [\n 'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT',\n 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI',\n 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY',\n 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN',\n 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM',\n 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK',\n 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL',\n 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM',\n 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR',\n 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN',\n 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS',\n 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK',\n 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW',\n 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP',\n 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM',\n 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW',\n 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM',\n 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF',\n 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW',\n 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI',\n 'VN', 'VU', 'WF', 'WS', 'XK', 'YE', 'YT', 'ZA', 'ZM', 'ZW',\n];\n\n/** Canadian provinces and territories (ISO 3166-2:CA codes without the CA- prefix). */\nexport const CA_PROVINCES: readonly (readonly [string, string])[] = [\n ['AB', 'Alberta'],\n ['BC', 'British Columbia'],\n ['MB', 'Manitoba'],\n ['NB', 'New Brunswick'],\n ['NL', 'Newfoundland and Labrador'],\n ['NT', 'Northwest Territories'],\n ['NS', 'Nova Scotia'],\n ['NU', 'Nunavut'],\n ['ON', 'Ontario'],\n ['PE', 'Prince Edward Island'],\n ['QC', 'Quebec'],\n ['SK', 'Saskatchewan'],\n ['YT', 'Yukon'],\n];\n\n/** Indian states and union territories (ISO 3166-2:IN codes without the IN- prefix). */\nexport const IN_STATES: readonly (readonly [string, string])[] = [\n ['AN', 'Andaman and Nicobar Islands'],\n ['AP', 'Andhra Pradesh'],\n ['AR', 'Arunachal Pradesh'],\n ['AS', 'Assam'],\n ['BR', 'Bihar'],\n ['CH', 'Chandigarh'],\n ['CG', 'Chhattisgarh'],\n ['DH', 'Dadra and Nagar Haveli and Daman and Diu'],\n ['DL', 'Delhi'],\n ['GA', 'Goa'],\n ['GJ', 'Gujarat'],\n ['HR', 'Haryana'],\n ['HP', 'Himachal Pradesh'],\n ['JK', 'Jammu and Kashmir'],\n ['JH', 'Jharkhand'],\n ['KA', 'Karnataka'],\n ['KL', 'Kerala'],\n ['LA', 'Ladakh'],\n ['LD', 'Lakshadweep'],\n ['MP', 'Madhya Pradesh'],\n ['MH', 'Maharashtra'],\n ['MN', 'Manipur'],\n ['ML', 'Meghalaya'],\n ['MZ', 'Mizoram'],\n ['NL', 'Nagaland'],\n ['OD', 'Odisha'],\n ['PY', 'Puducherry'],\n ['PB', 'Punjab'],\n ['RJ', 'Rajasthan'],\n ['SK', 'Sikkim'],\n ['TN', 'Tamil Nadu'],\n ['TS', 'Telangana'],\n ['TR', 'Tripura'],\n ['UP', 'Uttar Pradesh'],\n ['UK', 'Uttarakhand'],\n ['WB', 'West Bengal'],\n];\n\n// --- Stripe Element presentation ---------------------------------------------\n// A div that hosts a Stripe Element but reads like a Paragon input.\n// Vertical padding replaces Element `lineHeight` (discouraged by Stripe.js).\nexport const STRIPE_FIELD_STYLE: CSSProperties = {\n height: 'auto',\n minHeight: '2.875rem',\n display: 'flex',\n alignItems: 'center',\n paddingTop: '0.5rem',\n paddingBottom: '0.5rem',\n};\nexport const STRIPE_ELEMENT_OPTS = {\n style: {\n base: {\n fontFamily: 'Inter, system-ui, sans-serif',\n fontSize: '16px',\n fontWeight: '400',\n // Stripe's `lineHeight` requires a fixed unit (not a percentage) — 145% of 16px.\n lineHeight: '23px',\n color: '#1a1a1a',\n '::placeholder': { color: '#6e6e6e' },\n },\n },\n};\n/** cardNumber-only: disableLink is invalid on cardExpiry / cardCvc. */\nexport const STRIPE_CARD_NUMBER_OPTS = {\n ...STRIPE_ELEMENT_OPTS,\n disableLink: true,\n};\n"]}
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAGtD,MAAM,CAAC,MAAM,KAAK,GAAG,uCAAuC,CAAC;AAC7D,MAAM,CAAC,MAAM,eAAe,GAAG,wCAAwC,CAAC;AAExE,MAAM,CAAC,MAAM,uBAAuB,GAAG,GAAG,MAAA,MAAA,YAAY,CAAC,KAAK,CAAC,0CAAE,WAAW,mCAAI,EAAE,EAAE,CAAC;AACnF,MAAM,CAAC,MAAM,qBAAqB,GAAG,iBAAiB,CAAC;AACvD,MAAM,CAAC,MAAM,iBAAiB,GAAG,GAAG,MAAA,MAAA,YAAY,CAAC,KAAK,CAAC,0CAAE,iBAAiB,mCAAI,EAAE,EAAE,CAAC;AACnF,MAAM,CAAC,MAAM,OAAO,GAAG,GAAG,MAAA,MAAA,YAAY,CAAC,KAAK,CAAC,0CAAE,OAAO,mCAAI,EAAE,EAAE,CAAC;AAE/D,gFAAgF;AAChF,MAAM,CAAC,MAAM,MAAM,GAAG;IACpB,OAAO,EAAE,SAAS;IAClB,OAAO,EAAE,SAAS;IAClB,gBAAgB,EAAE,kBAAkB;IACpC,eAAe,EAAE,iBAAiB;IAClC,cAAc,EAAE,gBAAgB;IAChC,cAAc,EAAE,gBAAgB;IAChC,iBAAiB,EAAE,mBAAmB;IACtC,4BAA4B,EAAE,8BAA8B;IAC5D,WAAW,EAAE,aAAa;IAC1B,oBAAoB,EAAE,sBAAsB;CACp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W,CAAC;IACnB,CAAC,IAAI,EAAE,SAAS,CAAC;IACjB,CAAC,IAAI,EAAE,UAAU,CAAC;IAClB,CAAC,IAAI,EAAE,QAAQ,CAAC;IAChB,CAAC,IAAI,EAAE,YAAY,CAAC;IACpB,CAAC,IAAI,EAAE,QAAQ,CAAC;IAChB,CAAC,IAAI,EAAE,WAAW,CAAC;IACnB,CAAC,IAAI,EAAE,QAAQ,CAAC;IAChB,CAAC,IAAI,EAAE,YAAY,CAAC;IACpB,CAAC,IAAI,EAAE,WAAW,CAAC;IACnB,CAAC,IAAI,EAAE,SAAS,CAAC;IACjB,CAAC,IAAI,EAAE,eAAe,CAAC;IACvB,CAAC,IAAI,EAAE,aAAa,CAAC;IACrB,CAAC,IAAI,EAAE,aAAa,CAAC;CACtB,CAAC;AAEF,gFAAgF;AAChF,oEAAoE;AACpE,6EAA6E;AAC7E,MAAM,CAAC,MAAM,kBAAkB,GAAkB;IAC/C,MAAM,EAAE,MAAM;IACd,SAAS,EAAE,UAAU;IACrB,OAAO,EAAE,MAAM;IACf,UAAU,EAAE,QAAQ;IACpB,UAAU,EAAE,QAAQ;IACpB,aAAa,EAAE,QAAQ;CACxB,CAAC;AACF,MAAM,CAAC,MAAM,mBAAmB,GAAG;IACjC,KAAK,EAAE;QACL,IAAI,EAAE;YACJ,UAAU,EAAE,8BAA8B;YAC1C,QAAQ,EAAE,MAAM;YAChB,UAAU,EAAE,KAAK;YACjB,iFAAiF;YACjF,UAAU,EAAE,MAAM;YAClB,KAAK,EAAE,SAAS;YAChB,eAAe,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE;SACtC;KACF;CACF,CAAC;AACF,uEAAuE;AACvE,MAAM,CAAC,MAAM,uBAAuB,mCAC/B,mBAAmB,KACtB,WAAW,EAAE,IAAI,GAClB,CAAC","sourcesContent":["import { getAppConfig } from '@openedx/frontend-base';\nimport type { CSSProperties } from 'react';\n\nexport const appId = 'org.openedx.frontend.app.aca.checkout';\nexport const acaCheckoutRole = 'org.openedx.frontend.role.aca.checkout';\n\nexport const LEARNER_HELP_CENTER_URL = `${getAppConfig(appId)?.SUPPORT_URL ?? ''}`;\nexport const BILLING_SUPPORT_EMAIL = 'billing@edx.org';\nexport const REFUND_POLICY_URL = `${getAppConfig(appId)?.REFUND_POLICY_URL ?? ''}`;\nexport const FAQ_URL = `${getAppConfig(appId)?.FAQ_URL ?? ''}`;\n\n// --- Cart BI state machine ---------------------------------------------------\nexport const STATUS = {\n IN_CART: 'IN_CART',\n CONFIRM: 'CONFIRM',\n SANCTION_STARTED: 'SANCTION_STARTED',\n SANCTION_PASSED: 'SANCTION_PASSED',\n SANCTION_BLOCK: 'SANCTION_BLOCK',\n STRIPE_STARTED: 'STRIPE_STARTED',\n STRIPE_SUBSCRIBED: 'STRIPE_SUBSCRIBED',\n STRIPE_CONFIRMATION_REQUIRED: 'STRIPE_CONFIRMATION_REQUIRED',\n STRIPE_FAIL: 'STRIPE_FAIL',\n SUBSCRIPTION_CREATED: 'SUBSCRIPTION_CREATED',\n} as const;\n\nexport type Status = typeof STATUS[keyof typeof STATUS];\n\nexport type Phase = 'init' | 'ready' | 'processing' | 'threeds' | 'success' | 'blocked' | 'failed';\n\nexport const TERMINAL_STATES: Status[] = [\n STATUS.SUBSCRIPTION_CREATED,\n STATUS.SANCTION_BLOCK,\n STATUS.STRIPE_FAIL,\n];\n\nexport const STATUS_LABELS: Record<string, string> = {\n IN_CART: 'Cart created',\n CONFIRM: 'Order confirmed',\n SANCTION_STARTED: 'Checking sanctions…',\n SANCTION_PASSED: 'Sanctions passed — setting up your account…',\n SANCTION_BLOCK: 'Order blocked',\n STRIPE_STARTED: 'Setting up your subscription…',\n STRIPE_CONFIRMATION_REQUIRED: 'Card verification required',\n STRIPE_SUBSCRIBED: 'Card verified — finalizing…',\n STRIPE_FAIL: 'Payment failed',\n SUBSCRIPTION_CREATED: 'Subscription created',\n};\n\nexport const isTerminalStatus = (status: Status | null | undefined): boolean =>\n TERMINAL_STATES.includes(status as Status);\n\n/** UI phase derived from the raw bpStatus code + cart readiness. */\nexport function phaseFor(status: Status | null, ready: boolean): Phase {\n if (status === STATUS.SUBSCRIPTION_CREATED) return 'success';\n if (status === STATUS.SANCTION_BLOCK) return 'blocked';\n if (status === STATUS.STRIPE_FAIL) return 'failed';\n if (status && status !== STATUS.IN_CART) return 'processing';\n return ready ? 'ready' : 'init';\n}\n\n// --- Dev defaults (match the local test harness) -----------------------------\nexport const DEFAULTS = {\n apiUrl: '/api/graphql',\n confirmIntentUrl: '/api/stripe/confirm-pi',\n customerUid: '019d2bde-f769-743d-88f9-8bf0d1a7a002',\n salableUid: '019d2ce7-05bc-7dd6-b141-e32df9ac86c1',\n // Monthly Subscription template uid (not Annual)\n billingPlanUid: '019d2ce7-05bf-733c-ba56-0fcafafeb69b',\n};\n\nexport const LS_KEYS = { biId: 'twou.cartBiId', uid: 'twou.cartUid' };\n\n// ─── Checkout gate feature flags (dev controls) ───────────────────────────────\n// Set to false during development to bypass the country gate check.\n// Should be true in production. Subscriber access is enforced outside this app.\n\n/** When false, the country check is skipped — all countries can access checkout. */\nexport const GATE_CHECK_COUNTRY = true;\n\n/**\n * ISO 3166-1 alpha-2 country codes that are permitted to complete checkout.\n * Add or remove codes here to open or restrict access by country.\n */\nexport const ALLOWED_CHECKOUT_COUNTRIES: readonly string[] = ['GB', 'AU', 'CA', 'US', 'IN'];\n\n/**\n * ISO 3166-1 alpha-2 country codes that require the extra billing-consent checkbox.\n * Add or remove codes here to control which selected billing countries show it.\n */\nexport const COUNTRIES_REQUIRING_EXTRA_CONFIRM: readonly string[] = ['GB', 'CA'];\n\n/**\n * ISO 3166-1 alpha-2 codes (plus XK, Kosovo) offered in the billing country dropdown.\n * Display names are localized at runtime with Intl.DisplayNames (see utils/countries).\n * Sanctioned countries stay listed: the backend embargo check blocks them.\n */\nexport const BILLING_COUNTRY_CODES: readonly string[] = [\n 'AD', 'AE', 'AF', 'AG', 'AI', 'AL', 'AM', 'AO', 'AQ', 'AR', 'AS', 'AT',\n 'AU', 'AW', 'AX', 'AZ', 'BA', 'BB', 'BD', 'BE', 'BF', 'BG', 'BH', 'BI',\n 'BJ', 'BL', 'BM', 'BN', 'BO', 'BQ', 'BR', 'BS', 'BT', 'BV', 'BW', 'BY',\n 'BZ', 'CA', 'CC', 'CD', 'CF', 'CG', 'CH', 'CI', 'CK', 'CL', 'CM', 'CN',\n 'CO', 'CR', 'CU', 'CV', 'CW', 'CX', 'CY', 'CZ', 'DE', 'DJ', 'DK', 'DM',\n 'DO', 'DZ', 'EC', 'EE', 'EG', 'EH', 'ER', 'ES', 'ET', 'FI', 'FJ', 'FK',\n 'FM', 'FO', 'FR', 'GA', 'GB', 'GD', 'GE', 'GF', 'GG', 'GH', 'GI', 'GL',\n 'GM', 'GN', 'GP', 'GQ', 'GR', 'GS', 'GT', 'GU', 'GW', 'GY', 'HK', 'HM',\n 'HN', 'HR', 'HT', 'HU', 'ID', 'IE', 'IL', 'IM', 'IN', 'IO', 'IQ', 'IR',\n 'IS', 'IT', 'JE', 'JM', 'JO', 'JP', 'KE', 'KG', 'KH', 'KI', 'KM', 'KN',\n 'KP', 'KR', 'KW', 'KY', 'KZ', 'LA', 'LB', 'LC', 'LI', 'LK', 'LR', 'LS',\n 'LT', 'LU', 'LV', 'LY', 'MA', 'MC', 'MD', 'ME', 'MF', 'MG', 'MH', 'MK',\n 'ML', 'MM', 'MN', 'MO', 'MP', 'MQ', 'MR', 'MS', 'MT', 'MU', 'MV', 'MW',\n 'MX', 'MY', 'MZ', 'NA', 'NC', 'NE', 'NF', 'NG', 'NI', 'NL', 'NO', 'NP',\n 'NR', 'NU', 'NZ', 'OM', 'PA', 'PE', 'PF', 'PG', 'PH', 'PK', 'PL', 'PM',\n 'PN', 'PR', 'PS', 'PT', 'PW', 'PY', 'QA', 'RE', 'RO', 'RS', 'RU', 'RW',\n 'SA', 'SB', 'SC', 'SD', 'SE', 'SG', 'SH', 'SI', 'SJ', 'SK', 'SL', 'SM',\n 'SN', 'SO', 'SR', 'SS', 'ST', 'SV', 'SX', 'SY', 'SZ', 'TC', 'TD', 'TF',\n 'TG', 'TH', 'TJ', 'TK', 'TL', 'TM', 'TN', 'TO', 'TR', 'TT', 'TV', 'TW',\n 'TZ', 'UA', 'UG', 'UM', 'US', 'UY', 'UZ', 'VA', 'VC', 'VE', 'VG', 'VI',\n 'VN', 'VU', 'WF', 'WS', 'XK', 'YE', 'YT', 'ZA', 'ZM', 'ZW',\n];\n\n/** Canadian provinces and territories (ISO 3166-2:CA codes without the CA- prefix). */\nexport const CA_PROVINCES: readonly (readonly [string, string])[] = [\n ['AB', 'Alberta'],\n ['BC', 'British Columbia'],\n ['MB', 'Manitoba'],\n ['NB', 'New Brunswick'],\n ['NL', 'Newfoundland and Labrador'],\n ['NT', 'Northwest Territories'],\n ['NS', 'Nova Scotia'],\n ['NU', 'Nunavut'],\n ['ON', 'Ontario'],\n ['PE', 'Prince Edward Island'],\n ['QC', 'Quebec'],\n ['SK', 'Saskatchewan'],\n ['YT', 'Yukon'],\n];\n\n/** Indian states and union territories (ISO 3166-2:IN codes without the IN- prefix). */\nexport const IN_STATES: readonly (readonly [string, string])[] = [\n ['AN', 'Andaman and Nicobar Islands'],\n ['AP', 'Andhra Pradesh'],\n ['AR', 'Arunachal Pradesh'],\n ['AS', 'Assam'],\n ['BR', 'Bihar'],\n ['CH', 'Chandigarh'],\n ['CG', 'Chhattisgarh'],\n ['DH', 'Dadra and Nagar Haveli and Daman and Diu'],\n ['DL', 'Delhi'],\n ['GA', 'Goa'],\n ['GJ', 'Gujarat'],\n ['HR', 'Haryana'],\n ['HP', 'Himachal Pradesh'],\n ['JK', 'Jammu and Kashmir'],\n ['JH', 'Jharkhand'],\n ['KA', 'Karnataka'],\n ['KL', 'Kerala'],\n ['LA', 'Ladakh'],\n ['LD', 'Lakshadweep'],\n ['MP', 'Madhya Pradesh'],\n ['MH', 'Maharashtra'],\n ['MN', 'Manipur'],\n ['ML', 'Meghalaya'],\n ['MZ', 'Mizoram'],\n ['NL', 'Nagaland'],\n ['OD', 'Odisha'],\n ['PY', 'Puducherry'],\n ['PB', 'Punjab'],\n ['RJ', 'Rajasthan'],\n ['SK', 'Sikkim'],\n ['TN', 'Tamil Nadu'],\n ['TS', 'Telangana'],\n ['TR', 'Tripura'],\n ['UP', 'Uttar Pradesh'],\n ['UK', 'Uttarakhand'],\n ['WB', 'West Bengal'],\n];\n\n// --- Stripe Element presentation ---------------------------------------------\n// A div that hosts a Stripe Element but reads like a Paragon input.\n// Vertical padding replaces Element `lineHeight` (discouraged by Stripe.js).\nexport const STRIPE_FIELD_STYLE: CSSProperties = {\n height: 'auto',\n minHeight: '2.875rem',\n display: 'flex',\n alignItems: 'center',\n paddingTop: '0.5rem',\n paddingBottom: '0.5rem',\n};\nexport const STRIPE_ELEMENT_OPTS = {\n style: {\n base: {\n fontFamily: 'Inter, system-ui, sans-serif',\n fontSize: '16px',\n fontWeight: '400',\n // Stripe's `lineHeight` requires a fixed unit (not a percentage) — 145% of 16px.\n lineHeight: '23px',\n color: '#1a1a1a',\n '::placeholder': { color: '#6e6e6e' },\n },\n },\n};\n/** cardNumber-only: disableLink is invalid on cardExpiry / cardCvc. */\nexport const STRIPE_CARD_NUMBER_OPTS = {\n ...STRIPE_ELEMENT_OPTS,\n disableLink: true,\n};\n"]}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
.express-checkout {
|
|
4
4
|
position: relative;
|
|
5
|
+
// Lets the button grid react to the card's own width (see the end of file).
|
|
6
|
+
container-type: inline-size;
|
|
5
7
|
border: 1px solid #E7E9EF;
|
|
6
8
|
border-radius: 8px;
|
|
7
9
|
padding: 1.25rem 1rem;
|
|
@@ -121,3 +123,22 @@
|
|
|
121
123
|
grid-template-columns: 1fr !important;
|
|
122
124
|
}
|
|
123
125
|
}
|
|
126
|
+
|
|
127
|
+
// The PayPal SDK never renders its button narrower than 150px. In a narrower
|
|
128
|
+
// column the slot clips it: the right corners go square and the wordmark sits
|
|
129
|
+
// off-centre. Stack the buttons whenever the columns would drop below that.
|
|
130
|
+
// Thresholds: n columns × 150px + (n - 1) × 0.75rem gap.
|
|
131
|
+
$paypal-min-width: 150px;
|
|
132
|
+
$button-gap: 12px;
|
|
133
|
+
|
|
134
|
+
@container (max-width: #{3 * $paypal-min-width + 2 * $button-gap - 0.02px}) {
|
|
135
|
+
.express-checkout__buttons--cols-3 {
|
|
136
|
+
grid-template-columns: 1fr !important;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
@container (max-width: #{2 * $paypal-min-width + $button-gap - 0.02px}) {
|
|
141
|
+
.express-checkout__buttons--cols-2 {
|
|
142
|
+
grid-template-columns: 1fr !important;
|
|
143
|
+
}
|
|
144
|
+
}
|
|
@@ -44,13 +44,15 @@
|
|
|
44
44
|
/* default/box-shadow-default */
|
|
45
45
|
box-shadow: 0 3px 6px 0 rgba(0, 0, 0, 0.02), 0 1px 1px 0 rgba(0, 0, 0, 0.03);
|
|
46
46
|
|
|
47
|
-
//
|
|
48
|
-
//
|
|
49
|
-
|
|
47
|
+
// Key off Stripe's own focus class, not :focus-within. Tabbing in from
|
|
48
|
+
// outside the card fields (Tab from PayPal, Shift+Tab from Country)
|
|
49
|
+
// lands on Stripe's helper input first, which hands focus to the
|
|
50
|
+
// iframe — and Chrome then drops :focus-within from the wrapper.
|
|
51
|
+
&:has(.StripeElement--focus) {
|
|
50
52
|
@include focus.stripe-field-focus;
|
|
51
53
|
}
|
|
52
54
|
|
|
53
|
-
&.payment--field__input--error:focus
|
|
55
|
+
&.payment--field__input--error:has(.StripeElement--focus) {
|
|
54
56
|
@include focus.error-field-focus;
|
|
55
57
|
}
|
|
56
58
|
}
|