-
Notifications
You must be signed in to change notification settings - Fork 295
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
Conversation
Co-authored-by: scannillo <[email protected]>
Co-authored-by: scannillo <[email protected]>
@@ -122,14 +122,20 @@ extension BTThreeDSecureV2Provider: CardinalValidationDelegate { | |||
completion: completionHandler | |||
) | |||
case .error, .timeout: | |||
let userInfo = [NSLocalizedDescriptionKey: validateResponse.errorDescription] | |||
var userInfo = [NSLocalizedDescriptionKey: validateResponse.errorDescription] |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
} else if validateResponse.actionCode == .timeout { | ||
errorCode = BTThreeDSecureError.exceededTimeoutLimit.errorCode | ||
userInfo = [NSLocalizedDescriptionKey: BTThreeDSecureError.exceededTimeoutLimit.localizedDescription] | ||
completionHandler(nil, BTThreeDSecureError.exceededTimeoutLimit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Are we able to add a test for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll create a ticket to add tests for this and BTThreeDSecureV2Provider
. There doesn't seem to be a straightforward way to test cardinal responses or action codes
userInfo = [NSLocalizedDescriptionKey: BTThreeDSecureError.exceededTimeoutLimit.localizedDescription] | ||
completionHandler(nil, BTThreeDSecureError.exceededTimeoutLimit) | ||
} else { | ||
completionHandler(nil, BTThreeDSecureError.exceededTimeoutLimit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think we want our catch all else block to throw the timeout error
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think also we can on line 124 break out the case .error, .timeout:
into 2 separate cases where the new timeout case can throw the new error you added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea, makes it cleaner
Co-authored-by: Rich Herrera <[email protected]>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏
let timeoutUserInfo = [NSLocalizedDescriptionKey: BTThreeDSecureError.exceededTimeoutLimit.localizedDescription] | ||
|
||
if validateResponse.actionCode == .timeout { | ||
errorCode = BTThreeDSecureError.exceededTimeoutLimit.errorCode | ||
completionHandler(nil, NSError(domain: timeoutUserInfo.description, code: errorCode, userInfo: timeoutUserInfo)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
let timeoutUserInfo = [NSLocalizedDescriptionKey: BTThreeDSecureError.exceededTimeoutLimit.localizedDescription] | |
if validateResponse.actionCode == .timeout { | |
errorCode = BTThreeDSecureError.exceededTimeoutLimit.errorCode | |
completionHandler(nil, NSError(domain: timeoutUserInfo.description, code: errorCode, userInfo: timeoutUserInfo)) | |
completionHandler(nil, BTThreeDSecureError.exceededTimeoutLimit) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried running your suggestion and setting a breakpoint at validateResponse.actionCode
. The errorCode
returns as 0
instead of 9
when I reach the max timeout limited
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
9
is the error code for .exceededTimoutLimit
and it's what was missing before. I know that, in theory, the suggested refactored code should work. I'm using po errorCode
in the debugger but might need to test something else that returns the correct error code and error description, so let me know
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 if that is the case then something is certainly wrong with our logic. We do the same as my suggestion for cancel below and get the expected error code back so should be able to do the same here:
case .timeout:
completionHandler(nil, BTThreeDSecureError.exceededTimoutLimit)
@@ -14,6 +14,7 @@ class BTThreeDSecureV2Provider { | |||
|
|||
var lookupResult: BTThreeDSecureResult? = nil | |||
var completionHandler: (BTThreeDSecureResult?, Error?) -> Void = { _, _ in } | |||
var errorCode: Int = BTThreeDSecureError.unknown.errorCode |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can revert this change
let userInfo = [NSLocalizedDescriptionKey: validateResponse.errorDescription] | ||
var errorCode: Int = BTThreeDSecureError.unknown.errorCode | ||
case .error: | ||
let errorUserInfo = [NSLocalizedDescriptionKey: validateResponse.errorDescription] |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Blocking for now since there are some changes that would only return an error to the merchant for 1 error number. This would cause issues for merchants getting other errors.
I've added back this missing
|
let timeoutUserInfo = [NSLocalizedDescriptionKey: BTThreeDSecureError.exceededTimeoutLimit.localizedDescription] | ||
|
||
if validateResponse.actionCode == .timeout { | ||
errorCode = BTThreeDSecureError.exceededTimeoutLimit.errorCode | ||
completionHandler(nil, NSError(domain: timeoutUserInfo.description, code: errorCode, userInfo: timeoutUserInfo)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🤔 if that is the case then something is certainly wrong with our logic. We do the same as my suggestion for cancel below and get the expected error code back so should be able to do the same here:
case .timeout:
completionHandler(nil, BTThreeDSecureError.exceededTimoutLimit)
…braintree_ios into add-3ds-timeout-error # Conflicts: # Sources/BraintreeThreeDSecure/BTThreeDSecureV2Provider.swift
…o add-3ds-timeout-error # Conflicts: # CHANGELOG.md
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👏 Thanks for addressing feedback and getting a more specific error message added for our merchants!
Summary of changes
exceededTimeoutLimit
error code and error messageChecklist
Authors