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
Merged

Add exceededTimeoutLimit 3DS error #1354

merged 13 commits into from
Jul 17, 2024

Conversation

stechiu
Copy link
Collaborator

@stechiu stechiu commented Jul 3, 2024

Summary of changes

  • Added exceededTimeoutLimit error code and error message

Checklist

  • Added a changelog entry

Authors

List GitHub usernames for everyone who contributed to this pull request.

@stechiu stechiu requested a review from a team as a code owner July 3, 2024 00:15
@@ -122,14 +122,20 @@ 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

Comment on lines 131 to 134
} else if validateResponse.actionCode == .timeout {
errorCode = BTThreeDSecureError.exceededTimeoutLimit.errorCode
userInfo = [NSLocalizedDescriptionKey: BTThreeDSecureError.exceededTimeoutLimit.localizedDescription]
completionHandler(nil, BTThreeDSecureError.exceededTimeoutLimit)
Copy link
Contributor

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?

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'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)
Copy link
Contributor

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

Copy link
Contributor

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.

Copy link
Collaborator Author

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]>
Copy link
Contributor

@sshropshire sshropshire left a comment

Choose a reason for hiding this comment

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

👏

CHANGELOG.md Outdated Show resolved Hide resolved
Comment on lines 134 to 138
let timeoutUserInfo = [NSLocalizedDescriptionKey: BTThreeDSecureError.exceededTimeoutLimit.localizedDescription]

if validateResponse.actionCode == .timeout {
errorCode = BTThreeDSecureError.exceededTimeoutLimit.errorCode
completionHandler(nil, NSError(domain: timeoutUserInfo.description, code: errorCode, userInfo: timeoutUserInfo))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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)

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 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

Copy link
Collaborator Author

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

Copy link
Contributor

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
Copy link
Contributor

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]
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))

Copy link
Contributor

@jaxdesmarais jaxdesmarais left a 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.

@stechiu
Copy link
Collaborator Author

stechiu commented Jul 17, 2024

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 else statement from the original code to the .error case. That will fix the issue

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

Comment on lines 134 to 138
let timeoutUserInfo = [NSLocalizedDescriptionKey: BTThreeDSecureError.exceededTimeoutLimit.localizedDescription]

if validateResponse.actionCode == .timeout {
errorCode = BTThreeDSecureError.exceededTimeoutLimit.errorCode
completionHandler(nil, NSError(domain: timeoutUserInfo.description, code: errorCode, userInfo: timeoutUserInfo))
Copy link
Contributor

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)

stechiu added 3 commits July 17, 2024 12:02
…braintree_ios into add-3ds-timeout-error

# Conflicts:
#	Sources/BraintreeThreeDSecure/BTThreeDSecureV2Provider.swift
…o add-3ds-timeout-error

# Conflicts:
#	CHANGELOG.md
Copy link
Contributor

@jaxdesmarais jaxdesmarais left a 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!

@stechiu stechiu merged commit 7c9a542 into main Jul 17, 2024
7 of 8 checks passed
@stechiu stechiu deleted the add-3ds-timeout-error branch July 17, 2024 19:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants