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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Braintree iOS SDK Release Notes

## unreleased
* BraintreeThreeDSecure
* Add error code and error message for `exceededTimeoutLimit`
stechiu marked this conversation as resolved.
Show resolved Hide resolved

## 6.22.0 (2024-07-02)
* BraintreeThreeDSecure
* Add `customFields` param to `BTThreeDSecureRequest`
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
12 changes: 10 additions & 2 deletions Sources/BraintreeThreeDSecure/BTThreeDSecureV2Provider.swift
Original file line number Diff line number Diff line change
Expand Up @@ -122,14 +122,22 @@ extension BTThreeDSecureV2Provider: CardinalValidationDelegate {
completion: completionHandler
)
case .error, .timeout:
let userInfo = [NSLocalizedDescriptionKey: validateResponse.errorDescription]
var userInfo = [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.

Can we remove userInfo and errorCode since we're not using them?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

userInfo and errorCode get used within the case so we'll need to keep them... I can move errorCode as a global variable. Since I'm splitting off .error and .timeout, I'll keep userInfo in as local variable

var errorCode: Int = BTThreeDSecureError.unknown.errorCode

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