Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

fix(ucs): propagate connector_transaction_id on UCS authorize connector-error path (#17181) (#13042)

10X-GRACEdbc723cad176
diff --git a/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs b/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs
index 9a8cc6a28b..63a246c30e 100644
--- a/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs
+++ b/crates/hyperswitch_interfaces/src/unified_connector_service/transformers.rs
@@ -242,6 +242,9 @@ pub struct ConnectorErrorInner {
pub reason: Option<String>,
/// Name of the connector that returned the error
pub connector: String,
+ /// Connector's unique transaction identifier (e.g. Adyen `pspReference`), when the
+ /// connector returns one alongside the error response
+ pub connector_transaction_id: Option<String>,
/// Network decline code from card scheme (e.g. Visa/Mastercard decline code)
pub network_decline_code: Option<String>,
/// Network advice code for retry logic
@@ -1010,6 +1013,11 @@ impl UnifiedConnectorServiceError {
.and_then(|ei| ei.connector_details.as_ref())
.and_then(|cd| cd.reason.clone()),
connector: connector_name.to_string(),
+ connector_transaction_id: connector_error
+ .error_info
+ .as_ref()
+ .and_then(|ei| ei.connector_details.as_ref())
+ .and_then(|cd| cd.connector_transaction_id.clone()),
network_decline_code: connector_error
.error_info
.as_ref()
diff --git a/crates/router/src/core/payments/gateway/authorize_gateway.rs b/crates/router/src/core/payments/gateway/authorize_gateway.rs
index b559436ff5..efe70702bf 100644
--- a/crates/router/src/core/payments/gateway/authorize_gateway.rs
+++ b/crates/router/src/core/payments/gateway/authorize_gateway.rs
@@ -150,10 +150,12 @@ where
report.current_context()
{
let (code, message, status_code, reason,
+ connector_transaction_id,
network_decline_code, network_advice_code,
network_error_message, connector) = (
&inner.code, &inner.message, inner.status_code,
- &inner.reason, &inner.network_decline_code,
+ &inner.reason, &inner.connector_transaction_id,
+ &inner.network_decline_code,
&inner.network_advice_code, &inner.network_error_message,
&inner.connector,
);
@@ -171,7 +173,7 @@ where
reason: reason.clone(),
status_code,
attempt_status: None,
- connector_transaction_id: None,
+ connector_transaction_id: connector_transaction_id.clone(),
connector_response_reference_id: None,
network_decline_code: network_decline_code.clone(),
network_advice_code: network_advice_code.clone(),
@@ -277,6 +279,7 @@ where
message,
status_code,
reason,
+ connector_transaction_id,
network_decline_code,
network_advice_code,
network_error_message,
@@ -286,6 +289,7 @@ where
&inner.message,
inner.status_code,
&inner.reason,
+ &inner.connector_transaction_id,
&inner.network_decline_code,
&inner.network_advice_code,
&inner.network_error_message,
@@ -305,7 +309,7 @@ where
reason: reason.clone(),
status_code,
attempt_status: None,
- connector_transaction_id: None,
+ connector_transaction_id: connector_transaction_id.clone(),
connector_response_reference_id: None,
network_decline_code: network_decline_code.clone(),
network_advice_code: network_advice_code.clone(),