Skip to content

Fix Connect JS alert after destroyed activity - #13173

Merged
gimenete-stripe merged 1 commit into
masterfrom
RUN_MXMOBILE-16866-js-alert-bad-token
Jun 2, 2026
Merged

Fix Connect JS alert after destroyed activity#13173
gimenete-stripe merged 1 commit into
masterfrom
RUN_MXMOBILE-16866-js-alert-bad-token

Conversation

@gimenete-stripe

@gimenete-stripe gimenete-stripe commented Jun 1, 2026

Copy link
Copy Markdown
Contributor

Summary

Fix StripeConnectWebView JS alert handling when the host activity has already been destroyed.

Motivation

StripeConnectWebChromeClient.handleJsAlert could call AlertDialog.show() after the host activity was destroyed, which can throw WindowManager.BadTokenException and crash the host app.

This guards alert handling on a live ComponentActivity, cancels the pending JS result when the activity is unavailable, and catches BadTokenException as a final defensive fallback so the WebView callback is not left hanging.

RUN_MXMOBILE-16866

Testing

  • Added tests
  • Modified tests: updated PaymentMethodEndToEndTest.kt to match current Bancontact API behavior when billing_details[name] is omitted.

JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home timeout 600 ./gradlew :connect:testDebugUnitTest --tests com.stripe.android.connect.webview.StripeConnectWebViewTest

JAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home timeout 600 ./gradlew :payments-core:testDebugUnitTest --tests com.stripe.android.PaymentMethodEndToEndTest.createPaymentMethod_withBancontact_missingName_shouldCreateObject

Screenshots

N/A

Changelog

N/A

@gimenete-stripe
gimenete-stripe marked this pull request as ready for review June 1, 2026 08:53
@gimenete-stripe
gimenete-stripe requested review from a team as code owners June 1, 2026 08:53
maragues-stripe
maragues-stripe previously approved these changes Jun 1, 2026

@maragues-stripe maragues-stripe left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

LGTM 👌

@gimenete-stripe

Copy link
Copy Markdown
Contributor Author

r? @maragues-stripe can you re-approve? There were some flaky tests unrelated to my changes and I updated the workflow file to debug them, but finally all tests passed. I think it's worth keeping the workflow file changes though.

maragues-stripe
maragues-stripe previously approved these changes Jun 1, 2026
Committed-By-Agent: codex
Co-authored-by: codex <noreply@openai.com>
@gimenete-stripe
gimenete-stripe merged commit c2bee91 into master Jun 2, 2026
49 checks passed
@gimenete-stripe
gimenete-stripe deleted the RUN_MXMOBILE-16866-js-alert-bad-token branch June 2, 2026 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants