From 9ed959a89592912bf7fca015a329305bbf9c572c Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Mon, 17 Jun 2024 13:30:38 +0700 Subject: [PATCH 1/2] Refactor NetceteraThreeDSController --- .../3DS/NetceteraThreeDSController.swift | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/OmiseSDK/Sources/3DS/NetceteraThreeDSController.swift b/OmiseSDK/Sources/3DS/NetceteraThreeDSController.swift index dfbba5d7..4e5103e1 100644 --- a/OmiseSDK/Sources/3DS/NetceteraThreeDSController.swift +++ b/OmiseSDK/Sources/3DS/NetceteraThreeDSController.swift @@ -187,18 +187,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 +212,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? From ec50d36b4fb943b01ae6e5338733e910299e2a70 Mon Sep 17 00:00:00 2001 From: Andrei Solovev Date: Mon, 17 Jun 2024 13:33:47 +0700 Subject: [PATCH 2/2] Remove swiftlint disable command --- OmiseSDK/Sources/3DS/NetceteraThreeDSController.swift | 1 - 1 file changed, 1 deletion(-) diff --git a/OmiseSDK/Sources/3DS/NetceteraThreeDSController.swift b/OmiseSDK/Sources/3DS/NetceteraThreeDSController.swift index 4e5103e1..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?,