-
Notifications
You must be signed in to change notification settings - Fork 66
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
State on Card component not applied when apps comes back to foreground #1400
Comments
Hi @ronaldvanduren, thank you for reporting this bug to us. We just released 5.1.0, which includes some changes on how we draw views, which also fixes this issue. By design, V4 is not compatible with Compose. Additionally when using a v5.x.x version, you can use the card component to handle redirect and 3DS2 actions ( Based on the flow you use, you can find the card component integration example for advanced flow and the sessions flow. Could you please try the new 5.1.0 version and let us know if you still experience issues? |
Hi, I checked today the latest version and the problem still persists. I use the |
Hi @ronaldvanduren, thanks for trying with the latest version of our SDK. We verified again by using the information you provided, but unfortunately we are not able to reproduce the issue. To assist you further, we would need some additional information.
|
Hi @araratthehero, sorry for the late reply, we had a Christmas recess. I will work on this again and come back to you with the information you ask for. In the meantime, would it possible to add a feature to invalidate the component state? |
Hi @ronaldvanduren, thank you for keeping us updated. We are currently working on improving components, including handling of component states. We appreciate your feedback and will certainly take it into consideration. It would still be helpful if you could share information that would help us understand the issue better, and if possible, find a solution for you. |
Hi @araratthehero, great to see a team that is dedicated to improve the SDK 😄, I have seen the opposite too many times unfortunately. I found the issue, it's related to handeling a deeplink with the override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
if (isAdyenRedirectUri(intent.data ?: Uri.EMPTY)) {
navController.handleDeepLink(intent)
}
} This would trigger our Composable to be called because it's registered in our NavController like this: composable(
"/our-screen-with-adyen-component/",
deepLinks = listOf(navDeepLink {
uriPattern =
"our-scheme://our-host?some-params"
}) This triggers a full screen recomposition. Normally this shouldn't be an issue, the In In code it will look something like this //In the Activity
override fun onNewIntent(intent: Intent) {
super.onNewIntent(intent)
if (isAdyenRedirectUri(intent.data ?: Uri.EMPTY)) {
if(navController.currentDestination?.route?.contains("our-screen-with-adyen-component") == true) {
fooComponent.handleDeeplink(intent)
} else {
navController.handleDeepLink(intent)
}
}
}
//In the ViewModel
init {
launch {
fooComponent.deeplinkData().collect { deeplinkData ->
if (deeplinkData.orderId == orderId) {
onAdyenDataReceived(AdyenDeeplinkData(deeplinkData.payinId, deeplinkData.redirectResult))
}
}
}
} So whenever the screen is already opened, we update the view simply by listening to We are still in the process of testing edge cases with this approach, but so far it looks solid. |
Hi @ronaldvanduren, thank you for describing your approach so thoroughly. Our component acts as a I am curious to know where you create the If you create the But if you want to keep the state of the view, then indeed your approach is the way to do it, by making sure to not recompose the screen, when handling the deeplink. And that is what we are working on to fix. |
Hi @araratthehero, I have a mixed approach at the moment of what you describe. At the moment the //Compose utils
val LocalComponentActivity = compositionLocalOf<ComponentActivity> {
error("ComponentActivity scope not found")
}
//Activity
override fun onCreate(savedInstanceState: Bundle?) {
......
SomeTheme {
CompositionLocalProvider(
LocalKoinScopeProvider provides KoinScopeProvider(scope),
LocalComponentActivity provides this as ComponentActivity
) {
Surface {
SomeNavGraph(this, someArgs, navController = navController)
}
}
}
......
}
//The composable with the Adyen component
@Composable
internal fun CreditCardContent(
creditCardConfiguration: CreditCardConfiguration,
onCreditCardInputChanged: (CardComponentState) -> Unit = {}
) {
Column(
Modifier.height(PAYMENT_CONTENT_HEIGHT.dp)
) {
val cardConfiguration = remember {
CardConfiguration.Builder(
creditCardConfiguration.locale,
Environment.TEST,
BuildConfig.ADYEN_SDK_KEY
).setHolderNameRequired(true)
.setShowStorePaymentField(false)
.setSubmitButtonVisible(false)
.build()
}
val cardComponent = CardComponent.PROVIDER.get(
LocalComponentActivity.current,
paymentMethod = creditCardConfiguration.creditCardPaymentMethod,
configuration = cardConfiguration,
callback = object : ComponentCallback<CardComponentState> {
override fun onAdditionalDetails(actionComponentData: ActionComponentData) {
TODO("Not yet implemented")
}
override fun onError(componentError: ComponentError) {
TODO("Not yet implemented")
}
override fun onSubmit(state: CardComponentState) {
TODO("Not yet implemented")
}
override fun onStateChanged(state: CardComponentState) {
onCreditCardInputChanged(state)
}
}
)
Timber.d("cardComponent: $cardComponent")
AdyenComponent(
component = cardComponent,
modifier = Modifier.fillMaxWidth()
)
}
} After a recomposition, the same instance of the CardComponent is returned. Even when using the NavController to handle the deeplink. |
Hi @ronaldvanduren, that is true. If you create But if you use a different
I got this code from here. You can make use of those functions by implementing the following module:
In this case there should be no need to use Could you try this approach and let me know if it worked for you? |
Hi @araratthehero, I tested your suggested approach and that works as well, great! 🙌 |
Describe the bug
In our company we just started to integrate the Adyen components. With the Card component I notice that the state is not applied whenever the compose screen recomposes. This happens when the user fills in the credit card details, a payment request is made, the user is redirected to a webview for the 3ds challenge, the payment is cancelled and the deeplink returns the user to our app. At that point the fields of the card component are empty again, however, the state that is returned from the card component still have the old state. We use version 4.13.3, I tried 5.0.1 as well but it has the same issue.
To Reproduce
Steps to reproduce the behavior:
RedirectAction
so that the 3DS webview opens.CardComponentState
with the state before we left he app.Expected behavior
When the user returns to the app after the 3DS challenge and a recomposition happens (due to other changes in the UI), I expect that the CardView's old state is applied or that the state is invalided, so that
cardComponent.observe(lifecycleOwner)
returns an invalidated state.Screenshots
Smartphone (please complete the following information):
Additional context
We use Compose to build our UI.
The Composable used:
The text was updated successfully, but these errors were encountered: