Skip to content

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

Open
juabara wants to merge 4 commits into
mainfrom
fix/jm-stripe-payment-method-mismatch
Open

Fix express checkout PayPal payments failing with "paypal not allowed for this PaymentIntent"#8197
juabara wants to merge 4 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.82 MB

ℹ️ View Unchanged
Filename Size Change
support-frontend/public/compiled-assets/javascripts/[countryGroupId]/events/router.js 111 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 87.7 kB 0 B
support-frontend/public/compiled-assets/javascripts/error404Page.js 87.7 kB 0 B
support-frontend/public/compiled-assets/javascripts/error500Page.js 87.6 kB 0 B
support-frontend/public/compiled-assets/javascripts/favicons.js 43 B 0 B
support-frontend/public/compiled-assets/javascripts/paperSubscriptionLandingPage.js 111 kB 0 B
support-frontend/public/compiled-assets/javascripts/payPalErrorPage.js 85.8 kB 0 B
support-frontend/public/compiled-assets/javascripts/promotionTerms.js 91.5 kB 0 B
support-frontend/public/compiled-assets/javascripts/subscriptionsLandingPage.js 118 kB 0 B
support-frontend/public/compiled-assets/javascripts/switchesPage.js 28.4 kB 0 B
support-frontend/public/compiled-assets/javascripts/unsupportedBrowserPage.js 78.5 kB 0 B
support-frontend/public/compiled-assets/javascripts/weeklySubscriptionLandingPage.js 114 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 kB 0 B
support-frontend/public/compiled-assets/webpack/314.js 36.3 kB 0 B
support-frontend/public/compiled-assets/webpack/343.js 4.94 kB 0 B
support-frontend/public/compiled-assets/webpack/478.js 45.5 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.8 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.8 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.27 kB +165 B (+2.04%)
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 164 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 3 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix Departmental tracking: fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant