mirror of
https://github.com/juspay/hyperswitch.git
synced 2025-10-29 00:49:42 +08:00
feat(dummy_connector): allow a dummy connector to succeed a failed card (#8469)
This commit is contained in:
@ -11,7 +11,10 @@ use super::{
|
|||||||
consts, errors,
|
consts, errors,
|
||||||
types::{self, GetPaymentMethodDetails},
|
types::{self, GetPaymentMethodDetails},
|
||||||
};
|
};
|
||||||
use crate::{configs::settings, routes::SessionState};
|
use crate::{
|
||||||
|
configs::settings,
|
||||||
|
routes::{dummy_connector::types::DummyConnectors, SessionState},
|
||||||
|
};
|
||||||
|
|
||||||
pub async fn tokio_mock_sleep(delay: u64, tolerance: u64) {
|
pub async fn tokio_mock_sleep(delay: u64, tolerance: u64) {
|
||||||
let mut rng = rand::thread_rng();
|
let mut rng = rand::thread_rng();
|
||||||
@ -219,7 +222,7 @@ impl ProcessPaymentAttempt for types::DummyConnectorCard {
|
|||||||
payment_attempt: types::DummyConnectorPaymentAttempt,
|
payment_attempt: types::DummyConnectorPaymentAttempt,
|
||||||
redirect_url: String,
|
redirect_url: String,
|
||||||
) -> types::DummyConnectorResult<types::DummyConnectorPaymentData> {
|
) -> types::DummyConnectorResult<types::DummyConnectorPaymentData> {
|
||||||
match self.get_flow_from_card_number()? {
|
match self.get_flow_from_card_number(payment_attempt.payment_request.connector.clone())? {
|
||||||
types::DummyConnectorCardFlow::NoThreeDS(status, error) => {
|
types::DummyConnectorCardFlow::NoThreeDS(status, error) => {
|
||||||
if let Some(error) = error {
|
if let Some(error) = error {
|
||||||
Err(error)?;
|
Err(error)?;
|
||||||
@ -291,6 +294,7 @@ impl types::DummyConnectorUpiCollect {
|
|||||||
impl types::DummyConnectorCard {
|
impl types::DummyConnectorCard {
|
||||||
pub fn get_flow_from_card_number(
|
pub fn get_flow_from_card_number(
|
||||||
self,
|
self,
|
||||||
|
connector: DummyConnectors,
|
||||||
) -> types::DummyConnectorResult<types::DummyConnectorCardFlow> {
|
) -> types::DummyConnectorResult<types::DummyConnectorCardFlow> {
|
||||||
let card_number = self.number.peek();
|
let card_number = self.number.peek();
|
||||||
match card_number.as_str() {
|
match card_number.as_str() {
|
||||||
@ -309,12 +313,21 @@ impl types::DummyConnectorCard {
|
|||||||
}),
|
}),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
"4000000000009995" => Ok(types::DummyConnectorCardFlow::NoThreeDS(
|
"4000000000009995" => {
|
||||||
types::DummyConnectorStatus::Failed,
|
if connector == DummyConnectors::StripeTest {
|
||||||
Some(errors::DummyConnectorErrors::PaymentDeclined {
|
Ok(types::DummyConnectorCardFlow::NoThreeDS(
|
||||||
message: "Insufficient funds",
|
types::DummyConnectorStatus::Succeeded,
|
||||||
}),
|
None,
|
||||||
)),
|
))
|
||||||
|
} else {
|
||||||
|
Ok(types::DummyConnectorCardFlow::NoThreeDS(
|
||||||
|
types::DummyConnectorStatus::Failed,
|
||||||
|
Some(errors::DummyConnectorErrors::PaymentDeclined {
|
||||||
|
message: "Internal Server Error from Connector, Please try again later",
|
||||||
|
}),
|
||||||
|
))
|
||||||
|
}
|
||||||
|
}
|
||||||
"4000000000009987" => Ok(types::DummyConnectorCardFlow::NoThreeDS(
|
"4000000000009987" => Ok(types::DummyConnectorCardFlow::NoThreeDS(
|
||||||
types::DummyConnectorStatus::Failed,
|
types::DummyConnectorStatus::Failed,
|
||||||
Some(errors::DummyConnectorErrors::PaymentDeclined {
|
Some(errors::DummyConnectorErrors::PaymentDeclined {
|
||||||
|
|||||||
Reference in New Issue
Block a user