mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	feat(connector): [DummyConnector] add new dummy connectors (#1609)
This commit is contained in:
		| @ -78,6 +78,10 @@ impl<const T: u8> ConnectorCommon for DummyConnector<T> { | ||||
|             1 => "phonypay", | ||||
|             2 => "fauxpay", | ||||
|             3 => "pretendpay", | ||||
|             4 => "stripe_test", | ||||
|             5 => "adyen_test", | ||||
|             6 => "checkout_test", | ||||
|             7 => "paypal_test", | ||||
|             _ => "phonypay", | ||||
|         } | ||||
|     } | ||||
|  | ||||
| @ -8,9 +8,11 @@ pub enum ErrorType { | ||||
|  | ||||
| #[derive(Debug, Clone, router_derive::ApiError)] | ||||
| #[error(error_type_enum = ErrorType)] | ||||
| // TODO: Remove this line if InternalServerError is used anywhere | ||||
| #[allow(dead_code)] | ||||
| pub enum DummyConnectorErrors { | ||||
|     #[error(error_type = ErrorType::ServerNotAvailable, code = "DC_00", message = "Error occurred while storing the payment")] | ||||
|     PaymentStoringError, | ||||
|     #[error(error_type = ErrorType::ServerNotAvailable, code = "DC_00", message = "Something went wrong")] | ||||
|     InternalServerError, | ||||
|  | ||||
|     #[error(error_type = ErrorType::ObjectNotFound, code = "DC_01", message = "Payment does not exist in our records")] | ||||
|     PaymentNotFound, | ||||
| @ -29,6 +31,9 @@ pub enum DummyConnectorErrors { | ||||
|  | ||||
|     #[error(error_type = ErrorType::InvalidRequestError, code = "DC_06", message = "Payment is not successful")] | ||||
|     PaymentNotSuccessful, | ||||
|  | ||||
|     #[error(error_type = ErrorType::ServerNotAvailable, code = "DC_07", message = "Error occurred while storing the payment")] | ||||
|     PaymentStoringError, | ||||
| } | ||||
|  | ||||
| impl core::fmt::Display for DummyConnectorErrors { | ||||
| @ -48,7 +53,7 @@ impl common_utils::errors::ErrorSwitch<api_models::errors::types::ApiErrorRespon | ||||
|     fn switch(&self) -> api_models::errors::types::ApiErrorResponse { | ||||
|         use api_models::errors::types::{ApiError, ApiErrorResponse as AER}; | ||||
|         match self { | ||||
|             Self::PaymentStoringError => { | ||||
|             Self::InternalServerError => { | ||||
|                 AER::InternalServerError(ApiError::new("DC", 0, self.error_message(), None)) | ||||
|             } | ||||
|             Self::PaymentNotFound => { | ||||
| @ -69,6 +74,9 @@ impl common_utils::errors::ErrorSwitch<api_models::errors::types::ApiErrorRespon | ||||
|             Self::PaymentNotSuccessful => { | ||||
|                 AER::BadRequest(ApiError::new("DC", 6, self.error_message(), None)) | ||||
|             } | ||||
|             Self::PaymentStoringError => { | ||||
|                 AER::InternalServerError(ApiError::new("DC", 7, self.error_message(), None)) | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| @ -27,7 +27,7 @@ pub async fn payment( | ||||
|     ) | ||||
|     .await; | ||||
|  | ||||
|     let payment_id = generate_id(20, "dummy_pay_"); | ||||
|     let payment_id = generate_id(20, "dummy_pay"); | ||||
|     match req.payment_method_data { | ||||
|         types::DummyConnectorPaymentMethodData::Card(card) => { | ||||
|             let card_number = card.number.peek(); | ||||
| @ -139,7 +139,7 @@ pub async fn refund_payment( | ||||
|             .attach_printable("Payment is not successful to process the refund")); | ||||
|     } | ||||
|  | ||||
|     let refund_id = generate_id(20, "dummy_ref_"); | ||||
|     let refund_id = generate_id(20, "dummy_ref"); | ||||
|     payment_data.eligible_amount -= req.amount; | ||||
|     store_data_in_redis( | ||||
|         redis_conn.to_owned(), | ||||
|  | ||||
| @ -221,6 +221,14 @@ impl ConnectorData { | ||||
|                 enums::Connector::DummyConnector2 => Ok(Box::new(&connector::DummyConnector::<2>)), | ||||
|                 #[cfg(feature = "dummy_connector")] | ||||
|                 enums::Connector::DummyConnector3 => Ok(Box::new(&connector::DummyConnector::<3>)), | ||||
|                 #[cfg(feature = "dummy_connector")] | ||||
|                 enums::Connector::DummyConnector4 => Ok(Box::new(&connector::DummyConnector::<4>)), | ||||
|                 #[cfg(feature = "dummy_connector")] | ||||
|                 enums::Connector::DummyConnector5 => Ok(Box::new(&connector::DummyConnector::<5>)), | ||||
|                 #[cfg(feature = "dummy_connector")] | ||||
|                 enums::Connector::DummyConnector6 => Ok(Box::new(&connector::DummyConnector::<6>)), | ||||
|                 #[cfg(feature = "dummy_connector")] | ||||
|                 enums::Connector::DummyConnector7 => Ok(Box::new(&connector::DummyConnector::<7>)), | ||||
|                 enums::Connector::Fiserv => Ok(Box::new(&connector::Fiserv)), | ||||
|                 enums::Connector::Forte => Ok(Box::new(&connector::Forte)), | ||||
|                 enums::Connector::Globalpay => Ok(Box::new(&connector::Globalpay)), | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Mani Chandra
					Mani Chandra