Fix express checkout PayPal payments failing with "paypal not allowed for this PaymentIntent" - #8197
Open
juabara wants to merge 4 commits into
Open
Fix express checkout PayPal payments failing with "paypal not allowed for this PaymentIntent"#8197juabara wants to merge 4 commits into
juabara wants to merge 4 commits into
Conversation
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.
Contributor
Contributor
|
Size Change: 0 B Total Size: 1.82 MB ℹ️ View Unchanged
|
Contributor
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
PaymentMethodwas sent to payment-api asStripePaymentRequestButton.PaymentMethodobject rather than React UI state.Root cause
The Payment Element and Express Checkout Element share the same Stripe
Elementsinstance. 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
PaymentMethodwhile the React state indicatesStripeExpressCheckoutElement. The previous code prioritised that UI state and labelled the PaymentMethod asStripePaymentRequestButton, causing payment-api to create a card-only PaymentIntent. Stripe then rejected the PayPal PaymentMethod: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
StripePaypalStripeApplePayStripePaymentRequestButtonStripeCheckout