@edx/frontend-app-alacarte-checkout 1.52.0 → 1.53.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -110,7 +110,14 @@ const ExpressCheckout = ({ stripe, totalAmountCents, currency, onPaymentAuthoriz
110
110
  const buttons = paypal.Buttons({
111
111
  fundingSource: paypal.FUNDING.PAYPAL,
112
112
  style: {
113
- layout: 'horizontal', color: 'gold', shape: 'rect', label: 'paypal', height: 48, tagline: false,
113
+ layout: 'horizontal',
114
+ color: 'gold',
115
+ shape: 'rect',
116
+ label: 'paypal',
117
+ height: 48,
118
+ // Matches the Stripe wallets' `borderRadius: '12px'` appearance.
119
+ borderRadius: 12,
120
+ tagline: false,
114
121
  },
115
122
  createOrder: () => __awaiter(void 0, void 0, void 0, function* () {
116
123
  setWalletError(null);
@@ -202,17 +209,33 @@ const ExpressCheckout = ({ stripe, totalAmountCents, currency, onPaymentAuthoriz
202
209
  },
203
210
  };
204
211
  const bindWallet = (slot, elements, expressElement, mountNode, setReady, setVisible) => {
205
- expressElement.on('ready', (event) => {
206
- const methods = event.availablePaymentMethods;
207
- const visible = slot === 'apple' ? !!(methods === null || methods === void 0 ? void 0 : methods.applePay) : !!(methods === null || methods === void 0 ? void 0 : methods.googlePay);
208
- console.log(`[ExpressCheckout] ready (${slot})`, {
209
- applePay: !!(methods === null || methods === void 0 ? void 0 : methods.applePay),
210
- googlePay: !!(methods === null || methods === void 0 ? void 0 : methods.googlePay),
212
+ // Availability comes from `availablepaymentmethodschange`: it fires on initial
213
+ // render and again if it changes later (iOS checks Apple Pay asynchronously,
214
+ // so a one-shot read on `ready` could hide the button for good).
215
+ let availabilityReported = false;
216
+ expressElement.on('availablepaymentmethodschange', (event) => {
217
+ var _a;
218
+ const methods = event.paymentMethods;
219
+ const visible = !!((_a = (slot === 'apple' ? methods === null || methods === void 0 ? void 0 : methods.applePay : methods === null || methods === void 0 ? void 0 : methods.googlePay)) === null || _a === void 0 ? void 0 : _a.available);
220
+ console.log(`[ExpressCheckout] available payment methods (${slot})`, {
221
+ visible,
211
222
  raw: methods !== null && methods !== void 0 ? methods : null,
212
223
  });
224
+ availabilityReported = true;
213
225
  setVisible(visible);
214
226
  setReady(true);
215
227
  });
228
+ // Fallback for the deprecated `ready` payload, only while the change event
229
+ // hasn't reported. A negative answer here may be stale, so it's ignored.
230
+ expressElement.on('ready', (event) => {
231
+ const methods = event.availablePaymentMethods;
232
+ const visible = slot === 'apple' ? !!(methods === null || methods === void 0 ? void 0 : methods.applePay) : !!(methods === null || methods === void 0 ? void 0 : methods.googlePay);
233
+ console.log(`[ExpressCheckout] ready (${slot})`, { visible, raw: methods !== null && methods !== void 0 ? methods : null });
234
+ if (availabilityReported || !visible)
235
+ return;
236
+ setVisible(true);
237
+ setReady(true);
238
+ });
216
239
  // A wallet that fails to load counts as unavailable, so it can't hold the skeleton.
217
240
  expressElement.on('loaderror', (event) => {
218
241
  console.warn(`[ExpressCheckout] load error (${slot})`, event);
@@ -1 +1 @@
1
- {"version":3,"file":"ExpressCheckout.js","sourceRoot":"","sources":["../../../src/components/ExpressCheckout/ExpressCheckout.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAQ5C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,QAAQ,MAAM,YAAY,CAAC;AAiClC,uFAAuF;AACvF,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC;AAErC;;;;;;;GAOG;AACH,MAAM,eAAe,GAAmC,CAAC,E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AC,cAAc,KAAG,GACX,CACV,IACG,EAGN,cACE,GAAG,EAAE,aAAa,EAClB,SAAS,EAAE,eAAe,CAAC,UAAU,EAAE,YAAY,CAAC,iBACvC,UAAU,IAAI,CAAC,YAAY,gBAC5B,aAAa,CAAC,QAAQ,CAAC,QAAQ,CAAC,GAC5C,EACF,cACE,GAAG,EAAE,cAAc,EACnB,SAAS,EAAE,eAAe,CAAC,WAAW,EAAE,aAAa,CAAC,iBACzC,WAAW,IAAI,CAAC,aAAa,gBAC9B,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,GAC7C,IACE,EACL,WAAW,IAAI,CACd,YAAG,SAAS,EAAC,yBAAyB,EAAC,IAAI,EAAC,OAAO,YAChD,WAAW,GACV,CACL,EAEA,YAAY,IAAI,CACf,KAAC,QAAQ,IAAC,kBAAkB,EAAC,4BAA4B,EAAC,MAAM,EAAC,MAAM,EAAC,YAAY,EAAE,CAAC,EAAE,MAAM,SAAG,CACnG,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { useIntl } from '@openedx/frontend-base';\nimport { Skeleton } from '@openedx/paragon';\nimport type {\n ExpressCheckoutConfirmEvent,\n ExpressCheckoutReadyEvent,\n StripeElementsLike,\n StripeElementLike,\n StripeLike,\n} from '../../types';\nimport { PayPalWordmark } from '../BrandMarks/BrandMarks';\nimport { useInert } from '../../utils/inert';\nimport { loadPaypal } from '../../utils/paypal';\nimport messages from './Messages';\n\nexport interface ExpressCheckoutProps {\n /** Stripe.js instance — null until loaded. */\n stripe: StripeLike | null,\n /** Total amount in the smallest currency unit (cents). */\n totalAmountCents: number | null,\n /** ISO 4217 currency code, e.g. 'USD'. */\n currency: string | null,\n /** Two-letter country code (kept for API stability). */\n country: string,\n /**\n * Called when the user authorises a wallet payment (Apple Pay / Google Pay).\n * Receives the Stripe PaymentMethod id and the billing country from the wallet.\n * Must resolve on success or reject on failure.\n */\n onPaymentAuthorized: (paymentMethodId: string, walletCountry?: string) => Promise<void>,\n /** PayPal JS SDK client id — PayPal stays disabled without it. */\n paypalClientId?: string | null,\n /** PayPal `createOrder`: places the order with PayPal and resolves its id. */\n onPaypalCreateOrder?: () => Promise<string>,\n /** PayPal `onApprove`: captures the approved PayPal order. */\n onPaypalApprove?: (paypalOrderId: string) => Promise<void>,\n /** PayPal `onCancel` / `onError`: abandons the unapproved PayPal order. */\n onPaypalCancel?: (paypalOrderId: string) => Promise<void>,\n /** Disables the Apple Pay / Google Pay slots. */\n disabled?: boolean,\n /** Disables the PayPal slot — PayPal doesn't need Stripe, so it has its own flag. */\n paypalDisabled?: boolean,\n}\n\ntype WalletSlot = 'apple' | 'google';\n\n// Shows the block anyway if an SDK never settles (blocked script, Stripe never loads).\nexport const SKELETON_MAX_MS = 10000;\n\n/**\n * Express checkout: PayPal (local) | Apple Pay | Google Pay.\n *\n * Apple and Google each get their own Express Checkout Element (one wallet per\n * mount) so we can lay them out in equal columns. A single ECE with both wallets\n * stacks / overflows in this narrow column. `always` keeps the Shopify-like\n * show-even-without-a-saved-card behaviour.\n */\nconst ExpressCheckout: React.FC<ExpressCheckoutProps> = ({\n stripe,\n totalAmountCents,\n currency,\n onPaymentAuthorized,\n paypalClientId,\n onPaypalCreateOrder,\n onPaypalApprove,\n onPaypalCancel,\n disabled,\n paypalDisabled,\n}) => {\n const { formatMessage } = useIntl();\n const appleMountRef = useRef<HTMLDivElement | null>(null);\n const googleMountRef = useRef<HTMLDivElement | null>(null);\n const appleElementsRef = useRef<StripeElementsLike | null>(null);\n const googleElementsRef = useRef<StripeElementsLike | null>(null);\n const appleElementRef = useRef<StripeElementLike | null>(null);\n const googleElementRef = useRef<StripeElementLike | null>(null);\n const onPaymentAuthorizedRef = useRef(onPaymentAuthorized);\n const paypalMountRef = useRef<HTMLDivElement | null>(null);\n // The disabled class only blocks the pointer — inert drops the slot's\n // iframe from the tab order too.\n const paypalSlotRef = useInert<HTMLDivElement>(!!paypalDisabled);\n const paypalHandlersRef = useRef({ onPaypalCreateOrder, onPaypalApprove, onPaypalCancel });\n // PayPal order created but not yet approved — cancelled if the buttons error out.\n const openPaypalOrderRef = useRef<string | null>(null);\n\n const [appleReady, setAppleReady] = useState(false);\n const [googleReady, setGoogleReady] = useState(false);\n const [appleVisible, setAppleVisible] = useState(false);\n const [googleVisible, setGoogleVisible] = useState(false);\n const [walletError, setWalletError] = useState<string | null>(null);\n const [paypalRendered, setPaypalRendered] = useState(false);\n // PayPal finished: rendered, ineligible, failed, or never possible (no client id).\n const [paypalSettled, setPaypalSettled] = useState(false);\n // Latched so later remounts (currency change) don't bring the skeleton back.\n const [loaded, setLoaded] = useState(false);\n\n const hasAmount = !!totalAmountCents && !!currency;\n const paypalEnabled = !!paypalClientId && hasAmount && !!onPaypalCreateOrder && !!onPaypalApprove;\n // Keep slots in the grid until ready so Stripe measures a full column width.\n const showAppleSlot = !appleReady || appleVisible;\n const showGoogleSlot = !googleReady || googleVisible;\n const columnCount = 1 + (showAppleSlot ? 1 : 0) + (showGoogleSlot ? 1 : 0);\n const allSettled = paypalSettled && appleReady && googleReady;\n const showSkeleton = !loaded && !allSettled;\n\n useEffect(() => {\n if (allSettled) setLoaded(true);\n }, [allSettled]);\n\n useEffect(() => {\n const timer = setTimeout(() => setLoaded(true), SKELETON_MAX_MS);\n return () => clearTimeout(timer);\n }, []);\n\n useEffect(() => {\n onPaymentAuthorizedRef.current = onPaymentAuthorized;\n }, [onPaymentAuthorized]);\n\n // Wallet hosts keep object refs for remounts, so toggle inert here instead.\n useEffect(() => {\n appleMountRef.current?.toggleAttribute('inert', !!disabled);\n googleMountRef.current?.toggleAttribute('inert', !!disabled);\n }, [disabled]);\n\n useEffect(() => {\n paypalHandlersRef.current = { onPaypalCreateOrder, onPaypalApprove, onPaypalCancel };\n }, [onPaypalCreateOrder, onPaypalApprove, onPaypalCancel]);\n\n // PayPal buttons: tCheckoutPlaceOrder(PAYPAL) on click, capture on approve,\n // cancel when the learner closes the PayPal window.\n useEffect(() => {\n const mountNode = paypalMountRef.current;\n if (!paypalEnabled || !paypalClientId || !currency || !mountNode) {\n console.log('[ExpressCheckout] PayPal disabled', {\n hasClientId: !!paypalClientId,\n hasAmount,\n hasCreateOrder: !!onPaypalCreateOrder,\n hasApprove: !!onPaypalApprove,\n });\n setPaypalRendered(false);\n // Without a client id PayPal can never render — don't wait for it.\n setPaypalSettled(!paypalClientId);\n return undefined;\n }\n\n let cancelled = false;\n const cancelOpenOrder = async () => {\n const orderId = openPaypalOrderRef.current;\n openPaypalOrderRef.current = null;\n if (orderId) await paypalHandlersRef.current.onPaypalCancel?.(orderId);\n };\n\n loadPaypal(paypalClientId, currency)\n .then(async (paypal) => {\n if (cancelled) return;\n const buttons = paypal.Buttons({\n fundingSource: paypal.FUNDING.PAYPAL,\n style: {\n layout: 'horizontal', color: 'gold', shape: 'rect', label: 'paypal', height: 48, tagline: false,\n },\n createOrder: async () => {\n setWalletError(null);\n const orderId = await paypalHandlersRef.current.onPaypalCreateOrder!();\n openPaypalOrderRef.current = orderId;\n return orderId;\n },\n onApprove: async ({ orderID }) => {\n openPaypalOrderRef.current = null;\n try {\n await paypalHandlersRef.current.onPaypalApprove!(orderID);\n } catch (err) {\n // The checkout page already shows the capture error.\n console.warn('[ExpressCheckout] PayPal capture failed', err);\n }\n },\n onCancel: async () => {\n await cancelOpenOrder();\n },\n onError: (err) => {\n console.warn('[ExpressCheckout] PayPal error', err);\n // createOrder failures are already shown by the checkout page.\n if (openPaypalOrderRef.current) {\n setWalletError(formatMessage(messages.paypalError));\n cancelOpenOrder().catch(() => {});\n }\n },\n });\n if (!buttons.isEligible()) {\n console.warn('[ExpressCheckout] PayPal buttons not eligible', { currency });\n if (!cancelled) setPaypalSettled(true);\n return;\n }\n await buttons.render(mountNode);\n if (!cancelled) {\n setPaypalRendered(true);\n setPaypalSettled(true);\n }\n })\n .catch((err) => {\n console.warn('[ExpressCheckout] PayPal SDK unavailable', err);\n if (!cancelled) {\n setPaypalRendered(false);\n setPaypalSettled(true);\n }\n });\n\n return () => {\n cancelled = true;\n mountNode.innerHTML = '';\n setPaypalRendered(false);\n setPaypalSettled(false);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [paypalEnabled, paypalClientId, currency]);\n\n useEffect(() => {\n if (\n !stripe\n || !totalAmountCents\n || !currency\n || !appleMountRef.current\n || !googleMountRef.current\n ) {\n console.log('[ExpressCheckout] skip mount', {\n hasStripe: !!stripe,\n totalAmountCents,\n currency,\n hasAppleMount: !!appleMountRef.current,\n hasGoogleMount: !!googleMountRef.current,\n });\n setAppleReady(false);\n setGoogleReady(false);\n setAppleVisible(false);\n setGoogleVisible(false);\n setWalletError(null);\n return undefined;\n }\n\n console.log('[ExpressCheckout] mounting wallet slots', { totalAmountCents, currency });\n setAppleReady(false);\n setGoogleReady(false);\n setAppleVisible(false);\n setGoogleVisible(false);\n\n const sharedElementsOpts = {\n mode: 'payment' as const,\n amount: totalAmountCents,\n currency: currency.toLowerCase(),\n paymentMethodCreation: 'manual' as const,\n appearance: {\n variables: { borderRadius: '12px' },\n },\n };\n\n const bindWallet = (\n slot: WalletSlot,\n elements: StripeElementsLike,\n expressElement: StripeElementLike,\n mountNode: HTMLDivElement,\n setReady: (v: boolean) => void,\n setVisible: (v: boolean) => void,\n ) => {\n expressElement.on('ready', (event: ExpressCheckoutReadyEvent) => {\n const methods = event.availablePaymentMethods;\n const visible = slot === 'apple' ? !!methods?.applePay : !!methods?.googlePay;\n console.log(`[ExpressCheckout] ready (${slot})`, {\n applePay: !!methods?.applePay,\n googlePay: !!methods?.googlePay,\n raw: methods ?? null,\n });\n setVisible(visible);\n setReady(true);\n });\n\n // A wallet that fails to load counts as unavailable, so it can't hold the skeleton.\n expressElement.on('loaderror', (event: unknown) => {\n console.warn(`[ExpressCheckout] load error (${slot})`, event);\n setVisible(false);\n setReady(true);\n });\n\n expressElement.on('confirm', async (event: ExpressCheckoutConfirmEvent) => {\n setWalletError(null);\n if (!elements.submit) {\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n const walletLabel = formatMessage(\n slot === 'apple' ? messages.applePay : messages.googlePay,\n );\n\n let paymentMethodId: string;\n let walletCountry: string | undefined;\n try {\n const { error: submitError } = await elements.submit();\n if (submitError) {\n setWalletError(submitError.message || formatMessage(messages.walletUnavailable, {\n wallet: walletLabel,\n }));\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n const { paymentMethod, error } = await stripe.createPaymentMethod({ elements });\n if (error || !paymentMethod?.id) {\n setWalletError(error?.message || formatMessage(messages.walletUnavailable, {\n wallet: walletLabel,\n }));\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n paymentMethodId = paymentMethod.id;\n walletCountry = event.billingDetails?.address?.country\n || paymentMethod.billing_details?.address?.country;\n } catch (err) {\n console.warn(`[ExpressCheckout] wallet setup failed (${slot})`, err);\n setWalletError(formatMessage(messages.walletUnavailable, { wallet: walletLabel }));\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n try {\n await onPaymentAuthorizedRef.current(paymentMethodId, walletCountry);\n } catch (err) {\n // The wallet worked; the payment itself failed (e.g. card declined).\n // The checkout page already shows that error, so don't blame the wallet.\n console.warn(`[ExpressCheckout] payment failed (${slot})`, err);\n event.paymentFailed({ reason: 'fail' });\n }\n });\n\n expressElement.mount(mountNode);\n };\n\n const appleElements = stripe.elements(sharedElementsOpts);\n const googleElements = stripe.elements(sharedElementsOpts);\n appleElementsRef.current = appleElements;\n googleElementsRef.current = googleElements;\n\n const appleElement = appleElements.create('expressCheckout', {\n buttonHeight: 48,\n emailRequired: true,\n billingAddressRequired: true,\n paymentMethodOrder: ['applePay'],\n buttonType: { applePay: 'plain' },\n buttonTheme: { applePay: 'black' },\n paymentMethods: {\n applePay: 'always',\n googlePay: 'never',\n link: 'never',\n paypal: 'never',\n amazonPay: 'never',\n klarna: 'never',\n },\n layout: { maxColumns: 1, maxRows: 0, overflow: 'never' },\n });\n appleElementRef.current = appleElement;\n\n const googleElement = googleElements.create('expressCheckout', {\n buttonHeight: 48,\n emailRequired: true,\n billingAddressRequired: true,\n paymentMethodOrder: ['googlePay'],\n buttonType: { googlePay: 'plain' },\n buttonTheme: { googlePay: 'black' },\n paymentMethods: {\n applePay: 'never',\n googlePay: 'always',\n link: 'never',\n paypal: 'never',\n amazonPay: 'never',\n klarna: 'never',\n },\n layout: { maxColumns: 1, maxRows: 0, overflow: 'never' },\n });\n googleElementRef.current = googleElement;\n\n bindWallet(\n 'apple',\n appleElements,\n appleElement,\n appleMountRef.current,\n setAppleReady,\n setAppleVisible,\n );\n bindWallet(\n 'google',\n googleElements,\n googleElement,\n googleMountRef.current,\n setGoogleReady,\n setGoogleVisible,\n );\n\n return () => {\n try {\n appleElement.unmount?.();\n appleElement.destroy?.();\n googleElement.unmount?.();\n googleElement.destroy?.();\n } catch {\n // Elements may already be gone.\n }\n appleElementRef.current = null;\n googleElementRef.current = null;\n appleElementsRef.current = null;\n googleElementsRef.current = null;\n setAppleReady(false);\n setGoogleReady(false);\n setAppleVisible(false);\n setGoogleVisible(false);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [stripe, currency, hasAmount]);\n\n useEffect(() => {\n if (!totalAmountCents || !currency) return;\n const update = { amount: totalAmountCents, currency: currency.toLowerCase() };\n try {\n appleElementsRef.current?.update?.(update);\n googleElementsRef.current?.update?.(update);\n } catch {\n // Safe to ignore mid-sheet updates.\n }\n }, [totalAmountCents, currency]);\n\n const walletClassName = (ready: boolean, visible: boolean) => {\n const base = `express-checkout__wallet${disabled ? ' express-checkout__slot--disabled' : ''}`;\n if (!ready) return `${base} express-checkout__wallet--pending`;\n if (!visible) return `${base} express-checkout__wallet--unavailable`;\n return base;\n };\n\n return (\n <div\n className={`express-checkout${showSkeleton ? ' express-checkout--loading' : ''}`}\n role=\"group\"\n aria-labelledby=\"express-checkout-heading\"\n aria-busy={showSkeleton}\n >\n <h3 id=\"express-checkout-heading\" className=\"express-checkout__heading\">\n {formatMessage(messages.heading)}\n </h3>\n <div\n className=\"express-checkout__buttons\"\n style={{ gridTemplateColumns: `repeat(${columnCount}, minmax(0, 1fr))` }}\n >\n <div\n ref={paypalSlotRef}\n className={`express-checkout__paypal${paypalDisabled ? ' express-checkout__slot--disabled' : ''}`}\n >\n {/* PayPal SDK renders its button here; the wordmark stands in until it does. */}\n <div\n ref={paypalMountRef}\n className={paypalRendered ? undefined : 'express-checkout__paypal-mount--pending'}\n aria-label={formatMessage(messages.paypal)}\n />\n {!paypalRendered && (\n <button\n type=\"button\"\n disabled\n aria-label={formatMessage(messages.paypal)}\n className=\"express-checkout__button express-checkout__button--paypal\"\n >\n <PayPalWordmark />\n </button>\n )}\n </div>\n\n {/* Always in the DOM so remounts can find the nodes; CSS hides unavailable. */}\n <div\n ref={appleMountRef}\n className={walletClassName(appleReady, appleVisible)}\n aria-hidden={appleReady && !appleVisible}\n aria-label={formatMessage(messages.applePay)}\n />\n <div\n ref={googleMountRef}\n className={walletClassName(googleReady, googleVisible)}\n aria-hidden={googleReady && !googleVisible}\n aria-label={formatMessage(messages.googlePay)}\n />\n </div>\n {walletError && (\n <p className=\"express-checkout__error\" role=\"alert\">\n {walletError}\n </p>\n )}\n {/* One skeleton over the whole block; the slots stay mounted underneath so the SDKs can load. */}\n {showSkeleton && (\n <Skeleton containerClassName=\"express-checkout__skeleton\" height=\"100%\" borderRadius={8} inline />\n )}\n </div>\n );\n};\n\nexport default ExpressCheckout;\n"]}
1
+ {"version":3,"file":"ExpressCheckout.js","sourceRoot":"","sources":["../../../src/components/ExpressCheckout/ExpressCheckout.tsx"],"names":[],"mappings":";;;;;;;;;;AAAA,OAAc,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,MAAM,wBAAwB,CAAC;AACjD,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAS5C,OAAO,EAAE,cAAc,EAAE,MAAM,0BAA0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IAAI,CAAC,aAAa,gBAC9B,aAAa,CAAC,QAAQ,CAAC,SAAS,CAAC,GAC7C,IACE,EACL,WAAW,IAAI,CACd,YAAG,SAAS,EAAC,yBAAyB,EAAC,IAAI,EAAC,OAAO,YAChD,WAAW,GACV,CACL,EAEA,YAAY,IAAI,CACf,KAAC,QAAQ,IAAC,kBAAkB,EAAC,4BAA4B,EAAC,MAAM,EAAC,MAAM,EAAC,YAAY,EAAE,CAAC,EAAE,MAAM,SAAG,CACnG,IACG,CACP,CAAC;AACJ,CAAC,CAAC;AAEF,eAAe,eAAe,CAAC","sourcesContent":["import React, { useEffect, useRef, useState } from 'react';\nimport { useIntl } from '@openedx/frontend-base';\nimport { Skeleton } from '@openedx/paragon';\nimport type {\n ExpressCheckoutAvailablePaymentMethodsChangeEvent,\n ExpressCheckoutConfirmEvent,\n ExpressCheckoutReadyEvent,\n StripeElementsLike,\n StripeElementLike,\n StripeLike,\n} from '../../types';\nimport { PayPalWordmark } from '../BrandMarks/BrandMarks';\nimport { useInert } from '../../utils/inert';\nimport { loadPaypal } from '../../utils/paypal';\nimport messages from './Messages';\n\nexport interface ExpressCheckoutProps {\n /** Stripe.js instance — null until loaded. */\n stripe: StripeLike | null,\n /** Total amount in the smallest currency unit (cents). */\n totalAmountCents: number | null,\n /** ISO 4217 currency code, e.g. 'USD'. */\n currency: string | null,\n /** Two-letter country code (kept for API stability). */\n country: string,\n /**\n * Called when the user authorises a wallet payment (Apple Pay / Google Pay).\n * Receives the Stripe PaymentMethod id and the billing country from the wallet.\n * Must resolve on success or reject on failure.\n */\n onPaymentAuthorized: (paymentMethodId: string, walletCountry?: string) => Promise<void>,\n /** PayPal JS SDK client id — PayPal stays disabled without it. */\n paypalClientId?: string | null,\n /** PayPal `createOrder`: places the order with PayPal and resolves its id. */\n onPaypalCreateOrder?: () => Promise<string>,\n /** PayPal `onApprove`: captures the approved PayPal order. */\n onPaypalApprove?: (paypalOrderId: string) => Promise<void>,\n /** PayPal `onCancel` / `onError`: abandons the unapproved PayPal order. */\n onPaypalCancel?: (paypalOrderId: string) => Promise<void>,\n /** Disables the Apple Pay / Google Pay slots. */\n disabled?: boolean,\n /** Disables the PayPal slot — PayPal doesn't need Stripe, so it has its own flag. */\n paypalDisabled?: boolean,\n}\n\ntype WalletSlot = 'apple' | 'google';\n\n// Shows the block anyway if an SDK never settles (blocked script, Stripe never loads).\nexport const SKELETON_MAX_MS = 10000;\n\n/**\n * Express checkout: PayPal (local) | Apple Pay | Google Pay.\n *\n * Apple and Google each get their own Express Checkout Element (one wallet per\n * mount) so we can lay them out in equal columns. A single ECE with both wallets\n * stacks / overflows in this narrow column. `always` keeps the Shopify-like\n * show-even-without-a-saved-card behaviour.\n */\nconst ExpressCheckout: React.FC<ExpressCheckoutProps> = ({\n stripe,\n totalAmountCents,\n currency,\n onPaymentAuthorized,\n paypalClientId,\n onPaypalCreateOrder,\n onPaypalApprove,\n onPaypalCancel,\n disabled,\n paypalDisabled,\n}) => {\n const { formatMessage } = useIntl();\n const appleMountRef = useRef<HTMLDivElement | null>(null);\n const googleMountRef = useRef<HTMLDivElement | null>(null);\n const appleElementsRef = useRef<StripeElementsLike | null>(null);\n const googleElementsRef = useRef<StripeElementsLike | null>(null);\n const appleElementRef = useRef<StripeElementLike | null>(null);\n const googleElementRef = useRef<StripeElementLike | null>(null);\n const onPaymentAuthorizedRef = useRef(onPaymentAuthorized);\n const paypalMountRef = useRef<HTMLDivElement | null>(null);\n // The disabled class only blocks the pointer — inert drops the slot's\n // iframe from the tab order too.\n const paypalSlotRef = useInert<HTMLDivElement>(!!paypalDisabled);\n const paypalHandlersRef = useRef({ onPaypalCreateOrder, onPaypalApprove, onPaypalCancel });\n // PayPal order created but not yet approved — cancelled if the buttons error out.\n const openPaypalOrderRef = useRef<string | null>(null);\n\n const [appleReady, setAppleReady] = useState(false);\n const [googleReady, setGoogleReady] = useState(false);\n const [appleVisible, setAppleVisible] = useState(false);\n const [googleVisible, setGoogleVisible] = useState(false);\n const [walletError, setWalletError] = useState<string | null>(null);\n const [paypalRendered, setPaypalRendered] = useState(false);\n // PayPal finished: rendered, ineligible, failed, or never possible (no client id).\n const [paypalSettled, setPaypalSettled] = useState(false);\n // Latched so later remounts (currency change) don't bring the skeleton back.\n const [loaded, setLoaded] = useState(false);\n\n const hasAmount = !!totalAmountCents && !!currency;\n const paypalEnabled = !!paypalClientId && hasAmount && !!onPaypalCreateOrder && !!onPaypalApprove;\n // Keep slots in the grid until ready so Stripe measures a full column width.\n const showAppleSlot = !appleReady || appleVisible;\n const showGoogleSlot = !googleReady || googleVisible;\n const columnCount = 1 + (showAppleSlot ? 1 : 0) + (showGoogleSlot ? 1 : 0);\n const allSettled = paypalSettled && appleReady && googleReady;\n const showSkeleton = !loaded && !allSettled;\n\n useEffect(() => {\n if (allSettled) setLoaded(true);\n }, [allSettled]);\n\n useEffect(() => {\n const timer = setTimeout(() => setLoaded(true), SKELETON_MAX_MS);\n return () => clearTimeout(timer);\n }, []);\n\n useEffect(() => {\n onPaymentAuthorizedRef.current = onPaymentAuthorized;\n }, [onPaymentAuthorized]);\n\n // Wallet hosts keep object refs for remounts, so toggle inert here instead.\n useEffect(() => {\n appleMountRef.current?.toggleAttribute('inert', !!disabled);\n googleMountRef.current?.toggleAttribute('inert', !!disabled);\n }, [disabled]);\n\n useEffect(() => {\n paypalHandlersRef.current = { onPaypalCreateOrder, onPaypalApprove, onPaypalCancel };\n }, [onPaypalCreateOrder, onPaypalApprove, onPaypalCancel]);\n\n // PayPal buttons: tCheckoutPlaceOrder(PAYPAL) on click, capture on approve,\n // cancel when the learner closes the PayPal window.\n useEffect(() => {\n const mountNode = paypalMountRef.current;\n if (!paypalEnabled || !paypalClientId || !currency || !mountNode) {\n console.log('[ExpressCheckout] PayPal disabled', {\n hasClientId: !!paypalClientId,\n hasAmount,\n hasCreateOrder: !!onPaypalCreateOrder,\n hasApprove: !!onPaypalApprove,\n });\n setPaypalRendered(false);\n // Without a client id PayPal can never render — don't wait for it.\n setPaypalSettled(!paypalClientId);\n return undefined;\n }\n\n let cancelled = false;\n const cancelOpenOrder = async () => {\n const orderId = openPaypalOrderRef.current;\n openPaypalOrderRef.current = null;\n if (orderId) await paypalHandlersRef.current.onPaypalCancel?.(orderId);\n };\n\n loadPaypal(paypalClientId, currency)\n .then(async (paypal) => {\n if (cancelled) return;\n const buttons = paypal.Buttons({\n fundingSource: paypal.FUNDING.PAYPAL,\n style: {\n layout: 'horizontal',\n color: 'gold',\n shape: 'rect',\n label: 'paypal',\n height: 48,\n // Matches the Stripe wallets' `borderRadius: '12px'` appearance.\n borderRadius: 12,\n tagline: false,\n },\n createOrder: async () => {\n setWalletError(null);\n const orderId = await paypalHandlersRef.current.onPaypalCreateOrder!();\n openPaypalOrderRef.current = orderId;\n return orderId;\n },\n onApprove: async ({ orderID }) => {\n openPaypalOrderRef.current = null;\n try {\n await paypalHandlersRef.current.onPaypalApprove!(orderID);\n } catch (err) {\n // The checkout page already shows the capture error.\n console.warn('[ExpressCheckout] PayPal capture failed', err);\n }\n },\n onCancel: async () => {\n await cancelOpenOrder();\n },\n onError: (err) => {\n console.warn('[ExpressCheckout] PayPal error', err);\n // createOrder failures are already shown by the checkout page.\n if (openPaypalOrderRef.current) {\n setWalletError(formatMessage(messages.paypalError));\n cancelOpenOrder().catch(() => {});\n }\n },\n });\n if (!buttons.isEligible()) {\n console.warn('[ExpressCheckout] PayPal buttons not eligible', { currency });\n if (!cancelled) setPaypalSettled(true);\n return;\n }\n await buttons.render(mountNode);\n if (!cancelled) {\n setPaypalRendered(true);\n setPaypalSettled(true);\n }\n })\n .catch((err) => {\n console.warn('[ExpressCheckout] PayPal SDK unavailable', err);\n if (!cancelled) {\n setPaypalRendered(false);\n setPaypalSettled(true);\n }\n });\n\n return () => {\n cancelled = true;\n mountNode.innerHTML = '';\n setPaypalRendered(false);\n setPaypalSettled(false);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [paypalEnabled, paypalClientId, currency]);\n\n useEffect(() => {\n if (\n !stripe\n || !totalAmountCents\n || !currency\n || !appleMountRef.current\n || !googleMountRef.current\n ) {\n console.log('[ExpressCheckout] skip mount', {\n hasStripe: !!stripe,\n totalAmountCents,\n currency,\n hasAppleMount: !!appleMountRef.current,\n hasGoogleMount: !!googleMountRef.current,\n });\n setAppleReady(false);\n setGoogleReady(false);\n setAppleVisible(false);\n setGoogleVisible(false);\n setWalletError(null);\n return undefined;\n }\n\n console.log('[ExpressCheckout] mounting wallet slots', { totalAmountCents, currency });\n setAppleReady(false);\n setGoogleReady(false);\n setAppleVisible(false);\n setGoogleVisible(false);\n\n const sharedElementsOpts = {\n mode: 'payment' as const,\n amount: totalAmountCents,\n currency: currency.toLowerCase(),\n paymentMethodCreation: 'manual' as const,\n appearance: {\n variables: { borderRadius: '12px' },\n },\n };\n\n const bindWallet = (\n slot: WalletSlot,\n elements: StripeElementsLike,\n expressElement: StripeElementLike,\n mountNode: HTMLDivElement,\n setReady: (v: boolean) => void,\n setVisible: (v: boolean) => void,\n ) => {\n // Availability comes from `availablepaymentmethodschange`: it fires on initial\n // render and again if it changes later (iOS checks Apple Pay asynchronously,\n // so a one-shot read on `ready` could hide the button for good).\n let availabilityReported = false;\n expressElement.on(\n 'availablepaymentmethodschange',\n (event: ExpressCheckoutAvailablePaymentMethodsChangeEvent) => {\n const methods = event.paymentMethods;\n const visible = !!(slot === 'apple' ? methods?.applePay : methods?.googlePay)?.available;\n console.log(`[ExpressCheckout] available payment methods (${slot})`, {\n visible,\n raw: methods ?? null,\n });\n availabilityReported = true;\n setVisible(visible);\n setReady(true);\n },\n );\n\n // Fallback for the deprecated `ready` payload, only while the change event\n // hasn't reported. A negative answer here may be stale, so it's ignored.\n expressElement.on('ready', (event: ExpressCheckoutReadyEvent) => {\n const methods = event.availablePaymentMethods;\n const visible = slot === 'apple' ? !!methods?.applePay : !!methods?.googlePay;\n console.log(`[ExpressCheckout] ready (${slot})`, { visible, raw: methods ?? null });\n if (availabilityReported || !visible) return;\n setVisible(true);\n setReady(true);\n });\n\n // A wallet that fails to load counts as unavailable, so it can't hold the skeleton.\n expressElement.on('loaderror', (event: unknown) => {\n console.warn(`[ExpressCheckout] load error (${slot})`, event);\n setVisible(false);\n setReady(true);\n });\n\n expressElement.on('confirm', async (event: ExpressCheckoutConfirmEvent) => {\n setWalletError(null);\n if (!elements.submit) {\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n const walletLabel = formatMessage(\n slot === 'apple' ? messages.applePay : messages.googlePay,\n );\n\n let paymentMethodId: string;\n let walletCountry: string | undefined;\n try {\n const { error: submitError } = await elements.submit();\n if (submitError) {\n setWalletError(submitError.message || formatMessage(messages.walletUnavailable, {\n wallet: walletLabel,\n }));\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n const { paymentMethod, error } = await stripe.createPaymentMethod({ elements });\n if (error || !paymentMethod?.id) {\n setWalletError(error?.message || formatMessage(messages.walletUnavailable, {\n wallet: walletLabel,\n }));\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n paymentMethodId = paymentMethod.id;\n walletCountry = event.billingDetails?.address?.country\n || paymentMethod.billing_details?.address?.country;\n } catch (err) {\n console.warn(`[ExpressCheckout] wallet setup failed (${slot})`, err);\n setWalletError(formatMessage(messages.walletUnavailable, { wallet: walletLabel }));\n event.paymentFailed({ reason: 'fail' });\n return;\n }\n\n try {\n await onPaymentAuthorizedRef.current(paymentMethodId, walletCountry);\n } catch (err) {\n // The wallet worked; the payment itself failed (e.g. card declined).\n // The checkout page already shows that error, so don't blame the wallet.\n console.warn(`[ExpressCheckout] payment failed (${slot})`, err);\n event.paymentFailed({ reason: 'fail' });\n }\n });\n\n expressElement.mount(mountNode);\n };\n\n const appleElements = stripe.elements(sharedElementsOpts);\n const googleElements = stripe.elements(sharedElementsOpts);\n appleElementsRef.current = appleElements;\n googleElementsRef.current = googleElements;\n\n const appleElement = appleElements.create('expressCheckout', {\n buttonHeight: 48,\n emailRequired: true,\n billingAddressRequired: true,\n paymentMethodOrder: ['applePay'],\n buttonType: { applePay: 'plain' },\n buttonTheme: { applePay: 'black' },\n paymentMethods: {\n applePay: 'always',\n googlePay: 'never',\n link: 'never',\n paypal: 'never',\n amazonPay: 'never',\n klarna: 'never',\n },\n layout: { maxColumns: 1, maxRows: 0, overflow: 'never' },\n });\n appleElementRef.current = appleElement;\n\n const googleElement = googleElements.create('expressCheckout', {\n buttonHeight: 48,\n emailRequired: true,\n billingAddressRequired: true,\n paymentMethodOrder: ['googlePay'],\n buttonType: { googlePay: 'plain' },\n buttonTheme: { googlePay: 'black' },\n paymentMethods: {\n applePay: 'never',\n googlePay: 'always',\n link: 'never',\n paypal: 'never',\n amazonPay: 'never',\n klarna: 'never',\n },\n layout: { maxColumns: 1, maxRows: 0, overflow: 'never' },\n });\n googleElementRef.current = googleElement;\n\n bindWallet(\n 'apple',\n appleElements,\n appleElement,\n appleMountRef.current,\n setAppleReady,\n setAppleVisible,\n );\n bindWallet(\n 'google',\n googleElements,\n googleElement,\n googleMountRef.current,\n setGoogleReady,\n setGoogleVisible,\n );\n\n return () => {\n try {\n appleElement.unmount?.();\n appleElement.destroy?.();\n googleElement.unmount?.();\n googleElement.destroy?.();\n } catch {\n // Elements may already be gone.\n }\n appleElementRef.current = null;\n googleElementRef.current = null;\n appleElementsRef.current = null;\n googleElementsRef.current = null;\n setAppleReady(false);\n setGoogleReady(false);\n setAppleVisible(false);\n setGoogleVisible(false);\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [stripe, currency, hasAmount]);\n\n useEffect(() => {\n if (!totalAmountCents || !currency) return;\n const update = { amount: totalAmountCents, currency: currency.toLowerCase() };\n try {\n appleElementsRef.current?.update?.(update);\n googleElementsRef.current?.update?.(update);\n } catch {\n // Safe to ignore mid-sheet updates.\n }\n }, [totalAmountCents, currency]);\n\n const walletClassName = (ready: boolean, visible: boolean) => {\n const base = `express-checkout__wallet${disabled ? ' express-checkout__slot--disabled' : ''}`;\n if (!ready) return `${base} express-checkout__wallet--pending`;\n if (!visible) return `${base} express-checkout__wallet--unavailable`;\n return base;\n };\n\n return (\n <div\n className={`express-checkout${showSkeleton ? ' express-checkout--loading' : ''}`}\n role=\"group\"\n aria-labelledby=\"express-checkout-heading\"\n aria-busy={showSkeleton}\n >\n <h3 id=\"express-checkout-heading\" className=\"express-checkout__heading\">\n {formatMessage(messages.heading)}\n </h3>\n <div\n className=\"express-checkout__buttons\"\n style={{ gridTemplateColumns: `repeat(${columnCount}, minmax(0, 1fr))` }}\n >\n <div\n ref={paypalSlotRef}\n className={`express-checkout__paypal${paypalDisabled ? ' express-checkout__slot--disabled' : ''}`}\n >\n {/* PayPal SDK renders its button here; the wordmark stands in until it does. */}\n <div\n ref={paypalMountRef}\n className={paypalRendered ? undefined : 'express-checkout__paypal-mount--pending'}\n aria-label={formatMessage(messages.paypal)}\n />\n {!paypalRendered && (\n <button\n type=\"button\"\n disabled\n aria-label={formatMessage(messages.paypal)}\n className=\"express-checkout__button express-checkout__button--paypal\"\n >\n <PayPalWordmark />\n </button>\n )}\n </div>\n\n {/* Always in the DOM so remounts can find the nodes; CSS hides unavailable. */}\n <div\n ref={appleMountRef}\n className={walletClassName(appleReady, appleVisible)}\n aria-hidden={appleReady && !appleVisible}\n aria-label={formatMessage(messages.applePay)}\n />\n <div\n ref={googleMountRef}\n className={walletClassName(googleReady, googleVisible)}\n aria-hidden={googleReady && !googleVisible}\n aria-label={formatMessage(messages.googlePay)}\n />\n </div>\n {walletError && (\n <p className=\"express-checkout__error\" role=\"alert\">\n {walletError}\n </p>\n )}\n {/* One skeleton over the whole block; the slots stay mounted underneath so the SDKs can load. */}\n {showSkeleton && (\n <Skeleton containerClassName=\"express-checkout__skeleton\" height=\"100%\" borderRadius={8} inline />\n )}\n </div>\n );\n};\n\nexport default ExpressCheckout;\n"]}
@@ -7,8 +7,11 @@
7
7
  padding: 1.25rem 1rem;
8
8
 
9
9
  // Slots keep their layout (Stripe/PayPal measure them) but stay hidden under the skeleton.
10
+ // Opacity, not visibility: descendants (the SDK-injected iframes) can opt back into
11
+ // `visibility: visible` and pop through one by one; nothing undoes an ancestor's opacity.
10
12
  &--loading > :not(.express-checkout__skeleton) {
11
- visibility: hidden;
13
+ opacity: 0;
14
+ pointer-events: none;
12
15
  }
13
16
 
14
17
  // Covers the whole card, border included.
package/dist/types.d.ts CHANGED
@@ -308,12 +308,28 @@ export interface ExpressCheckoutConfirmEvent {
308
308
  }) => void;
309
309
  }
310
310
  export interface ExpressCheckoutReadyEvent {
311
+ /** Deprecated by Stripe — prefer `availablepaymentmethodschange`. */
311
312
  availablePaymentMethods?: {
312
313
  applePay?: boolean;
313
314
  googlePay?: boolean;
314
315
  link?: boolean;
315
316
  } | undefined;
316
317
  }
318
+ /** Fires on initial render and whenever wallet availability changes after load. */
319
+ export interface ExpressCheckoutAvailablePaymentMethodsChangeEvent {
320
+ /** `undefined` when no buttons will render. */
321
+ paymentMethods?: {
322
+ applePay?: {
323
+ available: boolean;
324
+ };
325
+ googlePay?: {
326
+ available: boolean;
327
+ };
328
+ link?: {
329
+ available: boolean;
330
+ };
331
+ } | undefined;
332
+ }
317
333
  export interface StripeLike {
318
334
  elements: (options?: StripeElementsOptions) => StripeElementsLike;
319
335
  createPaymentMethod: (params: CreatePaymentMethodParams) => Promise<PaymentMethodResult>;
package/dist/types.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Status, Phase } from './constants';\n\nexport type { Status, Phase };\n\n// --- Bootstrap domain --------------------------------------------------------\nexport interface TwouCustomerContact {\n email?: string,\n}\n\nexport interface TwouCustomerParty {\n paName: string,\n indFirstName?: string,\n indLastName?: string,\n paContacts: { edges: { node: TwouCustomerContact }[] },\n}\n\nexport interface TwouCustomer {\n uid: string,\n parId: string,\n parParty: TwouCustomerParty,\n}\n\nexport type GqlRunner = (query: string, variables?: Record<string, unknown>, retry?: boolean) => Promise<any>;\n\n// --- Cart domain -------------------------------------------------------------\nexport interface Cart {\n biId: string,\n uid: string,\n}\n\nexport interface CartIds {\n customerUid: string,\n salableUid: string,\n billingPlanUid: string,\n}\n\nexport type BillingCycle = 'monthly' | 'annual';\n\nexport type PaymentMethod = 'card' | 'googlepay' | 'paypal';\n\nexport type SupportedPaymentMethod = Exclude<PaymentMethod, 'googlepay'>;\n\nexport type BillingPeriod = 'MONTHLY' | 'ANNUAL' | 'QUARTERLY' | string;\n\nexport interface BillingPlanOwnershipModel {\n uid: string,\n omName: string,\n}\n\nexport interface BillingPlan {\n uid: string,\n stripePriceId: string,\n /** Price amount e.g. \"39.99\" */\n amount: string,\n /** Currency code e.g. \"USD\" */\n currency: string,\n isTemplate: boolean,\n ownershipModel: BillingPlanOwnershipModel,\n}\n\nexport interface SubscriptionDetails {\n biId: string, // \"BI301ZDAD6CMICG2\"\n trialStart: string | null,\n trialEnd: string | null,\n renewalType: string | null, // \"Annual\" | \"Monthly\"\n cardLast4: string | null, // \"4242\"\n cardBrand: string | null, // \"visa\" | \"mastercard\" etc\n stripePaymentMethodId: string | null,\n planName: string | null, // \"Monthly Subscription\"\n}\n\nexport interface CurrentUserSubscriberResult {\n isSubscriber: boolean,\n subscriptionBiId: string | null,\n status: string | null,\n subscriptionStartDate: string | null,\n currentPeriodEnd: string | null,\n}\n\n/** Course shown on checkout / post-checkout when arriving via ?course_run_key=. */\nexport interface CourseDetail {\n maId: string,\n maName: string,\n maDescription: string | null,\n tShortDescription: string | null,\n imageUrl: string | null,\n tCourseKey: string | null,\n tBrandText: string | null,\n tPrimarySubjectArea: string | null,\n tLevelType: string | null,\n tLanguage: string | null,\n tPacingType: string | null,\n tDurationLow: number | null,\n tDurationHigh: number | null,\n tDurationUnit: string | null,\n tEffortLow: number | null,\n tEffortHigh: number | null,\n tEffortUnit: string | null,\n tUrlCourse: string | null,\n tB2cSubscriptionInclusion: boolean | null,\n tHasOfacRestrictions: boolean | null,\n tCatalogActive: boolean | null,\n /** How many learners are enrolled in this course — real per-course count, not the\n * platform-wide subscription figure. */\n tEnrollmentCount: number | null,\n}\n\n/** Returned by legacy subscription billing lookups (unused by à la carte). */\nexport interface BillingPlansResult {\n plans: BillingPlan[],\n}\n\n/** Returned by getSalableUid — the product uid and its ownership models. */\nexport interface ProductInfo {\n uid: string,\n maName: string,\n ownershipModels: { uid: string, omName: string }[],\n}\n\nexport interface CartStatusResult {\n status: Status | null,\n stripeSubscriptionId: string | null,\n /** Stripe-hosted challenge URL for the checkout confirmation step. */\n stripeConfirmationRedirectUrl: string | null,\n /** PayPal-hosted approval URL for the same checkout confirmation step. */\n paypalApprovalUrl: string | null,\n lastComment: string,\n}\n\nexport interface CartBillingAddress {\n tFirstName: string,\n tLastName: string,\n upaLine1: string,\n upaCity: string,\n upaPostcode: string,\n gadStateOrProvince: string,\n gadCountry: { iso2Code: string },\n}\n\nexport interface UpdateCartItemArgs {\n cartItemUid: string,\n billingAddress?: CartBillingAddress,\n paymentMethodId?: string,\n /** Payer email attached when the payment type is TwouPaypalPayment. */\n paypalEmail?: string | null,\n}\n\n/** Auto-renewal consent captured on TwouCart at checkout confirmation (SUBS-228). */\nexport interface CheckoutConsent {\n /** Main auto-renewal checkbox — always required at submit. */\n tConsentRecurring: boolean,\n /** UK/CA resident checkbox; null when that checkbox is not shown. */\n tConsentUkCa: boolean | null,\n /** ISO-8601 timestamp when consent was captured. */\n tConsentAt: string,\n /** Exact disclosure text shown to the learner (audit trail). */\n tConsentText: string,\n}\n\nexport interface UpdateCartConsentArgs {\n cartUid: string,\n consent: CheckoutConsent,\n /** Absolute checkout return URL stored in the backend's tStripeReturnUrl field. */\n returnUrl?: string | null,\n}\n\nexport interface BillingInfo {\n firstName: string,\n lastName: string,\n city: string,\n zip: string,\n country: string,\n line1: string,\n state: string,\n}\n\n// --- Checkout client surface -------------------------------------------------\nexport interface CheckoutClient {\n gql: GqlRunner,\n setToken: (token: string) => void,\n createCart: (vars: CartIds) => Promise<Cart>,\n getCartItem: (biId: string) => Promise<{ cartUid: string, cartItemUid: string }>,\n updateCartItem: (args: UpdateCartItemArgs) => Promise<void>,\n updateCartConsent: (args: UpdateCartConsentArgs) => Promise<void>,\n placeOrder: (cartUid: string) => Promise<unknown>,\n getCartStatus: (biId: string) => Promise<CartStatusResult>,\n findSubscriptionBiId: (biId: string) => Promise<SubscriptionDetails | null>,\n getSalableUid: (maId: string) => Promise<ProductInfo>,\n isCurrentUserSubscriber: () => Promise<CurrentUserSubscriberResult | null>,\n getCourseDetail: (courseKey: string) => Promise<CourseDetail | null>,\n}\n\nexport interface DevAuth {\n iamUrl: string,\n clientId: string,\n clientSecret: string,\n}\n\n// --- Minimal Stripe.js types -------------------------------------------------\n// Just the surface this module uses. If you depend on `@stripe/stripe-js`,\n// you can replace these with its richer types.\nexport interface StripeElementChangeEvent {\n empty?: boolean,\n complete?: boolean,\n error?: { message?: string, code?: string },\n [key: string]: unknown,\n}\n\nexport interface CardFieldState {\n empty: boolean,\n complete: boolean,\n /** Stripe validation error message (e.g. \"Your card number is invalid.\"), empty string if no error. */\n error: string,\n /** True once the element has been blurred at least once. */\n blurred: boolean,\n /** True while the element's input has focus. */\n focused?: boolean,\n /** Card network Stripe detected from the number (e.g. 'visa'); card number only. */\n brand?: string,\n}\n\nexport interface CardFieldStates {\n number: CardFieldState,\n expiry: CardFieldState,\n cvc: CardFieldState,\n}\n\n// --- Stripe Payment Request (Apple Pay / Google Pay) -------------------------\nexport interface PaymentRequestPaymentMethodEvent {\n paymentMethod: {\n id: string,\n billing_details?: {\n address?: { country?: string },\n name?: string,\n email?: string,\n },\n },\n complete: (status: 'success' | 'fail') => void,\n}\n\nexport interface PaymentRequestCanMakePaymentResult {\n applePay?: boolean,\n googlePay?: boolean,\n link?: boolean,\n}\n\nexport interface PaymentRequestLike {\n canMakePayment: () => Promise<PaymentRequestCanMakePaymentResult | null>,\n on: (event: string, handler: (ev: PaymentRequestPaymentMethodEvent) => void) => void,\n show: () => void | Promise<void>,\n update: (details: { total: { label: string, amount: number } }) => void,\n}\n\nexport interface StripeElementLike {\n mount: (node: HTMLElement) => void,\n on: (event: string, handler: (...args: any[]) => void) => void,\n unmount?: () => void,\n destroy?: () => void,\n focus?: () => void,\n}\n\nexport interface StripeElementsOptions {\n mode?: 'payment' | 'setup' | 'subscription',\n amount?: number,\n currency?: string,\n /** Lets Express Checkout Element yield a PaymentMethod for our place-order flow. */\n paymentMethodCreation?: 'manual',\n}\n\nexport interface StripeElementsLike {\n create: (type: string, options?: Record<string, unknown>) => StripeElementLike,\n submit?: () => Promise<{ error?: StripeError }>,\n update?: (options: { amount?: number, currency?: string }) => void,\n}\n\nexport interface StripeError {\n message?: string,\n code?: string,\n /** Stripe.js error category, e.g. 'card_error' or 'api_connection_error'. */\n type?: string,\n}\n\nexport interface PaymentMethodResult {\n paymentMethod?: {\n id: string,\n billing_details?: {\n address?: { country?: string },\n name?: string,\n email?: string,\n },\n },\n error?: StripeError,\n}\n\nexport interface ConfirmResult {\n error?: StripeError,\n setupIntent?: unknown,\n paymentIntent?: unknown,\n}\n\nexport type CreatePaymentMethodParams =\n | {\n type: 'card',\n card: StripeElementLike,\n billing_details?: Record<string, unknown>,\n }\n | {\n elements: StripeElementsLike,\n };\n\nexport interface ConfirmCardPaymentData {\n payment_method?:\n | {\n card: StripeElementLike,\n billing_details?: Record<string, unknown>,\n }\n | string,\n}\n\nexport interface ExpressCheckoutConfirmEvent {\n expressPaymentType?: string,\n billingDetails?: {\n address?: { country?: string },\n name?: string,\n email?: string,\n },\n paymentFailed: (opts?: { reason?: string }) => void,\n}\n\nexport interface ExpressCheckoutReadyEvent {\n availablePaymentMethods?: {\n applePay?: boolean,\n googlePay?: boolean,\n link?: boolean,\n } | undefined,\n}\n\nexport interface StripeLike {\n elements: (options?: StripeElementsOptions) => StripeElementsLike,\n createPaymentMethod: (params: CreatePaymentMethodParams) => Promise<PaymentMethodResult>,\n confirmCardSetup: (clientSecret: string) => Promise<ConfirmResult>,\n confirmCardPayment: (\n clientSecret: string,\n data?: ConfirmCardPaymentData,\n ) => Promise<ConfirmResult>,\n paymentRequest: (options: {\n country: string,\n currency: string,\n total: { label: string, amount: number },\n requestPayerName?: boolean,\n requestPayerEmail?: boolean,\n disableWallets?: ('link' | 'applePay' | 'googlePay' | 'browserCard')[],\n }) => PaymentRequestLike,\n}\n\ndeclare global {\n interface Window {\n Stripe?: (publishableKey: string) => StripeLike,\n }\n}\n\nexport interface TrialDateRange {\n /** e.g. \"June 22, 2026\" */\n displayStart: string,\n /** e.g. \"June 29, 2026\" */\n displayEnd: string,\n}\n"]}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"","sourcesContent":["import type { Status, Phase } from './constants';\n\nexport type { Status, Phase };\n\n// --- Bootstrap domain --------------------------------------------------------\nexport interface TwouCustomerContact {\n email?: string,\n}\n\nexport interface TwouCustomerParty {\n paName: string,\n indFirstName?: string,\n indLastName?: string,\n paContacts: { edges: { node: TwouCustomerContact }[] },\n}\n\nexport interface TwouCustomer {\n uid: string,\n parId: string,\n parParty: TwouCustomerParty,\n}\n\nexport type GqlRunner = (query: string, variables?: Record<string, unknown>, retry?: boolean) => Promise<any>;\n\n// --- Cart domain -------------------------------------------------------------\nexport interface Cart {\n biId: string,\n uid: string,\n}\n\nexport interface CartIds {\n customerUid: string,\n salableUid: string,\n billingPlanUid: string,\n}\n\nexport type BillingCycle = 'monthly' | 'annual';\n\nexport type PaymentMethod = 'card' | 'googlepay' | 'paypal';\n\nexport type SupportedPaymentMethod = Exclude<PaymentMethod, 'googlepay'>;\n\nexport type BillingPeriod = 'MONTHLY' | 'ANNUAL' | 'QUARTERLY' | string;\n\nexport interface BillingPlanOwnershipModel {\n uid: string,\n omName: string,\n}\n\nexport interface BillingPlan {\n uid: string,\n stripePriceId: string,\n /** Price amount e.g. \"39.99\" */\n amount: string,\n /** Currency code e.g. \"USD\" */\n currency: string,\n isTemplate: boolean,\n ownershipModel: BillingPlanOwnershipModel,\n}\n\nexport interface SubscriptionDetails {\n biId: string, // \"BI301ZDAD6CMICG2\"\n trialStart: string | null,\n trialEnd: string | null,\n renewalType: string | null, // \"Annual\" | \"Monthly\"\n cardLast4: string | null, // \"4242\"\n cardBrand: string | null, // \"visa\" | \"mastercard\" etc\n stripePaymentMethodId: string | null,\n planName: string | null, // \"Monthly Subscription\"\n}\n\nexport interface CurrentUserSubscriberResult {\n isSubscriber: boolean,\n subscriptionBiId: string | null,\n status: string | null,\n subscriptionStartDate: string | null,\n currentPeriodEnd: string | null,\n}\n\n/** Course shown on checkout / post-checkout when arriving via ?course_run_key=. */\nexport interface CourseDetail {\n maId: string,\n maName: string,\n maDescription: string | null,\n tShortDescription: string | null,\n imageUrl: string | null,\n tCourseKey: string | null,\n tBrandText: string | null,\n tPrimarySubjectArea: string | null,\n tLevelType: string | null,\n tLanguage: string | null,\n tPacingType: string | null,\n tDurationLow: number | null,\n tDurationHigh: number | null,\n tDurationUnit: string | null,\n tEffortLow: number | null,\n tEffortHigh: number | null,\n tEffortUnit: string | null,\n tUrlCourse: string | null,\n tB2cSubscriptionInclusion: boolean | null,\n tHasOfacRestrictions: boolean | null,\n tCatalogActive: boolean | null,\n /** How many learners are enrolled in this course — real per-course count, not the\n * platform-wide subscription figure. */\n tEnrollmentCount: number | null,\n}\n\n/** Returned by legacy subscription billing lookups (unused by à la carte). */\nexport interface BillingPlansResult {\n plans: BillingPlan[],\n}\n\n/** Returned by getSalableUid — the product uid and its ownership models. */\nexport interface ProductInfo {\n uid: string,\n maName: string,\n ownershipModels: { uid: string, omName: string }[],\n}\n\nexport interface CartStatusResult {\n status: Status | null,\n stripeSubscriptionId: string | null,\n /** Stripe-hosted challenge URL for the checkout confirmation step. */\n stripeConfirmationRedirectUrl: string | null,\n /** PayPal-hosted approval URL for the same checkout confirmation step. */\n paypalApprovalUrl: string | null,\n lastComment: string,\n}\n\nexport interface CartBillingAddress {\n tFirstName: string,\n tLastName: string,\n upaLine1: string,\n upaCity: string,\n upaPostcode: string,\n gadStateOrProvince: string,\n gadCountry: { iso2Code: string },\n}\n\nexport interface UpdateCartItemArgs {\n cartItemUid: string,\n billingAddress?: CartBillingAddress,\n paymentMethodId?: string,\n /** Payer email attached when the payment type is TwouPaypalPayment. */\n paypalEmail?: string | null,\n}\n\n/** Auto-renewal consent captured on TwouCart at checkout confirmation (SUBS-228). */\nexport interface CheckoutConsent {\n /** Main auto-renewal checkbox — always required at submit. */\n tConsentRecurring: boolean,\n /** UK/CA resident checkbox; null when that checkbox is not shown. */\n tConsentUkCa: boolean | null,\n /** ISO-8601 timestamp when consent was captured. */\n tConsentAt: string,\n /** Exact disclosure text shown to the learner (audit trail). */\n tConsentText: string,\n}\n\nexport interface UpdateCartConsentArgs {\n cartUid: string,\n consent: CheckoutConsent,\n /** Absolute checkout return URL stored in the backend's tStripeReturnUrl field. */\n returnUrl?: string | null,\n}\n\nexport interface BillingInfo {\n firstName: string,\n lastName: string,\n city: string,\n zip: string,\n country: string,\n line1: string,\n state: string,\n}\n\n// --- Checkout client surface -------------------------------------------------\nexport interface CheckoutClient {\n gql: GqlRunner,\n setToken: (token: string) => void,\n createCart: (vars: CartIds) => Promise<Cart>,\n getCartItem: (biId: string) => Promise<{ cartUid: string, cartItemUid: string }>,\n updateCartItem: (args: UpdateCartItemArgs) => Promise<void>,\n updateCartConsent: (args: UpdateCartConsentArgs) => Promise<void>,\n placeOrder: (cartUid: string) => Promise<unknown>,\n getCartStatus: (biId: string) => Promise<CartStatusResult>,\n findSubscriptionBiId: (biId: string) => Promise<SubscriptionDetails | null>,\n getSalableUid: (maId: string) => Promise<ProductInfo>,\n isCurrentUserSubscriber: () => Promise<CurrentUserSubscriberResult | null>,\n getCourseDetail: (courseKey: string) => Promise<CourseDetail | null>,\n}\n\nexport interface DevAuth {\n iamUrl: string,\n clientId: string,\n clientSecret: string,\n}\n\n// --- Minimal Stripe.js types -------------------------------------------------\n// Just the surface this module uses. If you depend on `@stripe/stripe-js`,\n// you can replace these with its richer types.\nexport interface StripeElementChangeEvent {\n empty?: boolean,\n complete?: boolean,\n error?: { message?: string, code?: string },\n [key: string]: unknown,\n}\n\nexport interface CardFieldState {\n empty: boolean,\n complete: boolean,\n /** Stripe validation error message (e.g. \"Your card number is invalid.\"), empty string if no error. */\n error: string,\n /** True once the element has been blurred at least once. */\n blurred: boolean,\n /** True while the element's input has focus. */\n focused?: boolean,\n /** Card network Stripe detected from the number (e.g. 'visa'); card number only. */\n brand?: string,\n}\n\nexport interface CardFieldStates {\n number: CardFieldState,\n expiry: CardFieldState,\n cvc: CardFieldState,\n}\n\n// --- Stripe Payment Request (Apple Pay / Google Pay) -------------------------\nexport interface PaymentRequestPaymentMethodEvent {\n paymentMethod: {\n id: string,\n billing_details?: {\n address?: { country?: string },\n name?: string,\n email?: string,\n },\n },\n complete: (status: 'success' | 'fail') => void,\n}\n\nexport interface PaymentRequestCanMakePaymentResult {\n applePay?: boolean,\n googlePay?: boolean,\n link?: boolean,\n}\n\nexport interface PaymentRequestLike {\n canMakePayment: () => Promise<PaymentRequestCanMakePaymentResult | null>,\n on: (event: string, handler: (ev: PaymentRequestPaymentMethodEvent) => void) => void,\n show: () => void | Promise<void>,\n update: (details: { total: { label: string, amount: number } }) => void,\n}\n\nexport interface StripeElementLike {\n mount: (node: HTMLElement) => void,\n on: (event: string, handler: (...args: any[]) => void) => void,\n unmount?: () => void,\n destroy?: () => void,\n focus?: () => void,\n}\n\nexport interface StripeElementsOptions {\n mode?: 'payment' | 'setup' | 'subscription',\n amount?: number,\n currency?: string,\n /** Lets Express Checkout Element yield a PaymentMethod for our place-order flow. */\n paymentMethodCreation?: 'manual',\n}\n\nexport interface StripeElementsLike {\n create: (type: string, options?: Record<string, unknown>) => StripeElementLike,\n submit?: () => Promise<{ error?: StripeError }>,\n update?: (options: { amount?: number, currency?: string }) => void,\n}\n\nexport interface StripeError {\n message?: string,\n code?: string,\n /** Stripe.js error category, e.g. 'card_error' or 'api_connection_error'. */\n type?: string,\n}\n\nexport interface PaymentMethodResult {\n paymentMethod?: {\n id: string,\n billing_details?: {\n address?: { country?: string },\n name?: string,\n email?: string,\n },\n },\n error?: StripeError,\n}\n\nexport interface ConfirmResult {\n error?: StripeError,\n setupIntent?: unknown,\n paymentIntent?: unknown,\n}\n\nexport type CreatePaymentMethodParams =\n | {\n type: 'card',\n card: StripeElementLike,\n billing_details?: Record<string, unknown>,\n }\n | {\n elements: StripeElementsLike,\n };\n\nexport interface ConfirmCardPaymentData {\n payment_method?:\n | {\n card: StripeElementLike,\n billing_details?: Record<string, unknown>,\n }\n | string,\n}\n\nexport interface ExpressCheckoutConfirmEvent {\n expressPaymentType?: string,\n billingDetails?: {\n address?: { country?: string },\n name?: string,\n email?: string,\n },\n paymentFailed: (opts?: { reason?: string }) => void,\n}\n\nexport interface ExpressCheckoutReadyEvent {\n /** Deprecated by Stripe — prefer `availablepaymentmethodschange`. */\n availablePaymentMethods?: {\n applePay?: boolean,\n googlePay?: boolean,\n link?: boolean,\n } | undefined,\n}\n\n/** Fires on initial render and whenever wallet availability changes after load. */\nexport interface ExpressCheckoutAvailablePaymentMethodsChangeEvent {\n /** `undefined` when no buttons will render. */\n paymentMethods?: {\n applePay?: { available: boolean },\n googlePay?: { available: boolean },\n link?: { available: boolean },\n } | undefined,\n}\n\nexport interface StripeLike {\n elements: (options?: StripeElementsOptions) => StripeElementsLike,\n createPaymentMethod: (params: CreatePaymentMethodParams) => Promise<PaymentMethodResult>,\n confirmCardSetup: (clientSecret: string) => Promise<ConfirmResult>,\n confirmCardPayment: (\n clientSecret: string,\n data?: ConfirmCardPaymentData,\n ) => Promise<ConfirmResult>,\n paymentRequest: (options: {\n country: string,\n currency: string,\n total: { label: string, amount: number },\n requestPayerName?: boolean,\n requestPayerEmail?: boolean,\n disableWallets?: ('link' | 'applePay' | 'googlePay' | 'browserCard')[],\n }) => PaymentRequestLike,\n}\n\ndeclare global {\n interface Window {\n Stripe?: (publishableKey: string) => StripeLike,\n }\n}\n\nexport interface TrialDateRange {\n /** e.g. \"June 22, 2026\" */\n displayStart: string,\n /** e.g. \"June 29, 2026\" */\n displayEnd: string,\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@edx/frontend-app-alacarte-checkout",
3
- "version": "1.52.0",
3
+ "version": "1.53.0",
4
4
  "description": "alacarte Checkout Frontend application",
5
5
  "repository": {
6
6
  "type": "git",