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

refactor(connector): [Itaubank] add dynamic fields for pix (#5419)

Sakil Mostakafae5906a8d6
diff --git a/api-reference/openapi_spec.json b/api-reference/openapi_spec.json
index e55485e945..03dbf539c3 100644
--- a/api-reference/openapi_spec.json
+++ b/api-reference/openapi_spec.json
@@ -9847,6 +9847,24 @@
}
}
}
+ },
+ {
+ "type": "string",
+ "enum": [
+ "user_pix_key"
+ ]
+ },
+ {
+ "type": "string",
+ "enum": [
+ "user_cpf"
+ ]
+ },
+ {
+ "type": "string",
+ "enum": [
+ "user_cnpj"
+ ]
}
],
"description": "Possible field type of required fields in payment_method_data"
diff --git a/crates/api_models/src/enums.rs b/crates/api_models/src/enums.rs
index 79cb60da2d..85212ec7d0 100644
--- a/crates/api_models/src/enums.rs
+++ b/crates/api_models/src/enums.rs
@@ -476,6 +476,9 @@ pub enum FieldType {
UserDateOfBirth,
UserVpaId,
LanguagePreference { options: Vec<String> },
+ UserPixKey,
+ UserCpf,
+ UserCnpj,
}
impl FieldType {
@@ -562,6 +565,9 @@ impl PartialEq for FieldType {
) => options_self.eq(options_other),
(Self::UserDateOfBirth, Self::UserDateOfBirth) => true,
(Self::UserVpaId, Self::UserVpaId) => true,
+ (Self::UserPixKey, Self::UserPixKey) => true,
+ (Self::UserCpf, Self::UserCpf) => true,
+ (Self::UserCnpj, Self::UserCnpj) => true,
(Self::LanguagePreference { .. }, Self::LanguagePreference { .. }) => true,
_unused => false,
}
diff --git a/crates/router/src/configs/defaults.rs b/crates/router/src/configs/defaults.rs
index 6121d8e503..ffa3d81ede 100644
--- a/crates/router/src/configs/defaults.rs
+++ b/crates/router/src/configs/defaults.rs
@@ -8871,7 +8871,49 @@ impl Default for super::settings::RequiredFields {
}
),
])}),
- ])))
+ (enums::PaymentMethodType::Pix,
+ ConnectorFields {
+ fields: HashMap::from([
+ (
+ enums::Connector::Itaubank,
+ RequiredFieldFinal {
+ mandate: HashMap::new(),
+ non_mandate: HashMap::new(),
+ common: HashMap::from(
+ [
+ (
+ "payment_method_data.bank_transfer.pix.pix_key".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.bank_transfer.pix.pix_key".to_string(),
+ display_name: "pix_key".to_string(),
+ field_type: enums::FieldType::UserPixKey,
+ value: None,
+ }
+ ),
+ (
+ "payment_method_data.bank_transfer.pix.cnpj".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.bank_transfer.pix.cnpj".to_string(),
+ display_name: "cnpj".to_string(),
+ field_type: enums::FieldType::UserCnpj,
+ value: None,
+ }
+ ),
+ (
+ "payment_method_data.bank_transfer.pix.cpf".to_string(),
+ RequiredFieldInfo {
+ required_field: "payment_method_data.bank_transfer.pix.cpf".to_string(),
+ display_name: "cpf".to_string(),
+ field_type: enums::FieldType::UserCpf,
+ value: None,
+ }
+ ),
+ ]
+ ),
+ }
+ ),
+ ])}),
+ ])))
]))
}
}