Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue with custom flow PaymentSheet getting clipped #5545

Merged
merged 1 commit into from
Sep 13, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
match new brand guidelines.
* [FIXED][5480](https://github.com/stripe/stripe-android/pull/5480) `FlowController` now correctly
preserves the previously selected payment method for guests.
* [FIXED][5545](https://github.com/stripe/stripe-android/pull/5545) Fix an issue where custom flow
PaymentSheet UI would have the bottom of the form cut off

## 20.11.0 - 2022-08-29
This release adds postal code validation for PaymentSheet and fixed a fileprovider naming bug for Identity.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ import androidx.compose.ui.test.performTextInput
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.platform.app.InstrumentationRegistry
import androidx.test.uiautomator.UiDevice
import com.stripe.android.model.PaymentMethod
import com.stripe.android.test.core.AuthorizeAction
import com.stripe.android.test.core.Automatic
import com.stripe.android.test.core.Billing
import com.stripe.android.test.core.Browser
import com.stripe.android.test.core.Currency
import com.stripe.android.test.core.Customer
import com.stripe.android.test.core.DelayedPMs
Expand Down Expand Up @@ -90,6 +93,24 @@ class TestFieldPopulation {
authorizationAction = null
)

private val bancontact = TestParameters(
lpmRepository.fromCode("bancontact")!!,
Customer.New,
LinkState.Off,
GooglePayState.Off,
Currency.EUR,
IntentType.Pay,
Billing.Off,
shipping = Shipping.Off,
delayed = DelayedPMs.Off,
automatic = Automatic.Off,
saveCheckboxValue = false,
saveForFutureUseCheckboxVisible = false,
useBrowser = Browser.Chrome,
authorizationAction = AuthorizeAction.Authorize,
merchantCountryCode = "GB"
)

@Ignore("Testing of dropdowns is not yet supported")
fun testDropdowns() {

Expand Down Expand Up @@ -140,6 +161,18 @@ class TestFieldPopulation {
}
}

@Test
fun testSinglePaymentMethodWithoutGooglePayAndKeyboardInput() {
testDriver.confirmNewOrGuestComplete(
bancontact.copy(
supportedPaymentMethods = listOf(PaymentMethod.Type.Bancontact.code)
)
) {
composeTestRule.onNodeWithText("Full name")
.performTextInput("Jenny Rosen")
}
}

companion object {
private val lpmRepository = LpmRepository(
LpmRepository.LpmRepositoryArguments(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,9 @@ class PlaygroundTestDriver(
setup(testParameters)
launchComplete()

selectors.paymentSelection.click()
if (testParameters.supportedPaymentMethods.size > 1) {
selectors.paymentSelection.click()
}

// This takes a screenshot so that translation strings of placeholders
// and labels and design can all be verified
Expand Down Expand Up @@ -405,6 +407,10 @@ class PlaygroundTestDriver(
PaymentSheetPlaygroundActivity.USE_SNAPSHOT_RETURNING_CUSTOMER_EXTRA,
testParameters.snapshotReturningCustomer
)
intent.putExtra(
PaymentSheetPlaygroundActivity.SUPPORTED_PAYMENT_METHODS_EXTRA,
testParameters.supportedPaymentMethods.toTypedArray()
)
val scenario = ActivityScenario.launch<PaymentSheetPlaygroundActivity>(intent)
scenario.onActivity { activity ->

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.stripe.android.test.core

import com.stripe.android.model.PaymentMethodCode
import com.stripe.android.paymentsheet.PaymentSheet
import com.stripe.android.ui.core.forms.resources.LpmRepository.SupportedPaymentMethod

Expand All @@ -25,7 +26,8 @@ data class TestParameters(
val forceDarkMode: Boolean? = null,
val appearance: PaymentSheet.Appearance = PaymentSheet.Appearance(),
val snapshotReturningCustomer: Boolean = false,
val merchantCountryCode: String
val merchantCountryCode: String,
val supportedPaymentMethods: List<PaymentMethodCode> = listOf()
)

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,8 @@ class PaymentSheetPlaygroundActivity : AppCompatActivity() {
linkEnabled,
setShippingAddress,
setAutomaticPaymentMethods,
backendUrl
backendUrl,
intent.extras?.getStringArray(SUPPORTED_PAYMENT_METHODS_EXTRA)?.toList()
)
}
}
Expand Down Expand Up @@ -470,6 +471,7 @@ class PaymentSheetPlaygroundActivity : AppCompatActivity() {
const val FORCE_DARK_MODE_EXTRA = "ForceDark"
const val APPEARANCE_EXTRA = "Appearance"
const val USE_SNAPSHOT_RETURNING_CUSTOMER_EXTRA = "UseSnapshotReturningCustomer"
const val SUPPORTED_PAYMENT_METHODS_EXTRA = "SupportedPaymentMethods"
private const val merchantName = "Example, Inc."
private const val sharedPreferencesName = "playgroundToggles"

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@ data class CheckoutRequest(
val set_shipping_address: Boolean,
val automatic_payment_methods: Boolean,
val use_link: Boolean,
val merchant_country_code: String
val merchant_country_code: String,
val supported_payment_methods: List<String>?
)

@Serializable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,8 @@ class PaymentSheetPlaygroundViewModel(
linkEnabled: Boolean,
setShippingAddress: Boolean,
setAutomaticPaymentMethod: Boolean,
backendUrl: String
backendUrl: String,
supportedPaymentMethods: List<String>?
) {
customerConfig.value = null
clientSecret.value = null
Expand All @@ -158,7 +159,8 @@ class PaymentSheetPlaygroundViewModel(
set_shipping_address = setShippingAddress,
automatic_payment_methods = setAutomaticPaymentMethod,
use_link = linkEnabled,
merchant_country_code = merchantCountry.value
merchant_country_code = merchantCountry.value,
supported_payment_methods = supportedPaymentMethods
)

Fuel.post(backendUrl + "checkout")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.stripe.android.paymentsheet.ui

import android.animation.LayoutTransition
import android.content.pm.ActivityInfo
import android.content.res.ColorStateList
import android.graphics.Insets
Expand Down Expand Up @@ -98,6 +99,9 @@ internal abstract class BaseSheetActivity<ResultType> : AppCompatActivity() {
}
}

bottomSheet.layoutTransition.enableTransitionType(LayoutTransition.CHANGING)
fragmentContainerParent.layoutTransition.enableTransitionType(LayoutTransition.CHANGING)

bottomSheetController.setup()

bottomSheetController.shouldFinish.observe(this) { shouldFinish ->
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.stripe.android.paymentsheet

import android.animation.LayoutTransition
import android.content.Context
import androidx.activity.result.ActivityResultLauncher
import androidx.arch.core.executor.testing.InstantTaskExecutorRule
Expand Down Expand Up @@ -963,6 +964,28 @@ internal class PaymentSheetActivityTest {
}
}

@Test
fun `verify animation is enabled for layout transition changes`() {
val scenario = activityScenario()
scenario.launch(intent).onActivity { activity ->
// wait for bottom sheet to animate in
idleLooper()

assertThat(
activity.viewBinding.bottomSheet.layoutTransition.isTransitionTypeEnabled(
LayoutTransition.CHANGING
)
).isTrue()

assertThat(
activity.viewBinding.fragmentContainerParent.layoutTransition
.isTransitionTypeEnabled(
LayoutTransition.CHANGING
)
).isTrue()
}
}

private fun currentFragment(activity: PaymentSheetActivity) =
activity.supportFragmentManager.findFragmentById(activity.viewBinding.fragmentContainer.id)

Expand Down