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

fix(connector): [Bluesnap] Throw proper error message for redirection scenario #1367

Merged
merged 16 commits into from
Jun 9, 2023

Conversation

srujanchikke
Copy link
Contributor

Type of Change

  • Bugfix
  • New feature
  • Enhancement
  • Refactoring
  • Dependency updates
  • Documentation
  • CI/CD

Description

This PR has following changes
1)CardHolderInfo field is added in payment request of Bluesnap
2)Update error message and error code in statusUpdate in CallConnectorAction for redirection response

Additional Changes

  • This PR modifies the API contract
  • This PR modifies the database schema
  • This PR modifies application configuration/environment variables

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

Screenshot 2023-06-06 at 4 00 36 PM Screenshot 2023-06-06 at 8 15 38 PM

Checklist

  • I formatted the code cargo +nightly fmt --all
  • I addressed lints thrown by cargo clippy
  • I reviewed submitted code
  • I added unit tests for my changes where possible
  • I added a CHANGELOG entry if applicable

Signed-off-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
Signed-off-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
@srujanchikke srujanchikke added A-connector-integration Area: Connector integration A-core Area: Core flows C-bug Category: Bug R-waiting-on-L1 Review: Waiting on L1 reviewer labels Jun 6, 2023
@srujanchikke srujanchikke requested a review from a team as a code owner June 6, 2023 14:48
@srujanchikke srujanchikke self-assigned this Jun 6, 2023
@srujanchikke srujanchikke requested review from a team as code owners June 6, 2023 14:48
@github-actions github-actions bot added the S-conventions-not-followed Status: This PR does not follow contributing guidelines label Jun 6, 2023
@srujanchikke srujanchikke changed the title fix(connector) :[Bluesnap] Throw proper error message for redirection scenario fix(connector): [Bluesnap] Throw proper error message for redirection scenario Jun 6, 2023
@github-actions github-actions bot removed the S-conventions-not-followed Status: This PR does not follow contributing guidelines label Jun 6, 2023
})
.map(
|checkout_status| payments::CallConnectorAction::StatusUpdate {
status: checkout_status.into(),
Copy link
Contributor

Choose a reason for hiding this comment

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

use from here

Suggested change
status: checkout_status.into(),
status: <Status>::from(checkout_status),

&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();
Copy link
Contributor

Choose a reason for hiding this comment

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

check for " "

Copy link
Contributor Author

Choose a reason for hiding this comment

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

it works for " " too

words.first().unwrap_or(&"").to_string()
});
let last_name = Secret::new(if words.len() > 1 {
words.last().unwrap_or(&"").to_string()
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
words.last().unwrap_or(&"").to_string()
words.last().unwrap_or_default()

Copy link
Contributor Author

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

let first_name = Secret::new(if words.len() > 1 {
words[..words.len() - 1].join(" ")
} else {
words.first().unwrap_or(&"").to_string()
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
words.first().unwrap_or(&"").to_string()
words.first().unwrap_or_default()

Copy link
Contributor Author

Choose a reason for hiding this comment

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

same here

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

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>
jagan-jaya
jagan-jaya previously approved these changes Jun 8, 2023
@jagan-jaya jagan-jaya removed the R-waiting-on-L1 Review: Waiting on L1 reviewer label Jun 8, 2023
@jagan-jaya jagan-jaya added R-waiting-on-L2 Review: Waiting on L2 reviewer R-L1-completed Review: L1 Review completed labels Jun 8, 2023
payments::CallConnectorAction::StatusUpdate(status) => {
payments::CallConnectorAction::StatusUpdate {
status,
code,
Copy link
Contributor

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

router_data.status = status;
let error_response = code.zip(message).map(|(error_code, error_message)| {
Copy link
Contributor

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>
ArjunKarthik
ArjunKarthik previously approved these changes Jun 9, 2023
Signed-off-by: chikke srujan <121822803+srujanchikke@users.noreply.github.com>
@jagan-jaya jagan-jaya added S-ready-for-merge R-L2-completed Review: L2 Review completed and removed R-waiting-on-L2 Review: Waiting on L2 reviewer labels Jun 9, 2023
@jagan-jaya jagan-jaya enabled auto-merge June 9, 2023 13:27
error_message: redirection_result
.info
.as_ref()
.and_then(|info| info.errors.as_ref().and_then(|error| error.first()))
Copy link
Member

@lsampras lsampras Jun 9, 2023

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?

@jagan-jaya jagan-jaya added this pull request to the merge queue Jun 9, 2023
Merged via the queue into main with commit 4a8de77 Jun 9, 2023
@SanchithHegde SanchithHegde deleted the bluesnap_fixes branch June 13, 2023 07:47
@SanchithHegde SanchithHegde removed S-ready-for-merge R-L1-completed Review: L1 Review completed R-L2-completed Review: L2 Review completed labels Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-connector-integration Area: Connector integration A-core Area: Core flows C-bug Category: Bug
Projects
No open projects
Status: Merged
Development

Successfully merging this pull request may close these issues.

8 participants