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: added connector name from router data instead of MCA type in HS<>UCS tunnel (#10454)

Amitsingh Tanwar296290210598
diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs
index cb52e311ea..59f4ee91d0 100644
--- a/crates/router/src/core/payments/flows/authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/authorize_flow.rs
@@ -940,10 +940,13 @@ async fn call_unified_connector_service_authorize(
let merchant_connector_id = merchant_connector_account.get_mca_id();
- let connector_auth_metadata =
- build_unified_connector_service_auth_metadata(merchant_connector_account, platform)
- .change_context(ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to construct request metadata")?;
+ let connector_auth_metadata = build_unified_connector_service_auth_metadata(
+ merchant_connector_account,
+ platform,
+ router_data.connector.clone(),
+ )
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to construct request metadata")?;
let merchant_reference_id = header_payload
.x_reference_id
@@ -1154,10 +1157,13 @@ async fn call_unified_connector_service_pre_authenticate(
.change_context(ApiErrorResponse::InternalServerError)
.attach_printable("Failed to construct Payment Authorize Request")?;
- let connector_auth_metadata =
- build_unified_connector_service_auth_metadata(merchant_connector_account, platform)
- .change_context(ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to construct request metadata")?;
+ let connector_auth_metadata = build_unified_connector_service_auth_metadata(
+ merchant_connector_account,
+ platform,
+ router_data.connector.clone(),
+ )
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to construct request metadata")?;
let merchant_reference_id = header_payload
.x_reference_id
.clone()
@@ -1254,10 +1260,13 @@ async fn call_unified_connector_service_repeat_payment(
let merchant_connector_id = merchant_connector_account.get_mca_id();
- let connector_auth_metadata =
- build_unified_connector_service_auth_metadata(merchant_connector_account, platform)
- .change_context(ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to construct request metadata")?;
+ let connector_auth_metadata = build_unified_connector_service_auth_metadata(
+ merchant_connector_account,
+ platform,
+ router_data.connector.clone(),
+ )
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to construct request metadata")?;
let merchant_reference_id = header_payload
.x_reference_id
.clone()
diff --git a/crates/router/src/core/payments/flows/cancel_flow.rs b/crates/router/src/core/payments/flows/cancel_flow.rs
index 38eb2a3fca..6a1c22be1f 100644
--- a/crates/router/src/core/payments/flows/cancel_flow.rs
+++ b/crates/router/src/core/payments/flows/cancel_flow.rs
@@ -195,10 +195,13 @@ impl Feature<api::Void, types::PaymentsCancelData>
.change_context(ApiErrorResponse::InternalServerError)
.attach_printable("Failed to construct Payment Void Request")?;
- let connector_auth_metadata =
- build_unified_connector_service_auth_metadata(merchant_connector_account, platform)
- .change_context(ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to construct request metadata")?;
+ let connector_auth_metadata = build_unified_connector_service_auth_metadata(
+ merchant_connector_account,
+ platform,
+ self.connector.clone(),
+ )
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to construct request metadata")?;
let merchant_reference_id = header_payload
.x_reference_id
diff --git a/crates/router/src/core/payments/flows/capture_flow.rs b/crates/router/src/core/payments/flows/capture_flow.rs
index 621ebf767c..e04fc7482a 100644
--- a/crates/router/src/core/payments/flows/capture_flow.rs
+++ b/crates/router/src/core/payments/flows/capture_flow.rs
@@ -204,10 +204,13 @@ impl Feature<api::Capture, types::PaymentsCaptureData>
.change_context(ApiErrorResponse::InternalServerError)
.attach_printable("Failed to construct Payment Capture Request")?;
- let connector_auth_metadata =
- build_unified_connector_service_auth_metadata(merchant_connector_account, platform)
- .change_context(ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to construct request metadata")?;
+ let connector_auth_metadata = build_unified_connector_service_auth_metadata(
+ merchant_connector_account,
+ platform,
+ self.connector.clone(),
+ )
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to construct request metadata")?;
let merchant_reference_id = header_payload
.x_reference_id
.clone()
diff --git a/crates/router/src/core/payments/flows/complete_authorize_flow.rs b/crates/router/src/core/payments/flows/complete_authorize_flow.rs
index 4c4f3ec33c..eb33ebecd0 100644
--- a/crates/router/src/core/payments/flows/complete_authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/complete_authorize_flow.rs
@@ -542,6 +542,7 @@ async fn call_unified_connector_service_authenticate(
let connector_auth_metadata = ucs_core::build_unified_connector_service_auth_metadata(
merchant_connector_account,
platform,
+ router_data.connector.clone(),
)
.change_context(ApiErrorResponse::InternalServerError)
.attach_printable("Failed to construct request metadata")?;
@@ -659,6 +660,7 @@ async fn call_unified_connector_service_post_authenticate(
let connector_auth_metadata = ucs_core::build_unified_connector_service_auth_metadata(
merchant_connector_account,
platform,
+ router_data.connector.clone(),
)
.change_context(ApiErrorResponse::InternalServerError)
.attach_printable("Failed to construct request metadata")?;
@@ -878,6 +880,7 @@ async fn call_unified_connector_service_complete_authorize(
let connector_auth_metadata = ucs_core::build_unified_connector_service_auth_metadata(
merchant_connector_account,
platform,
+ router_data.connector.clone(),
)
.change_context(ApiErrorResponse::InternalServerError)
.attach_printable("Failed to construct request metadata")?;
diff --git a/crates/router/src/core/payments/flows/external_proxy_flow.rs b/crates/router/src/core/payments/flows/external_proxy_flow.rs
index 60ae091477..d56b60bb65 100644
--- a/crates/router/src/core/payments/flows/external_proxy_flow.rs
+++ b/crates/router/src/core/payments/flows/external_proxy_flow.rs
@@ -387,6 +387,7 @@ impl Feature<api::ExternalVaultProxy, types::ExternalVaultProxyPaymentsData>
unified_connector_service::build_unified_connector_service_auth_metadata(
merchant_connector_account,
platform,
+ self.connector.clone(),
)
.change_context(ApiErrorResponse::InternalServerError)
.attach_printable("Failed to construct request metadata")?;
diff --git a/crates/router/src/core/payments/flows/psync_flow.rs b/crates/router/src/core/payments/flows/psync_flow.rs
index daf3652734..aa84c430fd 100644
--- a/crates/router/src/core/payments/flows/psync_flow.rs
+++ b/crates/router/src/core/payments/flows/psync_flow.rs
@@ -342,6 +342,7 @@ impl Feature<api::PSync, types::PaymentsSyncData>
let connector_auth_metadata = build_unified_connector_service_auth_metadata(
merchant_connector_account,
platform,
+ self.connector.clone(),
)
.change_context(ApiErrorResponse::InternalServerError)
.attach_printable("Failed to construct request metadata")?;
diff --git a/crates/router/src/core/payments/flows/setup_mandate_flow.rs b/crates/router/src/core/payments/flows/setup_mandate_flow.rs
index 962cfeef46..bfaaccebc7 100644
--- a/crates/router/src/core/payments/flows/setup_mandate_flow.rs
+++ b/crates/router/src/core/payments/flows/setup_mandate_flow.rs
@@ -296,10 +296,13 @@ impl Feature<api::SetupMandate, types::SetupMandateRequestData> for types::Setup
let merchant_connector_id = merchant_connector_account.get_mca_id();
- let connector_auth_metadata =
- build_unified_connector_service_auth_metadata(merchant_connector_account, platform)
- .change_context(ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to construct request metadata")?;
+ let connector_auth_metadata = build_unified_connector_service_auth_metadata(
+ merchant_connector_account,
+ platform,
+ self.connector.clone(),
+ )
+ .change_context(ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to construct request metadata")?;
let merchant_reference_id = header_payload
.x_reference_id
.clone()
diff --git a/crates/router/src/core/payments/gateway/access_token_gateway.rs b/crates/router/src/core/payments/gateway/access_token_gateway.rs
index 0ec6f0b571..405750871e 100644
--- a/crates/router/src/core/payments/gateway/access_token_gateway.rs
+++ b/crates/router/src/core/payments/gateway/access_token_gateway.rs
@@ -99,6 +99,7 @@ where
unified_connector_service::build_unified_connector_service_auth_metadata(
merchant_connector_account.clone(),
&platform,
+ router_data.connector.clone(),
)
.change_context(ConnectorError::RequestEncodingFailed)
.attach_printable("Failed to construct request metadata")?;
diff --git a/crates/router/src/core/payments/gateway/authorize_gateway.rs b/crates/router/src/core/payments/gateway/authorize_gateway.rs
index d2711ca05d..4e85e723a7 100644
--- a/crates/router/src/core/payments/gateway/authorize_gateway.rs
+++ b/crates/router/src/core/payments/gateway/authorize_gateway.rs
@@ -88,6 +88,7 @@ where
unified_connector_service::build_unified_connector_service_auth_metadata(
merchant_connector_account,
&platform,
+ router_data.connector.clone(),
)
.change_context(ConnectorError::RequestEncodingFailed)
.attach_printable("Failed to construct request metadata")?;
diff --git a/crates/router/src/core/payments/gateway/create_customer_gateway.rs b/crates/router/src/core/payments/gateway/create_customer_gateway.rs
index 544f4a0af1..1bd8c86168 100644
--- a/crates/router/src/core/payments/gateway/create_customer_gateway.rs
+++ b/crates/router/src/core/payments/gateway/create_customer_gateway.rs
@@ -91,6 +91,7 @@ where
unified_connector_service::build_unified_connector_service_auth_metadata(
merchant_connector_account,
&platform,
+ router_data.connector.clone(),
)
.change_context(ConnectorError::RequestEncodingFailed)
.attach_printable("Failed to construct request metadata")?;
diff --git a/crates/router/src/core/payments/gateway/create_order_gateway.rs b/crates/router/src/core/payments/gateway/create_order_gateway.rs
index 22d315c699..7144b11a26 100644
--- a/crates/router/src/core/payments/gateway/create_order_gateway.rs
+++ b/crates/router/src/core/payments/gateway/create_order_gateway.rs
@@ -86,6 +86,7 @@ where
unified_connector_service::build_unified_connector_service_auth_metadata(
merchant_connector_account,
&platform,
+ router_data.connector.clone(),
)
.change_context(ConnectorError::RequestEncodingFailed)
.attach_printable("Failed to construct request metadata")?;
diff --git a/crates/router/src/core/payments/gateway/payment_method_token_create_gateway.rs b/crates/router/src/core/payments/gateway/payment_method_token_create_gateway.rs
index dab3786305..3fd3cc1c51 100644
--- a/crates/router/src/core/payments/gateway/payment_method_token_create_gateway.rs
+++ b/crates/router/src/core/payments/gateway/payment_method_token_create_gateway.rs
@@ -94,6 +94,7 @@ where
unified_connector_service::build_unified_connector_service_auth_metadata(
merchant_connector_account,
&platform,
+ router_data.connector.clone(),
)
.change_context(ConnectorError::RequestEncodingFailed)
.attach_printable("Failed to construct request metadata")?;
diff --git a/crates/router/src/core/payments/gateway/psync_gateway.rs b/crates/router/src/core/payments/gateway/psync_gateway.rs
index d0d70b3a8d..ac861ef72f 100644
--- a/crates/router/src/core/payments/gateway/psync_gateway.rs
+++ b/crates/router/src/core/payments/gateway/psync_gateway.rs
@@ -109,6 +109,7 @@ where
unified_connector_service::build_unified_connector_service_auth_metadata(
merchant_connector_account,
&platform,
+ router_data.connector.clone(),
)
.change_context(ConnectorError::RequestEncodingFailed)
.attach_printable("Failed to construct request metadata")?;
diff --git a/crates/router/src/core/payments/gateway/session_token_gateway.rs b/crates/router/src/core/payments/gateway/session_token_gateway.rs
index 1b3f8e6a10..cce70030d2 100644
--- a/crates/router/src/core/payments/gateway/session_token_gateway.rs
+++ b/crates/router/src/core/payments/gateway/session_token_gateway.rs
@@ -89,6 +89,7 @@ where
unified_connector_service::build_unified_connector_service_auth_metadata(
merchant_connector_account,
&platform,
+ router_data.connector.clone(),
)
.change_context(ConnectorError::RequestEncodingFailed)
.attach_printable("Failed to construct request metadata")?;
diff --git a/crates/router/src/core/payments/gateway/setup_mandate.rs b/crates/router/src/core/payments/gateway/setup_mandate.rs
index 5efae6b3cf..08872b980b 100644
--- a/crates/router/src/core/payments/gateway/setup_mandate.rs
+++ b/crates/router/src/core/payments/gateway/setup_mandate.rs
@@ -84,6 +84,7 @@ where
unified_connector_service::build_unified_connector_service_auth_metadata(
merchant_connector_account,
&platform,
+ router_data.connector.clone(),
)
.change_context(ConnectorError::RequestEncodingFailed)
.attach_printable("Failed to construct request metadata")?;
diff --git a/crates/router/src/core/unified_connector_service.rs b/crates/router/src/core/unified_connector_service.rs
index 2a51998408..2da9083a9a 100644
--- a/crates/router/src/core/unified_connector_service.rs
+++ b/crates/router/src/core/unified_connector_service.rs
@@ -978,6 +978,7 @@ pub fn build_unified_connector_service_auth_metadata(
#[cfg(feature = "v1")] merchant_connector_account: MerchantConnectorAccountType,
#[cfg(feature = "v2")] merchant_connector_account: MerchantConnectorAccountTypeDetails,
platform: &Platform,
+ connector_name: String,
) -> CustomResult<ConnectorAuthMetadata, UnifiedConnectorServiceError> {
#[cfg(feature = "v1")]
let auth_type: ConnectorAuthType = merchant_connector_account
@@ -992,25 +993,6 @@ pub fn build_unified_connector_service_auth_metadata(
.change_context(UnifiedConnectorServiceError::FailedToObtainAuthType)
.attach_printable("Failed to obtain ConnectorAuthType")?;
- let connector_name = {
- #[cfg(feature = "v1")]
- {
- merchant_connector_account
- .get_connector_name()
- .ok_or(UnifiedConnectorServiceError::MissingConnectorName)
- .attach_printable("Missing connector name")?
- }
-
- #[cfg(feature = "v2")]
- {
- merchant_connector_account
- .get_connector_name()
- .map(|connector| connector.to_string())
- .ok_or(UnifiedConnectorServiceError::MissingConnectorName)
- .attach_printable("Missing connector name")?
- }
- };
-
let merchant_id = platform
.get_processor()
.get_account()
@@ -1478,7 +1460,11 @@ pub async fn call_unified_connector_service_for_webhook(
mca.clone(),
));
- build_unified_connector_service_auth_metadata(mca_type, platform)
+ build_unified_connector_service_auth_metadata(
+ mca_type,
+ platform,
+ connector_name.to_string(),
+ )
})
.transpose()
.change_context(errors::ApiErrorResponse::InternalServerError)
@@ -1903,10 +1889,13 @@ pub async fn call_unified_connector_service_for_refund_execute(
let ucs_client = get_ucs_client(state)?;
// Build auth metadata using standard UCS function
- let connector_auth_metadata =
- build_unified_connector_service_auth_metadata(merchant_connector_account, platform)
- .change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to build UCS auth metadata for refund execute")?;
+ let connector_auth_metadata = build_unified_connector_service_auth_metadata(
+ merchant_connector_account,
+ platform,
+ router_data.connector.clone(),
+ )
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to build UCS auth metadata for refund execute")?;
// Transform router data to UCS refund request
let ucs_refund_request =
@@ -1974,10 +1963,13 @@ pub async fn call_unified_connector_service_for_refund_sync(
let ucs_client = get_ucs_client(state)?;
// Build auth metadata using standard UCS function
- let connector_auth_metadata =
- build_unified_connector_service_auth_metadata(merchant_connector_account, platform)
- .change_context(errors::ApiErrorResponse::InternalServerError)
- .attach_printable("Failed to build UCS auth metadata for refund sync")?;
+ let connector_auth_metadata = build_unified_connector_service_auth_metadata(
+ merchant_connector_account,
+ platform,
+ router_data.connector.clone(),
+ )
+ .change_context(errors::ApiErrorResponse::InternalServerError)
+ .attach_printable("Failed to build UCS auth metadata for refund sync")?;
// Transform router data to UCS refund sync request
let ucs_refund_sync_request =