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): add template code for stripebilling (#7228)
CHALLA NISHANTH BABUaf8778e0091f
diff --git a/config/config.example.toml b/config/config.example.tomlindex 1b24292e88..9e54c7e8c8 100644--- a/config/config.example.toml+++ b/config/config.example.toml@@ -263,6 +263,7 @@ square.base_url = "https://connect.squareupsandbox.com/"square.secondary_base_url = "https://pci-connect.squareupsandbox.com/"stax.base_url = "https://apiprod.fattlabs.com/"stripe.base_url = "https://api.stripe.com/"+stripebilling.base_url = "https://api.stripe.com/"taxjar.base_url = "https://api.sandbox.taxjar.com/v2/"threedsecureio.base_url = "https://service.sandbox.3dsecure.io"thunes.base_url = "https://api.limonetikqualif.com/"@@ -336,6 +337,7 @@ cards = ["square","stax","stripe",+ "stripebilling","threedsecureio","thunes","worldpay",diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.tomlindex 0faa8bd81a..c8eb14c985 100644--- a/config/deployments/integration_test.toml+++ b/config/deployments/integration_test.toml@@ -109,6 +109,7 @@ square.secondary_base_url = "https://pci-connect.squareupsandbox.com/"stax.base_url = "https://apiprod.fattlabs.com/"stripe.base_url = "https://api.stripe.com/"stripe.base_url_file_upload = "https://files.stripe.com/"+stripebilling.base_url = "https://api.stripe.com/"taxjar.base_url = "https://api.sandbox.taxjar.com/v2/"thunes.base_url = "https://api.limonetikqualif.com/"trustpay.base_url = "https://test-tpgw.trustpay.eu/"diff --git a/config/deployments/production.toml b/config/deployments/production.tomlindex 01e7bdd32b..90ca4ae143 100644--- a/config/deployments/production.toml+++ b/config/deployments/production.toml@@ -113,6 +113,7 @@ square.secondary_base_url = "https://pci-connect.squareupsandbox.com/"stax.base_url = "https://apiprod.fattlabs.com/"stripe.base_url = "https://api.stripe.com/"stripe.base_url_file_upload = "https://files.stripe.com/"+stripebilling.base_url = "https://api.stripe.com/"taxjar.base_url = "https://api.taxjar.com/v2/"thunes.base_url = "https://api.limonetik.com/"trustpay.base_url = "https://tpgw.trustpay.eu/"diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.tomlindex c61c8ae53f..29e6013114 100644--- a/config/deployments/sandbox.toml+++ b/config/deployments/sandbox.toml@@ -113,6 +113,7 @@ square.secondary_base_url = "https://pci-connect.squareupsandbox.com/"stax.base_url = "https://apiprod.fattlabs.com/"stripe.base_url = "https://api.stripe.com/"stripe.base_url_file_upload = "https://files.stripe.com/"+stripebilling.base_url = "https://api.stripe.com/"taxjar.base_url = "https://api.sandbox.taxjar.com/v2/"thunes.base_url = "https://api.limonetikqualif.com/"trustpay.base_url = "https://test-tpgw.trustpay.eu/"diff --git a/config/development.toml b/config/development.tomlindex b73f267dba..7619f992aa 100644--- a/config/development.toml+++ b/config/development.toml@@ -209,6 +209,7 @@ cards = ["square","stax","stripe",+ "stripebilling","taxjar","threedsecureio","thunes",@@ -334,6 +335,7 @@ square.base_url = "https://connect.squareupsandbox.com/"square.secondary_base_url = "https://pci-connect.squareupsandbox.com/"stax.base_url = "https://apiprod.fattlabs.com/"stripe.base_url = "https://api.stripe.com/"+stripebilling.base_url = "https://api.stripe.com/"taxjar.base_url = "https://api.sandbox.taxjar.com/v2/"threedsecureio.base_url = "https://service.sandbox.3dsecure.io"thunes.base_url = "https://api.limonetikqualif.com/"diff --git a/config/docker_compose.toml b/config/docker_compose.tomlindex a934bb5795..58cf75fb8d 100644--- a/config/docker_compose.toml+++ b/config/docker_compose.toml@@ -195,6 +195,7 @@ square.base_url = "https://connect.squareupsandbox.com/"square.secondary_base_url = "https://pci-connect.squareupsandbox.com/"stax.base_url = "https://apiprod.fattlabs.com/"stripe.base_url = "https://api.stripe.com/"+stripebilling.base_url = "https://api.stripe.com/"taxjar.base_url = "https://api.sandbox.taxjar.com/v2/"threedsecureio.base_url = "https://service.sandbox.3dsecure.io"thunes.base_url = "https://api.limonetikqualif.com/"@@ -290,6 +291,7 @@ cards = ["square","stax","stripe",+ "stripebilling","taxjar","threedsecureio","thunes",diff --git a/crates/common_enums/src/connector_enums.rs b/crates/common_enums/src/connector_enums.rsindex c65cd99d93..cadca5fad0 100644--- a/crates/common_enums/src/connector_enums.rs+++ b/crates/common_enums/src/connector_enums.rs@@ -123,6 +123,7 @@ pub enum RoutableConnectors {Square,Stax,Stripe,+ //Stripebilling,// Taxjar,Trustpay,// Thunes@@ -263,6 +264,7 @@ pub enum Connector {Square,Stax,Stripe,+ // Stripebilling,Taxjar,Threedsecureio,//Thunes,@@ -410,6 +412,7 @@ impl Connector {| Self::Shift4| Self::Square| Self::Stax+ // | Self::Stripebilling| Self::Taxjar// | Self::Thunes| Self::Trustpay@@ -546,6 +549,7 @@ impl From<RoutableConnectors> for Connector {RoutableConnectors::Square => Self::Square,RoutableConnectors::Stax => Self::Stax,RoutableConnectors::Stripe => Self::Stripe,+ // RoutableConnectors::Stripebilling => Self::Stripebilling,RoutableConnectors::Trustpay => Self::Trustpay,RoutableConnectors::Tsys => Self::Tsys,RoutableConnectors::Volt => Self::Volt,diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rsindex 97a2bdb77b..bf815d5c2c 100644--- a/crates/hyperswitch_connectors/src/connectors.rs+++ b/crates/hyperswitch_connectors/src/connectors.rs@@ -57,6 +57,7 @@ pub mod redsys;pub mod shift4;pub mod square;pub mod stax;+pub mod stripebilling;pub mod taxjar;pub mod thunes;pub mod tsys;@@ -83,8 +84,9 @@ pub use self::{nexinets::Nexinets, nexixpay::Nexixpay, nomupay::Nomupay, novalnet::Novalnet, nuvei::Nuvei,paybox::Paybox, payeezy::Payeezy, paystack::Paystack, payu::Payu, placetopay::Placetopay,powertranz::Powertranz, prophetpay::Prophetpay, rapyd::Rapyd, razorpay::Razorpay,- redsys::Redsys, shift4::Shift4, square::Square, stax::Stax, taxjar::Taxjar, thunes::Thunes,- tsys::Tsys, unified_authentication_service::UnifiedAuthenticationService, volt::Volt,+ redsys::Redsys, shift4::Shift4, square::Square, stax::Stax, stripebilling::Stripebilling,+ taxjar::Taxjar, thunes::Thunes, tsys::Tsys,+ unified_authentication_service::UnifiedAuthenticationService, volt::Volt,wellsfargo::Wellsfargo, worldline::Worldline, worldpay::Worldpay, xendit::Xendit, zen::Zen,zsl::Zsl,};diff --git a/crates/hyperswitch_connectors/src/connectors/stripebilling.rs b/crates/hyperswitch_connectors/src/connectors/stripebilling.rsnew file mode 100644index 0000000000..e05fb8b8e3--- /dev/null+++ b/crates/hyperswitch_connectors/src/connectors/stripebilling.rs@@ -0,0 +1,573 @@+pub mod transformers;++use common_utils::{+ errors::CustomResult,+ ext_traits::BytesExt,+ request::{Method, Request, RequestBuilder, RequestContent},+ types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector},+};+use error_stack::{report, ResultExt};+use hyperswitch_domain_models::{+ router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},+ router_flow_types::{+ access_token_auth::AccessTokenAuth,+ payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},+ refunds::{Execute, RSync},+ },+ router_request_types::{+ AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,+ PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData,+ RefundsData, SetupMandateRequestData,+ },+ router_response_types::{PaymentsResponseData, RefundsResponseData},+ types::{+ PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData,+ RefundSyncRouterData, RefundsRouterData,+ },+};+use hyperswitch_interfaces::{+ api::{+ self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorSpecifications,+ ConnectorValidation,+ },+ configs::Connectors,+ errors,+ events::connector_api_logs::ConnectorEvent,+ types::{self, Response},+ webhooks,+};+use masking::{ExposeInterface, Mask};+use transformers as stripebilling;++use crate::{constants::headers, types::ResponseRouterData, utils};++#[derive(Clone)]+pub struct Stripebilling {+ amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync),+}++impl Stripebilling {+ pub fn new() -> &'static Self {+ &Self {+ amount_converter: &StringMinorUnitForConnector,+ }+ }+}++impl api::Payment for Stripebilling {}+impl api::PaymentSession for Stripebilling {}+impl api::ConnectorAccessToken for Stripebilling {}+impl api::MandateSetup for Stripebilling {}+impl api::PaymentAuthorize for Stripebilling {}+impl api::PaymentSync for Stripebilling {}+impl api::PaymentCapture for Stripebilling {}+impl api::PaymentVoid for Stripebilling {}+impl api::Refund for Stripebilling {}+impl api::RefundExecute for Stripebilling {}+impl api::RefundSync for Stripebilling {}+impl api::PaymentToken for Stripebilling {}++impl ConnectorIntegration<PaymentMethodToken, PaymentMethodTokenizationData, PaymentsResponseData>+ for Stripebilling+{+ // Not Implemented (R)+}++impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Stripebilling+where+ Self: ConnectorIntegration<Flow, Request, Response>,+{+ fn build_headers(+ &self,+ req: &RouterData<Flow, Request, Response>,+ _connectors: &Connectors,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {+ let mut header = vec![(+ headers::CONTENT_TYPE.to_string(),+ self.get_content_type().to_string().into(),+ )];+ let mut api_key = self.get_auth_header(&req.connector_auth_type)?;+ header.append(&mut api_key);+ Ok(header)+ }+}++impl ConnectorCommon for Stripebilling {+ fn id(&self) -> &'static str {+ "stripebilling"+ }++ fn get_currency_unit(&self) -> api::CurrencyUnit {+ api::CurrencyUnit::Minor+ }++ fn common_get_content_type(&self) -> &'static str {+ "application/json"+ }++ fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str {+ connectors.stripebilling.base_url.as_ref()+ }++ fn get_auth_header(+ &self,+ auth_type: &ConnectorAuthType,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {+ let auth = stripebilling::StripebillingAuthType::try_from(auth_type)+ .change_context(errors::ConnectorError::FailedToObtainAuthType)?;+ Ok(vec![(+ headers::AUTHORIZATION.to_string(),+ auth.api_key.expose().into_masked(),+ )])+ }++ fn build_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ let response: stripebilling::StripebillingErrorResponse = res+ .response+ .parse_struct("StripebillingErrorResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;++ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);++ Ok(ErrorResponse {+ status_code: res.status_code,+ code: response.code,+ message: response.message,+ reason: response.reason,+ attempt_status: None,+ connector_transaction_id: None,+ })+ }+}++impl ConnectorValidation for Stripebilling {+ //TODO: implement functions when support enabled+}++impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Stripebilling {+ //TODO: implement sessions flow+}++impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Stripebilling {}++impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>+ for Stripebilling+{+}++impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData>+ for Stripebilling+{+ fn get_headers(+ &self,+ req: &PaymentsAuthorizeRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &PaymentsAuthorizeRouterData,+ _connectors: &Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())+ }++ fn get_request_body(+ &self,+ req: &PaymentsAuthorizeRouterData,+ _connectors: &Connectors,+ ) -> CustomResult<RequestContent, errors::ConnectorError> {+ let amount = utils::convert_amount(+ self.amount_converter,+ req.request.minor_amount,+ req.request.currency,+ )?;++ let connector_router_data = stripebilling::StripebillingRouterData::from((amount, req));+ let connector_req =+ stripebilling::StripebillingPaymentsRequest::try_from(&connector_router_data)?;+ Ok(RequestContent::Json(Box::new(connector_req)))+ }++ fn build_request(+ &self,+ req: &PaymentsAuthorizeRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {+ Ok(Some(+ RequestBuilder::new()+ .method(Method::Post)+ .url(&types::PaymentsAuthorizeType::get_url(+ self, req, connectors,+ )?)+ .attach_default_headers()+ .headers(types::PaymentsAuthorizeType::get_headers(+ self, req, connectors,+ )?)+ .set_body(types::PaymentsAuthorizeType::get_request_body(+ self, req, connectors,+ )?)+ .build(),+ ))+ }++ fn handle_response(+ &self,+ data: &PaymentsAuthorizeRouterData,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {+ let response: stripebilling::StripebillingPaymentsResponse = res+ .response+ .parse_struct("Stripebilling PaymentsAuthorizeResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ RouterData::try_from(ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Stripebilling {+ fn get_headers(+ &self,+ req: &PaymentsSyncRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &PaymentsSyncRouterData,+ _connectors: &Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())+ }++ fn build_request(+ &self,+ req: &PaymentsSyncRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {+ Ok(Some(+ RequestBuilder::new()+ .method(Method::Get)+ .url(&types::PaymentsSyncType::get_url(self, req, connectors)?)+ .attach_default_headers()+ .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)+ .build(),+ ))+ }++ fn handle_response(+ &self,+ data: &PaymentsSyncRouterData,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {+ let response: stripebilling::StripebillingPaymentsResponse = res+ .response+ .parse_struct("stripebilling PaymentsSyncResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ RouterData::try_from(ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> for Stripebilling {+ fn get_headers(+ &self,+ req: &PaymentsCaptureRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &PaymentsCaptureRouterData,+ _connectors: &Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())+ }++ fn get_request_body(+ &self,+ _req: &PaymentsCaptureRouterData,+ _connectors: &Connectors,+ ) -> CustomResult<RequestContent, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into())+ }++ fn build_request(+ &self,+ req: &PaymentsCaptureRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {+ Ok(Some(+ RequestBuilder::new()+ .method(Method::Post)+ .url(&types::PaymentsCaptureType::get_url(self, req, connectors)?)+ .attach_default_headers()+ .headers(types::PaymentsCaptureType::get_headers(+ self, req, connectors,+ )?)+ .set_body(types::PaymentsCaptureType::get_request_body(+ self, req, connectors,+ )?)+ .build(),+ ))+ }++ fn handle_response(+ &self,+ data: &PaymentsCaptureRouterData,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<PaymentsCaptureRouterData, errors::ConnectorError> {+ let response: stripebilling::StripebillingPaymentsResponse = res+ .response+ .parse_struct("Stripebilling PaymentsCaptureResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ RouterData::try_from(ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Stripebilling {}++impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Stripebilling {+ fn get_headers(+ &self,+ req: &RefundsRouterData<Execute>,+ connectors: &Connectors,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &RefundsRouterData<Execute>,+ _connectors: &Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())+ }++ fn get_request_body(+ &self,+ req: &RefundsRouterData<Execute>,+ _connectors: &Connectors,+ ) -> CustomResult<RequestContent, errors::ConnectorError> {+ let refund_amount = utils::convert_amount(+ self.amount_converter,+ req.request.minor_refund_amount,+ req.request.currency,+ )?;++ let connector_router_data =+ stripebilling::StripebillingRouterData::from((refund_amount, req));+ let connector_req =+ stripebilling::StripebillingRefundRequest::try_from(&connector_router_data)?;+ Ok(RequestContent::Json(Box::new(connector_req)))+ }++ fn build_request(+ &self,+ req: &RefundsRouterData<Execute>,+ connectors: &Connectors,+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {+ let request = RequestBuilder::new()+ .method(Method::Post)+ .url(&types::RefundExecuteType::get_url(self, req, connectors)?)+ .attach_default_headers()+ .headers(types::RefundExecuteType::get_headers(+ self, req, connectors,+ )?)+ .set_body(types::RefundExecuteType::get_request_body(+ self, req, connectors,+ )?)+ .build();+ Ok(Some(request))+ }++ fn handle_response(+ &self,+ data: &RefundsRouterData<Execute>,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<RefundsRouterData<Execute>, errors::ConnectorError> {+ let response: stripebilling::RefundResponse = res+ .response+ .parse_struct("stripebilling RefundResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ RouterData::try_from(ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Stripebilling {+ fn get_headers(+ &self,+ req: &RefundSyncRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {+ self.build_headers(req, connectors)+ }++ fn get_content_type(&self) -> &'static str {+ self.common_get_content_type()+ }++ fn get_url(+ &self,+ _req: &RefundSyncRouterData,+ _connectors: &Connectors,+ ) -> CustomResult<String, errors::ConnectorError> {+ Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())+ }++ fn build_request(+ &self,+ req: &RefundSyncRouterData,+ connectors: &Connectors,+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {+ Ok(Some(+ RequestBuilder::new()+ .method(Method::Get)+ .url(&types::RefundSyncType::get_url(self, req, connectors)?)+ .attach_default_headers()+ .headers(types::RefundSyncType::get_headers(self, req, connectors)?)+ .set_body(types::RefundSyncType::get_request_body(+ self, req, connectors,+ )?)+ .build(),+ ))+ }++ fn handle_response(+ &self,+ data: &RefundSyncRouterData,+ event_builder: Option<&mut ConnectorEvent>,+ res: Response,+ ) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> {+ let response: stripebilling::RefundResponse = res+ .response+ .parse_struct("stripebilling RefundSyncResponse")+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;+ event_builder.map(|i| i.set_response_body(&response));+ router_env::logger::info!(connector_response=?response);+ RouterData::try_from(ResponseRouterData {+ response,+ data: data.clone(),+ http_code: res.status_code,+ })+ }++ fn get_error_response(+ &self,+ res: Response,+ event_builder: Option<&mut ConnectorEvent>,+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {+ self.build_error_response(res, event_builder)+ }+}++#[async_trait::async_trait]+impl webhooks::IncomingWebhook for Stripebilling {+ fn get_webhook_object_reference_id(+ &self,+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,+ ) -> CustomResult<api_models::webhooks::ObjectReferenceId, errors::ConnectorError> {+ Err(report!(errors::ConnectorError::WebhooksNotImplemented))+ }++ fn get_webhook_event_type(+ &self,+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,+ ) -> CustomResult<api_models::webhooks::IncomingWebhookEvent, errors::ConnectorError> {+ Err(report!(errors::ConnectorError::WebhooksNotImplemented))+ }++ fn get_webhook_resource_object(+ &self,+ _request: &webhooks::IncomingWebhookRequestDetails<'_>,+ ) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {+ Err(report!(errors::ConnectorError::WebhooksNotImplemented))+ }+}++impl ConnectorSpecifications for Stripebilling {}diff --git a/crates/hyperswitch_connectors/src/connectors/stripebilling/transformers.rs b/crates/hyperswitch_connectors/src/connectors/stripebilling/transformers.rsnew file mode 100644index 0000000000..dcaa247463--- /dev/null+++ b/crates/hyperswitch_connectors/src/connectors/stripebilling/transformers.rs@@ -0,0 +1,232 @@+use common_enums::enums;+use common_utils::types::StringMinorUnit;+use hyperswitch_domain_models::{+ payment_method_data::PaymentMethodData,+ router_data::{ConnectorAuthType, RouterData},+ router_flow_types::refunds::{Execute, RSync},+ router_request_types::ResponseId,+ router_response_types::{PaymentsResponseData, RefundsResponseData},+ types::{PaymentsAuthorizeRouterData, RefundsRouterData},+};+use hyperswitch_interfaces::errors;+use masking::Secret;+use serde::{Deserialize, Serialize};++use crate::{+ types::{RefundsResponseRouterData, ResponseRouterData},+ utils::PaymentsAuthorizeRequestData,+};++//TODO: Fill the struct with respective fields+pub struct StripebillingRouterData<T> {+ pub amount: StringMinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc.+ pub router_data: T,+}++impl<T> From<(StringMinorUnit, T)> for StripebillingRouterData<T> {+ fn from((amount, item): (StringMinorUnit, T)) -> Self {+ //Todo : use utils to convert the amount to the type of amount that a connector accepts+ Self {+ amount,+ router_data: item,+ }+ }+}++//TODO: Fill the struct with respective fields+#[derive(Default, Debug, Serialize, PartialEq)]+pub struct StripebillingPaymentsRequest {+ amount: StringMinorUnit,+ card: StripebillingCard,+}++#[derive(Default, Debug, Serialize, Eq, PartialEq)]+pub struct StripebillingCard {+ number: cards::CardNumber,+ expiry_month: Secret<String>,+ expiry_year: Secret<String>,+ cvc: Secret<String>,+ complete: bool,+}++impl TryFrom<&StripebillingRouterData<&PaymentsAuthorizeRouterData>>+ for StripebillingPaymentsRequest+{+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: &StripebillingRouterData<&PaymentsAuthorizeRouterData>,+ ) -> Result<Self, Self::Error> {+ match item.router_data.request.payment_method_data.clone() {+ PaymentMethodData::Card(req_card) => {+ let card = StripebillingCard {+ number: req_card.card_number,+ expiry_month: req_card.card_exp_month,+ expiry_year: req_card.card_exp_year,+ cvc: req_card.card_cvc,+ complete: item.router_data.request.is_auto_capture()?,+ };+ Ok(Self {+ amount: item.amount.clone(),+ card,+ })+ }+ _ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),+ }+ }+}++//TODO: Fill the struct with respective fields+// Auth Struct+pub struct StripebillingAuthType {+ pub(super) api_key: Secret<String>,+}++impl TryFrom<&ConnectorAuthType> for StripebillingAuthType {+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {+ match auth_type {+ ConnectorAuthType::HeaderKey { api_key } => Ok(Self {+ api_key: api_key.to_owned(),+ }),+ _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),+ }+ }+}+// PaymentsResponse+//TODO: Append the remaining status flags+#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]+#[serde(rename_all = "lowercase")]+pub enum StripebillingPaymentStatus {+ Succeeded,+ Failed,+ #[default]+ Processing,+}++impl From<StripebillingPaymentStatus> for common_enums::AttemptStatus {+ fn from(item: StripebillingPaymentStatus) -> Self {+ match item {+ StripebillingPaymentStatus::Succeeded => Self::Charged,+ StripebillingPaymentStatus::Failed => Self::Failure,+ StripebillingPaymentStatus::Processing => Self::Authorizing,+ }+ }+}++//TODO: Fill the struct with respective fields+#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]+pub struct StripebillingPaymentsResponse {+ status: StripebillingPaymentStatus,+ id: String,+}++impl<F, T> TryFrom<ResponseRouterData<F, StripebillingPaymentsResponse, T, PaymentsResponseData>>+ for RouterData<F, T, PaymentsResponseData>+{+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: ResponseRouterData<F, StripebillingPaymentsResponse, T, PaymentsResponseData>,+ ) -> Result<Self, Self::Error> {+ Ok(Self {+ status: common_enums::AttemptStatus::from(item.response.status),+ response: Ok(PaymentsResponseData::TransactionResponse {+ resource_id: ResponseId::ConnectorTransactionId(item.response.id),+ redirection_data: Box::new(None),+ mandate_reference: Box::new(None),+ connector_metadata: None,+ network_txn_id: None,+ connector_response_reference_id: None,+ incremental_authorization_allowed: None,+ charges: None,+ }),+ ..item.data+ })+ }+}++//TODO: Fill the struct with respective fields+// REFUND :+// Type definition for RefundRequest+#[derive(Default, Debug, Serialize)]+pub struct StripebillingRefundRequest {+ pub amount: StringMinorUnit,+}++impl<F> TryFrom<&StripebillingRouterData<&RefundsRouterData<F>>> for StripebillingRefundRequest {+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: &StripebillingRouterData<&RefundsRouterData<F>>,+ ) -> Result<Self, Self::Error> {+ Ok(Self {+ amount: item.amount.to_owned(),+ })+ }+}++// Type definition for Refund Response++#[allow(dead_code)]+#[derive(Debug, Serialize, Default, Deserialize, Clone)]+pub enum RefundStatus {+ Succeeded,+ Failed,+ #[default]+ Processing,+}++impl From<RefundStatus> for enums::RefundStatus {+ fn from(item: RefundStatus) -> Self {+ match item {+ RefundStatus::Succeeded => Self::Success,+ RefundStatus::Failed => Self::Failure,+ RefundStatus::Processing => Self::Pending,+ //TODO: Review mapping+ }+ }+}++//TODO: Fill the struct with respective fields+#[derive(Default, Debug, Clone, Serialize, Deserialize)]+pub struct RefundResponse {+ id: String,+ status: RefundStatus,+}++impl TryFrom<RefundsResponseRouterData<Execute, RefundResponse>> for RefundsRouterData<Execute> {+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: RefundsResponseRouterData<Execute, RefundResponse>,+ ) -> Result<Self, Self::Error> {+ Ok(Self {+ response: Ok(RefundsResponseData {+ connector_refund_id: item.response.id.to_string(),+ refund_status: enums::RefundStatus::from(item.response.status),+ }),+ ..item.data+ })+ }+}++impl TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> for RefundsRouterData<RSync> {+ type Error = error_stack::Report<errors::ConnectorError>;+ fn try_from(+ item: RefundsResponseRouterData<RSync, RefundResponse>,+ ) -> Result<Self, Self::Error> {+ Ok(Self {+ response: Ok(RefundsResponseData {+ connector_refund_id: item.response.id.to_string(),+ refund_status: enums::RefundStatus::from(item.response.status),+ }),+ ..item.data+ })+ }+}++//TODO: Fill the struct with respective fields+#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]+pub struct StripebillingErrorResponse {+ pub status_code: u16,+ pub code: String,+ pub message: String,+ pub reason: Option<String>,+}diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rsindex 243afaa5f4..86bed02707 100644--- a/crates/hyperswitch_connectors/src/default_implementations.rs+++ b/crates/hyperswitch_connectors/src/default_implementations.rs@@ -153,6 +153,7 @@ default_imp_for_authorize_session_token!(connectors::Redsys,connectors::Shift4,connectors::Stax,+ connectors::Stripebilling,connectors::Taxjar,connectors::UnifiedAuthenticationService,connectors::Volt,@@ -240,6 +241,7 @@ default_imp_for_calculate_tax!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Thunes,connectors::Tsys,connectors::UnifiedAuthenticationService,@@ -305,6 +307,7 @@ default_imp_for_session_update!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Mifinity,connectors::Mollie,@@ -392,6 +395,7 @@ default_imp_for_post_session_tokens!(connectors::Redsys,connectors::Shift4,connectors::Stax,+ connectors::Stripebilling,connectors::Taxjar,connectors::Mifinity,connectors::Mollie,@@ -487,6 +491,7 @@ default_imp_for_complete_authorize!(connectors::Redsys,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -573,6 +578,7 @@ default_imp_for_incremental_authorization!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -658,6 +664,7 @@ default_imp_for_create_customer!(connectors::Redsys,connectors::Shift4,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -737,6 +744,7 @@ default_imp_for_connector_redirect_response!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -816,6 +824,7 @@ default_imp_for_pre_processing_steps!(connectors::Redsys,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -903,6 +912,7 @@ default_imp_for_post_processing_steps!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -991,6 +1001,7 @@ default_imp_for_approve!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1079,6 +1090,7 @@ default_imp_for_reject!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1167,6 +1179,7 @@ default_imp_for_webhook_source_verification!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1256,6 +1269,7 @@ default_imp_for_accept_dispute!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1344,6 +1358,7 @@ default_imp_for_submit_evidence!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1432,6 +1447,7 @@ default_imp_for_defend_dispute!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1529,6 +1545,7 @@ default_imp_for_file_upload!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1608,6 +1625,7 @@ default_imp_for_payouts!(connectors::Shift4,connectors::Square,connectors::Stax,+ connectors::Stripebilling,connectors::Taxjar,connectors::Tsys,connectors::UnifiedAuthenticationService,@@ -1696,6 +1714,7 @@ default_imp_for_payouts_create!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1785,6 +1804,7 @@ default_imp_for_payouts_retrieve!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1874,6 +1894,7 @@ default_imp_for_payouts_eligibility!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1962,6 +1983,7 @@ default_imp_for_payouts_fulfill!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -2051,6 +2073,7 @@ default_imp_for_payouts_cancel!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -2140,6 +2163,7 @@ default_imp_for_payouts_quote!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -2229,6 +2253,7 @@ default_imp_for_payouts_recipient!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -2318,6 +2343,7 @@ default_imp_for_payouts_recipient_account!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -2408,6 +2434,7 @@ default_imp_for_frm_sale!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -2498,6 +2525,7 @@ default_imp_for_frm_checkout!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -2588,6 +2616,7 @@ default_imp_for_frm_transaction!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -2678,6 +2707,7 @@ default_imp_for_frm_fulfillment!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -2768,6 +2798,7 @@ default_imp_for_frm_record_return!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -2854,6 +2885,7 @@ default_imp_for_revoking_mandates!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -2942,6 +2974,7 @@ default_imp_for_uas_pre_authentication!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -3028,6 +3061,7 @@ default_imp_for_uas_post_authentication!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -3114,6 +3148,7 @@ default_imp_for_uas_authentication!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -3201,6 +3236,7 @@ default_imp_for_uas_authentication_confirmation!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rsindex 003c3cc46d..ef339c22a4 100644--- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs+++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs@@ -263,6 +263,7 @@ default_imp_for_new_connector_integration_payment!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -352,6 +353,7 @@ default_imp_for_new_connector_integration_refund!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -436,6 +438,7 @@ default_imp_for_new_connector_integration_connector_access_token!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -525,6 +528,7 @@ default_imp_for_new_connector_integration_accept_dispute!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -613,6 +617,7 @@ default_imp_for_new_connector_integration_submit_evidence!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -702,6 +707,7 @@ default_imp_for_new_connector_integration_defend_dispute!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -801,6 +807,7 @@ default_imp_for_new_connector_integration_file_upload!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -892,6 +899,7 @@ default_imp_for_new_connector_integration_payouts_create!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -983,6 +991,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1074,6 +1083,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1165,6 +1175,7 @@ default_imp_for_new_connector_integration_payouts_cancel!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1256,6 +1267,7 @@ default_imp_for_new_connector_integration_payouts_quote!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1347,6 +1359,7 @@ default_imp_for_new_connector_integration_payouts_recipient!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1438,6 +1451,7 @@ default_imp_for_new_connector_integration_payouts_sync!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1529,6 +1543,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1618,6 +1633,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1709,6 +1725,7 @@ default_imp_for_new_connector_integration_frm_sale!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1800,6 +1817,7 @@ default_imp_for_new_connector_integration_frm_checkout!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1891,6 +1909,7 @@ default_imp_for_new_connector_integration_frm_transaction!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -1982,6 +2001,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -2073,6 +2093,7 @@ default_imp_for_new_connector_integration_frm_record_return!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,@@ -2161,6 +2182,7 @@ default_imp_for_new_connector_integration_revoking_mandates!(connectors::Shift4,connectors::Stax,connectors::Square,+ connectors::Stripebilling,connectors::Taxjar,connectors::Thunes,connectors::Tsys,diff --git a/crates/hyperswitch_interfaces/src/configs.rs b/crates/hyperswitch_interfaces/src/configs.rsindex 4c4801801f..5b46184c36 100644--- a/crates/hyperswitch_interfaces/src/configs.rs+++ b/crates/hyperswitch_interfaces/src/configs.rs@@ -88,6 +88,7 @@ pub struct Connectors {pub square: ConnectorParams,pub stax: ConnectorParams,pub stripe: ConnectorParamsWithFileUploadUrl,+ pub stripebilling: ConnectorParams,pub taxjar: ConnectorParams,pub threedsecureio: ConnectorParams,pub thunes: ConnectorParams,diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rsindex de9d86fdd7..c4720f60ff 100644--- a/crates/router/src/connector.rs+++ b/crates/router/src/connector.rs@@ -44,8 +44,9 @@ pub use hyperswitch_connectors::connectors::{nuvei::Nuvei, paybox, paybox::Paybox, payeezy, payeezy::Payeezy, paystack, paystack::Paystack,payu, payu::Payu, placetopay, placetopay::Placetopay, powertranz, powertranz::Powertranz,prophetpay, prophetpay::Prophetpay, rapyd, rapyd::Rapyd, razorpay, razorpay::Razorpay, redsys,- redsys::Redsys, shift4, shift4::Shift4, square, square::Square, stax, stax::Stax, taxjar,- taxjar::Taxjar, thunes, thunes::Thunes, tsys, tsys::Tsys, unified_authentication_service,+ redsys::Redsys, shift4, shift4::Shift4, square, square::Square, stax, stax::Stax,+ stripebilling, stripebilling::Stripebilling, taxjar, taxjar::Taxjar, thunes, thunes::Thunes,+ tsys, tsys::Tsys, unified_authentication_service,unified_authentication_service::UnifiedAuthenticationService, volt, volt::Volt, wellsfargo,wellsfargo::Wellsfargo, worldline, worldline::Worldline, worldpay, worldpay::Worldpay, xendit,xendit::Xendit, zen, zen::Zen, zsl, zsl::Zsl,diff --git a/crates/router/src/core/payments/connector_integration_v2_impls.rs b/crates/router/src/core/payments/connector_integration_v2_impls.rsindex 997a40c939..d19afa5368 100644--- a/crates/router/src/core/payments/connector_integration_v2_impls.rs+++ b/crates/router/src/core/payments/connector_integration_v2_impls.rs@@ -1041,6 +1041,7 @@ default_imp_for_new_connector_integration_payouts!(connector::Square,connector::Stax,connector::Stripe,+ connector::Stripebilling,connector::Shift4,connector::Taxjar,connector::Trustpay,@@ -1508,6 +1509,7 @@ default_imp_for_new_connector_integration_frm!(connector::Square,connector::Stax,connector::Stripe,+ connector::Stripebilling,connector::Shift4,connector::Taxjar,connector::Trustpay,@@ -1888,6 +1890,7 @@ default_imp_for_new_connector_integration_connector_authentication!(connector::Square,connector::Stax,connector::Stripe,+ connector::Stripebilling,connector::Shift4,connector::Taxjar,connector::Trustpay,diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rsindex e9e3ea10cd..af5b5e54cb 100644--- a/crates/router/src/core/payments/flows.rs+++ b/crates/router/src/core/payments/flows.rs@@ -467,6 +467,7 @@ default_imp_for_connector_request_id!(connector::Square,connector::Stax,connector::Stripe,+ connector::Stripebilling,connector::Taxjar,connector::Threedsecureio,connector::Trustpay,@@ -1427,6 +1428,7 @@ default_imp_for_fraud_check!(connector::Square,connector::Stax,connector::Stripe,+ connector::Stripebilling,connector::Taxjar,connector::Threedsecureio,connector::Trustpay,@@ -1965,6 +1967,7 @@ default_imp_for_connector_authentication!(connector::Square,connector::Stax,connector::Stripe,+ connector::Stripebilling,connector::Taxjar,connector::Trustpay,connector::Tsys,diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rsindex d4b9d1eafc..a32e0457df 100644--- a/crates/router/src/types/api.rs+++ b/crates/router/src/types/api.rs@@ -519,6 +519,7 @@ impl ConnectorData {enums::Connector::Stripe => {Ok(ConnectorEnum::Old(Box::new(connector::Stripe::new())))}+ // enums::Connector::Stripebilling => Ok(ConnectorEnum::Old(Box::new(connector::Stripebilling))),enums::Connector::Wise => Ok(ConnectorEnum::Old(Box::new(connector::Wise::new()))),enums::Connector::Worldline => {Ok(ConnectorEnum::Old(Box::new(&connector::Worldline)))diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rsindex 1035aed2f9..0171e6e7c9 100644--- a/crates/router/src/types/transformers.rs+++ b/crates/router/src/types/transformers.rs@@ -305,6 +305,7 @@ impl ForeignTryFrom<api_enums::Connector> for common_enums::RoutableConnectors {api_enums::Connector::Square => Self::Square,api_enums::Connector::Stax => Self::Stax,api_enums::Connector::Stripe => Self::Stripe,+ // api_enums::Connector::Stripebilling => Self::Stripebilling,// api_enums::Connector::Taxjar => Self::Taxjar,// api_enums::Connector::Thunes => Self::Thunes,api_enums::Connector::Trustpay => Self::Trustpay,diff --git a/crates/router/tests/connectors/main.rs b/crates/router/tests/connectors/main.rsindex d0eb96efcc..09718d5618 100644--- a/crates/router/tests/connectors/main.rs+++ b/crates/router/tests/connectors/main.rs@@ -83,6 +83,7 @@ mod shift4;mod square;mod stax;mod stripe;+mod stripebilling;mod taxjar;mod trustpay;mod tsys;diff --git a/crates/router/tests/connectors/sample_auth.toml b/crates/router/tests/connectors/sample_auth.tomlindex 6509e1e411..d30a500888 100644--- a/crates/router/tests/connectors/sample_auth.toml+++ b/crates/router/tests/connectors/sample_auth.toml@@ -316,5 +316,8 @@ api_key= "API Key"[moneris]api_key= "API Key"+[stripebilling]+api_key= "API Key"+[paystack]api_key = "API Key"\ No newline at end of filediff --git a/crates/router/tests/connectors/stripebilling.rs b/crates/router/tests/connectors/stripebilling.rsnew file mode 100644index 0000000000..8fccb9cb88--- /dev/null+++ b/crates/router/tests/connectors/stripebilling.rs@@ -0,0 +1,421 @@+use hyperswitch_domain_models::payment_method_data::{Card, PaymentMethodData};+use masking::Secret;+use router::types::{self, api, storage::enums};+use test_utils::connector_auth;++use crate::utils::{self, ConnectorActions};++#[derive(Clone, Copy)]+struct StripebillingTest;+impl ConnectorActions for StripebillingTest {}+impl utils::Connector for StripebillingTest {+ fn get_data(&self) -> api::ConnectorData {+ use router::connector::Stripebilling;+ utils::construct_connector_data_old(+ Box::new(Stripebilling::new()),+ types::Connector::Plaid,+ api::GetToken::Connector,+ None,+ )+ }++ fn get_auth_token(&self) -> types::ConnectorAuthType {+ utils::to_connector_auth_type(+ connector_auth::ConnectorAuthentication::new()+ .stripebilling+ .expect("Missing connector authentication configuration")+ .into(),+ )+ }++ fn get_name(&self) -> String {+ "stripebilling".to_string()+ }+}++static CONNECTOR: StripebillingTest = StripebillingTest {};++fn get_default_payment_info() -> Option<utils::PaymentInfo> {+ None+}++fn payment_method_details() -> Option<types::PaymentsAuthorizeData> {+ None+}++// Cards Positive Tests+// Creates a payment using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_only_authorize_payment() {+ let response = CONNECTOR+ .authorize_payment(payment_method_details(), get_default_payment_info())+ .await+ .expect("Authorize payment response");+ assert_eq!(response.status, enums::AttemptStatus::Authorized);+}++// Captures a payment using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_capture_authorized_payment() {+ let response = CONNECTOR+ .authorize_and_capture_payment(payment_method_details(), None, get_default_payment_info())+ .await+ .expect("Capture payment response");+ assert_eq!(response.status, enums::AttemptStatus::Charged);+}++// Partially captures a payment using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_partially_capture_authorized_payment() {+ let response = CONNECTOR+ .authorize_and_capture_payment(+ payment_method_details(),+ Some(types::PaymentsCaptureData {+ amount_to_capture: 50,+ ..utils::PaymentCaptureType::default().0+ }),+ get_default_payment_info(),+ )+ .await+ .expect("Capture payment response");+ assert_eq!(response.status, enums::AttemptStatus::Charged);+}++// Synchronizes a payment using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_sync_authorized_payment() {+ let authorize_response = CONNECTOR+ .authorize_payment(payment_method_details(), get_default_payment_info())+ .await+ .expect("Authorize payment response");+ let txn_id = utils::get_connector_transaction_id(authorize_response.response);+ let response = CONNECTOR+ .psync_retry_till_status_matches(+ enums::AttemptStatus::Authorized,+ Some(types::PaymentsSyncData {+ connector_transaction_id: types::ResponseId::ConnectorTransactionId(+ txn_id.unwrap(),+ ),+ ..Default::default()+ }),+ get_default_payment_info(),+ )+ .await+ .expect("PSync response");+ assert_eq!(response.status, enums::AttemptStatus::Authorized,);+}++// Voids a payment using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_void_authorized_payment() {+ let response = CONNECTOR+ .authorize_and_void_payment(+ payment_method_details(),+ Some(types::PaymentsCancelData {+ connector_transaction_id: String::from(""),+ cancellation_reason: Some("requested_by_customer".to_string()),+ ..Default::default()+ }),+ get_default_payment_info(),+ )+ .await+ .expect("Void payment response");+ assert_eq!(response.status, enums::AttemptStatus::Voided);+}++// Refunds a payment using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_refund_manually_captured_payment() {+ let response = CONNECTOR+ .capture_payment_and_refund(+ payment_method_details(),+ None,+ None,+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap().refund_status,+ enums::RefundStatus::Success,+ );+}++// Partially refunds a payment using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_partially_refund_manually_captured_payment() {+ let response = CONNECTOR+ .capture_payment_and_refund(+ payment_method_details(),+ None,+ Some(types::RefundsData {+ refund_amount: 50,+ ..utils::PaymentRefundType::default().0+ }),+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap().refund_status,+ enums::RefundStatus::Success,+ );+}++// Synchronizes a refund using the manual capture flow (Non 3DS).+#[actix_web::test]+async fn should_sync_manually_captured_refund() {+ let refund_response = CONNECTOR+ .capture_payment_and_refund(+ payment_method_details(),+ None,+ None,+ get_default_payment_info(),+ )+ .await+ .unwrap();+ let response = CONNECTOR+ .rsync_retry_till_status_matches(+ enums::RefundStatus::Success,+ refund_response.response.unwrap().connector_refund_id,+ None,+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap().refund_status,+ enums::RefundStatus::Success,+ );+}++// Creates a payment using the automatic capture flow (Non 3DS).+#[actix_web::test]+async fn should_make_payment() {+ let authorize_response = CONNECTOR+ .make_payment(payment_method_details(), get_default_payment_info())+ .await+ .unwrap();+ assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);+}++// Synchronizes a payment using the automatic capture flow (Non 3DS).+#[actix_web::test]+async fn should_sync_auto_captured_payment() {+ let authorize_response = CONNECTOR+ .make_payment(payment_method_details(), get_default_payment_info())+ .await+ .unwrap();+ assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);+ let txn_id = utils::get_connector_transaction_id(authorize_response.response);+ assert_ne!(txn_id, None, "Empty connector transaction id");+ let response = CONNECTOR+ .psync_retry_till_status_matches(+ enums::AttemptStatus::Charged,+ Some(types::PaymentsSyncData {+ connector_transaction_id: types::ResponseId::ConnectorTransactionId(+ txn_id.unwrap(),+ ),+ capture_method: Some(enums::CaptureMethod::Automatic),+ ..Default::default()+ }),+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(response.status, enums::AttemptStatus::Charged,);+}++// Refunds a payment using the automatic capture flow (Non 3DS).+#[actix_web::test]+async fn should_refund_auto_captured_payment() {+ let response = CONNECTOR+ .make_payment_and_refund(payment_method_details(), None, get_default_payment_info())+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap().refund_status,+ enums::RefundStatus::Success,+ );+}++// Partially refunds a payment using the automatic capture flow (Non 3DS).+#[actix_web::test]+async fn should_partially_refund_succeeded_payment() {+ let refund_response = CONNECTOR+ .make_payment_and_refund(+ payment_method_details(),+ Some(types::RefundsData {+ refund_amount: 50,+ ..utils::PaymentRefundType::default().0+ }),+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ refund_response.response.unwrap().refund_status,+ enums::RefundStatus::Success,+ );+}++// Creates multiple refunds against a payment using the automatic capture flow (Non 3DS).+#[actix_web::test]+async fn should_refund_succeeded_payment_multiple_times() {+ CONNECTOR+ .make_payment_and_multiple_refund(+ payment_method_details(),+ Some(types::RefundsData {+ refund_amount: 50,+ ..utils::PaymentRefundType::default().0+ }),+ get_default_payment_info(),+ )+ .await;+}++// Synchronizes a refund using the automatic capture flow (Non 3DS).+#[actix_web::test]+async fn should_sync_refund() {+ let refund_response = CONNECTOR+ .make_payment_and_refund(payment_method_details(), None, get_default_payment_info())+ .await+ .unwrap();+ let response = CONNECTOR+ .rsync_retry_till_status_matches(+ enums::RefundStatus::Success,+ refund_response.response.unwrap().connector_refund_id,+ None,+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap().refund_status,+ enums::RefundStatus::Success,+ );+}++// Cards Negative scenarios+// Creates a payment with incorrect CVC.+#[actix_web::test]+async fn should_fail_payment_for_incorrect_cvc() {+ let response = CONNECTOR+ .make_payment(+ Some(types::PaymentsAuthorizeData {+ payment_method_data: PaymentMethodData::Card(Card {+ card_cvc: Secret::new("12345".to_string()),+ ..utils::CCardType::default().0+ }),+ ..utils::PaymentAuthorizeType::default().0+ }),+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap_err().message,+ "Your card's security code is invalid.".to_string(),+ );+}++// Creates a payment with incorrect expiry month.+#[actix_web::test]+async fn should_fail_payment_for_invalid_exp_month() {+ let response = CONNECTOR+ .make_payment(+ Some(types::PaymentsAuthorizeData {+ payment_method_data: PaymentMethodData::Card(Card {+ card_exp_month: Secret::new("20".to_string()),+ ..utils::CCardType::default().0+ }),+ ..utils::PaymentAuthorizeType::default().0+ }),+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap_err().message,+ "Your card's expiration month is invalid.".to_string(),+ );+}++// Creates a payment with incorrect expiry year.+#[actix_web::test]+async fn should_fail_payment_for_incorrect_expiry_year() {+ let response = CONNECTOR+ .make_payment(+ Some(types::PaymentsAuthorizeData {+ payment_method_data: PaymentMethodData::Card(Card {+ card_exp_year: Secret::new("2000".to_string()),+ ..utils::CCardType::default().0+ }),+ ..utils::PaymentAuthorizeType::default().0+ }),+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap_err().message,+ "Your card's expiration year is invalid.".to_string(),+ );+}++// Voids a payment using automatic capture flow (Non 3DS).+#[actix_web::test]+async fn should_fail_void_payment_for_auto_capture() {+ let authorize_response = CONNECTOR+ .make_payment(payment_method_details(), get_default_payment_info())+ .await+ .unwrap();+ assert_eq!(authorize_response.status, enums::AttemptStatus::Charged);+ let txn_id = utils::get_connector_transaction_id(authorize_response.response);+ assert_ne!(txn_id, None, "Empty connector transaction id");+ let void_response = CONNECTOR+ .void_payment(txn_id.unwrap(), None, get_default_payment_info())+ .await+ .unwrap();+ assert_eq!(+ void_response.response.unwrap_err().message,+ "You cannot cancel this PaymentIntent because it has a status of succeeded."+ );+}++// Captures a payment using invalid connector payment id.+#[actix_web::test]+async fn should_fail_capture_for_invalid_payment() {+ let capture_response = CONNECTOR+ .capture_payment("123456789".to_string(), None, get_default_payment_info())+ .await+ .unwrap();+ assert_eq!(+ capture_response.response.unwrap_err().message,+ String::from("No such payment_intent: '123456789'")+ );+}++// Refunds a payment with refund amount higher than payment amount.+#[actix_web::test]+async fn should_fail_for_refund_amount_higher_than_payment_amount() {+ let response = CONNECTOR+ .make_payment_and_refund(+ payment_method_details(),+ Some(types::RefundsData {+ refund_amount: 150,+ ..utils::PaymentRefundType::default().0+ }),+ get_default_payment_info(),+ )+ .await+ .unwrap();+ assert_eq!(+ response.response.unwrap_err().message,+ "Refund amount (₹1.50) is greater than charge amount (₹1.00)",+ );+}++// Connector dependent test cases goes here++// [#478]: add unit tests for non 3DS, wallets & webhooks in connector testsdiff --git a/crates/test_utils/src/connector_auth.rs b/crates/test_utils/src/connector_auth.rsindex 521e58136a..bb40cc51ea 100644--- a/crates/test_utils/src/connector_auth.rs+++ b/crates/test_utils/src/connector_auth.rs@@ -87,6 +87,7 @@ pub struct ConnectorAuthentication {pub square: Option<BodyKey>,pub stax: Option<HeaderKey>,pub stripe: Option<HeaderKey>,+ pub stripebilling: Option<HeaderKey>,pub taxjar: Option<HeaderKey>,pub threedsecureio: Option<HeaderKey>,pub thunes: Option<HeaderKey>,diff --git a/loadtest/config/development.toml b/loadtest/config/development.tomlindex 5c2571cec1..526899b7ff 100644--- a/loadtest/config/development.toml+++ b/loadtest/config/development.toml@@ -161,6 +161,7 @@ square.base_url = "https://connect.squareupsandbox.com/"square.secondary_base_url = "https://pci-connect.squareupsandbox.com/"stax.base_url = "https://apiprod.fattlabs.com/"stripe.base_url = "https://api.stripe.com/"+stripebilling.base_url = "https://api.stripe.com/"taxjar.base_url = "https://api.sandbox.taxjar.com/v2/"threedsecureio.base_url = "https://service.sandbox.3dsecure.io"thunes.base_url = "https://api.limonetikqualif.com/"@@ -254,6 +255,7 @@ cards = ["square","stax","stripe",+ "stripebilling","taxjar","threedsecureio","thunes",diff --git a/scripts/add_connector.sh b/scripts/add_connector.shindex f2c55f54ad..046042bfa7 100755--- a/scripts/add_connector.sh+++ b/scripts/add_connector.sh@@ -6,7 +6,7 @@ function find_prev_connector() {git checkout $selfcp $self $self.tmp# Add new connector to existing list and sort it- connectors=(aci adyen adyenplatform airwallex amazonpay applepay authorizedotnet bambora bamboraapac bankofamerica billwerk bitpay bluesnap boku braintree cashtocode chargebee checkout coinbase cryptopay cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector ebanx elavon fiserv fiservemea fiuu forte getnet globalpay globepay gocardless gpayments helcim iatapay inespay itaubank jpmorgan klarna mifinity mollie moneris multisafepay netcetera nexinets nexixpay nomupay noon novalnet nuvei opayo opennode paybox payeezy payme payone paypal paystack payu placetopay plaid powertranz prophetpay rapyd razorpay redsys shift4 square stax stripe taxjar threedsecureio thunes trustpay tsys unified_authentication_service volt wellsfargo wellsfargopayout wise worldline worldpay xendit zsl "$1")+ connectors=(aci adyen adyenplatform airwallex amazonpay applepay authorizedotnet bambora bamboraapac bankofamerica billwerk bitpay bluesnap boku braintree cashtocode chargebee checkout coinbase cryptopay cybersource datatrans deutschebank digitalvirgo dlocal dummyconnector ebanx elavon fiserv fiservemea fiuu forte getnet globalpay globepay gocardless gpayments helcim iatapay inespay itaubank jpmorgan klarna mifinity mollie moneris multisafepay netcetera nexinets nexixpay nomupay noon novalnet nuvei opayo opennode paybox payeezy payme payone paypal paystack payu placetopay plaid powertranz prophetpay rapyd razorpay redsys shift4 square stax stripe stripebilling taxjar threedsecureio thunes trustpay tsys unified_authentication_service volt wellsfargo wellsfargopayout wise worldline worldpay xendit zsl "$1")IFS=$'\n' sorted=($(sort <<<"${connectors[*]}")); unset IFSres="$(echo ${sorted[@]})"sed -i'' -e "s/^ connectors=.*/ connectors=($res \"\$1\")/" $self.tmp