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 drop-in unable to handle 3DS2 on API v66 and below #1629

Merged
merged 2 commits into from
May 14, 2024
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
1 change: 1 addition & 0 deletions RELEASE_NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
- Drop-in no longer overrides the log level in case of debug builds.
- Address Lookup not displaying validation error on Card Component when no address has been selected.
- Actions no longer crash when your app uses obfuscation.
- Drop-in no longer throws an error while handling a 3DS2 challenge on API 66 and below.

## Changed
- Flags are replaced by ISO codes in the phone number inputs (affected payment methods: MB Way, Pay Easy, Convenience Stores Japan, Online Banking Japan and Seven-Eleven).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,17 @@ internal class ActionComponentDialogFragment :
.onEach {
when (it) {
ActionComponentFragmentEvent.HANDLE_ACTION -> {
actionComponent.handleAction(action, requireActivity())
handleAction(action)
}
}
}
.launchIn(viewLifecycleOwner.lifecycleScope)
}

fun handleAction(action: Action) {
actionComponent.handleAction(action, requireActivity())
}

override fun onBackPressed(): Boolean {
// polling will be canceled by lifecycle event
when {
Expand Down Expand Up @@ -215,21 +219,19 @@ internal class ActionComponentDialogFragment :
}

companion object {
const val ACTION = "ACTION"
const val CHECKOUT_CONFIGURATION = "CHECKOUT_CONFIGURATION"
private const val ACTION = "ACTION"
private const val CHECKOUT_CONFIGURATION = "CHECKOUT_CONFIGURATION"

fun newInstance(
action: Action,
checkoutConfiguration: CheckoutConfiguration,
): ActionComponentDialogFragment {
val args = Bundle()
args.putParcelable(ACTION, action)
args.putParcelable(CHECKOUT_CONFIGURATION, checkoutConfiguration)

val componentDialogFragment = ActionComponentDialogFragment()
componentDialogFragment.arguments = args

return componentDialogFragment
return ActionComponentDialogFragment().apply {
arguments = Bundle().apply {
putParcelable(ACTION, action)
putParcelable(CHECKOUT_CONFIGURATION, checkoutConfiguration)
}
}
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -482,6 +482,10 @@ internal class DropInActivity :

private fun handleAction(action: Action) {
adyenLog(AdyenLogLevel.DEBUG) { "showActionDialog" }
getExistingActionFragment()?.apply {
handleAction(action)
return
}
setLoading(false)
hideAllScreens()
val actionFragment = ActionComponentDialogFragment.newInstance(action, dropInViewModel.checkoutConfiguration)
Expand Down Expand Up @@ -563,14 +567,16 @@ internal class DropInActivity :
private fun isWeChatPayIntent(intent: Intent): Boolean = checkCompileOnly { WeChatPayUtils.isResultIntent(intent) }

private fun handleActionIntentResponse(intent: Intent) {
val actionFragment = getActionFragment() ?: return
val actionFragment = getExistingActionFragment()
if (actionFragment == null) {
adyenLog(AdyenLogLevel.ERROR) { "ActionComponentDialogFragment is not loaded" }
return
}
actionFragment.handleIntent(intent)
}

private fun getActionFragment(): ActionComponentDialogFragment? {
val fragment = getFragmentByTag(ACTION_FRAGMENT_TAG) as? ActionComponentDialogFragment
if (fragment == null) adyenLog(AdyenLogLevel.ERROR) { "ActionComponentDialogFragment is not loaded" }
return fragment
private fun getExistingActionFragment(): ActionComponentDialogFragment? {
return getFragmentByTag(ACTION_FRAGMENT_TAG) as? ActionComponentDialogFragment
}

private fun initObservers() {
Expand Down