Skip to content

Fix PaymentSheet displaying raw API error messages to end users#12950

Merged
cttsai-stripe merged 3 commits into
masterfrom
cttsai/fix-raw-error-messages-in-paymentsheet
Apr 24, 2026
Merged

Fix PaymentSheet displaying raw API error messages to end users#12950
cttsai-stripe merged 3 commits into
masterfrom
cttsai/fix-raw-error-messages-in-paymentsheet

Conversation

@cttsai-stripe

@cttsai-stripe cttsai-stripe commented Apr 22, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Only expose raw stripeError.message to end users for card_error type errors
  • All non-card error types (e.g. invalid_request_error, api_error) now fall through to the generic localized "Something went wrong" message
  • Previously, developer-facing messages like "This Connect account cannot currently make live charges. The requirements.disabled_reason property on the account will provide information about why..." were shown directly to consumers

Motivation

Per Stripe API docs: "For card errors, these messages can be shown to your users." Only card_error type should expose its raw message. This matches the behavior of StripeErrorMapping.kt which already gates on type == "card_error".

Testing

  • Updated unit tests to verify card errors show raw messages and non-card errors show generic fallback
  • Added new test cases for InvalidRequestException with a message (the actual bug scenario)
  • Updated CustomerAdapterTest expectations for non-card API errors

Changelog

  • [FIXED]12950 Fixed an issue where raw API error messages (e.g. invalid_request_error) were displayed to end users instead of a generic fallback message. Only card_error messages are now shown directly.

Fixes RUN_MOBILESDK-5334

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
cttsai-stripe and others added 2 commits April 23, 2026 10:15
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
@cttsai-stripe cttsai-stripe marked this pull request as ready for review April 23, 2026 18:16
@cttsai-stripe cttsai-stripe requested review from a team as code owners April 23, 2026 18:16
@cttsai-stripe cttsai-stripe merged commit 96dd679 into master Apr 24, 2026
19 checks passed
@cttsai-stripe cttsai-stripe deleted the cttsai/fix-raw-error-messages-in-paymentsheet branch April 24, 2026 16:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants