Prototype: Redesign CheckoutInstances registry#13264
Closed
cttsai-stripe wants to merge 6 commits into
Closed
Conversation
…oped registration Replace WeakReference list-based registry with a strong-reference, single-instance-per-key design. Registration is now SDK-managed at configure/present entry points with unregistration at integration teardown. No merchant-facing cleanup required. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
…tances-redesign Committed-By-Agent: claude # Conflicts: # paymentsheet/src/main/java/com/stripe/android/paymentsheet/PaymentSheet.kt
presentWithCheckout was removed from master; no one registers for PaymentSheet anymore, so onDestroy unregistration is dead. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
register() now takes an owner string. Same Checkout registered by a different owner throws, catching the integration error where one Checkout is configured into two live integrations simultaneously. Also adds @mainthread annotations and removes orphaned FakeCheckoutCurrencyUpdater. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
Callers pass `this` as the owner. Two different integration instances registering the same Checkout throw based on object identity, not string comparison. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com> Committed-By-Agent: claude
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
Simplifies
CheckoutInstancesbefore more checkout session code depends on it.What changed:
MutableList<WeakReference<Checkout>>with a single strong reference per keyCheckout.init; registration is now SDK-managed atconfigureWithCheckout/EmbeddedPaymentElement.configureentry pointsonDestroy, Embedded'sonCleared)markIntegrationDismissed()on dismiss but do not unregisterCheckoutCurrencyUpdatercodeWhy:
.firstOrNull()and.forEachon the list. The list is not a valid state; it's a lifecycle gap fromcreateWithState()producing same-key objects.Design doc: https://docs.google.com/document/d/1pvw4EGCdEkBjpCIBQ64CpDXge6N78W74YSBQg_dg5RQ
Status
This is a prototype PR. Missing integration-level tests (reconfigure with different key, FlowController multi-step lifecycle).
Test plan
CheckoutInstancesTestrewritten and passing🤖 Generated with Claude Code