Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/billing-web/src/checkout/payVerdict.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ describe('payVerdictOf', () => {
},
{
name: 'a stale subscription quote',
result: refusedWith('REQUEST_FAILED', 'SUBSCRIPTION_QUOTE_STALE'),
result: { status: 'error', code: 'QUOTE_STALE' },

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low — This row was replaced rather than added alongside, so nothing in the suite still covers a REQUEST_FAILED failure carrying serverCode: 'SUBSCRIPTION_QUOTE_STALE' — exactly the shape whose verdict changed from requote to a hard failure. The remaining server-code row also builds its fixture with refusedWith, which hardcodes httpStatus: 409, so the status-blind PRORATION_QUOTE_EXPIRED match is never exercised with a 5xx; keep both rows and add a 5xx case. Raised by 2 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case).

expected: { kind: 'requote', because: 'quote_expired' }
},
{
Expand Down
7 changes: 3 additions & 4 deletions apps/billing-web/src/checkout/payVerdict.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Medium — PRORATION_QUOTE_EXPIRED is still matched through matchesServerCode, which ignores httpStatus, while stale subscription quotes now depend on the command layer's QUOTE_STALE normalization that refusedWith only applies to 4xx — so the two stale-quote codes are trusted under different conditions. A 5xx from /billing/subscribe echoing PRORATION_QUOTE_EXPIRED therefore still yields requote, telling the customer the price was refreshed and they were not charged and skipping the OPERATION_ALREADY_PENDING/CONFLICT reconcile branch, even though the subscribe outcome is unknown and an operation may be in flight. Gate this match on a 4xx too, or move it beside the QUOTE_STALE mapping in subscriptionCommands.ts. Raised by 3 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, kimi-k3-max edge-case).


/**
* What a Pay's result asks of the page. `settled` needs nothing from
Expand All @@ -39,6 +36,8 @@ export function payVerdictOf(result: SubscriptionCommandResult): PayVerdict {
)
return { kind: 'requote', because: 'quote_expired' }
switch (result.code) {
case 'QUOTE_STALE':

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Low — Dropping SUBSCRIPTION_QUOTE_STALE from the server-code list makes stale-quote recognition depend entirely on issueSubscribe's 4xx-gated refusedWith mapping, so a response carrying that raw server code with a 5xx status now falls through to a generic {kind:'failure', code:'REQUEST_FAILED'} where it previously re-priced. Distrusting 5xx state is defensible, but it is an unremarked user-visible change and the view layer keeps no fallback if that single mapping is renamed or its status gate shifts. Confirm the change is intended and pin the 5xx outcome with a test. Raised by 3 of 8 reviewers (claude-opus-5-thinking-max adversarial, claude-opus-5-thinking-max edge-case, kimi-k3-max edge-case).

return { kind: 'requote', because: 'quote_expired' }
case 'REACTIVATION_CONFIRMATION_REQUIRED':
return { kind: 'requote', because: 'reactivation_required' }
case 'OPERATION_ALREADY_PENDING':
Expand Down
9 changes: 1 addition & 8 deletions apps/billing-web/src/views/FullPageCheckoutView.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand Down
Loading