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

Code before:
            .clone()
            .ok_or(errors::RecoveryError::ValueNotFound)
            .attach_printable("unable to derive payment connector from payment attempt")?;
        let gsm_record = helpers::get_gsm_record(
            state,
            error_code,
            error_message,
            connector_name,
            "revenue_recovery".to_string(),
        )
        .await;
        let is_hard_decline = gsm_record
            .map(|gsm_record| {
                if let Some(gsm_error_category) = gsm_record.error_category {
                    match gsm_error_category {
                        common_enums::ErrorCategory::HardDecline => {
                            //TODO:Add logic for card_switch
                            true
                        }
                        _ => false,
                    }
                } else {
                    true
                }
            })
            .unwrap_or(true);

        let schedule_time = revenue_recovery_payment_data
            .get_schedule_time_based_on_retry_type(
                db,
                merchant_id,
                next_retry_count,
                is_hard_decline,
            )
            .await;

        match schedule_time {
            Some(schedule_time) => Ok(Self::RetryPayment(schedule_time)),

            None => Ok(Self::TerminalFailure(payment_attempt.clone())),
        }
    }
}
// TODO: Move these to impl based functions
async fn record_back_to_billing_connector(
    state: &SessionState,
    payment_attempt: &payment_attempt::PaymentAttempt,
    payment_intent: &PaymentIntent,
    billing_mca: &merchant_connector_account::MerchantConnectorAccount,
) -> RecoveryResult<()> {
    let connector_name = billing_mca.connector_name.to_string();

Review comment (suggestion):
```suggestion
            .and_then(|gsm_record| gsm_record.error_category)
            .map(|gsm_error_category| gsm_error_category == common_enums::ErrorCategory::HardDecline)
            
            .unwrap_or(true);
```

Code after:

        match schedule_time {
            Some(schedule_time) => Ok(Self::RetryPayment(schedule_time)),

            None => Ok(Self::TerminalFailure(payment_attempt.clone())),
        }
    }
}
// TODO: Move these to impl based functions
async fn record_back_to_billing_connector(
    state: &SessionState,
    payment_attempt: &PaymentAttempt,
    payment_intent: &PaymentIntent,
    billing_mca: &merchant_connector_account::MerchantConnectorAccount,
) -> RecoveryResult<()> {
    let connector_name = billing_mca.connector_name.to_string();
    let connector_data = api_types::ConnectorData::get_connector_by_name(
        &state.conf.connectors,
        &connector_name,
        api_types::GetToken::Connector,
        Some(billing_mca.get_id()),
    )
    .change_context(errors::RecoveryError::RecordBackToBillingConnectorFailed)
    .attach_printable("invalid connector name received in billing merchant connector account")?;

    let connector_integration: services::BoxedRevenueRecoveryRecordBackInterface<
        router_flow_types::RecoveryRecordBack,
        revenue_recovery_request::RevenueRecoveryRecordBackRequest,
        revenue_recovery_response::RevenueRecoveryRecordBackResponse,
    > = connector_data.connector.get_connector_integration();

    let router_data = construct_recovery_record_back_router_data(
        state,
        billing_mca,
        payment_attempt,
        payment_intent,
    )?;

    let response = services::execute_connector_processing_step(
        state,
        connector_integration,
        &router_data,
        payments::CallConnectorAction::Trigger,
        None,
        None,
    )
    .await
    .change_context(errors::RecoveryError::RecordBackToBillingConnectorFailed)
    .attach_printable("Failed while handling response of record back to billing connector")?;

    match response.response {