Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(connector): [DummyConnector] add new dummy connectors (#1609)
Mani Chandracf7b67286c51
diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rsindex 28ef808c77..cf0de8e088 100644--- a/crates/api_models/src/enums.rs+++ b/crates/api_models/src/enums.rs@@ -620,6 +620,22 @@ pub enum Connector {#[serde(rename = "pretendpay")]#[strum(serialize = "pretendpay")]DummyConnector3,+ #[cfg(feature = "dummy_connector")]+ #[serde(rename = "stripe_test")]+ #[strum(serialize = "stripe_test")]+ DummyConnector4,+ #[cfg(feature = "dummy_connector")]+ #[serde(rename = "adyen_test")]+ #[strum(serialize = "adyen_test")]+ DummyConnector5,+ #[cfg(feature = "dummy_connector")]+ #[serde(rename = "checkout_test")]+ #[strum(serialize = "checkout_test")]+ DummyConnector6,+ #[cfg(feature = "dummy_connector")]+ #[serde(rename = "paypal_test")]+ #[strum(serialize = "paypal_test")]+ DummyConnector7,Bambora,Dlocal,Fiserv,@@ -695,6 +711,22 @@ pub enum RoutableConnectors {#[serde(rename = "pretendpay")]#[strum(serialize = "pretendpay")]DummyConnector3,+ #[cfg(feature = "dummy_connector")]+ #[serde(rename = "stripe_test")]+ #[strum(serialize = "stripe_test")]+ DummyConnector4,+ #[cfg(feature = "dummy_connector")]+ #[serde(rename = "adyen_test")]+ #[strum(serialize = "adyen_test")]+ DummyConnector5,+ #[cfg(feature = "dummy_connector")]+ #[serde(rename = "checkout_test")]+ #[strum(serialize = "checkout_test")]+ DummyConnector6,+ #[cfg(feature = "dummy_connector")]+ #[serde(rename = "paypal_test")]+ #[strum(serialize = "paypal_test")]+ DummyConnector7,Aci,Adyen,Airwallex,diff --git a/crates/router/src/connector/dummyconnector.rs b/crates/router/src/connector/dummyconnector.rsindex bffc6523e2..da377e7bbc 100644--- a/crates/router/src/connector/dummyconnector.rs+++ b/crates/router/src/connector/dummyconnector.rs@@ -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",}}diff --git a/crates/router/src/routes/dummy_connector/errors.rs b/crates/router/src/routes/dummy_connector/errors.rsindex 9387d67ce8..0cce7076c5 100644--- a/crates/router/src/routes/dummy_connector/errors.rs+++ b/crates/router/src/routes/dummy_connector/errors.rs@@ -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::ApiErrorResponfn 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::ApiErrorResponSelf::PaymentNotSuccessful => {AER::BadRequest(ApiError::new("DC", 6, self.error_message(), None))}+ Self::PaymentStoringError => {+ AER::InternalServerError(ApiError::new("DC", 7, self.error_message(), None))+ }}}}diff --git a/crates/router/src/routes/dummy_connector/utils.rs b/crates/router/src/routes/dummy_connector/utils.rsindex 840e1590d4..44f5217407 100644--- a/crates/router/src/routes/dummy_connector/utils.rs+++ b/crates/router/src/routes/dummy_connector/utils.rs@@ -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(),diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rsindex 66edf241cb..4589742005 100644--- a/crates/router/src/types/api.rs+++ b/crates/router/src/types/api.rs@@ -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)),diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.jsonindex d9cc619b9d..9d30709a06 100644--- a/openapi/openapi_spec.json+++ b/openapi/openapi_spec.json@@ -2885,6 +2885,10 @@"phonypay","fauxpay","pretendpay",+ "stripe_test",+ "adyen_test",+ "checkout_test",+ "paypal_test","bambora","dlocal","fiserv",