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): [SANTANDER] Added Boleto Payment Method (#9008)

Sayak Bhattacharya63857a86a603
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 3a94e62089..6c2fedbf68 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -10792,7 +10792,55 @@
"properties": {
"social_security_number": {
"type": "string",
- "description": "The shopper's social security number",
+ "description": "The shopper's social security number (CPF or CNPJ)",
+ "nullable": true
+ },
+ "bank_number": {
+ "type": "string",
+ "description": "The shopper's bank account number associated with the boleto",
+ "nullable": true
+ },
+ "document_type": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/DocumentKind"
+ }
+ ],
+ "default": "Cnpj",
+ "nullable": true
+ },
+ "fine_percentage": {
+ "type": "string",
+ "description": "The fine percentage charged if payment is overdue",
+ "nullable": true
+ },
+ "fine_quantity_days": {
+ "type": "string",
+ "description": "The number of days after the due date when the fine is applied",
+ "nullable": true
+ },
+ "interest_percentage": {
+ "type": "string",
+ "description": "The interest percentage charged on late payments",
+ "nullable": true
+ },
+ "write_off_quantity_days": {
+ "type": "string",
+ "description": "The number of days after which the boleto is written off (canceled)",
+ "nullable": true
+ },
+ "messages": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Custom messages or instructions to display on the boleto",
+ "nullable": true
+ },
+ "due_date": {
+ "type": "string",
+ "format": "date",
+ "example": "2025-08-22",
"nullable": true
}
}
@@ -14576,6 +14624,13 @@
"dispute_lost"
]
},
+ "DocumentKind": {
+ "type": "string",
+ "enum": [
+ "CNPJ",
+ "CPF"
+ ]
+ },
"DokuBankTransferInstructions": {
"type": "object",
"required": [
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 4cf8b42437..8a103d92a8 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -7312,7 +7312,55 @@
"properties": {
"social_security_number": {
"type": "string",
- "description": "The shopper's social security number",
+ "description": "The shopper's social security number (CPF or CNPJ)",
+ "nullable": true
+ },
+ "bank_number": {
+ "type": "string",
+ "description": "The shopper's bank account number associated with the boleto",
+ "nullable": true
+ },
+ "document_type": {
+ "allOf": [
+ {
+ "$ref": "#/components/schemas/DocumentKind"
+ }
+ ],
+ "default": "Cnpj",
+ "nullable": true
+ },
+ "fine_percentage": {
+ "type": "string",
+ "description": "The fine percentage charged if payment is overdue",
+ "nullable": true
+ },
+ "fine_quantity_days": {
+ "type": "string",
+ "description": "The number of days after the due date when the fine is applied",
+ "nullable": true
+ },
+ "interest_percentage": {
+ "type": "string",
+ "description": "The interest percentage charged on late payments",
+ "nullable": true
+ },
+ "write_off_quantity_days": {
+ "type": "string",
+ "description": "The number of days after which the boleto is written off (canceled)",
+ "nullable": true
+ },
+ "messages": {
+ "type": "array",
+ "items": {
+ "type": "string"
+ },
+ "description": "Custom messages or instructions to display on the boleto",
+ "nullable": true
+ },
+ "due_date": {
+ "type": "string",
+ "format": "date",
+ "example": "2025-08-22",
"nullable": true
}
}
@@ -10707,6 +10755,13 @@
"dispute_lost"
]
},
+ "DocumentKind": {
+ "type": "string",
+ "enum": [
+ "CNPJ",
+ "CPF"
+ ]
+ },
"DokuBankTransferInstructions": {
"type": "object",
"required": [
diff --git a/config/config.example.toml b/config/config.example.toml
index 3490ee80ea..18387dc5c6 100644
--- a/config/config.example.toml
+++ b/config/config.example.toml
@@ -291,6 +291,7 @@ recurly.base_url = "https://v3.recurly.com"
redsys.base_url = "https://sis-t.redsys.es:25443"
riskified.base_url = "https://sandbox.riskified.com/api"
santander.base_url = "https://pix.santander.com.br/api/v1/sandbox/"
+santander.secondary_base_url = "https://trust-sandbox.api.santander.com.br/collection_bill_management/"
shift4.base_url = "https://api.shift4.com/"
sift.base_url = "https://api.sift.com/v205"
silverflow.base_url = "https://api-sbx.silverflow.co/v1"
diff --git a/config/deployments/integration_test.toml b/config/deployments/integration_test.toml
index 15f3233e17..a0118ec104 100644
--- a/config/deployments/integration_test.toml
+++ b/config/deployments/integration_test.toml
@@ -127,6 +127,7 @@ razorpay.base_url = "https://api.razorpay.com/"
recurly.base_url = "https://v3.recurly.com"
redsys.base_url = "https://sis-t.redsys.es:25443"
santander.base_url = "https://pix.santander.com.br/api/v1/sandbox/"
+santander.secondary_base_url = "https://trust-sandbox.api.santander.com.br/collection_bill_management/"
shift4.base_url = "https://api.shift4.com/"
sift.base_url = "https://api.sift.com/v205"
silverflow.base_url = "https://api-sbx.silverflow.co/v1"
diff --git a/config/deployments/production.toml b/config/deployments/production.toml
index 124a31113d..8e3e33f1d4 100644
--- a/config/deployments/production.toml
+++ b/config/deployments/production.toml
@@ -132,6 +132,7 @@ recurly.base_url = "https://v3.recurly.com"
redsys.base_url = "https://sis.redsys.es"
riskified.base_url = "https://wh.riskified.com/api/"
santander.base_url = "https://trust-pix.santander.com.br/"
+santander.secondary_base_url = "https://trust-open.api.santander.com.br/collection_bill_management/"
shift4.base_url = "https://api.shift4.com/"
sift.base_url = "https://api.sift.com/v205"
silverflow.base_url = "https://api.silverflow.co/v1"
diff --git a/config/deployments/sandbox.toml b/config/deployments/sandbox.toml
index 4fe6332572..d4984d88b3 100644
--- a/config/deployments/sandbox.toml
+++ b/config/deployments/sandbox.toml
@@ -132,6 +132,7 @@ recurly.base_url = "https://v3.recurly.com"
redsys.base_url = "https://sis-t.redsys.es:25443"
riskified.base_url = "https://sandbox.riskified.com/api"
santander.base_url = "https://pix.santander.com.br/api/v1/sandbox/"
+santander.secondary_base_url = "https://trust-sandbox.api.santander.com.br/collection_bill_management/"
shift4.base_url = "https://api.shift4.com/"
sift.base_url = "https://api.sift.com/v205"
silverflow.base_url = "https://api-sbx.silverflow.co/v1"
diff --git a/config/development.toml b/config/development.toml
index 01506adb60..08c67f7dea 100644
--- a/config/development.toml
+++ b/config/development.toml
@@ -329,6 +329,7 @@ recurly.base_url = "https://v3.recurly.com"
redsys.base_url = "https://sis-t.redsys.es:25443"
riskified.base_url = "https://sandbox.riskified.com/api"
santander.base_url = "https://pix.santander.com.br/api/v1/sandbox/"
+santander.secondary_base_url = "https://trust-sandbox.api.santander.com.br/collection_bill_management/"
shift4.base_url = "https://api.shift4.com/"
sift.base_url = "https://api.sift.com/v205"
silverflow.base_url = "https://api-sbx.silverflow.co/v1"
diff --git a/config/docker_compose.toml b/config/docker_compose.toml
index 8dbbd2aada..cd2dfb5b73 100644
--- a/config/docker_compose.toml
+++ b/config/docker_compose.toml
@@ -217,6 +217,7 @@ recurly.base_url = "https://v3.recurly.com"
redsys.base_url = "https://sis-t.redsys.es:25443"
riskified.base_url = "https://sandbox.riskified.com/api"
santander.base_url = "https://pix.santander.com.br/api/v1/sandbox/"
+santander.secondary_base_url = "https://trust-sandbox.api.santander.com.br/collection_bill_management/"
shift4.base_url = "https://api.shift4.com/"
sift.base_url = "https://api.sift.com/v205"
silverflow.base_url = "https://api-sbx.silverflow.co/v1"
diff --git a/crates/api_models/src/payments.rs b/crates/api_models/src/payments.rs
index 4789ec15df..34a8beee16 100644
--- a/crates/api_models/src/payments.rs
+++ b/crates/api_models/src/payments.rs
@@ -4264,11 +4264,44 @@ pub struct RewardData {
pub merchant_id: id_type::MerchantId,
}
-#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
+#[derive(Debug, Clone, PartialEq, Eq, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct BoletoVoucherData {
- /// The shopper's social security number
+ /// The shopper's social security number (CPF or CNPJ)
#[schema(value_type = Option<String>)]
pub social_security_number: Option<Secret<String>>,
+
+ /// The shopper's bank account number associated with the boleto
+ #[schema(value_type = Option<String>)]
+ pub bank_number: Option<Secret<String>>,
+
+ /// The type of identification document used (e.g., CPF or CNPJ)
+ #[schema(value_type = Option<DocumentKind>, example = "Cpf", default = "Cnpj")]
+ pub document_type: Option<common_enums::DocumentKind>,
+
+ /// The fine percentage charged if payment is overdue
+ #[schema(value_type = Option<String>)]
+ pub fine_percentage: Option<String>,
+
+ /// The number of days after the due date when the fine is applied
+ #[schema(value_type = Option<String>)]
+ pub fine_quantity_days: Option<String>,
+
+ /// The interest percentage charged on late payments
+ #[schema(value_type = Option<String>)]
+ pub interest_percentage: Option<String>,
+
+ /// The number of days after which the boleto is written off (canceled)
+ #[schema(value_type = Option<String>)]
+ pub write_off_quantity_days: Option<String>,
+
+ /// Custom messages or instructions to display on the boleto
+ #[schema(value_type = Option<Vec<String>>)]
+ pub messages: Option<Vec<String>>,
+
+ // #[serde(with = "common_utils::custom_serde::date_yyyy_mm_dd::option")]
+ #[schema(value_type = Option<String>, format = "date", example = "2025-08-22")]
+ // The date upon which the boleto is due and is of format: "YYYY-MM-DD"
+ pub due_date: Option<String>,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
@@ -4979,6 +5012,8 @@ pub struct BankTransferNextStepsData {
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
pub struct VoucherNextStepData {
+ /// Voucher entry date
+ pub entry_date: Option<String>,
/// Voucher expiry date and time
pub expires_at: Option<i64>,
/// Reference number required for the transaction
@@ -4987,6 +5022,8 @@ pub struct VoucherNextStepData {
pub download_url: Option<Url>,
/// Url to payment instruction page
pub instructions_url: Option<Url>,
+ /// Human-readable numeric version of the barcode.
+ pub digitable_line: Option<Secret<String>>,
}
#[derive(Clone, Debug, Eq, PartialEq, serde::Serialize, serde::Deserialize, ToSchema)]
diff --git a/crates/common_enums/src/enums.rs b/crates/common_enums/src/enums.rs
index 67c5efb00a..25e28112f6 100644
--- a/crates/common_enums/src/enums.rs
+++ b/crates/common_enums/src/enums.rs
@@ -576,6 +576,27 @@ pub enum CallConnectorAction {
UCSHandleResponse(Vec<u8>),
}
+#[derive(
+ Clone,
+ Copy,
+ Debug,
+ Eq,
+ Hash,
+ PartialEq,
+ serde::Deserialize,
+ serde::Serialize,
+ strum::Display,
+ strum::VariantNames,
+ strum::EnumIter,
+ strum::EnumString,
+ ToSchema,
+)]
+#[serde(rename_all = "UPPERCASE")]
+pub enum DocumentKind {
+ Cnpj,
+ Cpf,
+}
+
/// The three-letter ISO 4217 currency code (e.g., "USD", "EUR") for the payment amount. This field is mandatory for creating a payment.
#[allow(clippy::upper_case_acronyms)]
#[derive(
diff --git a/crates/connector_configs/toml/development.toml b/crates/connector_configs/toml/development.toml
index ded3ee24bf..64b571ff9a 100644
--- a/crates/connector_configs/toml/development.toml
+++ b/crates/connector_configs/toml/development.toml
@@ -6552,6 +6552,12 @@ required=true
type="Select"
options=[]
+[santander]
+[[santander.voucher]]
+ payment_method_type = "boleto"
+[[santander.bank_transfer]]
+ payment_method_type = "pix"
+
[santander.connector_auth.BodyKey]
api_key="Client ID"
key1="Client Secret"
@@ -6591,6 +6597,20 @@ placeholder="Enter the merchant name"
required=true
type="Text"
+[santander.metadata.workspace_id]
+name="workspace_id"
+label="Workspace Id"
+placeholder="Enter the workspace id"
+required=true
+type="Text"
+
+[santander.metadata.covenant_code]
+name="covenant_code"
+label="Covenant Code"
+placeholder="Enter the covenant code"
+required=true
+type="Text"
+
[blackhawknetwork]
[[blackhawknetwork.gift_card]]
payment_method_type = "bhn_card_network"
diff --git a/crates/connector_configs/toml/production.toml b/crates/connector_configs/toml/production.toml
index c0332a75da..1587177208 100644
--- a/crates/connector_configs/toml/production.toml
+++ b/crates/connector_configs/toml/production.toml
@@ -5205,6 +5205,12 @@ placeholder = "Enter Acquirer Country Code"
required = false
type = "Text"
+
+[santander]
+[[santander.voucher]]
+ payment_method_type = "boleto"
+[[santander.bank_transfer]]
+ payment_method_type = "pix"
[santander.connector_auth.BodyKey]
api_key = "Client ID"
key1 = "Client Secret"
@@ -5244,6 +5250,20 @@ placeholder = "Enter the merchant name"
required = true
type = "Text"
+[santander.metadata.workspace_id]
+name="workspace_id"
+label="Workspace Id"
+placeholder="Enter the workspace id"
+required=true
+type="Text"
+
+[santander.metadata.covenant_code]
+name="covenant_code"
+label="Covenant Code"
+placeholder="Enter the covenant code"
+required=true
+type="Text"
+
[blackhawknetwork]
[[blackhawknetwork.gift_card]]
payment_method_type = "bhn_card_network"
diff --git a/crates/connector_configs/toml/sandbox.toml b/crates/connector_configs/toml/sandbox.toml
index 7f95cd02c5..8c8a5d0d19 100644
--- a/crates/connector_configs/toml/sandbox.toml
+++ b/crates/connector_configs/toml/sandbox.toml
@@ -6534,6 +6534,12 @@ required = true
type = "Select"
options = []
+[santander]
+[[santander.voucher]]
+ payment_method_type = "boleto"
+[[santander.bank_transfer]]
+ payment_method_type = "pix"
+
[santander.connector_auth.BodyKey]
api_key = "Client ID"
key1 = "Client Secret"
@@ -6573,6 +6579,20 @@ placeholder = "Enter the merchant name"
required = true
type = "Text"
+[santander.metadata.workspace_id]
+name="workspace_id"
+label="Workspace Id"
+placeholder="Enter the workspace id"
+required=true
+type="Text"
+
+[santander.metadata.covenant_code]
+name="covenant_code"
+label="Covenant Code"
+placeholder="Enter the covenant code"
+required=true
+type="Text"
+
[blackhawknetwork]
[[blackhawknetwork.gift_card]]
payment_method_type = "bhn_card_network"
diff --git a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
index 8abe4beb98..1a83cb7db6 100644
--- a/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/adyen/transformers.rs
@@ -4507,6 +4507,8 @@ pub fn get_present_to_shopper_metadata(
reference,
download_url: response.action.download_url.clone(),
instructions_url: response.action.instructions_url.clone(),
+ entry_date: None,
+ digitable_line: None,
};
Some(voucher_data.encode_to_value())
diff --git a/crates/hyperswitch_connectors/src/connectors/santander.rs b/crates/hyperswitch_connectors/src/connectors/santander.rs
index 90769e15f4..ee2b396417 100644
--- a/crates/hyperswitch_connectors/src/connectors/santander.rs
+++ b/crates/hyperswitch_connectors/src/connectors/santander.rs
@@ -5,12 +5,13 @@ use std::sync::LazyLock;
use base64::Engine;
use common_enums::enums;
use common_utils::{
+ crypto,
errors::CustomResult,
- ext_traits::BytesExt,
+ ext_traits::{ByteSliceExt, BytesExt},
request::{Method, Request, RequestBuilder, RequestContent},
- types::{AmountConvertor, StringMajorUnit, StringMajorUnitForConnector},
+ types::{AmountConvertor, MinorUnit, StringMajorUnit, StringMajorUnitForConnector},
};
-use error_stack::{report, ResultExt};
+use error_stack::ResultExt;
use hyperswitch_domain_models::{
router_data::{AccessToken, ErrorResponse, RouterData},
router_flow_types::{
@@ -44,7 +45,7 @@ use hyperswitch_interfaces::{
types::{self, RefreshTokenType, Response},
webhooks,
};
-use masking::{Mask, Maskable, PeekInterface};
+use masking::{Mask, Maskable, PeekInterface, Secret};
use transformers as santander;
use crate::{
@@ -66,6 +67,10 @@ impl Santander {
}
}
+pub mod santander_constants {
+ pub const SANTANDER_VERSION: &str = "v2";
+}
+
impl api::Payment for Santander {}
impl api::PaymentSession for Santander {}
impl api::ConnectorAccessToken for Santander {}
@@ -134,24 +139,47 @@ impl ConnectorCommon for Santander {
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
- let message = response
- .detail
- .as_ref()
- .cloned()
- .unwrap_or_else(|| NO_ERROR_MESSAGE.to_string());
-
- Ok(ErrorResponse {
- status_code: res.status_code,
- code: response.status.to_string(),
- message,
- reason: response.detail.clone(),
- attempt_status: None,
- connector_transaction_id: None,
- network_advice_code: None,
- network_decline_code: None,
- network_error_message: None,
- connector_metadata: None,
- })
+ match response {
+ santander::SantanderErrorResponse::PixQrCode(response) => {
+ let message = response
+ .detail
+ .as_ref()
+ .cloned()
+ .unwrap_or_else(|| NO_ERROR_MESSAGE.to_string());
+
+ Ok(ErrorResponse {
+ status_code: res.status_code,
+ code: response.status.to_string(),
+ message,
+ reason: response.detail.clone(),
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ })
+ }
+ santander::SantanderErrorResponse::Boleto(response) => Ok(ErrorResponse {
+ status_code: res.status_code,
+ code: response.error_code.to_string(),
+ message: response.error_message.clone(),
+ reason: Some(
+ response
+ .errors
+ .as_ref()
+ .and_then(|v| v.first())
+ .map(|e| e.message.clone())
+ .unwrap_or_else(|| NO_ERROR_MESSAGE.to_string()),
+ ),
+ attempt_status: None,
+ connector_transaction_id: None,
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
+ }),
+ }
}
}
@@ -279,11 +307,41 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
req: &PaymentsAuthorizeRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- Ok(format!(
- "{}cob/{}",
- self.base_url(connectors),
- req.payment_id
- ))
+ let santander_mca_metadata =
+ santander::SantanderMetadataObject::try_from(&req.connector_meta_data)?;
+
+ match req.payment_method {
+ enums::PaymentMethod::BankTransfer => match req.request.payment_method_type {
+ Some(enums::PaymentMethodType::Pix) => Ok(format!(
+ "{}cob/{}",
+ self.base_url(connectors),
+ req.payment_id
+ )),
+ _ => Err(errors::ConnectorError::NotSupported {
+ message: req.payment_method.to_string(),
+ connector: "Santander",
+ }
+ .into()),
+ },
+ enums::PaymentMethod::Voucher => match req.request.payment_method_type {
+ Some(enums::PaymentMethodType::Boleto) => Ok(format!(
+ "{:?}{}/workspaces/{}/bank_slips",
+ connectors.santander.secondary_base_url.clone(),
+ santander_constants::SANTANDER_VERSION,
+ santander_mca_metadata.workspace_id
+ )),
+ _ => Err(errors::ConnectorError::NotSupported {
+ message: req.payment_method.to_string(),
+ connector: "Santander",
+ }
+ .into()),
+ },
+ _ => Err(errors::ConnectorError::NotSupported {
+ message: req.payment_method.to_string(),
+ connector: "Santander",
+ }
+ .into()),
+ }
}
fn get_request_body(
@@ -335,7 +393,19 @@ impl ConnectorIntegration<Authorize, PaymentsAuthorizeData, PaymentsResponseData
.parse_struct("Santander PaymentsAuthorizeResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
- let original_amount = response.value.original.clone();
+ let original_amount = match response {
+ santander::SantanderPaymentsResponse::PixQRCode(ref pix_data) => {
+ pix_data.value.original.clone()
+ }
+ santander::SantanderPaymentsResponse::Boleto(_) => {
+ convert_amount(
+ self.amount_converter,
+ MinorUnit::new(data.request.amount),
+ data.request.currency,
+ )?
+ // no amount field in the boleto response
+ }
+ };
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
@@ -387,18 +457,60 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for San
req: &PaymentsSyncRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- let connector_payment_id = req
- .request
- .connector_transaction_id
- .get_connector_transaction_id()
- .change_context(errors::ConnectorError::MissingConnectorTransactionID)?;
+ match req.request.payment_method_type {
+ Some(enums::PaymentMethodType::Pix) => {
+ let connector_payment_id = req
+ .request
+ .connector_transaction_id
+ .get_connector_transaction_id()
+ .change_context(errors::ConnectorError::MissingConnectorTransactionID)?;
+
+ Ok(format!(
+ "{}{}{}",
+ self.base_url(connectors),
+ "cob/",
+ connector_payment_id
+ ))
+ }
+ Some(enums::PaymentMethodType::Boleto) => {
+ let bill_id = req
+ .request
+ .connector_meta
+ .clone()
+ .and_then(|val| val.as_str().map(|s| s.to_string()))
+ .ok_or_else(|| errors::ConnectorError::MissingRequiredField {
+ field_name: "bill_id",
+ })?;
+
+ Ok(format!(
+ "{:?}/{}/bills/{}/bank_slips",
+ connectors.santander.secondary_base_url.clone(),
+ santander_constants::SANTANDER_VERSION,
+ bill_id
+ ))
+ }
+ _ => Err(errors::ConnectorError::MissingRequiredField {
+ field_name: "payment_method_type",
+ }
+ .into()),
+ }
+ }
- Ok(format!(
- "{}{}{}",
- self.base_url(connectors),
- "cob/",
- connector_payment_id
- ))
+ fn get_request_body(
+ &self,
+ req: &PaymentsSyncRouterData,
+ _connectors: &Connectors,
+ ) -> CustomResult<RequestContent, errors::ConnectorError> {
+ let amount = convert_amount(
+ self.amount_converter,
+ req.request.amount,
+ req.request.currency,
+ )?;
+
+ let connector_router_data = santander::SantanderRouterData::from((amount, req));
+ let connector_req =
+ santander::SantanderPSyncBoletoRequest::try_from(&connector_router_data)?;
+ Ok(RequestContent::Json(Box::new(connector_req)))
}
fn build_request(
@@ -406,14 +518,31 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for San
req: &PaymentsSyncRouterData,
connectors: &Connectors,
) -> CustomResult<Option<Request>, errors::ConnectorError> {
- Ok(Some(
- RequestBuilder::new()
- .method(Method::Get)
- .url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
- .attach_default_headers()
- .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
- .build(),
- ))
+ match req.request.payment_method_type {
+ Some(enums::PaymentMethodType::Pix) => Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Get)
+ .url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
+ .build(),
+ )),
+ Some(enums::PaymentMethodType::Boleto) => Ok(Some(
+ RequestBuilder::new()
+ .method(Method::Post)
+ .url(&types::PaymentsSyncType::get_url(self, req, connectors)?)
+ .attach_default_headers()
+ .headers(types::PaymentsSyncType::get_headers(self, req, connectors)?)
+ .set_body(types::PaymentsSyncType::get_request_body(
+ self, req, connectors,
+ )?)
+ .build(),
+ )),
+ _ => Err(errors::ConnectorError::MissingRequiredField {
+ field_name: "payment_method_type",
+ }
+ .into()),
+ }
}
fn handle_response(
@@ -426,7 +555,17 @@ impl ConnectorIntegration<PSync, PaymentsSyncData, PaymentsResponseData> for San
.response
.parse_struct("santander SantanderPaymentsSyncResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
- let original_amount = response.value.original.clone();
+
+ let original_amount = match response {
+ santander::SantanderPaymentsSyncResponse::PixQRCode(ref pix_data) => {
+ pix_data.base.value.original.clone()
+ }
+ santander::SantanderPaymentsSyncResponse::Boleto(_) => convert_amount(
+ self.amount_converter,
+ data.request.amount,
+ data.request.currency,
+ )?,
+ };
event_builder.map(|i| i.set_response_body(&response));
router_env::logger::info!(connector_response=?response);
@@ -563,12 +702,21 @@ impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Sa
req: &PaymentsCancelRouterData,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- let connector_payment_id = req.request.connector_transaction_id.clone();
- Ok(format!(
- "{}cob/{}",
- self.base_url(connectors),
- connector_payment_id
- ))
+ match req.payment_method {
+ enums::PaymentMethod::BankTransfer => {
+ let connector_payment_id = req.request.connector_transaction_id.clone();
+ Ok(format!(
+ "{}cob/{}",
+ self.base_url(connectors),
+ connector_payment_id
+ ))
+ }
+ _ => Err(errors::ConnectorError::NotSupported {
+ message: req.payment_method.to_string(),
+ connector: "Santander",
+ }
+ .into()),
+ }
}
fn get_request_body(
@@ -604,7 +752,7 @@ impl ConnectorIntegration<Void, PaymentsCancelData, PaymentsResponseData> for Sa
event_builder: Option<&mut ConnectorEvent>,
res: Response,
) -> CustomResult<PaymentsCancelRouterData, errors::ConnectorError> {
- let response: santander::SantanderVoidResponse = res
+ let response: santander::SantanderPixVoidResponse = res
.response
.parse_struct("Santander PaymentsResponse")
.change_context(errors::ConnectorError::ResponseDeserializationFailed)?;
@@ -644,25 +792,34 @@ impl ConnectorIntegration<Execute, RefundsData, RefundsResponseData> for Santand
req: &RefundsRouterData<Execute>,
connectors: &Connectors,
) -> CustomResult<String, errors::ConnectorError> {
- let end_to_end_id = req
- .request
- .connector_metadata
- .as_ref()
- .and_then(|metadata| metadata.get("end_to_end_id"))
- .and_then(|val| val.as_str().map(|id| id.to_string()))
- .ok_or_else(|| errors::ConnectorError::MissingRequiredField {
- field_name: "end_to_end_id",
- })?;
-
- let refund_id = req.request.connector_refund_id.clone();
- Ok(format!(
- "{}{}{}{}{:?}",
- self.base_url(connectors),
- "pix/",
- end_to_end_id,
- "/refund/",
- refund_id
- ))
+ match req.payment_method {
+ enums::PaymentMethod::BankTransfer => {
+ let end_to_end_id = req
+ .request
+ .connector_metadata
+ .as_ref()
+ .and_then(|metadata| metadata.get("end_to_end_id"))
+ .and_then(|val| val.as_str().map(|id| id.to_string()))
+ .ok_or_else(|| errors::ConnectorError::MissingRequiredField {
+ field_name: "end_to_end_id",
+ })?;
+
+ let refund_id = req.request.connector_refund_id.clone();
+ Ok(format!(
+ "{}{}{}{}{:?}",
+ self.base_url(connectors),
+ "pix/",
+ end_to_end_id,
+ "/refund/",
+ refund_id
+ ))
+ }
+ _ => Err(errors::ConnectorError::NotSupported {
+ message: req.payment_method.to_string(),
+ connector: "Santander",
+ }
+ .into()),
+ }
}
fn get_request_body(
@@ -830,27 +987,59 @@ impl ConnectorIntegration<RSync, RefundsData, RefundsResponseData> for Santander
}
}
+fn get_webhook_object_from_body(
+ body: &[u8],
+) -> CustomResult<santander::SantanderWebhookBody, common_utils::errors::ParsingError> {
+ let webhook: santander::SantanderWebhookBody = body.parse_struct("SantanderIncomingWebhook")?;
+
+ Ok(webhook)
+}
+
#[async_trait::async_trait]
impl webhooks::IncomingWebhook for Santander {
- fn get_webhook_object_reference_id(
+ async fn verify_webhook_source(
&self,
_request: &webhooks::IncomingWebhookRequestDetails<'_>,
+ _merchant_id: &common_utils::id_type::MerchantId,
+ _connector_webhook_details: Option<common_utils::pii::SecretSerdeValue>,
+ _connector_account_details: crypto::Encryptable<Secret<serde_json::Value>>,
+ _connector_name: &str,
+ ) -> CustomResult<bool, errors::ConnectorError> {
+ Ok(true) // Hardcoded to true as the source verification algorithm for Santander remains to be unknown (in docs it is mentioned as MTLS)
+ }
+
+ fn get_webhook_object_reference_id(
+ &self,
+ request: &webhooks::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<api_models::webhooks::ObjectReferenceId, errors::ConnectorError> {
- Err(report!(errors::ConnectorError::WebhooksNotImplemented))
+ let webhook_body = transformers::get_webhook_object_from_body(request.body)
+ .change_context(errors::ConnectorError::WebhookReferenceIdNotFound)?;
+
+ Ok(api_models::webhooks::ObjectReferenceId::PaymentId(
+ api_models::payments::PaymentIdType::ConnectorTransactionId(
+ webhook_body.participant_code,
+ ),
+ ))
}
fn get_webhook_event_type(
&self,
- _request: &webhooks::IncomingWebhookRequestDetails<'_>,
+ request: &webhooks::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<api_models::webhooks::IncomingWebhookEvent, errors::ConnectorError> {
- Err(report!(errors::ConnectorError::WebhooksNotImplemented))
+ let body = get_webhook_object_from_body(request.body)
+ .change_context(errors::ConnectorError::WebhookEventTypeNotFound)?;
+
+ Ok(transformers::get_santander_webhook_event(body.function))
}
fn get_webhook_resource_object(
&self,
- _request: &webhooks::IncomingWebhookRequestDetails<'_>,
+ request: &webhooks::IncomingWebhookRequestDetails<'_>,
) -> CustomResult<Box<dyn masking::ErasedMaskSerialize>, errors::ConnectorError> {
- Err(report!(errors::ConnectorError::WebhooksNotImplemented))
+ let webhook_body = transformers::get_webhook_object_from_body(request.body)
+ .change_context(errors::ConnectorError::WebhookResourceObjectNotFound)?;
+
+ Ok(Box::new(webhook_body))
}
}
@@ -866,6 +1055,17 @@ static SANTANDER_SUPPORTED_PAYMENT_METHODS: LazyLock<SupportedPaymentMethods> =
PaymentMethodDetails {
mandates: enums::FeatureStatus::NotSupported,
refunds: enums::FeatureStatus::Supported,
+ supported_capture_methods: supported_capture_methods.clone(),
+ specific_features: None,
+ },
+ );
+
+ santander_supported_payment_methods.add(
+ enums::PaymentMethod::Voucher,
+ enums::PaymentMethodType::Boleto,
+ PaymentMethodDetails {
+ mandates: enums::FeatureStatus::NotSupported,
+ refunds: enums::FeatureStatus::NotSupported,
supported_capture_methods,
specific_features: None,
},
@@ -882,7 +1082,8 @@ static SANTANDER_CONNECTOR_INFO: ConnectorInfo = ConnectorInfo {
integration_status: enums::ConnectorIntegrationStatus::Alpha,
};
-static SANTANDER_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 0] = [];
+static SANTANDER_SUPPORTED_WEBHOOK_FLOWS: [enums::EventClass; 2] =
+ [enums::EventClass::Payments, enums::EventClass::Refunds];
impl ConnectorSpecifications for Santander {
fn get_connector_about(&self) -> Option<&'static ConnectorInfo> {
diff --git a/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs b/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
index 5755e7577b..8bb6002dcb 100644
--- a/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
+++ b/crates/hyperswitch_connectors/src/connectors/santander/transformers.rs
@@ -1,22 +1,31 @@
-use api_models::payments::QrCodeInformation;
-use chrono::Utc;
-use common_enums::enums;
+use std::collections::HashMap;
+
+use api_models::payments::{QrCodeInformation, VoucherNextStepData};
+use common_enums::{enums, AttemptStatus};
use common_utils::{
errors::CustomResult,
- ext_traits::Encode,
- types::{AmountConvertor, StringMajorUnit, StringMajorUnitForConnector},
+ ext_traits::{ByteSliceExt, Encode},
+ id_type,
+ request::Method,
+ types::{AmountConvertor, FloatMajorUnit, StringMajorUnit, StringMajorUnitForConnector},
};
use crc::{Algorithm, Crc};
use error_stack::ResultExt;
use hyperswitch_domain_models::{
- payment_method_data::{BankTransferData, PaymentMethodData},
- router_data::{AccessToken, ConnectorAuthType, RouterData},
+ payment_method_data::{BankTransferData, PaymentMethodData, VoucherData},
+ router_data::{AccessToken, ConnectorAuthType, ErrorResponse, RouterData},
router_request_types::ResponseId,
- router_response_types::{PaymentsResponseData, RefundsResponseData},
- types::{PaymentsAuthorizeRouterData, PaymentsCancelRouterData, RefundsRouterData},
+ router_response_types::{PaymentsResponseData, RedirectForm, RefundsResponseData},
+ types::{
+ PaymentsAuthorizeRouterData, PaymentsCancelRouterData, PaymentsSyncRouterData,
+ RefundsRouterData,
+ },
+};
+use hyperswitch_interfaces::{
+ consts::{NO_ERROR_CODE, NO_ERROR_MESSAGE},
+ errors,
};
-use hyperswitch_interfaces::errors;
-use masking::{ExposeInterface, Secret};
+use masking::{ExposeInterface, PeekInterface, Secret};
use serde::{Deserialize, Serialize};
use serde_json::Value;
use time::OffsetDateTime;
@@ -52,14 +61,16 @@ impl<T> From<(StringMajorUnit, T)> for SantanderRouterData<T> {
}
}
}
-
#[derive(Debug, Default, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
pub struct SantanderMetadataObject {
pub pix_key: Secret<String>,
pub expiration_time: i32,
pub cpf: Secret<String>,
pub merchant_city: String,
pub merchant_name: String,
+ pub workspace_id: String,
+ pub covenant_code: String, // max_size : 9
}
impl TryFrom<&Option<common_utils::pii::SecretSerdeValue>> for SantanderMetadataObject {
@@ -153,6 +164,12 @@ pub struct SantanderCard {
complete: bool,
}
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SantanderPSyncBoletoRequest {
+ payer_document_number: Secret<i64>,
+}
+
pub struct SantanderAuthType {
pub(super) _api_key: Secret<String>,
pub(super) _key1: Secret<String>,
@@ -191,19 +208,20 @@ impl<F, T> TryFrom<ResponseRouterData<F, SantanderAuthUpdateResponse, T, AccessT
impl TryFrom<&SantanderRouterData<&PaymentsAuthorizeRouterData>> for SantanderPaymentRequest {
type Error = Error;
fn try_from(
- item: &SantanderRouterData<&PaymentsAuthorizeRouterData>,
+ value: &SantanderRouterData<&PaymentsAuthorizeRouterData>,
) -> Result<Self, Self::Error> {
- if item.router_data.request.capture_method != Some(enums::CaptureMethod::Automatic) {
+ if value.router_data.request.capture_method != Some(enums::CaptureMethod::Automatic) {
return Err(errors::ConnectorError::FlowNotSupported {
- flow: format!("{:?}", item.router_data.request.capture_method),
+ flow: format!("{:?}", value.router_data.request.capture_method),
connector: "Santander".to_string(),
}
.into());
}
- match item.router_data.request.payment_method_data.clone() {
+ match value.router_data.request.payment_method_data.clone() {
PaymentMethodData::BankTransfer(ref bank_transfer_data) => {
- Self::try_from((item, bank_transfer_data.as_ref()))
+ Self::try_from((value, bank_transfer_data.as_ref()))
}
+ PaymentMethodData::Voucher(ref voucher_data) => Self::try_from((value, voucher_data)),
_ => Err(errors::ConnectorError::NotImplemented(
crate::utils::get_unimplemented_payment_method_error_message("Santander"),
))?,
@@ -211,6 +229,146 @@ impl TryFrom<&SantanderRouterData<&PaymentsAuthorizeRouterData>> for SantanderPa
}
}
+impl TryFrom<&SantanderRouterData<&PaymentsSyncRouterData>> for SantanderPSyncBoletoRequest {
+ type Error = Error;
+ fn try_from(value: &SantanderRouterData<&PaymentsSyncRouterData>) -> Result<Self, Self::Error> {
+ let payer_document_number: i64 = value
+ .router_data
+ .connector_request_reference_id
+ .parse()
+ .map_err(|_| errors::ConnectorError::ParsingFailed)?;
+
+ Ok(Self {
+ payer_document_number: Secret::new(payer_document_number),
+ })
+ }
+}
+
+impl
+ TryFrom<(
+ &SantanderRouterData<&PaymentsAuthorizeRouterData>,
+ &VoucherData,
+ )> for SantanderPaymentRequest
+{
+ type Error = Error;
+ fn try_from(
+ value: (
+ &SantanderRouterData<&PaymentsAuthorizeRouterData>,
+ &VoucherData,
+ ),
+ ) -> Result<Self, Self::Error> {
+ let santander_mca_metadata =
+ SantanderMetadataObject::try_from(&value.0.router_data.connector_meta_data)?;
+
+ let voucher_data = match &value.0.router_data.request.payment_method_data {
+ PaymentMethodData::Voucher(VoucherData::Boleto(boleto_data)) => boleto_data,
+ _ => {
+ return Err(errors::ConnectorError::NotImplemented(
+ crate::utils::get_unimplemented_payment_method_error_message("Santander"),
+ )
+ .into());
+ }
+ };
+
+ let nsu_code = if value
+ .0
+ .router_data
+ .is_payment_id_from_merchant
+ .unwrap_or(false)
+ && value.0.router_data.payment_id.len() > 20
+ {
+ return Err(errors::ConnectorError::MaxFieldLengthViolated {
+ connector: "Santander".to_string(),
+ field_name: "payment_id".to_string(),
+ max_length: 20,
+ received_length: value.0.router_data.payment_id.len(),
+ }
+ .into());
+ } else {
+ value.0.router_data.payment_id.clone()
+ };
+
+ Ok(Self::Boleto(Box::new(SantanderBoletoPaymentRequest {
+ environment: Environment::from(router_env::env::which()),
+ nsu_code,
+ nsu_date: OffsetDateTime::now_utc()
+ .date()
+ .format(&time::macros::format_description!("[year]-[month]-[day]"))
+ .change_context(errors::ConnectorError::DateFormattingFailed)?,
+ covenant_code: santander_mca_metadata.covenant_code.clone(),
+ bank_number: voucher_data.bank_number.clone().ok_or_else(|| {
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "document_type",
+ }
+ })?, // size: 13
+ client_number: Some(value.0.router_data.get_customer_id()?),
+ due_date: voucher_data.due_date.clone().ok_or(
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "due_date",
+ },
+ )?,
+ issue_date: OffsetDateTime::now_utc()
+ .date()
+ .format(&time::macros::format_description!("[year]-[month]-[day]"))
+ .change_context(errors::ConnectorError::DateFormattingFailed)?,
+ currency: Some(value.0.router_data.request.currency),
+ nominal_value: value.0.amount.to_owned(),
+ participant_code: value
+ .0
+ .router_data
+ .request
+ .merchant_order_reference_id
+ .clone(),
+ payer: Payer {
+ name: value.0.router_data.get_billing_full_name()?,
+ document_type: voucher_data.document_type.ok_or_else(|| {
+ errors::ConnectorError::MissingRequiredField {
+ field_name: "document_type",
+ }
+ })?,
+ document_number: voucher_data.social_security_number.clone(),
+ address: Secret::new(
+ [
+ value.0.router_data.get_billing_line1()?,
+ value.0.router_data.get_billing_line2()?,
+ ]
+ .map(|s| s.expose())
+ .join(" "),
+ ),
+ neighborhood: value.0.router_data.get_billing_line1()?,
+ city: value.0.router_data.get_billing_city()?,
+ state: value.0.router_data.get_billing_state()?,
+ zipcode: value.0.router_data.get_billing_zip()?,
+ },
+ beneficiary: None,
+ document_kind: BoletoDocumentKind::BillProposal, // to change
+ discount: Some(Discount {
+ discount_type: DiscountType::Free,
+ discount_one: None,
+ discount_two: None,
+ discount_three: None,
+ }),
+ fine_percentage: voucher_data.fine_percentage.clone(),
+ fine_quantity_days: voucher_data.fine_quantity_days.clone(),
+ interest_percentage: voucher_data.interest_percentage.clone(),
+ deduction_value: None,
+ protest_type: None,
+ protest_quantity_days: None,
+ write_off_quantity_days: voucher_data.write_off_quantity_days.clone(),
+ payment_type: PaymentType::Registration,
+ parcels_quantity: None,
+ value_type: None,
+ min_value_or_percentage: None,
+ max_value_or_percentage: None,
+ iof_percentage: None,
+ sharing: None,
+ key: None,
+ tx_id: None,
+ messages: voucher_data.messages.clone(),
+ })))
+ }
+}
+
impl
TryFrom<(
&SantanderRouterData<&PaymentsAuthorizeRouterData>,
@@ -227,14 +385,17 @@ impl
let santander_mca_metadata =
SantanderMetadataObject::try_from(&value.0.router_data.connector_meta_data)?;
- let debtor = SantanderDebtor {
+ let debtor = Some(SantanderDebtor {
cpf: santander_mca_metadata.cpf.clone(),
name: value.0.router_data.get_billing_full_name()?,
- };
+ });
- Ok(Self {
+ Ok(Self::PixQR(Box::new(SantanderPixQRPaymentRequest {
calender: SantanderCalendar {
- creation: Utc::now().to_rfc3339(),
+ creation: OffsetDateTime::now_utc()
+ .date()
+ .format(&time::macros::format_description!("[year]-[month]-[day]"))
+ .change_context(errors::ConnectorError::DateFormattingFailed)?,
expiration: santander_mca_metadata.expiration_time,
},
debtor,
@@ -244,13 +405,193 @@ impl
key: santander_mca_metadata.pix_key.clone(),
request_payer: value.0.router_data.request.statement_descriptor.clone(),
additional_info: None,
- })
+ })))
}
}
+#[derive(Debug, Serialize)]
+pub enum SantanderPaymentRequest {
+ PixQR(Box<SantanderPixQRPaymentRequest>),
+ Boleto(Box<SantanderBoletoPaymentRequest>),
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct Discount {
+ #[serde(rename = "type")]
+ pub discount_type: DiscountType,
+ pub discount_one: Option<DiscountObject>,
+ pub discount_two: Option<DiscountObject>,
+ pub discount_three: Option<DiscountObject>,
+}
+
+#[derive(Debug, Serialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SantanderBoletoPaymentRequest {
+ pub environment: Environment,
+ pub nsu_code: String,
+ pub nsu_date: String,
+ pub covenant_code: String,
+ pub bank_number: Secret<String>,
+ pub client_number: Option<id_type::CustomerId>,
+ pub due_date: String,
+ pub issue_date: String,
+ pub currency: Option<enums::Currency>,
+ pub nominal_value: StringMajorUnit,
+ pub participant_code: Option<String>,
+ pub payer: Payer,
+ pub beneficiary: Option<Beneficiary>,
+ pub document_kind: BoletoDocumentKind,
+ pub discount: Option<Discount>,
+ pub fine_percentage: Option<String>,
+ pub fine_quantity_days: Option<String>,
+ pub interest_percentage: Option<String>,
+ pub deduction_value: Option<FloatMajorUnit>,
+ pub protest_type: Option<ProtestType>,
+ pub protest_quantity_days: Option<i64>,
+ pub write_off_quantity_days: Option<String>,
+ pub payment_type: PaymentType,
+ pub parcels_quantity: Option<i64>,
+ pub value_type: Option<String>,
+ pub min_value_or_percentage: Option<f64>,
+ pub max_value_or_percentage: Option<f64>,
+ pub iof_percentage: Option<f64>,
+ pub sharing: Option<Sharing>,
+ pub key: Option<Key>,
+ pub tx_id: Option<String>,
+ pub messages: Option<Vec<String>>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct Payer {
+ pub name: Secret<String>,
+ pub document_type: enums::DocumentKind,
+ pub document_number: Option<Secret<String>>,
+ pub address: Secret<String>,
+ pub neighborhood: Secret<String>,
+ pub city: String,
+ pub state: Secret<String>,
+ pub zipcode: Secret<String>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct Beneficiary {
+ pub name: Option<Secret<String>>,
+ pub document_type: Option<enums::DocumentKind>,
+ pub document_number: Option<String>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "UPPERCASE")]
+pub enum Environment {
+ #[serde(rename = "Teste")]
+ Sandbox,
+ #[serde(rename = "Producao")]
+ Production,
+}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "UPPERCASE")]
+pub enum SantanderDocumentKind {
+ Cpf,
+ Cnpj,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum BoletoDocumentKind {
+ #[serde(rename = "DUPLICATA_MERCANTIL")]
+ DuplicateMercantil,
+ #[serde(rename = "DUPLICATA_SERVICO")]
+ DuplicateService,
+ #[serde(rename = "NOTA_PROMISSORIA")]
+ PromissoryNote,
+ #[serde(rename = "NOTA_PROMISSORIA_RURAL")]
+ RuralPromissoryNote,
+ #[serde(rename = "RECIBO")]
+ Receipt,
+ #[serde(rename = "APOLICE_SEGURO")]
+ InsurancePolicy,
+ #[serde(rename = "BOLETO_CARTAO_CREDITO")]
+ BillCreditCard,
+ #[serde(rename = "BOLETO_PROPOSTA")]
+ BillProposal,
+ #[serde(rename = "BOLETO_DEPOSITO_APORTE")]
+ BoletoDepositoAponte,
+ #[serde(rename = "CHEQUE")]
+ Check,
+ #[serde(rename = "NOTA_PROMISSORIA_DIRETA")]
+ DirectPromissoryNote,
+ #[serde(rename = "OUTROS")]
+ Others,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum DiscountType {
+ #[serde(rename = "ISENTO")]
+ Free,
+ #[serde(rename = "VALOR_DATA_FIXA")]
+ FixedDateValue,
+ #[serde(rename = "VALOR_DIA_CORRIDO")]
+ ValueDayConductor,
+ #[serde(rename = "VALOR_DIA_UTIL")]
+ ValueWorthDay,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub struct DiscountObject {
+ pub value: f64,
+ pub limit_date: String, // YYYY-MM-DD
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum ProtestType {
+ #[serde(rename = "SEM_PROTESTO")]
+ WithoutProtest,
+
+ #[serde(rename = "DIAS_CORRIDOS")]
+ DaysConducted,
+
+ #[serde(rename = "DIAS_UTEIS")]
+ WorkingDays,
+
+ #[serde(rename = "CADASTRO_CONVENIO")]
+ RegistrationAgreement,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "UPPERCASE")]
+pub enum PaymentType {
+ #[serde(rename = "REGISTRO")]
+ Registration,
+
+ #[serde(rename = "DIVERGENTE")]
+ Divergent,
+
+ #[serde(rename = "PARCIAL")]
+ Partial,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct Sharing {
+ pub code: String,
+ pub value: f64,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct Key {
+ #[serde(rename = "type")]
+ pub key_type: Option<String>,
+ pub dict_key: Option<String>,
+}
+
#[derive(Debug, Serialize)]
#[serde(rename_all = "camelCase")]
-pub struct SantanderPaymentRequest {
+pub struct SantanderPixQRCodeRequest {
#[serde(rename = "calendario")]
pub calender: SantanderCalendar,
#[serde(rename = "devedor")]
@@ -320,19 +661,75 @@ pub enum SantanderVoidStatus {
RemovedByReceivingUser,
}
-impl From<SantanderPaymentStatus> for common_enums::AttemptStatus {
+impl From<SantanderPaymentStatus> for AttemptStatus {
fn from(item: SantanderPaymentStatus) -> Self {
match item {
SantanderPaymentStatus::Active => Self::Authorizing,
SantanderPaymentStatus::Completed => Self::Charged,
- SantanderPaymentStatus::RemovedByReceivingUser
- | SantanderPaymentStatus::RemovedByPSP => Self::Failure,
+ SantanderPaymentStatus::RemovedByReceivingUser => Self::Voided,
+ SantanderPaymentStatus::RemovedByPSP => Self::Failure,
}
}
}
-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
-pub struct SantanderPaymentsResponse {
+impl From<router_env::env::Env> for Environment {
+ fn from(item: router_env::env::Env) -> Self {
+ match item {
+ router_env::env::Env::Sandbox | router_env::env::Env::Development => Self::Sandbox,
+ router_env::env::Env::Production => Self::Production,
+ }
+ }
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub enum SantanderPaymentsResponse {
+ PixQRCode(Box<SantanderPixQRCodePaymentsResponse>),
+ Boleto(Box<SantanderBoletoPaymentsResponse>),
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct SantanderBoletoPaymentsResponse {
+ pub environment: Environment,
+ pub nsu_code: String,
+ pub nsu_date: String,
+ pub covenant_code: String,
+ pub bank_number: String,
+ pub client_number: Option<id_type::CustomerId>,
+ pub due_date: String,
+ pub issue_date: String,
+ pub participant_code: Option<String>,
+ pub nominal_value: StringMajorUnit,
+ pub payer: Payer,
+ pub beneficiary: Option<Beneficiary>,
+ pub document_kind: BoletoDocumentKind,
+ pub discount: Option<Discount>,
+ pub fine_percentage: Option<String>,
+ pub fine_quantity_days: Option<String>,
+ pub interest_percentage: Option<String>,
+ pub deduction_value: Option<FloatMajorUnit>,
+ pub protest_type: Option<ProtestType>,
+ pub protest_quantity_days: Option<i64>,
+ pub write_off_quantity_days: Option<String>,
+ pub payment_type: PaymentType,
+ pub parcels_quantity: Option<i64>,
+ pub value_type: Option<String>,
+ pub min_value_or_percentage: Option<f64>,
+ pub max_value_or_percentage: Option<f64>,
+ pub iof_percentage: Option<f64>,
+ pub sharing: Option<Sharing>,
+ pub key: Option<Key>,
+ pub tx_id: Option<String>,
+ pub messages: Option<Vec<String>>,
+ pub barcode: Option<String>,
+ pub digitable_line: Option<Secret<String>>,
+ pub entry_date: Option<String>,
+ pub qr_code_pix: Option<String>,
+ pub qr_code_url: Option<String>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct SantanderPixQRCodePaymentsResponse {
+ pub status: SantanderPaymentStatus,
#[serde(rename = "calendario")]
pub calendar: SantanderCalendar,
#[serde(rename = "txid")]
@@ -342,7 +739,6 @@ pub struct SantanderPaymentsResponse {
#[serde(rename = "devedor")]
pub debtor: Option<SantanderDebtor>,
pub location: Option<String>,
- pub status: SantanderPaymentStatus,
#[serde(rename = "valor")]
pub value: SantanderValue,
#[serde(rename = "chave")]
@@ -355,7 +751,7 @@ pub struct SantanderPaymentsResponse {
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
#[serde(rename_all = "camelCase")]
-pub struct SantanderVoidResponse {
+pub struct SantanderPixVoidResponse {
#[serde(rename = "calendario")]
pub calendar: SantanderCalendar,
#[serde(rename = "txid")]
@@ -384,27 +780,22 @@ pub struct SantanderCalendar {
pub expiration: i32,
}
-#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
-pub struct SantanderPaymentsSyncResponse {
- pub status: SantanderPaymentStatus,
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub enum SantanderPaymentsSyncResponse {
+ PixQRCode(Box<SantanderPixPSyncResponse>),
+ Boleto(Box<SantanderBoletoPSyncResponse>),
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct SantanderBoletoPSyncResponse {
+ pub link: Option<Url>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct SantanderPixPSyncResponse {
+ #[serde(flatten)]
+ pub base: SantanderPixQRCodePaymentsResponse,
pub pix: Vec<SantanderPix>,
- #[serde(rename = "calendario")]
- pub calendar: SantanderCalendar,
- #[serde(rename = "devedor")]
- pub debtor: Option<SantanderDebtor>,
- #[serde(rename = "valor")]
- pub value: SantanderValue,
- #[serde(rename = "chave")]
- pub key: Secret<String>,
- #[serde(rename = "solicitacaoPagador")]
- pub request_payer: Option<String>,
- #[serde(rename = "infoAdicionais")]
- pub additional_info: Option<Vec<SantanderAdditionalInfo>>,
- #[serde(rename = "txid")]
- pub transaction_id: String,
- #[serde(rename = "revisao")]
- pub revision: i32,
- pub location: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
@@ -435,25 +826,89 @@ impl<F, T> TryFrom<ResponseRouterData<F, SantanderPaymentsSyncResponse, T, Payme
item: ResponseRouterData<F, SantanderPaymentsSyncResponse, T, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
let response = item.response.clone();
- let connector_metadata = response.pix.first().map(|pix| {
- serde_json::json!({
- "end_to_end_id": pix.end_to_end_id.clone().expose()
- })
- });
- Ok(Self {
- status: common_enums::AttemptStatus::from(item.response.status),
- response: Ok(PaymentsResponseData::TransactionResponse {
- resource_id: ResponseId::ConnectorTransactionId(response.transaction_id.clone()),
- redirection_data: Box::new(None),
- mandate_reference: Box::new(None),
- connector_metadata,
- network_txn_id: None,
- connector_response_reference_id: None,
- incremental_authorization_allowed: None,
- charges: None,
- }),
- ..item.data
- })
+
+ match response {
+ SantanderPaymentsSyncResponse::PixQRCode(pix_data) => {
+ let attempt_status = AttemptStatus::from(pix_data.base.status.clone());
+ match attempt_status {
+ AttemptStatus::Failure => {
+ let response = Err(get_error_response(
+ Box::new(pix_data.base),
+ item.http_code,
+ attempt_status,
+ ));
+ Ok(Self {
+ response,
+ ..item.data
+ })
+ }
+ _ => {
+ let connector_metadata = pix_data.pix.first().map(|pix| {
+ serde_json::json!({
+ "end_to_end_id": pix.end_to_end_id.clone().expose()
+ })
+ });
+ Ok(Self {
+ status: AttemptStatus::from(pix_data.base.status),
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(
+ pix_data.base.transaction_id.clone(),
+ ),
+ redirection_data: Box::new(None),
+ mandate_reference: Box::new(None),
+ connector_metadata,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ })
+ }
+ }
+ }
+ SantanderPaymentsSyncResponse::Boleto(boleto_data) => {
+ let redirection_data = boleto_data.link.clone().map(|url| RedirectForm::Form {
+ endpoint: url.to_string(),
+ method: Method::Get,
+ form_fields: HashMap::new(),
+ });
+
+ Ok(Self {
+ status: AttemptStatus::AuthenticationPending,
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::NoResponseId,
+ redirection_data: Box::new(redirection_data),
+ mandate_reference: Box::new(None),
+ connector_metadata: None,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ })
+ }
+ }
+ }
+}
+
+pub fn get_error_response(
+ pix_data: Box<SantanderPixQRCodePaymentsResponse>,
+ status_code: u16,
+ attempt_status: AttemptStatus,
+) -> ErrorResponse {
+ ErrorResponse {
+ code: NO_ERROR_CODE.to_string(),
+ message: NO_ERROR_MESSAGE.to_string(),
+ reason: None,
+ status_code,
+ attempt_status: Some(attempt_status),
+ connector_transaction_id: Some(pix_data.transaction_id.clone()),
+ network_advice_code: None,
+ network_decline_code: None,
+ network_error_message: None,
+ connector_metadata: None,
}
}
@@ -465,33 +920,112 @@ impl<F, T> TryFrom<ResponseRouterData<F, SantanderPaymentsResponse, T, PaymentsR
item: ResponseRouterData<F, SantanderPaymentsResponse, T, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
let response = item.response.clone();
- Ok(Self {
- status: common_enums::AttemptStatus::from(item.response.status.clone()),
- response: Ok(PaymentsResponseData::TransactionResponse {
- resource_id: ResponseId::ConnectorTransactionId(response.transaction_id.clone()),
- redirection_data: Box::new(None),
- mandate_reference: Box::new(None),
- connector_metadata: get_qr_code_data(&item)?,
- network_txn_id: None,
- connector_response_reference_id: None,
- incremental_authorization_allowed: None,
- charges: None,
- }),
- ..item.data
- })
+
+ match response {
+ SantanderPaymentsResponse::PixQRCode(pix_data) => {
+ let attempt_status = AttemptStatus::from(pix_data.status.clone());
+ match attempt_status {
+ AttemptStatus::Failure => {
+ let response = Err(get_error_response(
+ Box::new(*pix_data),
+ item.http_code,
+ attempt_status,
+ ));
+ Ok(Self {
+ response,
+ ..item.data
+ })
+ }
+ _ => Ok(Self {
+ status: AttemptStatus::from(pix_data.status.clone()),
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id: ResponseId::ConnectorTransactionId(
+ pix_data.transaction_id.clone(),
+ ),
+ redirection_data: Box::new(None),
+ mandate_reference: Box::new(None),
+ connector_metadata: get_qr_code_data(&item, &pix_data)?,
+ network_txn_id: None,
+ connector_response_reference_id: None,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ }),
+ }
+ }
+ SantanderPaymentsResponse::Boleto(boleto_data) => {
+ let voucher_data = VoucherNextStepData {
+ expires_at: None,
+ digitable_line: boleto_data.digitable_line.clone(),
+ reference: boleto_data.barcode.ok_or(
+ errors::ConnectorError::MissingConnectorRedirectionPayload {
+ field_name: "barcode",
+ },
+ )?,
+ entry_date: boleto_data.entry_date,
+ download_url: None,
+ instructions_url: None,
+ };
+
+ let connector_metadata = Some(voucher_data.encode_to_value())
+ .transpose()
+ .change_context(errors::ConnectorError::ResponseHandlingFailed)?;
+
+ let resource_id = match boleto_data.tx_id {
+ Some(tx_id) => ResponseId::ConnectorTransactionId(tx_id),
+ None => ResponseId::NoResponseId,
+ };
+
+ let connector_response_reference_id = Some(
+ boleto_data
+ .digitable_line
+ .as_ref()
+ .map(|s| s.peek().to_owned())
+ .clone()
+ .or_else(|| {
+ boleto_data.beneficiary.as_ref().map(|beneficiary| {
+ format!(
+ "{}.{:?}",
+ boleto_data.bank_number,
+ beneficiary.document_number.clone()
+ )
+ })
+ })
+ .ok_or(errors::ConnectorError::MissingRequiredField {
+ field_name: "beneficiary.document_number",
+ })?,
+ );
+
+ Ok(Self {
+ status: AttemptStatus::AuthenticationPending,
+ response: Ok(PaymentsResponseData::TransactionResponse {
+ resource_id,
+ redirection_data: Box::new(None),
+ mandate_reference: Box::new(None),
+ connector_metadata,
+ network_txn_id: None,
+ connector_response_reference_id,
+ incremental_authorization_allowed: None,
+ charges: None,
+ }),
+ ..item.data
+ })
+ }
+ }
}
}
-impl<F, T> TryFrom<ResponseRouterData<F, SantanderVoidResponse, T, PaymentsResponseData>>
+impl<F, T> TryFrom<ResponseRouterData<F, SantanderPixVoidResponse, T, PaymentsResponseData>>
for RouterData<F, T, PaymentsResponseData>
{
type Error = error_stack::Report<errors::ConnectorError>;
fn try_from(
- item: ResponseRouterData<F, SantanderVoidResponse, T, PaymentsResponseData>,
+ item: ResponseRouterData<F, SantanderPixVoidResponse, T, PaymentsResponseData>,
) -> Result<Self, Self::Error> {
let response = item.response.clone();
Ok(Self {
- status: common_enums::AttemptStatus::from(item.response.status),
+ status: AttemptStatus::from(item.response.status),
response: Ok(PaymentsResponseData::TransactionResponse {
resource_id: ResponseId::ConnectorTransactionId(response.transaction_id.clone()),
redirection_data: Box::new(None),
@@ -518,11 +1052,12 @@ impl TryFrom<&PaymentsCancelRouterData> for SantanderPaymentsCancelRequest {
fn get_qr_code_data<F, T>(
item: &ResponseRouterData<F, SantanderPaymentsResponse, T, PaymentsResponseData>,
+ pix_data: &SantanderPixQRCodePaymentsResponse,
) -> CustomResult<Option<Value>, errors::ConnectorError> {
let santander_mca_metadata = SantanderMetadataObject::try_from(&item.data.connector_meta_data)?;
- let response = item.response.clone();
- let expiration_time = item.response.calendar.expiration;
+ let response = pix_data.clone();
+ let expiration_time = response.calendar.expiration;
let expiration_i64 = i64::from(expiration_time);
@@ -651,9 +1186,48 @@ impl<F> TryFrom<RefundsResponseRouterData<F, SantanderRefundResponse>> for Refun
}
}
+#[derive(Debug, Serialize, Deserialize)]
+pub enum SantanderErrorResponse {
+ PixQrCode(SantanderPixQRCodeErrorResponse),
+ Boleto(SantanderBoletoErrorResponse),
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct SantanderBoletoErrorResponse {
+ #[serde(rename = "_errorCode")]
+ pub error_code: i64,
+
+ #[serde(rename = "_message")]
+ pub error_message: String,
+
+ #[serde(rename = "_details")]
+ pub issuer_error_message: String,
+
+ #[serde(rename = "_timestamp")]
+ pub timestamp: String,
+
+ #[serde(rename = "_traceId")]
+ pub trace_id: String,
+
+ #[serde(rename = "_errors")]
+ pub errors: Option<Vec<ErrorObject>>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct ErrorObject {
+ #[serde(rename = "_code")]
+ pub code: Option<i64>,
+
+ #[serde(rename = "_field")]
+ pub field: Option<String>,
+
+ #[serde(rename = "_message")]
+ pub message: String,
+}
+
#[derive(Debug, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
-pub struct SantanderErrorResponse {
+pub struct SantanderPixQRCodeErrorResponse {
#[serde(rename = "type")]
pub field_type: Secret<String>,
pub title: String,
@@ -673,3 +1247,119 @@ pub struct SantanderViolations {
#[serde(rename = "valor")]
pub value: Option<String>,
}
+
+#[derive(Debug, Serialize, Deserialize)]
+#[serde(rename_all = "camelCase")]
+pub struct SantanderWebhookBody {
+ pub message: MessageCode, // meaning of this enum variant is not clear
+ pub function: FunctionType, // event type of the webhook
+ pub payment_type: WebhookPaymentType,
+ pub issue_date: String,
+ pub payment_date: String,
+ pub bank_code: String,
+ pub payment_channel: PaymentChannel,
+ pub payment_kind: PaymentKind,
+ pub covenant: String,
+ pub type_of_person_agreement: enums::DocumentKind,
+ pub agreement_document: String,
+ pub bank_number: String,
+ pub client_number: String,
+ pub participant_code: String,
+ pub tx_id: String,
+ pub payer_document_type: enums::DocumentKind,
+ pub payer_document_number: String,
+ pub payer_name: String,
+ pub final_beneficiary_document_type: enums::DocumentKind,
+ pub final_beneficiary_document_number: String,
+ pub final_beneficiary_name: String,
+ pub due_date: String,
+ pub nominal_value: StringMajorUnit,
+ pub payed_value: String,
+ pub interest_value: String,
+ pub fine: String,
+ pub deduction_value: String,
+ pub rebate_value: String,
+ pub iof_value: String,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum MessageCode {
+ Wbhkpagest,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum FunctionType {
+ Pagamento, // Payment
+ Estorno, // Refund
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+pub enum WebhookPaymentType {
+ Santander,
+ OutrosBancos,
+ Pix,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+/// Represents the channel through which a boleto payment was made.
+pub enum PaymentChannel {
+ /// Payment made at a bank branch or ATM (self-service).
+ AgenciasAutoAtendimento,
+
+ /// Payment made through online banking.
+ InternetBanking,
+
+ /// Payment made at a physical correspondent agent (e.g., convenience stores, partner outlets).
+ CorrespondenteBancarioFisico,
+
+ /// Payment made via Santander’s call center.
+ CentralDeAtendimento,
+
+ /// Payment made via electronic file, typically for bulk company payments.
+ ArquivoEletronico,
+
+ /// Payment made via DDA (Débito Direto Autorizado) / electronic bill presentment system.
+ Dda,
+
+ /// Payment made via digital correspondent channels (apps, kiosks, digital partners).
+ CorrespondenteBancarioDigital,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
+/// Represents the type of payment instrument used to pay a boleto.
+pub enum PaymentKind {
+ /// Payment made in cash or physical form (not via account or card).
+ Especie,
+
+ /// Payment made via direct debit from a bank account.
+ DebitoEmConta,
+
+ /// Payment made via credit card.
+ CartaoDeCredito,
+
+ /// Payment made via check.
+ Cheque,
+}
+
+pub(crate) fn get_webhook_object_from_body(
+ body: &[u8],
+) -> CustomResult<SantanderWebhookBody, common_utils::errors::ParsingError> {
+ let webhook: SantanderWebhookBody = body.parse_struct("SantanderIncomingWebhook")?;
+
+ Ok(webhook)
+}
+
+pub(crate) fn get_santander_webhook_event(
+ event_type: FunctionType,
+) -> api_models::webhooks::IncomingWebhookEvent {
+ // need to confirm about the other possible webhook event statues, as of now only two known
+ match event_type {
+ FunctionType::Pagamento => api_models::webhooks::IncomingWebhookEvent::PaymentIntentSuccess,
+ FunctionType::Estorno => api_models::webhooks::IncomingWebhookEvent::RefundSuccess,
+ }
+}
diff --git a/crates/hyperswitch_connectors/src/utils.rs b/crates/hyperswitch_connectors/src/utils.rs
index d34cb48080..9887809c26 100644
--- a/crates/hyperswitch_connectors/src/utils.rs
+++ b/crates/hyperswitch_connectors/src/utils.rs
@@ -1588,6 +1588,9 @@ impl AddressDetailsData for AddressDetails {
UnitedKingdomStatesAbbreviation::foreign_try_from(state.peek().to_string())?
.to_string(),
)),
+ api_models::enums::CountryAlpha2::BR => Ok(Secret::new(
+ BrazilStatesAbbreviation::foreign_try_from(state.peek().to_string())?.to_string(),
+ )),
_ => Ok(state.clone()),
}
}
diff --git a/crates/hyperswitch_domain_models/src/payment_method_data.rs b/crates/hyperswitch_domain_models/src/payment_method_data.rs
index ee48226f4e..43af1bfa85 100644
--- a/crates/hyperswitch_domain_models/src/payment_method_data.rs
+++ b/crates/hyperswitch_domain_models/src/payment_method_data.rs
@@ -662,6 +662,22 @@ pub enum VoucherData {
pub struct BoletoVoucherData {
/// The shopper's social security number
pub social_security_number: Option<Secret<String>>,
+ /// The bank number associated with the boleto
+ pub bank_number: Option<Secret<String>>,
+ /// The type of document (e.g., CPF, CNPJ)
+ pub document_type: Option<common_enums::DocumentKind>,
+ /// The percentage of fine applied for late payment
+ pub fine_percentage: Option<String>,
+ /// The number of days after due date when fine is applied
+ pub fine_quantity_days: Option<String>,
+ /// The percentage of interest applied for late payment
+ pub interest_percentage: Option<String>,
+ /// Number of days after which the boleto can be written off
+ pub write_off_quantity_days: Option<String>,
+ /// Additional messages to display to the shopper
+ pub messages: Option<Vec<String>>,
+ /// The date upon which the boleto is due and is of format: "YYYY-MM-DD"
+ pub due_date: Option<String>,
}
#[derive(Debug, Clone, Eq, PartialEq, serde::Serialize, serde::Deserialize)]
@@ -1483,6 +1499,14 @@ impl From<api_models::payments::VoucherData> for VoucherData {
api_models::payments::VoucherData::Boleto(boleto_data) => {
Self::Boleto(Box::new(BoletoVoucherData {
social_security_number: boleto_data.social_security_number,
+ bank_number: boleto_data.bank_number,
+ document_type: boleto_data.document_type,
+ fine_percentage: boleto_data.fine_percentage,
+ fine_quantity_days: boleto_data.fine_quantity_days,
+ interest_percentage: boleto_data.interest_percentage,
+ write_off_quantity_days: boleto_data.write_off_quantity_days,
+ messages: boleto_data.messages,
+ due_date: boleto_data.due_date,
}))
}
api_models::payments::VoucherData::Alfamart(_) => {
@@ -1512,6 +1536,14 @@ impl From<Box<BoletoVoucherData>> for Box<api_models::payments::BoletoVoucherDat
fn from(value: Box<BoletoVoucherData>) -> Self {
Self::new(api_models::payments::BoletoVoucherData {
social_security_number: value.social_security_number,
+ bank_number: value.bank_number,
+ document_type: value.document_type,
+ fine_percentage: value.fine_percentage,
+ fine_quantity_days: value.fine_quantity_days,
+ interest_percentage: value.interest_percentage,
+ write_off_quantity_days: value.write_off_quantity_days,
+ messages: value.messages,
+ due_date: value.due_date,
})
}
}
diff --git a/crates/openapi/src/openapi.rs b/crates/openapi/src/openapi.rs
index 58809e0263..0adc53a841 100644
--- a/crates/openapi/src/openapi.rs
+++ b/crates/openapi/src/openapi.rs
@@ -334,6 +334,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::enums::PayoutConnectors,
api_models::enums::AuthenticationConnectors,
api_models::enums::Currency,
+ api_models::enums::DocumentKind,
api_models::enums::IntentStatus,
api_models::enums::CaptureMethod,
api_models::enums::FutureUsage,
diff --git a/crates/openapi/src/openapi_v2.rs b/crates/openapi/src/openapi_v2.rs
index e5d36a3a2a..c0b042b182 100644
--- a/crates/openapi/src/openapi_v2.rs
+++ b/crates/openapi/src/openapi_v2.rs
@@ -286,6 +286,7 @@ Never share your secret api keys. Keep them guarded and secure.
api_models::enums::AuthenticationConnectors,
api_models::enums::VaultSdk,
api_models::enums::Currency,
+ api_models::enums::DocumentKind,
api_models::enums::IntentStatus,
api_models::enums::CaptureMethod,
api_models::enums::FutureUsage,
diff --git a/loadtest/config/development.toml b/loadtest/config/development.toml
index b545322c4d..b763c43bcc 100644
--- a/loadtest/config/development.toml
+++ b/loadtest/config/development.toml
@@ -184,6 +184,7 @@ recurly.base_url = "https://v3.recurly.com"
redsys.base_url = "https://sis-t.redsys.es:25443"
riskified.base_url = "https://sandbox.riskified.com/api"
santander.base_url = "https://pix.santander.com.br/api/v1/sandbox/"
+santander.secondary_base_url = "https://trust-sandbox.api.santander.com.br/collection_bill_management/"
shift4.base_url = "https://api.shift4.com/"
sift.base_url = "https://api.sift.com/v205"
silverflow.base_url = "https://api-sbx.silverflow.co/v1"