Skip to content

Fix express checkout PayPal payments failing with "paypal not allowed for this PaymentIntent" - #8197

Merged
juabara merged 6 commits into
mainfrom
fix/jm-stripe-payment-method-mismatch
Sep 18, 2026
Merged

juabara merged 6 commits into
mainfrom
fix/jm-stripe-payment-method-mismatch

Conversation

@juabara

@juabara juabara commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Fixes one-off Stripe payments where a PayPal PaymentMethod was sent to payment-api as StripePaymentRequestButton.
  • Routes payments based on the actual Stripe PaymentMethod object rather than React UI state.
  • Adds coverage for PayPal, Apple Pay, Google Pay, other wallets, and unexpected payment types.

Root cause

The Payment Element and Express Checkout Element share the same Stripe Elements instance. A user can select PayPal in the Payment Element and then interact with Google Pay in Express Checkout.

In that state, Stripe can return a PayPal PaymentMethod while the React state indicates StripeExpressCheckoutElement. The previous code prioritised that UI state and labelled the PaymentMethod as StripePaymentRequestButton, causing payment-api to create a card-only PaymentIntent. Stripe then rejected the PayPal PaymentMethod:

The PaymentMethod provided (paypal) is not allowed for this PaymentIntent.

PR #8173 improved the PayPal detection for the Payment Element path, but its check remained after the Express Checkout branch and was therefore bypassed in this mixed state.

Changes

  • Map the actual Stripe PaymentMethod:
    • PayPal → StripePaypal
    • Apple Pay card wallet → StripeApplePay
    • Other card wallets, including Google Pay → StripePaymentRequestButton
    • Plain card → StripeCheckout
  • Log unexpected PaymentMethod types and Express Checkout mismatches.
  • Add unit tests for the mapping and the reproduced mixed-state scenario.

Express checkout PayPal clicks created a paypal PaymentMethod but labelled
it StripePaymentRequestButton, so payment-api built a card-only PaymentIntent
and the payment failed. Check the PM type first so paypal is routed correctly
from both the Payment Element and Express Checkout Element, and log unexpected
PM types for diagnosability.
@juabara juabara added the fix Departmental tracking: fix label Sep 2, 2026
@juabara
juabara requested a review from a team as a code owner September 2, 2026 09:10
@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Size Change: 0 B

Total Size: 1.91 MB

ℹ️ View Unchanged
Filename Size Change
support-frontend/public/compiled-assets/javascripts/[countryGroupId]/events/router.js 116 kB 0 B
support-frontend/public/compiled-assets/javascripts/[countryGroupId]/router.js 177 kB 0 B
support-frontend/public/compiled-assets/javascripts/ausMomentMap.js 110 kB 0 B
support-frontend/public/compiled-assets/javascripts/downForMaintenancePage.js 92.7 kB 0 B
support-frontend/public/compiled-assets/javascripts/error404Page.js 92.7 kB 0 B
support-frontend/public/compiled-assets/javascripts/error500Page.js 92.6 kB 0 B
support-frontend/public/compiled-assets/javascripts/favicons.js 43 B 0 B
support-frontend/public/compiled-assets/javascripts/paperSubscriptionLandingPage.js 117 kB 0 B
support-frontend/public/compiled-assets/javascripts/payPalErrorPage.js 90.8 kB 0 B
support-frontend/public/compiled-assets/javascripts/promotionTerms.js 96.5 kB 0 B
support-frontend/public/compiled-assets/javascripts/subscriptionsLandingPage.js 123 kB 0 B
support-frontend/public/compiled-assets/javascripts/switchesPage.js 28.4 kB 0 B
support-frontend/public/compiled-assets/javascripts/unsupportedBrowserPage.js 83.5 kB 0 B
support-frontend/public/compiled-assets/javascripts/weeklySubscriptionLandingPage.js 120 kB 0 B
support-frontend/public/compiled-assets/webpack/221.js 3.47 kB 0 B
support-frontend/public/compiled-assets/webpack/241.js 4.19 kB 0 B
support-frontend/public/compiled-assets/webpack/311.js 10.4 kB 0 B
support-frontend/public/compiled-assets/webpack/343.js 4.95 kB 0 B
support-frontend/public/compiled-assets/webpack/388.js 45.6 kB 0 B
support-frontend/public/compiled-assets/webpack/590.js 50 kB 0 B
support-frontend/public/compiled-assets/webpack/652.js 57.1 kB 0 B
support-frontend/public/compiled-assets/webpack/889.js 7.4 kB 0 B
support-frontend/public/compiled-assets/webpack/893.js 15.2 kB 0 B
support-frontend/public/compiled-assets/webpack/907.js 24.2 kB 0 B
support-frontend/public/compiled-assets/webpack/932.js 4.52 kB 0 B
support-frontend/public/compiled-assets/webpack/939.js 11.1 kB 0 B
support-frontend/public/compiled-assets/webpack/checkout.js 31.1 kB 0 B
support-frontend/public/compiled-assets/webpack/errorPage.js 19.8 kB 0 B
support-frontend/public/compiled-assets/webpack/GuardianAdLiteLanding.js 12.9 kB 0 B
support-frontend/public/compiled-assets/webpack/Invitation.js 12.3 kB 0 B
support-frontend/public/compiled-assets/webpack/LandingPage.js 16.4 kB 0 B
support-frontend/public/compiled-assets/webpack/oneTimeCheckout.js 8.38 kB +158 B (+1.92%)
support-frontend/public/compiled-assets/webpack/sentry.js 109 kB 0 B
support-frontend/public/compiled-assets/webpack/StudentLandingPageGlobalContainer.js 1.74 kB 0 B
support-frontend/public/compiled-assets/webpack/StudentLandingPageInstitutionContainer.js 715 B 0 B
support-frontend/public/compiled-assets/webpack/ThankYou.js 116 kB 0 B

compressed-size-action

@github-actions

github-actions Bot commented Sep 2, 2026

Copy link
Copy Markdown
Contributor

Juarez Mota and others added 5 commits September 4, 2026 16:02
Extract getStripePaymentMethod to a testable function and add comprehensive tests.
Fix Express Checkout PayPal routing by checking PaymentMethod type before wallet type,
ensuring PayPal payments are correctly routed through StripePaypal flow regardless of
UI flow. Log unexpected PaymentMethod types and inconsistencies for diagnosability.
@tomrf1

tomrf1 commented Sep 18, 2026

Copy link
Copy Markdown
Member

The bug can be reproduced with the following steps:

  1. select paypal in the PaymentElement
  2. select google pay in the express element higher up
  3. use a test card that fails
  4. click the CTA, to complete with paypal

Copilot AI left a comment

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.

🟢 Approval recommended

No unresolved review issues remain, and the changes include relevant test coverage.

Pull request overview

Fixes one-time Stripe payment routing by classifying payments from the actual PaymentMethod, preventing PayPal payments from being treated as card payments.

Changes:

  • Maps PayPal, Apple Pay, other wallets, and cards appropriately.
  • Adds mismatch and unexpected-type logging.
  • Adds unit coverage for payment-method mappings.
File summaries
File Description
support-frontend/assets/pages/[countryGroupId]/components/oneTimeCheckoutComponent.tsx Uses Stripe PaymentMethod data for payment routing.
support-frontend/assets/helpers/forms/paymentIntegrations/oneOffContributions.ts Implements payment-method classification and logging.
support-frontend/assets/helpers/forms/paymentIntegrations/oneOffContributions.test.ts Tests wallet, PayPal, card, and unexpected payment types.
Review details
  • Files reviewed: 3/3 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@tomrf1 tomrf1 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Looks good!
I tested in mobile in CODE - card, paypal + google pay are fine.
The test case for the bug (see other comment) now works fine

@juabara
juabara merged commit 99bdd04 into main Sep 18, 2026
25 checks passed
@juabara
juabara deleted the fix/jm-stripe-payment-method-mismatch branch September 18, 2026 08:30
@gu-prout

gu-prout Bot commented Sep 18, 2026

Copy link
Copy Markdown

Seen on PROD (merged by @juabara 10 minutes and 4 seconds ago)

Sentry Release: support-client-side, support

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Departmental tracking: fix Seen-on-PROD

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants