Repository: juspay/hyperswitch
File: crates/router/src/services/api.rs (Rust)

Code before:
    >;

pub type BoxedUnifiedAuthenticationServiceInterface<T, Req, Resp> =
    BoxedConnectorIntegrationInterface<T, common_types::UasFlowData, Req, Resp>;

pub type BoxedBillingConnectorPaymentsSyncIntegrationInterface<T, Req, Res> =
    BoxedConnectorIntegrationInterface<
        T,
        common_types::BillingConnectorPaymentsSyncFlowData,
        Req,
        Res,
    >;
pub type BoxedVaultConnectorIntegrationInterface<T, Req, Res> =
    BoxedConnectorIntegrationInterface<T, common_types::VaultConnectorFlowData, Req, Res>;

/// Handle UCS webhook response processing
fn handle_ucs_response<T, Req, Resp>(
    router_data: types::RouterData<T, Req, Resp>,
    transform_data_bytes: Vec<u8>,
) -> CustomResult<types::RouterData<T, Req, Resp>, errors::ConnectorError>
where
    T: Clone + Debug + 'static,
    Req: Debug + Clone + 'static,
    Resp: Debug + Clone + 'static,
{
    let webhook_transform_data: crate::core::unified_connector_service::WebhookTransformData =
        serde_json::from_slice(&transform_data_bytes)
            .change_context(errors::ConnectorError::ResponseDeserializationFailed)
            .attach_printable("Failed to deserialize UCS webhook transform data")?;

    let webhook_content = webhook_transform_data
        .webhook_content
        .ok_or(errors::ConnectorError::ResponseDeserializationFailed)
        .attach_printable("UCS webhook transform data missing webhook_content")?;

    let payment_get_response = match webhook_content.content {
        Some(unified_connector_service_client::payments::webhook_response_content::Content::PaymentsResponse(payments_response)) => {
            payments_response
        },
        Some(unified_connector_service_client::payments::webhook_response_content::Content::RefundsResponse(_)) => {
            return Err(errors::ConnectorError::ProcessingStepFailed(Some("UCS webhook contains refund response but payment processing was expected".to_string().into())).into());
        },
        Some(unified_connector_service_client::payments::webhook_response_content::Content::DisputesResponse(_)) => {
            return Err(errors::ConnectorError::ProcessingStepFailed(Some("UCS webhook contains dispute response but payment processing was expected".to_string().into())).into());
        },
        None => {
            return Err(errors::ConnectorError::ResponseDeserializationFailed)
                .attach_printable("UCS webhook content missing payments_response");
        }
    };


Review comment (suggestion):
```suggestion
    let webhook_transform_data: unified_connector_service::WebhookTransformData =
```

Code after:
    >;

pub type BoxedUnifiedAuthenticationServiceInterface<T, Req, Resp> =
    BoxedConnectorIntegrationInterface<T, common_types::UasFlowData, Req, Resp>;

pub type BoxedBillingConnectorPaymentsSyncIntegrationInterface<T, Req, Res> =
    BoxedConnectorIntegrationInterface<
        T,
        common_types::BillingConnectorPaymentsSyncFlowData,
        Req,
        Res,
    >;
pub type BoxedVaultConnectorIntegrationInterface<T, Req, Res> =
    BoxedConnectorIntegrationInterface<T, common_types::VaultConnectorFlowData, Req, Res>;

/// Handle UCS webhook response processing
fn handle_ucs_response<T, Req, Resp>(
    router_data: types::RouterData<T, Req, Resp>,
    transform_data_bytes: Vec<u8>,
) -> CustomResult<types::RouterData<T, Req, Resp>, errors::ConnectorError>
where
    T: Clone + Debug + 'static,
    Req: Debug + Clone + 'static,
    Resp: Debug + Clone + 'static,
{
    let webhook_transform_data: unified_connector_service::WebhookTransformData =
        serde_json::from_slice(&transform_data_bytes)
            .change_context(errors::ConnectorError::ResponseDeserializationFailed)
            .attach_printable("Failed to deserialize UCS webhook transform data")?;

    let webhook_content = webhook_transform_data
        .webhook_content
        .ok_or(errors::ConnectorError::ResponseDeserializationFailed)
        .attach_printable("UCS webhook transform data missing webhook_content")?;

    let payment_get_response = match webhook_content.content {
        Some(unified_connector_service_client::payments::webhook_response_content::Content::PaymentsResponse(payments_response)) => {
            Ok(payments_response)
        },
        Some(unified_connector_service_client::payments::webhook_response_content::Content::RefundsResponse(_)) => {
            Err(errors::ConnectorError::ProcessingStepFailed(Some("UCS webhook contains refund response but payment processing was expected".to_string().into())).into())
        },
        Some(unified_connector_service_client::payments::webhook_response_content::Content::DisputesResponse(_)) => {
            Err(errors::ConnectorError::ProcessingStepFailed(Some("UCS webhook contains dispute response but payment processing was expected".to_string().into())).into())
        },
        None => {
            Err(errors::ConnectorError::ResponseDeserializationFailed)
                .attach_printable("UCS webhook content missing payments_response")
        }
    }?;