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
Rust adyenbeginner-friendlyfeaturedfinancefintechhacktoberfesthigh-performanceopen-sourceorchestrationpaymentpayment-gatewaypayment-integrationpayment-processingpaymentspayments-platformrestful-apirustsdkstripeworks-with-react
feat(connector): [Itaubank] Add refund and rsync flow (#5420)
Sakil Mostak920b3236ee13
diff --git a/crates/hyperswitch_domain_models/src/router_request_types.rs b/crates/hyperswitch_domain_models/src/router_request_types.rsindex 121087bd11..808000e8dc 100644--- a/crates/hyperswitch_domain_models/src/router_request_types.rs+++ b/crates/hyperswitch_domain_models/src/router_request_types.rs@@ -414,7 +414,6 @@ 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>,diff --git a/crates/hyperswitch_interfaces/src/consts.rs b/crates/hyperswitch_interfaces/src/consts.rsindex 4d6c27b755..2ac6ac3c10 100644--- a/crates/hyperswitch_interfaces/src/consts.rs+++ b/crates/hyperswitch_interfaces/src/consts.rs@@ -5,3 +5,9 @@ pub const NO_ERROR_MESSAGE: &str = "No error message";/// No error code string constpub const NO_ERROR_CODE: &str = "No error code";++/// Accepted format for request+pub const ACCEPT_HEADER: &str = "text/html,application/json";++/// User agent for request send from backend server+pub const USER_AGENT: &str = "Hyperswitch-Backend-Server";diff --git a/crates/router/src/connector/itaubank.rs b/crates/router/src/connector/itaubank.rsindex aa1ccaa98c..a31aa9f1e2 100644--- a/crates/router/src/connector/itaubank.rs+++ b/crates/router/src/connector/itaubank.rs@@ -6,10 +6,7 @@ use hyperswitch_interfaces::consts;use masking::PeekInterface;use transformers as itaubank;-use super::utils::{- self as connector_utils, BrowserInformationData, PaymentsAuthorizeRequestData,- PaymentsSyncRequestData,-};+use super::utils::{self as connector_utils, RefundsRequestData};use crate::{configs::settings,core::errors::{self, CustomResult},@@ -75,10 +72,24 @@ wherefield_name: "access_token",})?;- let header = vec![(- headers::AUTHORIZATION.to_string(),- format!("Bearer {}", access_token.token.peek()).into(),- )];+ let header = vec![+ (+ headers::AUTHORIZATION.to_string(),+ format!("Bearer {}", access_token.token.peek()).into(),+ ),+ (+ headers::ACCEPT.to_string(),+ consts::ACCEPT_HEADER.to_string().into(),+ ),+ (+ headers::USER_AGENT.to_string(),+ consts::USER_AGENT.to_string().into(),+ ),+ (+ headers::CONTENT_TYPE.to_string(),+ self.common_get_content_type().to_string().into(),+ ),+ ];Ok(header)}@@ -153,20 +164,22 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, t_req: &types::RefreshTokenRouterData,_connectors: &settings::Connectors,) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {- let flow_header = vec![(- headers::CONTENT_TYPE.to_string(),- types::RefreshTokenType::get_content_type(self)- .to_string()- .into(),- ),- (- headers::ACCEPT.to_string(),- "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.".to_string().into(),- ),- (- headers::USER_AGENT.to_string(),- "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36".to_string().into(),- )];+ let flow_header = vec![+ (+ headers::CONTENT_TYPE.to_string(),+ types::RefreshTokenType::get_content_type(self)+ .to_string()+ .into(),+ ),+ (+ headers::ACCEPT.to_string(),+ consts::ACCEPT_HEADER.to_string().into(),+ ),+ (+ headers::USER_AGENT.to_string(),+ consts::USER_AGENT.to_string().into(),+ ),+ ];Ok(flow_header)}fn get_request_body(@@ -187,6 +200,7 @@ impl ConnectorIntegration<api::AccessTokenAuth, types::AccessTokenRequestData, tlet req = Some(services::RequestBuilder::new().method(services::Method::Post)+ .attach_default_headers().headers(types::RefreshTokenType::get_headers(self, req, connectors)?).url(&types::RefreshTokenType::get_url(self, req, connectors)?).set_body(types::RefreshTokenType::get_request_body(@@ -273,26 +287,7 @@ impl ConnectorIntegration<api::Authorize, types::PaymentsAuthorizeData, types::Preq: &types::PaymentsAuthorizeRouterData,connectors: &settings::Connectors,) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {- let mut header = self.build_headers(req, connectors)?;- let browser_info = req.request.get_browser_info()?;- let mut flow_header = vec![- (- headers::CONTENT_TYPE.to_string(),- types::PaymentsAuthorizeType::get_content_type(self)- .to_string()- .into(),- ),- (- headers::ACCEPT.to_string(),- browser_info.get_accept_header()?.into(),- ),- (- headers::USER_AGENT.to_string(),- browser_info.get_user_agent()?.into(),- ),- ];- header.append(&mut flow_header);- Ok(header)+ self.build_headers(req, connectors)}fn get_content_type(&self) -> &'static str {@@ -384,26 +379,7 @@ impl ConnectorIntegration<api::PSync, types::PaymentsSyncData, types::PaymentsRereq: &types::PaymentsSyncRouterData,connectors: &settings::Connectors,) -> CustomResult<Vec<(String, request::Maskable<String>)>, errors::ConnectorError> {- let mut header = self.build_headers(req, connectors)?;- let browser_info = req.request.get_browser_info()?;- let mut flow_header = vec![- (- headers::CONTENT_TYPE.to_string(),- types::PaymentsAuthorizeType::get_content_type(self)- .to_string()- .into(),- ),- (- headers::ACCEPT.to_string(),- browser_info.get_accept_header()?.into(),- ),- (- headers::USER_AGENT.to_string(),- browser_info.get_user_agent()?.into(),- ),- ];- header.append(&mut flow_header);- Ok(header)+ self.build_headers(req, connectors)}fn get_content_type(&self) -> &'static str {@@ -550,6 +526,17 @@ impl ConnectorIntegration<api::Capture, types::PaymentsCaptureData, types::Paymeimpl ConnectorIntegration<api::Void, types::PaymentsCancelData, types::PaymentsResponseData>for Itaubank{+ fn build_request(+ &self,+ _req: &types::PaymentsCancelRouterData,+ _connectors: &settings::Connectors,+ ) -> CustomResult<Option<services::Request>, errors::ConnectorError> {+ Err(errors::ConnectorError::FlowNotSupported {+ flow: "void".to_string(),+ connector: "itaubank".to_string(),+ }+ .into())+ }}impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsResponseData>@@ -569,10 +556,24 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsResponfn get_url(&self,- _req: &types::RefundsRouterData<api::Execute>,- _connectors: &settings::Connectors,+ req: &types::RefundsRouterData<api::Execute>,+ connectors: &settings::Connectors,) -> CustomResult<String, errors::ConnectorError> {- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())+ let itaubank_metadata = req.request.get_connector_metadata()?;+ let pix_data: itaubank::ItaubankMetaData = serde_json::from_value(itaubank_metadata)+ .change_context(errors::ConnectorError::MissingRequiredField {+ field_name: "itaubank_metadata",+ })?;+ Ok(format!(+ "{}itau-ep9-gtw-pix-recebimentos-ext-v2/v2/pix/{}/devolucao/{}",+ self.base_url(connectors),+ pix_data+ .pix_id+ .ok_or(errors::ConnectorError::MissingRequiredField {+ field_name: "pix_id"+ })?,+ req.request.connector_transaction_id+ ))}fn get_request_body(@@ -597,7 +598,7 @@ impl ConnectorIntegration<api::Execute, types::RefundsData, types::RefundsResponconnectors: &settings::Connectors,) -> CustomResult<Option<services::Request>, errors::ConnectorError> {let request = services::RequestBuilder::new()- .method(services::Method::Post)+ .method(services::Method::Put).url(&types::RefundExecuteType::get_url(self, req, connectors)?).attach_default_headers().headers(types::RefundExecuteType::get_headers(@@ -653,10 +654,24 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponsefn get_url(&self,- _req: &types::RefundSyncRouterData,- _connectors: &settings::Connectors,+ req: &types::RefundSyncRouterData,+ connectors: &settings::Connectors,) -> CustomResult<String, errors::ConnectorError> {- Err(errors::ConnectorError::NotImplemented("get_url method".to_string()).into())+ let itaubank_metadata = req.request.get_connector_metadata()?;+ let pix_data: itaubank::ItaubankMetaData = serde_json::from_value(itaubank_metadata)+ .change_context(errors::ConnectorError::MissingRequiredField {+ field_name: "itaubank_metadata",+ })?;+ Ok(format!(+ "{}itau-ep9-gtw-pix-recebimentos-ext-v2/v2/pix/{}/devolucao/{}",+ self.base_url(connectors),+ pix_data+ .pix_id+ .ok_or(errors::ConnectorError::MissingRequiredField {+ field_name: "pix_id"+ })?,+ req.request.connector_transaction_id+ ))}fn build_request(@@ -685,7 +700,7 @@ impl ConnectorIntegration<api::RSync, types::RefundsData, types::RefundsResponse) -> CustomResult<types::RefundSyncRouterData, errors::ConnectorError> {let response: itaubank::RefundResponse = res.response- .parse_struct("itaubank RefundSyncResponse")+ .parse_struct("itaubank RefundResponse").change_context(errors::ConnectorError::ResponseDeserializationFailed)?;event_builder.map(|i| i.set_response_body(&response));router_env::logger::info!(connector_response=?response);diff --git a/crates/router/src/connector/itaubank/transformers.rs b/crates/router/src/connector/itaubank/transformers.rsindex c6cad43f23..de96bdb2f2 100644--- a/crates/router/src/connector/itaubank/transformers.rs+++ b/crates/router/src/connector/itaubank/transformers.rs@@ -302,6 +302,18 @@ fn get_qr_code_data(pub struct ItaubankPaymentsSyncResponse {status: ItaubankPaymentStatus,txid: String,+ pix: Vec<ItaubankPixResponse>,+}++#[derive(Debug, Clone, Serialize, Deserialize)]+pub struct ItaubankPixResponse {+ #[serde(rename = "endToEndId")]+ pix_id: Option<String>,+}++#[derive(Debug, Clone, Serialize, Deserialize)]+pub struct ItaubankMetaData {+ pub pix_id: Option<String>,}impl<F, T>@@ -318,6 +330,19 @@ impl<F, T>types::PaymentsResponseData,>,) -> Result<Self, Self::Error> {+ let pix_data = item+ .response+ .pix+ .first()+ .ok_or(errors::ConnectorError::MissingRequiredField {+ field_name: "pix_id",+ })?+ .to_owned();++ let connector_metadata = Some(serde_json::json!(ItaubankMetaData {+ pix_id: pix_data.pix_id+ }));+Ok(Self {status: enums::AttemptStatus::from(item.response.status),response: Ok(types::PaymentsResponseData::TransactionResponse {@@ -326,7 +351,7 @@ impl<F, T>),redirection_data: None,mandate_reference: None,- connector_metadata: None,+ connector_metadata,network_txn_id: None,connector_response_reference_id: Some(item.response.txid),incremental_authorization_allowed: None,@@ -339,7 +364,7 @@ impl<F, T>#[derive(Default, Debug, Serialize)]pub struct ItaubankRefundRequest {- pub amount: StringMajorUnit,+ pub valor: StringMajorUnit, // refund_amount}impl<F> TryFrom<&ItaubankRouterData<&types::RefundsRouterData<F>>> for ItaubankRefundRequest {@@ -348,32 +373,34 @@ impl<F> TryFrom<&ItaubankRouterData<&types::RefundsRouterData<F>>> for ItaubankRitem: &ItaubankRouterData<&types::RefundsRouterData<F>>,) -> Result<Self, Self::Error> {Ok(Self {- amount: item.amount.to_owned(),+ valor: item.amount.to_owned(),})}}#[allow(dead_code)]#[derive(Debug, Serialize, Deserialize, Clone)]+#[serde(rename_all = "SCREAMING_SNAKE_CASE")]pub enum RefundStatus {- Succeeded,- Failed,- Processing,+ EmProcessamento, // Processing+ Devolvido, // Returned+ NaoRealizado, // Unrealized}impl From<RefundStatus> for enums::RefundStatus {fn from(item: RefundStatus) -> Self {match item {- RefundStatus::Succeeded => Self::Success,- RefundStatus::Failed => Self::Failure,- RefundStatus::Processing => Self::Pending,+ RefundStatus::Devolvido => Self::Success,+ RefundStatus::NaoRealizado => Self::Failure,+ RefundStatus::EmProcessamento => Self::Pending,}}}#[derive(Debug, Clone, Serialize, Deserialize)]+#[serde(rename_all = "camelCase")]pub struct RefundResponse {- id: String,+ rtr_id: String,status: RefundStatus,}@@ -386,7 +413,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::Execute, RefundResponse>>) -> Result<Self, Self::Error> {Ok(Self {response: Ok(types::RefundsResponseData {- connector_refund_id: item.response.id.to_string(),+ connector_refund_id: item.response.rtr_id,refund_status: enums::RefundStatus::from(item.response.status),}),..item.data@@ -403,7 +430,7 @@ impl TryFrom<types::RefundsResponseRouterData<api::RSync, RefundResponse>>) -> Result<Self, Self::Error> {Ok(Self {response: Ok(types::RefundsResponseData {- connector_refund_id: item.response.id.to_string(),+ connector_refund_id: item.response.rtr_id.to_string(),refund_status: enums::RefundStatus::from(item.response.status),}),..item.datadiff --git a/crates/router/src/connector/utils.rs b/crates/router/src/connector/utils.rsindex 8f732e1431..d61d78d37f 100644--- a/crates/router/src/connector/utils.rs+++ b/crates/router/src/connector/utils.rs@@ -1064,7 +1064,6 @@ impl PaymentsCompleteAuthorizeRequestData for types::CompleteAuthorizeData {pub trait PaymentsSyncRequestData {fn is_auto_capture(&self) -> Result<bool, Error>;fn get_connector_transaction_id(&self) -> CustomResult<String, errors::ConnectorError>;- fn get_browser_info(&self) -> Result<BrowserInformation, Error>;}impl PaymentsSyncRequestData for types::PaymentsSyncData {@@ -1085,11 +1084,6 @@ impl PaymentsSyncRequestData for types::PaymentsSyncData {.change_context(errors::ConnectorError::MissingConnectorTransactionID)?,}}- fn get_browser_info(&self) -> Result<BrowserInformation, Error> {- self.browser_info- .clone()- .ok_or_else(missing_field_err("browser_info"))- }}#[cfg(feature = "payouts")]@@ -1182,6 +1176,7 @@ pub trait RefundsRequestData {fn get_connector_refund_id(&self) -> Result<String, Error>;fn get_webhook_url(&self) -> Result<String, Error>;fn get_browser_info(&self) -> Result<BrowserInformation, Error>;+ fn get_connector_metadata(&self) -> Result<serde_json::Value, Error>;}impl RefundsRequestData for types::RefundsData {@@ -1202,6 +1197,11 @@ impl RefundsRequestData for types::RefundsData {.clone().ok_or_else(missing_field_err("browser_info"))}+ fn get_connector_metadata(&self) -> Result<serde_json::Value, Error> {+ self.connector_metadata+ .clone()+ .ok_or_else(missing_field_err("connector_metadata"))+ }}#[cfg(feature = "payouts")]diff --git a/crates/router/src/core/payments/transformers.rs b/crates/router/src/core/payments/transformers.rsindex f28dd10fc9..35d72ac6ef 100644--- a/crates/router/src/core/payments/transformers.rs+++ b/crates/router/src/core/payments/transformers.rs@@ -1445,16 +1445,6 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsSyncDatafn try_from(additional_data: PaymentAdditionalData<'_, F>) -> Result<Self, Self::Error> {let payment_data = additional_data.payment_data;- let browser_info: Option<types::BrowserInformation> = payment_data- .payment_attempt- .browser_info- .clone()- .map(|b| b.parse_value("BrowserInformation"))- .transpose()- .change_context(errors::ApiErrorResponse::InvalidDataValue {- field_name: "browser_info",- })?;-let amount = payment_data.surcharge_details.as_ref()@@ -1482,7 +1472,6 @@ impl<F: Clone> TryFrom<PaymentAdditionalData<'_, F>> for types::PaymentsSyncDatapayment_method_type: payment_data.payment_attempt.payment_method_type,currency: payment_data.currency,payment_experience: payment_data.payment_attempt.payment_experience,- browser_info,})}}diff --git a/crates/router/tests/connectors/bambora.rs b/crates/router/tests/connectors/bambora.rsindex a5926d2160..a4cb9b4c5e 100644--- a/crates/router/tests/connectors/bambora.rs+++ b/crates/router/tests/connectors/bambora.rs@@ -114,7 +114,6 @@ async fn should_sync_authorized_payment() {payment_experience: None,integrity_object: None,amount: MinorUnit::new(100),- browser_info: None,}),None,)@@ -234,7 +233,6 @@ async fn should_sync_auto_captured_payment() {payment_experience: None,integrity_object: None,amount: MinorUnit::new(100),- browser_info: None,}),None,)diff --git a/crates/router/tests/connectors/forte.rs b/crates/router/tests/connectors/forte.rsindex 2a9926df65..45a30614bf 100644--- a/crates/router/tests/connectors/forte.rs+++ b/crates/router/tests/connectors/forte.rs@@ -163,7 +163,6 @@ async fn should_sync_authorized_payment() {payment_experience: None,integrity_object: None,amount: MinorUnit::new(100),- browser_info: None,}),get_default_payment_info(),)diff --git a/crates/router/tests/connectors/nexinets.rs b/crates/router/tests/connectors/nexinets.rsindex 8623ae48e0..7909aa9c7f 100644--- a/crates/router/tests/connectors/nexinets.rs+++ b/crates/router/tests/connectors/nexinets.rs@@ -130,7 +130,6 @@ async fn should_sync_authorized_payment() {payment_experience: None,integrity_object: None,amount: MinorUnit::new(100),- browser_info: None,}),None,)diff --git a/crates/router/tests/connectors/paypal.rs b/crates/router/tests/connectors/paypal.rsindex d3891729d9..8de891ef09 100644--- a/crates/router/tests/connectors/paypal.rs+++ b/crates/router/tests/connectors/paypal.rs@@ -147,7 +147,6 @@ async fn should_sync_authorized_payment() {payment_experience: None,integrity_object: None,amount: MinorUnit::new(100),- browser_info: None,}),get_default_payment_info(),)@@ -349,7 +348,6 @@ async fn should_sync_auto_captured_payment() {payment_experience: None,amount: MinorUnit::new(100),integrity_object: None,- browser_info: None,}),get_default_payment_info(),)diff --git a/crates/router/tests/connectors/utils.rs b/crates/router/tests/connectors/utils.rsindex 612d2863e5..47e7274c05 100644--- a/crates/router/tests/connectors/utils.rs+++ b/crates/router/tests/connectors/utils.rs@@ -1003,7 +1003,6 @@ impl Default for PaymentSyncType {payment_experience: None,amount: MinorUnit::new(100),integrity_object: None,- browser_info: None,};Self(data)}diff --git a/crates/router/tests/connectors/zen.rs b/crates/router/tests/connectors/zen.rsindex 6e52db3409..2b9ea8f821 100644--- a/crates/router/tests/connectors/zen.rs+++ b/crates/router/tests/connectors/zen.rs@@ -108,7 +108,6 @@ async fn should_sync_authorized_payment() {payment_experience: None,amount: MinorUnit::new(100),integrity_object: None,- browser_info: None,}),None,)@@ -228,7 +227,6 @@ async fn should_sync_auto_captured_payment() {payment_experience: None,amount: MinorUnit::new(100),integrity_object: None,- browser_info: None,}),None,)diff --git a/cypress-tests/cypress/e2e/PaymentMethodListTest/00000-PaymentMethodListTests.cy.js b/cypress-tests/cypress/e2e/PaymentMethodListTest/00000-PaymentMethodListTests.cy.jsindex 768ad0f7c5..ce0d98c7f6 100644--- a/cypress-tests/cypress/e2e/PaymentMethodListTest/00000-PaymentMethodListTests.cy.js+++ b/cypress-tests/cypress/e2e/PaymentMethodListTest/00000-PaymentMethodListTests.cy.js@@ -84,9 +84,10 @@ describe("Payment Method list using Constraint Graph flow tests", () => {// payment method list which should only have ideal with stripeit("payment-method-list-call-test", () => {- let data = getConnectorDetails("stripe")[- "pm_list"- ]["PmListResponse"]["PmListWithStripeForIdeal"];+ let data =+ getConnectorDetails("stripe")["pm_list"]["PmListResponse"][+ "PmListWithStripeForIdeal"+ ];cy.paymentMethodListTestLessThanEqualToOnePaymentMethod(data,globalState@@ -164,9 +165,10 @@ describe("Payment Method list using Constraint Graph flow tests", () => {// payment method list which should only have ideal with stripeit("payment-method-list-call-test", () => {- let data = getConnectorDetails("stripe")[- "pm_list"- ]["PmListResponse"]["PmListNull"];+ let data =+ getConnectorDetails("stripe")["pm_list"]["PmListResponse"][+ "PmListNull"+ ];cy.paymentMethodListTestLessThanEqualToOnePaymentMethod(data,globalState@@ -244,9 +246,10 @@ describe("Payment Method list using Constraint Graph flow tests", () => {// payment method list which should only have credit with Stripe and Cybersourceit("payment-method-list-call-test", () => {- let data = getConnectorDetails("stripe")[- "pm_list"- ]["PmListResponse"]["PmListWithCreditTwoConnector"];+ let data =+ getConnectorDetails("stripe")["pm_list"]["PmListResponse"][+ "PmListWithCreditTwoConnector"+ ];cy.paymentMethodListTestTwoConnectorsForOnePaymentMethodCredit(data,globalState@@ -324,9 +327,10 @@ describe("Payment Method list using Constraint Graph flow tests", () => {// payment method list which shouldn't have anythingit("payment-method-list-call-test", () => {- let data = getConnectorDetails("stripe")[- "pm_list"- ]["PmListResponse"]["PmListNull"];+ let data =+ getConnectorDetails("stripe")["pm_list"]["PmListResponse"][+ "PmListNull"+ ];cy.paymentMethodListTestLessThanEqualToOnePaymentMethod(data,globalState@@ -408,9 +412,10 @@ describe("Payment Method list using Constraint Graph flow tests", () => {// payment method list which should have credit with stripe and cybersource and no idealit("payment-method-list-call-test", () => {- let data = getConnectorDetails("stripe")[- "pm_list"- ]["PmListResponse"]["PmListWithCreditTwoConnector"];+ let data =+ getConnectorDetails("stripe")["pm_list"]["PmListResponse"][+ "PmListWithCreditTwoConnector"+ ];cy.paymentMethodListTestTwoConnectorsForOnePaymentMethodCredit(data,globalStatediff --git a/cypress-tests/cypress/e2e/PaymentUtils/ItauBank.js b/cypress-tests/cypress/e2e/PaymentUtils/ItauBank.jsindex ab66b3f743..70b6b09eda 100644--- a/cypress-tests/cypress/e2e/PaymentUtils/ItauBank.js+++ b/cypress-tests/cypress/e2e/PaymentUtils/ItauBank.js@@ -1,68 +1,67 @@export const connectorDetails = {- card_pm: {- ZeroAuthMandate: {- Response: {- status: 500,- body: {- error: {- type: "invalid_request",- message: "setup mandate flow not supported",- code: "IR_20",- },- },- },+ card_pm: {+ ZeroAuthMandate: {+ Response: {+ status: 400,+ body: {+ error: {+ type: "invalid_request",+ message: "setup mandate flow not supported",+ code: "IR_20",},+ },+ },},- bank_transfer_pm: {- PaymentIntent: {- Request: {- currency: "BRL",- },- Response: {- status: 200,- body: {- status: "requires_payment_method",+ },+ bank_transfer_pm: {+ PaymentIntent: {+ Request: {+ currency: "BRL",+ },+ Response: {+ status: 200,+ body: {+ status: "requires_payment_method",+ },+ },+ },+ Pix: {+ Request: {+ payment_method: "bank_transfer",+ payment_method_type: "pix",+ payment_method_data: {+ bank_transfer: {+ pix: {+ pix_key: "a1f4102e-a446-4a57-bcce-6fa48899c1d1",+ cnpj: 74469027417312,+ cpf: 10599054689,},},},- Pix: {- Request: {- payment_method: "bank_transfer",- payment_method_type: "pix",- payment_method_data: {- bank_transfer: {- pix: {- pix_key: "a1f4102e-a446-4a57-bcce-6fa48899c1d1",- cnpj: 74469027417312,- cpf: 10599054689- },- },- },- billing: {- address: {- line1: "1467",- line2: "Harrison Street",- line3: "Harrison Street",- city: "San Fransico",- state: "California",- zip: "94122",- country: "BR",- first_name: "joseph",- last_name: "Doe",- },- phone: {- number: "9123456789",- country_code: "+91",- },- },- currency: "BRL",+ billing: {+ address: {+ line1: "1467",+ line2: "Harrison Street",+ line3: "Harrison Street",+ city: "San Fransico",+ state: "California",+ zip: "94122",+ country: "BR",+ first_name: "joseph",+ last_name: "Doe",},- Response: {- status: 200,- body: {- status: "requires_customer_action",- },+ phone: {+ number: "9123456789",+ country_code: "+91",},},},+ Response: {+ status: 200,+ body: {+ status: "requires_customer_action",+ },+ },+ },+ },};diff --git a/cypress-tests/cypress/e2e/PaymentUtils/Utils.js b/cypress-tests/cypress/e2e/PaymentUtils/Utils.jsindex a75b95024d..27e0b2b937 100644--- a/cypress-tests/cypress/e2e/PaymentUtils/Utils.js+++ b/cypress-tests/cypress/e2e/PaymentUtils/Utils.js@@ -26,7 +26,7 @@ const connectorDetails = {paypal: paypalConnectorDetails,stripe: stripeConnectorDetails,trustpay: trustpayConnectorDetails,- datatrans:datatransConnectorDetails+ datatrans: datatransConnectorDetails,};export default function getConnectorDetails(connectorId) {diff --git a/cypress-tests/cypress/support/commands.js b/cypress-tests/cypress/support/commands.jsindex 5901ba339e..ccf0ceedde 100644--- a/cypress-tests/cypress/support/commands.js+++ b/cypress-tests/cypress/support/commands.js@@ -337,7 +337,9 @@ Cypress.Commands.add(.sort();}let config_payment_method_type = getPaymentMethodType(res_data);- let response_payment_method_type = getPaymentMethodType(response.body);+ let response_payment_method_type = getPaymentMethodType(+ response.body+ );for (let i = 0; i < response_payment_method_type.length; i++) {expect(config_payment_method_type[i]).to.equal(response_payment_method_type[i]@@ -671,20 +673,13 @@ Cypress.Commands.add("nextActionUrl", // This is intentionally kept as nextActionUrl to avoid issues during handleRedirection call,response.body.next_action.qr_code_url);- globalState.set(- "nextActionType",- "qr_code_url"- );- }- else{+ globalState.set("nextActionType", "qr_code_url");+ } else {globalState.set("nextActionUrl", // This is intentionally kept as nextActionUrl to avoid issues during handleRedirection call,response.body.next_action.image_data_url);- globalState.set(- "nextActionType",- "image_data_url"- );+ globalState.set("nextActionType", "image_data_url");}break;default:@@ -1343,7 +1338,7 @@ Cypress.Commands.add(let connectorId = globalState.get("connectorId");let expected_url = new URL(expected_redirection);let redirection_url = new URL(globalState.get("nextActionUrl"));- let next_action_type = globalState.get("nextActionType")+ let next_action_type = globalState.get("nextActionType");cy.log(payment_method_type);handleRedirection("bank_transfer",diff --git a/cypress-tests/cypress/support/redirectionHandler.js b/cypress-tests/cypress/support/redirectionHandler.jsindex 278d20b275..f0998a44fc 100644--- a/cypress-tests/cypress/support/redirectionHandler.js+++ b/cypress-tests/cypress/support/redirectionHandler.js@@ -74,15 +74,14 @@ function bankTransferRedirection(verifyReturnUrl(redirection_url, expected_url, true);}});- break;+ break;case "image_data_url":switch (connectorId) {- case "itaubank":+ case "itaubank":switch (payment_method_type) {case "pix":fetchAndParseImageData(redirection_url).then((qrCodeData) => {- console.log("Imaage_data>>>>>>>>>", qrCodeData)- expect(qrCodeData).to.contains('itau.com.br/pix/qr/v2') // image data contains the following value+ expect(qrCodeData).to.contains("itau.com.br/pix/qr/v2"); // image data contains the following value});break;default:@@ -96,7 +95,6 @@ function bankTransferRedirection(default:verifyReturnUrl(redirection_url, expected_url, true);}-}function bankRedirectRedirection(diff --git a/cypress-tests/package.json b/cypress-tests/package.jsonindex 2eb58696d8..3f6647ee8b 100644--- a/cypress-tests/package.json+++ b/cypress-tests/package.json@@ -7,9 +7,9 @@"cypress": "npx cypress open","cypress-e2e": "npx cypress run --e2e","cypress:ci": "npx cypress run --headless",- "cypress:payments": "cypress run --spec 'cypress/e2e/PaymentTest/**/*'",- "cypress:payouts": "cypress run --spec 'cypress/e2e/PayoutTest/**/*'",- "cypress:routing": "cypress run --spec 'cypress/e2e/RoutingTest/**/*'"+ "cypress:payments": "cypress run --headless --spec 'cypress/e2e/PaymentTest/**/*'",+ "cypress:payouts": "cypress run --headless --spec 'cypress/e2e/PayoutTest/**/*'",+ "cypress:routing": "cypress run --headless --spec 'cypress/e2e/RoutingTest/**/*'"},"author": "","license": "ISC",