diff --git a/Checkout.podspec b/Checkout.podspec index fc54972e8..a77c7ba08 100644 --- a/Checkout.podspec +++ b/Checkout.podspec @@ -20,6 +20,6 @@ Pod::Spec.new do |s| s.exclude_files = "Checkout/Samples/**" s.dependency 'CheckoutEventLoggerKit', '~> 1.2.4' - s.dependency 'Risk', '3.0.0' + s.dependency 'Risk', '3.0.2' end diff --git a/Checkout/Source/Logging/CheckoutLogEvent.swift b/Checkout/Source/Logging/CheckoutLogEvent.swift index ccb2313aa..c48d4162f 100644 --- a/Checkout/Source/Logging/CheckoutLogEvent.swift +++ b/Checkout/Source/Logging/CheckoutLogEvent.swift @@ -18,6 +18,7 @@ enum CheckoutLogEvent: Equatable { case validateCVV case cvvRequested(SecurityCodeTokenRequestData) case cvvResponse(SecurityCodeTokenRequestData, TokenResponseData) + case riskSDKCompletion func event(date: Date) -> Event { Event( @@ -55,6 +56,8 @@ enum CheckoutLogEvent: Equatable { return "card_validator_expiry_integer" case .validateCVV: return "card_validator_cvv" + case .riskSDKCompletion: + return "risk_sdk_completion" } } @@ -66,9 +69,11 @@ enum CheckoutLogEvent: Equatable { .validateExpiryString, .validateExpiryInteger, .validateCVV, - .cvvRequested: + .cvvRequested, + .riskSDKCompletion: return .info - case .tokenResponse(_, let tokenResponseData), .cvvResponse(_, let tokenResponseData): + case .tokenResponse(_, let tokenResponseData), + .cvvResponse(_, let tokenResponseData): return level(from: tokenResponseData.httpStatusCode) } } @@ -87,7 +92,8 @@ enum CheckoutLogEvent: Equatable { .validateCardNumber, .validateExpiryString, .validateExpiryInteger, - .validateCVV: + .validateCVV, + .riskSDKCompletion: return [:] case let .tokenRequested(tokenRequestData): return [ diff --git a/Checkout/Source/Tokenisation/CheckoutAPIService.swift b/Checkout/Source/Tokenisation/CheckoutAPIService.swift index 3ded1029e..f990b7ed7 100644 --- a/Checkout/Source/Tokenisation/CheckoutAPIService.swift +++ b/Checkout/Source/Tokenisation/CheckoutAPIService.swift @@ -67,7 +67,7 @@ final public class CheckoutAPIService: CheckoutAPIProtocol { anyCodable: AnyCodable() ) - let framesOptions = FramesOptions(productIdentifier: Constants.Product.name, version: Constants.Product.version, correlationId: logManager.correlationID) + let framesOptions = FramesOptions(productIdentifier: Constants.Product.name, version: Constants.Product.version) let riskConfig = RiskConfig(publicKey: publicKey, environment: riskEnvironment, framesOptions: framesOptions) let riskSDK = Risk.init(config: riskConfig) @@ -162,20 +162,23 @@ final public class CheckoutAPIService: CheckoutAPIProtocol { guard let self else { return } self.riskSDK.configure { configurationResult in switch configurationResult { - case .failure: break + case .failure: + completion(.success(tokenDetails)) case .success(): - self.riskSDK.publishData(cardToken: tokenDetails.token) { _ in } + self.riskSDK.publishData(cardToken: tokenDetails.token) { _ in + logManager.queue(event: .riskSDKCompletion) + completion(.success(tokenDetails)) + logManager.resetCorrelationID() + } } } - - completion(.success(tokenDetails)) case .errorResponse(let errorResponse): completion(.failure(.serverError(errorResponse))) + logManager.resetCorrelationID() case .networkError(let networkError): completion(.failure(.networkError(networkError))) + logManager.resetCorrelationID() } - - logManager.resetCorrelationID() } } diff --git a/CheckoutTests/Tokenisation/CheckoutAPIServiceTests.swift b/CheckoutTests/Tokenisation/CheckoutAPIServiceTests.swift index 24b593aab..98780039e 100644 --- a/CheckoutTests/Tokenisation/CheckoutAPIServiceTests.swift +++ b/CheckoutTests/Tokenisation/CheckoutAPIServiceTests.swift @@ -88,7 +88,7 @@ final class CheckoutAPIServiceTests: XCTestCase { XCTAssertEqual(stubTokenDetailsFactory.createCalledWith, tokenResponse) - XCTAssertEqual(StubLogManager.queueCalledWith.last, .tokenResponse( + XCTAssertEqual(StubLogManager.queueCalledWith.dropLast().last, .tokenResponse( .init(tokenType: .card, publicKey: "publicKey"), .init(tokenID: "token", scheme: "visa", httpStatusCode: 200, serverError: nil) )) diff --git a/Package.resolved b/Package.resolved index 17c167c31..0b855c03d 100644 --- a/Package.resolved +++ b/Package.resolved @@ -14,8 +14,8 @@ "kind" : "remoteSourceControl", "location" : "https://github.com/checkout/checkout-risk-sdk-ios.git", "state" : { - "revision" : "d9d8bcbc18ad63e3ce5bf4bb1f34ce5b3508a84b", - "version" : "3.0.0" + "revision" : "26f77f09129e78bbab76b7c8916437e309c5051a", + "version" : "3.0.2" } }, { diff --git a/Package.swift b/Package.swift index dfd71306f..3c1d41474 100644 --- a/Package.swift +++ b/Package.swift @@ -20,7 +20,7 @@ let package = Package( exact: "3.5.9"), .package( url: "https://github.com/checkout/checkout-risk-sdk-ios.git", - exact: "3.0.0"), + exact: "3.0.2"), .package( url: "https://github.com/checkout/checkout-event-logger-ios-framework.git", from: "1.2.4"