Skip to content

Conversation

dgeee13
Copy link
Contributor

@dgeee13 dgeee13 commented Dec 3, 2024

Type of Change

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

Description

  1. Consuming error message given by DeutscheBank in case of 2xx errors, because it is currently not handled for 2xx errors. Error message is only consumed for 4xx and 5xx.
  2. Consuming error message given by Fiuu in case of 2xx errors only in case of refunds. In all 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

@dgeee13 dgeee13 self-assigned this Dec 3, 2024
@dgeee13 dgeee13 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/deutschebank/transformers.rs  49% smaller
  crates/hyperswitch_connectors/src/connectors/fiuu/transformers.rs  43% smaller

@dgeee13 dgeee13 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
@dgeee13 dgeee13 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 418
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 630
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?

Copy link
Contributor Author

@dgeee13 dgeee13 Dec 5, 2024

Choose a reason for hiding this comment

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

no @deepanshu-iiitu , not able to test this . reason is an optional field and will only come in unsucessful refund cases . Not able to test this unsuccesful refund flow locally

Copy link
Contributor

Choose a reason for hiding this comment

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

You could reach out to @awasthi21 to check if he knows how to trigger unsuccessful refunds.

@dgeee13 dgeee13 force-pushed the handle2xxErrorDB branch 2 times, most recently from d27ada7 to f0239cd Compare December 5, 2024 10:16
@@ -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.

You could reach out to @awasthi21 to check if he knows how to trigger unsuccessful refunds.

@Gnanasundari24 Gnanasundari24 added this pull request to the merge queue Dec 12, 2024
Merged via the queue into main with commit 573fc2c Dec 12, 2024
20 of 22 checks passed
@Gnanasundari24 Gnanasundari24 deleted the handle2xxErrorDB branch December 12, 2024 10:20
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.

4 participants