From e21ffc1e8a49ac0bbf996c40058ff0e456544af4 Mon Sep 17 00:00:00 2001 From: deepanshu-iiitu Date: Fri, 15 Nov 2024 17:08:10 +0530 Subject: [PATCH] refactor: [CYBERSOURCE] Move code to crate hyperswitch_connectors --- Cargo.lock | 1 + crates/common_utils/src/consts.rs | 6 + crates/hyperswitch_connectors/Cargo.toml | 1 + .../hyperswitch_connectors/src/connectors.rs | 15 +- .../src/connectors}/cybersource.rs | 849 ++++++----- .../connectors}/cybersource/transformers.rs | 1262 ++++++++--------- .../src/default_implementations.rs | 26 + .../src/default_implementations_v2.rs | 22 + crates/hyperswitch_connectors/src/types.rs | 4 + crates/hyperswitch_connectors/src/utils.rs | 354 ++++- crates/hyperswitch_domain_models/src/types.rs | 26 +- crates/router/src/connector.rs | 35 +- .../connector_integration_v2_impls.rs | 22 - crates/router/src/core/payments/flows.rs | 26 - 14 files changed, 1462 insertions(+), 1187 deletions(-) rename crates/{router/src/connector => hyperswitch_connectors/src/connectors}/cybersource.rs (66%) rename crates/{router/src/connector => hyperswitch_connectors/src/connectors}/cybersource/transformers.rs (78%) diff --git a/Cargo.lock b/Cargo.lock index 27b4158ba619..bfafcc5b7b88 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4006,6 +4006,7 @@ dependencies = [ "hyperswitch_domain_models", "hyperswitch_interfaces", "image", + "josekit", "masking", "mime", "once_cell", diff --git a/crates/common_utils/src/consts.rs b/crates/common_utils/src/consts.rs index a50555ced920..ab270778f2d3 100644 --- a/crates/common_utils/src/consts.rs +++ b/crates/common_utils/src/consts.rs @@ -165,3 +165,9 @@ pub const PUBLISHABLE_KEY_LENGTH: u16 = 39; /// The number of bytes allocated for the hashed connector transaction ID. /// Total number of characters equals CONNECTOR_TRANSACTION_ID_HASH_BYTES times 2. pub const CONNECTOR_TRANSACTION_ID_HASH_BYTES: usize = 25; + +/// Error message for Authentication Error from the connector +pub const CONNECTOR_UNAUTHORIZED_ERROR: &str = "Authentication Error from the connector"; + +/// Error message when Refund request has been voided. +pub const REFUND_VOIDED: &str = "Refund request has been voided."; diff --git a/crates/hyperswitch_connectors/Cargo.toml b/crates/hyperswitch_connectors/Cargo.toml index ca9d338920f8..243fc82d9c63 100644 --- a/crates/hyperswitch_connectors/Cargo.toml +++ b/crates/hyperswitch_connectors/Cargo.toml @@ -20,6 +20,7 @@ error-stack = "0.4.1" hex = "0.4.3" http = "0.2.12" image = { version = "0.25.1", default-features = false, features = ["png"] } +josekit = "0.8.6" mime = "0.3.17" once_cell = "1.19.0" qrcode = "0.14.0" diff --git a/crates/hyperswitch_connectors/src/connectors.rs b/crates/hyperswitch_connectors/src/connectors.rs index 2bc824500964..0defb017d382 100644 --- a/crates/hyperswitch_connectors/src/connectors.rs +++ b/crates/hyperswitch_connectors/src/connectors.rs @@ -6,6 +6,7 @@ pub mod bitpay; pub mod cashtocode; pub mod coinbase; pub mod cryptopay; +pub mod cybersource; pub mod deutschebank; pub mod digitalvirgo; pub mod dlocal; @@ -42,11 +43,11 @@ 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, + cybersource::Cybersource, 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/router/src/connector/cybersource.rs b/crates/hyperswitch_connectors/src/connectors/cybersource.rs similarity index 66% rename from crates/router/src/connector/cybersource.rs rename to crates/hyperswitch_connectors/src/connectors/cybersource.rs index 806cf67b2da2..84b5e9394952 100644 --- a/crates/router/src/connector/cybersource.rs +++ b/crates/hyperswitch_connectors/src/connectors/cybersource.rs @@ -3,37 +3,76 @@ pub mod transformers; use std::fmt::Debug; use base64::Engine; -use common_utils::request::RequestContent; -use diesel_models::enums; +use common_enums::enums; +use common_utils::{ + consts, + errors::CustomResult, + ext_traits::BytesExt, + request::{Method, Request, RequestBuilder, RequestContent}, +}; use error_stack::{report, Report, ResultExt}; -use masking::{ExposeInterface, PeekInterface}; +use hyperswitch_domain_models::{ + payment_method_data::PaymentMethodData, + router_data::{AccessToken, ErrorResponse, RouterData}, + router_flow_types::{ + access_token_auth::AccessTokenAuth, + mandate_revoke::MandateRevoke, + payments::{ + Authorize, Capture, CompleteAuthorize, IncrementalAuthorization, PSync, + PaymentMethodToken, Session, SetupMandate, Void, + }, + payouts::PoFulfill, + refunds::{Execute, RSync}, + PreProcessing, + }, + router_request_types::{ + AccessTokenRequestData, CompleteAuthorizeData, MandateRevokeRequestData, + PaymentMethodTokenizationData, PaymentsAuthorizeData, PaymentsCancelData, + PaymentsCaptureData, PaymentsIncrementalAuthorizationData, PaymentsPreProcessingData, + PaymentsSessionData, PaymentsSyncData, PayoutsData, RefundsData, SetupMandateRequestData, + }, + router_response_types::{ + MandateRevokeResponseData, PaymentsResponseData, PayoutsResponseData, RefundsResponseData, + }, + types::{ + MandateRevokeRouterData, PaymentsAuthorizeRouterData, PaymentsCancelRouterData, + PaymentsCaptureRouterData, PaymentsCompleteAuthorizeRouterData, + PaymentsIncrementalAuthorizationRouterData, PaymentsPreProcessingRouterData, + PaymentsSyncRouterData, PayoutsRouterData, RefundExecuteRouterData, RefundSyncRouterData, + SetupMandateRouterData, + }, +}; +use hyperswitch_interfaces::{ + api::{ + self, + payments::PaymentSession, + refunds::{Refund, RefundExecute, RefundSync}, + ConnectorCommon, ConnectorCommonExt, ConnectorIntegration, ConnectorValidation, + }, + configs::Connectors, + errors, + events::connector_api_logs::ConnectorEvent, + types::{ + IncrementalAuthorizationType, MandateRevokeType, PaymentsAuthorizeType, + PaymentsCaptureType, PaymentsCompleteAuthorizeType, PaymentsPreProcessingType, + PaymentsSyncType, PaymentsVoidType, PayoutFulfillType, RefundExecuteType, RefundSyncType, + Response, SetupMandateType, + }, + webhooks, +}; +use masking::{ExposeInterface, Mask, Maskable, PeekInterface}; use ring::{digest, hmac}; use time::OffsetDateTime; use transformers as cybersource; use url::Url; -use super::utils::{PaymentsAuthorizeRequestData, RouterData}; use crate::{ - configs::settings, - connector::{ - utils as connector_utils, - utils::{PaymentMethodDataType, RefundsRequestData}, + constants::headers, + types::ResponseRouterData, + utils::{ + ForeignTryFrom, PaymentMethodDataType, PaymentsAuthorizeRequestData, RefundsRequestData, + RouterData as OtherRouterData, }, - consts, - core::errors::{self, CustomResult}, - events::connector_api_logs::ConnectorEvent, - headers, - services::{ - self, - request::{self, Mask}, - ConnectorIntegration, ConnectorValidation, - }, - types::{ - self, - api::{self, ConnectorCommon, ConnectorCommonExt}, - transformers::ForeignTryFrom, - }, - utils::BytesExt, }; #[derive(Debug, Clone)] @@ -52,16 +91,16 @@ impl Cybersource { resource: &str, payload: &String, date: OffsetDateTime, - http_method: services::Method, + http_method: Method, ) -> CustomResult { let cybersource::CybersourceAuthType { api_key, merchant_account, api_secret, } = auth; - let is_post_method = matches!(http_method, services::Method::Post); - let is_patch_method = matches!(http_method, services::Method::Patch); - let is_delete_method = matches!(http_method, services::Method::Delete); + let is_post_method = matches!(http_method, Method::Post); + let is_patch_method = matches!(http_method, Method::Patch); + let is_delete_method = matches!(http_method, Method::Delete); let digest_str = if is_post_method || is_patch_method { "digest " } else { @@ -107,7 +146,7 @@ impl ConnectorCommon for Cybersource { "application/json;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.cybersource.base_url.as_ref() } @@ -117,9 +156,9 @@ impl ConnectorCommon for Cybersource { fn build_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { + ) -> CustomResult { let response: Result< cybersource::CybersourceErrorResponse, Report, @@ -128,7 +167,7 @@ impl ConnectorCommon for Cybersource { let error_message = if res.status_code == 401 { consts::CONNECTOR_UNAUTHORIZED_ERROR } else { - consts::NO_ERROR_MESSAGE + hyperswitch_interfaces::consts::NO_ERROR_MESSAGE }; match response { Ok(transformers::CybersourceErrorResponse::StandardError(response)) => { @@ -163,12 +202,10 @@ impl ConnectorCommon for Cybersource { .join(", ") }); ( - response - .reason - .clone() - .map_or(consts::NO_ERROR_CODE.to_string(), |reason| { - reason.to_string() - }), + response.reason.clone().map_or( + hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string(), + |reason| reason.to_string(), + ), response .reason .map_or(error_message.to_string(), |reason| reason.to_string()), @@ -181,7 +218,7 @@ impl ConnectorCommon for Cybersource { } }; - Ok(types::ErrorResponse { + Ok(ErrorResponse { status_code: res.status_code, code, message, @@ -193,9 +230,9 @@ impl ConnectorCommon for Cybersource { Ok(transformers::CybersourceErrorResponse::AuthenticationError(response)) => { event_builder.map(|i| i.set_error_response_body(&response)); router_env::logger::info!(connector_response=?response); - Ok(types::ErrorResponse { + Ok(ErrorResponse { status_code: res.status_code, - code: consts::NO_ERROR_CODE.to_string(), + code: hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string(), message: response.response.rmsg.clone(), reason: Some(response.response.rmsg), attempt_status: None, @@ -217,9 +254,9 @@ impl ConnectorCommon for Cybersource { }) .collect::>() .join(" & "); - Ok(types::ErrorResponse { + Ok(ErrorResponse { status_code: res.status_code, - code: consts::NO_ERROR_CODE.to_string(), + code: hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string(), message: error_response.clone(), reason: Some(error_response), attempt_status: None, @@ -245,21 +282,21 @@ impl ConnectorValidation for Cybersource { 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()), + crate::utils::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::Card, PaymentMethodDataType::ApplePay, PaymentMethodDataType::GooglePay, ]); - connector_utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id()) + crate::utils::is_mandate_supported(pm_data, pm_type, mandate_supported_pmd, self.id()) } } @@ -269,9 +306,9 @@ where { fn build_headers( &self, - req: &types::RouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &RouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { let date = OffsetDateTime::now_utc(); let cybersource_req = self.get_request_body(req, connectors)?; let auth = cybersource::CybersourceAuthType::try_from(&req.connector_auth_type)?; @@ -315,10 +352,7 @@ where ("Host".to_string(), host.to_string().into()), ("Signature".to_string(), signature.into_masked()), ]; - if matches!( - http_method, - services::Method::Post | services::Method::Put | services::Method::Patch - ) { + if matches!(http_method, Method::Post | Method::Put | Method::Patch) { headers.push(( "Digest".to_string(), format!("SHA-256={sha256}").into_masked(), @@ -345,28 +379,20 @@ impl api::Payouts for Cybersource {} #[cfg(feature = "payouts")] impl api::PayoutFulfill for Cybersource {} -impl - ConnectorIntegration< - api::PaymentMethodToken, - types::PaymentMethodTokenizationData, - types::PaymentsResponseData, - > for Cybersource +impl ConnectorIntegration + for Cybersource { // Not Implemented (R) } -impl - ConnectorIntegration< - api::SetupMandate, - types::SetupMandateRequestData, - types::PaymentsResponseData, - > for Cybersource +impl ConnectorIntegration + for Cybersource { 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_content_type(&self) -> &'static str { @@ -374,15 +400,15 @@ impl } fn get_url( &self, - _req: &types::SetupMandateRouterData, - connectors: &settings::Connectors, + _req: &SetupMandateRouterData, + connectors: &Connectors, ) -> CustomResult { Ok(format!("{}pts/v2/payments/", self.base_url(connectors))) } fn get_request_body( &self, - req: &types::SetupMandateRouterData, - _connectors: &settings::Connectors, + req: &SetupMandateRouterData, + _connectors: &Connectors, ) -> CustomResult { let connector_req = cybersource::CybersourceZeroMandateRequest::try_from(req)?; Ok(RequestContent::Json(Box::new(connector_req))) @@ -390,35 +416,33 @@ impl fn build_request( &self, - req: &types::SetupMandateRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + req: &SetupMandateRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) - .url(&types::SetupMandateType::get_url(self, req, connectors)?) + RequestBuilder::new() + .method(Method::Post) + .url(&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, - )?) + .headers(SetupMandateType::get_headers(self, req, connectors)?) + .set_body(SetupMandateType::get_request_body(self, req, connectors)?) .build(), )) } fn handle_response( &self, - data: &types::SetupMandateRouterData, + data: &SetupMandateRouterData, event_builder: Option<&mut ConnectorEvent>, - res: types::Response, - ) -> CustomResult { + res: Response, + ) -> CustomResult { let response: cybersource::CybersourcePaymentsResponse = res .response .parse_struct("CybersourceSetupMandatesResponse") .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, @@ -427,17 +451,17 @@ impl fn get_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { + ) -> CustomResult { self.build_error_response(res, event_builder) } fn get_5xx_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { + ) -> CustomResult { let response: cybersource::CybersourceServerErrorResponse = res .response .parse_struct("CybersourceServerErrorResponse") @@ -453,76 +477,72 @@ impl }, None => None, }; - Ok(types::ErrorResponse { + Ok(ErrorResponse { status_code: res.status_code, reason: response.status.clone(), - code: response.status.unwrap_or(consts::NO_ERROR_CODE.to_string()), + code: response + .status + .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()), message: response .message - .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), + .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()), attempt_status, connector_transaction_id: None, }) } } -impl - ConnectorIntegration< - api::MandateRevoke, - types::MandateRevokeRequestData, - types::MandateRevokeResponseData, - > for Cybersource +impl ConnectorIntegration + for Cybersource { fn get_headers( &self, - req: &types::MandateRevokeRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &MandateRevokeRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } - fn get_http_method(&self) -> services::Method { - services::Method::Delete + fn get_http_method(&self) -> Method { + Method::Delete } fn get_content_type(&self) -> &'static str { self.common_get_content_type() } fn get_url( &self, - req: &types::MandateRevokeRouterData, - connectors: &settings::Connectors, + req: &MandateRevokeRouterData, + connectors: &Connectors, ) -> CustomResult { Ok(format!( "{}tms/v1/paymentinstruments/{}", self.base_url(connectors), - connector_utils::RevokeMandateRequestData::get_connector_mandate_id(&req.request)? + crate::utils::RevokeMandateRequestData::get_connector_mandate_id(&req.request)? )) } fn build_request( &self, - req: &types::MandateRevokeRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + req: &MandateRevokeRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Delete) - .url(&types::MandateRevokeType::get_url(self, req, connectors)?) + RequestBuilder::new() + .method(Method::Delete) + .url(&MandateRevokeType::get_url(self, req, connectors)?) .attach_default_headers() - .headers(types::MandateRevokeType::get_headers( - self, req, connectors, - )?) + .headers(MandateRevokeType::get_headers(self, req, connectors)?) .build(), )) } fn handle_response( &self, - data: &types::MandateRevokeRouterData, + data: &MandateRevokeRouterData, event_builder: Option<&mut ConnectorEvent>, - res: types::Response, - ) -> CustomResult { + res: Response, + ) -> CustomResult { if matches!(res.status_code, 204) { event_builder.map(|i| i.set_response_body(&serde_json::json!({"mandate_status": common_enums::MandateStatus::Revoked.to_string()}))); - Ok(types::MandateRevokeRouterData { - response: Ok(types::MandateRevokeResponseData { + Ok(MandateRevokeRouterData { + response: Ok(MandateRevokeResponseData { mandate_status: common_enums::MandateStatus::Revoked, }), ..data.clone() @@ -540,9 +560,9 @@ impl }); router_env::logger::info!(connector_response=?response_string); - Ok(types::MandateRevokeRouterData { - response: Err(types::ErrorResponse { - code: consts::NO_ERROR_CODE.to_string(), + Ok(MandateRevokeRouterData { + response: Err(ErrorResponse { + code: hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string(), message: response_string.clone(), reason: Some(response_string), status_code: res.status_code, @@ -555,37 +575,28 @@ impl } fn get_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { + ) -> CustomResult { self.build_error_response(res, event_builder) } } -impl ConnectorIntegration - for Cybersource -{ +impl ConnectorIntegration for Cybersource { // Not Implemented (R) } -impl api::PaymentSession for Cybersource {} +impl PaymentSession for Cybersource {} -impl ConnectorIntegration - for Cybersource -{ -} +impl ConnectorIntegration for Cybersource {} -impl - ConnectorIntegration< - api::PreProcessing, - types::PaymentsPreProcessingData, - types::PaymentsResponseData, - > for Cybersource +impl ConnectorIntegration + for Cybersource { fn get_headers( &self, - req: &types::PaymentsPreProcessingRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &PaymentsPreProcessingRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } fn get_content_type(&self) -> &'static str { @@ -593,8 +604,8 @@ impl } fn get_url( &self, - req: &types::PaymentsPreProcessingRouterData, - connectors: &settings::Connectors, + req: &PaymentsPreProcessingRouterData, + connectors: &Connectors, ) -> CustomResult { let redirect_response = req.request.redirect_response.clone().ok_or( errors::ConnectorError::MissingRequiredField { @@ -614,8 +625,8 @@ impl } fn get_request_body( &self, - req: &types::PaymentsPreProcessingRouterData, - _connectors: &settings::Connectors, + req: &PaymentsPreProcessingRouterData, + _connectors: &Connectors, ) -> CustomResult { let connector_router_data = cybersource::CybersourceRouterData::try_from(( &self.get_currency_unit(), @@ -637,20 +648,18 @@ impl } fn build_request( &self, - req: &types::PaymentsPreProcessingRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + req: &PaymentsPreProcessingRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) - .url(&types::PaymentsPreProcessingType::get_url( - self, req, connectors, - )?) + RequestBuilder::new() + .method(Method::Post) + .url(&PaymentsPreProcessingType::get_url(self, req, connectors)?) .attach_default_headers() - .headers(types::PaymentsPreProcessingType::get_headers( + .headers(PaymentsPreProcessingType::get_headers( self, req, connectors, )?) - .set_body(types::PaymentsPreProcessingType::get_request_body( + .set_body(PaymentsPreProcessingType::get_request_body( self, req, connectors, )?) .build(), @@ -659,17 +668,17 @@ impl fn handle_response( &self, - data: &types::PaymentsPreProcessingRouterData, + data: &PaymentsPreProcessingRouterData, event_builder: Option<&mut ConnectorEvent>, - res: types::Response, - ) -> CustomResult { + res: Response, + ) -> CustomResult { let response: cybersource::CybersourcePreProcessingResponse = res .response .parse_struct("Cybersource AuthEnrollmentResponse") .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, @@ -678,21 +687,19 @@ impl fn get_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { + ) -> CustomResult { self.build_error_response(res, event_builder) } } -impl ConnectorIntegration - for Cybersource -{ +impl ConnectorIntegration for Cybersource { 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) } @@ -702,8 +709,8 @@ impl ConnectorIntegration CustomResult { let connector_payment_id = req.request.connector_transaction_id.clone(); Ok(format!( @@ -715,8 +722,8 @@ impl ConnectorIntegration CustomResult { let connector_router_data = cybersource::CybersourceRouterData::try_from(( &self.get_currency_unit(), @@ -730,18 +737,16 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + req: &PaymentsCaptureRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) - .url(&types::PaymentsCaptureType::get_url(self, req, connectors)?) + RequestBuilder::new() + .method(Method::Post) + .url(&PaymentsCaptureType::get_url(self, req, connectors)?) .attach_default_headers() - .headers(types::PaymentsCaptureType::get_headers( - self, req, connectors, - )?) - .set_body(types::PaymentsCaptureType::get_request_body( + .headers(PaymentsCaptureType::get_headers(self, req, connectors)?) + .set_body(PaymentsCaptureType::get_request_body( self, req, connectors, )?) .build(), @@ -749,11 +754,11 @@ impl ConnectorIntegration, - res: types::Response, + res: Response, ) -> CustomResult< - types::RouterData, + RouterData, errors::ConnectorError, > { let response: cybersource::CybersourcePaymentsResponse = res @@ -762,7 +767,7 @@ impl ConnectorIntegration, - ) -> CustomResult { + ) -> CustomResult { self.build_error_response(res, event_builder) } fn get_5xx_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { + ) -> CustomResult { let response: cybersource::CybersourceServerErrorResponse = res .response .parse_struct("CybersourceServerErrorResponse") @@ -789,38 +794,38 @@ impl ConnectorIntegration - for Cybersource -{ +impl ConnectorIntegration for Cybersource { 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) } - fn get_http_method(&self) -> services::Method { - services::Method::Get + fn get_http_method(&self) -> Method { + Method::Get } fn get_url( &self, - req: &types::PaymentsSyncRouterData, - connectors: &settings::Connectors, + req: &PaymentsSyncRouterData, + connectors: &Connectors, ) -> CustomResult { let connector_payment_id = req .request @@ -840,31 +845,31 @@ 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: types::Response, - ) -> CustomResult { + res: Response, + ) -> CustomResult { let response: cybersource::CybersourceTransactionResponse = res .response .parse_struct("Cybersource PaymentSyncResponse") .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, @@ -872,21 +877,19 @@ impl ConnectorIntegration, - ) -> CustomResult { + ) -> CustomResult { self.build_error_response(res, event_builder) } } -impl ConnectorIntegration - for Cybersource -{ +impl ConnectorIntegration for Cybersource { 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) } @@ -896,8 +899,8 @@ impl ConnectorIntegration CustomResult { if req.is_three_ds() && req.request.is_card() @@ -919,8 +922,8 @@ impl ConnectorIntegration CustomResult { let connector_router_data = cybersource::CybersourceRouterData::try_from(( &self.get_currency_unit(), @@ -946,18 +949,14 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { - let request = services::RequestBuilder::new() - .method(services::Method::Post) - .url(&types::PaymentsAuthorizeType::get_url( - self, req, connectors, - )?) + req: &PaymentsAuthorizeRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { + let request = RequestBuilder::new() + .method(Method::Post) + .url(&PaymentsAuthorizeType::get_url(self, req, connectors)?) .attach_default_headers() - .headers(types::PaymentsAuthorizeType::get_headers( - self, req, connectors, - )?) + .headers(PaymentsAuthorizeType::get_headers(self, req, connectors)?) .set_body(self.get_request_body(req, connectors)?) .build(); @@ -966,10 +965,10 @@ impl ConnectorIntegration, - res: types::Response, - ) -> CustomResult { + res: Response, + ) -> CustomResult { if data.is_three_ds() && data.request.is_card() && (data.request.connector_mandate_id().is_none() @@ -982,7 +981,7 @@ impl ConnectorIntegration, - ) -> CustomResult { + ) -> CustomResult { self.build_error_response(res, event_builder) } fn get_5xx_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { + ) -> CustomResult { let response: cybersource::CybersourceServerErrorResponse = res .response .parse_struct("CybersourceServerErrorResponse") @@ -1030,13 +1029,15 @@ impl ConnectorIntegration None, }; - Ok(types::ErrorResponse { + Ok(ErrorResponse { status_code: res.status_code, reason: response.status.clone(), - code: response.status.unwrap_or(consts::NO_ERROR_CODE.to_string()), + code: response + .status + .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()), message: response .message - .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), + .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()), attempt_status, connector_transaction_id: None, }) @@ -1044,29 +1045,27 @@ impl ConnectorIntegration - for Cybersource -{ +impl ConnectorIntegration for Cybersource { fn get_url( &self, - _req: &types::PayoutsRouterData, - connectors: &settings::Connectors, + _req: &PayoutsRouterData, + connectors: &Connectors, ) -> CustomResult { Ok(format!("{}pts/v2/payouts", self.base_url(connectors))) } fn get_headers( &self, - req: &types::PayoutsRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &PayoutsRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } fn get_request_body( &self, - req: &types::PayoutsRouterData, - _connectors: &settings::Connectors, + req: &PayoutsRouterData, + _connectors: &Connectors, ) -> CustomResult { let connector_router_data = cybersource::CybersourceRouterData::try_from(( &self.get_currency_unit(), @@ -1081,19 +1080,15 @@ impl ConnectorIntegration, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { - let request = services::RequestBuilder::new() - .method(services::Method::Post) - .url(&types::PayoutFulfillType::get_url(self, req, connectors)?) + req: &PayoutsRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { + let request = RequestBuilder::new() + .method(Method::Post) + .url(&PayoutFulfillType::get_url(self, req, connectors)?) .attach_default_headers() - .headers(types::PayoutFulfillType::get_headers( - self, req, connectors, - )?) - .set_body(types::PayoutFulfillType::get_request_body( - self, req, connectors, - )?) + .headers(PayoutFulfillType::get_headers(self, req, connectors)?) + .set_body(PayoutFulfillType::get_request_body(self, req, connectors)?) .build(); Ok(Some(request)) @@ -1101,10 +1096,10 @@ impl ConnectorIntegration, + data: &PayoutsRouterData, event_builder: Option<&mut ConnectorEvent>, - res: types::Response, - ) -> CustomResult, errors::ConnectorError> { + res: Response, + ) -> CustomResult, errors::ConnectorError> { let response: cybersource::CybersourceFulfillResponse = res .response .parse_struct("CybersourceFulfillResponse") @@ -1113,7 +1108,7 @@ impl ConnectorIntegration, - ) -> CustomResult { + ) -> CustomResult { self.build_error_response(res, event_builder) } fn get_5xx_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { + ) -> CustomResult { let response: cybersource::CybersourceServerErrorResponse = res .response .parse_struct("CybersourceServerErrorResponse") @@ -1148,31 +1143,29 @@ impl ConnectorIntegration None, }; - Ok(types::ErrorResponse { + Ok(ErrorResponse { status_code: res.status_code, reason: response.status.clone(), - code: response.status.unwrap_or(consts::NO_ERROR_CODE.to_string()), + code: response + .status + .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()), message: response .message - .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), + .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()), attempt_status, connector_transaction_id: None, }) } } -impl - ConnectorIntegration< - api::CompleteAuthorize, - types::CompleteAuthorizeData, - types::PaymentsResponseData, - > for Cybersource +impl ConnectorIntegration + for Cybersource { 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) } fn get_content_type(&self) -> &'static str { @@ -1180,8 +1173,8 @@ impl } fn get_url( &self, - _req: &types::PaymentsCompleteAuthorizeRouterData, - connectors: &settings::Connectors, + _req: &PaymentsCompleteAuthorizeRouterData, + connectors: &Connectors, ) -> CustomResult { Ok(format!( "{}pts/v2/payments/", @@ -1190,8 +1183,8 @@ impl } fn get_request_body( &self, - req: &types::PaymentsCompleteAuthorizeRouterData, - _connectors: &settings::Connectors, + req: &PaymentsCompleteAuthorizeRouterData, + _connectors: &Connectors, ) -> CustomResult { let connector_router_data = cybersource::CybersourceRouterData::try_from(( &self.get_currency_unit(), @@ -1205,20 +1198,20 @@ 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) - .url(&types::PaymentsCompleteAuthorizeType::get_url( + RequestBuilder::new() + .method(Method::Post) + .url(&PaymentsCompleteAuthorizeType::get_url( self, req, connectors, )?) .attach_default_headers() - .headers(types::PaymentsCompleteAuthorizeType::get_headers( + .headers(PaymentsCompleteAuthorizeType::get_headers( self, req, connectors, )?) - .set_body(types::PaymentsCompleteAuthorizeType::get_request_body( + .set_body(PaymentsCompleteAuthorizeType::get_request_body( self, req, connectors, )?) .build(), @@ -1227,17 +1220,17 @@ impl fn handle_response( &self, - data: &types::PaymentsCompleteAuthorizeRouterData, + data: &PaymentsCompleteAuthorizeRouterData, event_builder: Option<&mut ConnectorEvent>, - res: types::Response, - ) -> CustomResult { + res: Response, + ) -> CustomResult { let response: cybersource::CybersourcePaymentsResponse = res .response .parse_struct("Cybersource 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, @@ -1246,17 +1239,17 @@ impl fn get_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { + ) -> CustomResult { self.build_error_response(res, event_builder) } fn get_5xx_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { + ) -> CustomResult { let response: cybersource::CybersourceServerErrorResponse = res .response .parse_struct("CybersourceServerErrorResponse") @@ -1272,34 +1265,34 @@ impl }, None => None, }; - Ok(types::ErrorResponse { + Ok(ErrorResponse { status_code: res.status_code, reason: response.status.clone(), - code: response.status.unwrap_or(consts::NO_ERROR_CODE.to_string()), + code: response + .status + .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()), message: response .message - .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), + .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()), attempt_status, connector_transaction_id: None, }) } } -impl ConnectorIntegration - for Cybersource -{ +impl ConnectorIntegration for Cybersource { fn get_headers( &self, - req: &types::PaymentsCancelRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &PaymentsCancelRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } fn get_url( &self, - req: &types::PaymentsCancelRouterData, - connectors: &settings::Connectors, + req: &PaymentsCancelRouterData, + connectors: &Connectors, ) -> CustomResult { let connector_payment_id = req.request.connector_transaction_id.clone(); Ok(format!( @@ -1314,8 +1307,8 @@ impl ConnectorIntegration CustomResult { let connector_router_data = cybersource::CybersourceRouterData::try_from(( &self.get_currency_unit(), @@ -1338,15 +1331,15 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + req: &PaymentsCancelRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) - .url(&types::PaymentsVoidType::get_url(self, req, connectors)?) + RequestBuilder::new() + .method(Method::Post) + .url(&PaymentsVoidType::get_url(self, req, connectors)?) .attach_default_headers() - .headers(types::PaymentsVoidType::get_headers(self, req, connectors)?) + .headers(PaymentsVoidType::get_headers(self, req, connectors)?) .set_body(self.get_request_body(req, connectors)?) .build(), )) @@ -1354,17 +1347,17 @@ impl ConnectorIntegration, - res: types::Response, - ) -> CustomResult { + res: Response, + ) -> CustomResult { let response: cybersource::CybersourcePaymentsResponse = res .response .parse_struct("Cybersource 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, @@ -1373,17 +1366,17 @@ impl ConnectorIntegration, - ) -> CustomResult { + ) -> CustomResult { self.build_error_response(res, event_builder) } fn get_5xx_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { + ) -> CustomResult { let response: cybersource::CybersourceServerErrorResponse = res .response .parse_struct("CybersourceServerErrorResponse") @@ -1392,32 +1385,32 @@ impl ConnectorIntegration - for Cybersource -{ +impl ConnectorIntegration for Cybersource { fn get_headers( &self, - req: &types::RefundExecuteRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &RefundExecuteRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } @@ -1427,8 +1420,8 @@ impl ConnectorIntegration CustomResult { let connector_payment_id = req.request.connector_transaction_id.clone(); Ok(format!( @@ -1440,8 +1433,8 @@ impl ConnectorIntegration CustomResult { let connector_router_data = cybersource::CybersourceRouterData::try_from(( &self.get_currency_unit(), @@ -1455,17 +1448,15 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + req: &RefundExecuteRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Post) - .url(&types::RefundExecuteType::get_url(self, req, connectors)?) + RequestBuilder::new() + .method(Method::Post) + .url(&RefundExecuteType::get_url(self, req, connectors)?) .attach_default_headers() - .headers(types::RefundExecuteType::get_headers( - self, req, connectors, - )?) + .headers(RefundExecuteType::get_headers(self, req, connectors)?) .set_body(self.get_request_body(req, connectors)?) .build(), )) @@ -1473,17 +1464,17 @@ impl ConnectorIntegration, - res: types::Response, - ) -> CustomResult { + res: Response, + ) -> CustomResult { let response: cybersource::CybersourceRefundResponse = res .response .parse_struct("Cybersource 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, @@ -1491,34 +1482,32 @@ impl ConnectorIntegration, - ) -> CustomResult { + ) -> CustomResult { self.build_error_response(res, event_builder) } } #[allow(dead_code)] -impl ConnectorIntegration - for Cybersource -{ +impl ConnectorIntegration for Cybersource { 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) } fn get_content_type(&self) -> &'static str { self.common_get_content_type() } - fn get_http_method(&self) -> services::Method { - services::Method::Get + fn get_http_method(&self) -> Method { + Method::Get } fn get_url( &self, - req: &types::RefundSyncRouterData, - connectors: &settings::Connectors, + req: &RefundSyncRouterData, + connectors: &Connectors, ) -> CustomResult { let refund_id = req.request.get_connector_refund_id()?; Ok(format!( @@ -1529,31 +1518,31 @@ impl ConnectorIntegration CustomResult, errors::ConnectorError> { + req: &RefundSyncRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Get) - .url(&types::RefundSyncType::get_url(self, req, connectors)?) + RequestBuilder::new() + .method(Method::Get) + .url(&RefundSyncType::get_url(self, req, connectors)?) .attach_default_headers() - .headers(types::RefundSyncType::get_headers(self, req, connectors)?) + .headers(RefundSyncType::get_headers(self, req, connectors)?) .build(), )) } fn handle_response( &self, - data: &types::RefundSyncRouterData, + data: &RefundSyncRouterData, event_builder: Option<&mut ConnectorEvent>, - res: types::Response, - ) -> CustomResult { + res: Response, + ) -> CustomResult { let response: cybersource::CybersourceRsyncResponse = res .response .parse_struct("Cybersource RefundSyncResponse") .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, @@ -1561,30 +1550,30 @@ impl ConnectorIntegration, - ) -> CustomResult { + ) -> CustomResult { self.build_error_response(res, event_builder) } } impl ConnectorIntegration< - api::IncrementalAuthorization, - types::PaymentsIncrementalAuthorizationData, - types::PaymentsResponseData, + IncrementalAuthorization, + PaymentsIncrementalAuthorizationData, + PaymentsResponseData, > for Cybersource { fn get_headers( &self, - req: &types::PaymentsIncrementalAuthorizationRouterData, - connectors: &settings::Connectors, - ) -> CustomResult)>, errors::ConnectorError> { + req: &PaymentsIncrementalAuthorizationRouterData, + connectors: &Connectors, + ) -> CustomResult)>, errors::ConnectorError> { self.build_headers(req, connectors) } - fn get_http_method(&self) -> services::Method { - services::Method::Patch + fn get_http_method(&self) -> Method { + Method::Patch } fn get_content_type(&self) -> &'static str { @@ -1593,8 +1582,8 @@ impl fn get_url( &self, - req: &types::PaymentsIncrementalAuthorizationRouterData, - connectors: &settings::Connectors, + req: &PaymentsIncrementalAuthorizationRouterData, + connectors: &Connectors, ) -> CustomResult { let connector_payment_id = req.request.connector_transaction_id.clone(); Ok(format!( @@ -1606,8 +1595,8 @@ impl fn get_request_body( &self, - req: &types::PaymentsIncrementalAuthorizationRouterData, - _connectors: &settings::Connectors, + req: &PaymentsIncrementalAuthorizationRouterData, + _connectors: &Connectors, ) -> CustomResult { let connector_router_data = cybersource::CybersourceRouterData::try_from(( &self.get_currency_unit(), @@ -1623,20 +1612,20 @@ impl } fn build_request( &self, - req: &types::PaymentsIncrementalAuthorizationRouterData, - connectors: &settings::Connectors, - ) -> CustomResult, errors::ConnectorError> { + req: &PaymentsIncrementalAuthorizationRouterData, + connectors: &Connectors, + ) -> CustomResult, errors::ConnectorError> { Ok(Some( - services::RequestBuilder::new() - .method(services::Method::Patch) - .url(&types::IncrementalAuthorizationType::get_url( + RequestBuilder::new() + .method(Method::Patch) + .url(&IncrementalAuthorizationType::get_url( self, req, connectors, )?) .attach_default_headers() - .headers(types::IncrementalAuthorizationType::get_headers( + .headers(IncrementalAuthorizationType::get_headers( self, req, connectors, )?) - .set_body(types::IncrementalAuthorizationType::get_request_body( + .set_body(IncrementalAuthorizationType::get_request_body( self, req, connectors, )?) .build(), @@ -1644,14 +1633,14 @@ impl } fn handle_response( &self, - data: &types::PaymentsIncrementalAuthorizationRouterData, + data: &PaymentsIncrementalAuthorizationRouterData, event_builder: Option<&mut ConnectorEvent>, - res: types::Response, + res: Response, ) -> CustomResult< - types::RouterData< - api::IncrementalAuthorization, - types::PaymentsIncrementalAuthorizationData, - types::PaymentsResponseData, + RouterData< + IncrementalAuthorization, + PaymentsIncrementalAuthorizationData, + PaymentsResponseData, >, errors::ConnectorError, > { @@ -1661,8 +1650,8 @@ impl .change_context(errors::ConnectorError::ResponseDeserializationFailed)?; event_builder.map(|i| i.set_response_body(&response)); router_env::logger::info!(connector_response=?response); - types::RouterData::foreign_try_from(( - types::ResponseRouterData { + RouterData::foreign_try_from(( + ResponseRouterData { response, data: data.clone(), http_code: res.status_code, @@ -1673,32 +1662,32 @@ impl } fn get_error_response( &self, - res: types::Response, + res: Response, event_builder: Option<&mut ConnectorEvent>, - ) -> CustomResult { + ) -> CustomResult { self.build_error_response(res, event_builder) } } #[async_trait::async_trait] -impl api::IncomingWebhook for Cybersource { +impl webhooks::IncomingWebhook for Cybersource { fn get_webhook_object_reference_id( &self, - _request: &api::IncomingWebhookRequestDetails<'_>, + _request: &webhooks::IncomingWebhookRequestDetails<'_>, ) -> CustomResult { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } fn get_webhook_event_type( &self, - _request: &api::IncomingWebhookRequestDetails<'_>, - ) -> CustomResult { - Ok(api::IncomingWebhookEvent::EventNotSupported) + _request: &webhooks::IncomingWebhookRequestDetails<'_>, + ) -> CustomResult { + Ok(api_models::webhooks::IncomingWebhookEvent::EventNotSupported) } fn get_webhook_resource_object( &self, - _request: &api::IncomingWebhookRequestDetails<'_>, + _request: &webhooks::IncomingWebhookRequestDetails<'_>, ) -> CustomResult, errors::ConnectorError> { Err(report!(errors::ConnectorError::WebhooksNotImplemented)) } diff --git a/crates/router/src/connector/cybersource/transformers.rs b/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs similarity index 78% rename from crates/router/src/connector/cybersource/transformers.rs rename to crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs index c9ebba4a10d8..ee7e45b6d9f2 100644 --- a/crates/router/src/connector/cybersource/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/cybersource/transformers.rs @@ -5,38 +5,57 @@ use api_models::{ payouts::PayoutMethodData, }; use base64::Engine; -use common_enums::FutureUsage; +use common_enums::{enums, FutureUsage}; use common_utils::{ + consts, ext_traits::{OptionExt, ValueExt}, pii, types::SemanticVersion, }; use error_stack::ResultExt; +use hyperswitch_domain_models::{ + payment_method_data::{ + ApplePayWalletData, GooglePayWalletData, NetworkTokenData, PaymentMethodData, + SamsungPayWalletData, WalletData, + }, + router_data::{ + AdditionalPaymentMethodConnectorResponse, ApplePayPredecryptData, ConnectorAuthType, + ConnectorResponseData, ErrorResponse, PaymentMethodToken, RouterData, + }, + router_flow_types::{ + payments::Authorize, + refunds::{Execute, RSync}, + PoFulfill, SetupMandate, + }, + router_request_types::{ + CompleteAuthorizeData, PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, + PaymentsPreProcessingData, PaymentsSyncData, ResponseId, SetupMandateRequestData, + }, + router_response_types::{ + MandateReference, PaymentsResponseData, RedirectForm, RefundsResponseData, + }, + types::{ + PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData, + PaymentsCompleteAuthorizeRouterData, PaymentsIncrementalAuthorizationRouterData, + PaymentsPreProcessingRouterData, PayoutsResponseData, PayoutsRouterData, RefundsRouterData, + SetupMandateRouterData, + }, +}; +use hyperswitch_interfaces::{api, errors}; use masking::{ExposeInterface, PeekInterface, Secret}; use serde::{Deserialize, Serialize}; use serde_json::Value; -#[cfg(feature = "payouts")] -use crate::connector::utils::PayoutsData; use crate::{ - connector::utils::{ - self, AddressDetailsData, ApplePayDecrypt, CardData, NetworkTokenData, - PaymentsAuthorizeRequestData, PaymentsCompleteAuthorizeRequestData, - PaymentsPreProcessingData, PaymentsSetupMandateRequestData, PaymentsSyncRequestData, - RecurringMandateData, RouterData, - }, - consts, - core::errors, - services, - types::{ - self, - api::{self, enums as api_enums}, - domain, - storage::enums, - transformers::{ForeignFrom, ForeignTryFrom}, - ApplePayPredecryptData, - }, + types::{PayoutsResponseRouterData, RefundsResponseRouterData, ResponseRouterData}, unimplemented_payment_method, + utils::{ + self, AddressDetailsData, ApplePayDecrypt, CardData, CardIssuer, ForeignTryFrom, + NetworkTokenData as OtherNetworkTokenData, PaymentsAuthorizeRequestData, + PaymentsCompleteAuthorizeRequestData, PaymentsPreProcessingRequestData, + PaymentsSetupMandateRequestData, PaymentsSyncRequestData, PayoutsData, + RecurringMandateData, RouterData as OtherRouterData, + }, }; #[derive(Debug, Serialize)] @@ -85,9 +104,9 @@ pub struct CybersourceZeroMandateRequest { client_reference_information: ClientReferenceInformation, } -impl TryFrom<&types::SetupMandateRouterData> for CybersourceZeroMandateRequest { +impl TryFrom<&SetupMandateRouterData> for CybersourceZeroMandateRequest { type Error = error_stack::Report; - fn try_from(item: &types::SetupMandateRouterData) -> Result { + fn try_from(item: &SetupMandateRouterData) -> Result { let email = item.get_billing_email().or(item.request.get_email())?; let bill_to = build_bill_to(item.get_optional_billing(), email)?; @@ -124,7 +143,7 @@ impl TryFrom<&types::SetupMandateRouterData> for CybersourceZeroMandateRequest { }; let (payment_information, solution) = match item.request.payment_method_data.clone() { - domain::PaymentMethodData::Card(ccard) => { + PaymentMethodData::Card(ccard) => { let card_type = match ccard .card_network .clone() @@ -147,55 +166,54 @@ impl TryFrom<&types::SetupMandateRouterData> for CybersourceZeroMandateRequest { ) } - domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data { - domain::WalletData::ApplePay(apple_pay_data) => { - match item.payment_method_token.clone() { - Some(payment_method_token) => match payment_method_token { - types::PaymentMethodToken::ApplePayDecrypt(decrypt_data) => { - let expiration_month = decrypt_data.get_expiry_month()?; - let expiration_year = decrypt_data.get_four_digit_expiry_year()?; - ( - PaymentInformation::ApplePay(Box::new( - ApplePayPaymentInformation { - tokenized_card: TokenizedCard { - number: decrypt_data - .application_primary_account_number, - cryptogram: decrypt_data - .payment_data - .online_payment_cryptogram, - transaction_type: TransactionType::ApplePay, - expiration_year, - expiration_month, - }, + PaymentMethodData::Wallet(wallet_data) => match wallet_data { + WalletData::ApplePay(apple_pay_data) => match item.payment_method_token.clone() { + Some(payment_method_token) => match payment_method_token { + PaymentMethodToken::ApplePayDecrypt(decrypt_data) => { + let expiration_month = decrypt_data.get_expiry_month()?; + let expiration_year = decrypt_data.get_four_digit_expiry_year()?; + ( + PaymentInformation::ApplePay(Box::new( + ApplePayPaymentInformation { + tokenized_card: TokenizedCard { + number: decrypt_data.application_primary_account_number, + cryptogram: decrypt_data + .payment_data + .online_payment_cryptogram, + transaction_type: TransactionType::ApplePay, + expiration_year, + expiration_month, }, - )), - Some(PaymentSolution::ApplePay), - ) - } - types::PaymentMethodToken::Token(_) => Err( - unimplemented_payment_method!("Apple Pay", "Manual", "Cybersource"), - )?, - types::PaymentMethodToken::PazeDecrypt(_) => { - Err(unimplemented_payment_method!("Paze", "Cybersource"))? - } - }, - None => ( - PaymentInformation::ApplePayToken(Box::new( - ApplePayTokenPaymentInformation { - fluid_data: FluidData { - value: Secret::from(apple_pay_data.payment_data), - descriptor: Some(FLUID_DATA_DESCRIPTOR.to_string()), - }, - tokenized_card: ApplePayTokenizedCard { - transaction_type: TransactionType::ApplePay, }, + )), + Some(PaymentSolution::ApplePay), + ) + } + PaymentMethodToken::Token(_) => Err(unimplemented_payment_method!( + "Apple Pay", + "Manual", + "Cybersource" + ))?, + PaymentMethodToken::PazeDecrypt(_) => { + Err(unimplemented_payment_method!("Paze", "Cybersource"))? + } + }, + None => ( + PaymentInformation::ApplePayToken(Box::new( + ApplePayTokenPaymentInformation { + fluid_data: FluidData { + value: Secret::from(apple_pay_data.payment_data), + descriptor: Some(FLUID_DATA_DESCRIPTOR.to_string()), }, - )), - Some(PaymentSolution::ApplePay), - ), - } - } - domain::WalletData::GooglePay(google_pay_data) => ( + tokenized_card: ApplePayTokenizedCard { + transaction_type: TransactionType::ApplePay, + }, + }, + )), + Some(PaymentSolution::ApplePay), + ), + }, + WalletData::GooglePay(google_pay_data) => ( PaymentInformation::GooglePay(Box::new(GooglePayPaymentInformation { fluid_data: FluidData { value: Secret::from( @@ -207,52 +225,52 @@ impl TryFrom<&types::SetupMandateRouterData> for CybersourceZeroMandateRequest { })), Some(PaymentSolution::GooglePay), ), - domain::WalletData::AliPayQr(_) - | domain::WalletData::AliPayRedirect(_) - | domain::WalletData::AliPayHkRedirect(_) - | domain::WalletData::MomoRedirect(_) - | domain::WalletData::KakaoPayRedirect(_) - | domain::WalletData::GoPayRedirect(_) - | domain::WalletData::GcashRedirect(_) - | domain::WalletData::ApplePayRedirect(_) - | domain::WalletData::ApplePayThirdPartySdk(_) - | domain::WalletData::DanaRedirect {} - | 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::AliPayQr(_) + | WalletData::AliPayRedirect(_) + | WalletData::AliPayHkRedirect(_) + | WalletData::MomoRedirect(_) + | WalletData::KakaoPayRedirect(_) + | WalletData::GoPayRedirect(_) + | WalletData::GcashRedirect(_) + | WalletData::ApplePayRedirect(_) + | WalletData::ApplePayThirdPartySdk(_) + | WalletData::DanaRedirect {} + | 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("Cybersource"), ))?, }, - 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::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("Cybersource"), ))? @@ -574,24 +592,22 @@ pub struct BillTo { administrative_area: Option>, #[serde(skip_serializing_if = "Option::is_none")] postal_code: Option>, - country: Option, + country: Option, email: pii::Email, } -impl From<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> - for ClientReferenceInformation -{ - fn from(item: &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>) -> Self { +impl From<&CybersourceRouterData<&PaymentsAuthorizeRouterData>> for ClientReferenceInformation { + fn from(item: &CybersourceRouterData<&PaymentsAuthorizeRouterData>) -> Self { Self { code: Some(item.router_data.connector_request_reference_id.clone()), } } } -impl From<&CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>> +impl From<&CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>> for ClientReferenceInformation { - fn from(item: &CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>) -> Self { + fn from(item: &CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>) -> Self { Self { code: Some(item.router_data.connector_request_reference_id.clone()), } @@ -600,7 +616,7 @@ impl From<&CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>> impl TryFrom<( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, Option, Option, )> for ProcessingInformation @@ -608,7 +624,7 @@ impl type Error = error_stack::Report; fn try_from( (item, solution, network): ( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, Option, Option, ), @@ -950,7 +966,7 @@ fn get_commerce_indicator_for_external_authentication( impl TryFrom<( - &CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>, Option, &CybersourceConsumerAuthValidateResponse, )> for ProcessingInformation @@ -958,7 +974,7 @@ impl type Error = error_stack::Report; fn try_from( (item, solution, three_ds_data): ( - &CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>, Option, &CybersourceConsumerAuthValidateResponse, ), @@ -1015,13 +1031,13 @@ impl impl From<( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, Option, )> for OrderInformationWithBill { fn from( (item, bill_to): ( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, Option, ), ) -> Self { @@ -1037,13 +1053,13 @@ impl impl From<( - &CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>, BillTo, )> for OrderInformationWithBill { fn from( (item, bill_to): ( - &CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>, BillTo, ), ) -> Self { @@ -1135,35 +1151,49 @@ fn build_bill_to( .unwrap_or(default_address)) } -impl ForeignFrom for Vec { - fn foreign_from(metadata: Value) -> Self { - let hashmap: std::collections::BTreeMap = - serde_json::from_str(&metadata.to_string()) - .unwrap_or(std::collections::BTreeMap::new()); - let mut vector: Self = Self::new(); - let mut iter = 1; - for (key, value) in hashmap { - vector.push(MerchantDefinedInformation { - key: iter, - value: format!("{key}={value}"), - }); - iter += 1; - } - vector +fn get_merchant_defined_information(metadata: Value) -> Vec { + let hashmap: std::collections::BTreeMap = + serde_json::from_str(&metadata.to_string()).unwrap_or(std::collections::BTreeMap::new()); + let mut vector = Vec::::new(); + let mut iter = 1; + for (key, value) in hashmap { + vector.push(MerchantDefinedInformation { + key: iter, + value: format!("{key}={value}"), + }); + iter += 1; + } + vector +} + +impl From for String { + fn from(card_issuer: CardIssuer) -> Self { + let card_type = match card_issuer { + CardIssuer::AmericanExpress => "003", + CardIssuer::Master => "002", + //"042" is the type code for Masetro Cards(International). For Maestro Cards(UK-Domestic) the mapping should be "024" + CardIssuer::Maestro => "042", + CardIssuer::Visa => "001", + CardIssuer::Discover => "004", + CardIssuer::DinersClub => "005", + CardIssuer::CarteBlanche => "006", + CardIssuer::JCB => "007", + }; + card_type.to_string() } } impl TryFrom<( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, - domain::Card, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, + hyperswitch_domain_models::payment_method_data::Card, )> for CybersourcePaymentsRequest { type Error = error_stack::Report; fn try_from( (item, ccard): ( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, - domain::Card, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, + hyperswitch_domain_models::payment_method_data::Card, ), ) -> Result { let email = item @@ -1210,7 +1240,7 @@ impl .request .metadata .clone() - .map(Vec::::foreign_from); + .map(get_merchant_defined_information); let consumer_authentication_information = item .router_data @@ -1252,14 +1282,14 @@ impl impl TryFrom<( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, hyperswitch_domain_models::payment_method_data::CardDetailsForNetworkTransactionId, )> for CybersourcePaymentsRequest { type Error = error_stack::Report; fn try_from( (item, ccard): ( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, hyperswitch_domain_models::payment_method_data::CardDetailsForNetworkTransactionId, ), ) -> Result { @@ -1293,7 +1323,7 @@ impl .request .metadata .clone() - .map(Vec::::foreign_from); + .map(get_merchant_defined_information); let consumer_authentication_information = item .router_data @@ -1335,15 +1365,15 @@ impl impl TryFrom<( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, - domain::NetworkTokenData, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, + NetworkTokenData, )> for CybersourcePaymentsRequest { type Error = error_stack::Report; fn try_from( (item, token_data): ( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, - domain::NetworkTokenData, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, + NetworkTokenData, ), ) -> Result { let email = item.router_data.request.get_email()?; @@ -1374,7 +1404,7 @@ impl .request .metadata .clone() - .map(Vec::::foreign_from); + .map(get_merchant_defined_information); let consumer_authentication_information = item .router_data @@ -1416,14 +1446,14 @@ impl impl TryFrom<( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, Box, )> for CybersourcePaymentsRequest { type Error = error_stack::Report; fn try_from( (item, paze_data): ( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, Box, ), ) -> Result { @@ -1487,7 +1517,7 @@ impl .request .metadata .clone() - .map(Vec::::foreign_from); + .map(get_merchant_defined_information); Ok(Self { processing_information, @@ -1502,15 +1532,15 @@ impl impl TryFrom<( - &CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>, - domain::Card, + &CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>, + hyperswitch_domain_models::payment_method_data::Card, )> for CybersourcePaymentsRequest { type Error = error_stack::Report; fn try_from( (item, ccard): ( - &CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>, - domain::Card, + &CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>, + hyperswitch_domain_models::payment_method_data::Card, ), ) -> Result { let email = item @@ -1574,7 +1604,7 @@ impl .request .metadata .clone() - .map(Vec::::foreign_from); + .map(get_merchant_defined_information); Ok(Self { processing_information, @@ -1589,17 +1619,17 @@ impl impl TryFrom<( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, Box, - domain::ApplePayWalletData, + ApplePayWalletData, )> for CybersourcePaymentsRequest { type Error = error_stack::Report; fn try_from( (item, apple_pay_data, apple_pay_wallet_data): ( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, Box, - domain::ApplePayWalletData, + ApplePayWalletData, ), ) -> Result { let email = item @@ -1631,7 +1661,7 @@ impl .request .metadata .clone() - .map(Vec::::foreign_from); + .map(get_merchant_defined_information); let ucaf_collection_indicator = match apple_pay_wallet_data .payment_method .network @@ -1663,15 +1693,15 @@ impl impl TryFrom<( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, - domain::GooglePayWalletData, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, + GooglePayWalletData, )> for CybersourcePaymentsRequest { type Error = error_stack::Report; fn try_from( (item, google_pay_data): ( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, - domain::GooglePayWalletData, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, + GooglePayWalletData, ), ) -> Result { let email = item @@ -1698,7 +1728,7 @@ impl .request .metadata .clone() - .map(Vec::::foreign_from); + .map(get_merchant_defined_information); Ok(Self { processing_information, @@ -1713,15 +1743,15 @@ impl impl TryFrom<( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, - Box, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, + Box, )> for CybersourcePaymentsRequest { type Error = error_stack::Report; fn try_from( (item, samsung_pay_data): ( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, - Box, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, + Box, ), ) -> Result { let email = item @@ -1762,7 +1792,7 @@ impl .request .metadata .clone() - .map(Vec::::foreign_from); + .map(get_merchant_defined_information); Ok(Self { processing_information, @@ -1798,33 +1828,31 @@ fn get_samsung_pay_fluid_data_value( Ok(samsung_pay_fluid_data_value) } -impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> - for CybersourcePaymentsRequest -{ +impl TryFrom<&CybersourceRouterData<&PaymentsAuthorizeRouterData>> for CybersourcePaymentsRequest { type Error = error_stack::Report; fn try_from( - item: &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, + item: &CybersourceRouterData<&PaymentsAuthorizeRouterData>, ) -> Result { match item.router_data.request.connector_mandate_id() { Some(connector_mandate_id) => Self::try_from((item, connector_mandate_id)), None => { match item.router_data.request.payment_method_data.clone() { - domain::PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)), - domain::PaymentMethodData::Wallet(wallet_data) => match wallet_data { - domain::WalletData::ApplePay(apple_pay_data) => { + PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)), + PaymentMethodData::Wallet(wallet_data) => match wallet_data { + WalletData::ApplePay(apple_pay_data) => { match item.router_data.payment_method_token.clone() { Some(payment_method_token) => match payment_method_token { - types::PaymentMethodToken::ApplePayDecrypt(decrypt_data) => { + PaymentMethodToken::ApplePayDecrypt(decrypt_data) => { Self::try_from((item, decrypt_data, apple_pay_data)) } - types::PaymentMethodToken::Token(_) => { + PaymentMethodToken::Token(_) => { Err(unimplemented_payment_method!( "Apple Pay", "Manual", "Cybersource" ))? } - types::PaymentMethodToken::PazeDecrypt(_) => { + PaymentMethodToken::PazeDecrypt(_) => { Err(unimplemented_payment_method!("Paze", "Cybersource"))? } }, @@ -1860,9 +1888,7 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> ); let merchant_defined_information = item.router_data.request.metadata.clone().map(|metadata| { - Vec::::foreign_from( - metadata, - ) + get_merchant_defined_information(metadata) }); let ucaf_collection_indicator = match apple_pay_data .payment_method @@ -1895,17 +1921,17 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> } } } - domain::WalletData::GooglePay(google_pay_data) => { + WalletData::GooglePay(google_pay_data) => { Self::try_from((item, google_pay_data)) } - domain::WalletData::SamsungPay(samsung_pay_data) => { + WalletData::SamsungPay(samsung_pay_data) => { Self::try_from((item, samsung_pay_data)) } - domain::WalletData::Paze(_) => { + WalletData::Paze(_) => { match item.router_data.payment_method_token.clone() { - Some(types::PaymentMethodToken::PazeDecrypt( - paze_decrypted_data, - )) => Self::try_from((item, paze_decrypted_data)), + Some(PaymentMethodToken::PazeDecrypt(paze_decrypted_data)) => { + Self::try_from((item, paze_decrypted_data)) + } _ => Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message( "Cybersource", @@ -1914,41 +1940,37 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> .into()), } } - domain::WalletData::AliPayQr(_) - | domain::WalletData::AliPayRedirect(_) - | domain::WalletData::AliPayHkRedirect(_) - | domain::WalletData::MomoRedirect(_) - | domain::WalletData::KakaoPayRedirect(_) - | domain::WalletData::GoPayRedirect(_) - | domain::WalletData::GcashRedirect(_) - | domain::WalletData::ApplePayRedirect(_) - | domain::WalletData::ApplePayThirdPartySdk(_) - | domain::WalletData::DanaRedirect {} - | domain::WalletData::GooglePayRedirect(_) - | domain::WalletData::GooglePayThirdPartySdk(_) - | domain::WalletData::MbWayRedirect(_) - | domain::WalletData::MobilePayRedirect(_) - | domain::WalletData::PaypalRedirect(_) - | domain::WalletData::PaypalSdk(_) - | 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( - utils::get_unimplemented_payment_method_error_message( - "Cybersource", - ), - ) - .into()) - } + WalletData::AliPayQr(_) + | WalletData::AliPayRedirect(_) + | WalletData::AliPayHkRedirect(_) + | WalletData::MomoRedirect(_) + | WalletData::KakaoPayRedirect(_) + | WalletData::GoPayRedirect(_) + | WalletData::GcashRedirect(_) + | WalletData::ApplePayRedirect(_) + | WalletData::ApplePayThirdPartySdk(_) + | WalletData::DanaRedirect {} + | WalletData::GooglePayRedirect(_) + | WalletData::GooglePayThirdPartySdk(_) + | WalletData::MbWayRedirect(_) + | WalletData::MobilePayRedirect(_) + | WalletData::PaypalRedirect(_) + | WalletData::PaypalSdk(_) + | 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("Cybersource"), + ) + .into()), }, // If connector_mandate_id is present MandatePayment will be the PMD, the case will be handled in the first `if` clause. // This is a fallback implementation in the event of catastrophe. - domain::PaymentMethodData::MandatePayment => { + PaymentMethodData::MandatePayment => { let connector_mandate_id = item.router_data.request.connector_mandate_id().ok_or( errors::ConnectorError::MissingRequiredField { @@ -1957,26 +1979,26 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> )?; Self::try_from((item, connector_mandate_id)) } - domain::PaymentMethodData::NetworkToken(token_data) => { + PaymentMethodData::NetworkToken(token_data) => { Self::try_from((item, token_data)) } - domain::PaymentMethodData::CardDetailsForNetworkTransactionId(card) => { + PaymentMethodData::CardDetailsForNetworkTransactionId(card) => { Self::try_from((item, card)) } - domain::PaymentMethodData::CardRedirect(_) - | domain::PaymentMethodData::PayLater(_) - | domain::PaymentMethodData::BankRedirect(_) - | domain::PaymentMethodData::BankDebit(_) - | domain::PaymentMethodData::BankTransfer(_) - | domain::PaymentMethodData::Crypto(_) - | domain::PaymentMethodData::Reward - | domain::PaymentMethodData::RealTimePayment(_) - | domain::PaymentMethodData::MobilePayment(_) - | domain::PaymentMethodData::Upi(_) - | domain::PaymentMethodData::Voucher(_) - | domain::PaymentMethodData::GiftCard(_) - | domain::PaymentMethodData::OpenBanking(_) - | domain::PaymentMethodData::CardToken(_) => { + PaymentMethodData::CardRedirect(_) + | PaymentMethodData::PayLater(_) + | PaymentMethodData::BankRedirect(_) + | PaymentMethodData::BankDebit(_) + | PaymentMethodData::BankTransfer(_) + | PaymentMethodData::Crypto(_) + | PaymentMethodData::Reward + | PaymentMethodData::RealTimePayment(_) + | PaymentMethodData::MobilePayment(_) + | PaymentMethodData::Upi(_) + | PaymentMethodData::Voucher(_) + | PaymentMethodData::GiftCard(_) + | PaymentMethodData::OpenBanking(_) + | PaymentMethodData::CardToken(_) => { Err(errors::ConnectorError::NotImplemented( utils::get_unimplemented_payment_method_error_message("Cybersource"), ) @@ -1988,16 +2010,13 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> } } -impl - TryFrom<( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, - String, - )> for CybersourcePaymentsRequest +impl TryFrom<(&CybersourceRouterData<&PaymentsAuthorizeRouterData>, String)> + for CybersourcePaymentsRequest { type Error = error_stack::Report; fn try_from( (item, connector_mandate_id): ( - &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, + &CybersourceRouterData<&PaymentsAuthorizeRouterData>, String, ), ) -> Result { @@ -2021,7 +2040,7 @@ impl .request .metadata .clone() - .map(Vec::::foreign_from); + .map(get_merchant_defined_information); Ok(Self { processing_information, payment_information, @@ -2040,15 +2059,13 @@ pub struct CybersourceAuthSetupRequest { client_reference_information: ClientReferenceInformation, } -impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> - for CybersourceAuthSetupRequest -{ +impl TryFrom<&CybersourceRouterData<&PaymentsAuthorizeRouterData>> for CybersourceAuthSetupRequest { type Error = error_stack::Report; fn try_from( - item: &CybersourceRouterData<&types::PaymentsAuthorizeRouterData>, + item: &CybersourceRouterData<&PaymentsAuthorizeRouterData>, ) -> Result { match item.router_data.request.payment_method_data.clone() { - domain::PaymentMethodData::Card(ccard) => { + PaymentMethodData::Card(ccard) => { let card_type = match ccard .card_network .clone() @@ -2073,24 +2090,24 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsAuthorizeRouterData>> client_reference_information, }) } - domain::PaymentMethodData::Wallet(_) - | 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(_) + | 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("Cybersource"), ) @@ -2117,19 +2134,19 @@ pub struct CybersourcePaymentsIncrementalAuthorizationRequest { order_information: OrderInformationIncrementalAuthorization, } -impl TryFrom<&CybersourceRouterData<&types::PaymentsCaptureRouterData>> +impl TryFrom<&CybersourceRouterData<&PaymentsCaptureRouterData>> for CybersourcePaymentsCaptureRequest { type Error = error_stack::Report; fn try_from( - item: &CybersourceRouterData<&types::PaymentsCaptureRouterData>, + item: &CybersourceRouterData<&PaymentsCaptureRouterData>, ) -> Result { let merchant_defined_information = item .router_data .request .metadata .clone() - .map(Vec::::foreign_from); + .map(get_merchant_defined_information); Ok(Self { processing_information: ProcessingInformation { capture_options: Some(CaptureOptions { @@ -2158,12 +2175,12 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsCaptureRouterData>> } } -impl TryFrom<&CybersourceRouterData<&types::PaymentsIncrementalAuthorizationRouterData>> +impl TryFrom<&CybersourceRouterData<&PaymentsIncrementalAuthorizationRouterData>> for CybersourcePaymentsIncrementalAuthorizationRequest { type Error = error_stack::Report; fn try_from( - item: &CybersourceRouterData<&types::PaymentsIncrementalAuthorizationRouterData>, + item: &CybersourceRouterData<&PaymentsIncrementalAuthorizationRouterData>, ) -> Result { let connector_merchant_config = CybersourceConnectorMetadataObject::try_from(&item.router_data.connector_meta_data)?; @@ -2218,17 +2235,17 @@ pub struct ReversalInformation { reason: String, } -impl TryFrom<&CybersourceRouterData<&types::PaymentsCancelRouterData>> for CybersourceVoidRequest { +impl TryFrom<&CybersourceRouterData<&PaymentsCancelRouterData>> for CybersourceVoidRequest { type Error = error_stack::Report; fn try_from( - value: &CybersourceRouterData<&types::PaymentsCancelRouterData>, + value: &CybersourceRouterData<&PaymentsCancelRouterData>, ) -> Result { let merchant_defined_information = value .router_data .request .metadata .clone() - .map(Vec::::foreign_from); + .map(get_merchant_defined_information); Ok(Self { client_reference_information: ClientReferenceInformation { code: Some(value.router_data.connector_request_reference_id.clone()), @@ -2262,10 +2279,10 @@ pub struct CybersourceAuthType { pub(super) api_secret: Secret, } -impl TryFrom<&types::ConnectorAuthType> for CybersourceAuthType { +impl TryFrom<&ConnectorAuthType> for CybersourceAuthType { type Error = error_stack::Report; - fn try_from(auth_type: &types::ConnectorAuthType) -> Result { - if let types::ConnectorAuthType::SignatureKey { + fn try_from(auth_type: &ConnectorAuthType) -> Result { + if let ConnectorAuthType::SignatureKey { api_key, key1, api_secret, @@ -2315,37 +2332,37 @@ pub enum CybersourceIncrementalAuthorizationStatus { AuthorizedPendingReview, } -impl ForeignFrom<(CybersourcePaymentStatus, bool)> for enums::AttemptStatus { - fn foreign_from((status, capture): (CybersourcePaymentStatus, bool)) -> Self { - match status { - CybersourcePaymentStatus::Authorized => { - if capture { - // Because Cybersource will return Payment Status as Authorized even in AutoCapture Payment - Self::Charged - } else { - Self::Authorized - } - } - CybersourcePaymentStatus::Succeeded | CybersourcePaymentStatus::Transmitted => { - Self::Charged +fn get_attempt_status((status, capture): (CybersourcePaymentStatus, bool)) -> enums::AttemptStatus { + match status { + CybersourcePaymentStatus::Authorized => { + if capture { + // Because Cybersource will return Payment Status as Authorized even in AutoCapture Payment + enums::AttemptStatus::Charged + } else { + enums::AttemptStatus::Authorized } - CybersourcePaymentStatus::Voided - | CybersourcePaymentStatus::Reversed - | CybersourcePaymentStatus::Cancelled => Self::Voided, - CybersourcePaymentStatus::Failed - | CybersourcePaymentStatus::Declined - | CybersourcePaymentStatus::AuthorizedRiskDeclined - | CybersourcePaymentStatus::Rejected - | CybersourcePaymentStatus::InvalidRequest - | CybersourcePaymentStatus::ServerError => Self::Failure, - CybersourcePaymentStatus::PendingAuthentication => Self::AuthenticationPending, - CybersourcePaymentStatus::PendingReview - | CybersourcePaymentStatus::StatusNotReceived - | CybersourcePaymentStatus::Challenge - | CybersourcePaymentStatus::Accepted - | CybersourcePaymentStatus::Pending - | CybersourcePaymentStatus::AuthorizedPendingReview => Self::Pending, } + CybersourcePaymentStatus::Succeeded | CybersourcePaymentStatus::Transmitted => { + enums::AttemptStatus::Charged + } + CybersourcePaymentStatus::Voided + | CybersourcePaymentStatus::Reversed + | CybersourcePaymentStatus::Cancelled => enums::AttemptStatus::Voided, + CybersourcePaymentStatus::Failed + | CybersourcePaymentStatus::Declined + | CybersourcePaymentStatus::AuthorizedRiskDeclined + | CybersourcePaymentStatus::Rejected + | CybersourcePaymentStatus::InvalidRequest + | CybersourcePaymentStatus::ServerError => enums::AttemptStatus::Failure, + CybersourcePaymentStatus::PendingAuthentication => { + enums::AttemptStatus::AuthenticationPending + } + CybersourcePaymentStatus::PendingReview + | CybersourcePaymentStatus::StatusNotReceived + | CybersourcePaymentStatus::Challenge + | CybersourcePaymentStatus::Accepted + | CybersourcePaymentStatus::Pending + | CybersourcePaymentStatus::AuthorizedPendingReview => enums::AttemptStatus::Pending, } } @@ -2460,84 +2477,17 @@ pub struct CybersourceErrorInformation { details: Option>, } -impl - ForeignFrom<( - &CybersourceErrorInformationResponse, - types::ResponseRouterData, - Option, - )> for types::RouterData -{ - fn foreign_from( - (error_response, item, transaction_status): ( - &CybersourceErrorInformationResponse, - types::ResponseRouterData< - F, - CybersourcePaymentsResponse, - T, - types::PaymentsResponseData, - >, - Option, - ), - ) -> Self { - let detailed_error_info = - error_response - .error_information - .details - .to_owned() - .map(|details| { - details - .iter() - .map(|details| format!("{} : {}", details.field, details.reason)) - .collect::>() - .join(", ") - }); - - let reason = get_error_reason( - error_response.error_information.message.clone(), - detailed_error_info, - None, - ); - let response = Err(types::ErrorResponse { - code: error_response - .error_information - .reason - .clone() - .unwrap_or(consts::NO_ERROR_CODE.to_string()), - message: error_response - .error_information - .reason - .clone() - .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), - reason, - status_code: item.http_code, - attempt_status: None, - connector_transaction_id: Some(error_response.id.clone()), - }); - match transaction_status { - Some(status) => Self { - response, - status, - ..item.data - }, - None => Self { - response, - ..item.data - }, - } - } -} - fn get_error_response_if_failure( (info_response, status, http_code): (&CybersourcePaymentsResponse, enums::AttemptStatus, u16), -) -> Option { +) -> Option { if utils::is_payment_failure(status) { - Some(types::ErrorResponse::foreign_from(( + Some(get_error_response( &info_response.error_information, &info_response.risk_information, Some(status), http_code, info_response.id.clone(), - ))) + )) } else { None } @@ -2545,7 +2495,7 @@ fn get_error_response_if_failure( fn get_payment_response( (info_response, status, http_code): (&CybersourcePaymentsResponse, enums::AttemptStatus, u16), -) -> Result { +) -> Result { let error_response = get_error_response_if_failure((info_response, status, http_code)); match error_response { Some(error) => Err(error), @@ -2556,7 +2506,7 @@ fn get_payment_response( info_response .token_information .clone() - .map(|token_info| types::MandateReference { + .map(|token_info| MandateReference { connector_mandate_id: token_info .payment_instrument .map(|payment_instrument| payment_instrument.id.expose()), @@ -2565,8 +2515,8 @@ fn get_payment_response( connector_mandate_request_reference_id: None, }); - Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId(info_response.id.clone()), + Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::ConnectorTransactionId(info_response.id.clone()), redirection_data: Box::new(None), mandate_reference: Box::new(mandate_reference), connector_metadata: None, @@ -2589,25 +2539,24 @@ fn get_payment_response( impl TryFrom< - types::ResponseRouterData< - api::Authorize, + ResponseRouterData< + Authorize, CybersourcePaymentsResponse, - types::PaymentsAuthorizeData, - types::PaymentsResponseData, + PaymentsAuthorizeData, + PaymentsResponseData, >, - > - for types::RouterData + > for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData< - api::Authorize, + item: ResponseRouterData< + Authorize, CybersourcePaymentsResponse, - types::PaymentsAuthorizeData, - types::PaymentsResponseData, + PaymentsAuthorizeData, + PaymentsResponseData, >, ) -> Result { - let status = enums::AttemptStatus::foreign_from(( + let status = get_attempt_status(( item.response .status .clone() @@ -2619,8 +2568,8 @@ impl .response .processor_information .as_ref() - .map(types::AdditionalPaymentMethodConnectorResponse::from) - .map(types::ConnectorResponseData::with_additional_payment_method_data); + .map(AdditionalPaymentMethodConnectorResponse::from) + .map(ConnectorResponseData::with_additional_payment_method_data); Ok(Self { status, @@ -2633,41 +2582,39 @@ impl impl TryFrom< - types::ResponseRouterData< + ResponseRouterData< F, CybersourceAuthSetupResponse, - 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, CybersourceAuthSetupResponse, - types::PaymentsAuthorizeData, - types::PaymentsResponseData, + PaymentsAuthorizeData, + PaymentsResponseData, >, ) -> Result { match item.response { CybersourceAuthSetupResponse::ClientAuthSetupInfo(info_response) => Ok(Self { status: enums::AttemptStatus::AuthenticationPending, - response: Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::NoResponseId, - redirection_data: Box::new(Some( - services::RedirectForm::CybersourceAuthSetup { - access_token: info_response - .consumer_authentication_information - .access_token, - ddc_url: info_response - .consumer_authentication_information - .device_data_collection_url, - reference_id: info_response - .consumer_authentication_information - .reference_id, - }, - )), + response: Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::NoResponseId, + redirection_data: Box::new(Some(RedirectForm::CybersourceAuthSetup { + access_token: info_response + .consumer_authentication_information + .access_token, + ddc_url: info_response + .consumer_authentication_information + .device_data_collection_url, + reference_id: info_response + .consumer_authentication_information + .reference_id, + })), mandate_reference: Box::new(None), connector_metadata: None, network_txn_id: None, @@ -2703,11 +2650,13 @@ impl ); let error_message = error_response.error_information.reason; Ok(Self { - response: Err(types::ErrorResponse { + response: Err(ErrorResponse { code: error_message .clone() - .unwrap_or(consts::NO_ERROR_CODE.to_string()), - message: error_message.unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), + .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()), + message: error_message.unwrap_or( + hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string(), + ), reason, status_code: item.http_code, attempt_status: None, @@ -2764,12 +2713,12 @@ pub enum CybersourcePreProcessingRequest { AuthValidate(Box), } -impl TryFrom<&CybersourceRouterData<&types::PaymentsPreProcessingRouterData>> +impl TryFrom<&CybersourceRouterData<&PaymentsPreProcessingRouterData>> for CybersourcePreProcessingRequest { type Error = error_stack::Report; fn try_from( - item: &CybersourceRouterData<&types::PaymentsPreProcessingRouterData>, + item: &CybersourceRouterData<&PaymentsPreProcessingRouterData>, ) -> Result { let client_reference_information = ClientReferenceInformation { code: Some(item.router_data.connector_request_reference_id.clone()), @@ -2780,7 +2729,7 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsPreProcessingRouterData>> }, )?; let payment_information = match payment_method_data { - domain::PaymentMethodData::Card(ccard) => { + PaymentMethodData::Card(ccard) => { let card_type = match ccard .card_network .clone() @@ -2801,24 +2750,24 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsPreProcessingRouterData>> }, ))) } - domain::PaymentMethodData::Wallet(_) - | 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(_) + | 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("Cybersource"), )) @@ -2903,12 +2852,12 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsPreProcessingRouterData>> } } -impl TryFrom<&CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>> +impl TryFrom<&CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>> for CybersourcePaymentsRequest { type Error = error_stack::Report; fn try_from( - item: &CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData>, + item: &CybersourceRouterData<&PaymentsCompleteAuthorizeRouterData>, ) -> Result { let payment_method_data = item.router_data.request.payment_method_data.clone().ok_or( errors::ConnectorError::MissingRequiredField { @@ -2916,25 +2865,25 @@ impl TryFrom<&CybersourceRouterData<&types::PaymentsCompleteAuthorizeRouterData> }, )?; match payment_method_data { - domain::PaymentMethodData::Card(ccard) => Self::try_from((item, ccard)), - domain::PaymentMethodData::Wallet(_) - | 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::Card(ccard) => Self::try_from((item, ccard)), + PaymentMethodData::Wallet(_) + | 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("Cybersource"), ) @@ -3009,21 +2958,21 @@ impl From for enums::AttemptStatus { impl TryFrom< - types::ResponseRouterData< + ResponseRouterData< F, CybersourcePreProcessingResponse, - types::PaymentsPreProcessingData, - types::PaymentsResponseData, + PaymentsPreProcessingData, + PaymentsResponseData, >, - > for types::RouterData + > for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData< + item: ResponseRouterData< F, CybersourcePreProcessingResponse, - types::PaymentsPreProcessingData, - types::PaymentsResponseData, + PaymentsPreProcessingData, + PaymentsResponseData, >, ) -> Result { match item.response { @@ -3031,13 +2980,13 @@ impl let status = enums::AttemptStatus::from(info_response.status); let risk_info: Option = None; if utils::is_payment_failure(status) { - let response = Err(types::ErrorResponse::foreign_from(( + let response = Err(get_error_response( &info_response.error_information, &risk_info, Some(status), item.http_code, info_response.id.clone(), - ))); + )); Ok(Self { status, @@ -3061,7 +3010,7 @@ impl .step_up_url, ) { (Some(token), Some(step_up_url)) => { - Some(services::RedirectForm::CybersourceConsumerAuth { + Some(RedirectForm::CybersourceConsumerAuth { access_token: token.expose(), step_up_url, }) @@ -3076,8 +3025,8 @@ impl .change_context(errors::ConnectorError::ResponseHandlingFailed)?; Ok(Self { status, - 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: Some(serde_json::json!({ @@ -3112,11 +3061,12 @@ impl None, ); let error_message = error_response.error_information.reason.to_owned(); - let response = Err(types::ErrorResponse { + let response = Err(ErrorResponse { code: error_message .clone() - .unwrap_or(consts::NO_ERROR_CODE.to_string()), - message: error_message.unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), + .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()), + message: error_message + .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()), reason, status_code: item.http_code, attempt_status: None, @@ -3134,24 +3084,24 @@ impl impl TryFrom< - types::ResponseRouterData< + ResponseRouterData< F, CybersourcePaymentsResponse, - 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, CybersourcePaymentsResponse, - types::CompleteAuthorizeData, - types::PaymentsResponseData, + CompleteAuthorizeData, + PaymentsResponseData, >, ) -> Result { - let status = enums::AttemptStatus::foreign_from(( + let status = get_attempt_status(( item.response .status .clone() @@ -3163,8 +3113,8 @@ impl .response .processor_information .as_ref() - .map(types::AdditionalPaymentMethodConnectorResponse::from) - .map(types::ConnectorResponseData::with_additional_payment_method_data); + .map(AdditionalPaymentMethodConnectorResponse::from) + .map(ConnectorResponseData::with_additional_payment_method_data); Ok(Self { status, @@ -3175,7 +3125,7 @@ impl } } -impl From<&ClientProcessorInformation> for types::AdditionalPaymentMethodConnectorResponse { +impl From<&ClientProcessorInformation> for AdditionalPaymentMethodConnectorResponse { fn from(processor_information: &ClientProcessorInformation) -> Self { let payment_checks = Some( serde_json::json!({"avs_response": processor_information.avs, "card_verification": processor_information.card_verification}), @@ -3190,24 +3140,24 @@ impl From<&ClientProcessorInformation> for types::AdditionalPaymentMethodConnect impl TryFrom< - types::ResponseRouterData< + ResponseRouterData< F, CybersourcePaymentsResponse, - types::PaymentsCaptureData, - types::PaymentsResponseData, + PaymentsCaptureData, + PaymentsResponseData, >, - > for types::RouterData + > for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData< + item: ResponseRouterData< F, CybersourcePaymentsResponse, - types::PaymentsCaptureData, - types::PaymentsResponseData, + PaymentsCaptureData, + PaymentsResponseData, >, ) -> Result { - let status = enums::AttemptStatus::foreign_from(( + let status = get_attempt_status(( item.response .status .clone() @@ -3225,24 +3175,24 @@ impl impl TryFrom< - types::ResponseRouterData< + ResponseRouterData< F, CybersourcePaymentsResponse, - types::PaymentsCancelData, - types::PaymentsResponseData, + PaymentsCancelData, + PaymentsResponseData, >, - > for types::RouterData + > for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData< + item: ResponseRouterData< F, CybersourcePaymentsResponse, - types::PaymentsCancelData, - types::PaymentsResponseData, + PaymentsCancelData, + PaymentsResponseData, >, ) -> Result { - let status = enums::AttemptStatus::foreign_from(( + let status = get_attempt_status(( item.response .status .clone() @@ -3261,33 +3211,28 @@ impl // zero dollar response impl TryFrom< - types::ResponseRouterData< - api::SetupMandate, + ResponseRouterData< + SetupMandate, CybersourcePaymentsResponse, - types::SetupMandateRequestData, - types::PaymentsResponseData, + SetupMandateRequestData, + PaymentsResponseData, >, - > - for types::RouterData< - api::SetupMandate, - types::SetupMandateRequestData, - types::PaymentsResponseData, - > + > for RouterData { type Error = error_stack::Report; fn try_from( - item: types::ResponseRouterData< - api::SetupMandate, + item: ResponseRouterData< + SetupMandate, CybersourcePaymentsResponse, - types::SetupMandateRequestData, - types::PaymentsResponseData, + SetupMandateRequestData, + PaymentsResponseData, >, ) -> Result { let mandate_reference = item.response .token_information .clone() - .map(|token_info| types::MandateReference { + .map(|token_info| MandateReference { connector_mandate_id: token_info .payment_instrument .map(|payment_instrument| payment_instrument.id.expose()), @@ -3295,7 +3240,7 @@ impl mandate_metadata: None, connector_mandate_request_reference_id: None, }); - let mut mandate_status = enums::AttemptStatus::foreign_from(( + let mut mandate_status = get_attempt_status(( item.response .status .clone() @@ -3313,17 +3258,15 @@ impl .response .processor_information .as_ref() - .map(types::AdditionalPaymentMethodConnectorResponse::from) - .map(types::ConnectorResponseData::with_additional_payment_method_data); + .map(AdditionalPaymentMethodConnectorResponse::from) + .map(ConnectorResponseData::with_additional_payment_method_data); Ok(Self { status: mandate_status, response: match error_response { Some(error) => Err(error), - None => Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId( - item.response.id.clone(), - ), + None => Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::ConnectorTransactionId(item.response.id.clone()), redirection_data: Box::new(None), mandate_reference: Box::new(mandate_reference), connector_metadata: None, @@ -3354,23 +3297,23 @@ impl impl ForeignTryFrom<( - types::ResponseRouterData< + ResponseRouterData< F, CybersourcePaymentsIncrementalAuthorizationResponse, T, - types::PaymentsResponseData, + PaymentsResponseData, >, bool, - )> for types::RouterData + )> for RouterData { type Error = error_stack::Report; fn foreign_try_from( data: ( - types::ResponseRouterData< + ResponseRouterData< F, CybersourcePaymentsIncrementalAuthorizationResponse, T, - types::PaymentsResponseData, + PaymentsResponseData, >, bool, ), @@ -3378,22 +3321,18 @@ impl let item = data.0; Ok(Self { response: match item.response.error_information { - Some(error) => Ok( - types::PaymentsResponseData::IncrementalAuthorizationResponse { - status: common_enums::AuthorizationStatus::Failure, - error_code: error.reason, - error_message: error.message, - connector_authorization_id: None, - }, - ), - _ => Ok( - types::PaymentsResponseData::IncrementalAuthorizationResponse { - status: item.response.status.into(), - error_code: None, - error_message: None, - connector_authorization_id: None, - }, - ), + Some(error) => Ok(PaymentsResponseData::IncrementalAuthorizationResponse { + status: common_enums::AuthorizationStatus::Failure, + error_code: error.reason, + error_message: error.message, + connector_authorization_id: None, + }), + _ => Ok(PaymentsResponseData::IncrementalAuthorizationResponse { + status: item.response.status.into(), + error_code: None, + error_message: None, + connector_authorization_id: None, + }), }, ..item.data }) @@ -3417,49 +3356,46 @@ pub struct ApplicationInformation { impl TryFrom< - types::ResponseRouterData< + ResponseRouterData< F, CybersourceTransactionResponse, - 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, CybersourceTransactionResponse, - types::PaymentsSyncData, - types::PaymentsResponseData, + PaymentsSyncData, + PaymentsResponseData, >, ) -> Result { match item.response.application_information.status { Some(status) => { - let status = enums::AttemptStatus::foreign_from(( - status, - item.data.request.is_auto_capture()?, - )); + let status = get_attempt_status((status, item.data.request.is_auto_capture()?)); let incremental_authorization_allowed = Some(status == enums::AttemptStatus::Authorized); let risk_info: Option = None; if utils::is_payment_failure(status) { Ok(Self { - response: Err(types::ErrorResponse::foreign_from(( + response: Err(get_error_response( &item.response.error_information, &risk_info, Some(status), item.http_code, item.response.id.clone(), - ))), + )), status: enums::AttemptStatus::Failure, ..item.data }) } else { Ok(Self { status, - response: Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId( + response: Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::ConnectorTransactionId( item.response.id.clone(), ), redirection_data: Box::new(None), @@ -3480,10 +3416,8 @@ impl } None => Ok(Self { status: item.data.status, - response: Ok(types::PaymentsResponseData::TransactionResponse { - resource_id: types::ResponseId::ConnectorTransactionId( - item.response.id.clone(), - ), + response: Ok(PaymentsResponseData::TransactionResponse { + resource_id: ResponseId::ConnectorTransactionId(item.response.id.clone()), redirection_data: Box::new(None), mandate_reference: Box::new(None), connector_metadata: None, @@ -3505,11 +3439,9 @@ pub struct CybersourceRefundRequest { client_reference_information: ClientReferenceInformation, } -impl TryFrom<&CybersourceRouterData<&types::RefundsRouterData>> for CybersourceRefundRequest { +impl TryFrom<&CybersourceRouterData<&RefundsRouterData>> for CybersourceRefundRequest { type Error = error_stack::Report; - fn try_from( - item: &CybersourceRouterData<&types::RefundsRouterData>, - ) -> Result { + fn try_from(item: &CybersourceRouterData<&RefundsRouterData>) -> Result { Ok(Self { order_information: OrderInformation { amount_details: Amount { @@ -3557,24 +3489,24 @@ pub struct CybersourceRefundResponse { error_information: Option, } -impl TryFrom> - for types::RefundsRouterData +impl TryFrom> + for RefundsRouterData { type Error = error_stack::Report; fn try_from( - item: types::RefundsResponseRouterData, + item: RefundsResponseRouterData, ) -> Result { let refund_status = enums::RefundStatus::from(item.response.status.clone()); let response = if utils::is_refund_failure(refund_status) { - Err(types::ErrorResponse::foreign_from(( + Err(get_error_response( &item.response.error_information, &None, None, item.http_code, item.response.id.clone(), - ))) + )) } else { - Ok(types::RefundsResponseData { + Ok(RefundsResponseData { connector_refund_id: item.response.id, refund_status: enums::RefundStatus::from(item.response.status), }) @@ -3601,12 +3533,12 @@ pub struct CybersourceRsyncResponse { error_information: Option, } -impl TryFrom> - for types::RefundsRouterData +impl TryFrom> + for RefundsRouterData { type Error = error_stack::Report; fn try_from( - item: types::RefundsResponseRouterData, + item: RefundsResponseRouterData, ) -> Result { let response = match item .response @@ -3617,7 +3549,7 @@ impl TryFrom Ok(types::RefundsResponseData { + None => Ok(RefundsResponseData { connector_refund_id: item.response.id.clone(), refund_status: match item.data.response { Ok(response) => response.refund_status, @@ -3683,7 +3615,7 @@ pub struct CybersourceRecipientInfo { locality: String, administrative_area: Secret, postal_code: Secret, - country: api_enums::CountryAlpha2, + country: enums::CountryAlpha2, phone_number: Option>, } @@ -3726,12 +3658,12 @@ pub enum CybersourcePayoutBusinessType { } #[cfg(feature = "payouts")] -impl TryFrom<&CybersourceRouterData<&types::PayoutsRouterData>> +impl TryFrom<&CybersourceRouterData<&PayoutsRouterData>> for CybersourcePayoutFulfillRequest { type Error = error_stack::Report; fn try_from( - item: &CybersourceRouterData<&types::PayoutsRouterData>, + item: &CybersourceRouterData<&PayoutsRouterData>, ) -> Result { let payout_type = item.router_data.request.get_payout_type()?; match payout_type { @@ -3848,28 +3780,24 @@ pub enum CybersourcePayoutStatus { } #[cfg(feature = "payouts")] -impl ForeignFrom for enums::PayoutStatus { - fn foreign_from(status: CybersourcePayoutStatus) -> Self { - match status { - CybersourcePayoutStatus::Accepted => Self::Success, - CybersourcePayoutStatus::Declined | CybersourcePayoutStatus::InvalidRequest => { - Self::Failed - } +fn get_payout_status(status: CybersourcePayoutStatus) -> enums::PayoutStatus { + match status { + CybersourcePayoutStatus::Accepted => enums::PayoutStatus::Success, + CybersourcePayoutStatus::Declined | CybersourcePayoutStatus::InvalidRequest => { + enums::PayoutStatus::Failed } } } #[cfg(feature = "payouts")] -impl TryFrom> - for types::PayoutsRouterData -{ +impl TryFrom> for PayoutsRouterData { type Error = error_stack::Report; fn try_from( - item: types::PayoutsResponseRouterData, + item: PayoutsResponseRouterData, ) -> Result { Ok(Self { - response: Ok(types::PayoutsResponseData { - status: Some(enums::PayoutStatus::foreign_from(item.response.status)), + response: Ok(PayoutsResponseData { + status: Some(get_payout_status(item.response.status)), connector_payout_id: Some(item.response.id), payout_eligible: None, should_add_next_step_to_process_tracker: false, @@ -3954,72 +3882,70 @@ pub struct AuthenticationErrorInformation { pub rmsg: String, } -impl - ForeignFrom<( - &Option, - &Option, - Option, - u16, - String, - )> for types::ErrorResponse -{ - fn foreign_from( - (error_data, risk_information, attempt_status, status_code, transaction_id): ( - &Option, - &Option, - Option, - u16, - String, - ), - ) -> Self { - let avs_message = risk_information - .clone() - .map(|client_risk_information| { - client_risk_information.rules.map(|rules| { - rules - .iter() - .map(|risk_info| { - risk_info.name.clone().map_or("".to_string(), |name| { - format!(" , {}", name.clone().expose()) - }) +// impl +// ForeignFrom<( +// &Option, +// &Option, +// Option, +// u16, +// String, +// )> for ErrorResponse +// { +fn get_error_response( + error_data: &Option, + risk_information: &Option, + attempt_status: Option, + status_code: u16, + transaction_id: String, +) -> ErrorResponse { + let avs_message = risk_information + .clone() + .map(|client_risk_information| { + client_risk_information.rules.map(|rules| { + rules + .iter() + .map(|risk_info| { + risk_info.name.clone().map_or("".to_string(), |name| { + format!(" , {}", name.clone().expose()) }) - .collect::>() - .join("") - }) + }) + .collect::>() + .join("") }) - .unwrap_or(Some("".to_string())); + }) + .unwrap_or(Some("".to_string())); + + let detailed_error_info = error_data + .clone() + .map(|error_data| match error_data.details { + Some(details) => details + .iter() + .map(|details| format!("{} : {}", details.field, details.reason)) + .collect::>() + .join(", "), + None => "".to_string(), + }); - let detailed_error_info = error_data + let reason = get_error_reason( + error_data.clone().and_then(|error_info| error_info.message), + detailed_error_info, + avs_message, + ); + let error_message = error_data.clone().and_then(|error_info| error_info.reason); + ErrorResponse { + code: error_message .clone() - .map(|error_data| match error_data.details { - Some(details) => details - .iter() - .map(|details| format!("{} : {}", details.field, details.reason)) - .collect::>() - .join(", "), - None => "".to_string(), - }); - - let reason = get_error_reason( - error_data.clone().and_then(|error_info| error_info.message), - detailed_error_info, - avs_message, - ); - let error_message = error_data.clone().and_then(|error_info| error_info.reason); - Self { - code: error_message - .clone() - .unwrap_or(consts::NO_ERROR_CODE.to_string()), - message: error_message - .clone() - .unwrap_or(consts::NO_ERROR_MESSAGE.to_string()), - reason, - status_code, - attempt_status, - connector_transaction_id: Some(transaction_id.clone()), - } + .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_CODE.to_string()), + message: error_message + .clone() + .unwrap_or(hyperswitch_interfaces::consts::NO_ERROR_MESSAGE.to_string()), + reason, + status_code, + attempt_status, + connector_transaction_id: Some(transaction_id.clone()), } } +// } pub fn get_error_reason( error_info: Option, diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs index 6ee8926f8df8..6c5fc9b250a4 100644 --- a/crates/hyperswitch_connectors/src/default_implementations.rs +++ b/crates/hyperswitch_connectors/src/default_implementations.rs @@ -97,6 +97,7 @@ default_imp_for_authorize_session_token!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -153,6 +154,7 @@ default_imp_for_calculate_tax!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -209,6 +211,7 @@ default_imp_for_session_update!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Digitalvirgo, connectors::Dlocal, connectors::Elavon, @@ -266,6 +269,7 @@ default_imp_for_post_session_tokens!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Digitalvirgo, connectors::Dlocal, connectors::Elavon, @@ -432,6 +436,7 @@ default_imp_for_create_customer!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -489,6 +494,7 @@ default_imp_for_connector_redirect_response!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Dlocal, connectors::Elavon, @@ -597,6 +603,7 @@ default_imp_for_post_processing_steps!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -655,6 +662,7 @@ default_imp_for_approve!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -713,6 +721,7 @@ default_imp_for_reject!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -771,6 +780,7 @@ default_imp_for_webhook_source_verification!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -830,6 +840,7 @@ default_imp_for_accept_dispute!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -888,6 +899,7 @@ default_imp_for_submit_evidence!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -946,6 +958,7 @@ default_imp_for_defend_dispute!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1013,6 +1026,7 @@ default_imp_for_file_upload!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1123,6 +1137,7 @@ default_imp_for_payouts_create!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1183,6 +1198,7 @@ default_imp_for_payouts_retrieve!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1243,6 +1259,7 @@ default_imp_for_payouts_eligibility!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1363,6 +1380,7 @@ default_imp_for_payouts_cancel!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1423,6 +1441,7 @@ default_imp_for_payouts_quote!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1483,6 +1502,7 @@ default_imp_for_payouts_recipient!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1543,6 +1563,7 @@ default_imp_for_payouts_recipient_account!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1603,6 +1624,7 @@ default_imp_for_frm_sale!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1663,6 +1685,7 @@ default_imp_for_frm_checkout!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1723,6 +1746,7 @@ default_imp_for_frm_transaction!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1783,6 +1807,7 @@ default_imp_for_frm_fulfillment!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1843,6 +1868,7 @@ default_imp_for_frm_record_return!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, diff --git a/crates/hyperswitch_connectors/src/default_implementations_v2.rs b/crates/hyperswitch_connectors/src/default_implementations_v2.rs index d747d65d73a1..a3c884c01341 100644 --- a/crates/hyperswitch_connectors/src/default_implementations_v2.rs +++ b/crates/hyperswitch_connectors/src/default_implementations_v2.rs @@ -213,6 +213,7 @@ default_imp_for_new_connector_integration_payment!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -272,6 +273,7 @@ default_imp_for_new_connector_integration_refund!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -326,6 +328,7 @@ default_imp_for_new_connector_integration_connector_access_token!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -386,6 +389,7 @@ default_imp_for_new_connector_integration_accept_dispute!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -445,6 +449,7 @@ default_imp_for_new_connector_integration_submit_evidence!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -504,6 +509,7 @@ default_imp_for_new_connector_integration_defend_dispute!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -573,6 +579,7 @@ default_imp_for_new_connector_integration_file_upload!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -634,6 +641,7 @@ default_imp_for_new_connector_integration_payouts_create!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -695,6 +703,7 @@ default_imp_for_new_connector_integration_payouts_eligibility!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -756,6 +765,7 @@ default_imp_for_new_connector_integration_payouts_fulfill!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -817,6 +827,7 @@ default_imp_for_new_connector_integration_payouts_cancel!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -878,6 +889,7 @@ default_imp_for_new_connector_integration_payouts_quote!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -939,6 +951,7 @@ default_imp_for_new_connector_integration_payouts_recipient!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1000,6 +1013,7 @@ default_imp_for_new_connector_integration_payouts_sync!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1061,6 +1075,7 @@ default_imp_for_new_connector_integration_payouts_recipient_account!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1120,6 +1135,7 @@ default_imp_for_new_connector_integration_webhook_source_verification!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1181,6 +1197,7 @@ default_imp_for_new_connector_integration_frm_sale!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1242,6 +1259,7 @@ default_imp_for_new_connector_integration_frm_checkout!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1303,6 +1321,7 @@ default_imp_for_new_connector_integration_frm_transaction!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1364,6 +1383,7 @@ default_imp_for_new_connector_integration_frm_fulfillment!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1425,6 +1445,7 @@ default_imp_for_new_connector_integration_frm_record_return!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, @@ -1483,6 +1504,7 @@ default_imp_for_new_connector_integration_revoking_mandates!( connectors::Cashtocode, connectors::Coinbase, connectors::Cryptopay, + connectors::Cybersource, connectors::Deutschebank, connectors::Digitalvirgo, connectors::Dlocal, diff --git a/crates/hyperswitch_connectors/src/types.rs b/crates/hyperswitch_connectors/src/types.rs index 0d7ecfc36433..ecc328171f2e 100644 --- a/crates/hyperswitch_connectors/src/types.rs +++ b/crates/hyperswitch_connectors/src/types.rs @@ -6,6 +6,7 @@ use hyperswitch_domain_models::{ PaymentsSyncData, RefundsData, }, router_response_types::{PaymentsResponseData, RefundsResponseData}, + types::{PayoutsData, PayoutsResponseData}, }; pub(crate) type PaymentsSyncResponseRouterData = @@ -22,6 +23,9 @@ pub(crate) type PaymentsCancelResponseRouterData = ResponseRouterData; pub(crate) type PaymentsPreprocessingResponseRouterData = ResponseRouterData; +#[cfg(feature = "payouts")] +pub type PayoutsResponseRouterData = + ResponseRouterData; // TODO: Remove `ResponseRouterData` from router crate after all the related type aliases are moved to this crate. pub struct ResponseRouterData { diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs index 14596c0f2a21..9c331d604131 100644 --- a/crates/hyperswitch_connectors/src/utils.rs +++ b/crates/hyperswitch_connectors/src/utils.rs @@ -1,6 +1,9 @@ use std::collections::{HashMap, HashSet}; -use api_models::payments::{self, Address, AddressDetails, PhoneDetails}; +use api_models::{ + payments::{self, Address, AddressDetails, PhoneDetails}, + payouts::PayoutVendorAccountDetails, +}; use base64::Engine; use common_enums::{ enums, @@ -21,7 +24,7 @@ use hyperswitch_domain_models::{ ApplePayPredecryptData, ErrorResponse, PaymentMethodToken, RecurringMandatePaymentData, }, router_request_types::{ - AuthenticationData, BrowserInformation, CompleteAuthorizeData, + AuthenticationData, BrowserInformation, CompleteAuthorizeData, MandateRevokeRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsPreProcessingData, PaymentsSyncData, RefundsData, ResponseId, SetupMandateRequestData, @@ -781,6 +784,44 @@ impl RouterData } } +#[cfg(feature = "payouts")] +pub trait PayoutsData { + fn get_transfer_id(&self) -> Result; + fn get_customer_details( + &self, + ) -> Result; + fn get_vendor_details(&self) -> Result; + #[cfg(feature = "payouts")] + fn get_payout_type(&self) -> Result; +} + +#[cfg(feature = "payouts")] +impl PayoutsData for hyperswitch_domain_models::router_request_types::PayoutsData { + fn get_transfer_id(&self) -> Result { + self.connector_payout_id + .clone() + .ok_or_else(missing_field_err("transfer_id")) + } + fn get_customer_details( + &self, + ) -> Result { + self.customer_details + .clone() + .ok_or_else(missing_field_err("customer_details")) + } + fn get_vendor_details(&self) -> Result { + self.vendor_details + .clone() + .ok_or_else(missing_field_err("vendor_details")) + } + #[cfg(feature = "payouts")] + fn get_payout_type(&self) -> Result { + self.payout_type + .to_owned() + .ok_or_else(missing_field_err("payout_type")) + } +} + pub trait AccessTokenRequestInfo { fn get_request_id(&self) -> Result, Error>; } @@ -846,6 +887,86 @@ pub trait CardData { fn get_expiry_year_as_i32(&self) -> Result, Error>; } +impl CardData + for hyperswitch_domain_models::payment_method_data::CardDetailsForNetworkTransactionId +{ + fn get_card_expiry_year_2_digit(&self) -> Result, errors::ConnectorError> { + let binding = self.card_exp_year.clone(); + let year = binding.peek(); + Ok(Secret::new( + year.get(year.len() - 2..) + .ok_or(errors::ConnectorError::RequestEncodingFailed)? + .to_string(), + )) + } + fn get_card_issuer(&self) -> Result { + get_card_issuer(self.card_number.peek()) + } + fn get_card_expiry_month_year_2_digit_with_delimiter( + &self, + delimiter: String, + ) -> Result, errors::ConnectorError> { + let year = self.get_card_expiry_year_2_digit()?; + Ok(Secret::new(format!( + "{}{}{}", + self.card_exp_month.peek(), + delimiter, + year.peek() + ))) + } + fn get_expiry_date_as_yyyymm(&self, delimiter: &str) -> Secret { + let year = self.get_expiry_year_4_digit(); + Secret::new(format!( + "{}{}{}", + year.peek(), + delimiter, + self.card_exp_month.peek() + )) + } + fn get_expiry_date_as_mmyyyy(&self, delimiter: &str) -> Secret { + let year = self.get_expiry_year_4_digit(); + Secret::new(format!( + "{}{}{}", + self.card_exp_month.peek(), + delimiter, + year.peek() + )) + } + fn get_expiry_date_as_mmyy(&self) -> Result, errors::ConnectorError> { + let year = self.get_card_expiry_year_2_digit()?.expose(); + let month = self.card_exp_month.clone().expose(); + Ok(Secret::new(format!("{month}{year}"))) + } + fn get_expiry_year_4_digit(&self) -> Secret { + let mut year = self.card_exp_year.peek().clone(); + if year.len() == 2 { + year = format!("20{}", year); + } + Secret::new(year) + } + fn get_expiry_date_as_yymm(&self) -> Result, errors::ConnectorError> { + let year = self.get_card_expiry_year_2_digit()?.expose(); + let month = self.card_exp_month.clone().expose(); + Ok(Secret::new(format!("{year}{month}"))) + } + fn get_expiry_month_as_i8(&self) -> Result, Error> { + self.card_exp_month + .peek() + .clone() + .parse::() + .change_context(errors::ConnectorError::ResponseDeserializationFailed) + .map(Secret::new) + } + fn get_expiry_year_as_i32(&self) -> Result, Error> { + self.card_exp_year + .peek() + .clone() + .parse::() + .change_context(errors::ConnectorError::ResponseDeserializationFailed) + .map(Secret::new) + } +} + impl CardData for Card { fn get_card_expiry_year_2_digit(&self) -> Result, errors::ConnectorError> { let binding = self.card_exp_year.clone(); @@ -924,6 +1045,85 @@ impl CardData for Card { } } +#[cfg(feature = "payouts")] +impl CardData for api_models::payouts::CardPayout { + fn get_card_expiry_year_2_digit(&self) -> Result, errors::ConnectorError> { + let binding = self.expiry_year.clone(); + let year = binding.peek(); + Ok(Secret::new( + year.get(year.len() - 2..) + .ok_or(errors::ConnectorError::RequestEncodingFailed)? + .to_string(), + )) + } + fn get_card_issuer(&self) -> Result { + get_card_issuer(self.card_number.peek()) + } + fn get_card_expiry_month_year_2_digit_with_delimiter( + &self, + delimiter: String, + ) -> Result, errors::ConnectorError> { + let year = self.get_card_expiry_year_2_digit()?; + Ok(Secret::new(format!( + "{}{}{}", + self.expiry_month.peek(), + delimiter, + year.peek() + ))) + } + fn get_expiry_date_as_yyyymm(&self, delimiter: &str) -> Secret { + let year = self.get_expiry_year_4_digit(); + Secret::new(format!( + "{}{}{}", + year.peek(), + delimiter, + self.expiry_month.peek() + )) + } + fn get_expiry_date_as_mmyyyy(&self, delimiter: &str) -> Secret { + let year = self.get_expiry_year_4_digit(); + Secret::new(format!( + "{}{}{}", + self.expiry_month.peek(), + delimiter, + year.peek() + )) + } + fn get_expiry_date_as_mmyy(&self) -> Result, errors::ConnectorError> { + let year = self.get_card_expiry_year_2_digit()?.expose(); + let month = self.expiry_month.clone().expose(); + Ok(Secret::new(format!("{month}{year}"))) + } + fn get_expiry_year_4_digit(&self) -> Secret { + let mut year = self.expiry_year.peek().clone(); + if year.len() == 2 { + year = format!("20{}", year); + } + Secret::new(year) + } + fn get_expiry_date_as_yymm(&self) -> Result, errors::ConnectorError> { + let year = self.get_card_expiry_year_2_digit()?.expose(); + let month = self.expiry_month.clone().expose(); + Ok(Secret::new(format!("{year}{month}"))) + } + fn get_expiry_month_as_i8(&self) -> Result, Error> { + self.expiry_month + .peek() + .clone() + .parse::() + .change_context(errors::ConnectorError::ResponseDeserializationFailed) + .map(Secret::new) + } + fn get_expiry_year_as_i32(&self) -> Result, Error> { + self.expiry_year + .peek() + .clone() + .parse::() + .change_context(errors::ConnectorError::ResponseDeserializationFailed) + .map(Secret::new) + } +} + #[track_caller] fn get_card_issuer(card_number: &str) -> Result { for (k, v) in CARD_REGEX.iter() { @@ -981,6 +1181,22 @@ pub trait AddressDetailsData { fn get_optional_line2(&self) -> Option>; } +pub trait RecurringMandateData { + fn get_original_payment_amount(&self) -> Result; + fn get_original_payment_currency(&self) -> Result; +} + +impl RecurringMandateData for RecurringMandatePaymentData { + fn get_original_payment_amount(&self) -> Result { + self.original_payment_authorized_amount + .ok_or_else(missing_field_err("original_payment_authorized_amount")) + } + fn get_original_payment_currency(&self) -> Result { + self.original_payment_authorized_currency + .ok_or_else(missing_field_err("original_payment_authorized_currency")) + } +} + impl AddressDetailsData for AddressDetails { fn get_first_name(&self) -> Result<&Secret, Error> { self.first_name @@ -1158,6 +1374,8 @@ pub trait PaymentsAuthorizeRequestData { fn get_card_holder_name_from_additional_payment_method_data( &self, ) -> Result, Error>; + fn get_optional_network_transaction_id(&self) -> Option; + fn get_optional_email(&self) -> Option; } impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData { @@ -1182,6 +1400,9 @@ impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData { .clone() .and_then(|browser_info| browser_info.language) } + fn get_optional_email(&self) -> Option { + self.email.clone() + } fn get_order_details(&self) -> Result, Error> { self.order_details @@ -1336,6 +1557,18 @@ impl PaymentsAuthorizeRequestData for PaymentsAuthorizeData { .into()), } } + fn get_optional_network_transaction_id(&self) -> Option { + self.mandate_id + .as_ref() + .and_then(|mandate_ids| match &mandate_ids.mandate_reference_id { + Some(payments::MandateReferenceId::NetworkMandateId(network_transaction_id)) => { + Some(network_transaction_id.clone()) + } + Some(payments::MandateReferenceId::ConnectorMandateId(_)) + | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) + | None => None, + }) + } } pub trait PaymentsCaptureRequestData { @@ -1419,6 +1652,18 @@ impl PaymentsCancelRequestData for PaymentsCancelData { } } +pub trait RevokeMandateRequestData { + fn get_connector_mandate_id(&self) -> Result; +} + +impl RevokeMandateRequestData for MandateRevokeRequestData { + fn get_connector_mandate_id(&self) -> Result { + self.connector_mandate_id + .clone() + .ok_or_else(missing_field_err("connector_mandate_id")) + } +} + pub trait RefundsRequestData { fn get_optional_language_from_browser_info(&self) -> Option; fn get_connector_refund_id(&self) -> Result; @@ -1548,26 +1793,96 @@ impl AddressData for Address { } } pub trait PaymentsPreProcessingRequestData { - fn get_amount(&self) -> Result; + fn get_redirect_response_payload(&self) -> Result; + fn get_email(&self) -> Result; + fn get_payment_method_type(&self) -> Result; fn get_currency(&self) -> Result; + fn get_amount(&self) -> Result; + fn get_minor_amount(&self) -> Result; fn is_auto_capture(&self) -> Result; + fn get_order_details(&self) -> Result, Error>; + fn get_webhook_url(&self) -> Result; + fn get_return_url(&self) -> Result; + fn get_browser_info(&self) -> Result; + fn get_complete_authorize_url(&self) -> Result; + fn connector_mandate_id(&self) -> Option; } impl PaymentsPreProcessingRequestData for PaymentsPreProcessingData { + fn get_email(&self) -> Result { + self.email.clone().ok_or_else(missing_field_err("email")) + } + fn get_payment_method_type(&self) -> Result { + self.payment_method_type + .to_owned() + .ok_or_else(missing_field_err("payment_method_type")) + } + fn get_currency(&self) -> Result { + self.currency.ok_or_else(missing_field_err("currency")) + } + fn get_amount(&self) -> Result { + self.amount.ok_or_else(missing_field_err("amount")) + } + + // New minor amount function for amount framework + fn get_minor_amount(&self) -> Result { + self.minor_amount.ok_or_else(missing_field_err("amount")) + } + fn is_auto_capture(&self) -> Result { match self.capture_method { Some(enums::CaptureMethod::Automatic) | None => Ok(true), Some(enums::CaptureMethod::Manual) => Ok(false), - Some(enums::CaptureMethod::ManualMultiple) | Some(enums::CaptureMethod::Scheduled) => { - Err(errors::ConnectorError::CaptureMethodNotSupported.into()) - } + Some(_) => Err(errors::ConnectorError::CaptureMethodNotSupported.into()), } } - fn get_amount(&self) -> Result { - self.amount.ok_or_else(missing_field_err("amount")) + fn get_order_details(&self) -> Result, Error> { + self.order_details + .clone() + .ok_or_else(missing_field_err("order_details")) } - fn get_currency(&self) -> Result { - self.currency.ok_or_else(missing_field_err("currency")) + fn get_webhook_url(&self) -> Result { + self.webhook_url + .clone() + .ok_or_else(missing_field_err("webhook_url")) + } + fn get_return_url(&self) -> Result { + self.router_return_url + .clone() + .ok_or_else(missing_field_err("return_url")) + } + fn get_browser_info(&self) -> Result { + self.browser_info + .clone() + .ok_or_else(missing_field_err("browser_info")) + } + fn get_complete_authorize_url(&self) -> Result { + self.complete_authorize_url + .clone() + .ok_or_else(missing_field_err("complete_authorize_url")) + } + fn get_redirect_response_payload(&self) -> Result { + self.redirect_response + .as_ref() + .and_then(|res| res.payload.to_owned()) + .ok_or( + errors::ConnectorError::MissingConnectorRedirectionPayload { + field_name: "request.redirect_response.payload", + } + .into(), + ) + } + fn connector_mandate_id(&self) -> Option { + self.mandate_id + .as_ref() + .and_then(|mandate_ids| match &mandate_ids.mandate_reference_id { + Some(payments::MandateReferenceId::ConnectorMandateId(connector_mandate_ids)) => { + connector_mandate_ids.get_connector_mandate_id() + } + Some(payments::MandateReferenceId::NetworkMandateId(_)) + | None + | Some(payments::MandateReferenceId::NetworkTokenWithNTI(_)) => None, + }) } } @@ -2241,3 +2556,22 @@ impl WalletData for hyperswitch_domain_models::payment_method_data::WalletData { } } } + +pub trait NetworkTokenData { + fn get_card_issuer(&self) -> Result; + fn get_expiry_year_4_digit(&self) -> Secret; +} + +impl NetworkTokenData for hyperswitch_domain_models::payment_method_data::NetworkTokenData { + fn get_card_issuer(&self) -> Result { + get_card_issuer(self.token_number.peek()) + } + + fn get_expiry_year_4_digit(&self) -> Secret { + let mut year = self.token_exp_year.peek().clone(); + if year.len() == 2 { + year = format!("20{}", year); + } + Secret::new(year) + } +} diff --git a/crates/hyperswitch_domain_models/src/types.rs b/crates/hyperswitch_domain_models/src/types.rs index 201a073dd3e3..04236f7adde1 100644 --- a/crates/hyperswitch_domain_models/src/types.rs +++ b/crates/hyperswitch_domain_models/src/types.rs @@ -3,21 +3,26 @@ pub use diesel_models::types::OrderDetailsWithAmount; use crate::{ router_data::{AccessToken, RouterData}, router_flow_types::{ - AccessTokenAuth, Authorize, AuthorizeSessionToken, CalculateTax, Capture, - CompleteAuthorize, CreateConnectorCustomer, Execute, PSync, PaymentMethodToken, - PostSessionTokens, PreProcessing, RSync, Session, SetupMandate, Void, + mandate_revoke::MandateRevoke, AccessTokenAuth, Authorize, AuthorizeSessionToken, + CalculateTax, Capture, CompleteAuthorize, CreateConnectorCustomer, Execute, + IncrementalAuthorization, PSync, PaymentMethodToken, PostSessionTokens, PreProcessing, + RSync, Session, SetupMandate, Void, }, router_request_types::{ AccessTokenRequestData, AuthorizeSessionTokenData, CompleteAuthorizeData, - ConnectorCustomerData, PaymentMethodTokenizationData, PaymentsAuthorizeData, - PaymentsCancelData, PaymentsCaptureData, PaymentsPostSessionTokensData, + ConnectorCustomerData, MandateRevokeRequestData, PaymentMethodTokenizationData, + PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, + PaymentsIncrementalAuthorizationData, PaymentsPostSessionTokensData, PaymentsPreProcessingData, PaymentsSessionData, PaymentsSyncData, PaymentsTaxCalculationData, RefundsData, SetupMandateRequestData, }, router_response_types::{ - PaymentsResponseData, RefundsResponseData, TaxCalculationResponseData, + MandateRevokeResponseData, PaymentsResponseData, RefundsResponseData, + TaxCalculationResponseData, }, }; +#[cfg(feature = "payouts")] +pub use crate::{router_request_types::PayoutsData, router_response_types::PayoutsResponseData}; pub type PaymentsAuthorizeRouterData = RouterData; @@ -45,3 +50,12 @@ pub type RefreshTokenRouterData = RouterData; pub type PaymentsSessionRouterData = RouterData; +pub type MandateRevokeRouterData = + RouterData; +pub type PaymentsIncrementalAuthorizationRouterData = RouterData< + IncrementalAuthorization, + PaymentsIncrementalAuthorizationData, + PaymentsResponseData, +>; +#[cfg(feature = "payouts")] +pub type PayoutsRouterData = RouterData; diff --git a/crates/router/src/connector.rs b/crates/router/src/connector.rs index 7913d6543c85..a6f62de75d4a 100644 --- a/crates/router/src/connector.rs +++ b/crates/router/src/connector.rs @@ -8,7 +8,6 @@ pub mod bluesnap; pub mod boku; pub mod braintree; pub mod checkout; -pub mod cybersource; pub mod datatrans; #[cfg(feature = "dummy_connector")] pub mod dummyconnector; @@ -47,17 +46,17 @@ 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, + coinbase, coinbase::Coinbase, cryptopay, cryptopay::Cryptopay, cybersource, + cybersource::Cybersource, 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")] @@ -65,12 +64,12 @@ 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, + braintree::Braintree, checkout::Checkout, 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..87e35839b048 100644 --- a/crates/router/src/core/payments/connector_integration_v2_impls.rs +++ b/crates/router/src/core/payments/connector_integration_v2_impls.rs @@ -700,7 +700,6 @@ default_imp_for_new_connector_integration_payment!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -761,7 +760,6 @@ default_imp_for_new_connector_integration_refund!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -816,7 +814,6 @@ default_imp_for_new_connector_integration_connector_access_token!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -893,7 +890,6 @@ default_imp_for_new_connector_integration_accept_dispute!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -952,7 +948,6 @@ default_imp_for_new_connector_integration_defend_dispute!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -995,7 +990,6 @@ default_imp_for_new_connector_integration_submit_evidence!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1065,7 +1059,6 @@ default_imp_for_new_connector_integration_file_upload!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1218,7 +1211,6 @@ default_imp_for_new_connector_integration_payouts_create!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1280,7 +1272,6 @@ default_imp_for_new_connector_integration_payouts_eligibility!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1342,7 +1333,6 @@ default_imp_for_new_connector_integration_payouts_fulfill!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1404,7 +1394,6 @@ default_imp_for_new_connector_integration_payouts_cancel!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1466,7 +1455,6 @@ default_imp_for_new_connector_integration_payouts_quote!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1528,7 +1516,6 @@ default_imp_for_new_connector_integration_payouts_recipient!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1590,7 +1577,6 @@ default_imp_for_new_connector_integration_payouts_sync!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1652,7 +1638,6 @@ default_imp_for_new_connector_integration_payouts_recipient_account!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1712,7 +1697,6 @@ default_imp_for_new_connector_integration_webhook_source_verification!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1865,7 +1849,6 @@ default_imp_for_new_connector_integration_frm_sale!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1927,7 +1910,6 @@ default_imp_for_new_connector_integration_frm_checkout!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1989,7 +1971,6 @@ default_imp_for_new_connector_integration_frm_transaction!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -2051,7 +2032,6 @@ default_imp_for_new_connector_integration_frm_fulfillment!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -2113,7 +2093,6 @@ default_imp_for_new_connector_integration_frm_record_return!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -2172,7 +2151,6 @@ default_imp_for_new_connector_integration_revoking_mandates!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs index 1358bcedba1d..84e6ad0abdc2 100644 --- a/crates/router/src/core/payments/flows.rs +++ b/crates/router/src/core/payments/flows.rs @@ -273,7 +273,6 @@ default_imp_for_webhook_source_verification!( connector::Braintree, connector::Boku, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -344,7 +343,6 @@ default_imp_for_create_customer!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -412,7 +410,6 @@ default_imp_for_connector_redirect_response!( connector::Bamboraapac, connector::Bankofamerica, connector::Boku, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Gocardless, @@ -569,7 +566,6 @@ default_imp_for_accept_dispute!( connector::Bluesnap, connector::Boku, connector::Braintree, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -661,7 +657,6 @@ default_imp_for_file_upload!( connector::Bluesnap, connector::Boku, connector::Braintree, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -730,7 +725,6 @@ default_imp_for_submit_evidence!( connector::Bluesnap, connector::Boku, connector::Braintree, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -799,7 +793,6 @@ default_imp_for_defend_dispute!( connector::Bluesnap, connector::Boku, connector::Braintree, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -927,7 +920,6 @@ default_imp_for_post_processing_steps!( connector::Adyenplatform, connector::Adyen, connector::Bankofamerica, - connector::Cybersource, connector::Gocardless, connector::Nmi, connector::Nuvei, @@ -1053,7 +1045,6 @@ default_imp_for_payouts_create!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Globalpay, connector::Gocardless, @@ -1122,7 +1113,6 @@ default_imp_for_payouts_retrieve!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1196,7 +1186,6 @@ default_imp_for_payouts_eligibility!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Globalpay, connector::Gocardless, @@ -1331,7 +1320,6 @@ default_imp_for_payouts_cancel!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Globalpay, connector::Gocardless, @@ -1401,7 +1389,6 @@ default_imp_for_payouts_quote!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Globalpay, connector::Gocardless, @@ -1472,7 +1459,6 @@ default_imp_for_payouts_recipient!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Globalpay, connector::Gocardless, @@ -1545,7 +1531,6 @@ default_imp_for_payouts_recipient_account!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1616,7 +1601,6 @@ default_imp_for_approve!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1688,7 +1672,6 @@ default_imp_for_reject!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1855,7 +1838,6 @@ default_imp_for_frm_sale!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1927,7 +1909,6 @@ default_imp_for_frm_checkout!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -1999,7 +1980,6 @@ default_imp_for_frm_transaction!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -2071,7 +2051,6 @@ default_imp_for_frm_fulfillment!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -2143,7 +2122,6 @@ default_imp_for_frm_record_return!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -2513,7 +2491,6 @@ default_imp_for_authorize_session_token!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -2582,7 +2559,6 @@ default_imp_for_calculate_tax!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -2652,7 +2628,6 @@ default_imp_for_session_update!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay, @@ -2721,7 +2696,6 @@ default_imp_for_post_session_tokens!( connector::Boku, connector::Braintree, connector::Checkout, - connector::Cybersource, connector::Datatrans, connector::Ebanx, connector::Globalpay,