diff --git a/apps/billing-web/src/checkout/checkoutPage.test.ts b/apps/billing-web/src/checkout/checkoutPage.test.ts index b719ba19e37..50e667c6f8e 100644 --- a/apps/billing-web/src/checkout/checkoutPage.test.ts +++ b/apps/billing-web/src/checkout/checkoutPage.test.ts @@ -794,6 +794,33 @@ describe('reduceCheckoutPage reconciliation', () => { ], expected: { kind: 'resolving', outcome: declinedElsewhere } }, + { + name: "this tab's own Pay whose watch lapsed declines onto its card once the re-read settles", + events: [ + ...live, + submitted, + { type: 'payRejectedAsPending', because: 'unanswered' }, + reconciled({ ...pendingOperation(), awaitedHere: true }), + changed(failedOperation('card_declined'), declinedElsewhere) + ], + expected: { kind: 'resolving', outcome: declinedElsewhere } + }, + { + name: "this tab's own Pay whose watch lapsed keeps its card when the re-read finds the challenge refused", + events: [ + ...live, + submitted, + { type: 'payRejectedAsPending', because: 'unanswered' }, + reconciled( + { ...refusedChallenge(), awaitedHere: true }, + { kind: 'not_completed', operationId: 'op_3ds' } + ) + ], + expected: { + kind: 'resolving', + outcome: { kind: 'not_completed', operationId: 'op_3ds' } + } + }, { name: 'a form that watched another tab start paying is waiting on a sibling', events: [...live, reconciled(pendingOperation())], diff --git a/apps/billing-web/src/checkout/checkoutPage.ts b/apps/billing-web/src/checkout/checkoutPage.ts index 33da2a471e7..62176c26ad1 100644 --- a/apps/billing-web/src/checkout/checkoutPage.ts +++ b/apps/billing-web/src/checkout/checkoutPage.ts @@ -1104,12 +1104,14 @@ function waitingInCapture( operation: BillingOperationState, outcome: OperationOutcome | undefined ): CheckoutPage { + if (outcome !== undefined && operation.awaitedHere) + return { kind: 'resolving', outcome } if (!isInFlight(operation) || outcome !== undefined) return nothingPending(page) return { kind: 'waiting', operation, - sibling: true, + ...(operation.awaitedHere ? {} : { sibling: true }), ...(awaitsUnansweredPay(page) ? { unanswered: true } : {}), rail: page.rail } diff --git a/packages/account-ui/src/billing/stripe/StripePaymentForm.test.ts b/packages/account-ui/src/billing/stripe/StripePaymentForm.test.ts index 68c95af4733..f673fce3d4d 100644 --- a/packages/account-ui/src/billing/stripe/StripePaymentForm.test.ts +++ b/packages/account-ui/src/billing/stripe/StripePaymentForm.test.ts @@ -421,7 +421,7 @@ describe('StripePaymentForm', () => { }) }) - it('collects a one-time payment the card is never saved for when paying once', async () => { + it('collects a one-time card payment the card is never saved for when paying once', async () => { renderForm(2500, 'pmc_topup', { payOnce: true }) await waitFor(() => @@ -432,12 +432,21 @@ describe('StripePaymentForm', () => { mode: 'payment', amount: 2500, currency: 'usd', - paymentMethodConfiguration: 'pmc_topup' + paymentMethodTypes: ['card'] }) ) expect(stripeMocks.stripe.elements).not.toHaveBeenCalledWith( expect.objectContaining({ setupFutureUsage: expect.anything() }) ) + expect(stripeMocks.stripe.elements).not.toHaveBeenCalledWith( + expect.objectContaining({ + paymentMethodConfiguration: expect.anything() + }) + ) + expect(stripeMocks.create).toHaveBeenCalledWith( + 'payment', + expect.objectContaining({ wallets: { link: 'never' } }) + ) }) it('collects deferred subscription details and emits a confirmation token', async () => { diff --git a/packages/account-ui/src/billing/stripe/StripePaymentForm.vue b/packages/account-ui/src/billing/stripe/StripePaymentForm.vue index bbc86a52424..ceffa24b03f 100644 --- a/packages/account-ui/src/billing/stripe/StripePaymentForm.vue +++ b/packages/account-ui/src/billing/stripe/StripePaymentForm.vue @@ -106,8 +106,8 @@ const { amountCents: number currency: string copy: StripePaymentCopy - /** Stripe payment method configuration governing which methods Elements - * offers (served per-environment by the preview). */ + /** Stripe payment method configuration governing which methods a subscription + * offers (served per-environment by the preview); paying once is card only. */ paymentMethodConfigurationId?: string isLoading?: boolean /** A 3DS verification is pending: the host's own verification action is @@ -197,6 +197,7 @@ function mountPaymentElement( // inputs, and a customer who filled the two differently would send the // issuer an address that contradicts the one we collected for AVS. fields: { billingDetails: { address: 'never' } }, + ...(payOnce ? { wallets: { link: 'never' as const } } : {}), // The host's terms note carries the recurring-charge authorization; // Stripe's card mandate text would say it twice. terms: { card: 'never' } @@ -247,8 +248,12 @@ function mountAddressElement( function intentOptions() { return payOnce - ? ({ mode: 'payment' } as const) - : ({ mode: 'subscription', setupFutureUsage: 'off_session' } as const) + ? { mode: 'payment' as const, paymentMethodTypes: ['card'] } + : { + mode: 'subscription' as const, + setupFutureUsage: 'off_session' as const, + paymentMethodConfiguration: paymentMethodConfigurationId + } } onMounted(async () => { @@ -272,7 +277,6 @@ onMounted(async () => { ...intentOptions(), amount: amountCents, currency: currency.toLowerCase(), - paymentMethodConfiguration: paymentMethodConfigurationId, appearance: resolveAppearance(paymentElementTarget.value) }) mountPaymentElement(stripeElements.value, paymentElementTarget.value)