Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add exceededTimeoutLimit 3DS error #1354

Merged
merged 13 commits into from
Jul 17, 2024
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# Braintree iOS SDK Release Notes

## unreleased
* BraintreeThreeDSecure
* Add error code and error message for `exceededTimeoutLimit`
* Prevent duplicate outbound `v1/configuration` requests

## 6.23.0 (2024-07-15)
Expand Down
7 changes: 7 additions & 0 deletions Sources/BraintreeThreeDSecure/BTThreeDSecureError.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ public enum BTThreeDSecureError: Error, CustomNSError, LocalizedError, Equatable
/// 8. Deallocated BTThreeDSecureClient
case deallocated

/// 9. 3D Secure was idle and exceeded timout limit
case exceededTimeoutLimit

public static var errorDomain: String {
"com.braintreepayments.BTThreeDSecureFlowErrorDomain"
}
Expand All @@ -53,6 +56,8 @@ public enum BTThreeDSecureError: Error, CustomNSError, LocalizedError, Equatable
return 7
case .deallocated:
return 8
case .exceededTimeoutLimit:
return 9
}
}

Expand All @@ -76,6 +81,8 @@ public enum BTThreeDSecureError: Error, CustomNSError, LocalizedError, Equatable
return [NSLocalizedDescriptionKey: "The request could not be serialized."]
case .deallocated:
return [NSLocalizedDescriptionKey: "BTThreeDSecureClient has been deallocated."]
case .exceededTimeoutLimit:
return [NSLocalizedDescriptionKey: "User exceeded timeout limit."]
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,15 +121,17 @@ extension BTThreeDSecureV2Provider: CardinalValidationDelegate {
forResult: lookupResult,
completion: completionHandler
)
case .error, .timeout:
let userInfo = [NSLocalizedDescriptionKey: validateResponse.errorDescription]
case .error:
let errorUserInfo = [NSLocalizedDescriptionKey: validateResponse.errorDescription]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, the only diff should be on the case line. Right now we would only return if the errorNumber is 1050. We can revert the userInfo, errorCode, and completion diffs in this block

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just realized I left out this else statement that was part of the original .error case

else {
   completionHandler(nil, NSError(domain: BTThreeDSecureError.errorDomain, code: errorCode, userInfo: userInfo))

stechiu marked this conversation as resolved.
Show resolved Hide resolved
var errorCode: Int = BTThreeDSecureError.unknown.errorCode

if validateResponse.errorNumber == 1050 {
errorCode = BTThreeDSecureError.failedAuthentication("").errorCode
}
apiClient.sendAnalyticsEvent(BTThreeDSecureAnalytics.challengeFailed)
stechiu marked this conversation as resolved.
Show resolved Hide resolved
completionHandler(nil, NSError(domain: BTThreeDSecureError.errorDomain, code: errorCode, userInfo: userInfo))
completionHandler(nil, NSError(domain: BTThreeDSecureError.errorDomain, code: errorCode, userInfo: errorUserInfo))
case .timeout:
completionHandler(nil, BTThreeDSecureError.exceededTimeoutLimit)
case .cancel:
completionHandler(nil, BTThreeDSecureError.canceled)
default:
Expand Down
Loading