diff --git a/crates/hyperswitch_connectors/src/connectors/bankofamerica/transformers.rs b/crates/hyperswitch_connectors/src/connectors/bankofamerica/transformers.rs index b33555a7c5..a0868d688e 100644 --- a/crates/hyperswitch_connectors/src/connectors/bankofamerica/transformers.rs +++ b/crates/hyperswitch_connectors/src/connectors/bankofamerica/transformers.rs @@ -510,17 +510,26 @@ fn build_bill_to( country: None, email: email.clone(), }; + Ok(address_details .and_then(|addr| { - addr.address.as_ref().map(|addr| BillTo { - first_name: addr.first_name.clone(), - last_name: addr.last_name.clone(), - address1: addr.line1.clone(), - locality: addr.city.clone(), - administrative_area: addr.to_state_code_as_optional().ok().flatten(), - postal_code: addr.zip.clone(), - country: addr.country, - email, + addr.address.as_ref().map(|addr| { + let administrative_area = addr.to_state_code_as_optional().unwrap_or_else(|_| { + addr.state + .clone() + .map(|state| Secret::new(format!("{:.20}", state.expose()))) + }); + + BillTo { + first_name: addr.first_name.clone(), + last_name: addr.last_name.clone(), + address1: addr.line1.clone(), + locality: addr.city.clone(), + administrative_area, + postal_code: addr.zip.clone(), + country: addr.country, + email, + } }) }) .unwrap_or(default_address)) @@ -813,6 +822,13 @@ impl hyperswitch_domain_models::payment_method_data::Card, ), ) -> Result { + if item.router_data.is_three_ds() { + Err(errors::ConnectorError::NotSupported { + message: "Card 3DS".to_string(), + connector: "BankOfAmerica", + })? + }; + let email = item.router_data.request.get_email()?; let bill_to = build_bill_to(item.router_data.get_optional_billing(), email)?; let order_information = OrderInformationWithBill::from((item, Some(bill_to))); @@ -2242,6 +2258,13 @@ impl hyperswitch_domain_models::payment_method_data::Card, ), ) -> Result { + if item.is_three_ds() { + Err(errors::ConnectorError::NotSupported { + message: "Card 3DS".to_string(), + connector: "BankOfAmerica", + })? + }; + let order_information = OrderInformationWithBill::try_from(item)?; let client_reference_information = ClientReferenceInformation::from(item); let merchant_defined_information = diff --git a/cypress-tests/cypress/e2e/configs/Payment/BankOfAmerica.js b/cypress-tests/cypress/e2e/configs/Payment/BankOfAmerica.js index 308565e72f..0c8a880325 100644 --- a/cypress-tests/cypress/e2e/configs/Payment/BankOfAmerica.js +++ b/cypress-tests/cypress/e2e/configs/Payment/BankOfAmerica.js @@ -1,3 +1,5 @@ +import { getCustomExchange } from "./Modifiers"; + const successfulNo3DSCardDetails = { card_number: "4242424242424242", card_exp_month: "01", @@ -112,7 +114,7 @@ export const connectorDetails = { }, }, }, - "3DSManualCapture": { + "3DSManualCapture": getCustomExchange({ Request: { payment_method: "card", payment_method_data: { @@ -122,14 +124,8 @@ export const connectorDetails = { customer_acceptance: null, setup_future_usage: "on_session", }, - Response: { - status: 200, - body: { - status: "requires_capture", - }, - }, - }, - "3DSAutoCapture": { + }), + "3DSAutoCapture": getCustomExchange({ Request: { payment_method: "card", payment_method_data: { @@ -139,13 +135,7 @@ export const connectorDetails = { customer_acceptance: null, setup_future_usage: "on_session", }, - Response: { - status: 200, - body: { - status: "requires_customer_action", - }, - }, - }, + }), No3DSManualCapture: { Request: { payment_method: "card", @@ -301,7 +291,7 @@ export const connectorDetails = { }, }, }, - MandateSingleUse3DSAutoCapture: { + MandateSingleUse3DSAutoCapture: getCustomExchange({ Request: { payment_method: "card", payment_method_data: { @@ -310,14 +300,8 @@ export const connectorDetails = { currency: "USD", mandate_data: singleUseMandateData, }, - Response: { - status: 200, - body: { - status: "succeeded", - }, - }, - }, - MandateSingleUse3DSManualCapture: { + }), + MandateSingleUse3DSManualCapture: getCustomExchange({ Request: { payment_method: "card", payment_method_data: { @@ -326,13 +310,7 @@ export const connectorDetails = { currency: "USD", mandate_data: singleUseMandateData, }, - Response: { - status: 200, - body: { - status: "requires_customer_action", - }, - }, - }, + }), MandateSingleUseNo3DSAutoCapture: { Request: { payment_method: "card", @@ -397,7 +375,7 @@ export const connectorDetails = { }, }, }, - MandateMultiUse3DSAutoCapture: { + MandateMultiUse3DSAutoCapture: getCustomExchange({ Request: { payment_method: "card", payment_method_data: { @@ -406,14 +384,8 @@ export const connectorDetails = { currency: "USD", mandate_data: multiUseMandateData, }, - Response: { - status: 200, - body: { - status: "requires_capture", - }, - }, - }, - MandateMultiUse3DSManualCapture: { + }), + MandateMultiUse3DSManualCapture: getCustomExchange({ Request: { payment_method: "card", payment_method_data: { @@ -422,13 +394,7 @@ export const connectorDetails = { currency: "USD", mandate_data: multiUseMandateData, }, - Response: { - status: 200, - body: { - status: "requires_capture", - }, - }, - }, + }), MITAutoCapture: { Request: {}, Response: { @@ -659,7 +625,7 @@ export const connectorDetails = { }, }, }, - PaymentMethodIdMandate3DSAutoCapture: { + PaymentMethodIdMandate3DSAutoCapture: getCustomExchange({ Request: { payment_method: "card", payment_method_data: { @@ -677,14 +643,8 @@ export const connectorDetails = { }, }, }, - Response: { - status: 200, - body: { - status: "requires_customer_action", - }, - }, - }, - PaymentMethodIdMandate3DSManualCapture: { + }), + PaymentMethodIdMandate3DSManualCapture: getCustomExchange({ Request: { payment_method: "card", payment_method_data: { @@ -701,13 +661,7 @@ export const connectorDetails = { }, }, }, - Response: { - status: 200, - body: { - status: "requires_customer_action", - }, - }, - }, + }), }, pm_list: { PmListResponse: {