mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 04:04:43 +08:00
feat(router): add requeue support for payments and fix duplicate entry error in process tracker for requeued payments (#1567)
This commit is contained in:
committed by
GitHub
parent
7489c870d9
commit
b967d23251
@ -763,6 +763,7 @@ pub async fn add_domain_task_to_pt<Op>(
|
||||
operation: &Op,
|
||||
state: &AppState,
|
||||
payment_attempt: &storage::PaymentAttempt,
|
||||
requeue: bool,
|
||||
) -> CustomResult<(), errors::ApiErrorResponse>
|
||||
where
|
||||
Op: std::fmt::Debug,
|
||||
@ -786,12 +787,21 @@ where
|
||||
|
||||
match schedule_time {
|
||||
Some(stime) => {
|
||||
scheduler_metrics::TASKS_ADDED_COUNT.add(&metrics::CONTEXT, 1, &[]); // Metrics
|
||||
super::add_process_sync_task(&*state.store, payment_attempt, stime)
|
||||
.await
|
||||
.into_report()
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("Failed while adding task to process tracker")
|
||||
if !requeue {
|
||||
scheduler_metrics::TASKS_ADDED_COUNT.add(&metrics::CONTEXT, 1, &[]); // Metrics
|
||||
super::add_process_sync_task(&*state.store, payment_attempt, stime)
|
||||
.await
|
||||
.into_report()
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("Failed while adding task to process tracker")
|
||||
} else {
|
||||
scheduler_metrics::TASKS_RESET_COUNT.add(&metrics::CONTEXT, 1, &[]); // Metrics
|
||||
super::reset_process_sync_task(&*state.store, payment_attempt, stime)
|
||||
.await
|
||||
.into_report()
|
||||
.change_context(errors::ApiErrorResponse::InternalServerError)
|
||||
.attach_printable("Failed while updating task in process tracker")
|
||||
}
|
||||
}
|
||||
None => Ok(()),
|
||||
}
|
||||
@ -2155,7 +2165,10 @@ pub fn get_attempt_type(
|
||||
) -> RouterResult<AttemptType> {
|
||||
match payment_intent.status {
|
||||
enums::IntentStatus::Failed => {
|
||||
if request.manual_retry {
|
||||
if matches!(
|
||||
request.retry_action,
|
||||
Some(api_models::enums::RetryAction::ManualRetry)
|
||||
) {
|
||||
match payment_attempt.status {
|
||||
enums::AttemptStatus::Started
|
||||
| enums::AttemptStatus::AuthenticationPending
|
||||
|
||||
Reference in New Issue
Block a user