From 62b69958baf25aa7fad7229415cbd7c4dd4d83f3 Mon Sep 17 00:00:00 2001 From: Spriti Aneja Date: Fri, 22 Nov 2024 13:40:18 +0530 Subject: [PATCH 1/6] Move Bamboraapac to hyperswitch_connector_crate --- .../hyperswitch_connectors/src/connectors.rs | 19 +- .../src/connectors/bamboraapac.rs | 742 ++++++++++++ .../connectors/bamboraapac/transformers.rs | 1030 +++++++++++++++++ .../src/default_implementations.rs | 32 + .../src/default_implementations_v2.rs | 22 + crates/router/src/connector.rs | 39 +- .../connector_integration_v2_impls.rs | 22 - crates/router/src/core/payments/flows.rs | 32 - 8 files changed, 1855 insertions(+), 83 deletions(-) create mode 100644 crates/hyperswitch_connectors/src/connectors/bamboraapac.rs create mode 100644 crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers.rs diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs index 2bc824500964..fae40837a696 100644 --- a/crates/hyperswitch_connectors/src/connectors.rs +++ b/crates/hyperswitch_connectors/src/connectors.rs @@ -1,6 +1,7 @@ pub mod airwallex; pub mod amazonpay; pub mod bambora; +pub mod bamboraapac; pub mod billwerk; pub mod bitpay; pub mod cashtocode; @@ -40,13 +41,13 @@ pub mod zen; pub mod zsl; pub use self::{ - airwallex::Airwallex, amazonpay::Amazonpay, bambora::Bambora, billwerk::Billwerk, - bitpay::Bitpay, cashtocode::Cashtocode, coinbase::Coinbase, cryptopay::Cryptopay, - deutschebank::Deutschebank, digitalvirgo::Digitalvirgo, dlocal::Dlocal, elavon::Elavon, - fiserv::Fiserv, fiservemea::Fiservemea, fiuu::Fiuu, forte::Forte, globepay::Globepay, - helcim::Helcim, jpmorgan::Jpmorgan, mollie::Mollie, multisafepay::Multisafepay, - nexinets::Nexinets, nexixpay::Nexixpay, nomupay::Nomupay, novalnet::Novalnet, payeezy::Payeezy, - payu::Payu, powertranz::Powertranz, razorpay::Razorpay, shift4::Shift4, square::Square, - stax::Stax, taxjar::Taxjar, thunes::Thunes, tsys::Tsys, volt::Volt, worldline::Worldline, - worldpay::Worldpay, zen::Zen, zsl::Zsl, + airwallex::Airwallex, amazonpay::Amazonpay, bambora::Bambora, bamboraapac::Bamboraapac, + billwerk::Billwerk, bitpay::Bitpay, cashtocode::Cashtocode, coinbase::Coinbase, + cryptopay::Cryptopay, deutschebank::Deutschebank, digitalvirgo::Digitalvirgo, dlocal::Dlocal, + elavon::Elavon, fiserv::Fiserv, fiservemea::Fiservemea, fiuu::Fiuu, forte::Forte, + globepay::Globepay, helcim::Helcim, jpmorgan::Jpmorgan, mollie::Mollie, + multisafepay::Multisafepay, nexinets::Nexinets, nexixpay::Nexixpay, nomupay::Nomupay, + novalnet::Novalnet, payeezy::Payeezy, payu::Payu, powertranz::Powertranz, razorpay::Razorpay, + shift4::Shift4, square::Square, stax::Stax, taxjar::Taxjar, thunes::Thunes, tsys::Tsys, + volt::Volt, worldline::Worldline, worldpay::Worldpay, zen::Zen, zsl::Zsl, }; diff --git a/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs b/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs new file mode 100644 index 000000000000..16ecee19eea8 --- /dev/null +++ b/crates/hyperswitch_connectors/src/connectors/bamboraapac.rs @@ -0,0 +1,742 @@ +pub mod transformers; + +use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId}; +use common_enums::enums; +use common_utils::{ + errors::CustomResult, + ext_traits::{BytesExt, XmlExt}, + request::{Method, Request, RequestBuilder, RequestContent}, + types::{AmountConvertor, MinorUnit, MinorUnitForConnector}, +}; +use error_stack::{report, Report, ResultExt}; +use hyperswitch_domain_models::{ + payment_method_data::PaymentMethodData, + router_data::{AccessToken, 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, + RefundExecuteRouterData, RefundSyncRouterData, SetupMandateRouterData, + }, +}; +use hyperswitch_interfaces::{ + api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + configs::Connectors, + consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE}, + errors, + events::connector_api_logs::ConnectorEvent, + types::{self, Response}, + webhooks::{IncomingWebhook, IncomingWebhookRequestDetails}, +}; +use transformers as bamboraapac; + +use crate::{ + constants::headers, + types::ResponseRouterData, + utils::{self, construct_not_implemented_error_report, convert_amount}, +}; + +#[derive(Clone)] +pub struct Bamboraapac { + amount_converter: &'static (dyn AmountConvertor + Sync), +} + +impl Bamboraapac { + pub const fn new() -> &'static Self { + &Self { + amount_converter: &MinorUnitForConnector, + } + } +} + +impl api::Payment for Bamboraapac {} +impl api::PaymentSession for Bamboraapac {} +impl api::ConnectorAccessToken for Bamboraapac {} +impl api::MandateSetup for Bamboraapac {} +impl api::PaymentAuthorize for Bamboraapac {} +impl api::PaymentSync for Bamboraapac {} +impl api::PaymentCapture for Bamboraapac {} +impl api::PaymentVoid for Bamboraapac {} +impl api::Refund for Bamboraapac {} +impl api::RefundExecute for Bamboraapac {} +impl api::RefundSync for Bamboraapac {} +impl api::PaymentToken for Bamboraapac {} + +impl ConnectorIntegration + for Bamboraapac +{ + // Not Implemented (R) +} + +impl ConnectorCommonExt for Bamboraapac +where + Self: ConnectorIntegration, +{ + fn build_headers( + &self, + _req: &RouterData, + _connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + let header = vec![( + headers::CONTENT_TYPE.to_string(), + self.get_content_type().to_string().into(), + )]; + Ok(header) + } +} + +impl ConnectorValidation for Bamboraapac { + fn validate_capture_method( + &self, + capture_method: Option, + _pmt: Option, + ) -> CustomResult<(), errors::ConnectorError> { + let capture_method = capture_method.unwrap_or_default(); + match capture_method { + enums::CaptureMethod::Automatic | enums::CaptureMethod::Manual => Ok(()), + enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err( + construct_not_implemented_error_report(capture_method, self.id()), + ), + } + } + + fn validate_mandate_payment( + &self, + _pm_type: Option, + pm_data: PaymentMethodData, + ) -> CustomResult<(), errors::ConnectorError> { + let connector = self.id(); + match pm_data { + PaymentMethodData::Card(_) => Ok(()), + _ => Err(errors::ConnectorError::NotSupported { + message: "mandate payment".to_string(), + connector, + } + .into()), + } + } +} + +impl ConnectorCommon for Bamboraapac { + fn id(&self) -> &'static str { + "bamboraapac" + } + + fn get_currency_unit(&self) -> api::CurrencyUnit { + api::CurrencyUnit::Minor + } + + fn common_get_content_type(&self) -> &'static str { + "text/xml" + } + + fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str { + connectors.bamboraapac.base_url.as_ref() + } + + fn build_error_response( + &self, + res: Response, + event_builder: Option<&mut ConnectorEvent>, + ) -> CustomResult { + let response: Result< + bamboraapac::BamboraapacErrorResponse, + Report, + > = res.response.parse_struct("BamboraapacErrorResponse"); + + match response { + Ok(response_data) => { + event_builder.map(|i| i.set_error_response_body(&response_data)); + router_env::logger::info!(connector_response=?response_data); + + Ok(ErrorResponse { + status_code: res.status_code, + code: response_data + .declined_code + .unwrap_or(NO_ERROR_CODE.to_string()), + message: response_data + .declined_message + .clone() + .unwrap_or(NO_ERROR_MESSAGE.to_string()), + reason: response_data.declined_message, + attempt_status: None, + connector_transaction_id: None, + }) + } + Err(error_msg) => { + event_builder.map(|event| event.set_error(serde_json::json!({"error": res.response.escape_ascii().to_string(), "status_code": res.status_code}))); + router_env::logger::error!(deserialization_error =? error_msg); + utils::handle_json_response_deserialization_failure(res, "bamboaraapac") + } + } + } +} + +impl ConnectorIntegration for Bamboraapac { + //TODO: implement sessions flow +} + +impl ConnectorIntegration for Bamboraapac {} + +impl ConnectorIntegration + for Bamboraapac +{ + fn get_headers( + &self, + req: &SetupMandateRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + _req: &SetupMandateRouterData, + connectors: &Connectors, + ) -> CustomResult { + Ok(format!("{}/sipp.asmx", self.base_url(connectors))) + } + + fn get_request_body( + &self, + req: &SetupMandateRouterData, + _connectors: &Connectors, + ) -> CustomResult { + let connector_req = bamboraapac::get_setup_mandate_body(req)?; + + Ok(RequestContent::RawBytes(connector_req)) + } + + fn build_request( + &self, + req: &SetupMandateRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { + Ok(Some( + RequestBuilder::new() + .method(Method::Post) + .url(&types::SetupMandateType::get_url(self, req, connectors)?) + .attach_default_headers() + .headers(types::SetupMandateType::get_headers(self, req, connectors)?) + .set_body(types::SetupMandateType::get_request_body( + self, req, connectors, + )?) + .build(), + )) + } + + fn handle_response( + &self, + data: &SetupMandateRouterData, + event_builder: Option<&mut ConnectorEvent>, + res: Response, + ) -> CustomResult { + let response_data = html_to_xml_string_conversion( + String::from_utf8(res.response.to_vec()) + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, + ); + + let response = response_data + .parse_xml::() + .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 { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Bamboraapac { + fn get_headers( + &self, + req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult)>, 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 { + Ok(format!("{}/dts.asmx", self.base_url(connectors))) + } + + fn get_request_body( + &self, + req: &PaymentsAuthorizeRouterData, + _connectors: &Connectors, + ) -> CustomResult { + let amount = convert_amount( + self.amount_converter, + req.request.minor_amount, + req.request.currency, + )?; + let connector_router_data = bamboraapac::BamboraapacRouterData::try_from((amount, req))?; + + let connector_req = bamboraapac::get_payment_body(&connector_router_data)?; + + Ok(RequestContent::RawBytes(connector_req)) + } + + fn build_request( + &self, + req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult, 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 { + let response_data = html_to_xml_string_conversion( + String::from_utf8(res.response.to_vec()) + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, + ); + + let response = response_data + .parse_xml::() + .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 { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Bamboraapac { + fn get_headers( + &self, + req: &PaymentsSyncRouterData, + connectors: &Connectors, + ) -> CustomResult)>, 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 { + Ok(format!("{}/dts.asmx", self.base_url(connectors))) + } + + fn get_request_body( + &self, + req: &PaymentsSyncRouterData, + _connectors: &Connectors, + ) -> CustomResult { + let connector_req = bamboraapac::get_payment_sync_body(req)?; + + Ok(RequestContent::RawBytes(connector_req)) + } + + fn build_request( + &self, + req: &PaymentsSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { + Ok(Some( + RequestBuilder::new() + .method(Method::Post) + .url(&types::PaymentsSyncType::get_url(self, req, connectors)?) + .attach_default_headers() + .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?) + .set_body(types::PaymentsSyncType::get_request_body( + self, req, connectors, + )?) + .build(), + )) + } + + fn handle_response( + &self, + data: &PaymentsSyncRouterData, + event_builder: Option<&mut ConnectorEvent>, + res: Response, + ) -> CustomResult { + let response_data = html_to_xml_string_conversion( + String::from_utf8(res.response.to_vec()) + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, + ); + + let response = response_data + .parse_xml::() + .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 { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Bamboraapac { + fn get_headers( + &self, + req: &PaymentsCaptureRouterData, + connectors: &Connectors, + ) -> CustomResult)>, 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 { + Ok(format!("{}/dts.asmx", self.base_url(connectors))) + } + + fn get_request_body( + &self, + req: &PaymentsCaptureRouterData, + _connectors: &Connectors, + ) -> CustomResult { + let amount = convert_amount( + self.amount_converter, + req.request.minor_amount_to_capture, + req.request.currency, + )?; + let connector_router_data = bamboraapac::BamboraapacRouterData::try_from((amount, req))?; + + let connector_req = bamboraapac::get_capture_body(&connector_router_data)?; + + Ok(RequestContent::RawBytes(connector_req)) + } + + fn build_request( + &self, + req: &PaymentsCaptureRouterData, + connectors: &Connectors, + ) -> CustomResult, 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 { + let response_data = html_to_xml_string_conversion( + String::from_utf8(res.response.to_vec()) + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, + ); + + let response = response_data + .parse_xml::() + .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 { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Bamboraapac {} + +impl ConnectorIntegration for Bamboraapac { + fn get_headers( + &self, + req: &RefundExecuteRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { + self.build_headers(req, connectors) + } + + fn get_content_type(&self) -> &'static str { + self.common_get_content_type() + } + + fn get_url( + &self, + _req: &RefundExecuteRouterData, + connectors: &Connectors, + ) -> CustomResult { + Ok(format!("{}/dts.asmx", self.base_url(connectors))) + } + + fn get_request_body( + &self, + req: &RefundExecuteRouterData, + _connectors: &Connectors, + ) -> CustomResult { + let amount = convert_amount( + self.amount_converter, + req.request.minor_refund_amount, + req.request.currency, + )?; + let connector_router_data = bamboraapac::BamboraapacRouterData::try_from((amount, req))?; + + let connector_req = bamboraapac::get_refund_body(&connector_router_data)?; + + Ok(RequestContent::RawBytes(connector_req)) + } + + fn build_request( + &self, + req: &RefundExecuteRouterData, + connectors: &Connectors, + ) -> CustomResult, 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: &RefundExecuteRouterData, + event_builder: Option<&mut ConnectorEvent>, + res: Response, + ) -> CustomResult { + let response_data = html_to_xml_string_conversion( + String::from_utf8(res.response.to_vec()) + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, + ); + + let response = response_data + .parse_xml::() + .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 { + self.build_error_response(res, event_builder) + } +} + +impl ConnectorIntegration for Bamboraapac { + fn get_headers( + &self, + req: &RefundSyncRouterData, + connectors: &Connectors, + ) -> CustomResult)>, 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 { + Ok(format!("{}/dts.asmx", self.base_url(connectors))) + } + + fn get_request_body( + &self, + req: &RefundSyncRouterData, + _connectors: &Connectors, + ) -> CustomResult { + let connector_req = bamboraapac::get_refund_sync_body(req)?; + + Ok(RequestContent::RawBytes(connector_req)) + } + + fn build_request( + &self, + req: &RefundSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { + Ok(Some( + RequestBuilder::new() + .method(Method::Post) + .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 { + let response_data = html_to_xml_string_conversion( + String::from_utf8(res.response.to_vec()) + .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, + ); + + let response = response_data + .parse_xml::() + .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 { + self.build_error_response(res, event_builder) + } +} + +#[async_trait::async_trait] +impl IncomingWebhook for Bamboraapac { + fn get_webhook_object_reference_id( + &self, + _request: &IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) + } + + fn get_webhook_event_type( + &self, + _request: &IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) + } + + fn get_webhook_resource_object( + &self, + _request: &IncomingWebhookRequestDetails<'_>, + ) -> CustomResult, errors::ConnectorError> { + Err(report!(errors::ConnectorError::WebhooksNotImplemented)) + } +} + +fn html_to_xml_string_conversion(res: String) -> String { + res.replace("<", "<").replace(">", ">") +} diff --git a/crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers.rs b/crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers.rs new file mode 100644 index 000000000000..f4399d105c5d --- /dev/null +++ b/crates/hyperswitch_connectors/src/connectors/bamboraapac/transformers.rs @@ -0,0 +1,1030 @@ +use common_enums::enums; +use common_utils::types::MinorUnit; +use error_stack::ResultExt; +use hyperswitch_domain_models::{ + payment_method_data::PaymentMethodData, + router_data::{ConnectorAuthType, ErrorResponse, RouterData}, + router_request_types::{ + PaymentsAuthorizeData, PaymentsCaptureData, PaymentsSyncData, RefundsData, ResponseId, + SetupMandateRequestData, + }, + router_response_types::{MandateReference, PaymentsResponseData, RefundsResponseData}, + types, +}; +use hyperswitch_interfaces::{ + consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE}, + errors, +}; +use masking::{PeekInterface, Secret}; +use serde::{Deserialize, Serialize}; + +use crate::{ + types::ResponseRouterData, + utils::{self, CardData as _, PaymentsAuthorizeRequestData, RouterData as _}, +}; + +type Error = error_stack::Report; + +pub struct BamboraapacRouterData { + pub amount: MinorUnit, + pub router_data: T, +} + +impl TryFrom<(MinorUnit, T)> for BamboraapacRouterData { + type Error = error_stack::Report; + fn try_from((amount, item): (MinorUnit, T)) -> Result { + Ok(Self { + amount, + router_data: item, + }) + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct BamboraapacMeta { + pub authorize_id: String, +} + +// request body in soap format +pub fn get_payment_body( + req: &BamboraapacRouterData<&types::PaymentsAuthorizeRouterData>, +) -> Result, Error> { + let transaction_data = get_transaction_body(req)?; + let body = format!( + r#" + + + + + + + + + + "#, + transaction_data + ); + + Ok(body.as_bytes().to_vec()) +} + +fn get_transaction_body( + req: &BamboraapacRouterData<&types::PaymentsAuthorizeRouterData>, +) -> Result { + let auth_details = BamboraapacAuthType::try_from(&req.router_data.connector_auth_type)?; + let transaction_type = get_transaction_type(req.router_data.request.capture_method)?; + let card_info = get_card_data(req.router_data)?; + let transaction_data = format!( + r#" + + {} + {} + {} + {} + {} + + {} + {} + + + "#, + req.router_data.connector_request_reference_id.to_owned(), + req.amount, + transaction_type, + auth_details.account_number.peek(), + card_info, + auth_details.username.peek(), + auth_details.password.peek(), + ); + + Ok(transaction_data) +} + +fn get_card_data(req: &types::PaymentsAuthorizeRouterData) -> Result { + let card_data = match &req.request.payment_method_data { + PaymentMethodData::Card(card) => { + let card_holder_name = req.get_billing_full_name()?; + + if req.request.setup_future_usage == Some(enums::FutureUsage::OffSession) { + format!( + r#" + + 2 + {} + {} + {} + {} + {} + + "#, + card.card_number.get_card_no(), + card.card_exp_month.peek(), + card.get_expiry_year_4_digit().peek(), + card.card_cvc.peek(), + card_holder_name.peek(), + ) + } else { + format!( + r#" + + {} + {} + {} + {} + {} + + "#, + card.card_number.get_card_no(), + card.card_exp_month.peek(), + card.get_expiry_year_4_digit().peek(), + card.card_cvc.peek(), + card_holder_name.peek(), + ) + } + } + PaymentMethodData::MandatePayment => { + format!( + r#" + + 2 + {} + + "#, + req.request.get_connector_mandate_id()? + ) + } + _ => { + return Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("Bambora APAC"), + ))? + } + }; + Ok(card_data) +} + +fn get_transaction_type(capture_method: Option) -> Result { + match capture_method { + Some(enums::CaptureMethod::Automatic) | None => Ok(1), + Some(enums::CaptureMethod::Manual) => Ok(2), + _ => Err(errors::ConnectorError::CaptureMethodNotSupported)?, + } +} + +pub struct BamboraapacAuthType { + username: Secret, + password: Secret, + account_number: Secret, +} + +impl TryFrom<&ConnectorAuthType> for BamboraapacAuthType { + type Error = error_stack::Report; + fn try_from(auth_type: &ConnectorAuthType) -> Result { + match auth_type { + ConnectorAuthType::SignatureKey { + api_key, + key1, + api_secret, + } => Ok(Self { + username: api_key.to_owned(), + password: api_secret.to_owned(), + account_number: key1.to_owned(), + }), + _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()), + } + } +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename = "Envelope")] +#[serde(rename_all = "PascalCase")] +pub struct BamboraapacPaymentsResponse { + body: BodyResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct BodyResponse { + submit_single_payment_response: SubmitSinglePaymentResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct SubmitSinglePaymentResponse { + submit_single_payment_result: SubmitSinglePaymentResult, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct SubmitSinglePaymentResult { + response: PaymentResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct PaymentResponse { + response_code: u8, + receipt: String, + credit_card_token: Option, + declined_code: Option, + declined_message: Option, +} + +fn get_attempt_status( + response_code: u8, + capture_method: Option, +) -> enums::AttemptStatus { + match response_code { + 0 => match capture_method { + Some(enums::CaptureMethod::Automatic) | None => enums::AttemptStatus::Charged, + Some(enums::CaptureMethod::Manual) => enums::AttemptStatus::Authorized, + _ => enums::AttemptStatus::Pending, + }, + 1 => enums::AttemptStatus::Failure, + _ => enums::AttemptStatus::Pending, + } +} + +impl + TryFrom< + ResponseRouterData< + F, + BamboraapacPaymentsResponse, + PaymentsAuthorizeData, + PaymentsResponseData, + >, + > for RouterData +{ + type Error = error_stack::Report; + fn try_from( + item: ResponseRouterData< + F, + BamboraapacPaymentsResponse, + PaymentsAuthorizeData, + PaymentsResponseData, + >, + ) -> Result { + let response_code = item + .response + .body + .submit_single_payment_response + .submit_single_payment_result + .response + .response_code; + let connector_transaction_id = item + .response + .body + .submit_single_payment_response + .submit_single_payment_result + .response + .receipt; + + let mandate_reference = + if item.data.request.setup_future_usage == Some(enums::FutureUsage::OffSession) { + let connector_mandate_id = item + .response + .body + .submit_single_payment_response + .submit_single_payment_result + .response + .credit_card_token; + Some(MandateReference { + connector_mandate_id, + payment_method_id: None, + mandate_metadata: None, + connector_mandate_request_reference_id: None, + }) + } else { + None + }; + // transaction approved + if response_code == 0 { + Ok(Self { + status: get_attempt_status(response_code, item.data.request.capture_method), + response: Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::ConnectorTransactionId( + connector_transaction_id.to_owned(), + ), + redirection_data: Box::new(None), + mandate_reference: Box::new(mandate_reference), + connector_metadata: None, + network_txn_id: None, + connector_response_reference_id: Some(connector_transaction_id), + incremental_authorization_allowed: None, + charge_id: None, + }), + ..item.data + }) + } + // transaction failed + else { + let code = item + .response + .body + .submit_single_payment_response + .submit_single_payment_result + .response + .declined_code + .unwrap_or(NO_ERROR_CODE.to_string()); + + let declined_message = item + .response + .body + .submit_single_payment_response + .submit_single_payment_result + .response + .declined_message + .unwrap_or(NO_ERROR_MESSAGE.to_string()); + Ok(Self { + status: get_attempt_status(response_code, item.data.request.capture_method), + response: Err(ErrorResponse { + status_code: item.http_code, + code, + message: declined_message.to_owned(), + reason: Some(declined_message), + attempt_status: None, + connector_transaction_id: None, + }), + ..item.data + }) + } + } +} + +pub fn get_setup_mandate_body(req: &types::SetupMandateRouterData) -> Result, Error> { + let card_holder_name = req.get_billing_full_name()?; + let auth_details = BamboraapacAuthType::try_from(&req.connector_auth_type)?; + let body = match &req.request.payment_method_data { + PaymentMethodData::Card(card) => { + format!( + r#" + + + + + + + {} + {} + {} + {} + 2 + {} + {} + + ]]> + + + + + "#, + card.card_number.get_card_no(), + card.card_exp_month.peek(), + card.get_expiry_year_4_digit().peek(), + card_holder_name.peek(), + auth_details.username.peek(), + auth_details.password.peek(), + ) + } + _ => { + return Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("Bambora APAC"), + ))?; + } + }; + + Ok(body.as_bytes().to_vec()) +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename = "Envelope")] +#[serde(rename_all = "PascalCase")] +pub struct BamboraapacMandateResponse { + body: MandateBodyResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct MandateBodyResponse { + tokenise_credit_card_response: TokeniseCreditCardResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct TokeniseCreditCardResponse { + tokenise_credit_card_result: TokeniseCreditCardResult, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct TokeniseCreditCardResult { + tokenise_credit_card_response: MandateResponseBody, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct MandateResponseBody { + return_value: u8, + token: Option, +} + +impl + TryFrom< + ResponseRouterData< + F, + BamboraapacMandateResponse, + SetupMandateRequestData, + PaymentsResponseData, + >, + > for RouterData +{ + type Error = error_stack::Report; + fn try_from( + item: ResponseRouterData< + F, + BamboraapacMandateResponse, + SetupMandateRequestData, + PaymentsResponseData, + >, + ) -> Result { + let response_code = item + .response + .body + .tokenise_credit_card_response + .tokenise_credit_card_result + .tokenise_credit_card_response + .return_value; + + let connector_mandate_id = item + .response + .body + .tokenise_credit_card_response + .tokenise_credit_card_result + .tokenise_credit_card_response + .token + .ok_or(errors::ConnectorError::MissingConnectorMandateID)?; + + // transaction approved + if response_code == 0 { + Ok(Self { + status: enums::AttemptStatus::Charged, + response: Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::NoResponseId, + redirection_data: Box::new(None), + mandate_reference: Box::new(Some(MandateReference { + connector_mandate_id: Some(connector_mandate_id), + payment_method_id: None, + mandate_metadata: None, + connector_mandate_request_reference_id: None, + })), + connector_metadata: None, + network_txn_id: None, + connector_response_reference_id: None, + incremental_authorization_allowed: None, + charge_id: None, + }), + ..item.data + }) + } + // transaction failed + else { + Ok(Self { + status: enums::AttemptStatus::Failure, + response: Err(ErrorResponse { + status_code: item.http_code, + code: NO_ERROR_CODE.to_string(), + message: NO_ERROR_MESSAGE.to_string(), + reason: None, + attempt_status: None, + connector_transaction_id: None, + }), + ..item.data + }) + } + } +} + +// capture body in soap format +pub fn get_capture_body( + req: &BamboraapacRouterData<&types::PaymentsCaptureRouterData>, +) -> Result, Error> { + let receipt = req.router_data.request.connector_transaction_id.to_owned(); + let auth_details = BamboraapacAuthType::try_from(&req.router_data.connector_auth_type)?; + let body = format!( + r#" + + + + + + {} + {} + + {} + {} + + + ]]> + + + + + "#, + receipt, + req.amount, + auth_details.username.peek(), + auth_details.password.peek(), + ); + + Ok(body.as_bytes().to_vec()) +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename = "Envelope")] +#[serde(rename_all = "PascalCase")] +pub struct BamboraapacCaptureResponse { + body: CaptureBodyResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct CaptureBodyResponse { + submit_single_capture_response: SubmitSingleCaptureResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct SubmitSingleCaptureResponse { + submit_single_capture_result: SubmitSingleCaptureResult, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct SubmitSingleCaptureResult { + response: CaptureResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct CaptureResponse { + response_code: u8, + receipt: String, + declined_code: Option, + declined_message: Option, +} + +impl + TryFrom< + ResponseRouterData< + F, + BamboraapacCaptureResponse, + PaymentsCaptureData, + PaymentsResponseData, + >, + > for RouterData +{ + type Error = error_stack::Report; + fn try_from( + item: ResponseRouterData< + F, + BamboraapacCaptureResponse, + PaymentsCaptureData, + PaymentsResponseData, + >, + ) -> Result { + let response_code = item + .response + .body + .submit_single_capture_response + .submit_single_capture_result + .response + .response_code; + let connector_transaction_id = item + .response + .body + .submit_single_capture_response + .submit_single_capture_result + .response + .receipt; + + // storing receipt_id of authorize to metadata for future usage + let connector_metadata = Some(serde_json::json!(BamboraapacMeta { + authorize_id: item.data.request.connector_transaction_id.to_owned() + })); + // transaction approved + if response_code == 0 { + Ok(Self { + status: enums::AttemptStatus::Charged, + response: Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::ConnectorTransactionId( + connector_transaction_id.to_owned(), + ), + redirection_data: Box::new(None), + mandate_reference: Box::new(None), + connector_metadata, + network_txn_id: None, + connector_response_reference_id: Some(connector_transaction_id), + incremental_authorization_allowed: None, + charge_id: None, + }), + ..item.data + }) + } + // transaction failed + else { + let code = item + .response + .body + .submit_single_capture_response + .submit_single_capture_result + .response + .declined_code + .unwrap_or(NO_ERROR_CODE.to_string()); + let declined_message = item + .response + .body + .submit_single_capture_response + .submit_single_capture_result + .response + .declined_message + .unwrap_or(NO_ERROR_MESSAGE.to_string()); + Ok(Self { + status: enums::AttemptStatus::Failure, + response: Err(ErrorResponse { + status_code: item.http_code, + code, + message: declined_message.to_owned(), + reason: Some(declined_message), + attempt_status: None, + connector_transaction_id: None, + }), + ..item.data + }) + } + } +} + +// refund body in soap format +pub fn get_refund_body( + req: &BamboraapacRouterData<&types::RefundExecuteRouterData>, +) -> Result, Error> { + let receipt = req.router_data.request.connector_transaction_id.to_owned(); + let auth_details = BamboraapacAuthType::try_from(&req.router_data.connector_auth_type)?; + let body = format!( + r#" + + + + + + + {} + {} + {} + + {} + {} + + + ]]> + + + + + "#, + req.router_data.request.refund_id.to_owned(), + receipt, + req.amount, + auth_details.username.peek(), + auth_details.password.peek(), + ); + + Ok(body.as_bytes().to_vec()) +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename = "Envelope")] +#[serde(rename_all = "PascalCase")] +pub struct BamboraapacRefundsResponse { + body: RefundBodyResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct RefundBodyResponse { + submit_single_refund_response: SubmitSingleRefundResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct SubmitSingleRefundResponse { + submit_single_refund_result: SubmitSingleRefundResult, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct SubmitSingleRefundResult { + response: RefundResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct RefundResponse { + response_code: u8, + receipt: String, + declined_code: Option, + declined_message: Option, +} + +fn get_status(item: u8) -> enums::RefundStatus { + match item { + 0 => enums::RefundStatus::Success, + 1 => enums::RefundStatus::Failure, + _ => enums::RefundStatus::Pending, + } +} + +impl TryFrom> + for RouterData +{ + type Error = error_stack::Report; + fn try_from( + item: ResponseRouterData, + ) -> Result { + let response_code = item + .response + .body + .submit_single_refund_response + .submit_single_refund_result + .response + .response_code; + let connector_refund_id = item + .response + .body + .submit_single_refund_response + .submit_single_refund_result + .response + .receipt; + + Ok(Self { + response: Ok(RefundsResponseData { + connector_refund_id: connector_refund_id.to_owned(), + refund_status: get_status(response_code), + }), + ..item.data + }) + } +} + +pub fn get_payment_sync_body(req: &types::PaymentsSyncRouterData) -> Result, Error> { + let auth_details = BamboraapacAuthType::try_from(&req.connector_auth_type)?; + let connector_transaction_id = req + .request + .connector_transaction_id + .get_connector_transaction_id() + .change_context(errors::ConnectorError::MissingConnectorTransactionID)?; + let body = format!( + r#" + + + + + + + + {} + 2024-06-23 00:00:00 + 2099-12-31 23:59:59 + {} + + + {} + {} + + + ]]> + + + + + "#, + auth_details.account_number.peek(), + connector_transaction_id, + auth_details.username.peek(), + auth_details.password.peek(), + ); + + Ok(body.as_bytes().to_vec()) +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename = "Envelope")] +#[serde(rename_all = "PascalCase")] +pub struct BamboraapacSyncResponse { + body: SyncBodyResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct SyncBodyResponse { + query_transaction_response: QueryTransactionResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct QueryTransactionResponse { + query_transaction_result: QueryTransactionResult, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct QueryTransactionResult { + query_response: QueryResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct QueryResponse { + response: SyncResponse, +} + +#[derive(Debug, Clone, Serialize, Deserialize)] +#[serde(rename_all = "PascalCase")] +pub struct SyncResponse { + response_code: u8, + receipt: String, + declined_code: Option, + declined_message: Option, +} + +impl + TryFrom> + for RouterData +{ + type Error = error_stack::Report; + fn try_from( + item: ResponseRouterData< + F, + BamboraapacSyncResponse, + PaymentsSyncData, + PaymentsResponseData, + >, + ) -> Result { + let response_code = item + .response + .body + .query_transaction_response + .query_transaction_result + .query_response + .response + .response_code; + let connector_transaction_id = item + .response + .body + .query_transaction_response + .query_transaction_result + .query_response + .response + .receipt; + // transaction approved + if response_code == 0 { + Ok(Self { + status: get_attempt_status(response_code, item.data.request.capture_method), + response: Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::ConnectorTransactionId( + connector_transaction_id.to_owned(), + ), + redirection_data: Box::new(None), + mandate_reference: Box::new(None), + connector_metadata: None, + network_txn_id: None, + connector_response_reference_id: Some(connector_transaction_id), + incremental_authorization_allowed: None, + charge_id: None, + }), + ..item.data + }) + } + // transaction failed + else { + let code = item + .response + .body + .query_transaction_response + .query_transaction_result + .query_response + .response + .declined_code + .unwrap_or(NO_ERROR_CODE.to_string()); + let declined_message = item + .response + .body + .query_transaction_response + .query_transaction_result + .query_response + .response + .declined_message + .unwrap_or(NO_ERROR_MESSAGE.to_string()); + Ok(Self { + status: get_attempt_status(response_code, item.data.request.capture_method), + response: Err(ErrorResponse { + status_code: item.http_code, + code, + message: declined_message.to_owned(), + reason: Some(declined_message), + attempt_status: None, + connector_transaction_id: None, + }), + ..item.data + }) + } + } +} + +pub fn get_refund_sync_body(req: &types::RefundSyncRouterData) -> Result, Error> { + let auth_details = BamboraapacAuthType::try_from(&req.connector_auth_type)?; + + let body = format!( + r#" + + + + + + + + {} + 2024-06-23 00:00:00 + 2099-12-31 23:59:59 + {} + + + {} + {} + + + ]]> + + + + + "#, + auth_details.account_number.peek(), + req.request.refund_id, + auth_details.username.peek(), + auth_details.password.peek(), + ); + + Ok(body.as_bytes().to_vec()) +} + +impl TryFrom> + for RouterData +{ + type Error = error_stack::Report; + fn try_from( + item: ResponseRouterData, + ) -> Result { + let response_code = item + .response + .body + .query_transaction_response + .query_transaction_result + .query_response + .response + .response_code; + let connector_refund_id = item + .response + .body + .query_transaction_response + .query_transaction_result + .query_response + .response + .receipt; + Ok(Self { + response: Ok(RefundsResponseData { + connector_refund_id: connector_refund_id.to_owned(), + refund_status: get_status(response_code), + }), + ..item.data + }) + } +} + +#[derive(Default, Debug, Serialize, Deserialize, PartialEq)] +pub struct BamboraapacErrorResponse { + pub declined_code: Option, + pub declined_message: Option, +} diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs index 6ee8926f8df8..0afd48079046 100644 --- a/crates/hyperswitch_connectors/src/default_implementations.rs +++ b/crates/hyperswitch_connectors/src/default_implementations.rs @@ -92,6 +92,7 @@ default_imp_for_authorize_session_token!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -148,6 +149,7 @@ default_imp_for_calculate_tax!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -204,6 +206,7 @@ default_imp_for_session_update!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -261,6 +264,7 @@ default_imp_for_post_session_tokens!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Bitpay, connectors::Billwerk, connectors::Cashtocode, @@ -318,6 +322,7 @@ macro_rules! default_imp_for_complete_authorize { default_imp_for_complete_authorize!( connectors::Amazonpay, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -369,6 +374,7 @@ default_imp_for_incremental_authorization!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -427,6 +433,7 @@ default_imp_for_create_customer!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -486,6 +493,7 @@ default_imp_for_connector_redirect_response!( connectors::Amazonpay, connectors::Billwerk, connectors::Bitpay, + connectors::Bamboraapac, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -536,6 +544,7 @@ macro_rules! default_imp_for_pre_processing_steps{ default_imp_for_pre_processing_steps!( connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -592,6 +601,7 @@ default_imp_for_post_processing_steps!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -650,6 +660,7 @@ default_imp_for_approve!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -708,6 +719,7 @@ default_imp_for_reject!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -766,6 +778,7 @@ default_imp_for_webhook_source_verification!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -825,6 +838,7 @@ default_imp_for_accept_dispute!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -883,6 +897,7 @@ default_imp_for_submit_evidence!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -941,6 +956,7 @@ default_imp_for_defend_dispute!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1008,6 +1024,7 @@ default_imp_for_file_upload!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1059,6 +1076,7 @@ default_imp_for_payouts!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1118,6 +1136,7 @@ default_imp_for_payouts_create!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1178,6 +1197,7 @@ default_imp_for_payouts_retrieve!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1238,6 +1258,7 @@ default_imp_for_payouts_eligibility!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1298,6 +1319,7 @@ default_imp_for_payouts_fulfill!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1358,6 +1380,7 @@ default_imp_for_payouts_cancel!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1418,6 +1441,7 @@ default_imp_for_payouts_quote!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1478,6 +1502,7 @@ default_imp_for_payouts_recipient!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1538,6 +1563,7 @@ default_imp_for_payouts_recipient_account!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1598,6 +1624,7 @@ default_imp_for_frm_sale!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1658,6 +1685,7 @@ default_imp_for_frm_checkout!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1718,6 +1746,7 @@ default_imp_for_frm_transaction!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1778,6 +1807,7 @@ default_imp_for_frm_fulfillment!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1838,6 +1868,7 @@ default_imp_for_frm_record_return!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1895,6 +1926,7 @@ default_imp_for_revoking_mandates!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rs index d747d65d73a1..362b6a6e93a8 100644 --- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs +++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs @@ -208,6 +208,7 @@ default_imp_for_new_connector_integration_payment!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -267,6 +268,7 @@ default_imp_for_new_connector_integration_refund!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -321,6 +323,7 @@ default_imp_for_new_connector_integration_connector_access_token!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -381,6 +384,7 @@ default_imp_for_new_connector_integration_accept_dispute!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -440,6 +444,7 @@ default_imp_for_new_connector_integration_submit_evidence!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -499,6 +504,7 @@ default_imp_for_new_connector_integration_defend_dispute!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -568,6 +574,7 @@ default_imp_for_new_connector_integration_file_upload!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -629,6 +636,7 @@ default_imp_for_new_connector_integration_payouts_create!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -690,6 +698,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -751,6 +760,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -812,6 +822,7 @@ default_imp_for_new_connector_integration_payouts_cancel!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -873,6 +884,7 @@ default_imp_for_new_connector_integration_payouts_quote!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -934,6 +946,7 @@ default_imp_for_new_connector_integration_payouts_recipient!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -995,6 +1008,7 @@ default_imp_for_new_connector_integration_payouts_sync!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1056,6 +1070,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1115,6 +1130,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1176,6 +1192,7 @@ default_imp_for_new_connector_integration_frm_sale!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1237,6 +1254,7 @@ default_imp_for_new_connector_integration_frm_checkout!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1298,6 +1316,7 @@ default_imp_for_new_connector_integration_frm_transaction!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1359,6 +1378,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1420,6 +1440,7 @@ default_imp_for_new_connector_integration_frm_record_return!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, @@ -1478,6 +1499,7 @@ default_imp_for_new_connector_integration_revoking_mandates!( connectors::Airwallex, connectors::Amazonpay, connectors::Bambora, + connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, connectors::Cashtocode, diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs index 7913d6543c85..4e1281c7fe8d 100644 --- a/crates/router/src/connector.rs +++ b/crates/router/src/connector.rs @@ -2,7 +2,6 @@ pub mod aci; pub mod adyen; pub mod adyenplatform; pub mod authorizedotnet; -pub mod bamboraapac; pub mod bankofamerica; pub mod bluesnap; pub mod boku; @@ -46,31 +45,31 @@ pub mod wise; pub use hyperswitch_connectors::connectors::{ airwallex, airwallex::Airwallex, amazonpay, amazonpay::Amazonpay, bambora, bambora::Bambora, - billwerk, billwerk::Billwerk, bitpay, bitpay::Bitpay, cashtocode, cashtocode::Cashtocode, - coinbase, coinbase::Coinbase, cryptopay, cryptopay::Cryptopay, deutschebank, - deutschebank::Deutschebank, digitalvirgo, digitalvirgo::Digitalvirgo, dlocal, dlocal::Dlocal, - elavon, elavon::Elavon, fiserv, fiserv::Fiserv, fiservemea, fiservemea::Fiservemea, fiuu, - fiuu::Fiuu, forte, forte::Forte, globepay, globepay::Globepay, helcim, helcim::Helcim, - jpmorgan, jpmorgan::Jpmorgan, mollie, mollie::Mollie, multisafepay, multisafepay::Multisafepay, - nexinets, nexinets::Nexinets, nexixpay, nexixpay::Nexixpay, nomupay, nomupay::Nomupay, - novalnet, novalnet::Novalnet, payeezy, payeezy::Payeezy, payu, payu::Payu, powertranz, - powertranz::Powertranz, razorpay, razorpay::Razorpay, shift4, shift4::Shift4, square, - square::Square, stax, stax::Stax, taxjar, taxjar::Taxjar, thunes, thunes::Thunes, tsys, - tsys::Tsys, volt, volt::Volt, worldline, worldline::Worldline, worldpay, worldpay::Worldpay, - zen, zen::Zen, zsl, zsl::Zsl, + bamboraapac, bamboraapac::Bamboraapac, billwerk, billwerk::Billwerk, bitpay, bitpay::Bitpay, + cashtocode, cashtocode::Cashtocode, coinbase, coinbase::Coinbase, cryptopay, + cryptopay::Cryptopay, deutschebank, deutschebank::Deutschebank, digitalvirgo, + digitalvirgo::Digitalvirgo, dlocal, dlocal::Dlocal, elavon, elavon::Elavon, fiserv, + fiserv::Fiserv, fiservemea, fiservemea::Fiservemea, fiuu, fiuu::Fiuu, forte, forte::Forte, + globepay, globepay::Globepay, helcim, helcim::Helcim, jpmorgan, jpmorgan::Jpmorgan, mollie, + mollie::Mollie, multisafepay, multisafepay::Multisafepay, nexinets, nexinets::Nexinets, + nexixpay, nexixpay::Nexixpay, nomupay, nomupay::Nomupay, novalnet, novalnet::Novalnet, payeezy, + payeezy::Payeezy, payu, payu::Payu, powertranz, powertranz::Powertranz, razorpay, + razorpay::Razorpay, shift4, shift4::Shift4, square, square::Square, stax, stax::Stax, taxjar, + taxjar::Taxjar, thunes, thunes::Thunes, tsys, tsys::Tsys, volt, volt::Volt, worldline, + worldline::Worldline, worldpay, worldpay::Worldpay, zen, zen::Zen, zsl, zsl::Zsl, }; #[cfg(feature = "dummy_connector")] pub use self::dummyconnector::DummyConnector; pub use self::{ aci::Aci, adyen::Adyen, adyenplatform::Adyenplatform, authorizedotnet::Authorizedotnet, - bamboraapac::Bamboraapac, bankofamerica::Bankofamerica, bluesnap::Bluesnap, boku::Boku, - braintree::Braintree, checkout::Checkout, cybersource::Cybersource, datatrans::Datatrans, - ebanx::Ebanx, globalpay::Globalpay, gocardless::Gocardless, gpayments::Gpayments, - iatapay::Iatapay, itaubank::Itaubank, klarna::Klarna, mifinity::Mifinity, netcetera::Netcetera, - nmi::Nmi, noon::Noon, nuvei::Nuvei, opayo::Opayo, opennode::Opennode, paybox::Paybox, - payme::Payme, payone::Payone, paypal::Paypal, placetopay::Placetopay, plaid::Plaid, - prophetpay::Prophetpay, rapyd::Rapyd, riskified::Riskified, signifyd::Signifyd, stripe::Stripe, + bankofamerica::Bankofamerica, bluesnap::Bluesnap, boku::Boku, braintree::Braintree, + checkout::Checkout, cybersource::Cybersource, datatrans::Datatrans, ebanx::Ebanx, + globalpay::Globalpay, gocardless::Gocardless, gpayments::Gpayments, iatapay::Iatapay, + itaubank::Itaubank, klarna::Klarna, mifinity::Mifinity, netcetera::Netcetera, nmi::Nmi, + noon::Noon, nuvei::Nuvei, opayo::Opayo, opennode::Opennode, paybox::Paybox, payme::Payme, + payone::Payone, paypal::Paypal, placetopay::Placetopay, plaid::Plaid, prophetpay::Prophetpay, + rapyd::Rapyd, riskified::Riskified, signifyd::Signifyd, stripe::Stripe, threedsecureio::Threedsecureio, trustpay::Trustpay, wellsfargo::Wellsfargo, wellsfargopayout::Wellsfargopayout, wise::Wise, }; diff --git a/crates/router/src/core/payments/connector_integration_v2_impls.rs b/crates/router/src/core/payments/connector_integration_v2_impls.rs index 94c531a09630..2b776c8ec7b6 100644 --- a/crates/router/src/core/payments/connector_integration_v2_impls.rs +++ b/crates/router/src/core/payments/connector_integration_v2_impls.rs @@ -694,7 +694,6 @@ default_imp_for_new_connector_integration_payment!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -755,7 +754,6 @@ default_imp_for_new_connector_integration_refund!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -810,7 +808,6 @@ default_imp_for_new_connector_integration_connector_access_token!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -887,7 +884,6 @@ default_imp_for_new_connector_integration_accept_dispute!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -946,7 +942,6 @@ default_imp_for_new_connector_integration_defend_dispute!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -989,7 +984,6 @@ default_imp_for_new_connector_integration_submit_evidence!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1059,7 +1053,6 @@ default_imp_for_new_connector_integration_file_upload!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1212,7 +1205,6 @@ default_imp_for_new_connector_integration_payouts_create!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1274,7 +1266,6 @@ default_imp_for_new_connector_integration_payouts_eligibility!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1336,7 +1327,6 @@ default_imp_for_new_connector_integration_payouts_fulfill!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1398,7 +1388,6 @@ default_imp_for_new_connector_integration_payouts_cancel!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1460,7 +1449,6 @@ default_imp_for_new_connector_integration_payouts_quote!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1522,7 +1510,6 @@ default_imp_for_new_connector_integration_payouts_recipient!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1584,7 +1571,6 @@ default_imp_for_new_connector_integration_payouts_sync!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1646,7 +1632,6 @@ default_imp_for_new_connector_integration_payouts_recipient_account!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1706,7 +1691,6 @@ default_imp_for_new_connector_integration_webhook_source_verification!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1859,7 +1843,6 @@ default_imp_for_new_connector_integration_frm_sale!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1921,7 +1904,6 @@ default_imp_for_new_connector_integration_frm_checkout!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1983,7 +1965,6 @@ default_imp_for_new_connector_integration_frm_transaction!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -2045,7 +2026,6 @@ default_imp_for_new_connector_integration_frm_fulfillment!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -2107,7 +2087,6 @@ default_imp_for_new_connector_integration_frm_record_return!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -2166,7 +2145,6 @@ default_imp_for_new_connector_integration_revoking_mandates!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs index 1358bcedba1d..2e19515517d5 100644 --- a/crates/router/src/core/payments/flows.rs +++ b/crates/router/src/core/payments/flows.rs @@ -207,7 +207,6 @@ default_imp_for_complete_authorize!( connector::Adyenplatform, connector::Aci, connector::Adyen, - connector::Bamboraapac, connector::Bankofamerica, connector::Boku, connector::Checkout, @@ -267,7 +266,6 @@ default_imp_for_webhook_source_verification!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Braintree, @@ -338,7 +336,6 @@ default_imp_for_create_customer!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -409,7 +406,6 @@ default_imp_for_connector_redirect_response!( connector::Adyenplatform, connector::Aci, connector::Adyen, - connector::Bamboraapac, connector::Bankofamerica, connector::Boku, connector::Cybersource, @@ -564,7 +560,6 @@ default_imp_for_accept_dispute!( connector::Adyenplatform, connector::Aci, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -656,7 +651,6 @@ default_imp_for_file_upload!( connector::Adyenplatform, connector::Aci, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -725,7 +719,6 @@ default_imp_for_submit_evidence!( connector::Adyenplatform, connector::Aci, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -794,7 +787,6 @@ default_imp_for_defend_dispute!( connector::Adyenplatform, connector::Aci, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -879,7 +871,6 @@ default_imp_for_pre_processing_steps!( connector::Adyenplatform, connector::Aci, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -937,7 +928,6 @@ default_imp_for_post_processing_steps!( connector::Trustpay, connector::Aci, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bluesnap, connector::Boku, connector::Braintree, @@ -981,7 +971,6 @@ impl Payouts for connector::DummyConnector {} default_imp_for_payouts!( connector::Aci, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1047,7 +1036,6 @@ default_imp_for_payouts_create!( connector::Adyenplatform, connector::Aci, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1116,7 +1104,6 @@ default_imp_for_payouts_retrieve!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1190,7 +1177,6 @@ default_imp_for_payouts_eligibility!( connector::Adyenplatform, connector::Aci, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1259,7 +1245,6 @@ impl default_imp_for_payouts_fulfill!( connector::Aci, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1325,7 +1310,6 @@ default_imp_for_payouts_cancel!( connector::Adyenplatform, connector::Aci, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1395,7 +1379,6 @@ default_imp_for_payouts_quote!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1466,7 +1449,6 @@ default_imp_for_payouts_recipient!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1539,7 +1521,6 @@ default_imp_for_payouts_recipient_account!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1610,7 +1591,6 @@ default_imp_for_approve!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1682,7 +1662,6 @@ default_imp_for_reject!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1849,7 +1828,6 @@ default_imp_for_frm_sale!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1921,7 +1899,6 @@ default_imp_for_frm_checkout!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -1993,7 +1970,6 @@ default_imp_for_frm_transaction!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -2065,7 +2041,6 @@ default_imp_for_frm_fulfillment!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -2137,7 +2112,6 @@ default_imp_for_frm_record_return!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -2207,7 +2181,6 @@ default_imp_for_incremental_authorization!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -2275,7 +2248,6 @@ default_imp_for_revoking_mandates!( connector::Aci, connector::Adyen, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -2507,7 +2479,6 @@ default_imp_for_authorize_session_token!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -2576,7 +2547,6 @@ default_imp_for_calculate_tax!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -2646,7 +2616,6 @@ default_imp_for_session_update!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, @@ -2715,7 +2684,6 @@ default_imp_for_post_session_tokens!( connector::Adyen, connector::Adyenplatform, connector::Authorizedotnet, - connector::Bamboraapac, connector::Bankofamerica, connector::Bluesnap, connector::Boku, From dfcaa69147ee1b949716cfad9b3e68f0a959bbc8 Mon Sep 17 00:00:00 2001 From: Spriti Aneja Date: Mon, 25 Nov 2024 16:46:37 +0530 Subject: [PATCH 2/6] Move Boku to hyperswitch_connector crate --- Cargo.lock | 9 +- crates/hyperswitch_connectors/Cargo.toml | 1 + .../hyperswitch_connectors/src/connectors.rs | 3 +- .../src/connectors}/boku.rs | 304 +++-- .../src/connectors}/boku/transformers.rs | 156 +-- .../src/default_implementations.rs | 32 + .../src/default_implementations_v2.rs | 22 + crates/router/src/connector.rs | 5 +- crates/router/src/connector/bamboraapac.rs | 748 ------------ .../src/connector/bamboraapac/transformers.rs | 1049 ----------------- .../connector_integration_v2_impls.rs | 22 - crates/router/src/core/payments/flows.rs | 32 - 12 files changed, 292 insertions(+), 2091 deletions(-) rename crates/{router/src/connector => hyperswitch_connectors/src/connectors}/boku.rs (71%) rename crates/{router/src/connector => hyperswitch_connectors/src/connectors}/boku/transformers.rs (73%) delete mode 100644 crates/router/src/connector/bamboraapac.rs delete mode 100644 crates/router/src/connector/bamboraapac/transformers.rs diff --git a/Cargo.lock b/Cargo.lock index a2ede8c08c10..5aabd46216f7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4053,6 +4053,7 @@ dependencies = [ "reqwest 0.11.27", "ring 0.17.8", "router_env", + "roxmltree 0.20.0", "serde", "serde_json", "serde_urlencoded", @@ -6674,7 +6675,7 @@ dependencies = [ "ring 0.17.8", "router_derive", "router_env", - "roxmltree", + "roxmltree 0.19.0", "rust-i18n", "rust_decimal", "rustc-hash", @@ -6760,6 +6761,12 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3cd14fd5e3b777a7422cca79358c57a8f6e3a703d9ac187448d0daf220c2407f" +[[package]] +name = "roxmltree" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" + [[package]] name = "rsa" version = "0.9.6" diff --git a/crates/hyperswitch_connectors/Cargo.toml b/crates/hyperswitch_connectors/Cargo.toml index ca9d338920f8..c6c88f6d32a0 100644 --- a/crates/hyperswitch_connectors/Cargo.toml +++ b/crates/hyperswitch_connectors/Cargo.toml @@ -27,6 +27,7 @@ rand = "0.8.5" regex = "1.10.4" reqwest = { version = "0.11.27" } ring = "0.17.8" +roxmltree = "0.20.0" serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.115" serde_urlencoded = "0.7.1" diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs index fae40837a696..5fbf8334c3e1 100644 --- a/crates/hyperswitch_connectors/src/connectors.rs +++ b/crates/hyperswitch_connectors/src/connectors.rs @@ -4,6 +4,7 @@ pub mod bambora; pub mod bamboraapac; pub mod billwerk; pub mod bitpay; +pub mod boku; pub mod cashtocode; pub mod coinbase; pub mod cryptopay; @@ -42,7 +43,7 @@ pub mod zsl; pub use self::{ airwallex::Airwallex, amazonpay::Amazonpay, bambora::Bambora, bamboraapac::Bamboraapac, - billwerk::Billwerk, bitpay::Bitpay, cashtocode::Cashtocode, coinbase::Coinbase, + billwerk::Billwerk, bitpay::Bitpay, boku::Boku, cashtocode::Cashtocode, coinbase::Coinbase, cryptopay::Cryptopay, deutschebank::Deutschebank, digitalvirgo::Digitalvirgo, dlocal::Dlocal, elavon::Elavon, fiserv::Fiserv, fiservemea::Fiservemea, fiuu::Fiuu, forte::Forte, globepay::Globepay, helcim::Helcim, jpmorgan::Jpmorgan, mollie::Mollie, diff --git a/crates/router/src/connector/boku.rs b/crates/hyperswitch_connectors/src/connectors/boku.rs similarity index 71% rename from crates/router/src/connector/boku.rs rename to crates/hyperswitch_connectors/src/connectors/boku.rs index a132094693a1..d23d34e47304 100644 --- a/crates/router/src/connector/boku.rs +++ b/crates/hyperswitch_connectors/src/connectors/boku.rs @@ -1,38 +1,52 @@ pub mod transformers; +use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId}; +use common_enums::enums; use common_utils::{ - ext_traits::XmlExt, - request::RequestContent, + errors::CustomResult, + ext_traits::{BytesExt, OptionExt, XmlExt}, + request::{Method, Request, RequestBuilder, RequestContent}, types::{AmountConvertor, MinorUnit, MinorUnitForConnector}, }; -use diesel_models::enums; use error_stack::{report, Report, ResultExt}; -use masking::{ExposeInterface, PeekInterface, Secret, WithType}; +use hyperswitch_domain_models::{ + router_data::{AccessToken, 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, ConnectorValidation}, + configs::Connectors, + consts::NO_ERROR_CODE, + errors, + events::connector_api_logs::ConnectorEvent, + types::{self, Response}, + webhooks::{IncomingWebhook, IncomingWebhookRequestDetails}, +}; +use masking::{ExposeInterface, Mask, PeekInterface, Secret, WithType}; use ring::hmac; -use router_env::metrics::add_attributes; -use roxmltree; +use router_env::{logger, metrics::add_attributes}; use time::OffsetDateTime; use transformers as boku; -use super::utils as connector_utils; use crate::{ - configs::settings, - consts, - core::errors::{self, CustomResult}, - events::connector_api_logs::ConnectorEvent, - headers, logger, - routes::metrics, - services::{ - self, - request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, - }, - types::{ - self, - api::{self, ConnectorCommon, ConnectorCommonExt}, - ErrorResponse, Response, - }, - utils::{BytesExt, OptionExt}, + constants::{headers, UNSUPPORTED_ERROR_MESSAGE}, + metrics, + types::ResponseRouterData, + utils::{construct_not_supported_error_report, convert_amount}, }; #[derive(Clone)] @@ -61,12 +75,8 @@ impl api::RefundExecute for Boku {} impl api::RefundSync for Boku {} impl api::PaymentToken for Boku {} -impl - ConnectorIntegration< - api::PaymentMethodToken, - types::PaymentMethodTokenizationData, - types::PaymentsResponseData, - > for Boku +impl ConnectorIntegration + for Boku { // Not Implemented (R) } @@ -77,9 +87,9 @@ where { fn build_headers( &self, - req: &types::RouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &RouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { let connector_auth = boku::BokuAuthType::try_from(&req.connector_auth_type)?; let boku_url = Self::get_url(self, req, connectors)?; @@ -125,7 +135,7 @@ impl ConnectorCommon for Boku { "text/xml;charset=utf-8" } - fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str { + fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str { connectors.boku.base_url.as_ref() } @@ -167,39 +177,24 @@ impl ConnectorValidation for Boku { match capture_method { enums::CaptureMethod::Automatic | enums::CaptureMethod::Manual => Ok(()), enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err( - connector_utils::construct_not_supported_error_report(capture_method, self.id()), + construct_not_supported_error_report(capture_method, self.id()), ), } } } -impl ConnectorIntegration - for Boku -{ +impl ConnectorIntegration for Boku { //TODO: implement sessions flow } -impl ConnectorIntegration - for Boku -{ -} +impl ConnectorIntegration for Boku {} -impl - ConnectorIntegration< - api::SetupMandate, - types::SetupMandateRequestData, - types::PaymentsResponseData, - > for Boku -{ +impl ConnectorIntegration for Boku { fn build_request( &self, - _req: &types::RouterData< - api::SetupMandate, - types::SetupMandateRequestData, - types::PaymentsResponseData, - >, - _connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + _req: &RouterData, + _connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Err( errors::ConnectorError::NotImplemented("Setup Mandate flow for Boku".to_string()) .into(), @@ -207,19 +202,17 @@ impl } } -impl ConnectorIntegration - for Boku -{ +impl ConnectorIntegration for Boku { fn get_headers( &self, - req: &types::PaymentsAuthorizeRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } - fn get_http_method(&self) -> services::Method { - services::Method::Post + fn get_http_method(&self) -> Method { + Method::Post } fn get_content_type(&self) -> &'static str { @@ -228,8 +221,8 @@ impl ConnectorIntegration CustomResult { let boku_url = get_country_url( req.connector_meta_data.clone(), @@ -241,10 +234,10 @@ impl ConnectorIntegration CustomResult { - let amount = connector_utils::convert_amount( + let amount = convert_amount( self.amount_converter, req.request.minor_amount, req.request.currency, @@ -257,12 +250,12 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) + RequestBuilder::new() + .method(Method::Post) .url(&types::PaymentsAuthorizeType::get_url( self, req, connectors, )?) @@ -279,10 +272,10 @@ impl ConnectorIntegration, res: Response, - ) -> CustomResult { + ) -> CustomResult { let response_data = String::from_utf8(res.response.to_vec()) .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; @@ -291,7 +284,7 @@ impl ConnectorIntegration - for Boku -{ +impl ConnectorIntegration for Boku { fn get_headers( &self, - req: &types::PaymentsSyncRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &PaymentsSyncRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } @@ -324,8 +315,8 @@ impl ConnectorIntegration CustomResult { let boku_url = get_country_url( req.connector_meta_data.clone(), @@ -337,8 +328,8 @@ impl ConnectorIntegration CustomResult { let connector_req = boku::BokuPsyncRequest::try_from(req)?; Ok(RequestContent::Xml(Box::new(connector_req))) @@ -346,12 +337,12 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + req: &PaymentsSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Get) + RequestBuilder::new() + .method(Method::Get) .url(&types::PaymentsSyncType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?) @@ -364,10 +355,10 @@ impl ConnectorIntegration, res: Response, - ) -> CustomResult { + ) -> CustomResult { let response_data = String::from_utf8(res.response.to_vec()) .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; @@ -376,7 +367,7 @@ impl ConnectorIntegration - for Boku -{ +impl ConnectorIntegration for Boku { fn get_headers( &self, - req: &types::PaymentsCaptureRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &PaymentsCaptureRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } @@ -409,28 +398,28 @@ impl ConnectorIntegration CustomResult { Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into()) } fn get_request_body( &self, - _req: &types::PaymentsCaptureRouterData, - _connectors: &settings::Connectors, + _req: &PaymentsCaptureRouterData, + _connectors: &Connectors, ) -> CustomResult { Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into()) } fn build_request( &self, - req: &types::PaymentsCaptureRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + req: &PaymentsCaptureRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) + RequestBuilder::new() + .method(Method::Post) .url(&types::PaymentsCaptureType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::PaymentsCaptureType::get_headers( @@ -445,10 +434,10 @@ impl ConnectorIntegration, res: Response, - ) -> CustomResult { + ) -> CustomResult { let response_data = String::from_utf8(res.response.to_vec()) .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; @@ -457,7 +446,7 @@ impl ConnectorIntegration - for Boku -{ -} +impl ConnectorIntegration for Boku {} -impl ConnectorIntegration for Boku { +impl ConnectorIntegration for Boku { fn get_headers( &self, - req: &types::RefundsRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &RefundsRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } @@ -493,8 +479,8 @@ impl ConnectorIntegration, - connectors: &settings::Connectors, + req: &RefundsRouterData, + connectors: &Connectors, ) -> CustomResult { let boku_url = get_country_url( req.connector_meta_data.clone(), @@ -506,10 +492,10 @@ impl ConnectorIntegration, - _connectors: &settings::Connectors, + req: &RefundsRouterData, + _connectors: &Connectors, ) -> CustomResult { - let refund_amount = connector_utils::convert_amount( + let refund_amount = convert_amount( self.amount_converter, req.request.minor_refund_amount, req.request.currency, @@ -522,11 +508,11 @@ impl ConnectorIntegration, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { - let request = services::RequestBuilder::new() - .method(services::Method::Post) + req: &RefundsRouterData, + connectors: &Connectors, + ) -> CustomResult, 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( @@ -541,10 +527,10 @@ impl ConnectorIntegration, + data: &RefundsRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, - ) -> CustomResult, errors::ConnectorError> { + ) -> CustomResult, errors::ConnectorError> { let response: boku::RefundResponse = res .response .parse_struct("boku RefundResponse") @@ -553,7 +539,7 @@ impl ConnectorIntegration for Boku { +impl ConnectorIntegration for Boku { fn get_headers( &self, - req: &types::RefundSyncRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &RefundSyncRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } @@ -584,8 +570,8 @@ impl ConnectorIntegration CustomResult { let boku_url = get_country_url( req.connector_meta_data.clone(), @@ -597,8 +583,8 @@ impl ConnectorIntegration CustomResult { let connector_req = boku::BokuRsyncRequest::try_from(req)?; Ok(RequestContent::Xml(Box::new(connector_req))) @@ -606,12 +592,12 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + req: &RefundSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Get) + RequestBuilder::new() + .method(Method::Get) .url(&types::RefundSyncType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::RefundSyncType::get_headers(self, req, connectors)?) @@ -624,17 +610,17 @@ impl ConnectorIntegration, res: Response, - ) -> CustomResult { + ) -> CustomResult { let response: boku::BokuRsyncResponse = res .response .parse_struct("boku BokuRsyncResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { + RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, @@ -651,24 +637,24 @@ impl ConnectorIntegration, - ) -> CustomResult { + _request: &IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, - _request: &api::IncomingWebhookRequestDetails<'_>, - ) -> CustomResult { + _request: &IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, - _request: &api::IncomingWebhookRequestDetails<'_>, + _request: &IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } @@ -690,7 +676,7 @@ fn get_xml_deserialized( res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult { - metrics::RESPONSE_DESERIALIZATION_FAILURE.add( + metrics::CONNECTOR_RESPONSE_DESERIALIZATION_FAILURE.add( &metrics::CONTEXT, 1, &add_attributes([("connector", "boku")]), @@ -711,8 +697,8 @@ fn get_xml_deserialized( logger::error!("UNEXPECTED RESPONSE FROM CONNECTOR: {}", response_data); Ok(ErrorResponse { status_code: res.status_code, - code: consts::NO_ERROR_CODE.to_string(), - message: consts::UNSUPPORTED_ERROR_MESSAGE.to_string(), + code: NO_ERROR_CODE.to_string(), + message: UNSUPPORTED_ERROR_MESSAGE.to_string(), reason: Some(response_data), attempt_status: None, connector_transaction_id: None, diff --git a/crates/router/src/connector/boku/transformers.rs b/crates/hyperswitch_connectors/src/connectors/boku/transformers.rs similarity index 73% rename from crates/router/src/connector/boku/transformers.rs rename to crates/hyperswitch_connectors/src/connectors/boku/transformers.rs index 4a947284d79d..df1331750378 100644 --- a/crates/router/src/connector/boku/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/boku/transformers.rs @@ -1,16 +1,24 @@ use std::fmt; -use common_utils::types::MinorUnit; +use common_enums::enums; +use common_utils::{request::Method, types::MinorUnit}; +use hyperswitch_domain_models::{ + payment_method_data::{PaymentMethodData, WalletData}, + router_data::{ConnectorAuthType, RouterData}, + router_flow_types::refunds::{Execute, RSync}, + router_request_types::ResponseId, + router_response_types::{PaymentsResponseData, RedirectForm, RefundsResponseData}, + types::{self, RefundsRouterData}, +}; +use hyperswitch_interfaces::errors; use masking::Secret; use serde::{Deserialize, Serialize}; use url::Url; use uuid::Uuid; use crate::{ - connector::utils::{self, AddressDetailsData, RouterData}, - core::errors, - services::{self, RedirectForm}, - types::{self, api, domain, storage::enums}, + types::{RefundsResponseRouterData, ResponseRouterData}, + utils::{self, AddressDetailsData, RouterData as _}, }; #[derive(Debug, Serialize)] @@ -96,25 +104,25 @@ impl TryFrom<&BokuRouterData<&types::PaymentsAuthorizeRouterData>> for BokuPayme item: &BokuRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result { match item.router_data.request.payment_method_data.clone() { - domain::PaymentMethodData::Wallet(wallet_data) => Self::try_from((item, &wallet_data)), - domain::PaymentMethodData::Card(_) - | domain::PaymentMethodData::CardRedirect(_) - | domain::PaymentMethodData::PayLater(_) - | domain::PaymentMethodData::BankRedirect(_) - | domain::PaymentMethodData::BankDebit(_) - | domain::PaymentMethodData::BankTransfer(_) - | domain::PaymentMethodData::Crypto(_) - | domain::PaymentMethodData::MandatePayment - | domain::PaymentMethodData::Reward - | domain::PaymentMethodData::RealTimePayment(_) - | domain::PaymentMethodData::MobilePayment(_) - | domain::PaymentMethodData::Upi(_) - | domain::PaymentMethodData::Voucher(_) - | domain::PaymentMethodData::GiftCard(_) - | domain::PaymentMethodData::OpenBanking(_) - | domain::PaymentMethodData::CardToken(_) - | domain::PaymentMethodData::NetworkToken(_) - | domain::PaymentMethodData::CardDetailsForNetworkTransactionId(_) => { + PaymentMethodData::Wallet(wallet_data) => Self::try_from((item, &wallet_data)), + PaymentMethodData::Card(_) + | PaymentMethodData::CardRedirect(_) + | PaymentMethodData::PayLater(_) + | PaymentMethodData::BankRedirect(_) + | PaymentMethodData::BankDebit(_) + | PaymentMethodData::BankTransfer(_) + | PaymentMethodData::Crypto(_) + | PaymentMethodData::MandatePayment + | PaymentMethodData::Reward + | PaymentMethodData::RealTimePayment(_) + | PaymentMethodData::MobilePayment(_) + | PaymentMethodData::Upi(_) + | PaymentMethodData::Voucher(_) + | PaymentMethodData::GiftCard(_) + | PaymentMethodData::OpenBanking(_) + | PaymentMethodData::CardToken(_) + | PaymentMethodData::NetworkToken(_) + | PaymentMethodData::CardDetailsForNetworkTransactionId(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("boku"), ))? @@ -126,14 +134,14 @@ impl TryFrom<&BokuRouterData<&types::PaymentsAuthorizeRouterData>> for BokuPayme impl TryFrom<( &BokuRouterData<&types::PaymentsAuthorizeRouterData>, - &domain::WalletData, + &WalletData, )> for BokuPaymentsRequest { type Error = error_stack::Report; fn try_from( value: ( &BokuRouterData<&types::PaymentsAuthorizeRouterData>, - &domain::WalletData, + &WalletData, ), ) -> Result { let (item_router_data, wallet_data) = value; @@ -162,36 +170,36 @@ impl } } -fn get_wallet_type(wallet_data: &domain::WalletData) -> Result { +fn get_wallet_type(wallet_data: &WalletData) -> Result { match wallet_data { - domain::WalletData::DanaRedirect { .. } => Ok(BokuPaymentType::Dana.to_string()), - domain::WalletData::MomoRedirect { .. } => Ok(BokuPaymentType::Momo.to_string()), - domain::WalletData::GcashRedirect { .. } => Ok(BokuPaymentType::Gcash.to_string()), - domain::WalletData::GoPayRedirect { .. } => Ok(BokuPaymentType::GoPay.to_string()), - domain::WalletData::KakaoPayRedirect { .. } => Ok(BokuPaymentType::Kakaopay.to_string()), - domain::WalletData::AliPayQr(_) - | domain::WalletData::AliPayRedirect(_) - | domain::WalletData::AliPayHkRedirect(_) - | domain::WalletData::ApplePay(_) - | domain::WalletData::ApplePayRedirect(_) - | domain::WalletData::ApplePayThirdPartySdk(_) - | domain::WalletData::GooglePay(_) - | domain::WalletData::GooglePayRedirect(_) - | domain::WalletData::GooglePayThirdPartySdk(_) - | domain::WalletData::MbWayRedirect(_) - | domain::WalletData::MobilePayRedirect(_) - | domain::WalletData::PaypalRedirect(_) - | domain::WalletData::PaypalSdk(_) - | domain::WalletData::Paze(_) - | domain::WalletData::SamsungPay(_) - | domain::WalletData::TwintRedirect {} - | domain::WalletData::VippsRedirect {} - | domain::WalletData::TouchNGoRedirect(_) - | domain::WalletData::WeChatPayRedirect(_) - | domain::WalletData::WeChatPayQr(_) - | domain::WalletData::CashappQr(_) - | domain::WalletData::SwishQr(_) - | domain::WalletData::Mifinity(_) => Err(errors::ConnectorError::NotImplemented( + WalletData::DanaRedirect { .. } => Ok(BokuPaymentType::Dana.to_string()), + WalletData::MomoRedirect { .. } => Ok(BokuPaymentType::Momo.to_string()), + WalletData::GcashRedirect { .. } => Ok(BokuPaymentType::Gcash.to_string()), + WalletData::GoPayRedirect { .. } => Ok(BokuPaymentType::GoPay.to_string()), + WalletData::KakaoPayRedirect { .. } => Ok(BokuPaymentType::Kakaopay.to_string()), + WalletData::AliPayQr(_) + | WalletData::AliPayRedirect(_) + | WalletData::AliPayHkRedirect(_) + | WalletData::ApplePay(_) + | WalletData::ApplePayRedirect(_) + | WalletData::ApplePayThirdPartySdk(_) + | WalletData::GooglePay(_) + | WalletData::GooglePayRedirect(_) + | WalletData::GooglePayThirdPartySdk(_) + | WalletData::MbWayRedirect(_) + | WalletData::MobilePayRedirect(_) + | WalletData::PaypalRedirect(_) + | WalletData::PaypalSdk(_) + | WalletData::Paze(_) + | WalletData::SamsungPay(_) + | WalletData::TwintRedirect {} + | WalletData::VippsRedirect {} + | WalletData::TouchNGoRedirect(_) + | WalletData::WeChatPayRedirect(_) + | WalletData::WeChatPayQr(_) + | WalletData::CashappQr(_) + | WalletData::SwishQr(_) + | WalletData::Mifinity(_) => Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("boku"), )), } @@ -202,11 +210,11 @@ pub struct BokuAuthType { pub(super) key_id: Secret, } -impl TryFrom<&types::ConnectorAuthType> for BokuAuthType { +impl TryFrom<&ConnectorAuthType> for BokuAuthType { type Error = error_stack::Report; - fn try_from(auth_type: &types::ConnectorAuthType) -> Result { + fn try_from(auth_type: &ConnectorAuthType) -> Result { match auth_type { - types::ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self { + ConnectorAuthType::BodyKey { api_key, key1 } => Ok(Self { merchant_id: key1.to_owned(), key_id: api_key.to_owned(), }), @@ -286,12 +294,12 @@ pub struct SingleChargeResponseData { charge_id: String, } -impl TryFrom> - for types::RouterData +impl TryFrom> + for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData, + item: ResponseRouterData, ) -> Result { let (status, transaction_id, redirection_data) = match item.response { BokuResponse::BeginSingleChargeResponse(response) => get_authorize_response(response), @@ -300,8 +308,8 @@ impl TryFrom Ok(hosted_value .redirect_url - .map(|url| RedirectForm::from((url, services::Method::Get)))), + .map(|url| RedirectForm::from((url, Method::Get)))), None => Err(errors::ConnectorError::MissingConnectorRedirectionPayload { field_name: "redirect_url", }), @@ -372,9 +380,9 @@ impl fmt::Display for BokuRefundReasonCode { } } -impl TryFrom<&BokuRouterData<&types::RefundsRouterData>> for BokuRefundRequest { +impl TryFrom<&BokuRouterData<&RefundsRouterData>> for BokuRefundRequest { type Error = error_stack::Report; - fn try_from(item: &BokuRouterData<&types::RefundsRouterData>) -> Result { + fn try_from(item: &BokuRouterData<&RefundsRouterData>) -> Result { let auth_type = BokuAuthType::try_from(&item.router_data.connector_auth_type)?; let payment_data = Self { refund_amount: item.amount, @@ -408,15 +416,13 @@ fn get_refund_status(status: String) -> enums::RefundStatus { } } -impl TryFrom> - for types::RefundsRouterData -{ +impl TryFrom> for RefundsRouterData { type Error = error_stack::Report; fn try_from( - item: types::RefundsResponseRouterData, + item: RefundsResponseRouterData, ) -> Result { Ok(Self { - response: Ok(types::RefundsResponseData { + response: Ok(RefundsResponseData { connector_refund_id: item.response.charge_id, refund_status: get_refund_status(item.response.refund_status), }), @@ -469,15 +475,13 @@ pub struct SingleRefundResponseData { refund_id: String, } -impl TryFrom> - for types::RefundsRouterData -{ +impl TryFrom> for RefundsRouterData { type Error = error_stack::Report; fn try_from( - item: types::RefundsResponseRouterData, + item: RefundsResponseRouterData, ) -> Result { Ok(Self { - response: Ok(types::RefundsResponseData { + response: Ok(RefundsResponseData { connector_refund_id: item.response.refunds.refund.refund_id, refund_status: get_refund_status(item.response.refunds.refund.refund_status), }), diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs index 0afd48079046..27d0307e9ad5 100644 --- a/crates/hyperswitch_connectors/src/default_implementations.rs +++ b/crates/hyperswitch_connectors/src/default_implementations.rs @@ -95,6 +95,7 @@ default_imp_for_authorize_session_token!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -152,6 +153,7 @@ default_imp_for_calculate_tax!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -209,6 +211,7 @@ default_imp_for_session_update!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -266,6 +269,7 @@ default_imp_for_post_session_tokens!( connectors::Bambora, connectors::Bamboraapac, connectors::Bitpay, + connectors::Boku, connectors::Billwerk, connectors::Cashtocode, connectors::Coinbase, @@ -325,6 +329,7 @@ default_imp_for_complete_authorize!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -377,6 +382,7 @@ default_imp_for_incremental_authorization!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -436,6 +442,7 @@ default_imp_for_create_customer!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -493,6 +500,7 @@ default_imp_for_connector_redirect_response!( connectors::Amazonpay, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Bamboraapac, connectors::Cashtocode, connectors::Coinbase, @@ -547,6 +555,7 @@ default_imp_for_pre_processing_steps!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -604,6 +613,7 @@ default_imp_for_post_processing_steps!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -663,6 +673,7 @@ default_imp_for_approve!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -722,6 +733,7 @@ default_imp_for_reject!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -781,6 +793,7 @@ default_imp_for_webhook_source_verification!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -841,6 +854,7 @@ default_imp_for_accept_dispute!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -900,6 +914,7 @@ default_imp_for_submit_evidence!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -959,6 +974,7 @@ default_imp_for_defend_dispute!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1027,6 +1043,7 @@ default_imp_for_file_upload!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1079,6 +1096,7 @@ default_imp_for_payouts!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Cryptopay, connectors::Coinbase, @@ -1139,6 +1157,7 @@ default_imp_for_payouts_create!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1200,6 +1219,7 @@ default_imp_for_payouts_retrieve!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1261,6 +1281,7 @@ default_imp_for_payouts_eligibility!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1322,6 +1343,7 @@ default_imp_for_payouts_fulfill!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1383,6 +1405,7 @@ default_imp_for_payouts_cancel!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1444,6 +1467,7 @@ default_imp_for_payouts_quote!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1505,6 +1529,7 @@ default_imp_for_payouts_recipient!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1566,6 +1591,7 @@ default_imp_for_payouts_recipient_account!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1627,6 +1653,7 @@ default_imp_for_frm_sale!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1688,6 +1715,7 @@ default_imp_for_frm_checkout!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1749,6 +1777,7 @@ default_imp_for_frm_transaction!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1810,6 +1839,7 @@ default_imp_for_frm_fulfillment!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1871,6 +1901,7 @@ default_imp_for_frm_record_return!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1929,6 +1960,7 @@ default_imp_for_revoking_mandates!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rs index 362b6a6e93a8..3fe0298f45be 100644 --- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs +++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs @@ -211,6 +211,7 @@ default_imp_for_new_connector_integration_payment!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -271,6 +272,7 @@ default_imp_for_new_connector_integration_refund!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -326,6 +328,7 @@ default_imp_for_new_connector_integration_connector_access_token!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -387,6 +390,7 @@ default_imp_for_new_connector_integration_accept_dispute!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -447,6 +451,7 @@ default_imp_for_new_connector_integration_submit_evidence!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -507,6 +512,7 @@ default_imp_for_new_connector_integration_defend_dispute!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -577,6 +583,7 @@ default_imp_for_new_connector_integration_file_upload!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -639,6 +646,7 @@ default_imp_for_new_connector_integration_payouts_create!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -701,6 +709,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -763,6 +772,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -825,6 +835,7 @@ default_imp_for_new_connector_integration_payouts_cancel!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -887,6 +898,7 @@ default_imp_for_new_connector_integration_payouts_quote!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -949,6 +961,7 @@ default_imp_for_new_connector_integration_payouts_recipient!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1011,6 +1024,7 @@ default_imp_for_new_connector_integration_payouts_sync!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1073,6 +1087,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1133,6 +1148,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1195,6 +1211,7 @@ default_imp_for_new_connector_integration_frm_sale!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1257,6 +1274,7 @@ default_imp_for_new_connector_integration_frm_checkout!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1319,6 +1337,7 @@ default_imp_for_new_connector_integration_frm_transaction!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1381,6 +1400,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1443,6 +1463,7 @@ default_imp_for_new_connector_integration_frm_record_return!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, @@ -1502,6 +1523,7 @@ default_imp_for_new_connector_integration_revoking_mandates!( connectors::Bamboraapac, connectors::Billwerk, connectors::Bitpay, + connectors::Boku, connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs index 4e1281c7fe8d..5a77b2fb7251 100644 --- a/crates/router/src/connector.rs +++ b/crates/router/src/connector.rs @@ -4,7 +4,6 @@ pub mod adyenplatform; pub mod authorizedotnet; pub mod bankofamerica; pub mod bluesnap; -pub mod boku; pub mod braintree; pub mod checkout; pub mod cybersource; @@ -46,7 +45,7 @@ pub mod wise; pub use hyperswitch_connectors::connectors::{ airwallex, airwallex::Airwallex, amazonpay, amazonpay::Amazonpay, bambora, bambora::Bambora, bamboraapac, bamboraapac::Bamboraapac, billwerk, billwerk::Billwerk, bitpay, bitpay::Bitpay, - cashtocode, cashtocode::Cashtocode, coinbase, coinbase::Coinbase, cryptopay, + boku, boku::Boku, cashtocode, cashtocode::Cashtocode, coinbase, coinbase::Coinbase, cryptopay, cryptopay::Cryptopay, deutschebank, deutschebank::Deutschebank, digitalvirgo, digitalvirgo::Digitalvirgo, dlocal, dlocal::Dlocal, elavon, elavon::Elavon, fiserv, fiserv::Fiserv, fiservemea, fiservemea::Fiservemea, fiuu, fiuu::Fiuu, forte, forte::Forte, @@ -63,7 +62,7 @@ pub use hyperswitch_connectors::connectors::{ pub use self::dummyconnector::DummyConnector; pub use self::{ aci::Aci, adyen::Adyen, adyenplatform::Adyenplatform, authorizedotnet::Authorizedotnet, - bankofamerica::Bankofamerica, bluesnap::Bluesnap, boku::Boku, braintree::Braintree, + bankofamerica::Bankofamerica, bluesnap::Bluesnap, braintree::Braintree, checkout::Checkout, cybersource::Cybersource, datatrans::Datatrans, ebanx::Ebanx, globalpay::Globalpay, gocardless::Gocardless, gpayments::Gpayments, iatapay::Iatapay, itaubank::Itaubank, klarna::Klarna, mifinity::Mifinity, netcetera::Netcetera, nmi::Nmi, diff --git a/crates/router/src/connector/bamboraapac.rs b/crates/router/src/connector/bamboraapac.rs deleted file mode 100644 index 82ed134a9756..000000000000 --- a/crates/router/src/connector/bamboraapac.rs +++ /dev/null @@ -1,748 +0,0 @@ -pub mod transformers; - -use common_utils::{ - self, - ext_traits::XmlExt, - types::{AmountConvertor, MinorUnit, MinorUnitForConnector}, -}; -use diesel_models::enums; -use error_stack::{report, Report, ResultExt}; -use hyperswitch_interfaces::consts; -use transformers as bamboraapac; - -use crate::{ - configs::settings, - connector::utils as connector_utils, - core::errors::{self, CustomResult}, - events::connector_api_logs::ConnectorEvent, - headers, - services::{self, request, ConnectorIntegration, ConnectorValidation}, - types::{ - self, - api::{self, ConnectorCommon, ConnectorCommonExt}, - ErrorResponse, RequestContent, Response, - }, - utils::{self, BytesExt}, -}; - -#[derive(Clone)] -pub struct Bamboraapac { - amount_converter: &'static (dyn AmountConvertor + Sync), -} - -impl Bamboraapac { - pub const fn new() -> &'static Self { - &Self { - amount_converter: &MinorUnitForConnector, - } - } -} - -impl api::Payment for Bamboraapac {} -impl api::PaymentSession for Bamboraapac {} -impl api::ConnectorAccessToken for Bamboraapac {} -impl api::MandateSetup for Bamboraapac {} -impl api::PaymentAuthorize for Bamboraapac {} -impl api::PaymentSync for Bamboraapac {} -impl api::PaymentCapture for Bamboraapac {} -impl api::PaymentVoid for Bamboraapac {} -impl api::Refund for Bamboraapac {} -impl api::RefundExecute for Bamboraapac {} -impl api::RefundSync for Bamboraapac {} -impl api::PaymentToken for Bamboraapac {} - -impl - ConnectorIntegration< - api::PaymentMethodToken, - types::PaymentMethodTokenizationData, - types::PaymentsResponseData, - > for Bamboraapac -{ - // Not Implemented (R) -} - -impl ConnectorCommonExt for Bamboraapac -where - Self: ConnectorIntegration, -{ - fn build_headers( - &self, - _req: &types::RouterData, - _connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { - let header = vec![( - headers::CONTENT_TYPE.to_string(), - self.get_content_type().to_string().into(), - )]; - Ok(header) - } -} - -impl ConnectorValidation for Bamboraapac { - fn validate_capture_method( - &self, - capture_method: Option, - _pmt: Option, - ) -> CustomResult<(), errors::ConnectorError> { - let capture_method = capture_method.unwrap_or_default(); - match capture_method { - enums::CaptureMethod::Automatic | enums::CaptureMethod::Manual => Ok(()), - enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err( - connector_utils::construct_not_implemented_error_report(capture_method, self.id()), - ), - } - } - - fn validate_mandate_payment( - &self, - _pm_type: Option, - pm_data: types::domain::payments::PaymentMethodData, - ) -> CustomResult<(), errors::ConnectorError> { - let connector = self.id(); - match pm_data { - types::domain::payments::PaymentMethodData::Card(_) => Ok(()), - _ => Err(errors::ConnectorError::NotSupported { - message: "mandate payment".to_string(), - connector, - } - .into()), - } - } -} - -impl ConnectorCommon for Bamboraapac { - fn id(&self) -> &'static str { - "bamboraapac" - } - - fn get_currency_unit(&self) -> api::CurrencyUnit { - api::CurrencyUnit::Minor - } - - fn common_get_content_type(&self) -> &'static str { - "text/xml" - } - - fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str { - connectors.bamboraapac.base_url.as_ref() - } - - fn build_error_response( - &self, - res: Response, - event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { - let response: Result< - bamboraapac::BamboraapacErrorResponse, - Report, - > = res.response.parse_struct("BamboraapacErrorResponse"); - - match response { - Ok(response_data) => { - event_builder.map(|i| i.set_error_response_body(&response_data)); - router_env::logger::info!(connector_response=?response_data); - - Ok(ErrorResponse { - status_code: res.status_code, - code: response_data - .declined_code - .unwrap_or(consts::NO_ERROR_CODE.to_string()), - message: response_data - .declined_message - .clone() - .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), - reason: response_data.declined_message, - attempt_status: None, - connector_transaction_id: None, - }) - } - Err(error_msg) => { - event_builder.map(|event| event.set_error(serde_json::json!({"error": res.response.escape_ascii().to_string(), "status_code": res.status_code}))); - router_env::logger::error!(deserialization_error =? error_msg); - utils::handle_json_response_deserialization_failure(res, "bamboaraapac") - } - } - } -} - -impl ConnectorIntegration - for Bamboraapac -{ - //TODO: implement sessions flow -} - -impl ConnectorIntegration - for Bamboraapac -{ -} - -impl - ConnectorIntegration< - api::SetupMandate, - types::SetupMandateRequestData, - types::PaymentsResponseData, - > for Bamboraapac -{ - fn get_headers( - &self, - req: &types::SetupMandateRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { - self.build_headers(req, connectors) - } - - fn get_content_type(&self) -> &'static str { - self.common_get_content_type() - } - - fn get_url( - &self, - _req: &types::SetupMandateRouterData, - connectors: &settings::Connectors, - ) -> CustomResult { - Ok(format!("{}/sipp.asmx", self.base_url(connectors))) - } - - fn get_request_body( - &self, - req: &types::SetupMandateRouterData, - _connectors: &settings::Connectors, - ) -> CustomResult { - let connector_req = bamboraapac::get_setup_mandate_body(req)?; - - Ok(RequestContent::RawBytes(connector_req)) - } - - fn build_request( - &self, - req: &types::SetupMandateRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { - Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) - .url(&types::SetupMandateType::get_url(self, req, connectors)?) - .attach_default_headers() - .headers(types::SetupMandateType::get_headers(self, req, connectors)?) - .set_body(types::SetupMandateType::get_request_body( - self, req, connectors, - )?) - .build(), - )) - } - - fn handle_response( - &self, - data: &types::SetupMandateRouterData, - event_builder: Option<&mut ConnectorEvent>, - res: Response, - ) -> CustomResult { - let response_data = html_to_xml_string_conversion( - String::from_utf8(res.response.to_vec()) - .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, - ); - - let response = response_data - .parse_xml::() - .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; - - event_builder.map(|i| i.set_response_body(&response)); - router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { - response, - data: data.clone(), - http_code: res.status_code, - }) - } - - fn get_error_response( - &self, - res: Response, - event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { - self.build_error_response(res, event_builder) - } -} - -impl ConnectorIntegration - for Bamboraapac -{ - fn get_headers( - &self, - req: &types::PaymentsAuthorizeRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { - self.build_headers(req, connectors) - } - - fn get_content_type(&self) -> &'static str { - self.common_get_content_type() - } - - fn get_url( - &self, - _req: &types::PaymentsAuthorizeRouterData, - connectors: &settings::Connectors, - ) -> CustomResult { - Ok(format!("{}/dts.asmx", self.base_url(connectors))) - } - - fn get_request_body( - &self, - req: &types::PaymentsAuthorizeRouterData, - _connectors: &settings::Connectors, - ) -> CustomResult { - let amount = connector_utils::convert_amount( - self.amount_converter, - req.request.minor_amount, - req.request.currency, - )?; - let connector_router_data = bamboraapac::BamboraapacRouterData::try_from((amount, req))?; - - let connector_req = bamboraapac::get_payment_body(&connector_router_data)?; - - Ok(RequestContent::RawBytes(connector_req)) - } - - fn build_request( - &self, - req: &types::PaymentsAuthorizeRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { - Ok(Some( - services::RequestBuilder::new() - .method(services::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: &types::PaymentsAuthorizeRouterData, - event_builder: Option<&mut ConnectorEvent>, - res: Response, - ) -> CustomResult { - let response_data = html_to_xml_string_conversion( - String::from_utf8(res.response.to_vec()) - .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, - ); - - let response = response_data - .parse_xml::() - .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; - - event_builder.map(|i| i.set_response_body(&response)); - router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { - response, - data: data.clone(), - http_code: res.status_code, - }) - } - - fn get_error_response( - &self, - res: Response, - event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { - self.build_error_response(res, event_builder) - } -} - -impl ConnectorIntegration - for Bamboraapac -{ - fn get_headers( - &self, - req: &types::PaymentsSyncRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { - self.build_headers(req, connectors) - } - - fn get_content_type(&self) -> &'static str { - self.common_get_content_type() - } - - fn get_url( - &self, - _req: &types::PaymentsSyncRouterData, - connectors: &settings::Connectors, - ) -> CustomResult { - Ok(format!("{}/dts.asmx", self.base_url(connectors))) - } - - fn get_request_body( - &self, - req: &types::PaymentsSyncRouterData, - _connectors: &settings::Connectors, - ) -> CustomResult { - let connector_req = bamboraapac::get_payment_sync_body(req)?; - - Ok(RequestContent::RawBytes(connector_req)) - } - - fn build_request( - &self, - req: &types::PaymentsSyncRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { - Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) - .url(&types::PaymentsSyncType::get_url(self, req, connectors)?) - .attach_default_headers() - .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?) - .set_body(types::PaymentsSyncType::get_request_body( - self, req, connectors, - )?) - .build(), - )) - } - - fn handle_response( - &self, - data: &types::PaymentsSyncRouterData, - event_builder: Option<&mut ConnectorEvent>, - res: Response, - ) -> CustomResult { - let response_data = html_to_xml_string_conversion( - String::from_utf8(res.response.to_vec()) - .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, - ); - - let response = response_data - .parse_xml::() - .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; - - event_builder.map(|i| i.set_response_body(&response)); - router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { - response, - data: data.clone(), - http_code: res.status_code, - }) - } - - fn get_error_response( - &self, - res: Response, - event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { - self.build_error_response(res, event_builder) - } -} - -impl ConnectorIntegration - for Bamboraapac -{ - fn get_headers( - &self, - req: &types::PaymentsCaptureRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { - self.build_headers(req, connectors) - } - - fn get_content_type(&self) -> &'static str { - self.common_get_content_type() - } - - fn get_url( - &self, - _req: &types::PaymentsCaptureRouterData, - connectors: &settings::Connectors, - ) -> CustomResult { - Ok(format!("{}/dts.asmx", self.base_url(connectors))) - } - - fn get_request_body( - &self, - req: &types::PaymentsCaptureRouterData, - _connectors: &settings::Connectors, - ) -> CustomResult { - let amount = connector_utils::convert_amount( - self.amount_converter, - req.request.minor_amount_to_capture, - req.request.currency, - )?; - let connector_router_data = bamboraapac::BamboraapacRouterData::try_from((amount, req))?; - - let connector_req = bamboraapac::get_capture_body(&connector_router_data)?; - - Ok(RequestContent::RawBytes(connector_req)) - } - - fn build_request( - &self, - req: &types::PaymentsCaptureRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { - Ok(Some( - services::RequestBuilder::new() - .method(services::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: &types::PaymentsCaptureRouterData, - event_builder: Option<&mut ConnectorEvent>, - res: Response, - ) -> CustomResult { - let response_data = html_to_xml_string_conversion( - String::from_utf8(res.response.to_vec()) - .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, - ); - - let response = response_data - .parse_xml::() - .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; - - event_builder.map(|i| i.set_response_body(&response)); - router_env::logger::info!(connector_response=?response); - - types::RouterData::try_from(types::ResponseRouterData { - response, - data: data.clone(), - http_code: res.status_code, - }) - } - - fn get_error_response( - &self, - res: Response, - event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { - self.build_error_response(res, event_builder) - } -} - -impl ConnectorIntegration - for Bamboraapac -{ -} - -impl ConnectorIntegration - for Bamboraapac -{ - fn get_headers( - &self, - req: &types::RefundExecuteRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { - self.build_headers(req, connectors) - } - - fn get_content_type(&self) -> &'static str { - self.common_get_content_type() - } - - fn get_url( - &self, - _req: &types::RefundExecuteRouterData, - connectors: &settings::Connectors, - ) -> CustomResult { - Ok(format!("{}/dts.asmx", self.base_url(connectors))) - } - - fn get_request_body( - &self, - req: &types::RefundExecuteRouterData, - _connectors: &settings::Connectors, - ) -> CustomResult { - let amount = connector_utils::convert_amount( - self.amount_converter, - req.request.minor_refund_amount, - req.request.currency, - )?; - let connector_router_data = bamboraapac::BamboraapacRouterData::try_from((amount, req))?; - - let connector_req = bamboraapac::get_refund_body(&connector_router_data)?; - - Ok(RequestContent::RawBytes(connector_req)) - } - - fn build_request( - &self, - req: &types::RefundExecuteRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { - let request = services::RequestBuilder::new() - .method(services::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: &types::RefundExecuteRouterData, - event_builder: Option<&mut ConnectorEvent>, - res: Response, - ) -> CustomResult { - let response_data = html_to_xml_string_conversion( - String::from_utf8(res.response.to_vec()) - .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, - ); - - let response = response_data - .parse_xml::() - .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; - - event_builder.map(|i| i.set_response_body(&response)); - router_env::logger::info!(connector_response=?response); - - types::RouterData::try_from(types::ResponseRouterData { - response, - data: data.clone(), - http_code: res.status_code, - }) - } - - fn get_error_response( - &self, - res: Response, - event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { - self.build_error_response(res, event_builder) - } -} - -impl ConnectorIntegration - for Bamboraapac -{ - fn get_headers( - &self, - req: &types::RefundSyncRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { - self.build_headers(req, connectors) - } - - fn get_content_type(&self) -> &'static str { - self.common_get_content_type() - } - - fn get_url( - &self, - _req: &types::RefundSyncRouterData, - connectors: &settings::Connectors, - ) -> CustomResult { - Ok(format!("{}/dts.asmx", self.base_url(connectors))) - } - - fn get_request_body( - &self, - req: &types::RefundSyncRouterData, - _connectors: &settings::Connectors, - ) -> CustomResult { - let connector_req = bamboraapac::get_refund_sync_body(req)?; - - Ok(RequestContent::RawBytes(connector_req)) - } - - fn build_request( - &self, - req: &types::RefundSyncRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { - Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) - .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: &types::RefundSyncRouterData, - event_builder: Option<&mut ConnectorEvent>, - res: Response, - ) -> CustomResult { - let response_data = html_to_xml_string_conversion( - String::from_utf8(res.response.to_vec()) - .change_context(errors::ConnectorError::ResponseDeserializationFailed)?, - ); - - let response = response_data - .parse_xml::() - .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; - - event_builder.map(|i| i.set_response_body(&response)); - router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { - response, - data: data.clone(), - http_code: res.status_code, - }) - } - - fn get_error_response( - &self, - res: Response, - event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { - self.build_error_response(res, event_builder) - } -} - -#[async_trait::async_trait] -impl api::IncomingWebhook for Bamboraapac { - fn get_webhook_object_reference_id( - &self, - _request: &api::IncomingWebhookRequestDetails<'_>, - ) -> CustomResult { - Err(report!(errors::ConnectorError::WebhooksNotImplemented)) - } - - fn get_webhook_event_type( - &self, - _request: &api::IncomingWebhookRequestDetails<'_>, - ) -> CustomResult { - Err(report!(errors::ConnectorError::WebhooksNotImplemented)) - } - - fn get_webhook_resource_object( - &self, - _request: &api::IncomingWebhookRequestDetails<'_>, - ) -> CustomResult, errors::ConnectorError> { - Err(report!(errors::ConnectorError::WebhooksNotImplemented)) - } -} - -fn html_to_xml_string_conversion(res: String) -> String { - res.replace("<", "<").replace(">", ">") -} diff --git a/crates/router/src/connector/bamboraapac/transformers.rs b/crates/router/src/connector/bamboraapac/transformers.rs deleted file mode 100644 index 1a254c052a49..000000000000 --- a/crates/router/src/connector/bamboraapac/transformers.rs +++ /dev/null @@ -1,1049 +0,0 @@ -use common_utils::types::MinorUnit; -use error_stack::ResultExt; -use hyperswitch_interfaces::consts; -use masking::{PeekInterface, Secret}; -use serde::{Deserialize, Serialize}; - -use crate::{ - connector::utils::{self, CardData, PaymentsAuthorizeRequestData, RouterData}, - core::errors, - types::{self, domain, storage::enums, transformers::ForeignFrom}, -}; - -type Error = error_stack::Report; - -pub struct BamboraapacRouterData { - pub amount: MinorUnit, - pub router_data: T, -} - -impl TryFrom<(MinorUnit, T)> for BamboraapacRouterData { - type Error = error_stack::Report; - fn try_from((amount, item): (MinorUnit, T)) -> Result { - Ok(Self { - amount, - router_data: item, - }) - } -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -pub struct BamboraapacMeta { - pub authorize_id: String, -} - -// request body in soap format -pub fn get_payment_body( - req: &BamboraapacRouterData<&types::PaymentsAuthorizeRouterData>, -) -> Result, Error> { - let transaction_data = get_transaction_body(req)?; - let body = format!( - r#" - - - - - - - - - - "#, - transaction_data - ); - - Ok(body.as_bytes().to_vec()) -} - -fn get_transaction_body( - req: &BamboraapacRouterData<&types::PaymentsAuthorizeRouterData>, -) -> Result { - let auth_details = BamboraapacAuthType::try_from(&req.router_data.connector_auth_type)?; - let transaction_type = get_transaction_type(req.router_data.request.capture_method)?; - let card_info = get_card_data(req.router_data)?; - let transaction_data = format!( - r#" - - {} - {} - {} - {} - {} - - {} - {} - - - "#, - req.router_data.connector_request_reference_id.to_owned(), - req.amount, - transaction_type, - auth_details.account_number.peek(), - card_info, - auth_details.username.peek(), - auth_details.password.peek(), - ); - - Ok(transaction_data) -} - -fn get_card_data(req: &types::PaymentsAuthorizeRouterData) -> Result { - let card_data = match &req.request.payment_method_data { - domain::PaymentMethodData::Card(card) => { - let card_holder_name = req.get_billing_full_name()?; - - if req.request.setup_future_usage == Some(enums::FutureUsage::OffSession) { - format!( - r#" - - 2 - {} - {} - {} - {} - {} - - "#, - card.card_number.get_card_no(), - card.card_exp_month.peek(), - card.get_expiry_year_4_digit().peek(), - card.card_cvc.peek(), - card_holder_name.peek(), - ) - } else { - format!( - r#" - - {} - {} - {} - {} - {} - - "#, - card.card_number.get_card_no(), - card.card_exp_month.peek(), - card.get_expiry_year_4_digit().peek(), - card.card_cvc.peek(), - card_holder_name.peek(), - ) - } - } - domain::PaymentMethodData::MandatePayment => { - format!( - r#" - - 2 - {} - - "#, - req.request.get_connector_mandate_id()? - ) - } - _ => { - return Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Bambora APAC"), - ))? - } - }; - Ok(card_data) -} - -fn get_transaction_type(capture_method: Option) -> Result { - match capture_method { - Some(enums::CaptureMethod::Automatic) | None => Ok(1), - Some(enums::CaptureMethod::Manual) => Ok(2), - _ => Err(errors::ConnectorError::CaptureMethodNotSupported)?, - } -} - -pub struct BamboraapacAuthType { - username: Secret, - password: Secret, - account_number: Secret, -} - -impl TryFrom<&types::ConnectorAuthType> for BamboraapacAuthType { - type Error = error_stack::Report; - fn try_from(auth_type: &types::ConnectorAuthType) -> Result { - match auth_type { - types::ConnectorAuthType::SignatureKey { - api_key, - key1, - api_secret, - } => Ok(Self { - username: api_key.to_owned(), - password: api_secret.to_owned(), - account_number: key1.to_owned(), - }), - _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()), - } - } -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename = "Envelope")] -#[serde(rename_all = "PascalCase")] -pub struct BamboraapacPaymentsResponse { - body: BodyResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct BodyResponse { - submit_single_payment_response: SubmitSinglePaymentResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct SubmitSinglePaymentResponse { - submit_single_payment_result: SubmitSinglePaymentResult, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct SubmitSinglePaymentResult { - response: PaymentResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct PaymentResponse { - response_code: u8, - receipt: String, - credit_card_token: Option, - declined_code: Option, - declined_message: Option, -} - -fn get_attempt_status( - response_code: u8, - capture_method: Option, -) -> enums::AttemptStatus { - match response_code { - 0 => match capture_method { - Some(enums::CaptureMethod::Automatic) | None => enums::AttemptStatus::Charged, - Some(enums::CaptureMethod::Manual) => enums::AttemptStatus::Authorized, - _ => enums::AttemptStatus::Pending, - }, - 1 => enums::AttemptStatus::Failure, - _ => enums::AttemptStatus::Pending, - } -} - -impl - TryFrom< - types::ResponseRouterData< - F, - BamboraapacPaymentsResponse, - types::PaymentsAuthorizeData, - types::PaymentsResponseData, - >, - > for types::RouterData -{ - type Error = error_stack::Report; - fn try_from( - item: types::ResponseRouterData< - F, - BamboraapacPaymentsResponse, - types::PaymentsAuthorizeData, - types::PaymentsResponseData, - >, - ) -> Result { - let response_code = item - .response - .body - .submit_single_payment_response - .submit_single_payment_result - .response - .response_code; - let connector_transaction_id = item - .response - .body - .submit_single_payment_response - .submit_single_payment_result - .response - .receipt; - - let mandate_reference = - if item.data.request.setup_future_usage == Some(enums::FutureUsage::OffSession) { - let connector_mandate_id = item - .response - .body - .submit_single_payment_response - .submit_single_payment_result - .response - .credit_card_token; - Some(types::MandateReference { - connector_mandate_id, - payment_method_id: None, - mandate_metadata: None, - connector_mandate_request_reference_id: None, - }) - } else { - None - }; - // transaction approved - if response_code == 0 { - Ok(Self { - status: get_attempt_status(response_code, item.data.request.capture_method), - response: Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId( - connector_transaction_id.to_owned(), - ), - redirection_data: Box::new(None), - mandate_reference: Box::new(mandate_reference), - connector_metadata: None, - network_txn_id: None, - connector_response_reference_id: Some(connector_transaction_id), - incremental_authorization_allowed: None, - charge_id: None, - }), - ..item.data - }) - } - // transaction failed - else { - let code = item - .response - .body - .submit_single_payment_response - .submit_single_payment_result - .response - .declined_code - .unwrap_or(consts::NO_ERROR_CODE.to_string()); - - let declined_message = item - .response - .body - .submit_single_payment_response - .submit_single_payment_result - .response - .declined_message - .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()); - Ok(Self { - status: get_attempt_status(response_code, item.data.request.capture_method), - response: Err(types::ErrorResponse { - status_code: item.http_code, - code, - message: declined_message.to_owned(), - reason: Some(declined_message), - attempt_status: None, - connector_transaction_id: None, - }), - ..item.data - }) - } - } -} - -pub fn get_setup_mandate_body(req: &types::SetupMandateRouterData) -> Result, Error> { - let card_holder_name = req.get_billing_full_name()?; - let auth_details = BamboraapacAuthType::try_from(&req.connector_auth_type)?; - let body = match &req.request.payment_method_data { - domain::PaymentMethodData::Card(card) => { - format!( - r#" - - - - - - - {} - {} - {} - {} - 2 - {} - {} - - ]]> - - - - - "#, - card.card_number.get_card_no(), - card.card_exp_month.peek(), - card.get_expiry_year_4_digit().peek(), - card_holder_name.peek(), - auth_details.username.peek(), - auth_details.password.peek(), - ) - } - _ => { - return Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Bambora APAC"), - ))?; - } - }; - - Ok(body.as_bytes().to_vec()) -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename = "Envelope")] -#[serde(rename_all = "PascalCase")] -pub struct BamboraapacMandateResponse { - body: MandateBodyResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct MandateBodyResponse { - tokenise_credit_card_response: TokeniseCreditCardResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct TokeniseCreditCardResponse { - tokenise_credit_card_result: TokeniseCreditCardResult, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct TokeniseCreditCardResult { - tokenise_credit_card_response: MandateResponseBody, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct MandateResponseBody { - return_value: u8, - token: Option, -} - -impl - TryFrom< - types::ResponseRouterData< - F, - BamboraapacMandateResponse, - types::SetupMandateRequestData, - types::PaymentsResponseData, - >, - > for types::RouterData -{ - type Error = error_stack::Report; - fn try_from( - item: types::ResponseRouterData< - F, - BamboraapacMandateResponse, - types::SetupMandateRequestData, - types::PaymentsResponseData, - >, - ) -> Result { - let response_code = item - .response - .body - .tokenise_credit_card_response - .tokenise_credit_card_result - .tokenise_credit_card_response - .return_value; - - let connector_mandate_id = item - .response - .body - .tokenise_credit_card_response - .tokenise_credit_card_result - .tokenise_credit_card_response - .token - .ok_or(errors::ConnectorError::MissingConnectorMandateID)?; - - // transaction approved - if response_code == 0 { - Ok(Self { - status: enums::AttemptStatus::Charged, - response: Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::NoResponseId, - redirection_data: Box::new(None), - mandate_reference: Box::new(Some(types::MandateReference { - connector_mandate_id: Some(connector_mandate_id), - payment_method_id: None, - mandate_metadata: None, - connector_mandate_request_reference_id: None, - })), - connector_metadata: None, - network_txn_id: None, - connector_response_reference_id: None, - incremental_authorization_allowed: None, - charge_id: None, - }), - ..item.data - }) - } - // transaction failed - else { - Ok(Self { - status: enums::AttemptStatus::Failure, - response: Err(types::ErrorResponse { - status_code: item.http_code, - code: consts::NO_ERROR_CODE.to_string(), - message: consts::NO_ERROR_MESSAGE.to_string(), - reason: None, - attempt_status: None, - connector_transaction_id: None, - }), - ..item.data - }) - } - } -} - -// capture body in soap format -pub fn get_capture_body( - req: &BamboraapacRouterData<&types::PaymentsCaptureRouterData>, -) -> Result, Error> { - let receipt = req.router_data.request.connector_transaction_id.to_owned(); - let auth_details = BamboraapacAuthType::try_from(&req.router_data.connector_auth_type)?; - let body = format!( - r#" - - - - - - {} - {} - - {} - {} - - - ]]> - - - - - "#, - receipt, - req.amount, - auth_details.username.peek(), - auth_details.password.peek(), - ); - - Ok(body.as_bytes().to_vec()) -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename = "Envelope")] -#[serde(rename_all = "PascalCase")] -pub struct BamboraapacCaptureResponse { - body: CaptureBodyResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct CaptureBodyResponse { - submit_single_capture_response: SubmitSingleCaptureResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct SubmitSingleCaptureResponse { - submit_single_capture_result: SubmitSingleCaptureResult, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct SubmitSingleCaptureResult { - response: CaptureResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct CaptureResponse { - response_code: u8, - receipt: String, - declined_code: Option, - declined_message: Option, -} - -impl - TryFrom< - types::ResponseRouterData< - F, - BamboraapacCaptureResponse, - types::PaymentsCaptureData, - types::PaymentsResponseData, - >, - > for types::RouterData -{ - type Error = error_stack::Report; - fn try_from( - item: types::ResponseRouterData< - F, - BamboraapacCaptureResponse, - types::PaymentsCaptureData, - types::PaymentsResponseData, - >, - ) -> Result { - let response_code = item - .response - .body - .submit_single_capture_response - .submit_single_capture_result - .response - .response_code; - let connector_transaction_id = item - .response - .body - .submit_single_capture_response - .submit_single_capture_result - .response - .receipt; - - // storing receipt_id of authorize to metadata for future usage - let connector_metadata = Some(serde_json::json!(BamboraapacMeta { - authorize_id: item.data.request.connector_transaction_id.to_owned() - })); - // transaction approved - if response_code == 0 { - Ok(Self { - status: enums::AttemptStatus::Charged, - response: Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId( - connector_transaction_id.to_owned(), - ), - redirection_data: Box::new(None), - mandate_reference: Box::new(None), - connector_metadata, - network_txn_id: None, - connector_response_reference_id: Some(connector_transaction_id), - incremental_authorization_allowed: None, - charge_id: None, - }), - ..item.data - }) - } - // transaction failed - else { - let code = item - .response - .body - .submit_single_capture_response - .submit_single_capture_result - .response - .declined_code - .unwrap_or(consts::NO_ERROR_CODE.to_string()); - let declined_message = item - .response - .body - .submit_single_capture_response - .submit_single_capture_result - .response - .declined_message - .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()); - Ok(Self { - status: enums::AttemptStatus::Failure, - response: Err(types::ErrorResponse { - status_code: item.http_code, - code, - message: declined_message.to_owned(), - reason: Some(declined_message), - attempt_status: None, - connector_transaction_id: None, - }), - ..item.data - }) - } - } -} - -// refund body in soap format -pub fn get_refund_body( - req: &BamboraapacRouterData<&types::RefundExecuteRouterData>, -) -> Result, Error> { - let receipt = req.router_data.request.connector_transaction_id.to_owned(); - let auth_details = BamboraapacAuthType::try_from(&req.router_data.connector_auth_type)?; - let body = format!( - r#" - - - - - - - {} - {} - {} - - {} - {} - - - ]]> - - - - - "#, - req.router_data.request.refund_id.to_owned(), - receipt, - req.amount, - auth_details.username.peek(), - auth_details.password.peek(), - ); - - Ok(body.as_bytes().to_vec()) -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename = "Envelope")] -#[serde(rename_all = "PascalCase")] -pub struct BamboraapacRefundsResponse { - body: RefundBodyResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct RefundBodyResponse { - submit_single_refund_response: SubmitSingleRefundResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct SubmitSingleRefundResponse { - submit_single_refund_result: SubmitSingleRefundResult, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct SubmitSingleRefundResult { - response: RefundResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct RefundResponse { - response_code: u8, - receipt: String, - declined_code: Option, - declined_message: Option, -} - -impl ForeignFrom for enums::RefundStatus { - fn foreign_from(item: u8) -> Self { - match item { - 0 => Self::Success, - 1 => Self::Failure, - _ => Self::Pending, - } - } -} - -impl - TryFrom< - types::ResponseRouterData< - F, - BamboraapacRefundsResponse, - types::RefundsData, - types::RefundsResponseData, - >, - > for types::RouterData -{ - type Error = error_stack::Report; - fn try_from( - item: types::ResponseRouterData< - F, - BamboraapacRefundsResponse, - types::RefundsData, - types::RefundsResponseData, - >, - ) -> Result { - let response_code = item - .response - .body - .submit_single_refund_response - .submit_single_refund_result - .response - .response_code; - let connector_refund_id = item - .response - .body - .submit_single_refund_response - .submit_single_refund_result - .response - .receipt; - - Ok(Self { - response: Ok(types::RefundsResponseData { - connector_refund_id: connector_refund_id.to_owned(), - refund_status: enums::RefundStatus::foreign_from(response_code), - }), - ..item.data - }) - } -} - -pub fn get_payment_sync_body(req: &types::PaymentsSyncRouterData) -> Result, Error> { - let auth_details = BamboraapacAuthType::try_from(&req.connector_auth_type)?; - let connector_transaction_id = req - .request - .connector_transaction_id - .get_connector_transaction_id() - .change_context(errors::ConnectorError::MissingConnectorTransactionID)?; - let body = format!( - r#" - - - - - - - - {} - 2024-06-23 00:00:00 - 2099-12-31 23:59:59 - {} - - - {} - {} - - - ]]> - - - - - "#, - auth_details.account_number.peek(), - connector_transaction_id, - auth_details.username.peek(), - auth_details.password.peek(), - ); - - Ok(body.as_bytes().to_vec()) -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename = "Envelope")] -#[serde(rename_all = "PascalCase")] -pub struct BamboraapacSyncResponse { - body: SyncBodyResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct SyncBodyResponse { - query_transaction_response: QueryTransactionResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct QueryTransactionResponse { - query_transaction_result: QueryTransactionResult, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct QueryTransactionResult { - query_response: QueryResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct QueryResponse { - response: SyncResponse, -} - -#[derive(Debug, Clone, Serialize, Deserialize)] -#[serde(rename_all = "PascalCase")] -pub struct SyncResponse { - response_code: u8, - receipt: String, - declined_code: Option, - declined_message: Option, -} - -impl - TryFrom< - types::ResponseRouterData< - F, - BamboraapacSyncResponse, - types::PaymentsSyncData, - types::PaymentsResponseData, - >, - > for types::RouterData -{ - type Error = error_stack::Report; - fn try_from( - item: types::ResponseRouterData< - F, - BamboraapacSyncResponse, - types::PaymentsSyncData, - types::PaymentsResponseData, - >, - ) -> Result { - let response_code = item - .response - .body - .query_transaction_response - .query_transaction_result - .query_response - .response - .response_code; - let connector_transaction_id = item - .response - .body - .query_transaction_response - .query_transaction_result - .query_response - .response - .receipt; - // transaction approved - if response_code == 0 { - Ok(Self { - status: get_attempt_status(response_code, item.data.request.capture_method), - response: Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId( - connector_transaction_id.to_owned(), - ), - redirection_data: Box::new(None), - mandate_reference: Box::new(None), - connector_metadata: None, - network_txn_id: None, - connector_response_reference_id: Some(connector_transaction_id), - incremental_authorization_allowed: None, - charge_id: None, - }), - ..item.data - }) - } - // transaction failed - else { - let code = item - .response - .body - .query_transaction_response - .query_transaction_result - .query_response - .response - .declined_code - .unwrap_or(consts::NO_ERROR_CODE.to_string()); - let declined_message = item - .response - .body - .query_transaction_response - .query_transaction_result - .query_response - .response - .declined_message - .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()); - Ok(Self { - status: get_attempt_status(response_code, item.data.request.capture_method), - response: Err(types::ErrorResponse { - status_code: item.http_code, - code, - message: declined_message.to_owned(), - reason: Some(declined_message), - attempt_status: None, - connector_transaction_id: None, - }), - ..item.data - }) - } - } -} - -pub fn get_refund_sync_body(req: &types::RefundSyncRouterData) -> Result, Error> { - let auth_details = BamboraapacAuthType::try_from(&req.connector_auth_type)?; - - let body = format!( - r#" - - - - - - - - {} - 2024-06-23 00:00:00 - 2099-12-31 23:59:59 - {} - - - {} - {} - - - ]]> - - - - - "#, - auth_details.account_number.peek(), - req.request.refund_id, - auth_details.username.peek(), - auth_details.password.peek(), - ); - - Ok(body.as_bytes().to_vec()) -} - -impl - TryFrom< - types::ResponseRouterData< - F, - BamboraapacSyncResponse, - types::RefundsData, - types::RefundsResponseData, - >, - > for types::RouterData -{ - type Error = error_stack::Report; - fn try_from( - item: types::ResponseRouterData< - F, - BamboraapacSyncResponse, - types::RefundsData, - types::RefundsResponseData, - >, - ) -> Result { - let response_code = item - .response - .body - .query_transaction_response - .query_transaction_result - .query_response - .response - .response_code; - let connector_refund_id = item - .response - .body - .query_transaction_response - .query_transaction_result - .query_response - .response - .receipt; - Ok(Self { - response: Ok(types::RefundsResponseData { - connector_refund_id: connector_refund_id.to_owned(), - refund_status: enums::RefundStatus::foreign_from(response_code), - }), - ..item.data - }) - } -} - -#[derive(Default, Debug, Serialize, Deserialize, PartialEq)] -pub struct BamboraapacErrorResponse { - pub declined_code: Option, - pub declined_message: Option, -} diff --git a/crates/router/src/core/payments/connector_integration_v2_impls.rs b/crates/router/src/core/payments/connector_integration_v2_impls.rs index 2b776c8ec7b6..7b1c093e350c 100644 --- a/crates/router/src/core/payments/connector_integration_v2_impls.rs +++ b/crates/router/src/core/payments/connector_integration_v2_impls.rs @@ -696,7 +696,6 @@ default_imp_for_new_connector_integration_payment!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -756,7 +755,6 @@ default_imp_for_new_connector_integration_refund!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -810,7 +808,6 @@ default_imp_for_new_connector_integration_connector_access_token!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -886,7 +883,6 @@ default_imp_for_new_connector_integration_accept_dispute!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -944,7 +940,6 @@ default_imp_for_new_connector_integration_defend_dispute!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -986,7 +981,6 @@ default_imp_for_new_connector_integration_submit_evidence!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1055,7 +1049,6 @@ default_imp_for_new_connector_integration_file_upload!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1207,7 +1200,6 @@ default_imp_for_new_connector_integration_payouts_create!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1268,7 +1260,6 @@ default_imp_for_new_connector_integration_payouts_eligibility!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1329,7 +1320,6 @@ default_imp_for_new_connector_integration_payouts_fulfill!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1390,7 +1380,6 @@ default_imp_for_new_connector_integration_payouts_cancel!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1451,7 +1440,6 @@ default_imp_for_new_connector_integration_payouts_quote!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1512,7 +1500,6 @@ default_imp_for_new_connector_integration_payouts_recipient!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1573,7 +1560,6 @@ default_imp_for_new_connector_integration_payouts_sync!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1634,7 +1620,6 @@ default_imp_for_new_connector_integration_payouts_recipient_account!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1693,7 +1678,6 @@ default_imp_for_new_connector_integration_webhook_source_verification!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1845,7 +1829,6 @@ default_imp_for_new_connector_integration_frm_sale!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1906,7 +1889,6 @@ default_imp_for_new_connector_integration_frm_checkout!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1967,7 +1949,6 @@ default_imp_for_new_connector_integration_frm_transaction!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -2028,7 +2009,6 @@ default_imp_for_new_connector_integration_frm_fulfillment!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -2089,7 +2069,6 @@ default_imp_for_new_connector_integration_frm_record_return!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -2147,7 +2126,6 @@ default_imp_for_new_connector_integration_revoking_mandates!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs index 2e19515517d5..366fe13b191b 100644 --- a/crates/router/src/core/payments/flows.rs +++ b/crates/router/src/core/payments/flows.rs @@ -208,7 +208,6 @@ default_imp_for_complete_authorize!( connector::Aci, connector::Adyen, connector::Bankofamerica, - connector::Boku, connector::Checkout, connector::Datatrans, connector::Ebanx, @@ -269,7 +268,6 @@ default_imp_for_webhook_source_verification!( connector::Bankofamerica, connector::Bluesnap, connector::Braintree, - connector::Boku, connector::Checkout, connector::Cybersource, connector::Datatrans, @@ -338,7 +336,6 @@ default_imp_for_create_customer!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -407,7 +404,6 @@ default_imp_for_connector_redirect_response!( connector::Aci, connector::Adyen, connector::Bankofamerica, - connector::Boku, connector::Cybersource, connector::Datatrans, connector::Ebanx, @@ -562,7 +558,6 @@ default_imp_for_accept_dispute!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Cybersource, connector::Datatrans, @@ -653,7 +648,6 @@ default_imp_for_file_upload!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Cybersource, connector::Datatrans, @@ -721,7 +715,6 @@ default_imp_for_submit_evidence!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Cybersource, connector::Datatrans, @@ -789,7 +782,6 @@ default_imp_for_defend_dispute!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Cybersource, connector::Datatrans, @@ -873,7 +865,6 @@ default_imp_for_pre_processing_steps!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Datatrans, @@ -929,7 +920,6 @@ default_imp_for_post_processing_steps!( connector::Aci, connector::Authorizedotnet, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Datatrans, @@ -973,7 +963,6 @@ default_imp_for_payouts!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Datatrans, @@ -1038,7 +1027,6 @@ default_imp_for_payouts_create!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1106,7 +1094,6 @@ default_imp_for_payouts_retrieve!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1179,7 +1166,6 @@ default_imp_for_payouts_eligibility!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1247,7 +1233,6 @@ default_imp_for_payouts_fulfill!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Datatrans, @@ -1312,7 +1297,6 @@ default_imp_for_payouts_cancel!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1381,7 +1365,6 @@ default_imp_for_payouts_quote!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1451,7 +1434,6 @@ default_imp_for_payouts_recipient!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1523,7 +1505,6 @@ default_imp_for_payouts_recipient_account!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1593,7 +1574,6 @@ default_imp_for_approve!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1664,7 +1644,6 @@ default_imp_for_reject!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1830,7 +1809,6 @@ default_imp_for_frm_sale!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1901,7 +1879,6 @@ default_imp_for_frm_checkout!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -1972,7 +1949,6 @@ default_imp_for_frm_transaction!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -2043,7 +2019,6 @@ default_imp_for_frm_fulfillment!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -2114,7 +2089,6 @@ default_imp_for_frm_record_return!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -2183,7 +2157,6 @@ default_imp_for_incremental_authorization!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Datatrans, @@ -2250,7 +2223,6 @@ default_imp_for_revoking_mandates!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Datatrans, @@ -2481,7 +2453,6 @@ default_imp_for_authorize_session_token!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -2549,7 +2520,6 @@ default_imp_for_calculate_tax!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -2618,7 +2588,6 @@ default_imp_for_session_update!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, @@ -2686,7 +2655,6 @@ default_imp_for_post_session_tokens!( connector::Authorizedotnet, connector::Bankofamerica, connector::Bluesnap, - connector::Boku, connector::Braintree, connector::Checkout, connector::Cybersource, From f52bf131ad522dfb41976dd0cf801c3ae946695d Mon Sep 17 00:00:00 2001 From: Spriti Aneja Date: Wed, 27 Nov 2024 17:36:03 +0530 Subject: [PATCH 3/6] Moved Gocardless to hyperswitch_connector crate --- .../hyperswitch_connectors/src/connectors.rs | 3 +- .../src/connectors}/gocardless.rs | 359 +++++++++--------- .../connectors}/gocardless/transformers.rs | 242 ++++++------ .../src/default_implementations.rs | 59 +-- .../src/default_implementations_v2.rs | 44 +-- crates/hyperswitch_connectors/src/utils.rs | 11 +- crates/router/src/connector.rs | 5 +- .../connector_integration_v2_impls.rs | 45 +-- crates/router/src/core/payments/flows.rs | 58 ++- 9 files changed, 425 insertions(+), 401 deletions(-) rename crates/{router/src/connector => hyperswitch_connectors/src/connectors}/gocardless.rs (71%) rename crates/{router/src/connector => hyperswitch_connectors/src/connectors}/gocardless/transformers.rs (79%) diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs index 5fbf8334c3e1..61bf9db40e34 100644 --- a/crates/hyperswitch_connectors/src/connectors.rs +++ b/crates/hyperswitch_connectors/src/connectors.rs @@ -17,6 +17,7 @@ pub mod fiservemea; pub mod fiuu; pub mod forte; pub mod globepay; +pub mod gocardless; pub mod helcim; pub mod jpmorgan; pub mod mollie; @@ -46,7 +47,7 @@ pub use self::{ billwerk::Billwerk, bitpay::Bitpay, boku::Boku, cashtocode::Cashtocode, coinbase::Coinbase, cryptopay::Cryptopay, deutschebank::Deutschebank, digitalvirgo::Digitalvirgo, dlocal::Dlocal, elavon::Elavon, fiserv::Fiserv, fiservemea::Fiservemea, fiuu::Fiuu, forte::Forte, - globepay::Globepay, helcim::Helcim, jpmorgan::Jpmorgan, mollie::Mollie, + globepay::Globepay, gocardless::Gocardless, helcim::Helcim, jpmorgan::Jpmorgan, mollie::Mollie, multisafepay::Multisafepay, nexinets::Nexinets, nexixpay::Nexixpay, nomupay::Nomupay, novalnet::Novalnet, payeezy::Payeezy, payu::Payu, powertranz::Powertranz, razorpay::Razorpay, shift4::Shift4, square::Square, stax::Stax, taxjar::Taxjar, thunes::Thunes, tsys::Tsys, diff --git a/crates/router/src/connector/gocardless.rs b/crates/hyperswitch_connectors/src/connectors/gocardless.rs similarity index 71% rename from crates/router/src/connector/gocardless.rs rename to crates/hyperswitch_connectors/src/connectors/gocardless.rs index 281a1ea5c9b8..376b4686e57b 100644 --- a/crates/router/src/connector/gocardless.rs +++ b/crates/hyperswitch_connectors/src/connectors/gocardless.rs @@ -2,29 +2,44 @@ pub mod transformers; use std::fmt::Debug; -use api_models::enums::enums; -use common_utils::{crypto, ext_traits::ByteSliceExt, request::RequestContent}; +use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId}; +use common_enums::enums; +use common_utils::{ + crypto, errors::CustomResult, ext_traits::{ByteSliceExt, BytesExt}, request::{Method, Request, RequestBuilder, RequestContent} +}; use error_stack::ResultExt; -use masking::PeekInterface; -use transformers as gocardless; - -use crate::{ - configs::settings, - connector::utils::{self as connector_utils, PaymentMethodDataType}, - core::errors::{self, CustomResult}, - events::connector_api_logs::ConnectorEvent, - headers, - services::{ - self, - request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, +use hyperswitch_domain_models::{ + payment_method_data::PaymentMethodData, router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData}, router_flow_types::{ + access_token_auth::AccessTokenAuth, + payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void}, + refunds::{Execute, RSync}, CreateConnectorCustomer, PreProcessing, + }, router_request_types::{ + AccessTokenRequestData, ConnectorCustomerData, PaymentMethodTokenizationData, PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsPreProcessingData, PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData + }, router_response_types::{PaymentsResponseData, RefundsResponseData}, types::{ + ConnectorCustomerRouterData, PaymentsAuthorizeRouterData, PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData, SetupMandateRouterData, TokenizationRouterData + } +}; +use hyperswitch_interfaces::{ + api::{ + self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, + ConnectorValidation, }, + configs::Connectors, + errors, + events::connector_api_logs::ConnectorEvent, types::{ self, - api::{self, ConnectorCommon, ConnectorCommonExt}, - ErrorResponse, Response, + PaymentsSyncType,Response, }, - utils::BytesExt, + webhooks::{IncomingWebhook, IncomingWebhookRequestDetails}, +}; +use masking::{Mask, PeekInterface}; +use transformers as gocardless; + +use crate::{ + constants::headers, + types::ResponseRouterData, + utils::{construct_not_implemented_error_report, is_mandate_supported, PaymentMethodDataType}, }; #[derive(Debug, Clone)] @@ -54,9 +69,9 @@ where { fn build_headers( &self, - req: &types::RouterData, - _connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &RouterData, + _connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { let mut header = vec![ ( headers::CONTENT_TYPE.to_string(), @@ -86,14 +101,14 @@ impl ConnectorCommon for Gocardless { "application/json" } - fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str { + fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str { connectors.gocardless.base_url.as_ref() } fn get_auth_header( &self, - auth_type: &types::ConnectorAuthType, - ) -> CustomResult)>, errors::ConnectorError> { + auth_type: &ConnectorAuthType, + ) -> CustomResult)>, errors::ConnectorError> { let auth = gocardless::GocardlessAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; Ok(vec![( @@ -136,31 +151,31 @@ impl ConnectorCommon for Gocardless { impl ConnectorIntegration< - api::CreateConnectorCustomer, - types::ConnectorCustomerData, - types::PaymentsResponseData, + CreateConnectorCustomer, + ConnectorCustomerData, + PaymentsResponseData, > for Gocardless { fn get_headers( &self, - req: &types::ConnectorCustomerRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &ConnectorCustomerRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } fn get_url( &self, - _req: &types::ConnectorCustomerRouterData, - connectors: &settings::Connectors, + _req: &ConnectorCustomerRouterData, + connectors: &Connectors, ) -> CustomResult { Ok(format!("{}/customers", self.base_url(connectors))) } fn get_request_body( &self, - req: &types::ConnectorCustomerRouterData, - _connectors: &settings::Connectors, + req: &ConnectorCustomerRouterData, + _connectors: &Connectors, ) -> CustomResult { let connector_req = gocardless::GocardlessCustomerRequest::try_from(req)?; Ok(RequestContent::Json(Box::new(connector_req))) @@ -168,12 +183,12 @@ impl fn build_request( &self, - req: &types::ConnectorCustomerRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + req: &ConnectorCustomerRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) + RequestBuilder::new() + .method(Method::Post) .url(&types::ConnectorCustomerType::get_url( self, req, connectors, )?) @@ -190,21 +205,21 @@ impl fn handle_response( &self, - data: &types::ConnectorCustomerRouterData, + data: &ConnectorCustomerRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult< - types::RouterData< - api::CreateConnectorCustomer, - types::ConnectorCustomerData, - types::PaymentsResponseData, + RouterData< + CreateConnectorCustomer, + ConnectorCustomerData, + PaymentsResponseData, >, errors::ConnectorError, > where - api::CreateConnectorCustomer: Clone, - types::ConnectorCustomerData: Clone, - types::PaymentsResponseData: Clone, + CreateConnectorCustomer: Clone, + ConnectorCustomerData: Clone, + PaymentsResponseData: Clone, { let response: gocardless::GocardlessCustomerResponse = res .response @@ -214,7 +229,7 @@ impl event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { + RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, @@ -232,23 +247,23 @@ impl impl ConnectorIntegration< - api::PaymentMethodToken, - types::PaymentMethodTokenizationData, - types::PaymentsResponseData, + PaymentMethodToken, + PaymentMethodTokenizationData, + PaymentsResponseData, > for Gocardless { fn get_headers( &self, - req: &types::TokenizationRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &TokenizationRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } fn get_url( &self, - _req: &types::TokenizationRouterData, - connectors: &settings::Connectors, + _req: &TokenizationRouterData, + connectors: &Connectors, ) -> CustomResult { Ok(format!( "{}/customer_bank_accounts", @@ -258,8 +273,8 @@ impl fn get_request_body( &self, - req: &types::TokenizationRouterData, - _connectors: &settings::Connectors, + req: &TokenizationRouterData, + _connectors: &Connectors, ) -> CustomResult { let connector_req = gocardless::GocardlessBankAccountRequest::try_from(req)?; Ok(RequestContent::Json(Box::new(connector_req))) @@ -267,12 +282,12 @@ impl fn build_request( &self, - req: &types::TokenizationRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + req: &TokenizationRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) + RequestBuilder::new() + .method(Method::Post) .url(&types::TokenizationType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::TokenizationType::get_headers(self, req, connectors)?) @@ -285,14 +300,14 @@ impl fn handle_response( &self, - data: &types::TokenizationRouterData, + data: &TokenizationRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, - ) -> CustomResult + ) -> CustomResult where - api::PaymentMethodToken: Clone, - types::PaymentMethodTokenizationData: Clone, - types::PaymentsResponseData: Clone, + PaymentMethodToken: Clone, + PaymentMethodTokenizationData: Clone, + PaymentsResponseData: Clone, { let response: gocardless::GocardlessBankAccountResponse = res .response @@ -302,7 +317,7 @@ impl event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { + RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, @@ -320,9 +335,9 @@ impl impl ConnectorIntegration< - api::PreProcessing, - types::PaymentsPreProcessingData, - types::PaymentsResponseData, + PreProcessing, + PaymentsPreProcessingData, + PaymentsResponseData, > for Gocardless { } @@ -339,14 +354,14 @@ impl ConnectorValidation for Gocardless { enums::CaptureMethod::Manual | enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err( - connector_utils::construct_not_implemented_error_report(capture_method, self.id()), + construct_not_implemented_error_report(capture_method, self.id()), ), } } fn validate_mandate_payment( &self, - pm_type: Option, - pm_data: types::domain::payments::PaymentMethodData, + pm_type: Option, + pm_data: PaymentMethodData, ) -> CustomResult<(), errors::ConnectorError> { let mandate_supported_pmd = std::collections::HashSet::from([ PaymentMethodDataType::SepaBankDebit, @@ -354,48 +369,48 @@ impl ConnectorValidation for Gocardless { PaymentMethodDataType::BecsBankDebit, PaymentMethodDataType::BacsBankDebit, ]); - connector_utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id()) + is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id()) } } -impl ConnectorIntegration +impl ConnectorIntegration for Gocardless { //TODO: implement sessions flow } -impl ConnectorIntegration +impl ConnectorIntegration for Gocardless { } impl ConnectorIntegration< - api::SetupMandate, - types::SetupMandateRequestData, - types::PaymentsResponseData, + SetupMandate, + SetupMandateRequestData, + PaymentsResponseData, > for Gocardless { fn get_headers( &self, - req: &types::SetupMandateRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &SetupMandateRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } fn get_url( &self, - _req: &types::SetupMandateRouterData, - connectors: &settings::Connectors, + _req: &SetupMandateRouterData, + connectors: &Connectors, ) -> CustomResult { Ok(format!("{}/mandates", self.base_url(connectors))) } fn get_request_body( &self, - req: &types::SetupMandateRouterData, - _connectors: &settings::Connectors, + req: &SetupMandateRouterData, + _connectors: &Connectors, ) -> CustomResult { let connector_req = gocardless::GocardlessMandateRequest::try_from(req)?; Ok(RequestContent::Json(Box::new(connector_req))) @@ -403,14 +418,14 @@ impl fn build_request( &self, - req: &types::SetupMandateRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + req: &SetupMandateRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { // Preprocessing flow is to create mandate, which should to be called only in case of First mandate if req.request.setup_mandate_details.is_some() { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) + RequestBuilder::new() + .method(Method::Post) .url(&types::SetupMandateType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::SetupMandateType::get_headers(self, req, connectors)?) @@ -426,10 +441,10 @@ impl fn handle_response( &self, - data: &types::SetupMandateRouterData, + data: &SetupMandateRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, - ) -> CustomResult { + ) -> CustomResult { let response: gocardless::GocardlessMandateResponse = res .response .parse_struct("GocardlessMandateResponse") @@ -438,7 +453,7 @@ impl event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { + RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, @@ -454,14 +469,14 @@ impl } } -impl ConnectorIntegration +impl ConnectorIntegration for Gocardless { fn get_headers( &self, - req: &types::PaymentsAuthorizeRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } @@ -471,16 +486,16 @@ impl ConnectorIntegration CustomResult { Ok(format!("{}/payments", self.base_url(connectors))) } fn get_request_body( &self, - req: &types::PaymentsAuthorizeRouterData, - _connectors: &settings::Connectors, + req: &PaymentsAuthorizeRouterData, + _connectors: &Connectors, ) -> CustomResult { let connector_router_data = gocardless::GocardlessRouterData::try_from(( &self.get_currency_unit(), @@ -495,12 +510,12 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) + RequestBuilder::new() + .method(Method::Post) .url(&types::PaymentsAuthorizeType::get_url( self, req, connectors, )?) @@ -517,10 +532,10 @@ impl ConnectorIntegration, res: Response, - ) -> CustomResult { + ) -> CustomResult { let response: gocardless::GocardlessPaymentsResponse = res .response .parse_struct("GocardlessPaymentsResponse") @@ -529,7 +544,7 @@ impl ConnectorIntegration +impl ConnectorIntegration for Gocardless { fn get_headers( &self, - req: &types::PaymentsSyncRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &PaymentsSyncRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } @@ -562,8 +577,8 @@ impl ConnectorIntegration CustomResult { Ok(format!( "{}/payments/{}", @@ -577,25 +592,25 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + req: &PaymentsSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Get) - .url(&types::PaymentsSyncType::get_url(self, req, connectors)?) + RequestBuilder::new() + .method(Method::Get) + .url(&PaymentsSyncType::get_url(self, req, connectors)?) .attach_default_headers() - .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?) + .headers(PaymentsSyncType::get_headers(self, req, connectors)?) .build(), )) } fn handle_response( &self, - data: &types::PaymentsSyncRouterData, + data: &PaymentsSyncRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, - ) -> CustomResult { + ) -> CustomResult { let response: gocardless::GocardlessPaymentsResponse = res .response .parse_struct("GocardlessPaymentsResponse") @@ -604,7 +619,7 @@ impl ConnectorIntegration +impl ConnectorIntegration for Gocardless { } -impl ConnectorIntegration +impl ConnectorIntegration for Gocardless { } -impl ConnectorIntegration +impl ConnectorIntegration for Gocardless { fn get_headers( &self, - req: &types::RefundsRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &RefundsRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } @@ -647,16 +662,16 @@ impl ConnectorIntegration, - connectors: &settings::Connectors, + _req: &RefundsRouterData, + connectors: &Connectors, ) -> CustomResult { Ok(format!("{}/refunds", self.base_url(connectors))) } fn get_request_body( &self, - req: &types::RefundsRouterData, - _connectors: &settings::Connectors, + req: &RefundsRouterData, + _connectors: &Connectors, ) -> CustomResult { let connector_router_data = gocardless::GocardlessRouterData::try_from(( &self.get_currency_unit(), @@ -670,11 +685,11 @@ impl ConnectorIntegration, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { - let request = services::RequestBuilder::new() - .method(services::Method::Post) + req: &RefundsRouterData, + connectors: &Connectors, + ) -> CustomResult, 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( @@ -689,10 +704,10 @@ impl ConnectorIntegration, + data: &RefundsRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, - ) -> CustomResult, errors::ConnectorError> { + ) -> CustomResult, errors::ConnectorError> { let response: gocardless::RefundResponse = res .response .parse_struct("gocardless RefundResponse") @@ -701,7 +716,7 @@ impl ConnectorIntegration +impl ConnectorIntegration for Gocardless { fn build_request( &self, - _req: &types::RefundSyncRouterData, - _connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + _req: &RefundSyncRouterData, + _connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(None) } } #[async_trait::async_trait] -impl api::IncomingWebhook for Gocardless { +impl IncomingWebhook for Gocardless { fn get_webhook_source_verification_algorithm( &self, - _request: &api::IncomingWebhookRequestDetails<'_>, + _request: &IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { Ok(Box::new(crypto::HmacSha256)) } fn get_webhook_source_verification_signature( &self, - request: &api::IncomingWebhookRequestDetails<'_>, + request: &IncomingWebhookRequestDetails<'_>, _connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets, ) -> CustomResult, errors::ConnectorError> { let signature = request @@ -759,7 +774,7 @@ impl api::IncomingWebhook for Gocardless { fn get_webhook_source_verification_message( &self, - request: &api::IncomingWebhookRequestDetails<'_>, + request: &IncomingWebhookRequestDetails<'_>, _merchant_id: &common_utils::id_type::MerchantId, _connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets, ) -> CustomResult, errors::ConnectorError> { @@ -770,8 +785,8 @@ impl api::IncomingWebhook for Gocardless { fn get_webhook_object_reference_id( &self, - request: &api::IncomingWebhookRequestDetails<'_>, - ) -> CustomResult { + request: &IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { let details: gocardless::GocardlessWebhookEvent = request .body .parse_struct("GocardlessWebhookEvent") @@ -785,18 +800,18 @@ impl api::IncomingWebhook for Gocardless { let payment_id = api_models::payments::PaymentIdType::ConnectorTransactionId( link.payment.to_owned(), ); - api::webhooks::ObjectReferenceId::PaymentId(payment_id) + ObjectReferenceId::PaymentId(payment_id) } transformers::WebhooksLink::RefundWebhookLink(link) => { let refund_id = api_models::webhooks::RefundIdType::ConnectorRefundId(link.refund.to_owned()); - api::webhooks::ObjectReferenceId::RefundId(refund_id) + ObjectReferenceId::RefundId(refund_id) } transformers::WebhooksLink::MandateWebhookLink(link) => { let mandate_id = api_models::webhooks::MandateIdType::ConnectorMandateId( link.mandate.to_owned(), ); - api::webhooks::ObjectReferenceId::MandateId(mandate_id) + ObjectReferenceId::MandateId(mandate_id) } }; Ok(reference_id) @@ -804,8 +819,8 @@ impl api::IncomingWebhook for Gocardless { fn get_webhook_event_type( &self, - request: &api::IncomingWebhookRequestDetails<'_>, - ) -> CustomResult { + request: &IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { let details: gocardless::GocardlessWebhookEvent = request .body .parse_struct("GocardlessWebhookEvent") @@ -819,40 +834,40 @@ impl api::IncomingWebhook for Gocardless { transformers::PaymentsAction::Created | transformers::PaymentsAction::Submitted | transformers::PaymentsAction::CustomerApprovalGranted => { - api::IncomingWebhookEvent::PaymentIntentProcessing + IncomingWebhookEvent::PaymentIntentProcessing } transformers::PaymentsAction::CustomerApprovalDenied | transformers::PaymentsAction::Failed | transformers::PaymentsAction::Cancelled | transformers::PaymentsAction::LateFailureSettled => { - api::IncomingWebhookEvent::PaymentIntentFailure + IncomingWebhookEvent::PaymentIntentFailure } transformers::PaymentsAction::Confirmed | transformers::PaymentsAction::PaidOut => { - api::IncomingWebhookEvent::PaymentIntentSuccess + IncomingWebhookEvent::PaymentIntentSuccess } transformers::PaymentsAction::SurchargeFeeDebited | transformers::PaymentsAction::ResubmissionRequired => { - api::IncomingWebhookEvent::EventNotSupported + IncomingWebhookEvent::EventNotSupported } }, transformers::WebhookAction::RefundsAction(action) => match action { - transformers::RefundsAction::Failed => api::IncomingWebhookEvent::RefundFailure, - transformers::RefundsAction::Paid => api::IncomingWebhookEvent::RefundSuccess, + transformers::RefundsAction::Failed => IncomingWebhookEvent::RefundFailure, + transformers::RefundsAction::Paid => IncomingWebhookEvent::RefundSuccess, transformers::RefundsAction::RefundSettled | transformers::RefundsAction::FundsReturned | transformers::RefundsAction::Created => { - api::IncomingWebhookEvent::EventNotSupported + IncomingWebhookEvent::EventNotSupported } }, transformers::WebhookAction::MandatesAction(action) => match action { transformers::MandatesAction::Active | transformers::MandatesAction::Reinstated => { - api::IncomingWebhookEvent::MandateActive + IncomingWebhookEvent::MandateActive } transformers::MandatesAction::Expired | transformers::MandatesAction::Cancelled | transformers::MandatesAction::Failed | transformers::MandatesAction::Consumed => { - api::IncomingWebhookEvent::MandateRevoked + IncomingWebhookEvent::MandateRevoked } transformers::MandatesAction::Created | transformers::MandatesAction::CustomerApprovalGranted @@ -862,7 +877,7 @@ impl api::IncomingWebhook for Gocardless { | transformers::MandatesAction::ResubmissionRequested | transformers::MandatesAction::Replaced | transformers::MandatesAction::Blocked => { - api::IncomingWebhookEvent::EventNotSupported + IncomingWebhookEvent::EventNotSupported } }, }; @@ -871,7 +886,7 @@ impl api::IncomingWebhook for Gocardless { fn get_webhook_resource_object( &self, - request: &api::IncomingWebhookRequestDetails<'_>, + request: &IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { let details: gocardless::GocardlessWebhookEvent = request .body diff --git a/crates/router/src/connector/gocardless/transformers.rs b/crates/hyperswitch_connectors/src/connectors/gocardless/transformers.rs similarity index 79% rename from crates/router/src/connector/gocardless/transformers.rs rename to crates/hyperswitch_connectors/src/connectors/gocardless/transformers.rs index c5c34574433d..2fbedbab5eba 100644 --- a/crates/router/src/connector/gocardless/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/gocardless/transformers.rs @@ -1,23 +1,27 @@ -use api_models::{ - enums::{CountryAlpha2, UsStatesAbbreviation}, - payments::AddressDetails, -}; +use api_models::payments::AddressDetails; + +use common_enums::{enums, CountryAlpha2, UsStatesAbbreviation}; use common_utils::{ - id_type, - pii::{self, IpAddress}, + id_type, pii::{self, IpAddress} }; +use hyperswitch_domain_models::{ + payment_method_data::{BankDebitData, PaymentMethodData}, + router_data::{ConnectorAuthType, PaymentMethodToken, RouterData}, + router_flow_types::refunds::Execute, + router_request_types::{ + ConnectorCustomerData, PaymentMethodTokenizationData, PaymentsAuthorizeData, PaymentsSyncData, ResponseId, SetupMandateRequestData + }, + router_response_types::{MandateReference, PaymentsResponseData, RefundsResponseData}, + types, +}; +use hyperswitch_interfaces::{api, errors}; use masking::{ExposeInterface, Secret}; use serde::{Deserialize, Serialize}; use crate::{ - connector::utils::{ - self, AddressDetailsData, BrowserInformationData, ConnectorCustomerData, - PaymentsAuthorizeRequestData, PaymentsSetupMandateRequestData, RouterData, - }, - core::errors, - types::{ - self, api, domain, storage::enums, transformers::ForeignTryFrom, MandateReference, - ResponseId, + types::{RefundsResponseRouterData, ResponseRouterData}, + utils::{ + self, AddressDetailsData, BrowserInformationData, ForeignTryFrom, PaymentsAuthorizeRequestData, PaymentsSetupMandateRequestData, RouterData as _, CustomerData, }, }; @@ -130,25 +134,25 @@ pub struct Customers { impl TryFrom< - types::ResponseRouterData< + ResponseRouterData< F, GocardlessCustomerResponse, - types::ConnectorCustomerData, - types::PaymentsResponseData, + ConnectorCustomerData, + PaymentsResponseData, >, - > for types::RouterData + > for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData< + item: ResponseRouterData< F, GocardlessCustomerResponse, - types::ConnectorCustomerData, - types::PaymentsResponseData, + ConnectorCustomerData, + PaymentsResponseData, >, ) -> Result { Ok(Self { - response: Ok(types::PaymentsResponseData::ConnectorCustomerResponse { + response: Ok(PaymentsResponseData::ConnectorCustomerResponse { connector_customer_id: item.response.customers.id.expose(), }), ..item.data @@ -230,27 +234,27 @@ impl TryFrom<&types::TokenizationRouterData> for CustomerBankAccount { type Error = error_stack::Report; fn try_from(item: &types::TokenizationRouterData) -> Result { match &item.request.payment_method_data { - domain::PaymentMethodData::BankDebit(bank_debit_data) => { + PaymentMethodData::BankDebit(bank_debit_data) => { Self::try_from((bank_debit_data, item)) } - domain::PaymentMethodData::Card(_) - | domain::PaymentMethodData::CardRedirect(_) - | domain::PaymentMethodData::Wallet(_) - | domain::PaymentMethodData::PayLater(_) - | domain::PaymentMethodData::BankRedirect(_) - | domain::PaymentMethodData::BankTransfer(_) - | domain::PaymentMethodData::Crypto(_) - | domain::PaymentMethodData::MandatePayment - | domain::PaymentMethodData::Reward - | domain::PaymentMethodData::RealTimePayment(_) - | domain::PaymentMethodData::MobilePayment(_) - | domain::PaymentMethodData::Upi(_) - | domain::PaymentMethodData::Voucher(_) - | domain::PaymentMethodData::GiftCard(_) - | domain::PaymentMethodData::OpenBanking(_) - | domain::PaymentMethodData::CardToken(_) - | domain::PaymentMethodData::NetworkToken(_) - | domain::PaymentMethodData::CardDetailsForNetworkTransactionId(_) => { + PaymentMethodData::Card(_) + | PaymentMethodData::CardRedirect(_) + | PaymentMethodData::Wallet(_) + | PaymentMethodData::PayLater(_) + | PaymentMethodData::BankRedirect(_) + | PaymentMethodData::BankTransfer(_) + | PaymentMethodData::Crypto(_) + | PaymentMethodData::MandatePayment + | PaymentMethodData::Reward + | PaymentMethodData::RealTimePayment(_) + | PaymentMethodData::MobilePayment(_) + | PaymentMethodData::Upi(_) + | PaymentMethodData::Voucher(_) + | PaymentMethodData::GiftCard(_) + | PaymentMethodData::OpenBanking(_) + | PaymentMethodData::CardToken(_) + | PaymentMethodData::NetworkToken(_) + | PaymentMethodData::CardDetailsForNetworkTransactionId(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Gocardless"), ) @@ -260,13 +264,13 @@ impl TryFrom<&types::TokenizationRouterData> for CustomerBankAccount { } } -impl TryFrom<(&domain::BankDebitData, &types::TokenizationRouterData)> for CustomerBankAccount { +impl TryFrom<(&BankDebitData, &types::TokenizationRouterData)> for CustomerBankAccount { type Error = error_stack::Report; fn try_from( - (bank_debit_data, item): (&domain::BankDebitData, &types::TokenizationRouterData), + (bank_debit_data, item): (&BankDebitData, &types::TokenizationRouterData), ) -> Result { match bank_debit_data { - domain::BankDebitData::AchBankDebit { + BankDebitData::AchBankDebit { account_number, routing_number, bank_type, @@ -284,7 +288,7 @@ impl TryFrom<(&domain::BankDebitData, &types::TokenizationRouterData)> for Custo }; Ok(Self::USBankAccount(us_bank_account)) } - domain::BankDebitData::BecsBankDebit { + BankDebitData::BecsBankDebit { account_number, bsb_number, .. @@ -299,7 +303,7 @@ impl TryFrom<(&domain::BankDebitData, &types::TokenizationRouterData)> for Custo }; Ok(Self::AUBankAccount(au_bank_account)) } - domain::BankDebitData::SepaBankDebit { iban, .. } => { + BankDebitData::SepaBankDebit { iban, .. } => { let account_holder_name = item.get_billing_full_name()?; let international_bank_account = InternationalBankAccount { iban: iban.clone(), @@ -307,7 +311,7 @@ impl TryFrom<(&domain::BankDebitData, &types::TokenizationRouterData)> for Custo }; Ok(Self::InternationalBankAccount(international_bank_account)) } - domain::BankDebitData::BacsBankDebit { .. } => { + BankDebitData::BacsBankDebit { .. } => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Gocardless"), ) @@ -338,25 +342,25 @@ pub struct CustomerBankAccountResponse { impl TryFrom< - types::ResponseRouterData< + ResponseRouterData< F, GocardlessBankAccountResponse, - types::PaymentMethodTokenizationData, - types::PaymentsResponseData, + PaymentMethodTokenizationData, + PaymentsResponseData, >, - > for types::RouterData + > for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData< + item: ResponseRouterData< F, GocardlessBankAccountResponse, - types::PaymentMethodTokenizationData, - types::PaymentsResponseData, + PaymentMethodTokenizationData, + PaymentsResponseData, >, ) -> Result { Ok(Self { - response: Ok(types::PaymentsResponseData::TokenizationResponse { + response: Ok(PaymentsResponseData::TokenizationResponse { token: item.response.customer_bank_accounts.id.expose(), }), ..item.data @@ -400,31 +404,31 @@ impl TryFrom<&types::SetupMandateRouterData> for GocardlessMandateRequest { type Error = error_stack::Report; fn try_from(item: &types::SetupMandateRouterData) -> Result { let (scheme, payer_ip_address) = match &item.request.payment_method_data { - domain::PaymentMethodData::BankDebit(bank_debit_data) => { + PaymentMethodData::BankDebit(bank_debit_data) => { let payer_ip_address = get_ip_if_required(bank_debit_data, item)?; Ok(( GocardlessScheme::try_from(bank_debit_data)?, payer_ip_address, )) } - domain::PaymentMethodData::Card(_) - | domain::PaymentMethodData::CardRedirect(_) - | domain::PaymentMethodData::Wallet(_) - | domain::PaymentMethodData::PayLater(_) - | domain::PaymentMethodData::BankRedirect(_) - | domain::PaymentMethodData::BankTransfer(_) - | domain::PaymentMethodData::Crypto(_) - | domain::PaymentMethodData::MandatePayment - | domain::PaymentMethodData::Reward - | domain::PaymentMethodData::RealTimePayment(_) - | domain::PaymentMethodData::MobilePayment(_) - | domain::PaymentMethodData::Upi(_) - | domain::PaymentMethodData::Voucher(_) - | domain::PaymentMethodData::GiftCard(_) - | domain::PaymentMethodData::OpenBanking(_) - | domain::PaymentMethodData::CardToken(_) - | domain::PaymentMethodData::NetworkToken(_) - | domain::PaymentMethodData::CardDetailsForNetworkTransactionId(_) => { + PaymentMethodData::Card(_) + | PaymentMethodData::CardRedirect(_) + | PaymentMethodData::Wallet(_) + | PaymentMethodData::PayLater(_) + | PaymentMethodData::BankRedirect(_) + | PaymentMethodData::BankTransfer(_) + | PaymentMethodData::Crypto(_) + | PaymentMethodData::MandatePayment + | PaymentMethodData::Reward + | PaymentMethodData::RealTimePayment(_) + | PaymentMethodData::MobilePayment(_) + | PaymentMethodData::Upi(_) + | PaymentMethodData::Voucher(_) + | PaymentMethodData::GiftCard(_) + | PaymentMethodData::OpenBanking(_) + | PaymentMethodData::CardToken(_) + | PaymentMethodData::NetworkToken(_) + | PaymentMethodData::CardDetailsForNetworkTransactionId(_) => { Err(errors::ConnectorError::NotImplemented( "Setup Mandate flow for selected payment method through Gocardless".to_string(), )) @@ -432,9 +436,9 @@ impl TryFrom<&types::SetupMandateRouterData> for GocardlessMandateRequest { }?; let payment_method_token = item.get_payment_method_token()?; let customer_bank_account = match payment_method_token { - types::PaymentMethodToken::Token(token) => Ok(token), - types::PaymentMethodToken::ApplePayDecrypt(_) - | types::PaymentMethodToken::PazeDecrypt(_) => { + PaymentMethodToken::Token(token) => Ok(token), + PaymentMethodToken::ApplePayDecrypt(_) + | PaymentMethodToken::PazeDecrypt(_) => { Err(errors::ConnectorError::NotImplemented( "Setup Mandate flow for selected payment method through Gocardless".to_string(), )) @@ -456,26 +460,26 @@ impl TryFrom<&types::SetupMandateRouterData> for GocardlessMandateRequest { } fn get_ip_if_required( - bank_debit_data: &domain::BankDebitData, + bank_debit_data: &BankDebitData, item: &types::SetupMandateRouterData, ) -> Result>, error_stack::Report> { let ip_address = item.request.get_browser_info()?.get_ip_address()?; match bank_debit_data { - domain::BankDebitData::AchBankDebit { .. } => Ok(Some(ip_address)), - domain::BankDebitData::SepaBankDebit { .. } - | domain::BankDebitData::BecsBankDebit { .. } - | domain::BankDebitData::BacsBankDebit { .. } => Ok(None), + BankDebitData::AchBankDebit { .. } => Ok(Some(ip_address)), + BankDebitData::SepaBankDebit { .. } + | BankDebitData::BecsBankDebit { .. } + | BankDebitData::BacsBankDebit { .. } => Ok(None), } } -impl TryFrom<&domain::BankDebitData> for GocardlessScheme { +impl TryFrom<&BankDebitData> for GocardlessScheme { type Error = error_stack::Report; - fn try_from(item: &domain::BankDebitData) -> Result { + fn try_from(item: &BankDebitData) -> Result { match item { - domain::BankDebitData::AchBankDebit { .. } => Ok(Self::Ach), - domain::BankDebitData::SepaBankDebit { .. } => Ok(Self::SepaCore), - domain::BankDebitData::BecsBankDebit { .. } => Ok(Self::Becs), - domain::BankDebitData::BacsBankDebit { .. } => { + BankDebitData::AchBankDebit { .. } => Ok(Self::Ach), + BankDebitData::SepaBankDebit { .. } => Ok(Self::SepaCore), + BankDebitData::BecsBankDebit { .. } => Ok(Self::Becs), + BankDebitData::BacsBankDebit { .. } => { Err(errors::ConnectorError::NotImplemented( "Setup Mandate flow for selected payment method through Gocardless".to_string(), ) @@ -497,21 +501,21 @@ pub struct MandateResponse { impl TryFrom< - types::ResponseRouterData< + ResponseRouterData< F, GocardlessMandateResponse, - types::SetupMandateRequestData, - types::PaymentsResponseData, + SetupMandateRequestData, + PaymentsResponseData, >, - > for types::RouterData + > for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData< + item: ResponseRouterData< F, GocardlessMandateResponse, - types::SetupMandateRequestData, - types::PaymentsResponseData, + SetupMandateRequestData, + PaymentsResponseData, >, ) -> Result { let mandate_reference = Some(MandateReference { @@ -521,7 +525,7 @@ impl connector_mandate_request_reference_id: None, }); Ok(Self { - response: Ok(types::PaymentsResponseData::TransactionResponse { + response: Ok(PaymentsResponseData::TransactionResponse { connector_metadata: None, connector_response_reference_id: None, incremental_authorization_allowed: None, @@ -599,11 +603,11 @@ pub struct GocardlessAuthType { pub(super) access_token: Secret, } -impl TryFrom<&types::ConnectorAuthType> for GocardlessAuthType { +impl TryFrom<&ConnectorAuthType> for GocardlessAuthType { type Error = error_stack::Report; - fn try_from(auth_type: &types::ConnectorAuthType) -> Result { + fn try_from(auth_type: &ConnectorAuthType) -> Result { match auth_type { - types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self { + ConnectorAuthType::HeaderKey { api_key } => Ok(Self { access_token: api_key.to_owned(), }), _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()), @@ -651,21 +655,21 @@ pub struct PaymentResponse { impl TryFrom< - types::ResponseRouterData< + ResponseRouterData< F, GocardlessPaymentsResponse, - types::PaymentsAuthorizeData, - types::PaymentsResponseData, + PaymentsAuthorizeData, + PaymentsResponseData, >, - > for types::RouterData + > for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData< + item: ResponseRouterData< F, GocardlessPaymentsResponse, - types::PaymentsAuthorizeData, - types::PaymentsResponseData, + PaymentsAuthorizeData, + PaymentsResponseData, >, ) -> Result { let mandate_reference = MandateReference { @@ -676,7 +680,7 @@ impl }; Ok(Self { status: enums::AttemptStatus::from(item.response.payments.status), - response: Ok(types::PaymentsResponseData::TransactionResponse { + response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.payments.id), redirection_data: Box::new(None), mandate_reference: Box::new(Some(mandate_reference)), @@ -693,26 +697,26 @@ impl impl TryFrom< - types::ResponseRouterData< + ResponseRouterData< F, GocardlessPaymentsResponse, - types::PaymentsSyncData, - types::PaymentsResponseData, + PaymentsSyncData, + PaymentsResponseData, >, - > for types::RouterData + > for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData< + item: ResponseRouterData< F, GocardlessPaymentsResponse, - types::PaymentsSyncData, - types::PaymentsResponseData, + PaymentsSyncData, + PaymentsResponseData, >, ) -> Result { Ok(Self { status: enums::AttemptStatus::from(item.response.payments.status), - response: Ok(types::PaymentsResponseData::TransactionResponse { + response: Ok(PaymentsResponseData::TransactionResponse { resource_id: ResponseId::ConnectorTransactionId(item.response.payments.id), redirection_data: Box::new(None), mandate_reference: Box::new(None), @@ -774,15 +778,15 @@ pub struct RefundResponse { id: String, } -impl TryFrom> - for types::RefundsRouterData +impl TryFrom> + for types::RefundsRouterData { type Error = error_stack::Report; fn try_from( - item: types::RefundsResponseRouterData, + item: RefundsResponseRouterData, ) -> Result { Ok(Self { - response: Ok(types::RefundsResponseData { + response: Ok(RefundsResponseData { connector_refund_id: item.response.id.to_string(), refund_status: enums::RefundStatus::Pending, }), diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs index 27d0307e9ad5..e38e8de1ffee 100644 --- a/crates/hyperswitch_connectors/src/default_implementations.rs +++ b/crates/hyperswitch_connectors/src/default_implementations.rs @@ -107,7 +107,7 @@ default_imp_for_authorize_session_token!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -165,7 +165,7 @@ default_imp_for_calculate_tax!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Mollie, @@ -237,7 +237,7 @@ default_imp_for_session_update!( connectors::Payeezy, connectors::Payu, connectors::Fiuu, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Worldline, connectors::Worldpay, connectors::Zen, @@ -296,7 +296,7 @@ default_imp_for_post_session_tokens!( connectors::Payeezy, connectors::Payu, connectors::Fiuu, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Worldline, connectors::Worldpay, connectors::Powertranz, @@ -339,7 +339,7 @@ default_imp_for_complete_authorize!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Multisafepay, @@ -394,7 +394,7 @@ default_imp_for_incremental_authorization!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -512,7 +512,7 @@ default_imp_for_connector_redirect_response!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Multisafepay, @@ -625,7 +625,7 @@ default_imp_for_post_processing_steps!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -685,7 +685,7 @@ default_imp_for_approve!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -745,7 +745,7 @@ default_imp_for_reject!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -805,7 +805,7 @@ default_imp_for_webhook_source_verification!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -867,6 +867,7 @@ default_imp_for_accept_dispute!( connectors::Fiuu, connectors::Forte, connectors::Globepay, + connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -926,7 +927,7 @@ default_imp_for_submit_evidence!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -986,7 +987,7 @@ default_imp_for_defend_dispute!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Jpmorgan, connectors::Helcim, connectors::Nomupay, @@ -1055,7 +1056,7 @@ default_imp_for_file_upload!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1108,7 +1109,7 @@ default_imp_for_payouts!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Mollie, @@ -1169,7 +1170,7 @@ default_imp_for_payouts_create!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1231,7 +1232,7 @@ default_imp_for_payouts_retrieve!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1293,7 +1294,7 @@ default_imp_for_payouts_eligibility!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1355,7 +1356,7 @@ default_imp_for_payouts_fulfill!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1417,7 +1418,7 @@ default_imp_for_payouts_cancel!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1479,7 +1480,7 @@ default_imp_for_payouts_quote!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1541,7 +1542,7 @@ default_imp_for_payouts_recipient!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1603,7 +1604,7 @@ default_imp_for_payouts_recipient_account!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1665,7 +1666,7 @@ default_imp_for_frm_sale!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1727,7 +1728,7 @@ default_imp_for_frm_checkout!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1789,7 +1790,7 @@ default_imp_for_frm_transaction!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1851,7 +1852,7 @@ default_imp_for_frm_fulfillment!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1913,7 +1914,7 @@ default_imp_for_frm_record_return!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1972,7 +1973,7 @@ default_imp_for_revoking_mandates!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rs index 3fe0298f45be..8e6236a6ff34 100644 --- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs +++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs @@ -223,7 +223,7 @@ default_imp_for_new_connector_integration_payment!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -284,7 +284,7 @@ default_imp_for_new_connector_integration_refund!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -340,7 +340,7 @@ default_imp_for_new_connector_integration_connector_access_token!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -402,7 +402,7 @@ default_imp_for_new_connector_integration_accept_dispute!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -463,7 +463,7 @@ default_imp_for_new_connector_integration_submit_evidence!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -524,7 +524,7 @@ default_imp_for_new_connector_integration_defend_dispute!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -595,7 +595,7 @@ default_imp_for_new_connector_integration_file_upload!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -658,7 +658,7 @@ default_imp_for_new_connector_integration_payouts_create!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -721,7 +721,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -784,7 +784,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -847,7 +847,7 @@ default_imp_for_new_connector_integration_payouts_cancel!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -910,7 +910,7 @@ default_imp_for_new_connector_integration_payouts_quote!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -973,7 +973,7 @@ default_imp_for_new_connector_integration_payouts_recipient!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1036,7 +1036,7 @@ default_imp_for_new_connector_integration_payouts_sync!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1099,7 +1099,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1160,7 +1160,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1223,7 +1223,7 @@ default_imp_for_new_connector_integration_frm_sale!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1286,7 +1286,7 @@ default_imp_for_new_connector_integration_frm_checkout!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1349,7 +1349,7 @@ default_imp_for_new_connector_integration_frm_transaction!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1412,7 +1412,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1475,7 +1475,7 @@ default_imp_for_new_connector_integration_frm_record_return!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, @@ -1535,7 +1535,7 @@ default_imp_for_new_connector_integration_revoking_mandates!( connectors::Fiservemea, connectors::Fiuu, connectors::Forte, - connectors::Globepay, + connectors::Globepay, connectors::Gocardless, connectors::Helcim, connectors::Jpmorgan, connectors::Nomupay, diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs index d928bbfa4eb4..64fa3eef33ee 100644 --- a/crates/hyperswitch_connectors/src/utils.rs +++ b/crates/hyperswitch_connectors/src/utils.rs @@ -24,7 +24,7 @@ use hyperswitch_domain_models::{ AuthenticationData, BrowserInformation, CompleteAuthorizeData, PaymentMethodTokenizationData, PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId, - SetupMandateRequestData, + SetupMandateRequestData, ConnectorCustomerData }, types::OrderDetailsWithAmount, }; @@ -1138,6 +1138,15 @@ impl PhoneDetailsData for PhoneDetails { } } +pub trait CustomerData { + fn get_email(&self) -> Result; +} + +impl CustomerData for ConnectorCustomerData { + fn get_email(&self) -> Result { + self.email.clone().ok_or_else(missing_field_err("email")) + } +} pub trait PaymentsAuthorizeRequestData { fn get_optional_language_from_browser_info(&self) -> Option; fn is_auto_capture(&self) -> Result; diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs index 5a77b2fb7251..501d4206a339 100644 --- a/crates/router/src/connector.rs +++ b/crates/router/src/connector.rs @@ -12,7 +12,6 @@ pub mod datatrans; pub mod dummyconnector; pub mod ebanx; pub mod globalpay; -pub mod gocardless; pub mod gpayments; pub mod iatapay; pub mod itaubank; @@ -49,7 +48,7 @@ pub use hyperswitch_connectors::connectors::{ cryptopay::Cryptopay, deutschebank, deutschebank::Deutschebank, digitalvirgo, digitalvirgo::Digitalvirgo, dlocal, dlocal::Dlocal, elavon, elavon::Elavon, fiserv, fiserv::Fiserv, fiservemea, fiservemea::Fiservemea, fiuu, fiuu::Fiuu, forte, forte::Forte, - globepay, globepay::Globepay, helcim, helcim::Helcim, jpmorgan, jpmorgan::Jpmorgan, mollie, + globepay, globepay::Globepay, gocardless, gocardless::Gocardless, helcim, helcim::Helcim, jpmorgan, jpmorgan::Jpmorgan, mollie, mollie::Mollie, multisafepay, multisafepay::Multisafepay, nexinets, nexinets::Nexinets, nexixpay, nexixpay::Nexixpay, nomupay, nomupay::Nomupay, novalnet, novalnet::Novalnet, payeezy, payeezy::Payeezy, payu, payu::Payu, powertranz, powertranz::Powertranz, razorpay, @@ -64,7 +63,7 @@ pub use self::{ aci::Aci, adyen::Adyen, adyenplatform::Adyenplatform, authorizedotnet::Authorizedotnet, bankofamerica::Bankofamerica, bluesnap::Bluesnap, braintree::Braintree, checkout::Checkout, cybersource::Cybersource, datatrans::Datatrans, ebanx::Ebanx, - globalpay::Globalpay, gocardless::Gocardless, gpayments::Gpayments, iatapay::Iatapay, + globalpay::Globalpay, gpayments::Gpayments, iatapay::Iatapay, itaubank::Itaubank, klarna::Klarna, mifinity::Mifinity, netcetera::Netcetera, nmi::Nmi, noon::Noon, nuvei::Nuvei, opayo::Opayo, opennode::Opennode, paybox::Paybox, payme::Payme, payone::Payone, paypal::Paypal, placetopay::Placetopay, plaid::Plaid, prophetpay::Prophetpay, diff --git a/crates/router/src/core/payments/connector_integration_v2_impls.rs b/crates/router/src/core/payments/connector_integration_v2_impls.rs index 7b1c093e350c..ecdb0161e256 100644 --- a/crates/router/src/core/payments/connector_integration_v2_impls.rs +++ b/crates/router/src/core/payments/connector_integration_v2_impls.rs @@ -702,7 +702,7 @@ default_imp_for_new_connector_integration_payment!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -761,7 +761,7 @@ default_imp_for_new_connector_integration_refund!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -814,7 +814,7 @@ default_imp_for_new_connector_integration_connector_access_token!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -889,7 +889,6 @@ default_imp_for_new_connector_integration_accept_dispute!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -946,7 +945,7 @@ default_imp_for_new_connector_integration_defend_dispute!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -987,7 +986,7 @@ default_imp_for_new_connector_integration_submit_evidence!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1055,7 +1054,7 @@ default_imp_for_new_connector_integration_file_upload!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1124,7 +1123,6 @@ default_imp_for_new_connector_integration_payouts!( connector::Forte, connector::Globalpay, connector::Globepay, - connector::Gocardless, connector::Gpayments, connector::Helcim, connector::Iatapay, @@ -1206,7 +1204,7 @@ default_imp_for_new_connector_integration_payouts_create!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1266,7 +1264,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1326,7 +1324,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1386,7 +1384,7 @@ default_imp_for_new_connector_integration_payouts_cancel!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1446,7 +1444,7 @@ default_imp_for_new_connector_integration_payouts_quote!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1506,7 +1504,7 @@ default_imp_for_new_connector_integration_payouts_recipient!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1566,7 +1564,7 @@ default_imp_for_new_connector_integration_payouts_sync!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1626,7 +1624,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1684,7 +1682,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1753,7 +1751,6 @@ default_imp_for_new_connector_integration_frm!( connector::Fiuu, connector::Globalpay, connector::Globepay, - connector::Gocardless, connector::Gpayments, connector::Helcim, connector::Iatapay, @@ -1835,7 +1832,7 @@ default_imp_for_new_connector_integration_frm_sale!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1895,7 +1892,7 @@ default_imp_for_new_connector_integration_frm_checkout!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1955,7 +1952,7 @@ default_imp_for_new_connector_integration_frm_transaction!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -2015,7 +2012,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -2075,7 +2072,7 @@ default_imp_for_new_connector_integration_frm_record_return!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -2132,7 +2129,7 @@ default_imp_for_new_connector_integration_revoking_mandates!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs index 366fe13b191b..2351404b6a89 100644 --- a/crates/router/src/core/payments/flows.rs +++ b/crates/router/src/core/payments/flows.rs @@ -211,7 +211,7 @@ default_imp_for_complete_authorize!( connector::Checkout, connector::Datatrans, connector::Ebanx, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -273,7 +273,7 @@ default_imp_for_webhook_source_verification!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -407,7 +407,6 @@ default_imp_for_connector_redirect_response!( connector::Cybersource, connector::Datatrans, connector::Ebanx, - connector::Gocardless, connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -563,7 +562,6 @@ default_imp_for_accept_dispute!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -653,7 +651,7 @@ default_imp_for_file_upload!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -720,7 +718,7 @@ default_imp_for_submit_evidence!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -787,7 +785,7 @@ default_imp_for_defend_dispute!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -910,7 +908,7 @@ default_imp_for_post_processing_steps!( connector::Adyen, connector::Bankofamerica, connector::Cybersource, - connector::Gocardless, + connector::Nmi, connector::Nuvei, connector::Payme, @@ -967,7 +965,7 @@ default_imp_for_payouts!( connector::Checkout, connector::Datatrans, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1032,7 +1030,7 @@ default_imp_for_payouts_create!( connector::Cybersource, connector::Datatrans, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1100,7 +1098,7 @@ default_imp_for_payouts_retrieve!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1171,7 +1169,7 @@ default_imp_for_payouts_eligibility!( connector::Cybersource, connector::Datatrans, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1237,7 +1235,7 @@ default_imp_for_payouts_fulfill!( connector::Checkout, connector::Datatrans, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1302,7 +1300,7 @@ default_imp_for_payouts_cancel!( connector::Cybersource, connector::Datatrans, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1370,7 +1368,7 @@ default_imp_for_payouts_quote!( connector::Cybersource, connector::Datatrans, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1439,7 +1437,7 @@ default_imp_for_payouts_recipient!( connector::Cybersource, connector::Datatrans, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1511,7 +1509,7 @@ default_imp_for_payouts_recipient_account!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1580,7 +1578,7 @@ default_imp_for_approve!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1650,7 +1648,7 @@ default_imp_for_reject!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1815,7 +1813,7 @@ default_imp_for_frm_sale!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1885,7 +1883,7 @@ default_imp_for_frm_checkout!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -1955,7 +1953,7 @@ default_imp_for_frm_transaction!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -2025,7 +2023,7 @@ default_imp_for_frm_fulfillment!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -2095,7 +2093,7 @@ default_imp_for_frm_record_return!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -2162,7 +2160,7 @@ default_imp_for_incremental_authorization!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -2228,7 +2226,7 @@ default_imp_for_revoking_mandates!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -2459,7 +2457,7 @@ default_imp_for_authorize_session_token!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -2526,7 +2524,7 @@ default_imp_for_calculate_tax!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -2594,7 +2592,7 @@ default_imp_for_session_update!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, @@ -2661,7 +2659,7 @@ default_imp_for_post_session_tokens!( connector::Datatrans, connector::Ebanx, connector::Globalpay, - connector::Gocardless, + connector::Gpayments, connector::Iatapay, connector::Itaubank, From 6fbb36d5f9876724ab76eb117aaac7e50abcbb57 Mon Sep 17 00:00:00 2001 From: Spriti Aneja Date: Thu, 28 Nov 2024 17:18:11 +0530 Subject: [PATCH 4/6] Moved prophetpay to hyperswitch_connector crate --- .../hyperswitch_connectors/src/connectors.rs | 8 +- .../src/connectors/gocardless.rs | 130 +++----- .../src/connectors/gocardless/transformers.rs | 40 +-- .../src/connectors}/prophetpay.rs | 311 +++++++++--------- .../connectors}/prophetpay/transformers.rs | 144 ++++---- .../src/default_implementations.rs | 118 +++++-- .../src/default_implementations_v2.rs | 88 +++-- crates/hyperswitch_connectors/src/utils.rs | 4 +- crates/router/src/connector.rs | 29 +- .../connector_integration_v2_impls.rs | 45 --- crates/router/src/core/payments/flows.rs | 59 ---- 11 files changed, 456 insertions(+), 520 deletions(-) rename crates/{router/src/connector => hyperswitch_connectors/src/connectors}/prophetpay.rs (69%) rename crates/{router/src/connector => hyperswitch_connectors/src/connectors}/prophetpay/transformers.rs (83%) diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs index 61bf9db40e34..37adce862ad9 100644 --- a/crates/hyperswitch_connectors/src/connectors.rs +++ b/crates/hyperswitch_connectors/src/connectors.rs @@ -29,6 +29,7 @@ pub mod novalnet; pub mod payeezy; pub mod payu; pub mod powertranz; +pub mod prophetpay; pub mod razorpay; pub mod shift4; pub mod square; @@ -49,7 +50,8 @@ pub use self::{ elavon::Elavon, fiserv::Fiserv, fiservemea::Fiservemea, fiuu::Fiuu, forte::Forte, globepay::Globepay, gocardless::Gocardless, helcim::Helcim, jpmorgan::Jpmorgan, mollie::Mollie, multisafepay::Multisafepay, nexinets::Nexinets, nexixpay::Nexixpay, nomupay::Nomupay, - novalnet::Novalnet, payeezy::Payeezy, payu::Payu, powertranz::Powertranz, razorpay::Razorpay, - shift4::Shift4, square::Square, stax::Stax, taxjar::Taxjar, thunes::Thunes, tsys::Tsys, - volt::Volt, worldline::Worldline, worldpay::Worldpay, zen::Zen, zsl::Zsl, + novalnet::Novalnet, payeezy::Payeezy, payu::Payu, powertranz::Powertranz, + prophetpay::Prophetpay, razorpay::Razorpay, shift4::Shift4, square::Square, stax::Stax, + taxjar::Taxjar, thunes::Thunes, tsys::Tsys, volt::Volt, worldline::Worldline, + worldpay::Worldpay, zen::Zen, zsl::Zsl, }; diff --git a/crates/hyperswitch_connectors/src/connectors/gocardless.rs b/crates/hyperswitch_connectors/src/connectors/gocardless.rs index 376b4686e57b..becc8749b5d5 100644 --- a/crates/hyperswitch_connectors/src/connectors/gocardless.rs +++ b/crates/hyperswitch_connectors/src/connectors/gocardless.rs @@ -5,32 +5,38 @@ use std::fmt::Debug; use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId}; use common_enums::enums; use common_utils::{ - crypto, errors::CustomResult, ext_traits::{ByteSliceExt, BytesExt}, request::{Method, Request, RequestBuilder, RequestContent} + crypto, + errors::CustomResult, + ext_traits::{ByteSliceExt, BytesExt}, + request::{Method, Request, RequestBuilder, RequestContent}, }; use error_stack::ResultExt; use hyperswitch_domain_models::{ - payment_method_data::PaymentMethodData, router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData}, router_flow_types::{ + payment_method_data::PaymentMethodData, + router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData}, + router_flow_types::{ access_token_auth::AccessTokenAuth, payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void}, - refunds::{Execute, RSync}, CreateConnectorCustomer, PreProcessing, - }, router_request_types::{ - AccessTokenRequestData, ConnectorCustomerData, PaymentMethodTokenizationData, PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsPreProcessingData, PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData - }, router_response_types::{PaymentsResponseData, RefundsResponseData}, types::{ - ConnectorCustomerRouterData, PaymentsAuthorizeRouterData, PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData, SetupMandateRouterData, TokenizationRouterData - } + refunds::{Execute, RSync}, + CreateConnectorCustomer, PreProcessing, + }, + router_request_types::{ + AccessTokenRequestData, ConnectorCustomerData, PaymentMethodTokenizationData, + PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsPreProcessingData, + PaymentsSessionData, PaymentsSyncData, RefundsData, SetupMandateRequestData, + }, + router_response_types::{PaymentsResponseData, RefundsResponseData}, + types::{ + ConnectorCustomerRouterData, PaymentsAuthorizeRouterData, PaymentsSyncRouterData, + RefundSyncRouterData, RefundsRouterData, SetupMandateRouterData, TokenizationRouterData, + }, }; use hyperswitch_interfaces::{ - api::{ - self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, - ConnectorValidation, - }, + api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, configs::Connectors, errors, events::connector_api_logs::ConnectorEvent, - types::{ - self, - PaymentsSyncType,Response, - }, + types::{self, PaymentsSyncType, Response}, webhooks::{IncomingWebhook, IncomingWebhookRequestDetails}, }; use masking::{Mask, PeekInterface}; @@ -149,12 +155,8 @@ impl ConnectorCommon for Gocardless { } } -impl - ConnectorIntegration< - CreateConnectorCustomer, - ConnectorCustomerData, - PaymentsResponseData, - > for Gocardless +impl ConnectorIntegration + for Gocardless { fn get_headers( &self, @@ -209,11 +211,7 @@ impl event_builder: Option<&mut ConnectorEvent>, res: Response, ) -> CustomResult< - RouterData< - CreateConnectorCustomer, - ConnectorCustomerData, - PaymentsResponseData, - >, + RouterData, errors::ConnectorError, > where @@ -245,12 +243,8 @@ impl } } -impl - ConnectorIntegration< - PaymentMethodToken, - PaymentMethodTokenizationData, - PaymentsResponseData, - > for Gocardless +impl ConnectorIntegration + for Gocardless { fn get_headers( &self, @@ -333,12 +327,8 @@ impl } } -impl - ConnectorIntegration< - PreProcessing, - PaymentsPreProcessingData, - PaymentsResponseData, - > for Gocardless +impl ConnectorIntegration + for Gocardless { } @@ -353,9 +343,10 @@ impl ConnectorValidation for Gocardless { enums::CaptureMethod::Automatic => Ok(()), enums::CaptureMethod::Manual | enums::CaptureMethod::ManualMultiple - | enums::CaptureMethod::Scheduled => Err( - construct_not_implemented_error_report(capture_method, self.id()), - ), + | enums::CaptureMethod::Scheduled => Err(construct_not_implemented_error_report( + capture_method, + self.id(), + )), } } fn validate_mandate_payment( @@ -373,23 +364,14 @@ impl ConnectorValidation for Gocardless { } } -impl ConnectorIntegration - for Gocardless -{ +impl ConnectorIntegration for Gocardless { //TODO: implement sessions flow } -impl ConnectorIntegration - for Gocardless -{ -} +impl ConnectorIntegration for Gocardless {} -impl - ConnectorIntegration< - SetupMandate, - SetupMandateRequestData, - PaymentsResponseData, - > for Gocardless +impl ConnectorIntegration + for Gocardless { fn get_headers( &self, @@ -469,9 +451,7 @@ impl } } -impl ConnectorIntegration - for Gocardless -{ +impl ConnectorIntegration for Gocardless { fn get_headers( &self, req: &PaymentsAuthorizeRouterData, @@ -560,9 +540,7 @@ impl ConnectorIntegration - for Gocardless -{ +impl ConnectorIntegration for Gocardless { fn get_headers( &self, req: &PaymentsSyncRouterData, @@ -635,19 +613,11 @@ impl ConnectorIntegration } } -impl ConnectorIntegration - for Gocardless -{ -} +impl ConnectorIntegration for Gocardless {} -impl ConnectorIntegration - for Gocardless -{ -} +impl ConnectorIntegration for Gocardless {} -impl ConnectorIntegration - for Gocardless -{ +impl ConnectorIntegration for Gocardless { fn get_headers( &self, req: &RefundsRouterData, @@ -732,9 +702,7 @@ impl ConnectorIntegration } } -impl ConnectorIntegration - for Gocardless -{ +impl ConnectorIntegration for Gocardless { fn build_request( &self, _req: &RefundSyncRouterData, @@ -855,9 +823,7 @@ impl IncomingWebhook for Gocardless { transformers::RefundsAction::Paid => IncomingWebhookEvent::RefundSuccess, transformers::RefundsAction::RefundSettled | transformers::RefundsAction::FundsReturned - | transformers::RefundsAction::Created => { - IncomingWebhookEvent::EventNotSupported - } + | transformers::RefundsAction::Created => IncomingWebhookEvent::EventNotSupported, }, transformers::WebhookAction::MandatesAction(action) => match action { transformers::MandatesAction::Active | transformers::MandatesAction::Reinstated => { @@ -866,9 +832,7 @@ impl IncomingWebhook for Gocardless { transformers::MandatesAction::Expired | transformers::MandatesAction::Cancelled | transformers::MandatesAction::Failed - | transformers::MandatesAction::Consumed => { - IncomingWebhookEvent::MandateRevoked - } + | transformers::MandatesAction::Consumed => IncomingWebhookEvent::MandateRevoked, transformers::MandatesAction::Created | transformers::MandatesAction::CustomerApprovalGranted | transformers::MandatesAction::CustomerApprovalSkipped @@ -876,9 +840,7 @@ impl IncomingWebhook for Gocardless { | transformers::MandatesAction::Submitted | transformers::MandatesAction::ResubmissionRequested | transformers::MandatesAction::Replaced - | transformers::MandatesAction::Blocked => { - IncomingWebhookEvent::EventNotSupported - } + | transformers::MandatesAction::Blocked => IncomingWebhookEvent::EventNotSupported, }, }; Ok(event_type) diff --git a/crates/hyperswitch_connectors/src/connectors/gocardless/transformers.rs b/crates/hyperswitch_connectors/src/connectors/gocardless/transformers.rs index 2fbedbab5eba..1468fad2a490 100644 --- a/crates/hyperswitch_connectors/src/connectors/gocardless/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/gocardless/transformers.rs @@ -1,15 +1,16 @@ use api_models::payments::AddressDetails; - use common_enums::{enums, CountryAlpha2, UsStatesAbbreviation}; use common_utils::{ - id_type, pii::{self, IpAddress} + id_type, + pii::{self, IpAddress}, }; use hyperswitch_domain_models::{ payment_method_data::{BankDebitData, PaymentMethodData}, router_data::{ConnectorAuthType, PaymentMethodToken, RouterData}, router_flow_types::refunds::Execute, router_request_types::{ - ConnectorCustomerData, PaymentMethodTokenizationData, PaymentsAuthorizeData, PaymentsSyncData, ResponseId, SetupMandateRequestData + ConnectorCustomerData, PaymentMethodTokenizationData, PaymentsAuthorizeData, + PaymentsSyncData, ResponseId, SetupMandateRequestData, }, router_response_types::{MandateReference, PaymentsResponseData, RefundsResponseData}, types, @@ -21,7 +22,8 @@ use serde::{Deserialize, Serialize}; use crate::{ types::{RefundsResponseRouterData, ResponseRouterData}, utils::{ - self, AddressDetailsData, BrowserInformationData, ForeignTryFrom, PaymentsAuthorizeRequestData, PaymentsSetupMandateRequestData, RouterData as _, CustomerData, + self, AddressDetailsData, BrowserInformationData, CustomerData, ForeignTryFrom, + PaymentsAuthorizeRequestData, PaymentsSetupMandateRequestData, RouterData as _, }, }; @@ -311,12 +313,10 @@ impl TryFrom<(&BankDebitData, &types::TokenizationRouterData)> for CustomerBankA }; Ok(Self::InternationalBankAccount(international_bank_account)) } - BankDebitData::BacsBankDebit { .. } => { - Err(errors::ConnectorError::NotImplemented( - utils::get_unimplemented_payment_method_error_message("Gocardless"), - ) - .into()) - } + BankDebitData::BacsBankDebit { .. } => Err(errors::ConnectorError::NotImplemented( + utils::get_unimplemented_payment_method_error_message("Gocardless"), + ) + .into()), } } } @@ -437,8 +437,7 @@ impl TryFrom<&types::SetupMandateRouterData> for GocardlessMandateRequest { let payment_method_token = item.get_payment_method_token()?; let customer_bank_account = match payment_method_token { PaymentMethodToken::Token(token) => Ok(token), - PaymentMethodToken::ApplePayDecrypt(_) - | PaymentMethodToken::PazeDecrypt(_) => { + PaymentMethodToken::ApplePayDecrypt(_) | PaymentMethodToken::PazeDecrypt(_) => { Err(errors::ConnectorError::NotImplemented( "Setup Mandate flow for selected payment method through Gocardless".to_string(), )) @@ -479,12 +478,10 @@ impl TryFrom<&BankDebitData> for GocardlessScheme { BankDebitData::AchBankDebit { .. } => Ok(Self::Ach), BankDebitData::SepaBankDebit { .. } => Ok(Self::SepaCore), BankDebitData::BecsBankDebit { .. } => Ok(Self::Becs), - BankDebitData::BacsBankDebit { .. } => { - Err(errors::ConnectorError::NotImplemented( - "Setup Mandate flow for selected payment method through Gocardless".to_string(), - ) - .into()) - } + BankDebitData::BacsBankDebit { .. } => Err(errors::ConnectorError::NotImplemented( + "Setup Mandate flow for selected payment method through Gocardless".to_string(), + ) + .into()), } } } @@ -697,12 +694,7 @@ impl impl TryFrom< - ResponseRouterData< - F, - GocardlessPaymentsResponse, - PaymentsSyncData, - PaymentsResponseData, - >, + ResponseRouterData, > for RouterData { type Error = error_stack::Report; diff --git a/crates/router/src/connector/prophetpay.rs b/crates/hyperswitch_connectors/src/connectors/prophetpay.rs similarity index 69% rename from crates/router/src/connector/prophetpay.rs rename to crates/hyperswitch_connectors/src/connectors/prophetpay.rs index ef49e716d9a8..b6e16fc23579 100644 --- a/crates/router/src/connector/prophetpay.rs +++ b/crates/hyperswitch_connectors/src/connectors/prophetpay.rs @@ -2,30 +2,47 @@ pub mod transformers; use std::fmt::Debug; +use api_models::webhooks::{IncomingWebhookEvent, ObjectReferenceId}; use base64::Engine; -use common_utils::request::RequestContent; +use common_utils::{ + consts::BASE64_ENGINE, + errors::CustomResult, + ext_traits::BytesExt, + request::{Method, Request, RequestBuilder, RequestContent}, +}; use error_stack::{report, ResultExt}; -use masking::PeekInterface; -use transformers as prophetpay; - -use crate::{ - configs::settings, - consts, - core::errors::{self, CustomResult}, - events::connector_api_logs::ConnectorEvent, - headers, - services::{ - self, - request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, +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}, + CompleteAuthorize, + }, + router_request_types::{ + AccessTokenRequestData, CompleteAuthorizeData, PaymentMethodTokenizationData, + PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, + PaymentsSyncData, RefundsData, SetupMandateRequestData, }, + router_response_types::{PaymentsResponseData, RefundsResponseData}, types::{ - self, - api::{self, ConnectorCommon, ConnectorCommonExt}, - ErrorResponse, Response, + PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCompleteAuthorizeRouterData, + PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData, }, - utils::BytesExt, }; +use hyperswitch_interfaces::{ + api::{self, ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation}, + configs::Connectors, + consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE}, + errors, + events::connector_api_logs::ConnectorEvent, + types::{self, Response}, + webhooks::{IncomingWebhook, IncomingWebhookRequestDetails}, +}; +use masking::{Mask, PeekInterface}; +use transformers as prophetpay; + +use crate::{constants::headers, types::ResponseRouterData}; #[derive(Debug, Clone)] pub struct Prophetpay; @@ -43,12 +60,8 @@ impl api::RefundSync for Prophetpay {} impl api::PaymentToken for Prophetpay {} impl api::payments::PaymentsCompleteAuthorize for Prophetpay {} -impl - ConnectorIntegration< - api::PaymentMethodToken, - types::PaymentMethodTokenizationData, - types::PaymentsResponseData, - > for Prophetpay +impl ConnectorIntegration + for Prophetpay { // Not Implemented (R) } @@ -59,9 +72,9 @@ where { fn build_headers( &self, - req: &types::RouterData, - _connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &RouterData, + _connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { let mut header = vec![( headers::CONTENT_TYPE.to_string(), self.get_content_type().to_string().into(), @@ -85,19 +98,19 @@ impl ConnectorCommon for Prophetpay { "application/json" } - fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str { + fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str { connectors.prophetpay.base_url.as_ref() } fn get_auth_header( &self, - auth_type: &types::ConnectorAuthType, - ) -> CustomResult)>, errors::ConnectorError> { + auth_type: &ConnectorAuthType, + ) -> CustomResult)>, errors::ConnectorError> { let auth = prophetpay::ProphetpayAuthType::try_from(auth_type) .change_context(errors::ConnectorError::FailedToObtainAuthType)?; let auth_val = format!("{}:{}", auth.user_name.peek(), auth.password.peek()); - let basic_token = format!("Basic {}", consts::BASE64_ENGINE.encode(auth_val)); + let basic_token = format!("Basic {}", BASE64_ENGINE.encode(auth_val)); Ok(vec![( headers::AUTHORIZATION.to_string(), @@ -120,8 +133,8 @@ impl ConnectorCommon for Prophetpay { Ok(ErrorResponse { status_code: res.status_code, - code: consts::NO_ERROR_CODE.to_string(), - message: consts::NO_ERROR_MESSAGE.to_string(), + code: NO_ERROR_CODE.to_string(), + message: NO_ERROR_MESSAGE.to_string(), reason: Some(response.to_string()), attempt_status: None, connector_transaction_id: None, @@ -133,33 +146,20 @@ impl ConnectorValidation for Prophetpay { //TODO: implement functions when support enabled } -impl ConnectorIntegration - for Prophetpay -{ +impl ConnectorIntegration for Prophetpay { //TODO: implement sessions flow } -impl ConnectorIntegration - for Prophetpay -{ -} +impl ConnectorIntegration for Prophetpay {} -impl - ConnectorIntegration< - api::SetupMandate, - types::SetupMandateRequestData, - types::PaymentsResponseData, - > for Prophetpay +impl ConnectorIntegration + for Prophetpay { fn build_request( &self, - _req: &types::RouterData< - api::SetupMandate, - types::SetupMandateRequestData, - types::PaymentsResponseData, - >, - _connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + _req: &RouterData, + _connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Err( errors::ConnectorError::NotImplemented("Setup Mandate flow for Prophetpay".to_string()) .into(), @@ -167,14 +167,12 @@ impl } } -impl ConnectorIntegration - for Prophetpay -{ +impl ConnectorIntegration for Prophetpay { fn get_headers( &self, - req: &types::PaymentsAuthorizeRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } @@ -184,8 +182,8 @@ impl ConnectorIntegration CustomResult { Ok(format!( "{}hp/api/HostedTokenize/CreateHostedTokenize", @@ -195,8 +193,8 @@ impl ConnectorIntegration CustomResult { let connector_router_data = prophetpay::ProphetpayRouterData::try_from(( &self.get_currency_unit(), @@ -211,12 +209,12 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) + RequestBuilder::new() + .method(Method::Post) .url(&types::PaymentsAuthorizeType::get_url( self, req, connectors, )?) @@ -233,12 +231,12 @@ impl ConnectorIntegration, res: Response, - ) -> CustomResult + ) -> CustomResult where - types::PaymentsResponseData: Clone, + PaymentsResponseData: Clone, { let response: prophetpay::ProphetpayTokenResponse = res .response @@ -248,7 +246,7 @@ impl ConnectorIntegration for Prophetpay +impl ConnectorIntegration + for Prophetpay { fn get_headers( &self, - req: &types::PaymentsCompleteAuthorizeRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &PaymentsCompleteAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } @@ -285,8 +279,8 @@ impl fn get_url( &self, - _req: &types::PaymentsCompleteAuthorizeRouterData, - connectors: &settings::Connectors, + _req: &PaymentsCompleteAuthorizeRouterData, + connectors: &Connectors, ) -> CustomResult { Ok(format!( "{}hp/api/Transactions/ProcessTransaction", @@ -296,8 +290,8 @@ impl fn get_request_body( &self, - req: &types::PaymentsCompleteAuthorizeRouterData, - _connectors: &settings::Connectors, + req: &PaymentsCompleteAuthorizeRouterData, + _connectors: &Connectors, ) -> CustomResult { let connector_router_data = prophetpay::ProphetpayRouterData::try_from(( &self.get_currency_unit(), @@ -313,12 +307,12 @@ impl fn build_request( &self, - req: &types::PaymentsCompleteAuthorizeRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + req: &PaymentsCompleteAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) + RequestBuilder::new() + .method(Method::Post) .url(&types::PaymentsCompleteAuthorizeType::get_url( self, req, connectors, )?) @@ -335,12 +329,12 @@ impl fn handle_response( &self, - data: &types::PaymentsCompleteAuthorizeRouterData, + data: &PaymentsCompleteAuthorizeRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, - ) -> CustomResult + ) -> CustomResult where - types::PaymentsResponseData: Clone, + PaymentsResponseData: Clone, { let response: prophetpay::ProphetpayCompleteAuthResponse = res .response @@ -350,7 +344,7 @@ impl event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { + RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, @@ -366,14 +360,12 @@ impl } } -impl ConnectorIntegration - for Prophetpay -{ +impl ConnectorIntegration for Prophetpay { fn get_headers( &self, - req: &types::PaymentsSyncRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &PaymentsSyncRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } @@ -383,8 +375,8 @@ impl ConnectorIntegration CustomResult { Ok(format!( "{}hp/api/Transactions/ProcessTransaction", @@ -394,8 +386,8 @@ impl ConnectorIntegration CustomResult { let connector_req = prophetpay::ProphetpaySyncRequest::try_from(req)?; @@ -404,12 +396,12 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + req: &PaymentsSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) + RequestBuilder::new() + .method(Method::Post) .url(&types::PaymentsSyncType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?) @@ -422,10 +414,10 @@ impl ConnectorIntegration, res: Response, - ) -> CustomResult { + ) -> CustomResult { let response: prophetpay::ProphetpaySyncResponse = res .response .parse_struct("prophetpay PaymentsSyncResponse") @@ -434,7 +426,7 @@ impl ConnectorIntegration - for Prophetpay -{ -} +impl ConnectorIntegration for Prophetpay {} // This is Void Implementation for Prophetpay // Since Prophetpay does not have capture this have been commented out but kept if it is required for future usage -impl ConnectorIntegration - for Prophetpay -{ +impl ConnectorIntegration for Prophetpay { /* fn get_headers( &self, @@ -497,9 +484,9 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + _req: &PaymentsCancelRouterData, + _connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Err(errors::ConnectorError::NotImplemented("Void flow not implemented".to_string()).into()) } @@ -530,14 +517,12 @@ impl ConnectorIntegration - for Prophetpay -{ +impl ConnectorIntegration for Prophetpay { fn get_headers( &self, - req: &types::RefundsRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &RefundsRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } @@ -547,8 +532,8 @@ impl ConnectorIntegration, - connectors: &settings::Connectors, + _req: &RefundsRouterData, + connectors: &Connectors, ) -> CustomResult { Ok(format!( "{}hp/api/Transactions/ProcessTransaction", @@ -558,8 +543,8 @@ impl ConnectorIntegration, - _connectors: &settings::Connectors, + req: &RefundsRouterData, + _connectors: &Connectors, ) -> CustomResult { let connector_router_data = prophetpay::ProphetpayRouterData::try_from(( &self.get_currency_unit(), @@ -573,11 +558,11 @@ impl ConnectorIntegration, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { - let request = services::RequestBuilder::new() - .method(services::Method::Post) + req: &RefundsRouterData, + connectors: &Connectors, + ) -> CustomResult, 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( @@ -592,10 +577,10 @@ impl ConnectorIntegration, + data: &RefundsRouterData, event_builder: Option<&mut ConnectorEvent>, res: Response, - ) -> CustomResult, errors::ConnectorError> { + ) -> CustomResult, errors::ConnectorError> { let response: prophetpay::ProphetpayRefundResponse = res .response .parse_struct("prophetpay ProphetpayRefundResponse") @@ -604,7 +589,7 @@ impl ConnectorIntegration - for Prophetpay -{ +impl ConnectorIntegration for Prophetpay { fn get_headers( &self, - req: &types::RefundSyncRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &RefundSyncRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } @@ -637,8 +620,8 @@ impl ConnectorIntegration CustomResult { Ok(format!( "{}hp/api/Transactions/ProcessTransaction", @@ -648,8 +631,8 @@ impl ConnectorIntegration CustomResult { let connector_req = prophetpay::ProphetpayRefundSyncRequest::try_from(req)?; @@ -658,12 +641,12 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + req: &RefundSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) + RequestBuilder::new() + .method(Method::Post) .url(&types::RefundSyncType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::RefundSyncType::get_headers(self, req, connectors)?) @@ -676,10 +659,10 @@ impl ConnectorIntegration, res: Response, - ) -> CustomResult { + ) -> CustomResult { let response: prophetpay::ProphetpayRefundSyncResponse = res .response .parse_struct("prophetpay ProphetpayRefundResponse") @@ -688,7 +671,7 @@ impl ConnectorIntegration, - ) -> CustomResult { + _request: &IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, - _request: &api::IncomingWebhookRequestDetails<'_>, - ) -> CustomResult { + _request: &IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_resource_object( &self, - _request: &api::IncomingWebhookRequestDetails<'_>, + _request: &IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } diff --git a/crates/router/src/connector/prophetpay/transformers.rs b/crates/hyperswitch_connectors/src/connectors/prophetpay/transformers.rs similarity index 83% rename from crates/router/src/connector/prophetpay/transformers.rs rename to crates/hyperswitch_connectors/src/connectors/prophetpay/transformers.rs index 24bd4642c019..53f902ff4956 100644 --- a/crates/router/src/connector/prophetpay/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/prophetpay/transformers.rs @@ -1,17 +1,30 @@ use std::collections::HashMap; -use common_utils::{consts, errors::CustomResult}; +use common_enums::enums; +use common_utils::{ + consts::{PROPHETPAY_REDIRECT_URL, PROPHETPAY_TOKEN}, + errors::CustomResult, + request::Method, +}; use error_stack::ResultExt; +use hyperswitch_domain_models::{ + payment_method_data::{CardRedirectData, PaymentMethodData}, + router_data::{ConnectorAuthType, ErrorResponse, RouterData}, + router_flow_types::refunds::Execute, + router_request_types::{ + CompleteAuthorizeData, CompleteAuthorizeRedirectResponse, PaymentsAuthorizeData, ResponseId, + }, + router_response_types::{PaymentsResponseData, RedirectForm, RefundsResponseData}, + types, +}; +use hyperswitch_interfaces::{api, consts::NO_ERROR_CODE, errors}; use masking::{ExposeInterface, PeekInterface, Secret}; use serde::{Deserialize, Serialize}; use url::Url; use crate::{ - connector::utils::{self, to_connector_meta}, - consts as const_val, - core::errors, - services, - types::{self, api, domain, storage::enums}, + types::{RefundsResponseRouterData, ResponseRouterData}, + utils::{self, to_connector_meta}, }; pub struct ProphetpayRouterData { @@ -38,11 +51,11 @@ pub struct ProphetpayAuthType { pub(super) profile_id: Secret, } -impl TryFrom<&types::ConnectorAuthType> for ProphetpayAuthType { +impl TryFrom<&ConnectorAuthType> for ProphetpayAuthType { type Error = error_stack::Report; - fn try_from(auth_type: &types::ConnectorAuthType) -> Result { + fn try_from(auth_type: &ConnectorAuthType) -> Result { match auth_type { - types::ConnectorAuthType::SignatureKey { + ConnectorAuthType::SignatureKey { api_key, key1, api_secret, @@ -124,9 +137,7 @@ impl TryFrom<&ProphetpayRouterData<&types::PaymentsAuthorizeRouterData>> ) -> Result { if item.router_data.request.currency == api_models::enums::Currency::USD { match item.router_data.request.payment_method_data.clone() { - domain::PaymentMethodData::CardRedirect( - domain::payments::CardRedirectData::CardRedirect {}, - ) => { + PaymentMethodData::CardRedirect(CardRedirectData::CardRedirect {}) => { let auth_data = ProphetpayAuthType::try_from(&item.router_data.connector_auth_type)?; Ok(Self { @@ -165,26 +176,21 @@ pub struct ProphetpayTokenResponse { impl TryFrom< - types::ResponseRouterData< - F, - ProphetpayTokenResponse, - types::PaymentsAuthorizeData, - types::PaymentsResponseData, - >, - > for types::RouterData + ResponseRouterData, + > for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData< + item: ResponseRouterData< F, ProphetpayTokenResponse, - types::PaymentsAuthorizeData, - types::PaymentsResponseData, + PaymentsAuthorizeData, + PaymentsResponseData, >, ) -> Result { let url_data = format!( "{}{}", - consts::PROPHETPAY_REDIRECT_URL, + PROPHETPAY_REDIRECT_URL, item.response.hosted_tokenize_id.expose() ); @@ -199,8 +205,8 @@ impl Ok(Self { status: enums::AttemptStatus::AuthenticationPending, - response: Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::NoResponseId, + response: Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::NoResponseId, redirection_data: Box::new(redirection_data), mandate_reference: Box::new(None), connector_metadata: None, @@ -217,7 +223,7 @@ impl fn get_redirect_url_form( mut redirect_url: Url, complete_auth_url: Option, -) -> CustomResult { +) -> CustomResult { let mut form_fields = HashMap::::new(); form_fields.insert( @@ -230,9 +236,9 @@ fn get_redirect_url_form( // Do not include query params in the endpoint redirect_url.set_query(None); - Ok(services::RedirectForm::Form { + Ok(RedirectForm::Form { endpoint: redirect_url.to_string(), - method: services::Method::Get, + method: Method::Get, form_fields, }) } @@ -271,7 +277,7 @@ impl TryFrom<&ProphetpayRouterData<&types::PaymentsCompleteAuthorizeRouterData>> } fn get_card_token( - response: Option, + response: Option, ) -> CustomResult { let res = response.ok_or(errors::ConnectorError::MissingRequiredField { field_name: "redirect_response", @@ -298,7 +304,7 @@ fn get_card_token( .ok_or(errors::ConnectorError::ResponseDeserializationFailed)?; for (key, val) in queries_params { - if key.as_str() == consts::PROPHETPAY_TOKEN { + if key.as_str() == PROPHETPAY_TOKEN { return Ok(val); } } @@ -372,21 +378,21 @@ pub struct ProphetpayCardTokenData { impl TryFrom< - types::ResponseRouterData< + ResponseRouterData< F, ProphetpayCompleteAuthResponse, - types::CompleteAuthorizeData, - types::PaymentsResponseData, + CompleteAuthorizeData, + PaymentsResponseData, >, - > for types::RouterData + > for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData< + item: ResponseRouterData< F, ProphetpayCompleteAuthResponse, - types::CompleteAuthorizeData, - types::PaymentsResponseData, + CompleteAuthorizeData, + PaymentsResponseData, >, ) -> Result { if item.response.success { @@ -397,10 +403,8 @@ impl let connector_metadata = serde_json::to_value(card_token_data).ok(); Ok(Self { status: enums::AttemptStatus::Charged, - response: Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId( - item.response.transaction_id, - ), + response: Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::ConnectorTransactionId(item.response.transaction_id), redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata, @@ -414,7 +418,7 @@ impl } else { Ok(Self { status: enums::AttemptStatus::Failure, - response: Err(types::ErrorResponse { + response: Err(ErrorResponse { code: item.response.response_code, message: item.response.response_text.clone(), reason: Some(item.response.response_text), @@ -437,21 +441,18 @@ pub struct ProphetpaySyncResponse { pub transaction_id: String, } -impl - TryFrom> - for types::RouterData +impl TryFrom> + for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData, + item: ResponseRouterData, ) -> Result { if item.response.success { Ok(Self { status: enums::AttemptStatus::Charged, - response: Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId( - item.response.transaction_id, - ), + response: Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::ConnectorTransactionId(item.response.transaction_id), redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata: None, @@ -465,8 +466,8 @@ impl } else { Ok(Self { status: enums::AttemptStatus::Failure, - response: Err(types::ErrorResponse { - code: const_val::NO_ERROR_CODE.to_string(), + response: Err(ErrorResponse { + code: NO_ERROR_CODE.to_string(), message: item.response.response_text.clone(), reason: Some(item.response.response_text), status_code: item.http_code, @@ -488,21 +489,18 @@ pub struct ProphetpayVoidResponse { pub transaction_id: String, } -impl - TryFrom> - for types::RouterData +impl TryFrom> + for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData, + item: ResponseRouterData, ) -> Result { if item.response.success { Ok(Self { status: enums::AttemptStatus::Voided, - response: Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId( - item.response.transaction_id, - ), + response: Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::ConnectorTransactionId(item.response.transaction_id), redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata: None, @@ -516,8 +514,8 @@ impl } else { Ok(Self { status: enums::AttemptStatus::VoidFailed, - response: Err(types::ErrorResponse { - code: const_val::NO_ERROR_CODE.to_string(), + response: Err(ErrorResponse { + code: NO_ERROR_CODE.to_string(), message: item.response.response_text.clone(), reason: Some(item.response.response_text), status_code: item.http_code, @@ -601,16 +599,16 @@ pub struct ProphetpayRefundResponse { pub tran_seq_number: Option, } -impl TryFrom> - for types::RefundsRouterData +impl TryFrom> + for types::RefundsRouterData { type Error = error_stack::Report; fn try_from( - item: types::RefundsResponseRouterData, + item: RefundsResponseRouterData, ) -> Result { if item.response.success { Ok(Self { - response: Ok(types::RefundsResponseData { + response: Ok(RefundsResponseData { // no refund id is generated, tranSeqNumber is kept for future usage connector_refund_id: item.response.tran_seq_number.ok_or( errors::ConnectorError::MissingRequiredField { @@ -624,8 +622,8 @@ impl TryFrom TryFrom> +impl TryFrom> for types::RefundsRouterData { type Error = error_stack::Report; fn try_from( - item: types::RefundsResponseRouterData, + item: RefundsResponseRouterData, ) -> Result { if item.response.success { Ok(Self { - response: Ok(types::RefundsResponseData { + response: Ok(RefundsResponseData { // no refund id is generated, rather transaction id is used for referring to status in refund also connector_refund_id: item.data.request.connector_transaction_id.clone(), refund_status: enums::RefundStatus::Success, @@ -664,8 +662,8 @@ impl TryFrom Date: Fri, 29 Nov 2024 16:11:31 +0530 Subject: [PATCH 5/6] Moved Rapyd to hyperswitch_connector crate --- .../hyperswitch_connectors/src/connectors.rs | 5 +- .../src/connectors}/rapyd.rs | 380 ++++++++---------- .../src/connectors}/rapyd/transformers.rs | 127 +++--- .../src/default_implementations.rs | 32 ++ .../src/default_implementations_v2.rs | 22 + crates/router/src/connector.rs | 11 +- crates/router/src/consts.rs | 3 - .../connector_integration_v2_impls.rs | 22 - crates/router/src/core/payments/flows.rs | 32 -- 9 files changed, 293 insertions(+), 341 deletions(-) rename crates/{router/src/connector => hyperswitch_connectors/src/connectors}/rapyd.rs (76%) rename crates/{router/src/connector => hyperswitch_connectors/src/connectors}/rapyd/transformers.rs (82%) diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs index 37adce862ad9..9b0508ddf704 100644 --- a/crates/hyperswitch_connectors/src/connectors.rs +++ b/crates/hyperswitch_connectors/src/connectors.rs @@ -30,6 +30,7 @@ pub mod payeezy; pub mod payu; pub mod powertranz; pub mod prophetpay; +pub mod rapyd; pub mod razorpay; pub mod shift4; pub mod square; @@ -51,7 +52,7 @@ pub use self::{ globepay::Globepay, gocardless::Gocardless, helcim::Helcim, jpmorgan::Jpmorgan, mollie::Mollie, multisafepay::Multisafepay, nexinets::Nexinets, nexixpay::Nexixpay, nomupay::Nomupay, novalnet::Novalnet, payeezy::Payeezy, payu::Payu, powertranz::Powertranz, - prophetpay::Prophetpay, razorpay::Razorpay, shift4::Shift4, square::Square, stax::Stax, - taxjar::Taxjar, thunes::Thunes, tsys::Tsys, volt::Volt, worldline::Worldline, + prophetpay::Prophetpay, rapyd::Rapyd, razorpay::Razorpay, shift4::Shift4, square::Square, + stax::Stax, taxjar::Taxjar, thunes::Thunes, tsys::Tsys, volt::Volt, worldline::Worldline, worldpay::Worldpay, zen::Zen, zsl::Zsl, }; diff --git a/crates/router/src/connector/rapyd.rs b/crates/hyperswitch_connectors/src/connectors/rapyd.rs similarity index 76% rename from crates/router/src/connector/rapyd.rs rename to crates/hyperswitch_connectors/src/connectors/rapyd.rs index 64c3fcdf5a1b..ef12952ee118 100644 --- a/crates/router/src/connector/rapyd.rs +++ b/crates/hyperswitch_connectors/src/connectors/rapyd.rs @@ -1,38 +1,54 @@ pub mod transformers; +use api_models::webhooks::IncomingWebhookEvent; use base64::Engine; +use common_enums::enums; use common_utils::{ - date_time, - ext_traits::{Encode, StringExt}, - request::RequestContent, + consts::BASE64_ENGINE_URL_SAFE, + crypto, date_time, + errors::CustomResult, + ext_traits::{ByteSliceExt, BytesExt, Encode, StringExt}, + request::{Method, Request, RequestBuilder, RequestContent}, types::{AmountConvertor, MinorUnit, MinorUnitForConnector}, }; -use diesel_models::enums; use error_stack::{Report, ResultExt}; -use masking::{ExposeInterface, PeekInterface, Secret}; +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, PaymentsCancelRouterData, PaymentsCaptureRouterData, + PaymentsSyncRouterData, RefundSyncRouterData, RefundsRouterData, + }, +}; +use hyperswitch_interfaces::{ + api::{self, ConnectorCommon, ConnectorIntegration, ConnectorValidation}, + configs::Connectors, + disputes::DisputePayload, + errors, + events::connector_api_logs::ConnectorEvent, + types::{self, Response}, + webhooks::{IncomingWebhook, IncomingWebhookRequestDetails}, +}; +use masking::{ExposeInterface, Mask, PeekInterface, Secret}; use rand::distributions::{Alphanumeric, DistString}; use ring::hmac; +use router_env::logger; use transformers as rapyd; -use super::utils as connector_utils; use crate::{ - configs::settings, - connector::utils::convert_amount, - consts, - core::errors::{self, CustomResult}, - events::connector_api_logs::ConnectorEvent, - headers, logger, - services::{ - self, - request::{self, Mask}, - ConnectorValidation, - }, - types::{ - self, - api::{self, ConnectorCommon}, - ErrorResponse, - }, - utils::{self, crypto, ByteSliceExt, BytesExt}, + constants::headers, + types::ResponseRouterData, + utils::{self, construct_not_supported_error_report, convert_amount, get_header_key_value}, }; #[derive(Clone)] @@ -68,7 +84,7 @@ impl Rapyd { let key = hmac::Key::new(hmac::HMAC_SHA256, secret_key.peek().as_bytes()); let tag = hmac::sign(&key, to_sign.as_bytes()); let hmac_sign = hex::encode(tag); - let signature_value = consts::BASE64_ENGINE_URL_SAFE.encode(hmac_sign); + let signature_value = BASE64_ENGINE_URL_SAFE.encode(hmac_sign); Ok(signature_value) } } @@ -86,20 +102,20 @@ impl ConnectorCommon for Rapyd { "application/json" } - fn base_url<'a>(&self, connectors: &'a settings::Connectors) -> &'a str { + fn base_url<'a>(&self, connectors: &'a Connectors) -> &'a str { connectors.rapyd.base_url.as_ref() } fn get_auth_header( &self, - _auth_type: &types::ConnectorAuthType, - ) -> CustomResult)>, errors::ConnectorError> { + _auth_type: &ConnectorAuthType, + ) -> CustomResult)>, errors::ConnectorError> { Ok(vec![]) } fn build_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult { let response: Result< @@ -139,7 +155,7 @@ impl ConnectorValidation for Rapyd { match capture_method { enums::CaptureMethod::Automatic | enums::CaptureMethod::Manual => Ok(()), enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err( - connector_utils::construct_not_supported_error_report(capture_method, self.id()), + construct_not_supported_error_report(capture_method, self.id()), ), } } @@ -149,39 +165,22 @@ impl api::ConnectorAccessToken for Rapyd {} impl api::PaymentToken for Rapyd {} -impl - services::ConnectorIntegration< - api::PaymentMethodToken, - types::PaymentMethodTokenizationData, - types::PaymentsResponseData, - > for Rapyd +impl ConnectorIntegration + for Rapyd { // Not Implemented (R) } -impl - services::ConnectorIntegration< - api::AccessTokenAuth, - types::AccessTokenRequestData, - types::AccessToken, - > for Rapyd -{ -} +impl ConnectorIntegration for Rapyd {} impl api::PaymentAuthorize for Rapyd {} -impl - services::ConnectorIntegration< - api::Authorize, - types::PaymentsAuthorizeData, - types::PaymentsResponseData, - > for Rapyd -{ +impl ConnectorIntegration for Rapyd { fn get_headers( &self, - _req: &types::PaymentsAuthorizeRouterData, - _connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + _req: &PaymentsAuthorizeRouterData, + _connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { Ok(vec![( headers::CONTENT_TYPE.to_string(), types::PaymentsAuthorizeType::get_content_type(self) @@ -196,16 +195,16 @@ impl fn get_url( &self, - _req: &types::PaymentsAuthorizeRouterData, - connectors: &settings::Connectors, + _req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, ) -> CustomResult { Ok(format!("{}/v1/payments", self.base_url(connectors))) } fn get_request_body( &self, - req: &types::PaymentsAuthorizeRouterData, - _connectors: &settings::Connectors, + req: &PaymentsAuthorizeRouterData, + _connectors: &Connectors, ) -> CustomResult { let amount = convert_amount( self.amount_converter, @@ -219,13 +218,9 @@ impl fn build_request( &self, - req: &types::RouterData< - api::Authorize, - types::PaymentsAuthorizeData, - types::PaymentsResponseData, - >, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + req: &RouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { let timestamp = date_time::now_unix_timestamp(); let salt = Alphanumeric.sample_string(&mut rand::thread_rng(), 12); @@ -240,8 +235,8 @@ impl ("timestamp".to_string(), timestamp.to_string().into()), ("signature".to_string(), signature.into_masked()), ]; - let request = services::RequestBuilder::new() - .method(services::Method::Post) + let request = RequestBuilder::new() + .method(Method::Post) .url(&types::PaymentsAuthorizeType::get_url( self, req, connectors, )?) @@ -259,17 +254,17 @@ impl fn handle_response( &self, - data: &types::PaymentsAuthorizeRouterData, + data: &PaymentsAuthorizeRouterData, event_builder: Option<&mut ConnectorEvent>, - res: types::Response, - ) -> CustomResult { + res: Response, + ) -> CustomResult { let response: rapyd::RapydPaymentsResponse = res .response .parse_struct("Rapyd PaymentResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { + RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, @@ -279,7 +274,7 @@ impl fn get_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult { self.build_error_response(res, event_builder) @@ -289,22 +284,12 @@ impl impl api::Payment for Rapyd {} impl api::MandateSetup for Rapyd {} -impl - services::ConnectorIntegration< - api::SetupMandate, - types::SetupMandateRequestData, - types::PaymentsResponseData, - > for Rapyd -{ +impl ConnectorIntegration for Rapyd { fn build_request( &self, - _req: &types::RouterData< - api::SetupMandate, - types::SetupMandateRequestData, - types::PaymentsResponseData, - >, - _connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + _req: &RouterData, + _connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Err( errors::ConnectorError::NotImplemented("Setup Mandate flow for Rapyd".to_string()) .into(), @@ -314,18 +299,12 @@ impl impl api::PaymentVoid for Rapyd {} -impl - services::ConnectorIntegration< - api::Void, - types::PaymentsCancelData, - types::PaymentsResponseData, - > for Rapyd -{ +impl ConnectorIntegration for Rapyd { fn get_headers( &self, - _req: &types::PaymentsCancelRouterData, - _connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + _req: &PaymentsCancelRouterData, + _connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { Ok(vec![( headers::CONTENT_TYPE.to_string(), types::PaymentsVoidType::get_content_type(self) @@ -340,8 +319,8 @@ impl fn get_url( &self, - req: &types::PaymentsCancelRouterData, - connectors: &settings::Connectors, + req: &PaymentsCancelRouterData, + connectors: &Connectors, ) -> CustomResult { Ok(format!( "{}/v1/payments/{}", @@ -352,9 +331,9 @@ impl fn build_request( &self, - req: &types::PaymentsCancelRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + req: &PaymentsCancelRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { let timestamp = date_time::now_unix_timestamp(); let salt = Alphanumeric.sample_string(&mut rand::thread_rng(), 12); @@ -369,8 +348,8 @@ impl ("timestamp".to_string(), timestamp.to_string().into()), ("signature".to_string(), signature.into_masked()), ]; - let request = services::RequestBuilder::new() - .method(services::Method::Delete) + let request = RequestBuilder::new() + .method(Method::Delete) .url(&types::PaymentsVoidType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::PaymentsVoidType::get_headers(self, req, connectors)?) @@ -381,17 +360,17 @@ impl fn handle_response( &self, - data: &types::PaymentsCancelRouterData, + data: &PaymentsCancelRouterData, event_builder: Option<&mut ConnectorEvent>, - res: types::Response, - ) -> CustomResult { + res: Response, + ) -> CustomResult { let response: rapyd::RapydPaymentsResponse = res .response .parse_struct("Rapyd PaymentResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { + RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, @@ -401,7 +380,7 @@ impl fn get_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult { self.build_error_response(res, event_builder) @@ -409,15 +388,12 @@ impl } impl api::PaymentSync for Rapyd {} -impl - services::ConnectorIntegration - for Rapyd -{ +impl ConnectorIntegration for Rapyd { fn get_headers( &self, - _req: &types::PaymentsSyncRouterData, - _connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + _req: &PaymentsSyncRouterData, + _connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { Ok(vec![( headers::CONTENT_TYPE.to_string(), types::PaymentsSyncType::get_content_type(self) @@ -432,8 +408,8 @@ impl fn get_url( &self, - req: &types::PaymentsSyncRouterData, - connectors: &settings::Connectors, + req: &PaymentsSyncRouterData, + connectors: &Connectors, ) -> CustomResult { let id = req.request.connector_transaction_id.clone(); Ok(format!( @@ -446,9 +422,9 @@ impl fn build_request( &self, - req: &types::PaymentsSyncRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + req: &PaymentsSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { let timestamp = date_time::now_unix_timestamp(); let salt = Alphanumeric.sample_string(&mut rand::thread_rng(), 12); @@ -468,8 +444,8 @@ impl ("timestamp".to_string(), timestamp.to_string().into()), ("signature".to_string(), signature.into_masked()), ]; - let request = services::RequestBuilder::new() - .method(services::Method::Get) + let request = RequestBuilder::new() + .method(Method::Get) .url(&types::PaymentsSyncType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?) @@ -480,7 +456,7 @@ impl fn get_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult { self.build_error_response(res, event_builder) @@ -488,17 +464,17 @@ impl fn handle_response( &self, - data: &types::PaymentsSyncRouterData, + data: &PaymentsSyncRouterData, event_builder: Option<&mut ConnectorEvent>, - res: types::Response, - ) -> CustomResult { + res: Response, + ) -> CustomResult { let response: rapyd::RapydPaymentsResponse = res .response .parse_struct("Rapyd PaymentResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { + RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, @@ -508,18 +484,12 @@ impl } impl api::PaymentCapture for Rapyd {} -impl - services::ConnectorIntegration< - api::Capture, - types::PaymentsCaptureData, - types::PaymentsResponseData, - > for Rapyd -{ +impl ConnectorIntegration for Rapyd { fn get_headers( &self, - _req: &types::PaymentsCaptureRouterData, - _connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + _req: &PaymentsCaptureRouterData, + _connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { Ok(vec![( headers::CONTENT_TYPE.to_string(), types::PaymentsCaptureType::get_content_type(self) @@ -534,8 +504,8 @@ impl fn get_request_body( &self, - req: &types::PaymentsCaptureRouterData, - _connectors: &settings::Connectors, + req: &PaymentsCaptureRouterData, + _connectors: &Connectors, ) -> CustomResult { let amount = convert_amount( self.amount_converter, @@ -549,9 +519,9 @@ impl fn build_request( &self, - req: &types::PaymentsCaptureRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + req: &PaymentsCaptureRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { let timestamp = date_time::now_unix_timestamp(); let salt = Alphanumeric.sample_string(&mut rand::thread_rng(), 12); @@ -570,8 +540,8 @@ impl ("timestamp".to_string(), timestamp.to_string().into()), ("signature".to_string(), signature.into_masked()), ]; - let request = services::RequestBuilder::new() - .method(services::Method::Post) + let request = RequestBuilder::new() + .method(Method::Post) .url(&types::PaymentsCaptureType::get_url(self, req, connectors)?) .attach_default_headers() .headers(types::PaymentsCaptureType::get_headers( @@ -587,10 +557,10 @@ impl fn handle_response( &self, - data: &types::PaymentsCaptureRouterData, + data: &PaymentsCaptureRouterData, event_builder: Option<&mut ConnectorEvent>, - res: types::Response, - ) -> CustomResult { + res: Response, + ) -> CustomResult { let response: rapyd::RapydPaymentsResponse = res .response .parse_struct("RapydPaymentResponse") @@ -599,7 +569,7 @@ impl event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { + RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, @@ -609,8 +579,8 @@ impl fn get_url( &self, - req: &types::PaymentsCaptureRouterData, - connectors: &settings::Connectors, + req: &PaymentsCaptureRouterData, + connectors: &Connectors, ) -> CustomResult { Ok(format!( "{}/v1/payments/{}/capture", @@ -621,7 +591,7 @@ impl fn get_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, ) -> CustomResult { self.build_error_response(res, event_builder) @@ -630,13 +600,7 @@ impl impl api::PaymentSession for Rapyd {} -impl - services::ConnectorIntegration< - api::Session, - types::PaymentsSessionData, - types::PaymentsResponseData, - > for Rapyd -{ +impl ConnectorIntegration for Rapyd { //TODO: implement sessions flow } @@ -644,14 +608,12 @@ impl api::Refund for Rapyd {} impl api::RefundExecute for Rapyd {} impl api::RefundSync for Rapyd {} -impl services::ConnectorIntegration - for Rapyd -{ +impl ConnectorIntegration for Rapyd { fn get_headers( &self, - _req: &types::RefundsRouterData, - _connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + _req: &RefundsRouterData, + _connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { Ok(vec![( headers::CONTENT_TYPE.to_string(), types::RefundExecuteType::get_content_type(self) @@ -666,16 +628,16 @@ impl services::ConnectorIntegration, - connectors: &settings::Connectors, + _req: &RefundsRouterData, + connectors: &Connectors, ) -> CustomResult { Ok(format!("{}/v1/refunds", self.base_url(connectors))) } fn get_request_body( &self, - req: &types::RefundsRouterData, - _connectors: &settings::Connectors, + req: &RefundsRouterData, + _connectors: &Connectors, ) -> CustomResult { let amount = convert_amount( self.amount_converter, @@ -690,9 +652,9 @@ impl services::ConnectorIntegration, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + req: &RefundsRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { let timestamp = date_time::now_unix_timestamp(); let salt = Alphanumeric.sample_string(&mut rand::thread_rng(), 12); @@ -707,8 +669,8 @@ impl services::ConnectorIntegration, + data: &RefundsRouterData, event_builder: Option<&mut ConnectorEvent>, - res: types::Response, - ) -> CustomResult, errors::ConnectorError> { + res: Response, + ) -> CustomResult, errors::ConnectorError> { let response: rapyd::RefundResponse = res .response .parse_struct("rapyd RefundResponse") .change_context(errors::ConnectorError::RequestEncodingFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { + RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, @@ -741,30 +703,28 @@ impl services::ConnectorIntegration, ) -> CustomResult { self.build_error_response(res, event_builder) } } -impl services::ConnectorIntegration - for Rapyd -{ +impl ConnectorIntegration for Rapyd { // default implementation of build_request method will be executed fn handle_response( &self, - data: &types::RefundSyncRouterData, + data: &RefundSyncRouterData, event_builder: Option<&mut ConnectorEvent>, - res: types::Response, - ) -> CustomResult { + res: Response, + ) -> CustomResult { let response: rapyd::RefundResponse = res .response .parse_struct("rapyd RefundResponse") .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::RouterData::try_from(types::ResponseRouterData { + RouterData::try_from(ResponseRouterData { response, data: data.clone(), http_code: res.status_code, @@ -774,21 +734,21 @@ impl services::ConnectorIntegration, + _request: &IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { Ok(Box::new(crypto::HmacSha256)) } fn get_webhook_source_verification_signature( &self, - request: &api::IncomingWebhookRequestDetails<'_>, + request: &IncomingWebhookRequestDetails<'_>, _connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets, ) -> CustomResult, errors::ConnectorError> { - let base64_signature = connector_utils::get_header_key_value("signature", request.headers)?; - let signature = consts::BASE64_ENGINE_URL_SAFE + let base64_signature = get_header_key_value("signature", request.headers)?; + let signature = BASE64_ENGINE_URL_SAFE .decode(base64_signature.as_bytes()) .change_context(errors::ConnectorError::WebhookSourceVerificationFailed)?; Ok(signature) @@ -796,18 +756,18 @@ impl api::IncomingWebhook for Rapyd { fn get_webhook_source_verification_message( &self, - request: &api::IncomingWebhookRequestDetails<'_>, + request: &IncomingWebhookRequestDetails<'_>, merchant_id: &common_utils::id_type::MerchantId, connector_webhook_secrets: &api_models::webhooks::ConnectorWebhookSecrets, ) -> CustomResult, errors::ConnectorError> { - let host = connector_utils::get_header_key_value("host", request.headers)?; + let host = get_header_key_value("host", request.headers)?; let connector = self.id(); let url_path = format!( "https://{host}/webhooks/{}/{connector}", merchant_id.get_string_repr() ); - let salt = connector_utils::get_header_key_value("salt", request.headers)?; - let timestamp = connector_utils::get_header_key_value("timestamp", request.headers)?; + let salt = get_header_key_value("salt", request.headers)?; + let timestamp = get_header_key_value("timestamp", request.headers)?; let stringify_auth = String::from_utf8(connector_webhook_secrets.secret.to_vec()) .change_context(errors::ConnectorError::WebhookSourceVerificationFailed) .attach_printable("Could not convert secret to UTF-8")?; @@ -830,7 +790,7 @@ impl api::IncomingWebhook for Rapyd { async fn verify_webhook_source( &self, - request: &api::IncomingWebhookRequestDetails<'_>, + request: &IncomingWebhookRequestDetails<'_>, merchant_id: &common_utils::id_type::MerchantId, connector_webhook_details: Option, _connector_account_details: crypto::Encryptable>, @@ -870,7 +830,7 @@ impl api::IncomingWebhook for Rapyd { fn get_webhook_object_reference_id( &self, - request: &api::IncomingWebhookRequestDetails<'_>, + request: &IncomingWebhookRequestDetails<'_>, ) -> CustomResult { let webhook: transformers::RapydIncomingWebhook = request .body @@ -900,8 +860,8 @@ impl api::IncomingWebhook for Rapyd { fn get_webhook_event_type( &self, - request: &api::IncomingWebhookRequestDetails<'_>, - ) -> CustomResult { + request: &IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { let webhook: transformers::RapydIncomingWebhook = request .body .parse_struct("RapydIncomingWebhook") @@ -909,34 +869,32 @@ impl api::IncomingWebhook for Rapyd { Ok(match webhook.webhook_type { rapyd::RapydWebhookObjectEventType::PaymentCompleted | rapyd::RapydWebhookObjectEventType::PaymentCaptured => { - api::IncomingWebhookEvent::PaymentIntentSuccess + IncomingWebhookEvent::PaymentIntentSuccess } rapyd::RapydWebhookObjectEventType::PaymentFailed => { - api::IncomingWebhookEvent::PaymentIntentFailure + IncomingWebhookEvent::PaymentIntentFailure } rapyd::RapydWebhookObjectEventType::PaymentRefundFailed | rapyd::RapydWebhookObjectEventType::PaymentRefundRejected => { - api::IncomingWebhookEvent::RefundFailure + IncomingWebhookEvent::RefundFailure } rapyd::RapydWebhookObjectEventType::RefundCompleted => { - api::IncomingWebhookEvent::RefundSuccess + IncomingWebhookEvent::RefundSuccess } rapyd::RapydWebhookObjectEventType::PaymentDisputeCreated => { - api::IncomingWebhookEvent::DisputeOpened - } - rapyd::RapydWebhookObjectEventType::Unknown => { - api::IncomingWebhookEvent::EventNotSupported + IncomingWebhookEvent::DisputeOpened } + rapyd::RapydWebhookObjectEventType::Unknown => IncomingWebhookEvent::EventNotSupported, rapyd::RapydWebhookObjectEventType::PaymentDisputeUpdated => match webhook.data { - rapyd::WebhookData::Dispute(data) => api::IncomingWebhookEvent::from(data.status), - _ => api::IncomingWebhookEvent::EventNotSupported, + rapyd::WebhookData::Dispute(data) => IncomingWebhookEvent::from(data.status), + _ => IncomingWebhookEvent::EventNotSupported, }, }) } fn get_webhook_resource_object( &self, - request: &api::IncomingWebhookRequestDetails<'_>, + request: &IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { let webhook: transformers::RapydIncomingWebhook = request .body @@ -962,8 +920,8 @@ impl api::IncomingWebhook for Rapyd { fn get_dispute_details( &self, - request: &api::IncomingWebhookRequestDetails<'_>, - ) -> CustomResult { + request: &IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { let webhook: transformers::RapydIncomingWebhook = request .body .parse_struct("RapydIncomingWebhook") @@ -972,7 +930,7 @@ impl api::IncomingWebhook for Rapyd { transformers::WebhookData::Dispute(dispute_data) => Ok(dispute_data), _ => Err(errors::ConnectorError::WebhookBodyDecodingFailed), }?; - Ok(api::disputes::DisputePayload { + Ok(DisputePayload { amount: webhook_dispute_data.amount.to_string(), currency: webhook_dispute_data.currency, dispute_stage: api_models::enums::DisputeStage::Dispute, diff --git a/crates/router/src/connector/rapyd/transformers.rs b/crates/hyperswitch_connectors/src/connectors/rapyd/transformers.rs similarity index 82% rename from crates/router/src/connector/rapyd/transformers.rs rename to crates/hyperswitch_connectors/src/connectors/rapyd/transformers.rs index b83ffcec4124..d376fe72eb0c 100644 --- a/crates/router/src/connector/rapyd/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/rapyd/transformers.rs @@ -1,17 +1,23 @@ -use common_utils::types::MinorUnit; +use common_enums::enums; +use common_utils::{ext_traits::OptionExt, request::Method, types::MinorUnit}; use error_stack::ResultExt; +use hyperswitch_domain_models::{ + payment_method_data::{PaymentMethodData, WalletData}, + router_data::{ConnectorAuthType, ErrorResponse, RouterData}, + router_flow_types::refunds::{Execute, RSync}, + router_request_types::ResponseId, + router_response_types::{PaymentsResponseData, RedirectForm, RefundsResponseData}, + types, +}; +use hyperswitch_interfaces::{consts::NO_ERROR_CODE, errors}; +use masking::Secret; use serde::{Deserialize, Serialize}; use time::PrimitiveDateTime; use url::Url; use crate::{ - connector::utils::{PaymentsAuthorizeRequestData, RouterData}, - consts, - core::errors, - pii::Secret, - services, - types::{self, api, domain, storage::enums, transformers::ForeignFrom}, - utils::OptionExt, + types::{RefundsResponseRouterData, ResponseRouterData}, + utils::{PaymentsAuthorizeRequestData, RouterData as _}, }; #[derive(Debug, Serialize)] @@ -92,7 +98,7 @@ impl TryFrom<&RapydRouterData<&types::PaymentsAuthorizeRouterData>> for RapydPay item: &RapydRouterData<&types::PaymentsAuthorizeRouterData>, ) -> Result { let (capture, payment_method_options) = match item.router_data.payment_method { - diesel_models::enums::PaymentMethod::Card => { + enums::PaymentMethod::Card => { let three_ds_enabled = matches!( item.router_data.auth_type, enums::AuthenticationType::ThreeDs @@ -111,7 +117,7 @@ impl TryFrom<&RapydRouterData<&types::PaymentsAuthorizeRouterData>> for RapydPay _ => (None, None), }; let payment_method = match item.router_data.request.payment_method_data { - domain::PaymentMethodData::Card(ref ccard) => { + PaymentMethodData::Card(ref ccard) => { Some(PaymentMethod { pm_type: "in_amex_card".to_owned(), //[#369] Map payment method type based on country fields: Some(PaymentFields { @@ -129,13 +135,13 @@ impl TryFrom<&RapydRouterData<&types::PaymentsAuthorizeRouterData>> for RapydPay digital_wallet: None, }) } - domain::PaymentMethodData::Wallet(ref wallet_data) => { + PaymentMethodData::Wallet(ref wallet_data) => { let digital_wallet = match wallet_data { - domain::WalletData::GooglePay(data) => Some(RapydWallet { + WalletData::GooglePay(data) => Some(RapydWallet { payment_type: "google_pay".to_string(), token: Some(Secret::new(data.tokenization_data.token.to_owned())), }), - domain::WalletData::ApplePay(data) => Some(RapydWallet { + WalletData::ApplePay(data) => Some(RapydWallet { payment_type: "apple_pay".to_string(), token: Some(Secret::new(data.payment_data.to_string())), }), @@ -175,10 +181,10 @@ pub struct RapydAuthType { pub secret_key: Secret, } -impl TryFrom<&types::ConnectorAuthType> for RapydAuthType { +impl TryFrom<&ConnectorAuthType> for RapydAuthType { type Error = error_stack::Report; - fn try_from(auth_type: &types::ConnectorAuthType) -> Result { - if let types::ConnectorAuthType::BodyKey { api_key, key1 } = auth_type { + fn try_from(auth_type: &ConnectorAuthType) -> Result { + if let ConnectorAuthType::BodyKey { api_key, key1 } = auth_type { Ok(Self { access_key: api_key.to_owned(), secret_key: key1.to_owned(), @@ -209,30 +215,28 @@ pub enum RapydPaymentStatus { New, } -impl ForeignFrom<(RapydPaymentStatus, NextAction)> for enums::AttemptStatus { - fn foreign_from(item: (RapydPaymentStatus, NextAction)) -> Self { - let (status, next_action) = item; - match (status, next_action) { - (RapydPaymentStatus::Closed, _) => Self::Charged, - ( - RapydPaymentStatus::Active, - NextAction::ThreedsVerification | NextAction::PendingConfirmation, - ) => Self::AuthenticationPending, - ( - RapydPaymentStatus::Active, - NextAction::PendingCapture | NextAction::NotApplicable, - ) => Self::Authorized, - ( - RapydPaymentStatus::CanceledByClientOrBank - | RapydPaymentStatus::Expired - | RapydPaymentStatus::ReversedByRapyd, - _, - ) => Self::Voided, - (RapydPaymentStatus::Error, _) => Self::Failure, - (RapydPaymentStatus::New, _) => Self::Authorizing, +// impl ForeignFrom<(RapydPaymentStatus, NextAction)> for enums::AttemptStatus { +fn get_status(status: RapydPaymentStatus, next_action: NextAction) -> enums::AttemptStatus { + match (status, next_action) { + (RapydPaymentStatus::Closed, _) => enums::AttemptStatus::Charged, + ( + RapydPaymentStatus::Active, + NextAction::ThreedsVerification | NextAction::PendingConfirmation, + ) => enums::AttemptStatus::AuthenticationPending, + (RapydPaymentStatus::Active, NextAction::PendingCapture | NextAction::NotApplicable) => { + enums::AttemptStatus::Authorized } + ( + RapydPaymentStatus::CanceledByClientOrBank + | RapydPaymentStatus::Expired + | RapydPaymentStatus::ReversedByRapyd, + _, + ) => enums::AttemptStatus::Voided, + (RapydPaymentStatus::Error, _) => enums::AttemptStatus::Failure, + (RapydPaymentStatus::New, _) => enums::AttemptStatus::Authorizing, } } +// } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct RapydPaymentsResponse { @@ -357,12 +361,12 @@ pub struct RefundResponseData { pub failure_reason: Option, } -impl TryFrom> - for types::RefundsRouterData +impl TryFrom> + for types::RefundsRouterData { type Error = error_stack::Report; fn try_from( - item: types::RefundsResponseRouterData, + item: RefundsResponseRouterData, ) -> Result { let (connector_refund_id, refund_status) = match item.response.data { Some(data) => (data.id, enums::RefundStatus::from(data.status)), @@ -372,7 +376,7 @@ impl TryFrom> ), }; Ok(Self { - response: Ok(types::RefundsResponseData { + response: Ok(RefundsResponseData { connector_refund_id, refund_status, }), @@ -381,12 +385,10 @@ impl TryFrom> } } -impl TryFrom> - for types::RefundsRouterData -{ +impl TryFrom> for types::RefundsRouterData { type Error = error_stack::Report; fn try_from( - item: types::RefundsResponseRouterData, + item: RefundsResponseRouterData, ) -> Result { let (connector_refund_id, refund_status) = match item.response.data { Some(data) => (data.id, enums::RefundStatus::from(data.status)), @@ -396,7 +398,7 @@ impl TryFrom> ), }; Ok(Self { - response: Ok(types::RefundsResponseData { + response: Ok(RefundsResponseData { connector_refund_id, refund_status, }), @@ -425,24 +427,21 @@ impl TryFrom<&RapydRouterData<&types::PaymentsCaptureRouterData>> for CaptureReq } } -impl - TryFrom> - for types::RouterData +impl TryFrom> + for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData, + item: ResponseRouterData, ) -> Result { let (status, response) = match &item.response.data { Some(data) => { - let attempt_status = enums::AttemptStatus::foreign_from(( - data.status.to_owned(), - data.next_action.to_owned(), - )); + let attempt_status = + get_status(data.status.to_owned(), data.next_action.to_owned()); match attempt_status { - diesel_models::enums::AttemptStatus::Failure => ( + enums::AttemptStatus::Failure => ( enums::AttemptStatus::Failure, - Err(types::ErrorResponse { + Err(ErrorResponse { code: data .failure_code .to_owned() @@ -466,15 +465,13 @@ impl }) .transpose()?; - let redirection_data = redirection_url - .map(|url| services::RedirectForm::from((url, services::Method::Get))); + let redirection_data = + redirection_url.map(|url| RedirectForm::from((url, Method::Get))); ( attempt_status, - Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId( - data.id.to_owned(), - ), //transaction_id is also the field but this id is used to initiate a refund + Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::ConnectorTransactionId(data.id.to_owned()), //transaction_id is also the field but this id is used to initiate a refund redirection_data: Box::new(redirection_data), mandate_reference: Box::new(None), connector_metadata: None, @@ -491,7 +488,7 @@ impl } None => ( enums::AttemptStatus::Failure, - Err(types::ErrorResponse { + Err(ErrorResponse { code: item.response.status.error_code, status_code: item.http_code, message: item.response.status.status.unwrap_or_default(), @@ -574,7 +571,7 @@ impl From for RapydPaymentsResponse { fn from(value: ResponseData) -> Self { Self { status: Status { - error_code: consts::NO_ERROR_CODE.to_owned(), + error_code: NO_ERROR_CODE.to_owned(), status: None, message: None, response_code: None, @@ -589,7 +586,7 @@ impl From for RefundResponse { fn from(value: RefundResponseData) -> Self { Self { status: Status { - error_code: consts::NO_ERROR_CODE.to_owned(), + error_code: NO_ERROR_CODE.to_owned(), status: None, message: None, response_code: None, diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs index 41029084e1dc..2fba6ab117ef 100644 --- a/crates/hyperswitch_connectors/src/default_implementations.rs +++ b/crates/hyperswitch_connectors/src/default_implementations.rs @@ -121,6 +121,7 @@ default_imp_for_authorize_session_token!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -181,6 +182,7 @@ default_imp_for_calculate_tax!( connectors::Payu, connectors::Powertranz, connectors::Prophetpay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -227,6 +229,7 @@ default_imp_for_session_update!( connectors::Forte, connectors::Helcim, connectors::Jpmorgan, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -289,6 +292,7 @@ default_imp_for_post_session_tokens!( connectors::Forte, connectors::Helcim, connectors::Jpmorgan, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -357,6 +361,7 @@ default_imp_for_complete_authorize!( connectors::Nexinets, connectors::Payeezy, connectors::Payu, + connectors::Rapyd, connectors::Razorpay, connectors::Stax, connectors::Square, @@ -417,6 +422,7 @@ default_imp_for_incremental_authorization!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -478,6 +484,7 @@ default_imp_for_create_customer!( connectors::Payu, connectors::Powertranz, connectors::Prophetpay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Square, @@ -536,6 +543,7 @@ default_imp_for_connector_redirect_response!( connectors::Payu, connectors::Powertranz, connectors::Prophetpay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -593,6 +601,7 @@ default_imp_for_pre_processing_steps!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Stax, connectors::Square, @@ -654,6 +663,7 @@ default_imp_for_post_processing_steps!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -716,6 +726,7 @@ default_imp_for_approve!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -778,6 +789,7 @@ default_imp_for_reject!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -840,6 +852,7 @@ default_imp_for_webhook_source_verification!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -903,6 +916,7 @@ default_imp_for_accept_dispute!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -965,6 +979,7 @@ default_imp_for_submit_evidence!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1027,6 +1042,7 @@ default_imp_for_defend_dispute!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1098,6 +1114,7 @@ default_imp_for_file_upload!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1153,6 +1170,7 @@ default_imp_for_payouts!( connectors::Payu, connectors::Powertranz, connectors::Prophetpay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Square, @@ -1216,6 +1234,7 @@ default_imp_for_payouts_create!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1280,6 +1299,7 @@ default_imp_for_payouts_retrieve!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1344,6 +1364,7 @@ default_imp_for_payouts_eligibility!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1408,6 +1429,7 @@ default_imp_for_payouts_fulfill!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1472,6 +1494,7 @@ default_imp_for_payouts_cancel!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1536,6 +1559,7 @@ default_imp_for_payouts_quote!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1600,6 +1624,7 @@ default_imp_for_payouts_recipient!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1664,6 +1689,7 @@ default_imp_for_payouts_recipient_account!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1728,6 +1754,7 @@ default_imp_for_frm_sale!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1792,6 +1819,7 @@ default_imp_for_frm_checkout!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1856,6 +1884,7 @@ default_imp_for_frm_transaction!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1920,6 +1949,7 @@ default_imp_for_frm_fulfillment!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1984,6 +2014,7 @@ default_imp_for_frm_record_return!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -2045,6 +2076,7 @@ default_imp_for_revoking_mandates!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rs index 71c1dc63a3eb..87f282ec6dd2 100644 --- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs +++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs @@ -237,6 +237,7 @@ default_imp_for_new_connector_integration_payment!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -300,6 +301,7 @@ default_imp_for_new_connector_integration_refund!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -358,6 +360,7 @@ default_imp_for_new_connector_integration_connector_access_token!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -422,6 +425,7 @@ default_imp_for_new_connector_integration_accept_dispute!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -485,6 +489,7 @@ default_imp_for_new_connector_integration_submit_evidence!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -548,6 +553,7 @@ default_imp_for_new_connector_integration_defend_dispute!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -621,6 +627,7 @@ default_imp_for_new_connector_integration_file_upload!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -686,6 +693,7 @@ default_imp_for_new_connector_integration_payouts_create!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -751,6 +759,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -816,6 +825,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -881,6 +891,7 @@ default_imp_for_new_connector_integration_payouts_cancel!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -946,6 +957,7 @@ default_imp_for_new_connector_integration_payouts_quote!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1011,6 +1023,7 @@ default_imp_for_new_connector_integration_payouts_recipient!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1076,6 +1089,7 @@ default_imp_for_new_connector_integration_payouts_sync!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1141,6 +1155,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1204,6 +1219,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1269,6 +1285,7 @@ default_imp_for_new_connector_integration_frm_sale!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1334,6 +1351,7 @@ default_imp_for_new_connector_integration_frm_checkout!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1399,6 +1417,7 @@ default_imp_for_new_connector_integration_frm_transaction!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1464,6 +1483,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1529,6 +1549,7 @@ default_imp_for_new_connector_integration_frm_record_return!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, @@ -1591,6 +1612,7 @@ default_imp_for_new_connector_integration_revoking_mandates!( connectors::Prophetpay, connectors::Mollie, connectors::Multisafepay, + connectors::Rapyd, connectors::Razorpay, connectors::Shift4, connectors::Stax, diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs index b0e2826da68c..ccdb29c23796 100644 --- a/crates/router/src/connector.rs +++ b/crates/router/src/connector.rs @@ -29,7 +29,6 @@ pub mod payone; pub mod paypal; pub mod placetopay; pub mod plaid; -pub mod rapyd; pub mod riskified; pub mod signifyd; pub mod stripe; @@ -51,10 +50,10 @@ pub use hyperswitch_connectors::connectors::{ jpmorgan, jpmorgan::Jpmorgan, mollie, mollie::Mollie, multisafepay, multisafepay::Multisafepay, nexinets, nexinets::Nexinets, nexixpay, nexixpay::Nexixpay, nomupay, nomupay::Nomupay, novalnet, novalnet::Novalnet, payeezy, payeezy::Payeezy, payu, payu::Payu, powertranz, - powertranz::Powertranz, prophetpay, prophetpay::Prophetpay, razorpay, razorpay::Razorpay, - shift4, shift4::Shift4, square, square::Square, stax, stax::Stax, taxjar, taxjar::Taxjar, - thunes, thunes::Thunes, tsys, tsys::Tsys, volt, volt::Volt, worldline, worldline::Worldline, - worldpay, worldpay::Worldpay, zen, zen::Zen, zsl, zsl::Zsl, + powertranz::Powertranz, prophetpay, prophetpay::Prophetpay, rapyd, rapyd::Rapyd, razorpay, + razorpay::Razorpay, shift4, shift4::Shift4, square, square::Square, stax, stax::Stax, taxjar, + taxjar::Taxjar, thunes, thunes::Thunes, tsys, tsys::Tsys, volt, volt::Volt, worldline, + worldline::Worldline, worldpay, worldpay::Worldpay, zen, zen::Zen, zsl, zsl::Zsl, }; #[cfg(feature = "dummy_connector")] @@ -66,7 +65,7 @@ pub use self::{ gpayments::Gpayments, iatapay::Iatapay, itaubank::Itaubank, klarna::Klarna, mifinity::Mifinity, netcetera::Netcetera, nmi::Nmi, noon::Noon, nuvei::Nuvei, opayo::Opayo, opennode::Opennode, paybox::Paybox, payme::Payme, payone::Payone, paypal::Paypal, placetopay::Placetopay, - plaid::Plaid, rapyd::Rapyd, riskified::Riskified, signifyd::Signifyd, stripe::Stripe, + plaid::Plaid, riskified::Riskified, signifyd::Signifyd, stripe::Stripe, threedsecureio::Threedsecureio, trustpay::Trustpay, wellsfargo::Wellsfargo, wellsfargopayout::Wellsfargopayout, wise::Wise, }; diff --git a/crates/router/src/consts.rs b/crates/router/src/consts.rs index 51385593e9d1..e7af9e7f0b65 100644 --- a/crates/router/src/consts.rs +++ b/crates/router/src/consts.rs @@ -52,9 +52,6 @@ pub(crate) const DEFAULT_NOTIFICATION_SCRIPT_LANGUAGE: &str = "en-US"; pub(crate) const BASE64_ENGINE: base64::engine::GeneralPurpose = consts::BASE64_ENGINE; -pub(crate) const BASE64_ENGINE_URL_SAFE: base64::engine::GeneralPurpose = - base64::engine::general_purpose::URL_SAFE; - pub(crate) const API_KEY_LENGTH: usize = 64; // Apple Pay validation url diff --git a/crates/router/src/core/payments/connector_integration_v2_impls.rs b/crates/router/src/core/payments/connector_integration_v2_impls.rs index 8914d23c3e7d..4e0de0dbf12b 100644 --- a/crates/router/src/core/payments/connector_integration_v2_impls.rs +++ b/crates/router/src/core/payments/connector_integration_v2_impls.rs @@ -718,7 +718,6 @@ default_imp_for_new_connector_integration_payment!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -775,7 +774,6 @@ default_imp_for_new_connector_integration_refund!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -826,7 +824,6 @@ default_imp_for_new_connector_integration_connector_access_token!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -899,7 +896,6 @@ default_imp_for_new_connector_integration_accept_dispute!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -954,7 +950,6 @@ default_imp_for_new_connector_integration_defend_dispute!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -993,7 +988,6 @@ default_imp_for_new_connector_integration_submit_evidence!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1059,7 +1053,6 @@ default_imp_for_new_connector_integration_file_upload!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1206,7 +1199,6 @@ default_imp_for_new_connector_integration_payouts_create!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1264,7 +1256,6 @@ default_imp_for_new_connector_integration_payouts_eligibility!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1322,7 +1313,6 @@ default_imp_for_new_connector_integration_payouts_fulfill!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1380,7 +1370,6 @@ default_imp_for_new_connector_integration_payouts_cancel!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1438,7 +1427,6 @@ default_imp_for_new_connector_integration_payouts_quote!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1496,7 +1484,6 @@ default_imp_for_new_connector_integration_payouts_recipient!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1554,7 +1541,6 @@ default_imp_for_new_connector_integration_payouts_sync!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1612,7 +1598,6 @@ default_imp_for_new_connector_integration_payouts_recipient_account!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1668,7 +1653,6 @@ default_imp_for_new_connector_integration_webhook_source_verification!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1815,7 +1799,6 @@ default_imp_for_new_connector_integration_frm_sale!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1873,7 +1856,6 @@ default_imp_for_new_connector_integration_frm_checkout!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1931,7 +1913,6 @@ default_imp_for_new_connector_integration_frm_transaction!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1989,7 +1970,6 @@ default_imp_for_new_connector_integration_frm_fulfillment!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -2047,7 +2027,6 @@ default_imp_for_new_connector_integration_frm_record_return!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -2102,7 +2081,6 @@ default_imp_for_new_connector_integration_revoking_mandates!( connector::Payone, connector::Paypal, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs index 5fcc0b4b90a7..fb486e534b1a 100644 --- a/crates/router/src/core/payments/flows.rs +++ b/crates/router/src/core/payments/flows.rs @@ -223,7 +223,6 @@ default_imp_for_complete_authorize!( connector::Payone, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -288,7 +287,6 @@ default_imp_for_webhook_source_verification!( connector::Payone, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -356,7 +354,6 @@ default_imp_for_create_customer!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Threedsecureio, @@ -414,7 +411,6 @@ default_imp_for_connector_redirect_response!( connector::Payone, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Threedsecureio, @@ -574,7 +570,6 @@ default_imp_for_accept_dispute!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -661,7 +656,6 @@ default_imp_for_file_upload!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Threedsecureio, @@ -726,7 +720,6 @@ default_imp_for_submit_evidence!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Threedsecureio, @@ -791,7 +784,6 @@ default_imp_for_defend_dispute!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -869,7 +861,6 @@ default_imp_for_pre_processing_steps!( connector::Payone, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Threedsecureio, @@ -921,7 +912,6 @@ default_imp_for_post_processing_steps!( connector::Paybox, connector::Payone, connector::Placetopay, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Threedsecureio, @@ -965,7 +955,6 @@ default_imp_for_payouts!( connector::Payme, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Threedsecureio, @@ -1029,7 +1018,6 @@ default_imp_for_payouts_create!( connector::Payone, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Threedsecureio, @@ -1095,7 +1083,6 @@ default_imp_for_payouts_retrieve!( connector::Payone, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1165,7 +1152,6 @@ default_imp_for_payouts_eligibility!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1227,7 +1213,6 @@ default_imp_for_payouts_fulfill!( connector::Payme, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Threedsecureio, @@ -1292,7 +1277,6 @@ default_imp_for_payouts_cancel!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Threedsecureio, @@ -1358,7 +1342,6 @@ default_imp_for_payouts_quote!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1425,7 +1408,6 @@ default_imp_for_payouts_recipient!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Threedsecureio, @@ -1495,7 +1477,6 @@ default_imp_for_payouts_recipient_account!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Threedsecureio, @@ -1562,7 +1543,6 @@ default_imp_for_approve!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1630,7 +1610,6 @@ default_imp_for_reject!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -1793,7 +1772,6 @@ default_imp_for_frm_sale!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Stripe, connector::Threedsecureio, connector::Trustpay, @@ -1861,7 +1839,6 @@ default_imp_for_frm_checkout!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Stripe, connector::Threedsecureio, connector::Trustpay, @@ -1929,7 +1906,6 @@ default_imp_for_frm_transaction!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Stripe, connector::Threedsecureio, connector::Trustpay, @@ -1997,7 +1973,6 @@ default_imp_for_frm_fulfillment!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Stripe, connector::Threedsecureio, connector::Trustpay, @@ -2065,7 +2040,6 @@ default_imp_for_frm_record_return!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Stripe, connector::Threedsecureio, connector::Trustpay, @@ -2130,7 +2104,6 @@ default_imp_for_incremental_authorization!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -2193,7 +2166,6 @@ default_imp_for_revoking_mandates!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -2422,7 +2394,6 @@ default_imp_for_authorize_session_token!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -2488,7 +2459,6 @@ default_imp_for_calculate_tax!( connector::Paypal, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -2553,7 +2523,6 @@ default_imp_for_session_update!( connector::Payone, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, @@ -2618,7 +2587,6 @@ default_imp_for_post_session_tokens!( connector::Payone, connector::Placetopay, connector::Plaid, - connector::Rapyd, connector::Riskified, connector::Signifyd, connector::Stripe, From 788e96a90ee896b6187ec41707f8596a5182e36f Mon Sep 17 00:00:00 2001 From: Spriti Aneja Date: Mon, 2 Dec 2024 16:48:41 +0530 Subject: [PATCH 6/6] Resolved comments --- Cargo.lock | 9 +-------- crates/hyperswitch_connectors/Cargo.toml | 2 +- .../src/connectors/rapyd/transformers.rs | 2 -- crates/router/Cargo.toml | 1 - 4 files changed, 2 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b38265d565ff..835f7d3240d9 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4054,7 +4054,7 @@ dependencies = [ "reqwest 0.11.27", "ring 0.17.8", "router_env", - "roxmltree 0.20.0", + "roxmltree", "serde", "serde_json", "serde_urlencoded", @@ -6676,7 +6676,6 @@ dependencies = [ "ring 0.17.8", "router_derive", "router_env", - "roxmltree 0.19.0", "rust-i18n", "rust_decimal", "rustc-hash", @@ -6762,12 +6761,6 @@ version = "0.19.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3cd14fd5e3b777a7422cca79358c57a8f6e3a703d9ac187448d0daf220c2407f" -[[package]] -name = "roxmltree" -version = "0.20.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6c20b6793b5c2fa6553b250154b78d6d0db37e72700ae35fad9387a46f487c97" - [[package]] name = "rsa" version = "0.9.6" diff --git a/crates/hyperswitch_connectors/Cargo.toml b/crates/hyperswitch_connectors/Cargo.toml index ea887537ba50..664c78a5f45d 100644 --- a/crates/hyperswitch_connectors/Cargo.toml +++ b/crates/hyperswitch_connectors/Cargo.toml @@ -28,7 +28,7 @@ rand = "0.8.5" regex = "1.10.4" reqwest = { version = "0.11.27" } ring = "0.17.8" -roxmltree = "0.20.0" +roxmltree = "0.19.0" serde = { version = "1.0.197", features = ["derive"] } serde_json = "1.0.115" serde_urlencoded = "0.7.1" diff --git a/crates/hyperswitch_connectors/src/connectors/rapyd/transformers.rs b/crates/hyperswitch_connectors/src/connectors/rapyd/transformers.rs index d376fe72eb0c..4f9f276c1913 100644 --- a/crates/hyperswitch_connectors/src/connectors/rapyd/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/rapyd/transformers.rs @@ -215,7 +215,6 @@ pub enum RapydPaymentStatus { New, } -// impl ForeignFrom<(RapydPaymentStatus, NextAction)> for enums::AttemptStatus { fn get_status(status: RapydPaymentStatus, next_action: NextAction) -> enums::AttemptStatus { match (status, next_action) { (RapydPaymentStatus::Closed, _) => enums::AttemptStatus::Charged, @@ -236,7 +235,6 @@ fn get_status(status: RapydPaymentStatus, next_action: NextAction) -> enums::Att (RapydPaymentStatus::New, _) => enums::AttemptStatus::Authorizing, } } -// } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct RapydPaymentsResponse { diff --git a/crates/router/Cargo.toml b/crates/router/Cargo.toml index f6e1f0efc69f..dde06fe832fc 100644 --- a/crates/router/Cargo.toml +++ b/crates/router/Cargo.toml @@ -91,7 +91,6 @@ rdkafka = "0.36.2" regex = "1.10.4" reqwest = { version = "0.11.27", features = ["json", "rustls-tls", "gzip", "multipart"] } ring = "0.17.8" -roxmltree = "0.19.0" rust_decimal = { version = "1.35.0", features = ["serde-with-float", "serde-with-str"] } rust-i18n = { git = "https://github.com/kashif-m/rust-i18n", rev = "f2d8096aaaff7a87a847c35a5394c269f75e077a" } rustc-hash = "1.1.0"