From 6cef52b3c8b1296e040a6981d21f3af45694ae35 Mon Sep 17 00:00:00 2001 From: Alexander Brown Date: Tue, 29 Sep 2026 23:57:19 +0000 Subject: [PATCH] fix(billing-web): re-quote on QUOTE_STALE in the full-page checkout (#19499) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary Fixes the `full-page-promo.spec.ts` "a code that lapses before Pay" failure that has been red on main since #19126. The full-page checkout now re-quotes when a subscribe comes back as `QUOTE_STALE`. ## Changes - **What**: #19253 made `payVerdictOf` re-quote only when a raw `SUBSCRIPTION_QUOTE_STALE` `serverCode` came back. #19126 then changed account-core to turn a 4xx with that code into `{ code: 'QUOTE_STALE' }` with no `serverCode`. The two PRs were written in parallel and merged about 40 minutes apart. Since then, `payVerdictOf` falls through to `failure`. The page shows "Your quote changed…" instead of re-pricing and showing the expired-promo card. `payVerdictOf` now maps `QUOTE_STALE` to `requote`. - The `payVerdict` and `FullPageCheckoutView` unit tests built the pre-#19126 result shape by hand, so they missed this. They now use the shape account-core actually returns. ## Review Focus `SUBSCRIPTION_QUOTE_STALE` is gone from `STALE_QUOTE_SERVER_CODES`. Only `subscribe` emits it, and account-core now maps it for 4xx responses. A 5xx that echoes the code arrives as `REQUEST_FAILED`, which account-core treats as an upstream failure, not a stale quote. With this change, that 5xx no longer triggers a re-quote. Red/green: both updated unit tests fail without the `payVerdict.ts` change and pass with it. `pnpm test:e2e:local e2e/full-page-promo.spec.ts` passes 6/6. (cherry picked from commit 9fa2eb037fb1c0e2b51d7b90f5fab119cb63d33f) --- apps/billing-web/src/checkout/payVerdict.test.ts | 2 +- apps/billing-web/src/checkout/payVerdict.ts | 7 +++---- apps/billing-web/src/views/FullPageCheckoutView.test.ts | 9 +-------- 3 files changed, 5 insertions(+), 13 deletions(-) diff --git a/apps/billing-web/src/checkout/payVerdict.test.ts b/apps/billing-web/src/checkout/payVerdict.test.ts index e3b3eba3185..b33e1f9e59c 100644 --- a/apps/billing-web/src/checkout/payVerdict.test.ts +++ b/apps/billing-web/src/checkout/payVerdict.test.ts @@ -124,7 +124,7 @@ describe('payVerdictOf', () => { }, { name: 'a stale subscription quote', - result: refusedWith('REQUEST_FAILED', 'SUBSCRIPTION_QUOTE_STALE'), + result: { status: 'error', code: 'QUOTE_STALE' }, expected: { kind: 'requote', because: 'quote_expired' } }, { diff --git a/apps/billing-web/src/checkout/payVerdict.ts b/apps/billing-web/src/checkout/payVerdict.ts index 85565b866b4..909b7f470f8 100644 --- a/apps/billing-web/src/checkout/payVerdict.ts +++ b/apps/billing-web/src/checkout/payVerdict.ts @@ -12,10 +12,7 @@ import { import type { InlineOutcome, OperationOutcome } from '@/checkout/checkoutPage' /** The server refused the quote the customer consented to; re-price before asking again. */ -const STALE_QUOTE_SERVER_CODES = [ - 'PRORATION_QUOTE_EXPIRED', - 'SUBSCRIPTION_QUOTE_STALE' -] as const +const STALE_QUOTE_SERVER_CODES = ['PRORATION_QUOTE_EXPIRED'] as const /** * What a Pay's result asks of the page. `settled` needs nothing from @@ -39,6 +36,8 @@ export function payVerdictOf(result: SubscriptionCommandResult): PayVerdict { ) return { kind: 'requote', because: 'quote_expired' } switch (result.code) { + case 'QUOTE_STALE': + return { kind: 'requote', because: 'quote_expired' } case 'REACTIVATION_CONFIRMATION_REQUIRED': return { kind: 'requote', because: 'reactivation_required' } case 'OPERATION_ALREADY_PENDING': diff --git a/apps/billing-web/src/views/FullPageCheckoutView.test.ts b/apps/billing-web/src/views/FullPageCheckoutView.test.ts index 2c8615542d4..da75d1ee4b5 100644 --- a/apps/billing-web/src/views/FullPageCheckoutView.test.ts +++ b/apps/billing-web/src/views/FullPageCheckoutView.test.ts @@ -2169,14 +2169,7 @@ describe('FullPageCheckoutView promo codes', () => { it('a code that lapsed before Pay: back to capture, chip gone, the expired card instead of a decline', async () => { const fake = await renderCheckout( { - subscribe: { - status: 'error', - code: 'REQUEST_FAILED', - serverCode: readBillingErrorCode({ - code: 'SUBSCRIPTION_QUOTE_STALE', - message: 'stale' - }) - } + subscribe: { status: 'error', code: 'QUOTE_STALE' } }, quotesByCode )