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): [Gocardless] add support for Ach, Sepa, Becs payment methods (#2180)

Arjun Karthik3efce9013d05
diff --git a/config/config.example.toml b/config/config.example.toml
index 97f233fa71..babad61735 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -312,6 +312,7 @@ mollie = {long_lived_token = false, payment_method = "card"}
stax = { long_lived_token = true, payment_method = "card,bank_debit" }
square = {long_lived_token = false, payment_method = "card"}
braintree = { long_lived_token = false, payment_method = "card" }
+gocardless = {long_lived_token = true, payment_method = "bank_debit"}
[temp_locker_disable_config]
trustpay = {payment_method = "card,bank_redirect,wallet"}
@@ -400,7 +401,7 @@ ach = { currency = "USD" }
cashapp = {country = "US", currency = "USD"}
[connector_customer]
-connector_list = "stax,stripe"
+connector_list = "gocardless,stax,stripe"
payout_connector_list = "wise"
[bank_config.online_banking_fpx]
diff --git a/config/development.toml b/config/development.toml
index ee4199eaaa..07e911087f 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -374,13 +374,14 @@ mollie = {long_lived_token = false, payment_method = "card"}
square = {long_lived_token = false, payment_method = "card"}
braintree = { long_lived_token = false, payment_method = "card" }
payme = {long_lived_token = false, payment_method = "card"}
+gocardless = {long_lived_token = true, payment_method = "bank_debit"}
[temp_locker_disable_config]
trustpay = {payment_method = "card,bank_redirect,wallet"}
stripe = {payment_method = "card,bank_redirect,pay_later,wallet,bank_debit"}
[connector_customer]
-connector_list = "stax,stripe"
+connector_list = "gocardless,stax,stripe"
payout_connector_list = "wise"
[dummy_connector]
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index c5582e844f..05e032421d 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -203,6 +203,7 @@ mollie = {long_lived_token = false, payment_method = "card"}
stax = { long_lived_token = true, payment_method = "card,bank_debit" }
square = {long_lived_token = false, payment_method = "card"}
braintree = { long_lived_token = false, payment_method = "card" }
+gocardless = {long_lived_token = true, payment_method = "bank_debit"}
[temp_locker_disable_config]
trustpay = {payment_method = "card,bank_redirect,wallet"}
@@ -294,7 +295,7 @@ card.credit = {connector_list = "stripe,adyen,authorizedotnet,globalpay,worldpay
card.debit = {connector_list = "stripe,adyen,authorizedotnet,globalpay,worldpay,multisafepay,nmi,nexinets,noon"}
[connector_customer]
-connector_list = "stax,stripe"
+connector_list = "gocardless,stax,stripe"
payout_connector_list = "wise"
[multiple_api_version_supported_connectors]
diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs
index 9485bfeff7..33cde866ee 100644
--- a/crates/api_models/src/enums.rs
+++ b/crates/api_models/src/enums.rs
@@ -90,7 +90,7 @@ pub enum Connector {
Forte,
Globalpay,
Globepay,
- //Gocardless,
+ Gocardless,
//Helcim, added as template code for future usage,
Iatapay,
Klarna,
@@ -207,7 +207,7 @@ pub enum RoutableConnectors {
Forte,
Globalpay,
Globepay,
- //Gocardless,
+ Gocardless,
//Helcim, added as template code for future usage,
Iatapay,
Klarna,
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index f931070e4b..796a1642ba 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -753,6 +753,9 @@ pub enum BankDebitData {
/// Bank-State-Branch (bsb) number
#[schema(value_type = String, example = "000000")]
bsb_number: Secret<String>,
+ /// Owner name for bank debit
+ #[schema(value_type = Option<String>, example = "A. Schneider")]
+ bank_account_holder_name: Option<Secret<String>>,
},
BacsBankDebit {
/// Billing details for bank debit
diff --git a/crates/router/src/connector/gocardless.rs b/crates/router/src/connector/gocardless.rs
index 2b9286afc8..6692c869e0 100644
--- a/crates/router/src/connector/gocardless.rs
+++ b/crates/router/src/connector/gocardless.rs
@@ -2,12 +2,15 @@ pub mod transformers;
use std::fmt::Debug;
+use api_models::enums::enums;
+use common_utils::{crypto, ext_traits::ByteSliceExt};
use error_stack::{IntoReport, ResultExt};
-use masking::ExposeInterface;
+use masking::PeekInterface;
use transformers as gocardless;
use crate::{
configs::settings,
+ connector::utils as connector_utils,
core::errors::{self, CustomResult},
headers,
services::{
@@ -38,16 +41,11 @@ impl api::Refund for Gocardless {}
impl api::RefundExecute for Gocardless {}
impl api::RefundSync for Gocardless {}
impl api::PaymentToken for Gocardless {}
+impl api::ConnectorCustomer for Gocardless {}
+impl api::PaymentsPreProcessing for Gocardless {}
-impl
- ConnectorIntegration<
- api::PaymentMethodToken,
- types::PaymentMethodTokenizationData,
- types::PaymentsResponseData,
- > for Gocardless
-{
- // Not Implemented (R)
-}
+const GOCARDLESS_VERSION: &str = "2015-07-06";
+const GOCARDLESS_VERSION_HEADER: &str = "GoCardless-Version";
impl<Flow, Request, Response> ConnectorCommonExt<Flow, Request, Response> for Gocardless
where
@@ -58,12 +56,16 @@ where
req: &types::RouterData<Flow, Request, Response>,
_connectors: &settings::Connectors,
) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
- let mut header = vec![(
- headers::CONTENT_TYPE.to_string(),
- types::PaymentsAuthorizeType::get_content_type(self)
- .to_string()
- .into(),
- )];
+ let mut header = vec![
+ (
+ headers::CONTENT_TYPE.to_string(),
+ self.get_content_type().to_string().into(),
+ ),
+ (
+ GOCARDLESS_VERSION_HEADER.to_string(),
+ GOCARDLESS_VERSION.to_string().into(),
+ ),
+ ];
let mut api_key = self.get_auth_header(&req.connector_auth_type)?;
header.append(&mut api_key);
Ok(header)
@@ -95,7 +97,7 @@ impl ConnectorCommon for Gocardless {
.change_context(errors::ConnectorError::FailedToObtainAuthType)?;
Ok(vec![(
headers::AUTHORIZATION.to_string(),
- auth.api_key.expose().into_masked(),
+ format!("Bearer {}", auth.access_token.peek()).into_masked(),
)])
}
@@ -107,18 +109,306 @@ impl ConnectorCommon for Gocardless {
.response
.parse_struct("GocardlessErrorResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
-
+ let error_iter = response.error.errors.iter();
+ let mut error_reason: Vec<String> = Vec::new();
+ for error in error_iter {
+ let reason = error.field.clone().map_or(error.message.clone(), |field| {
+ format!("{} {}", field, error.message)
+ });
+ error_reason.push(reason)
+ }
Ok(ErrorResponse {
status_code: res.status_code,
- code: response.code,
- message: response.message,
- reason: response.reason,
+ code: response.error.code.to_string(),
+ message: response.error.error_type,
+ reason: Some(error_reason.join("; ")),
+ })
+ }
+}
+
+impl
+ ConnectorIntegration<
+ api::CreateConnectorCustomer,
+ types::ConnectorCustomerData,
+ types::PaymentsResponseData,
+ > for Gocardless
+{
+ fn get_headers(
+ &self,
+ req: &types::ConnectorCustomerRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
+ }
+
+ fn get_url(
+ &self,
+ _req: &types::ConnectorCustomerRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(format!("{}/customers", self.base_url(connectors)))
+ }
+
+ fn get_request_body(
+ &self,
+ req: &types::ConnectorCustomerRouterData,
+ ) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
+ let req_obj = gocardless::GocardlessCustomerRequest::try_from(req)?;
+ let gocardless_req = types::RequestBody::log_and_get_request_body(
+ &req_obj,
+ utils::Encode::<gocardless::GocardlessCustomerRequest>::encode_to_string_of_json,
+ )
+ .change_context(errors::ConnectorError::RequestEncodingFailed)?;
+ Ok(Some(gocardless_req))
+ }
+
+ fn build_request(
+ &self,
+ req: &types::ConnectorCustomerRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Option<common_utils::request::Request>, errors::ConnectorError> {
+ Ok(Some(
+ services::RequestBuilder::new()
+ .method(services::Method::Post)
+ .url(&types::ConnectorCustomerType::get_url(
+ self, req, connectors,
+ )?)
+ .attach_default_headers()
+ .headers(types::ConnectorCustomerType::get_headers(
+ self, req, connectors,
+ )?)
+ .body(types::ConnectorCustomerType::get_request_body(self, req)?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &types::ConnectorCustomerRouterData,
+ res: Response,
+ ) -> CustomResult<
+ types::RouterData<
+ api::CreateConnectorCustomer,
+ types::ConnectorCustomerData,
+ types::PaymentsResponseData,
+ >,
+ errors::ConnectorError,
+ >
+ where
+ api::CreateConnectorCustomer: Clone,
+ types::ConnectorCustomerData: Clone,
+ types::PaymentsResponseData: Clone,
+ {
+ let response: gocardless::GocardlessCustomerResponse = res
+ .response
+ .parse_struct("GocardlessCustomerResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ types::RouterData::try_from(types::ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res)
+ }
+}
+
+impl
+ ConnectorIntegration<
+ api::PaymentMethodToken,
+ types::PaymentMethodTokenizationData,
+ types::PaymentsResponseData,
+ > for Gocardless
+{
+ fn get_headers(
+ &self,
+ req: &types::TokenizationRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
+ }
+
+ fn get_url(
+ &self,
+ _req: &types::TokenizationRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(format!(
+ "{}/customer_bank_accounts",
+ self.base_url(connectors),
+ ))
+ }
+
+ fn get_request_body(
+ &self,
+ req: &types::TokenizationRouterData,
+ ) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
+ let req_obj = gocardless::GocardlessBankAccountRequest::try_from(req)?;
+ let gocardless_req = types::RequestBody::log_and_get_request_body(
+ &req_obj,
+ utils::Encode::<gocardless::GocardlessBankAccountRequest>::encode_to_string_of_json,
+ )
+ .change_context(errors::ConnectorError::RequestEncodingFailed)?;
+ Ok(Some(gocardless_req))
+ }
+
+ fn build_request(
+ &self,
+ req: &types::TokenizationRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Option<common_utils::request::Request>, errors::ConnectorError> {
+ Ok(Some(
+ services::RequestBuilder::new()
+ .method(services::Method::Post)
+ .url(&types::TokenizationType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(types::TokenizationType::get_headers(self, req, connectors)?)
+ .body(types::TokenizationType::get_request_body(self, req)?)
+ .build(),
+ ))
+ }
+
+ fn handle_response(
+ &self,
+ data: &types::TokenizationRouterData,
+ res: Response,
+ ) -> CustomResult<types::TokenizationRouterData, errors::ConnectorError>
+ where
+ api::PaymentMethodToken: Clone,
+ types::PaymentMethodTokenizationData: Clone,
+ types::PaymentsResponseData: Clone,
+ {
+ let response: gocardless::GocardlessBankAccountResponse = res
+ .response
+ .parse_struct("GocardlessBankAccountResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ types::RouterData::try_from(types::ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
+ })
+ }
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res)
+ }
+}
+
+impl
+ ConnectorIntegration<
+ api::PreProcessing,
+ types::PaymentsPreProcessingData,
+ types::PaymentsResponseData,
+ > for Gocardless
+{
+ fn get_headers(
+ &self,
+ req: &types::PaymentsPreProcessingRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
+ self.build_headers(req, connectors)
+ }
+
+ fn get_url(
+ &self,
+ _req: &types::PaymentsPreProcessingRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<String, errors::ConnectorError> {
+ Ok(format!("{}/mandates", self.base_url(connectors)))
+ }
+
+ fn get_request_body(
+ &self,
+ req: &types::PaymentsPreProcessingRouterData,
+ ) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
+ let req_obj = gocardless::GocardlessMandateRequest::try_from(req)?;
+ let gocardless_req = types::RequestBody::log_and_get_request_body(
+ &req_obj,
+ utils::Encode::<gocardless::GocardlessMandateRequest>::encode_to_string_of_json,
+ )
+ .change_context(errors::ConnectorError::RequestEncodingFailed)?;
+ Ok(Some(gocardless_req))
+ }
+
+ fn build_request(
+ &self,
+ req: &types::PaymentsPreProcessingRouterData,
+ connectors: &settings::Connectors,
+ ) -> CustomResult<Option<common_utils::request::Request>, errors::ConnectorError> {
+ // Preprocessing flow is to create mandate, which should to be called only in case of First mandate
+ if req.request.setup_mandate_details.is_some() {
+ Ok(Some(
+ services::RequestBuilder::new()
+ .method(services::Method::Post)
+ .url(&types::PaymentsPreProcessingType::get_url(
+ self, req, connectors,
+ )?)
+ .attach_default_headers()
+ .headers(types::PaymentsPreProcessingType::get_headers(
+ self, req, connectors,
+ )?)
+ .body(types::PaymentsPreProcessingType::get_request_body(
+ self, req,
+ )?)
+ .build(),
+ ))
+ } else {
+ Ok(None)
+ }
+ }
+
+ fn handle_response(
+ &self,
+ data: &types::PaymentsPreProcessingRouterData,
+ res: Response,
+ ) -> CustomResult<types::PaymentsPreProcessingRouterData, errors::ConnectorError>
+ where
+ api::PreProcessing: Clone,
+ types::PaymentsPreProcessingData: Clone,
+ types::PaymentsResponseData: Clone,
+ {
+ let response: gocardless::GocardlessMandateResponse = res
+ .response
+ .parse_struct("GocardlessMandateResponse")
+ .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
+ types::RouterData::try_from(types::ResponseRouterData {
+ response,
+ data: data.clone(),
+ http_code: res.status_code,
})
}
+
+ fn get_error_response(
+ &self,
+ res: Response,
+ ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
+ self.build_error_response(res)
+ }
}
impl ConnectorValidation for Gocardless {
- //TODO: implement functions when support enabled
+ fn validate_capture_method(
+ &self,
+ capture_method: Option<api_models::enums::CaptureMethod>,
+ ) -> CustomResult<(), errors::ConnectorError> {
+ let capture_method = capture_method.unwrap_or_default();
+ match capture_method {
+ enums::CaptureMethod::Automatic => Ok(()),
+ enums::CaptureMethod::Manual
+ | enums::CaptureMethod::ManualMultiple
+ | enums::CaptureMethod::Scheduled => Err(
+ connector_utils::construct_not_implemented_error_report(capture_method, self.id()),
+ ),
+ }
+ }
}
impl ConnectorIntegration<api::Session, types::PaymentsSessionData, types::PaymentsResponseData>
@@ -155,9 +445,9 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
fn get_url(
&self,
_req: &types::PaymentsAuthorizeRouterData,
- _connectors: &settings::Connectors,
+ connectors: &settings::Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ Ok(format!("{}/payments", self.base_url(connectors)))
}
fn get_request_body(
@@ -184,7 +474,6 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
req: &types::PaymentsAuthorizeRouterData,
connectors: &settings::Connectors,
) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
- self.validate_capture_method(req.request.capture_method)?;
Ok(Some(
services::RequestBuilder::new()
.method(services::Method::Post)
@@ -207,7 +496,7 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::P
) -> CustomResult<types::PaymentsAuthorizeRouterData, errors::ConnectorError> {
let response: gocardless::GocardlessPaymentsResponse = res
.response
- .parse_struct("Gocardless PaymentsAuthorizeResponse")
+ .parse_struct("GocardlessPaymentsResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
types::RouterData::try_from(types::ResponseRouterData {
response,
@@ -241,10 +530,17 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
fn get_url(
&self,
- _req: &types::PaymentsSyncRouterData,
- _connectors: &settings::Connectors,
+ req: &types::PaymentsSyncRouterData,
+ connectors: &settings::Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ Ok(format!(
+ "{}/payments/{}",
+ self.base_url(connectors),
+ req.request
+ .connector_transaction_id
+ .get_connector_transaction_id()
+ .change_context(errors::ConnectorError::MissingConnectorTransactionID)?
+ ))
}
fn build_request(
@@ -269,7 +565,7 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
) -> CustomResult<types::PaymentsSyncRouterData, errors::ConnectorError> {
let response: gocardless::GocardlessPaymentsResponse = res
.response
- .parse_struct("gocardless PaymentsSyncResponse")
+ .parse_struct("GocardlessPaymentsResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
types::RouterData::try_from(types::ResponseRouterData {
response,
@@ -289,73 +585,6 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRe
impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::PaymentsResponseData>
for Gocardless
{
- fn get_headers(
- &self,
- req: &types::PaymentsCaptureRouterData,
- connectors: &settings::Connectors,
- ) -> CustomResult<Vec<(String, request::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: &types::PaymentsCaptureRouterData,
- _connectors: &settings::Connectors,
- ) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
- }
-
- fn get_request_body(
- &self,
- _req: &types::PaymentsCaptureRouterData,
- ) -> CustomResult<Option<types::RequestBody>, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_request_body method".to_string()).into())
- }
-
- fn build_request(
- &self,
- req: &types::PaymentsCaptureRouterData,
- connectors: &settings::Connectors,
- ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
- Ok(Some(
- services::RequestBuilder::new()
- .method(services::Method::Post)
- .url(&types::PaymentsCaptureType::get_url(self, req, connectors)?)
- .attach_default_headers()
- .headers(types::PaymentsCaptureType::get_headers(
- self, req, connectors,
- )?)
- .body(types::PaymentsCaptureType::get_request_body(self, req)?)
- .build(),
- ))
- }
-
- fn handle_response(
- &self,
- data: &types::PaymentsCaptureRouterData,
- res: Response,
- ) -> CustomResult<types::PaymentsCaptureRouterData, errors::ConnectorError> {
- let response: gocardless::GocardlessPaymentsResponse = res
- .response
- .parse_struct("Gocardless PaymentsCaptureResponse")
- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
- types::RouterData::try_from(types::ResponseRouterData {
- response,
- data: data.clone(),
- http_code: res.status_code,
- })
- }
-
- fn get_error_response(
- &self,
- res: Response,
- ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
- self.build_error_response(res)
- }
}
impl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsResponseData>
@@ -381,9 +610,9 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
fn get_url(
&self,
_req: &types::RefundsRouterData<api::Execute>,
- _connectors: &settings::Connectors,
+ connectors: &settings::Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ Ok(format!("{}/refunds", self.base_url(connectors)))
}
fn get_request_body(
@@ -449,86 +678,152 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsRespon
impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponseData>
for Gocardless
{
- fn get_headers(
- &self,
- req: &types::RefundSyncRouterData,
- connectors: &settings::Connectors,
- ) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {
- self.build_headers(req, connectors)
- }
-
- fn get_content_type(&self) -> &'static str {
- self.common_get_content_type()
- }
-
- fn get_url(
+ fn build_request(
&self,
_req: &types::RefundSyncRouterData,
_connectors: &settings::Connectors,
- ) -> CustomResult<String, errors::ConnectorError> {
- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())
+ ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
+ Ok(None)
}
+}
- fn build_request(
+#[async_trait::async_trait]
+impl api::IncomingWebhook for Gocardless {
+ fn get_webhook_source_verification_algorithm(
&self,
- req: &types::RefundSyncRouterData,
- connectors: &settings::Connectors,
- ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {
- Ok(Some(
- services::RequestBuilder::new()
- .method(services::Method::Get)
- .url(&types::RefundSyncType::get_url(self, req, connectors)?)
- .attach_default_headers()
- .headers(types::RefundSyncType::get_headers(self, req, connectors)?)
- .body(types::RefundSyncType::get_request_body(self, req)?)
- .build(),
- ))
+ _request: &api::IncomingWebhookRequestDetails<'_>,
+ ) -> CustomResult<Box<dyn crypto::VerifySignature + Send>, errors::ConnectorError> {
+ Ok(Box::new(crypto::HmacSha256))
}
- fn handle_response(
+ fn get_webhook_source_verification_signature(
&self,
- data: &types::RefundSyncRouterData,
- res: Response,
- ) -> CustomResult<types::RefundSyncRouterData, errors::ConnectorError> {
- let response: gocardless::RefundResponse = res
- .response
- .parse_struct("gocardless RefundSyncResponse")
- .change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
- types::RouterData::try_from(types::ResponseRouterData {
- response,
- data: data.clone(),
- http_code: res.status_code,
- })
+ request: &api::IncomingWebhookRequestDetails<'_>,
+ ) -> CustomResult<Vec<u8>, errors::ConnectorError> {
+ let signature = request
+ .headers
+ .get("Webhook-Signature")
+ .map(|header_value| {
+ header_value
+ .to_str()
+ .map(String::from)
+ .map_err(|_| errors::ConnectorError::WebhookSignatureNotFound)
+ .into_report()
+ })
+ .ok_or(errors::ConnectorError::WebhookSignatureNotFound)
+ .into_report()??;
+
+ hex::decode(signature)
+ .into_report()
+ .change_context(errors::ConnectorError::WebhookSignatureNotFound)
}
- fn get_error_response(
+ fn get_webhook_source_verification_message(
&self,
- res: Response,
- ) -> CustomResult<ErrorResponse, errors::ConnectorError> {
- self.build_error_response(res)
+ request: &api::IncomingWebhookRequestDetails<'_>,
+ _merchant_id: &str,
+ _secret: &[u8],
+ ) -> CustomResult<Vec<u8>, errors::ConnectorError> {
+ Ok(format!("{}", String::from_utf8_lossy(request.body))
+ .as_bytes()
+ .to_vec())
}
-}
-#[async_trait::async_trait]
-impl api::IncomingWebhook for Gocardless {
fn get_webhook_object_reference_id(
&self,
- _request: &api::IncomingWebhookRequestDetails<'_>,
+ request: &api::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<api::webhooks::ObjectReferenceId, errors::ConnectorError> {
- Err(errors::ConnectorError::WebhooksNotImplemented).into_report()
+ let details: gocardless::GocardlessWebhookEvent = request
+ .body
+ .parse_struct("GocardlessWebhookEvent")
+ .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
+ let first_event = details
+ .events
+ .first()
+ .ok_or_else(|| errors::ConnectorError::WebhookReferenceIdNotFound)?;
+ let reference_id = match &first_event.links {
+ transformers::WebhooksLink::PaymentWebhooksLink(link) => {
+ let payment_id = api_models::payments::PaymentIdType::ConnectorTransactionId(
+ link.payment.to_owned(),
+ );
+ api::webhooks::ObjectReferenceId::PaymentId(payment_id)
+ }
+ transformers::WebhooksLink::RefundWebhookLink(link) => {
+ let refund_id =
+ api_models::webhooks::RefundIdType::ConnectorRefundId(link.refund.to_owned());
+ api::webhooks::ObjectReferenceId::RefundId(refund_id)
+ }
+ };
+ Ok(reference_id)
}
fn get_webhook_event_type(
&self,
- _request: &api::IncomingWebhookRequestDetails<'_>,
+ request: &api::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<api::IncomingWebhookEvent, errors::ConnectorError> {
- Err(errors::ConnectorError::WebhooksNotImplemented).into_report()
+ let details: gocardless::GocardlessWebhookEvent = request
+ .body
+ .parse_struct("GocardlessWebhookEvent")
+ .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
+ let first_event = details
+ .events
+ .first()
+ .ok_or_else(|| errors::ConnectorError::WebhookReferenceIdNotFound)?;
+ let event_type = match &first_event.action {
+ transformers::WebhookAction::PaymentsAction(action) => match action {
+ transformers::PaymentsAction::Created
+ | transformers::PaymentsAction::Submitted
+ | transformers::PaymentsAction::CustomerApprovalGranted => {
+ api::IncomingWebhookEvent::PaymentIntentProcessing
+ }
+ transformers::PaymentsAction::CustomerApprovalDenied
+ | transformers::PaymentsAction::Failed
+ | transformers::PaymentsAction::Cancelled
+ | transformers::PaymentsAction::LateFailureSettled => {
+ api::IncomingWebhookEvent::PaymentIntentFailure
+ }
+ transformers::PaymentsAction::Confirmed | transformers::PaymentsAction::PaidOut => {
+ api::IncomingWebhookEvent::PaymentIntentSuccess
+ }
+ transformers::PaymentsAction::SurchargeFeeDebited
+ | transformers::PaymentsAction::ResubmissionRequired => {
+ api::IncomingWebhookEvent::EventNotSupported
+ }
+ },
+ transformers::WebhookAction::RefundsAction(action) => match action {
+ transformers::RefundsAction::Failed => api::IncomingWebhookEvent::RefundFailure,
+ transformers::RefundsAction::Paid => api::IncomingWebhookEvent::RefundSuccess,
+ transformers::RefundsAction::RefundSettled
+ | transformers::RefundsAction::FundsReturned
+ | transformers::RefundsAction::Created => {
+ api::IncomingWebhookEvent::EventNotSupported
+ }
+ },
+ };
+ Ok(event_type)
}
fn get_webhook_resource_object(
&self,
- _request: &api::IncomingWebhookRequestDetails<'_>,
+ request: &api::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<serde_json::Value, errors::ConnectorError> {
- Err(errors::ConnectorError::WebhooksNotImplemented).into_report()
+ let details: gocardless::GocardlessWebhookEvent = request
+ .body
+ .parse_struct("GocardlessWebhookEvent")
+ .change_context(errors::ConnectorError::WebhookBodyDecodingFailed)?;
+ let first_event = details
+ .events
+ .first()
+ .ok_or_else(|| errors::ConnectorError::WebhookReferenceIdNotFound)?;
+ match first_event.resource_type {
+ transformers::WebhookResourceType::Payments => serde_json::to_value(
+ gocardless::GocardlessPaymentsResponse::try_from(first_event)?,
+ )
+ .into_report()
+ .change_context(errors::ConnectorError::WebhookBodyDecodingFailed),
+ transformers::WebhookResourceType::Refunds => serde_json::to_value(first_event)
+ .into_report()
+ .change_context(errors::ConnectorError::WebhookBodyDecodingFailed),
+ }
}
}
diff --git a/crates/router/src/connector/gocardless/transformers.rs b/crates/router/src/connector/gocardless/transformers.rs
index 9d15567ba8..222855db67 100644
--- a/crates/router/src/connector/gocardless/transformers.rs
+++ b/crates/router/src/connector/gocardless/transformers.rs
@@ -1,13 +1,20 @@
-use masking::Secret;
+use api_models::{
+ enums::{BankType, CountryAlpha2},
+ payments::BankDebitData,
+};
+use common_utils::pii::{self, IpAddress};
+use masking::{ExposeInterface, Secret};
use serde::{Deserialize, Serialize};
use crate::{
- connector::utils::PaymentsAuthorizeRequestData,
+ connector::utils::{
+ self, AddressDetailsData, BankDirectDebitBillingData, BrowserInformationData,
+ ConnectorCustomerData, PaymentsAuthorizeRequestData, PaymentsPreProcessingData, RouterData,
+ },
core::errors,
- types::{self, api, storage::enums},
+ types::{self, api, storage::enums, MandateReference},
};
-//TODO: Fill the struct with respective fields
pub struct GocardlessRouterData<T> {
pub amount: i64, // The type of amount that a connector accepts, for example, String, i64, f64, etc.
pub router_data: T,
@@ -30,7 +37,6 @@ impl<T>
T,
),
) -> Result<Self, Self::Error> {
- //Todo : use utils to convert the amount to the type of amount that a connector accepts
Ok(Self {
amount,
router_data: item,
@@ -38,21 +44,506 @@ impl<T>
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Serialize, Eq, PartialEq)]
+#[derive(Default, Debug, Serialize)]
+pub struct GocardlessCustomerRequest {
+ customers: GocardlessCustomer,
+}
+
+#[derive(Default, Debug, Serialize)]
+pub struct GocardlessCustomer {
+ address_line1: Option<Secret<String>>,
+ address_line2: Option<Secret<String>>,
+ address_line3: Option<Secret<String>>,
+ city: Option<Secret<String>>,
+ country_code: Option<CountryAlpha2>,
+ email: pii::Email,
+ given_name: Secret<String>,
+ family_name: Secret<String>,
+ metadata: CustomerMetaData,
+ danish_identity_number: Option<Secret<String>>,
+ postal_code: Option<Secret<String>>,
+ swedish_identity_number: Option<Secret<String>>,
+}
+
+#[derive(Default, Debug, Serialize)]
+pub struct CustomerMetaData {
+ crm_id: Option<Secret<String>>,
+}
+
+impl TryFrom<&types::ConnectorCustomerRouterData> for GocardlessCustomerRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &types::ConnectorCustomerRouterData) -> Result<Self, Self::Error> {
+ let email = item.request.get_email()?;
+ let billing_address = item.get_billing_address()?;
+ let given_name = billing_address.get_first_name()?.to_owned();
+ let family_name = billing_address.get_last_name()?.to_owned();
+ let metadata = CustomerMetaData {
+ crm_id: item.customer_id.clone().map(Secret::new),
+ };
+ Ok(Self {
+ customers: GocardlessCustomer {
+ email,
+ given_name,
+ family_name,
+ metadata,
+ address_line1: billing_address.line1.to_owned(),
+ address_line2: billing_address.line2.to_owned(),
+ address_line3: billing_address.line3.to_owned(),
+ country_code: billing_address.country,
+ // Should be populated based on the billing country
+ danish_identity_number: None,
+ postal_code: billing_address.zip.to_owned(),
+ // Should be populated based on the billing country
+ swedish_identity_number: None,
+ city: billing_address.city.clone().map(Secret::new),
+ },
+ })
+ }
+}
+
+#[derive(Debug, Clone, Deserialize)]
+pub struct GocardlessCustomerResponse {
+ customers: Customers,
+}
+
+#[derive(Debug, Clone, Deserialize)]
+pub struct Customers {
+ id: Secret<String>,
+}
+
+impl<F>
+ TryFrom<
+ types::ResponseRouterData<
+ F,
+ GocardlessCustomerResponse,
+ types::ConnectorCustomerData,
+ types::PaymentsResponseData,
+ >,
+ > for types::RouterData<F, types::ConnectorCustomerData, types::PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: types::ResponseRouterData<
+ F,
+ GocardlessCustomerResponse,
+ types::ConnectorCustomerData,
+ types::PaymentsResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ response: Ok(types::PaymentsResponseData::ConnectorCustomerResponse {
+ connector_customer_id: item.response.customers.id.expose(),
+ }),
+ ..item.data
+ })
+ }
+}
+
+#[derive(Debug, Serialize)]
+pub struct GocardlessBankAccountRequest {
+ customer_bank_accounts: CustomerBankAccounts,
+}
+
+#[derive(Debug, Serialize)]
+pub struct CustomerBankAccounts {
+ #[serde(flatten)]
+ accounts: CustomerBankAccount,
+ links: CustomerAccountLink,
+}
+
+#[derive(Debug, Serialize)]
+pub struct CustomerAccountLink {
+ customer: Secret<String>,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(untagged)]
+pub enum CustomerBankAccount {
+ InternationalBankAccount(InternationalBankAccount),
+ AUBankAccount(AUBankAccount),
+ USBankAccount(USBankAccount),
+}
+
+#[derive(Debug, Serialize)]
+pub struct InternationalBankAccount {
+ iban: Secret<String>,
+ account_holder_name: Secret<String>,
+}
+
+#[derive(Debug, Serialize)]
+pub struct AUBankAccount {
+ country_code: CountryAlpha2,
+ account_number: Secret<String>,
+ branch_code: Secret<String>,
+ account_holder_name: Secret<String>,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "lowercase")]
+pub struct USBankAccount {
+ country_code: CountryAlpha2,
+ account_number: Secret<String>,
+ bank_code: Secret<String>,
+ account_type: AccountType,
+ account_holder_name: Secret<String>,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "lowercase")]
+pub enum AccountType {
+ Checking,
+ Savings,
+}
+
+impl TryFrom<&types::TokenizationRouterData> for GocardlessBankAccountRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &types::TokenizationRouterData) -> Result<Self, Self::Error> {
+ let customer = item.get_connector_customer_id()?;
+ let accounts = CustomerBankAccount::try_from(item)?;
+ let links = CustomerAccountLink {
+ customer: Secret::new(customer),
+ };
+ Ok(Self {
+ customer_bank_accounts: CustomerBankAccounts { accounts, links },
+ })
+ }
+}
+
+impl TryFrom<&types::TokenizationRouterData> for CustomerBankAccount {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &types::TokenizationRouterData) -> Result<Self, Self::Error> {
+ match &item.request.payment_method_data {
+ api_models::payments::PaymentMethodData::BankDebit(bank_debit_data) => {
+ Self::try_from(bank_debit_data)
+ }
+ api_models::payments::PaymentMethodData::Card(_)
+ | api_models::payments::PaymentMethodData::CardRedirect(_)
+ | api_models::payments::PaymentMethodData::Wallet(_)
+ | api_models::payments::PaymentMethodData::PayLater(_)
+ | api_models::payments::PaymentMethodData::BankRedirect(_)
+ | api_models::payments::PaymentMethodData::BankTransfer(_)
+ | api_models::payments::PaymentMethodData::Crypto(_)
+ | api_models::payments::PaymentMethodData::MandatePayment
+ | api_models::payments::PaymentMethodData::Reward
+ | api_models::payments::PaymentMethodData::Upi(_)
+ | api_models::payments::PaymentMethodData::Voucher(_)
+ | api_models::payments::PaymentMethodData::GiftCard(_) => {
+ Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("Gocardless"),
+ )
+ .into())
+ }
+ }
+ }
+}
+
+impl TryFrom<&BankDebitData> for CustomerBankAccount {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &BankDebitData) -> Result<Self, Self::Error> {
+ match item {
+ BankDebitData::AchBankDebit {
+ billing_details,
+ account_number,
+ routing_number,
+ bank_type,
+ bank_account_holder_name,
+ ..
+ } => {
+ let bank_type = bank_type.ok_or_else(utils::missing_field_err("bank_type"))?;
+ let country_code = billing_details.get_billing_country()?;
+ let account_holder_name =
+ bank_account_holder_name
+ .clone()
+ .ok_or_else(utils::missing_field_err(
+ "payment_method_data.bank_debit.ach_bank_debit.bank_account_holder_name",
+ ))?;
+ let us_bank_account = USBankAccount {
+ country_code,
+ account_number: account_number.clone(),
+ bank_code: routing_number.clone(),
+ account_type: AccountType::from(bank_type),
+ account_holder_name,
+ };
+ Ok(Self::USBankAccount(us_bank_account))
+ }
+ BankDebitData::BecsBankDebit {
+ billing_details,
+ account_number,
+ bsb_number,
+ bank_account_holder_name,
+ } => {
+ let country_code = billing_details.get_billing_country()?;
+ let account_holder_name =
+ bank_account_holder_name
+ .clone()
+ .ok_or_else(utils::missing_field_err(
+ "payment_method_data.bank_debit.becs_bank_debit.bank_account_holder_name",
+ ))?;
+ let au_bank_account = AUBankAccount {
+ country_code,
+ account_number: account_number.clone(),
+ branch_code: bsb_number.clone(),
+ account_holder_name,
+ };
+ Ok(Self::AUBankAccount(au_bank_account))
+ }
+ BankDebitData::SepaBankDebit {
+ iban,
+ bank_account_holder_name,
+ ..
+ } => {
+ let account_holder_name =
+ bank_account_holder_name
+ .clone()
+ .ok_or_else(utils::missing_field_err(
+ "payment_method_data.bank_debit.sepa_bank_debit.bank_account_holder_name",
+ ))?;
+ let international_bank_account = InternationalBankAccount {
+ iban: iban.clone(),
+ account_holder_name,
+ };
+ Ok(Self::InternationalBankAccount(international_bank_account))
+ }
+ BankDebitData::BacsBankDebit { .. } => Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("Gocardless"),
+ )
+ .into()),
+ }
+ }
+}
+
+impl From<BankType> for AccountType {
+ fn from(item: BankType) -> Self {
+ match item {
+ BankType::Checking => Self::Checking,
+ BankType::Savings => Self::Savings,
+ }
+ }
+}
+
+#[derive(Debug, Clone, Deserialize)]
+pub struct GocardlessBankAccountResponse {
+ customer_bank_accounts: CustomerBankAccountResponse,
+}
+
+#[derive(Debug, Clone, Deserialize)]
+pub struct CustomerBankAccountResponse {
+ pub id: Secret<String>,
+}
+
+impl<F>
+ TryFrom<
+ types::ResponseRouterData<
+ F,
+ GocardlessBankAccountResponse,
+ types::PaymentMethodTokenizationData,
+ types::PaymentsResponseData,
+ >,
+ > for types::RouterData<F, types::PaymentMethodTokenizationData, types::PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: types::ResponseRouterData<
+ F,
+ GocardlessBankAccountResponse,
+ types::PaymentMethodTokenizationData,
+ types::PaymentsResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ response: Ok(types::PaymentsResponseData::TokenizationResponse {
+ token: item.response.customer_bank_accounts.id.expose(),
+ }),
+ ..item.data
+ })
+ }
+}
+
+#[derive(Debug, Serialize)]
+pub struct GocardlessMandateRequest {
+ mandates: Mandate,
+}
+
+#[derive(Debug, Serialize)]
+pub struct Mandate {
+ scheme: GocardlessScheme,
+ metadata: MandateMetaData,
+ payer_ip_address: Option<Secret<String, IpAddress>>,
+ links: MandateLink,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "snake_case")]
+pub enum GocardlessScheme {
+ Becs,
+ SepaCore,
+ Ach,
+ BecsNz,
+}
+
+#[derive(Debug, Serialize)]
+pub struct MandateMetaData {
+ payment_reference: String,
+}
+
+#[derive(Debug, Serialize)]
+pub struct MandateLink {
+ customer_bank_account: Secret<String>,
+}
+
+impl TryFrom<&types::PaymentsPreProcessingRouterData> for GocardlessMandateRequest {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &types::PaymentsPreProcessingRouterData) -> Result<Self, Self::Error> {
+ let (scheme, payer_ip_address) = match &item.request.payment_method_data {
+ Some(payment_method_data) => match payment_method_data {
+ api_models::payments::PaymentMethodData::BankDebit(bank_debit_data) => {
+ let payer_ip_address = get_ip_if_required(bank_debit_data, item)?;
+ Ok((
+ GocardlessScheme::try_from(bank_debit_data)?,
+ payer_ip_address,
+ ))
+ }
+ api_models::payments::PaymentMethodData::Card(_)
+ | api_models::payments::PaymentMethodData::CardRedirect(_)
+ | api_models::payments::PaymentMethodData::Wallet(_)
+ | api_models::payments::PaymentMethodData::PayLater(_)
+ | api_models::payments::PaymentMethodData::BankRedirect(_)
+ | api_models::payments::PaymentMethodData::BankTransfer(_)
+ | api_models::payments::PaymentMethodData::Crypto(_)
+ | api_models::payments::PaymentMethodData::MandatePayment
+ | api_models::payments::PaymentMethodData::Reward
+ | api_models::payments::PaymentMethodData::Upi(_)
+ | api_models::payments::PaymentMethodData::Voucher(_)
+ | api_models::payments::PaymentMethodData::GiftCard(_) => {
+ Err(errors::ConnectorError::NotImplemented(
+ "Preprocessing flow for selected payment method through Gocardless"
+ .to_string(),
+ ))
+ }
+ },
+ None => Err(errors::ConnectorError::NotImplemented(
+ "Preprocessing flow for selected payment method through Gocardless".to_string(),
+ )),
+ }?;
+ let payment_method_token = item.get_payment_method_token()?;
+ let customer_bank_account = match payment_method_token {
+ types::PaymentMethodToken::Token(token) => Ok(token),
+ types::PaymentMethodToken::ApplePayDecrypt(_) => {
+ Err(errors::ConnectorError::NotImplemented(
+ "Preprocessing flow for selected payment method through Gocardless".to_string(),
+ ))
+ }
+ }?;
+ Ok(Self {
+ mandates: Mandate {
+ scheme,
+ metadata: MandateMetaData {
+ payment_reference: item.connector_request_reference_id.clone(),
+ },
+ payer_ip_address,
+ links: MandateLink {
+ customer_bank_account: Secret::new(customer_bank_account),
+ },
+ },
+ })
+ }
+}
+
+fn get_ip_if_required(
+ bank_debit_data: &BankDebitData,
+ item: &types::PaymentsPreProcessingRouterData,
+) -> Result<Option<Secret<String, IpAddress>>, error_stack::Report<errors::ConnectorError>> {
+ let ip_address = item.request.get_browser_info()?.get_ip_address()?;
+ match bank_debit_data {
+ BankDebitData::AchBankDebit { .. } => Ok(Some(ip_address)),
+ BankDebitData::SepaBankDebit { .. }
+ | BankDebitData::BecsBankDebit { .. }
+ | BankDebitData::BacsBankDebit { .. } => Ok(None),
+ }
+}
+
+impl TryFrom<&BankDebitData> for GocardlessScheme {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &BankDebitData) -> Result<Self, Self::Error> {
+ match item {
+ BankDebitData::AchBankDebit { .. } => Ok(Self::Ach),
+ BankDebitData::SepaBankDebit { .. } => Ok(Self::SepaCore),
+ BankDebitData::BecsBankDebit { .. } => Ok(Self::Becs),
+ BankDebitData::BacsBankDebit { .. } => Err(errors::ConnectorError::NotImplemented(
+ "Preprocessing flow for selected payment method through Gocardless".to_string(),
+ )
+ .into()),
+ }
+ }
+}
+
+#[derive(Debug, Clone, Deserialize)]
+pub struct GocardlessMandateResponse {
+ mandates: MandateResponse,
+}
+
+#[derive(Debug, Clone, Deserialize)]
+pub struct MandateResponse {
+ id: String,
+}
+
+impl<F>
+ TryFrom<
+ types::ResponseRouterData<
+ F,
+ GocardlessMandateResponse,
+ types::PaymentsPreProcessingData,
+ types::PaymentsResponseData,
+ >,
+ > for types::RouterData<F, types::PaymentsPreProcessingData, types::PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: types::ResponseRouterData<
+ F,
+ GocardlessMandateResponse,
+ types::PaymentsPreProcessingData,
+ types::PaymentsResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ preprocessing_id: Some(item.response.mandates.id.clone()),
+ response: Ok(types::PaymentsResponseData::PreProcessingResponse {
+ pre_processing_id: types::PreprocessingResponseId::PreProcessingId(
+ item.response.mandates.id,
+ ),
+ connector_metadata: None,
+ session_token: None,
+ connector_response_reference_id: None,
+ }),
+ status: enums::AttemptStatus::Pending,
+ ..item.data
+ })
+ }
+}
+
+#[derive(Debug, Serialize)]
pub struct GocardlessPaymentsRequest {
+ payments: GocardlessPayment,
+}
+
+#[derive(Debug, Serialize)]
+pub struct GocardlessPayment {
amount: i64,
- card: GocardlessCard,
+ currency: enums::Currency,
+ description: Option<String>,
+ metadata: PaymentMetaData,
+ links: PaymentLink,
+}
+
+#[derive(Debug, Serialize)]
+pub struct PaymentMetaData {
+ payment_reference: String,
}
-#[derive(Default, Debug, Serialize, Eq, PartialEq)]
-pub struct GocardlessCard {
- name: Secret<String>,
- number: cards::CardNumber,
- expiry_month: Secret<String>,
- expiry_year: Secret<String>,
- cvc: Secret<String>,
- complete: bool,
+#[derive(Debug, Serialize)]
+pub struct PaymentLink {
+ mandate: Secret<String>,
}
impl TryFrom<&GocardlessRouterData<&types::PaymentsAuthorizeRouterData>>
@@ -62,30 +553,39 @@ impl TryFrom<&GocardlessRouterData<&types::PaymentsAuthorizeRouterData>>
fn try_from(
item: &GocardlessRouterData<&types::PaymentsAuthorizeRouterData>,
) -> Result<Self, Self::Error> {
- match item.router_data.request.payment_method_data.clone() {
- api::PaymentMethodData::Card(req_card) => {
- let card = GocardlessCard {
- name: req_card.card_holder_name,
- 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.to_owned(),
- card,
- })
+ let mandate_id = if item.router_data.request.is_mandate_payment() {
+ if item.router_data.request.setup_future_usage.is_some() {
+ item.router_data.get_preprocessing_id()
+ } else {
+ item.router_data
+ .request
+ .connector_mandate_id()
+ .ok_or_else(utils::missing_field_err("preprocessing_id"))
}
- _ => Err(errors::ConnectorError::NotImplemented("Payment methods".to_string()).into()),
- }
+ } else {
+ Err(errors::ConnectorError::NotImplemented(
+ utils::get_unimplemented_payment_method_error_message("gocardless"),
+ )
+ .into())
+ }?;
+ let payments = GocardlessPayment {
+ amount: item.router_data.request.amount,
+ currency: item.router_data.request.currency,
+ description: item.router_data.description.clone(),
+ metadata: PaymentMetaData {
+ payment_reference: item.router_data.connector_request_reference_id.clone(),
+ },
+ links: PaymentLink {
+ mandate: Secret::new(mandate_id),
+ },
+ };
+ Ok(Self { payments })
}
}
-//TODO: Fill the struct with respective fields
// Auth Struct
pub struct GocardlessAuthType {
- pub(super) api_key: Secret<String>,
+ pub(super) access_token: Secret<String>,
}
impl TryFrom<&types::ConnectorAuthType> for GocardlessAuthType {
@@ -93,58 +593,117 @@ impl TryFrom<&types::ConnectorAuthType> for GocardlessAuthType {
fn try_from(auth_type: &types::ConnectorAuthType) -> Result<Self, Self::Error> {
match auth_type {
types::ConnectorAuthType::HeaderKey { api_key } => Ok(Self {
- api_key: api_key.to_owned(),
+ access_token: api_key.to_owned(),
}),
_ => Err(errors::ConnectorError::FailedToObtainAuthType.into()),
}
}
}
-// PaymentsResponse
-//TODO: Append the remaining status flags
-#[derive(Debug, Clone, Default, Serialize, Deserialize, PartialEq)]
-#[serde(rename_all = "lowercase")]
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
pub enum GocardlessPaymentStatus {
- Succeeded,
+ PendingCustomerApproval,
+ PendingSubmission,
+ Submitted,
+ Confirmed,
+ PaidOut,
+ Cancelled,
+ CustomerApprovalDenied,
Failed,
- #[default]
- Processing,
}
impl From<GocardlessPaymentStatus> for enums::AttemptStatus {
fn from(item: GocardlessPaymentStatus) -> Self {
match item {
- GocardlessPaymentStatus::Succeeded => Self::Charged,
+ GocardlessPaymentStatus::PendingCustomerApproval
+ | GocardlessPaymentStatus::PendingSubmission
+ | GocardlessPaymentStatus::Submitted => Self::Pending,
+ GocardlessPaymentStatus::Confirmed | GocardlessPaymentStatus::PaidOut => Self::Charged,
+ GocardlessPaymentStatus::Cancelled => Self::Voided,
+ GocardlessPaymentStatus::CustomerApprovalDenied => Self::AuthenticationFailed,
GocardlessPaymentStatus::Failed => Self::Failure,
- GocardlessPaymentStatus::Processing => Self::Authorizing,
}
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Clone, Serialize, Deserialize, PartialEq)]
+#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct GocardlessPaymentsResponse {
+ payments: PaymentResponse,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct PaymentResponse {
status: GocardlessPaymentStatus,
id: String,
}
-impl<F, T>
+impl<F>
TryFrom<
- types::ResponseRouterData<F, GocardlessPaymentsResponse, T, types::PaymentsResponseData>,
- > for types::RouterData<F, T, types::PaymentsResponseData>
+ types::ResponseRouterData<
+ F,
+ GocardlessPaymentsResponse,
+ types::PaymentsAuthorizeData,
+ types::PaymentsResponseData,
+ >,
+ > for types::RouterData<F, types::PaymentsAuthorizeData, types::PaymentsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
item: types::ResponseRouterData<
F,
GocardlessPaymentsResponse,
- T,
+ types::PaymentsAuthorizeData,
types::PaymentsResponseData,
>,
) -> Result<Self, Self::Error> {
+ let connector_mandate_id = if item.data.request.setup_mandate_details.is_some() {
+ item.data.get_preprocessing_id()?
+ } else {
+ item.data.request.get_connector_mandate_id()?
+ };
+ let mandate_reference = MandateReference {
+ connector_mandate_id: Some(connector_mandate_id),
+ payment_method_id: None,
+ };
Ok(Self {
- status: enums::AttemptStatus::from(item.response.status),
+ status: enums::AttemptStatus::from(item.response.payments.status),
response: Ok(types::PaymentsResponseData::TransactionResponse {
- resource_id: types::ResponseId::ConnectorTransactionId(item.response.id),
+ resource_id: types::ResponseId::ConnectorTransactionId(item.response.payments.id),
+ redirection_data: None,
+ mandate_reference: Some(mandate_reference),
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ }),
+ ..item.data
+ })
+ }
+}
+
+impl<F>
+ TryFrom<
+ types::ResponseRouterData<
+ F,
+ GocardlessPaymentsResponse,
+ types::PaymentsSyncData,
+ types::PaymentsResponseData,
+ >,
+ > for types::RouterData<F, types::PaymentsSyncData, types::PaymentsResponseData>
+{
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(
+ item: types::ResponseRouterData<
+ F,
+ GocardlessPaymentsResponse,
+ types::PaymentsSyncData,
+ types::PaymentsResponseData,
+ >,
+ ) -> Result<Self, Self::Error> {
+ Ok(Self {
+ status: enums::AttemptStatus::from(item.response.payments.status),
+ response: Ok(types::PaymentsResponseData::TransactionResponse {
+ resource_id: types::ResponseId::ConnectorTransactionId(item.response.payments.id),
redirection_data: None,
mandate_reference: None,
connector_metadata: None,
@@ -156,12 +715,27 @@ impl<F, T>
}
}
-//TODO: Fill the struct with respective fields
// REFUND :
-// Type definition for RefundRequest
#[derive(Default, Debug, Serialize)]
pub struct GocardlessRefundRequest {
- pub amount: i64,
+ refunds: GocardlessRefund,
+}
+
+#[derive(Default, Debug, Serialize)]
+pub struct GocardlessRefund {
+ amount: i64,
+ metadata: RefundMetaData,
+ links: RefundLink,
+}
+
+#[derive(Default, Debug, Serialize)]
+pub struct RefundMetaData {
+ refund_reference: String,
+}
+
+#[derive(Default, Debug, Serialize)]
+pub struct RefundLink {
+ payment: String,
}
impl<F> TryFrom<&GocardlessRouterData<&types::RefundsRouterData<F>>> for GocardlessRefundRequest {
@@ -170,38 +744,22 @@ impl<F> TryFrom<&GocardlessRouterData<&types::RefundsRouterData<F>>> for Gocardl
item: &GocardlessRouterData<&types::RefundsRouterData<F>>,
) -> Result<Self, Self::Error> {
Ok(Self {
- amount: item.amount.to_owned(),
+ refunds: GocardlessRefund {
+ amount: item.amount.to_owned(),
+ metadata: RefundMetaData {
+ refund_reference: item.router_data.connector_request_reference_id.clone(),
+ },
+ links: RefundLink {
+ payment: item.router_data.request.connector_transaction_id.clone(),
+ },
+ },
})
}
}
-// Type definition for Refund Response
-
-#[allow(dead_code)]
-#[derive(Debug, Serialize, Default, Deserialize, Clone)]
-pub enum RefundStatus {
- Succeeded,
- Failed,
- #[default]
- Processing,
-}
-
-impl From<RefundStatus> for enums::RefundStatus {
- fn from(item: RefundStatus) -> Self {
- match item {
- RefundStatus::Succeeded => Self::Success,
- RefundStatus::Failed => Self::Failure,
- RefundStatus::Processing => Self::Pending,
- //TODO: Review mapping
- }
- }
-}
-
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Clone, Serialize, Deserialize)]
+#[derive(Default, Debug, Clone, Deserialize)]
pub struct RefundResponse {
id: String,
- status: RefundStatus,
}
impl TryFrom<types::RefundsResponseRouterData<api::Execute, RefundResponse>>
@@ -214,35 +772,142 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, RefundResponse>>
Ok(Self {
response: Ok(types::RefundsResponseData {
connector_refund_id: item.response.id.to_string(),
- refund_status: enums::RefundStatus::from(item.response.status),
+ refund_status: enums::RefundStatus::Pending,
}),
..item.data
})
}
}
-impl TryFrom<types::RefundsResponseRouterData<api::RSync, RefundResponse>>
- for types::RefundsRouterData<api::RSync>
-{
+#[derive(Clone, Debug, Deserialize)]
+pub struct GocardlessErrorResponse {
+ pub error: GocardlessError,
+}
+
+#[derive(Clone, Debug, Deserialize)]
+pub struct GocardlessError {
+ pub message: String,
+ pub code: u16,
+ pub errors: Vec<Error>,
+ #[serde(rename = "type")]
+ pub error_type: String,
+}
+
+#[derive(Clone, Debug, Deserialize)]
+pub struct Error {
+ pub field: Option<String>,
+ pub message: String,
+}
+
+#[derive(Debug, Deserialize)]
+pub struct GocardlessWebhookEvent {
+ pub events: Vec<WebhookEvent>,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct WebhookEvent {
+ pub resource_type: WebhookResourceType,
+ pub action: WebhookAction,
+ pub links: WebhooksLink,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum WebhookResourceType {
+ Payments,
+ Refunds,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(untagged)]
+pub enum WebhookAction {
+ PaymentsAction(PaymentsAction),
+ RefundsAction(RefundsAction),
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum PaymentsAction {
+ Created,
+ CustomerApprovalGranted,
+ CustomerApprovalDenied,
+ Submitted,
+ Confirmed,
+ PaidOut,
+ LateFailureSettled,
+ SurchargeFeeDebited,
+ Failed,
+ Cancelled,
+ ResubmissionRequired,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "snake_case")]
+pub enum RefundsAction {
+ Created,
+ Failed,
+ Paid,
+ // Payout statuses
+ RefundSettled,
+ FundsReturned,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(untagged)]
+pub enum WebhooksLink {
+ PaymentWebhooksLink(PaymentWebhooksLink),
+ RefundWebhookLink(RefundWebhookLink),
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct RefundWebhookLink {
+ pub refund: String,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+pub struct PaymentWebhooksLink {
+ pub payment: String,
+}
+
+impl TryFrom<&WebhookEvent> for GocardlessPaymentsResponse {
type Error = error_stack::Report<errors::ConnectorError>;
- fn try_from(
- item: types::RefundsResponseRouterData<api::RSync, RefundResponse>,
- ) -> Result<Self, Self::Error> {
+ fn try_from(item: &WebhookEvent) -> Result<Self, Self::Error> {
+ let id = match &item.links {
+ WebhooksLink::PaymentWebhooksLink(link) => link.payment.to_owned(),
+ WebhooksLink::RefundWebhookLink(_) => {
+ Err(errors::ConnectorError::WebhookEventTypeNotFound)?
+ }
+ };
Ok(Self {
- response: Ok(types::RefundsResponseData {
- connector_refund_id: item.response.id.to_string(),
- refund_status: enums::RefundStatus::from(item.response.status),
- }),
- ..item.data
+ payments: PaymentResponse {
+ status: GocardlessPaymentStatus::try_from(&item.action)?,
+ id,
+ },
})
}
}
-//TODO: Fill the struct with respective fields
-#[derive(Default, Debug, Serialize, Deserialize, PartialEq)]
-pub struct GocardlessErrorResponse {
- pub status_code: u16,
- pub code: String,
- pub message: String,
- pub reason: Option<String>,
+impl TryFrom<&WebhookAction> for GocardlessPaymentStatus {
+ type Error = error_stack::Report<errors::ConnectorError>;
+ fn try_from(item: &WebhookAction) -> Result<Self, Self::Error> {
+ match item {
+ WebhookAction::PaymentsAction(action) => match action {
+ PaymentsAction::CustomerApprovalGranted | PaymentsAction::Submitted => {
+ Ok(Self::Submitted)
+ }
+ PaymentsAction::CustomerApprovalDenied => Ok(Self::CustomerApprovalDenied),
+ PaymentsAction::LateFailureSettled => Ok(Self::Failed),
+ PaymentsAction::Failed => Ok(Self::Failed),
+ PaymentsAction::Cancelled => Ok(Self::Cancelled),
+ PaymentsAction::Confirmed => Ok(Self::Confirmed),
+ PaymentsAction::PaidOut => Ok(Self::PaidOut),
+ PaymentsAction::SurchargeFeeDebited
+ | PaymentsAction::ResubmissionRequired
+ | PaymentsAction::Created => Err(errors::ConnectorError::WebhookEventTypeNotFound)?,
+ },
+ WebhookAction::RefundsAction(_) => {
+ Err(errors::ConnectorError::WebhookEventTypeNotFound)?
+ }
+ }
+ }
}
diff --git a/crates/router/src/connector/stripe/transformers.rs b/crates/router/src/connector/stripe/transformers.rs
index d84db563e1..bd67a3f6d8 100644
--- a/crates/router/src/connector/stripe/transformers.rs
+++ b/crates/router/src/connector/stripe/transformers.rs
@@ -1199,6 +1199,7 @@ fn get_bank_debit_data(
billing_details,
account_number,
bsb_number,
+ ..
} => {
let becs_data = BankDebitData::Becs {
account_number: account_number.to_owned(),
diff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rs
index 07c04e05cf..c9904b41e6 100644
--- a/crates/router/src/connector/utils.rs
+++ b/crates/router/src/connector/utils.rs
@@ -2,7 +2,7 @@ use std::collections::HashMap;
use api_models::{
enums::{CanadaStatesAbbreviation, UsStatesAbbreviation},
- payments::{self, OrderDetailsWithAmount},
+ payments::{self, BankDebitBilling, OrderDetailsWithAmount},
};
use base64::Engine;
use common_utils::{
@@ -199,6 +199,7 @@ pub trait PaymentsPreProcessingData {
fn get_order_details(&self) -> Result<Vec<OrderDetailsWithAmount>, Error>;
fn get_webhook_url(&self) -> Result<String, Error>;
fn get_return_url(&self) -> Result<String, Error>;
+ fn get_browser_info(&self) -> Result<types::BrowserInformation, Error>;
}
impl PaymentsPreProcessingData for types::PaymentsPreProcessingData {
@@ -238,6 +239,11 @@ impl PaymentsPreProcessingData for types::PaymentsPreProcessingData {
.clone()
.ok_or_else(missing_field_err("return_url"))
}
+ fn get_browser_info(&self) -> Result<types::BrowserInformation, Error> {
+ self.browser_info
+ .clone()
+ .ok_or_else(missing_field_err("browser_info"))
+ }
}
pub trait PaymentsCaptureRequestData {
@@ -355,6 +361,16 @@ impl PaymentsAuthorizeRequestData for types::PaymentsAuthorizeData {
}
}
+pub trait ConnectorCustomerData {
+ fn get_email(&self) -> Result<Email, Error>;
+}
+
+impl ConnectorCustomerData for types::ConnectorCustomerData {
+ fn get_email(&self) -> Result<Email, Error> {
+ self.email.clone().ok_or_else(missing_field_err("email"))
+ }
+}
+
pub trait BrowserInformationData {
fn get_accept_header(&self) -> Result<String, Error>;
fn get_language(&self) -> Result<String, Error>;
@@ -863,6 +879,19 @@ impl BankRedirectBillingData for payments::BankRedirectBilling {
}
}
+pub trait BankDirectDebitBillingData {
+ fn get_billing_country(&self) -> Result<api_models::enums::CountryAlpha2, Error>;
+}
+
+impl BankDirectDebitBillingData for BankDebitBilling {
+ fn get_billing_country(&self) -> Result<api_models::enums::CountryAlpha2, Error> {
+ self.address
+ .as_ref()
+ .and_then(|address| address.country)
+ .ok_or_else(missing_field_err("billing_details.country"))
+ }
+}
+
pub trait MandateData {
fn get_end_date(&self, format: date_time::DateFormat) -> Result<String, Error>;
fn get_metadata(&self) -> Result<pii::SecretSerdeValue, Error>;
diff --git a/crates/router/src/core/admin.rs b/crates/router/src/core/admin.rs
index 8b6a33a5d3..db1af73e62 100644
--- a/crates/router/src/core/admin.rs
+++ b/crates/router/src/core/admin.rs
@@ -1302,10 +1302,10 @@ pub(crate) fn validate_auth_type(
globepay::transformers::GlobepayAuthType::try_from(val)?;
Ok(())
}
- /*api_enums::Connector::Gocardless => {
+ api_enums::Connector::Gocardless => {
gocardless::transformers::GocardlessAuthType::try_from(val)?;
Ok(())
- }*/
+ }
api_enums::Connector::Iatapay => {
iatapay::transformers::IatapayAuthType::try_from(val)?;
Ok(())
diff --git a/crates/router/src/core/payments.rs b/crates/router/src/core/payments.rs
index 9b7d0b3eec..4f8fa4a7b5 100644
--- a/crates/router/src/core/payments.rs
+++ b/crates/router/src/core/payments.rs
@@ -1030,6 +1030,16 @@ where
(router_data, should_continue_payment)
}
}
+ Some(api_models::payments::PaymentMethodData::BankDebit(_)) => {
+ if connector.connector_name == router_types::Connector::Gocardless {
+ router_data = router_data.preprocessing_steps(state, connector).await?;
+ let is_error_in_response = router_data.response.is_err();
+ // If is_error_in_response is true, should_continue_payment should be false, we should throw the error
+ (router_data, !is_error_in_response)
+ } else {
+ (router_data, should_continue_payment)
+ }
+ }
_ => (router_data, should_continue_payment),
};
diff --git a/crates/router/src/core/payments/flows.rs b/crates/router/src/core/payments/flows.rs
index 2dae93ac78..034ed4b662 100644
--- a/crates/router/src/core/payments/flows.rs
+++ b/crates/router/src/core/payments/flows.rs
@@ -142,7 +142,6 @@ impl<const T: u8>
}
default_imp_for_complete_authorize!(
- connector::Gocardless,
connector::Aci,
connector::Adyen,
connector::Bitpay,
@@ -156,6 +155,7 @@ default_imp_for_complete_authorize!(
connector::Fiserv,
connector::Forte,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -207,7 +207,6 @@ impl<const T: u8>
}
default_imp_for_create_customer!(
- connector::Gocardless,
connector::Aci,
connector::Adyen,
connector::Airwallex,
@@ -284,7 +283,6 @@ impl<const T: u8> services::ConnectorRedirectResponse for connector::DummyConnec
}
default_imp_for_connector_redirect_response!(
- connector::Gocardless,
connector::Aci,
connector::Adyen,
connector::Bitpay,
@@ -297,6 +295,7 @@ default_imp_for_connector_redirect_response!(
connector::Fiserv,
connector::Forte,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -330,7 +329,6 @@ macro_rules! default_imp_for_connector_request_id {
impl<const T: u8> api::ConnectorTransactionId for connector::DummyConnector<T> {}
default_imp_for_connector_request_id!(
- connector::Gocardless,
connector::Aci,
connector::Adyen,
connector::Airwallex,
@@ -350,6 +348,7 @@ default_imp_for_connector_request_id!(
connector::Forte,
connector::Globalpay,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -409,7 +408,6 @@ impl<const T: u8>
}
default_imp_for_accept_dispute!(
- connector::Gocardless,
connector::Aci,
connector::Adyen,
connector::Airwallex,
@@ -428,6 +426,7 @@ default_imp_for_accept_dispute!(
connector::Forte,
connector::Globalpay,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -507,7 +506,6 @@ impl<const T: u8>
}
default_imp_for_file_upload!(
- connector::Gocardless,
connector::Aci,
connector::Adyen,
connector::Airwallex,
@@ -526,6 +524,7 @@ default_imp_for_file_upload!(
connector::Forte,
connector::Globalpay,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -582,7 +581,6 @@ impl<const T: u8>
}
default_imp_for_submit_evidence!(
- connector::Gocardless,
connector::Aci,
connector::Adyen,
connector::Airwallex,
@@ -601,6 +599,7 @@ default_imp_for_submit_evidence!(
connector::Forte,
connector::Globalpay,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -657,7 +656,6 @@ impl<const T: u8>
}
default_imp_for_defend_dispute!(
- connector::Gocardless,
connector::Aci,
connector::Adyen,
connector::Airwallex,
@@ -676,6 +674,7 @@ default_imp_for_defend_dispute!(
connector::Globepay,
connector::Forte,
connector::Globalpay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -733,7 +732,6 @@ impl<const T: u8>
}
default_imp_for_pre_processing_steps!(
- connector::Gocardless,
connector::Aci,
connector::Adyen,
connector::Airwallex,
@@ -791,7 +789,6 @@ macro_rules! default_imp_for_payouts {
impl<const T: u8> api::Payouts for connector::DummyConnector<T> {}
default_imp_for_payouts!(
- connector::Gocardless,
connector::Aci,
connector::Airwallex,
connector::Authorizedotnet,
@@ -810,6 +807,7 @@ default_imp_for_payouts!(
connector::Forte,
connector::Globalpay,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -867,7 +865,6 @@ impl<const T: u8>
#[cfg(feature = "payouts")]
default_imp_for_payouts_create!(
- connector::Gocardless,
connector::Aci,
connector::Airwallex,
connector::Authorizedotnet,
@@ -886,6 +883,7 @@ default_imp_for_payouts_create!(
connector::Forte,
connector::Globalpay,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -946,7 +944,6 @@ impl<const T: u8>
#[cfg(feature = "payouts")]
default_imp_for_payouts_eligibility!(
- connector::Gocardless,
connector::Aci,
connector::Airwallex,
connector::Authorizedotnet,
@@ -965,6 +962,7 @@ default_imp_for_payouts_eligibility!(
connector::Forte,
connector::Globalpay,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -1022,7 +1020,6 @@ impl<const T: u8>
#[cfg(feature = "payouts")]
default_imp_for_payouts_fulfill!(
- connector::Gocardless,
connector::Aci,
connector::Airwallex,
connector::Authorizedotnet,
@@ -1041,6 +1038,7 @@ default_imp_for_payouts_fulfill!(
connector::Forte,
connector::Globalpay,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -1098,7 +1096,6 @@ impl<const T: u8>
#[cfg(feature = "payouts")]
default_imp_for_payouts_cancel!(
- connector::Gocardless,
connector::Aci,
connector::Airwallex,
connector::Authorizedotnet,
@@ -1117,6 +1114,7 @@ default_imp_for_payouts_cancel!(
connector::Forte,
connector::Globalpay,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -1174,7 +1172,6 @@ impl<const T: u8>
#[cfg(feature = "payouts")]
default_imp_for_payouts_quote!(
- connector::Gocardless,
connector::Aci,
connector::Adyen,
connector::Airwallex,
@@ -1194,6 +1191,7 @@ default_imp_for_payouts_quote!(
connector::Forte,
connector::Globalpay,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -1251,7 +1249,6 @@ impl<const T: u8>
#[cfg(feature = "payouts")]
default_imp_for_payouts_recipient!(
- connector::Gocardless,
connector::Aci,
connector::Adyen,
connector::Airwallex,
@@ -1271,6 +1268,7 @@ default_imp_for_payouts_recipient!(
connector::Forte,
connector::Globalpay,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -1327,7 +1325,6 @@ impl<const T: u8>
}
default_imp_for_approve!(
- connector::Gocardless,
connector::Aci,
connector::Adyen,
connector::Airwallex,
@@ -1347,6 +1344,7 @@ default_imp_for_approve!(
connector::Forte,
connector::Globalpay,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
@@ -1404,7 +1402,6 @@ impl<const T: u8>
}
default_imp_for_reject!(
- connector::Gocardless,
connector::Aci,
connector::Adyen,
connector::Airwallex,
@@ -1424,6 +1421,7 @@ default_imp_for_reject!(
connector::Forte,
connector::Globalpay,
connector::Globepay,
+ connector::Gocardless,
connector::Helcim,
connector::Iatapay,
connector::Klarna,
diff --git a/crates/router/src/core/payments/flows/authorize_flow.rs b/crates/router/src/core/payments/flows/authorize_flow.rs
index 7313195a2d..00d3b02058 100644
--- a/crates/router/src/core/payments/flows/authorize_flow.rs
+++ b/crates/router/src/core/payments/flows/authorize_flow.rs
@@ -379,6 +379,7 @@ impl TryFrom<types::PaymentsAuthorizeData> for types::PaymentsPreProcessingData
router_return_url: data.router_return_url,
webhook_url: data.webhook_url,
complete_authorize_url: data.complete_authorize_url,
+ browser_info: data.browser_info,
})
}
}
diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rs
index 2606b81ae3..9723b4c92f 100644
--- a/crates/router/src/core/payments/transformers.rs
+++ b/crates/router/src/core/payments/transformers.rs
@@ -1323,6 +1323,15 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProce
attempt,
connector_name,
));
+ let browser_info: Option<types::BrowserInformation> = payment_data
+ .payment_attempt
+ .browser_info
+ .clone()
+ .map(|b| b.parse_value("BrowserInformation"))
+ .transpose()
+ .change_context(errors::ApiErrorResponse::InvalidDataValue {
+ field_name: "browser_info",
+ })?;
Ok(Self {
payment_method_data,
@@ -1336,6 +1345,7 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsPreProce
router_return_url,
webhook_url,
complete_authorize_url,
+ browser_info,
})
}
}
diff --git a/crates/router/src/types.rs b/crates/router/src/types.rs
index 77c053d47c..dd1cec763f 100644
--- a/crates/router/src/types.rs
+++ b/crates/router/src/types.rs
@@ -419,6 +419,7 @@ pub struct PaymentsPreProcessingData {
pub router_return_url: Option<String>,
pub webhook_url: Option<String>,
pub complete_authorize_url: Option<String>,
+ pub browser_info: Option<BrowserInformation>,
}
#[derive(Debug, Clone)]
diff --git a/crates/router/src/types/api.rs b/crates/router/src/types/api.rs
index 1ec5907378..1783017b12 100644
--- a/crates/router/src/types/api.rs
+++ b/crates/router/src/types/api.rs
@@ -315,7 +315,7 @@ impl ConnectorData {
enums::Connector::Forte => Ok(Box::new(&connector::Forte)),
enums::Connector::Globalpay => Ok(Box::new(&connector::Globalpay)),
enums::Connector::Globepay => Ok(Box::new(&connector::Globepay)),
- //enums::Connector::Gocardless => Ok(Box::new(&connector::Gocardless)),
+ enums::Connector::Gocardless => Ok(Box::new(&connector::Gocardless)),
//enums::Connector::Helcim => Ok(Box::new(&connector::Helcim)), , it is added as template code for future usage
enums::Connector::Iatapay => Ok(Box::new(&connector::Iatapay)),
enums::Connector::Klarna => Ok(Box::new(&connector::Klarna)),
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index aa71a21e1c..ebab00cac1 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -187,6 +187,11 @@ stripe = { long_lived_token = false, payment_method = "wallet", payment_method_t
checkout = { long_lived_token = false, payment_method = "wallet" }
mollie = {long_lived_token = false, payment_method = "card"}
braintree = { long_lived_token = false, payment_method = "card" }
+gocardless = {long_lived_token = true, payment_method = "bank_debit"}
+
+[connector_customer]
+connector_list = "gocardless,stax,stripe"
+payout_connector_list = "wise"
[dummy_connector]
enabled = true
diff --git a/openapi/openapi_spec.json b/openapi/openapi_spec.json
index 51e6494d8e..33f86dab7b 100644
--- a/openapi/openapi_spec.json
+++ b/openapi/openapi_spec.json
@@ -2626,6 +2626,12 @@
"type": "string",
"description": "Bank-State-Branch (bsb) number",
"example": "000000"
+ },
+ "bank_account_holder_name": {
+ "type": "string",
+ "description": "Owner name for bank debit",
+ "example": "A. Schneider",
+ "nullable": true
}
}
}
@@ -3848,6 +3854,7 @@
"forte",
"globalpay",
"globepay",
+ "gocardless",
"iatapay",
"klarna",
"mollie",