Fix PaymentSheet displaying raw API error messages to end users#12950
Merged
cttsai-stripe merged 3 commits intoApr 24, 2026
Conversation
Previously, stripeErrorMessage() returned the raw API error message for all StripeException types, exposing developer-facing messages (e.g. "This Connect account cannot currently make live charges") to end users. Now only card_error types show the raw message; all others fall through to the generic "Something went wrong" fallback. RUN_MOBILESDK-5334 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
The 3 CustomerAdapterTest cases were asserting that non-card API errors show raw StripeError messages. After the card_error type guard, these correctly fall through to the generic "Something went wrong" fallback. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
Attach/detach/update payment method APIs only return non-card errors, so the "no stripeError" and "has stripeError" variants both assert "Something went wrong". Merged each pair into a single test. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
jaynewstrom-stripe
approved these changes
Apr 24, 2026
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
stripeError.messageto end users forcard_errortype errorsinvalid_request_error,api_error) now fall through to the generic localized "Something went wrong" messagerequirements.disabled_reasonproperty on the account will provide information about why..." were shown directly to consumersMotivation
Per Stripe API docs: "For card errors, these messages can be shown to your users." Only
card_errortype should expose its raw message. This matches the behavior ofStripeErrorMapping.ktwhich already gates ontype == "card_error".Testing
InvalidRequestExceptionwith a message (the actual bug scenario)CustomerAdapterTestexpectations for non-card API errorsChangelog
invalid_request_error) were displayed to end users instead of a generic fallback message. Onlycard_errormessages are now shown directly.Fixes RUN_MOBILESDK-5334