Fix Connect JS alert after destroyed activity - #13173
Merged
Merged
Conversation
gimenete-stripe
marked this pull request as ready for review
June 1, 2026 08:53
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
previously approved these changes
Jun 1, 2026
Committed-By-Agent: codex Co-authored-by: codex <noreply@openai.com>
gimenete-stripe
force-pushed
the
RUN_MXMOBILE-16866-js-alert-bad-token
branch
from
June 1, 2026 20:02
0490782 to
03fd5ff
Compare
samer-stripe
approved these changes
Jun 1, 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
Fix
StripeConnectWebViewJS alert handling when the host activity has already been destroyed.Motivation
StripeConnectWebChromeClient.handleJsAlertcould callAlertDialog.show()after the host activity was destroyed, which can throwWindowManager.BadTokenExceptionand crash the host app.This guards alert handling on a live
ComponentActivity, cancels the pending JS result when the activity is unavailable, and catchesBadTokenExceptionas a final defensive fallback so the WebView callback is not left hanging.RUN_MXMOBILE-16866
Testing
PaymentMethodEndToEndTest.ktto match current Bancontact API behavior whenbilling_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.StripeConnectWebViewTestJAVA_HOME=/Applications/Android\ Studio.app/Contents/jbr/Contents/Home timeout 600 ./gradlew :payments-core:testDebugUnitTest --tests com.stripe.android.PaymentMethodEndToEndTest.createPaymentMethod_withBancontact_missingName_shouldCreateObjectScreenshots
N/A
Changelog
N/A