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

Code before:
        Ok(signature_auth == secret_auth)
    }

    #[cfg(all(feature = "revenue_recovery", feature = "v2"))]
    fn get_webhook_object_reference_id(
        &self,
        request: &webhooks::IncomingWebhookRequestDetails<'_>,
    ) -> CustomResult<api_models::webhooks::ObjectReferenceId, errors::ConnectorError> {
        let webhook =
            chargebee::ChargebeeInvoiceBody::get_invoice_webhook_data_from_body(request.body)
                .change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?;
        Ok(api_models::webhooks::ObjectReferenceId::InvoiceId(
            api_models::webhooks::InvoiceIdType::ConnectorInvoiceId(webhook.content.invoice.id),
        ))
    }
    #[cfg(any(feature = "v1", not(all(feature = "revenue_recovery", feature = "v2"))))]
    fn get_webhook_object_reference_id(
        &self,
        request: &webhooks::IncomingWebhookRequestDetails<'_>,
    ) -> CustomResult<api_models::webhooks::ObjectReferenceId, errors::ConnectorError> {
        let webhook =
            chargebee::ChargebeeInvoiceBody::get_invoice_webhook_data_from_body(request.body)
                .change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?;

        let subscription_id = webhook.content.invoice.subscription_id;
        Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
            api_models::payments::PaymentIdType::PaymentIntentId(
                common_utils::id_type::PaymentId::wrap(
                    subscription_id.get_string_repr().to_string(),
                )
                .change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?,
            ),
        ))
    }
    fn get_webhook_event_type(
        &self,
        request: &webhooks::IncomingWebhookRequestDetails<'_>,
    ) -> CustomResult<api_models::webhooks::IncomingWebhookEvent, errors::ConnectorError> {
        let webhook =
            chargebee::ChargebeeInvoiceBody::get_invoice_webhook_data_from_body(request.body)
                .change_context(errors::ConnectorError::WebhookEventTypeNotFound)?;
        let event = api_models::webhooks::IncomingWebhookEvent::from(webhook.event_type);
        Ok(event)
    }

    fn get_webhook_resource_object(
        &self,
        request: &webhooks::IncomingWebhookRequestDetails<'_>,
    ) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
        let webhook =
            chargebee::ChargebeeInvoiceBody::get_invoice_webhook_data_from_body(request.body)

Review comment (suggestion):
```suggestion
        Ok(api_models::webhooks::ObjectReferenceId::InvoiceId(
```
remove feature flag for InvoiceId in ObjectReferenceId
follow the revenue recovery invoice handling webhook only

Code after:
    ) -> CustomResult<String, errors::ConnectorError> {
        let metadata: chargebee::ChargebeeMetadata =
            utils::to_connector_meta_from_secret(req.connector_meta_data.clone())?;
        let url = self
            .base_url(connectors)
            .to_string()
            .replace("{{merchant_endpoint_prefix}}", metadata.site.peek());
        Ok(format!("{url}v2/estimates/create_subscription_for_items"))
    }
    fn get_content_type(&self) -> &'static str {
        self.common_get_content_type()
    }
    fn get_request_body(
        &self,
        req: &GetSubscriptionEstimateRouterData,
        _connectors: &Connectors,
    ) -> CustomResult<RequestContent, errors::ConnectorError> {
        let connector_req = chargebee::ChargebeeSubscriptionEstimateRequest::try_from(req)?;
        Ok(RequestContent::FormUrlEncoded(Box::new(connector_req)))
    }
    fn build_request(
        &self,
        req: &GetSubscriptionEstimateRouterData,
        connectors: &Connectors,
    ) -> CustomResult<Option<Request>, errors::ConnectorError> {
        Ok(Some(
            RequestBuilder::new()
                .method(Method::Post)
                .url(&types::GetSubscriptionEstimateType::get_url(
                    self, req, connectors,
                )?)
                .attach_default_headers()
                .headers(types::GetSubscriptionEstimateType::get_headers(
                    self, req, connectors,
                )?)
                .set_body(types::GetSubscriptionEstimateType::get_request_body(
                    self, req, connectors,
                )?)
                .build(),
        ))
    }
    fn handle_response(
        &self,
        data: &GetSubscriptionEstimateRouterData,
        event_builder: Option<&mut ConnectorEvent>,
        res: Response,
    ) -> CustomResult<GetSubscriptionEstimateRouterData, errors::ConnectorError> {
        let response: chargebee::SubscriptionEstimateResponse = res
            .response
            .parse_struct("chargebee SubscriptionEstimateResponse")
            .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;