Skip to content

Commit

Permalink
Update PaymentSheet bottom paddings with error
Browse files Browse the repository at this point in the history
  • Loading branch information
samer-stripe committed Sep 9, 2024
1 parent 2b7daa5 commit 6a11c5e
Show file tree
Hide file tree
Showing 21 changed files with 147 additions and 10 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ import java.io.Closeable
import com.stripe.android.R as PaymentsCoreR

internal val verticalModeBottomContentPadding = 20.dp
internal val horizontalModeBottomContentPadding = 8.dp
internal val horizontalModeBottomContentPadding = 20.dp
internal val horizontalModeWalletsDividerSpacing = 16.dp
internal val verticalModeWalletsDividerSpacing = 24.dp

Expand Down Expand Up @@ -223,7 +223,7 @@ internal sealed interface PaymentSheetScreen {

@Composable
override fun Content(modifier: Modifier) {
AddPaymentMethod(interactor = interactor, modifier)
AddPaymentMethod(interactor = interactor)
}

override fun close() {
Expand Down Expand Up @@ -276,7 +276,7 @@ internal sealed interface PaymentSheetScreen {

@Composable
override fun Content(modifier: Modifier) {
AddPaymentMethod(interactor = interactor, modifier)
AddPaymentMethod(interactor = interactor)
}

override fun close() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ import androidx.compose.foundation.layout.BoxScope
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.fillMaxWidth
import androidx.compose.foundation.layout.height
import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.requiredHeight
import androidx.compose.foundation.layout.requiredSize
Expand Down Expand Up @@ -288,7 +287,7 @@ private fun PaymentSheetContent(
) {
val horizontalPadding = dimensionResource(R.dimen.stripe_paymentsheet_outer_spacing_horizontal)

Column(modifier = modifier) {
Column(modifier = modifier.padding(bottom = currentScreen.bottomContentPadding)) {
headerText?.let { text ->
H4Text(
text = text.resolve(),
Expand Down Expand Up @@ -328,13 +327,11 @@ private fun PaymentSheetContent(
)
}

Spacer(modifier = Modifier.height(currentScreen.bottomContentPadding))

error?.let {
ErrorMessage(
error = it.resolve(),
modifier = Modifier
.padding(vertical = 2.dp, horizontal = horizontalPadding)
.padding(vertical = 6.dp, horizontal = horizontalPadding)
.testTag(PAYMENT_SHEET_ERROR_TEXT_TEST_TAG),
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.stripe.android.core.strings.resolvableString
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadataFactory
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodSaveConsentBehavior
import com.stripe.android.model.SetupIntentFixtures
import com.stripe.android.paymentsheet.navigation.PaymentSheetScreen.AddAnotherPaymentMethod
import com.stripe.android.paymentsheet.ui.FakeAddPaymentMethodInteractor
import com.stripe.android.paymentsheet.ui.FakeAddPaymentMethodInteractor.Companion.createState
Expand Down Expand Up @@ -41,6 +43,23 @@ internal class PaymentSheetScreenAddAnotherPaymentMethodScreenshotTest {
}
}

@Test
fun displaysCheckbox() {
val metadata = PaymentMethodMetadataFactory.create(
hasCustomerConfiguration = true,
paymentMethodSaveConsentBehavior = PaymentMethodSaveConsentBehavior.Enabled,
)
val interactor = FakeAddPaymentMethodInteractor(initialState = createState(metadata))
val initialScreen = AddAnotherPaymentMethod(interactor)
val viewModel = FakeBaseSheetViewModel.create(metadata, initialScreen)

paparazziRule.snapshot {
ViewModelStoreOwnerContext {
PaymentSheetScreen(viewModel = viewModel, type = PaymentSheetFlowType.Complete)
}
}
}

@Test
fun displaysError() {
val metadata = PaymentMethodMetadataFactory.create()
Expand All @@ -55,4 +74,55 @@ internal class PaymentSheetScreenAddAnotherPaymentMethodScreenshotTest {
}
}
}

@Test
fun displaysCardWithMandate() {
val metadata = PaymentMethodMetadataFactory.create(
stripeIntent = SetupIntentFixtures.SI_REQUIRES_PAYMENT_METHOD
)
val interactor = FakeAddPaymentMethodInteractor(initialState = createState(metadata))
val initialScreen = AddAnotherPaymentMethod(interactor)
val viewModel = FakeBaseSheetViewModel.create(metadata, initialScreen)

paparazziRule.snapshot {
ViewModelStoreOwnerContext {
PaymentSheetScreen(viewModel = viewModel, type = PaymentSheetFlowType.Complete)
}
}
}

@Test
fun displaysCheckboxWithMandate() {
val metadata = PaymentMethodMetadataFactory.create(
stripeIntent = SetupIntentFixtures.SI_REQUIRES_PAYMENT_METHOD,
hasCustomerConfiguration = true,
paymentMethodSaveConsentBehavior = PaymentMethodSaveConsentBehavior.Enabled,
)
val interactor = FakeAddPaymentMethodInteractor(initialState = createState(metadata))
val initialScreen = AddAnotherPaymentMethod(interactor)
val viewModel = FakeBaseSheetViewModel.create(metadata, initialScreen)

paparazziRule.snapshot {
ViewModelStoreOwnerContext {
PaymentSheetScreen(viewModel = viewModel, type = PaymentSheetFlowType.Complete)
}
}
}

@Test
fun displaysErrorWithMandate() {
val metadata = PaymentMethodMetadataFactory.create(
stripeIntent = SetupIntentFixtures.SI_REQUIRES_PAYMENT_METHOD,
)
val interactor = FakeAddPaymentMethodInteractor(initialState = createState(metadata))
val initialScreen = AddAnotherPaymentMethod(interactor)
val viewModel = FakeBaseSheetViewModel.create(metadata, initialScreen)
viewModel.onError("An error occurred.".resolvableString)

paparazziRule.snapshot {
ViewModelStoreOwnerContext {
PaymentSheetScreen(viewModel = viewModel, type = PaymentSheetFlowType.Complete)
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.dp
import com.stripe.android.core.strings.resolvableString
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodMetadataFactory
import com.stripe.android.lpmfoundations.paymentmethod.PaymentMethodSaveConsentBehavior
import com.stripe.android.model.SetupIntentFixtures
import com.stripe.android.paymentsheet.navigation.PaymentSheetScreen.AddFirstPaymentMethod
import com.stripe.android.paymentsheet.ui.FakeAddPaymentMethodInteractor
import com.stripe.android.paymentsheet.ui.FakeAddPaymentMethodInteractor.Companion.createState
Expand All @@ -30,7 +32,24 @@ internal class PaymentSheetScreenAddFirstPaymentMethodScreenshotTest {
@Test
fun displaysCard() {
val metadata = PaymentMethodMetadataFactory.create()
val interactor = FakeAddPaymentMethodInteractor(initialState = createState())
val interactor = FakeAddPaymentMethodInteractor(initialState = createState(metadata))
val initialScreen = AddFirstPaymentMethod(interactor)
val viewModel = FakeBaseSheetViewModel.create(metadata, initialScreen)

paparazziRule.snapshot {
ViewModelStoreOwnerContext {
PaymentSheetScreen(viewModel = viewModel, type = PaymentSheetFlowType.Complete)
}
}
}

@Test
fun displaysCheckbox() {
val metadata = PaymentMethodMetadataFactory.create(
hasCustomerConfiguration = true,
paymentMethodSaveConsentBehavior = PaymentMethodSaveConsentBehavior.Enabled,
)
val interactor = FakeAddPaymentMethodInteractor(initialState = createState(metadata))
val initialScreen = AddFirstPaymentMethod(interactor)
val viewModel = FakeBaseSheetViewModel.create(metadata, initialScreen)

Expand All @@ -44,7 +63,58 @@ internal class PaymentSheetScreenAddFirstPaymentMethodScreenshotTest {
@Test
fun displaysError() {
val metadata = PaymentMethodMetadataFactory.create()
val interactor = FakeAddPaymentMethodInteractor(initialState = createState())
val interactor = FakeAddPaymentMethodInteractor(initialState = createState(metadata))
val initialScreen = AddFirstPaymentMethod(interactor)
val viewModel = FakeBaseSheetViewModel.create(metadata, initialScreen)
viewModel.onError("An error occurred.".resolvableString)

paparazziRule.snapshot {
ViewModelStoreOwnerContext {
PaymentSheetScreen(viewModel = viewModel, type = PaymentSheetFlowType.Complete)
}
}
}

@Test
fun displaysCardWithMandate() {
val metadata = PaymentMethodMetadataFactory.create(
stripeIntent = SetupIntentFixtures.SI_REQUIRES_PAYMENT_METHOD
)
val interactor = FakeAddPaymentMethodInteractor(initialState = createState(metadata))
val initialScreen = AddFirstPaymentMethod(interactor)
val viewModel = FakeBaseSheetViewModel.create(metadata, initialScreen)

paparazziRule.snapshot {
ViewModelStoreOwnerContext {
PaymentSheetScreen(viewModel = viewModel, type = PaymentSheetFlowType.Complete)
}
}
}

@Test
fun displaysCheckboxWithMandate() {
val metadata = PaymentMethodMetadataFactory.create(
stripeIntent = SetupIntentFixtures.SI_REQUIRES_PAYMENT_METHOD,
hasCustomerConfiguration = true,
paymentMethodSaveConsentBehavior = PaymentMethodSaveConsentBehavior.Enabled,
)
val interactor = FakeAddPaymentMethodInteractor(initialState = createState(metadata))
val initialScreen = AddFirstPaymentMethod(interactor)
val viewModel = FakeBaseSheetViewModel.create(metadata, initialScreen)

paparazziRule.snapshot {
ViewModelStoreOwnerContext {
PaymentSheetScreen(viewModel = viewModel, type = PaymentSheetFlowType.Complete)
}
}
}

@Test
fun displaysErrorWithMandate() {
val metadata = PaymentMethodMetadataFactory.create(
stripeIntent = SetupIntentFixtures.SI_REQUIRES_PAYMENT_METHOD,
)
val interactor = FakeAddPaymentMethodInteractor(initialState = createState(metadata))
val initialScreen = AddFirstPaymentMethod(interactor)
val viewModel = FakeBaseSheetViewModel.create(metadata, initialScreen)
viewModel.onError("An error occurred.".resolvableString)
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 6a11c5e

Please sign in to comment.