mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-11-02 12:06:56 +08:00
fix(router): fix attempt status for techincal failures in psync flow (#2252)
This commit is contained in:
committed by
GitHub
parent
aa8d0ddda1
commit
2b8bd03a72
@ -12,6 +12,7 @@ use crate::{
|
||||
errors::{self, RouterResult, StorageErrorExt},
|
||||
mandate,
|
||||
payments::{types::MultipleCaptureData, PaymentData},
|
||||
utils as core_utils,
|
||||
},
|
||||
db::StorageInterface,
|
||||
routes::metrics,
|
||||
@ -311,9 +312,20 @@ async fn payment_response_update_tracker<F: Clone, T: types::Capturable>(
|
||||
(Some((multiple_capture_data, capture_update_list)), None)
|
||||
}
|
||||
None => {
|
||||
let status = match err.status_code {
|
||||
let flow_name = core_utils::get_flow_name::<F>()?;
|
||||
let status =
|
||||
// mark previous attempt status for technical failures in PSync flow
|
||||
if flow_name == "PSync" {
|
||||
match err.status_code {
|
||||
// marking failure for 2xx because this is genuine payment failure
|
||||
200..=299 => storage::enums::AttemptStatus::Failure,
|
||||
_ => payment_data.payment_attempt.status,
|
||||
}
|
||||
} else {
|
||||
match err.status_code {
|
||||
500..=511 => storage::enums::AttemptStatus::Pending,
|
||||
_ => storage::enums::AttemptStatus::Failure,
|
||||
}
|
||||
};
|
||||
(
|
||||
None,
|
||||
|
||||
@ -1033,3 +1033,15 @@ pub async fn get_profile_id_from_business_details(
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn get_flow_name<F>() -> RouterResult<String> {
|
||||
Ok(std::any::type_name::<F>()
|
||||
.to_string()
|
||||
.rsplit("::")
|
||||
.next()
|
||||
.ok_or(errors::ApiErrorResponse::InternalServerError)
|
||||
.into_report()
|
||||
.attach_printable("Flow stringify failed")?
|
||||
.to_string())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user