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

Code before:
impl api::PaymentVoid for Chargebee {}
impl api::Refund for Chargebee {}
impl api::RefundExecute for Chargebee {}
impl api::RefundSync for Chargebee {}
impl api::PaymentToken for Chargebee {}
impl api::subscriptions::Subscriptions for Chargebee {}
#[cfg(all(feature = "v2", feature = "revenue_recovery"))]
impl api::revenue_recovery::RevenueRecoveryRecordBack for Chargebee {}

#[cfg(feature = "v1")]
impl api::subscriptions::SubscriptionRecordBack for Chargebee {}

#[cfg(feature = "v1")]
impl api::subscriptions::SubscriptionCreate for Chargebee {}

#[cfg(feature = "v1")]
impl
    ConnectorIntegration<
        SubscriptionRecordBack,
        SubscriptionsRecordBackRequest,
        RevenueRecoveryRecordBackResponse,
    > for Chargebee
{
    fn get_headers(
        &self,
        req: &hyperswitch_domain_models::types::SubscriptionRecordBackRouterData,
        connectors: &Connectors,
    ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
        self.build_headers(req, connectors)
    }
    fn get_url(
        &self,
        req: &hyperswitch_domain_models::types::SubscriptionRecordBackRouterData,
        connectors: &Connectors,
    ) -> 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());
        let invoice_id = req.request.merchant_reference_id.to_string();
        Ok(format!("{url}v2/invoices/{invoice_id}/record_payment"))
    }

    fn get_content_type(&self) -> &'static str {
        self.common_get_content_type()
    }

    fn get_request_body(
        &self,

Review comment (suggestion):
```suggestion
        req: &SubscriptionRecordBackRouterData,
```
change it in other places also

Code after:
        }
    }
}
impl ConnectorCustomer for Chargebee {}
impl api::Payment for Chargebee {}
impl api::PaymentSession for Chargebee {}
impl api::ConnectorAccessToken for Chargebee {}
impl api::MandateSetup for Chargebee {}
impl api::PaymentAuthorize for Chargebee {}
impl api::PaymentSync for Chargebee {}
impl api::PaymentCapture for Chargebee {}
impl api::PaymentVoid for Chargebee {}
impl api::Refund for Chargebee {}
impl api::RefundExecute for Chargebee {}
impl api::RefundSync for Chargebee {}
impl api::PaymentToken for Chargebee {}
impl api::subscriptions::Subscriptions for Chargebee {}

#[cfg(all(feature = "v2", feature = "revenue_recovery"))]
impl api::revenue_recovery::RevenueRecoveryRecordBack for Chargebee {}

impl api::subscriptions::SubscriptionCreate for Chargebee {}

impl ConnectorIntegration<SubscriptionCreate, SubscriptionCreateRequest, SubscriptionCreateResponse>
    for Chargebee
{
    fn get_headers(
        &self,
        req: &SubscriptionCreateRouterData,
        connectors: &Connectors,
    ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
        self.build_headers(req, connectors)
    }

    fn get_url(
        &self,
        req: &SubscriptionCreateRouterData,
        connectors: &Connectors,
    ) -> 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());
        let customer_id = &req.request.customer_id.get_string_repr().to_string();
        Ok(format!(
            "{url}v2/customers/{customer_id}/subscription_for_items"
        ))
    }