feat(router): add card testing check in payments eligibility flow (#9876)

Co-authored-by: hyperswitch-bot[bot] <148525504+hyperswitch-bot[bot]@users.noreply.github.com>
This commit is contained in:
Sai Harsha Vardhan
2025-10-17 13:56:41 +05:30
committed by GitHub
parent 247bce518f
commit 01cb658696
7 changed files with 243 additions and 53 deletions

View File

@ -339,6 +339,12 @@ pub trait AsyncExt<A> {
where
F: FnOnce() -> Fut + Send,
Fut: futures::Future<Output = A> + Send;
/// Extending `or_else` to allow async fallback that returns Self::WrappedSelf<A>
async fn async_or_else<F, Fut>(self, func: F) -> Self::WrappedSelf<A>
where
F: FnOnce() -> Fut + Send,
Fut: futures::Future<Output = Self::WrappedSelf<A>> + Send;
}
#[cfg(feature = "async_ext")]
@ -381,6 +387,21 @@ impl<A: Send, E: Send + std::fmt::Debug> AsyncExt<A> for Result<A, E> {
}
}
}
async fn async_or_else<F, Fut>(self, func: F) -> Self::WrappedSelf<A>
where
F: FnOnce() -> Fut + Send,
Fut: futures::Future<Output = Self::WrappedSelf<A>> + Send,
{
match self {
Ok(a) => Ok(a),
Err(_err) => {
#[cfg(feature = "logs")]
logger::error!("Error: {:?}", _err);
func().await
}
}
}
}
#[cfg(feature = "async_ext")]
@ -419,6 +440,17 @@ impl<A: Send> AsyncExt<A> for Option<A> {
None => func().await,
}
}
async fn async_or_else<F, Fut>(self, func: F) -> Self::WrappedSelf<A>
where
F: FnOnce() -> Fut + Send,
Fut: futures::Future<Output = Self::WrappedSelf<A>> + Send,
{
match self {
Some(a) => Some(a),
None => func().await,
}
}
}
/// Extension trait for validating application configuration. This trait provides utilities to