mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-10-31 10:06:32 +08:00 
			
		
		
		
	fix(connector): [Pix] convert data type of pix fields (#5476)
This commit is contained in:
		| @ -6632,15 +6632,13 @@ | |||||||
|                     "nullable": true |                     "nullable": true | ||||||
|                   }, |                   }, | ||||||
|                   "cpf": { |                   "cpf": { | ||||||
|                     "type": "integer", |                     "type": "string", | ||||||
|                     "format": "int64", |  | ||||||
|                     "description": "CPF is a Brazilian tax identification number", |                     "description": "CPF is a Brazilian tax identification number", | ||||||
|                     "example": "10599054689", |                     "example": "10599054689", | ||||||
|                     "nullable": true |                     "nullable": true | ||||||
|                   }, |                   }, | ||||||
|                   "cnpj": { |                   "cnpj": { | ||||||
|                     "type": "integer", |                     "type": "string", | ||||||
|                     "format": "int64", |  | ||||||
|                     "description": "CNPJ is a Brazilian company tax identification number", |                     "description": "CNPJ is a Brazilian company tax identification number", | ||||||
|                     "example": "74469027417312", |                     "example": "74469027417312", | ||||||
|                     "nullable": true |                     "nullable": true | ||||||
|  | |||||||
| @ -2473,11 +2473,11 @@ pub enum BankTransferData { | |||||||
|         #[schema(value_type = Option<String>, example = "a1f4102e-a446-4a57-bcce-6fa48899c1d1")] |         #[schema(value_type = Option<String>, example = "a1f4102e-a446-4a57-bcce-6fa48899c1d1")] | ||||||
|         pix_key: Option<Secret<String>>, |         pix_key: Option<Secret<String>>, | ||||||
|         /// CPF is a Brazilian tax identification number |         /// CPF is a Brazilian tax identification number | ||||||
|         #[schema(value_type = Option<i64>, example = "10599054689")] |         #[schema(value_type = Option<String>, example = "10599054689")] | ||||||
|         cpf: Option<Secret<i64>>, |         cpf: Option<Secret<String>>, | ||||||
|         /// CNPJ is a Brazilian company tax identification number |         /// CNPJ is a Brazilian company tax identification number | ||||||
|         #[schema(value_type = Option<i64>, example = "74469027417312")] |         #[schema(value_type = Option<String>, example = "74469027417312")] | ||||||
|         cnpj: Option<Secret<i64>>, |         cnpj: Option<Secret<String>>, | ||||||
|     }, |     }, | ||||||
|     Pse {}, |     Pse {}, | ||||||
|     LocalBankTransfer { |     LocalBankTransfer { | ||||||
|  | |||||||
| @ -450,9 +450,9 @@ pub enum BankTransferData { | |||||||
|         /// Unique key for pix transfer |         /// Unique key for pix transfer | ||||||
|         pix_key: Option<Secret<String>>, |         pix_key: Option<Secret<String>>, | ||||||
|         /// CPF is a Brazilian tax identification number |         /// CPF is a Brazilian tax identification number | ||||||
|         cpf: Option<Secret<i64>>, |         cpf: Option<Secret<String>>, | ||||||
|         /// CNPJ is a Brazilian company tax identification number |         /// CNPJ is a Brazilian company tax identification number | ||||||
|         cnpj: Option<Secret<i64>>, |         cnpj: Option<Secret<String>>, | ||||||
|     }, |     }, | ||||||
|     Pse {}, |     Pse {}, | ||||||
|     LocalBankTransfer { |     LocalBankTransfer { | ||||||
|  | |||||||
| @ -42,9 +42,9 @@ pub struct PixPaymentValue { | |||||||
| #[derive(Default, Debug, Serialize)] | #[derive(Default, Debug, Serialize)] | ||||||
| pub struct ItaubankDebtor { | pub struct ItaubankDebtor { | ||||||
|     #[serde(skip_serializing_if = "Option::is_none")] |     #[serde(skip_serializing_if = "Option::is_none")] | ||||||
|     cpf: Option<Secret<i64>>, // CPF is a Brazilian tax identification number |     cpf: Option<Secret<String>>, // CPF is a Brazilian tax identification number | ||||||
|     #[serde(skip_serializing_if = "Option::is_none")] |     #[serde(skip_serializing_if = "Option::is_none")] | ||||||
|     cnpj: Option<Secret<i64>>, // CNPJ is a Brazilian company tax identification number |     cnpj: Option<Secret<String>>, // CNPJ is a Brazilian company tax identification number | ||||||
|     #[serde(skip_serializing_if = "Option::is_none")] |     #[serde(skip_serializing_if = "Option::is_none")] | ||||||
|     nome: Option<Secret<String>>, // name of the debtor |     nome: Option<Secret<String>>, // name of the debtor | ||||||
| } | } | ||||||
| @ -60,17 +60,17 @@ impl TryFrom<&ItaubankRouterData<&types::PaymentsAuthorizeRouterData>> for Itaub | |||||||
|                     domain::BankTransferData::Pix { pix_key, cpf, cnpj } => { |                     domain::BankTransferData::Pix { pix_key, cpf, cnpj } => { | ||||||
|                         let nome = item.router_data.get_optional_billing_full_name(); |                         let nome = item.router_data.get_optional_billing_full_name(); | ||||||
|                         // cpf and cnpj are mutually exclusive |                         // cpf and cnpj are mutually exclusive | ||||||
|                         let devedor = match (cpf, cnpj) { |                         let devedor = match (cnpj, cpf) { | ||||||
|                             (Some(cpf), _) => ItaubankDebtor { |                             (Some(cnpj), _) => ItaubankDebtor { | ||||||
|                                 cpf: Some(cpf), |  | ||||||
|                                 cnpj: None, |  | ||||||
|                                 nome, |  | ||||||
|                             }, |  | ||||||
|                             (None, Some(cnpj)) => ItaubankDebtor { |  | ||||||
|                                 cpf: None, |                                 cpf: None, | ||||||
|                                 cnpj: Some(cnpj), |                                 cnpj: Some(cnpj), | ||||||
|                                 nome, |                                 nome, | ||||||
|                             }, |                             }, | ||||||
|  |                             (None, Some(cpf)) => ItaubankDebtor { | ||||||
|  |                                 cpf: Some(cpf), | ||||||
|  |                                 cnpj: None, | ||||||
|  |                                 nome, | ||||||
|  |                             }, | ||||||
|                             _ => Err(errors::ConnectorError::MissingRequiredField { |                             _ => Err(errors::ConnectorError::MissingRequiredField { | ||||||
|                                 field_name: "cpf and cnpj both missing in payment_method_data", |                                 field_name: "cpf and cnpj both missing in payment_method_data", | ||||||
|                             })?, |                             })?, | ||||||
|  | |||||||
| @ -33,8 +33,8 @@ export const connectorDetails = { | |||||||
|           bank_transfer: { |           bank_transfer: { | ||||||
|             pix: { |             pix: { | ||||||
|               pix_key: "a1f4102e-a446-4a57-bcce-6fa48899c1d1", |               pix_key: "a1f4102e-a446-4a57-bcce-6fa48899c1d1", | ||||||
|               cnpj: 74469027417312, |               cnpj: "74469027417312", | ||||||
|               cpf: 10599054689, |               cpf: "10599054689", | ||||||
|             }, |             }, | ||||||
|           }, |           }, | ||||||
|         }, |         }, | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Sakil Mostak
					Sakil Mostak