@edx/frontend-app-alacarte-checkout 1.69.0 → 1.70.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/components/Checkout/Checkout.js +2 -5
- package/dist/components/Checkout/Checkout.js.map +1 -1
- package/dist/components/Checkout/Messages.d.ts +0 -5
- package/dist/components/Checkout/Messages.js +0 -5
- package/dist/components/Checkout/Messages.js.map +1 -1
- package/dist/data/hooks/useAlacarteCheckout.js +11 -1
- package/dist/data/hooks/useAlacarteCheckout.js.map +1 -1
- package/package.json +1 -1
|
@@ -52,7 +52,7 @@ import messages from './Messages';
|
|
|
52
52
|
// Flip back to true to restore the redirect.
|
|
53
53
|
const REDIRECT_ON_NO_ACTIVE_CHECKOUT = false;
|
|
54
54
|
const Checkout = (_a) => {
|
|
55
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w
|
|
55
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w;
|
|
56
56
|
var { homeUrl = '/', orderHistoryUrl, learnerDashboardUrl, paypalClientId } = _a, props = __rest(_a, ["homeUrl", "orderHistoryUrl", "learnerDashboardUrl", "paypalClientId"]);
|
|
57
57
|
const { formatMessage } = useIntl();
|
|
58
58
|
const alacarte = useAlacarteCheckout({
|
|
@@ -288,10 +288,7 @@ const Checkout = (_a) => {
|
|
|
288
288
|
message: alacarte.paymentDecline.message,
|
|
289
289
|
code: (_w = alacarte.paymentDecline.code) !== null && _w !== void 0 ? _w : undefined,
|
|
290
290
|
}) })), 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
|
|
291
|
-
&& !alacarte.paymentDecline && !alacarte.placeOrderError && !paymentTimedOut && (_jsx(Alert, { variant: "danger", icon: ErrorIcon, dismissible: true, onClose: alacarte.clearWalletPaymentCancelled, className: "mb-3", "data-testid": "wallet-payment-cancelled-alert", children: formatMessage(messages.walletPaymentCancelledAlert) })), showPriceChangedAlert && (_jsx(PriceChangedAlert, { kind: priceChangedKind, onDismiss: () => setDismissedPriceChange(true), className: "mb-3" })),
|
|
292
|
-
amount: alacarte.line.amountDue.amount.toFixed(2),
|
|
293
|
-
currency: alacarte.line.amountDue.currency,
|
|
294
|
-
}) })), showForm && (_jsxs(_Fragment, { children: [_jsx(PaymentValidationAlert, { fields: invalidPaymentFields, country: c.billing.country, focusRequest: validationRequest, onFieldSelect: focusPaymentField, className: "mb-3" }), c.phase === 'failed' && (_jsx(Alert, { variant: "danger", icon: ErrorIcon, className: "mb-3", children: failedMessage
|
|
291
|
+
&& !alacarte.paymentDecline && !alacarte.placeOrderError && !paymentTimedOut && (_jsx(Alert, { variant: "danger", icon: ErrorIcon, dismissible: true, onClose: alacarte.clearWalletPaymentCancelled, className: "mb-3", "data-testid": "wallet-payment-cancelled-alert", children: formatMessage(messages.walletPaymentCancelledAlert) })), showPriceChangedAlert && (_jsx(PriceChangedAlert, { kind: priceChangedKind, onDismiss: () => setDismissedPriceChange(true), className: "mb-3" })), showForm && (_jsxs(_Fragment, { children: [_jsx(PaymentValidationAlert, { fields: invalidPaymentFields, country: c.billing.country, focusRequest: validationRequest, onFieldSelect: focusPaymentField, className: "mb-3" }), c.phase === 'failed' && (_jsx(Alert, { variant: "danger", icon: ErrorIcon, className: "mb-3", children: failedMessage
|
|
295
292
|
|| formatMessage(messages.paymentProcessingDescription) })), appliedCouponCode && appliedDiscount && dismissedCouponAlert !== appliedCouponCode && (_jsxs(AutoDismissAlert, { variant: "success", icon: CheckCircle, dismissible: true, closeLabel: formatMessage(messages.dismiss), onClose: () => {
|
|
296
293
|
setDismissedCouponAlert(appliedCouponCode);
|
|
297
294
|
setFocusCouponAlert(false);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Checkout.js","sourceRoot":"","sources":["../../../src/components/Checkout/Checkout.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA,OAAc,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC3D,OAAO,EAAE,WAAW,EAAE,KAAK,IAAI,SAAS,EAAE,MAAM,wBAAwB,CAAC;AACzE,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,WAAW,MAAM,8BAA8B,CAAC;AAEvD,OAAO,EAAE,mBAAmB,EAAE,MAAM,sCAAsC,CAAC;AAC3E,kGAAkG;AAClG,oFAAoF;AACpF,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,OAAO,iBAAiB,MAAM,wCAAwC,CAAC;AACvE,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,4FAA4F;AAC5F,OAAO,iBAAiB,MAAM,wCAAwC,CAAC;AACvE,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAC9D,OAAO,oBAAoB,MAAM,8CAA8C,CAAC;AAChF,OAAO,mBAAmB,MAAM,4CAA4C,CAAC;AAC7E,OAAO,iBAAiB,MAAM,wCAAwC,CAAC;AACvE,OAAO,sBAAsB,MAAM,kDAAkD,CAAC;AACtF,OAAO,gBAAgB,MAAM,sCAAsC,CAAC;AACpE,OAAO,kBAAkB,MAAM,0CAA0C,CAAC,CAAC,kDAAkD;AAC7H,OAAO,EAAE,iBAAiB,EAAE,MAAM,YAAY,CAAC;AAC/C,OAAO,EAAE,+BAA+B,EAAE,MAAM,4BAA4B,CAAC;AAC7E,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CA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AAI,EAC1D,gBAAgB,EAAE,eAAe,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,SAAS,EACpE,cAAc,EAAE,eAAe,CAAC,CAAC,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CAAC,CAAC,SAAS,EACzE,eAAe,EAAE,eAAe,CAAC,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';\n// import CountryUnavailableModal from '../CountryUnavailableModal/CountryUnavailableModal';\nimport OrderBlockedModal from '../OrderBlockedModal/OrderBlockedModal';\nimport AlacarteNotice from '../AlacarteNotice/AlacarteNotice';\nimport AlacarteConfirmation from '../AlacarteConfirmation/AlacarteConfirmation';\nimport PaymentTimeoutAlert from '../PaymentTimeoutAlert/PaymentTimeoutAlert';\nimport PriceChangedAlert from '../PriceChangedAlert/PriceChangedAlert';\nimport PaymentValidationAlert from '../PaymentValidationAlert/PaymentValidationAlert';\nimport AutoDismissAlert from '../AutoDismissAlert/AutoDismissAlert';\nimport AlacarteDebugPanel from '../AlacarteDebugPanel/AlacarteDebugPanel'; // TEMPORARY — remove alongside AlacarteDebugPanel\nimport { getTrialDateRange } from '@src/utils';\nimport { getLearnerFacingCheckoutMessage } from '../../utils/checkoutErrors';\nimport { appliedDiscountPercent } from '../../utils/discount';\nimport { useInert } from '../../utils/inert';\nimport { getInvalidPaymentFields, isCardFieldKey } from '../../utils/paymentValidation';\nimport type { PaymentFieldKey } from '../../utils/paymentValidation';\nimport { confirmPaymentWithMethodId, getLearnerFacingStripeMessage } from '../../utils/stripeCard';\nimport { SuccessScreen, BlockedScreen, ProcessingScreen } from '../StatusScreens/StatusScreens';\nimport type { BillingCycle, CourseDetail } from '../../types';\nimport type { ProgramDetail } from '../../types/alacarte';\nimport messages from './Messages';\n\n// TEMPORARY — redirect-home-on-noActiveCheckout disabled per request; shows a\n// banner instead so the case is visible while the flow is being verified.\n// Flip back to true to restore the redirect.\nconst REDIRECT_ON_NO_ACTIVE_CHECKOUT = false;\n\nexport type CheckoutProps = UseCheckoutOptions & {\n /** Homepage URL for the country-unavailable modal CTA. */\n homeUrl?: string,\n /** Endpoint used to look up the representative IP for a selected country. */\n geolocationUrl?: string,\n /** Learner dashboard / order history URL for confirmation CTAs. */\n orderHistoryUrl?: string,\n /** 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 // 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 // Only treat the line discount as a removable coupon when the backend says\n // so (or a coupon code is present). Automatic offers show only in CartSummary's\n // discount row and must not drive PromoCode's applied/remove UI.\n const isCouponDiscount = !!alacarte.line?.discount\n && alacarte.line.discountSource !== 'automatic'\n && (alacarte.line.discountSource === 'coupon' || !!appliedCouponCode);\n const appliedDiscount = isCouponDiscount && discountPercent != null\n ? {\n percent: discountPercent,\n amount: alacarte.line!.discount!.amount,\n currency: alacarte.line!.discount!.currency,\n }\n : null;\n // Automatic offer (no code entered): announced with its own success alert.\n const automaticOfferCode = 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 // Keep the coupon field in sync when a code is applied via URL or API.\n // Don't overwrite the field with empty when only an automatic offer applies.\n useEffect(() => {\n if (alacarte.checkout?.couponCode) {\n setPromoCodeValue(alacarte.checkout.couponCode);\n }\n }, [alacarte.checkout?.couponCode]);\n\n useEffect(() => {\n if (appliedCouponCode && isCouponDiscount && discountPercent != null) {\n setAdvertisedOffer({ code: appliedCouponCode, percent: discountPercent });\n }\n }, [appliedCouponCode, isCouponDiscount, discountPercent]);\n\n // A coupon alert closed with focus inside it: go back to the coupon control\n // (Remove when a coupon is applied, otherwise the field).\n const focusCouponControl = useCallback(() => {\n (document.getElementById('promoCodeRemove') ?? document.getElementById('promoCode'))?.focus();\n }, []);\n\n // No query params and no active cart — nothing to check out, send the\n // learner home rather than showing a placeholder.\n useEffect(() => {\n if (REDIRECT_ON_NO_ACTIVE_CHECKOUT && alacarte.phase === 'noActiveCheckout') {\n window.location.href = homeUrl;\n }\n }, [alacarte.phase, homeUrl]);\n\n // Express checkout (Apple Pay / Google Pay): runs the full place-order flow\n // using a wallet-provided PaymentMethod id instead of the mounted card element.\n const handleExpressPayment = useCallback(async (paymentMethodId: string, walletCountry?: string) => {\n if (!c.stripe) throw new Error('Stripe not loaded');\n const stripeInstance = c.stripe;\n const country = (c.billing.country || walletCountry || c.userCountry || '').trim().toUpperCase();\n if (!country) {\n throw new Error('Please select a country before using Apple Pay or Google Pay.');\n }\n\n await alacarte.placeOrderAsync({\n billing: {\n ...c.billing,\n country,\n },\n confirmCardPayment: async (clientSecret: string) => {\n await confirmPaymentWithMethodId({\n stripe: stripeInstance,\n clientSecret,\n paymentMethodId,\n });\n },\n });\n }, [alacarte, c.billing, c.userCountry, c.stripe]);\n\n // Express checkout (PayPal): tCheckoutPlaceOrder(PAYPAL) when the PayPal\n // button is clicked; approve/cancel go straight to the à la carte hook.\n // The card form isn't validated — PayPal collects the payer's details.\n const handlePaypalCreateOrder = useCallback(() => alacarte.startPaypalOrder({\n billing: {\n ...c.billing,\n country: c.billing.country || c.userCountry || '',\n },\n }), [alacarte, c.billing, c.userCountry]);\n\n const showProcessing\n = c.returningFromStripe\n && c.processingSubscription\n && c.phase !== 'success'\n && c.phase !== 'blocked'\n && c.phase !== 'failed';\n const showForm\n = !showProcessing\n && (c.phase === 'init'\n || c.phase === 'ready'\n || c.phase === 'failed'\n || c.phase === 'processing');\n const failedMessage = getLearnerFacingCheckoutMessage(c.lastComment);\n\n const { displayStart, displayEnd } = getTrialDateRange();\n\n // const isBillingCountryBlocked = GATE_CHECK_COUNTRY\n // && !!c.billing.country\n // && !ALLOWED_CHECKOUT_COUNTRIES.includes(c.billing.country);\n\n const selectedCycle: BillingCycle = c.selectedCycle;\n\n // Prefer the à la carte course's own detail (skills/badge/image, richer than\n // the subscription flow's ?course_run_key= lookup) when we selected a course.\n // When already-owned the line may be null, so fall back to the selector kind.\n const isCourseProduct = alacarte.line?.kind === 'course' || alacarte.selector?.kind === 'course';\n const isProgramProduct = alacarte.line?.kind === 'program' || alacarte.selector?.kind === 'program';\n\n const alacarteCourseDetail: CourseDetail | null\n = isCourseProduct && alacarte.productDetail && 'maId' in alacarte.productDetail\n ? alacarte.productDetail\n : null;\n const courseForSummary = alacarteCourseDetail ?? c.course;\n\n const alacarteProgramDetail: ProgramDetail | null\n = isProgramProduct && alacarte.productDetail && 'tCourses' in alacarte.productDetail\n ? alacarte.productDetail\n : null;\n\n const handleStartCourse = () => {\n const alacarteCourseUrl = alacarteCourseDetail?.tUrlCourse\n || (alacarte.productDetail && 'tUrlCourse' in alacarte.productDetail\n ? alacarte.productDetail.tUrlCourse\n : null);\n if (alacarteCourseUrl) {\n window.location.href = alacarteCourseUrl;\n } else if (c.course?.tUrlCourse) {\n window.location.href = c.course.tUrlCourse;\n } else {\n window.location.href = homeUrl || '/';\n }\n };\n\n const courseLabel = c.course\n ? [c.course.tBrandText, c.course.maName].filter(Boolean).join(': ')\n : null;\n\n const isAlreadyOwned = alacarte.isAlreadyOwned;\n // 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; only the alerts above stay usable.\n const isLocked = isAlreadyOwned || paymentTimedOut;\n // The overlay only blocks the pointer — inert takes the locked content out\n // of the tab order too.\n const lockedInertRef = useInert<HTMLDivElement>(isLocked);\n\n // Live while shown, so the links drop off as the learner fixes each field.\n const invalidPaymentFields = validationRequest > 0\n ? getInvalidPaymentFields(c.cardFieldStates, c.billing)\n : [];\n const handleValidationResult = (invalidFields: PaymentFieldKey[]) => {\n setValidationRequest((n) => (invalidFields.length > 0 ? n + 1 : 0));\n };\n const focusPaymentField = (field: PaymentFieldKey) => {\n if (isCardFieldKey(field)) {\n c.focusCardField(field);\n } else {\n // Billing controls use the field key as their id (Form.Group controlId).\n document.getElementById(field)?.focus();\n }\n };\n\n if (showProcessing) {\n return <ProcessingScreen />;\n }\n\n // TEMPORARY — flip to true to dump à la carte hook state while validating\n // against the real backend. Remove AlacarteDebugPanel once the flow is solid.\n const SHOW_ALACARTE_DEBUG = false;\n const alacarteDebug = SHOW_ALACARTE_DEBUG\n ? <AlacarteDebugPanel data={alacarte} />\n : null;\n\n // Confirmation: show once the order is ready (or failed to load). While\n // 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 return (\n <>\n {alacarteDebug}\n <Row className=\"checkout__container bg-light-200\">\n <Col xs={12}>\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n data-testid=\"alacarte-error-banner\"\n >\n {alacarte.error || 'Something went wrong with checkout.'}\n </Alert>\n </Col>\n </Row>\n </>\n );\n }\n\n // Price differs from what the learner viewed before checkout (ALC-159).\n const showPriceChangedAlert = !!alacarte.priceChanged && !dismissedPriceChange && !isLocked;\n const priceChangedKind = isProgramProduct ? 'program' : 'course';\n\n return (\n <>\n {alacarteDebug}\n <Row className=\"checkout__container bg-light-200\">\n {/* <CountryUnavailableModal\n isOpen={isBillingCountryBlocked}\n homeUrl={homeUrl}\n /> */}\n {alacarte.sanctionsBlocked && (\n <OrderBlockedModal\n isOpen\n referenceCode={alacarte.sanctionsBlocked.referenceCode}\n homeUrl={homeUrl}\n />\n )}\n <Col xs={12} className={isLocked ? 'checkout__locked-overlay' : ''}>\n {/* DOM order is the tab order on every breakpoint: alerts, then the\n summary and coupon, then payment. From lg up, the grid in\n checkout.scss moves the summary to the right column. */}\n <Row className=\"checkout__layout\">\n <Col xs={12} className=\"checkout__header\">\n <div>\n <h1 className=\"font-weight-bold text-primary-900 mb-lg-4\">\n Checkout\n </h1>\n\n {paymentTimedOut && (\n <PaymentTimeoutAlert className=\"checkout__overlay-alert mb-3\" />\n )}\n\n {isAlreadyOwned && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n className=\"checkout__overlay-alert mb-3\"\n data-testid=\"already-owned-alert\"\n >\n <p className=\"mb-3\">{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 {!alacarte.priceAccepted && !alacarte.priceChanged && isAlacarteReady && alacarte.line?.amountDue && (\n <Alert variant=\"info\" className=\"mb-3\" data-testid=\"price-accept-notice\">\n {formatMessage(messages.priceChangedNotice, {\n amount: alacarte.line.amountDue.amount.toFixed(2),\n currency: alacarte.line.amountDue.currency,\n })}\n </Alert>\n )}\n\n {showForm && (\n <>\n <PaymentValidationAlert\n fields={invalidPaymentFields}\n country={c.billing.country}\n focusRequest={validationRequest}\n onFieldSelect={focusPaymentField}\n className=\"mb-3\"\n />\n {c.phase === 'failed' && (\n <Alert variant=\"danger\" icon={ErrorIcon} className=\"mb-3\">\n {failedMessage\n || formatMessage(messages.paymentProcessingDescription)}\n </Alert>\n )}\n {appliedCouponCode && appliedDiscount && dismissedCouponAlert !== appliedCouponCode && (\n <AutoDismissAlert\n key={appliedCouponCode}\n variant=\"success\"\n icon={CheckCircle}\n dismissible\n closeLabel={formatMessage(messages.dismiss)}\n onClose={() => {\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 {automaticOffer && dismissedAutomaticOfferAlert !== automaticOffer.code && (\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 ref={lockedInertRef} data-testid=\"checkout-summary-region\">\n {c.phase === 'success' ? (\n <EnrollmentSummary\n course={c.course}\n onStartCourse={handleStartCourse}\n />\n ) : (\n <CartSummary\n defaultCycle={selectedCycle}\n onCycleChange={c.processingSubscription ? undefined : c.setCycle}\n course={courseForSummary}\n alacarteLine={alacarte.line}\n programDetail={alacarteProgramDetail}\n programName={alacarte.ownedProductName}\n promoCode={isAlacarteReady ? {\n value: promoCodeValue,\n // Keep a coupon error up while the learner edits the code;\n // applyCoupon clears it on the next Apply.\n onChange: setPromoCodeValue,\n onApply: () => {\n setFocusCouponAlert(true);\n alacarte.applyCoupon(promoCodeValue);\n },\n onRemove: () => {\n setFocusCouponAlert(true);\n alacarte.removeCoupon();\n setPromoCodeValue('');\n setAdvertisedOffer(null);\n // The applied alert auto-dismisses, so re-applying the\n // same code must be able to show it again.\n setDismissedCouponAlert(null);\n },\n appliedCode: appliedCouponCode,\n discount: appliedDiscount,\n offer: !appliedCouponCode ? advertisedOffer : null,\n error: alacarte.couponError,\n isApplying: alacarte.couponApplying,\n disabled: alacarte.placingOrder,\n } : null}\n />\n )}\n </div>\n </Col>\n\n {/* ── Payment ── */}\n <Col xs={12} className=\"payment__options\">\n <div ref={lockedInertRef} data-testid=\"checkout-payment-region\">\n {showForm && (\n <PaymentForm\n billing={c.billing}\n setField={c.setField}\n numberMountRef={c.numberMountRef}\n expiryMountRef={c.expiryMountRef}\n cvcMountRef={c.cvcMountRef}\n cardError={c.cardError}\n cardFieldStates={c.cardFieldStates}\n stripeReady={c.stripeReady}\n sessionReady={c.sessionReady}\n submitting={\n isAlacarteReady\n ? (alacarte.placingOrder || alacarte.awaitingPlacedOrder)\n : c.processingSubscription\n }\n onPlaceOrder={\n isAlacarteReady\n ? () => {\n alacarte.placeOrder({\n billing: {\n ...c.billing,\n // Country is required on tCheckoutPlaceOrder (two-letter ISO).\n // Prefer the form selection; fall back to gate geolocation.\n country: c.billing.country || c.userCountry || '',\n },\n confirmCardPayment: c.confirmCardPayment,\n });\n }\n : c.placeOrder\n }\n onValidationError={handleValidationResult}\n trialEnd={selectedCycle === 'monthly' ? displayEnd : undefined}\n priceToShow={null}\n cycleToShow={selectedCycle === 'monthly' ? 'monthly' : 'annual'}\n userCountry={c.userCountry}\n geolocationUrl={props.geolocationUrl}\n alacarteLine={alacarte.line}\n stripe={c.stripe}\n expressCountry={c.billing.country || c.userCountry || 'US'}\n onExpressPayment={isAlacarteReady ? handleExpressPayment : undefined}\n onExpressClick={isAlacarteReady ? alacarte.clearPaymentAlerts : undefined}\n onExpressCancel={isAlacarteReady ? alacarte.markWalletPaymentCancelled : undefined}\n paypalClientId={paypalClientId}\n onPaypalCreateOrder={isAlacarteReady ? handlePaypalCreateOrder : undefined}\n onPaypalApprove={isAlacarteReady ? alacarte.approvePaypalOrder : undefined}\n onPaypalCancel={isAlacarteReady ? alacarte.cancelPaypalOrder : undefined}\n />\n )}\n\n {c.phase === 'success' && (\n <SuccessScreen\n 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,OAAO,WAAW,MAAM,4BAA4B,CAAC;AACrD,4FAA4F;AAC5F,OAAO,iBAAiB,MAAM,wCAAwC,CAAC;AACvE,OAAO,cAAc,MAAM,kCAAkC,CAAC;AAC9D,OAAO,oBAAoB,MAAM,8CAA8C,CAAC;AAChF,OAAO,mBAAmB,MAAM,4CAA4C,CAAC;AAC7E,OAAO,iBAAiB,MAAM,wCAAwC,CAAC;AACv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,CAAC,CAAC,SAAS,EACzE,eAAe,EAAE,eAAe,CAAC,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';\n// import CountryUnavailableModal from '../CountryUnavailableModal/CountryUnavailableModal';\nimport OrderBlockedModal from '../OrderBlockedModal/OrderBlockedModal';\nimport AlacarteNotice from '../AlacarteNotice/AlacarteNotice';\nimport AlacarteConfirmation from '../AlacarteConfirmation/AlacarteConfirmation';\nimport PaymentTimeoutAlert from '../PaymentTimeoutAlert/PaymentTimeoutAlert';\nimport PriceChangedAlert from '../PriceChangedAlert/PriceChangedAlert';\nimport PaymentValidationAlert from '../PaymentValidationAlert/PaymentValidationAlert';\nimport AutoDismissAlert from '../AutoDismissAlert/AutoDismissAlert';\nimport AlacarteDebugPanel from '../AlacarteDebugPanel/AlacarteDebugPanel'; // TEMPORARY — remove alongside AlacarteDebugPanel\nimport { getTrialDateRange } from '@src/utils';\nimport { getLearnerFacingCheckoutMessage } from '../../utils/checkoutErrors';\nimport { appliedDiscountPercent } from '../../utils/discount';\nimport { useInert } from '../../utils/inert';\nimport { getInvalidPaymentFields, isCardFieldKey } from '../../utils/paymentValidation';\nimport type { PaymentFieldKey } from '../../utils/paymentValidation';\nimport { confirmPaymentWithMethodId, getLearnerFacingStripeMessage } from '../../utils/stripeCard';\nimport { SuccessScreen, BlockedScreen, ProcessingScreen } from '../StatusScreens/StatusScreens';\nimport type { BillingCycle, CourseDetail } from '../../types';\nimport type { ProgramDetail } from '../../types/alacarte';\nimport messages from './Messages';\n\n// TEMPORARY — redirect-home-on-noActiveCheckout disabled per request; shows a\n// banner instead so the case is visible while the flow is being verified.\n// Flip back to true to restore the redirect.\nconst REDIRECT_ON_NO_ACTIVE_CHECKOUT = false;\n\nexport type CheckoutProps = UseCheckoutOptions & {\n /** Homepage URL for the country-unavailable modal CTA. */\n homeUrl?: string,\n /** Endpoint used to look up the representative IP for a selected country. */\n geolocationUrl?: string,\n /** Learner dashboard / order history URL for confirmation CTAs. */\n orderHistoryUrl?: string,\n /** 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 // 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 // Only treat the line discount as a removable coupon when the backend says\n // so (or a coupon code is present). Automatic offers show only in CartSummary's\n // discount row and must not drive PromoCode's applied/remove UI.\n const isCouponDiscount = !!alacarte.line?.discount\n && alacarte.line.discountSource !== 'automatic'\n && (alacarte.line.discountSource === 'coupon' || !!appliedCouponCode);\n const appliedDiscount = isCouponDiscount && discountPercent != null\n ? {\n percent: discountPercent,\n amount: alacarte.line!.discount!.amount,\n currency: alacarte.line!.discount!.currency,\n }\n : null;\n // Automatic offer (no code entered): announced with its own success alert.\n const automaticOfferCode = 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 // Keep the coupon field in sync when a code is applied via URL or API.\n // Don't overwrite the field with empty when only an automatic offer applies.\n useEffect(() => {\n if (alacarte.checkout?.couponCode) {\n setPromoCodeValue(alacarte.checkout.couponCode);\n }\n }, [alacarte.checkout?.couponCode]);\n\n useEffect(() => {\n if (appliedCouponCode && isCouponDiscount && discountPercent != null) {\n setAdvertisedOffer({ code: appliedCouponCode, percent: discountPercent });\n }\n }, [appliedCouponCode, isCouponDiscount, discountPercent]);\n\n // A coupon alert closed with focus inside it: go back to the coupon control\n // (Remove when a coupon is applied, otherwise the field).\n const focusCouponControl = useCallback(() => {\n (document.getElementById('promoCodeRemove') ?? document.getElementById('promoCode'))?.focus();\n }, []);\n\n // No query params and no active cart — nothing to check out, send the\n // learner home rather than showing a placeholder.\n useEffect(() => {\n if (REDIRECT_ON_NO_ACTIVE_CHECKOUT && alacarte.phase === 'noActiveCheckout') {\n window.location.href = homeUrl;\n }\n }, [alacarte.phase, homeUrl]);\n\n // Express checkout (Apple Pay / Google Pay): runs the full place-order flow\n // using a wallet-provided PaymentMethod id instead of the mounted card element.\n const handleExpressPayment = useCallback(async (paymentMethodId: string, walletCountry?: string) => {\n if (!c.stripe) throw new Error('Stripe not loaded');\n const stripeInstance = c.stripe;\n const country = (c.billing.country || walletCountry || c.userCountry || '').trim().toUpperCase();\n if (!country) {\n throw new Error('Please select a country before using Apple Pay or Google Pay.');\n }\n\n await alacarte.placeOrderAsync({\n billing: {\n ...c.billing,\n country,\n },\n confirmCardPayment: async (clientSecret: string) => {\n await confirmPaymentWithMethodId({\n stripe: stripeInstance,\n clientSecret,\n paymentMethodId,\n });\n },\n });\n }, [alacarte, c.billing, c.userCountry, c.stripe]);\n\n // Express checkout (PayPal): tCheckoutPlaceOrder(PAYPAL) when the PayPal\n // button is clicked; approve/cancel go straight to the à la carte hook.\n // The card form isn't validated — PayPal collects the payer's details.\n const handlePaypalCreateOrder = useCallback(() => alacarte.startPaypalOrder({\n billing: {\n ...c.billing,\n country: c.billing.country || c.userCountry || '',\n },\n }), [alacarte, c.billing, c.userCountry]);\n\n const showProcessing\n = c.returningFromStripe\n && c.processingSubscription\n && c.phase !== 'success'\n && c.phase !== 'blocked'\n && c.phase !== 'failed';\n const showForm\n = !showProcessing\n && (c.phase === 'init'\n || c.phase === 'ready'\n || c.phase === 'failed'\n || c.phase === 'processing');\n const failedMessage = getLearnerFacingCheckoutMessage(c.lastComment);\n\n const { displayStart, displayEnd } = getTrialDateRange();\n\n // const isBillingCountryBlocked = GATE_CHECK_COUNTRY\n // && !!c.billing.country\n // && !ALLOWED_CHECKOUT_COUNTRIES.includes(c.billing.country);\n\n const selectedCycle: BillingCycle = c.selectedCycle;\n\n // Prefer the à la carte course's own detail (skills/badge/image, richer than\n // the subscription flow's ?course_run_key= lookup) when we selected a course.\n // When already-owned the line may be null, so fall back to the selector kind.\n const isCourseProduct = alacarte.line?.kind === 'course' || alacarte.selector?.kind === 'course';\n const isProgramProduct = alacarte.line?.kind === 'program' || alacarte.selector?.kind === 'program';\n\n const alacarteCourseDetail: CourseDetail | null\n = isCourseProduct && alacarte.productDetail && 'maId' in alacarte.productDetail\n ? alacarte.productDetail\n : null;\n const courseForSummary = alacarteCourseDetail ?? c.course;\n\n const alacarteProgramDetail: ProgramDetail | null\n = isProgramProduct && alacarte.productDetail && 'tCourses' in alacarte.productDetail\n ? alacarte.productDetail\n : null;\n\n const handleStartCourse = () => {\n const alacarteCourseUrl = alacarteCourseDetail?.tUrlCourse\n || (alacarte.productDetail && 'tUrlCourse' in alacarte.productDetail\n ? alacarte.productDetail.tUrlCourse\n : null);\n if (alacarteCourseUrl) {\n window.location.href = alacarteCourseUrl;\n } else if (c.course?.tUrlCourse) {\n window.location.href = c.course.tUrlCourse;\n } else {\n window.location.href = homeUrl || '/';\n }\n };\n\n const courseLabel = c.course\n ? [c.course.tBrandText, c.course.maName].filter(Boolean).join(': ')\n : null;\n\n const isAlreadyOwned = alacarte.isAlreadyOwned;\n // 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; only the alerts above stay usable.\n const isLocked = isAlreadyOwned || paymentTimedOut;\n // The overlay only blocks the pointer — inert takes the locked content out\n // of the tab order too.\n const lockedInertRef = useInert<HTMLDivElement>(isLocked);\n\n // Live while shown, so the links drop off as the learner fixes each field.\n const invalidPaymentFields = validationRequest > 0\n ? getInvalidPaymentFields(c.cardFieldStates, c.billing)\n : [];\n const handleValidationResult = (invalidFields: PaymentFieldKey[]) => {\n setValidationRequest((n) => (invalidFields.length > 0 ? n + 1 : 0));\n };\n const focusPaymentField = (field: PaymentFieldKey) => {\n if (isCardFieldKey(field)) {\n c.focusCardField(field);\n } else {\n // Billing controls use the field key as their id (Form.Group controlId).\n document.getElementById(field)?.focus();\n }\n };\n\n if (showProcessing) {\n return <ProcessingScreen />;\n }\n\n // TEMPORARY — flip to true to dump à la carte hook state while validating\n // against the real backend. Remove AlacarteDebugPanel once the flow is solid.\n const SHOW_ALACARTE_DEBUG = false;\n const alacarteDebug = SHOW_ALACARTE_DEBUG\n ? <AlacarteDebugPanel data={alacarte} />\n : null;\n\n // Confirmation: show once the order is ready (or failed to load). While\n // 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 return (\n <>\n {alacarteDebug}\n <Row className=\"checkout__container bg-light-200\">\n <Col xs={12}>\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n data-testid=\"alacarte-error-banner\"\n >\n {alacarte.error || 'Something went wrong with checkout.'}\n </Alert>\n </Col>\n </Row>\n </>\n );\n }\n\n // Price differs from what the learner viewed before checkout (ALC-159).\n const showPriceChangedAlert = !!alacarte.priceChanged && !dismissedPriceChange && !isLocked;\n const priceChangedKind = isProgramProduct ? 'program' : 'course';\n\n return (\n <>\n {alacarteDebug}\n <Row className=\"checkout__container bg-light-200\">\n {/* <CountryUnavailableModal\n isOpen={isBillingCountryBlocked}\n homeUrl={homeUrl}\n /> */}\n {alacarte.sanctionsBlocked && (\n <OrderBlockedModal\n isOpen\n referenceCode={alacarte.sanctionsBlocked.referenceCode}\n homeUrl={homeUrl}\n />\n )}\n <Col xs={12} className={isLocked ? 'checkout__locked-overlay' : ''}>\n {/* DOM order is the tab order on every breakpoint: alerts, then the\n summary and coupon, then payment. From lg up, the grid in\n checkout.scss moves the summary to the right column. */}\n <Row className=\"checkout__layout\">\n <Col xs={12} className=\"checkout__header\">\n <div>\n <h1 className=\"font-weight-bold text-primary-900 mb-lg-4\">\n Checkout\n </h1>\n\n {paymentTimedOut && (\n <PaymentTimeoutAlert className=\"checkout__overlay-alert mb-3\" />\n )}\n\n {isAlreadyOwned && (\n <Alert\n variant=\"danger\"\n icon={ErrorIcon}\n className=\"checkout__overlay-alert mb-3\"\n data-testid=\"already-owned-alert\"\n >\n <p className=\"mb-3\">{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 <PaymentValidationAlert\n fields={invalidPaymentFields}\n country={c.billing.country}\n focusRequest={validationRequest}\n onFieldSelect={focusPaymentField}\n className=\"mb-3\"\n />\n {c.phase === 'failed' && (\n <Alert variant=\"danger\" icon={ErrorIcon} className=\"mb-3\">\n {failedMessage\n || formatMessage(messages.paymentProcessingDescription)}\n </Alert>\n )}\n {appliedCouponCode && appliedDiscount && dismissedCouponAlert !== appliedCouponCode && (\n <AutoDismissAlert\n key={appliedCouponCode}\n variant=\"success\"\n icon={CheckCircle}\n dismissible\n closeLabel={formatMessage(messages.dismiss)}\n onClose={() => {\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 {automaticOffer && dismissedAutomaticOfferAlert !== automaticOffer.code && (\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 ref={lockedInertRef} data-testid=\"checkout-summary-region\">\n {c.phase === 'success' ? (\n <EnrollmentSummary\n course={c.course}\n onStartCourse={handleStartCourse}\n />\n ) : (\n <CartSummary\n defaultCycle={selectedCycle}\n onCycleChange={c.processingSubscription ? undefined : c.setCycle}\n course={courseForSummary}\n alacarteLine={alacarte.line}\n programDetail={alacarteProgramDetail}\n programName={alacarte.ownedProductName}\n promoCode={isAlacarteReady ? {\n value: promoCodeValue,\n // Keep a coupon error up while the learner edits the code;\n // applyCoupon clears it on the next Apply.\n onChange: setPromoCodeValue,\n onApply: () => {\n setFocusCouponAlert(true);\n alacarte.applyCoupon(promoCodeValue);\n },\n onRemove: () => {\n setFocusCouponAlert(true);\n alacarte.removeCoupon();\n setPromoCodeValue('');\n setAdvertisedOffer(null);\n // The applied alert auto-dismisses, so re-applying the\n // same code must be able to show it again.\n setDismissedCouponAlert(null);\n },\n appliedCode: appliedCouponCode,\n discount: appliedDiscount,\n offer: !appliedCouponCode ? advertisedOffer : null,\n error: alacarte.couponError,\n isApplying: alacarte.couponApplying,\n disabled: alacarte.placingOrder,\n } : null}\n />\n )}\n </div>\n </Col>\n\n {/* ── Payment ── */}\n <Col xs={12} className=\"payment__options\">\n <div ref={lockedInertRef} data-testid=\"checkout-payment-region\">\n {showForm && (\n <PaymentForm\n billing={c.billing}\n setField={c.setField}\n numberMountRef={c.numberMountRef}\n expiryMountRef={c.expiryMountRef}\n cvcMountRef={c.cvcMountRef}\n cardError={c.cardError}\n cardFieldStates={c.cardFieldStates}\n stripeReady={c.stripeReady}\n sessionReady={c.sessionReady}\n submitting={\n isAlacarteReady\n ? (alacarte.placingOrder || alacarte.awaitingPlacedOrder)\n : c.processingSubscription\n }\n onPlaceOrder={\n isAlacarteReady\n ? () => {\n alacarte.placeOrder({\n billing: {\n ...c.billing,\n // Country is required on tCheckoutPlaceOrder (two-letter ISO).\n // Prefer the form selection; fall back to gate geolocation.\n country: c.billing.country || c.userCountry || '',\n },\n confirmCardPayment: c.confirmCardPayment,\n });\n }\n : c.placeOrder\n }\n onValidationError={handleValidationResult}\n trialEnd={selectedCycle === 'monthly' ? displayEnd : undefined}\n priceToShow={null}\n cycleToShow={selectedCycle === 'monthly' ? 'monthly' : 'annual'}\n userCountry={c.userCountry}\n geolocationUrl={props.geolocationUrl}\n alacarteLine={alacarte.line}\n stripe={c.stripe}\n expressCountry={c.billing.country || c.userCountry || 'US'}\n onExpressPayment={isAlacarteReady ? handleExpressPayment : undefined}\n onExpressClick={isAlacarteReady ? alacarte.clearPaymentAlerts : undefined}\n onExpressCancel={isAlacarteReady ? alacarte.markWalletPaymentCancelled : undefined}\n paypalClientId={paypalClientId}\n onPaypalCreateOrder={isAlacarteReady ? handlePaypalCreateOrder : undefined}\n onPaypalApprove={isAlacarteReady ? alacarte.approvePaypalOrder : undefined}\n onPaypalCancel={isAlacarteReady ? alacarte.cancelPaypalOrder : undefined}\n />\n )}\n\n {c.phase === 'success' && (\n <SuccessScreen\n 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"]}
|
|
@@ -15,11 +15,6 @@ const messages = defineMessages({
|
|
|
15
15
|
defaultMessage: "Your payment wasn't completed. You haven't been charged and your order is still here.",
|
|
16
16
|
description: 'Alert shown when the learner closes the Apple Pay / Google Pay sheet without paying',
|
|
17
17
|
},
|
|
18
|
-
priceChangedNotice: {
|
|
19
|
-
id: 'checkout.alacarte.priceChangedNotice',
|
|
20
|
-
defaultMessage: 'The price is now ${amount} {currency}. Click Pay now to accept this amount and continue.',
|
|
21
|
-
description: 'Shown when checkout.priceAccepted is false so the learner confirms the current amount due',
|
|
22
|
-
},
|
|
23
18
|
couponAppliedAlert: {
|
|
24
19
|
id: 'checkout.couponAppliedAlert',
|
|
25
20
|
defaultMessage: 'Coupon code {code} applied for {percent}% off!',
|
|
@@ -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,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,
|
|
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,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AAY,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 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"]}
|
|
@@ -789,6 +789,10 @@ export function useAlacarteCheckout(options) {
|
|
|
789
789
|
if (isRequestTimeoutError(err)) {
|
|
790
790
|
setPaymentTimedOut(true);
|
|
791
791
|
}
|
|
792
|
+
else if (isSanctionsBlockedError(err)) {
|
|
793
|
+
// TODO: use the backend reference code once tCheckoutPlaceOrder returns one.
|
|
794
|
+
setSanctionsBlocked({ referenceCode: 'REF-8F2K-40QX-1177' });
|
|
795
|
+
}
|
|
792
796
|
else if (isCouponError(paypalErrMsg)) {
|
|
793
797
|
setCouponError(getCouponErrorMessage(paypalErrMsg));
|
|
794
798
|
}
|
|
@@ -846,7 +850,13 @@ export function useAlacarteCheckout(options) {
|
|
|
846
850
|
yield setOrderBiId(biId);
|
|
847
851
|
}
|
|
848
852
|
catch (err) {
|
|
849
|
-
|
|
853
|
+
if (isSanctionsBlockedError(err)) {
|
|
854
|
+
// TODO: use the backend reference code once tCheckoutCapturePaypalOrder returns one.
|
|
855
|
+
setSanctionsBlocked({ referenceCode: 'REF-8F2K-40QX-1177' });
|
|
856
|
+
}
|
|
857
|
+
else {
|
|
858
|
+
setPlaceOrderError(errorMessage(err));
|
|
859
|
+
}
|
|
850
860
|
// A declined/failed capture leaves the order settled as failed — reload so
|
|
851
861
|
// the learner can retry (paymentDecline comes back on tCheckout).
|
|
852
862
|
setCardRetryBiId(null);
|
|
@@ -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,uBAAuB,EAAE,oBAAoB,EAAE,iBAAiB,EAAE,MAAM,8BAA8B,CAAC;AACzI,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,yBAAyB,EAAE,uBAAuB,EAAE,qBAAqB,GAC1E,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzD,OAAO,EACL,oBAAoB,EAAE,wBAAwB,E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AAI,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,EAChB,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, 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 /** 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 /** 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\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 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 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 return {\n phase: 'notPurchasable',\n ...empty,\n productDetail,\n error: selectMutation.data.blocked.kind === 'program'\n ? 'This program is not eligible for checkout.'\n : 'This course is not eligible for checkout.',\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 const blockedDetail = selectMutation.data.blocked?.detail;\n return {\n phase: 'error',\n ...empty,\n error: blockedDetail ?? selectError ?? 'unknown',\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 // 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 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 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, productDetailQuery.data ?? null),\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 (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 (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 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;AAC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,kBAAkB;QAClB,eAAe;QACf,gBAAgB,EAChB,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, 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 /** 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 /** 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\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 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 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 return {\n phase: 'notPurchasable',\n ...empty,\n productDetail,\n error: selectMutation.data.blocked.kind === 'program'\n ? 'This program is not eligible for checkout.'\n : 'This course is not eligible for checkout.',\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 const blockedDetail = selectMutation.data.blocked?.detail;\n return {\n phase: 'error',\n ...empty,\n error: blockedDetail ?? selectError ?? 'unknown',\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 // 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 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 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, productDetailQuery.data ?? null),\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 (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 // TODO: use the backend reference code once tCheckoutPlaceOrder returns one.\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 if (isSanctionsBlockedError(err)) {\n // TODO: use the backend reference code once tCheckoutCapturePaypalOrder returns one.\n setSanctionsBlocked({ referenceCode: 'REF-8F2K-40QX-1177' });\n } else {\n setPlaceOrderError(errorMessage(err));\n }\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 paymentDecline: derived.checkout?.paymentDecline ?? null,\n placedOrder,\n awaitingPlacedOrder: placedView.awaitingPlacedOrder,\n placedOrderError: placedView.placedOrderError,\n placedOrderPlacedAt,\n };\n}\n\nexport default useAlacarteCheckout;\n"]}
|