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): [ADYEN, WORLDPAY ] Consume transaction id for error cases #7061

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions crates/hyperswitch_connectors/src/connectors/worldpay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ impl ConnectorCommon for Worldpay {
WorldpayErrorResponse::default(res.status_code)
};

let optional_correlation_id = res.headers.and_then(|headers| {
headers
.get(WP_CORRELATION_ID)
.and_then(|header_value| header_value.to_str().ok())
.map(|id| id.to_string())
});

event_builder.map(|i| i.set_error_response_body(&response));
router_env::logger::info!(connector_response=?response);

Expand All @@ -155,7 +162,7 @@ impl ConnectorCommon for Worldpay {
message: response.message,
reason: response.validation_errors.map(|e| e.to_string()),
attempt_status: Some(enums::AttemptStatus::Failure),
connector_transaction_id: None,
connector_transaction_id: optional_correlation_id,
})
}
}
Expand Down Expand Up @@ -475,14 +482,20 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Wor

event_builder.map(|i| i.set_error_response_body(&response));
router_env::logger::info!(connector_response=?response);
let optional_correlation_id = res.headers.and_then(|headers| {
headers
.get(WP_CORRELATION_ID)
.and_then(|header_value| header_value.to_str().ok())
.map(|id| id.to_string())
});

Ok(ErrorResponse {
status_code: res.status_code,
code: response.error_name,
message: response.message,
reason: response.validation_errors.map(|e| e.to_string()),
attempt_status: None,
connector_transaction_id: None,
connector_transaction_id: optional_correlation_id,
})
}

Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/adyen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ impl
reason: Some(consts::LOW_BALANCE_ERROR_MESSAGE.to_string()),
status_code: res.status_code,
attempt_status: Some(enums::AttemptStatus::Failure),
connector_transaction_id: None,
connector_transaction_id: Some(response.psp_reference),
}),
..data.clone()
})
Expand Down
Loading