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

feat(connector): [DEUTSCHEBANK, FIUU ] Handle 2xx errors given by Connector #6727

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cookieg13
Copy link
Contributor

@cookieg13 cookieg13 commented Dec 3, 2024

Type of Change

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

Description

  1. Consuming error message given by DB in case of 2xx errors, because it is currently not handled for 2xx errors. Error message is only consumed for 4xx and 5xx.
  2. Also consuming error message given by Fiuu in case of 2xx errors in case of refunds. In other cases where 2xx errors are thrown code is already handling it.

Additional Changes

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

Motivation and Context

How did you test it?

Tested manually using Postman

  1. DB testing
    Test Doc
  2. Not able to test manually for Fiuu

Checklist

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

@cookieg13 cookieg13 self-assigned this Dec 3, 2024
@cookieg13 cookieg13 requested a review from a team as a code owner December 3, 2024 08:22
Copy link

semanticdiff-com bot commented Dec 3, 2024

Review changes with  SemanticDiff

Changed Files
File Status
  crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs  47% smaller
  crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs  46% smaller

@cookieg13 cookieg13 changed the title consume connector error message for 2xx errors for DeutscheBank feat(connector): [DEUTSCHEBANK] Consume connector error message for 2xx errors for DeutscheBank Dec 3, 2024
@cookieg13 cookieg13 changed the title feat(connector): [DEUTSCHEBANK] Consume connector error message for 2xx errors for DeutscheBank feat(connector): [DEUTSCHEBANK, FIUU ] Handle 2xx errors given by Connector Dec 4, 2024
Ok(Self {
response: Err(ErrorResponse {
code: response_status.clone(),
message: refund_data.reason.clone().unwrap_or("".to_owned()),
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 map this to NO_ERROR_MESSAGE in unwrap ?

Comment on lines +395 to +398
let response_code = item.response.rc.clone();
let is_response_success = is_response_success(response_code.clone());

if is_response_success {
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 response_code = item.response.rc.clone();
let is_response_success = is_response_success(response_code.clone());
if is_response_success {
if is_response_success(item.response.rc.clone()) {

Comment on lines +417 to +428
let error_reason = item.response.message.clone();
let response = Err(get_error_response(
response_code.clone(),
error_reason,
item.http_code,
));

Ok(Self {
status: common_enums::AttemptStatus::Failure,
response,
..item.data
})
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 error_reason = item.response.message.clone();
let response = Err(get_error_response(
response_code.clone(),
error_reason,
item.http_code,
));
Ok(Self {
status: common_enums::AttemptStatus::Failure,
response,
..item.data
})
Ok(Self {
status: common_enums::AttemptStatus::Failure,
response: Err(get_error_response(
response_code.clone(),
item.response.message.clone(),
item.http_code,
)),
..item.data
})

Comment on lines +359 to +370
let error_reason = item.response.message.clone();
let response = Err(get_error_response(
response_code.clone(),
error_reason,
item.http_code,
));

Ok(Self {
status: common_enums::AttemptStatus::Failure,
response,
..item.data
})
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 error_reason = item.response.message.clone();
let response = Err(get_error_response(
response_code.clone(),
error_reason,
item.http_code,
));
Ok(Self {
status: common_enums::AttemptStatus::Failure,
response,
..item.data
})
Ok(Self {
status: common_enums::AttemptStatus::Failure,
response: Err(get_error_response(
response_code.clone(),
item.response.message.clone(),
item.http_code,
)),
..item.data
})

Comment on lines +612 to +615
let response_code = item.response.rc.clone();
let is_response_success = is_response_success(response_code.clone());

if is_response_success {
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 response_code = item.response.rc.clone();
let is_response_success = is_response_success(response_code.clone());
if is_response_success {
if is_response_success(item.response.rc.clone()) {

Comment on lines +634 to +645
let error_reason = item.response.message.clone();
let response = Err(get_error_response(
response_code.clone(),
error_reason,
item.http_code,
));

Ok(Self {
status: common_enums::AttemptStatus::Failure,
response,
..item.data
})
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 error_reason = item.response.message.clone();
let response = Err(get_error_response(
response_code.clone(),
error_reason,
item.http_code,
));
Ok(Self {
status: common_enums::AttemptStatus::Failure,
response,
..item.data
})
Ok(Self {
status: common_enums::AttemptStatus::Failure,
response: Err(get_error_response(
response_code.clone(),
item.response.message.clone(),
item.http_code,
)),
..item.data
})

Comment on lines +899 to +902
let response_code = item.response.rc.clone();
let is_response_success = is_response_success(response_code.clone());

let status = if is_response_success {
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 response_code = item.response.rc.clone();
let is_response_success = is_response_success(response_code.clone());
let status = if is_response_success {
let status = if is_response_success(item.response.rc.clone()) {

Comment on lines +923 to +936
Some(enums::RefundStatus::Failure) => {
let error_reason = item.response.message.clone();
let response = Err(get_error_response(
response_code.clone(),
error_reason,
item.http_code,
));

Ok(Self {
status: common_enums::AttemptStatus::Failure,
response,
..item.data
})
}
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
Some(enums::RefundStatus::Failure) => {
let error_reason = item.response.message.clone();
let response = Err(get_error_response(
response_code.clone(),
error_reason,
item.http_code,
));
Ok(Self {
status: common_enums::AttemptStatus::Failure,
response,
..item.data
})
}
Some(enums::RefundStatus::Failure) => {
Ok(Self {
status: common_enums::AttemptStatus::Failure,
response: Err(get_error_response(
response_code.clone(),
item.response.message.clone(),
item.http_code,
)),
..item.data
})
}

Comment on lines +1022 to +1023
let response_status = refund_data.status;
let refund_status = match response_status.as_str() {
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 response_status = refund_data.status;
let refund_status = match response_status.as_str() {
let refund_status = match refund_data.status.as_str() {

Ok(Self {
response: Err(ErrorResponse {
code: response_status.clone(),
message: refund_data.reason.clone().unwrap_or("".to_owned()),
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
message: refund_data.reason.clone().unwrap_or("".to_owned()),
message: refund_data.reason.clone().unwrap_or(consts::NO_ERROR_MESSAGE),

@@ -991,6 +991,7 @@ pub struct FiuuRefundSuccessResponse {
#[serde(rename = "RefundID")]
refund_id: i64,
status: String,
reason: Option<String>,
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 getting this reason in response. Did you test it?

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.

3 participants