Skip to content

Commit

Permalink
feat(connector): [Itau Bank] Add payment and sync flow for Pix (#5405)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sakilmostak authored Jul 22, 2024
1 parent 1ac1775 commit 25b8c37
Show file tree
Hide file tree
Showing 41 changed files with 768 additions and 144 deletions.
26 changes: 25 additions & 1 deletion api-reference/openapi_spec.json
Original file line number Diff line number Diff line change
Expand Up @@ -6518,7 +6518,29 @@
],
"properties": {
"pix": {
"type": "object"
"type": "object",
"properties": {
"pix_key": {
"type": "string",
"description": "Unique key for pix transfer",
"example": "a1f4102e-a446-4a57-bcce-6fa48899c1d1",
"nullable": true
},
"cpf": {
"type": "integer",
"format": "int64",
"description": "CPF is a Brazilian tax identification number",
"example": "10599054689",
"nullable": true
},
"cnpj": {
"type": "integer",
"format": "int64",
"description": "CNPJ is a Brazilian company tax identification number",
"example": "74469027417312",
"nullable": true
}
}
}
}
},
Expand Down Expand Up @@ -7783,6 +7805,7 @@
"gpayments",
"helcim",
"iatapay",
"itaubank",
"klarna",
"mifinity",
"mollie",
Expand Down Expand Up @@ -19702,6 +19725,7 @@
"gocardless",
"helcim",
"iatapay",
"itaubank",
"klarna",
"mifinity",
"mollie",
Expand Down
2 changes: 1 addition & 1 deletion config/config.example.toml
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ gocardless.base_url = "https://api-sandbox.gocardless.com"
gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayments.net"
helcim.base_url = "https://api.helcim.com/"
iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"
itaubank.base_url = "https://sandbox.devportal.itau.com.br/itau-ep9-gtw-pix-recebimentos-ext-v2/v2"
itaubank.base_url = "https://sandbox.devportal.itau.com.br/"
klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"
mifinity.base_url = "https://demo.mifinity.com/"
mollie.base_url = "https://api.mollie.com/v2/"
Expand Down
2 changes: 1 addition & 1 deletion config/deployments/integration_test.toml
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ gocardless.base_url = "https://api-sandbox.gocardless.com"
gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayments.net"
helcim.base_url = "https://api.helcim.com/"
iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"
itaubank.base_url = "https://sandbox.devportal.itau.com.br/itau-ep9-gtw-pix-recebimentos-ext-v2/v2"
itaubank.base_url = "https://sandbox.devportal.itau.com.br/"
klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"
mifinity.base_url = "https://demo.mifinity.com/"
mollie.base_url = "https://api.mollie.com/v2/"
Expand Down
2 changes: 1 addition & 1 deletion config/deployments/production.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ gocardless.base_url = "https://api.gocardless.com"
gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayments.net"
helcim.base_url = "https://api.helcim.com/"
iatapay.base_url = "https://iata-pay.iata.org/api/v1"
itaubank.base_url = "https://sandbox.devportal.itau.com.br/itau-ep9-gtw-pix-recebimentos-ext-v2/v2"
itaubank.base_url = "https://secure.api.itau/"
klarna.base_url = "https://api{{klarna_region}}.klarna.com/"
mifinity.base_url = "https://secure.mifinity.com/"
mollie.base_url = "https://api.mollie.com/v2/"
Expand Down
2 changes: 1 addition & 1 deletion config/deployments/sandbox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ gocardless.base_url = "https://api-sandbox.gocardless.com"
gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayments.net"
helcim.base_url = "https://api.helcim.com/"
iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"
itaubank.base_url = "https://sandbox.devportal.itau.com.br/itau-ep9-gtw-pix-recebimentos-ext-v2/v2"
itaubank.base_url = "https://sandbox.devportal.itau.com.br/"
klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"
mifinity.base_url = "https://demo.mifinity.com/"
mollie.base_url = "https://api.mollie.com/v2/"
Expand Down
2 changes: 1 addition & 1 deletion config/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ gocardless.base_url = "https://api-sandbox.gocardless.com"
gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayments.net"
helcim.base_url = "https://api.helcim.com/"
iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"
itaubank.base_url = "https://sandbox.devportal.itau.com.br/itau-ep9-gtw-pix-recebimentos-ext-v2/v2"
itaubank.base_url = "https://sandbox.devportal.itau.com.br/"
klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"
mifinity.base_url = "https://demo.mifinity.com/"
mollie.base_url = "https://api.mollie.com/v2/"
Expand Down
2 changes: 1 addition & 1 deletion config/docker_compose.toml
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ gocardless.base_url = "https://api-sandbox.gocardless.com"
gpayments.base_url = "https://{{merchant_endpoint_prefix}}-test.api.as1.gpayments.net"
helcim.base_url = "https://api.helcim.com/"
iatapay.base_url = "https://sandbox.iata-pay.iata.org/api/v1"
itaubank.base_url = "https://sandbox.devportal.itau.com.br/itau-ep9-gtw-pix-recebimentos-ext-v2/v2"
itaubank.base_url = "https://sandbox.devportal.itau.com.br/"
klarna.base_url = "https://api{{klarna_region}}.playground.klarna.com/"
mifinity.base_url = "https://demo.mifinity.com/"
mollie.base_url = "https://api.mollie.com/v2/"
Expand Down
4 changes: 3 additions & 1 deletion crates/api_models/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ pub enum Connector {
Gpayments,
Helcim,
Iatapay,
// Itaubank, template code for future usage
Itaubank,
Klarna,
Mifinity,
Mollie,
Expand Down Expand Up @@ -182,6 +182,7 @@ impl Connector {
| (Self::Trustpay, PaymentMethod::BankRedirect)
| (Self::Iatapay, _)
| (Self::Volt, _)
| (Self::Itaubank, _)
)
}
pub fn supports_file_storage_module(&self) -> bool {
Expand Down Expand Up @@ -227,6 +228,7 @@ impl Connector {
| Self::Gpayments
| Self::Helcim
| Self::Iatapay
| Self::Itaubank
| Self::Klarna
| Self::Mifinity
| Self::Mollie
Expand Down
16 changes: 13 additions & 3 deletions crates/api_models/src/payments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1858,7 +1858,7 @@ impl GetPaymentMethodType for BankTransferData {
Self::CimbVaBankTransfer { .. } => api_enums::PaymentMethodType::CimbVa,
Self::DanamonVaBankTransfer { .. } => api_enums::PaymentMethodType::DanamonVa,
Self::MandiriVaBankTransfer { .. } => api_enums::PaymentMethodType::MandiriVa,
Self::Pix {} => api_enums::PaymentMethodType::Pix,
Self::Pix { .. } => api_enums::PaymentMethodType::Pix,
Self::Pse {} => api_enums::PaymentMethodType::Pse,
Self::LocalBankTransfer { .. } => api_enums::PaymentMethodType::LocalBankTransfer,
}
Expand Down Expand Up @@ -2460,7 +2460,17 @@ pub enum BankTransferData {
/// The billing details for BniVa Bank Transfer
billing_details: Option<DokuBillingDetails>,
},
Pix {},
Pix {
/// Unique key for pix transfer
#[schema(value_type = Option<String>, example = "a1f4102e-a446-4a57-bcce-6fa48899c1d1")]
pix_key: Option<Secret<String>>,
/// CPF is a Brazilian tax identification number
#[schema(value_type = Option<i64>, example = "10599054689")]
cpf: Option<Secret<i64>>,
/// CNPJ is a Brazilian company tax identification number
#[schema(value_type = Option<i64>, example = "74469027417312")]
cnpj: Option<Secret<i64>>,
},
Pse {},
LocalBankTransfer {
bank_code: Option<String>,
Expand Down Expand Up @@ -2532,7 +2542,7 @@ impl GetAddressFromPaymentMethodData for BankTransferData {
email: details.email.clone(),
})
}
Self::LocalBankTransfer { .. } | Self::Pix {} | Self::Pse {} => None,
Self::LocalBankTransfer { .. } | Self::Pix { .. } | Self::Pse {} => None,
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/common_enums/src/enums.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ pub enum RoutableConnectors {
Gocardless,
Helcim,
Iatapay,
// Itaubank, template code for future usage
Itaubank,
Klarna,
Mifinity,
Mollie,
Expand Down
2 changes: 2 additions & 0 deletions crates/connector_configs/src/connector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ pub struct ConnectorConfig {
#[cfg(feature = "payouts")]
pub cybersource_payout: Option<ConnectorTomlConfig>,
pub iatapay: Option<ConnectorTomlConfig>,
pub itaubank: Option<ConnectorTomlConfig>,
pub opennode: Option<ConnectorTomlConfig>,
pub bambora: Option<ConnectorTomlConfig>,
pub datatrans: Option<ConnectorTomlConfig>,
Expand Down Expand Up @@ -288,6 +289,7 @@ impl ConnectorConfig {
Connector::Cryptopay => Ok(connector_data.cryptopay),
Connector::Cybersource => Ok(connector_data.cybersource),
Connector::Iatapay => Ok(connector_data.iatapay),
Connector::Itaubank => Ok(connector_data.itaubank),
Connector::Opennode => Ok(connector_data.opennode),
Connector::Bambora => Ok(connector_data.bambora),
Connector::Datatrans => Ok(connector_data.datatrans),
Expand Down
7 changes: 7 additions & 0 deletions crates/connector_configs/toml/development.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,13 @@ api_secret="Client Secret"
[iatapay.connector_webhook_details]
merchant_secret="Source verification key"

[itaubank]
[[itaubank.bank_transfer]]
payment_method_type = "pix"
[itaubank.connector_auth.BodyKey]
key1="Client Id"
api_key="Client Secret"

[klarna]
[[klarna.pay_later]]
payment_method_type = "klarna"
Expand Down
7 changes: 7 additions & 0 deletions crates/connector_configs/toml/production.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1348,6 +1348,13 @@ api_secret="Client Secret"
[iatapay.connector_webhook_details]
merchant_secret="Source verification key"

[itaubank]
[[itaubank.bank_transfer]]
payment_method_type = "pix"
[itaubank.connector_auth.BodyKey]
key1="Client Id"
api_key="Client Secret"

[klarna]
[[klarna.pay_later]]
payment_method_type = "klarna"
Expand Down
7 changes: 7 additions & 0 deletions crates/connector_configs/toml/sandbox.toml
Original file line number Diff line number Diff line change
Expand Up @@ -1609,6 +1609,13 @@ api_secret="Client Secret"
[iatapay.connector_webhook_details]
merchant_secret="Source verification key"

[itaubank]
[[itaubank.bank_transfer]]
payment_method_type = "pix"
[itaubank.connector_auth.BodyKey]
key1="Client Id"
api_key="Client Secret"

[klarna]
[[klarna.pay_later]]
payment_method_type = "klarna"
Expand Down
17 changes: 14 additions & 3 deletions crates/hyperswitch_domain_models/src/payment_method_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -446,9 +446,18 @@ pub enum BankTransferData {
CimbVaBankTransfer {},
DanamonVaBankTransfer {},
MandiriVaBankTransfer {},
Pix {},
Pix {
/// Unique key for pix transfer
pix_key: Option<Secret<String>>,
/// CPF is a Brazilian tax identification number
cpf: Option<Secret<i64>>,
/// CNPJ is a Brazilian company tax identification number
cnpj: Option<Secret<i64>>,
},
Pse {},
LocalBankTransfer { bank_code: Option<String> },
LocalBankTransfer {
bank_code: Option<String>,
},
}

#[derive(Debug, Clone, Eq, PartialEq, serde::Deserialize, serde::Serialize)]
Expand Down Expand Up @@ -914,7 +923,9 @@ impl From<api_models::payments::BankTransferData> for BankTransferData {
api_models::payments::BankTransferData::MandiriVaBankTransfer { .. } => {
Self::MandiriVaBankTransfer {}
}
api_models::payments::BankTransferData::Pix {} => Self::Pix {},
api_models::payments::BankTransferData::Pix { pix_key, cpf, cnpj } => {
Self::Pix { pix_key, cpf, cnpj }
}
api_models::payments::BankTransferData::Pse {} => Self::Pse {},
api_models::payments::BankTransferData::LocalBankTransfer { bank_code } => {
Self::LocalBankTransfer { bank_code }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -408,6 +408,7 @@ pub struct PaymentsSyncData {
pub payment_method_type: Option<storage_enums::PaymentMethodType>,
pub currency: storage_enums::Currency,
pub payment_experience: Option<common_enums::PaymentExperience>,
pub browser_info: Option<BrowserInformation>,

pub amount: MinorUnit,
pub integrity_object: Option<SyncIntegrityObject>,
Expand Down
1 change: 1 addition & 0 deletions crates/masking/src/serde.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ impl SerializableSecret for u8 {}
impl SerializableSecret for u16 {}
impl SerializableSecret for i8 {}
impl SerializableSecret for i32 {}
impl SerializableSecret for i64 {}
impl SerializableSecret for url::Url {}

#[cfg(feature = "time")]
Expand Down
2 changes: 1 addition & 1 deletion crates/router/src/connector/adyen/transformers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2445,7 +2445,7 @@ impl<'a>
domain::BankTransferData::MandiriVaBankTransfer {} => Ok(
AdyenPaymentMethod::MandiriVa(Box::new(DokuBankData::try_from(item)?)),
),
domain::BankTransferData::Pix {} => {
domain::BankTransferData::Pix { .. } => {
Ok(AdyenPaymentMethod::Pix(Box::new(PmdForPaymentType {
payment_type: PaymentType::Pix,
})))
Expand Down
Loading

0 comments on commit 25b8c37

Please sign in to comment.