Repository: juspay/hyperswitch
File: crates/router/src/core/admin.rs (Rust)

Code before:
        key_store: &domain::MerchantKeyStore,
        business_profile: &domain::Profile,
    ) -> RouterResult<domain::ProfileUpdate>;
}

#[cfg(all(feature = "olap", feature = "v1"))]
#[async_trait::async_trait]
impl ProfileUpdateBridge for api::ProfileUpdate {
    async fn get_update_profile_object(
        self,
        state: &SessionState,
        key_store: &domain::MerchantKeyStore,
        business_profile: &domain::Profile,
    ) -> RouterResult<domain::ProfileUpdate> {
        if let Some(session_expiry) = &self.session_expiry {
            helpers::validate_session_expiry(session_expiry.to_owned())?;
        }

        if let Some(intent_fulfillment_expiry) = self.intent_fulfillment_time {
            helpers::validate_intent_fulfillment_expiry(intent_fulfillment_expiry)?;
        }

        let webhook_details = self
            .webhook_details
            .and_then(|webhook_details| {
                let mut existing_webhook_details = business_profile
                    .webhook_details
                    .clone()
                    .map(|wh| api_models::admin::WebhookDetails::foreign_from(wh.clone()));

                if let Some(existing_details) = existing_webhook_details.as_mut() {
                    existing_details.merge(webhook_details);
                } else {
                    existing_webhook_details = Some(webhook_details);
                }

                existing_webhook_details
            })
            .map(ForeignInto::foreign_into);

        if let Some(ref routing_algorithm) = self.routing_algorithm {
            let _: api_models::routing::StaticRoutingAlgorithm = routing_algorithm
                .clone()
                .parse_value("RoutingAlgorithm")
                .change_context(errors::ApiErrorResponse::InvalidDataValue {
                    field_name: "routing_algorithm",
                })
                .attach_printable("Invalid routing algorithm given")?;
        }

        let payment_link_config = self

Review comment (suggestion):
```suggestion
                let existing_webhook_details = business_profile
```

Code after:
        key_store: &domain::MerchantKeyStore,
        business_profile: &domain::Profile,
    ) -> RouterResult<domain::ProfileUpdate>;
}

#[cfg(all(feature = "olap", feature = "v1"))]
#[async_trait::async_trait]
impl ProfileUpdateBridge for api::ProfileUpdate {
    async fn get_update_profile_object(
        self,
        state: &SessionState,
        key_store: &domain::MerchantKeyStore,
        business_profile: &domain::Profile,
    ) -> RouterResult<domain::ProfileUpdate> {
        if let Some(session_expiry) = &self.session_expiry {
            helpers::validate_session_expiry(session_expiry.to_owned())?;
        }

        if let Some(intent_fulfillment_expiry) = self.intent_fulfillment_time {
            helpers::validate_intent_fulfillment_expiry(intent_fulfillment_expiry)?;
        }

        let webhook_details = self
            .webhook_details
            .map(|webhook_details| {
                let existing_webhook_details = business_profile
                    .webhook_details
                    .clone()
                    .map(|wh| api_models::admin::WebhookDetails::foreign_from(wh.clone()));

                match existing_webhook_details {
                    Some(existing_details) => existing_details.merge(webhook_details),
                    None => webhook_details,
                }
            })
            .map(ForeignInto::foreign_into);

        if let Some(ref routing_algorithm) = self.routing_algorithm {
            let _: api_models::routing::StaticRoutingAlgorithm = routing_algorithm
                .clone()
                .parse_value("RoutingAlgorithm")
                .change_context(errors::ApiErrorResponse::InvalidDataValue {
                    field_name: "routing_algorithm",
                })
                .attach_printable("Invalid routing algorithm given")?;
        }

        let payment_link_config = self
            .payment_link_config
            .map(|payment_link_conf| match payment_link_conf.validate() {
                Ok(_) => Ok(payment_link_conf.foreign_into()),