diff --git a/OmiseSDK/Sources/3DS/NetceteraThreeDSController.swift b/OmiseSDK/Sources/3DS/NetceteraThreeDSController.swift index dfbba5d7..464a3d30 100644 --- a/OmiseSDK/Sources/3DS/NetceteraThreeDSController.swift +++ b/OmiseSDK/Sources/3DS/NetceteraThreeDSController.swift @@ -149,7 +149,6 @@ extension NetceteraThreeDSController: NetceteraThreeDSControllerProtocol { ThreeDSSDKAppDelegate.shared.appOpened(url: url) } - // swiftlint:disable:next function_body_length func processAuthorizedURL( _ authorizeUrl: URL, threeDSRequestorAppURL: String?, @@ -187,18 +186,8 @@ extension NetceteraThreeDSController: NetceteraThreeDSControllerProtocol { return } - switch response.status { - case .success: - onComplete(.success(())) + guard !Self.processAuthenticationResponse(response, onComplete: onComplete) else { return - case .failed: - onComplete(.failure(NetceteraThreeDSController.Errors.authResStatusFailed)) - return - case .unknown: - onComplete(.failure(NetceteraThreeDSController.Errors.authResStatusUnknown(response.serverStatus))) - return - case .challenge: - break } DispatchQueue.main.async { @@ -222,6 +211,22 @@ extension NetceteraThreeDSController: NetceteraThreeDSControllerProtocol { } } + static func processAuthenticationResponse(_ response: AuthResponse, onComplete: ((Result) -> Void)) -> Bool { + switch response.status { + case .success: + onComplete(.success(())) + return true + case .failed: + onComplete(.failure(NetceteraThreeDSController.Errors.authResStatusFailed)) + return true + case .unknown: + onComplete(.failure(NetceteraThreeDSController.Errors.authResStatusUnknown(response.serverStatus))) + return true + case .challenge: + return false + } + } + func prepareChallengeParameters( aRes: AuthResponse.ARes, threeDSRequestorAppURL: String?