Closed gabrielglbh closed 7 months ago
Hi @gabrielglbh, thanks for opening the bug report.
I've followed the steps you provided but couldn't replicate the issue on an emulator and using SDK version 5.3.0
.
To proceed further, could you please provide some additional information?
SessionDropInCallback
to Drop-in.Hi @araratthehero of course!
I have tried the below code in different versions of Android SDK always with a Pixel 8 emulator device. Here are the Android versions in which the callback function works and does not work...
Here is the code to instantiate the drop-in with version 5.3.0 of Adyen:
var paymentSessionResponse: PaymentSessionResponse? = null
val dropInLauncher = rememberLauncherForDropInResult(callback = SessionDropInCallback {
paymentSessionResponse = null
// Finalize the session and check for the result code
// Do some other stuff...
})
// When the session [PaymentSessionResponse] is created and not null, this LaunchedEffect will trigger
LaunchedEffect(paymentSessionResponse != null) {
val configuration = CheckoutConfiguration(environment, ADYEN_CLIENT_KEY) {
card {
setHolderNameRequired(true)
}
dropIn {
addCardConfiguration(this@CheckoutConfiguration.getCardConfiguration()!!)
setAmount(...)
setShowPreselectedStoredPaymentMethod(true)
}
}
// PaymentSessionResponse is gathered previously to get the SessionID and SessionData as per the docs
val result = runBlocking {
return@runBlocking CheckoutSessionProvider.createSession(SessionModel(
paymentSessionResponse.sessionId,
paymentSessionResponse.sessionData
), configuration)
}
when (result) {
is CheckoutSessionResult.Success -> {
DropIn.startPayment(
context = context,
dropInLauncher = dropInLauncher,
checkoutSession = result.checkoutSession,
dropInConfiguration = configuration.getDropInConfiguration()!!
)
}
is CheckoutSessionResult.Error -> { ... }
}
}
Center(
CustomButton(
text = text,
onClick = {
// Create the session for the drop-in, using mocks...
paymentSessionResponse = PaymentSessionResponse("id", "data")
}
)
)
I do not have anymore clues on why is this failing, all the code related to the creation of the Drop-in is that. It seems that with my code below API 30 the callback does not work, it is rather strange...
Hope this comment helps debugging this :)
@gabrielglbh thanks for sharing the details.
I was still not able to reproduce the issue, but I have some ideas which can help:
checkoutConfiguration
as it is to DropIn.startPayment
as mentioned in the "Start Drop-in" code sample in the docs? These methods are not documented, because they are not supposed to be used for launching drop-in or creating components. We already added a warning against using them in the 5.3.0 release notes and we'll make them internal in the next release.
Similarly for addCardConfiguration()
. The CheckoutConfiguration.getCardConfiguration()
will also be made internal.I've also noticed that below API 30 the recomposition works differently in Compose.
DropIn.startPayment
gets called twice? Because if you use the same dropInLauncher
to launch drop in more than once, it will only return result for the first launch.dropInLauncher
, but I would try creating an instance of SessionDropInCallback
outside of Compose (Can be in your ViewModel
or Activity
) and pass it to your compose screens. This way a single instance of SessionDropInCallback
will be used when recomposition happens.Could you make the changes and let me know if it resolves the issue?
@araratthehero Thank you for the tips! I will try them next week and I will let you know ASAP!
@araratthehero It seemed that the trigger to the DropIn.startPayment
was getting called various times even before the SessionDropInCallback
was performed. Adding a control variable solved the issue. And I also applied the suggested change from the docs :) Thank you very much!
Hi @gabrielglbh, I am happy to hear it worked for you.
Describe the bug When coming back from the bank verification using Session and DropIn, if the transaction somehow gets
Refused
, when coming back to the main app, the DropIn dismisses but theSessionDropInCallback
is not called at all.Only happens in Android 10. I have tried it in Android 14 and it goes smoothly as butter.
To Reproduce Steps to reproduce the behavior:
Expected behavior When coming back to the app from the bank verification page, I expect the flow to always go through
SessionDropInCallback
.Screenshots
In Android 10 https://github.com/Adyen/adyen-android/assets/26835924/18f9491d-688e-463a-ab1c-b75d44682531
As you can see in the video, when returning back from the verification screen, the DropIn completely disappears and the
SessionDropInCallback
is not called (thus the appearance of the 2 or 3 other DropIns - expected). I know the code isRefused
because when I dismiss the new DropIns, the failed one actually completes. Strange behaviour.In Android 14 https://github.com/Adyen/adyen-android/assets/26835924/133a8e4f-0e43-4836-9a1b-1f24756c9fbc
Works fine and the callback gets executed and the expected error screen is shown.
Smartphone (please complete the following information):