Repository: juspay/hyperswitch
File: crates/hyperswitch_connectors/src/connectors/nexixpay/transformers.rs (Rust)

Code before:
                get_random_string()
            };
        let billing_address_street = match (
            item.router_data.get_optional_billing_line1(),
            item.router_data.get_optional_billing_line2(),
        ) {
            (Some(line1), Some(line2)) => Some(Secret::new(format!(
                "{}, {}",
                line1.expose(),
                line2.expose()
            ))),
            (Some(line1), None) => Some(line1),
            (None, Some(line2)) => Some(line2),
            (None, None) => None,
        };

        let billing_address = item
            .router_data
            .get_optional_billing()
            .map(|_| {
                let name = item.router_data.get_optional_billing_full_name();
                if let Some(ref val) = name {
                    if val.clone().expose().len() > MAX_BILLING_ADDRESS_NAME_LENGTH {
                        return Err(error_stack::Report::from(
                            errors::ConnectorError::MaxFieldLengthViolated {
                                field_name: "Billing Name".to_string(),
                                connector: "Nexixpay".to_string(),
                            },
                        ));
                    }
                }

                if let Some(ref val) = billing_address_street {
                    if val.clone().expose().len() > MAX_BILLING_ADDRESS_STREET_LENGTH {
                        return Err(error_stack::Report::from(
                            errors::ConnectorError::MaxFieldLengthViolated {
                                field_name: "Billing Street".to_string(),
                                connector: "Nexixpay".to_string(),
                            },
                        ));
                    }
                }

                let city = item.router_data.get_optional_billing_city();
                if let Some(ref val) = city {
                    if val.len() > MAX_BILLING_ADDRESS_CITY_LENGTH {
                        return Err(error_stack::Report::from(
                            errors::ConnectorError::MaxFieldLengthViolated {
                                field_name: "Billing City".to_string(),
                                connector: "Nexixpay".to_string(),
                            },

Review comment (suggestion):
nit - better to add the field path here - which corresponds to Nexi's request 

so something like `address.billing.name` depending on the field

Code after:
            .or(update_request.three_d_s_auth_result),
        three_d_s_auth_response: nexixpay_meta_data
            .three_d_s_auth_response
            .or(update_request.three_d_s_auth_response),
        authorization_operation_id: nexixpay_meta_data
            .authorization_operation_id
            .clone()
            .or(update_request.authorization_operation_id.clone()),
        capture_operation_id: {
            nexixpay_meta_data
                .capture_operation_id
                .or(if update_request.is_auto_capture {
                    nexixpay_meta_data
                        .authorization_operation_id
                        .or(update_request.authorization_operation_id.clone())
                } else {
                    update_request.capture_operation_id
                })
        },
        cancel_operation_id: nexixpay_meta_data
            .cancel_operation_id
            .or(update_request.cancel_operation_id),
        psync_flow: update_request
            .psync_flow
            .unwrap_or(nexixpay_meta_data.psync_flow)
    }))
}

pub fn get_error_response(
    operation_result: NexixpayPaymentStatus,
    status_code: u16,
) -> ErrorResponse {
    ErrorResponse {
        status_code,
        code: NO_ERROR_CODE.to_string(),
        message: operation_result.to_string(),
        reason: Some(operation_result.to_string()),
        attempt_status: None,
        connector_transaction_id: None,
        network_advice_code: None,
        network_decline_code: None,
        network_error_message: None,
    }
}

#[derive(Debug, Clone, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct ThreeDSAuthData {
    three_d_s_auth_response: Option<Secret<String>>,
    authentication_value: Option<Secret<String>>,
}