diff --git a/payments-core/src/main/java/com/stripe/android/model/ElementsSessionParams.kt b/payments-core/src/main/java/com/stripe/android/model/ElementsSessionParams.kt index b6bb468bf46..33f5db6e13c 100644 --- a/payments-core/src/main/java/com/stripe/android/model/ElementsSessionParams.kt +++ b/payments-core/src/main/java/com/stripe/android/model/ElementsSessionParams.kt @@ -14,7 +14,7 @@ sealed interface ElementsSessionParams : Parcelable { val customerSessionClientSecret: String? val locale: String? val expandFields: List - val defaultPaymentMethodId: String? + val savedPaymentMethodSelectionId: String? val externalPaymentMethods: List @RestrictTo(RestrictTo.Scope.LIBRARY_GROUP) @@ -23,7 +23,7 @@ sealed interface ElementsSessionParams : Parcelable { override val clientSecret: String, override val locale: String? = Locale.getDefault().toLanguageTag(), override val customerSessionClientSecret: String? = null, - override val defaultPaymentMethodId: String? = null, + override val savedPaymentMethodSelectionId: String? = null, override val externalPaymentMethods: List, ) : ElementsSessionParams { @@ -40,7 +40,7 @@ sealed interface ElementsSessionParams : Parcelable { override val clientSecret: String, override val locale: String? = Locale.getDefault().toLanguageTag(), override val customerSessionClientSecret: String? = null, - override val defaultPaymentMethodId: String? = null, + override val savedPaymentMethodSelectionId: String? = null, override val externalPaymentMethods: List, ) : ElementsSessionParams { @@ -57,7 +57,7 @@ sealed interface ElementsSessionParams : Parcelable { override val locale: String? = Locale.getDefault().toLanguageTag(), val deferredIntentParams: DeferredIntentParams, override val externalPaymentMethods: List, - override val defaultPaymentMethodId: String? = null, + override val savedPaymentMethodSelectionId: String? = null, override val customerSessionClientSecret: String? = null, ) : ElementsSessionParams { diff --git a/payments-core/src/main/java/com/stripe/android/networking/StripeApiRepository.kt b/payments-core/src/main/java/com/stripe/android/networking/StripeApiRepository.kt index 817c2ea277b..15d9487f0eb 100644 --- a/payments-core/src/main/java/com/stripe/android/networking/StripeApiRepository.kt +++ b/payments-core/src/main/java/com/stripe/android/networking/StripeApiRepository.kt @@ -1564,7 +1564,7 @@ class StripeApiRepository @JvmOverloads internal constructor( params.locale.let { this["locale"] = it } params.customerSessionClientSecret?.let { this["customer_session_client_secret"] = it } params.externalPaymentMethods.takeIf { it.isNotEmpty() }?.let { this["external_payment_methods"] = it } - params.defaultPaymentMethodId?.let { this["client_default_payment_method"] = it } + params.savedPaymentMethodSelectionId?.let { this["client_default_payment_method"] = it } (params as? ElementsSessionParams.DeferredIntentType)?.let { type -> this.putAll(type.deferredIntentParams.toQueryParams()) } diff --git a/payments-core/src/test/java/com/stripe/android/networking/StripeApiRepositoryTest.kt b/payments-core/src/test/java/com/stripe/android/networking/StripeApiRepositoryTest.kt index 36b43882141..0af34ecd350 100644 --- a/payments-core/src/test/java/com/stripe/android/networking/StripeApiRepositoryTest.kt +++ b/payments-core/src/test/java/com/stripe/android/networking/StripeApiRepositoryTest.kt @@ -2569,7 +2569,7 @@ internal class StripeApiRepositoryTest { params = ElementsSessionParams.PaymentIntentType( clientSecret = "client_secret", externalPaymentMethods = emptyList(), - defaultPaymentMethodId = "pm_123", + savedPaymentMethodSelectionId = "pm_123", ), options = DEFAULT_OPTIONS, ) @@ -2601,7 +2601,7 @@ internal class StripeApiRepositoryTest { create().retrieveElementsSession( params = ElementsSessionParams.PaymentIntentType( clientSecret = "client_secret", - defaultPaymentMethodId = null, + savedPaymentMethodSelectionId = null, externalPaymentMethods = emptyList(), ), options = DEFAULT_OPTIONS, diff --git a/paymentsheet/src/main/java/com/stripe/android/customersheet/data/CustomerAdapterDataSource.kt b/paymentsheet/src/main/java/com/stripe/android/customersheet/data/CustomerAdapterDataSource.kt index a7c4f4b029e..009aec261a9 100644 --- a/paymentsheet/src/main/java/com/stripe/android/customersheet/data/CustomerAdapterDataSource.kt +++ b/paymentsheet/src/main/java/com/stripe/android/customersheet/data/CustomerAdapterDataSource.kt @@ -116,7 +116,7 @@ internal class CustomerAdapterDataSource @Inject constructor( initializationMode, customer = null, externalPaymentMethods = emptyList(), - defaultPaymentMethodId = null, + savedPaymentMethodSelectionId = null, ).onSuccess { errorReporter.report( errorEvent = ErrorReporter.SuccessEvent.CUSTOMER_SHEET_ELEMENTS_SESSION_LOAD_SUCCESS, diff --git a/paymentsheet/src/main/java/com/stripe/android/customersheet/data/CustomerSessionElementsSessionManager.kt b/paymentsheet/src/main/java/com/stripe/android/customersheet/data/CustomerSessionElementsSessionManager.kt index e030c21d203..2cbc6548a9e 100644 --- a/paymentsheet/src/main/java/com/stripe/android/customersheet/data/CustomerSessionElementsSessionManager.kt +++ b/paymentsheet/src/main/java/com/stripe/android/customersheet/data/CustomerSessionElementsSessionManager.kt @@ -84,7 +84,7 @@ internal class DefaultCustomerSessionElementsSessionManager @Inject constructor( paymentMethodTypes = intentConfiguration.paymentMethodTypes, ) ), - defaultPaymentMethodId = savedSelection?.id, + savedPaymentMethodSelectionId = savedSelection?.id, customer = PaymentSheet.CustomerConfiguration.createWithCustomerSession( id = customerSessionClientSecret.customerId, clientSecret = customerSessionClientSecret.clientSecret, diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/repositories/ElementsSessionRepository.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/repositories/ElementsSessionRepository.kt index 021ea0b70f6..0d26cc9b871 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/repositories/ElementsSessionRepository.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/repositories/ElementsSessionRepository.kt @@ -25,7 +25,7 @@ internal interface ElementsSessionRepository { initializationMode: PaymentElementLoader.InitializationMode, customer: PaymentSheet.CustomerConfiguration?, externalPaymentMethods: List, - defaultPaymentMethodId: String?, + savedPaymentMethodSelectionId: String?, ): Result } @@ -50,12 +50,12 @@ internal class RealElementsSessionRepository @Inject constructor( initializationMode: PaymentElementLoader.InitializationMode, customer: PaymentSheet.CustomerConfiguration?, externalPaymentMethods: List, - defaultPaymentMethodId: String?, + savedPaymentMethodSelectionId: String?, ): Result { val params = initializationMode.toElementsSessionParams( customer = customer, externalPaymentMethods = externalPaymentMethods, - defaultPaymentMethodId = defaultPaymentMethodId, + savedPaymentMethodSelectionId = savedPaymentMethodSelectionId, ) val elementsSession = stripeRepository.retrieveElementsSession( @@ -113,7 +113,7 @@ private fun StripeIntent.withoutWeChatPay(): StripeIntent { internal fun PaymentElementLoader.InitializationMode.toElementsSessionParams( customer: PaymentSheet.CustomerConfiguration?, externalPaymentMethods: List, - defaultPaymentMethodId: String?, + savedPaymentMethodSelectionId: String?, ): ElementsSessionParams { val customerSessionClientSecret = customer?.toElementSessionParam() @@ -123,7 +123,7 @@ internal fun PaymentElementLoader.InitializationMode.toElementsSessionParams( clientSecret = clientSecret, customerSessionClientSecret = customerSessionClientSecret, externalPaymentMethods = externalPaymentMethods, - defaultPaymentMethodId = defaultPaymentMethodId, + savedPaymentMethodSelectionId = savedPaymentMethodSelectionId, ) } @@ -132,7 +132,7 @@ internal fun PaymentElementLoader.InitializationMode.toElementsSessionParams( clientSecret = clientSecret, customerSessionClientSecret = customerSessionClientSecret, externalPaymentMethods = externalPaymentMethods, - defaultPaymentMethodId = defaultPaymentMethodId, + savedPaymentMethodSelectionId = savedPaymentMethodSelectionId, ) } @@ -141,7 +141,7 @@ internal fun PaymentElementLoader.InitializationMode.toElementsSessionParams( deferredIntentParams = intentConfiguration.toDeferredIntentParams(), externalPaymentMethods = externalPaymentMethods, customerSessionClientSecret = customerSessionClientSecret, - defaultPaymentMethodId = defaultPaymentMethodId, + savedPaymentMethodSelectionId = savedPaymentMethodSelectionId, ) } } diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/state/PaymentElementLoader.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/state/PaymentElementLoader.kt index 3ae59f24020..c9dcf8f2dd5 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/state/PaymentElementLoader.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/state/PaymentElementLoader.kt @@ -147,7 +147,7 @@ internal class DefaultPaymentElementLoader @Inject constructor( initializationMode = initializationMode, customer = configuration.customer, externalPaymentMethods = configuration.externalPaymentMethods, - defaultPaymentMethodId = savedPaymentMethodSelection?.id, + savedPaymentMethodSelectionId = savedPaymentMethodSelection?.id, ).getOrThrow() val customerInfo = createCustomerInfo( @@ -233,13 +233,13 @@ internal class DefaultPaymentElementLoader @Inject constructor( initializationMode: PaymentElementLoader.InitializationMode, customer: PaymentSheet.CustomerConfiguration?, externalPaymentMethods: List, - defaultPaymentMethodId: String?, + savedPaymentMethodSelectionId: String?, ): Result { return elementsSessionRepository.get( initializationMode = initializationMode, customer = customer, externalPaymentMethods = externalPaymentMethods, - defaultPaymentMethodId = defaultPaymentMethodId + savedPaymentMethodSelectionId = savedPaymentMethodSelectionId ) } diff --git a/paymentsheet/src/test/java/com/stripe/android/customersheet/data/DefaultCustomerSessionElementsSessionManagerTest.kt b/paymentsheet/src/test/java/com/stripe/android/customersheet/data/DefaultCustomerSessionElementsSessionManagerTest.kt index 484521d0bb8..3f613196a2b 100644 --- a/paymentsheet/src/test/java/com/stripe/android/customersheet/data/DefaultCustomerSessionElementsSessionManagerTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/customersheet/data/DefaultCustomerSessionElementsSessionManagerTest.kt @@ -53,7 +53,7 @@ class DefaultCustomerSessionElementsSessionManagerTest { val lastParams = elementsSessionRepository.lastParams - assertThat(lastParams?.defaultPaymentMethodId).isEqualTo("pm_123") + assertThat(lastParams?.savedPaymentMethodSelectionId).isEqualTo("pm_123") assertThat(lastParams?.externalPaymentMethods).isEmpty() val initializationMode = lastParams?.initializationMode diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/repositories/ElementsSessionRepositoryTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/repositories/ElementsSessionRepositoryTest.kt index 0476d473656..7683d1d8b6e 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/repositories/ElementsSessionRepositoryTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/repositories/ElementsSessionRepositoryTest.kt @@ -53,7 +53,7 @@ internal class ElementsSessionRepositoryTest { ), customer = null, externalPaymentMethods = emptyList(), - defaultPaymentMethodId = null, + savedPaymentMethodSelectionId = null, ).getOrThrow() } @@ -82,7 +82,7 @@ internal class ElementsSessionRepositoryTest { ), customer = null, externalPaymentMethods = emptyList(), - defaultPaymentMethodId = null, + savedPaymentMethodSelectionId = null, ).getOrThrow() } @@ -108,7 +108,7 @@ internal class ElementsSessionRepositoryTest { ), customer = null, externalPaymentMethods = emptyList(), - defaultPaymentMethodId = null, + savedPaymentMethodSelectionId = null, ).getOrThrow() } @@ -140,7 +140,7 @@ internal class ElementsSessionRepositoryTest { ), customer = null, externalPaymentMethods = emptyList(), - defaultPaymentMethodId = null, + savedPaymentMethodSelectionId = null, ).getOrThrow() val argumentCaptor: KArgumentCaptor = argumentCaptor() @@ -177,7 +177,7 @@ internal class ElementsSessionRepositoryTest { ), customer = null, externalPaymentMethods = emptyList(), - defaultPaymentMethodId = null, + savedPaymentMethodSelectionId = null, ) assertThat(session.isSuccess).isTrue() @@ -210,7 +210,7 @@ internal class ElementsSessionRepositoryTest { ), customer = null, externalPaymentMethods = emptyList(), - defaultPaymentMethodId = null, + savedPaymentMethodSelectionId = null, ) assertThat(session.isSuccess).isTrue() @@ -246,7 +246,7 @@ internal class ElementsSessionRepositoryTest { clientSecret = "customer_session_client_secret" ), externalPaymentMethods = emptyList(), - defaultPaymentMethodId = null, + savedPaymentMethodSelectionId = null, ) verify(stripeRepository).retrieveElementsSession( @@ -255,7 +255,7 @@ internal class ElementsSessionRepositoryTest { clientSecret = "client_secret", customerSessionClientSecret = "customer_session_client_secret", externalPaymentMethods = emptyList(), - defaultPaymentMethodId = null, + savedPaymentMethodSelectionId = null, ) ), options = any() @@ -287,7 +287,7 @@ internal class ElementsSessionRepositoryTest { ), customer = null, externalPaymentMethods = emptyList(), - defaultPaymentMethodId = "pm_123", + savedPaymentMethodSelectionId = "pm_123", ) verify(stripeRepository).retrieveElementsSession( @@ -295,7 +295,7 @@ internal class ElementsSessionRepositoryTest { ElementsSessionParams.PaymentIntentType( clientSecret = "client_secret", externalPaymentMethods = emptyList(), - defaultPaymentMethodId = "pm_123", + savedPaymentMethodSelectionId = "pm_123", ) ), options = any() diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/state/DefaultPaymentElementLoaderTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/state/DefaultPaymentElementLoaderTest.kt index dbac87bb3de..6d85a0a7c04 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/state/DefaultPaymentElementLoaderTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/state/DefaultPaymentElementLoaderTest.kt @@ -1919,7 +1919,7 @@ internal class DefaultPaymentElementLoaderTest { initializedViaCompose = false, ) - assertThat(repository.lastParams?.defaultPaymentMethodId) + assertThat(repository.lastParams?.savedPaymentMethodSelectionId) .isEqualTo("pm_1234321") } @@ -1950,7 +1950,7 @@ internal class DefaultPaymentElementLoaderTest { initializedViaCompose = false, ) - assertThat(repository.lastParams?.defaultPaymentMethodId).isNull() + assertThat(repository.lastParams?.savedPaymentMethodSelectionId).isNull() } @Test @@ -1999,7 +1999,7 @@ internal class DefaultPaymentElementLoaderTest { initializedViaCompose = false, ) - assertThat(repository.lastParams?.defaultPaymentMethodId).isNull() + assertThat(repository.lastParams?.savedPaymentMethodSelectionId).isNull() } @Test diff --git a/paymentsheet/src/test/java/com/stripe/android/utils/FakeElementsSessionRepository.kt b/paymentsheet/src/test/java/com/stripe/android/utils/FakeElementsSessionRepository.kt index 6e5de439dbb..2600827e596 100644 --- a/paymentsheet/src/test/java/com/stripe/android/utils/FakeElementsSessionRepository.kt +++ b/paymentsheet/src/test/java/com/stripe/android/utils/FakeElementsSessionRepository.kt @@ -20,7 +20,7 @@ internal class FakeElementsSessionRepository( val initializationMode: PaymentElementLoader.InitializationMode, val customer: PaymentSheet.CustomerConfiguration?, val externalPaymentMethods: List, - val defaultPaymentMethodId: String? + val savedPaymentMethodSelectionId: String? ) var lastParams: Params? = null @@ -29,13 +29,13 @@ internal class FakeElementsSessionRepository( initializationMode: PaymentElementLoader.InitializationMode, customer: PaymentSheet.CustomerConfiguration?, externalPaymentMethods: List, - defaultPaymentMethodId: String?, + savedPaymentMethodSelectionId: String?, ): Result { lastParams = Params( initializationMode = initializationMode, customer = customer, externalPaymentMethods = externalPaymentMethods, - defaultPaymentMethodId = defaultPaymentMethodId, + savedPaymentMethodSelectionId = savedPaymentMethodSelectionId, ) return if (error != null) { Result.failure(error)