From 0c6357d46cbaf9174a300d9be6cc713f165e2265 Mon Sep 17 00:00:00 2001 From: jameswoo-stripe <99316447+jameswoo-stripe@users.noreply.github.com> Date: Fri, 27 Oct 2023 11:53:09 -0700 Subject: [PATCH] Fix mandate text disappearing --- .../paymentsheet/model/PaymentSelection.kt | 8 ++++++++ .../paymentsheet/model/PaymentSelectionTest.kt | 18 ++++++++++++++++++ .../ach/USBankAccountFormViewModelTest.kt | 8 ++++---- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/model/PaymentSelection.kt b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/model/PaymentSelection.kt index c0d2d7a07f8..f4c2acfcb66 100644 --- a/paymentsheet/src/main/java/com/stripe/android/paymentsheet/model/PaymentSelection.kt +++ b/paymentsheet/src/main/java/com/stripe/android/paymentsheet/model/PaymentSelection.kt @@ -143,6 +143,14 @@ internal sealed class PaymentSelection : Parcelable { override val paymentMethodOptionsParams: PaymentMethodOptionsParams? = null, ) : New() { + override fun mandateText( + context: Context, + merchantName: String, + isSaveForFutureUseSelected: Boolean, + ): String? { + return screenState.mandateText + } + @Parcelize data class Input( val name: String, diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/model/PaymentSelectionTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/model/PaymentSelectionTest.kt index 9285bd458a4..c50948a6992 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/model/PaymentSelectionTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/model/PaymentSelectionTest.kt @@ -134,6 +134,24 @@ class PaymentSelectionTest { ) } + @Test + fun `Displays the correct mandate for US Bank Account`() { + val paymentSelection = PaymentSelection.Saved( + paymentMethod = PaymentMethodFactory.usBankAccount(), + ) + + val result = paymentSelection.mandateText( + context = context, + merchantName = "Merchant", + isSaveForFutureUseSelected = false, + ) + + assertThat(result).isEqualTo( + "By continuing, you agree to authorize payments pursuant to " + + "these terms." + ) + } + @Test fun `Doesn't display a mandate for a saved payment method that isn't US bank account`() = runAllConfigurations { isSaveForFutureUseSelected -> diff --git a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModelTest.kt b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModelTest.kt index 711b98e7181..2a3d97f4084 100644 --- a/paymentsheet/src/test/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModelTest.kt +++ b/paymentsheet/src/test/java/com/stripe/android/paymentsheet/paymentdatacollection/ach/USBankAccountFormViewModelTest.kt @@ -149,7 +149,7 @@ class USBankAccountFormViewModelTest { val currentScreenState = viewModel.currentScreenState.stateIn(viewModel.viewModelScope).value viewModel.handlePrimaryButtonClick(currentScreenState as USBankAccountFormScreenState.VerifyWithMicrodeposits) - assertThat(awaitItem().screenState).isEqualTo(currentScreenState) + assertThat(awaitItem().screenState).isEqualTo(currentScreenState.copy(isProcessing = true)) } } @@ -163,7 +163,7 @@ class USBankAccountFormViewModelTest { val currentScreenState = viewModel.currentScreenState.stateIn(viewModel.viewModelScope).value viewModel.handlePrimaryButtonClick(currentScreenState as USBankAccountFormScreenState.MandateCollection) - assertThat(awaitItem().screenState).isEqualTo(currentScreenState) + assertThat(awaitItem().screenState).isEqualTo(currentScreenState.copy(isProcessing = true)) } } @@ -178,7 +178,7 @@ class USBankAccountFormViewModelTest { val currentScreenState = viewModel.currentScreenState.stateIn(viewModel.viewModelScope).value viewModel.handlePrimaryButtonClick(currentScreenState as USBankAccountFormScreenState.VerifyWithMicrodeposits) - assertThat(awaitItem().screenState).isEqualTo(currentScreenState) + assertThat(awaitItem().screenState).isEqualTo(currentScreenState.copy(isProcessing = true)) } } @@ -193,7 +193,7 @@ class USBankAccountFormViewModelTest { val currentScreenState = viewModel.currentScreenState.stateIn(viewModel.viewModelScope).value viewModel.handlePrimaryButtonClick(currentScreenState as USBankAccountFormScreenState.MandateCollection) - assertThat(awaitItem().screenState).isEqualTo(currentScreenState) + assertThat(awaitItem().screenState).isEqualTo(currentScreenState.copy(isProcessing = true)) } }