feat(revenue_recovery): Implement redis API to update the lock status for connector customer id (#9403)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
AdityaWNL
2025-09-18 20:18:01 +05:30
committed by GitHub
parent 1c0fc496d1
commit 1d23e28a17
4 changed files with 68 additions and 2 deletions

View File

@ -2,7 +2,7 @@ use std::collections::HashMap;
use api_models::revenue_recovery_data_backfill::{
BackfillError, ComprehensiveCardData, RevenueRecoveryBackfillRequest,
RevenueRecoveryDataBackfillResponse,
RevenueRecoveryDataBackfillResponse, UnlockStatusResponse,
};
use common_enums::{CardNetwork, PaymentMethodType};
use hyperswitch_domain_models::api::ApplicationResponse;
@ -60,6 +60,33 @@ pub async fn revenue_recovery_data_backfill(
Ok(ApplicationResponse::Json(response))
}
pub async fn unlock_connector_customer_status(
state: SessionState,
connector_customer_id: String,
) -> RouterResult<ApplicationResponse<UnlockStatusResponse>> {
let unlocked = storage::revenue_recovery_redis_operation::
RedisTokenManager::unlock_connector_customer_status(&state, &connector_customer_id)
.await
.map_err(|e| {
logger::error!(
"Failed to unlock connector customer status for {}: {}",
connector_customer_id,
e
);
errors::ApiErrorResponse::InternalServerError
})?;
let response = UnlockStatusResponse { unlocked };
logger::info!(
"Unlock operation completed for connector customer {}: {}",
connector_customer_id,
unlocked
);
Ok(ApplicationResponse::Json(response))
}
async fn process_payment_method_record(
state: &SessionState,
record: &RevenueRecoveryBackfillRequest,

View File

@ -3002,5 +3002,10 @@ impl RecoveryDataBackfill {
.to(super::revenue_recovery_data_backfill::revenue_recovery_data_backfill),
),
)
.service(web::resource("/status/{token_id}").route(
web::post().to(
super::revenue_recovery_data_backfill::revenue_recovery_data_backfill_status,
),
))
}
}

View File

@ -7,7 +7,7 @@ use crate::{
core::{api_locking, revenue_recovery_data_backfill},
routes::AppState,
services::{api, authentication as auth},
types::domain,
types::{domain, storage},
};
#[instrument(skip_all, fields(flow = ?Flow::RecoveryDataBackfill))]
@ -65,3 +65,26 @@ pub async fn revenue_recovery_data_backfill(
))
.await
}
#[instrument(skip_all, fields(flow = ?Flow::RecoveryDataBackfill))]
pub async fn revenue_recovery_data_backfill_status(
state: web::Data<AppState>,
req: HttpRequest,
path: web::Path<String>,
) -> HttpResponse {
let flow = Flow::RecoveryDataBackfill;
let connector_customer_id = path.into_inner();
Box::pin(api::server_wrap(
flow,
state,
&req,
connector_customer_id,
|state, _: (), id, _| {
revenue_recovery_data_backfill::unlock_connector_customer_status(state, id)
},
&auth::V2AdminApiAuth,
api_locking::LockAction::NotApplicable,
))
.await
}