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(payout): collect ispb in pix bank transfer payout (#12268)

Sakil Mostakf538f9fcca8c
diff --git a/api-reference/v1/openapi_spec_v1.json b/api-reference/v1/openapi_spec_v1.json
index 5278378058..dc93705151 100644
--- a/api-reference/v1/openapi_spec_v1.json
+++ b/api-reference/v1/openapi_spec_v1.json
@@ -36581,6 +36581,12 @@
"description": "Individual taxpayer identification number",
"example": "000123456",
"nullable": true
+ },
+ "ispb": {
+ "type": "string",
+ "description": "ispb code is a unique identifier assigned by Brazilian Central Bank to identify the financial institution of the recipient's bank account in Pix transactions.",
+ "example": "60701190",
+ "nullable": true
}
}
},
@@ -36820,6 +36826,12 @@
"type": "string",
"description": "String formatted QR code for pix payout",
"example": "00020126580014br.gov.bcb.pix0114000123456785204000053039865802BR5925John Doe6009Sao Paulo61080540900062070503***63041D3D"
+ },
+ "ispb": {
+ "type": "string",
+ "description": "ispb code is a unique identifier assigned by Brazilian Central Bank to identify the financial institution of the recipient's bank account in Pix transactions.",
+ "example": "60701190",
+ "nullable": true
}
}
},
diff --git a/api-reference/v2/openapi_spec_v2.json b/api-reference/v2/openapi_spec_v2.json
index 232d6fe7b7..cb8fbc7c84 100644
--- a/api-reference/v2/openapi_spec_v2.json
+++ b/api-reference/v2/openapi_spec_v2.json
@@ -26570,6 +26570,12 @@
"description": "Individual taxpayer identification number",
"example": "000123456",
"nullable": true
+ },
+ "ispb": {
+ "type": "string",
+ "description": "ispb code is a unique identifier assigned by Brazilian Central Bank to identify the financial institution of the recipient's bank account in Pix transactions.",
+ "example": "60701190",
+ "nullable": true
}
}
},
@@ -26809,6 +26815,12 @@
"type": "string",
"description": "String formatted QR code for pix payout",
"example": "00020126580014br.gov.bcb.pix0114000123456785204000053039865802BR5925John Doe6009Sao Paulo61080540900062070503***63041D3D"
+ },
+ "ispb": {
+ "type": "string",
+ "description": "ispb code is a unique identifier assigned by Brazilian Central Bank to identify the financial institution of the recipient's bank account in Pix transactions.",
+ "example": "60701190",
+ "nullable": true
}
}
},
diff --git a/crates/api_models/src/payouts.rs b/crates/api_models/src/payouts.rs
index 3f6e0a665f..06cdacd92b 100644
--- a/crates/api_models/src/payouts.rs
+++ b/crates/api_models/src/payouts.rs
@@ -285,6 +285,7 @@ impl TryFrom<Bank> for BankTransfer {
bank_branch: pix.bank_branch,
bank_account_number,
tax_id: pix.tax_id,
+ ispb: pix.ispb,
})),
// If pix key is present then it's PixKeyBankTransfer
(None, Some(pix_key), None) => Ok(Self::PixKey(PixKeyBankTransfer {
@@ -324,6 +325,7 @@ impl From<BankTransfer> for Bank {
pix_key: None,
tax_id: pix.tax_id,
emv: None,
+ ispb: pix.ispb,
}),
BankTransfer::Trustly(trustly) => Self::Trustly(TrustlyBankTransfer {
iban: trustly.iban,
@@ -338,6 +340,7 @@ impl From<BankTransfer> for Bank {
pix_key: None,
tax_id: None,
emv: Some(pix_emv.emv),
+ ispb: None,
}),
BankTransfer::PixKey(pix_key) => Self::Pix(PixBankTransfer {
bank_name: None,
@@ -346,6 +349,7 @@ impl From<BankTransfer> for Bank {
pix_key: Some(pix_key.pix_key),
tax_id: None,
emv: None,
+ ispb: None,
}),
BankTransfer::OpenBanking(open_banking) => Self::OpenBanking(open_banking),
}
@@ -507,6 +511,10 @@ pub struct PixBankTransfer {
/// String formatted QR code for pix payout
#[schema(value_type = String, example = "00020126580014br.gov.bcb.pix0114000123456785204000053039865802BR5925John Doe6009Sao Paulo61080540900062070503***63041D3D")]
pub emv: Option<Secret<String>>,
+
+ /// ispb code is a unique identifier assigned by Brazilian Central Bank to identify the financial institution of the recipient's bank account in Pix transactions.
+ #[schema(value_type = Option<String>, example = "60701190")]
+ pub ispb: Option<String>,
}
#[derive(Default, Eq, PartialEq, Clone, Debug, Deserialize, Serialize, ToSchema)]
@@ -526,6 +534,10 @@ pub struct PixAccountBankTransfer {
/// Individual taxpayer identification number
#[schema(value_type = Option<String>, example = "000123456")]
pub tax_id: Option<Secret<String>>,
+
+ /// ispb code is a unique identifier assigned by Brazilian Central Bank to identify the financial institution of the recipient's bank account in Pix transactions.
+ #[schema(value_type = Option<String>, example = "60701190")]
+ pub ispb: Option<String>,
}
#[derive(Default, Eq, PartialEq, Clone, Debug, Deserialize, Serialize, ToSchema)]
@@ -1275,6 +1287,7 @@ impl From<Bank> for payout_method_utils::BankAdditionalData {
pix_key,
tax_id,
emv,
+ ispb,
}) => Self::Pix(Box::new(
payout_method_utils::PixBankTransferAdditionalData {
bank_name,
@@ -1283,6 +1296,7 @@ impl From<Bank> for payout_method_utils::BankAdditionalData {
pix_key: pix_key.map(From::from),
tax_id: tax_id.map(From::from),
emv: emv.map(From::from),
+ ispb,
},
)),
Bank::Trustly(TrustlyBankTransfer {
@@ -1368,6 +1382,7 @@ impl From<BankTransfer> for payout_method_utils::BankAdditionalData {
bank_branch,
bank_account_number,
tax_id,
+ ispb,
}) => Self::Pix(Box::new(
payout_method_utils::PixBankTransferAdditionalData {
bank_name,
@@ -1376,6 +1391,7 @@ impl From<BankTransfer> for payout_method_utils::BankAdditionalData {
pix_key: None,
emv: None,
tax_id: tax_id.map(From::from),
+ ispb,
},
)),
BankTransfer::PixKey(PixKeyBankTransfer { pix_key }) => Self::Pix(Box::new(
@@ -1386,6 +1402,7 @@ impl From<BankTransfer> for payout_method_utils::BankAdditionalData {
pix_key: Some(pix_key.into()),
emv: None,
tax_id: None,
+ ispb: None,
},
)),
BankTransfer::PixEmv(PixEmvBankTransfer { emv }) => Self::Pix(Box::new(
@@ -1396,6 +1413,7 @@ impl From<BankTransfer> for payout_method_utils::BankAdditionalData {
pix_key: None,
emv: Some(emv.into()),
tax_id: None,
+ ispb: None,
},
)),
diff --git a/crates/common_utils/src/payout_method_utils.rs b/crates/common_utils/src/payout_method_utils.rs
index e23308757f..730c48bbd2 100644
--- a/crates/common_utils/src/payout_method_utils.rs
+++ b/crates/common_utils/src/payout_method_utils.rs
@@ -219,6 +219,10 @@ pub struct PixBankTransferAdditionalData {
/// Bank branch
#[schema(value_type = Option<String>, example = "3707")]
pub bank_branch: Option<String>,
+
+ /// ISPB code is a unique identifier assigned by Brazilian Central Bank to identify the financial institution of the recipient's bank account in Pix transactions.
+ #[schema(value_type = Option<String>, example = "60701190")]
+ pub ispb: Option<String>,
}
/// Masked payout method details for Trustly bank transfer payout method
diff --git a/crates/router/src/core/payment_methods/vault.rs b/crates/router/src/core/payment_methods/vault.rs
index 9d02ccfeab..379fe4b718 100644
--- a/crates/router/src/core/payment_methods/vault.rs
+++ b/crates/router/src/core/payment_methods/vault.rs
@@ -709,6 +709,7 @@ pub struct TokenizedBankInsensitiveValues {
pub bank_country_code: Option<api::enums::CountryAlpha2>,
pub bank_city: Option<String>,
pub bank_branch: Option<String>,
+ pub ispb: Option<String>,
pub payout_method_type: Option<PaymentMethodType>,
}
@@ -810,6 +811,7 @@ impl Vaultable for api::BankPayout {
bank_country_code: b.bank_country_code.to_owned(),
bank_city: b.bank_city.to_owned(),
bank_branch: None,
+ ispb: None,
payout_method_type: Some(PaymentMethodType::Ach),
},
Self::Bacs(b) => TokenizedBankInsensitiveValues {
@@ -818,6 +820,7 @@ impl Vaultable for api::BankPayout {
bank_country_code: b.bank_country_code.to_owned(),
bank_city: b.bank_city.to_owned(),
bank_branch: None,
+ ispb: None,
payout_method_type: Some(PaymentMethodType::Bacs),
},
Self::Sepa(bank_details) => TokenizedBankInsensitiveValues {
@@ -826,6 +829,7 @@ impl Vaultable for api::BankPayout {
bank_country_code: bank_details.bank_country_code.to_owned(),
bank_city: bank_details.bank_city.to_owned(),
bank_branch: None,
+ ispb: None,
payout_method_type: Some(PaymentMethodType::Sepa),
},
Self::Pix(bank_details) => TokenizedBankInsensitiveValues {
@@ -834,6 +838,7 @@ impl Vaultable for api::BankPayout {
bank_country_code: None,
bank_city: None,
bank_branch: bank_details.bank_branch.to_owned(),
+ ispb: bank_details.ispb.to_owned(),
payout_method_type: Some(PaymentMethodType::Pix),
},
Self::Trustly(bank_details) => TokenizedBankInsensitiveValues {
@@ -842,6 +847,7 @@ impl Vaultable for api::BankPayout {
bank_city: None,
bank_branch: None,
bank_country_code: Some(bank_details.country_code.to_owned()),
+ ispb: None,
payout_method_type: Some(PaymentMethodType::Trustly),
},
Self::OpenBanking(_) => TokenizedBankInsensitiveValues {
@@ -850,6 +856,7 @@ impl Vaultable for api::BankPayout {
bank_city: None,
bank_branch: None,
bank_country_code: None,
+ ispb: None,
payout_method_type: Some(PaymentMethodType::OpenBanking),
},
};
@@ -943,6 +950,7 @@ impl Vaultable for api::BankPayout {
pix_key: Some(pix_key),
tax_id,
emv: bank_sensitive_data.emv,
+ ispb: bank_insensitive_data.ispb,
})
}
_ => Err(errors::VaultError::ResponseDeserializationFailed)?,
@@ -1079,6 +1087,7 @@ impl Vaultable for api::BankTransferPayout {
bank_country_code: b.bank_country_code.to_owned(),
bank_city: b.bank_city.to_owned(),
bank_branch: None,
+ ispb: None,
payout_method_type: Some(PaymentMethodType::Ach),
},
Self::Bacs(b) => TokenizedBankInsensitiveValues {
@@ -1087,6 +1096,7 @@ impl Vaultable for api::BankTransferPayout {
bank_country_code: b.bank_country_code.to_owned(),
bank_city: b.bank_city.to_owned(),
bank_branch: None,
+ ispb: None,
payout_method_type: Some(PaymentMethodType::Bacs),
},
Self::Sepa(bank_details) => TokenizedBankInsensitiveValues {
@@ -1095,6 +1105,7 @@ impl Vaultable for api::BankTransferPayout {
bank_country_code: bank_details.bank_country_code.to_owned(),
bank_city: bank_details.bank_city.to_owned(),
bank_branch: None,
+ ispb: None,
payout_method_type: Some(PaymentMethodType::Sepa),
},
Self::Pix(bank_details) => TokenizedBankInsensitiveValues {
@@ -1103,6 +1114,7 @@ impl Vaultable for api::BankTransferPayout {
bank_country_code: None,
bank_city: None,
bank_branch: bank_details.bank_branch.to_owned(),
+ ispb: bank_details.ispb.to_owned(),
payout_method_type: Some(PaymentMethodType::Pix),
},
Self::PixKey(_) => TokenizedBankInsensitiveValues {
@@ -1111,6 +1123,7 @@ impl Vaultable for api::BankTransferPayout {
bank_country_code: None,
bank_city: None,
bank_branch: None,
+ ispb: None,
payout_method_type: Some(PaymentMethodType::PixKey),
},
Self::PixEmv(_) => TokenizedBankInsensitiveValues {
@@ -1119,6 +1132,7 @@ impl Vaultable for api::BankTransferPayout {
bank_country_code: None,
bank_city: None,
bank_branch: None,
+ ispb: None,
payout_method_type: Some(PaymentMethodType::PixEmv),
},
Self::Trustly(bank_details) => TokenizedBankInsensitiveValues {
@@ -1127,6 +1141,7 @@ impl Vaultable for api::BankTransferPayout {
bank_city: None,
bank_branch: None,
bank_country_code: Some(bank_details.bank_country_code.to_owned()),
+ ispb: None,
payout_method_type: Some(PaymentMethodType::Trustly),
},
Self::OpenBanking(_) => TokenizedBankInsensitiveValues {
@@ -1135,6 +1150,7 @@ impl Vaultable for api::BankTransferPayout {
bank_city: None,
bank_branch: None,
bank_country_code: None,
+ ispb: None,
payout_method_type: Some(PaymentMethodType::OpenBanking),
},
};
@@ -1221,6 +1237,7 @@ impl Vaultable for api::BankTransferPayout {
bank_branch: bank_insensitive_data.bank_branch,
bank_name: bank_insensitive_data.bank_name,
tax_id: bank_sensitive_data.tax_id,
+ ispb: bank_insensitive_data.ispb,
}),
Some(PaymentMethodType::PixKey) => Self::PixKey(payouts::PixKeyBankTransfer {
pix_key: bank_sensitive_data.pix_key.ok_or(
diff --git a/crates/router/src/core/unified_connector_service/transformers.rs b/crates/router/src/core/unified_connector_service/transformers.rs
index e71cdbb8c7..15fb45752d 100644
--- a/crates/router/src/core/unified_connector_service/transformers.rs
+++ b/crates/router/src/core/unified_connector_service/transformers.rs
@@ -7012,7 +7012,7 @@ impl transformers::ForeignTryFrom<&api_models::payouts::PixBankTransfer>
bank_branch: item.bank_branch.clone(),
bank_account_number: item.bank_account_number.clone(),
tax_id: item.tax_id.clone(),
- ispb: None,
+ ispb: item.ispb.clone().map(Secret::new),
})
}
}
@@ -7031,7 +7031,7 @@ impl transformers::ForeignTryFrom<&api_models::payouts::PixAccountBankTransfer>
bank_branch: item.bank_branch.clone(),
bank_account_number: Some(item.bank_account_number.clone()),
tax_id: item.tax_id.clone(),
- ispb: None,
+ ispb: item.ispb.clone().map(Secret::new),
})
}
}