@edx/frontend-app-alacarte-checkout 1.75.0 → 1.77.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.
@@ -272,10 +272,13 @@ const Checkout = (_a) => {
272
272
  const handleSeeMyCourses = () => {
273
273
  window.location.href = learnerDashboardUrl || homeUrl || '/';
274
274
  };
275
- const { paymentTimedOut } = alacarte;
275
+ const handleReturnToHomepage = () => {
276
+ window.location.href = homeUrl || '/';
277
+ };
278
+ const { paymentTimedOut, checkoutPaused } = alacarte;
276
279
  // Grey out and block the form + summary. The header (h1 + alerts) sits
277
280
  // outside the overlay so its text keeps full contrast.
278
- const isLocked = isAlreadyOwned || paymentTimedOut;
281
+ const isLocked = isAlreadyOwned || paymentTimedOut || checkoutPaused;
279
282
  // The overlay only blocks the pointer — inert takes the locked content out
280
283
  // of the tab order too.
281
284
  const lockedInertRef = useInert(isLocked);
@@ -345,7 +348,7 @@ const Checkout = (_a) => {
345
348
  // Price differs from what the learner viewed before checkout (ALC-159).
346
349
  const showPriceChangedAlert = !!alacarte.priceChanged && !dismissedPriceChange && !isLocked;
347
350
  const priceChangedKind = isProgramProduct ? 'program' : 'course';
348
- return (_jsxs(_Fragment, { children: [alacarteDebug, _jsxs(Row, { className: "checkout__container bg-light-200", children: [alacarte.sanctionsBlocked && (_jsx(OrderBlockedModal, { isOpen: true, referenceCode: alacarte.sanctionsBlocked.referenceCode, homeUrl: homeUrl })), alacarte.purchaseBlocked && (_jsx(PurchaseBlockedModal, { isOpen: true, homeUrl: homeUrl })), _jsx(Col, { xs: 12, children: _jsxs(Row, { className: "checkout__layout", children: [_jsx(Col, { xs: 12, className: "checkout__header", children: _jsxs("div", { children: [_jsx("h1", { className: "font-weight-bold text-primary-900 mb-lg-4", children: "Checkout" }), paymentTimedOut && (_jsx(PaymentTimeoutAlert, { className: "checkout__overlay-alert mb-3" })), isAlreadyOwned && (_jsxs(Alert, { variant: "danger", icon: ErrorIcon, className: "checkout__overlay-alert mb-3", "data-testid": "already-owned-alert", children: [_jsx("p", { className: "mb-3", children: alreadyOwnedMessage }), _jsxs("div", { className: "d-flex align-items-center justify-content-end gap-3 flex-wrap", children: [orderHistoryUrl && (_jsx("a", { href: orderHistoryUrl, className: "checkout__order-history text-gray-900 font-weight-bold", children: formatMessage(messages.viewOrderHistory) })), isAlreadyOwnedProgram ? (_jsx(Button, { variant: "brand", className: "rounded-pill", onClick: handleSeeMyCourses, children: formatMessage(messages.seeMyCourses) })) : (_jsx(Button, { variant: "brand", className: "rounded-pill", onClick: handleStartCourse, children: formatMessage(messages.goToCourse) }))] })] })), c.error && (_jsx(Alert, { variant: "danger", icon: ErrorIcon, dismissible: true, onClose: c.clearError, children: c.error })), alacarte.placeOrderError && (_jsx(Alert, { variant: "danger", icon: ErrorIcon, dismissible: true, onClose: alacarte.clearPlaceOrderError, className: "mb-3", children: alacarte.placeOrderError })), ((_w = alacarte.paymentDecline) === null || _w === void 0 ? void 0 : _w.message) && !alacarte.placeOrderError && !paymentTimedOut && (_jsx(Alert, { variant: "danger", icon: ErrorIcon, className: "mb-3", "data-testid": "payment-decline-alert", children: getLearnerFacingStripeMessage({
351
+ return (_jsxs(_Fragment, { children: [alacarteDebug, _jsxs(Row, { className: "checkout__container bg-light-200", children: [alacarte.sanctionsBlocked && (_jsx(OrderBlockedModal, { isOpen: true, referenceCode: alacarte.sanctionsBlocked.referenceCode, homeUrl: homeUrl })), alacarte.purchaseBlocked && (_jsx(PurchaseBlockedModal, { isOpen: true, homeUrl: homeUrl })), _jsx(Col, { xs: 12, children: _jsxs(Row, { className: "checkout__layout", children: [_jsx(Col, { xs: 12, className: "checkout__header", children: _jsxs("div", { children: [_jsx("h1", { className: "font-weight-bold text-primary-900 mb-lg-4", children: "Checkout" }), paymentTimedOut && (_jsx(PaymentTimeoutAlert, { className: "checkout__overlay-alert mb-3" })), checkoutPaused && (_jsxs(Alert, { variant: "danger", icon: ErrorIcon, className: "checkout__overlay-alert mb-3", "data-testid": "checkout-paused-alert", children: [_jsx("p", { className: "mb-3", children: formatMessage(messages.checkoutPaused) }), _jsx("div", { className: "d-flex align-items-center justify-content-end", children: _jsx(Button, { variant: "brand", className: "rounded-pill", onClick: handleReturnToHomepage, children: formatMessage(messages.returnToHomepage) }) })] })), isAlreadyOwned && !checkoutPaused && (_jsxs(Alert, { variant: "danger", icon: ErrorIcon, className: "checkout__overlay-alert mb-3", "data-testid": "already-owned-alert", children: [_jsx("p", { className: "mb-3", children: alreadyOwnedMessage }), _jsxs("div", { className: "d-flex align-items-center justify-content-end gap-3 flex-wrap", children: [orderHistoryUrl && (_jsx("a", { href: orderHistoryUrl, className: "checkout__order-history text-gray-900 font-weight-bold", children: formatMessage(messages.viewOrderHistory) })), isAlreadyOwnedProgram ? (_jsx(Button, { variant: "brand", className: "rounded-pill", onClick: handleSeeMyCourses, children: formatMessage(messages.seeMyCourses) })) : (_jsx(Button, { variant: "brand", className: "rounded-pill", onClick: handleStartCourse, children: formatMessage(messages.goToCourse) }))] })] })), c.error && (_jsx(Alert, { variant: "danger", icon: ErrorIcon, dismissible: true, onClose: c.clearError, children: c.error })), alacarte.placeOrderError && (_jsx(Alert, { variant: "danger", icon: ErrorIcon, dismissible: true, onClose: alacarte.clearPlaceOrderError, className: "mb-3", children: alacarte.placeOrderError })), ((_w = alacarte.paymentDecline) === null || _w === void 0 ? void 0 : _w.message) && !alacarte.placeOrderError && !paymentTimedOut && (_jsx(Alert, { variant: "danger", icon: ErrorIcon, className: "mb-3", "data-testid": "payment-decline-alert", children: getLearnerFacingStripeMessage({
349
352
  message: alacarte.paymentDecline.message,
350
353
  code: (_x = alacarte.paymentDecline.code) !== null && _x !== void 0 ? _x : undefined,
351
354
  }) })), alacarte.paymentInterrupted && !alacarte.paymentDecline && !alacarte.placeOrderError && !paymentTimedOut && (_jsx(Alert, { variant: "danger", icon: ErrorIcon, dismissible: true, onClose: alacarte.clearPaymentInterrupted, className: "mb-3", "data-testid": "payment-interrupted-alert", children: formatMessage(messages.paymentInterruptedAlert) })), alacarte.walletPaymentCancelled && !alacarte.paymentInterrupted
@@ -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,OAAO,YAAY,MAAM,8BAA8B,CAAC;AACxD,4FAA4F;AAC5F,OAAO,iBAAiB,MAAM,wCAAwC,CAAC;AACvE,OAAO,oBAAoB,MAAM,8CAA8C,CAAC;AAChF,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,EAAE,+BAA+B,EAAE,M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AAC,CAAC,CAAC,QAAQ,CAAC,0BAA0B,CAAC,CAAC,CAAC,SAAS,EAClF,cAAc,EAAE,cAAc,EAC9B,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,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';\nimport ZeroCostForm from '../ZeroCostForm/ZeroCostForm';\n// import CountryUnavailableModal from '../CountryUnavailableModal/CountryUnavailableModal';\nimport OrderBlockedModal from '../OrderBlockedModal/OrderBlockedModal';\nimport PurchaseBlockedModal from '../PurchaseBlockedModal/PurchaseBlockedModal';\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 /** Learner dashboard URL — session-error recovery link and \"See my courses\" on the already-owned program alert. */\n learnerDashboardUrl?: string,\n /** PayPal JS SDK client id — enables the express PayPal button. */\n paypalClientId?: string,\n};\n\nconst Checkout = ({\n homeUrl = '/',\n orderHistoryUrl,\n learnerDashboardUrl,\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 const [dismissedAutomaticOfferAlert, setDismissedAutomaticOfferAlert] = useState<string | null>(null);\n // Code the learner last submitted with Apply (cleared on Remove).\n const [learnerAppliedCode, setLearnerAppliedCode] = useState<string | null>(null);\n // Set by the learner's own Apply / Remove, so the coupon alert it produces\n // takes focus (a coupon applied on load doesn't). By the time the alert\n // mounts, couponApplying has already gone false, so it can't drive this.\n const [focusCouponAlert, setFocusCouponAlert] = useState(false);\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 // Some codes are configured as offers, so the backend reports\n // discountSource \"automatic\" even when the learner typed the code. A code\n // the learner applied themselves is always shown as a coupon.\n // Nothing to pay (e.g. a 100% coupon): the payment form is swapped for a\n // country select and Buy now — no payment method is collected. Not for an\n // already-owned product, which can also come to $0 (program deductions).\n const zeroAmountDue = alacarte.phase === 'ready' && !!alacarte.checkout && alacarte.line?.amountDue\n && Math.abs(alacarte.line.amountDue.amount) < 0.005\n ? alacarte.line.amountDue\n : null;\n const isZeroTotal = !!zeroAmountDue;\n const appliedByLearner = !!appliedCouponCode && !!learnerAppliedCode\n && appliedCouponCode.toLowerCase() === learnerAppliedCode.toLowerCase();\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 && (appliedByLearner || (\n alacarte.line.discountSource !== 'automatic'\n && (alacarte.line.discountSource === 'coupon' || !!appliedCouponCode)\n ));\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 // Automatic offer (no code entered): announced with its own success alert.\n const automaticOfferCode = !isCouponDiscount\n && alacarte.line?.discountSource === 'automatic' && alacarte.line.discount\n ? (appliedCouponCode ?? alacarte.line.discountName?.trim()) || null\n : null;\n const automaticOffer = automaticOfferCode && discountPercent != null\n ? { code: automaticOfferCode, percent: discountPercent }\n : null;\n\n // Reset once the coupon is actually gone, not on the Remove click: while\n // the removal is pending the coupon is still applied, and resetting early\n // flashes its applied alert (or, for a code the backend reports as\n // automatic, the automatic one). The applied alert auto-dismisses, so\n // re-applying the same code must be able to show it again.\n useEffect(() => {\n if (appliedCouponCode) return;\n setDismissedCouponAlert(null);\n setLearnerAppliedCode(null);\n }, [appliedCouponCode]);\n\n // An automatic offer left in place after a coupon removal is announced\n // again once the removed alert closes, so the learner sees why a discount\n // remains even if its alert already dismissed itself on load.\n useEffect(() => {\n if (alacarte.removedCouponCode) setDismissedAutomaticOfferAlert(null);\n }, [alacarte.removedCouponCode]);\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 // $0 order: tCheckoutPlaceOrder runs the sanctions check and places the\n // order without a charge. Only the country is collected, so the card form's\n // billing fields are not sent.\n const handleZeroCostBuyNow = (country: string) => {\n alacarte.placeOrder({\n billing: {\n firstName: '', lastName: '', line1: '', city: '', state: '', zip: '', country,\n },\n // A client secret means the backend expects a charge after all — there\n // is no card form to confirm it with.\n confirmCardPayment: async () => {\n throw new Error(formatMessage(messages.zeroCostPaymentRequired));\n },\n });\n };\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 // Fully-owned program: name the program and how many certificates it has.\n // The line may be synthetic (built from owned products), so fall back to the\n // owned-product name and the owned-course count.\n const isAlreadyOwnedProgram = isAlreadyOwned && alacarte.selector?.kind === 'program';\n const ownedProgramName = (alacarte.line?.kind === 'program' ? alacarte.line.programName : null)\n || alacarte.ownedProductName;\n const ownedProgramCertificateCount = alacarteProgramDetail?.tCourses.length\n || (alacarte.line?.kind === 'program' ? alacarte.line.ownedCourses?.length : null)\n || null;\n const alreadyOwnedMessage = !isAlreadyOwnedProgram\n ? formatMessage(messages.alreadyPaidCourse)\n : ownedProgramName && ownedProgramCertificateCount\n ? formatMessage(messages.alreadyPaidAllProgramCertificates, {\n certificateCount: ownedProgramCertificateCount,\n programName: ownedProgramName,\n })\n : formatMessage(messages.alreadyPaidProgram);\n const handleSeeMyCourses = () => {\n window.location.href = learnerDashboardUrl || homeUrl || '/';\n };\n const { paymentTimedOut } = alacarte;\n // Grey out and block the form + summary. The header (h1 + alerts) sits\n // outside the overlay so its text keeps full contrast.\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 // The validation alert belongs to the payment form — drop it while the\n // form is swapped out so it doesn't come back stale.\n useEffect(() => {\n if (isZeroTotal) setValidationRequest(0);\n }, [isZeroTotal]);\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 // getTwouOrder 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 const coursePageUrl = alacarte.productDetail && 'tUrlCourse' in alacarte.productDetail\n ? alacarte.productDetail.tUrlCourse\n : null;\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 {alacarte.isRunBlocked && coursePageUrl && (\n <a href={coursePageUrl} className=\"alert-link\" data-testid=\"choose-another-session-link\">\n Choose another session\n </a>\n )}\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 {alacarte.purchaseBlocked && (\n <PurchaseBlockedModal\n isOpen\n homeUrl={homeUrl}\n />\n )}\n <Col xs={12}>\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\">{alreadyOwnedMessage}</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 {isAlreadyOwnedProgram ? (\n <Button variant=\"brand\" className=\"rounded-pill\" onClick={handleSeeMyCourses}>\n {formatMessage(messages.seeMyCourses)}\n </Button>\n ) : (\n <Button variant=\"brand\" className=\"rounded-pill\" onClick={handleStartCourse}>\n {formatMessage(messages.goToCourse)}\n </Button>\n )}\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 {showPriceChangedAlert && (\n <PriceChangedAlert\n kind={priceChangedKind}\n onDismiss={() => setDismissedPriceChange(true)}\n className=\"mb-3\"\n />\n )}\n\n {showForm && (\n <>\n {!zeroAmountDue && (\n <PaymentValidationAlert\n fields={invalidPaymentFields}\n country={c.billing.country}\n focusRequest={validationRequest}\n onFieldSelect={focusPaymentField}\n className=\"mb-3\"\n />\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={() => {\n setDismissedCouponAlert(appliedCouponCode);\n setFocusCouponAlert(false);\n }}\n className=\"coupon-applied-alert\"\n data-testid=\"coupon-applied-alert\"\n role=\"status\"\n // Only the learner's own Apply takes focus here, so\n // screen readers read the alert, not Remove.\n focusOnMount={focusCouponAlert}\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 {/* Coupon alerts don't stack: the removed alert goes first, then this one. */}\n {automaticOffer && dismissedAutomaticOfferAlert !== automaticOffer.code\n && !alacarte.removedCouponCode && (\n <AutoDismissAlert\n key={`automatic-${automaticOffer.code}`}\n variant=\"success\"\n icon={CheckCircle}\n dismissible\n closeLabel={formatMessage(messages.dismiss)}\n onClose={() => setDismissedAutomaticOfferAlert(automaticOffer.code)}\n className=\"coupon-applied-alert\"\n data-testid=\"automatic-coupon-applied-alert\"\n role=\"status\"\n // Not the learner's own action — don't steal focus.\n focusOnMount={false}\n returnFocus={focusCouponControl}\n >\n <span aria-hidden=\"true\">🎉 </span>\n {formatMessage(messages.automaticCouponAppliedAlert, {\n code: automaticOffer.code,\n percent: automaticOffer.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={() => {\n alacarte.clearRemovedCouponCode();\n setFocusCouponAlert(false);\n }}\n className=\"coupon-removed-alert\"\n data-testid=\"coupon-removed-alert\"\n role=\"status\"\n focusOnMount={focusCouponAlert}\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\n ref={lockedInertRef}\n className={isLocked ? 'checkout__locked-overlay' : undefined}\n data-testid=\"checkout-summary-region\"\n >\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: () => {\n setFocusCouponAlert(true);\n setLearnerAppliedCode(promoCodeValue.trim());\n alacarte.applyCoupon(promoCodeValue);\n },\n onRemove: () => {\n setFocusCouponAlert(true);\n alacarte.removeCoupon();\n setPromoCodeValue('');\n setAdvertisedOffer(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\n ref={lockedInertRef}\n className={isLocked ? 'checkout__locked-overlay' : undefined}\n data-testid=\"checkout-payment-region\"\n >\n {showForm && zeroAmountDue && (\n <ZeroCostForm\n amountDue={zeroAmountDue}\n submitting={alacarte.placingOrder || alacarte.awaitingPlacedOrder}\n onBuyNow={handleZeroCostBuyNow}\n />\n )}\n {showForm && !zeroAmountDue && (\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 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,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,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AAe,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,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';\nimport ZeroCostForm from '../ZeroCostForm/ZeroCostForm';\n// import CountryUnavailableModal from '../CountryUnavailableModal/CountryUnavailableModal';\nimport OrderBlockedModal from '../OrderBlockedModal/OrderBlockedModal';\nimport PurchaseBlockedModal from '../PurchaseBlockedModal/PurchaseBlockedModal';\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 /** Learner dashboard URL — session-error recovery link and \"See my courses\" on the already-owned program alert. */\n learnerDashboardUrl?: string,\n /** PayPal JS SDK client id — enables the express PayPal button. */\n paypalClientId?: string,\n};\n\nconst Checkout = ({\n homeUrl = '/',\n orderHistoryUrl,\n learnerDashboardUrl,\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 const [dismissedAutomaticOfferAlert, setDismissedAutomaticOfferAlert] = useState<string | null>(null);\n // Code the learner last submitted with Apply (cleared on Remove).\n const [learnerAppliedCode, setLearnerAppliedCode] = useState<string | null>(null);\n // Set by the learner's own Apply / Remove, so the coupon alert it produces\n // takes focus (a coupon applied on load doesn't). By the time the alert\n // mounts, couponApplying has already gone false, so it can't drive this.\n const [focusCouponAlert, setFocusCouponAlert] = useState(false);\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 // Some codes are configured as offers, so the backend reports\n // discountSource \"automatic\" even when the learner typed the code. A code\n // the learner applied themselves is always shown as a coupon.\n // Nothing to pay (e.g. a 100% coupon): the payment form is swapped for a\n // country select and Buy now — no payment method is collected. Not for an\n // already-owned product, which can also come to $0 (program deductions).\n const zeroAmountDue = alacarte.phase === 'ready' && !!alacarte.checkout && alacarte.line?.amountDue\n && Math.abs(alacarte.line.amountDue.amount) < 0.005\n ? alacarte.line.amountDue\n : null;\n const isZeroTotal = !!zeroAmountDue;\n const appliedByLearner = !!appliedCouponCode && !!learnerAppliedCode\n && appliedCouponCode.toLowerCase() === learnerAppliedCode.toLowerCase();\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 && (appliedByLearner || (\n alacarte.line.discountSource !== 'automatic'\n && (alacarte.line.discountSource === 'coupon' || !!appliedCouponCode)\n ));\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 // Automatic offer (no code entered): announced with its own success alert.\n const automaticOfferCode = !isCouponDiscount\n && alacarte.line?.discountSource === 'automatic' && alacarte.line.discount\n ? (appliedCouponCode ?? alacarte.line.discountName?.trim()) || null\n : null;\n const automaticOffer = automaticOfferCode && discountPercent != null\n ? { code: automaticOfferCode, percent: discountPercent }\n : null;\n\n // Reset once the coupon is actually gone, not on the Remove click: while\n // the removal is pending the coupon is still applied, and resetting early\n // flashes its applied alert (or, for a code the backend reports as\n // automatic, the automatic one). The applied alert auto-dismisses, so\n // re-applying the same code must be able to show it again.\n useEffect(() => {\n if (appliedCouponCode) return;\n setDismissedCouponAlert(null);\n setLearnerAppliedCode(null);\n }, [appliedCouponCode]);\n\n // An automatic offer left in place after a coupon removal is announced\n // again once the removed alert closes, so the learner sees why a discount\n // remains even if its alert already dismissed itself on load.\n useEffect(() => {\n if (alacarte.removedCouponCode) setDismissedAutomaticOfferAlert(null);\n }, [alacarte.removedCouponCode]);\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 // $0 order: tCheckoutPlaceOrder runs the sanctions check and places the\n // order without a charge. Only the country is collected, so the card form's\n // billing fields are not sent.\n const handleZeroCostBuyNow = (country: string) => {\n alacarte.placeOrder({\n billing: {\n firstName: '', lastName: '', line1: '', city: '', state: '', zip: '', country,\n },\n // A client secret means the backend expects a charge after all — there\n // is no card form to confirm it with.\n confirmCardPayment: async () => {\n throw new Error(formatMessage(messages.zeroCostPaymentRequired));\n },\n });\n };\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 // Fully-owned program: name the program and how many certificates it has.\n // The line may be synthetic (built from owned products), so fall back to the\n // owned-product name and the owned-course count.\n const isAlreadyOwnedProgram = isAlreadyOwned && alacarte.selector?.kind === 'program';\n const ownedProgramName = (alacarte.line?.kind === 'program' ? alacarte.line.programName : null)\n || alacarte.ownedProductName;\n const ownedProgramCertificateCount = alacarteProgramDetail?.tCourses.length\n || (alacarte.line?.kind === 'program' ? alacarte.line.ownedCourses?.length : null)\n || null;\n const alreadyOwnedMessage = !isAlreadyOwnedProgram\n ? formatMessage(messages.alreadyPaidCourse)\n : ownedProgramName && ownedProgramCertificateCount\n ? formatMessage(messages.alreadyPaidAllProgramCertificates, {\n certificateCount: ownedProgramCertificateCount,\n programName: ownedProgramName,\n })\n : formatMessage(messages.alreadyPaidProgram);\n const handleSeeMyCourses = () => {\n window.location.href = learnerDashboardUrl || homeUrl || '/';\n };\n const handleReturnToHomepage = () => {\n window.location.href = homeUrl || '/';\n };\n const { paymentTimedOut, checkoutPaused } = alacarte;\n // Grey out and block the form + summary. The header (h1 + alerts) sits\n // outside the overlay so its text keeps full contrast.\n const isLocked = isAlreadyOwned || paymentTimedOut || checkoutPaused;\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 // The validation alert belongs to the payment form — drop it while the\n // form is swapped out so it doesn't come back stale.\n useEffect(() => {\n if (isZeroTotal) setValidationRequest(0);\n }, [isZeroTotal]);\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 // getTwouOrder 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 const coursePageUrl = alacarte.productDetail && 'tUrlCourse' in alacarte.productDetail\n ? alacarte.productDetail.tUrlCourse\n : null;\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 {alacarte.isRunBlocked && coursePageUrl && (\n <a href={coursePageUrl} className=\"alert-link\" data-testid=\"choose-another-session-link\">\n Choose another session\n </a>\n )}\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 {alacarte.purchaseBlocked && (\n <PurchaseBlockedModal\n isOpen\n homeUrl={homeUrl}\n />\n )}\n <Col xs={12}>\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 {checkoutPaused && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n className=\"checkout__overlay-alert mb-3\"\n data-testid=\"checkout-paused-alert\"\n >\n <p className=\"mb-3\">{formatMessage(messages.checkoutPaused)}</p>\n <div className=\"d-flex align-items-center justify-content-end\">\n <Button variant=\"brand\" className=\"rounded-pill\" onClick={handleReturnToHomepage}>\n {formatMessage(messages.returnToHomepage)}\n </Button>\n </div>\n </Alert>\n )}\n\n {isAlreadyOwned && !checkoutPaused && (\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\">{alreadyOwnedMessage}</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 {isAlreadyOwnedProgram ? (\n <Button variant=\"brand\" className=\"rounded-pill\" onClick={handleSeeMyCourses}>\n {formatMessage(messages.seeMyCourses)}\n </Button>\n ) : (\n <Button variant=\"brand\" className=\"rounded-pill\" onClick={handleStartCourse}>\n {formatMessage(messages.goToCourse)}\n </Button>\n )}\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 {showPriceChangedAlert && (\n <PriceChangedAlert\n kind={priceChangedKind}\n onDismiss={() => setDismissedPriceChange(true)}\n className=\"mb-3\"\n />\n )}\n\n {showForm && (\n <>\n {!zeroAmountDue && (\n <PaymentValidationAlert\n fields={invalidPaymentFields}\n country={c.billing.country}\n focusRequest={validationRequest}\n onFieldSelect={focusPaymentField}\n className=\"mb-3\"\n />\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={() => {\n setDismissedCouponAlert(appliedCouponCode);\n setFocusCouponAlert(false);\n }}\n className=\"coupon-applied-alert\"\n data-testid=\"coupon-applied-alert\"\n role=\"status\"\n // Only the learner's own Apply takes focus here, so\n // screen readers read the alert, not Remove.\n focusOnMount={focusCouponAlert}\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 {/* Coupon alerts don't stack: the removed alert goes first, then this one. */}\n {automaticOffer && dismissedAutomaticOfferAlert !== automaticOffer.code\n && !alacarte.removedCouponCode && (\n <AutoDismissAlert\n key={`automatic-${automaticOffer.code}`}\n variant=\"success\"\n icon={CheckCircle}\n dismissible\n closeLabel={formatMessage(messages.dismiss)}\n onClose={() => setDismissedAutomaticOfferAlert(automaticOffer.code)}\n className=\"coupon-applied-alert\"\n data-testid=\"automatic-coupon-applied-alert\"\n role=\"status\"\n // Not the learner's own action — don't steal focus.\n focusOnMount={false}\n returnFocus={focusCouponControl}\n >\n <span aria-hidden=\"true\">🎉 </span>\n {formatMessage(messages.automaticCouponAppliedAlert, {\n code: automaticOffer.code,\n percent: automaticOffer.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={() => {\n alacarte.clearRemovedCouponCode();\n setFocusCouponAlert(false);\n }}\n className=\"coupon-removed-alert\"\n data-testid=\"coupon-removed-alert\"\n role=\"status\"\n focusOnMount={focusCouponAlert}\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\n ref={lockedInertRef}\n className={isLocked ? 'checkout__locked-overlay' : undefined}\n data-testid=\"checkout-summary-region\"\n >\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: () => {\n setFocusCouponAlert(true);\n setLearnerAppliedCode(promoCodeValue.trim());\n alacarte.applyCoupon(promoCodeValue);\n },\n onRemove: () => {\n setFocusCouponAlert(true);\n alacarte.removeCoupon();\n setPromoCodeValue('');\n setAdvertisedOffer(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\n ref={lockedInertRef}\n className={isLocked ? 'checkout__locked-overlay' : undefined}\n data-testid=\"checkout-payment-region\"\n >\n {showForm && zeroAmountDue && (\n <ZeroCostForm\n amountDue={zeroAmountDue}\n submitting={alacarte.placingOrder || alacarte.awaitingPlacedOrder}\n onBuyNow={handleZeroCostBuyNow}\n />\n )}\n {showForm && !zeroAmountDue && (\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 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"]}
@@ -69,5 +69,15 @@ declare const messages: {
69
69
  defaultMessage: string;
70
70
  description: string;
71
71
  };
72
+ checkoutPaused: {
73
+ id: string;
74
+ defaultMessage: string;
75
+ description: string;
76
+ };
77
+ returnToHomepage: {
78
+ id: string;
79
+ defaultMessage: string;
80
+ description: string;
81
+ };
72
82
  };
73
83
  export default messages;
@@ -70,6 +70,16 @@ const messages = defineMessages({
70
70
  defaultMessage: 'See my courses',
71
71
  description: 'Button to open the learner dashboard on the already-paid program alert',
72
72
  },
73
+ checkoutPaused: {
74
+ id: 'checkout.checkoutPaused.message',
75
+ defaultMessage: 'Checkout is temporarily unavailable. Please try again later.',
76
+ description: 'Blocking alert shown when checkout has been paused (CHECKOUT_PAUSED)',
77
+ },
78
+ returnToHomepage: {
79
+ id: 'checkout.checkoutPaused.returnToHomepage',
80
+ defaultMessage: 'Return to homepage',
81
+ description: 'Button on the checkout-paused alert that navigates the learner to the edX homepage',
82
+ },
73
83
  });
74
84
  export default messages;
75
85
  //# sourceMappingURL=Messages.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"Messages.js","sourceRoot":"","sources":["../../../src/components/Checkout/Messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,QAAQ,GAAG,cAAc,CAAC;IAC9B,4BAA4B,EAAE;QAC5B,EAAE,EAAE,mDAAmD;QACvD,cAAc,EAAE,oFAAoF;QACpG,WAAW,EAAE,gCAAgC;KAC9C;IACD,uBAAuB,EAAE;QACvB,EAAE,EAAE,kCAAkC;QACtC,cAAc,EAAE,kEAAkE;QAClF,WAAW,EAAE,0EAA0E;KACxF;IACD,uBAAuB,EAAE;QACvB,EAAE,EAAE,kCAAkC;QACtC,cAAc,EAAE,uGAAuG;QACvH,WAAW,EAAE,6EAA6E;KAC3F;IACD,2BAA2B,EAAE;QAC3B,EAAE,EAAE,sCAAsC;QAC1C,cAAc,EAAE,uFAAuF;QACvG,WAAW,EAAE,qFAAqF;KACnG;IACD,kBAAkB,EAAE;QAClB,EAAE,EAAE,6BAA6B;QACjC,cAAc,EAAE,gDAAgD;QAChE,WAAW,EAAE,sHAAsH;KACpI;IACD,2BAA2B,EAAE;QAC3B,EAAE,EAAE,sCAAsC;QAC1C,cAAc,EAAE,8DAA8D;QAC9E,WAAW,EAAE,kLAAkL;KAChM;IACD,kBAAkB,EAAE;QAClB,EAAE,EAAE,6BAA6B;QACjC,cAAc,EAAE,gDAAgD;QAChE,WAAW,EAAE,qEAAqE;KACnF;IACD,OAAO,EAAE;QACP,EAAE,EAAE,qCAAqC;QACzC,cAAc,EAAE,SAAS;QACzB,WAAW,EAAE,yCAAyC;KACvD;IACD,iBAAiB,EAAE;QACjB,EAAE,EAAE,6BAA6B;QACjC,cAAc,EAAE,sEAAsE;QACtF,WAAW,EAAE,sDAAsD;KACpE;IACD,kBAAkB,EAAE;QAClB,EAAE,EAAE,8BAA8B;QAClC,cAAc,EAAE,uEAAuE;QACvF,WAAW,EAAE,wGAAwG;KACtH;IACD,iCAAiC,EAAE;QACjC,EAAE,EAAE,6CAA6C;QACjD,cAAc,EAAE,qGAAqG;QACrH,WAAW,EAAE,qFAAqF;KACnG;IACD,gBAAgB,EAAE;QAChB,EAAE,EAAE,uCAAuC;QAC3C,cAAc,EAAE,oBAAoB;QACpC,WAAW,EAAE,iDAAiD;KAC/D;IACD,UAAU,EAAE;QACV,EAAE,EAAE,iCAAiC;QACrC,cAAc,EAAE,cAAc;QAC9B,WAAW,EAAE,4DAA4D;KAC1E;IACD,YAAY,EAAE;QACZ,EAAE,EAAE,mCAAmC;QACvC,cAAc,EAAE,gBAAgB;QAChC,WAAW,EAAE,wEAAwE;KACtF;CACF,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { defineMessages } from '@openedx/frontend-base';\n\nconst messages = defineMessages({\n paymentProcessingDescription: {\n id: 'checkout.paymentForm.paymentProcessingdescription',\n defaultMessage: 'Your payment could not be processed. Please check your card details and try again.',\n description: 'Payment processing description',\n },\n zeroCostPaymentRequired: {\n id: 'checkout.zeroCostPaymentRequired',\n defaultMessage: 'This order now requires payment. Refresh the page and try again.',\n description: 'Error shown when a $0 order unexpectedly needs a card payment at Buy now',\n },\n paymentInterruptedAlert: {\n id: 'checkout.paymentInterruptedAlert',\n defaultMessage: \"Your payment wasn't completed, and you haven't been charged. Try again or use another payment method.\",\n description: 'Alert shown when the learner returns to checkout without completing payment',\n },\n walletPaymentCancelledAlert: {\n id: 'checkout.walletPaymentCancelledAlert',\n defaultMessage: \"Your payment wasn't completed. You haven't been charged and your order is still here.\",\n description: 'Alert shown when the learner closes the Apple Pay / Google Pay sheet without paying',\n },\n couponAppliedAlert: {\n id: 'checkout.couponAppliedAlert',\n defaultMessage: 'Coupon code {code} applied for {percent}% off!',\n description: 'Success alert shown at the top of checkout after a coupon is applied, e.g. \"Coupon code SAVE15 applied for 15% off!\"',\n },\n automaticCouponAppliedAlert: {\n id: 'checkout.automaticCouponAppliedAlert',\n defaultMessage: 'Coupon code {code} automatically applied for {percent}% off!',\n description: 'Success alert shown at the top of checkout when an automatic offer is applied without the learner entering a code, e.g. \"Coupon code NEW2EDX automatically applied for 30% off!\"',\n },\n couponRemovedAlert: {\n id: 'checkout.couponRemovedAlert',\n defaultMessage: 'Coupon code {code} was removed from your cart.',\n description: 'Success alert shown above payment methods after a coupon is removed',\n },\n dismiss: {\n id: 'checkout.couponAppliedAlert.dismiss',\n defaultMessage: 'Dismiss',\n description: 'Closes the coupon-applied success alert',\n },\n alreadyPaidCourse: {\n id: 'checkout.alreadyPaid.course',\n defaultMessage: \"You've already paid for this course. You haven't been charged again.\",\n description: 'Alert shown when the learner already owns the course',\n },\n alreadyPaidProgram: {\n id: 'checkout.alreadyPaid.program',\n defaultMessage: \"You've already paid for this program. You haven't been charged again.\",\n description: 'Alert shown when the learner already owns the program but its name or certificate count is unavailable',\n },\n alreadyPaidAllProgramCertificates: {\n id: 'checkout.alreadyPaid.programAllCertificates',\n defaultMessage: \"You've purchased all {certificateCount} certificates {programName}, so there's nothing left to buy.\",\n description: 'Alert shown when the learner already owns every course (certificate) in the program',\n },\n viewOrderHistory: {\n id: 'checkout.alreadyPaid.viewOrderHistory',\n defaultMessage: 'View order history',\n description: 'Link to order history on the already-paid alert',\n },\n goToCourse: {\n id: 'checkout.alreadyPaid.goToCourse',\n defaultMessage: 'Go to course',\n description: 'Button to navigate to the course on the already-paid alert',\n },\n seeMyCourses: {\n id: 'checkout.alreadyPaid.seeMyCourses',\n defaultMessage: 'See my courses',\n description: 'Button to open the learner dashboard on the already-paid program alert',\n },\n});\n\nexport default messages;\n"]}
1
+ {"version":3,"file":"Messages.js","sourceRoot":"","sources":["../../../src/components/Checkout/Messages.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,wBAAwB,CAAC;AAExD,MAAM,QAAQ,GAAG,cAAc,CAAC;IAC9B,4BAA4B,EAAE;QAC5B,EAAE,EAAE,mDAAmD;QACvD,cAAc,EAAE,oFAAoF;QACpG,WAAW,EAAE,gCAAgC;KAC9C;IACD,uBAAuB,EAAE;QACvB,EAAE,EAAE,kCAAkC;QACtC,cAAc,EAAE,kEAAkE;QAClF,WAAW,EAAE,0EAA0E;KACxF;IACD,uBAAuB,EAAE;QACvB,EAAE,EAAE,kCAAkC;QACtC,cAAc,EAAE,uGAAuG;QACvH,WAAW,EAAE,6EAA6E;KAC3F;IACD,2BAA2B,EAAE;QAC3B,EAAE,EAAE,sCAAsC;QAC1C,cAAc,EAAE,uFAAuF;QACvG,WAAW,EAAE,qFAAqF;KACnG;IACD,kBAAkB,EAAE;QAClB,EAAE,EAAE,6BAA6B;QACjC,cAAc,EAAE,gDAAgD;QAChE,WAAW,EAAE,sHAAsH;KACpI;IACD,2BAA2B,EAAE;QAC3B,EAAE,EAAE,sCAAsC;QAC1C,cAAc,EAAE,8DAA8D;QAC9E,WAAW,EAAE,kLAAkL;KAChM;IACD,kBAAkB,EAAE;QAClB,EAAE,EAAE,6BAA6B;QACjC,cAAc,EAAE,gDAAgD;QAChE,WAAW,EAAE,qEAAqE;KACnF;IACD,OAAO,EAAE;QACP,EAAE,EAAE,qCAAqC;QACzC,cAAc,EAAE,SAAS;QACzB,WAAW,EAAE,yCAAyC;KACvD;IACD,iBAAiB,EAAE;QACjB,EAAE,EAAE,6BAA6B;QACjC,cAAc,EAAE,sEAAsE;QACtF,WAAW,EAAE,sDAAsD;KACpE;IACD,kBAAkB,EAAE;QAClB,EAAE,EAAE,8BAA8B;QAClC,cAAc,EAAE,uEAAuE;QACvF,WAAW,EAAE,wGAAwG;KACtH;IACD,iCAAiC,EAAE;QACjC,EAAE,EAAE,6CAA6C;QACjD,cAAc,EAAE,qGAAqG;QACrH,WAAW,EAAE,qFAAqF;KACnG;IACD,gBAAgB,EAAE;QAChB,EAAE,EAAE,uCAAuC;QAC3C,cAAc,EAAE,oBAAoB;QACpC,WAAW,EAAE,iDAAiD;KAC/D;IACD,UAAU,EAAE;QACV,EAAE,EAAE,iCAAiC;QACrC,cAAc,EAAE,cAAc;QAC9B,WAAW,EAAE,4DAA4D;KAC1E;IACD,YAAY,EAAE;QACZ,EAAE,EAAE,mCAAmC;QACvC,cAAc,EAAE,gBAAgB;QAChC,WAAW,EAAE,wEAAwE;KACtF;IACD,cAAc,EAAE;QACd,EAAE,EAAE,iCAAiC;QACrC,cAAc,EAAE,8DAA8D;QAC9E,WAAW,EAAE,sEAAsE;KACpF;IACD,gBAAgB,EAAE;QAChB,EAAE,EAAE,0CAA0C;QAC9C,cAAc,EAAE,oBAAoB;QACpC,WAAW,EAAE,oFAAoF;KAClG;CACF,CAAC,CAAC;AAEH,eAAe,QAAQ,CAAC","sourcesContent":["import { defineMessages } from '@openedx/frontend-base';\n\nconst messages = defineMessages({\n paymentProcessingDescription: {\n id: 'checkout.paymentForm.paymentProcessingdescription',\n defaultMessage: 'Your payment could not be processed. Please check your card details and try again.',\n description: 'Payment processing description',\n },\n zeroCostPaymentRequired: {\n id: 'checkout.zeroCostPaymentRequired',\n defaultMessage: 'This order now requires payment. Refresh the page and try again.',\n description: 'Error shown when a $0 order unexpectedly needs a card payment at Buy now',\n },\n paymentInterruptedAlert: {\n id: 'checkout.paymentInterruptedAlert',\n defaultMessage: \"Your payment wasn't completed, and you haven't been charged. Try again or use another payment method.\",\n description: 'Alert shown when the learner returns to checkout without completing payment',\n },\n walletPaymentCancelledAlert: {\n id: 'checkout.walletPaymentCancelledAlert',\n defaultMessage: \"Your payment wasn't completed. You haven't been charged and your order is still here.\",\n description: 'Alert shown when the learner closes the Apple Pay / Google Pay sheet without paying',\n },\n couponAppliedAlert: {\n id: 'checkout.couponAppliedAlert',\n defaultMessage: 'Coupon code {code} applied for {percent}% off!',\n description: 'Success alert shown at the top of checkout after a coupon is applied, e.g. \"Coupon code SAVE15 applied for 15% off!\"',\n },\n automaticCouponAppliedAlert: {\n id: 'checkout.automaticCouponAppliedAlert',\n defaultMessage: 'Coupon code {code} automatically applied for {percent}% off!',\n description: 'Success alert shown at the top of checkout when an automatic offer is applied without the learner entering a code, e.g. \"Coupon code NEW2EDX automatically applied for 30% off!\"',\n },\n couponRemovedAlert: {\n id: 'checkout.couponRemovedAlert',\n defaultMessage: 'Coupon code {code} was removed from your cart.',\n description: 'Success alert shown above payment methods after a coupon is removed',\n },\n dismiss: {\n id: 'checkout.couponAppliedAlert.dismiss',\n defaultMessage: 'Dismiss',\n description: 'Closes the coupon-applied success alert',\n },\n alreadyPaidCourse: {\n id: 'checkout.alreadyPaid.course',\n defaultMessage: \"You've already paid for this course. You haven't been charged again.\",\n description: 'Alert shown when the learner already owns the course',\n },\n alreadyPaidProgram: {\n id: 'checkout.alreadyPaid.program',\n defaultMessage: \"You've already paid for this program. You haven't been charged again.\",\n description: 'Alert shown when the learner already owns the program but its name or certificate count is unavailable',\n },\n alreadyPaidAllProgramCertificates: {\n id: 'checkout.alreadyPaid.programAllCertificates',\n defaultMessage: \"You've purchased all {certificateCount} certificates {programName}, so there's nothing left to buy.\",\n description: 'Alert shown when the learner already owns every course (certificate) in the program',\n },\n viewOrderHistory: {\n id: 'checkout.alreadyPaid.viewOrderHistory',\n defaultMessage: 'View order history',\n description: 'Link to order history on the already-paid alert',\n },\n goToCourse: {\n id: 'checkout.alreadyPaid.goToCourse',\n defaultMessage: 'Go to course',\n description: 'Button to navigate to the course on the already-paid alert',\n },\n seeMyCourses: {\n id: 'checkout.alreadyPaid.seeMyCourses',\n defaultMessage: 'See my courses',\n description: 'Button to open the learner dashboard on the already-paid program alert',\n },\n checkoutPaused: {\n id: 'checkout.checkoutPaused.message',\n defaultMessage: 'Checkout is temporarily unavailable. Please try again later.',\n description: 'Blocking alert shown when checkout has been paused (CHECKOUT_PAUSED)',\n },\n returnToHomepage: {\n id: 'checkout.checkoutPaused.returnToHomepage',\n defaultMessage: 'Return to homepage',\n description: 'Button on the checkout-paused alert that navigates the learner to the edX homepage',\n },\n});\n\nexport default messages;\n"]}
@@ -1,6 +1,6 @@
1
1
  import type { AlacarteCheckout, AlacarteCheckoutResult, AlacarteLine, AlacartePaymentDecline, AlacartePriceChanged, OwnedProductResult, PlacedOrder, ProductDetail, ProductSelector } from '../../types/alacarte';
2
2
  import type { BillingInfo } from '../../types';
3
- export type AlacartePhase = 'loading' | 'alreadyOwned' | 'noActiveCheckout' | 'notPurchasable' | 'ready' | 'error';
3
+ export type AlacartePhase = 'loading' | 'alreadyOwned' | 'noActiveCheckout' | 'notPurchasable' | 'checkoutPaused' | 'ready' | 'error';
4
4
  export type AlacarteNoticeMessageId = 'alreadyOwnedCourse' | 'alreadyOwnedProgram' | 'noActiveCheckout';
5
5
  /** Pure phase decision output — no action callbacks. */
6
6
  export interface AlacartePhaseState {
@@ -97,6 +97,9 @@ export interface UseAlacarteCheckoutResult extends AlacartePhaseState {
97
97
  * made; the UI shows a blocking modal directing the learner to contact
98
98
  * support. */
99
99
  purchaseBlocked: boolean;
100
+ /** True when tCheckoutSelect or tCheckoutPlaceOrder returned CHECKOUT_PAUSED
101
+ * (ALC-200 kill switch). The UI locks the page behind a blocking banner. */
102
+ checkoutPaused: boolean;
100
103
  /** Decline details from the last card attempt on this checkout, if any. */
101
104
  paymentDecline: AlacartePaymentDecline | null;
102
105
  /** When ?order_bi_id= is present, the placed order (or null while polling). */
@@ -28,7 +28,7 @@ import { useQueryStates, useQueryState, parseAsString } from 'nuqs';
28
28
  import { createAlacarteCheckoutClient } from '../../utils/alacarteCheckout';
29
29
  import { getCouponErrorMessage, getCouponRecheckMessage, isCouponError } from '../../utils/couponErrors';
30
30
  import { placeAlacarteOrder, startAlacartePaypalOrder, toAlacarteBillingAddress, } from '../../utils/alacartePayment';
31
- import { AlacartePlaceOrderError, isPurchaseBlockedError, isSanctionsBlockedError, POLL_TIMEOUT_MESSAGE, toPlaceOrderError } from '../../utils/placeOrderErrors';
31
+ import { AlacartePlaceOrderError, isCheckoutPausedError, isPurchaseBlockedError, isSanctionsBlockedError, POLL_TIMEOUT_MESSAGE, toPlaceOrderError, } from '../../utils/placeOrderErrors';
32
32
  import { CardValidationError } from '../../utils/stripeCard';
33
33
  import { isRequestTimeoutError, RequestTimeoutError } from '../../utils/timeoutErrors';
34
34
  import { useSubscriptionCourseKeyQuery, useViaxSessionQuery, useRefreshViaxSession, viaxTokenForRejectedCall, } from './useCheckoutQueries';
@@ -162,7 +162,7 @@ function blockedDetailMessage(detail, kind) {
162
162
  * data — so every branch combination can be unit-tested directly.
163
163
  */
164
164
  export function deriveAlacartePhase(input) {
165
- var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v;
165
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
166
166
  const { selector, sessionReady, sessionIsError, sessionErrorMessage, ownedQuery, selectMutation, checkoutQuery, productDetail, couponMutation, checkoutOverride = null, urlCouponPending: urlCouponPendingProp = false, courseRunLookup = { pending: false, notFound: false }, } = input;
167
167
  const ownedProductName = (_c = (_b = (_a = ownedQuery.data) === null || _a === void 0 ? void 0 : _a.product) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : null;
168
168
  const empty = {
@@ -257,11 +257,18 @@ export function deriveAlacartePhase(input) {
257
257
  if (selectError === 'PROGRAM_NOT_FOUND') {
258
258
  return Object.assign(Object.assign({ phase: 'error' }, empty), { error: 'This program could not be found.' });
259
259
  }
260
+ if (selectError === 'CHECKOUT_PAUSED') {
261
+ // No checkout comes back — build the line from the owned-product
262
+ // pricing so the locked page still shows the summary and total.
263
+ const ownedProduct = (_m = ownedQuery.data) === null || _m === void 0 ? void 0 : _m.product;
264
+ return Object.assign(Object.assign({ phase: 'checkoutPaused' }, empty), { line: ownedProduct ? buildLineFromOwnedProduct(ownedProduct) : null, productDetail,
265
+ ownedProductName });
266
+ }
260
267
  if (selectError === 'PURCHASE_BLOCKED') {
261
268
  return Object.assign(Object.assign({ phase: 'ready' }, empty), { productDetail, isPurchaseBlocked: true });
262
269
  }
263
270
  // Unknown blocked reason — never surface the raw code.
264
- const blockedKind = (_o = (_m = selectMutation.data.blocked) === null || _m === void 0 ? void 0 : _m.kind) !== null && _o !== void 0 ? _o : 'course';
271
+ const blockedKind = (_p = (_o = selectMutation.data.blocked) === null || _o === void 0 ? void 0 : _o.kind) !== null && _p !== void 0 ? _p : 'course';
265
272
  return Object.assign(Object.assign({ phase: 'error' }, empty), { error: blockedDetailMessage(undefined, blockedKind) });
266
273
  }
267
274
  // When a URL discount code still needs to be applied, stay in 'loading'
@@ -272,14 +279,14 @@ export function deriveAlacartePhase(input) {
272
279
  // Once the coupon-apply (?discount_code=) mutation succeeds, its checkout
273
280
  // (with the discount reflected) supersedes the pre-coupon one. Manual
274
281
  // updates (override) win over both.
275
- const finalCheckout = checkoutOverride !== null && checkoutOverride !== void 0 ? checkoutOverride : (((_p = couponMutation === null || couponMutation === void 0 ? void 0 : couponMutation.data) === null || _p === void 0 ? void 0 : _p.ok)
282
+ const finalCheckout = checkoutOverride !== null && checkoutOverride !== void 0 ? checkoutOverride : (((_q = couponMutation === null || couponMutation === void 0 ? void 0 : couponMutation.data) === null || _q === void 0 ? void 0 : _q.ok)
276
283
  ? couponMutation.data.checkout
277
- : (_r = (_q = selectMutation.data) === null || _q === void 0 ? void 0 : _q.checkout) !== null && _r !== void 0 ? _r : null);
284
+ : (_s = (_r = selectMutation.data) === null || _r === void 0 ? void 0 : _r.checkout) !== null && _s !== void 0 ? _s : null);
278
285
  // When select succeeds but the owned-products query says the learner
279
286
  // already has this product, show the full checkout under an overlay.
280
- return withCheckout(finalCheckout, ((_s = selectMutation.data) === null || _s === void 0 ? void 0 : _s.priceChanged)
287
+ return withCheckout(finalCheckout, ((_t = selectMutation.data) === null || _t === void 0 ? void 0 : _t.priceChanged)
281
288
  ? selectMutation.data
282
- : (((_t = couponMutation === null || couponMutation === void 0 ? void 0 : couponMutation.data) === null || _t === void 0 ? void 0 : _t.ok) ? couponMutation.data : null), isOwned);
289
+ : (((_u = couponMutation === null || couponMutation === void 0 ? void 0 : couponMutation.data) === null || _u === void 0 ? void 0 : _u.ok) ? couponMutation.data : null), isOwned);
283
290
  }
284
291
  // No selector: fall back to the learner's existing open checkout, if any.
285
292
  if (!sessionReady || checkoutQuery.isLoading) {
@@ -288,9 +295,9 @@ export function deriveAlacartePhase(input) {
288
295
  if (checkoutQuery.isError) {
289
296
  return Object.assign(Object.assign({ phase: 'error' }, empty), { error: errorMessage(checkoutQuery.error) });
290
297
  }
291
- if (checkoutOverride || ((_u = checkoutQuery.data) === null || _u === void 0 ? void 0 : _u.checkout)) {
298
+ if (checkoutOverride || ((_v = checkoutQuery.data) === null || _v === void 0 ? void 0 : _v.checkout)) {
292
299
  const checkout = checkoutOverride !== null && checkoutOverride !== void 0 ? checkoutOverride : checkoutQuery.data.checkout;
293
- return withCheckout(checkout, (_v = checkoutQuery.data) !== null && _v !== void 0 ? _v : null);
300
+ return withCheckout(checkout, (_w = checkoutQuery.data) !== null && _w !== void 0 ? _w : null);
294
301
  }
295
302
  return Object.assign(Object.assign({ phase: 'noActiveCheckout', noticeMessageId: 'noActiveCheckout' }, empty), { isAlreadyOwned: false, ownedProductName: null });
296
303
  }
@@ -463,6 +470,7 @@ export function useAlacarteCheckout(options) {
463
470
  const [paymentTimedOut, setPaymentTimedOut] = useState(false);
464
471
  const [sanctionsBlocked, setSanctionsBlocked] = useState(null);
465
472
  const [purchaseBlocked, setPurchaseBlocked] = useState(false);
473
+ const [placeOrderPaused, setPlaceOrderPaused] = useState(false);
466
474
  // biId of a checkout that's locked (CART_PAYMENT_PENDING) from a prior
467
475
  // tCheckoutPlaceOrder call whose Stripe confirmation was rejected
468
476
  // client-side. The next attempt must skip tCheckoutUpdate (it would fail
@@ -490,6 +498,7 @@ export function useAlacarteCheckout(options) {
490
498
  setPaymentTimedOut(false);
491
499
  setSanctionsBlocked(null);
492
500
  setPurchaseBlocked(false);
501
+ setPlaceOrderPaused(false);
493
502
  setCardRetryBiId(null);
494
503
  automaticBaselineRef.current = null;
495
504
  selectReset();
@@ -748,6 +757,9 @@ export function useAlacarteCheckout(options) {
748
757
  else if (isPurchaseBlockedError(err)) {
749
758
  setPurchaseBlocked(true);
750
759
  }
760
+ else if (isCheckoutPausedError(err)) {
761
+ setPlaceOrderPaused(true);
762
+ }
751
763
  else if (isCouponError(errMsg)) {
752
764
  // Coupon errors show inline below the promo code input, not as a top banner.
753
765
  setCouponError(getCouponErrorMessage(errMsg));
@@ -836,6 +848,9 @@ export function useAlacarteCheckout(options) {
836
848
  else if (isSanctionsBlockedError(err)) {
837
849
  setSanctionsBlocked({ referenceCode: 'REF-8F2K-40QX-1177' });
838
850
  }
851
+ else if (isCheckoutPausedError(err)) {
852
+ setPlaceOrderPaused(true);
853
+ }
839
854
  else if (isCouponError(paypalErrMsg)) {
840
855
  setCouponError(getCouponErrorMessage(paypalErrMsg));
841
856
  }
@@ -997,7 +1012,7 @@ export function useAlacarteCheckout(options) {
997
1012
  cancelPaypalOrder, clearPlaceOrderError: () => setPlaceOrderError(null), clearPaymentInterrupted: () => setPaymentInterrupted(false), markWalletPaymentCancelled: () => setWalletPaymentCancelled(true), clearWalletPaymentCancelled: () => setWalletPaymentCancelled(false), clearPaymentAlerts,
998
1013
  paymentTimedOut,
999
1014
  sanctionsBlocked,
1000
- purchaseBlocked, paymentDecline: (_p = (_o = derived.checkout) === null || _o === void 0 ? void 0 : _o.paymentDecline) !== null && _p !== void 0 ? _p : null, placedOrder, awaitingPlacedOrder: placedView.awaitingPlacedOrder, placedOrderError: placedView.placedOrderError, placedOrderPlacedAt });
1015
+ purchaseBlocked, checkoutPaused: placeOrderPaused || derived.phase === 'checkoutPaused', paymentDecline: (_p = (_o = derived.checkout) === null || _o === void 0 ? void 0 : _o.paymentDecline) !== null && _p !== void 0 ? _p : null, placedOrder, awaitingPlacedOrder: placedView.awaitingPlacedOrder, placedOrderError: placedView.placedOrderError, placedOrderPlacedAt });
1001
1016
  }
1002
1017
  export default useAlacarteCheckout;
1003
1018
  //# sourceMappingURL=useAlacarteCheckout.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"useAlacarteCheckout.js","sourceRoot":"","sources":["../../../src/data/hooks/useAlacarteCheckout.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzG,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EAAE,uBAAuB,EAAE,sBAAsB,EAAE,uBAAuB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACjK,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EACL,6BAA6B,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,wBAAwB,GACpG,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,y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UAAU,CAAC,gBAAgB,EAAE,UAAU,CAAC,qBAAqB,EAAE,MAAM,EAAE,YAAY,EAAE,WAAW,CAAC,CAAC,CAAC;IAElH,uCACK,OAAO,KACV,WAAW,EACX,cAAc,EAAE,oBAAoB,CAAC,SAAS,EAC9C,WAAW;QACX,YAAY,EACZ,gBAAgB,EAAE,GAAG,EAAE,CAAC,cAAc,CAAC,IAAI,CAAC,EAC5C,iBAAiB,EACjB,sBAAsB,EAAE,GAAG,EAAE,CAAC,oBAAoB,CAAC,IAAI,CAAC,EACxD,YAAY;QACZ,eAAe;QACf,kBAAkB;QAClB,sBAAsB;QACtB,UAAU,EACV,eAAe,EAAE,cAAc,EAC/B,gBAAgB;QAChB,kBAAkB;QAClB,iBAAiB,EACjB,oBAAoB,EAAE,GAAG,EAAE,CAAC,kBAAkB,CAAC,IAAI,CAAC,EACpD,uBAAuB,EAAE,GAAG,EAAE,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAC3D,0BAA0B,EAAE,GAAG,EAAE,CAAC,yBAAyB,CAAC,IAAI,CAAC,EACjE,2BAA2B,EAAE,GAAG,EAAE,CAAC,yBAAyB,CAAC,KAAK,CAAC,EACnE,kBAAkB;QAClB,eAAe;QACf,gBAAgB;QAChB,eAAe,EACf,cAAc,EAAE,MAAA,MAAA,OAAO,CAAC,QAAQ,0CAAE,cAAc,mCAAI,IAAI,EACxD,WAAW,EACX,mBAAmB,EAAE,UAAU,CAAC,mBAAmB,EACnD,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,EAC7C,mBAAmB,IACnB;AACJ,CAAC;AAED,eAAe,mBAAmB,CAAC","sourcesContent":["/**\n * data/hooks/useAlacarteCheckout.ts — page-level orchestration for the à la\n * carte checkout flow:\n *\n * 1. Read a product selector (course or program) from the URL via nuqs.\n * 2. If a product is selected: check ownership (tOwnedProducts). Already\n * owned -> 'alreadyOwned'. Otherwise select it into the checkout\n * (tCheckoutSelect) and fetch its display details in parallel.\n * 3. If no product is selected: look for an existing open checkout\n * (tCheckout). Found -> 'ready'. Not found -> 'noActiveCheckout'.\n * 4. Coupon apply/remove and payment prep via tCheckoutUpdate.\n *\n * See /alacarte-checkout-api.md and /alacarte-owned-products-api.md at the\n * repo root for the underlying API contract.\n */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useQueryStates, useQueryState, parseAsString } from 'nuqs';\nimport { createAlacarteCheckoutClient } from '../../utils/alacarteCheckout';\nimport { getCouponErrorMessage, getCouponRecheckMessage, isCouponError } from '../../utils/couponErrors';\nimport {\n placeAlacarteOrder,\n startAlacartePaypalOrder,\n toAlacarteBillingAddress,\n} from '../../utils/alacartePayment';\nimport { AlacartePlaceOrderError, isPurchaseBlockedError, isSanctionsBlockedError, POLL_TIMEOUT_MESSAGE, toPlaceOrderError } from '../../utils/placeOrderErrors';\nimport { CardValidationError } from '../../utils/stripeCard';\nimport { isRequestTimeoutError, RequestTimeoutError } from '../../utils/timeoutErrors';\nimport {\n useSubscriptionCourseKeyQuery, useViaxSessionQuery, useRefreshViaxSession, viaxTokenForRejectedCall,\n} from './useCheckoutQueries';\nimport {\n courseKeyFromCourseRunKey, lmsOriginFromSessionUrl, isCourseNotFoundError,\n} from '../../utils/provision';\nimport { getCourseRunKeyFromUrl } from '../../utils/url';\nimport {\n useOwnedProductQuery, useAlacarteCheckoutQuery, useSelectProductMutation, useProductDetailQuery,\n useUpdateCheckoutMutation, usePlacedOrderQuery,\n} from './useAlacarteQueries';\nimport { alacarteKeys } from './keys';\nimport { derivePlacedOrderView } from './placedOrderPoll';\nimport { trackEvent, trackEventOnce } from '../../analytics/trackEvent';\nimport { buildProductsFromLine, buildProductsFromOrder } from '../../analytics/buildProducts';\nimport type {\n AlacarteCheckout, AlacarteCheckoutResult, AlacarteLine, AlacarteMoney, AlacartePaymentDecline,\n AlacartePriceChanged, OwnedProduct, OwnedProductResult, PlacedOrder, ProductDetail, ProductSelector,\n} from '../../types/alacarte';\nimport type { BillingInfo } from '../../types';\n\nexport type AlacartePhase = 'loading' | 'alreadyOwned' | 'noActiveCheckout' | 'notPurchasable' | 'ready' | 'error';\n\nexport type AlacarteNoticeMessageId = 'alreadyOwnedCourse' | 'alreadyOwnedProgram' | 'noActiveCheckout';\n\n/** Pure phase decision output — no action callbacks. */\nexport interface AlacartePhaseState {\n phase: AlacartePhase,\n noticeMessageId?: AlacarteNoticeMessageId,\n selector: ProductSelector,\n checkout: AlacarteCheckout | null,\n line: AlacarteLine | null,\n productDetail: ProductDetail | null,\n error: string | null,\n priceChanged: AlacartePriceChanged | null,\n priceAccepted: boolean,\n /** True when the learner already owns this product. The checkout data may\n * still be populated so the UI can render the full page under an overlay. */\n isAlreadyOwned: boolean,\n /** True when the selection was refused because the specific run is unavailable\n * (e.g. enrollment closed, run archived). The UI shows a \"choose another\n * session\" link back to the course page. */\n isRunBlocked: boolean,\n /** True when the learner's account is blocked from purchasing (PURCHASE_BLOCKED\n * at select time). The UI shows a blocking modal instead of the error banner. */\n isPurchaseBlocked: boolean,\n /** Product name from the owned-products query — used as a fallback when the\n * checkout line (which normally carries the name) is not available. */\n ownedProductName: string | null,\n}\n\nexport interface UseAlacarteCheckoutResult extends AlacartePhaseState {\n couponError: string | null,\n couponApplying: boolean,\n applyCoupon: (code: string) => void,\n removeCoupon: () => void,\n clearCouponError: () => void,\n /** Code of the coupon just removed, set only once the removal round-trip\n * completes — kept in sync with when the discount actually leaves the line. */\n removedCouponCode: string | null,\n clearRemovedCouponCode: () => void,\n placingOrder: boolean,\n placeOrderError: string | null,\n /** True when the learner returns to checkout without completing payment. */\n paymentInterrupted: boolean,\n /** True when the learner dismissed the Apple Pay / Google Pay sheet without paying. */\n walletPaymentCancelled: boolean,\n /**\n * Accepts price (if needed) + terms, calls tCheckoutPlaceOrder with billing,\n * confirms the card via Stripe.js, then sets ?order_bi_id= to poll getTwouOrder.\n * Fire-and-forget — errors go to placeOrderError state.\n */\n placeOrder: (opts: {\n billing: BillingInfo,\n confirmCardPayment: (clientSecret: string) => Promise<void>,\n }) => void,\n /**\n * Same as placeOrder but returns a Promise — used by ExpressCheckout\n * so the wallet sheet can await the result and call ev.complete().\n */\n placeOrderAsync: (opts: {\n billing: BillingInfo,\n confirmCardPayment: (clientSecret: string) => Promise<void>,\n }) => Promise<void>,\n /**\n * PayPal buttons `createOrder`: accepts price + terms and calls\n * tCheckoutPlaceOrder(paymentMethod: PAYPAL). Resolves the PayPal order id.\n */\n startPaypalOrder: (opts: { billing: BillingInfo }) => Promise<string>,\n /** PayPal buttons `onApprove`: tCheckoutCapturePaypalOrder, then sets ?order_bi_id=. */\n approvePaypalOrder: (paypalOrderId: string) => Promise<void>,\n /** PayPal buttons `onCancel` / `onError`: tCheckoutCancelPaypalOrder and reload tCheckout. */\n cancelPaypalOrder: (paypalOrderId: string) => Promise<void>,\n clearPlaceOrderError: () => void,\n clearPaymentInterrupted: () => void,\n /** Express Checkout Element `cancel`: the wallet sheet was closed without paying. */\n markWalletPaymentCancelled: () => void,\n clearWalletPaymentCancelled: () => void,\n /**\n * Express Checkout Element `click`: a new Apple Pay / Google Pay attempt is\n * starting, so the previous attempt's banners go (PayPal does this in\n * startPaypalOrder).\n */\n clearPaymentAlerts: () => void,\n /** True once the payment provider timed out during place order (HTTP 408 /\n * Stripe network error). The order may still go through, so further\n * attempts are blocked and the UI shows the timeout warning instead. */\n paymentTimedOut: boolean,\n /** Set when tCheckoutPlaceOrder returned SANCTIONS_BLOCKED. No charge was\n * made; the UI shows a blocking modal with a code the learner can quote\n * to support. Hardcoded until the backend returns a reference code\n * with SANCTIONS_BLOCKED. */\n sanctionsBlocked: { referenceCode: string } | null,\n /** Set when tCheckoutPlaceOrder returned PURCHASE_BLOCKED. No charge was\n * made; the UI shows a blocking modal directing the learner to contact\n * support. */\n purchaseBlocked: boolean,\n /** Decline details from the last card attempt on this checkout, if any. */\n paymentDecline: AlacartePaymentDecline | null,\n /** When ?order_bi_id= is present, the placed order (or null while polling). */\n placedOrder: PlacedOrder | null,\n /**\n * True while getTwouOrder is still awaiting tPlacedAt (payment confirming,\n * including 3DS) or while we reload tCheckout after NOT_PLACED.\n */\n awaitingPlacedOrder: boolean,\n placedOrderError: string | null,\n /** ISO timestamp the order was placed (tPlacedAt, falling back to\n * biCreatedAt); null while the order-dates query hasn't resolved yet. */\n placedOrderPlacedAt: string | null,\n}\n\n/**\n * Read the product selector from the URL: course_uuid+course_run_key, or\n * program_uuid, or neither. Both course params must be present together; if a\n * course param and a program param are both present, that's\n * CONFLICTING_SELECTION.\n *\n * Legacy aliases `course_uid` / `program_uid` are still accepted; the `*_uuid`\n * names win when both are present.\n *\n * NOTE: course_run_key values look like \"course-v1:HarvardX+CS50+X\" — nuqs\n * decodes query values the standards-compliant way (literal `+` -> space),\n * same as native URLSearchParams. runKey is therefore read from the raw query\n * string via getCourseRunKeyFromUrl(), which preserves literal `+`.\n */\nexport function useProductSelector(): ProductSelector {\n const [{\n courseUuid, courseUidLegacy, runKey: nuqsRunKey, programUuid, programUidLegacy,\n }] = useQueryStates({\n courseUuid: parseAsString,\n courseUidLegacy: parseAsString,\n runKey: parseAsString,\n programUuid: parseAsString,\n programUidLegacy: parseAsString,\n }, {\n urlKeys: {\n courseUuid: 'course_uuid',\n courseUidLegacy: 'course_uid',\n runKey: 'course_run_key',\n programUuid: 'program_uuid',\n programUidLegacy: 'program_uid',\n },\n });\n const courseUid = courseUuid ?? courseUidLegacy;\n const programUid = programUuid ?? programUidLegacy;\n const runKey = nuqsRunKey ? (getCourseRunKeyFromUrl() ?? nuqsRunKey) : null;\n\n return useMemo<ProductSelector>(() => {\n const hasCourse = !!courseUid || !!runKey;\n const hasProgram = !!programUid;\n if (hasCourse && hasProgram) return { kind: 'invalid' };\n if (courseUid && runKey) return { kind: 'course', courseUid, runKey };\n if (programUid) return { kind: 'program', programUid };\n return { kind: 'none' };\n }, [courseUid, runKey, programUid]);\n}\n\n/** Reads ?discount_code= — applied to the checkout right after it's created. */\nexport function useDiscountCode(): string | null {\n const [discountCode] = useQueryState('discount_code', parseAsString);\n return discountCode;\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : 'Unknown error';\n}\n\n/**\n * Build a synthetic AlacarteLine from the owned-product pricing data so the\n * checkout overlay can show subtotal / deduction / total even when the backend\n * blocks tCheckoutSelect and returns no checkout object.\n */\nfunction buildLineFromOwnedProduct(product: OwnedProduct): AlacarteLine | null {\n if (!product.price) return null;\n const { full, deduction, amountDue, currency } = product.price;\n const toMoney = (amount: number): AlacarteMoney => ({ amount, currency });\n\n if (product.kind === 'program') {\n return {\n biiId: '',\n kind: 'program',\n programId: product.productId,\n programName: product.name,\n price: toMoney(full),\n deduction: deduction ? toMoney(deduction) : null,\n ownedCourses: product.ownedCourses.map((c) => ({\n courseId: c.courseId, name: c.name, via: c.via,\n })),\n discount: null,\n amountDue: toMoney(amountDue),\n billingAddressSet: false,\n };\n }\n\n return {\n biiId: '',\n kind: 'course',\n courseName: product.name,\n courseUid: product.productId,\n courseRunKey: '',\n seatType: 'verified',\n price: toMoney(full),\n discount: null,\n amountDue: toMoney(amountDue),\n billingAddressSet: false,\n };\n}\n\ninterface QueryLikeState<T> {\n isLoading: boolean,\n isError: boolean,\n error?: unknown,\n data?: T,\n}\n\ninterface MutationLikeState<T> {\n isIdle: boolean,\n isPending: boolean,\n isError: boolean,\n error?: unknown,\n data?: T,\n}\n\nexport interface DeriveAlacartePhaseInput {\n selector: ProductSelector,\n sessionReady: boolean,\n sessionIsError: boolean,\n sessionErrorMessage?: string,\n ownedQuery: QueryLikeState<OwnedProductResult>,\n selectMutation: MutationLikeState<AlacarteCheckoutResult>,\n checkoutQuery: QueryLikeState<AlacarteCheckoutResult>,\n productDetail: ProductDetail | null,\n /** Coupon (?discount_code=) applied right after the checkout is created —\n * when it succeeds, its checkout (with the coupon's discount reflected)\n * is shown in place of the pre-coupon one from selectMutation. */\n couponMutation?: MutationLikeState<AlacarteCheckoutResult>,\n /** True when a URL discount code still needs to be applied — the phase\n * stays 'loading' until the coupon mutation resolves so the user never sees\n * the pre-discount price flash. */\n urlCouponPending?: boolean,\n /** Latest successful manual update (coupon / acceptPrice / terms). Wins over\n * select + URL coupon when present. */\n checkoutOverride?: AlacarteCheckout | null,\n /** Course-runs lookup for a course selector. Empty `elements` is notFound. */\n courseRunLookup?: { pending: boolean, notFound: boolean },\n}\n\nconst RUN_BLOCKED_DETAILS = new Set([\n 'run_not_found', 'run_archived', 'run_enrollment_closed', 'run_no_paid_seat', 'run_ended',\n]);\n\n/**\n * Map a `blocked.detail` to a learner-facing message.\n * Never surfaces the raw code — unknown details get a generic fallback.\n */\nfunction blockedDetailMessage(detail: string | undefined, kind: 'course' | 'program'): string {\n if (detail && RUN_BLOCKED_DETAILS.has(detail)) {\n return 'This session is no longer open for enrollment.';\n }\n switch (detail) {\n case 'course_no_price':\n case 'program_no_price':\n return kind === 'program'\n ? 'Pricing is not available for this program right now.'\n : 'Pricing is not available for this course right now.';\n case 'lms_unavailable':\n return 'We couldn\\u2019t verify your existing enrollments right now. Please try again in a few minutes.';\n default:\n return kind === 'program'\n ? 'This program is not eligible for checkout.'\n : 'This course is not eligible for checkout.';\n }\n}\n\n/**\n * Pure decision function — no hooks, no React Query/nuqs types beyond plain\n * data — so every branch combination can be unit-tested directly.\n */\nexport function deriveAlacartePhase(input: DeriveAlacartePhaseInput): AlacartePhaseState {\n const {\n selector, sessionReady, sessionIsError, sessionErrorMessage,\n ownedQuery, selectMutation, checkoutQuery, productDetail, couponMutation,\n checkoutOverride = null, urlCouponPending: urlCouponPendingProp = false,\n courseRunLookup = { pending: false, notFound: false },\n } = input;\n\n const ownedProductName = ownedQuery.data?.product?.name ?? null;\n\n const empty: Omit<AlacartePhaseState, 'phase'> = {\n selector,\n checkout: null,\n line: null,\n productDetail: null,\n error: null,\n priceChanged: null,\n priceAccepted: false,\n isAlreadyOwned: false,\n isRunBlocked: false,\n isPurchaseBlocked: false,\n ownedProductName: null,\n };\n\n /**\n * `priceChangeSource` is the response that reported priceChanged. A change\n * that only reflects an automatic offer on that response's line is dropped\n * (the learner gets the offer's success alert instead) and treated as\n * accepted so the price-accept notice stays hidden too. Payment still sends\n * acceptPrice, since it reads checkout.priceAccepted from the backend.\n */\n const withCheckout = (\n checkout: AlacarteCheckout | null,\n priceChangeSource: AlacarteCheckoutResult | null = null,\n isAlreadyOwned = false,\n ): AlacartePhaseState => {\n const priceChanged = priceChangeSource?.priceChanged ?? null;\n const automaticOfferOnly = !!priceChanged\n && isAutomaticOfferPriceChange(priceChanged, priceChangeSource?.checkout?.line);\n return {\n phase: isAlreadyOwned ? 'alreadyOwned' : 'ready',\n selector,\n checkout,\n line: checkout?.line ?? null,\n productDetail,\n error: null,\n priceChanged: automaticOfferOnly ? null : priceChanged,\n priceAccepted: checkout?.priceAccepted === true || automaticOfferOnly,\n isAlreadyOwned,\n isRunBlocked: false,\n isPurchaseBlocked: false,\n ownedProductName: isAlreadyOwned ? ownedProductName : null,\n };\n };\n\n if (selector.kind === 'invalid') {\n return { phase: 'error', ...empty, error: 'CONFLICTING_SELECTION' };\n }\n if (sessionIsError) {\n return { phase: 'error', ...empty, error: sessionErrorMessage ?? 'Session error' };\n }\n\n const hasSelector = selector.kind === 'course' || selector.kind === 'program';\n\n if (hasSelector) {\n if (selector.kind === 'course' && courseRunLookup.notFound) {\n return {\n phase: 'error',\n ...empty,\n error: 'This course could not be found.',\n };\n }\n if (!sessionReady || ownedQuery.isLoading || courseRunLookup.pending) {\n return { phase: 'loading', ...empty };\n }\n if (ownedQuery.isError) {\n return { phase: 'error', ...empty, error: errorMessage(ownedQuery.error) };\n }\n\n const isOwned = ownedQuery.data?.ok === true && ownedQuery.data.product?.status === 'full';\n\n if (selectMutation.isIdle || selectMutation.isPending) {\n return { phase: 'loading', ...empty };\n }\n if (selectMutation.isError) {\n return { phase: 'error', ...empty, error: errorMessage(selectMutation.error) };\n }\n if (selectMutation.data && !selectMutation.data.ok) {\n // The backend may block ALREADY_OWNED at select time. When the\n // blocked response still includes checkout data (line, pricing), use\n // it so the overlay page shows the real totals. Fall back to the\n // standalone tCheckout query, then to an empty state.\n if (selectMutation.data.blocked?.reason === 'ALREADY_OWNED') {\n const blockedCheckout = selectMutation.data.checkout\n ?? (checkoutQuery.data?.ok ? checkoutQuery.data.checkout : null);\n if (blockedCheckout) {\n return withCheckout(blockedCheckout, selectMutation.data, true);\n }\n // Build a synthetic line from the owned-product pricing so the\n // overlay can show subtotal / deduction / total.\n const ownedProduct = ownedQuery.data?.product;\n const syntheticLine = ownedProduct ? buildLineFromOwnedProduct(ownedProduct) : null;\n return {\n phase: 'alreadyOwned',\n noticeMessageId: selectMutation.data.blocked.kind === 'course' ? 'alreadyOwnedCourse' : 'alreadyOwnedProgram',\n ...empty,\n line: syntheticLine,\n productDetail,\n isAlreadyOwned: true,\n ownedProductName,\n };\n }\n if (selectMutation.data.blocked?.reason === 'NOT_PURCHASABLE'\n || selectMutation.data.blocked?.reason === 'OWNERSHIP_UNAVAILABLE') {\n const { detail, kind } = selectMutation.data.blocked;\n return {\n phase: 'notPurchasable',\n ...empty,\n productDetail,\n isRunBlocked: !!detail && RUN_BLOCKED_DETAILS.has(detail),\n error: blockedDetailMessage(detail, kind),\n };\n }\n const selectError = selectMutation.data.error;\n if (selectError === 'COURSE_NOT_FOUND' || selectError === 'PRODUCT_NOT_FOUND') {\n return {\n phase: 'error',\n ...empty,\n error: 'This course could not be found.',\n };\n }\n if (selectError === 'PROGRAM_NOT_FOUND') {\n return {\n phase: 'error',\n ...empty,\n error: 'This program could not be found.',\n };\n }\n if (selectError === 'PURCHASE_BLOCKED') {\n return {\n phase: 'ready',\n ...empty,\n productDetail,\n isPurchaseBlocked: true,\n };\n }\n // Unknown blocked reason — never surface the raw code.\n const blockedKind = selectMutation.data.blocked?.kind ?? 'course';\n return {\n phase: 'error',\n ...empty,\n error: blockedDetailMessage(undefined, blockedKind),\n };\n }\n\n // When a URL discount code still needs to be applied, stay in 'loading'\n // so the user never sees the pre-discount price flash.\n if (urlCouponPendingProp && !checkoutOverride) {\n return { phase: 'loading', ...empty };\n }\n\n // Once the coupon-apply (?discount_code=) mutation succeeds, its checkout\n // (with the discount reflected) supersedes the pre-coupon one. Manual\n // updates (override) win over both.\n const finalCheckout = checkoutOverride\n ?? (couponMutation?.data?.ok\n ? couponMutation.data.checkout\n : selectMutation.data?.checkout ?? null);\n\n // When select succeeds but the owned-products query says the learner\n // already has this product, show the full checkout under an overlay.\n return withCheckout(\n finalCheckout,\n selectMutation.data?.priceChanged\n ? selectMutation.data\n : (couponMutation?.data?.ok ? couponMutation.data : null),\n isOwned,\n );\n }\n\n // No selector: fall back to the learner's existing open checkout, if any.\n if (!sessionReady || checkoutQuery.isLoading) {\n return { phase: 'loading', ...empty };\n }\n if (checkoutQuery.isError) {\n return { phase: 'error', ...empty, error: errorMessage(checkoutQuery.error) };\n }\n if (checkoutOverride || checkoutQuery.data?.checkout) {\n const checkout = checkoutOverride ?? checkoutQuery.data!.checkout;\n return withCheckout(checkout, checkoutQuery.data ?? null);\n }\n\n return { phase: 'noActiveCheckout', noticeMessageId: 'noActiveCheckout', ...empty, isAlreadyOwned: false, ownedProductName: null };\n}\n\n/** amountDue with coupon/automatic discount removed (price − program deduction). */\nfunction amountDueWithoutDiscount(line: AlacarteLine): AlacarteMoney | null {\n if (!line.price) return null;\n if (line.kind === 'program' && line.deduction) {\n return {\n amount: line.price.amount - line.deduction.amount,\n currency: line.price.currency,\n };\n }\n return line.price;\n}\n\nfunction sameMoney(a: AlacarteMoney, b: AlacarteMoney): boolean {\n return a.currency === b.currency && Math.abs(a.amount - b.amount) < 0.005;\n}\n\n/**\n * True when priceChanged only reflects an automatic offer (e.g. a first-order\n * code): viewedPrice is sent before any discount, so the backend reports the\n * offer as a price change. Viewed must match the line before the offer and\n * current the line after it.\n */\nfunction isAutomaticOfferPriceChange(\n priceChanged: AlacartePriceChanged,\n line: AlacarteLine | null | undefined,\n): boolean {\n if (line?.discountSource !== 'automatic' || !line.discount || !line.amountDue) return false;\n const base = amountDueWithoutDiscount(line);\n return !!base && sameMoney(priceChanged.viewed, base) && sameMoney(priceChanged.current, line.amountDue);\n}\n\n/** amountDue after applying a discount on top of price (− program deduction). */\nfunction amountDueWithDiscount(\n line: AlacarteLine,\n discount: AlacarteMoney,\n): AlacarteMoney | null {\n const base = amountDueWithoutDiscount(line);\n if (!base) return null;\n return { amount: base.amount - discount.amount, currency: base.currency };\n}\n\n/**\n * Checkout to show once a coupon removal succeeds. The backend may return a\n * line that still carries the old coupon discount/amountDue, so that line is\n * patched to clear it. An automatic offer (bundle / first-order) the backend\n * re-applied once the coupon is gone is the real state and is kept as-is.\n *\n * When the backend clears the coupon but does not re-apply the automatic\n * offer that was present before the coupon, `priorCheckout` (typically the\n * pre-coupon select response) is used to restore that offer.\n */\nexport function checkoutWithoutCoupon(\n checkout: AlacarteCheckout,\n priorCheckout?: AlacarteCheckout | null,\n): AlacarteCheckout {\n const { line } = checkout;\n if (!line) {\n return { ...checkout, couponCode: null };\n }\n if (line.discountSource === 'automatic') {\n return { ...checkout, couponCode: null };\n }\n\n const priorLine = priorCheckout?.line;\n const priorAutomatic = priorLine?.discountSource === 'automatic' && priorLine.discount\n ? priorLine\n : null;\n\n const clearedLine = {\n ...line,\n discount: null,\n discountSource: null,\n discountName: null,\n amountDue: amountDueWithoutDiscount(line),\n } as typeof line;\n\n if (priorAutomatic?.discount) {\n return {\n ...checkout,\n couponCode: null,\n line: {\n ...clearedLine,\n discount: priorAutomatic.discount,\n discountSource: 'automatic',\n discountName: priorAutomatic.discountName ?? null,\n amountDue: amountDueWithDiscount(clearedLine, priorAutomatic.discount),\n } as typeof line,\n };\n }\n\n return { ...checkout, couponCode: null, line: clearedLine };\n}\n\nexport function useAlacarteCheckout(\n options: {\n apiUrl?: string,\n edxSessionUrl?: string,\n /**\n * When true, skip GET /api/subscription/course_runs/ and call Viax with a\n * course key derived from ?course_run_key= instead.\n */\n skipSubscriptionCourseRuns?: boolean,\n },\n): UseAlacarteCheckoutResult {\n const { apiUrl, edxSessionUrl, skipSubscriptionCourseRuns = false } = options;\n const queryClient = useQueryClient();\n const selector = useProductSelector();\n const discountCode = useDiscountCode();\n const [orderBiId, setOrderBiId] = useQueryState('order_bi_id', parseAsString);\n\n // Reuses the same query key as useCheckout's session exchange — React\n // Query dedupes the network call regardless of how many hooks read it.\n const sessionQuery = useViaxSessionQuery(edxSessionUrl ?? null);\n const sessionReady = !!sessionQuery.data;\n const refreshSession = useRefreshViaxSession(edxSessionUrl ?? null);\n\n // Stable ref so the onRefreshToken callback always uses the latest\n // refreshSession without recreating the client on every render.\n const refreshSessionRef = useRef(refreshSession);\n refreshSessionRef.current = refreshSession;\n\n const client = useMemo(\n () => (apiUrl ? createAlacarteCheckoutClient({\n apiUrl,\n onRefreshToken: () => viaxTokenForRejectedCall(() => refreshSessionRef.current()),\n }) : null),\n [apiUrl],\n );\n\n useEffect(() => {\n if (sessionQuery.data && client) {\n client.setToken(sessionQuery.data.viaxToken);\n }\n }, [sessionQuery.data, client]);\n\n const hasSelector = selector.kind === 'course' || selector.kind === 'program';\n const productId = selector.kind === 'course'\n ? selector.courseUid\n : selector.kind === 'program' ? selector.programUid : null;\n\n const ownedQuery = useOwnedProductQuery(client, sessionReady && hasSelector, productId);\n const isOwned = ownedQuery.data?.ok === true && ownedQuery.data.product?.status === 'full';\n\n const selectMutation = useSelectProductMutation(client);\n const {\n isIdle: selectIsIdle, mutate: selectMutate, reset: selectReset,\n } = selectMutation;\n\n const courseRunKey = selector.kind === 'course' ? selector.runKey : null;\n const lmsBaseUrl = useMemo(\n () => lmsOriginFromSessionUrl(edxSessionUrl),\n [edxSessionUrl],\n );\n const courseLookupEnabled = !skipSubscriptionCourseRuns\n && selector.kind === 'course'\n && !!lmsBaseUrl\n && !!courseRunKey;\n const courseKeyQuery = useSubscriptionCourseKeyQuery(\n skipSubscriptionCourseRuns ? null : lmsBaseUrl,\n skipSubscriptionCourseRuns ? null : courseRunKey,\n );\n const courseKey = skipSubscriptionCourseRuns\n ? (courseRunKey ? courseKeyFromCourseRunKey(courseRunKey) : null)\n : (courseKeyQuery.data ?? null);\n const courseNotFound = courseLookupEnabled\n && courseKeyQuery.isError\n && isCourseNotFoundError(courseKeyQuery.error);\n\n // Mutations aren't called during render — fire once the owned-products\n // query resolves (regardless of result) so we always get checkout/line data.\n // A course is not selected until the course-runs lookup returns a course.\n // Pass viewedPrice from tOwnedProducts.amountDue (ALC-159) when available.\n useEffect(() => {\n if (!hasSelector || ownedQuery.isLoading || ownedQuery.isError) return;\n if (selector.kind === 'course' && !courseKey) return;\n if (!selectIsIdle) return;\n const amountDue = ownedQuery.data?.product?.price?.amountDue;\n selectMutate({\n selector,\n viewedPrice: typeof amountDue === 'number' ? amountDue : undefined,\n });\n }, [\n hasSelector,\n ownedQuery.isLoading,\n ownedQuery.isError,\n ownedQuery.data?.product?.price?.amountDue,\n selector,\n courseKey,\n selectIsIdle,\n selectMutate,\n ]);\n\n const productDetailEnabled = hasSelector && sessionReady && !ownedQuery.isLoading\n && (selector.kind !== 'course' || !!courseKey);\n const productDetailQuery = useProductDetailQuery(client, productDetailEnabled, selector, courseKey);\n\n // Run the checkout query when there's no selector (standard path) OR when\n // the product is already owned — after the select mutation is blocked with\n // ALREADY_OWNED the server may still have an open checkout with pricing data.\n const selectBlocked = !selectMutation.isIdle && !selectMutation.isPending\n && selectMutation.data && !selectMutation.data.ok;\n const checkoutQuery = useAlacarteCheckoutQuery(\n client,\n sessionReady && (!hasSelector || (isOwned && !!selectBlocked)),\n );\n\n // Apply ?discount_code= to the freshly-created checkout — fired once the\n // select mutation succeeds with a checkout that doesn't already carry it.\n const urlCouponMutation = useUpdateCheckoutMutation(client);\n const {\n isIdle: couponIsIdle, mutate: couponMutate, reset: urlCouponReset,\n } = urlCouponMutation;\n const createdCheckout = selectMutation.data?.ok ? selectMutation.data.checkout : null;\n\n useEffect(() => {\n if (!createdCheckout || !discountCode) return;\n if (createdCheckout.couponCode === discountCode) return;\n if (couponIsIdle) {\n couponMutate({ biId: createdCheckout.biId, couponCode: discountCode });\n }\n }, [createdCheckout, discountCode, couponIsIdle, couponMutate]);\n\n const [checkoutOverride, setCheckoutOverride] = useState<AlacarteCheckout | null>(null);\n const [couponError, setCouponError] = useState<string | null>(null);\n const [removedCouponCode, setRemovedCouponCode] = useState<string | null>(null);\n const [placeOrderError, setPlaceOrderError] = useState<string | null>(null);\n const [paymentInterrupted, setPaymentInterrupted] = useState(false);\n const [walletPaymentCancelled, setWalletPaymentCancelled] = useState(false);\n const [placingOrder, setPlacingOrder] = useState(false);\n const [paymentTimedOut, setPaymentTimedOut] = useState(false);\n const [sanctionsBlocked, setSanctionsBlocked] = useState<{ referenceCode: string } | null>(null);\n const [purchaseBlocked, setPurchaseBlocked] = useState(false);\n // biId of a checkout that's locked (CART_PAYMENT_PENDING) from a prior\n // tCheckoutPlaceOrder call whose Stripe confirmation was rejected\n // client-side. The next attempt must skip tCheckoutUpdate (it would fail\n // with CHECKOUT_NOT_OPEN) and go straight to tCheckoutPlaceOrder again.\n const [cardRetryBiId, setCardRetryBiId] = useState<string | null>(null);\n // Last checkout that carried an automatic offer — restored after a custom\n // coupon is removed if the backend does not re-apply it.\n const automaticBaselineRef = useRef<AlacarteCheckout | null>(null);\n // Tracks the payment method/processor used for the last place-order attempt,\n // so the Order Completed event can include them.\n const lastPaymentInfoRef = useRef<{ method: string, processor: string }>({ method: 'card', processor: 'stripe' });\n // Ref for product detail so trackEvent inside useCallback always reads the\n // latest value instead of a stale closure capture.\n const productDetailRef = useRef<ProductDetail | null>(null);\n productDetailRef.current = productDetailQuery.data ?? null;\n\n // Reset local overrides and in-flight select/coupon when the product changes\n // so viewedPrice / couponRecheck run again for the new selection.\n useEffect(() => {\n setCheckoutOverride(null);\n setCouponError(null);\n setRemovedCouponCode(null);\n setPlaceOrderError(null);\n setPaymentInterrupted(false);\n setWalletPaymentCancelled(false);\n setPaymentTimedOut(false);\n setSanctionsBlocked(null);\n setPurchaseBlocked(false);\n setCardRetryBiId(null);\n automaticBaselineRef.current = null;\n selectReset();\n urlCouponReset();\n }, [selector, selectReset, urlCouponReset]);\n\n // Surface couponRecheck from product switch (section 2 of the API doc).\n useEffect(() => {\n const result = selectMutation.data;\n if (!result?.ok) return;\n const message = getCouponRecheckMessage(\n result.couponRecheck,\n result.checkout?.line?.discountSource,\n );\n if (message) setCouponError(message);\n }, [selectMutation.data]);\n\n // Surface ?discount_code= apply failures (domain ok:false or transport error).\n useEffect(() => {\n if (!discountCode) return;\n if (urlCouponMutation.isIdle || urlCouponMutation.isPending) return;\n if (urlCouponMutation.isError) {\n setCouponError(errorMessage(urlCouponMutation.error));\n return;\n }\n const result = urlCouponMutation.data;\n if (result && !result.ok) {\n setCouponError(getCouponErrorMessage(result.error, discountCode));\n }\n }, [\n discountCode,\n urlCouponMutation.isIdle,\n urlCouponMutation.isPending,\n urlCouponMutation.isError,\n urlCouponMutation.error,\n urlCouponMutation.data,\n ]);\n\n // Segment: Coupon Applied for ?discount_code= auto-apply.\n const urlCouponTrackedRef = useRef(false);\n useEffect(() => {\n if (urlCouponTrackedRef.current) return;\n const result = urlCouponMutation.data;\n if (!result?.ok || !result.checkout?.line) return;\n urlCouponTrackedRef.current = true;\n const line = result.checkout.line;\n trackEvent('Coupon Applied', {\n checkoutType: 'a_la_carte',\n track_plan_id: 30,\n trigger_source: 'client-side',\n cart_id: result.checkout.biId,\n checkout_id: result.checkout.biId,\n coupon_name: result.checkout.couponCode ?? discountCode ?? '',\n discount: line.discount?.amount ?? 0,\n currency: line.discount?.currency ?? line.amountDue?.currency ?? 'USD',\n products: buildProductsFromLine(line, productDetailQuery.data ?? null),\n });\n }, [urlCouponMutation.data, discountCode, productDetailQuery.data]);\n\n const manualUpdateMutation = useUpdateCheckoutMutation(client);\n\n const placedOrderQuery = usePlacedOrderQuery(\n client,\n orderBiId,\n sessionReady && !!orderBiId,\n );\n\n const derived = deriveAlacartePhase({\n selector,\n sessionReady,\n sessionIsError: sessionQuery.isError,\n sessionErrorMessage: sessionQuery.error?.message,\n ownedQuery: {\n isLoading: ownedQuery.isLoading,\n isError: ownedQuery.isError,\n error: ownedQuery.error,\n data: ownedQuery.data,\n },\n selectMutation: {\n isIdle: selectMutation.isIdle,\n isPending: selectMutation.isPending,\n isError: selectMutation.isError,\n error: selectMutation.error,\n data: selectMutation.data,\n },\n checkoutQuery: {\n isLoading: checkoutQuery.isLoading,\n isError: checkoutQuery.isError,\n error: checkoutQuery.error,\n data: checkoutQuery.data,\n },\n productDetail: productDetailQuery.data ?? null,\n courseRunLookup: {\n pending: courseLookupEnabled && courseKeyQuery.isLoading,\n notFound: courseNotFound,\n },\n couponMutation: {\n isIdle: urlCouponMutation.isIdle,\n isPending: urlCouponMutation.isPending,\n isError: urlCouponMutation.isError,\n error: urlCouponMutation.error,\n data: urlCouponMutation.data,\n },\n checkoutOverride,\n // The URL coupon is pending only when the checkout exists, doesn't already\n // carry the code, and the mutation hasn't completed yet. When the backend\n // returns the coupon pre-applied (couponCode === discountCode) or when\n // there's no discount_code param at all, this is false from the start.\n urlCouponPending: !!discountCode\n && !!createdCheckout\n && createdCheckout.couponCode !== discountCode\n && (urlCouponMutation.isIdle || urlCouponMutation.isPending),\n });\n\n // Sync the purchase-blocked flag from the derived phase (tCheckoutSelect returned\n // PURCHASE_BLOCKED) so the modal shows without waiting for a place-order attempt.\n useEffect(() => {\n if (derived.isPurchaseBlocked) setPurchaseBlocked(true);\n }, [derived.isPurchaseBlocked]);\n\n const applyCoupon = useCallback((code: string) => {\n const biId = derived.checkout?.biId;\n if (!biId || !client) return;\n const trimmed = code.trim();\n if (!trimmed) return;\n\n setCouponError(null);\n manualUpdateMutation.mutate(\n { biId, couponCode: trimmed },\n {\n onSuccess: (result) => {\n if (result.ok && result.checkout) {\n setCheckoutOverride(result.checkout);\n setCouponError(null);\n setRemovedCouponCode(null);\n // Segment: Coupon Applied (track_plan_id 30)\n const line = result.checkout.line;\n if (line) {\n trackEvent('Coupon Applied', {\n checkoutType: 'a_la_carte',\n track_plan_id: 30,\n trigger_source: 'client-side',\n cart_id: result.checkout.biId,\n checkout_id: result.checkout.biId,\n coupon_name: result.checkout.couponCode ?? trimmed,\n discount: line.discount?.amount ?? 0,\n currency: line.discount?.currency ?? line.amountDue?.currency ?? 'USD',\n products: buildProductsFromLine(line, productDetailRef.current),\n });\n }\n } else {\n setCouponError(getCouponErrorMessage(result.error, trimmed));\n }\n },\n onError: (err) => {\n setCouponError(errorMessage(err));\n },\n },\n );\n }, [derived.checkout?.biId, client, manualUpdateMutation]);\n\n // Remember the latest automatic offer so removeCoupon can restore it.\n useEffect(() => {\n const checkout = derived.checkout;\n if (\n checkout?.line?.discountSource === 'automatic'\n && checkout.line.discount\n ) {\n automaticBaselineRef.current = checkout;\n }\n }, [derived.checkout]);\n\n const removeCoupon = useCallback(() => {\n const currentCheckout = derived.checkout;\n if (!currentCheckout?.biId || !client) return;\n const removedCode = currentCheckout.couponCode?.trim() || null;\n // Prefer the remembered automatic offer; fall back to the pre-coupon\n // select response when the baseline was never captured.\n const priorCheckout = automaticBaselineRef.current\n ?? (selectMutation.data?.ok ? selectMutation.data.checkout : null);\n\n setCouponError(null);\n manualUpdateMutation.mutate(\n { biId: currentCheckout.biId, couponCode: '' },\n {\n onSuccess: (result) => {\n if (!result.ok) {\n setCouponError(getCouponErrorMessage(result.error));\n return;\n }\n setCheckoutOverride(\n checkoutWithoutCoupon(result.checkout ?? currentCheckout, priorCheckout),\n );\n setCouponError(null);\n if (removedCode) setRemovedCouponCode(removedCode);\n },\n onError: (err) => {\n setCouponError(errorMessage(err));\n },\n },\n );\n }, [derived.checkout, client, manualUpdateMutation, selectMutation.data]);\n\n const placeOrderCore = useCallback(async (opts: {\n billing: BillingInfo,\n confirmCardPayment: (clientSecret: string) => Promise<void>,\n }) => {\n const checkout = derived.checkout;\n if (!checkout || !client) throw new Error('Checkout not ready');\n // A timed-out attempt may still complete — never start a second one.\n if (paymentTimedOut) throw new RequestTimeoutError();\n\n setPlacingOrder(true);\n setPlaceOrderError(null);\n setPaymentInterrupted(false);\n setWalletPaymentCancelled(false);\n lastPaymentInfoRef.current = { method: 'card', processor: 'stripe' };\n\n // Segment: Payment Info Entered (track_plan_id 31)\n if (checkout.line) {\n trackEvent('Payment Info Entered', {\n checkoutType: 'a_la_carte',\n track_plan_id: 31,\n trigger_source: 'client-side',\n cart_id: checkout.biId,\n checkout_id: checkout.biId,\n currency: checkout.line.amountDue?.currency ?? 'USD',\n revenue: checkout.line.amountDue?.amount ?? 0,\n payment_method: 'card',\n discount: checkout.line.discount?.amount ?? 0,\n products: buildProductsFromLine(checkout.line, productDetailRef.current),\n });\n }\n\n try {\n const { checkout: updated } = await placeAlacarteOrder({\n updateCheckout: (args) => client.updateCheckout(args),\n placeCheckoutOrder: (biId, billing) => client.placeCheckoutOrder(biId, billing),\n checkout,\n billing: toAlacarteBillingAddress(opts.billing),\n confirmCardPayment: opts.confirmCardPayment,\n skipPrepare: cardRetryBiId === checkout.biId,\n });\n\n setCardRetryBiId(null);\n setCheckoutOverride(updated);\n await setOrderBiId(updated.biId);\n } catch (err: unknown) {\n if (err instanceof CardValidationError) {\n // tCheckoutPlaceOrder already succeeded and locked the checkout\n // (CART_PAYMENT_PENDING); Stripe rejected the card before it ever\n // reached the backend. Next attempt must retry tCheckoutPlaceOrder\n // directly, not tCheckoutUpdate.\n setCardRetryBiId(checkout.biId);\n } else {\n setCardRetryBiId(null);\n }\n if (err instanceof AlacartePlaceOrderError && err.checkout) {\n setCheckoutOverride(err.checkout);\n }\n // The timeout warning and sanctions modal replace the generic error banner.\n const errMsg = err instanceof Error ? err.message : '';\n if (isRequestTimeoutError(err)) {\n setPaymentTimedOut(true);\n } else if (isSanctionsBlockedError(err)) {\n // TODO: use the backend reference code once tCheckoutPlaceOrder returns one.\n setSanctionsBlocked({ referenceCode: 'REF-8F2K-40QX-1177' });\n } else if (isPurchaseBlockedError(err)) {\n setPurchaseBlocked(true);\n } else if (isCouponError(errMsg)) {\n // Coupon errors show inline below the promo code input, not as a top banner.\n setCouponError(getCouponErrorMessage(errMsg));\n } else {\n setPlaceOrderError(errorMessage(err));\n }\n throw err;\n } finally {\n setPlacingOrder(false);\n }\n }, [derived.checkout, client, setOrderBiId, cardRetryBiId, paymentTimedOut]);\n\n /** Fire-and-forget wrapper for card payments. */\n const placeOrder = useCallback((opts: {\n billing: BillingInfo,\n confirmCardPayment: (clientSecret: string) => Promise<void>,\n }) => {\n if (placingOrder || paymentTimedOut) return;\n placeOrderCore(opts).catch(() => { /* error already in state */ });\n }, [placeOrderCore, placingOrder, paymentTimedOut]);\n\n // biId of the checkout the open PayPal order belongs to — capture/cancel need it.\n const paypalBiIdRef = useRef<string | null>(null);\n\n const reloadCheckout = useCallback(async () => {\n if (!client) return;\n try {\n const fresh = await client.getCheckout();\n if (fresh.ok && fresh.checkout) {\n setCheckoutOverride(fresh.checkout);\n queryClient.setQueryData(alacarteKeys.checkout(), fresh);\n }\n } catch {\n // The learner can still retry from the current checkout.\n }\n }, [client, queryClient]);\n\n const startPaypalOrder = useCallback(async (opts: { billing: BillingInfo }) => {\n const checkout = derived.checkout;\n if (!checkout || !client) throw new Error('Checkout not ready');\n if (paymentTimedOut) throw new RequestTimeoutError();\n\n setPlacingOrder(true);\n setPlaceOrderError(null);\n setPaymentInterrupted(false);\n setWalletPaymentCancelled(false);\n lastPaymentInfoRef.current = { method: 'paypal', processor: 'paypal' };\n\n // Segment: Payment Info Entered (track_plan_id 31)\n if (checkout.line) {\n await trackEvent('Payment Info Entered', {\n checkoutType: 'a_la_carte',\n track_plan_id: 31,\n trigger_source: 'client-side',\n cart_id: checkout.biId,\n checkout_id: checkout.biId,\n currency: checkout.line.amountDue?.currency ?? 'USD',\n revenue: checkout.line.amountDue?.amount ?? 0,\n payment_method: 'paypal',\n discount: checkout.line.discount?.amount ?? 0,\n products: buildProductsFromLine(checkout.line, productDetailRef.current),\n });\n }\n\n try {\n const { checkout: updated, paypalOrderId } = await startAlacartePaypalOrder({\n updateCheckout: (args) => client.updateCheckout(args),\n placeCheckoutOrder: (biId, billing, paymentMethod) => (\n client.placeCheckoutOrder(biId, billing, paymentMethod)\n ),\n checkout,\n billing: toAlacarteBillingAddress(opts.billing),\n skipPrepare: cardRetryBiId === checkout.biId,\n });\n // tCheckoutPlaceOrder locked the checkout (CART_PAYMENT_PENDING) until\n // the PayPal order is captured or cancelled; a retry must skip tCheckoutUpdate.\n setCardRetryBiId(updated.biId);\n setCheckoutOverride(updated);\n paypalBiIdRef.current = updated.biId;\n return paypalOrderId;\n } catch (err: unknown) {\n if (err instanceof AlacartePlaceOrderError && err.checkout) {\n setCheckoutOverride(err.checkout);\n }\n const paypalErrMsg = err instanceof Error ? err.message : '';\n if (isRequestTimeoutError(err)) {\n setPaymentTimedOut(true);\n } else if (isSanctionsBlockedError(err)) {\n setSanctionsBlocked({ referenceCode: 'REF-8F2K-40QX-1177' });\n } else if (isCouponError(paypalErrMsg)) {\n setCouponError(getCouponErrorMessage(paypalErrMsg));\n } else {\n setPlaceOrderError(errorMessage(err));\n }\n setPlacingOrder(false);\n throw err;\n }\n }, [derived.checkout, client, cardRetryBiId, paymentTimedOut]);\n\n const cancelPaypalOrder = useCallback(async (paypalOrderId: string) => {\n const biId = paypalBiIdRef.current;\n if (!biId || !client) {\n setPlacingOrder(false);\n return;\n }\n try {\n const result = await client.cancelPaypalOrder(biId, paypalOrderId);\n if (result.ok) {\n // Settled as a failed payment — the checkout is open again.\n paypalBiIdRef.current = null;\n setCardRetryBiId(null);\n setPaymentInterrupted(true);\n }\n await reloadCheckout();\n } catch {\n // Leave cardRetryBiId set so the next attempt reuses the locked checkout.\n } finally {\n setPlacingOrder(false);\n }\n }, [client, reloadCheckout]);\n\n const approvePaypalOrder = useCallback(async (paypalOrderId: string) => {\n const biId = paypalBiIdRef.current;\n if (!biId || !client) throw new Error('Checkout not ready');\n\n setPlacingOrder(true);\n setPlaceOrderError(null);\n setPaymentInterrupted(false);\n setWalletPaymentCancelled(false);\n\n try {\n const result = await client.capturePaypalOrder(biId, paypalOrderId);\n // PAYMENT_IN_PROGRESS: another capture holds the lock and will settle the\n // order — poll getTwouOrder like a COMPLETED / PENDING capture.\n const placed = result.ok\n ? result.status === 'COMPLETED' || result.status === 'PENDING'\n : result.error === 'PAYMENT_IN_PROGRESS';\n if (!placed) {\n throw toPlaceOrderError(result.ok ? 'PAYPAL_PAYMENT_DECLINED' : (result.error ?? 'CAPTURE_FAILED'));\n }\n paypalBiIdRef.current = null;\n setCardRetryBiId(null);\n await setOrderBiId(biId);\n } catch (err: unknown) {\n setPlaceOrderError(errorMessage(err));\n // A declined/failed capture leaves the order settled as failed — reload so\n // the learner can retry (paymentDecline comes back on tCheckout).\n setCardRetryBiId(null);\n await reloadCheckout();\n throw err;\n } finally {\n setPlacingOrder(false);\n }\n }, [client, setOrderBiId, reloadCheckout]);\n\n const clearPaymentAlerts = useCallback(() => {\n setPlaceOrderError(null);\n setPaymentInterrupted(false);\n setWalletPaymentCancelled(false);\n }, []);\n\n const placedView = derivePlacedOrderView({\n orderBiId,\n result: placedOrderQuery.data,\n pollTimedOut: placedOrderQuery.pollTimedOut,\n isLoading: placedOrderQuery.isLoading,\n isFetching: placedOrderQuery.isFetching,\n });\n const { placedOrder } = placedView;\n const placedOrderPlacedAt = placedOrder?.placedAt ?? null;\n\n // Segment: Order Completed (track_plan_id 32), deduplicated by order number.\n useEffect(() => {\n if (!placedOrder || !orderBiId) return;\n const { method, processor } = lastPaymentInfoRef.current;\n trackEventOnce('Order Completed', {\n checkoutType: 'a_la_carte',\n track_plan_id: 32,\n trigger_source: 'client-side',\n order_id: placedOrder.orderNumber,\n checkout_id: orderBiId,\n total: placedOrder.totals.paid,\n revenue: placedOrder.totals.paid,\n currency: placedOrder.totals.currency,\n tax: placedOrder.totals.discount === 0 && placedOrder.totals.paid === 0 ? 0 : placedOrder.totals.deduction,\n coupon: placedOrder.couponCode ?? null,\n coupon_name: [],\n discount: placedOrder.totals.discount,\n processor_name: processor,\n payment_method: method,\n products: derived.line\n ? buildProductsFromLine(derived.line, productDetailRef.current)\n : buildProductsFromOrder(placedOrder.lines, productDetailRef.current),\n });\n }, [placedOrder, orderBiId, productDetailQuery.data, derived.line]);\n\n // NOT_PLACED / poll timeout: the payment either failed or we couldn't confirm\n // it in time. Reload tCheckout and drop ?order_bi_id= so the learner can\n // retry instead of sitting on the confirmation error.\n // The ref blocks a second reload for the same attempt. It is not cleared in\n // cleanup — a re-run must not cancel the reload that is already in flight.\n const returnedToCheckoutFor = useRef<string | null>(null);\n useEffect(() => {\n if (!orderBiId) {\n returnedToCheckoutFor.current = null;\n return undefined;\n }\n if (!placedView.returnToCheckout) return undefined;\n if (returnedToCheckoutFor.current === orderBiId) return undefined;\n returnedToCheckoutFor.current = orderBiId;\n\n if (placedView.returnedByPollTimeout) {\n // ALC-452 #6: the poll window expired without a payment outcome.\n // Show a retry-friendly error instead of the \"payment interrupted\"\n // message, which implies \"you haven't been charged\".\n setPlaceOrderError(POLL_TIMEOUT_MESSAGE);\n } else {\n // NOT_PLACED: the backend confirmed the payment did not go through.\n setPaymentInterrupted(true);\n }\n\n (async () => {\n if (client) {\n try {\n const fresh = await client.getCheckout();\n if (fresh.ok && fresh.checkout) {\n setCheckoutOverride(fresh.checkout);\n queryClient.setQueryData(alacarteKeys.checkout(), fresh);\n }\n } catch {\n // Still leave the poll — the cart is editable even if this read fails.\n }\n }\n await setOrderBiId(null);\n })();\n\n return undefined;\n }, [orderBiId, placedView.returnToCheckout, placedView.returnedByPollTimeout, client, setOrderBiId, queryClient]);\n\n return {\n ...derived,\n couponError,\n couponApplying: manualUpdateMutation.isPending,\n applyCoupon,\n removeCoupon,\n clearCouponError: () => setCouponError(null),\n removedCouponCode,\n clearRemovedCouponCode: () => setRemovedCouponCode(null),\n placingOrder,\n placeOrderError,\n paymentInterrupted,\n walletPaymentCancelled,\n placeOrder,\n placeOrderAsync: placeOrderCore,\n startPaypalOrder,\n approvePaypalOrder,\n cancelPaypalOrder,\n clearPlaceOrderError: () => setPlaceOrderError(null),\n clearPaymentInterrupted: () => setPaymentInterrupted(false),\n markWalletPaymentCancelled: () => setWalletPaymentCancelled(true),\n clearWalletPaymentCancelled: () => setWalletPaymentCancelled(false),\n clearPaymentAlerts,\n paymentTimedOut,\n sanctionsBlocked,\n purchaseBlocked,\n paymentDecline: derived.checkout?.paymentDecline ?? null,\n placedOrder,\n awaitingPlacedOrder: placedView.awaitingPlacedOrder,\n placedOrderError: placedView.placedOrderError,\n placedOrderPlacedAt,\n };\n}\n\nexport default useAlacarteCheckout;\n"]}
1
+ {"version":3,"file":"useAlacarteCheckout.js","sourceRoot":"","sources":["../../../src/data/hooks/useAlacarteCheckout.ts"],"names":[],"mappings":";;;;;;;;;AAAA;;;;;;;;;;;;;;GAcG;AACH,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC1E,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;AACpE,OAAO,EAAE,4BAA4B,EAAE,MAAM,8BAA8B,CAAC;AAC5E,OAAO,EAAE,qBAAqB,EAAE,uBAAuB,EAAE,aAAa,EAAE,MAAM,0BAA0B,CAAC;AACzG,OAAO,EACL,kBAAkB,EAClB,wBAAwB,EACxB,wBAAwB,GACzB,MAAM,6BAA6B,CAAC;AACrC,OAAO,EACL,uBAAuB,EAAE,qBAAqB,EAAE,sBAAsB,EAAE,uBAAuB,EAC/F,oBAAoB,EAAE,iBAAiB,GACxC,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,mBAAmB,EAAE,MAAM,wBAAwB,CAAC;AAC7D,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AACvF,OAAO,EACL,6BAA6B,EAAE,mBAAmB,EAAE,qBAAqB,EAAE,wBAAwB,GACpG,MAA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uBAAuB,EAAE,GAAG,EAAE,CAAC,qBAAqB,CAAC,KAAK,CAAC,EAC3D,0BAA0B,EAAE,GAAG,EAAE,CAAC,yBAAyB,CAAC,IAAI,CAAC,EACjE,2BAA2B,EAAE,GAAG,EAAE,CAAC,yBAAyB,CAAC,KAAK,CAAC,EACnE,kBAAkB;QAClB,eAAe;QACf,gBAAgB;QAChB,eAAe,EACf,cAAc,EAAE,gBAAgB,IAAI,OAAO,CAAC,KAAK,KAAK,gBAAgB,EACtE,cAAc,EAAE,MAAA,MAAA,OAAO,CAAC,QAAQ,0CAAE,cAAc,mCAAI,IAAI,EACxD,WAAW,EACX,mBAAmB,EAAE,UAAU,CAAC,mBAAmB,EACnD,gBAAgB,EAAE,UAAU,CAAC,gBAAgB,EAC7C,mBAAmB,IACnB;AACJ,CAAC;AAED,eAAe,mBAAmB,CAAC","sourcesContent":["/**\n * data/hooks/useAlacarteCheckout.ts — page-level orchestration for the à la\n * carte checkout flow:\n *\n * 1. Read a product selector (course or program) from the URL via nuqs.\n * 2. If a product is selected: check ownership (tOwnedProducts). Already\n * owned -> 'alreadyOwned'. Otherwise select it into the checkout\n * (tCheckoutSelect) and fetch its display details in parallel.\n * 3. If no product is selected: look for an existing open checkout\n * (tCheckout). Found -> 'ready'. Not found -> 'noActiveCheckout'.\n * 4. Coupon apply/remove and payment prep via tCheckoutUpdate.\n *\n * See /alacarte-checkout-api.md and /alacarte-owned-products-api.md at the\n * repo root for the underlying API contract.\n */\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { useQueryClient } from '@tanstack/react-query';\nimport { useQueryStates, useQueryState, parseAsString } from 'nuqs';\nimport { createAlacarteCheckoutClient } from '../../utils/alacarteCheckout';\nimport { getCouponErrorMessage, getCouponRecheckMessage, isCouponError } from '../../utils/couponErrors';\nimport {\n placeAlacarteOrder,\n startAlacartePaypalOrder,\n toAlacarteBillingAddress,\n} from '../../utils/alacartePayment';\nimport {\n AlacartePlaceOrderError, isCheckoutPausedError, isPurchaseBlockedError, isSanctionsBlockedError,\n POLL_TIMEOUT_MESSAGE, toPlaceOrderError,\n} from '../../utils/placeOrderErrors';\nimport { CardValidationError } from '../../utils/stripeCard';\nimport { isRequestTimeoutError, RequestTimeoutError } from '../../utils/timeoutErrors';\nimport {\n useSubscriptionCourseKeyQuery, useViaxSessionQuery, useRefreshViaxSession, viaxTokenForRejectedCall,\n} from './useCheckoutQueries';\nimport {\n courseKeyFromCourseRunKey, lmsOriginFromSessionUrl, isCourseNotFoundError,\n} from '../../utils/provision';\nimport { getCourseRunKeyFromUrl } from '../../utils/url';\nimport {\n useOwnedProductQuery, useAlacarteCheckoutQuery, useSelectProductMutation, useProductDetailQuery,\n useUpdateCheckoutMutation, usePlacedOrderQuery,\n} from './useAlacarteQueries';\nimport { alacarteKeys } from './keys';\nimport { derivePlacedOrderView } from './placedOrderPoll';\nimport { trackEvent, trackEventOnce } from '../../analytics/trackEvent';\nimport { buildProductsFromLine, buildProductsFromOrder } from '../../analytics/buildProducts';\nimport type {\n AlacarteCheckout, AlacarteCheckoutResult, AlacarteLine, AlacarteMoney, AlacartePaymentDecline,\n AlacartePriceChanged, OwnedProduct, OwnedProductResult, PlacedOrder, ProductDetail, ProductSelector,\n} from '../../types/alacarte';\nimport type { BillingInfo } from '../../types';\n\nexport type AlacartePhase = 'loading' | 'alreadyOwned' | 'noActiveCheckout' | 'notPurchasable' | 'checkoutPaused' | 'ready' | 'error';\n\nexport type AlacarteNoticeMessageId = 'alreadyOwnedCourse' | 'alreadyOwnedProgram' | 'noActiveCheckout';\n\n/** Pure phase decision output — no action callbacks. */\nexport interface AlacartePhaseState {\n phase: AlacartePhase,\n noticeMessageId?: AlacarteNoticeMessageId,\n selector: ProductSelector,\n checkout: AlacarteCheckout | null,\n line: AlacarteLine | null,\n productDetail: ProductDetail | null,\n error: string | null,\n priceChanged: AlacartePriceChanged | null,\n priceAccepted: boolean,\n /** True when the learner already owns this product. The checkout data may\n * still be populated so the UI can render the full page under an overlay. */\n isAlreadyOwned: boolean,\n /** True when the selection was refused because the specific run is unavailable\n * (e.g. enrollment closed, run archived). The UI shows a \"choose another\n * session\" link back to the course page. */\n isRunBlocked: boolean,\n /** True when the learner's account is blocked from purchasing (PURCHASE_BLOCKED\n * at select time). The UI shows a blocking modal instead of the error banner. */\n isPurchaseBlocked: boolean,\n /** Product name from the owned-products query — used as a fallback when the\n * checkout line (which normally carries the name) is not available. */\n ownedProductName: string | null,\n}\n\nexport interface UseAlacarteCheckoutResult extends AlacartePhaseState {\n couponError: string | null,\n couponApplying: boolean,\n applyCoupon: (code: string) => void,\n removeCoupon: () => void,\n clearCouponError: () => void,\n /** Code of the coupon just removed, set only once the removal round-trip\n * completes — kept in sync with when the discount actually leaves the line. */\n removedCouponCode: string | null,\n clearRemovedCouponCode: () => void,\n placingOrder: boolean,\n placeOrderError: string | null,\n /** True when the learner returns to checkout without completing payment. */\n paymentInterrupted: boolean,\n /** True when the learner dismissed the Apple Pay / Google Pay sheet without paying. */\n walletPaymentCancelled: boolean,\n /**\n * Accepts price (if needed) + terms, calls tCheckoutPlaceOrder with billing,\n * confirms the card via Stripe.js, then sets ?order_bi_id= to poll getTwouOrder.\n * Fire-and-forget — errors go to placeOrderError state.\n */\n placeOrder: (opts: {\n billing: BillingInfo,\n confirmCardPayment: (clientSecret: string) => Promise<void>,\n }) => void,\n /**\n * Same as placeOrder but returns a Promise — used by ExpressCheckout\n * so the wallet sheet can await the result and call ev.complete().\n */\n placeOrderAsync: (opts: {\n billing: BillingInfo,\n confirmCardPayment: (clientSecret: string) => Promise<void>,\n }) => Promise<void>,\n /**\n * PayPal buttons `createOrder`: accepts price + terms and calls\n * tCheckoutPlaceOrder(paymentMethod: PAYPAL). Resolves the PayPal order id.\n */\n startPaypalOrder: (opts: { billing: BillingInfo }) => Promise<string>,\n /** PayPal buttons `onApprove`: tCheckoutCapturePaypalOrder, then sets ?order_bi_id=. */\n approvePaypalOrder: (paypalOrderId: string) => Promise<void>,\n /** PayPal buttons `onCancel` / `onError`: tCheckoutCancelPaypalOrder and reload tCheckout. */\n cancelPaypalOrder: (paypalOrderId: string) => Promise<void>,\n clearPlaceOrderError: () => void,\n clearPaymentInterrupted: () => void,\n /** Express Checkout Element `cancel`: the wallet sheet was closed without paying. */\n markWalletPaymentCancelled: () => void,\n clearWalletPaymentCancelled: () => void,\n /**\n * Express Checkout Element `click`: a new Apple Pay / Google Pay attempt is\n * starting, so the previous attempt's banners go (PayPal does this in\n * startPaypalOrder).\n */\n clearPaymentAlerts: () => void,\n /** True once the payment provider timed out during place order (HTTP 408 /\n * Stripe network error). The order may still go through, so further\n * attempts are blocked and the UI shows the timeout warning instead. */\n paymentTimedOut: boolean,\n /** Set when tCheckoutPlaceOrder returned SANCTIONS_BLOCKED. No charge was\n * made; the UI shows a blocking modal with a code the learner can quote\n * to support. Hardcoded until the backend returns a reference code\n * with SANCTIONS_BLOCKED. */\n sanctionsBlocked: { referenceCode: string } | null,\n /** Set when tCheckoutPlaceOrder returned PURCHASE_BLOCKED. No charge was\n * made; the UI shows a blocking modal directing the learner to contact\n * support. */\n purchaseBlocked: boolean,\n /** True when tCheckoutSelect or tCheckoutPlaceOrder returned CHECKOUT_PAUSED\n * (ALC-200 kill switch). The UI locks the page behind a blocking banner. */\n checkoutPaused: boolean,\n /** Decline details from the last card attempt on this checkout, if any. */\n paymentDecline: AlacartePaymentDecline | null,\n /** When ?order_bi_id= is present, the placed order (or null while polling). */\n placedOrder: PlacedOrder | null,\n /**\n * True while getTwouOrder is still awaiting tPlacedAt (payment confirming,\n * including 3DS) or while we reload tCheckout after NOT_PLACED.\n */\n awaitingPlacedOrder: boolean,\n placedOrderError: string | null,\n /** ISO timestamp the order was placed (tPlacedAt, falling back to\n * biCreatedAt); null while the order-dates query hasn't resolved yet. */\n placedOrderPlacedAt: string | null,\n}\n\n/**\n * Read the product selector from the URL: course_uuid+course_run_key, or\n * program_uuid, or neither. Both course params must be present together; if a\n * course param and a program param are both present, that's\n * CONFLICTING_SELECTION.\n *\n * Legacy aliases `course_uid` / `program_uid` are still accepted; the `*_uuid`\n * names win when both are present.\n *\n * NOTE: course_run_key values look like \"course-v1:HarvardX+CS50+X\" — nuqs\n * decodes query values the standards-compliant way (literal `+` -> space),\n * same as native URLSearchParams. runKey is therefore read from the raw query\n * string via getCourseRunKeyFromUrl(), which preserves literal `+`.\n */\nexport function useProductSelector(): ProductSelector {\n const [{\n courseUuid, courseUidLegacy, runKey: nuqsRunKey, programUuid, programUidLegacy,\n }] = useQueryStates({\n courseUuid: parseAsString,\n courseUidLegacy: parseAsString,\n runKey: parseAsString,\n programUuid: parseAsString,\n programUidLegacy: parseAsString,\n }, {\n urlKeys: {\n courseUuid: 'course_uuid',\n courseUidLegacy: 'course_uid',\n runKey: 'course_run_key',\n programUuid: 'program_uuid',\n programUidLegacy: 'program_uid',\n },\n });\n const courseUid = courseUuid ?? courseUidLegacy;\n const programUid = programUuid ?? programUidLegacy;\n const runKey = nuqsRunKey ? (getCourseRunKeyFromUrl() ?? nuqsRunKey) : null;\n\n return useMemo<ProductSelector>(() => {\n const hasCourse = !!courseUid || !!runKey;\n const hasProgram = !!programUid;\n if (hasCourse && hasProgram) return { kind: 'invalid' };\n if (courseUid && runKey) return { kind: 'course', courseUid, runKey };\n if (programUid) return { kind: 'program', programUid };\n return { kind: 'none' };\n }, [courseUid, runKey, programUid]);\n}\n\n/** Reads ?discount_code= — applied to the checkout right after it's created. */\nexport function useDiscountCode(): string | null {\n const [discountCode] = useQueryState('discount_code', parseAsString);\n return discountCode;\n}\n\nfunction errorMessage(error: unknown): string {\n return error instanceof Error ? error.message : 'Unknown error';\n}\n\n/**\n * Build a synthetic AlacarteLine from the owned-product pricing data so the\n * checkout overlay can show subtotal / deduction / total even when the backend\n * blocks tCheckoutSelect and returns no checkout object.\n */\nfunction buildLineFromOwnedProduct(product: OwnedProduct): AlacarteLine | null {\n if (!product.price) return null;\n const { full, deduction, amountDue, currency } = product.price;\n const toMoney = (amount: number): AlacarteMoney => ({ amount, currency });\n\n if (product.kind === 'program') {\n return {\n biiId: '',\n kind: 'program',\n programId: product.productId,\n programName: product.name,\n price: toMoney(full),\n deduction: deduction ? toMoney(deduction) : null,\n ownedCourses: product.ownedCourses.map((c) => ({\n courseId: c.courseId, name: c.name, via: c.via,\n })),\n discount: null,\n amountDue: toMoney(amountDue),\n billingAddressSet: false,\n };\n }\n\n return {\n biiId: '',\n kind: 'course',\n courseName: product.name,\n courseUid: product.productId,\n courseRunKey: '',\n seatType: 'verified',\n price: toMoney(full),\n discount: null,\n amountDue: toMoney(amountDue),\n billingAddressSet: false,\n };\n}\n\ninterface QueryLikeState<T> {\n isLoading: boolean,\n isError: boolean,\n error?: unknown,\n data?: T,\n}\n\ninterface MutationLikeState<T> {\n isIdle: boolean,\n isPending: boolean,\n isError: boolean,\n error?: unknown,\n data?: T,\n}\n\nexport interface DeriveAlacartePhaseInput {\n selector: ProductSelector,\n sessionReady: boolean,\n sessionIsError: boolean,\n sessionErrorMessage?: string,\n ownedQuery: QueryLikeState<OwnedProductResult>,\n selectMutation: MutationLikeState<AlacarteCheckoutResult>,\n checkoutQuery: QueryLikeState<AlacarteCheckoutResult>,\n productDetail: ProductDetail | null,\n /** Coupon (?discount_code=) applied right after the checkout is created —\n * when it succeeds, its checkout (with the coupon's discount reflected)\n * is shown in place of the pre-coupon one from selectMutation. */\n couponMutation?: MutationLikeState<AlacarteCheckoutResult>,\n /** True when a URL discount code still needs to be applied — the phase\n * stays 'loading' until the coupon mutation resolves so the user never sees\n * the pre-discount price flash. */\n urlCouponPending?: boolean,\n /** Latest successful manual update (coupon / acceptPrice / terms). Wins over\n * select + URL coupon when present. */\n checkoutOverride?: AlacarteCheckout | null,\n /** Course-runs lookup for a course selector. Empty `elements` is notFound. */\n courseRunLookup?: { pending: boolean, notFound: boolean },\n}\n\nconst RUN_BLOCKED_DETAILS = new Set([\n 'run_not_found', 'run_archived', 'run_enrollment_closed', 'run_no_paid_seat', 'run_ended',\n]);\n\n/**\n * Map a `blocked.detail` to a learner-facing message.\n * Never surfaces the raw code — unknown details get a generic fallback.\n */\nfunction blockedDetailMessage(detail: string | undefined, kind: 'course' | 'program'): string {\n if (detail && RUN_BLOCKED_DETAILS.has(detail)) {\n return 'This session is no longer open for enrollment.';\n }\n switch (detail) {\n case 'course_no_price':\n case 'program_no_price':\n return kind === 'program'\n ? 'Pricing is not available for this program right now.'\n : 'Pricing is not available for this course right now.';\n case 'lms_unavailable':\n return 'We couldn\\u2019t verify your existing enrollments right now. Please try again in a few minutes.';\n default:\n return kind === 'program'\n ? 'This program is not eligible for checkout.'\n : 'This course is not eligible for checkout.';\n }\n}\n\n/**\n * Pure decision function — no hooks, no React Query/nuqs types beyond plain\n * data — so every branch combination can be unit-tested directly.\n */\nexport function deriveAlacartePhase(input: DeriveAlacartePhaseInput): AlacartePhaseState {\n const {\n selector, sessionReady, sessionIsError, sessionErrorMessage,\n ownedQuery, selectMutation, checkoutQuery, productDetail, couponMutation,\n checkoutOverride = null, urlCouponPending: urlCouponPendingProp = false,\n courseRunLookup = { pending: false, notFound: false },\n } = input;\n\n const ownedProductName = ownedQuery.data?.product?.name ?? null;\n\n const empty: Omit<AlacartePhaseState, 'phase'> = {\n selector,\n checkout: null,\n line: null,\n productDetail: null,\n error: null,\n priceChanged: null,\n priceAccepted: false,\n isAlreadyOwned: false,\n isRunBlocked: false,\n isPurchaseBlocked: false,\n ownedProductName: null,\n };\n\n /**\n * `priceChangeSource` is the response that reported priceChanged. A change\n * that only reflects an automatic offer on that response's line is dropped\n * (the learner gets the offer's success alert instead) and treated as\n * accepted so the price-accept notice stays hidden too. Payment still sends\n * acceptPrice, since it reads checkout.priceAccepted from the backend.\n */\n const withCheckout = (\n checkout: AlacarteCheckout | null,\n priceChangeSource: AlacarteCheckoutResult | null = null,\n isAlreadyOwned = false,\n ): AlacartePhaseState => {\n const priceChanged = priceChangeSource?.priceChanged ?? null;\n const automaticOfferOnly = !!priceChanged\n && isAutomaticOfferPriceChange(priceChanged, priceChangeSource?.checkout?.line);\n return {\n phase: isAlreadyOwned ? 'alreadyOwned' : 'ready',\n selector,\n checkout,\n line: checkout?.line ?? null,\n productDetail,\n error: null,\n priceChanged: automaticOfferOnly ? null : priceChanged,\n priceAccepted: checkout?.priceAccepted === true || automaticOfferOnly,\n isAlreadyOwned,\n isRunBlocked: false,\n isPurchaseBlocked: false,\n ownedProductName: isAlreadyOwned ? ownedProductName : null,\n };\n };\n\n if (selector.kind === 'invalid') {\n return { phase: 'error', ...empty, error: 'CONFLICTING_SELECTION' };\n }\n if (sessionIsError) {\n return { phase: 'error', ...empty, error: sessionErrorMessage ?? 'Session error' };\n }\n\n const hasSelector = selector.kind === 'course' || selector.kind === 'program';\n\n if (hasSelector) {\n if (selector.kind === 'course' && courseRunLookup.notFound) {\n return {\n phase: 'error',\n ...empty,\n error: 'This course could not be found.',\n };\n }\n if (!sessionReady || ownedQuery.isLoading || courseRunLookup.pending) {\n return { phase: 'loading', ...empty };\n }\n if (ownedQuery.isError) {\n return { phase: 'error', ...empty, error: errorMessage(ownedQuery.error) };\n }\n\n const isOwned = ownedQuery.data?.ok === true && ownedQuery.data.product?.status === 'full';\n\n if (selectMutation.isIdle || selectMutation.isPending) {\n return { phase: 'loading', ...empty };\n }\n if (selectMutation.isError) {\n return { phase: 'error', ...empty, error: errorMessage(selectMutation.error) };\n }\n if (selectMutation.data && !selectMutation.data.ok) {\n // The backend may block ALREADY_OWNED at select time. When the\n // blocked response still includes checkout data (line, pricing), use\n // it so the overlay page shows the real totals. Fall back to the\n // standalone tCheckout query, then to an empty state.\n if (selectMutation.data.blocked?.reason === 'ALREADY_OWNED') {\n const blockedCheckout = selectMutation.data.checkout\n ?? (checkoutQuery.data?.ok ? checkoutQuery.data.checkout : null);\n if (blockedCheckout) {\n return withCheckout(blockedCheckout, selectMutation.data, true);\n }\n // Build a synthetic line from the owned-product pricing so the\n // overlay can show subtotal / deduction / total.\n const ownedProduct = ownedQuery.data?.product;\n const syntheticLine = ownedProduct ? buildLineFromOwnedProduct(ownedProduct) : null;\n return {\n phase: 'alreadyOwned',\n noticeMessageId: selectMutation.data.blocked.kind === 'course' ? 'alreadyOwnedCourse' : 'alreadyOwnedProgram',\n ...empty,\n line: syntheticLine,\n productDetail,\n isAlreadyOwned: true,\n ownedProductName,\n };\n }\n if (selectMutation.data.blocked?.reason === 'NOT_PURCHASABLE'\n || selectMutation.data.blocked?.reason === 'OWNERSHIP_UNAVAILABLE') {\n const { detail, kind } = selectMutation.data.blocked;\n return {\n phase: 'notPurchasable',\n ...empty,\n productDetail,\n isRunBlocked: !!detail && RUN_BLOCKED_DETAILS.has(detail),\n error: blockedDetailMessage(detail, kind),\n };\n }\n const selectError = selectMutation.data.error;\n if (selectError === 'COURSE_NOT_FOUND' || selectError === 'PRODUCT_NOT_FOUND') {\n return {\n phase: 'error',\n ...empty,\n error: 'This course could not be found.',\n };\n }\n if (selectError === 'PROGRAM_NOT_FOUND') {\n return {\n phase: 'error',\n ...empty,\n error: 'This program could not be found.',\n };\n }\n if (selectError === 'CHECKOUT_PAUSED') {\n // No checkout comes back — build the line from the owned-product\n // pricing so the locked page still shows the summary and total.\n const ownedProduct = ownedQuery.data?.product;\n return {\n phase: 'checkoutPaused',\n ...empty,\n line: ownedProduct ? buildLineFromOwnedProduct(ownedProduct) : null,\n productDetail,\n ownedProductName,\n };\n }\n if (selectError === 'PURCHASE_BLOCKED') {\n return {\n phase: 'ready',\n ...empty,\n productDetail,\n isPurchaseBlocked: true,\n };\n }\n // Unknown blocked reason — never surface the raw code.\n const blockedKind = selectMutation.data.blocked?.kind ?? 'course';\n return {\n phase: 'error',\n ...empty,\n error: blockedDetailMessage(undefined, blockedKind),\n };\n }\n\n // When a URL discount code still needs to be applied, stay in 'loading'\n // so the user never sees the pre-discount price flash.\n if (urlCouponPendingProp && !checkoutOverride) {\n return { phase: 'loading', ...empty };\n }\n\n // Once the coupon-apply (?discount_code=) mutation succeeds, its checkout\n // (with the discount reflected) supersedes the pre-coupon one. Manual\n // updates (override) win over both.\n const finalCheckout = checkoutOverride\n ?? (couponMutation?.data?.ok\n ? couponMutation.data.checkout\n : selectMutation.data?.checkout ?? null);\n\n // When select succeeds but the owned-products query says the learner\n // already has this product, show the full checkout under an overlay.\n return withCheckout(\n finalCheckout,\n selectMutation.data?.priceChanged\n ? selectMutation.data\n : (couponMutation?.data?.ok ? couponMutation.data : null),\n isOwned,\n );\n }\n\n // No selector: fall back to the learner's existing open checkout, if any.\n if (!sessionReady || checkoutQuery.isLoading) {\n return { phase: 'loading', ...empty };\n }\n if (checkoutQuery.isError) {\n return { phase: 'error', ...empty, error: errorMessage(checkoutQuery.error) };\n }\n if (checkoutOverride || checkoutQuery.data?.checkout) {\n const checkout = checkoutOverride ?? checkoutQuery.data!.checkout;\n return withCheckout(checkout, checkoutQuery.data ?? null);\n }\n\n return { phase: 'noActiveCheckout', noticeMessageId: 'noActiveCheckout', ...empty, isAlreadyOwned: false, ownedProductName: null };\n}\n\n/** amountDue with coupon/automatic discount removed (price − program deduction). */\nfunction amountDueWithoutDiscount(line: AlacarteLine): AlacarteMoney | null {\n if (!line.price) return null;\n if (line.kind === 'program' && line.deduction) {\n return {\n amount: line.price.amount - line.deduction.amount,\n currency: line.price.currency,\n };\n }\n return line.price;\n}\n\nfunction sameMoney(a: AlacarteMoney, b: AlacarteMoney): boolean {\n return a.currency === b.currency && Math.abs(a.amount - b.amount) < 0.005;\n}\n\n/**\n * True when priceChanged only reflects an automatic offer (e.g. a first-order\n * code): viewedPrice is sent before any discount, so the backend reports the\n * offer as a price change. Viewed must match the line before the offer and\n * current the line after it.\n */\nfunction isAutomaticOfferPriceChange(\n priceChanged: AlacartePriceChanged,\n line: AlacarteLine | null | undefined,\n): boolean {\n if (line?.discountSource !== 'automatic' || !line.discount || !line.amountDue) return false;\n const base = amountDueWithoutDiscount(line);\n return !!base && sameMoney(priceChanged.viewed, base) && sameMoney(priceChanged.current, line.amountDue);\n}\n\n/** amountDue after applying a discount on top of price (− program deduction). */\nfunction amountDueWithDiscount(\n line: AlacarteLine,\n discount: AlacarteMoney,\n): AlacarteMoney | null {\n const base = amountDueWithoutDiscount(line);\n if (!base) return null;\n return { amount: base.amount - discount.amount, currency: base.currency };\n}\n\n/**\n * Checkout to show once a coupon removal succeeds. The backend may return a\n * line that still carries the old coupon discount/amountDue, so that line is\n * patched to clear it. An automatic offer (bundle / first-order) the backend\n * re-applied once the coupon is gone is the real state and is kept as-is.\n *\n * When the backend clears the coupon but does not re-apply the automatic\n * offer that was present before the coupon, `priorCheckout` (typically the\n * pre-coupon select response) is used to restore that offer.\n */\nexport function checkoutWithoutCoupon(\n checkout: AlacarteCheckout,\n priorCheckout?: AlacarteCheckout | null,\n): AlacarteCheckout {\n const { line } = checkout;\n if (!line) {\n return { ...checkout, couponCode: null };\n }\n if (line.discountSource === 'automatic') {\n return { ...checkout, couponCode: null };\n }\n\n const priorLine = priorCheckout?.line;\n const priorAutomatic = priorLine?.discountSource === 'automatic' && priorLine.discount\n ? priorLine\n : null;\n\n const clearedLine = {\n ...line,\n discount: null,\n discountSource: null,\n discountName: null,\n amountDue: amountDueWithoutDiscount(line),\n } as typeof line;\n\n if (priorAutomatic?.discount) {\n return {\n ...checkout,\n couponCode: null,\n line: {\n ...clearedLine,\n discount: priorAutomatic.discount,\n discountSource: 'automatic',\n discountName: priorAutomatic.discountName ?? null,\n amountDue: amountDueWithDiscount(clearedLine, priorAutomatic.discount),\n } as typeof line,\n };\n }\n\n return { ...checkout, couponCode: null, line: clearedLine };\n}\n\nexport function useAlacarteCheckout(\n options: {\n apiUrl?: string,\n edxSessionUrl?: string,\n /**\n * When true, skip GET /api/subscription/course_runs/ and call Viax with a\n * course key derived from ?course_run_key= instead.\n */\n skipSubscriptionCourseRuns?: boolean,\n },\n): UseAlacarteCheckoutResult {\n const { apiUrl, edxSessionUrl, skipSubscriptionCourseRuns = false } = options;\n const queryClient = useQueryClient();\n const selector = useProductSelector();\n const discountCode = useDiscountCode();\n const [orderBiId, setOrderBiId] = useQueryState('order_bi_id', parseAsString);\n\n // Reuses the same query key as useCheckout's session exchange — React\n // Query dedupes the network call regardless of how many hooks read it.\n const sessionQuery = useViaxSessionQuery(edxSessionUrl ?? null);\n const sessionReady = !!sessionQuery.data;\n const refreshSession = useRefreshViaxSession(edxSessionUrl ?? null);\n\n // Stable ref so the onRefreshToken callback always uses the latest\n // refreshSession without recreating the client on every render.\n const refreshSessionRef = useRef(refreshSession);\n refreshSessionRef.current = refreshSession;\n\n const client = useMemo(\n () => (apiUrl ? createAlacarteCheckoutClient({\n apiUrl,\n onRefreshToken: () => viaxTokenForRejectedCall(() => refreshSessionRef.current()),\n }) : null),\n [apiUrl],\n );\n\n useEffect(() => {\n if (sessionQuery.data && client) {\n client.setToken(sessionQuery.data.viaxToken);\n }\n }, [sessionQuery.data, client]);\n\n const hasSelector = selector.kind === 'course' || selector.kind === 'program';\n const productId = selector.kind === 'course'\n ? selector.courseUid\n : selector.kind === 'program' ? selector.programUid : null;\n\n const ownedQuery = useOwnedProductQuery(client, sessionReady && hasSelector, productId);\n const isOwned = ownedQuery.data?.ok === true && ownedQuery.data.product?.status === 'full';\n\n const selectMutation = useSelectProductMutation(client);\n const {\n isIdle: selectIsIdle, mutate: selectMutate, reset: selectReset,\n } = selectMutation;\n\n const courseRunKey = selector.kind === 'course' ? selector.runKey : null;\n const lmsBaseUrl = useMemo(\n () => lmsOriginFromSessionUrl(edxSessionUrl),\n [edxSessionUrl],\n );\n const courseLookupEnabled = !skipSubscriptionCourseRuns\n && selector.kind === 'course'\n && !!lmsBaseUrl\n && !!courseRunKey;\n const courseKeyQuery = useSubscriptionCourseKeyQuery(\n skipSubscriptionCourseRuns ? null : lmsBaseUrl,\n skipSubscriptionCourseRuns ? null : courseRunKey,\n );\n const courseKey = skipSubscriptionCourseRuns\n ? (courseRunKey ? courseKeyFromCourseRunKey(courseRunKey) : null)\n : (courseKeyQuery.data ?? null);\n const courseNotFound = courseLookupEnabled\n && courseKeyQuery.isError\n && isCourseNotFoundError(courseKeyQuery.error);\n\n // Mutations aren't called during render — fire once the owned-products\n // query resolves (regardless of result) so we always get checkout/line data.\n // A course is not selected until the course-runs lookup returns a course.\n // Pass viewedPrice from tOwnedProducts.amountDue (ALC-159) when available.\n useEffect(() => {\n if (!hasSelector || ownedQuery.isLoading || ownedQuery.isError) return;\n if (selector.kind === 'course' && !courseKey) return;\n if (!selectIsIdle) return;\n const amountDue = ownedQuery.data?.product?.price?.amountDue;\n selectMutate({\n selector,\n viewedPrice: typeof amountDue === 'number' ? amountDue : undefined,\n });\n }, [\n hasSelector,\n ownedQuery.isLoading,\n ownedQuery.isError,\n ownedQuery.data?.product?.price?.amountDue,\n selector,\n courseKey,\n selectIsIdle,\n selectMutate,\n ]);\n\n const productDetailEnabled = hasSelector && sessionReady && !ownedQuery.isLoading\n && (selector.kind !== 'course' || !!courseKey);\n const productDetailQuery = useProductDetailQuery(client, productDetailEnabled, selector, courseKey);\n\n // Run the checkout query when there's no selector (standard path) OR when\n // the product is already owned — after the select mutation is blocked with\n // ALREADY_OWNED the server may still have an open checkout with pricing data.\n const selectBlocked = !selectMutation.isIdle && !selectMutation.isPending\n && selectMutation.data && !selectMutation.data.ok;\n const checkoutQuery = useAlacarteCheckoutQuery(\n client,\n sessionReady && (!hasSelector || (isOwned && !!selectBlocked)),\n );\n\n // Apply ?discount_code= to the freshly-created checkout — fired once the\n // select mutation succeeds with a checkout that doesn't already carry it.\n const urlCouponMutation = useUpdateCheckoutMutation(client);\n const {\n isIdle: couponIsIdle, mutate: couponMutate, reset: urlCouponReset,\n } = urlCouponMutation;\n const createdCheckout = selectMutation.data?.ok ? selectMutation.data.checkout : null;\n\n useEffect(() => {\n if (!createdCheckout || !discountCode) return;\n if (createdCheckout.couponCode === discountCode) return;\n if (couponIsIdle) {\n couponMutate({ biId: createdCheckout.biId, couponCode: discountCode });\n }\n }, [createdCheckout, discountCode, couponIsIdle, couponMutate]);\n\n const [checkoutOverride, setCheckoutOverride] = useState<AlacarteCheckout | null>(null);\n const [couponError, setCouponError] = useState<string | null>(null);\n const [removedCouponCode, setRemovedCouponCode] = useState<string | null>(null);\n const [placeOrderError, setPlaceOrderError] = useState<string | null>(null);\n const [paymentInterrupted, setPaymentInterrupted] = useState(false);\n const [walletPaymentCancelled, setWalletPaymentCancelled] = useState(false);\n const [placingOrder, setPlacingOrder] = useState(false);\n const [paymentTimedOut, setPaymentTimedOut] = useState(false);\n const [sanctionsBlocked, setSanctionsBlocked] = useState<{ referenceCode: string } | null>(null);\n const [purchaseBlocked, setPurchaseBlocked] = useState(false);\n const [placeOrderPaused, setPlaceOrderPaused] = useState(false);\n // biId of a checkout that's locked (CART_PAYMENT_PENDING) from a prior\n // tCheckoutPlaceOrder call whose Stripe confirmation was rejected\n // client-side. The next attempt must skip tCheckoutUpdate (it would fail\n // with CHECKOUT_NOT_OPEN) and go straight to tCheckoutPlaceOrder again.\n const [cardRetryBiId, setCardRetryBiId] = useState<string | null>(null);\n // Last checkout that carried an automatic offer — restored after a custom\n // coupon is removed if the backend does not re-apply it.\n const automaticBaselineRef = useRef<AlacarteCheckout | null>(null);\n // Tracks the payment method/processor used for the last place-order attempt,\n // so the Order Completed event can include them.\n const lastPaymentInfoRef = useRef<{ method: string, processor: string }>({ method: 'card', processor: 'stripe' });\n // Ref for product detail so trackEvent inside useCallback always reads the\n // latest value instead of a stale closure capture.\n const productDetailRef = useRef<ProductDetail | null>(null);\n productDetailRef.current = productDetailQuery.data ?? null;\n\n // Reset local overrides and in-flight select/coupon when the product changes\n // so viewedPrice / couponRecheck run again for the new selection.\n useEffect(() => {\n setCheckoutOverride(null);\n setCouponError(null);\n setRemovedCouponCode(null);\n setPlaceOrderError(null);\n setPaymentInterrupted(false);\n setWalletPaymentCancelled(false);\n setPaymentTimedOut(false);\n setSanctionsBlocked(null);\n setPurchaseBlocked(false);\n setPlaceOrderPaused(false);\n setCardRetryBiId(null);\n automaticBaselineRef.current = null;\n selectReset();\n urlCouponReset();\n }, [selector, selectReset, urlCouponReset]);\n\n // Surface couponRecheck from product switch (section 2 of the API doc).\n useEffect(() => {\n const result = selectMutation.data;\n if (!result?.ok) return;\n const message = getCouponRecheckMessage(\n result.couponRecheck,\n result.checkout?.line?.discountSource,\n );\n if (message) setCouponError(message);\n }, [selectMutation.data]);\n\n // Surface ?discount_code= apply failures (domain ok:false or transport error).\n useEffect(() => {\n if (!discountCode) return;\n if (urlCouponMutation.isIdle || urlCouponMutation.isPending) return;\n if (urlCouponMutation.isError) {\n setCouponError(errorMessage(urlCouponMutation.error));\n return;\n }\n const result = urlCouponMutation.data;\n if (result && !result.ok) {\n setCouponError(getCouponErrorMessage(result.error, discountCode));\n }\n }, [\n discountCode,\n urlCouponMutation.isIdle,\n urlCouponMutation.isPending,\n urlCouponMutation.isError,\n urlCouponMutation.error,\n urlCouponMutation.data,\n ]);\n\n // Segment: Coupon Applied for ?discount_code= auto-apply.\n const urlCouponTrackedRef = useRef(false);\n useEffect(() => {\n if (urlCouponTrackedRef.current) return;\n const result = urlCouponMutation.data;\n if (!result?.ok || !result.checkout?.line) return;\n urlCouponTrackedRef.current = true;\n const line = result.checkout.line;\n trackEvent('Coupon Applied', {\n checkoutType: 'a_la_carte',\n track_plan_id: 30,\n trigger_source: 'client-side',\n cart_id: result.checkout.biId,\n checkout_id: result.checkout.biId,\n coupon_name: result.checkout.couponCode ?? discountCode ?? '',\n discount: line.discount?.amount ?? 0,\n currency: line.discount?.currency ?? line.amountDue?.currency ?? 'USD',\n products: buildProductsFromLine(line, productDetailQuery.data ?? null),\n });\n }, [urlCouponMutation.data, discountCode, productDetailQuery.data]);\n\n const manualUpdateMutation = useUpdateCheckoutMutation(client);\n\n const placedOrderQuery = usePlacedOrderQuery(\n client,\n orderBiId,\n sessionReady && !!orderBiId,\n );\n\n const derived = deriveAlacartePhase({\n selector,\n sessionReady,\n sessionIsError: sessionQuery.isError,\n sessionErrorMessage: sessionQuery.error?.message,\n ownedQuery: {\n isLoading: ownedQuery.isLoading,\n isError: ownedQuery.isError,\n error: ownedQuery.error,\n data: ownedQuery.data,\n },\n selectMutation: {\n isIdle: selectMutation.isIdle,\n isPending: selectMutation.isPending,\n isError: selectMutation.isError,\n error: selectMutation.error,\n data: selectMutation.data,\n },\n checkoutQuery: {\n isLoading: checkoutQuery.isLoading,\n isError: checkoutQuery.isError,\n error: checkoutQuery.error,\n data: checkoutQuery.data,\n },\n productDetail: productDetailQuery.data ?? null,\n courseRunLookup: {\n pending: courseLookupEnabled && courseKeyQuery.isLoading,\n notFound: courseNotFound,\n },\n couponMutation: {\n isIdle: urlCouponMutation.isIdle,\n isPending: urlCouponMutation.isPending,\n isError: urlCouponMutation.isError,\n error: urlCouponMutation.error,\n data: urlCouponMutation.data,\n },\n checkoutOverride,\n // The URL coupon is pending only when the checkout exists, doesn't already\n // carry the code, and the mutation hasn't completed yet. When the backend\n // returns the coupon pre-applied (couponCode === discountCode) or when\n // there's no discount_code param at all, this is false from the start.\n urlCouponPending: !!discountCode\n && !!createdCheckout\n && createdCheckout.couponCode !== discountCode\n && (urlCouponMutation.isIdle || urlCouponMutation.isPending),\n });\n\n // Sync the purchase-blocked flag from the derived phase (tCheckoutSelect returned\n // PURCHASE_BLOCKED) so the modal shows without waiting for a place-order attempt.\n useEffect(() => {\n if (derived.isPurchaseBlocked) setPurchaseBlocked(true);\n }, [derived.isPurchaseBlocked]);\n\n const applyCoupon = useCallback((code: string) => {\n const biId = derived.checkout?.biId;\n if (!biId || !client) return;\n const trimmed = code.trim();\n if (!trimmed) return;\n\n setCouponError(null);\n manualUpdateMutation.mutate(\n { biId, couponCode: trimmed },\n {\n onSuccess: (result) => {\n if (result.ok && result.checkout) {\n setCheckoutOverride(result.checkout);\n setCouponError(null);\n setRemovedCouponCode(null);\n // Segment: Coupon Applied (track_plan_id 30)\n const line = result.checkout.line;\n if (line) {\n trackEvent('Coupon Applied', {\n checkoutType: 'a_la_carte',\n track_plan_id: 30,\n trigger_source: 'client-side',\n cart_id: result.checkout.biId,\n checkout_id: result.checkout.biId,\n coupon_name: result.checkout.couponCode ?? trimmed,\n discount: line.discount?.amount ?? 0,\n currency: line.discount?.currency ?? line.amountDue?.currency ?? 'USD',\n products: buildProductsFromLine(line, productDetailRef.current),\n });\n }\n } else {\n setCouponError(getCouponErrorMessage(result.error, trimmed));\n }\n },\n onError: (err) => {\n setCouponError(errorMessage(err));\n },\n },\n );\n }, [derived.checkout?.biId, client, manualUpdateMutation]);\n\n // Remember the latest automatic offer so removeCoupon can restore it.\n useEffect(() => {\n const checkout = derived.checkout;\n if (\n checkout?.line?.discountSource === 'automatic'\n && checkout.line.discount\n ) {\n automaticBaselineRef.current = checkout;\n }\n }, [derived.checkout]);\n\n const removeCoupon = useCallback(() => {\n const currentCheckout = derived.checkout;\n if (!currentCheckout?.biId || !client) return;\n const removedCode = currentCheckout.couponCode?.trim() || null;\n // Prefer the remembered automatic offer; fall back to the pre-coupon\n // select response when the baseline was never captured.\n const priorCheckout = automaticBaselineRef.current\n ?? (selectMutation.data?.ok ? selectMutation.data.checkout : null);\n\n setCouponError(null);\n manualUpdateMutation.mutate(\n { biId: currentCheckout.biId, couponCode: '' },\n {\n onSuccess: (result) => {\n if (!result.ok) {\n setCouponError(getCouponErrorMessage(result.error));\n return;\n }\n setCheckoutOverride(\n checkoutWithoutCoupon(result.checkout ?? currentCheckout, priorCheckout),\n );\n setCouponError(null);\n if (removedCode) setRemovedCouponCode(removedCode);\n },\n onError: (err) => {\n setCouponError(errorMessage(err));\n },\n },\n );\n }, [derived.checkout, client, manualUpdateMutation, selectMutation.data]);\n\n const placeOrderCore = useCallback(async (opts: {\n billing: BillingInfo,\n confirmCardPayment: (clientSecret: string) => Promise<void>,\n }) => {\n const checkout = derived.checkout;\n if (!checkout || !client) throw new Error('Checkout not ready');\n // A timed-out attempt may still complete — never start a second one.\n if (paymentTimedOut) throw new RequestTimeoutError();\n\n setPlacingOrder(true);\n setPlaceOrderError(null);\n setPaymentInterrupted(false);\n setWalletPaymentCancelled(false);\n lastPaymentInfoRef.current = { method: 'card', processor: 'stripe' };\n\n // Segment: Payment Info Entered (track_plan_id 31)\n if (checkout.line) {\n trackEvent('Payment Info Entered', {\n checkoutType: 'a_la_carte',\n track_plan_id: 31,\n trigger_source: 'client-side',\n cart_id: checkout.biId,\n checkout_id: checkout.biId,\n currency: checkout.line.amountDue?.currency ?? 'USD',\n revenue: checkout.line.amountDue?.amount ?? 0,\n payment_method: 'card',\n discount: checkout.line.discount?.amount ?? 0,\n products: buildProductsFromLine(checkout.line, productDetailRef.current),\n });\n }\n\n try {\n const { checkout: updated } = await placeAlacarteOrder({\n updateCheckout: (args) => client.updateCheckout(args),\n placeCheckoutOrder: (biId, billing) => client.placeCheckoutOrder(biId, billing),\n checkout,\n billing: toAlacarteBillingAddress(opts.billing),\n confirmCardPayment: opts.confirmCardPayment,\n skipPrepare: cardRetryBiId === checkout.biId,\n });\n\n setCardRetryBiId(null);\n setCheckoutOverride(updated);\n await setOrderBiId(updated.biId);\n } catch (err: unknown) {\n if (err instanceof CardValidationError) {\n // tCheckoutPlaceOrder already succeeded and locked the checkout\n // (CART_PAYMENT_PENDING); Stripe rejected the card before it ever\n // reached the backend. Next attempt must retry tCheckoutPlaceOrder\n // directly, not tCheckoutUpdate.\n setCardRetryBiId(checkout.biId);\n } else {\n setCardRetryBiId(null);\n }\n if (err instanceof AlacartePlaceOrderError && err.checkout) {\n setCheckoutOverride(err.checkout);\n }\n // The timeout warning and sanctions modal replace the generic error banner.\n const errMsg = err instanceof Error ? err.message : '';\n if (isRequestTimeoutError(err)) {\n setPaymentTimedOut(true);\n } else if (isSanctionsBlockedError(err)) {\n // TODO: use the backend reference code once tCheckoutPlaceOrder returns one.\n setSanctionsBlocked({ referenceCode: 'REF-8F2K-40QX-1177' });\n } else if (isPurchaseBlockedError(err)) {\n setPurchaseBlocked(true);\n } else if (isCheckoutPausedError(err)) {\n setPlaceOrderPaused(true);\n } else if (isCouponError(errMsg)) {\n // Coupon errors show inline below the promo code input, not as a top banner.\n setCouponError(getCouponErrorMessage(errMsg));\n } else {\n setPlaceOrderError(errorMessage(err));\n }\n throw err;\n } finally {\n setPlacingOrder(false);\n }\n }, [derived.checkout, client, setOrderBiId, cardRetryBiId, paymentTimedOut]);\n\n /** Fire-and-forget wrapper for card payments. */\n const placeOrder = useCallback((opts: {\n billing: BillingInfo,\n confirmCardPayment: (clientSecret: string) => Promise<void>,\n }) => {\n if (placingOrder || paymentTimedOut) return;\n placeOrderCore(opts).catch(() => { /* error already in state */ });\n }, [placeOrderCore, placingOrder, paymentTimedOut]);\n\n // biId of the checkout the open PayPal order belongs to — capture/cancel need it.\n const paypalBiIdRef = useRef<string | null>(null);\n\n const reloadCheckout = useCallback(async () => {\n if (!client) return;\n try {\n const fresh = await client.getCheckout();\n if (fresh.ok && fresh.checkout) {\n setCheckoutOverride(fresh.checkout);\n queryClient.setQueryData(alacarteKeys.checkout(), fresh);\n }\n } catch {\n // The learner can still retry from the current checkout.\n }\n }, [client, queryClient]);\n\n const startPaypalOrder = useCallback(async (opts: { billing: BillingInfo }) => {\n const checkout = derived.checkout;\n if (!checkout || !client) throw new Error('Checkout not ready');\n if (paymentTimedOut) throw new RequestTimeoutError();\n\n setPlacingOrder(true);\n setPlaceOrderError(null);\n setPaymentInterrupted(false);\n setWalletPaymentCancelled(false);\n lastPaymentInfoRef.current = { method: 'paypal', processor: 'paypal' };\n\n // Segment: Payment Info Entered (track_plan_id 31)\n if (checkout.line) {\n await trackEvent('Payment Info Entered', {\n checkoutType: 'a_la_carte',\n track_plan_id: 31,\n trigger_source: 'client-side',\n cart_id: checkout.biId,\n checkout_id: checkout.biId,\n currency: checkout.line.amountDue?.currency ?? 'USD',\n revenue: checkout.line.amountDue?.amount ?? 0,\n payment_method: 'paypal',\n discount: checkout.line.discount?.amount ?? 0,\n products: buildProductsFromLine(checkout.line, productDetailRef.current),\n });\n }\n\n try {\n const { checkout: updated, paypalOrderId } = await startAlacartePaypalOrder({\n updateCheckout: (args) => client.updateCheckout(args),\n placeCheckoutOrder: (biId, billing, paymentMethod) => (\n client.placeCheckoutOrder(biId, billing, paymentMethod)\n ),\n checkout,\n billing: toAlacarteBillingAddress(opts.billing),\n skipPrepare: cardRetryBiId === checkout.biId,\n });\n // tCheckoutPlaceOrder locked the checkout (CART_PAYMENT_PENDING) until\n // the PayPal order is captured or cancelled; a retry must skip tCheckoutUpdate.\n setCardRetryBiId(updated.biId);\n setCheckoutOverride(updated);\n paypalBiIdRef.current = updated.biId;\n return paypalOrderId;\n } catch (err: unknown) {\n if (err instanceof AlacartePlaceOrderError && err.checkout) {\n setCheckoutOverride(err.checkout);\n }\n const paypalErrMsg = err instanceof Error ? err.message : '';\n if (isRequestTimeoutError(err)) {\n setPaymentTimedOut(true);\n } else if (isSanctionsBlockedError(err)) {\n setSanctionsBlocked({ referenceCode: 'REF-8F2K-40QX-1177' });\n } else if (isCheckoutPausedError(err)) {\n setPlaceOrderPaused(true);\n } else if (isCouponError(paypalErrMsg)) {\n setCouponError(getCouponErrorMessage(paypalErrMsg));\n } else {\n setPlaceOrderError(errorMessage(err));\n }\n setPlacingOrder(false);\n throw err;\n }\n }, [derived.checkout, client, cardRetryBiId, paymentTimedOut]);\n\n const cancelPaypalOrder = useCallback(async (paypalOrderId: string) => {\n const biId = paypalBiIdRef.current;\n if (!biId || !client) {\n setPlacingOrder(false);\n return;\n }\n try {\n const result = await client.cancelPaypalOrder(biId, paypalOrderId);\n if (result.ok) {\n // Settled as a failed payment — the checkout is open again.\n paypalBiIdRef.current = null;\n setCardRetryBiId(null);\n setPaymentInterrupted(true);\n }\n await reloadCheckout();\n } catch {\n // Leave cardRetryBiId set so the next attempt reuses the locked checkout.\n } finally {\n setPlacingOrder(false);\n }\n }, [client, reloadCheckout]);\n\n const approvePaypalOrder = useCallback(async (paypalOrderId: string) => {\n const biId = paypalBiIdRef.current;\n if (!biId || !client) throw new Error('Checkout not ready');\n\n setPlacingOrder(true);\n setPlaceOrderError(null);\n setPaymentInterrupted(false);\n setWalletPaymentCancelled(false);\n\n try {\n const result = await client.capturePaypalOrder(biId, paypalOrderId);\n // PAYMENT_IN_PROGRESS: another capture holds the lock and will settle the\n // order — poll getTwouOrder like a COMPLETED / PENDING capture.\n const placed = result.ok\n ? result.status === 'COMPLETED' || result.status === 'PENDING'\n : result.error === 'PAYMENT_IN_PROGRESS';\n if (!placed) {\n throw toPlaceOrderError(result.ok ? 'PAYPAL_PAYMENT_DECLINED' : (result.error ?? 'CAPTURE_FAILED'));\n }\n paypalBiIdRef.current = null;\n setCardRetryBiId(null);\n await setOrderBiId(biId);\n } catch (err: unknown) {\n setPlaceOrderError(errorMessage(err));\n // A declined/failed capture leaves the order settled as failed — reload so\n // the learner can retry (paymentDecline comes back on tCheckout).\n setCardRetryBiId(null);\n await reloadCheckout();\n throw err;\n } finally {\n setPlacingOrder(false);\n }\n }, [client, setOrderBiId, reloadCheckout]);\n\n const clearPaymentAlerts = useCallback(() => {\n setPlaceOrderError(null);\n setPaymentInterrupted(false);\n setWalletPaymentCancelled(false);\n }, []);\n\n const placedView = derivePlacedOrderView({\n orderBiId,\n result: placedOrderQuery.data,\n pollTimedOut: placedOrderQuery.pollTimedOut,\n isLoading: placedOrderQuery.isLoading,\n isFetching: placedOrderQuery.isFetching,\n });\n const { placedOrder } = placedView;\n const placedOrderPlacedAt = placedOrder?.placedAt ?? null;\n\n // Segment: Order Completed (track_plan_id 32), deduplicated by order number.\n useEffect(() => {\n if (!placedOrder || !orderBiId) return;\n const { method, processor } = lastPaymentInfoRef.current;\n trackEventOnce('Order Completed', {\n checkoutType: 'a_la_carte',\n track_plan_id: 32,\n trigger_source: 'client-side',\n order_id: placedOrder.orderNumber,\n checkout_id: orderBiId,\n total: placedOrder.totals.paid,\n revenue: placedOrder.totals.paid,\n currency: placedOrder.totals.currency,\n tax: placedOrder.totals.discount === 0 && placedOrder.totals.paid === 0 ? 0 : placedOrder.totals.deduction,\n coupon: placedOrder.couponCode ?? null,\n coupon_name: [],\n discount: placedOrder.totals.discount,\n processor_name: processor,\n payment_method: method,\n products: derived.line\n ? buildProductsFromLine(derived.line, productDetailRef.current)\n : buildProductsFromOrder(placedOrder.lines, productDetailRef.current),\n });\n }, [placedOrder, orderBiId, productDetailQuery.data, derived.line]);\n\n // NOT_PLACED / poll timeout: the payment either failed or we couldn't confirm\n // it in time. Reload tCheckout and drop ?order_bi_id= so the learner can\n // retry instead of sitting on the confirmation error.\n // The ref blocks a second reload for the same attempt. It is not cleared in\n // cleanup — a re-run must not cancel the reload that is already in flight.\n const returnedToCheckoutFor = useRef<string | null>(null);\n useEffect(() => {\n if (!orderBiId) {\n returnedToCheckoutFor.current = null;\n return undefined;\n }\n if (!placedView.returnToCheckout) return undefined;\n if (returnedToCheckoutFor.current === orderBiId) return undefined;\n returnedToCheckoutFor.current = orderBiId;\n\n if (placedView.returnedByPollTimeout) {\n // ALC-452 #6: the poll window expired without a payment outcome.\n // Show a retry-friendly error instead of the \"payment interrupted\"\n // message, which implies \"you haven't been charged\".\n setPlaceOrderError(POLL_TIMEOUT_MESSAGE);\n } else {\n // NOT_PLACED: the backend confirmed the payment did not go through.\n setPaymentInterrupted(true);\n }\n\n (async () => {\n if (client) {\n try {\n const fresh = await client.getCheckout();\n if (fresh.ok && fresh.checkout) {\n setCheckoutOverride(fresh.checkout);\n queryClient.setQueryData(alacarteKeys.checkout(), fresh);\n }\n } catch {\n // Still leave the poll — the cart is editable even if this read fails.\n }\n }\n await setOrderBiId(null);\n })();\n\n return undefined;\n }, [orderBiId, placedView.returnToCheckout, placedView.returnedByPollTimeout, client, setOrderBiId, queryClient]);\n\n return {\n ...derived,\n couponError,\n couponApplying: manualUpdateMutation.isPending,\n applyCoupon,\n removeCoupon,\n clearCouponError: () => setCouponError(null),\n removedCouponCode,\n clearRemovedCouponCode: () => setRemovedCouponCode(null),\n placingOrder,\n placeOrderError,\n paymentInterrupted,\n walletPaymentCancelled,\n placeOrder,\n placeOrderAsync: placeOrderCore,\n startPaypalOrder,\n approvePaypalOrder,\n cancelPaypalOrder,\n clearPlaceOrderError: () => setPlaceOrderError(null),\n clearPaymentInterrupted: () => setPaymentInterrupted(false),\n markWalletPaymentCancelled: () => setWalletPaymentCancelled(true),\n clearWalletPaymentCancelled: () => setWalletPaymentCancelled(false),\n clearPaymentAlerts,\n paymentTimedOut,\n sanctionsBlocked,\n purchaseBlocked,\n checkoutPaused: placeOrderPaused || derived.phase === 'checkoutPaused',\n paymentDecline: derived.checkout?.paymentDecline ?? null,\n placedOrder,\n awaitingPlacedOrder: placedView.awaitingPlacedOrder,\n placedOrderError: placedView.placedOrderError,\n placedOrderPlacedAt,\n };\n}\n\nexport default useAlacarteCheckout;\n"]}
@@ -107,7 +107,7 @@ export interface AlacarteCheckout {
107
107
  paymentDecline?: AlacartePaymentDecline | null;
108
108
  line: AlacarteLine | null;
109
109
  }
110
- export type AlacarteErrorCode = 'NOT_AUTHENTICATED' | 'RUN_KEY_REQUIRED' | 'CONFLICTING_SELECTION' | 'NOTHING_SELECTED' | 'COURSE_NOT_FOUND' | 'PROGRAM_NOT_FOUND' | 'CHECKOUT_NOT_FOUND' | 'CHECKOUT_NOT_YOURS' | 'PRODUCT_NOT_FOUND' | 'ALREADY_OWNED' | 'NOT_PURCHASABLE' | 'PRICING_UNAVAILABLE' | 'COUPON_INVALID' | 'COUPON_NOT_ACTIVE' | 'COUPON_EXPIRED' | 'COUPON_CAP_REACHED' | 'COUPON_PRODUCT_NOT_ELIGIBLE' | 'COUPON_PARTY_NOT_ELIGIBLE' | 'COUPON_PER_CUSTOMER_LIMIT' | 'COUPON_REJECTED' | 'ORDER_ID_REQUIRED' | 'ORDER_NOT_FOUND' | 'NOT_PLACED' | 'ORDER_READ_FAILED' | 'PAYMENT_PENDING';
110
+ export type AlacarteErrorCode = 'NOT_AUTHENTICATED' | 'RUN_KEY_REQUIRED' | 'CONFLICTING_SELECTION' | 'NOTHING_SELECTED' | 'COURSE_NOT_FOUND' | 'PROGRAM_NOT_FOUND' | 'CHECKOUT_NOT_FOUND' | 'CHECKOUT_NOT_YOURS' | 'PRODUCT_NOT_FOUND' | 'ALREADY_OWNED' | 'NOT_PURCHASABLE' | 'PRICING_UNAVAILABLE' | 'CHECKOUT_PAUSED' | 'COUPON_INVALID' | 'COUPON_NOT_ACTIVE' | 'COUPON_EXPIRED' | 'COUPON_CAP_REACHED' | 'COUPON_PRODUCT_NOT_ELIGIBLE' | 'COUPON_PARTY_NOT_ELIGIBLE' | 'COUPON_PER_CUSTOMER_LIMIT' | 'COUPON_REJECTED' | 'ORDER_ID_REQUIRED' | 'ORDER_NOT_FOUND' | 'NOT_PLACED' | 'ORDER_READ_FAILED' | 'PAYMENT_PENDING';
111
111
  export interface AlacarteReplaced {
112
112
  courseName?: string;
113
113
  courseUid?: string;
@@ -340,7 +340,7 @@ export interface AlacartePlaceOrderPayment {
340
340
  amount: number;
341
341
  currency: string;
342
342
  }
343
- export type AlacartePlaceOrderErrorCode = 'TERMS_NOT_ACCEPTED' | 'PRICE_NOT_ACCEPTED' | 'BILLING_ADDRESS_REQUIRED' | 'SANCTIONS_BLOCKED' | 'COUPON_UNAVAILABLE' | 'PAYMENT_NOT_STARTED' | 'CHECKOUT_NOT_FOUND' | 'NOT_AUTHENTICATED';
343
+ export type AlacartePlaceOrderErrorCode = 'TERMS_NOT_ACCEPTED' | 'PRICE_NOT_ACCEPTED' | 'BILLING_ADDRESS_REQUIRED' | 'SANCTIONS_BLOCKED' | 'COUPON_UNAVAILABLE' | 'PAYMENT_NOT_STARTED' | 'CHECKOUT_NOT_FOUND' | 'NOT_AUTHENTICATED' | 'CHECKOUT_PAUSED';
344
344
  /** PayPal order returned by tCheckoutPlaceOrder(paymentMethod: "PAYPAL"). */
345
345
  export interface AlacartePaypalPayment {
346
346
  paypalOrderId: string;
@@ -1 +1 @@
1
- {"version":3,"file":"alacarte.js","sourceRoot":"","sources":["../../src/types/alacarte.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * types/alacarte.ts — domain types for the à la carte checkout flow\n * (tCheckout / tCheckoutSelect / tCheckoutUpdate / tOwnedProducts), a separate\n * bounded context from the subscription checkout modeled in ../types.ts.\n * See alacarte-checkout-api.md and alacarte-owned-products-api.md at the repo\n * root for the full contract.\n */\nimport type { GqlRunner, CourseDetail } from '../types';\n\nexport type { GqlRunner };\n\n// --- Checkout status -----------------------------------------------------------\nexport type AlacarteStatus =\n | 'CART_CREATED'\n | 'CART_SANCTION_PASSED'\n | 'CART_PAYMENT_FAILED';\n\n// --- Money -----------------------------------------------------------------------\nexport interface AlacarteMoney {\n amount: number,\n currency: string,\n}\n\n// --- Checkout line (discriminated union on `kind`) --------------------------------\n/** Where the line discount came from — coupon code vs automatic offer (bundle / first-order). */\nexport type AlacarteDiscountSource = 'coupon' | 'automatic';\n\nexport interface AlacarteCourseLine {\n biiId: string,\n kind: 'course',\n courseName: string,\n courseUid: string,\n courseRunKey: string,\n /** The seat being bought on that run, e.g. \"verified\". */\n seatType: string | null,\n price: AlacarteMoney | null,\n /** Taken off by an applied coupon or automatic offer; absent when neither applies. */\n discount: AlacarteMoney | null,\n /** `\"coupon\"` or `\"automatic\"`; absent with no discount. */\n discountSource?: AlacarteDiscountSource | null,\n /** Discount name for the order summary, e.g. \"First order discount\". */\n discountName?: string | null,\n /** price less discount. */\n amountDue: AlacarteMoney | null,\n billingAddressSet: boolean,\n}\n\n/** Owned member course on a program checkout line (simpler than OwnedCourseRef). */\nexport interface AlacarteProgramOwnedCourse {\n courseId: string,\n name: string,\n via: 'order' | 'program' | 'enrollment',\n}\n\nexport interface AlacarteProgramLine {\n biiId: string,\n kind: 'program',\n programId: string,\n programName: string,\n price: AlacarteMoney | null,\n /** Taken off for member courses the learner already owns; absent when they own none. */\n deduction: AlacarteMoney | null,\n /**\n * Member courses the learner already owns — explains the deduction\n * (\"Already yours: …\"). Empty/absent when they own none.\n */\n ownedCourses?: AlacarteProgramOwnedCourse[] | null,\n /** Taken off by an applied coupon or automatic offer; absent when neither applies. */\n discount: AlacarteMoney | null,\n /** `\"coupon\"` or `\"automatic\"`; absent with no discount. */\n discountSource?: AlacarteDiscountSource | null,\n /** Discount name for the order summary, e.g. \"Bundle discount\". */\n discountName?: string | null,\n /** price less deduction less discount. */\n amountDue: AlacarteMoney | null,\n billingAddressSet: boolean,\n}\n\nexport type AlacarteLine = AlacarteCourseLine | AlacarteProgramLine;\n\n/** Present when the learner switches product while a coupon is on the cart. */\nexport type AlacarteCouponRecheckOutcome = 'kept' | 'rejected' | 'unverified';\n\nexport interface AlacarteCouponRecheck {\n outcome: AlacarteCouponRecheckOutcome,\n /** Coupon error code when outcome is `rejected`. */\n reason?: AlacarteErrorCode | string | null,\n}\n\n/** Last card-decline details; cleared when the next payment attempt starts. */\nexport interface AlacartePaymentDecline {\n code?: string | null,\n /** Ready to show the learner. */\n message: string,\n}\n\n/** Why a selection was refused — see section 5 of alacarte-checkout-api.md. */\nexport interface AlacarteBlocked {\n reason: 'ALREADY_OWNED' | 'NOT_PURCHASABLE' | 'OWNERSHIP_UNAVAILABLE',\n productId: string,\n kind: 'course' | 'program',\n /** ALREADY_OWNED only — where to send the learner (the learner dashboard). */\n route?: string,\n /** ALREADY_OWNED only. */\n ownedCourses?: OwnedCourseRef[],\n /** NOT_PURCHASABLE / OWNERSHIP_UNAVAILABLE — the catalog's reason. */\n detail?: string,\n}\n\n/** Present when the price the learner saw (viewedPrice) differs from what checkout resolves now. */\nexport interface AlacartePriceChanged {\n viewed: AlacarteMoney,\n current: AlacarteMoney,\n}\n\n// --- Checkout envelope -------------------------------------------------------------\nexport interface AlacarteCheckout {\n biId: string,\n uid: string,\n status: AlacarteStatus,\n // Not always present in real responses (absent, not null, when no coupon was entered).\n couponCode?: string | null,\n termsAcceptedAt: string | null,\n acceptedAmount?: AlacarteMoney | null,\n priceAccepted?: boolean,\n /** True when this is the learner's first à-la-carte order (first-order offer applies). */\n firstOrder?: boolean,\n /** Present after the card was declined on the last attempt. */\n paymentDecline?: AlacartePaymentDecline | null,\n line: AlacarteLine | null,\n}\n\nexport type AlacarteErrorCode =\n | 'NOT_AUTHENTICATED'\n | 'RUN_KEY_REQUIRED'\n | 'CONFLICTING_SELECTION'\n | 'NOTHING_SELECTED'\n | 'COURSE_NOT_FOUND'\n | 'PROGRAM_NOT_FOUND'\n | 'CHECKOUT_NOT_FOUND'\n | 'CHECKOUT_NOT_YOURS'\n | 'PRODUCT_NOT_FOUND'\n // Blocked selection — details in the `blocked` envelope field.\n | 'ALREADY_OWNED'\n | 'NOT_PURCHASABLE'\n // No price can be resolved for the product right now.\n | 'PRICING_UNAVAILABLE'\n // Coupon errors — returned from tCheckoutUpdate, checkout left unchanged.\n | 'COUPON_INVALID'\n | 'COUPON_NOT_ACTIVE'\n | 'COUPON_EXPIRED'\n | 'COUPON_CAP_REACHED'\n | 'COUPON_PRODUCT_NOT_ELIGIBLE'\n | 'COUPON_PARTY_NOT_ELIGIBLE'\n | 'COUPON_PER_CUSTOMER_LIMIT'\n | 'COUPON_REJECTED'\n // getTwouOrder (placed order) errors.\n | 'ORDER_ID_REQUIRED'\n | 'ORDER_NOT_FOUND'\n | 'NOT_PLACED'\n | 'ORDER_READ_FAILED'\n // Payment is still being confirmed, including a 3D Secure check. Poll; not a failure yet.\n | 'PAYMENT_PENDING';\n\nexport interface AlacarteReplaced {\n courseName?: string,\n courseUid?: string,\n courseRunKey?: string,\n programId?: string,\n programName?: string,\n}\n\n/** Shared response envelope for tCheckout / tCheckoutSelect / tCheckoutUpdate. */\nexport interface AlacarteCheckoutResult {\n ok: boolean,\n checkout: AlacarteCheckout | null,\n replaced?: AlacarteReplaced,\n priceChanged?: AlacartePriceChanged,\n blocked?: AlacarteBlocked,\n /** Present when select switches product while a coupon was applied. */\n couponRecheck?: AlacarteCouponRecheck,\n error?: AlacarteErrorCode | string,\n}\n\n// --- Owned products ------------------------------------------------------------------\nexport type OwnedProductStatus = 'full' | 'partial' | 'none';\n\nexport interface OwnedCourseRef {\n courseId: string,\n via: 'order' | 'program' | 'enrollment',\n orderBiId?: string,\n enrollmentBiId?: string,\n programId?: string,\n name: string,\n slug: string,\n}\n\nexport interface OwnedProductPrice {\n full: number,\n deduction: number,\n amountDue: number,\n currency: string,\n}\n\nexport interface OwnedProduct {\n productId: string,\n kind: 'course' | 'program',\n name: string,\n slug: string,\n status: OwnedProductStatus,\n memberCount?: number,\n ownedCourses: OwnedCourseRef[],\n /** Pricing breakdown — available when the backend returns it (e.g. for\n * already-owned products where the checkout line is not created). */\n price?: OwnedProductPrice | null,\n}\n\nexport interface OwnedProductResult {\n ok: boolean,\n product: OwnedProduct | null,\n error?: AlacarteErrorCode | string,\n}\n\nexport interface OwnedProgramRef {\n programId: string,\n orderBiId: string,\n}\n\nexport interface OwnedProductsSummary {\n courses: OwnedCourseRef[],\n programs: OwnedProgramRef[],\n}\n\nexport interface AllOwnedProductsResult {\n ok: boolean,\n owned: OwnedProductsSummary | null,\n error?: AlacarteErrorCode | string,\n}\n\n// --- Program details (filterTwouProgram, by tProgramUuid) -----------------------------\nexport interface ProgramCourseRef {\n id: string,\n maId: string | null,\n uid: string | null,\n maName: string | null,\n maDescription: string | null,\n tShortDescription: string | null,\n imageUrl: string | null,\n tBrandText: string | null,\n tOrgLogoUrl: string | null,\n tUrlCourse: string | null,\n tMarketingSlug: string | null,\n tStatus: { code: string } | null,\n}\n\nexport interface ProgramDetail {\n uid: string,\n tEffortLow: number | null,\n tEnrollmentCount: number | null,\n tMarketingSlug: string | null,\n tSkills: string[] | null,\n tFaq: string | null,\n tLevelType: string | null,\n tCourses: ProgramCourseRef[],\n}\n\n/** Course or program detail, depending on which was selected. */\nexport type ProductDetail = CourseDetail | ProgramDetail;\n\n// --- Banner details (PDP banner before checkout) ---------------------------------\n\nexport interface BannerCourseInstructor {\n tGivenName: string | null,\n tFamilyName: string | null,\n tOrganization: string | null,\n tInstructorUuid: string | null,\n tSortValue: number | null,\n}\n\nexport interface BannerCourseDetail {\n uid: string,\n id: string | null,\n maName: string,\n tEnrollmentCount: number | null,\n tAlacartePurchasable: boolean | null,\n tCourseKey: string | null,\n tShortDescription: string | null,\n maDescription: string | null,\n tBrandText: string | null,\n tOrgLogoUrl: string | null,\n imageUrl: string | null,\n tUrlCourse: string | null,\n tMarketingSlug: string | null,\n tLevelType: string | null,\n tPacingType: string | null,\n tDurationLow: number | null,\n tDurationHigh: number | null,\n tDurationUnit: string | null,\n tEffortLow: number | null,\n tEffortHigh: number | null,\n tEffortUnit: string | null,\n tLanguage: string | null,\n tExpectedLearningItems: string | null,\n tSkills: string[] | null,\n tPrerequisites: string | null,\n tSyllabus: string | null,\n tFaq: string | null,\n tTestimonials: string | null,\n tTranscriptLanguages: string[] | null,\n tInstructors: BannerCourseInstructor[],\n}\n\nexport interface BannerProgramCourse {\n id: string,\n uid: string | null,\n maName: string | null,\n tShortDescription: string | null,\n maDescription: string | null,\n tBrandText: string | null,\n tOrgLogoUrl: string | null,\n tCourseKey: string | null,\n imageUrl: string | null,\n tUrlCourse: string | null,\n tMarketingSlug: string | null,\n tStatus: { code: string } | null,\n}\n\nexport interface BannerProgramDetail {\n uid: string,\n tEffortLow: number | null,\n tEnrollmentCount: number | null,\n tMarketingSlug: string | null,\n tAlacartePurchasable: boolean | null,\n tSkills: string[] | null,\n tFaq: string | null,\n tLevelType: string | null,\n imageUrl: string | null,\n tBannerImageUrl: string | null,\n tCourses: BannerProgramCourse[],\n}\n\nexport type BannerData =\n | { kind: 'course', data: BannerCourseDetail }\n | { kind: 'program', data: BannerProgramDetail };\n\n// --- Placed order (getTwouOrder, confirmation page) ------------------------------------\nexport interface PlacedOrderAmounts {\n price: number,\n deduction: number,\n discount: number,\n paid: number,\n currency: string,\n}\n\nexport interface PlacedOrderLine {\n lineId: string,\n kind: 'course' | 'program',\n productId?: string,\n productUid?: string,\n name: string,\n /** Present on course lines and on each course line of a program order. */\n courseRunKey?: string | null,\n seatType?: string | null,\n /** Set on every line of a program order (one line per course bought). */\n programId?: string,\n bundleRef?: string,\n discountRuleId?: string,\n amounts: PlacedOrderAmounts,\n}\n\nexport interface PlacedOrder {\n orderId: string,\n /** `biId` from getTwouOrder — the order number shown on the confirmation page. */\n orderNumber: string,\n status: string,\n couponCode: string | null,\n /** `card` covers Stripe cards and Apple Pay / Google Pay (named in `wallet`); `paypal` has no card. */\n paymentMethod: { type: 'card' | 'paypal', brand?: string, last4?: string, wallet?: string } | null,\n lines: PlacedOrderLine[],\n totals: PlacedOrderAmounts,\n /** ISO timestamp from tPlacedAt, falling back to biCreatedAt. */\n placedAt?: string | null,\n}\n\nexport interface PlacedOrderResult {\n ok: boolean,\n order: PlacedOrder | null,\n error?: AlacarteErrorCode | string,\n}\n\n/** Billing for tCheckoutPlaceOrder. Only `country` (ISO-2) is required;\n * name/line/city/etc. are optional when the UI doesn't collect a full address. */\nexport interface AlacarteBillingAddress {\n country: string,\n firstName?: string,\n lastName?: string,\n line1?: string,\n line2?: string,\n city?: string,\n state?: string,\n postcode?: string,\n}\n\n/** Stripe payment details returned by a successful tCheckoutPlaceOrder. */\nexport interface AlacartePlaceOrderPayment {\n clientSecret: string,\n paymentIntentId: string,\n /** Amount in cents. */\n amount: number,\n currency: string,\n}\n\nexport type AlacartePlaceOrderErrorCode =\n | 'TERMS_NOT_ACCEPTED'\n | 'PRICE_NOT_ACCEPTED'\n | 'BILLING_ADDRESS_REQUIRED'\n | 'SANCTIONS_BLOCKED'\n | 'COUPON_UNAVAILABLE'\n | 'PAYMENT_NOT_STARTED'\n | 'CHECKOUT_NOT_FOUND'\n | 'NOT_AUTHENTICATED';\n\n/** PayPal order returned by tCheckoutPlaceOrder(paymentMethod: \"PAYPAL\"). */\nexport interface AlacartePaypalPayment {\n paypalOrderId: string,\n /** Amount in cents. */\n amount: number,\n currency: string,\n}\n\n/** paymentMethod argument of tCheckoutPlaceOrder — omitted means STRIPE. */\nexport type AlacartePaymentMethod = 'STRIPE' | 'PAYPAL';\n\n/** tCheckoutCapturePaypalOrder / tCheckoutCancelPaypalOrder response. */\nexport interface AlacartePaypalOrderResult {\n ok: boolean,\n status?: 'COMPLETED' | 'PENDING' | 'FAILED' | 'CANCELLED',\n orderNumber?: string,\n error?: string,\n}\n\n/** Immediate placement from tCheckoutPlaceOrder (e.g. $0 — no PaymentIntent). */\nexport interface AlacartePlacedOrderRef {\n orderNumber: string,\n}\n\nexport interface AlacartePlaceOrderApiResult {\n ok: boolean,\n payment: AlacartePlaceOrderPayment | null,\n /** Set instead of `payment` when placed with paymentMethod \"PAYPAL\". */\n paypal?: AlacartePaypalPayment | null,\n /** Set when the order was placed immediately without a Stripe/PayPal charge. */\n placed?: AlacartePlacedOrderRef | null,\n /** True when amount due is 0 and no payment processor was started. */\n noChargeRequired?: boolean,\n /** Present on some failures (e.g. PRICE_NOT_ACCEPTED, COUPON_UNAVAILABLE). */\n checkout?: AlacarteCheckout | null,\n error?: AlacartePlaceOrderErrorCode | string,\n}\n\n// --- Product selector (derived from query params) --------------------------------------\nexport type ProductSelector =\n | { kind: 'course', courseUid: string, runKey: string }\n | { kind: 'program', programUid: string }\n | { kind: 'invalid' }\n | { kind: 'none' };\n\n// --- Client surface --------------------------------------------------------------------\nexport interface AlacarteCheckoutClient {\n gql: GqlRunner,\n setToken: (token: string) => void,\n getCheckout: () => Promise<AlacarteCheckoutResult>,\n /** viewedPrice: the amount the learner saw on the page before checkout (USD, before any coupon). */\n selectCourse: (courseUid: string, runKey: string, viewedPrice?: number) => Promise<AlacarteCheckoutResult>,\n selectProgram: (programUid: string, viewedPrice?: number) => Promise<AlacarteCheckoutResult>,\n updateCheckout: (args: {\n biId?: string, couponCode?: string, termsAccepted?: boolean, acceptPrice?: boolean,\n }) => Promise<AlacarteCheckoutResult>,\n getOwnedProduct: (productId: string) => Promise<OwnedProductResult>,\n getAllOwnedProducts: () => Promise<AllOwnedProductsResult>,\n getProgramDetail: (programUid: string) => Promise<ProgramDetail | null>,\n getCourseDetail: (courseKey: string) => Promise<CourseDetail | null>,\n getPlacedOrder: (biId: string) => Promise<PlacedOrderResult>,\n /** One-call place order — returns Stripe client secret (section 5a). */\n placeCheckoutOrder: (\n biId: string,\n billing?: AlacarteBillingAddress,\n paymentMethod?: AlacartePaymentMethod,\n ) => Promise<AlacartePlaceOrderApiResult>,\n capturePaypalOrder: (biId: string, paypalOrderId: string) => Promise<AlacartePaypalOrderResult>,\n cancelPaypalOrder: (biId: string, paypalOrderId: string) => Promise<AlacartePaypalOrderResult>,\n}\n"]}
1
+ {"version":3,"file":"alacarte.js","sourceRoot":"","sources":["../../src/types/alacarte.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * types/alacarte.ts — domain types for the à la carte checkout flow\n * (tCheckout / tCheckoutSelect / tCheckoutUpdate / tOwnedProducts), a separate\n * bounded context from the subscription checkout modeled in ../types.ts.\n * See alacarte-checkout-api.md and alacarte-owned-products-api.md at the repo\n * root for the full contract.\n */\nimport type { GqlRunner, CourseDetail } from '../types';\n\nexport type { GqlRunner };\n\n// --- Checkout status -----------------------------------------------------------\nexport type AlacarteStatus =\n | 'CART_CREATED'\n | 'CART_SANCTION_PASSED'\n | 'CART_PAYMENT_FAILED';\n\n// --- Money -----------------------------------------------------------------------\nexport interface AlacarteMoney {\n amount: number,\n currency: string,\n}\n\n// --- Checkout line (discriminated union on `kind`) --------------------------------\n/** Where the line discount came from — coupon code vs automatic offer (bundle / first-order). */\nexport type AlacarteDiscountSource = 'coupon' | 'automatic';\n\nexport interface AlacarteCourseLine {\n biiId: string,\n kind: 'course',\n courseName: string,\n courseUid: string,\n courseRunKey: string,\n /** The seat being bought on that run, e.g. \"verified\". */\n seatType: string | null,\n price: AlacarteMoney | null,\n /** Taken off by an applied coupon or automatic offer; absent when neither applies. */\n discount: AlacarteMoney | null,\n /** `\"coupon\"` or `\"automatic\"`; absent with no discount. */\n discountSource?: AlacarteDiscountSource | null,\n /** Discount name for the order summary, e.g. \"First order discount\". */\n discountName?: string | null,\n /** price less discount. */\n amountDue: AlacarteMoney | null,\n billingAddressSet: boolean,\n}\n\n/** Owned member course on a program checkout line (simpler than OwnedCourseRef). */\nexport interface AlacarteProgramOwnedCourse {\n courseId: string,\n name: string,\n via: 'order' | 'program' | 'enrollment',\n}\n\nexport interface AlacarteProgramLine {\n biiId: string,\n kind: 'program',\n programId: string,\n programName: string,\n price: AlacarteMoney | null,\n /** Taken off for member courses the learner already owns; absent when they own none. */\n deduction: AlacarteMoney | null,\n /**\n * Member courses the learner already owns — explains the deduction\n * (\"Already yours: …\"). Empty/absent when they own none.\n */\n ownedCourses?: AlacarteProgramOwnedCourse[] | null,\n /** Taken off by an applied coupon or automatic offer; absent when neither applies. */\n discount: AlacarteMoney | null,\n /** `\"coupon\"` or `\"automatic\"`; absent with no discount. */\n discountSource?: AlacarteDiscountSource | null,\n /** Discount name for the order summary, e.g. \"Bundle discount\". */\n discountName?: string | null,\n /** price less deduction less discount. */\n amountDue: AlacarteMoney | null,\n billingAddressSet: boolean,\n}\n\nexport type AlacarteLine = AlacarteCourseLine | AlacarteProgramLine;\n\n/** Present when the learner switches product while a coupon is on the cart. */\nexport type AlacarteCouponRecheckOutcome = 'kept' | 'rejected' | 'unverified';\n\nexport interface AlacarteCouponRecheck {\n outcome: AlacarteCouponRecheckOutcome,\n /** Coupon error code when outcome is `rejected`. */\n reason?: AlacarteErrorCode | string | null,\n}\n\n/** Last card-decline details; cleared when the next payment attempt starts. */\nexport interface AlacartePaymentDecline {\n code?: string | null,\n /** Ready to show the learner. */\n message: string,\n}\n\n/** Why a selection was refused — see section 5 of alacarte-checkout-api.md. */\nexport interface AlacarteBlocked {\n reason: 'ALREADY_OWNED' | 'NOT_PURCHASABLE' | 'OWNERSHIP_UNAVAILABLE',\n productId: string,\n kind: 'course' | 'program',\n /** ALREADY_OWNED only — where to send the learner (the learner dashboard). */\n route?: string,\n /** ALREADY_OWNED only. */\n ownedCourses?: OwnedCourseRef[],\n /** NOT_PURCHASABLE / OWNERSHIP_UNAVAILABLE — the catalog's reason. */\n detail?: string,\n}\n\n/** Present when the price the learner saw (viewedPrice) differs from what checkout resolves now. */\nexport interface AlacartePriceChanged {\n viewed: AlacarteMoney,\n current: AlacarteMoney,\n}\n\n// --- Checkout envelope -------------------------------------------------------------\nexport interface AlacarteCheckout {\n biId: string,\n uid: string,\n status: AlacarteStatus,\n // Not always present in real responses (absent, not null, when no coupon was entered).\n couponCode?: string | null,\n termsAcceptedAt: string | null,\n acceptedAmount?: AlacarteMoney | null,\n priceAccepted?: boolean,\n /** True when this is the learner's first à-la-carte order (first-order offer applies). */\n firstOrder?: boolean,\n /** Present after the card was declined on the last attempt. */\n paymentDecline?: AlacartePaymentDecline | null,\n line: AlacarteLine | null,\n}\n\nexport type AlacarteErrorCode =\n | 'NOT_AUTHENTICATED'\n | 'RUN_KEY_REQUIRED'\n | 'CONFLICTING_SELECTION'\n | 'NOTHING_SELECTED'\n | 'COURSE_NOT_FOUND'\n | 'PROGRAM_NOT_FOUND'\n | 'CHECKOUT_NOT_FOUND'\n | 'CHECKOUT_NOT_YOURS'\n | 'PRODUCT_NOT_FOUND'\n // Blocked selection — details in the `blocked` envelope field.\n | 'ALREADY_OWNED'\n | 'NOT_PURCHASABLE'\n // No price can be resolved for the product right now.\n | 'PRICING_UNAVAILABLE'\n // Checkout switched off by the kill switch (ALC-200) — also returned by tCheckoutPlaceOrder.\n | 'CHECKOUT_PAUSED'\n // Coupon errors — returned from tCheckoutUpdate, checkout left unchanged.\n | 'COUPON_INVALID'\n | 'COUPON_NOT_ACTIVE'\n | 'COUPON_EXPIRED'\n | 'COUPON_CAP_REACHED'\n | 'COUPON_PRODUCT_NOT_ELIGIBLE'\n | 'COUPON_PARTY_NOT_ELIGIBLE'\n | 'COUPON_PER_CUSTOMER_LIMIT'\n | 'COUPON_REJECTED'\n // getTwouOrder (placed order) errors.\n | 'ORDER_ID_REQUIRED'\n | 'ORDER_NOT_FOUND'\n | 'NOT_PLACED'\n | 'ORDER_READ_FAILED'\n // Payment is still being confirmed, including a 3D Secure check. Poll; not a failure yet.\n | 'PAYMENT_PENDING';\n\nexport interface AlacarteReplaced {\n courseName?: string,\n courseUid?: string,\n courseRunKey?: string,\n programId?: string,\n programName?: string,\n}\n\n/** Shared response envelope for tCheckout / tCheckoutSelect / tCheckoutUpdate. */\nexport interface AlacarteCheckoutResult {\n ok: boolean,\n checkout: AlacarteCheckout | null,\n replaced?: AlacarteReplaced,\n priceChanged?: AlacartePriceChanged,\n blocked?: AlacarteBlocked,\n /** Present when select switches product while a coupon was applied. */\n couponRecheck?: AlacarteCouponRecheck,\n error?: AlacarteErrorCode | string,\n}\n\n// --- Owned products ------------------------------------------------------------------\nexport type OwnedProductStatus = 'full' | 'partial' | 'none';\n\nexport interface OwnedCourseRef {\n courseId: string,\n via: 'order' | 'program' | 'enrollment',\n orderBiId?: string,\n enrollmentBiId?: string,\n programId?: string,\n name: string,\n slug: string,\n}\n\nexport interface OwnedProductPrice {\n full: number,\n deduction: number,\n amountDue: number,\n currency: string,\n}\n\nexport interface OwnedProduct {\n productId: string,\n kind: 'course' | 'program',\n name: string,\n slug: string,\n status: OwnedProductStatus,\n memberCount?: number,\n ownedCourses: OwnedCourseRef[],\n /** Pricing breakdown — available when the backend returns it (e.g. for\n * already-owned products where the checkout line is not created). */\n price?: OwnedProductPrice | null,\n}\n\nexport interface OwnedProductResult {\n ok: boolean,\n product: OwnedProduct | null,\n error?: AlacarteErrorCode | string,\n}\n\nexport interface OwnedProgramRef {\n programId: string,\n orderBiId: string,\n}\n\nexport interface OwnedProductsSummary {\n courses: OwnedCourseRef[],\n programs: OwnedProgramRef[],\n}\n\nexport interface AllOwnedProductsResult {\n ok: boolean,\n owned: OwnedProductsSummary | null,\n error?: AlacarteErrorCode | string,\n}\n\n// --- Program details (filterTwouProgram, by tProgramUuid) -----------------------------\nexport interface ProgramCourseRef {\n id: string,\n maId: string | null,\n uid: string | null,\n maName: string | null,\n maDescription: string | null,\n tShortDescription: string | null,\n imageUrl: string | null,\n tBrandText: string | null,\n tOrgLogoUrl: string | null,\n tUrlCourse: string | null,\n tMarketingSlug: string | null,\n tStatus: { code: string } | null,\n}\n\nexport interface ProgramDetail {\n uid: string,\n tEffortLow: number | null,\n tEnrollmentCount: number | null,\n tMarketingSlug: string | null,\n tSkills: string[] | null,\n tFaq: string | null,\n tLevelType: string | null,\n tCourses: ProgramCourseRef[],\n}\n\n/** Course or program detail, depending on which was selected. */\nexport type ProductDetail = CourseDetail | ProgramDetail;\n\n// --- Banner details (PDP banner before checkout) ---------------------------------\n\nexport interface BannerCourseInstructor {\n tGivenName: string | null,\n tFamilyName: string | null,\n tOrganization: string | null,\n tInstructorUuid: string | null,\n tSortValue: number | null,\n}\n\nexport interface BannerCourseDetail {\n uid: string,\n id: string | null,\n maName: string,\n tEnrollmentCount: number | null,\n tAlacartePurchasable: boolean | null,\n tCourseKey: string | null,\n tShortDescription: string | null,\n maDescription: string | null,\n tBrandText: string | null,\n tOrgLogoUrl: string | null,\n imageUrl: string | null,\n tUrlCourse: string | null,\n tMarketingSlug: string | null,\n tLevelType: string | null,\n tPacingType: string | null,\n tDurationLow: number | null,\n tDurationHigh: number | null,\n tDurationUnit: string | null,\n tEffortLow: number | null,\n tEffortHigh: number | null,\n tEffortUnit: string | null,\n tLanguage: string | null,\n tExpectedLearningItems: string | null,\n tSkills: string[] | null,\n tPrerequisites: string | null,\n tSyllabus: string | null,\n tFaq: string | null,\n tTestimonials: string | null,\n tTranscriptLanguages: string[] | null,\n tInstructors: BannerCourseInstructor[],\n}\n\nexport interface BannerProgramCourse {\n id: string,\n uid: string | null,\n maName: string | null,\n tShortDescription: string | null,\n maDescription: string | null,\n tBrandText: string | null,\n tOrgLogoUrl: string | null,\n tCourseKey: string | null,\n imageUrl: string | null,\n tUrlCourse: string | null,\n tMarketingSlug: string | null,\n tStatus: { code: string } | null,\n}\n\nexport interface BannerProgramDetail {\n uid: string,\n tEffortLow: number | null,\n tEnrollmentCount: number | null,\n tMarketingSlug: string | null,\n tAlacartePurchasable: boolean | null,\n tSkills: string[] | null,\n tFaq: string | null,\n tLevelType: string | null,\n imageUrl: string | null,\n tBannerImageUrl: string | null,\n tCourses: BannerProgramCourse[],\n}\n\nexport type BannerData =\n | { kind: 'course', data: BannerCourseDetail }\n | { kind: 'program', data: BannerProgramDetail };\n\n// --- Placed order (getTwouOrder, confirmation page) ------------------------------------\nexport interface PlacedOrderAmounts {\n price: number,\n deduction: number,\n discount: number,\n paid: number,\n currency: string,\n}\n\nexport interface PlacedOrderLine {\n lineId: string,\n kind: 'course' | 'program',\n productId?: string,\n productUid?: string,\n name: string,\n /** Present on course lines and on each course line of a program order. */\n courseRunKey?: string | null,\n seatType?: string | null,\n /** Set on every line of a program order (one line per course bought). */\n programId?: string,\n bundleRef?: string,\n discountRuleId?: string,\n amounts: PlacedOrderAmounts,\n}\n\nexport interface PlacedOrder {\n orderId: string,\n /** `biId` from getTwouOrder — the order number shown on the confirmation page. */\n orderNumber: string,\n status: string,\n couponCode: string | null,\n /** `card` covers Stripe cards and Apple Pay / Google Pay (named in `wallet`); `paypal` has no card. */\n paymentMethod: { type: 'card' | 'paypal', brand?: string, last4?: string, wallet?: string } | null,\n lines: PlacedOrderLine[],\n totals: PlacedOrderAmounts,\n /** ISO timestamp from tPlacedAt, falling back to biCreatedAt. */\n placedAt?: string | null,\n}\n\nexport interface PlacedOrderResult {\n ok: boolean,\n order: PlacedOrder | null,\n error?: AlacarteErrorCode | string,\n}\n\n/** Billing for tCheckoutPlaceOrder. Only `country` (ISO-2) is required;\n * name/line/city/etc. are optional when the UI doesn't collect a full address. */\nexport interface AlacarteBillingAddress {\n country: string,\n firstName?: string,\n lastName?: string,\n line1?: string,\n line2?: string,\n city?: string,\n state?: string,\n postcode?: string,\n}\n\n/** Stripe payment details returned by a successful tCheckoutPlaceOrder. */\nexport interface AlacartePlaceOrderPayment {\n clientSecret: string,\n paymentIntentId: string,\n /** Amount in cents. */\n amount: number,\n currency: string,\n}\n\nexport type AlacartePlaceOrderErrorCode =\n | 'TERMS_NOT_ACCEPTED'\n | 'PRICE_NOT_ACCEPTED'\n | 'BILLING_ADDRESS_REQUIRED'\n | 'SANCTIONS_BLOCKED'\n | 'COUPON_UNAVAILABLE'\n | 'PAYMENT_NOT_STARTED'\n | 'CHECKOUT_NOT_FOUND'\n | 'NOT_AUTHENTICATED'\n | 'CHECKOUT_PAUSED';\n\n/** PayPal order returned by tCheckoutPlaceOrder(paymentMethod: \"PAYPAL\"). */\nexport interface AlacartePaypalPayment {\n paypalOrderId: string,\n /** Amount in cents. */\n amount: number,\n currency: string,\n}\n\n/** paymentMethod argument of tCheckoutPlaceOrder — omitted means STRIPE. */\nexport type AlacartePaymentMethod = 'STRIPE' | 'PAYPAL';\n\n/** tCheckoutCapturePaypalOrder / tCheckoutCancelPaypalOrder response. */\nexport interface AlacartePaypalOrderResult {\n ok: boolean,\n status?: 'COMPLETED' | 'PENDING' | 'FAILED' | 'CANCELLED',\n orderNumber?: string,\n error?: string,\n}\n\n/** Immediate placement from tCheckoutPlaceOrder (e.g. $0 — no PaymentIntent). */\nexport interface AlacartePlacedOrderRef {\n orderNumber: string,\n}\n\nexport interface AlacartePlaceOrderApiResult {\n ok: boolean,\n payment: AlacartePlaceOrderPayment | null,\n /** Set instead of `payment` when placed with paymentMethod \"PAYPAL\". */\n paypal?: AlacartePaypalPayment | null,\n /** Set when the order was placed immediately without a Stripe/PayPal charge. */\n placed?: AlacartePlacedOrderRef | null,\n /** True when amount due is 0 and no payment processor was started. */\n noChargeRequired?: boolean,\n /** Present on some failures (e.g. PRICE_NOT_ACCEPTED, COUPON_UNAVAILABLE). */\n checkout?: AlacarteCheckout | null,\n error?: AlacartePlaceOrderErrorCode | string,\n}\n\n// --- Product selector (derived from query params) --------------------------------------\nexport type ProductSelector =\n | { kind: 'course', courseUid: string, runKey: string }\n | { kind: 'program', programUid: string }\n | { kind: 'invalid' }\n | { kind: 'none' };\n\n// --- Client surface --------------------------------------------------------------------\nexport interface AlacarteCheckoutClient {\n gql: GqlRunner,\n setToken: (token: string) => void,\n getCheckout: () => Promise<AlacarteCheckoutResult>,\n /** viewedPrice: the amount the learner saw on the page before checkout (USD, before any coupon). */\n selectCourse: (courseUid: string, runKey: string, viewedPrice?: number) => Promise<AlacarteCheckoutResult>,\n selectProgram: (programUid: string, viewedPrice?: number) => Promise<AlacarteCheckoutResult>,\n updateCheckout: (args: {\n biId?: string, couponCode?: string, termsAccepted?: boolean, acceptPrice?: boolean,\n }) => Promise<AlacarteCheckoutResult>,\n getOwnedProduct: (productId: string) => Promise<OwnedProductResult>,\n getAllOwnedProducts: () => Promise<AllOwnedProductsResult>,\n getProgramDetail: (programUid: string) => Promise<ProgramDetail | null>,\n getCourseDetail: (courseKey: string) => Promise<CourseDetail | null>,\n getPlacedOrder: (biId: string) => Promise<PlacedOrderResult>,\n /** One-call place order — returns Stripe client secret (section 5a). */\n placeCheckoutOrder: (\n biId: string,\n billing?: AlacarteBillingAddress,\n paymentMethod?: AlacartePaymentMethod,\n ) => Promise<AlacartePlaceOrderApiResult>,\n capturePaypalOrder: (biId: string, paypalOrderId: string) => Promise<AlacartePaypalOrderResult>,\n cancelPaypalOrder: (biId: string, paypalOrderId: string) => Promise<AlacartePaypalOrderResult>,\n}\n"]}
@@ -6,7 +6,7 @@ const COUPON_MESSAGES = {
6
6
  COUPON_INVALID: "This code doesn't exist",
7
7
  COUPON_NOT_ACTIVE: "This code isn't active",
8
8
  COUPON_EXPIRED: 'This code has expired.',
9
- COUPON_CAP_REACHED: "You've already used this code.",
9
+ COUPON_CAP_REACHED: 'This code has been fully redeemed.',
10
10
  COUPON_PRODUCT_NOT_ELIGIBLE: "This code isn't valid for this course/program.",
11
11
  COUPON_PARTY_NOT_ELIGIBLE: "This code isn't available for your account",
12
12
  COUPON_PER_CUSTOMER_LIMIT: "You've already used this code.",
@@ -1 +1 @@
1
- {"version":3,"file":"couponErrors.js","sourceRoot":"","sources":["../../src/utils/couponErrors.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,eAAe,GAA2B;IAC9C,cAAc,EAAE,yBAAyB;IACzC,iBAAiB,EAAE,wBAAwB;IAC3C,cAAc,EA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arte-checkout-api.md section 7.\n */\nconst COUPON_MESSAGES: Record<string, string> = {\n COUPON_INVALID: \"This code doesn't exist\",\n COUPON_NOT_ACTIVE: \"This code isn't active\",\n COUPON_EXPIRED: 'This code has expired.',\n COUPON_CAP_REACHED: \"You've already used this code.\",\n COUPON_PRODUCT_NOT_ELIGIBLE: \"This code isn't valid for this course/program.\",\n COUPON_PARTY_NOT_ELIGIBLE: \"This code isn't available for your account\",\n COUPON_PER_CUSTOMER_LIMIT: \"You've already used this code.\",\n COUPON_REJECTED: \"This code couldn't be applied\",\n};\n\n/** Shown when couponRecheck.outcome is unverified and the line no longer carries the coupon. */\nexport const COUPON_RECHECK_UNVERIFIED_MESSAGE = \"We couldn't verify your promo code. Please try entering it again.\";\n\n/** COUPON_INVALID needs the entered code interpolated, so it's built separately. */\nfunction invalidCouponMessage(code?: string | null): string {\n return code\n ? `Coupon code '${code}' does not exist. Please check the code and try again.`\n : \"This code doesn't exist\";\n}\n\nexport function getCouponErrorMessage(error?: string | null, code?: string | null): string {\n if (!error) return COUPON_MESSAGES.COUPON_REJECTED;\n if (error === 'COUPON_INVALID') return invalidCouponMessage(code);\n return COUPON_MESSAGES[error] ?? error;\n}\n\nexport function isCouponError(error?: string | null): boolean {\n return !!error && error in COUPON_MESSAGES;\n}\n\n/**\n * Learner-facing copy for couponRecheck on product switch (section 2).\n * Returns null when nothing extra should be shown (`kept`, or `unverified` while\n * the line still carries a coupon discount).\n */\nexport function getCouponRecheckMessage(\n recheck: { outcome: string, reason?: string | null } | null | undefined,\n discountSource?: string | null,\n code?: string | null,\n): string | null {\n if (!recheck) return null;\n if (recheck.outcome === 'rejected') {\n return getCouponErrorMessage(recheck.reason, code);\n }\n if (recheck.outcome === 'unverified' && discountSource !== 'coupon') {\n return COUPON_RECHECK_UNVERIFIED_MESSAGE;\n }\n return null;\n}\n"]}
1
+ {"version":3,"file":"couponErrors.js","sourceRoot":"","sources":["../../src/utils/couponErrors.ts"],"names":[],"mappings":"AAAA;;;G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;IAC3C,CAAC;IACD,OAAO,IAAI,CAAC;AACd,CAAC","sourcesContent":["/**\n * Learner-facing messages for tCheckoutUpdate coupon errors.\n * See alacarte-checkout-api.md section 7.\n */\nconst COUPON_MESSAGES: Record<string, string> = {\n COUPON_INVALID: \"This code doesn't exist\",\n COUPON_NOT_ACTIVE: \"This code isn't active\",\n COUPON_EXPIRED: 'This code has expired.',\n COUPON_CAP_REACHED: 'This code has been fully redeemed.',\n COUPON_PRODUCT_NOT_ELIGIBLE: \"This code isn't valid for this course/program.\",\n COUPON_PARTY_NOT_ELIGIBLE: \"This code isn't available for your account\",\n COUPON_PER_CUSTOMER_LIMIT: \"You've already used this code.\",\n COUPON_REJECTED: \"This code couldn't be applied\",\n};\n\n/** Shown when couponRecheck.outcome is unverified and the line no longer carries the coupon. */\nexport const COUPON_RECHECK_UNVERIFIED_MESSAGE = \"We couldn't verify your promo code. Please try entering it again.\";\n\n/** COUPON_INVALID needs the entered code interpolated, so it's built separately. */\nfunction invalidCouponMessage(code?: string | null): string {\n return code\n ? `Coupon code '${code}' does not exist. Please check the code and try again.`\n : \"This code doesn't exist\";\n}\n\nexport function getCouponErrorMessage(error?: string | null, code?: string | null): string {\n if (!error) return COUPON_MESSAGES.COUPON_REJECTED;\n if (error === 'COUPON_INVALID') return invalidCouponMessage(code);\n return COUPON_MESSAGES[error] ?? error;\n}\n\nexport function isCouponError(error?: string | null): boolean {\n return !!error && error in COUPON_MESSAGES;\n}\n\n/**\n * Learner-facing copy for couponRecheck on product switch (section 2).\n * Returns null when nothing extra should be shown (`kept`, or `unverified` while\n * the line still carries a coupon discount).\n */\nexport function getCouponRecheckMessage(\n recheck: { outcome: string, reason?: string | null } | null | undefined,\n discountSource?: string | null,\n code?: string | null,\n): string | null {\n if (!recheck) return null;\n if (recheck.outcome === 'rejected') {\n return getCouponErrorMessage(recheck.reason, code);\n }\n if (recheck.outcome === 'unverified' && discountSource !== 'coupon') {\n return COUPON_RECHECK_UNVERIFIED_MESSAGE;\n }\n return null;\n}\n"]}
@@ -17,3 +17,6 @@ export declare function isSanctionsBlockedError(err: unknown): err is AlacartePl
17
17
  /** The learner's account is blocked from purchasing — no charge was made and
18
18
  * retrying won't help, so the UI shows a blocking modal instead. */
19
19
  export declare function isPurchaseBlockedError(err: unknown): err is AlacartePlaceOrderError;
20
+ /** Checkout is switched off (ALC-200 kill switch) — retrying won't help until
21
+ * it's back on, so the UI locks the page behind a blocking banner. */
22
+ export declare function isCheckoutPausedError(err: unknown): err is AlacartePlaceOrderError;
@@ -8,6 +8,7 @@ const PLACE_ORDER_MESSAGES = {
8
8
  PAYMENT_NOT_STARTED: 'Payment could not be started. Please try again.',
9
9
  CHECKOUT_NOT_FOUND: 'Your checkout could not be found. Please refresh and try again.',
10
10
  NOT_AUTHENTICATED: 'Please sign in again to complete your purchase.',
11
+ CHECKOUT_PAUSED: 'Checkout is temporarily unavailable. Please try again later.',
11
12
  // tCheckoutCapturePaypalOrder / tCheckoutCancelPaypalOrder.
12
13
  CAPTURE_FAILED: 'Your PayPal payment could not be completed. Please try again or use another payment method.',
13
14
  CANCEL_FAILED: 'Your PayPal payment could not be cancelled. Please refresh and try again.',
@@ -45,4 +46,9 @@ export function isSanctionsBlockedError(err) {
45
46
  export function isPurchaseBlockedError(err) {
46
47
  return err instanceof AlacartePlaceOrderError && err.code === 'PURCHASE_BLOCKED';
47
48
  }
49
+ /** Checkout is switched off (ALC-200 kill switch) — retrying won't help until
50
+ * it's back on, so the UI locks the page behind a blocking banner. */
51
+ export function isCheckoutPausedError(err) {
52
+ return err instanceof AlacartePlaceOrderError && err.code === 'CHECKOUT_PAUSED';
53
+ }
48
54
  //# sourceMappingURL=placeOrderErrors.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"placeOrderErrors.js","sourceRoot":"","sources":["../../src/utils/placeOrderErrors.ts"],"names":[],"mappings":"AAKA,MAAM,oBAAoB,GAA2B;IACnD,kBAAkB,EAAE,sCAAsC;IAC1D,kBAAkB,EAAE,mEAAmE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;AACrE,MAAM,UAAU,sBAAsB,CAAC,GAAY;IACjD,OAAO,GAAG,YAAY,uBAAuB,IAAI,GAAG,CAAC,IAAI,KAAK,kBAAkB,CAAC;AACnF,CAAC","sourcesContent":["/**\n * Learner-facing messages for tCheckoutPlaceOrder errors (section 5a).\n */\nimport type { AlacarteCheckout } from '../types/alacarte';\n\nconst PLACE_ORDER_MESSAGES: Record<string, string> = {\n TERMS_NOT_ACCEPTED: 'Please accept the terms to continue.',\n PRICE_NOT_ACCEPTED: 'The price has changed. Please review the new total and try again.',\n BILLING_ADDRESS_REQUIRED: 'Please select a billing country.',\n SANCTIONS_BLOCKED: \"We're unable to complete this purchase.\",\n PURCHASE_BLOCKED: \"We can't complete this purchase.\",\n COUPON_UNAVAILABLE:\n 'This promo code can no longer be used. Review the new total and accept it to continue.',\n PAYMENT_NOT_STARTED: 'Payment could not be started. Please try again.',\n CHECKOUT_NOT_FOUND: 'Your checkout could not be found. Please refresh and try again.',\n NOT_AUTHENTICATED: 'Please sign in again to complete your purchase.',\n // tCheckoutCapturePaypalOrder / tCheckoutCancelPaypalOrder.\n CAPTURE_FAILED: 'Your PayPal payment could not be completed. Please try again or use another payment method.',\n CANCEL_FAILED: 'Your PayPal payment could not be cancelled. Please refresh and try again.',\n PAYMENT_RECONCILIATION_REQUIRED: 'We could not confirm your PayPal payment. Please contact support.',\n PAYPAL_PAYMENT_DECLINED: 'Your PayPal payment was declined. Please try again or use another payment method.',\n // ALC-452 #6: poll timeout — the learner waited ~30s without a confirmed outcome.\n POLL_TIMEOUT: \"Your payment could not be confirmed. Please try again — you won't be charged twice.\",\n};\n\nexport class AlacartePlaceOrderError extends Error {\n code: string;\n\n checkout: AlacarteCheckout | null;\n\n constructor(code: string, message: string, checkout: AlacarteCheckout | null = null) {\n super(message);\n this.name = 'AlacartePlaceOrderError';\n this.code = code;\n this.checkout = checkout;\n }\n}\n\n/** Learner-facing message for the poll-timeout return-to-checkout (ALC-452 #6). */\nexport const POLL_TIMEOUT_MESSAGE = PLACE_ORDER_MESSAGES.POLL_TIMEOUT;\n\nexport function getPlaceOrderErrorMessage(error?: string | null): string {\n if (!error) return 'Something went wrong placing your order. Please try again.';\n return PLACE_ORDER_MESSAGES[error] ?? error;\n}\n\nexport function toPlaceOrderError(\n code: string,\n checkout: AlacarteCheckout | null = null,\n): AlacartePlaceOrderError {\n return new AlacartePlaceOrderError(code, getPlaceOrderErrorMessage(code), checkout);\n}\n\n/** The learner failed sanctions screening at place order — no charge was\n * made and retrying won't help, so the UI shows a blocking modal instead. */\nexport function isSanctionsBlockedError(err: unknown): err is AlacartePlaceOrderError {\n return err instanceof AlacartePlaceOrderError && err.code === 'SANCTIONS_BLOCKED';\n}\n\n/** The learner's account is blocked from purchasing — no charge was made and\n * retrying won't help, so the UI shows a blocking modal instead. */\nexport function isPurchaseBlockedError(err: unknown): err is AlacartePlaceOrderError {\n return err instanceof AlacartePlaceOrderError && err.code === 'PURCHASE_BLOCKED';\n}\n"]}
1
+ {"version":3,"file":"placeOrderErrors.js","sourceRoot":"","sources":["../../src/utils/placeOrderErrors.ts"],"names":[],"mappings":"AAKA,MAAM,oBAAoB,GAA2B;IACnD,kBAAkB,EAAE,sCAAsC;IAC1D,kBAAkB,EAAE,mEAAmE;IACvF,wBAAwB,EAAE,kCAAkC;IAC5D,iBAAiB,EAAE,yCAAyC;IAC5D,gBAAgB,EAAE,kCAAkC;IACpD,kBAAkB,EAChB,wFAAwF;IAC1F,mBAAmB,EAAE,iDAAiD;IACtE,kBAAkB,EAAE,iEAAiE;IACrF,iBAAiB,EAAE,iDAAiD;IACpE,eAAe,EAAE,8DAA8D;IAC/E,4DAA4D;IAC5D,cAAc,EAAE,6FAA6F;IAC7G,aAAa,EAAE,2EAA2E;IAC1F,+BAA+B,EAAE,mEAAmE;IACpG,uBAAuB,EAAE,mFAAmF;IAC5G,kFAAkF;IAClF,YAAY,EAAE,qFAAqF;CACpG,CAAC;AAEF,MAAM,OAAO,uBAAwB,SAAQ,KAAK;IAKhD,YAAY,IAAY,EAAE,OAAe,EAAE,WAAoC,IAAI;QACjF,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,yBAAyB,CAAC;QACtC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;CACF;AAED,mFAAmF;AACnF,MAAM,CAAC,MAAM,oBAAoB,GAAG,oBAAoB,CAAC,YAAY,CAAC;AAEtE,MAAM,UAAU,yBAAyB,CAAC,KAAqB;;IAC7D,IAAI,CAAC,KAAK;QAAE,OAAO,4DAA4D,CAAC;IAChF,OAAO,MAAA,oBAAoB,CAAC,KAAK,CAAC,mCAAI,KAAK,CAAC;AAC9C,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,IAAY,EACZ,WAAoC,IAAI;IAExC,OAAO,IAAI,uBAAuB,CAAC,IAAI,EAAE,yBAAyB,CAAC,IAAI,CAAC,EAAE,QAAQ,CAAC,CAAC;AACtF,CAAC;AAED;8EAC8E;AAC9E,MAAM,UAAU,uBAAuB,CAAC,GAAY;IAClD,OAAO,GAAG,YAAY,uBAAuB,IAAI,GAAG,CAAC,IAAI,KAAK,mBAAmB,CAAC;AACpF,CAAC;AAED;qEACqE;AACrE,MAAM,UAAU,sBAAsB,CAAC,GAAY;IACjD,OAAO,GAAG,YAAY,uBAAuB,IAAI,GAAG,CAAC,IAAI,KAAK,kBAAkB,CAAC;AACnF,CAAC;AAED;uEACuE;AACvE,MAAM,UAAU,qBAAqB,CAAC,GAAY;IAChD,OAAO,GAAG,YAAY,uBAAuB,IAAI,GAAG,CAAC,IAAI,KAAK,iBAAiB,CAAC;AAClF,CAAC","sourcesContent":["/**\n * Learner-facing messages for tCheckoutPlaceOrder errors (section 5a).\n */\nimport type { AlacarteCheckout } from '../types/alacarte';\n\nconst PLACE_ORDER_MESSAGES: Record<string, string> = {\n TERMS_NOT_ACCEPTED: 'Please accept the terms to continue.',\n PRICE_NOT_ACCEPTED: 'The price has changed. Please review the new total and try again.',\n BILLING_ADDRESS_REQUIRED: 'Please select a billing country.',\n SANCTIONS_BLOCKED: \"We're unable to complete this purchase.\",\n PURCHASE_BLOCKED: \"We can't complete this purchase.\",\n COUPON_UNAVAILABLE:\n 'This promo code can no longer be used. Review the new total and accept it to continue.',\n PAYMENT_NOT_STARTED: 'Payment could not be started. Please try again.',\n CHECKOUT_NOT_FOUND: 'Your checkout could not be found. Please refresh and try again.',\n NOT_AUTHENTICATED: 'Please sign in again to complete your purchase.',\n CHECKOUT_PAUSED: 'Checkout is temporarily unavailable. Please try again later.',\n // tCheckoutCapturePaypalOrder / tCheckoutCancelPaypalOrder.\n CAPTURE_FAILED: 'Your PayPal payment could not be completed. Please try again or use another payment method.',\n CANCEL_FAILED: 'Your PayPal payment could not be cancelled. Please refresh and try again.',\n PAYMENT_RECONCILIATION_REQUIRED: 'We could not confirm your PayPal payment. Please contact support.',\n PAYPAL_PAYMENT_DECLINED: 'Your PayPal payment was declined. Please try again or use another payment method.',\n // ALC-452 #6: poll timeout — the learner waited ~30s without a confirmed outcome.\n POLL_TIMEOUT: \"Your payment could not be confirmed. Please try again — you won't be charged twice.\",\n};\n\nexport class AlacartePlaceOrderError extends Error {\n code: string;\n\n checkout: AlacarteCheckout | null;\n\n constructor(code: string, message: string, checkout: AlacarteCheckout | null = null) {\n super(message);\n this.name = 'AlacartePlaceOrderError';\n this.code = code;\n this.checkout = checkout;\n }\n}\n\n/** Learner-facing message for the poll-timeout return-to-checkout (ALC-452 #6). */\nexport const POLL_TIMEOUT_MESSAGE = PLACE_ORDER_MESSAGES.POLL_TIMEOUT;\n\nexport function getPlaceOrderErrorMessage(error?: string | null): string {\n if (!error) return 'Something went wrong placing your order. Please try again.';\n return PLACE_ORDER_MESSAGES[error] ?? error;\n}\n\nexport function toPlaceOrderError(\n code: string,\n checkout: AlacarteCheckout | null = null,\n): AlacartePlaceOrderError {\n return new AlacartePlaceOrderError(code, getPlaceOrderErrorMessage(code), checkout);\n}\n\n/** The learner failed sanctions screening at place order — no charge was\n * made and retrying won't help, so the UI shows a blocking modal instead. */\nexport function isSanctionsBlockedError(err: unknown): err is AlacartePlaceOrderError {\n return err instanceof AlacartePlaceOrderError && err.code === 'SANCTIONS_BLOCKED';\n}\n\n/** The learner's account is blocked from purchasing — no charge was made and\n * retrying won't help, so the UI shows a blocking modal instead. */\nexport function isPurchaseBlockedError(err: unknown): err is AlacartePlaceOrderError {\n return err instanceof AlacartePlaceOrderError && err.code === 'PURCHASE_BLOCKED';\n}\n\n/** Checkout is switched off (ALC-200 kill switch) — retrying won't help until\n * it's back on, so the UI locks the page behind a blocking banner. */\nexport function isCheckoutPausedError(err: unknown): err is AlacartePlaceOrderError {\n return err instanceof AlacartePlaceOrderError && err.code === 'CHECKOUT_PAUSED';\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edx/frontend-app-alacarte-checkout",
3
- "version": "1.75.0",
3
+ "version": "1.77.0",
4
4
  "description": "alacarte Checkout Frontend application",
5
5
  "repository": {
6
6
  "type": "git",