Skip to content

Commit

Permalink
Add missing calls
Browse files Browse the repository at this point in the history
  • Loading branch information
andrii-vysotskyi-cko committed Jul 7, 2023
1 parent 43fddbd commit ee565e9
Showing 1 changed file with 13 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ final class Checkout3DSService: PO3DSService {

// MARK: - PO3DSService

// swiftlint:disable:next function_body_length
func authenticationRequest(
configuration: PO3DS2Configuration,
completion: @escaping (Result<PO3DS2AuthenticationRequest, POFailure>) -> Void
Expand All @@ -54,7 +55,7 @@ final class Checkout3DSService: PO3DSService {
self.delegate.shouldContinue(with: warnings) { shouldContinue in
assert(Thread.isMainThread, "Completion must be called on main thread.")
if shouldContinue {
context.transaction.getAuthenticationRequestParameters { result in
context.transaction.getAuthenticationRequestParameters { [unowned self] result in
let mappedResult = result
.mapError(errorMapper.convert)
.map(self.convertToAuthenticationRequest)
Expand All @@ -65,19 +66,25 @@ final class Checkout3DSService: PO3DSService {
self.setIdleStateUnchecked()
}
completion(mappedResult)
self.delegate.didCreateAuthenticationRequest(result: mappedResult)
}
} else {
self.setIdleStateUnchecked()
completion(.failure(POFailure(code: .cancelled)))
let failure = POFailure(code: .cancelled)
completion(.failure(failure))
self.delegate.didCreateAuthenticationRequest(result: .failure(failure))
}
}
}
}
} catch let error as AuthenticationError {
completion(.failure(errorMapper.convert(error: error)))
let failure = errorMapper.convert(error: error)
completion(.failure(failure))
delegate.didCreateAuthenticationRequest(result: .failure(failure))
} catch {
let failure = POFailure(code: .generic(.mobile), underlyingError: error)
completion(.failure(failure))
delegate.didCreateAuthenticationRequest(result: .failure(failure))
}
}

Expand All @@ -92,9 +99,9 @@ final class Checkout3DSService: PO3DSService {
let parameters = convertToChallengeParameters(data: challenge)
context.transaction.doChallenge(challengeParameters: parameters) { [unowned self, errorMapper] result in
self.setIdleStateUnchecked()
let challengeResult = result.map(extractStatus(challengeResult:)).mapError(errorMapper.convert)
completion(challengeResult)
delegate.didHandle3DS2Challenge(result: challengeResult)
let mappedResult = result.map(extractStatus(challengeResult:)).mapError(errorMapper.convert)
completion(mappedResult)
delegate.didHandle3DS2Challenge(result: mappedResult)
}
}

Expand Down

0 comments on commit ee565e9

Please sign in to comment.