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): [ACI] Implement Trustly Bank Redirect (#1130)

Sakil Mostak46b40ecce540
diff --git a/Cargo.lock b/Cargo.lock
index 6cb3e12410..b504c3db42 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -2970,7 +2970,7 @@ dependencies = [
[[package]]
name = "opentelemetry"
version = "0.18.0"
-source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
+source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
dependencies = [
"opentelemetry_api",
"opentelemetry_sdk",
@@ -2979,7 +2979,7 @@ dependencies = [
[[package]]
name = "opentelemetry-otlp"
version = "0.11.0"
-source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
+source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
dependencies = [
"async-trait",
"futures",
@@ -2996,7 +2996,7 @@ dependencies = [
[[package]]
name = "opentelemetry-proto"
version = "0.1.0"
-source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
+source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
dependencies = [
"futures",
"futures-util",
@@ -3008,7 +3008,7 @@ dependencies = [
[[package]]
name = "opentelemetry_api"
version = "0.18.0"
-source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
+source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
dependencies = [
"fnv",
"futures-channel",
@@ -3023,7 +3023,7 @@ dependencies = [
[[package]]
name = "opentelemetry_sdk"
version = "0.18.0"
-source = "git+https://github.com/open-telemetry/opentelemetry-rust?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
+source = "git+https://github.com/open-telemetry/opentelemetry-rust/?rev=44b90202fd744598db8b0ace5b8f0bad7ec45658#44b90202fd744598db8b0ace5b8f0bad7ec45658"
dependencies = [
"async-trait",
"crossbeam-channel",
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 59671836ae..52e72fd2f3 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -670,7 +670,11 @@ pub enum BankRedirectData {
preferred_language: String,
},
Swish {},
- Trustly {},
+ Trustly {
+ /// The country for bank payment
+ #[schema(value_type = CountryAlpha2, example = "US")]
+ country: api_enums::CountryAlpha2,
+ },
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize, ToSchema)]
diff --git a/crates/router/src/connector/aci/transformers.rs b/crates/router/src/connector/aci/transformers.rs
index 62b25c343e..760dfa3809 100644
--- a/crates/router/src/connector/aci/transformers.rs
+++ b/crates/router/src/connector/aci/transformers.rs
@@ -74,8 +74,13 @@ pub struct BankRedirectionPMData {
bank_account_bic: Option<Secret<String>>,
#[serde(rename = "bankAccount.iban")]
bank_account_iban: Option<Secret<String>>,
+ #[serde(rename = "billing.country")]
+ billing_country: Option<api_models::enums::CountryAlpha2>,
#[serde(rename = "customer.email")]
customer_email: Option<Email>,
+ #[serde(rename = "customer.merchantCustomerId")]
+ merchant_customer_id: Option<Secret<String>>,
+ merchant_transaction_id: Option<Secret<String>>,
shopper_result_url: Option<String>,
}
@@ -151,6 +156,9 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AciPaymentsRequest {
bank_account_bank_name: None,
bank_account_bic: None,
bank_account_iban: None,
+ billing_country: None,
+ merchant_customer_id: None,
+ merchant_transaction_id: None,
customer_email: None,
shopper_result_url: item.request.router_return_url.clone(),
}))
@@ -165,6 +173,9 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AciPaymentsRequest {
bank_account_bank_name: None,
bank_account_bic: bank_account_bic.clone(),
bank_account_iban: bank_account_iban.clone(),
+ billing_country: None,
+ merchant_customer_id: None,
+ merchant_transaction_id: None,
customer_email: None,
shopper_result_url: item.request.router_return_url.clone(),
})),
@@ -175,6 +186,9 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AciPaymentsRequest {
bank_account_bank_name: Some(bank_name.to_string()),
bank_account_bic: None,
bank_account_iban: None,
+ billing_country: None,
+ merchant_customer_id: None,
+ merchant_transaction_id: None,
customer_email: None,
shopper_result_url: item.request.router_return_url.clone(),
}))
@@ -186,6 +200,9 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AciPaymentsRequest {
bank_account_bank_name: None,
bank_account_bic: None,
bank_account_iban: None,
+ billing_country: None,
+ merchant_customer_id: None,
+ merchant_transaction_id: None,
customer_email: None,
shopper_result_url: item.request.router_return_url.clone(),
}))
@@ -197,6 +214,9 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AciPaymentsRequest {
bank_account_bank_name: None,
bank_account_bic: None,
bank_account_iban: None,
+ billing_country: None,
+ merchant_customer_id: None,
+ merchant_transaction_id: None,
customer_email: Some(email.to_owned()),
shopper_result_url: item.request.router_return_url.clone(),
@@ -209,10 +229,33 @@ impl TryFrom<&types::PaymentsAuthorizeRouterData> for AciPaymentsRequest {
bank_account_bank_name: None,
bank_account_bic: None,
bank_account_iban: None,
+ billing_country: None,
+ merchant_customer_id: None,
+ merchant_transaction_id: None,
customer_email: Some(email.to_owned()),
shopper_result_url: item.request.router_return_url.clone(),
}))
}
+ api_models::payments::BankRedirectData::Trustly { country } => {
+ PaymentDetails::BankRedirect(Box::new(BankRedirectionPMData {
+ payment_brand: PaymentBrand::Trustly,
+ bank_account_country: None,
+ bank_account_bank_name: None,
+ bank_account_bic: None,
+ bank_account_iban: None,
+ billing_country: Some(*country),
+ merchant_customer_id: Some(Secret::new(
+ item.customer_id.clone().ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "customer_id",
+ },
+ )?,
+ )),
+ merchant_transaction_id: Some(Secret::new(item.payment_id.clone())),
+ customer_email: None,
+ shopper_result_url: item.request.router_return_url.clone(),
+ }))
+ }
_ => Err(errors::ConnectorError::NotImplemented(
"Payment method".to_string(),
))?,
diff --git a/crates/router/src/connector/adyen/transformers.rs b/crates/router/src/connector/adyen/transformers.rs
index d1d5b3ef35..57dfe7f3fc 100644
--- a/crates/router/src/connector/adyen/transformers.rs
+++ b/crates/router/src/connector/adyen/transformers.rs
@@ -1165,11 +1165,11 @@ impl<'a> TryFrom<&api_models::payments::BankRedirectData> for AdyenPaymentMethod
payment_type: PaymentType::Sofort,
})),
),
- api_models::payments::BankRedirectData::Trustly {} => Ok(AdyenPaymentMethod::Trustly(
- Box::new(BankRedirectionPMData {
+ api_models::payments::BankRedirectData::Trustly { .. } => Ok(
+ AdyenPaymentMethod::Trustly(Box::new(BankRedirectionPMData {
payment_type: PaymentType::Trustly,
- }),
- )),
+ })),
+ ),
_ => Err(errors::ConnectorError::NotImplemented("Payment method".to_string()).into()),
}
}