Skip to content

Commit

Permalink
consume txn id for error cases for worldpay, adyen
Browse files Browse the repository at this point in the history
  • Loading branch information
cookieg13 committed Jan 20, 2025
1 parent 37f10fb commit 6697c13
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion 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
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

0 comments on commit 6697c13

Please sign in to comment.