Skip to content

Commit

Permalink
Merge pull request #535 from checkout/fix/await-risk-sdk-actions
Browse files Browse the repository at this point in the history
Await risk sdk actions
  • Loading branch information
okhan-okbay-cko committed May 30, 2024
2 parents 4c385a8 + 89c432e commit 40cd342
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 15 deletions.
2 changes: 1 addition & 1 deletion Checkout.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -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
12 changes: 9 additions & 3 deletions Checkout/Source/Logging/CheckoutLogEvent.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ enum CheckoutLogEvent: Equatable {
case validateCVV
case cvvRequested(SecurityCodeTokenRequestData)
case cvvResponse(SecurityCodeTokenRequestData, TokenResponseData)
case riskSDKCompletion

func event(date: Date) -> Event {
Event(
Expand Down Expand Up @@ -55,6 +56,8 @@ enum CheckoutLogEvent: Equatable {
return "card_validator_expiry_integer"
case .validateCVV:
return "card_validator_cvv"
case .riskSDKCompletion:
return "risk_sdk_completion"
}
}

Expand All @@ -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)
}
}
Expand All @@ -87,7 +92,8 @@ enum CheckoutLogEvent: Equatable {
.validateCardNumber,
.validateExpiryString,
.validateExpiryInteger,
.validateCVV:
.validateCVV,
.riskSDKCompletion:
return [:]
case let .tokenRequested(tokenRequestData):
return [
Expand Down
17 changes: 10 additions & 7 deletions Checkout/Source/Tokenisation/CheckoutAPIService.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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()
}
}

Expand Down
2 changes: 1 addition & 1 deletion CheckoutTests/Tokenisation/CheckoutAPIServiceTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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)
))
Expand Down
4 changes: 2 additions & 2 deletions Package.resolved
Original file line number Diff line number Diff line change
Expand Up @@ -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"
}
},
{
Expand Down
2 changes: 1 addition & 1 deletion Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit 40cd342

Please sign in to comment.