Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

feat(connector): [DEUTSCHEBANK] Integrate SEPA Payments (#5826)

DEEPANSHU BANSAL6fc206062027
diff --git a/api-reference-v2/openapi_spec.json b/api-reference-v2/openapi_spec.json
index bda5fab29c..acff517e10 100644
--- a/api-reference-v2/openapi_spec.json
+++ b/api-reference-v2/openapi_spec.json
@@ -4979,6 +4979,7 @@
"cryptopay",
"cybersource",
"datatrans",
+ "deutschebank",
"dlocal",
"ebanx",
"fiserv",
@@ -17213,6 +17214,7 @@
"cryptopay",
"cybersource",
"datatrans",
+ "deutschebank",
"dlocal",
"ebanx",
"fiserv",
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json
index 9d6074fe16..e6cb4ede37 100644
--- a/api-reference/openapi_spec.json
+++ b/api-reference/openapi_spec.json
@@ -8626,6 +8626,7 @@
"cryptopay",
"cybersource",
"datatrans",
+ "deutschebank",
"dlocal",
"ebanx",
"fiserv",
@@ -21651,6 +21652,7 @@
"cryptopay",
"cybersource",
"datatrans",
+ "deutschebank",
"dlocal",
"ebanx",
"fiserv",
diff --git a/config/config.example.toml b/config/config.example.toml
index 4c543fbdec..7059626f8c 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -201,7 +201,7 @@ coinbase.base_url = "https://api.commerce.coinbase.com"
cryptopay.base_url = "https://business-sandbox.cryptopay.me"
cybersource.base_url = "https://apitest.cybersource.com/"
datatrans.base_url = "https://api.sandbox.datatrans.com/"
-deutschebank.base_url = "https://sandbox.directpos.de/rest-api/services/v2.1"
+deutschebank.base_url = "https://testmerch.directpos.de/rest-api"
dlocal.base_url = "https://sandbox.dlocal.com/"
dummyconnector.base_url = "http://localhost:8080/dummy-connector"
ebanx.base_url = "https://sandbox.ebanxpay.com/"
@@ -411,6 +411,7 @@ bankofamerica = { payment_method = "card" }
cybersource = { payment_method = "card" }
nmi = { payment_method = "card" }
payme = { payment_method = "card" }
+deutschebank = { payment_method = "bank_debit" }
[dummy_connector]
enabled = true # Whether dummy connector is enabled or not
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index 4f109fc612..90d29a6992 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -43,7 +43,7 @@ coinbase.base_url = "https://api.commerce.coinbase.com"
cryptopay.base_url = "https://business-sandbox.cryptopay.me"
cybersource.base_url = "https://apitest.cybersource.com/"
datatrans.base_url = "https://api.sandbox.datatrans.com/"
-deutschebank.base_url = "https://sandbox.directpos.de/rest-api/services/v2.1"
+deutschebank.base_url = "https://testmerch.directpos.de/rest-api"
dlocal.base_url = "https://sandbox.dlocal.com/"
dummyconnector.base_url = "http://localhost:8080/dummy-connector"
ebanx.base_url = "https://sandbox.ebanxpay.com/"
@@ -346,6 +346,7 @@ bankofamerica = { payment_method = "card" }
cybersource = { payment_method = "card" }
nmi.payment_method = "card"
payme.payment_method = "card"
+deutschebank = { payment_method = "bank_debit" }
#tokenization configuration which describe token lifetime and payment method for specific connector
[tokenization]
diff --git a/config/deployments/production.toml b/config/deployments/production.toml
index 9c387aa10a..0443d19154 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -48,7 +48,7 @@ cryptopay.base_url = "https://business.cryptopay.me/"
cybersource.base_url = "https://api.cybersource.com/"
datatrans.base_url = "https://api.datatrans.com/"
dlocal.base_url = "https://sandbox.dlocal.com/"
-deutschebank.base_url = "https://merch.directpos.de/rest-api/services/v2.1"
+deutschebank.base_url = "https://merch.directpos.de/rest-api"
dummyconnector.base_url = "http://localhost:8080/dummy-connector"
ebanx.base_url = "https://sandbox.ebanxpay.com/"
fiserv.base_url = "https://cert.api.fiservapps.com/"
@@ -359,6 +359,7 @@ bankofamerica = { payment_method = "card" }
cybersource = { payment_method = "card" }
nmi.payment_method = "card"
payme.payment_method = "card"
+deutschebank = { payment_method = "bank_debit" }
#tokenization configuration which describe token lifetime and payment method for specific connector
[tokenization]
diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml
index 706bcb6e1b..8c67924172 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -48,7 +48,7 @@ cryptopay.base_url = "https://business-sandbox.cryptopay.me"
cybersource.base_url = "https://apitest.cybersource.com/"
datatrans.base_url = "https://api.sandbox.datatrans.com/"
dlocal.base_url = "https://sandbox.dlocal.com/"
-deutschebank.base_url = "https://sandbox.directpos.de/rest-api/services/v2.1"
+deutschebank.base_url = "https://testmerch.directpos.de/rest-api"
dummyconnector.base_url = "http://localhost:8080/dummy-connector"
ebanx.base_url = "https://sandbox.ebanxpay.com/"
fiserv.base_url = "https://cert.api.fiservapps.com/"
@@ -363,6 +363,7 @@ bankofamerica = { payment_method = "card" }
cybersource = { payment_method = "card" }
nmi.payment_method = "card"
payme.payment_method = "card"
+deutschebank = { payment_method = "bank_debit" }
#tokenization configuration which describe token lifetime and payment method for specific connector
[tokenization]
diff --git a/config/development.toml b/config/development.toml
index 0b6c1c7690..1c6a4a827f 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -210,7 +210,7 @@ coinbase.base_url = "https://api.commerce.coinbase.com"
cryptopay.base_url = "https://business-sandbox.cryptopay.me"
cybersource.base_url = "https://apitest.cybersource.com/"
datatrans.base_url = "https://api.sandbox.datatrans.com/"
-deutschebank.base_url = "https://sandbox.directpos.de/rest-api/services/v2.1"
+deutschebank.base_url = "https://testmerch.directpos.de/rest-api"
dlocal.base_url = "https://sandbox.dlocal.com/"
dummyconnector.base_url = "http://localhost:8080/dummy-connector"
ebanx.base_url = "https://sandbox.ebanxpay.com/"
@@ -538,6 +538,7 @@ bankofamerica = { payment_method = "card" }
cybersource = { payment_method = "card" }
nmi = { payment_method = "card" }
payme = { payment_method = "card" }
+deutschebank = { payment_method = "bank_debit" }
[connector_customer]
connector_list = "gocardless,stax,stripe"
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index bc1be36f82..704acdfee1 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -130,7 +130,7 @@ coinbase.base_url = "https://api.commerce.coinbase.com"
cryptopay.base_url = "https://business-sandbox.cryptopay.me"
cybersource.base_url = "https://apitest.cybersource.com/"
datatrans.base_url = "https://api.sandbox.datatrans.com/"
-deutschebank.base_url = "https://sandbox.directpos.de/rest-api/services/v2.1"
+deutschebank.base_url = "https://testmerch.directpos.de/rest-api"
dlocal.base_url = "https://sandbox.dlocal.com/"
dummyconnector.base_url = "http://localhost:8080/dummy-connector"
ebanx.base_url = "https://sandbox.ebanxpay.com/"
@@ -317,6 +317,7 @@ bankofamerica = { payment_method = "card" }
cybersource = { payment_method = "card" }
nmi = { payment_method = "card" }
payme = { payment_method = "card" }
+deutschebank = { payment_method = "bank_debit" }
[dummy_connector]
enabled = true
diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs
index 2826608b63..64af2349f7 100644
--- a/crates/api_models/src/enums.rs
+++ b/crates/api_models/src/enums.rs
@@ -94,7 +94,7 @@ pub enum Connector {
Cryptopay,
Cybersource,
Datatrans,
- // Deutschebank,
+ Deutschebank,
Dlocal,
Ebanx,
Fiserv,
@@ -187,6 +187,7 @@ impl Connector {
matches!(
(self, payment_method),
(Self::Airwallex, _)
+ | (Self::Deutschebank, _)
| (Self::Globalpay, _)
| (Self::Paypal, _)
| (Self::Payu, _)
@@ -231,7 +232,7 @@ impl Connector {
| Self::Cashtocode
| Self::Coinbase
| Self::Cryptopay
- // | Self::Deutschebank
+ | Self::Deutschebank
| Self::Dlocal
| Self::Ebanx
| Self::Fiserv
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index b6500d79b8..10c9dae2cc 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -208,7 +208,7 @@ pub enum RoutableConnectors {
Cryptopay,
Cybersource,
Datatrans,
- // Deutschebank,
+ Deutschebank,
Dlocal,
Ebanx,
Fiserv,
diff --git a/crates/connector_configs/src/connector.rs b/crates/connector_configs/src/connector.rs
index fb4d92581e..3ead246702 100644
--- a/crates/connector_configs/src/connector.rs
+++ b/crates/connector_configs/src/connector.rs
@@ -171,6 +171,7 @@ pub struct ConnectorConfig {
pub opennode: Option<ConnectorTomlConfig>,
pub bambora: Option<ConnectorTomlConfig>,
pub datatrans: Option<ConnectorTomlConfig>,
+ pub deutschebank: Option<ConnectorTomlConfig>,
pub dlocal: Option<ConnectorTomlConfig>,
pub ebanx_payout: Option<ConnectorTomlConfig>,
pub fiserv: Option<ConnectorTomlConfig>,
@@ -322,6 +323,7 @@ impl ConnectorConfig {
Connector::Opennode => Ok(connector_data.opennode),
Connector::Bambora => Ok(connector_data.bambora),
Connector::Datatrans => Ok(connector_data.datatrans),
+ Connector::Deutschebank => Ok(connector_data.deutschebank),
Connector::Dlocal => Ok(connector_data.dlocal),
Connector::Ebanx => Ok(connector_data.ebanx_payout),
Connector::Fiserv => Ok(connector_data.fiserv),
diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml
index ef2cf56f31..41bcb52704 100644
--- a/crates/connector_configs/toml/development.toml
+++ b/crates/connector_configs/toml/development.toml
@@ -1353,6 +1353,14 @@ api_key="Key"
key1="Merchant ID"
api_secret="Shared Secret"
+[deutschebank]
+[[deutschebank.bank_debit]]
+ payment_method_type = "sepa"
+[deutschebank.connector_auth.SignatureKey]
+api_key="Client ID"
+key1="Merchant ID"
+api_secret="Client Key"
+
[dlocal]
[[dlocal.credit]]
payment_method_type = "Mastercard"
diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml
index c7e55ca7a7..8d6d2d3a5c 100644
--- a/crates/connector_configs/toml/production.toml
+++ b/crates/connector_configs/toml/production.toml
@@ -1125,6 +1125,14 @@ placeholder="Enter Acquirer Country Code"
required=false
type="Text"
+[deutschebank]
+[[deutschebank.bank_debit]]
+ payment_method_type = "sepa"
+[deutschebank.connector_auth.SignatureKey]
+api_key="Client ID"
+key1="Merchant ID"
+api_secret="Client Key"
+
[dlocal]
[[dlocal.credit]]
payment_method_type = "Mastercard"
diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml
index 9d44f76970..165682b750 100644
--- a/crates/connector_configs/toml/sandbox.toml
+++ b/crates/connector_configs/toml/sandbox.toml
@@ -1352,6 +1352,14 @@ api_key="Key"
key1="Merchant ID"
api_secret="Shared Secret"
+[deutschebank]
+[[deutschebank.bank_debit]]
+ payment_method_type = "sepa"
+[deutschebank.connector_auth.SignatureKey]
+api_key="Client ID"
+key1="Merchant ID"
+api_secret="Client Key"
+
[dlocal]
[[dlocal.credit]]
payment_method_type = "Mastercard"
diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs
index 3d7e55c3a9..30e67babe8 100644
--- a/crates/hyperswitch_connectors/src/connectors/deutschebank.rs
+++ b/crates/hyperswitch_connectors/src/connectors/deutschebank.rs
@@ -1,27 +1,36 @@
pub mod transformers;
+use std::time::SystemTime;
+
+use actix_web::http::header::Date;
+use base64::Engine;
+use common_enums::enums;
use common_utils::{
errors::CustomResult,
ext_traits::BytesExt,
request::{Method, Request, RequestBuilder, RequestContent},
- types::{AmountConvertor, StringMinorUnit, StringMinorUnitForConnector},
+ types::{AmountConvertor, MinorUnit, MinorUnitForConnector},
};
use error_stack::{report, ResultExt};
use hyperswitch_domain_models::{
router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
router_flow_types::{
access_token_auth::AccessTokenAuth,
- payments::{Authorize, Capture, PSync, PaymentMethodToken, Session, SetupMandate, Void},
+ payments::{
+ Authorize, Capture, CompleteAuthorize, PSync, PaymentMethodToken, Session,
+ SetupMandate, Void,
+ },
refunds::{Execute, RSync},
},
router_request_types::{
- AccessTokenRequestData, PaymentMethodTokenizationData, PaymentsAuthorizeData,
- PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData, PaymentsSyncData,
- RefundsData, SetupMandateRequestData,
+ AccessTokenRequestData, CompleteAuthorizeData, PaymentMethodTokenizationData,
+ PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSessionData,
+ PaymentsSyncData, RefundsData, SetupMandateRequestData,
},
router_response_types::{PaymentsResponseData, RefundsResponseData},
types::{
- PaymentsAuthorizeRouterData, PaymentsCaptureRouterData, PaymentsSyncRouterData,
+ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
+ PaymentsCompleteAuthorizeRouterData, PaymentsSyncRouterData, RefreshTokenRouterData,
RefundSyncRouterData, RefundsRouterData,
},
};
@@ -33,20 +42,26 @@ use hyperswitch_interfaces::{
types::{self, Response},
webhooks,
};
-use masking::{ExposeInterface, Mask};
+use masking::{ExposeInterface, Mask, Secret};
+use rand::distributions::{Alphanumeric, DistString};
+use ring::hmac;
use transformers as deutschebank;
-use crate::{constants::headers, types::ResponseRouterData, utils};
+use crate::{
+ constants::headers,
+ types::ResponseRouterData,
+ utils::{self, PaymentsCompleteAuthorizeRequestData, RefundsRequestData},
+};
#[derive(Clone)]
pub struct Deutschebank {
- amount_converter: &'static (dyn AmountConvertor<Output = StringMinorUnit> + Sync),
+ amount_converter: &'static (dyn AmountConvertor<Output = MinorUnit> + Sync),
}
impl Deutschebank {
pub fn new() -> &'static Self {
&Self {
- amount_converter: &StringMinorUnitForConnector,
+ amount_converter: &MinorUnitForConnector,
}
}
}
@@ -56,6 +71,7 @@ impl api::PaymentSession for Deutschebank {}
impl api::ConnectorAccessToken for Deutschebank {}
impl api::MandateSetup for Deutschebank {}
impl api::PaymentAuthorize for Deutschebank {}
+impl api::PaymentsCompleteAuthorize for Deutschebank {}
impl api::PaymentSync for Deutschebank {}
impl api::PaymentCapture for Deutschebank {}
impl api::PaymentVoid for Deutschebank {}
@@ -79,10 +95,20 @@ where
req: &RouterData<Flow, Request, Response>,
_connectors: &Connectors,
) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
- let mut header = vec![(
- headers::CONTENT_TYPE.to_string(),
- self.get_content_type().to_string().into(),
- )];
+ let access_token = req
+ .access_token
+ .clone()
+ .ok_or(errors::ConnectorError::FailedToObtainAuthType)?;
+ let mut header = vec![
+ (
+ headers::CONTENT_TYPE.to_string(),
+ self.get_content_type().to_string().into(),
+ ),
+ (
+ headers::AUTHORIZATION.to_string(),
+ format!("Bearer {}", access_token.token.expose()).into_masked(),
+ ),
+ ];
let mut api_key = self.get_auth_header(&req.connector_auth_type)?;
header.append(&mut api_key);
Ok(header)
@@ -96,9 +122,6 @@ impl ConnectorCommon for Deutschebank {
fn get_currency_unit(&self) -> api::CurrencyUnit {
api::CurrencyUnit::Base
- // TODO! Check connector documentation, on which unit they are processing the currency.
- // If the connector accepts amount in lower unit ( i.e cents for USD) then return api::CurrencyUnit::Minor,
- // if connector accepts amount in base unit (i.e dollars for USD) then return api::CurrencyUnit::Base
}
fn common_get_content_type(&self) -> &'static str {
@@ -116,8 +139,8 @@ impl ConnectorCommon for Deutschebank {
let auth = deutschebank::DeutschebankAuthType::try_from(auth_type)
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![(
- headers::AUTHORIZATION.to_string(),
- auth.api_key.expose().into_masked(),
+ headers::MERCHANT_ID.to_string(),
+ auth.merchant_id.expose().into_masked(),
)])
}
@@ -136,9 +159,9 @@ impl ConnectorCommon for Deutschebank {
Ok(ErrorResponse {
status_code: res.status_code,
- code: response.code,
- message: response.message,
- reason: response.reason,
+ code: response.rc,
+ message: response.message.clone(),
+ reason: Some(response.message),
attempt_status: None,
connector_transaction_id: None,
})
@@ -146,20 +169,124 @@ impl ConnectorCommon for Deutschebank {
}
impl ConnectorValidation for Deutschebank {
- //TODO: implement functions when support enabled
+ fn validate_capture_method(
+ &self,
+ capture_method: Option<enums::CaptureMethod>,
+ _pmt: Option<enums::PaymentMethodType>,
+ ) -> CustomResult<(), errors::ConnectorError> {
+ let capture_method = capture_method.unwrap_or_default();
+ match capture_method {
+ enums::CaptureMethod::Automatic | enums::CaptureMethod::Manual => Ok(()),
+ enums::CaptureMethod::ManualMultiple | enums::CaptureMethod::Scheduled => Err(
+ utils::construct_not_implemented_error_report(capture_method, self.id()),
+ ),
+ }
+ }
}
impl ConnectorIntegration<Session, PaymentsSessionData, PaymentsResponseData> for Deutschebank {
//TODO: implement sessions flow
}
-impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Deutschebank {}
-
impl ConnectorIntegration<SetupMandate, SetupMandateRequestData, PaymentsResponseData>
for Deutschebank
{
}
+impl ConnectorIntegration<AccessTokenAuth, AccessTokenRequestData, AccessToken> for Deutschebank {
+ fn get_url(
+ &self,
+ _req: &RefreshTokenRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(format!("{}/security/v1/token", self.base_url(connectors)))
+ }
+
+ fn get_content_type(&self) -> &'static str {
+ "application/x-www-form-urlencoded"
+ }
+
+ fn build_request(
+ &self,
+ req: &RefreshTokenRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ let auth = deutschebank::DeutschebankAuthType::try_from(&req.connector_auth_type)?;
+ let client_id = auth.client_id.expose();
+ let date = Date(SystemTime::now().into()).to_string();
+ let random_string = Alphanumeric.sample_string(&mut rand::thread_rng(), 50);
+
+ let string_to_sign = client_id.clone() + &date + &random_string;
+ let key = hmac::Key::new(hmac::HMAC_SHA256, auth.client_key.expose().as_bytes());
+ let client_secret = format!(
+ "V1:{}",
+ common_utils::consts::BASE64_ENGINE
+ .encode(hmac::sign(&key, string_to_sign.as_bytes()).as_ref())
+ );
+
+ let headers = vec![
+ (
+ headers::X_RANDOM_VALUE.to_string(),
+ random_string.into_masked(),
+ ),
+ (headers::X_REQUEST_DATE.to_string(), date.into_masked()),
+ (
+ headers::CONTENT_TYPE.to_string(),
+ types::RefreshTokenType::get_content_type(self)
+ .to_string()
+ .into(),
+ ),
+ ];
+
+ let connector_req = deutschebank::DeutschebankAccessTokenRequest {
+ client_id: Secret::from(client_id),
+ client_secret: Secret::from(client_secret),
+ grant_type: "client_credentials".to_string(),
+ scope: "ftx".to_string(),
+ };
+ let body = RequestContent::FormUrlEncoded(Box::new(connector_req));
+
+ let req = Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .headers(headers)
+ .url(&types::RefreshTokenType::get_url(self, req, connectors)?)
+ .set_body(body)
+ .build(),
+ );
+ Ok(req)
+ }
+
+ fn handle_response(
+ &self,
+ data: &RefreshTokenRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<RefreshTokenRouterData, errors::ConnectorError> {
+ let response: deutschebank::DeutschebankAccessTokenResponse = res
+ .response
+ .parse_struct("Paypal PaypalAuthUpdateResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res, event_builder)
+ }
+}
+
impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData> for Deutschebank {
fn get_headers(
&self,
@@ -176,9 +303,12 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
fn get_url(
&self,
_req: &PaymentsAuthorizeRouterData,
- _connectors: &Connectors,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ Ok(format!(
+ "{}/services/v2.1/managedmandate",
+ self.base_url(connectors)
+ ))
}
fn get_request_body(
@@ -226,7 +356,7 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsAuthorizeRouterData, errors::ConnectorError> {
- let response: deutschebank::DeutschebankPaymentsResponse = res
+ let response: deutschebank::DeutschebankMandatePostResponse = res
.response
.parse_struct("Deutschebank PaymentsAuthorizeResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
@@ -248,6 +378,105 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
}
}
+impl ConnectorIntegration<CompleteAuthorize, CompleteAuthorizeData, PaymentsResponseData>
+ for Deutschebank
+{
+ fn get_headers(
+ &self,
+ req: &PaymentsCompleteAuthorizeRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
+ }
+
+ fn get_content_type(&self) -> &'static str {
+ self.common_get_content_type()
+ }
+
+ fn get_url(
+ &self,
+ req: &PaymentsCompleteAuthorizeRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ let event_id = req.connector_request_reference_id.clone();
+ let tx_action = if req.request.is_auto_capture()? {
+ "authorization"
+ } else {
+ "preauthorization"
+ };
+ Ok(format!(
+ "{}/services/v2.1/payment/event/{event_id}/directdebit/{tx_action}",
+ self.base_url(connectors)
+ ))
+ }
+
+ fn get_request_body(
+ &self,
+ req: &PaymentsCompleteAuthorizeRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let amount = utils::convert_amount(
+ self.amount_converter,
+ req.request.minor_amount,
+ req.request.currency,
+ )?;
+
+ let connector_router_data = deutschebank::DeutschebankRouterData::from((amount, req));
+ let connector_req =
+ deutschebank::DeutschebankDirectDebitRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+
+ fn build_request(
+ &self,
+ req: &PaymentsCompleteAuthorizeRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .url(&types::PaymentsCompleteAuthorizeType::get_url(
+ self, req, connectors,
+ )?)
+ .attach_default_headers()
+ .headers(types::PaymentsCompleteAuthorizeType::get_headers(
+ self, req, connectors,
+ )?)
+ .set_body(types::PaymentsCompleteAuthorizeType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &PaymentsCompleteAuthorizeRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<PaymentsCompleteAuthorizeRouterData, errors::ConnectorError> {
+ let response: deutschebank::DeutschebankPaymentsResponse = res
+ .response
+ .parse_struct("Deutschebank PaymentsCompleteAuthorizeResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res, event_builder)
+ }
+}
+
impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Deutschebank {
fn get_headers(
&self,
@@ -263,10 +492,18 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Deu
fn get_url(
&self,
- _req: &PaymentsSyncRouterData,
- _connectors: &Connectors,
+ req: &PaymentsSyncRouterData,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ let tx_id = req
+ .request
+ .connector_transaction_id
+ .get_connector_transaction_id()
+ .change_context(errors::ConnectorError::MissingConnectorTransactionID)?;
+ Ok(format!(
+ "{}/services/v2.1/payment/tx/{tx_id}",
+ self.base_url(connectors)
+ ))
}
fn build_request(
@@ -292,7 +529,7 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for Deu
) -> CustomResult<PaymentsSyncRouterData, errors::ConnectorError> {
let response: deutschebank::DeutschebankPaymentsResponse = res
.response
- .parse_struct("deutschebank PaymentsSyncResponse")
+ .parse_struct("DeutschebankPaymentsSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
@@ -327,18 +564,32 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
fn get_url(
&self,
- _req: &PaymentsCaptureRouterData,
- _connectors: &Connectors,
+ req: &PaymentsCaptureRouterData,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ let event_id = req.connector_request_reference_id.clone();
+ let tx_id = req.request.connector_transaction_id.clone();
+ Ok(format!(
+ "{}/services/v2.1/payment/event/{event_id}/tx/{tx_id}/capture",
+ self.base_url(connectors)
+ ))
}
fn get_request_body(
&self,
- _req: &PaymentsCaptureRouterData,
+ req: &PaymentsCaptureRouterData,
_connectors: &Connectors,
) -> CustomResult<RequestContent, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into())
+ let amount = utils::convert_amount(
+ self.amount_converter,
+ req.request.minor_amount_to_capture,
+ req.request.currency,
+ )?;
+
+ let connector_router_data = deutschebank::DeutschebankRouterData::from((amount, req));
+ let connector_req =
+ deutschebank::DeutschebankCaptureRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
@@ -389,7 +640,86 @@ impl ConnectorIntegration<Capture, PaymentsCaptureData, PaymentsResponseData> fo
}
}
-impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Deutschebank {}
+impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Deutschebank {
+ fn get_headers(
+ &self,
+ req: &PaymentsCancelRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Vec<(String, masking::Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
+ }
+
+ fn get_content_type(&self) -> &'static str {
+ self.common_get_content_type()
+ }
+
+ fn get_url(
+ &self,
+ req: &PaymentsCancelRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ let event_id = req.connector_request_reference_id.clone();
+ let tx_id = req.request.connector_transaction_id.clone();
+ Ok(format!(
+ "{}/services/v2.1/payment/event/{event_id}/tx/{tx_id}/reversal",
+ self.base_url(connectors)
+ ))
+ }
+
+ fn get_request_body(
+ &self,
+ req: &PaymentsCancelRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let connector_req = deutschebank::DeutschebankReversalRequest::try_from(req)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
+ }
+
+ fn build_request(
+ &self,
+ req: &PaymentsCancelRouterData,
+ connectors: &Connectors,
+ ) -> CustomResult<Option<Request>, errors::ConnectorError> {
+ Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .url(&types::PaymentsVoidType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(types::PaymentsVoidType::get_headers(self, req, connectors)?)
+ .set_body(types::PaymentsVoidType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &PaymentsCancelRouterData,
+ event_builder: Option<&mut ConnectorEvent>,
+ res: Response,
+ ) -> CustomResult<PaymentsCancelRouterData, errors::ConnectorError> {
+ let response: deutschebank::DeutschebankPaymentsResponse = res
+ .response
+ .parse_struct("Deutschebank PaymentsCancelResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ event_builder.map(|i| i.set_response_body(&response));
+ router_env::logger::info!(connector_response=?response);
+ RouterData::try_from(ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ event_builder: Option<&mut ConnectorEvent>,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res, event_builder)
+ }
+}
impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Deutschebank {
fn get_headers(
@@ -406,10 +736,15 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Deutsch
fn get_url(
&self,
- _req: &RefundsRouterData<Execute>,
- _connectors: &Connectors,
+ req: &RefundsRouterData<Execute>,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ let event_id = req.attempt_id.clone();
+ let tx_id = req.request.connector_transaction_id.clone();
+ Ok(format!(
+ "{}/services/v2.1/payment/event/{event_id}/tx/{tx_id}/refund",
+ self.base_url(connectors)
+ ))
}
fn get_request_body(
@@ -455,9 +790,9 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Deutsch
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<RefundsRouterData<Execute>, errors::ConnectorError> {
- let response: deutschebank::RefundResponse = res
+ let response: deutschebank::DeutschebankPaymentsResponse = res
.response
- .parse_struct("deutschebank RefundResponse")
+ .parse_struct("DeutschebankPaymentsResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
@@ -492,10 +827,14 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Deutscheb
fn get_url(
&self,
- _req: &RefundSyncRouterData,
- _connectors: &Connectors,
+ req: &RefundSyncRouterData,
+ connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ let tx_id = req.request.get_connector_refund_id()?;
+ Ok(format!(
+ "{}/services/v2.1/payment/tx/{tx_id}",
+ self.base_url(connectors)
+ ))
}
fn build_request(
@@ -522,9 +861,9 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Deutscheb
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<RefundSyncRouterData, errors::ConnectorError> {
- let response: deutschebank::RefundResponse = res
+ let response: deutschebank::DeutschebankPaymentsResponse = res
.response
- .parse_struct("deutschebank RefundSyncResponse")
+ .parse_struct("DeutschebankPaymentsResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
diff --git a/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs b/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs
index aca2bd497b..dc146dc38d 100644
--- a/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/deutschebank/transformers.rs
@@ -1,31 +1,43 @@
+use std::collections::HashMap;
+
use common_enums::enums;
-use common_utils::types::StringMinorUnit;
+use common_utils::{pii::Email, types::MinorUnit};
use hyperswitch_domain_models::{
- payment_method_data::PaymentMethodData,
- router_data::{ConnectorAuthType, RouterData},
- router_flow_types::refunds::{Execute, RSync},
- router_request_types::ResponseId,
- router_response_types::{PaymentsResponseData, RefundsResponseData},
- types::{PaymentsAuthorizeRouterData, RefundsRouterData},
+ payment_method_data::{BankDebitData, PaymentMethodData},
+ router_data::{AccessToken, ConnectorAuthType, RouterData},
+ router_flow_types::{
+ payments::{Authorize, Capture, CompleteAuthorize, PSync},
+ refunds::{Execute, RSync},
+ },
+ router_request_types::{
+ CompleteAuthorizeData, PaymentsAuthorizeData, PaymentsCaptureData, PaymentsSyncData,
+ ResponseId,
+ },
+ router_response_types::{PaymentsResponseData, RedirectForm, RefundsResponseData},
+ types::{
+ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsCaptureRouterData,
+ PaymentsCompleteAuthorizeRouterData, RefundsRouterData,
+ },
};
use hyperswitch_interfaces::errors;
-use masking::Secret;
+use masking::{PeekInterface, Secret};
use serde::{Deserialize, Serialize};
use crate::{
- types::{RefundsResponseRouterData, ResponseRouterData},
- utils::PaymentsAuthorizeRequestData,
+ types::{PaymentsCancelResponseRouterData, RefundsResponseRouterData, ResponseRouterData},
+ utils::{
+ AddressDetailsData, PaymentsAuthorizeRequestData, PaymentsCompleteAuthorizeRequestData,
+ RefundsRequestData, RouterData as OtherRouterData,
+ },
};
-//TODO: Fill the struct with respective fields
pub struct DeutschebankRouterData<T> {
- pub amount: StringMinorUnit, // The type of amount that a connector accepts, for example, String, i64, f64, etc.
+ pub amount: MinorUnit,
pub router_data: T,
}
-impl<T> From<(StringMinorUnit, T)> for DeutschebankRouterData<T> {
- fn from((amount, item): (StringMinorUnit, T)) -> Self {
- //Todo : use utils to convert the amount to the type of amount that a connector accepts
+impl<T> From<(MinorUnit, T)> for DeutschebankRouterData<T> {
+ fn from((amount, item): (MinorUnit, T)) -> Self {
Self {
amount,
router_data: item,
@@ -33,20 +45,80 @@ impl<T> From<(StringMinorUnit, T)> for DeutschebankRouterData<T> {
}
}
-//TODO: Fill the struct with respective fields
+pub struct DeutschebankAuthType {
+ pub(super) client_id: Secret<String>,
+ pub(super) merchant_id: Secret<String>,
+ pub(super) client_key: Secret<String>,
+}
+
+impl TryFrom<&ConnectorAuthType> for DeutschebankAuthType {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {
+ match auth_type {
+ ConnectorAuthType::SignatureKey {
+ api_key,
+ key1,
+ api_secret,
+ } => Ok(Self {
+ client_id: api_key.to_owned(),
+ merchant_id: key1.to_owned(),
+ client_key: api_secret.to_owned(),
+ }),
+ _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),
+ }
+ }
+}
+
#[derive(Default, Debug, Serialize, PartialEq)]
-pub struct DeutschebankPaymentsRequest {
- amount: StringMinorUnit,
- card: DeutschebankCard,
+pub struct DeutschebankAccessTokenRequest {
+ pub grant_type: String,
+ pub client_id: Secret<String>,
+ pub client_secret: Secret<String>,
+ pub scope: String,
}
-#[derive(Default, Debug, Serialize, Eq, PartialEq)]
-pub struct DeutschebankCard {
- number: cards::CardNumber,
- expiry_month: Secret<String>,
- expiry_year: Secret<String>,
- cvc: Secret<String>,
- complete: bool,
+#[derive(Default, Debug, Clone, Deserialize, PartialEq, Serialize)]
+pub struct DeutschebankAccessTokenResponse {
+ pub access_token: Secret<String>,
+ pub expires_in: i64,
+ pub expires_on: i64,
+ pub scope: String,
+ pub token_type: String,
+}
+
+impl<F, T> TryFrom<ResponseRouterData<F, DeutschebankAccessTokenResponse, T, AccessToken>>
+ for RouterData<F, T, AccessToken>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<F, DeutschebankAccessTokenResponse, T, AccessToken>,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ response: Ok(AccessToken {
+ token: item.response.access_token,
+ expires: item.response.expires_in,
+ }),
+ ..item.data
+ })
+ }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "UPPERCASE")]
+pub enum DeutschebankSEPAApproval {
+ Click,
+ Email,
+ Sms,
+ Dynamic,
+}
+
+#[derive(Debug, Serialize, PartialEq)]
+pub struct DeutschebankPaymentsRequest {
+ approval_by: DeutschebankSEPAApproval,
+ email_address: Email,
+ iban: Secret<String>,
+ first_name: Secret<String>,
+ last_name: Secret<String>,
}
impl TryFrom<&DeutschebankRouterData<&PaymentsAuthorizeRouterData>>
@@ -56,81 +128,315 @@ impl TryFrom<&DeutschebankRouterData<&PaymentsAuthorizeRouterData>>
fn try_from(
item: &DeutschebankRouterData<&PaymentsAuthorizeRouterData>,
) -> Result<Self, Self::Error> {
+ let billing_address = item.router_data.get_billing_address()?;
match item.router_data.request.payment_method_data.clone() {
- PaymentMethodData::Card(req_card) => {
- let card = DeutschebankCard {
- number: req_card.card_number,
- expiry_month: req_card.card_exp_month,
- expiry_year: req_card.card_exp_year,
- cvc: req_card.card_cvc,
- complete: item.router_data.request.is_auto_capture()?,
- };
- Ok(Self {
- amount: item.amount.clone(),
- card,
- })
- }
+ PaymentMethodData::BankDebit(BankDebitData::SepaBankDebit { iban, .. }) => Ok(Self {
+ approval_by: DeutschebankSEPAApproval::Click,
+ email_address: item.router_data.request.get_email()?,
+ iban,
+ first_name: billing_address.get_first_name()?.clone(),
+ last_name: billing_address.get_last_name()?.clone(),
+ }),
_ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()),
}
}
}
-//TODO: Fill the struct with respective fields
-// Auth Struct
-pub struct DeutschebankAuthType {
- pub(super) api_key: Secret<String>,
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum DeutschebankSEPAMandateStatus {
+ Created,
+ PendingApproval,
+ PendingSecondaryApproval,
+ PendingReview,
+ PendingSubmission,
+ Submitted,
+ Active,
+ Failed,
+ Discarded,
+ Expired,
+ Replaced,
}
-impl TryFrom<&ConnectorAuthType> for DeutschebankAuthType {
+impl From<DeutschebankSEPAMandateStatus> for common_enums::AttemptStatus {
+ fn from(item: DeutschebankSEPAMandateStatus) -> Self {
+ match item {
+ DeutschebankSEPAMandateStatus::Active
+ | DeutschebankSEPAMandateStatus::Created
+ | DeutschebankSEPAMandateStatus::PendingApproval
+ | DeutschebankSEPAMandateStatus::PendingSecondaryApproval
+ | DeutschebankSEPAMandateStatus::PendingReview
+ | DeutschebankSEPAMandateStatus::PendingSubmission
+ | DeutschebankSEPAMandateStatus::Submitted => Self::AuthenticationPending,
+ DeutschebankSEPAMandateStatus::Failed
+ | DeutschebankSEPAMandateStatus::Discarded
+ | DeutschebankSEPAMandateStatus::Expired
+ | DeutschebankSEPAMandateStatus::Replaced => Self::Failure,
+ }
+ }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
+pub struct DeutschebankMandatePostResponse {
+ rc: String,
+ message: String,
+ mandate_id: Option<String>,
+ reference: Option<String>,
+ approval_date: Option<String>,
+ language: Option<String>,
+ approval_by: Option<DeutschebankSEPAApproval>,
+ state: Option<DeutschebankSEPAMandateStatus>,
+}
+
+impl
+ TryFrom<
+ ResponseRouterData<
+ Authorize,
+ DeutschebankMandatePostResponse,
+ PaymentsAuthorizeData,
+ PaymentsResponseData,
+ >,
+ > for RouterData<Authorize, PaymentsAuthorizeData, PaymentsResponseData>
+{
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(auth_type: &ConnectorAuthType) -> Result<Self, Self::Error> {
- match auth_type {
- ConnectorAuthType::HeaderKey { api_key } => Ok(Self {
- api_key: api_key.to_owned(),
+ fn try_from(
+ item: ResponseRouterData<
+ Authorize,
+ DeutschebankMandatePostResponse,
+ PaymentsAuthorizeData,
+ PaymentsResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ let signed_on = match item.response.approval_date {
+ Some(date) => date.chars().take(10).collect(),
+ None => time::OffsetDateTime::now_utc().date().to_string(),
+ };
+ match item.response.reference {
+ Some(reference) => Ok(Self {
+ status: if item.response.rc == "0" {
+ match item.response.state {
+ Some(state) => common_enums::AttemptStatus::from(state),
+ None => common_enums::AttemptStatus::Failure,
+ }
+ } else {
+ common_enums::AttemptStatus::Failure
+ },
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::NoResponseId,
+ redirection_data: Some(RedirectForm::Form {
+ endpoint: item.data.request.get_complete_authorize_url()?,
+ method: common_utils::request::Method::Get,
+ form_fields: HashMap::from([
+ ("reference".to_string(), reference),
+ ("signed_on".to_string(), signed_on),
+ ]),
+ }),
+ mandate_reference: None,
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charge_id: None,
+ }),
+ ..item.data
+ }),
+ None => Ok(Self {
+ status: common_enums::AttemptStatus::Failure,
+ ..item.data
}),
- _ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),
}
}
}
-// PaymentsResponse
-//TODO: Append the remaining status flags
-#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
-#[serde(rename_all = "lowercase")]
-pub enum DeutschebankPaymentStatus {
- Succeeded,
- Failed,
- #[default]
- Processing,
+
+#[derive(Debug, Serialize, Deserialize, PartialEq)]
+pub struct DeutschebankAmount {
+ amount: MinorUnit,
+ currency: api_models::enums::Currency,
}
-impl From<DeutschebankPaymentStatus> for common_enums::AttemptStatus {
- fn from(item: DeutschebankPaymentStatus) -> Self {
- match item {
- DeutschebankPaymentStatus::Succeeded => Self::Charged,
- DeutschebankPaymentStatus::Failed => Self::Failure,
- DeutschebankPaymentStatus::Processing => Self::Authorizing,
+#[derive(Debug, Serialize, PartialEq)]
+pub struct DeutschebankMeansOfPayment {
+ bank_account: DeutschebankBankAccount,
+}
+
+#[derive(Debug, Serialize, PartialEq)]
+pub struct DeutschebankBankAccount {
+ account_holder: Secret<String>,
+ iban: Secret<String>,
+}
+
+#[derive(Debug, Serialize, PartialEq)]
+pub struct DeutschebankMandate {
+ reference: Secret<String>,
+ signed_on: Secret<String>,
+}
+
+#[derive(Debug, Serialize, PartialEq)]
+pub struct DeutschebankDirectDebitRequest {
+ amount_total: DeutschebankAmount,
+ means_of_payment: DeutschebankMeansOfPayment,
+ mandate: DeutschebankMandate,
+}
+
+impl TryFrom<&DeutschebankRouterData<&PaymentsCompleteAuthorizeRouterData>>
+ for DeutschebankDirectDebitRequest
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: &DeutschebankRouterData<&PaymentsCompleteAuthorizeRouterData>,
+ ) -> Result<Self, Self::Error> {
+ let account_holder = item.router_data.get_billing_address()?.get_full_name()?;
+ let redirect_response = item.router_data.request.redirect_response.clone().ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "redirect_response",
+ },
+ )?;
+ let queries_params = redirect_response
+ .params
+ .map(|param| {
+ let mut queries = HashMap::<String, String>::new();
+ let values = param.peek().split('&').collect::<Vec<&str>>();
+ for value in values {
+ let pair = value.split('=').collect::<Vec<&str>>();
+ queries.insert(
+ pair.first()
+ .ok_or(errors::ConnectorError::ResponseDeserializationFailed)?
+ .to_string(),
+ pair.get(1)
+ .ok_or(errors::ConnectorError::ResponseDeserializationFailed)?
+ .to_string(),
+ );
+ }
+ Ok::<_, errors::ConnectorError>(queries)
+ })
+ .transpose()?
+ .ok_or(errors::ConnectorError::ResponseDeserializationFailed)?;
+ let reference = Secret::from(
+ queries_params
+ .get("reference")
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "reference",
+ })?
+ .to_owned(),
+ );
+ let signed_on = Secret::from(
+ queries_params
+ .get("signed_on")
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "signed_on",
+ })?
+ .to_owned(),
+ );
+
+ match item.router_data.request.payment_method_data.clone() {
+ Some(PaymentMethodData::BankDebit(BankDebitData::SepaBankDebit { iban, .. })) => {
+ Ok(Self {
+ amount_total: DeutschebankAmount {
+ amount: item.amount,
+ currency: item.router_data.request.currency,
+ },
+ means_of_payment: DeutschebankMeansOfPayment {
+ bank_account: DeutschebankBankAccount {
+ account_holder,
+ iban,
+ },
+ },
+ mandate: {
+ DeutschebankMandate {
+ reference,
+ signed_on,
+ }
+ },
+ })
+ }
+ _ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()),
}
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
+#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
+#[serde(rename_all = "snake_case")]
+pub enum DeutschebankTXAction {
+ Authorization,
+ Capture,
+ Credit,
+ Preauthorization,
+ Refund,
+ Reversal,
+ RiskCheck,
+ #[serde(rename = "verify-mop")]
+ VerifyMop,
+ Payment,
+ AccountInformation,
+}
+
+#[derive(Debug, Deserialize, Serialize, PartialEq)]
+pub struct BankAccount {
+ account_holder: Option<Secret<String>>,
+ bank_name: Option<Secret<String>>,
+ bic: Option<Secret<String>>,
+ iban: Option<Secret<String>>,
+}
+
+#[derive(Debug, Deserialize, Serialize, PartialEq)]
+pub struct TransactionBankAccountInfo {
+ bank_account: Option<BankAccount>,
+}
+
+#[derive(Debug, Deserialize, Serialize, PartialEq)]
+pub struct DeutschebankTransactionInfo {
+ back_state: Option<String>,
+ ip_address: Option<Secret<String>>,
+ #[serde(rename = "type")]
+ pm_type: Option<String>,
+ transaction_bankaccount_info: Option<TransactionBankAccountInfo>,
+}
+
+#[derive(Debug, Deserialize, Serialize, PartialEq)]
pub struct DeutschebankPaymentsResponse {
- status: DeutschebankPaymentStatus,
- id: String,
+ rc: String,
+ message: String,
+ timestamp: String,
+ back_ext_id: Option<String>,
+ back_rc: Option<String>,
+ event_id: Option<String>,
+ kind: Option<String>,
+ tx_action: Option<DeutschebankTXAction>,
+ tx_id: String,
+ amount_total: Option<DeutschebankAmount>,
+ transaction_info: Option<DeutschebankTransactionInfo>,
}
-impl<F, T> TryFrom<ResponseRouterData<F, DeutschebankPaymentsResponse, T, PaymentsResponseData>>
- for RouterData<F, T, PaymentsResponseData>
+impl
+ TryFrom<
+ ResponseRouterData<
+ CompleteAuthorize,
+ DeutschebankPaymentsResponse,
+ CompleteAuthorizeData,
+ PaymentsResponseData,
+ >,
+ > for RouterData<CompleteAuthorize, CompleteAuthorizeData, PaymentsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: ResponseRouterData<F, DeutschebankPaymentsResponse, T, PaymentsResponseData>,
+ item: ResponseRouterData<
+ CompleteAuthorize,
+ DeutschebankPaymentsResponse,
+ CompleteAuthorizeData,
+ PaymentsResponseData,
+ >,
) -> Result<Self, Self::Error> {
Ok(Self {
- status: common_enums::AttemptStatus::from(item.response.status),
+ status: if item.response.rc == "0" {
+ match item.data.request.is_auto_capture()? {
+ true => common_enums::AttemptStatus::Charged,
+ false => common_enums::AttemptStatus::Authorized,
+ }
+ } else {
+ common_enums::AttemptStatus::Failure
+ },
response: Ok(PaymentsResponseData::TransactionResponse {
- resource_id: ResponseId::ConnectorTransactionId(item.response.id),
+ resource_id: ResponseId::ConnectorTransactionId(item.response.tx_id),
redirection_data: None,
mandate_reference: None,
connector_metadata: None,
@@ -144,87 +450,230 @@ impl<F, T> TryFrom<ResponseRouterData<F, DeutschebankPaymentsResponse, T, Paymen
}
}
-//TODO: Fill the struct with respective fields
-// REFUND :
-// Type definition for RefundRequest
-#[derive(Default, Debug, Serialize)]
-pub struct DeutschebankRefundRequest {
- pub amount: StringMinorUnit,
+#[derive(Debug, Serialize, PartialEq)]
+#[serde(rename_all = "UPPERCASE")]
+pub enum DeutschebankTransactionKind {
+ Directdebit,
}
-impl<F> TryFrom<&DeutschebankRouterData<&RefundsRouterData<F>>> for DeutschebankRefundRequest {
+#[derive(Debug, Serialize, PartialEq)]
+pub struct DeutschebankCaptureRequest {
+ changed_amount: MinorUnit,
+ kind: DeutschebankTransactionKind,
+}
+
+impl TryFrom<&DeutschebankRouterData<&PaymentsCaptureRouterData>> for DeutschebankCaptureRequest {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(item: &DeutschebankRouterData<&RefundsRouterData<F>>) -> Result<Self, Self::Error> {
+ fn try_from(
+ item: &DeutschebankRouterData<&PaymentsCaptureRouterData>,
+ ) -> Result<Self, Self::Error> {
Ok(Self {
- amount: item.amount.to_owned(),
+ changed_amount: item.amount,
+ kind: DeutschebankTransactionKind::Directdebit,
})
}
}
-// Type definition for Refund Response
-
-#[allow(dead_code)]
-#[derive(Debug, Serialize, Default, Deserialize, Clone)]
-pub enum RefundStatus {
- Succeeded,
- Failed,
- #[default]
- Processing,
+impl
+ TryFrom<
+ ResponseRouterData<
+ Capture,
+ DeutschebankPaymentsResponse,
+ PaymentsCaptureData,
+ PaymentsResponseData,
+ >,
+ > for RouterData<Capture, PaymentsCaptureData, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<
+ Capture,
+ DeutschebankPaymentsResponse,
+ PaymentsCaptureData,
+ PaymentsResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(item.response.tx_id),
+ redirection_data: None,
+ mandate_reference: None,
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charge_id: None,
+ }),
+ status: if item.response.rc == "0" {
+ common_enums::AttemptStatus::Charged
+ } else {
+ common_enums::AttemptStatus::Failure
+ },
+ ..item.data
+ })
+ }
}
-impl From<RefundStatus> for enums::RefundStatus {
- fn from(item: RefundStatus) -> Self {
- match item {
- RefundStatus::Succeeded => Self::Success,
- RefundStatus::Failed => Self::Failure,
- RefundStatus::Processing => Self::Pending,
- //TODO: Review mapping
+impl
+ TryFrom<
+ ResponseRouterData<
+ PSync,
+ DeutschebankPaymentsResponse,
+ PaymentsSyncData,
+ PaymentsResponseData,
+ >,
+ > for RouterData<PSync, PaymentsSyncData, PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: ResponseRouterData<
+ PSync,
+ DeutschebankPaymentsResponse,
+ PaymentsSyncData,
+ PaymentsResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ let status = if item.response.rc == "0" {
+ item.response
+ .tx_action
+ .and_then(|tx_action| match tx_action {
+ DeutschebankTXAction::Preauthorization => {
+ Some(common_enums::AttemptStatus::Authorized)
+ }
+ DeutschebankTXAction::Authorization | DeutschebankTXAction::Capture => {
+ Some(common_enums::AttemptStatus::Charged)
+ }
+ DeutschebankTXAction::Credit
+ | DeutschebankTXAction::Refund
+ | DeutschebankTXAction::Reversal
+ | DeutschebankTXAction::RiskCheck
+ | DeutschebankTXAction::VerifyMop
+ | DeutschebankTXAction::Payment
+ | DeutschebankTXAction::AccountInformation => None,
+ })
+ } else {
+ Some(common_enums::AttemptStatus::Failure)
+ };
+ match status {
+ Some(status) => Ok(Self {
+ status,
+ ..item.data
+ }),
+ None => Ok(Self { ..item.data }),
}
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Clone, Serialize, Deserialize)]
-pub struct RefundResponse {
- id: String,
- status: RefundStatus,
+#[derive(Debug, Serialize)]
+pub struct DeutschebankReversalRequest {
+ kind: DeutschebankTransactionKind,
+}
+
+impl TryFrom<&PaymentsCancelRouterData> for DeutschebankReversalRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(_item: &PaymentsCancelRouterData) -> Result<Self, Self::Error> {
+ Ok(Self {
+ kind: DeutschebankTransactionKind::Directdebit,
+ })
+ }
}
-impl TryFrom<RefundsResponseRouterData<Execute, RefundResponse>> for RefundsRouterData<Execute> {
+impl TryFrom<PaymentsCancelResponseRouterData<DeutschebankPaymentsResponse>>
+ for PaymentsCancelRouterData
+{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: RefundsResponseRouterData<Execute, RefundResponse>,
+ item: PaymentsCancelResponseRouterData<DeutschebankPaymentsResponse>,
) -> Result<Self, Self::Error> {
Ok(Self {
- response: Ok(RefundsResponseData {
- connector_refund_id: item.response.id.to_string(),
- refund_status: enums::RefundStatus::from(item.response.status),
- }),
+ status: if item.response.rc == "0" {
+ common_enums::AttemptStatus::Voided
+ } else {
+ common_enums::AttemptStatus::VoidFailed
+ },
..item.data
})
}
}
-impl TryFrom<RefundsResponseRouterData<RSync, RefundResponse>> for RefundsRouterData<RSync> {
+#[derive(Debug, Serialize)]
+pub struct DeutschebankRefundRequest {
+ changed_amount: MinorUnit,
+ kind: DeutschebankTransactionKind,
+}
+
+impl<F> TryFrom<&DeutschebankRouterData<&RefundsRouterData<F>>> for DeutschebankRefundRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &DeutschebankRouterData<&RefundsRouterData<F>>) -> Result<Self, Self::Error> {
+ Ok(Self {
+ changed_amount: item.amount.to_owned(),
+ kind: DeutschebankTransactionKind::Directdebit,
+ })
+ }
+}
+
+impl TryFrom<RefundsResponseRouterData<Execute, DeutschebankPaymentsResponse>>
+ for RefundsRouterData<Execute>
+{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: RefundsResponseRouterData<RSync, RefundResponse>,
+ item: RefundsResponseRouterData<Execute, DeutschebankPaymentsResponse>,
) -> Result<Self, Self::Error> {
Ok(Self {
response: Ok(RefundsResponseData {
- connector_refund_id: item.response.id.to_string(),
- refund_status: enums::RefundStatus::from(item.response.status),
+ connector_refund_id: item.response.tx_id,
+ refund_status: if item.response.rc == "0" {
+ enums::RefundStatus::Success
+ } else {
+ enums::RefundStatus::Failure
+ },
}),
..item.data
})
}
}
-//TODO: Fill the struct with respective fields
+impl TryFrom<RefundsResponseRouterData<RSync, DeutschebankPaymentsResponse>>
+ for RefundsRouterData<RSync>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: RefundsResponseRouterData<RSync, DeutschebankPaymentsResponse>,
+ ) -> Result<Self, Self::Error> {
+ let status = if item.response.rc == "0" {
+ item.response
+ .tx_action
+ .and_then(|tx_action| match tx_action {
+ DeutschebankTXAction::Credit | DeutschebankTXAction::Refund => {
+ Some(enums::RefundStatus::Success)
+ }
+ DeutschebankTXAction::Preauthorization
+ | DeutschebankTXAction::Authorization
+ | DeutschebankTXAction::Capture
+ | DeutschebankTXAction::Reversal
+ | DeutschebankTXAction::RiskCheck
+ | DeutschebankTXAction::VerifyMop
+ | DeutschebankTXAction::Payment
+ | DeutschebankTXAction::AccountInformation => None,
+ })
+ } else {
+ Some(enums::RefundStatus::Failure)
+ };
+ match status {
+ Some(refund_status) => Ok(Self {
+ response: Ok(RefundsResponseData {
+ refund_status,
+ connector_refund_id: item.data.request.get_connector_refund_id()?,
+ }),
+ ..item.data
+ }),
+ None => Ok(Self { ..item.data }),
+ }
+ }
+}
+
#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
pub struct DeutschebankErrorResponse {
- pub status_code: u16,
- pub code: String,
+ pub rc: String,
pub message: String,
- pub reason: Option<String>,
}
diff --git a/crates/hyperswitch_connectors/src/constants.rs b/crates/hyperswitch_connectors/src/constants.rs
index 86d6144b1f..c5ca6512a3 100644
--- a/crates/hyperswitch_connectors/src/constants.rs
+++ b/crates/hyperswitch_connectors/src/constants.rs
@@ -7,7 +7,10 @@ pub(crate) mod headers {
pub(crate) const DATE: &str = "Date";
pub(crate) const IDEMPOTENCY_KEY: &str = "Idempotency-Key";
pub(crate) const MESSAGE_SIGNATURE: &str = "Message-Signature";
+ pub(crate) const MERCHANT_ID: &str = "Merchant-ID";
pub(crate) const TIMESTAMP: &str = "Timestamp";
pub(crate) const X_ACCEPT_VERSION: &str = "X-Accept-Version";
pub(crate) const X_NN_ACCESS_KEY: &str = "X-NN-Access-Key";
+ pub(crate) const X_RANDOM_VALUE: &str = "X-RandomValue";
+ pub(crate) const X_REQUEST_DATE: &str = "X-RequestDate";
}
diff --git a/crates/hyperswitch_connectors/src/default_implementations.rs b/crates/hyperswitch_connectors/src/default_implementations.rs
index 1f50150c08..b9ae736e43 100644
--- a/crates/hyperswitch_connectors/src/default_implementations.rs
+++ b/crates/hyperswitch_connectors/src/default_implementations.rs
@@ -190,7 +190,6 @@ macro_rules! default_imp_for_complete_authorize {
default_imp_for_complete_authorize!(
connectors::Bitpay,
- connectors::Deutschebank,
connectors::Fiserv,
connectors::Fiservemea,
connectors::Fiuu,
diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rs
index f714dfac86..b64c745eec 100644
--- a/crates/hyperswitch_domain_models/src/payment_method_data.rs
+++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs
@@ -1308,6 +1308,16 @@ pub struct TokenizedBankRedirectValue2 {
pub customer_id: Option<id_type::CustomerId>,
}
+#[derive(Debug, serde::Serialize, serde::Deserialize)]
+pub struct TokenizedBankDebitValue2 {
+ pub customer_id: Option<id_type::CustomerId>,
+}
+
+#[derive(Debug, serde::Serialize, serde::Deserialize)]
+pub struct TokenizedBankDebitValue1 {
+ pub data: BankDebitData,
+}
+
pub trait GetPaymentMethodType {
fn get_payment_method_type(&self) -> api_enums::PaymentMethodType;
}
diff --git a/crates/hyperswitch_domain_models/src/types.rs b/crates/hyperswitch_domain_models/src/types.rs
index d27c797409..3d47afb9b8 100644
--- a/crates/hyperswitch_domain_models/src/types.rs
+++ b/crates/hyperswitch_domain_models/src/types.rs
@@ -1,13 +1,14 @@
use crate::{
- router_data::RouterData,
+ router_data::{AccessToken, RouterData},
router_flow_types::{
- Authorize, CalculateTax, Capture, CompleteAuthorize, CreateConnectorCustomer, PSync,
- PaymentMethodToken, RSync, SetupMandate, Void,
+ AccessTokenAuth, Authorize, CalculateTax, Capture, CompleteAuthorize,
+ CreateConnectorCustomer, PSync, PaymentMethodToken, RSync, SetupMandate, Void,
},
router_request_types::{
- CompleteAuthorizeData, ConnectorCustomerData, PaymentMethodTokenizationData,
- PaymentsAuthorizeData, PaymentsCancelData, PaymentsCaptureData, PaymentsSyncData,
- PaymentsTaxCalculationData, RefundsData, SetupMandateRequestData,
+ AccessTokenRequestData, CompleteAuthorizeData, ConnectorCustomerData,
+ PaymentMethodTokenizationData, PaymentsAuthorizeData, PaymentsCancelData,
+ PaymentsCaptureData, PaymentsSyncData, PaymentsTaxCalculationData, RefundsData,
+ SetupMandateRequestData,
},
router_response_types::{
PaymentsResponseData, RefundsResponseData, TaxCalculationResponseData,
@@ -31,3 +32,4 @@ pub type PaymentsCompleteAuthorizeRouterData =
RouterData<CompleteAuthorize, CompleteAuthorizeData, PaymentsResponseData>;
pub type PaymentsTaxCalculationRouterData =
RouterData<CalculateTax, PaymentsTaxCalculationData, TaxCalculationResponseData>;
+pub type RefreshTokenRouterData = RouterData<AccessTokenAuth, AccessTokenRequestData, AccessToken>;
diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs
index acffafa6c3..659c94423d 100644
--- a/crates/router/src/configs/defaults.rs
+++ b/crates/router/src/configs/defaults.rs
@@ -11209,8 +11209,43 @@ impl Default for super::settings::RequiredFields {
}
)
]),
- })
- ]),
+ }
+ ),
+ (
+ enums::Connector::Deutschebank,
+ RequiredFieldFinal {
+ mandate: HashMap::new(),
+ non_mandate: HashMap::new(),
+ common: HashMap::from([ (
+ "billing.address.first_name".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.address.first_name".to_string(),
+ display_name: "owner_name".to_string(),
+ field_type: enums::FieldType::UserBillingName,
+ value: None,
+ }),
+ (
+ "billing.address.last_name".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.billing.address.last_name".to_string(),
+ display_name: "owner_name".to_string(),
+ field_type: enums::FieldType::UserBillingName,
+ value: None,
+ }
+ ),
+ (
+ "payment_method_data.bank_debit.sepa.iban".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.bank_debit.bacs.iban".to_string(),
+ display_name: "bank_account_number".to_string(),
+ field_type: enums::FieldType::Text,
+ value: None,
+ }
+ )
+ ]),
+ }
+ )
+ ]),
},
),
(
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index 996224d7be..75b8d922f8 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -1300,6 +1300,10 @@ impl<'a> ConnectorAuthTypeAndMetadataValidation<'a> {
datatrans::transformers::DatatransAuthType::try_from(self.auth_type)?;
Ok(())
}
+ api_enums::Connector::Deutschebank => {
+ deutschebank::transformers::DeutschebankAuthType::try_from(self.auth_type)?;
+ Ok(())
+ }
api_enums::Connector::Dlocal => {
dlocal::transformers::DlocalAuthType::try_from(self.auth_type)?;
Ok(())
diff --git a/crates/router/src/core/payment_methods.rs b/crates/router/src/core/payment_methods.rs
index 0061eb4fbc..9a39a3c341 100644
--- a/crates/router/src/core/payment_methods.rs
+++ b/crates/router/src/core/payment_methods.rs
@@ -79,9 +79,22 @@ pub async fn retrieve_payment_method(
Ok((pm_opt.to_owned(), payment_token))
}
+ pm_opt @ Some(pm @ domain::PaymentMethodData::BankDebit(_)) => {
+ let payment_token = helpers::store_payment_method_data_in_vault(
+ state,
+ payment_attempt,
+ payment_intent,
+ enums::PaymentMethod::BankDebit,
+ pm,
+ merchant_key_store,
+ business_profile,
+ )
+ .await?;
+
+ Ok((pm_opt.to_owned(), payment_token))
+ }
pm @ Some(domain::PaymentMethodData::PayLater(_)) => Ok((pm.to_owned(), None)),
pm @ Some(domain::PaymentMethodData::Crypto(_)) => Ok((pm.to_owned(), None)),
- pm @ Some(domain::PaymentMethodData::BankDebit(_)) => Ok((pm.to_owned(), None)),
pm @ Some(domain::PaymentMethodData::Upi(_)) => Ok((pm.to_owned(), None)),
pm @ Some(domain::PaymentMethodData::Voucher(_)) => Ok((pm.to_owned(), None)),
pm @ Some(domain::PaymentMethodData::Reward) => Ok((pm.to_owned(), None)),
diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rs
index 54da4308bf..75278010ce 100644
--- a/crates/router/src/core/payment_methods/vault.rs
+++ b/crates/router/src/core/payment_methods/vault.rs
@@ -279,6 +279,58 @@ impl Vaultable for domain::BankRedirectData {
}
}
+impl Vaultable for domain::BankDebitData {
+ fn get_value1(
+ &self,
+ _customer_id: Option<id_type::CustomerId>,
+ ) -> CustomResult<String, errors::VaultError> {
+ let value1 = domain::TokenizedBankDebitValue1 {
+ data: self.to_owned(),
+ };
+
+ value1
+ .encode_to_string_of_json()
+ .change_context(errors::VaultError::RequestEncodingFailed)
+ .attach_printable("Failed to encode bank debit data")
+ }
+
+ fn get_value2(
+ &self,
+ customer_id: Option<id_type::CustomerId>,
+ ) -> CustomResult<String, errors::VaultError> {
+ let value2 = domain::TokenizedBankDebitValue2 { customer_id };
+
+ value2
+ .encode_to_string_of_json()
+ .change_context(errors::VaultError::RequestEncodingFailed)
+ .attach_printable("Failed to encode bank debit supplementary data")
+ }
+
+ fn from_values(
+ value1: String,
+ value2: String,
+ ) -> CustomResult<(Self, SupplementaryVaultData), errors::VaultError> {
+ let value1: domain::TokenizedBankDebitValue1 = value1
+ .parse_struct("TokenizedBankDebitValue1")
+ .change_context(errors::VaultError::ResponseDeserializationFailed)
+ .attach_printable("Could not deserialize into bank debit data")?;
+
+ let value2: domain::TokenizedBankDebitValue2 = value2
+ .parse_struct("TokenizedBankDebitValue2")
+ .change_context(errors::VaultError::ResponseDeserializationFailed)
+ .attach_printable("Could not deserialize into supplementary bank debit data")?;
+
+ let bank_transfer_data = value1.data;
+
+ let supp_data = SupplementaryVaultData {
+ customer_id: value2.customer_id,
+ payment_method_id: None,
+ };
+
+ Ok((bank_transfer_data, supp_data))
+ }
+}
+
#[derive(Debug, Clone, serde::Serialize, serde::Deserialize)]
#[serde(tag = "type", content = "value", rename_all = "snake_case")]
pub enum VaultPaymentMethod {
@@ -286,6 +338,7 @@ pub enum VaultPaymentMethod {
Wallet(String),
BankTransfer(String),
BankRedirect(String),
+ BankDebit(String),
}
impl Vaultable for domain::PaymentMethodData {
@@ -302,6 +355,9 @@ impl Vaultable for domain::PaymentMethodData {
Self::BankRedirect(bank_redirect) => {
VaultPaymentMethod::BankRedirect(bank_redirect.get_value1(customer_id)?)
}
+ Self::BankDebit(bank_debit) => {
+ VaultPaymentMethod::BankDebit(bank_debit.get_value1(customer_id)?)
+ }
_ => Err(errors::VaultError::PaymentMethodNotSupported)
.attach_printable("Payment method not supported")?,
};
@@ -325,6 +381,9 @@ impl Vaultable for domain::PaymentMethodData {
Self::BankRedirect(bank_redirect) => {
VaultPaymentMethod::BankRedirect(bank_redirect.get_value2(customer_id)?)
}
+ Self::BankDebit(bank_debit) => {
+ VaultPaymentMethod::BankDebit(bank_debit.get_value2(customer_id)?)
+ }
_ => Err(errors::VaultError::PaymentMethodNotSupported)
.attach_printable("Payment method not supported")?,
};
@@ -374,6 +433,10 @@ impl Vaultable for domain::PaymentMethodData {
domain::BankRedirectData::from_values(mvalue1, mvalue2)?;
Ok((Self::BankRedirect(bank_redirect), supp_data))
}
+ (VaultPaymentMethod::BankDebit(mvalue1), VaultPaymentMethod::BankDebit(mvalue2)) => {
+ let (bank_debit, supp_data) = domain::BankDebitData::from_values(mvalue1, mvalue2)?;
+ Ok((Self::BankDebit(bank_debit), supp_data))
+ }
_ => Err(errors::VaultError::PaymentMethodNotSupported)
.attach_printable("Payment method not supported"),
diff --git a/crates/router/src/core/payments/helpers.rs b/crates/router/src/core/payments/helpers.rs
index 5f9c1a7be0..6cb4532d61 100644
--- a/crates/router/src/core/payments/helpers.rs
+++ b/crates/router/src/core/payments/helpers.rs
@@ -1770,6 +1770,10 @@ pub async fn retrieve_payment_method_with_temporary_token(
Some((the_pm, enums::PaymentMethod::BankRedirect))
}
+ Some(the_pm @ domain::PaymentMethodData::BankDebit(_)) => {
+ Some((the_pm, enums::PaymentMethod::BankDebit))
+ }
+
Some(_) => Err(errors::ApiErrorResponse::InternalServerError)
.attach_printable("Payment method received from locker is unsupported by locker")?,
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index ca86003f4b..34dea537b2 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -359,9 +359,9 @@ impl ConnectorData {
enums::Connector::Datatrans => {
Ok(ConnectorEnum::Old(Box::new(connector::Datatrans::new())))
}
- // enums::Connector::Deutschebank => {
- // Ok(ConnectorEnum::Old(Box::new(connector::Deutschebank::new())))
- // }
+ enums::Connector::Deutschebank => {
+ Ok(ConnectorEnum::Old(Box::new(connector::Deutschebank::new())))
+ }
enums::Connector::Dlocal => Ok(ConnectorEnum::Old(Box::new(&connector::Dlocal))),
#[cfg(feature = "dummy_connector")]
enums::Connector::DummyConnector1 => Ok(ConnectorEnum::Old(Box::new(
diff --git a/crates/router/src/types/domain/payments.rs b/crates/router/src/types/domain/payments.rs
index 1cf36bc442..bfd7b54f55 100644
--- a/crates/router/src/types/domain/payments.rs
+++ b/crates/router/src/types/domain/payments.rs
@@ -6,8 +6,9 @@ pub use hyperswitch_domain_models::payment_method_data::{
GooglePayThirdPartySdkData, GooglePayWalletData, GpayTokenizationData, IndomaretVoucherData,
KakaoPayRedirection, MbWayRedirection, MifinityData, OpenBankingData, PayLaterData,
PaymentMethodData, RealTimePaymentData, SamsungPayWalletData, SepaAndBacsBillingDetails,
- SwishQrData, TokenizedBankRedirectValue1, TokenizedBankRedirectValue2,
- TokenizedBankTransferValue1, TokenizedBankTransferValue2, TokenizedCardValue1,
- TokenizedCardValue2, TokenizedWalletValue1, TokenizedWalletValue2, TouchNGoRedirection,
- UpiCollectData, UpiData, UpiIntentData, VoucherData, WalletData, WeChatPayQr,
+ SwishQrData, TokenizedBankDebitValue1, TokenizedBankDebitValue2, TokenizedBankRedirectValue1,
+ TokenizedBankRedirectValue2, TokenizedBankTransferValue1, TokenizedBankTransferValue2,
+ TokenizedCardValue1, TokenizedCardValue2, TokenizedWalletValue1, TokenizedWalletValue2,
+ TouchNGoRedirection, UpiCollectData, UpiData, UpiIntentData, VoucherData, WalletData,
+ WeChatPayQr,
};
diff --git a/crates/router/src/types/transformers.rs b/crates/router/src/types/transformers.rs
index f883d1d4c5..46210d4dd0 100644
--- a/crates/router/src/types/transformers.rs
+++ b/crates/router/src/types/transformers.rs
@@ -274,7 +274,7 @@ impl ForeignTryFrom<api_enums::Connector> for common_enums::RoutableConnectors {
api_enums::Connector::Cryptopay => Self::Cryptopay,
api_enums::Connector::Cybersource => Self::Cybersource,
api_enums::Connector::Datatrans => Self::Datatrans,
- // api_enums::Connector::Deutschebank => Self::Deutschebank,
+ api_enums::Connector::Deutschebank => Self::Deutschebank,
api_enums::Connector::Dlocal => Self::Dlocal,
api_enums::Connector::Ebanx => Self::Ebanx,
api_enums::Connector::Fiserv => Self::Fiserv,
diff --git a/crates/router/tests/connectors/sample_auth.toml b/crates/router/tests/connectors/sample_auth.toml
index 6ed9bd7103..f61770a5bd 100644
--- a/crates/router/tests/connectors/sample_auth.toml
+++ b/crates/router/tests/connectors/sample_auth.toml
@@ -276,7 +276,9 @@ api_key = "API Key"
api_key="API Key"
[deutschebank]
-api_key="API Key"
+api_key = "Client ID"
+key1 = "Merchant ID"
+api_secret = "Client Key"
[thunes]
-api_key="API Key"
\ No newline at end of file
+api_key="API Key"
diff --git a/crates/test_utils/src/connector_auth.rs b/crates/test_utils/src/connector_auth.rs
index 68895e5876..a0fed3c003 100644
--- a/crates/test_utils/src/connector_auth.rs
+++ b/crates/test_utils/src/connector_auth.rs
@@ -31,7 +31,7 @@ pub struct ConnectorAuthentication {
pub cryptopay: Option<BodyKey>,
pub cybersource: Option<SignatureKey>,
pub datatrans: Option<HeaderKey>,
- pub deutschebank: Option<HeaderKey>,
+ pub deutschebank: Option<SignatureKey>,
pub dlocal: Option<SignatureKey>,
#[cfg(feature = "dummy_connector")]
pub dummyconnector: Option<HeaderKey>,
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index b1f74f57fe..ed15e8893b 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -96,7 +96,7 @@ coinbase.base_url = "https://api.commerce.coinbase.com"
cryptopay.base_url = "https://business-sandbox.cryptopay.me"
cybersource.base_url = "https://apitest.cybersource.com/"
datatrans.base_url = "https://api.sandbox.datatrans.com/"
-deutschebank.base_url = "https://sandbox.directpos.de/rest-api/services/v2.1"
+deutschebank.base_url = "https://testmerch.directpos.de/rest-api"
dlocal.base_url = "https://sandbox.dlocal.com/"
dummyconnector.base_url = "http://localhost:8080/dummy-connector"
ebanx.base_url = "https://sandbox.ebanxpay.com/"