Skip to content

Refactor PaymentConfiguration for per-instance use in EmbeddedPayment…#13331

Draft
tjclawson-stripe wants to merge 1 commit into
masterfrom
tjclawson/refactor-paymentconfiguration-perinstance-embeddedpaymentelement
Draft

Refactor PaymentConfiguration for per-instance use in EmbeddedPayment…#13331
tjclawson-stripe wants to merge 1 commit into
masterfrom
tjclawson/refactor-paymentconfiguration-perinstance-embeddedpaymentelement

Conversation

@tjclawson-stripe

Copy link
Copy Markdown
Collaborator

…Element

  • Remove @RestrictTo from PaymentConfiguration constructor so users can construct it directly for per-instance use. Add KDoc explaining that direct construction does not write to SharedPreferences or affect the global singleton returned by getInstance().

  • Add PaymentConfigurationHolder: a mutable, @Singleton-scoped holder that owns a nullable PaymentConfiguration override. When the override is null (the default), get() falls back to PaymentConfiguration.getInstance(context), preserving existing behavior for all non-embedded components.

  • Update PaymentConfigurationModule.providePaymentConfiguration to delegate to PaymentConfigurationHolder.get() instead of calling getInstance(context) directly. Remove unused Context import.

  • Wire PaymentConfiguration through EmbeddedPaymentElement.Configuration: add an optional paymentConfiguration field (default null) to the data class and Builder, and set the holder in both configure() overloads so per-instance overrides take effect before loading begins.

  • Add TODO comment in EmbeddedConfigurationHandler noting that the cache key (Arguments) does not include paymentConfiguration, so calling configure() twice with the same intent/config but a different PaymentConfiguration returns the cached result.

Committed-By-Agent: goose

Summary

Motivation

Testing

  • Added tests
  • Modified tests
  • Manually verified

Screenshots

Before After
before screenshot after screenshot

Changelog

…Element

- Remove @RestrictTo from PaymentConfiguration constructor so users can
  construct it directly for per-instance use. Add KDoc explaining that
  direct construction does not write to SharedPreferences or affect the
  global singleton returned by getInstance().

- Add PaymentConfigurationHolder: a mutable, @Singleton-scoped holder that
  owns a nullable PaymentConfiguration override. When the override is null
  (the default), get() falls back to PaymentConfiguration.getInstance(context),
  preserving existing behavior for all non-embedded components.

- Update PaymentConfigurationModule.providePaymentConfiguration to delegate
  to PaymentConfigurationHolder.get() instead of calling getInstance(context)
  directly. Remove unused Context import.

- Wire PaymentConfiguration through EmbeddedPaymentElement.Configuration:
  add an optional paymentConfiguration field (default null) to the data
  class and Builder, and set the holder in both configure() overloads so
  per-instance overrides take effect before loading begins.

- Add TODO comment in EmbeddedConfigurationHandler noting that the cache
  key (Arguments) does not include paymentConfiguration, so calling
  configure() twice with the same intent/config but a different
  PaymentConfiguration returns the cached result.

Committed-By-Agent: goose
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.

1 participant