-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
fix(connector): [Bluesnap] Throw proper error message for redirection scenario #1367
Conversation
Signed-off-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
Signed-off-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
Signed-off-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
}) | ||
.map( | ||
|checkout_status| payments::CallConnectorAction::StatusUpdate { | ||
status: checkout_status.into(), |
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.
use from here
status: checkout_status.into(), | |
status: <Status>::from(checkout_status), |
crates/router/src/connector/utils.rs
Outdated
&self, | ||
) -> Result<(Secret<String>, Secret<String>), errors::ConnectorError> { | ||
let card_holder_name = self.card_holder_name.peek(); | ||
let words: Vec<&str> = card_holder_name.split_whitespace().collect(); |
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.
check for " "
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.
it works for " " too
crates/router/src/connector/utils.rs
Outdated
words.first().unwrap_or(&"").to_string() | ||
}); | ||
let last_name = Secret::new(if words.len() > 1 { | ||
words.last().unwrap_or(&"").to_string() |
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.
words.last().unwrap_or(&"").to_string() | |
words.last().unwrap_or_default() |
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.
we can't use unwrap_or_default()
here as the trait bound &&str: std::default::Default
is not satisfied
crates/router/src/connector/utils.rs
Outdated
let first_name = Secret::new(if words.len() > 1 { | ||
words[..words.len() - 1].join(" ") | ||
} else { | ||
words.first().unwrap_or(&"").to_string() |
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.
words.first().unwrap_or(&"").to_string() | |
words.first().unwrap_or_default() |
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
crates/router/src/services/api.rs
Outdated
let response = ErrorResponse { | ||
code: code.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()), | ||
message: message.unwrap_or_else(|| consts::NO_ERROR_MESSAGE.to_string()), | ||
status_code: 200, |
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.
Add a comment justifying why 200 is needed here
Signed-off-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
Signed-off-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
Signed-off-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
crates/router/src/services/api.rs
Outdated
payments::CallConnectorAction::StatusUpdate(status) => { | ||
payments::CallConnectorAction::StatusUpdate { | ||
status, | ||
code, |
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.
rename this to error_code & error_ message
crates/router/src/services/api.rs
Outdated
router_data.status = status; | ||
let error_response = code.zip(message).map(|(error_code, error_message)| { |
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.
This has to changed to or condition, zip will return tuple of values only if both the values are Some
Signed-off-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
Signed-off-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
error_message: redirection_result | ||
.info | ||
.as_ref() | ||
.and_then(|info| info.errors.as_ref().and_then(|error| error.first())) |
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.
Should we have rather joined the errors into a single string?
Type of Change
Description
This PR has following changes
1)
CardHolderInfo
field is added in payment request of Bluesnap2)Update error message and error code in statusUpdate in CallConnectorAction for redirection response
Additional Changes
Motivation and Context
Previously for connector bluesnap we were not sending proper error message when 3ds is disabled in dashboard . This pr modifies statusUpdate in CallConnectorAction by making it as struct which contains error message and error code as well . This PR also have
cardHolderInfo
field added in payment request for bluesnap .How did you test it?
i tested it locally and ran unit tests for bluesnap
Checklist
cargo +nightly fmt --all
cargo clippy